Simple utility to list the so called "DOS Devices", that is
[reactos.git] / rosapps / sysutils / ldd.c
1 /* $Id: ldd.c,v 1.1 2000/08/04 21:49:31 ea Exp $
2 *
3 * FILE : ldd.c
4 * AUTHOR: Emanuele ALIBERTI
5 * DATE : 2000-08-04
6 * DESC : List DOS devices, i.e. symbolic links created
7 * in the \?? object manager's name space.
8 */
9 #include <windows.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12
13 #include "win32err.h"
14
15 #define LINKS_SIZE 32768
16 #define DEVICE_SIZE 8192
17
18 static char SymbolicLinks [LINKS_SIZE];
19 static char DosDeviceName [DEVICE_SIZE];
20
21 static char DeviceNames [DEVICE_SIZE];
22 static char DeviceName [DEVICE_SIZE];
23
24
25 BOOL
26 STDCALL
27 GetNextString (
28 char * BufferIn,
29 char * BufferOut,
30 char ** Next
31 )
32 {
33 char * next = *Next;
34 char * w;
35
36 if ('\0' == *next) return FALSE;
37 for ( w = BufferOut;
38 ('\0' != *next);
39 next ++
40 )
41 {
42 *(w ++) = *next;
43 }
44 *w = '\0';
45 *Next = ++ next;
46 return TRUE;
47 }
48
49
50 int
51 main (int argc, char * argv [] )
52 {
53 printf (
54 "ReactOS W32 - List DOS Devices\n"
55 "Written by E.Aliberti (%s)\n\n",
56 __DATE__
57 );
58
59 if (0 != QueryDosDevice (
60 NULL, /* dump full directory */
61 SymbolicLinks,
62 sizeof SymbolicLinks
63 )
64 )
65 {
66 char * NextDosDevice = SymbolicLinks;
67 char * NextDevice;
68
69 while (TRUE == GetNextString (
70 SymbolicLinks,
71 DosDeviceName,
72 & NextDosDevice
73 )
74 )
75 {
76 printf ("%s\n", DosDeviceName);
77 if (0 != QueryDosDevice (
78 DosDeviceName,
79 DeviceNames,
80 sizeof DeviceNames
81 )
82 )
83 {
84 NextDevice = DeviceNames;
85 while (TRUE == GetNextString (
86 DeviceNames,
87 DeviceName,
88 & NextDevice
89 )
90 )
91 {
92 printf (" %s\n", DeviceName);
93 }
94 }
95 else
96 {
97 PrintWin32Error (
98 L"ldd: ",
99 GetLastError ()
100 );
101 }
102 printf ("\n");
103 }
104 }
105 else
106 {
107 PrintWin32Error (
108 L"ldd: ",
109 GetLastError ()
110 );
111 return EXIT_FAILURE;
112 }
113 return EXIT_SUCCESS;
114 }
115
116
117 /* EOF */