Updated the MIME Parser API to include Content-ID in
[citadel.git] / libcitadel / lib / libcitadel.h
index ef20f954313a9e1156aa5cd5fff7fc40d8c78fe1..35438cdd7625121041795f56c4a409d1f77acdb6 100644 (file)
@@ -15,7 +15,7 @@
 #include <time.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#define LIBCITADEL_VERSION_NUMBER      738
+#define LIBCITADEL_VERSION_NUMBER      739
 
 /*
  * Here's a bunch of stupid magic to make the MIME parser portable.
@@ -90,6 +90,7 @@ void mime_parser(char *content_start, char *content_end,
                        char *cbcharset,
                        size_t cblength,
                        char *cbencoding,
+                       char *cbid,
                        void *cbuserdata),
                void (*PreMultiPartCallBack)
                        (char *cbname,
@@ -101,6 +102,7 @@ void mime_parser(char *content_start, char *content_end,
                        char *cbcharset,
                        size_t cblength,
                        char *cbencoding,
+                       char *cbid,
                        void *cbuserdata),
                void (*PostMultiPartCallBack)
                        (char *cbname,
@@ -112,6 +114,7 @@ void mime_parser(char *content_start, char *content_end,
                        char *cbcharset,
                        size_t cblength,
                        char *cbencoding,
+                       char *cbid,
                        void *cbuserdata),
                void *userdata,
                int dont_decode
@@ -124,6 +127,7 @@ void mime_decode(char *partnum,
                 char *part_start, size_t length,
                 char *content_type, char *charset, char *encoding,
                 char *disposition,
+                char *id,
                 char *name, char *filename,
                 void (*CallBack)
                  (char *cbname,
@@ -135,6 +139,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                 void (*PreMultiPartCallBack)
                  (char *cbname,
@@ -146,6 +151,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                 void (*PostMultiPartCallBack)
                  (char *cbname,
@@ -157,6 +163,7 @@ void mime_decode(char *partnum,
                   char *cbcharset,
                   size_t cblength,
                   char *cbencoding,
+                  char *cbid,
                   void *cbuserdata),
                  void *userdata,
                  int dont_decode
@@ -173,6 +180,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                     void (*PreMultiPartCallBack)
                      (char *cbname,
@@ -184,6 +192,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                     void (*PostMultiPartCallBack)
                      (char *cbname,
@@ -195,6 +204,7 @@ void the_mime_parser(char *partnum,
                       char *cbcharset,
                       size_t cblength,
                       char *cbencoding,
+                      char *cbid,
                       void *cbuserdata),
                      void *userdata,
                      int dont_decode
@@ -203,17 +213,28 @@ void the_mime_parser(char *partnum,
 typedef struct StrBuf StrBuf;
 
 StrBuf* NewStrBuf(void);
+StrBuf* NewStrBufDup(const StrBuf *CopyMe);
 StrBuf* NewStrBufPlain(const char* ptr, int nChars);
+int StrBufPlain(StrBuf *Buf, const char* ptr, int nChars);
 StrBuf* _NewConstStrBuf(const char* StringConstant, size_t SizeOfStrConstant);
 #define NewConstStrBuf(a) _NewConstStrBuf(a, sizeof(a))
 void FreeStrBuf (StrBuf **FreeMe);
 void HFreeStrBuf (void *VFreeMe);
 int FlushStrBuf(StrBuf *buf);
 
-inline const char *ChrPtr(StrBuf *Str);
-inline int StrLength(StrBuf *Str);
+const char *ChrPtr(const StrBuf *Str);
+int StrLength(const StrBuf *Str);
+#define SKEY(a) ChrPtr(a), StrLength(a)
+long StrBufPeek(StrBuf *Buf, const char* ptr, long nThChar, char PeekValue);
 
-int StrBufTCP_read_line(StrBuf *buf, int fd, int append, const char **Error);
+int StrBufTCP_read_line(StrBuf *buf, int *fd, int append, const char **Error);
+int StrBufReadBLOB(StrBuf *Buf, int *fd, int append, long nBytes, const char **Error);
+int StrBufTCP_read_buffered_line(StrBuf *Line, 
+                                StrBuf *buf, 
+                                int *fd, 
+                                int timeout, 
+                                int selectresolution, 
+                                const char **Error);
 
 int StrBufExtract_token(StrBuf *dest, const StrBuf *Source, int parmnum, char separator);
 int StrBufSub(StrBuf *dest, const StrBuf *Source, size_t Offset, size_t nChars);
@@ -221,16 +242,38 @@ unsigned long StrBufExtract_unsigned_long(const StrBuf* Source, int parmnum, cha
 long StrBufExtract_long(const StrBuf* Source, int parmnum, char separator);
 int StrBufExtract_int(const StrBuf* Source, int parmnum, char separator);
 inline int StrBufNum_tokens(const StrBuf *source, char tok);
-
-void StrBufAppendBuf(StrBuf *Buf, StrBuf *AppendBuf, size_t Offset);
+int StrBufRemove_token(StrBuf *Source, int parmnum, char separator);
+
+void StrBufAppendBufPlain(StrBuf *Buf, const char *AppendBuf, long AppendSize, size_t Offset);
+void StrBufAppendBuf(StrBuf *Buf, const StrBuf *AppendBuf, size_t Offset);
+void StrBufAppendPrintf(StrBuf *Buf, const char *format, ...);
+#ifdef SHOW_ME_VAPPEND_PRINTF
+/* so owe don't create an include depndency, this is just visible on demand. */
+void StrBufVAppendPrintf(StrBuf *Buf, const char *format, va_list ap);
+#endif
 void StrBufPrintf(StrBuf *Buf, const char *format, ...) __attribute__((__format__(__printf__,2,3)));
 void StrBufCutLeft(StrBuf *Buf, int nChars);
 void StrBufCutRight(StrBuf *Buf, int nChars);
-void StrBufEUid_unescapize(StrBuf *target, StrBuf *source);
-
-long StrTol(StrBuf *Buf);
-
-const char *GuessMimeType(char *data, size_t dlen);
+void StrBufUpCase(StrBuf *Buf);
+void StrBufEUid_unescapize(StrBuf *target, const StrBuf *source);
+void StrBufEUid_escapize(StrBuf *target, const StrBuf *source);
+
+void StrBufReplaceChars(StrBuf *buf, char search, char replace);
+
+int CompressBuffer(StrBuf *Buf);
+int StrBufDecodeBase64(StrBuf *Buf);
+int StrBufRFC2047encode(StrBuf **target, const StrBuf *source);
+#define LB                     (1)             /* Internal escape chars */
+#define RB                     (2)
+#define QU                     (3)
+void StrBufUrlescAppend(StrBuf *OutBuf, const StrBuf *In, const char *PlainIn);
+long StrEscAppend(StrBuf *Target, const StrBuf *Source, const char *PlainIn, int nbsp, int nolinebreaks);
+void StrMsgEscAppend(StrBuf *Target, StrBuf *Source, const char *PlainIn);
+
+long StrTol(const StrBuf *Buf);
+int StrToi(const StrBuf *Buf);
+
+const char *GuessMimeType(const char *data, size_t dlen);
 const char* GuessMimeByFilename(const char *what, size_t len);
 
 /* Run once at Programstart */
@@ -313,6 +356,7 @@ char *vcard_get_prop(struct vCard *v, char *propname, int is_partial,
 char *vcard_serialize(struct vCard *);
 void vcard_fn_to_n(char *vname, char *n, size_t vname_size);
 void remove_charset_attribute(char *strbuf);
+long StrBufUnescape(StrBuf *Buf, int StripBlanks);
 
 /*
  * Hash list implementation for Citadel
@@ -333,6 +377,7 @@ typedef void (*PrintHashDataFunc) (const char *Key, void *Item, int Odd);
 
 HashList *NewHash(int Uniq, HashFunc F);
 void DeleteHash(HashList **Hash);
+void HDeleteHash(void *vHash);
 int GetHash(HashList *Hash, const char *HKey, long HKLen, void **Data);
 void Put(HashList *Hash, const char *HKey, long HKLen, void *Data, DeleteHashDataFunc DeleteIt);
 int GetKey(HashList *Hash, char *HKey, long HKLen, void **Data);
@@ -341,7 +386,7 @@ int dbg_PrintHash(HashList *Hash, PrintHashContent first, PrintHashContent Secon
 int PrintHash(HashList *Hash, TransitionFunc Trans, PrintHashDataFunc PrintEntry);
 HashPos *GetNewHashPos(void);
 void DeleteHashPos(HashPos **DelMe);
-int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, char **HashKey, void **Data);
+int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, const char **HashKey, void **Data);
 void SortByHashKey(HashList *Hash, int Order);
 void SortByHashKeyStr(HashList *Hash);
 int GetCount(HashList *Hash);