inc.c
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· C语言 代码 · 共 1,510 行 · 第 1/3 页
C
1,510 行
msgnum++; if (file) { /* -packf option. */ (void) fseek (x400_pf, 0L, 1); x400_pos = ftell (x400_pf); x400_size = 0; (void) fwrite (mmdlm1, 1, strlen (mmdlm1), x400_pf); x400_start = ftell (x400_pf); if (x400d_retr (i, x400_pack) == NOTOK) { fprintf (stderr, "%s: %s\n", invo_name, x400_response); if (all_src == 0) done (1); continue; } (void) fseek (x400_pf, 0L, 1); x400_stop = ftell (x400_pf); if (fflush (x400_pf)) { fprintf (stderr, "write error on %s\n", file); if (all_src == 0) done (1); continue; } (void) fseek (x400_pf, x400_start, 0); } else { cp = getcpy (m_name (msgnum)); if ((x400_pf = fopen (cp, "w+")) == NULL) { fprintf (stderr, "unable to write %s\n", cp); if (all_src == 0) done (1); continue; } (void) chmod (cp, m_gmprot ()); x400_start = x400_stop = 0L; if (x400d_retr (i, x400_action) == NOTOK) { fprintf (stderr, "%s: %s\n", invo_name, x400_response); if (all_src == 0) done (1); continue; } if (fflush (x400_pf)) { fprintf (stderr, "write error on %s\n", cp); if (all_src == 0) done (1); continue; } (void) fseek (x400_pf, 0L, 0); } switch (x400_p = scan (x400_pf, msgnum, 0, nfs, width, file ? 0 : msgnum == mp -> hghmsg + 1 && chgflag && !cur_updtd, 0, x400_stop - x400_start, noisy)) { case SCNEOF: fprintf (stderr, "%*d empty\n", DMAXFOLDER, msgnum); break; case SCNERR: case SCNNUM: break; case SCNMSG: case SCNENC: default: if (aud) fputs (scanl, aud);#ifdef MHE if (mhe) fputs (scanl, mhe);#endif MHE if (noisy) (void) fflush (stdout); if (!file) { mp -> msgstats[msgnum] = EXISTS;#ifdef TMA if (x400_p == SCNENC) { if (mp -> lowsel == 0 || msgnum < mp -> lowsel) mp -> lowsel = msgnum; if (mp -> hghsel == 0 || msgnum > mp -> hghsel) mp -> hghsel = msgnum; mp -> numsel++; mp -> msgstats[msgnum] |= SELECTED; }#endif TMA mp -> msgstats[msgnum] |= UNSEEN; mp -> msgflags |= SEQMOD; } break; } if (file) { /* -packf option. */ (void) fseek (x400_pf, x400_stop, 0); (void) fwrite (mmdlm2, 1, strlen (mmdlm2), x400_pf); if (fflush (x400_pf)) { fprintf (stderr, "write error on %s\n", file); if (all_src == 0) done (1); continue; } (void) map_write (file, x400_pd, 0, 0L, x400_start, x400_stop, x400_pos, x400_size, noisy); } else { (void) fclose (x400_pf); free (cp); } if (trnflag && x400d_dele (i) == NOTOK) { fprintf (stderr, "%s: %s\n", invo_name, x400_response); if (all_src == 0) done (1); continue; } } if (x400d_quit () == NOTOK) { fprintf (stderr, "%s: %s\n", invo_name, x400_response); if (all_src == 0) done (1); continue; } if (file) { /* -packf option. */ (void) mbx_close (file, x400_pd); x400_pd = NOTOK; } }#endif X400 if (this_src == FILESRC) { m_unknown (in); /* the MAGIC invocation... */ hghnum = msgnum = mp -> hghmsg; for (;;) { if (msgnum >= mp -> hghoff) if ((mp = m_remsg (mp, 0, mp -> hghoff + MAXFOLDER)) == NULL) { if (all_src == 0) adios (NULLCP, "unable to allocate folder storage"); continue; } switch (i = scan (in, msgnum + 1, msgnum + 1, nfs, width, msgnum == hghnum && chgflag && !cur_updtd, 0, 0L, noisy)) { case SCNEOF: break; case SCNERR: if (aud) fputs ("inc aborted!\n", aud); adios (NULLCP, "aborted!"); case SCNNUM: adios (NULLCP, "more than %d messages in folder %s, %s not zero'd", MAXFOLDER, folder, newmail); default: adios (NULLCP, "scan() botch (%d)", i); case SCNMSG: case SCNENC: if (aud) fputs (scanl, aud);#ifdef MHE if (mhe) fputs (scanl, mhe);#endif MHE if (noisy) (void) fflush (stdout); msgnum++, mp -> hghmsg++; mp -> msgstats[msgnum] = EXISTS;#ifdef TMA if (i == SCNENC) { if (mp -> lowsel == 0 || mp -> lowsel > msgnum) mp -> lowsel = msgnum; if (mp -> hghsel == 0 || mp -> hghsel < msgnum) mp -> hghsel = msgnum; mp -> numsel++; mp -> msgstats[msgnum] |= SELECTED; }#endif TMA mp -> msgstats[msgnum] |= UNSEEN; mp -> msgflags |= SEQMOD; continue; } break; } } if (aud) (void) fclose (aud);#ifdef MHE if (mhe) (void) fclose (mhe);#endif MHE if (noisy) (void) fflush (stdout);#ifdef POP if (pophost && file) done (0);#endif POP#ifdef X400 if (x400host && file) done (0);#endif X400/* */ if (this_src == FILESRC) { if (trnflag) { if (stat (newmail, &st) != NOTOK && s1.st_mtime != st.st_mtime) advise (NULLCP, "new messages have arrived!\007"); else { if ((i = creat (newmail, 0600)) != NOTOK) (void) close (i); else admonish (newmail, "error zero'ing"); (void) unlink (map_name (newmail)); } } else if (noisy) fprintf (stderr, "%s not zero'd\n", newmail); } if (msgnum == hghnum && done_inc != 0) admonish (NULLCP, "no messages incorporated"); else { if (cur_updtd == 0 && msgnum != hghnum) { cur_updtd++; m_replace (pfolder, folder); if (chgflag) mp -> curmsg = hghnum + 1; mp -> hghmsg = msgnum; if (mp -> lowmsg == 0) mp -> lowmsg = 1; if (chgflag) /* sigh... */ m_setcur (mp, mp -> curmsg); } } (void) setruid (0); (void) seteuid (real_uid); if ( this_src == FILESRC ) { if (locked) (void) lkfclose (in, newmail); else (void) fclose (in); } m_setvis (mp, 0); m_sync (mp); (void) seteuid (0); (void) setruid (real_uid); m_update ();#ifdef TMA if (decflag && mp -> numsel > 0) { if (noisy) { printf ("\nIncorporating encrypted mail into %s...\n\n", folder); (void) fflush (stdout); } tmastart (0); for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++) if (mp -> msgstats[msgnum] & SELECTED && decipher (msgnum) == OK) { if ((in = fopen (cp = m_name (msgnum), "r")) == NULL) { admonish (cp, "unable to open message"); free (cp); continue; } switch (scan (in, msgnum, 0, nfs, width, msgnum == mp -> curmsg, 0, fstat (fileno (in), &st) != NOTOK ? (long) st.st_size : 0L, noisy)) { case SCNEOF: printf ("%*d empty\n", DMAXFOLDER, msgnum); break; default: break; } (void) fclose (in); free (cp); } tmastop (); if (noisy) (void) fflush (stdout); }#endif TMA } done (0); }/* */#if defined (POP) || defined (X400)void done (status)int status;{ if (file && pd != NOTOK) (void) mbx_close (file, pd); exit (status);}#endif defined (POP) || defined (X400)/* */#ifdef MFget_uucp_mail () { int child_id; char buffer[BUFSIZ]; struct stat st; (void) sprintf (buffer, "%s/%s", UUCPDIR, UUCPFIL); if (stat (buffer, &st) == NOTOK || st.st_size == 0) return; switch (child_id = vfork ()) { case NOTOK: admonish ("fork", "unable to"); break; case OK: execlp (umincproc, r1bindex (umincproc, '/'), NULLCP); fprintf (stderr, "unable to exec "); perror (umincproc); _exit (-1); default: (void) pidXwait (child_id, umincproc); break; }}#endif MF/* */#ifdef POPstatic int pop_action (s)register char *s;{ fprintf (pf, "%s\n", s); stop += strlen (s) + 1;}static int pop_pack (s)register char *s;{ register int j; char buffer[BUFSIZ]; (void) sprintf (buffer, "%s\n", s); for (j = 0; (j = stringdex (mmdlm1, buffer)) >= 0; buffer[j]++) continue; for (j = 0; (j = stringdex (mmdlm2, buffer)) >= 0; buffer[j]++) continue; fputs (buffer, pf); size += strlen (buffer) + 1;}static int map_count () { int md; char *cp; struct drop d; struct stat st; if (stat (file, &st) == NOTOK) return 0; if ((md = open (cp = map_name (file), 0)) == NOTOK || map_chk (cp, md, &d, (long) st.st_size, 1)) { if (md != NOTOK) (void) close (md); return 0; } (void) close (md); return (d.d_id);}#endif POP#ifdef X400static int x400_action (s)register char *s;{ fprintf (x400_pf, "%s\n", s); x400_stop += strlen (s) + 1;}static int x400_pack (s)register char *s;{ register int j; char buffer[BUFSIZ]; (void) sprintf (buffer, "%s\n", s); for (j = 0; (j = stringdex (mmdlm1, buffer)) >= 0; buffer[j]++) continue; for (j = 0; (j = stringdex (mmdlm2, buffer)) >= 0; buffer[j]++) continue; fputs (buffer, x400_pf); x400_size += strlen (buffer) + 1;}static int x400_map_count () { int md; char *cp; struct drop d; struct stat st; if (stat (file, &st) == NOTOK) return 0; if ((md = open (cp = map_name (file), 0)) == NOTOK || map_chk (cp, md, &d, (long) st.st_size, 1)) { if (md != NOTOK) (void) close (md); return 0; } (void) close (md); return (d.d_id);}#endif X400/* PDW: get_source_arg - gets the argument following "-source" flag */get_source_arg (cp) char *cp;{ int numents, loop = 0; numents = sizeof (srctbl) / sizeof (srctbl[1]); for (loop = 0; loop < numents; loop++) if (strcmp (srctbl[loop].name, cp) == 0) break; return ((loop == numents) ? NONESRC : srctbl[loop].bitflag);}/* PDW: old version : *//*.sbttl onhup(), onintr(), onquit(), onterm() *//* Function: * * onxxxx * * Function Description: * * Routines to process termination signals. * ie. Interrupt control flow for termination processing. * (control-c, etc..) * * Arguments: * * none * * Return values: * * none * * Side Effects: * * The existing "lock" file is removed.. *//*onhup(){ (void) signal(SIGHUP, SIG_IGN); done (lkfclose (in, newmail));}onintr(){ (void) signal(SIGINT, SIG_IGN); done (lkfclose (in, newmail));}onquit(){ (void) signal(SIGQUIT, SIG_IGN); done (lkfclose (in, newmail));}onterm(){ (void) signal(SIGTERM, SIG_IGN); done (lkfclose (in, newmail));}*//*E onxxxx() */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?