update for HEAD-2003021201
[reactos.git] / apps / utils / sc / query.c
1 /*
2  *  ReactOS SC - service control console program
3  *
4  *  query.c
5  *
6  *  Copyright (C) 2002  Robert Dickenson <robd@reactos.org>
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include <windows.h>
24 #include <wchar.h>
25 #include <tchar.h>
26 #include "main.h"
27
28
29
30 int DisplayServiceInfo(BOOL display_ex)
31 {
32     const char* type_str = "WIN32_SHARE_PROCESS";
33     const char* state_str = "RUNNING";
34     const char* flags_str = "RUNS_IN_SYSTEM_PROCESS";
35     const char* features_str = "NOT_STOPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN";
36
37     const char* ServiceName = "none";
38     const char* DisplayName = "none";
39     int Type;
40     int State;
41     int Win32ExitCode;
42     int ServiceExitCode;
43     int CheckPoint;
44     int WaitHint;
45     int Pid;
46     int Flags;
47
48     Type = 20;
49     State = 4;
50     Win32ExitCode = 0;
51     ServiceExitCode = 0;
52     CheckPoint = 0;
53     WaitHint = 0;
54     Pid = 0;
55     Flags = 0;
56
57     dprintf("\nSERVICE_NAME: %s\n", ServiceName);
58     dprintf("DISPLAY_NAME: %s\n", DisplayName);
59     dprintf("\tTYPE               : %d  %s\n", Type, type_str);
60     dprintf("\tSTATE              : %d  %s\n", State, state_str);
61     dprintf("\t                   :    (%s)\n", features_str);
62     dprintf("\tWIN32_EXIT_CODE    : %d  (0x%01x)\n", Win32ExitCode, Win32ExitCode);
63     dprintf("\tSERVICE_EXIT_CODE  : %d  (0x%01x)\n", ServiceExitCode, ServiceExitCode);
64     dprintf("\tCHECKPOINT         : 0x%01x\n", CheckPoint);
65     dprintf("\tWAIT_HINT          : 0x%01x\n", WaitHint);
66
67     if (display_ex) {
68         dprintf("\tPID                : %d\n", Pid);
69         dprintf("\tFLAGS              : %s\n", flags_str);
70     }
71
72     return 0;
73 }
74
75 int EnumServicesInfo(void)
76 {
77     int entriesRead = 0;
78     int resumeIndex = 0;
79
80     dprintf("Enum: entriesRead = %d\n", entriesRead);
81     dprintf("Enum: resumeIndex = %d\n", resumeIndex);
82
83     DisplayServiceInfo(1);
84
85     return 0;
86 }
87
88 int sc_query(SC_HANDLE hSCManager, SC_CMDS sc_cmd, char* argv[])
89 {
90     switch (sc_cmd) {
91     case SC_CMD_QUERY:
92     case SC_CMD_QUERYEX:
93     case SC_CMD_QC:
94     case SC_CMD_QDESCRIPTION:
95     case SC_CMD_QFAILURE:
96     case SC_CMD_SDSHOW:
97     case SC_CMD_GETDISPLAYNAME:
98     case SC_CMD_GETKEYNAME:
99         dprintf("sc_query(%x, %d, %s) - command not implemented.\n", hSCManager, sc_cmd, argv[0]);
100         break;
101     case SC_CMD_ENUMDEPEND:
102         return EnumServicesInfo();
103 //    case SC_CMD_QUERYLOCK:
104 //        return sc_QueryLock(hSCManager);
105     default:
106         dprintf("sc_query(%x, %d, %s) - unknown command.\n", hSCManager, sc_cmd, argv[0]);
107         break;
108     }
109     return 0;
110 }
111