?? mail.h
字號:
#include <sys/types.h>#include <sys/stat.h> /* open() & mail_open() mode */#include <fcntl.h> /* open() & mail_open() flags */#include <stddef.h> /* NULL */#include <time.h>#include "ourhdr.h"#include "pass.h" /* flags for mail_store() */#define TMPMSGFILE "message" #define ANYIDX 0 /*any index(writew_lock(mail->idxfd,*/#define FREEIDX 1 /* free index*/ #define REALIDX 2 /* not free index*/ /* magic numbers */#define IDXLEN_SZ 4 /* #ascii chars for length of index record */#define IDXLEN_MIN 6 /* key, sep, start, sep, length, newline */#define IDXLEN_MAX 1024 /* arbitrary */#define SEP '|' /* separator character in index record */#define DATLEN_MIN 2 /* data byte, newline */#define DATLEN_MAX 1024 /* arbitrary */ /* following definitions are for hash chains and free list chain in index file */#define PTR_SZ 6 /* size of ptr field in hash chain */#define PTR_MAX 999999 /* max offset (file size) = 10**PTR_SZ - 1 */#define NHASH_DEF 137 /* default hash table size */#define FREE_OFF 0 /* offset of ptr to free list in index file */#define HASH_OFF PTR_SZ /* offset of hash table in index file */char *hint;/*const for message hint*//*struct message **msgpp;point to the content of the message for client to get message*/typedef struct { /* our internal structure */ int idxfd; /* fd for index file */ int datfd; /* fd for data file */ int oflag; /* flags for open()/mail_open(): O_xxx */ char *keybuf; char *idxbuf;/* malloc'ed buffer for index record */ char *datbuf;/* malloc'ed buffer for data record*/ char *name; /* name mail was opened under */ off_t idxoff; /* offset in index file of index record */ /* actual key is at (idxoff + PTR_SZ + IDXLEN_SZ) */ size_t idxlen;/* length of index record */ /* excludes IDXLEN_SZ bytes at front of index record */ /* includes newline at end of index record */ off_t datoff; /* offset in data file of data record */ size_t datlen;/* length of data record */ /* includes newline at end */ off_t ptrval; /* contents of chain ptr in index record */ off_t ptroff; /* offset of chain ptr that points to this index record */ off_t chainoff;/* offset of hash chain for this index record */ off_t hashoff;/* offset in index file of hash table */ int nhash; /* current hash table size */ long cnt_delok; /* delete OK */ long cnt_delerr; /* delete error */ long cnt_fetchok;/* fetch OK */ long cnt_fetcherr;/* fetch error */ long cnt_nextrec;/* nextrec */ /* long cnt_stor1; store: mail_INSERT, no empty, appended */ /*long cnt_stor2; store: mail_INSERT, found empty, reused */ /*long cnt_stor3; store: mail_REPLACE, diff data len, appended */ /*long cnt_stor4; store: mail_REPLACE, same data len, overwrote */ /*long cnt_storerr; store error */} MAIL;typedef unsigned long hash_t; /* hash values */ /* user-callable functions */MAIL *mail_open(const char *, int, int);void mail_close(MAIL *);char *mail_fetch(MAIL *, struct message *);int mail_store(MAIL *, struct message *);int mail_delete(MAIL *, const char *);void mail_rewind(MAIL *);char *mail_nextrec(MAIL *, char *);void mail_stats(MAIL *); /* internal functions */MAIL *_mail_alloc(int);int _mail_checkfree(MAIL *);int _mail_dodelete(MAIL *);int _mail_emptykey(char *);int _mail_find(MAIL *, const char *, int);int _mail_findfree(MAIL *, int, int);int _mail_free(MAIL *);hash_t _mail_hash(MAIL *, const char *);char *_mail_nextkey(MAIL *);char *_mail_readdat(MAIL *);off_t _mail_readidx(MAIL *, off_t,int);off_t _mail_readptr(MAIL *, off_t);void _mail_writedat(MAIL *, const char *, off_t, int);void _mail_writeidx(MAIL *, struct message *, off_t, int, off_t);void _mail_writeptr(MAIL *, off_t, off_t);void _mail_gethint(struct message*); #include "interface.h"
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -