diff options
Diffstat (limited to 'maildirmisc.h')
| -rw-r--r-- | maildirmisc.h | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/maildirmisc.h b/maildirmisc.h new file mode 100644 index 0000000..86743bc --- /dev/null +++ b/maildirmisc.h | |||
| @@ -0,0 +1,145 @@ | |||
| 1 | #ifndef maildirmisc_h | ||
| 2 | #define maildirmisc_h | ||
| 3 | |||
| 4 | /* | ||
| 5 | ** Copyright 2000 Double Precision, Inc. | ||
| 6 | ** See COPYING for distribution information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #if HAVE_CONFIG_H | ||
| 10 | #include "config.h" | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #ifdef __cplusplus | ||
| 14 | extern "C" { | ||
| 15 | #endif | ||
| 16 | |||
| 17 | static const char maildirmisc_h_rcsid[]="$Id: maildirmisc.h,v 1.8 2000/12/25 17:33:06 mrsam Exp $"; | ||
| 18 | |||
| 19 | /* | ||
| 20 | ** | ||
| 21 | ** Miscellaneous maildir-related code | ||
| 22 | ** | ||
| 23 | */ | ||
| 24 | |||
| 25 | /* Some special folders */ | ||
| 26 | |||
| 27 | #define INBOX "INBOX" | ||
| 28 | #define DRAFTS "Drafts" | ||
| 29 | #define SENT "Sent" | ||
| 30 | #define TRASH "Trash" | ||
| 31 | |||
| 32 | #define SHAREDSUBDIR "shared-folders" | ||
| 33 | |||
| 34 | char *maildir_folderdir(const char *, /* maildir */ | ||
| 35 | const char *); /* folder name */ | ||
| 36 | /* Returns the directory corresponding to foldername (foldername is | ||
| 37 | ** checked to make sure that it's a valid name, else we set errno | ||
| 38 | ** to EINVAL, and return (0). | ||
| 39 | */ | ||
| 40 | |||
| 41 | char *maildir_filename(const char *, /* maildir */ | ||
| 42 | const char *, /* folder */ | ||
| 43 | const char *); /* filename */ | ||
| 44 | /* | ||
| 45 | ** Builds the filename to this message, suitable for opening. | ||
| 46 | ** If the file doesn't appear to be there, search the maildir to | ||
| 47 | ** see if someone changed the flags, and return the current filename. | ||
| 48 | */ | ||
| 49 | |||
| 50 | int maildir_safeopen(const char *, /* filename */ | ||
| 51 | int, /* mode */ | ||
| 52 | int); /* perm */ | ||
| 53 | |||
| 54 | /* | ||
| 55 | ** Same arguments as open(). When we're accessing a shared maildir, | ||
| 56 | ** prevent someone from playing cute and dumping a bunch of symlinks | ||
| 57 | ** in there. This function will open the indicate file only if the | ||
| 58 | ** last component is not a symlink. | ||
| 59 | ** This is implemented by opening the file with O_NONBLOCK (to prevent | ||
| 60 | ** a DOS attack of someone pointing the symlink to a pipe, causing | ||
| 61 | ** the open to hang), clearing O_NONBLOCK, then stat-int the file | ||
| 62 | ** descriptor, lstating the filename, and making sure that dev/ino | ||
| 63 | ** match. | ||
| 64 | */ | ||
| 65 | |||
| 66 | int maildir_semisafeopen(const char *, /* filename */ | ||
| 67 | int, /* mode */ | ||
| 68 | int); /* perm */ | ||
| 69 | |||
| 70 | /* | ||
| 71 | ** Same thing, except that we allow ONE level of soft link indirection, | ||
| 72 | ** because we're reading from our own maildir, which points to the | ||
| 73 | ** message in the sharable maildir. | ||
| 74 | */ | ||
| 75 | |||
| 76 | int maildir_mkdir(const char *); /* directory */ | ||
| 77 | /* | ||
| 78 | ** Create maildir including all subdirectories in the path (like mkdir -p) | ||
| 79 | */ | ||
| 80 | |||
| 81 | void maildir_purgetmp(const char *); /* maildir */ | ||
| 82 | /* purges old stuff out of tmp */ | ||
| 83 | |||
| 84 | void maildir_purge(const char *, /* directory */ | ||
| 85 | unsigned); /* time_t to purge */ | ||
| 86 | |||
| 87 | void maildir_getnew(const char *, /* maildir */ | ||
| 88 | const char *); /* folder */ | ||
| 89 | /* move messages from new to cur */ | ||
| 90 | |||
| 91 | int maildir_deletefolder(const char *, /* maildir */ | ||
| 92 | const char *); /* folder */ | ||
| 93 | /* deletes a folder */ | ||
| 94 | |||
| 95 | int maildir_mddelete(const char *); /* delete a maildir folder by path */ | ||
| 96 | |||
| 97 | void maildir_list_sharable(const char *, /* maildir */ | ||
| 98 | void (*)(const char *, void *), /* callback function */ | ||
| 99 | void *); /* 2nd arg to callback func */ | ||
| 100 | /* list sharable folders */ | ||
| 101 | |||
| 102 | int maildir_shared_subscribe(const char *, /* maildir */ | ||
| 103 | const char *); /* folder */ | ||
| 104 | /* subscribe to a shared folder */ | ||
| 105 | |||
| 106 | void maildir_list_shared(const char *, /* maildir */ | ||
| 107 | void (*)(const char *, void *), /* callback function */ | ||
| 108 | void *); /* 2nd arg to the callback func */ | ||
| 109 | /* list subscribed folders */ | ||
| 110 | |||
| 111 | int maildir_shared_unsubscribe(const char *, /* maildir */ | ||
| 112 | const char *); /* folder */ | ||
| 113 | /* unsubscribe from a shared folder */ | ||
| 114 | |||
| 115 | char *maildir_shareddir(const char *, /* maildir */ | ||
| 116 | const char *); /* folder */ | ||
| 117 | /* | ||
| 118 | ** Validate and return a path to a shared folder. folderdir must be | ||
| 119 | ** a name of a valid shared folder. | ||
| 120 | */ | ||
| 121 | |||
| 122 | void maildir_shared_sync(const char *); /* maildir */ | ||
| 123 | /* "sync" the shared folder */ | ||
| 124 | |||
| 125 | int maildir_sharedisro(const char *); /* maildir */ | ||
| 126 | /* maildir is a shared read-only folder */ | ||
| 127 | |||
| 128 | int maildir_unlinksharedmsg(const char *); /* filename */ | ||
| 129 | /* Remove a message from a shared folder */ | ||
| 130 | |||
| 131 | /* Internal function that reads a symlink */ | ||
| 132 | |||
| 133 | char *maildir_getlink(const char *); | ||
| 134 | |||
| 135 | /* Determine whether the maildir filename has a certain flag */ | ||
| 136 | |||
| 137 | int maildir_hasflag(const char *filename, char); | ||
| 138 | |||
| 139 | #define MAILDIR_DELETED(f) maildir_hasflag((f), 'T') | ||
| 140 | |||
| 141 | #ifdef __cplusplus | ||
| 142 | } | ||
| 143 | #endif | ||
| 144 | |||
| 145 | #endif | ||
