10 User Commands

l. 10 --- needs --- "ls *" ---

<..process user commands..>
 eoln_ch = (int) ’x’;
 while( eoln_ch != EOF ) {              Q_CHAR *command, ch;
                                        int n;
                                        struct sys_call_rec *p;
                                        BOOL flag;
    status = scan_str("l. ", TRUE, lg_file);
    status = scan_until_str(" --- needs --- \"", 1, status, lg_file);
    status = scan_until_str("\" ---", 2, status, lg_file);
    if( status ){
       command = match[2];
       *(command + (int) strlen((char *) command) - 5) = ’\0’;
       <.flag = permission for system calls.>
       if( flag ){
         <.execute system command.>
       } else { (IGNORED) printf(
           "No permission for system call: %s\n", command); }
 }  }
 -_-_-

<..env permissions for system calls..>
 {     struct sys_call_rec *q;
   q = m_alloc(struct sys_call_rec, 1);
   q->next = system_calls;
   q->filter = match[1];
               match[1] = (Q_CHAR *) malloc(70);  max_match[1] = 70;
   system_calls = q;
 if( debug ){
    (IGNORED) printf(".......’S’ script: ’%s’\n",
                                 q->filter); }
 }
 -_-_-

<..permission for system calls..>
 {     struct sys_call_rec *q;
   q = m_alloc(struct sys_call_rec, 1);
   q->next = system_calls;
   q->filter = p + 2;
   system_calls = q;
 }
 -_-_-

<..flag = permission for system calls..>
 flag = FALSE;
 p = system_calls;
 while( p ){
   if( (n = (int) strlen((char *) p->filter)) == 1 ) {
      if( *(p->filter) == ’*’ ){
          flag = TRUE; break;
      }
   }
   if( strlen((char *) command) >= (unsigned int) n ) {
       ch = command[n]; command[n] = ’\0’;
       flag = flag || eq_str(p->filter,command);
       command[n] = ch;
   }
   p = p->next;
 }
 -_-_-

<..defines..>+
 struct sys_call_rec{
   Q_CHAR * filter;
   struct sys_call_rec *next;
 };
 -_-_-

<..vars..>+
 static BOOL system_yes;
 static struct sys_call_rec *system_calls = (struct sys_call_rec *) 0;
 -_-_-

From log files ‘l. # --- needs --- "command" ---