/[cvs]/joko/Uni/BSArch/03/win32/min_shell.c
ViewVC logotype

Diff of /joko/Uni/BSArch/03/win32/min_shell.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by joko, Thu Jun 15 14:21:16 2006 UTC revision 1.6 by joko, Thu Jun 15 22:34:55 2006 UTC
# Line 33  int main(int argc, char * argv[]) { Line 33  int main(int argc, char * argv[]) {
33  void read_commands(FILE * fp) {  void read_commands(FILE * fp) {
34        
35    char command[MAX_COMMAND_LENGTH];    char command[MAX_COMMAND_LENGTH];
   int command_length;  
36        
37    fgets(command, MAX_COMMAND_LENGTH, fp);    fgets(command, MAX_COMMAND_LENGTH, fp);
38    command_length = strlen(command);    chomp(command);
     
   /* if last char is newline, strip it */  
   if (command[command_length-1] == '\n') {  
     command[command_length-1] = '\0';  
   }  
39        
40    process_command(command);    process_command(command);
41  }  }
42    
43    /* if last char is newline, "strip" it */
44    void chomp(char * string) {
45      int string_length = strlen(string);
46      if (string[string_length-1] == '\n') {
47        string[string_length-1] = '\0';
48      }
49    }
50    
51  void process_command(char * command) {  void process_command(char * command) {
52    printf("process_command: %s\n", command);    printf("process_command: %s\n", command);
53    start_process(command, 0);    start_process(command, 0);
# Line 56  BOOL start_process(char * filename, BOOL Line 58  BOOL start_process(char * filename, BOOL
58    STARTUPINFO si;    STARTUPINFO si;
59    PROCESS_INFORMATION pi;    PROCESS_INFORMATION pi;
60    
61    printf("start_process: '%s'\n", filename);    //printf("start_process: '%s'\n", filename);
62        
63    ZeroMemory(&si,sizeof(si));    ZeroMemory(&si,sizeof(si));
64    si.cb = sizeof(STARTUPINFO);    si.cb = sizeof(STARTUPINFO);
65        
66    ZeroMemory(&pi,sizeof(pi));    ZeroMemory(&pi,sizeof(pi));
   //pi.cb=sizeof(PROCESS_INFORMATION);  
67        
68    CreateProcess(    CreateProcess(
     //"C:\windows\system32\notepad.exe", NULL,  
     //"C:\\windows\\system32\\notepad.exe", NULL,  
69      NULL, filename,      NULL, filename,
70      NULL, NULL, FALSE, 0,      NULL, NULL, FALSE, 0,
71      NULL, NULL,      NULL, NULL,

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed