1 | /* $Id: FIL_STANDARDL.c 889 2003-12-10 16:51:33Z bird $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * Testcase for FIL_STANDARDL defect.
|
---|
5 | *
|
---|
6 | *
|
---|
7 | * Example of how to get into trouble:
|
---|
8 | * FIL_STANDARDL.EXE 99 c:\os2\dll\*
|
---|
9 | *
|
---|
10 | * Where 99 specifies the number of files to request and c:\os2\dll\* is
|
---|
11 | * the file pattern to search for.
|
---|
12 | *
|
---|
13 | *
|
---|
14 | * InnoTek Systemberatung GmbH confidential
|
---|
15 | *
|
---|
16 | * Copyright (c) 2003 InnoTek Systemberatung GmbH
|
---|
17 | * Author: knut st. osmundsen <bird-srcspam@anduin.net>
|
---|
18 | *
|
---|
19 | * All Rights Reserved
|
---|
20 | *
|
---|
21 | */
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 | /*******************************************************************************
|
---|
26 | * Header Files *
|
---|
27 | *******************************************************************************/
|
---|
28 | #define INCL_BASE
|
---|
29 | #include <os2.h>
|
---|
30 | #include <string.h>
|
---|
31 | #include <stdio.h>
|
---|
32 | #include <stdlib.h>
|
---|
33 |
|
---|
34 |
|
---|
35 | /*******************************************************************************
|
---|
36 | * Defined Constants And Macros *
|
---|
37 | *******************************************************************************/
|
---|
38 | /** Size of the file find buffer. */
|
---|
39 | #define CBBUFFER 2048
|
---|
40 |
|
---|
41 |
|
---|
42 | int main(int argc, char **argv)
|
---|
43 | {
|
---|
44 | static char achBuffer[CBBUFFER];
|
---|
45 | PFILEFINDBUF3L pCur;
|
---|
46 | int rc;
|
---|
47 | int i;
|
---|
48 | ULONG cFilesArg;
|
---|
49 | ULONG cFiles;
|
---|
50 | HDIR hDir;
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Validate and parse the arguments.
|
---|
54 | */
|
---|
55 | if (argc <= 2)
|
---|
56 | {
|
---|
57 | printf("syntax: %s <cfiles> <pattern> [pattern [..]]\n", argv[0]);
|
---|
58 | return EXIT_FAILURE;
|
---|
59 | }
|
---|
60 |
|
---|
61 | cFilesArg = atol(argv[1]);
|
---|
62 | if (cFilesArg == 0)
|
---|
63 | {
|
---|
64 | printf("syntax error!\n");
|
---|
65 | return EXIT_FAILURE;
|
---|
66 | }
|
---|
67 |
|
---|
68 |
|
---|
69 | /*
|
---|
70 | * Do the work.
|
---|
71 | */
|
---|
72 | for (i = 2; i < argc; i++)
|
---|
73 | {
|
---|
74 | /*
|
---|
75 | * Start file find...
|
---|
76 | */
|
---|
77 | cFiles = cFilesArg;
|
---|
78 | hDir = HDIR_CREATE;
|
---|
79 | rc = DosFindFirst(argv[i], &hDir, FILE_NORMAL, &achBuffer[0], CBBUFFER, &cFiles, FIL_STANDARDL);
|
---|
80 | if (!rc)
|
---|
81 | {
|
---|
82 | do
|
---|
83 | {
|
---|
84 | /*
|
---|
85 | * Dump files.
|
---|
86 | */
|
---|
87 | pCur = (PFILEFINDBUF3L)&achBuffer[0];
|
---|
88 | while (cFiles-- > 0)
|
---|
89 | {
|
---|
90 | printf("%03d %s\n", (int)pCur->cchName, pCur->achName);
|
---|
91 |
|
---|
92 | /* next */
|
---|
93 | pCur = (PFILEFINDBUF3L)((char*)pCur + pCur->oNextEntryOffset);
|
---|
94 | }
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * Next chunk.
|
---|
98 | */
|
---|
99 | cFiles = cFilesArg;
|
---|
100 | rc = DosFindNext(hDir, &achBuffer[0], CBBUFFER, &cFiles);
|
---|
101 | } while (!rc);
|
---|
102 | DosFindClose(hDir);
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | return EXIT_SUCCESS;
|
---|
107 | }
|
---|
108 |
|
---|