+ register char *cp = index(term, '/'), **cpp;
+ char *speed;
+
+ if (cp) {
+ *cp++ = '\0';
+ speed = cp;
+ cp = index(speed, '/');
+ if (cp)
+ *cp++ = '\0';
+ for (cpp = speeds; cpp < &speeds[NSPEEDS]; cpp++)
+ if (strcmp(*cpp, speed) == 0) {
+ tp->sg_ispeed = tp->sg_ospeed = cpp-speeds;
+ break;
+ }
+ }
+ tp->sg_flags = ECHO|CRMOD|ANYP|XTABS;
+}
+
+/*
+ * 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;
+}
+
+tty_gid(default_gid)
+ int default_gid;
+{
+ struct group *getgrnam(), *gr;
+ int gid = default_gid;
+
+ gr = getgrnam(TTYGRPNAME);
+ if (gr != (struct group *) 0)
+ gid = gr->gr_gid;
+
+ endgrent();