start service tasks separately in-case platforms need to perform additional set-up...
[AROS.git] / test / examine.c
blobfa56454ec0813e29a96a0c3da46d23a39cfb552c
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <dos/dos.h>
8 #include <dos/bptr.h>
9 #include <dos/dosextens.h>
10 #include <dos/datetime.h>
11 #include <proto/dos.h>
12 #include <stdio.h>
14 #define ENTRYTYPESTR(e) ( \
15 e == ST_PIPEFILE ? "ST_PIPEFILE" : \
16 e == ST_LINKFILE ? "ST_LINKFILE" : \
17 e == ST_FILE ? "ST_FILE" : \
18 e == ST_ROOT ? "ST_ROOT" : \
19 e == ST_USERDIR ? "ST_USERDIR" : \
20 e == ST_SOFTLINK ? "ST_SOFTLINK" : \
21 e == ST_LINKDIR ? "ST_LINKDIR" : \
22 "unknown" \
25 int main (int argc, char **argv) {
26 BPTR lock;
27 struct FileInfoBlock *fib;
28 struct DateTime dt;
29 char date[32], time[32];
31 if (argc == 1) {
32 printf("usage: %s file\n", argv[0]);
33 return RETURN_FAIL;
36 lock = Lock(argv[1], SHARED_LOCK);
37 if (lock == BNULL) {
38 printf("couldn't open file [%ld]\n", (long)IoErr());
39 return RETURN_FAIL;
42 fib = (struct FileInfoBlock *) AllocDosObject(DOS_FIB, NULL);
43 if (fib == NULL) {
44 printf("couldn't allocate FileInfoBlock structure\n");
45 UnLock(lock);
46 return RETURN_FAIL;
49 if (! Examine(lock, fib)) {
50 printf("Examine() failed [%ld]\n", (long)IoErr());
51 FreeDosObject(DOS_FIB, fib);
52 UnLock(lock);
53 return RETURN_FAIL;
56 printf("fib_DiskKey : 0x%lx\n", fib->fib_DiskKey);
57 printf("fib_DirEntryType: %d [%s]\n", (int)fib->fib_DirEntryType, ENTRYTYPESTR(fib->fib_DirEntryType));
58 printf("fib_FileName : %s\n", fib->fib_FileName);
59 printf("fib_Protection : 0x%04x\n", (unsigned)fib->fib_Protection);
60 printf("fib_EntryType : %d [%s]\n", (int)fib->fib_EntryType, ENTRYTYPESTR(fib->fib_EntryType));
61 printf("fib_Size : %d\n", (int)fib->fib_Size);
62 printf("fib_NumBlocks : %d\n", (int)fib->fib_NumBlocks);
64 dt.dat_Stamp = fib->fib_Date;
65 dt.dat_Format = FORMAT_DOS;
66 dt.dat_Flags = 0;
67 dt.dat_StrDay = NULL;
68 dt.dat_StrDate = date;
69 dt.dat_StrTime = time;
70 DateToStr(&dt);
72 printf("fib_Date : %s %s\n", date, time);
74 printf("fib_Comment : %s\n", fib->fib_Comment);
75 printf("fib_OwnerUID : %d\n", fib->fib_OwnerUID);
76 printf("fib_OwnerGID : %d\n", fib->fib_OwnerGID);
78 FreeDosObject(DOS_FIB, fib);
79 UnLock(lock);
81 return RETURN_OK;