annotate osdep/glob-win.c @ 34999:b0133d910683

Add parentheses to avoid compiler warning.
author ib
date Wed, 15 Aug 2012 13:14:59 +0000
parents c7ff1a52e160
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28744
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
1 /*
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
2 * This file is part of MPlayer.
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
3 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
5 * it under the terms of the GNU General Public License as published by
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
7 * (at your option) any later version.
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
8 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
12 * GNU General Public License for more details.
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
13 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
14 * You should have received a copy of the GNU General Public License along
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
17 */
5cfef41a1771 Add standard license headers to files.
diego
parents: 25100
diff changeset
18
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
19 #include <sys/types.h>
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
20 #include <stdio.h>
32675
c70109fc98b2 Add/remove a few standard header #includes in our libc function replacements.
diego
parents: 29263
diff changeset
21 #include <stdlib.h>
c70109fc98b2 Add/remove a few standard header #includes in our libc function replacements.
diego
parents: 29263
diff changeset
22 #include <string.h>
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
23
16985
08cac43f1e38 Unify include paths, -I.. is in CFLAGS.
diego
parents: 10272
diff changeset
24 #include "config.h"
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
25
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
26 #include <windows.h>
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
27 #include "glob.h"
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
28
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
29 int glob(const char *pattern, int flags,
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
30 int (*errfunc)(const char *epath, int eerrno), glob_t *pglob)
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
31 {
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
32 HANDLE searchhndl;
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
33 WIN32_FIND_DATA found_file;
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
34 if (errfunc)
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
35 printf("glob():ERROR:Sorry errfunc not supported by this implementation\n");
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
36 if (flags)
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
37 printf("glob():ERROR:Sorry no flags supported by this globimplementation\n");
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
38 //printf("PATTERN \"%s\"\n",pattern);
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
39 pglob->gl_pathc = 0;
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
40 searchhndl = FindFirstFile(pattern, &found_file);
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
41 if (searchhndl == INVALID_HANDLE_VALUE) {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
42 if (GetLastError() == ERROR_FILE_NOT_FOUND) {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
43 pglob->gl_pathc = 0;
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
44 //printf("could not find a file matching your search criteria\n");
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
45 return 1;
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
46 } else {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
47 //printf("glob():ERROR:FindFirstFile: %i\n",GetLastError());
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
48 return 1;
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
49 }
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
50 }
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
51 pglob->gl_pathv = malloc(sizeof(char *));
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
52 pglob->gl_pathv[0] = strdup(found_file.cFileName);
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
53 pglob->gl_pathc++;
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
54 while (1) {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
55 if (!FindNextFile(searchhndl, &found_file)) {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
56 if (GetLastError() == ERROR_NO_MORE_FILES) {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
57 //printf("glob(): no more files found\n");
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
58 break;
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
59 } else {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
60 //printf("glob():ERROR:FindNextFile:%i\n",GetLastError());
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
61 return 1;
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
62 }
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
63 } else {
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
64 //printf("glob: found file %s\n",found_file.cFileName);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28744
diff changeset
65 pglob->gl_pathc++;
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
66 pglob->gl_pathv = realloc(pglob->gl_pathv, pglob->gl_pathc * sizeof(char *));
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
67 pglob->gl_pathv[pglob->gl_pathc - 1] = strdup(found_file.cFileName);
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
68 }
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
69 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
70 FindClose(searchhndl);
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
71 return 0;
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
72 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
73
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
74 void globfree(glob_t *pglob)
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
75 {
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
76 int i;
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
77 for (i = 0; i < pglob->gl_pathc; i++)
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
78 free(pglob->gl_pathv[i]);
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
79 free(pglob->gl_pathv);
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
80 }
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
81
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
82 #if 0
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
83 int main(void)
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
84 {
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
85 glob_t gg;
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
86 printf("globtest\n");
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
87 glob("*.jpeg", 0, NULL, &gg);
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
88 {
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
89 int i;
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
90 for (i = 0; i < gg.gl_pathc; i++)
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
91 printf("GLOBED:%i %s\n", i, gg.gl_pathv[i]);
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
92 }
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
93 globfree(&gg);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28744
diff changeset
94
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
95 return 0;
9983
14c92818ab75 alternative timer and glob emulation code for mingw32 port
faust3
parents:
diff changeset
96 }
34151
c7ff1a52e160 Use uncrustify on glob-win.c to fix the indentation mess in it.
reimar
parents: 32675
diff changeset
97
21865
ccf368143acd 100l misplaced #endif
diego
parents: 21855
diff changeset
98 #endif