(mkfilename): Renamed to maildir_mkfilename. Made external.
Showing
1 changed file
with
10 additions
and
14 deletions
... | @@ -64,6 +64,7 @@ | ... | @@ -64,6 +64,7 @@ |
64 | #include <mailbox0.h> | 64 | #include <mailbox0.h> |
65 | #include <registrar0.h> | 65 | #include <registrar0.h> |
66 | #include <amd.h> | 66 | #include <amd.h> |
67 | #include <maildir.h> | ||
67 | 68 | ||
68 | struct _maildir_message | 69 | struct _maildir_message |
69 | { | 70 | { |
... | @@ -200,13 +201,8 @@ read_random (void *buf, size_t size) | ... | @@ -200,13 +201,8 @@ read_random (void *buf, size_t size) |
200 | return rc != size; | 201 | return rc != size; |
201 | } | 202 | } |
202 | 203 | ||
203 | #define PERMS 0700 | 204 | char * |
204 | #define TMPSUF "tmp" | 205 | maildir_mkfilename (char *directory, char *suffix, char *name) |
205 | #define CURSUF "cur" | ||
206 | #define NEWSUF "new" | ||
207 | |||
208 | static char * | ||
209 | mkfilename (char *directory, char *suffix, char *name) | ||
210 | { | 206 | { |
211 | size_t size = strlen (directory) + 1 + strlen (suffix) + 1; | 207 | size_t size = strlen (directory) + 1 + strlen (suffix) + 1; |
212 | char *tmp; | 208 | char *tmp; |
... | @@ -305,7 +301,7 @@ char * | ... | @@ -305,7 +301,7 @@ char * |
305 | maildir_message_name (struct _amd_message *amsg, int deleted) | 301 | maildir_message_name (struct _amd_message *amsg, int deleted) |
306 | { | 302 | { |
307 | struct _maildir_message *msg = (struct _maildir_message *) amsg; | 303 | struct _maildir_message *msg = (struct _maildir_message *) amsg; |
308 | return mkfilename (amsg->amd->name, msg->newflag ? NEWSUF : CURSUF, msg->file_name); | 304 | return maildir_mkfilename (amsg->amd->name, msg->newflag ? NEWSUF : CURSUF, msg->file_name); |
309 | } | 305 | } |
310 | 306 | ||
311 | static void | 307 | static void |
... | @@ -323,7 +319,7 @@ static void | ... | @@ -323,7 +319,7 @@ static void |
323 | maildir_delete_file (char *dirname, char *filename) | 319 | maildir_delete_file (char *dirname, char *filename) |
324 | { | 320 | { |
325 | struct stat st; | 321 | struct stat st; |
326 | char *name = mkfilename (dirname, filename, NULL); | 322 | char *name = maildir_mkfilename (dirname, filename, NULL); |
327 | 323 | ||
328 | if (stat (name, &st) == 0) | 324 | if (stat (name, &st) == 0) |
329 | { | 325 | { |
... | @@ -389,8 +385,8 @@ static int | ... | @@ -389,8 +385,8 @@ static int |
389 | maildir_msg_finish_delivery (struct _amd_data *amd, struct _amd_message *amm) | 385 | maildir_msg_finish_delivery (struct _amd_data *amd, struct _amd_message *amm) |
390 | { | 386 | { |
391 | struct _maildir_message *msg = (struct _maildir_message *) amm; | 387 | struct _maildir_message *msg = (struct _maildir_message *) amm; |
392 | char *oldname = mkfilename (amd->name, TMPSUF, msg->file_name); | 388 | char *oldname = maildir_mkfilename (amd->name, TMPSUF, msg->file_name); |
393 | char *newname = mkfilename (amd->name, NEWSUF, msg->file_name); | 389 | char *newname = maildir_mkfilename (amd->name, NEWSUF, msg->file_name); |
394 | 390 | ||
395 | unlink (newname); | 391 | unlink (newname); |
396 | if (link (oldname, newname)) | 392 | if (link (oldname, newname)) |
... | @@ -458,7 +454,7 @@ maildir_deliver_new (struct _amd_data *amd, DIR *dir) | ... | @@ -458,7 +454,7 @@ maildir_deliver_new (struct _amd_data *amd, DIR *dir) |
458 | break; | 454 | break; |
459 | 455 | ||
460 | default: | 456 | default: |
461 | oldname = mkfilename (amd->name, NEWSUF, entry->d_name); | 457 | oldname = maildir_mkfilename (amd->name, NEWSUF, entry->d_name); |
462 | newname = mk_info_filename (amd->name, CURSUF, entry->d_name, 0); | 458 | newname = mk_info_filename (amd->name, CURSUF, entry->d_name, 0); |
463 | rename (oldname, newname); | 459 | rename (oldname, newname); |
464 | free (oldname); | 460 | free (oldname); |
... | @@ -549,7 +545,7 @@ maildir_scan0 (mailbox_t mailbox, size_t msgno ARG_UNUSED, size_t *pcount, | ... | @@ -549,7 +545,7 @@ maildir_scan0 (mailbox_t mailbox, size_t msgno ARG_UNUSED, size_t *pcount, |
549 | maildir_flush (amd); | 545 | maildir_flush (amd); |
550 | 546 | ||
551 | /* 2nd phase: Scan and deliver messages from new */ | 547 | /* 2nd phase: Scan and deliver messages from new */ |
552 | name = mkfilename (amd->name, NEWSUF, NULL); | 548 | name = maildir_mkfilename (amd->name, NEWSUF, NULL); |
553 | 549 | ||
554 | status = maildir_opendir (&dir, name, PERMS); | 550 | status = maildir_opendir (&dir, name, PERMS); |
555 | if (status == 0) | 551 | if (status == 0) |
... | @@ -559,7 +555,7 @@ maildir_scan0 (mailbox_t mailbox, size_t msgno ARG_UNUSED, size_t *pcount, | ... | @@ -559,7 +555,7 @@ maildir_scan0 (mailbox_t mailbox, size_t msgno ARG_UNUSED, size_t *pcount, |
559 | } | 555 | } |
560 | free (name); | 556 | free (name); |
561 | 557 | ||
562 | name = mkfilename (amd->name, CURSUF, NULL); | 558 | name = maildir_mkfilename (amd->name, CURSUF, NULL); |
563 | /* 3rd phase: Scan cur/ */ | 559 | /* 3rd phase: Scan cur/ */ |
564 | status = maildir_opendir (&dir, name, PERMS); | 560 | status = maildir_opendir (&dir, name, PERMS); |
565 | if (status == 0) | 561 | if (status == 0) | ... | ... |
-
Please register or sign in to post a comment