1: /* Copyright 1988,1990,1993,1994 by Paul Vixie
   2:  * All rights reserved
   3:  *
   4:  * Distribute freely, except: don't remove my name from the source or
   5:  * documentation (don't take credit for my work), mark your changes (don't
   6:  * get me blamed for your possible bugs), don't alter or remove this
   7:  * notice.  May be sold if buildable source is provided to buyer.  No
   8:  * warrantee of any kind, express or implied, is included with this
   9:  * software; use at your own risk, responsibility for damages (if any) to
  10:  * anyone resulting from the use of this software rests entirely with the
  11:  * user.
  12:  *
  13:  * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
  14:  * I'll try to keep a version up to date.  I can be reached as follows:
  15:  * Paul Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
  16:  */
  17: 
  18: #if !defined(lint) && !defined(LINT)
  19: static char rcsid[] = "$Id: user.c,v 2.8 1994/01/15 20:43:43 vixie Exp $";
  20: #endif
  21: 
  22: /* vix 26jan87 [log is in RCS file]
  23:  */
  24: 
  25: 
  26: #include "cron.h"
  27: 
  28: 
  29: void
  30: free_user(u)
  31:     user    *u;
  32: {
  33:     register entry  *e, *ne;
  34: 
  35:     free(u->name);
  36:     for (e = u->crontab;  e != NULL;  e = ne) {
  37:         ne = e->next;
  38:         free_entry(e);
  39:     }
  40:     free(u);
  41: }
  42: 
  43: 
  44: user *
  45: load_user(crontab_fd, pw, name)
  46:     int     crontab_fd;
  47:     struct passwd   *pw;        /* NULL implies syscrontab */
  48:     char        *name;
  49: {
  50:     char    envstr[MAX_ENVSTR];
  51:     FILE    *file;
  52:     register user   *u;
  53:     register entry  *e;
  54:     int status;
  55:     char    **envp;
  56: 
  57:     if (!(file = fdopen(crontab_fd, "r"))) {
  58:         perror("fdopen on crontab_fd in load_user");
  59:         return NULL;
  60:     }
  61: 
  62:     Debug(DPARS, ("load_user()\n"))
  63: 
  64:     /* file is open.  build user entry, then read the crontab file.
  65: 	 */
  66:     u = (user *) malloc(sizeof(user));
  67:     u->name = strdup(name);
  68:     u->crontab = NULL;
  69: 
  70:     /*
  71: 	 * init environment.  this will be copied/augmented for each entry.
  72: 	 */
  73:     envp = env_init();
  74: 
  75:     /*
  76: 	 * load the crontab
  77: 	 */
  78:     while ((status = load_env(envstr, file)) >= OK) {
  79:         switch (status) {
  80:         case ERR:
  81:             free_user(u);
  82:             u = NULL;
  83:             goto done;
  84:         case FALSE:
  85:             e = load_entry(file, NULL, pw, envp);
  86:             if (e) {
  87:                 e->next = u->crontab;
  88:                 u->crontab = e;
  89:             }
  90:             break;
  91:         case TRUE:
  92:             envp = env_set(envp, envstr);
  93:             break;
  94:         }
  95:     }
  96: 
  97:  done:
  98:     env_free(envp);
  99:     fclose(file);
 100:     Debug(DPARS, ("...load_user() done\n"))
 101:     return u;
 102: }

Defined functions

free_user defined in line 29; used 1 times
  • in line 81
load_user defined in line 44; never used

Defined variables

rcsid defined in line 19; never used
Last modified: 1999-06-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 645
Valid CSS Valid XHTML 1.0 Strict