]>
diplodocus.org Git - nmh/blob - uip/inc.c
3 * inc.c -- incorporate messages from a maildrop into a folder
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
11 /* Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs)
12 * Added hpux hacks to set and reset gid to be "mail" as needed. The reset
13 * is necessary so inc'ed mail is the group of the inc'er, rather than
14 * "mail". We setgid to egid only when [un]locking the mail file. This
15 * is also a major security precaution which will not be explained here.
17 * Fri Feb 7 16:04:57 PST 1992 John Romine <bug-mh@ics.uci.edu>
18 * NB: I'm not 100% sure that this setgid stuff is secure even now.
20 * See the *GROUPPRIVS() macros later. I'm reasonably happy with the setgid
21 * attribute. Running setuid root is probably not a terribly good idea, though.
22 * -- Peter Maydell <pmaydell@chiark.greenend.org.uk>, 04/1998
24 * Peter Maydell's patch slightly modified for nmh 0.28-pre2.
25 * Ruud de Rooij <ruud@debian.org> Wed, 22 Jul 1998 13:24:22 +0200
32 #include <h/dropsbr.h>
34 #include <h/fmt_scan.h>
35 #include <h/scansbr.h>
36 #include <h/signals.h>
41 # define SASLminc(a) (a)
43 # define SASLminc(a) 0
46 #define INC_SWITCHES \
47 X("audit audit-file", 0, AUDSW) \
48 X("noaudit", 0, NAUDSW) \
49 X("changecur", 0, CHGSW) \
50 X("nochangecur", 0, NCHGSW) \
51 X("file name", 0, FILESW) \
52 X("form formatfile", 0, FORMSW) \
53 X("format string", 5, FMTSW) \
54 X("host hostname", 0, HOSTSW) \
55 X("user username", 0, USERSW) \
56 X("pack file", 0, PACKSW) \
57 X("nopack", 0, NPACKSW) \
58 X("port name/number", 0, PORTSW) \
59 X("silent", 0, SILSW) \
60 X("nosilent", 0, NSILSW) \
61 X("truncate", 0, TRNCSW) \
62 X("notruncate", 0, NTRNCSW) \
63 X("width columns", 0, WIDTHSW) \
64 X("version", 0, VERSIONSW) \
65 X("help", 0, HELPSW) \
66 X("snoop", -5, SNOOPSW) \
67 X("sasl", SASLminc(-4), SASLSW) \
68 X("nosasl", SASLminc(-6), NOSASLSW) \
69 X("saslmech", SASLminc(-8), SASLMECHSW) \
70 X("proxy command", 0, PROXYSW) \
72 #define X(sw, minchars, id) id,
73 DEFINE_SWITCH_ENUM(INC
);
76 #define X(sw, minchars, id) { sw, minchars, id },
77 DEFINE_SWITCH_ARRAY(INC
, switches
);
81 * flags for the mail source
87 static struct Maildir_entry
{
91 static int num_maildir_entries
= 0;
94 extern char response
[];
99 static int mbx_style
= MMDF_FORMAT
;
100 static int pd
= NOTOK
;
105 static char *packfile
= NULL
;
106 static FILE *pf
= NULL
;
108 /* This is an attempt to simplify things by putting all the
109 * privilege ops into macros.
110 * *GROUPPRIVS() is related to handling the setgid MAIL property,
111 * and only applies if MAILGROUP is defined.
112 * Basically, SAVEGROUPPRIVS() is called right at the top of main()
113 * to initialise things, and then DROPGROUPPRIVS() and GETGROUPPRIVS()
114 * do the obvious thing.
116 * There's probably a better implementation if we're allowed to use
117 * BSD-style setreuid() rather than using POSIX saved-ids.
118 * Anyway, if you're euid root it's a bit pointless to drop the group
121 * I'm pretty happy that the security is good provided we aren't setuid root.
122 * The only things we trust with group=mail privilege are lkfopen()
127 * For setting and returning to "mail" gid
130 static int return_gid
;
131 #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS()
132 #define DROPGROUPPRIVS() setgid(getgid())
133 #define GETGROUPPRIVS() setgid(return_gid)
134 #define SAVEGROUPPRIVS() return_gid = getegid()
136 /* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */
137 #define TRYDROPGROUPPRIVS()
138 #define DROPGROUPPRIVS()
139 #define GETGROUPPRIVS()
140 #define SAVEGROUPPRIVS()
141 #endif /* not MAILGROUP */
143 /* these variables have to be globals so that done() can correctly clean up the lockfile */
144 static int locked
= 0;
145 static char *newmail
;
151 char *map_name(char *);
153 static void inc_done(int) NORETURN
;
154 static int pop_action(char *);
155 static int pop_pack(char *);
156 static int map_count(void);
159 maildir_srt(const void *va
, const void *vb
)
161 const struct Maildir_entry
*a
= va
, *b
= vb
;
162 if (a
->mtime
> b
->mtime
)
164 else if (a
->mtime
< b
->mtime
)
171 main (int argc
, char **argv
)
173 int chgflag
= 1, trnflag
= 1;
174 int noisy
= 1, width
= -1;
175 int hghnum
= 0, msgnum
= 0;
177 int incerr
= 0; /* <0 if inc hits an error which means it should not truncate mailspool */
178 char *cp
, *maildir
= NULL
, *folder
= NULL
;
179 char *format
= NULL
, *form
= NULL
;
180 char *host
= NULL
, *port
= NULL
, *user
= NULL
, *proxy
= NULL
;
181 char *audfile
= NULL
, *from
= NULL
, *saslmech
= NULL
;
182 char buf
[BUFSIZ
], **argp
, *nfs
, **arguments
;
183 struct msgs
*mp
= NULL
;
186 char b
[PATH_MAX
+ 1];
187 char *maildir_copy
= NULL
; /* copy of mail directory because the static gets overwritten */
190 char *MAILHOST_env_variable
;
194 /* absolutely the first thing we do is save our privileges,
195 * and drop them if we can.
200 if (nmh_init(argv
[0], 1)) { return 1; }
202 mts_init (invo_name
);
203 arguments
= getarguments (invo_name
, argc
, argv
, 1);
208 * use MAILHOST environment variable if present,
210 * If that fails, use the default (if any)
211 * provided by mts.conf in mts_init()
213 if ((MAILHOST_env_variable
= getenv("MAILHOST")) != NULL
)
214 pophost
= MAILHOST_env_variable
;
216 * If there is a valid "pophost" entry in mts.conf,
217 * then use it as the default host.
219 if (pophost
&& *pophost
)
222 while ((cp
= *argp
++)) {
224 switch (smatch (++cp
, switches
)) {
226 ambigsw (cp
, switches
);
229 adios (NULL
, "-%s unknown", cp
);
232 snprintf (buf
, sizeof(buf
), "%s [+folder] [switches]", invo_name
);
233 print_help (buf
, switches
, 1);
236 print_version(invo_name
);
240 if (!(cp
= *argp
++) || *cp
== '-')
241 adios (NULL
, "missing argument to %s", argp
[-2]);
242 audfile
= getcpy (m_maildir (cp
));
256 * The flag `trnflag' has the value:
258 * 2 if -truncate is given
259 * 1 by default (truncating is default)
260 * 0 if -notruncate is given
270 if (!(cp
= *argp
++) || *cp
== '-')
271 adios (NULL
, "missing argument to %s", argp
[-2]);
272 from
= path (cp
, TFILE
);
275 * If the truncate file is in default state,
276 * change to not truncate.
290 if (!(form
= *argp
++) || *form
== '-')
291 adios (NULL
, "missing argument to %s", argp
[-2]);
295 if (!(format
= *argp
++) || *format
== '-')
296 adios (NULL
, "missing argument to %s", argp
[-2]);
301 if (!(cp
= *argp
++) || *cp
== '-')
302 adios (NULL
, "missing argument to %s", argp
[-2]);
307 if (!(host
= *argp
++) || *host
== '-')
308 adios (NULL
, "missing argument to %s", argp
[-2]);
312 if (!(port
= *argp
++) || *port
== '-')
313 adios (NULL
, "missing argument to %s", argp
[-2]);
317 if (!(user
= *argp
++) || *user
== '-')
318 adios (NULL
, "missing argument to %s", argp
[-2]);
322 if (!(packfile
= *argp
++) || *packfile
== '-')
323 adios (NULL
, "missing argument to %s", argp
[-2]);
341 if (!(saslmech
= *argp
++) || *saslmech
== '-')
342 adios (NULL
, "missing argument to %s", argp
[-2]);
345 if (!(proxy
= *argp
++) || *proxy
== '-')
346 adios (NULL
, "missing argument to %s", argp
[-2]);
350 if (*cp
== '+' || *cp
== '@') {
352 adios (NULL
, "only one folder at a time!");
354 folder
= pluspath (cp
);
356 adios (NULL
, "usage: %s [+folder] [switches]", invo_name
);
360 /* NOTE: above this point you should use TRYDROPGROUPPRIVS(),
361 * not DROPGROUPPRIVS().
366 /* guarantee dropping group priveleges; we might not have done so earlier */
370 * Where are we getting the new mail?
380 * Are we getting the mail from
383 if (inc_type
== INC_POP
) {
384 struct nmh_creds creds
= { 0, 0, 0 };
387 * initialize POP connection
389 nmh_get_credentials (host
, user
, sasl
, &creds
);
390 if (pop_init (host
, port
, creds
.user
, creds
.password
, proxy
, snoop
,
391 sasl
, saslmech
) == NOTOK
)
392 adios (NULL
, "%s", response
);
394 /* Check if there are any messages */
395 if (pop_stat (&nmsgs
, &nbytes
) == NOTOK
)
396 adios (NULL
, "%s", response
);
400 adios (NULL
, "no mail to incorporate");
405 * We will get the mail from a file
406 * (typically the standard maildrop)
409 if (inc_type
== INC_FILE
) {
412 else if ((newmail
= getenv ("MAILDROP")) && *newmail
)
413 newmail
= m_mailpath (newmail
);
414 else if ((newmail
= context_find ("maildrop")) && *newmail
)
415 newmail
= m_mailpath (newmail
);
417 newmail
= concat (MAILDIR
, "/", MAILFIL
, NULL
);
419 if (stat (newmail
, &s1
) == NOTOK
|| s1
.st_size
== 0)
420 adios (NULL
, "no mail to incorporate");
421 if (s1
.st_mode
& S_IFDIR
) {
427 cp
= concat (newmail
, "/new", NULL
);
428 if ((md
= opendir(cp
)) == NULL
)
429 adios (NULL
, "unable to open %s", cp
);
430 while ((de
= readdir (md
)) != NULL
) {
431 if (de
->d_name
[0] == '.')
433 if (i
>= num_maildir_entries
) {
434 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
435 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
436 num_maildir_entries
= 2*i
+16;
438 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
439 if (stat(Maildir
[i
].filename
, &ms
) != 0)
440 adios (Maildir
[i
].filename
, "couldn't get delivery time");
441 Maildir
[i
].mtime
= ms
.st_mtime
;
446 cp
= concat (newmail
, "/cur", NULL
);
447 if ((md
= opendir(cp
)) == NULL
)
448 adios (NULL
, "unable to open %s", cp
);
449 while ((de
= readdir (md
)) != NULL
) {
450 if (de
->d_name
[0] == '.')
452 if (i
>= num_maildir_entries
) {
453 if ((Maildir
= realloc(Maildir
, sizeof(*Maildir
) * (2*i
+16))) == NULL
)
454 adios(NULL
, "not enough memory for %d messages", 2*i
+16);
455 num_maildir_entries
= 2*i
+16;
457 Maildir
[i
].filename
= concat (cp
, "/", de
->d_name
, NULL
);
458 if (stat(Maildir
[i
].filename
, &ms
) != 0)
459 adios (Maildir
[i
].filename
, "couldn't get delivery time");
460 Maildir
[i
].mtime
= ms
.st_mtime
;
466 adios (NULL
, "no mail to incorporate");
467 num_maildir_entries
= i
;
468 qsort (Maildir
, num_maildir_entries
, sizeof(*Maildir
), maildir_srt
);
471 if ((cp
= strdup(newmail
)) == (char *)0)
472 adios (NULL
, "error allocating memory to copy newmail");
477 /* skip the folder setup */
478 if ((inc_type
== INC_POP
) && packfile
)
481 if (!context_find ("path"))
482 free (path ("./", TFOLDER
));
484 folder
= getfolder (0);
485 maildir
= m_maildir (folder
);
487 if ((maildir_copy
= strdup(maildir
)) == (char *)0)
488 adios (maildir
, "error allocating memory to copy maildir");
490 if (!folder_exists(maildir
)) {
491 /* If the folder doesn't exist, and we're given the -silent flag,
495 create_folder(maildir
, 0, done
);
500 if (chdir (maildir
) == NOTOK
)
501 adios (maildir
, "unable to change directory to");
503 /* read folder and create message structure */
504 if (!(mp
= folder_read (folder
, 0)))
505 adios (NULL
, "unable to read folder %s", folder
);
509 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
510 if (access (newmail
, W_OK
) != NOTOK
) {
513 SIGNAL (SIGHUP
, SIG_IGN
);
514 SIGNAL (SIGINT
, SIG_IGN
);
515 SIGNAL (SIGQUIT
, SIG_IGN
);
516 SIGNAL (SIGTERM
, SIG_IGN
);
519 GETGROUPPRIVS(); /* Reset gid to lock mail file */
520 in
= lkfopenspool (newmail
, "r");
523 adios (NULL
, "unable to lock and fopen %s", newmail
);
524 fstat (fileno(in
), &s1
);
527 if ((in
= fopen (newmail
, "r")) == NULL
)
528 adios (newmail
, "unable to read");
532 /* This shouldn't be necessary but it can't hurt. */
537 if ((i
= stat (audfile
, &st
)) == NOTOK
)
538 advise (NULL
, "Creating Receive-Audit: %s", audfile
);
539 if ((aud
= fopen (audfile
, "a")) == NULL
)
540 adios (audfile
, "unable to append to");
542 chmod (audfile
, m_gmprot ());
545 fprintf (aud
, "<<inc>> %s -ms %s\n", dtimenow(0), from
);
548 fprintf (aud
, "<<inc>> %s -host %s -user %s\n", dtimenow(0),
551 fprintf (aud
, "<<inc>> %s\n", dtimenow (0));
555 /* Get new format string */
556 nfs
= new_fs (form
, format
, FORMAT
);
559 printf ("Incorporating new mail into %s...\n\n", folder
);
565 * Get the mail from a POP server
567 if (inc_type
== INC_POP
) {
570 packfile
= path (packfile
, TFILE
);
571 if (stat (packfile
, &st
) == NOTOK
) {
573 adios (packfile
, "error on file");
574 cp
= concat ("Create file \"", packfile
, "\"? ", NULL
);
575 if (noisy
&& !getanswer (cp
))
579 msgnum
= map_count ();
580 if ((pd
= mbx_open (packfile
, mbx_style
, getuid(), getgid(), m_gmprot()))
582 adios (packfile
, "unable to open");
583 if ((pf
= fdopen (pd
, "w+")) == NULL
)
584 adios (NULL
, "unable to fdopen %s", packfile
);
586 hghnum
= msgnum
= mp
->hghmsg
;
589 for (i
= 1; i
<= nmsgs
; i
++) {
590 charstring_t scanl
= NULL
;
594 fseek (pf
, 0L, SEEK_CUR
);
597 if (fwrite (mmdlm1
, 1, strlen (mmdlm1
), pf
) < strlen (mmdlm1
)) {
598 advise (mmdlm1
, "fwrite");
602 if (pop_retr (i
, pop_pack
) == NOTOK
)
603 adios (NULL
, "%s", response
);
605 fseek (pf
, 0L, SEEK_CUR
);
608 adios (packfile
, "write error on");
609 fseek (pf
, start
, SEEK_SET
);
611 cp
= getcpy (m_name (msgnum
));
612 if ((pf
= fopen (cp
, "w+")) == NULL
)
613 adios (cp
, "unable to write");
614 chmod (cp
, m_gmprot ());
617 if (pop_retr (i
, pop_action
) == NOTOK
)
618 adios (NULL
, "%s", response
);
621 adios (cp
, "write error on");
622 fseek (pf
, 0L, SEEK_SET
);
624 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
625 packfile
? 0 : msgnum
== mp
->hghmsg
+ 1 && chgflag
,
626 1, NULL
, stop
- start
, noisy
, &scanl
)) {
628 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
634 /* advise (cp, "unable to read"); already advised */
645 fputs (charstring_buffer (scanl
), aud
);
650 charstring_free (scanl
);
653 fseek (pf
, stop
, SEEK_SET
);
654 if (fwrite (mmdlm2
, 1, strlen (mmdlm2
), pf
) < strlen (mmdlm1
)) {
655 advise (mmdlm2
, "fwrite");
657 if (fflush (pf
) || ferror (pf
)) {
661 adios (packfile
, "write error on");
663 map_write (packfile
, pd
, 0, 0L, start
, stop
, pos
, size
, noisy
);
665 if (ferror(pf
) || fclose (pf
)) {
667 (void) m_unlink (cp
);
670 adios (cp
, "write error on");
675 if (trnflag
&& pop_dele (i
) == NOTOK
)
676 adios (NULL
, "%s", response
);
681 if (pop_quit () == NOTOK
)
682 adios (NULL
, "%s", response
);
684 mbx_close (packfile
, pd
);
690 * Get the mail from file (usually mail spool)
692 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
693 scan_detect_mbox_style (in
); /* the MAGIC invocation... */
694 hghnum
= msgnum
= mp
->hghmsg
;
696 charstring_t scanl
= NULL
;
698 /* create scanline for new message */
699 switch (incerr
= scan (in
, msgnum
+ 1, msgnum
+ 1, nfs
, width
,
700 msgnum
== hghnum
&& chgflag
, 1, NULL
, 0L, noisy
,
708 fputs ("inc aborted!\n", aud
);
709 advise (NULL
, "aborted!"); /* doesn't clean up locks! */
713 advise (NULL
, "BUG in %s, number out of range", invo_name
);
717 advise (NULL
, "BUG in %s, scan() botch (%d)", invo_name
, incerr
);
723 * Run the external program hook on the message.
726 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
727 (void)ext_hook("add-hook", b
, (char *)0);
730 fputs (charstring_buffer (scanl
), aud
);
737 charstring_free (scanl
);
739 /* If we get here there was some sort of error from scan(),
740 * so stop processing anything more from the spool.
744 } else if (inc_type
== INC_FILE
) { /* Maildir inbox to process */
749 hghnum
= msgnum
= mp
->hghmsg
;
750 for (i
= 0; i
< num_maildir_entries
; i
++) {
751 charstring_t scanl
= NULL
;
755 sp
= Maildir
[i
].filename
;
756 cp
= getcpy (m_name (msgnum
));
758 if (!trnflag
|| link(sp
, cp
) == -1) {
759 static char buf
[65536];
762 if ((sf
= fopen (sp
, "r")) == NULL
)
763 adios (sp
, "unable to read for copy");
764 if ((pf
= fopen (cp
, "w+")) == NULL
)
765 adios (cp
, "unable to write for copy");
766 while ((nrd
= fread(buf
, 1, sizeof(buf
), sf
)) > 0)
767 if (fwrite(buf
, 1, nrd
, pf
) != nrd
)
769 if (ferror(sf
) || fflush(pf
) || ferror(pf
)) {
771 fclose(pf
); fclose(sf
); (void) m_unlink(cp
);
773 adios(cp
, "copy error %s -> %s", sp
, cp
);
778 if (pf
== NULL
&& (pf
= fopen (cp
, "r")) == NULL
)
779 adios (cp
, "not available");
780 chmod (cp
, m_gmprot ());
782 fseek (pf
, 0L, SEEK_SET
);
783 switch (incerr
= scan (pf
, msgnum
, 0, nfs
, width
,
784 msgnum
== mp
->hghmsg
+ 1 && chgflag
,
785 1, NULL
, stop
- start
, noisy
, &scanl
)) {
787 printf ("%*d empty\n", DMAXFOLDER
, msgnum
);
793 /* advise (cp, "unable to read"); already advised */
804 * Run the external program hook on the message.
807 (void)snprintf(b
, sizeof (b
), "%s/%d", maildir_copy
, msgnum
+ 1);
808 (void)ext_hook("add-hook", b
, (char *)0);
811 fputs (charstring_buffer (scanl
), aud
);
816 charstring_free (scanl
);
818 if (ferror(pf
) || fclose (pf
)) {
820 (void) m_unlink (cp
);
822 adios (cp
, "write error on");
827 if (trnflag
&& m_unlink (sp
) == NOTOK
)
828 adios (sp
, "couldn't unlink");
829 free (sp
); /* Free Maildir[i]->filename */
833 free (Maildir
); /* From now on Maildir is just a flag - don't dref! */
838 if (incerr
< 0) { /* error */
840 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
841 (void) lkfclosespool (in
, newmail
); in
= NULL
;
842 DROPGROUPPRIVS(); /* And then return us to normal privileges */
844 fclose (in
); in
= NULL
;
846 adios (NULL
, "failed");
855 if ((inc_type
== INC_POP
) && packfile
)
859 * truncate file we are incorporating from
861 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
863 if (stat (newmail
, &st
) != NOTOK
&& s1
.st_mtime
!= st
.st_mtime
)
864 advise (NULL
, "new messages have arrived!\007");
867 if ((newfd
= creat (newmail
, 0600)) != NOTOK
)
870 admonish (newmail
, "error zero'ing");
871 (void) m_unlink(map_name(newmail
));
875 printf ("%s not zero'd\n", newmail
);
879 if (msgnum
== hghnum
) {
880 admonish (NULL
, "no messages incorporated");
883 * Lock the sequence file now, and loop to set the right flags
884 * in the folder structure
890 context_replace (pfolder
, folder
); /* update current folder */
892 if ((mp2
= folder_read(folder
, 1)) == NULL
) {
893 admonish(NULL
, "Unable to reread folder %s", folder
);
898 * Shouldn't happen, but just in case ...
901 if (msgnum
>= mp2
->hghoff
902 && !(mp2
= folder_realloc (mp2
, mp2
->lowoff
, msgnum
+ 1))) {
903 advise (NULL
, "unable to reallocate folder storage");
908 mp2
->curmsg
= hghnum
+ 1;
909 mp2
->hghmsg
= msgnum
;
911 if (mp2
->lowmsg
== 0)
913 if (chgflag
) /* sigh... */
914 seq_setcur (mp2
, mp2
->curmsg
);
916 for (i
= hghnum
+ 1; i
<= msgnum
; i
++) {
917 clear_msg_flags (mp2
, i
);
921 mp2
->msgflags
|= SEQMOD
;
922 seq_setunseen(mp2
, 0); /* Set the Unseen-Sequence */
923 seq_save(mp2
); /* Save the sequence file */
929 * unlock the mail spool
931 if (inc_type
== INC_FILE
&& Maildir
== NULL
) {
933 GETGROUPPRIVS(); /* Be sure we can unlock mail file */
934 (void) lkfclosespool (in
, newmail
); in
= NULL
;
935 DROPGROUPPRIVS(); /* And then return us to normal privileges */
937 fclose (in
); in
= NULL
;
941 context_save (); /* save the context file */
948 inc_done (int status
)
950 if (packfile
&& pd
!= NOTOK
)
951 mbx_close (packfile
, pd
);
955 lkfclosespool(in
, newmail
);
964 fprintf (pf
, "%s\n", s
);
965 stop
+= strlen (s
) + 1;
966 return 0; /* Is return value used? This was missing before 1999-07-15. */
975 snprintf (buffer
, sizeof(buffer
), "%s\n", s
);
976 for ( ; (j
= stringdex (mmdlm1
, buffer
)) >= 0; buffer
[j
]++)
978 for ( ; (j
= stringdex (mmdlm2
, buffer
)) >= 0; buffer
[j
]++)
981 size
+= strlen (buffer
) + 1;
982 return 0; /* Is return value used? This was missing before 1999-07-15. */
993 if (stat (packfile
, &st
) == NOTOK
)
995 if ((md
= open (cp
= map_name (packfile
), O_RDONLY
)) == NOTOK
996 || map_chk (cp
, md
, &d
, (long) st
.st_size
, 1)) {