Annotation of coherent/d/286_KERNEL/USRSRC/coh/arg_exist.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Determine whether or not a given argument exists on the command line
        !             3:  * passed into the kernel.
        !             4:  *
        !             5:  * Takes a pointer to a NUL terminated string that is the name of
        !             6:  * the desired argument.
        !             7:  */
        !             8: #include <sys/typed.h>
        !             9: #ifndef TRUE
        !            10: #define TRUE   1
        !            11: #define FALSE  0
        !            12: #endif /* TRUE */
        !            13: 
        !            14: extern typed_space boot_gift;
        !            15: 
        !            16: int
        !            17: arg_exist(arg)
        !            18: {
        !            19:     FIFO *gift_ffp;
        !            20:     typed_space *tp;
        !            21:     int retval;
        !            22: 
        !            23:     retval = FALSE;
        !            24: 
        !            25:     /* If we can't open the gift, we can't find the argument.  */
        !            26:     gift_ffp = fifo_open(&boot_gift, 0);
        !            27: 
        !            28:     if (F_NULL != gift_ffp) {
        !            29:         while (T_NULL != (tp = fifo_read(gift_ffp))) {
        !            30:              if (T_STR_ARGF == tp->ts_type) {
        !            31:                  RETYPE(tp, T_FIFO_SIC);
        !            32:                  retval = fifo_find_str(tp, arg);
        !            33:                  break;
        !            34:              }
        !            35:         }
        !            36:     }
        !            37: 
        !            38:     fifo_close(gift_ffp);
        !            39:     return(retval);
        !            40: } /* arg_exist() */
        !            41: 
        !            42: 
        !            43: /*
        !            44:  * Looks for the string "astring" in the fifo "afifo".
        !            45:  * Returns TRUE if it find the string.
        !            46:  */
        !            47: int
        !            48: fifo_find_str(afifo, astring)
        !            49:        typed_space *afifo;
        !            50:        char *astring;
        !            51: {
        !            52:     FIFO *command_line;
        !            53:     typed_space *tp;
        !            54:     int retval;
        !            55: 
        !            56:     retval = FALSE;
        !            57: 
        !            58:     /* If we can't open the gift, we can't find the argument.  */
        !            59:     command_line = fifo_open(afifo, 0);
        !            60:  
        !            61:     if (F_NULL != command_line) {
        !            62:         while (T_NULL != (tp = fifo_read(command_line))) {
        !            63:              /* Only check those items that are strings.  */
        !            64:              if (T_STR_STR == tp->ts_type) {
        !            65:                  /* Is this the string we've been looking for?  */
        !            66:                  if (0 == strcmp(tp->ts_data, astring)) {
        !            67:                        retval = TRUE;
        !            68:                        break;
        !            69:                  }
        !            70:              }
        !            71:         }
        !            72:    }
        !            73: 
        !            74:    fifo_close(command_line);
        !            75:    return(retval);
        !            76: 
        !            77: } /* fifo_find_str() */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.