Added a mini http fetcher into webcit
[citadel.git] / libcitadel / lib / libcitadel.h
index ce76ac61b1b82d2d767e00092ef5342884700cfa..8c90357a96da565551aaae23fe14f895c67c6c88 100644 (file)
@@ -4,13 +4,17 @@
  */
 
 
+/* protect against double includes */
+#ifndef LIBCITADEL_H
+#define LIBCITADEL_H
+
 
 /*
  * since we reference time_t...
  */
 #include <time.h>
-
-#define LIBCITADEL_VERSION_NUMBER      105
+#include <stdlib.h>
+#define LIBCITADEL_VERSION_NUMBER      113
 
 /*
  * Here's a bunch of stupid magic to make the MIME parser portable.
 #endif
 
 
+/* Logging levels - correspond to syslog(3) */
+enum LogLevel {
+       /* When about to exit the server for an unrecoverable error */
+        CTDL_EMERG,    /* system is unusable */
+       /* Manual intervention is required to avoid an abnormal exit */
+        CTDL_ALERT,    /* action must be taken immediately */
+       /* The server can continue to run with degraded functionality */
+        CTDL_CRIT,     /* critical conditions */
+       /* An error occurs but the server continues to run normally */
+        CTDL_ERR,      /* error conditions */
+       /* An abnormal condition was detected; server will continue normally */
+        CTDL_WARNING,  /* warning conditions */
+       /* Normal messages (login/out, activity, etc.) */
+        CTDL_NOTICE,   /* normal but significant condition */
+       /* Unimportant progress messages, etc. */
+        CTDL_INFO,     /* informational */
+       /* Debugging messages */
+        CTDL_DEBUG     /* debug-level messages */
+};
+
+
 /*
  * View definitions.
  * Note that not all views are implemented in all clients.
@@ -177,13 +202,24 @@ void the_mime_parser(char *partnum,
 const char *GuessMimeType(char *data, size_t dlen);
 const char* GuessMimeByFilename(const char *what, size_t len);
 
+/* Run once at Programstart */
+int LoadIconDir(const char *DirName);
+
+/* Select the icon for a given MIME type */
+const char *GetIconFilename(char *MimeType, size_t len);
+
+void ShutDownLibCitadel(void);
 
 
 /* tools */
 
+int Ctdl_IsUtf8SequenceStart(char Char);
+int Ctdl_GetUtf8SequenceLength(char Char);
+int Ctdl_Utf8StrLen(char *str);
+char *Ctdl_Utf8StrCut(char *str, int maxlen);
 
 
-char *safestrncpy(char *dest, const char *src, size_t n);
+int safestrncpy(char *dest, const char *src, size_t n);
 int num_tokens (const char *source, char tok);
 long extract_token(char *dest, const char *source, int parmnum, char separator, int maxlen);
 long grab_token(char **dest, const char *source, int parmnum, char separator);
@@ -216,6 +252,7 @@ char *rfc2047encode(char *line, long length);
 int is_msg_in_mset(char *mset, long msgnum);
 int pattern2(char *search, char *patn);
 void stripltlen(char *, int *);
+char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaformat);
 
 
 
@@ -245,6 +282,10 @@ char *vcard_serialize(struct vCard *);
 void vcard_fn_to_n(char *vname, char *n, size_t vname_size);
 void remove_charset_attribute(char *strbuf);
 
+/*
+ * Hash list implementation for Citadel
+ */
+#define HKEY(a) a, sizeof(a) - 1
 typedef struct HashList HashList;
 
 typedef struct HashKey HashKey;
@@ -252,24 +293,63 @@ typedef struct HashKey HashKey;
 typedef struct HashPos HashPos;
 
 typedef void (*DeleteHashDataFunc)(void * Data);
+typedef const char *(*PrintHashContent)(void * Data);
+typedef int (*CompareFunc)(const void* Item1, const void*Item2);
+typedef int (*HashFunc)(const char *Str, long Len);
+typedef void (*TransitionFunc) (void *Item1, void *Item2, int Odd);
+typedef void (*PrintHashDataFunc) (const char *Key, void *Item, int Odd);
 
-
-
-HashList *NewHash(void);
+HashList *NewHash(int Uniq, HashFunc F);
 void DeleteHash(HashList **Hash);
+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);
+int GetHashKeys(HashList *Hash, char ***List);
+int dbg_PrintHash(HashList *Hash, PrintHashContent first, PrintHashContent Second);
+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);
+void SortByHashKey(HashList *Hash, int Order);
+void SortByHashKeyStr(HashList *Hash);
+int GetCount(HashList *Hash);
+const void *GetSearchPayload(const void *HashVoid);
+void SortByPayload(HashList *Hash, CompareFunc SortBy);
+void convert_spaces_to_underscores(char *str);
+int parse_url(char *url, char *hostname, int *port, char *identifier);
 
+/*
+ * Convert 4 bytes char into an Integer.
+ * usefull for easy inexpensive hashing 
+ * of for char strings.
+ */
+#define CHAR4TO_INT(a) ((int) (a[0] | (a[1]<<8) | (a[2]<<16) | (a[3]<<24)))
 
-int GetHash(HashList *Hash, char *HKey, long HKLen, void **Data);
+/* vNote implementation */
 
-void Put(HashList *Hash, char *HKey, long HKLen, void *Data, DeleteHashDataFunc DeleteIt);
+#define CTDL_VNOTE_MAGIC       0xa1fa
 
-int GetKey(HashList *Hash, char *HKey, long HKLen, void **Data);
+struct vnote {
+       int magic;
+       char *uid;
+       char *summary;
+       char *body;
+       int pos_left;
+       int pos_top;
+       int pos_width;
+       int pos_height;
+       int color_red;
+       int color_green;
+       int color_blue;
+};
 
-int GetHashKeys(HashList *Hash, const char ***List);
 
-int PrintHash(HashList *Hash);
 
-HashPos *GetNewHashPos(void);
-void DeleteHashPos(HashPos **DelMe);
+struct vnote *vnote_new(void);
+struct vnote *vnote_new_from_str(char *s);
+void vnote_free(struct vnote *v);
+char *vnote_serialize(struct vnote *v);
+void vnote_serialize_output_field(char *append_to, char *field, char *label);
 
-int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, char **HashKey, void **Data);
+
+#endif // LIBCITADEL_H