/[hurd]/hurd/daemons/runttys.c
ViewVC logotype

Diff of /hurd/daemons/runttys.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by roland, Sun Sep 19 19:43:31 1999 UTC revision 1.4 by roland, Thu Nov 22 04:00:33 2001 UTC
# Line 1  Line 1 
1  /* /etc/ttys support for Hurd  /* /etc/ttys support for Hurd
2     Copyright (C) 1993,94,95,96,97,98,99 Free Software Foundation, Inc.     Copyright (C) 1993,94,95,96,97,98,99,2001 Free Software Foundation, Inc.
3     This file is part of the GNU Hurd.     This file is part of the GNU Hurd.
4    
5     The GNU Hurd is free software; you can redistribute it and/or modify     The GNU Hurd is free software; you can redistribute it and/or modify
# Line 92  setup_terminal (struct terminal *t, stru Line 92  setup_terminal (struct terminal *t, stru
92            size_t len;            size_t len;
93            argz_create_sep (line, ' ', &argz, &len);            argz_create_sep (line, ' ', &argz, &len);
94            argc = argz_count (argz, len);            argc = argz_count (argz, len);
95            argv = malloc (argc * sizeof (char *));            argv = malloc ((argc + 1) * sizeof (char *));
96            argz_extract (argz, len, argv);            if (argv == 0)
97                error (0, ENOMEM,
98                       "cannot allocate argument vector for %s", t->name);
99              else
100                argz_extract (argz, len, argv);
101            return argv;            return argv;
102          }          }
103    
104        char *line;        char *line;
105        asprintf (&line, "%s %s", tt->ty_getty, tt->ty_name);        asprintf (&line, "%s %s", tt->ty_getty, tt->ty_name);
106        t->getty_argv = make_args (line);        if (line == 0)
107        free (line);          {
108              error (0, ENOMEM,
109                     "cannot allocate arguments for %s", t->name);
110              t->getty_argv = 0;
111            }
112          else
113            {
114              t->getty_argv = make_args (line);
115              free (line);
116            }
117        t->window_argv = tt->ty_window ? make_args (tt->ty_window) : 0;        t->window_argv = tt->ty_window ? make_args (tt->ty_window) : 0;
118      }      }
119    else    else
# Line 116  add_terminal (struct ttyent *tt) Line 129  add_terminal (struct ttyent *tt)
129    
130    if (nttys >= ttyslen)    if (nttys >= ttyslen)
131      {      {
132        ttys = realloc (ttys, (ttyslen * 2) * sizeof (struct ttyent));        struct terminal *newttys = realloc (ttys,
133        memset (&ttys[nttys], 0, ttyslen);                                            (ttyslen * 2) * sizeof ttys[0]);
134        ttyslen *= 2;        if (newttys == 0)
135            {
136              error (0, ENOMEM, "cannot expand terminals table past %d", ttyslen);
137              return 0;
138            }
139          else
140            {
141              ttys = newttys;
142              memset (&ttys[nttys], 0, ttyslen);
143              ttyslen *= 2;
144            }
145      }      }
146    
147    t = &ttys[nttys];    t = &ttys[nttys];
   nttys++;  
   
148    t->name = strdup (tt->ty_name);    t->name = strdup (tt->ty_name);
149      if (t->name == 0)
150        {
151          error (0, ENOMEM, "cannot allocate entry for %s", tt->ty_name);
152          return 0;
153        }
154    
155      nttys++;
156    setup_terminal (t, tt);    setup_terminal (t, tt);
157    if (t->getty_argv)    if (t->getty_argv)
158      t->on = 1;      t->on = 1;
# Line 142  init_ttys (void) Line 169  init_ttys (void)
169    ttyslen = 10;    ttyslen = 10;
170    nttys = 0;    nttys = 0;
171    
172    ttys = calloc (ttyslen, sizeof (struct ttyent));    ttys = calloc (ttyslen, sizeof ttys[0]);
173      if (ttys == 0)
174        error (2, ENOMEM, "cannot allocate table");
175    
176    if (!setttyent ())    if (!setttyent ())
177      {      {
# Line 335  reread_ttys (void) Line 364  reread_ttys (void)
364        else        else
365          {          {
366            t = add_terminal (tt);            t = add_terminal (tt);
367              if (t == 0)
368                continue;
369            if (on)            if (on)
370              startup_terminal (t);              startup_terminal (t);
371          }          }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26