Add it build Czech catalog KeyShow (tools)
[AROS.git] / test / dos / match.c
blob228b3336bce42a893d4c9455b5b0b46e8572956f
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/exec.h>
7 #include <dos/dos.h>
8 #include <dos/dosextens.h>
9 #include <dos/dosasl.h>
10 #include <proto/exec.h>
11 #include <proto/dos.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdlib.h>
17 /****************************************************************************************/
19 static void showacflags(struct AChain *ac)
21 BYTE flags = ac->an_Flags;
23 printf("(");
25 if (flags & DDF_PatternBit)
27 flags &= ~DDF_PatternBit;
28 printf("DDF_PatternBit ");
31 if (flags & DDF_ExaminedBit)
33 flags &= ~DDF_ExaminedBit;
34 printf("DDF_ExaminedBit ");
37 if (flags & DDF_Completed)
39 flags &= ~DDF_Completed;
40 printf("DDF_Completed ");
43 if (flags & DDF_AllBit)
45 flags &= ~DDF_AllBit;
46 printf("DDF_All ");
49 if (flags & DDF_Single)
51 flags &= ~DDF_Single;
52 printf("DDF_Single ");
55 if (flags)
57 printf("UNKNOWN = %8x ", flags);
60 printf(")");
63 static void showaclist(struct AChain *ac)
65 while(ac)
67 printf("achain: address = %p flags = %x ", ac, ac->an_Flags);
68 showacflags(ac);
69 printf(" string=\"%s\"\n", ac->an_String);
70 ac = ac->an_Child;
75 /****************************************************************************************/
77 #define ARG_TEMPLATE "FILE/A,ALL/S"
78 #define ARG_FILE 0
79 #define ARG_ALL 1
80 #define NUM_ARGS 2
82 /****************************************************************************************/
84 static char s[300];
85 static char *filename;
86 static BOOL all;
87 static struct RDArgs *myargs;
88 static IPTR args[NUM_ARGS];
90 /****************************************************************************************/
92 static void cleanup(char *msg)
94 if (msg) printf("newmatch: %s\n", msg);
96 if (myargs) FreeArgs(myargs);
98 exit(0);
101 /****************************************************************************************/
103 static void doserror(void)
105 Fault(IoErr(), 0, s, 255);
106 cleanup(s);
109 /****************************************************************************************/
111 static void getarguments(void)
113 if (!(myargs = ReadArgs(ARG_TEMPLATE, args, 0)))
115 doserror();
118 filename = (char *)args[ARG_FILE];
119 all = args[ARG_ALL] ? TRUE : FALSE;
122 /****************************************************************************************/
124 static void my_matchme(char *pattern, BOOL all)
126 struct AnchorPath stackap[2], *AP;
127 LONG error = 0;
129 AP = (struct AnchorPath *)((((IPTR)stackap) + 3) & ~3);
131 memset(AP, 0, sizeof(struct AnchorPath));
133 error = MatchFirst(pattern, AP);
135 if (error != 0)
137 printf("MatchFirst: error = %d\n", (int)error);
139 else
141 printf("direntrytype = %d\n", (int)AP->ap_Info.fib_DirEntryType);
142 if (!(AP->ap_Flags & APF_ITSWILD) &&
143 (AP->ap_Info.fib_DirEntryType > 0))
145 /* pattern was an explicitely named directory */
146 AP->ap_Flags |= APF_DODIR;
149 printf("ap_Flags = %x\n", AP->ap_Flags);
150 NameFromLock(AP->ap_Current->an_Lock, s, 300);
151 printf("BaseLock = \"%s\"\n", s);
153 showaclist(AP->ap_Base);
155 while(error == 0)
157 if (AP->ap_Flags & APF_DIDDIR)
159 printf("DIDDIR: ");
160 } else {
161 if (all && (AP->ap_Info.fib_DirEntryType > 0))
163 AP->ap_Flags |= APF_DODIR;
164 printf("DOING DIR: ");
167 printf("fib_FileName = \"%s\"\n", AP->ap_Info.fib_FileName);
169 error = MatchNext(AP);
174 MatchEnd(AP);
178 /****************************************************************************************/
179 /****************************************************************************************/
181 int main(void)
183 getarguments();
184 my_matchme(filename, all);
185 cleanup(0);
186 return 0;
189 /****************************************************************************************/