Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendiskpart.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS DiskPart 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: base/system/diskpart/diskpart.c 00005 * PURPOSE: Manages all the partitions of the OS in 00006 * an interactive way 00007 * PROGRAMMERS: Lee Schroeder 00008 */ 00009 00010 /* INCLUDES ******************************************************************/ 00011 #include "diskpart.h" 00012 00013 /* FUNCTIONS ******************************************************************/ 00014 00015 VOID 00016 PrintResourceString(INT resID, ...) 00017 { 00018 WCHAR szMsg[3072]; 00019 va_list arg_ptr; 00020 00021 va_start(arg_ptr, resID); 00022 LoadStringW(GetModuleHandle(NULL), resID, szMsg, 3072); 00023 vwprintf(szMsg, arg_ptr); 00024 va_end(arg_ptr); 00025 } 00026 00027 00028 /* 00029 * run_script(const char *filename): 00030 * opens the file, reads the contents, convert the text into readable 00031 * code for the computer, and then execute commands in order. 00032 */ 00033 BOOL 00034 run_script(LPCWSTR filename) 00035 { 00036 FILE *script_file; 00037 WCHAR tmp_string[MAX_STRING_SIZE]; 00038 00039 /* Open the file for processing */ 00040 script_file = _wfopen(filename, L"r"); 00041 if (script_file == NULL) 00042 { 00043 /* if there was problems opening the file */ 00044 PrintResourceString(IDS_ERROR_MSG_NO_SCRIPT, filename); 00045 return FALSE; /* if there is no script, exit the program */ 00046 } 00047 00048 /* Read and process the script */ 00049 while (fgetws(tmp_string, MAX_STRING_SIZE, script_file) != NULL) 00050 { 00051 if (interpret_script(tmp_string) == FALSE) 00052 return FALSE; 00053 } 00054 00055 /* Close the file */ 00056 fclose(script_file); 00057 00058 return TRUE; 00059 } 00060 00061 /* 00062 * wmain(): 00063 * Main entry point of the application. 00064 */ 00065 int wmain(int argc, const WCHAR *argv[]) 00066 { 00067 WCHAR szComputerName[MAX_STRING_SIZE]; 00068 DWORD comp_size = MAX_STRING_SIZE; 00069 LPCWSTR file_name = NULL; 00070 int i; 00071 int timeout = 0; 00072 00073 /* Get the name of the computer for us and change the value of comp_name */ 00074 GetComputerName(szComputerName, &comp_size); 00075 00076 /* TODO: Remove this section of code when program becomes stable enough for production use. */ 00077 wprintf(L"\n*WARNING*: This program is incomplete and may not work properly.\n"); 00078 00079 /* Print the header information */ 00080 PrintResourceString(IDS_APP_HEADER, DISKPART_VERSION); 00081 PrintResourceString(IDS_APP_LICENSE); 00082 PrintResourceString(IDS_APP_CURR_COMPUTER, szComputerName); 00083 00084 /* Process arguments */ 00085 for (i = 1; i < argc; i++) 00086 { 00087 if ((argv[i][0] == L'-') || (argv[i][0] == L'/')) 00088 { 00089 if (wcsicmp(&argv[i][1], L"s") == 0) 00090 { 00091 /* 00092 * Get the file name only if there is at least one more 00093 * argument and it is not another option 00094 */ 00095 if ((i + 1 < argc) && 00096 (argv[i + 1][0] != L'-') && 00097 (argv[i + 1][0] != L'/')) 00098 { 00099 /* Next argument */ 00100 i++; 00101 00102 /* Get the file name */ 00103 file_name = argv[i]; 00104 } 00105 } 00106 else if (wcsicmp(&argv[i][1], L"t") == 0) 00107 { 00108 /* 00109 * Get the timeout value only if there is at least one more 00110 * argument and it is not another option 00111 */ 00112 if ((i + 1 < argc) && 00113 (argv[i + 1][0] != L'-') && 00114 (argv[i + 1][0] != L'/')) 00115 { 00116 /* Next argument */ 00117 i++; 00118 00119 /* Get the timeout value */ 00120 timeout = _wtoi(argv[i]); 00121 } 00122 } 00123 else if (wcscmp(&argv[i][1], L"?") == 0) 00124 { 00125 PrintResourceString(IDS_APP_USAGE); 00126 return EXIT_SUCCESS; 00127 } 00128 } 00129 } 00130 00131 /* Run the script if we got a script name or call the interpreter otherwise */ 00132 if (file_name != NULL) 00133 { 00134 if (run_script(file_name) == FALSE) 00135 return EXIT_FAILURE; 00136 } 00137 else 00138 { 00139 interpret_main(); 00140 } 00141 00142 /* Let the user know the program is exiting */ 00143 PrintResourceString(IDS_APP_LEAVING); 00144 00145 return EXIT_SUCCESS; 00146 } Generated on Sun May 27 2012 04:18:47 for ReactOS by
1.7.6.1
|