243eadf7e5271f0f591541a15e9d1de0ea1a4569
2 * PROJECT: ReactOS DiskPart
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/system/diskpart/diskpart.c
5 * PURPOSE: Manages all the partitions of the OS in
7 * PROGRAMMERS: Lee Schroeder
10 /* INCLUDES ******************************************************************/
13 /* FUNCTIONS ******************************************************************/
16 PrintResourceString(INT resID
, ...)
21 va_start(arg_ptr
, resID
);
22 LoadStringW(GetModuleHandle(NULL
), resID
, szMsg
, 3072);
23 vwprintf(szMsg
, arg_ptr
);
29 * run_script(const char *filename):
30 * opens the file, reads the contents, convert the text into readable
31 * code for the computer, and then execute commands in order.
33 BOOL
run_script(LPCWSTR filename
)
36 WCHAR tmp_string
[MAX_STRING_SIZE
];
38 /* Open the file for processing */
39 script_file
= _wfopen(filename
, L
"r");
40 if (script_file
== NULL
)
42 /* if there was problems opening the file */
43 PrintResourceString(IDS_ERROR_MSG_NO_SCRIPT
, filename
);
44 return FALSE
; /* if there is no script, exit the program */
47 /* Read and process the script */
48 while (fgetws(tmp_string
, MAX_STRING_SIZE
, script_file
) != NULL
)
50 if (interpret_script(tmp_string
) == FALSE
)
62 * Main entry point of the application.
64 int wmain(int argc
, const WCHAR
*argv
[])
66 /* Gets the current name of the computer */
67 WCHAR comp_name
[MAX_STRING_SIZE
]; //used to store the name of the computer */
68 DWORD comp_size
= MAX_STRING_SIZE
; // used for the char size of comp_name */
69 BOOL interpreter_running
= TRUE
; //used for the main program loop */
71 /* Get the name of the computer for us and change the value of comp_name */
72 GetComputerName(comp_name
, &comp_size
);
74 /* TODO: Remove this section of code when program becomes stable enough for production use. */
75 wprintf(L
"\n*WARNING*: This program is incomplete and may not work properly.\n");
77 /* Print the header information */
78 PrintResourceString(IDS_APP_HEADER
, DISKPART_VERSION
);
79 PrintResourceString(IDS_APP_LICENSE
);
80 PrintResourceString(IDS_APP_CURR_COMPUTER
, comp_name
);
82 /* Find out if the user is loading a script */
85 /* if there are arguments when starting the program
86 determine if the script flag is enabled */
87 if ((wcsicmp(argv
[1], L
"/s") == 0) ||
88 (wcsicmp(argv
[1], L
"-s") == 0))
90 /* see if the user has put anything after the script flag; if not,
91 then it doesn't run the run_script() command. */
92 /* Alternative comment: Fail if the script name is missing */
96 interpreter_running
= run_script(argv
[2]);
100 /* the main program loop */
101 while (interpreter_running
)
103 interpreter_running
= interpret_main();
106 /* Let the user know the program is exiting */
107 PrintResourceString(IDS_APP_LEAVING
);