Tweaks, some spacing, bump some limits, kill some XXXs.
Nicholas Marriott
17 years ago
153 | 153 | len--; |
154 | 154 | hdr++; |
155 | 155 | |
156 | /* now follows a set of attributes of the form name=value, seperated | |
157 | by semicolons, possibly crossing multiple lines and possibly with | |
158 | the value enclosed in quotes */ | |
156 | /* | |
157 | * Now follows a set of attributes of the form name=value, seperated | |
158 | * by semicolons, possibly crossing multiple lines and possibly with | |
159 | * the value enclosed in quotes. | |
160 | */ | |
159 | 161 | namelen = strlen(name); |
160 | 162 | for (;;) { |
161 | 163 | /* skip spaces and newlines */ |
167 | 167 | int blocked, u_int queued) |
168 | 168 | { |
169 | 169 | static int holding; /* holding fetch until queues drop */ |
170 | struct io *rio, *iop[NFDS]; | |
170 | struct io *rio, *iop[IO_POLLFDS]; | |
171 | 171 | char *cause; |
172 | 172 | u_int n; |
173 | 173 | int timeout, error; |
63 | 63 | return (DELIVER_FAILURE); |
64 | 64 | } |
65 | 65 | |
66 | /* XXX needed? */ | |
67 | 66 | ARRAY_FREE(&m->wrapped); |
68 | 67 | m->wrapchar = '\0'; |
69 | 68 | fill_wrapped(m); |
51 | 51 | } |
52 | 52 | log_debug2("%s: removing header: %s", a->name, hdr); |
53 | 53 | |
54 | /* XXX necessary? */ | |
55 | 54 | ARRAY_FREE(&m->wrapped); |
56 | 55 | m->wrapchar = '\0'; |
57 | 56 | fill_wrapped(m); |
41 | 41 | |
42 | 42 | /* Delivery types. */ |
43 | 43 | enum delivertype { |
44 | DELIVER_INCHILD, /* do not pass up to parent */ | |
45 | DELIVER_ASUSER, /* do pass up to parent to drop privs */ | |
46 | DELIVER_WRBACK /* modifies mail: pass up to parent and expect | |
47 | a new mail back */ | |
44 | DELIVER_INCHILD,/* don't pass to parent */ | |
45 | DELIVER_ASUSER, /* pass to parent to drop privs */ | |
46 | DELIVER_WRBACK /* modifies mail: pass to parent and receive new mail */ | |
48 | 47 | }; |
49 | 48 | |
50 | 49 | /* Deliver functions. */ |
77 | 77 | #define __packed __attribute__ ((__packed__)) |
78 | 78 | #endif |
79 | 79 | |
80 | #ifdef DEBUG | |
80 | 81 | #define NFDS 64 |
81 | 82 | #define COUNTFDS(s) do { \ |
82 | 83 | int fd_i, fd_n; \ |
87 | 88 | } \ |
88 | 89 | log_debug2("%s: %d file descriptors in use", s, fd_n); \ |
89 | 90 | } while (0) |
91 | #endif | |
90 | 92 | |
91 | 93 | /* Convert a file mode. */ |
92 | 94 | #define MODE(m) \ |
317 | 319 | |
318 | 320 | /* Initial string block slots and block size. */ |
319 | 321 | #define STRBENTRIES 64 |
320 | #define STRBBLOCK 512 | |
322 | #define STRBBLOCK 1024 | |
321 | 323 | |
322 | 324 | /* String block access macros. */ |
323 | 325 | #define STRB_KEY(sb, sbe) (((char *) (sb)) + (sizeof *(sb)) + (sbe)->key) |
688 | 690 | #define IO_FLUSHSIZE (2 * IO_BLOCKSIZE) |
689 | 691 | |
690 | 692 | /* Maximum number of pollfds. */ |
691 | #define IO_POLLFDS 64 | |
693 | #define IO_POLLFDS 256 | |
692 | 694 | |
693 | 695 | /* IO buffer size macros. */ |
694 | 696 | #define IO_ROUND(n) (((n / IO_BLOCKSIZE) + 1) * IO_BLOCKSIZE) |
781 | 781 | xfree($1); |
782 | 782 | } |
783 | 783 | |
784 | /** REPLPATHV: <string> (char *) */ | |
784 | 785 | replpathv: strv |
786 | /** [$1: strv (char *)] */ | |
785 | 787 | { |
786 | 788 | struct replpath rp; |
787 | 789 | |
797 | 799 | |
798 | 800 | /** INCLUDE */ |
799 | 801 | include: TOKINCLUDE replpathv |
800 | /** [$2: replstrv (char *)] */ | |
802 | /** [$2: replpathv (char *)] */ | |
801 | 803 | { |
802 | 804 | char *path; |
803 | 805 | struct fileent *top; |
932 | 934 | conf.lock_types = $3; |
933 | 935 | } |
934 | 936 | | TOKSET TOKLOCKFILE replpathv |
935 | /** [$3: replstrv (char *)] */ | |
937 | /** [$3: replpathv (char *)] */ | |
936 | 938 | { |
937 | 939 | if (conf.lock_file != NULL) |
938 | 940 | xfree(conf.lock_file); |
959 | 961 | conf.timeout = $3 * 1000; |
960 | 962 | } |
961 | 963 | | TOKSET TOKQUEUEHIGH numv |
962 | /** [$3: time (long long)] */ | |
964 | /** [$3: numv (long long)] */ | |
963 | 965 | { |
964 | 966 | if ($3 == 0) |
965 | 967 | yyerror("zero queue-high"); |
970 | 972 | conf.queue_high = $3; |
971 | 973 | } |
972 | 974 | | TOKSET TOKQUEUELOW numv |
973 | /** [$3: time (long long)] */ | |
975 | /** [$3: numv (long long)] */ | |
974 | 976 | { |
975 | 977 | if ($3 > MAXQUEUEVALUE) |
976 | 978 | yyerror("queue-low too big: %lld", $3); |
1230 | 1232 | |
1231 | 1233 | /** MAILDIRSLIST: <strings> (struct strings *) */ |
1232 | 1234 | maildirslist: maildirslist replpathv |
1233 | /** [$1: maildirslist (struct strings *)] [$2: replstrv (char *)] */ | |
1235 | /** [$1: maildirslist (struct strings *)] [$2: replpathv (char *)] */ | |
1234 | 1236 | { |
1235 | 1237 | if (*$2 == '\0') |
1236 | 1238 | yyerror("invalid maildir"); |
1239 | 1241 | ARRAY_ADD($$, $2, char *); |
1240 | 1242 | } |
1241 | 1243 | | replpathv |
1242 | /** [$1: replstrv (char *)] */ | |
1244 | /** [$1: replpathv (char *)] */ | |
1243 | 1245 | { |
1244 | 1246 | if (*$1 == '\0') |
1245 | 1247 | yyerror("invalid maildir"); |
1251 | 1253 | |
1252 | 1254 | /** MAILDIRS: <strings> (struct strings *) */ |
1253 | 1255 | maildirs: TOKMAILDIR replpathv |
1254 | /** [$2: replstrv (char *)] */ | |
1256 | /** [$2: replpathv (char *)] */ | |
1255 | 1257 | { |
1256 | 1258 | if (*$2 == '\0') |
1257 | 1259 | yyerror("invalid maildir"); |
2452 | 2454 | $$ = FETCHPORT_SSL; |
2453 | 2455 | } |
2454 | 2456 | |
2457 | /** USERPASSNETRC: <userpass> (struct { ... } userpass) */ | |
2455 | 2458 | userpassnetrc: TOKUSER replstrv TOKPASS replstrv |
2456 | /** [$2: replstrv (char *)] [$4: replstrv (char *)] */ | |
2459 | /** [$2: replstrv (char *)] [$4: replstrv (char *)] */ | |
2457 | 2460 | { |
2458 | 2461 | if (*$2 == '\0') |
2459 | 2462 | yyerror("invalid user"); |
2473 | 2476 | $$.pass_netrc = 1; |
2474 | 2477 | } |
2475 | 2478 | | TOKUSER replstrv |
2479 | /** [$2: replstrv (char *)] */ | |
2476 | 2480 | { |
2477 | 2481 | if (*$2 == '\0') |
2478 | 2482 | yyerror("invalid user"); |
2483 | 2487 | $$.pass_netrc = 1; |
2484 | 2488 | } |
2485 | 2489 | | TOKPASS replstrv |
2490 | /** [$2: replstrv (char *)] */ | |
2486 | 2491 | { |
2487 | 2492 | if (*$2 == '\0') |
2488 | 2493 | yyerror("invalid pass"); |
2519 | 2524 | /** FETCHTYPE: <fetch> (struct { ... } fetch) */ |
2520 | 2525 | fetchtype: poptype server userpassnetrc |
2521 | 2526 | /** [$1: poptype (int)] [$2: server (struct { ... } server)] */ |
2522 | /** [$4: replstrv (char *)] [$6: replstrv (char *)] */ | |
2527 | /** [$3: userpassnetrc (struct { ... } userpass)] */ | |
2523 | 2528 | { |
2524 | 2529 | struct fetch_pop3_data *data; |
2525 | 2530 | |
2550 | 2555 | } |
2551 | 2556 | | imaptype server userpassnetrc folder |
2552 | 2557 | /** [$1: imaptype (int)] [$2: server (struct { ... } server)] */ |
2553 | /** [$4: replstrv (char *)] [$6: replstrv (char *)] [$7: folder (char *)] */ | |
2558 | /** [$3: userpassnetrc (struct { ... } userpass)] [$4: folder (char *)] */ | |
2554 | 2559 | { |
2555 | 2560 | struct fetch_imap_data *data; |
2556 | 2561 | |
2622 | 2627 | } |
2623 | 2628 | | TOKNNTP server groups TOKCACHE replpathv |
2624 | 2629 | /** [$2: server (struct { ... } server)] */ |
2625 | /** [$3: groups (struct strings *)] [$5: replstrv (char *)] */ | |
2630 | /** [$3: groups (struct strings *)] [$5: replpathv (char *)] */ | |
2626 | 2631 | { |
2627 | 2632 | struct fetch_nntp_data *data; |
2628 | 2633 | char *group; |
111 | 111 | if (sbep == NULL) { |
112 | 112 | if (sb->ent_used > sb->ent_max) { |
113 | 113 | /* allocate some more */ |
114 | if (sb->ent_max > UINT_MAX / 2) /* XXX */ | |
115 | fatalx("strb_add: ent_max too large"); | |
116 | 114 | n = sb->ent_max; |
117 | 115 | |
116 | size = STRB_SIZE(sb); | |
117 | if (sb->ent_max > UINT_MAX / 2) | |
118 | fatalx("strb_add: ent_max too large"); | |
118 | 119 | sb->ent_max *= 2; |
120 | if (STRB_SIZE(sb) < size) | |
121 | fatalx("strb_add: size too large"); | |
122 | ||
119 | 123 | sb = *sbp = xrealloc(sb, 1, STRB_SIZE(sb)); |
120 | 124 | |
121 | 125 | memset(STRB_ENTRY(sb, n), 0, STRB_ENTSIZE(sb) / 2); |