Changeset 1198 for trunk/src/kash/mail.c


Ignore:
Timestamp:
Oct 6, 2007, 11:19:19 PM (18 years ago)
Author:
bird
Message:

moving globals into shinstance...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/mail.c

    r809 r1198  
    5858#include "error.h"
    5959#include "mail.h"
     60#include "shinstance.h"
    6061
    6162
    62 #define MAXMBOXES 10
     63/*#define MAXMBOXES 10*/
    6364
    6465
    65 STATIC int nmboxes;                     /* number of mailboxes */
    66 STATIC time_t mailtime[MAXMBOXES];      /* times of mailboxes */
     66/*STATIC int nmboxes;                   /* number of mailboxes */
     67/*STATIC time_t mailtime[MAXMBOXES];*/  /* times of mailboxes */
    6768
    6869
     
    7576
    7677void
    77 chkmail(int silent)
     78chkmail(shinstance *psh, int silent)
    7879{
    7980        int i;
     
    8586
    8687        if (silent)
    87                 nmboxes = 10;
    88         if (nmboxes == 0)
     88                psh->nmboxes = 10;
     89        if (psh->nmboxes == 0)
    8990                return;
    90         setstackmark(&smark);
    91         mpath = mpathset() ? mpathval() : mailval();
    92         for (i = 0 ; i < nmboxes ; i++) {
    93                 p = padvance(&mpath, nullstr);
     91        setstackmark(psh, &smark);
     92        mpath = mpathset(psh) ? mpathval(psh) : mailval(psh);
     93        for (i = 0 ; i < psh->nmboxes ; i++) {
     94                p = padvance(psh, &mpath, nullstr);
    9495                if (p == NULL)
    9596                        break;
     
    101102                q[-1] = '\0';                   /* delete trailing '/' */
    102103#ifdef notdef /* this is what the System V shell claims to do (it lies) */
    103                 if (stat(p, &statb) < 0)
     104                if (shfile_stat(&psh->fdtab, p, &statb) < 0)
    104105                        statb.st_mtime = 0;
    105                 if (statb.st_mtime > mailtime[i] && ! silent) {
    106                         out2str(pathopt ? pathopt : "you have mail");
    107                         out2c('\n');
     106                if (statb.st_mtime > psh->mailtime[i] && ! silent) {
     107                        out2str(psh, psh->pathopt ? psh->pathopt : "you have mail");
     108                        out2c(psh, '\n');
    108109                }
    109                 mailtime[i] = statb.st_mtime;
     110                psh->mailtime[i] = statb.st_mtime;
    110111#else /* this is what it should do */
    111                 if (stat(p, &statb) < 0)
     112                if (shfile_stat(&psh->fdtab, p, &statb) < 0)
    112113                        statb.st_size = 0;
    113                 if (statb.st_size > mailtime[i] && ! silent) {
    114                         out2str(pathopt ? pathopt : "you have mail");
    115                         out2c('\n');
     114                if (statb.st_size > psh->mailtime[i] && ! silent) {
     115                        out2str(psh, psh->pathopt ? psh->pathopt : "you have mail");
     116                        out2c(psh, '\n');
    116117                }
    117                 mailtime[i] = statb.st_size;
     118                psh->mailtime[i] = statb.st_size;
    118119#endif
    119120        }
    120         nmboxes = i;
    121         popstackmark(&smark);
     121        psh->nmboxes = i;
     122        popstackmark(psh, &smark);
    122123}
Note: See TracChangeset for help on using the changeset viewer.