Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
7.2 KiB

  1. //---------------------------------------------------------
  2. // Copyright (c) 1999-2000 Microsoft Corporation
  3. //
  4. // admutils.h
  5. //
  6. // vikram K.R.C. ([email protected])
  7. //
  8. // The header file for the command line admin tools.
  9. // (May-2000)
  10. //---------------------------------------------------------
  11. #ifndef _ADMIN_FUNCTIONS_HEADER_
  12. #define _ADMIN_FUNCTIONS_HEADER_
  13. #include <wbemidl.h>
  14. #include <stdio.h>
  15. #include <winsock2.h>
  16. #ifndef WHISTLER_BUILD
  17. #include "allutils.h"
  18. #else
  19. // the other definition is in commfunc.h
  20. typedef struct _StrList
  21. {
  22. TCHAR *Str;
  23. struct _StrList *next;
  24. }StrList;
  25. #endif
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. // Arraysize(buf) returns the no. of chars in the buffer
  30. // Please do not use it for dynamic arrays. This will
  31. // work only for static buffers.
  32. #ifndef ARRAYSIZE
  33. #define ARRAYSIZE(buf) (sizeof(buf) / sizeof((buf)[0]))
  34. #endif
  35. typedef struct _STRING_LIST
  36. {
  37. DWORD count;
  38. LPTSTR *strings;
  39. } STRING_LIST, *PSTRING_LIST;
  40. #define TEXT_MAX_INTEGER_VALUE L"2147483647"
  41. #define MAX_LEN_FOR_CODEPAGE 6
  42. #define SZLOCALMACHINE L"localhost"
  43. #define MAX_COMMAND_LINE 500
  44. #define MAX_BUFFER_SIZE 4096
  45. //FOR XPSP1. If the variables are not defined, that means they are not present in .rc
  46. //and .h files. Hardcode the values that fall in the range obtained for Telnet resources
  47. //in xpsp1res.h
  48. #ifndef IDR_NEW_TELNET_USAGE
  49. #define IDR_NEW_TELNET_USAGE 20001
  50. #endif
  51. #ifndef IDR_YES
  52. #define IDR_YES 20002
  53. #endif
  54. #ifndef IDR_NO
  55. #define IDR_NO 20003
  56. #endif
  57. #ifndef IDR_TIME_HOURS
  58. #define IDR_TIME_HOURS 20004
  59. #endif
  60. #ifndef IDR_TIME_MINUTES
  61. #define IDR_TIME_MINUTES 20005
  62. #endif
  63. #ifndef IDR_TIME_SECONDS
  64. #define IDR_TIME_SECONDS 20006
  65. #endif
  66. #ifndef IDR_MAPPING_NOT_ON
  67. #define IDR_MAPPING_NOT_ON 20007
  68. #endif
  69. #ifndef IDR_STATUS_STOPPED
  70. #define IDR_STATUS_STOPPED 20008
  71. #endif
  72. #ifndef IDR_STATUS_RUNNING
  73. #define IDR_STATUS_RUNNING 20009
  74. #endif
  75. #ifndef IDR_STATUS_PAUSED
  76. #define IDR_STATUS_PAUSED 20010
  77. #endif
  78. #ifndef IDR_STATUS_START_PENDING
  79. #define IDR_STATUS_START_PENDING 20011
  80. #endif
  81. #ifndef IDR_STATUS_STOP_PENDING
  82. #define IDR_STATUS_STOP_PENDING 20012
  83. #endif
  84. #ifndef IDR_STATUS_CONTINUE_PENDING
  85. #define IDR_STATUS_CONTINUE_PENDING 20013
  86. #endif
  87. #ifndef IDR_STATUS_PAUSE_PENDING
  88. #define IDR_STATUS_PAUSE_PENDING 20014
  89. #endif
  90. #ifndef IDR_ALREADY_STARTED
  91. #define IDR_ALREADY_STARTED 20015
  92. #endif
  93. #ifndef IDS_SERVICE_STARTED
  94. #define IDS_SERVICE_STARTED 20016
  95. #endif
  96. #ifndef IDS_E_SERVICE_NOT_STARTED
  97. #define IDS_E_SERVICE_NOT_STARTED 20017
  98. #endif
  99. #ifndef IDR_SERVICE_PAUSED
  100. #define IDR_SERVICE_PAUSED 20018
  101. #endif
  102. #ifndef IDR_SERVICE_CONTINUED
  103. #define IDR_SERVICE_CONTINUED 20019
  104. #endif
  105. #ifndef IDR_SERVICE_NOT_PAUSED
  106. #define IDR_SERVICE_NOT_PAUSED 20020
  107. #endif
  108. #ifndef IDR_SERVICE_NOT_CONTINUED
  109. #define IDR_SERVICE_NOT_CONTINUED 20021
  110. #endif
  111. #ifndef IDS_E_INVALIDARG
  112. #define IDS_E_INVALIDARG 20022
  113. #endif
  114. #define SLASH_SLASH L"\\\\"
  115. #define _p_CNAME_ 0
  116. #define _p_USER_ 1
  117. #define _p_PASSWD_ 2
  118. int GetTrustedDomainList(LPTSTR szMachine, LPTSTR * list, LPTSTR * primary);
  119. void HelperFreeStringList(PSTRING_LIST pList);
  120. HRESULT LoadNTDomainList(LPTSTR szMachine);
  121. extern BOOL g_fCoInitSuccess;
  122. //Structure defn to store all the information
  123. typedef struct
  124. {
  125. int classname;
  126. wchar_t* propname;
  127. VARIANT var;
  128. int fDontput;
  129. }ConfigProperty;
  130. // Some defines used to access the name of the computer from the registry
  131. #define REG_SUBKEY_COMPUTER_NAME L"SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName"
  132. #define REG_ENTRY_COMPUTER_NAME L"ComputerName"
  133. // If at all if needed to increase the no. of mapping servers names that
  134. // can be configurable thru sfuadmin.exe, just change the #define here
  135. #define MAX_NO_OF_MAPPING_SERVERS 1
  136. //common functions for all the sfu-admins.
  137. #define GetClass(x, y) GetClassEx((x), (y), TRUE, KEY_ALL_ACCESS)
  138. #define SAFE_FREE(x) {if ((x)) {free((x));(x)=NULL;}}
  139. //authenticate to the remote computer
  140. HRESULT DoNetUseAdd(WCHAR*wzLoginname, WCHAR* wzPassword,WCHAR* wzCname);
  141. HRESULT DoNetUseDel(WCHAR* wzCname);
  142. // to connect to the registry on the specified computer
  143. HRESULT GetConnection(WCHAR* wzCname);
  144. //to get a handle to a specfic class(hive)
  145. HRESULT GetClassEx(int, int, BOOL bPrintErrorMessages, REGSAM samDesired);
  146. //close all the open hives.
  147. HRESULT PutClasses();
  148. //read the value of the property
  149. HRESULT GetProperty(int , int , VARIANT* );
  150. //set the value of the property
  151. HRESULT PutProperty(int , int , VARIANT* );
  152. //to get handle to the service and do start/stop/etc.
  153. HRESULT GetSerHandle(LPCTSTR lpServiceName,DWORD dwScmDesiredAccess, DWORD dwRegDesiredAccess,BOOL fSuppressMsg);
  154. HRESULT CloseHandles(void);
  155. HRESULT StartSfuService(LPCTSTR lpServiceName);
  156. HRESULT ControlSfuService(LPCTSTR lpServiceName,DWORD dwControl);
  157. HRESULT QuerySfuService(LPCTSTR lpServiceName);
  158. //for printing out any message by loading from strings dll.
  159. HRESULT PrintMessage(HANDLE fp, int);
  160. //for printing out any message by loading the string from correct resource and
  161. //display english message if everything else fails.
  162. HRESULT PrintMessageEx(HANDLE fp, int, LPCTSTR);
  163. //for printing out error messages by loading from strings dll.
  164. int ShowError(int);
  165. int ShowErrorEx(int nError,WCHAR *wzFormatString);
  166. int ShowErrorFallback(int, LPCTSTR);
  167. BOOL FileIsConsole( HANDLE fp );
  168. void MyWriteConsole( HANDLE fp, LPWSTR lpBuffer, DWORD cchBuffer);
  169. //get and set bit(in pos given by second arg) in int( the first arg)
  170. int GetBit(int , int );
  171. int SetBit(int , int );
  172. //returns a WCHAR string .
  173. wchar_t* DupWStr(char *str);
  174. //returns Char string from wchar String
  175. char* DupCStr(wchar_t *wzStr);
  176. //Is it a valid machine???
  177. HRESULT IsValidMachine(wchar_t*, int*);
  178. BOOL Get_Inet_Address(struct sockaddr_in *addr, char *host);
  179. HRESULT getHostNameFromIP(char *szCname, WCHAR** wzCname);
  180. //To determine if the specified domain a valid domain.
  181. HRESULT IsValidDomain(wchar_t *wsDomainName, int *fValid);
  182. //Check for Password; If only user name specified, get password. If the other way round, report error
  183. HRESULT CheckForPassword(void);
  184. void ConvertintoSeconds(int nProperty,int * nSeconds);
  185. void PrintFormattedErrorMessage(LONG ErrorCode);
  186. HRESULT GetDomainHostedByThisMc( LPWSTR szDomain );
  187. BOOL CheckForInt(int nProperty);
  188. HRESULT CheckForMaxInt(WCHAR *wzValue,DWORD ErrorCode);
  189. DWORD PreAnalyzer(int argc,WCHAR *argv[],int nProperty,WCHAR *wzOption,
  190. int nCurrentOp,int *nNextOp, BOOL *fSuccess,BOOL IsSpaceAllowed);
  191. DWORD PrintMissingRegValueMsg(int nProperty, int nNumofprop);
  192. int TnLoadString(int msg_id, LPTSTR string, int max_size_of_buffer, LPCTSTR english_string);
  193. #ifdef __cplusplus
  194. }
  195. #endif
  196. #endif