/** * @brief Helper routine to parse a single arg and return its mask * * Parse all the - options to create a mask (or a serial speed in the * case of -S). If the arg doesn't start with '-' assume it's an env * variable and set that instead. */ int boot_parse_arg(char *v) { char *n; int howto; #if 0 /* Need to see if this is better or worse than the meat of the #else */ static const char howto_switches[] = "aCdrgDmphsv"; static int howto_masks[] = { RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE, RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE }; opts = strchr(kargs, '-'); while (opts != NULL) { while (*(++opts) != '\0') { sw = strchr(howto_switches, *opts); if (sw == NULL) break; howto |= howto_masks[sw - howto_switches]; } opts = strchr(opts, '-'); } #else howto = 0; if (*v == '-') { while (*v != '\0') { v++; switch (*v) { case 'a': howto |= RB_ASKNAME; break; case 'C': howto |= RB_CDROM; break; case 'd': howto |= RB_KDB; break; case 'D': howto |= RB_MULTIPLE; break; case 'm': howto |= RB_MUTE; break; case 'g': howto |= RB_GDB; break; case 'h': howto |= RB_SERIAL; break; case 'p': howto |= RB_PAUSE; break; case 'P': howto |= RB_PROBE; break; case 'r': howto |= RB_DFLTROOT; break; case 's': howto |= RB_SINGLE; break; case 'S': SETENV("comconsole_speed", v + 1); v += strlen(v); break; case 'v': howto |= RB_VERBOSE; break; } } } else { n = strsep(&v, "="); if (v == NULL) SETENV(n, "1"); else SETENV(n, v); } #endif return (howto); }
/** * @brief Set env vars from howto_names based on howto passed in */ void boot_howto_to_env(int howto) { int i; for (i = 0; howto_names[i].ev != NULL; i++) if (howto & howto_names[i].mask) SETENV(howto_names[i].ev, "YES"); }
long long sys_set( UDF_INIT *initid , UDF_ARGS *args , char *is_null , char *error ){ char *name = initid->ptr; char *value = name + args->lengths[0] + 1; memcpy( name , args->args[0] , args->lengths[0] ); *(name + args->lengths[0]) = '\0'; memcpy( value , args->args[1] , args->lengths[1] ); *(value + args->lengths[1]) = '\0'; return SETENV(name,value); }
void setenv (char *varname, char *varvalue) { SETENV(varname, varvalue); }