static char * my_basename (char *d, int dsize, /* const */ char *s) { s = last_slash (s); strncpy (d, s + 1, dsize - 1); d[dsize - 1] = 0; return d; }
static char * dirname (char *d, int dsize, /* const */ char *s) { char *p; strncpy (d, s, dsize - 1); d[dsize - 1] = 0; p = last_slash (d); *p = 0; return d; }
static void exec_sh_c(char *cmd) { static char bin_sh[] = "/bin/sh"; char *sh, *shname; int i; #ifndef NOFILE # define NOFILE 20 #endif /* Make sure there are no upper inherited file descriptors */ for (i = 3; i < NOFILE; i++) (void) close(i); sh = user_SHELL(); if (isEmpty(sh)) { sh = bin_sh; shname = pathleaf(sh); } else { shname = last_slash(sh); if (shname == NULL) { shname = sh; } else { shname++; if (*shname == EOS) shname = sh; } } if (cmd) { #if SYS_OS2_EMX /* * OS/2 EMX accepts forward and backward slashes * interchangeably except in one special case - * invoking the OS/2 cmd.exe program for syntax * filters. That accepts only backslashes if we put a * ".exe" suffix on the pathname. */ for (i = 0; ispath(cmd[i]); i++) if (cmd[i] == '/') cmd[i] = '\\'; #endif (void) execlp(sh, shname, SHELL_C, cmd, (void *) 0); } else { (void) execlp(sh, shname, (void *) 0); } IGNORE_RC(write(2, "exec failed\r\n", (size_t) 14)); exit(-1); }
void debug_outputf(const char *level, const char *flow, const char *module, const char *file, int line, const char *func, const char *format, ...) { if (debug_filter(level, flow, module, file, func)) { va_list args; printk("%s %s %s:%d ", level, module, last_slash(file), line); va_start(args, format); vprintk(format, args); va_end(args); printk("\n"); } }