/* * This is only used in sh.glob.c for sorting purpose. */ int strcoll_(tchar *s1, tchar *s2) { char buf1[BUFSIZ]; char buf2[BUFSIZ]; tstostr(buf1, s1); tstostr(buf2, s2); return (strcoll(buf1, buf2)); }
static void tconvert(struct command *cmd, tchar *fname, tchar **list) { char **rc; int len; cmd->cfname = tstostr(NULL, fname); len = blklen(list); rc = cmd->cargs = (char **) xcalloc((uint_t)(len + 1), sizeof (char **)); while (len--) *rc++ = tstostr(NULL, *list++); *rc = NULL; }
/* * Two getenv() substitute functions. They differ in the type of arguments. * BUGS: Both returns the pointer to an allocated space where the env var's * values is stored. This space is freed automatically on the successive * call of either function. Therefore the caller must copy the contents * if it needs to access two env vars. There is an arbitary limitation * on the number of chars of a env var name. */ #define LONGEST_ENVVARNAME 256 /* Too big? */ tchar * getenv_(tchar *name_) { char name[LONGEST_ENVVARNAME * MB_LEN_MAX]; assert(strlen_(name_) < LONGEST_ENVVARNAME); return (getenvs_(tstostr(name, name_))); }
/* * creat() and open() replacement. * BUGS: An unusually long file name could be dangerous. */ int creat_(tchar *name_, int mode) { int fd; char chbuf[MAXPATHLEN * MB_LEN_MAX]; /* General use buffer. */ tstostr(chbuf, name_); fd = creat((char *)chbuf, mode); if (fd != -1) { setfd(fd); } return (fd); }