/[pkg-mixmaster]/branches/mixmaster_2_9_STABLE/Mix/Src/mix.c
ViewVC logotype

Diff of /branches/mixmaster_2_9_STABLE/Mix/Src/mix.c

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

revision 326 by rabbi, Sat Oct 5 00:39:25 2002 UTC revision 327 by weaselp, Wed Oct 9 20:29:44 2002 UTC
# Line 6  Line 6 
6     details.     details.
7    
8     Mixmaster initialization, configuration     Mixmaster initialization, configuration
9     $Id: mix.c,v 1.11.2.2 2002/10/05 00:39:25 rabbi Exp $ */     $Id: mix.c,v 1.11.2.3 2002/10/09 20:29:44 weaselp Exp $ */
10    
11    
12  #include "mix3.h"  #include "mix3.h"
# Line 22  Line 22 
22  #include <unistd.h>  #include <unistd.h>
23  #include <pwd.h>  #include <pwd.h>
24  #include <sys/utsname.h>  #include <sys/utsname.h>
25  #else  #else /* end of POSIX */
26  #include <io.h>  #include <io.h>
27  #include <direct.h>  #include <direct.h>
28  #endif  #endif /* else if not POSIX */
29  #ifdef WIN32  #ifdef WIN32
30  #include <windows.h>  #include <windows.h>
31  #endif  #endif /* WIN32 */
32  #include <assert.h>  #include <assert.h>
33  #include "menu.h"  #include "menu.h"
34    
# Line 83  char POOLDIR[PATHMAX]; Line 83  char POOLDIR[PATHMAX];
83  /* programs */  /* programs */
84  #ifdef WIN32  #ifdef WIN32
85  char SENDMAIL[LINELEN] = "outfile";  char SENDMAIL[LINELEN] = "outfile";
86  #else  #else /* end of WIN32 */
87  char SENDMAIL[LINELEN] = "/usr/lib/sendmail -t";  char SENDMAIL[LINELEN] = "/usr/lib/sendmail -t";
88  #endif  #endif /* else if not WIN32 */
89  char SENDANONMAIL[LINELEN];  char SENDANONMAIL[LINELEN];
90  char NEWS[LINELEN];  char NEWS[LINELEN];
91  char TYPE1[LINELEN];  char TYPE1[LINELEN];
# Line 109  int POP3DEL = 0; Line 109  int POP3DEL = 0;
109  int POP3SIZELIMIT = 0;  int POP3SIZELIMIT = 0;
110  long POP3TIME = 60 * 60;  long POP3TIME = 60 * 60;
111    
112  #endif  #endif /* USE_SOCK */
113    
114  char SHORTNAME[LINELEN];  char SHORTNAME[LINELEN];
115    
# Line 154  char PGPPUBRING[PATHMAX]; Line 154  char PGPPUBRING[PATHMAX];
154  char PGPSECRING[PATHMAX];  char PGPSECRING[PATHMAX];
155  #ifdef COMPILEDPASS  #ifdef COMPILEDPASS
156  char PASSPHRASE[LINELEN] = COMPILEDPASS;  char PASSPHRASE[LINELEN] = COMPILEDPASS;
157  #else  #else /* end of COMPILEDPASS */
158  char PASSPHRASE[LINELEN] = "";  char PASSPHRASE[LINELEN] = "";
159  #endif  #endif /* else if not COMPILEDPASS */
160  char MAILBOX[PATHMAX] = "mbox";  char MAILBOX[PATHMAX] = "mbox";
161  char MAILABUSE[PATHMAX];  char MAILABUSE[PATHMAX];
162  char MAILBLOCK[PATHMAX];  char MAILBLOCK[PATHMAX];
# Line 164  char MAILBLOCK[PATHMAX]; Line 164  char MAILBLOCK[PATHMAX];
164  char MAILUSAGE[PATHMAX] = "nul:";  char MAILUSAGE[PATHMAX] = "nul:";
165  char MAILANON[PATHMAX] = "nul:";  char MAILANON[PATHMAX] = "nul:";
166  char MAILERROR[PATHMAX] = "nul:";  char MAILERROR[PATHMAX] = "nul:";
167  #else  #else /* end of WIN32 */
168  char MAILUSAGE[PATHMAX] = "/dev/null";  char MAILUSAGE[PATHMAX] = "/dev/null";
169  char MAILANON[PATHMAX] = "/dev/null";  char MAILANON[PATHMAX] = "/dev/null";
170  char MAILERROR[PATHMAX] = "/dev/null";  char MAILERROR[PATHMAX] = "/dev/null";
171  #endif  #endif /* else if not WIN32 */
172  char MAILBOUNCE[PATHMAX];  char MAILBOUNCE[PATHMAX];
173    
174  #if defined(S_IFDIR) && !defined(S_ISDIR)  #if defined(S_IFDIR) && !defined(S_ISDIR)
175  #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)  #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
176  #endif  #endif /* defined(S_IFDIR) && !defined(S_ISDIR) */
177    
178  static int mixdir(char *d, int create)  static int mixdir(char *d, int create)
179  {  {
# Line 189  static int mixdir(char *d, int create) Line 189  static int mixdir(char *d, int create)
189      if (create) {      if (create) {
190  #ifndef POSIX  #ifndef POSIX
191        err = mkdir(MIXDIR);        err = mkdir(MIXDIR);
192  #else  #else /* end of not POSIX */
193        err = mkdir(MIXDIR, S_IRWXU);        err = mkdir(MIXDIR, S_IRWXU);
194  #endif  #endif /* else if POSIX */
195        if (err == 0)        if (err == 0)
196          errlog(NOTICE, "Creating directory %s.\n", MIXDIR);          errlog(NOTICE, "Creating directory %s.\n", MIXDIR);
197      } else      } else
# Line 210  void whoami(char *addr, char *defaultnam Line 210  void whoami(char *addr, char *defaultnam
210  #if defined(HAVE_GETDOMAINNAME) || (defined(HAVE_GETHOSTNAME) && ! defined(HAVE_UNAME))  #if defined(HAVE_GETDOMAINNAME) || (defined(HAVE_GETHOSTNAME) && ! defined(HAVE_UNAME))
211    char line[LINELEN];    char line[LINELEN];
212    
213  #endif  #endif /* defined(HAVE_GETDOMAINNAME) || [...] */
214  #ifdef HAVE_UNAME  #ifdef HAVE_UNAME
215    struct utsname uts;    struct utsname uts;
216    
217  #endif  #endif /* HAVE_UNAME */
218  #ifdef POSIX  #ifdef POSIX
219    p = getlogin();    p = getlogin();
220  #endif  #endif /* POSIX */
221    if (p == NULL)    if (p == NULL)
222      strcpy(addr, defaultname);      strcpy(addr, defaultname);
223    else    else
# Line 227  void whoami(char *addr, char *defaultnam Line 227  void whoami(char *addr, char *defaultnam
227  #ifdef HAVE_UNAME  #ifdef HAVE_UNAME
228    if (uname(&uts) != -1)    if (uname(&uts) != -1)
229      strcatn(addr, uts.nodename, LINELEN);      strcatn(addr, uts.nodename, LINELEN);
230  #elif defined(HAVE_GETHOSTNAME)  #elif defined(HAVE_GETHOSTNAME) /* end of HAVE_UNAME */
231    if (gethostname(line, LINELEN) == 0)    if (gethostname(line, LINELEN) == 0)
232      strcatn(addr, line, LINELEN);      strcatn(addr, line, LINELEN);
233  #endif  #endif /* defined(HAVE_GETHOSTNAME) */
234    if (addr[strlen(addr) - 1] == '@')    if (addr[strlen(addr) - 1] == '@')
235      strcatn(addr, SHORTNAME, LINELEN);      strcatn(addr, SHORTNAME, LINELEN);
236    
# Line 240  void whoami(char *addr, char *defaultnam Line 240  void whoami(char *addr, char *defaultnam
240        strcatn(addr, ".", LINELEN);        strcatn(addr, ".", LINELEN);
241        strcatn(addr, line, LINELEN);        strcatn(addr, line, LINELEN);
242      }      }
243  #endif  #endif /* HAVE_GETDOMAINNAME */
244    }    }
245  }  }
246    
# Line 349  int mix_configline(char *line) Line 349  int mix_configline(char *line)
349            read_conf(SMTPUSERNAME) || read_conf(SMTPPASSWORD) ||            read_conf(SMTPUSERNAME) || read_conf(SMTPPASSWORD) ||
350  #ifdef USE_SOCK  #ifdef USE_SOCK
351            read_conf(HELONAME) || read_conf(ENVFROM) ||            read_conf(HELONAME) || read_conf(ENVFROM) ||
352  #endif  #endif /* USE_SOCK */
353            read_conf(SENDMAIL) || read_conf(SENDANONMAIL) ||            read_conf(SENDMAIL) || read_conf(SENDANONMAIL) ||
354            read_conf_i(REMAIL) || read_conf_i(MIX) ||            read_conf_i(REMAIL) || read_conf_i(MIX) ||
355            read_conf_i(PGP) || read_conf_i(UNENCRYPTED) ||            read_conf_i(PGP) || read_conf_i(UNENCRYPTED) ||
# Line 373  int mix_configline(char *line) Line 373  int mix_configline(char *line)
373  #ifdef USE_SOCK  #ifdef USE_SOCK
374            read_conf_i(POP3DEL) || read_conf_i(POP3SIZELIMIT) ||            read_conf_i(POP3DEL) || read_conf_i(POP3SIZELIMIT) ||
375            read_conf_t(POP3TIME) ||            read_conf_t(POP3TIME) ||
376  #endif  #endif /* USE_SOCK */
377            read_conf(MAILBOX) || read_conf(MAILABUSE) ||            read_conf(MAILBOX) || read_conf(MAILABUSE) ||
378            read_conf(MAILBLOCK) || read_conf(MAILUSAGE) ||            read_conf(MAILBLOCK) || read_conf(MAILUSAGE) ||
379            read_conf(MAILANON) || read_conf(MAILERROR) ||            read_conf(MAILANON) || read_conf(MAILERROR) ||
# Line 408  int mix_config(void) Line 408  int mix_config(void)
408    int err = -1;    int err = -1;
409  #ifdef POSIX  #ifdef POSIX
410    struct passwd *pw;    struct passwd *pw;
411  #endif  #endif /* POSIX */
412    struct stat buf;    struct stat buf;
413  #ifdef HAVE_UNAME  #ifdef HAVE_UNAME
414    struct utsname uts;    struct utsname uts;
415  #endif  #endif /* HAVE_UNAME */
416  #ifdef WIN32  #ifdef WIN32
417    HKEY regsw, reg, regpgp;    HKEY regsw, reg, regpgp;
418    DWORD type, len;    DWORD type, len;
419    int rkey = 0;    int rkey = 0;
420  #endif  #endif /* WIN32 */
421    
422  #ifdef POSIX  #ifdef POSIX
423    pw = getpwuid(getuid());    pw = getpwuid(getuid());
424  #endif  #endif /* POSIX */
425    
426    if (MIXDIR[0])                /* if set by main() */    if (MIXDIR[0])                /* if set by main() */
427      err = mixdir(MIXDIR, 1);      err = mixdir(MIXDIR, 1);
# Line 435  int mix_config(void) Line 435  int mix_config(void)
435        err = mixdir(line, 1);        err = mixdir(line, 1);
436      RegCloseKey(reg);      RegCloseKey(reg);
437    }    }
438  #endif  #endif /* WIN32 */
439    
440    if (err == -1 && (d = getenv("MIXPATH")) != NULL)    if (err == -1 && (d = getenv("MIXPATH")) != NULL)
441      err = mixdir(d, 1);      err = mixdir(d, 1);
# Line 443  int mix_config(void) Line 443  int mix_config(void)
443  #ifdef SPOOL  #ifdef SPOOL
444    if (err == -1 && strlen(SPOOL) > 0)    if (err == -1 && strlen(SPOOL) > 0)
445      err = mixdir(SPOOL, 0);      err = mixdir(SPOOL, 0);
446  #endif  #endif /* SPOOL */
447    
448  #ifdef POSIX  #ifdef POSIX
449    if (err == -1 && pw != NULL) {    if (err == -1 && pw != NULL) {
# Line 454  int mix_config(void) Line 454  int mix_config(void)
454      strcatn(line, HOMEMIXDIR, PATHMAX);      strcatn(line, HOMEMIXDIR, PATHMAX);
455      err = mixdir(line, 1);      err = mixdir(line, 1);
456    }    }
457  #endif  #endif /* POSIX */
458    
459    if (err == -1) {    if (err == -1) {
460      getcwd(MIXDIR, PATHMAX);      getcwd(MIXDIR, PATHMAX);
# Line 469  int mix_config(void) Line 469  int mix_config(void)
469          mix_configline(line);          mix_configline(line);
470      fclose(f);      fclose(f);
471    }    }
472  #endif  #endif /* GLOBALMIXCONF */
473    f = mix_openfile(MIXCONF, "r");    f = mix_openfile(MIXCONF, "r");
474    if (f != NULL) {    if (f != NULL) {
475      while (fgets(line, LINELEN, f) != NULL)      while (fgets(line, LINELEN, f) != NULL)
# Line 502  int mix_config(void) Line 502  int mix_config(void)
502  #ifdef HAVE_UNAME  #ifdef HAVE_UNAME
503    if (SHORTNAME[0] == '\0' && uname(&uts) != -1)    if (SHORTNAME[0] == '\0' && uname(&uts) != -1)
504      strncpy(SHORTNAME, uts.nodename, LINELEN);      strncpy(SHORTNAME, uts.nodename, LINELEN);
505  #elif defined(HAVE_GETHOSTNAME)  #elif defined(HAVE_GETHOSTNAME) /* end of HAVE_UNAME */
506    if (SHORTNAME[0] == '\0')    if (SHORTNAME[0] == '\0')
507      gethostname(SHORTNAME, LINELEN);      gethostname(SHORTNAME, LINELEN);
508  #endif  #endif /* defined(HAVE_GETHOSTNAME) */
509    if (SHORTNAME[0] == '\0')    if (SHORTNAME[0] == '\0')
510      strcpy(SHORTNAME, "unknown");      strcpy(SHORTNAME, "unknown");
511    
# Line 515  int mix_config(void) Line 515  int mix_config(void)
515  #ifdef HAVE_GECOS  #ifdef HAVE_GECOS
516    if (NAME[0] == '\0' && pw != NULL)    if (NAME[0] == '\0' && pw != NULL)
517      strcatn(NAME, pw->pw_gecos, sizeof(NAME));      strcatn(NAME, pw->pw_gecos, sizeof(NAME));
518  #endif  #endif /* HAVE_GECOS */
519    
520    if (REMAILERADDR[0] == '\0')    if (REMAILERADDR[0] == '\0')
521      strncpy(REMAILERADDR, ADDRESS, LINELEN);      strncpy(REMAILERADDR, ADDRESS, LINELEN);
# Line 541  int mix_config(void) Line 541  int mix_config(void)
541  #ifndef USE_PGP  #ifndef USE_PGP
542    if (TYPE1[0] == '\0')    if (TYPE1[0] == '\0')
543      PGP = 0;      PGP = 0;
544  #endif  #endif /* not USE_PGP */
545  #ifndef USE_RSA  #ifndef USE_RSA
546    MIX = 0;    MIX = 0;
547  #endif  #endif /* not USE_RSA */
548    
549  #ifdef WIN32  #ifdef WIN32
550    if (RegOpenKeyEx(regsw, "PGP", 0, KEY_ALL_ACCESS, &regpgp) == 0)    if (RegOpenKeyEx(regsw, "PGP", 0, KEY_ALL_ACCESS, &regpgp) == 0)
# Line 564  int mix_config(void) Line 564  int mix_config(void)
564    if (rkey)    if (rkey)
565      RegCloseKey(regpgp);      RegCloseKey(regpgp);
566    RegCloseKey(regsw);    RegCloseKey(regsw);
567  #endif  #endif /* WIN32 */
568    
569    if (PGPPUBRING[0] == '\0') {    if (PGPPUBRING[0] == '\0') {
570      char *d;      char *d;
# Line 608  int mix_config(void) Line 608  int mix_config(void)
608        fprintf(f, "COMPLAINTS    %s\n", COMPLAINTS);        fprintf(f, "COMPLAINTS    %s\n", COMPLAINTS);
609        fclose(f);        fclose(f);
610      }      }
611  #endif  #endif /* not GLOBALMIXCONF */
612      REMAIL = 0;      REMAIL = 0;
613    }    }
614    
# Line 627  int mix_init(char *mixdir) Line 627  int mix_init(char *mixdir)
627      mix_config();      mix_config();
628  #if defined(USE_SOCK) && defined(WIN32)  #if defined(USE_SOCK) && defined(WIN32)
629      sock_init();      sock_init();
630  #endif  #endif /* defined(USE_SOCK) && defined(WIN32) */
631      /* atexit (mix_exit); */      /* atexit (mix_exit); */
632      initialized = 1;      initialized = 1;
633    }    }
# Line 644  void mix_exit(void) Line 644  void mix_exit(void)
644    rnd_final();    rnd_final();
645  #if defined(USE_SOCK) && defined(WIN32)  #if defined(USE_SOCK) && defined(WIN32)
646    sock_exit();    sock_exit();
647  #endif  #endif /* defined(USE_SOCK) && defined(WIN32) */
648    initialized=0;    initialized=0;
649  }  }
650    
# Line 666  int mix_regular(int force) Line 666  int mix_regular(int force)
666  #ifdef USE_SOCK  #ifdef USE_SOCK
667      if (now - tpop3 >= POP3TIME)      if (now - tpop3 >= POP3TIME)
668        force |= FORCE_POP3;        force |= FORCE_POP3;
669  #endif  #endif /* USE_SOCK */
670      if (now - tdaily >= SECONDSPERDAY)      if (now - tdaily >= SECONDSPERDAY)
671        force |= FORCE_DAILY;        force |= FORCE_DAILY;
672      if (force & FORCE_POOL)      if (force & FORCE_POOL)
# Line 696  int mix_regular(int force) Line 696  int mix_regular(int force)
696  #ifdef USE_SOCK  #ifdef USE_SOCK
697    if (force & FORCE_POP3)    if (force & FORCE_POP3)
698      pop3get();      pop3get();
699  #endif  #endif /* USE_SOCK */
700    if (force & FORCE_POOL)    if (force & FORCE_POOL)
701      ret = pool_send();      ret = pool_send();
702    
# Line 755  int mix_daemon(void) Line 755  int mix_daemon(void)
755  #ifdef USE_SOCK  #ifdef USE_SOCK
756    if (POP3TIME < t)    if (POP3TIME < t)
757      t = POP3TIME;      t = POP3TIME;
758  #endif  #endif /* USE_SOCK */
759    
760    for(;;) {    for(;;) {
761      mix_regular(0);      mix_regular(0);
# Line 767  int mix_daemon(void) Line 767  int mix_daemon(void)
767          return 0;          return 0;
768        }        }
769      } else      } else
770  #endif  #endif /* WIN32SERVICE */
771        Sleep(t * 1000);        Sleep(t * 1000);
772  #else  #else /* end of WIN32 */
773      sleep(t);      sleep(t);
774  #endif  #endif /* else if not WIN32 */
775    }    }
776  }  }
777    
# Line 834  void mix_status(char *fmt,...) Line 834  void mix_status(char *fmt,...)
834      va_start(args, fmt);      va_start(args, fmt);
835  #ifdef _MSC  #ifdef _MSC
836      _vsnprintf(statusline, sizeof(statusline) - 1, fmt, args);      _vsnprintf(statusline, sizeof(statusline) - 1, fmt, args);
837  #else  #else /* end of _MSC */
838      vsnprintf(statusline, sizeof(statusline) - 1, fmt, args);      vsnprintf(statusline, sizeof(statusline) - 1, fmt, args);
839  #endif  #endif /* else if not _MSC */
840      va_end(args);      va_end(args);
841    }    }
842  #ifdef USE_NCURSES  #ifdef USE_NCURSES
# Line 845  void mix_status(char *fmt,...) Line 845  void mix_status(char *fmt,...)
845      printw("%s", statusline);      printw("%s", statusline);
846      refresh();      refresh();
847    } else    } else
848  #endif  #endif /* USE_NCURSES */
849    {    {
850      fprintf(stderr, "%s", statusline);      fprintf(stderr, "%s", statusline);
851    }    }

Legend:
Removed from v.326  
changed lines
  Added in v.327

  ViewVC Help
Powered by ViewVC 1.1.5