- struct winsize ws;
-
- ws.ws_row = ws.ws_col = -1;
- ws.ws_xpixel = ws.ws_ypixel = -1;
- if (cp) {
- ws.ws_row = atoi(cp);
- cp = index(cp, ',');
- if (cp == 0)
- goto done;
- ws.ws_col = atoi(++cp);
- cp = index(cp, ',');
- if (cp == 0)
- goto done;
- ws.ws_xpixel = atoi(++cp);
- cp = index(cp, ',');
- if (cp == 0)
- goto done;
- ws.ws_ypixel = atoi(++cp);
- }
-done:
- if (ws.ws_row != -1 && ws.ws_col != -1 &&
- ws.ws_xpixel != -1 && ws.ws_ypixel != -1)
- ioctl(0, TIOCSWINSZ, &ws);
-}
-/* END TRASH */
-
-/*
- * Set the value of var to be arg in the Unix 4.2 BSD environment env.
- * Var should end with '='.
- * (bindings are of the form "var=value")
- * This procedure assumes the memory for the first level of environ
- * was allocated using malloc.
- */
-setenv(var, value, clobber)
- char *var, *value;
-{
- extern char **environ;
- int index = 0;
- int varlen = strlen(var);
- int vallen = strlen(value);
-
- for (index = 0; environ[index] != NULL; index++) {
- if (strncmp(environ[index], var, varlen) == 0) {
- /* found it */
- if (!clobber)
- return;
- environ[index] = malloc(varlen + vallen + 1);
- strcpy(environ[index], var);
- strcat(environ[index], value);
- return;
- }
- }
- environ = (char **) realloc(environ, sizeof (char *) * (index + 2));
- if (environ == NULL) {
- fprintf(stderr, "login: malloc out of memory\n");
- exit(1);
- }
- environ[index] = malloc(varlen + vallen + 1);
- strcpy(environ[index], var);
- strcat(environ[index], value);
- environ[++index] = NULL;