S
Sascha Wüstemann
56: int file_select(const struct dirent *namelist) {
57: if ( ( strcmp(namelist->d_name, "." ) == 0 ) || ( strcmp(
namelist->d_name, ".." ) == 0) )
58: return (0);
59: char *buff=namelist->d_name;
60: char *snippet;
61: char *treffer = strtok(buff, ".");
62: while ( treffer != 0 ) {
63: snippet = treffer;
64: treffer = strtok(NULL, ".");
65: }
66: if ( ( strcmp(snippet, "xdb") == 0 ) ) {
67: return (1);
68: }
69: else
70: return (0);
71:}
73:int main(
....
135: databases_count = scandir(dst, &namelist, file_select, alphasort);
gcc throws a warning:
ab.c: In function ‘file_select’:
ab.c:59:14: warning: initialization discards qualifiers from pointer
target type
I'd like to make shure scandir targets only '*.xdb' files. I first took
if ( strstr( namelist->d_name, ".xdb" ) != NULL )
return (1);
but that targets '*.xdb*' so I cannot use it.
My code above works without errors, but I don't know why
- strcmp(namelist->d_name, "." ) operates fine without warning and
char *buff=namelist->d_name; does not.
Would you please enlighten me and what if you can tell how to make it
without warnings, thanks.
Greetings from Braunschweig, Germany.
Sascha Wüstemann
57: if ( ( strcmp(namelist->d_name, "." ) == 0 ) || ( strcmp(
namelist->d_name, ".." ) == 0) )
58: return (0);
59: char *buff=namelist->d_name;
60: char *snippet;
61: char *treffer = strtok(buff, ".");
62: while ( treffer != 0 ) {
63: snippet = treffer;
64: treffer = strtok(NULL, ".");
65: }
66: if ( ( strcmp(snippet, "xdb") == 0 ) ) {
67: return (1);
68: }
69: else
70: return (0);
71:}
73:int main(
....
135: databases_count = scandir(dst, &namelist, file_select, alphasort);
gcc throws a warning:
ab.c: In function ‘file_select’:
ab.c:59:14: warning: initialization discards qualifiers from pointer
target type
I'd like to make shure scandir targets only '*.xdb' files. I first took
if ( strstr( namelist->d_name, ".xdb" ) != NULL )
return (1);
but that targets '*.xdb*' so I cannot use it.
My code above works without errors, but I don't know why
- strcmp(namelist->d_name, "." ) operates fine without warning and
char *buff=namelist->d_name; does not.
Would you please enlighten me and what if you can tell how to make it
without warnings, thanks.
Greetings from Braunschweig, Germany.
Sascha Wüstemann