Use pop3d_outf instead of fprintf
Showing
11 changed files
with
33 additions
and
33 deletions
... | @@ -256,7 +256,7 @@ pop3d_apop (const char *arg) | ... | @@ -256,7 +256,7 @@ pop3d_apop (const char *arg) |
256 | username = strdup (pw->pw_name); | 256 | username = strdup (pw->pw_name); |
257 | if (username == NULL) | 257 | if (username == NULL) |
258 | pop3d_abquit (ERR_NO_MEM); | 258 | pop3d_abquit (ERR_NO_MEM); |
259 | fprintf (ofile, "+OK opened mailbox for %s\r\n", username); | 259 | pop3d_outf ("+OK opened mailbox for %s\r\n", username); |
260 | /* mailbox name */ | 260 | /* mailbox name */ |
261 | { | 261 | { |
262 | url_t url = NULL; | 262 | url_t url = NULL; | ... | ... |
... | @@ -35,17 +35,17 @@ pop3d_capa (const char *arg) | ... | @@ -35,17 +35,17 @@ pop3d_capa (const char *arg) |
35 | if (state != AUTHORIZATION && state != TRANSACTION) | 35 | if (state != AUTHORIZATION && state != TRANSACTION) |
36 | return ERR_WRONG_STATE; | 36 | return ERR_WRONG_STATE; |
37 | 37 | ||
38 | fprintf (ofile, "+OK Capability list follows\r\n"); | 38 | pop3d_outf ("+OK Capability list follows\r\n"); |
39 | fprintf (ofile, "TOP\r\n"); | 39 | pop3d_outf ("TOP\r\n"); |
40 | fprintf (ofile, "USER\r\n"); | 40 | pop3d_outf ("USER\r\n"); |
41 | fprintf (ofile, "UIDL\r\n"); | 41 | pop3d_outf ("UIDL\r\n"); |
42 | fprintf (ofile, "RESP-CODES\r\n"); | 42 | pop3d_outf ("RESP-CODES\r\n"); |
43 | fprintf (ofile, "PIPELINING\r\n"); | 43 | pop3d_outf ("PIPELINING\r\n"); |
44 | /* FIXME: This can be Implemented by setting an header field on the | 44 | /* FIXME: This can be Implemented by setting an header field on the |
45 | message. */ | 45 | message. */ |
46 | /*fprintf (ofile, "EXPIRE NEVER\r\n"); */ | 46 | /*pop3d_outf ("EXPIRE NEVER\r\n"); */ |
47 | if (state == TRANSACTION) /* let's not advertise to just anyone */ | 47 | if (state == TRANSACTION) /* let's not advertise to just anyone */ |
48 | fprintf (ofile, "IMPLEMENTATION %s %s\r\n", IMPL, VERSION); | 48 | pop3d_outf ("IMPLEMENTATION %s %s\r\n", IMPL, VERSION); |
49 | fprintf (ofile, ".\r\n"); | 49 | pop3d_outf (".\r\n"); |
50 | return OK; | 50 | return OK; |
51 | } | 51 | } | ... | ... |
... | @@ -39,6 +39,6 @@ pop3d_dele (const char *arg) | ... | @@ -39,6 +39,6 @@ pop3d_dele (const char *arg) |
39 | 39 | ||
40 | message_get_attribute (msg, &attr); | 40 | message_get_attribute (msg, &attr); |
41 | attribute_set_deleted (attr); | 41 | attribute_set_deleted (attr); |
42 | fprintf (ofile, "+OK Message %d marked\r\n", num); | 42 | pop3d_outf ("+OK Message %d marked\r\n", num); |
43 | return OK; | 43 | return OK; |
44 | } | 44 | } | ... | ... |
... | @@ -37,7 +37,7 @@ pop3d_list (const char *arg) | ... | @@ -37,7 +37,7 @@ pop3d_list (const char *arg) |
37 | if (strlen (arg) == 0) | 37 | if (strlen (arg) == 0) |
38 | { | 38 | { |
39 | size_t total = 0; | 39 | size_t total = 0; |
40 | fprintf (ofile, "+OK\r\n"); | 40 | pop3d_outf ("+OK\r\n"); |
41 | mailbox_messages_count (mbox, &total); | 41 | mailbox_messages_count (mbox, &total); |
42 | for (mesgno = 1; mesgno <= total; mesgno++) | 42 | for (mesgno = 1; mesgno <= total; mesgno++) |
43 | { | 43 | { |
... | @@ -47,10 +47,10 @@ pop3d_list (const char *arg) | ... | @@ -47,10 +47,10 @@ pop3d_list (const char *arg) |
47 | { | 47 | { |
48 | message_size (msg, &size); | 48 | message_size (msg, &size); |
49 | message_lines (msg, &lines); | 49 | message_lines (msg, &lines); |
50 | fprintf (ofile, "%d %d\r\n", mesgno, size + lines); | 50 | pop3d_outf ("%d %d\r\n", mesgno, size + lines); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | fprintf (ofile, ".\r\n"); | 53 | pop3d_outf (".\r\n"); |
54 | } | 54 | } |
55 | else | 55 | else |
56 | { | 56 | { |
... | @@ -62,7 +62,7 @@ pop3d_list (const char *arg) | ... | @@ -62,7 +62,7 @@ pop3d_list (const char *arg) |
62 | return ERR_MESG_DELE; | 62 | return ERR_MESG_DELE; |
63 | message_size (msg, &size); | 63 | message_size (msg, &size); |
64 | message_lines (msg, &lines); | 64 | message_lines (msg, &lines); |
65 | fprintf (ofile, "+OK %d %d\r\n", mesgno, size + lines); | 65 | pop3d_outf ("+OK %d %d\r\n", mesgno, size + lines); |
66 | } | 66 | } |
67 | 67 | ||
68 | return OK; | 68 | return OK; | ... | ... |
... | @@ -26,6 +26,6 @@ pop3d_noop (const char *arg) | ... | @@ -26,6 +26,6 @@ pop3d_noop (const char *arg) |
26 | return ERR_BAD_ARGS; | 26 | return ERR_BAD_ARGS; |
27 | if (state != TRANSACTION) | 27 | if (state != TRANSACTION) |
28 | return ERR_WRONG_STATE; | 28 | return ERR_WRONG_STATE; |
29 | fprintf (ofile, "+OK\r\n"); | 29 | pop3d_outf ("+OK\r\n"); |
30 | return OK; | 30 | return OK; |
31 | } | 31 | } | ... | ... |
... | @@ -46,7 +46,7 @@ pop3d_retr (const char *arg) | ... | @@ -46,7 +46,7 @@ pop3d_retr (const char *arg) |
46 | return ERR_MESG_DELE; | 46 | return ERR_MESG_DELE; |
47 | 47 | ||
48 | message_get_stream (msg, &stream); | 48 | message_get_stream (msg, &stream); |
49 | fprintf (ofile, "+OK\r\n"); | 49 | pop3d_outf ("+OK\r\n"); |
50 | 50 | ||
51 | off = n = 0; | 51 | off = n = 0; |
52 | buf = malloc (buflen * sizeof (*buf)); | 52 | buf = malloc (buflen * sizeof (*buf)); |
... | @@ -68,9 +68,9 @@ pop3d_retr (const char *arg) | ... | @@ -68,9 +68,9 @@ pop3d_retr (const char *arg) |
68 | continue; | 68 | continue; |
69 | } | 69 | } |
70 | if (buf[0] == '.') | 70 | if (buf[0] == '.') |
71 | fprintf (ofile, ".%s\r\n", buf); | 71 | pop3d_outf (".%s\r\n", buf); |
72 | else | 72 | else |
73 | fprintf (ofile, "%s\r\n", buf); | 73 | pop3d_outf ("%s\r\n", buf); |
74 | off += n; | 74 | off += n; |
75 | } | 75 | } |
76 | 76 | ||
... | @@ -78,7 +78,7 @@ pop3d_retr (const char *arg) | ... | @@ -78,7 +78,7 @@ pop3d_retr (const char *arg) |
78 | attribute_set_read (attr); | 78 | attribute_set_read (attr); |
79 | 79 | ||
80 | free (buf); | 80 | free (buf); |
81 | fprintf (ofile, ".\r\n"); | 81 | pop3d_outf (".\r\n"); |
82 | 82 | ||
83 | return OK; | 83 | return OK; |
84 | } | 84 | } | ... | ... |
... | @@ -42,6 +42,6 @@ pop3d_rset (const char *arg) | ... | @@ -42,6 +42,6 @@ pop3d_rset (const char *arg) |
42 | if (attribute_is_deleted (attr)) | 42 | if (attribute_is_deleted (attr)) |
43 | attribute_unset_deleted (attr); | 43 | attribute_unset_deleted (attr); |
44 | } | 44 | } |
45 | fprintf (ofile, "+OK\r\n"); | 45 | pop3d_outf ("+OK\r\n"); |
46 | return OK; | 46 | return OK; |
47 | } | 47 | } | ... | ... |
... | @@ -58,7 +58,7 @@ pop3d_top (const char *arg) | ... | @@ -58,7 +58,7 @@ pop3d_top (const char *arg) |
58 | if (attribute_is_deleted (attr)) | 58 | if (attribute_is_deleted (attr)) |
59 | return ERR_MESG_DELE; | 59 | return ERR_MESG_DELE; |
60 | 60 | ||
61 | fprintf (ofile, "+OK\r\n"); | 61 | pop3d_outf ("+OK\r\n"); |
62 | 62 | ||
63 | /* Header. */ | 63 | /* Header. */ |
64 | message_get_header (msg, &hdr); | 64 | message_get_header (msg, &hdr); |
... | @@ -74,10 +74,10 @@ pop3d_top (const char *arg) | ... | @@ -74,10 +74,10 @@ pop3d_top (const char *arg) |
74 | if (buf[n - 1] == '\n') | 74 | if (buf[n - 1] == '\n') |
75 | { | 75 | { |
76 | buf[n - 1] = '\0'; | 76 | buf[n - 1] = '\0'; |
77 | fprintf (ofile, "%s\r\n", buf); | 77 | pop3d_outf ("%s\r\n", buf); |
78 | } | 78 | } |
79 | else | 79 | else |
80 | fprintf (ofile, "%s", buf); | 80 | pop3d_outf ("%s", buf); |
81 | off += n; | 81 | off += n; |
82 | } | 82 | } |
83 | 83 | ||
... | @@ -102,16 +102,16 @@ pop3d_top (const char *arg) | ... | @@ -102,16 +102,16 @@ pop3d_top (const char *arg) |
102 | continue; | 102 | continue; |
103 | } | 103 | } |
104 | if (buf[0] == '.') | 104 | if (buf[0] == '.') |
105 | fprintf (ofile, ".%s\r\n", buf); | 105 | pop3d_outf (".%s\r\n", buf); |
106 | else | 106 | else |
107 | fprintf (ofile, "%s\r\n", buf); | 107 | pop3d_outf ("%s\r\n", buf); |
108 | lines--; | 108 | lines--; |
109 | off += n; | 109 | off += n; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | free (buf); | 113 | free (buf); |
114 | fprintf (ofile, ".\r\n"); | 114 | pop3d_outf (".\r\n"); |
115 | 115 | ||
116 | return OK; | 116 | return OK; |
117 | } | 117 | } | ... | ... |
... | @@ -34,7 +34,7 @@ pop3d_uidl (const char *arg) | ... | @@ -34,7 +34,7 @@ pop3d_uidl (const char *arg) |
34 | if (strlen (arg) == 0) | 34 | if (strlen (arg) == 0) |
35 | { | 35 | { |
36 | size_t total = 0; | 36 | size_t total = 0; |
37 | fprintf (ofile, "+OK\r\n"); | 37 | pop3d_outf ("+OK\r\n"); |
38 | mailbox_messages_count (mbox, &total); | 38 | mailbox_messages_count (mbox, &total); |
39 | for (mesgno = 1; mesgno <= total; mesgno++) | 39 | for (mesgno = 1; mesgno <= total; mesgno++) |
40 | { | 40 | { |
... | @@ -43,10 +43,10 @@ pop3d_uidl (const char *arg) | ... | @@ -43,10 +43,10 @@ pop3d_uidl (const char *arg) |
43 | if (!attribute_is_deleted (attr)) | 43 | if (!attribute_is_deleted (attr)) |
44 | { | 44 | { |
45 | message_get_uidl (msg, uidl, sizeof (uidl), NULL); | 45 | message_get_uidl (msg, uidl, sizeof (uidl), NULL); |
46 | fprintf (ofile, "%d %s\r\n", mesgno, uidl); | 46 | pop3d_outf ("%d %s\r\n", mesgno, uidl); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | fprintf (ofile, ".\r\n"); | 49 | pop3d_outf (".\r\n"); |
50 | } | 50 | } |
51 | else | 51 | else |
52 | { | 52 | { |
... | @@ -57,7 +57,7 @@ pop3d_uidl (const char *arg) | ... | @@ -57,7 +57,7 @@ pop3d_uidl (const char *arg) |
57 | if (attribute_is_deleted (attr)) | 57 | if (attribute_is_deleted (attr)) |
58 | return ERR_MESG_DELE; | 58 | return ERR_MESG_DELE; |
59 | message_get_uidl (msg, uidl, sizeof (uidl), NULL); | 59 | message_get_uidl (msg, uidl, sizeof (uidl), NULL); |
60 | fprintf (ofile, "+OK %d %s\r\n", mesgno, uidl); | 60 | pop3d_outf ("+OK %d %s\r\n", mesgno, uidl); |
61 | } | 61 | } |
62 | 62 | ||
63 | return OK; | 63 | return OK; | ... | ... |
-
Please register or sign in to post a comment