annotate netinstall/find.cc @ 4614:afbfad080ddd

The URLs in our current config.guess and config.sub files are obsolete. Update to the latest upstream release to get correct URLs, as well as fixes and enhancements to those scripts.
author Jerry James <james@xemacs.org>
date Wed, 11 Feb 2009 11:09:35 -0700
parents 3078fd1074e8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
1 /*
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
2 * Copyright (c) 2000, Red Hat, Inc.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
3 *
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
7 * (at your option) any later version.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
8 *
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
9 * A copy of the GNU General Public License can be found at
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
10 * http://www.gnu.org/
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
11 *
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
12 * Written by DJ Delorie <dj@cygnus.com>
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
13 *
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
14 */
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
15
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
16 /* The purpose of this file is to doa recursive find on a given
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
17 directory, calling a given function for each file found. */
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
18
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
19 #include "win32.h"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
20 #include <stdio.h>
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
21 #include <stdlib.h>
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
22
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
23 #include "port.h"
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
24
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
25 static void (*for_each)(char *, unsigned int);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
26 static char dir[_MAX_PATH], *found_part;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
27
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
28 static int
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
29 find_sub ()
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
30 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
31 WIN32_FIND_DATA wfd;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
32 HANDLE h;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
33 char *end = dir + strlen (dir);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
34 int rv = 0;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
35
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
36 *end++ = '/';
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
37 strcpy (end, "*");
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
38
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
39 h = FindFirstFile (dir, &wfd);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
40
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
41 if (h == INVALID_HANDLE_VALUE)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
42 return 0;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
43
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
44 do {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
45 if (strcmp (wfd.cFileName, ".") == 0
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
46 || strcmp (wfd.cFileName, "..") == 0)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
47 continue;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
48
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
49 strcpy (end, wfd.cFileName);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
50
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
51 if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
52 find_sub ();
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
53 else
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
54 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
55 for_each (found_part, wfd.nFileSizeLow);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
56 rv ++;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
57 }
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
58
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
59 } while (FindNextFile (h, &wfd));
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
60
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
61 FindClose (h);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
62 return rv;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
63 }
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
64
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
65 int
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
66 find (char *starting_dir, void (*_for_each)(char *, unsigned int))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
67 {
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
68 strcpy (dir, starting_dir);
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
69 for_each = _for_each;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
70 found_part = dir + strlen (dir) + 1;
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
71
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
72 return find_sub ();
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents:
diff changeset
73 }