Back to index

libcitadel  8.12
Classes | Defines | Typedefs | Enumerations | Functions | Variables
libcitadel.h File Reference
#include <time.h>
#include <stdlib.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <netinet/in.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ConstStr
struct  _file_buffer
struct  __fd_iobuffer
struct  ParsedURL
struct  vCard
struct  vCard::vCardProp
struct  vnote

Defines

#define LIBCITADEL_VERSION_NUMBER   812
#define SIZ   4096
#define BLOG_EUIDBUF_SIZE   40
#define IsEmptyStr(a)   ((a)[0] == '\0')
#define strof(a)   #a
#define CStrOf(a)   #a, sizeof(#a) - 1
#define CKEY(a)   (a).Key, (a).len
#define NewConstStrBuf(a)   _NewConstStrBuf(a, sizeof(a))
#define SKEY(a)   ChrPtr(a), StrLength(a)
#define NNN_TERM   1
#define O_TERM   0
#define LB   (1) /* Internal escape chars */
#define RB   (2)
#define QU   (3)
#define IsEmptyStr(a)   ((a)[0] == '\0')
#define num_parms(source)   num_tokens(source,(char)'|')
#define CTDL_VCARD_MAGIC   0xa1f9
#define HKEY(a)   a, (sizeof(a) - 1)
#define IKEY(a)   (const char*) &a, sizeof(a)
#define LKEY(a)   (const char*) &a, sizeof(a)
#define CHAR4TO_INT(a)   ((int) (a[0] | (a[1]<<8) | (a[2]<<16) | (a[3]<<24)))
#define CTDL_VNOTE_MAGIC   0xa1fa
#define WF_MAJOR   "1"
#define WF_STRUCTINDEX   "1"
#define WF_SUB   "1"
#define CtdlLogResult(x)   if (x) syslog(LOG_CRIT, "%s:%d %s", __FILE__, __LINE__, strerror(errno))
#define ThreadIdHash(Buf)   abs(HashLittle(ChrPtr(Buf), StrLength(Buf)))

Typedefs

typedef enum AXLevel eUsrAxlvl
typedef enum __GPEXWhichPolicy GPEXWhichPolicy
typedef enum _room_views ROOM_VIEWS
typedef void(* MimeParserCallBackType )(char *cbname, char *cbfilename, char *cbpartnum, char *cbdisp, void *cbcontent, char *cbtype, char *cbcharset, size_t cblength, char *cbencoding, char *cbid, void *cbuserdata)
typedef struct StrBuf
typedef struct _ConstStr ConstStr
typedef enum _eReadState eReadState
typedef struct _file_buffer IOBuffer
typedef struct __fd_iobuffer FDIOBuffer
typedef struct ParsedURL
typedef struct HashList
typedef struct HashKey
typedef struct HashPos
typedef void(* DeleteHashDataFunc )(void *Data)
typedef const char *(* PrintHashContent )(void *Data)
typedef int(* CompareFunc )(const void *Item1, const void *Item2)
typedef long(* 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)
typedef struct MSet
typedef struct JsonValue
typedef void(* AddHeaderFunc )(const char *HdrName, const char *HdrValue)
typedef enum _WF_MessageType WF_MessageType

Enumerations

enum  AXLevel {
  AxDeleted = 0, AxNewU = 1, AxProbU = 2, AxLocU = 3,
  AxNetU = 4, AxPrefU = 5, AxAideU = 6
}
enum  RoomNetCfg {
  subpending, unsubpending, lastsent, ignet_push_share,
  listrecp, digestrecp, pop3client, rssclient,
  participate, maxRoomNetCfg
}
enum  GNET_POP3_PARTS {
  GNET_POP3_HOST = 1, GNET_POP3_USER = 2, GNET_POP3_PASS = 4, GNET_POP3_DONT_DELETE_REMOTE = 4,
  GNET_POP3_INTERVAL = 5
}
enum  GNET_PUSH_SHARE { GNET_IGNET_NODE = 1, GNET_IGNET_ROOM = 2 }
enum  __GPEXWhichPolicy {
  roompolicy, floorpolicy, sitepolicy, mailboxespolicy,
  maxpolicy
}
enum  _room_views {
  VIEW_BBS = 0, VIEW_MAILBOX = 1, VIEW_ADDRESSBOOK = 2, VIEW_CALENDAR = 3,
  VIEW_TASKS = 4, VIEW_NOTES = 5, VIEW_WIKI = 6, VIEW_CALBRIEF = 7,
  VIEW_JOURNAL = 8, VIEW_DRAFTS = 9, VIEW_BLOG = 10, VIEW_QUEUE = 11,
  VIEW_MAX, VIEW_JSON_LIST
}
enum  _eReadState { eReadFail, eReadSuccess, eMustReadMore, eBufferNotEmpty }
enum  _WF_MessageType {
  eLOG, eINFO, eWARN, eERROR,
  eTRACE, eEXCEPTION
}

Functions

char * libcitadel_version_string (void)
int libcitadel_version_number (void)
void StartLibCitadel (size_t basesize)
void ShutDownLibCitadel (void)
long extract_key (char *target, char *source, long sourcelen, char *key, long keylen, char KeyEnd)
void mime_parser (char *content_start, char *content_end, MimeParserCallBackType CallBack, MimeParserCallBackType PreMultiPartCallBack, MimeParserCallBackType PostMultiPartCallBack, void *userdata, int dont_decode)
char * fixed_partnum (char *)
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, MimeParserCallBackType CallBack, MimeParserCallBackType PreMultiPartCallBack, MimeParserCallBackType PostMultiPartCallBack, void *userdata, int dont_decode)
int mime_decode_now (char *part_start, size_t length, char *encoding, char **decoded, size_t *bytes_decoded)
void the_mime_parser (char *partnum, char *content_start, char *content_end, MimeParserCallBackType CallBack, MimeParserCallBackType PreMultiPartCallBack, MimeParserCallBackType PostMultiPartCallBack, void *userdata, int dont_decode)
StrBufNewStrBuf (void)
 Allocate a new buffer with default buffer size.
StrBufNewStrBufDup (const StrBuf *CopyMe)
 Copy Constructor; returns a duplicate of CopyMe.
StrBufNewStrBufPlain (const char *ptr, int nChars)
 create a new Buffer using an existing c-string this function should also be used if you want to pre-suggest the buffer size to allocate in conjunction with ptr == NULL
long StrBufShrinkToFit (StrBuf *Buf, int Force)
 shrink long term buffers to their real size so they don't waste memory
void ReAdjustEmptyBuf (StrBuf *Buf, long ThreshHold, long NewSize)
 shrink / increase an EMPTY buffer to NewSize.
void NewStrBufDupAppendFlush (StrBuf **CreateRelpaceMe, StrBuf *CopyFlushMe, const char *NoMe, int KeepOriginal)
 Copy Constructor; CreateRelpaceMe will contain CopyFlushMe afterwards.
int StrBufPlain (StrBuf *Buf, const char *ptr, int nChars)
 Set an existing buffer from a c-string.
StrBuf_NewConstStrBuf (const char *StringConstant, size_t SizeOfStrConstant)
 use strbuf as wrapper for a string constant for easy handling
void FreeStrBuf (StrBuf **FreeMe)
 Release a Buffer Its a double pointer, so it can NULL your pointer so fancy SIG11 appear instead of random results.
char * SmashStrBuf (StrBuf **SmashMe)
 flatten a Buffer to the Char * we return Its a double pointer, so it can NULL your pointer so fancy SIG11 appear instead of random results The Callee then owns the buffer and is responsible for freeing it.
void HFreeStrBuf (void *VFreeMe)
 Release the buffer If you want put your StrBuf into a Hash, use this as Destructor.
int FlushStrBuf (StrBuf *buf)
 flush the content of a Buf; keep its struct
int FLUSHStrBuf (StrBuf *buf)
 wipe the content of a Buf thoroughly (overwrite it -> expensive); keep its struct
const char * ChrPtr (const StrBuf *Str)
 Cast operator to Plain String.
int StrLength (const StrBuf *Str)
 since we know strlen()'s result, provide it here.
long StrBufPeek (StrBuf *Buf, const char *ptr, long nThChar, char PeekValue)
 modifies a Single char of the Buf You can point to it via char* or a zero-based integer
long StrBufPook (StrBuf *Buf, const char *ptr, long nThChar, long nChars, char PookValue)
 modifies a range of chars of the Buf You can point to it via char* or a zero-based integer
int StrBufTCP_read_line (StrBuf *buf, int *fd, int append, const char **Error)
 Read a line from socket flushes and closes the FD on error.
int StrBufReadBLOB (StrBuf *Buf, int *fd, int append, long nBytes, const char **Error)
 Input binary data from socket flushes and closes the FD on error.
int StrBufReadBLOBBuffered (StrBuf *Buf, StrBuf *IOBuf, const char **BufPos, int *fd, int append, long nBytes, int check, const char **Error)
 Input binary data from socket flushes and closes the FD on error.
int StrBufTCP_read_buffered_line (StrBuf *Line, StrBuf *buf, int *fd, int timeout, int selectresolution, const char **Error)
 Read a line from socket flushes and closes the FD on error.
int StrBufTCP_read_buffered_line_fast (StrBuf *Line, StrBuf *buf, const char **Pos, int *fd, int timeout, int selectresolution, const char **Error)
 Read a line from socket flushes and closes the FD on error.
void FDIOBufferInit (FDIOBuffer *FDB, IOBuffer *IO, int FD, long TotalSendSize)
void FDIOBufferDelete (FDIOBuffer *FDB)
int FileSendChunked (FDIOBuffer *FDB, const char **Err)
int FileRecvChunked (FDIOBuffer *FDB, const char **Err)
int FileMoveChunked (FDIOBuffer *FDB, const char **Err)
eReadState WriteIOBAlreadyRead (FDIOBuffer *FDB, const char **Error)
long StrBuf_read_one_chunk_callback (int fd, short event, IOBuffer *FB)
int StrBuf_write_one_chunk_callback (int fd, short event, IOBuffer *FB)
eReadState StrBufChunkSipLine (StrBuf *LineBuf, IOBuffer *FB)
 extract a "next line" from Buf; Ptr to persist across several iterations
eReadState StrBufCheckBuffer (IOBuffer *FB)
 check whether the chunk-buffer has more data waiting or not.
long IOBufferStrLength (IOBuffer *FB)
int StrBufSipLine (StrBuf *LineBuf, const StrBuf *Buf, const char **Ptr)
 extract a "next line" from Buf; Ptr to persist across several iterations
int StrBufReplaceToken (StrBuf *Buf, long where, long HowLong, const char *Repl, long ReplLen)
 Replace a token at a given place with a given length by another token with given length.
int StrBufExtract_tokenFromStr (StrBuf *dest, const char *Source, long SourceLen, int parmnum, char separator)
int StrBufExtract_token (StrBuf *dest, const StrBuf *Source, int parmnum, char separator)
 a string tokenizer
int StrBufSub (StrBuf *dest, const StrBuf *Source, unsigned long Offset, size_t nChars)
 extracts a substring from Source into dest
unsigned long StrBufExtract_unsigned_long (const StrBuf *Source, int parmnum, char separator)
 a string tokenizer to fetch an unsigned long
long StrBufExtract_long (const StrBuf *Source, int parmnum, char separator)
 a string tokenizer to fetch a long integer
int StrBufExtract_int (const StrBuf *Source, int parmnum, char separator)
 a string tokenizer to fetch an integer
int StrBufNum_tokens (const StrBuf *source, char tok)
 Counts the numbmer of tokens in a buffer.
int StrBufRemove_token (StrBuf *Source, int parmnum, char separator)
 a string tokenizer
int StrBufHaveNextToken (const StrBuf *Source, const char **pStart)
 a string tokenizer; Bounds checker function to make shure whether StrBufExtract_NextToken and friends have reached the end of the string.
int StrBufExtract_NextToken (StrBuf *dest, const StrBuf *Source, const char **pStart, char separator)
 a string tokenizer
int StrBufSkip_NTokenS (const StrBuf *Source, const char **pStart, char separator, int nTokens)
 a string tokenizer
unsigned long StrBufExtractNext_unsigned_long (const StrBuf *Source, const char **pStart, char separator)
 a string tokenizer to fetch an unsigned long
long StrBufExtractNext_long (const StrBuf *Source, const char **pStart, char separator)
 a string tokenizer to fetch a long integer
int StrBufExtractNext_int (const StrBuf *Source, const char **pStart, char separator)
 a string tokenizer to fetch an integer
void StrBufAppendBufPlain (StrBuf *Buf, const char *AppendBuf, long AppendSize, unsigned long Offset)
 Append a C-String to the buffer.
void StrBufAppendBuf (StrBuf *Buf, const StrBuf *AppendBuf, unsigned long Offset)
 Append a StringBuffer to the buffer.
size_t CurlFillStrBuf_callback (void *ptr, size_t size, size_t nmemb, void *stream)
 Callback for cURL to append the webserver reply to a buffer.
void StrBufAppendPrintf (StrBuf *Buf, const char *format,...)
 sprintf like function appending the formated string to the buffer
void StrBufPrintf (StrBuf *Buf, const char *format,...) __attribute__((__format__(__printf__
void void StrBufCutLeft (StrBuf *Buf, int nChars)
 Cut nChars from the start of the string.
void StrBufCutRight (StrBuf *Buf, int nChars)
 Cut the trailing n Chars from the string.
void StrBufCutAt (StrBuf *Buf, int AfternChars, const char *At)
 Cut the string after n Chars.
void StrBufTrim (StrBuf *Buf)
 Strip leading and trailing spaces from a string; with premeasured and adjusted length.
void StrBufSpaceToBlank (StrBuf *Buf)
 changes all spaces in the string (tab, linefeed...) to Blank (0x20)
void StrBufStripAllBut (StrBuf *Buf, char leftboundary, char rightboundary)
void StrBufUpCase (StrBuf *Buf)
 uppercase the contents of a buffer
void StrBufLowerCase (StrBuf *Buf)
 lowercase the contents of a buffer
void StrBufStripSlashes (StrBuf *Dir, int RemoveTrailingSlash)
 removes double slashes from pathnames
void StrBufEUid_unescapize (StrBuf *target, const StrBuf *source)
 unhide special chars hidden to the HTML escaper
void StrBufEUid_escapize (StrBuf *target, const StrBuf *source)
 hide special chars from the HTML escapers and friends
void StrBufToUnixLF (StrBuf *buf)
 removes all \r s from the string, or replaces them with
if its not a combination of both.
void StrBufReplaceChars (StrBuf *buf, char search, char replace)
 replaces all occurances of 'search' by 'replace'
int CompressBuffer (StrBuf *Buf)
 compress the buffer with gzip Attention! If you feed this a Const String, you must maintain the uncompressed buffer yourself!
void StrBufConvert (StrBuf *ConvertBuf, StrBuf *TmpBuf, void *pic)
 convert one buffer according to the preselected iconv pointer PIC
void ctdl_iconv_open (const char *tocode, const char *fromcode, void *pic)
 Wrapper around iconv_open() Our version adds aliases for non-standard Microsoft charsets such as 'MS950', aliasing them to names like 'CP950'.
void StrBuf_RFC822_2_Utf8 (StrBuf *Target, const StrBuf *DecodeMe, const StrBuf *DefaultCharset, StrBuf *FoundCharset, StrBuf *ConvertBuf, StrBuf *ConvertBuf2)
 Handle subjects with RFC2047 encoding such as: =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=.
void StrBuf_RFC822_to_Utf8 (StrBuf *Target, const StrBuf *DecodeMe, const StrBuf *DefaultCharset, StrBuf *FoundCharset)
 Handle subjects with RFC2047 encoding such as: [deprecated old syntax!] =?koi8-r?B?78bP0s3Mxc7JxSDXz9rE1dvO2c3JINvB0sHNySDP?=.
int StrBufDecodeBase64 (StrBuf *Buf)
 decode a buffer from base 64 encoding; destroys original
int StrBufDecodeHex (StrBuf *Buf)
 decode a buffer from base 64 encoding; destroys original
int StrBufRFC2047encode (StrBuf **target, const StrBuf *source)
 RFC2047-encode a header field if necessary.
StrBufStrBufSanitizeEmailRecipientVector (const StrBuf *Recp, StrBuf *UserName, StrBuf *EmailAddress, StrBuf *EncBuf)
 QP encode parts of an email TO/CC/BCC vector, and strip/filter invalid parts.
int StrBufSanitizeAscii (StrBuf *Buf, const char Mute)
 replace all chars >0x20 && < 0x7F with Mute
void StrBufUrlescAppend (StrBuf *OutBuf, const StrBuf *In, const char *PlainIn)
 Escape a string for feeding out as a URL while appending it to a Buffer.
void StrBufUrlescUPAppend (StrBuf *OutBuf, const StrBuf *In, const char *PlainIn)
 Escape a string for feeding out as a the username/password part of an URL while appending it to a Buffer.
void StrBufHexescAppend (StrBuf *OutBuf, const StrBuf *In, const char *PlainIn)
 append a string in hex encoding to the buffer
void StrBufHexEscAppend (StrBuf *OutBuf, const StrBuf *In, const unsigned char *PlainIn, long PlainInLen)
 append a string in hex encoding to the buffer
long StrEscAppend (StrBuf *Target, const StrBuf *Source, const char *PlainIn, int nbsp, int nolinebreaks)
 Append a string, escaping characters which have meaning in HTML.
long StrECMAEscAppend (StrBuf *Target, const StrBuf *Source, const char *PlainIn)
 Append a string, escaping characters which have meaning in JavaScript strings .
long StrHtmlEcmaEscAppend (StrBuf *Target, const StrBuf *Source, const char *PlainIn, int nbsp, int nolinebreaks)
 Append a string, escaping characters which have meaning in HTML + json.
void StrMsgEscAppend (StrBuf *Target, const StrBuf *Source, const char *PlainIn)
 Append a string, escaping characters which have meaning in HTML.
void StrIcalEscAppend (StrBuf *Target, const StrBuf *Source, const char *PlainIn)
 Append a string, escaping characters which have meaning in ICAL.
long StrTol (const StrBuf *Buf)
 Wrapper around atol.
int StrToi (const StrBuf *Buf)
 Wrapper around atoi.
int StrBufIsNumber (const StrBuf *Buf)
 Checks to see if the string is a pure number.
long StrBuf_Utf8StrLen (StrBuf *Buf)
 measure the number of glyphs in an UTF8 string...
long StrBuf_Utf8StrCut (StrBuf *Buf, int maxlen)
 cuts a string after maxlen glyphs
const char * GuessMimeType (const char *data, size_t dlen)
const char * GuessMimeByFilename (const char *what, size_t len)
int LoadIconDir (const char *DirName)
const char * GetIconFilename (char *MimeType, size_t len)
void FreeURL (ParsedURL **Url)
 frees a linked list of ParsedURL
int ParseURL (ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
 parses the string provided with UrlStr into *Url
void CurlPrepareURL (ParsedURL *Url)
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)
int extract_int (const char *source, int parmnum)
long extract_long (const char *source, int parmnum)
unsigned long extract_unsigned_long (const char *source, int parmnum)
void CtdlInitBase64Table (void)
size_t CtdlEncodeBase64 (char *dest, const char *source, size_t sourcelen, int linebreaks)
int CtdlDecodeBase64 (char *dest, const char *source, size_t length)
unsigned int decode_hex (char *Source)
int CtdlDecodeQuotedPrintable (char *decoded, char *encoded, int sourcelen)
void StripSlashes (char *Dir, int TrailingSlash)
size_t striplt (char *)
int haschar (const char *st, int ch)
 check for the presence of a character within a string (returns count)
void remove_token (char *source, int parmnum, char separator)
void fmt_date (char *buf, size_t n, time_t thetime, int seconds)
int is_msg_in_sequence_set (const char *mset, long msgnum)
char * memreadline (char *start, char *buf, int maxlen)
 Utility function to "readline" from memory.
char * memreadlinelen (char *start, char *buf, int maxlen, int *retlen)
 Utility function to "readline" from memory.
const char * cmemreadline (const char *start, char *buf, int maxlen)
 Utility function to "readline" from memory.
const char * cmemreadlinelen (const char *start, char *buf, int maxlen, int *retlen)
 Utility function to "readline" from memory.
int stripout (char *str, char leftboundary, char rightboundary)
long stripallbut (char *str, char leftboundary, char rightboundary)
char * myfgets (char *s, int size, FILE *stream)
void urlesc (char *outbuf, size_t oblen, char *strbuf)
 Escape a string for feeding out as a URL.
char * CtdlTempFileName (char *prefix1, int prefix2)
FILE * CtdlTempFile (void)
void generate_uuid (char *buf)
char * bmstrcasestr (char *text, const char *pattern)
char * bmstrcasestr_len (char *text, size_t textlen, const char *pattern, size_t patlen)
const char * cbmstrcasestr (const char *text, const char *pattern)
const char * cbmstrcasestr_len (const char *text, size_t textlen, const char *pattern, size_t patlen)
void CtdlMakeTempFileName (char *name, int len)
char * rfc2047encode (char *line, long length)
int is_msg_in_mset (const char *mset, long msgnum)
int pattern2 (char *search, char *patn)
void stripltlen (char *, int *)
char * html_to_ascii (const char *inputmsg, int msglen, int screenwidth, int do_citaformat)
void LoadEntityList (char *FileName)
struct vCardvcard_new (void)
void vcard_add_prop (struct vCard *v, char *propname, char *propvalue)
struct vCardvcard_load (char *vtext)
struct vCardVCardLoad (StrBuf *vbtext)
void vcard_free (struct vCard *)
void vcard_set_prop (struct vCard *v, char *name, char *value, int append)
char * vcard_get_prop (struct vCard *v, char *propname, int is_partial, int instance, int return_propname)
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)
 remove escaped strings from i.e.
long Flathash (const char *str, long len)
 another hashing algorithm; treat it as just a pointer to int.
long lFlathash (const char *str, long len)
 another hashing algorithm; treat it as just a pointer to long.
int TestValidateHash (HashList *TestHash)
HashListNewHash (int Uniq, HashFunc F)
 instanciate a new hashlist
void DeleteHash (HashList **Hash)
 destroy a hashlist and all of its members Crashing? do 'print *FreeMe->LookupTable[i]'
void DeleteHashContent (HashList **Hash)
 flush the members of a hashlist Crashing? do 'print *FreeMe->LookupTable[i]'
void HDeleteHash (void *vHash)
 Destructor for nested hashes.
int GetHash (HashList *Hash, const char *HKey, long HKLen, void **Data)
 Lookup the Data associated with HKey.
void Put (HashList *Hash, const char *HKey, long HKLen, void *Data, DeleteHashDataFunc DeleteIt)
 Add a new / Replace an existing item in the Hash.
int GetKey (HashList *Hash, char *HKey, long HKLen, void **Data)
int GetHashKeys (HashList *Hash, char ***List)
 get the Keys present in this hash, simila to array_keys() in PHP Attention: List remains to Hash! don't modify or free it!
int dbg_PrintHash (HashList *Hash, PrintHashContent first, PrintHashContent Second)
 verify the contents of a hash list; here for debugging purposes.
int PrintHash (HashList *Hash, TransitionFunc Trans, PrintHashDataFunc PrintEntry)
 Iterate over the hash and call PrintEntry.
HashPosGetNewHashPos (HashList *Hash, int StepWidth)
 creates a hash-linear iterator object
int GetHashPosFromKey (HashList *Hash, const char *HKey, long HKLen, HashPos *At)
 Set iterator object to point to key.
int DeleteEntryFromHash (HashList *Hash, HashPos *At)
 Delete from the Hash the entry at Position.
int GetHashPosCounter (HashList *Hash, HashPos *At)
 retrieve the counter from the itteratoor
void DeleteHashPos (HashPos **DelMe)
 frees a linear hash iterator
int NextHashPos (HashList *Hash, HashPos *At)
 Move HashPos one forward.
int GetHashPos (HashList *Hash, HashPos *At, long *HKLen, const char **HashKey, void **Data)
 Get the data located where HashPos Iterator points at.
int GetNextHashPos (HashList *Hash, HashPos *At, long *HKLen, const char **HashKey, void **Data)
 Get the data located where HashPos Iterator points at, and Move HashPos one forward.
int GetHashAt (HashList *Hash, long At, long *HKLen, const char **HashKey, void **Data)
 Get the data located where At points to note: you should prefer iterator operations instead of using me.
void SortByHashKey (HashList *Hash, int Order)
 sort the hash alphabeticaly by their keys.
void SortByHashKeyStr (HashList *Hash)
 sort the hash by their keys (so it regains untainted state).
int GetCount (HashList *Hash)
const void * GetSearchPayload (const void *HashVoid)
 gives user sort routines access to the hash payload
void SortByPayload (HashList *Hash, CompareFunc SortBy)
 sort the hash by your sort function.
void reference_free_handler (void *ptr)
 given you've put char * into your hash as a payload, a sort function might look like this: int SortByChar(const void* First, const void* Second) { char a, b; a = (char) GetSearchPayload(First); b = (char) GetSearchPayload(Second); return strcmp (a, b); }
int HashLittle (const void *key, size_t length)
 This exposes the hashlittle() function to consumers.
int ParseMSet (MSet **MsetList, StrBuf *MSetStr)
 parses an MSet string into a list for later use
int IsInMSetList (MSet *MSetList, long MsgNo)
 checks whether a message is inside a mset
void DeleteMSet (MSet **FreeMe)
 frees a mset [redirects to DeleteHash
void convert_spaces_to_underscores (char *str)
int CheckEncode (const char *pch, long len, const char *pche)
struct vnotevnote_new (void)
struct vnotevnote_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)
void DeleteJSONValue (void *vJsonValue)
JsonValueNewJsonObject (const char *Key, long keylen)
JsonValueNewJsonArray (const char *Key, long keylen)
JsonValueNewJsonNumber (const char *Key, long keylen, long Number)
JsonValueNewJsonBigNumber (const char *Key, long keylen, double Number)
JsonValueNewJsonString (const char *Key, long keylen, StrBuf *CopyMe)
JsonValueNewJsonPlainString (const char *Key, long keylen, const char *CopyMe, long len)
JsonValueNewJsonNull (const char *Key, long keylen)
JsonValueNewJsonBool (const char *Key, long keylen, int value)
void JsonArrayAppend (JsonValue *Array, JsonValue *Val)
void JsonObjectAppend (JsonValue *Array, JsonValue *Val)
void SerializeJson (StrBuf *Target, JsonValue *Val, int FreeVal)
JsonValueWildFireException (const char *Filename, long FileLen, long LineNo, StrBuf *Message, int StackOffset)
void WildFireAddArray (JsonValue *ReportBase, JsonValue *Array, WF_MessageType Type)
JsonValueWildFireMessagePlain (const char *Filename, long fnlen, long LineNo, const char *Message, long len, WF_MessageType Type)
JsonValueWildFireMessage (const char *Filename, long fnlen, long lineno, StrBuf *Msg, WF_MessageType Type)
void WildFireInitBacktrace (const char *argvNull, int AddBaseFrameSkip)
void WildFireSerializePayload (StrBuf *JsonBuffer, StrBuf *OutBuf, int *MsgCount, AddHeaderFunc AddHdr)

Variables

const char * StrBufNOTNULL
ConstStr RoomNetCfgStrs [maxRoomNetCfg]

Class Documentation

struct _ConstStr

Definition at line 184 of file libcitadel.h.

Class Members
const char * Key
long len
struct _file_buffer

Definition at line 245 of file libcitadel.h.

Collaboration diagram for _file_buffer:
Class Members
StrBuf * Buf
int fd
int LineCompleted
int nBlobBytesWanted
const char * ReadWritePointer
struct __fd_iobuffer

Definition at line 254 of file libcitadel.h.

Collaboration diagram for __fd_iobuffer:
Class Members
StrBuf * ChunkBuffer
long ChunkSendRemain
long ChunkSize
IOBuffer * IOB
int OtherFD
int PipeSize
int SplicePipe
long TotalReadAlready
long TotalSendSize
long TotalSentAlready
struct ParsedURL

Definition at line 377 of file libcitadel.h.

Collaboration diagram for ParsedURL:
Class Members
int af
StrBuf * CurlCreds
struct hostent * HEnt
const char * Host
int IPv6
int IsIP
const char * LocalPart
ParsedURL * Next
const char * Pass
const char * PlainUrl
unsigned Port
int Priority
StrBuf * URL
StrBuf * UrlWithoutCred
const char * User
struct vCard

Definition at line 453 of file libcitadel.h.

Collaboration diagram for vCard:
Class Members
int magic
int numprops
struct vCardProp * prop
struct vCard::vCardProp

Definition at line 456 of file libcitadel.h.

Class Members
char * name
char * value
struct vnote

Definition at line 548 of file libcitadel.h.

Class Members
char * body
int color_blue
int color_green
int color_red
int magic
int pos_height
int pos_left
int pos_top
int pos_width
char * summary
char * uid

Define Documentation

#define BLOG_EUIDBUF_SIZE   40

Definition at line 106 of file libcitadel.h.

#define CHAR4TO_INT (   a)    ((int) (a[0] | (a[1]<<8) | (a[2]<<16) | (a[3]<<24)))

Definition at line 542 of file libcitadel.h.

#define CKEY (   a)    (a).Key, (a).len

Definition at line 188 of file libcitadel.h.

#define CStrOf (   a)    #a, sizeof(#a) - 1

Definition at line 183 of file libcitadel.h.

#define CTDL_VCARD_MAGIC   0xa1f9

Definition at line 450 of file libcitadel.h.

#define CTDL_VNOTE_MAGIC   0xa1fa

Definition at line 546 of file libcitadel.h.

#define CtdlLogResult (   x)    if (x) syslog(LOG_CRIT, "%s:%d %s", __FILE__, __LINE__, strerror(errno))

Definition at line 650 of file libcitadel.h.

#define HKEY (   a)    a, (sizeof(a) - 1)

Definition at line 480 of file libcitadel.h.

#define IKEY (   a)    (const char*) &a, sizeof(a)

Definition at line 497 of file libcitadel.h.

#define IsEmptyStr (   a)    ((a)[0] == '\0')

Definition at line 425 of file libcitadel.h.

#define IsEmptyStr (   a)    ((a)[0] == '\0')

Definition at line 425 of file libcitadel.h.

#define LB   (1) /* Internal escape chars */

Definition at line 346 of file libcitadel.h.

#define LIBCITADEL_VERSION_NUMBER   812

Definition at line 31 of file libcitadel.h.

#define LKEY (   a)    (const char*) &a, sizeof(a)

Definition at line 498 of file libcitadel.h.

#define NewConstStrBuf (   a)    _NewConstStrBuf(a, sizeof(a))

Definition at line 199 of file libcitadel.h.

#define NNN_TERM   1

Definition at line 214 of file libcitadel.h.

#define num_parms (   source)    num_tokens(source,(char)'|')

Definition at line 426 of file libcitadel.h.

#define O_TERM   0

Definition at line 215 of file libcitadel.h.

#define QU   (3)

Definition at line 348 of file libcitadel.h.

#define RB   (2)

Definition at line 347 of file libcitadel.h.

#define SIZ   4096

Definition at line 37 of file libcitadel.h.

#define SKEY (   a)    ChrPtr(a), StrLength(a)

Definition at line 208 of file libcitadel.h.

#define strof (   a)    #a

Definition at line 182 of file libcitadel.h.

#define ThreadIdHash (   Buf)    abs(HashLittle(ChrPtr(Buf), StrLength(Buf)))

Definition at line 653 of file libcitadel.h.

#define WF_MAJOR   "1"

Definition at line 643 of file libcitadel.h.

#define WF_STRUCTINDEX   "1"

Definition at line 644 of file libcitadel.h.

#define WF_SUB   "1"

Definition at line 645 of file libcitadel.h.


Typedef Documentation

typedef void(* AddHeaderFunc)(const char *HdrName, const char *HdrValue)

Definition at line 611 of file libcitadel.h.

typedef int(* CompareFunc)(const void *Item1, const void *Item2)

Definition at line 490 of file libcitadel.h.

typedef struct _ConstStr ConstStr
typedef void(* DeleteHashDataFunc)(void *Data)

Definition at line 488 of file libcitadel.h.

typedef enum _eReadState eReadState
typedef enum AXLevel eUsrAxlvl
typedef struct __fd_iobuffer FDIOBuffer
typedef long(* HashFunc)(const char *Str, long Len)

Definition at line 491 of file libcitadel.h.

typedef struct HashKey

Definition at line 484 of file libcitadel.h.

typedef struct HashList

Definition at line 482 of file libcitadel.h.

typedef struct HashPos

Definition at line 486 of file libcitadel.h.

typedef struct _file_buffer IOBuffer
typedef struct JsonValue

Definition at line 577 of file libcitadel.h.

typedef void(* MimeParserCallBackType)(char *cbname, char *cbfilename, char *cbpartnum, char *cbdisp, void *cbcontent, char *cbtype, char *cbcharset, size_t cblength, char *cbencoding, char *cbid, void *cbuserdata)

Definition at line 134 of file libcitadel.h.

typedef struct MSet

Definition at line 529 of file libcitadel.h.

typedef struct ParsedURL

Definition at line 376 of file libcitadel.h.

typedef const char*(* PrintHashContent)(void *Data)

Definition at line 489 of file libcitadel.h.

typedef void(* PrintHashDataFunc)(const char *Key, void *Item, int Odd)

Definition at line 493 of file libcitadel.h.

typedef enum _room_views ROOM_VIEWS
typedef struct StrBuf

Definition at line 180 of file libcitadel.h.

typedef void(* TransitionFunc)(void *Item1, void *Item2, int Odd)

Definition at line 492 of file libcitadel.h.


Enumeration Type Documentation

Enumerator:
roompolicy 
floorpolicy 
sitepolicy 
mailboxespolicy 
maxpolicy 

Definition at line 77 of file libcitadel.h.

Enumerator:
eReadFail 
eReadSuccess 
eMustReadMore 
eBufferNotEmpty 

Definition at line 238 of file libcitadel.h.

Enumerator:
VIEW_BBS 
VIEW_MAILBOX 
VIEW_ADDRESSBOOK 
VIEW_CALENDAR 
VIEW_TASKS 
VIEW_NOTES 
VIEW_WIKI 
VIEW_CALBRIEF 
VIEW_JOURNAL 
VIEW_DRAFTS 
VIEW_BLOG 
VIEW_QUEUE 
VIEW_MAX 
VIEW_JSON_LIST 

Definition at line 89 of file libcitadel.h.

                         {
       VIEW_BBS             = 0,   /* Bulletin board view */
       VIEW_MAILBOX         = 1,   /* Mailbox summary */
       VIEW_ADDRESSBOOK     = 2,   /* Address book view */
       VIEW_CALENDAR        = 3,   /* Calendar view */
       VIEW_TASKS           = 4,   /* Tasks view */
       VIEW_NOTES           = 5,   /* Notes view */
       VIEW_WIKI            = 6,   /* Wiki view */
       VIEW_CALBRIEF        = 7,   /* Brief Calendar view */
       VIEW_JOURNAL         = 8,   /* Journal view */
       VIEW_DRAFTS          = 9,   /* Drafts view */
       VIEW_BLOG            = 10,  /* Blog view */
       VIEW_QUEUE           = 11,   /* SMTP/... QUEUE rooms */
       VIEW_MAX,
       VIEW_JSON_LIST,
} ROOM_VIEWS;
Enumerator:
eLOG 
eINFO 
eWARN 
eERROR 
eTRACE 
eEXCEPTION 

Definition at line 613 of file libcitadel.h.

enum AXLevel
Enumerator:
AxDeleted 
AxNewU 
AxProbU 
AxLocU 
AxNetU 
AxPrefU 
AxAideU 

Definition at line 41 of file libcitadel.h.

                     {
       AxDeleted = 0,
       AxNewU = 1,
       AxProbU = 2,
       AxLocU = 3,
       AxNetU = 4,
       AxPrefU = 5,
       AxAideU = 6
}eUsrAxlvl;
Enumerator:
GNET_POP3_HOST 
GNET_POP3_USER 
GNET_POP3_PASS 
GNET_POP3_DONT_DELETE_REMOTE 
GNET_POP3_INTERVAL 

Definition at line 64 of file libcitadel.h.

                     { /* pop3client splits into these columns: */
       GNET_POP3_HOST = 1,
       GNET_POP3_USER = 2,
       GNET_POP3_PASS = 4,
       GNET_POP3_DONT_DELETE_REMOTE = 4,
       GNET_POP3_INTERVAL = 5
};
Enumerator:
GNET_IGNET_NODE 
GNET_IGNET_ROOM 

Definition at line 72 of file libcitadel.h.

                     { /* ignet_push_share splits into these columns: */
       GNET_IGNET_NODE = 1,
       GNET_IGNET_ROOM = 2
};
enum RoomNetCfg
Enumerator:
subpending 
unsubpending 
lastsent 
ignet_push_share 
listrecp 
digestrecp 
pop3client 
rssclient 
participate 
maxRoomNetCfg 

Definition at line 51 of file libcitadel.h.


Function Documentation

char* bmstrcasestr ( char *  text,
const char *  pattern 
)

Definition at line 976 of file tools.c.

                                                    {
       size_t textlen;
       size_t patlen;

       if (!text) return(NULL);
       if (!pattern) return(NULL);

       textlen = strlen (text);
       patlen = strlen (pattern);

       return _bmstrcasestr_len(text, textlen, pattern, patlen);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* bmstrcasestr_len ( char *  text,
size_t  textlen,
const char *  pattern,
size_t  patlen 
)

Definition at line 989 of file tools.c.

                                                                                       {
       return _bmstrcasestr_len(text, textlen, pattern, patlen);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* cbmstrcasestr ( const char *  text,
const char *  pattern 
)

Definition at line 1061 of file tools.c.

                                                                 {
       size_t textlen;
       size_t patlen;

       if (!text) return(NULL);
       if (!pattern) return(NULL);

       textlen = strlen (text);
       patlen = strlen (pattern);

       return _cbmstrcasestr_len(text, textlen, pattern, patlen);
}

Here is the call graph for this function:

const char* cbmstrcasestr_len ( const char *  text,
size_t  textlen,
const char *  pattern,
size_t  patlen 
)

Definition at line 1074 of file tools.c.

                                                                                                    {
       return _cbmstrcasestr_len(text, textlen, pattern, patlen);
}

Here is the call graph for this function:

int CheckEncode ( const char *  pch,
long  len,
const char *  pche 
)

Definition at line 1197 of file tools.c.

{
       if (pche == NULL)
              pche = pch + len;
       while (pch < pche) {
              if (((unsigned char) *pch < 32) || 
                  ((unsigned char) *pch > 126)) {
                     return 1;
              }
              pch++;
       }
       return 0;
}

Here is the caller graph for this function:

const char* cmemreadline ( const char *  start,
char *  buf,
int  maxlen 
)

Utility function to "readline" from memory.

Parameters:
startLocation in memory from which we are reading.
bufthe buffer to place the string in.
maxlenSize of string buffer
Returns:
Pointer to the source memory right after we stopped reading.

< tally our own length to avoid strlen() delays

Definition at line 705 of file tools.c.

{
       char ch;
       const char *ptr;
       int len = 0;         
       ptr = start;

       while (1) {
              ch = *ptr++;
              if ((len + 1 < (maxlen)) && (ch != 13) && (ch != 10)) {
                     buf[len++] = ch;
              }
              if ((ch == 10) || (ch == 0)) {
                     buf[len] = 0;
                     return ptr;
              }
       }
}
const char* cmemreadlinelen ( const char *  start,
char *  buf,
int  maxlen,
int *  retlen 
)

Utility function to "readline" from memory.

Parameters:
startLocation in memory from which we are reading.
bufthe buffer to place the string in.
maxlenSize of string buffer
retlenthe length of the returned string
Returns:
Pointer to the source memory right after we stopped reading.

< tally our own length to avoid strlen() delays

Definition at line 734 of file tools.c.

{
       char ch;
       const char *ptr;
       int len = 0;         
       ptr = start;

       while (1) {
              ch = *ptr++;
              if ((len + 1 < (maxlen)) && (ch != 13) && (ch != 10)) {
                     buf[len++] = ch;
              }
              if ((ch == 10) || (ch == 0)) {
                     buf[len] = 0;
                     *retlen = len;
                     return ptr;
              }
       }
}
void convert_spaces_to_underscores ( char *  str)

Definition at line 1178 of file tools.c.

{
       int len;
       int i;

       if (!str) return;

       len = strlen(str);
       for (i=0; i<len; ++i) {
              if (isspace(str[i])) {
                     str[i] = '_';
              }
       }
}
int CtdlDecodeBase64 ( char *  dest,
const char *  source,
size_t  length 
)

Definition at line 401 of file tools.c.

{
    int i, c;
    int dpos = 0;
    int spos = 0;

    while (TRUE) {
       byte a[4], b[4], o[3];

       for (i = 0; i < 4; i++) {
           if (spos >= length) {
              return(dpos);
           }
           c = source[spos++];

           if (c == 0) {
              if (i > 0) {
                  return(dpos);
              }
              return(dpos);
           }
           if (dtable[c] & 0x80) {
              /* Ignoring errors: discard invalid character. */
              i--;
              continue;
           }
           a[i] = (byte) c;
           b[i] = (byte) dtable[c];
       }
       o[0] = (b[0] << 2) | (b[1] >> 4);
       o[1] = (b[1] << 4) | (b[2] >> 2);
       o[2] = (b[2] << 6) | b[3];
        i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3);
       if (i>=1) dest[dpos++] = o[0];
       if (i>=2) dest[dpos++] = o[1];
       if (i>=3) dest[dpos++] = o[2];
       dest[dpos] = 0;
       if (i < 3) {
           return(dpos);
       }
    }
}

Here is the caller graph for this function:

int CtdlDecodeQuotedPrintable ( char *  decoded,
char *  encoded,
int  sourcelen 
)

Definition at line 159 of file mime_parser.c.

                                                                           {
       unsigned int ch;
       int decoded_length = 0;
       int pos = 0;

       while (pos < sourcelen)
       {
              if (*(encoded + pos) == '=')
              {
                     pos ++;
                     if (*(encoded + pos) == '\n')
                     {
                            pos ++;
                     }
                     else if (*(encoded + pos) == '\r')
                     {
                            pos ++;
                            if (*(encoded + pos) == '\n')
                                   pos++;
                     }
                     else
                     {
                            ch = _decode_hex(&encoded[pos]);
                            pos += 2;
                            decoded[decoded_length++] = ch;
                     }
              }
              else
              {
                     decoded[decoded_length++] = encoded[pos];
                     pos += 1;
              }
       }
       decoded[decoded_length] = 0;
       return(decoded_length);
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t CtdlEncodeBase64 ( char *  dest,
const char *  source,
size_t  sourcelen,
int  linebreaks 
)

Definition at line 331 of file tools.c.

{
       int i, hiteof = FALSE;
       int spos = 0;
       int dpos = 0;
       int thisline = 0;

       while (!hiteof) {
              byte igroup[3], ogroup[4];
              int c, n;

              igroup[0] = igroup[1] = igroup[2] = 0;
              for (n = 0; n < 3; n++) {
                     if (spos >= sourcelen) {
                            hiteof = TRUE;
                            break;
                     }
                     c = source[spos++];
                     igroup[n] = (byte) c;
              }
              if (n > 0) {
                     ogroup[0] = etable[igroup[0] >> 2];
                     ogroup[1] =
                         etable[((igroup[0] & 3) << 4) |
                               (igroup[1] >> 4)];
                     ogroup[2] =
                         etable[((igroup[1] & 0xF) << 2) |
                               (igroup[2] >> 6)];
                     ogroup[3] = etable[igroup[2] & 0x3F];

                     /*
                      * Replace characters in output stream with "=" pad
                      * characters if fewer than three characters were
                      * read from the end of the input stream. 
                      */

                     if (n < 3) {
                            ogroup[3] = '=';
                            if (n < 2) {
                                   ogroup[2] = '=';
                            }
                     }
                     for (i = 0; i < 4; i++) {
                            dest[dpos++] = ogroup[i];
                            dest[dpos] = 0;
                     }
                     thisline += 4;
                     if ( (linebreaks) && (thisline > 70) ) {
                            dest[dpos++] = '\r';
                            dest[dpos++] = '\n';
                            dest[dpos] = 0;
                            thisline = 0;
                     }
              }
       }
       if ( (linebreaks) && (thisline > 70) ) {
              dest[dpos++] = '\r';
              dest[dpos++] = '\n';
              dest[dpos] = 0;
       }

       return(dpos);
}

Here is the caller graph for this function:

void CtdlInitBase64Table ( void  )
void CtdlMakeTempFileName ( char *  name,
int  len 
)

Definition at line 1082 of file tools.c.

                                               {
       int i = 0;

       while (i++, i < 100) {
              snprintf(name, len, "/tmp/ctdl.%04lx.%04x",
                     (long)getpid(),
                     rand()
              );
              if (!access(name, F_OK)) {
                     return;
              }
       }
}
FILE* CtdlTempFile ( void  )
char* CtdlTempFileName ( char *  prefix1,
int  prefix2 
)
void CurlPrepareURL ( ParsedURL Url)

Definition at line 138 of file urlhandling.c.

{
       if (!strcmp(ChrPtr(Url->URL), "http"))
              Url->UrlWithoutCred = NewStrBufPlain(ChrPtr(Url->URL), -1);
       else 
              Url->UrlWithoutCred = NewStrBufPlain(HKEY("http://"));
       StrBufAppendBufPlain(Url->UrlWithoutCred, Url->Host, -1, 0);

       StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY(":"), 0);

       StrBufAppendPrintf(Url->UrlWithoutCred, "%u", Url->Port);

       StrBufAppendBufPlain(Url->UrlWithoutCred, HKEY("/"), 0);
       if (Url->LocalPart)
       {
           StrBufAppendBufPlain(Url->UrlWithoutCred, Url->LocalPart, -1, 0);
       }
       if (Url->User != NULL)
       {
              Url->CurlCreds = NewStrBufPlain(Url->User, -1);
              StrBufAppendBufPlain(Url->CurlCreds, HKEY(":"), 0);
              if (Url->Pass != NULL)
                     StrBufAppendBufPlain(Url->CurlCreds, Url->Pass, -1, 0);
       }
       Url->PlainUrl = ChrPtr(Url->UrlWithoutCred);
}

Here is the call graph for this function:

unsigned int decode_hex ( char *  Source)

Definition at line 153 of file mime_parser.c.

{return _decode_hex(Source);}

Here is the call graph for this function:

Here is the caller graph for this function:

int extract_int ( const char *  source,
int  parmnum 
)

Definition at line 289 of file tools.c.

{
       char buf[32];
       
       if (extract_token(buf, source, parmnum, '|', sizeof buf) > 0)
              return(atoi(buf));
       else
              return 0;
}

Here is the call graph for this function:

long extract_key ( char *  target,
char *  source,
long  sourcelen,
char *  key,
long  keylen,
char  KeyEnd 
)

Definition at line 67 of file mime_parser.c.

{
       char *sptr, *ptr = NULL;
       int double_quotes = 0;
       long RealKeyLen = keylen;

       sptr = source;

       while (sptr != NULL)
       {
              ptr = bmstrcasestr_len(sptr, sourcelen - (sptr - source), 
                                   key, keylen);
              if(ptr != NULL)
              {
                     while (isspace(*(ptr + RealKeyLen)))
                            RealKeyLen ++;
                     if (*(ptr + RealKeyLen) == KeyEnd)
                     {
                            sptr = NULL;
                            RealKeyLen ++;                            
                     }
                     else
                     {
                            sptr = ptr + RealKeyLen + 1;
                     }
              }
              else 
                     sptr = ptr;
       }
       if (ptr == NULL) {
              *target = '\0';
              return 0;
       }
       strcpy(target, (ptr + RealKeyLen));

       for (ptr=target; (*ptr != 0); ptr++) {

              /* A semicolon means we've hit the end of the key, unless we're inside double quotes */
              if ( (double_quotes != 1) && (*ptr == ';')) {
                     *ptr = 0;
              }

              /* if we find double quotes, we've got a great set of string boundaries */
              if (*ptr == '\"') {
                     ++double_quotes;
                     if (double_quotes == 1) {
                            strcpy(ptr, ptr+1);
                     }
                     else {
                            *ptr = 0;
                     }
              }
       }
       *ptr = '\0';
       return ptr - target;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long extract_long ( const char *  source,
int  parmnum 
)

Definition at line 302 of file tools.c.

{
       char buf[32];
       
       if (extract_token(buf, source, parmnum, '|', sizeof buf) > 0)
              return(atol(buf));
       else
              return 0;
}

Here is the call graph for this function:

long extract_token ( char *  dest,
const char *  source,
int  parmnum,
char  separator,
int  maxlen 
)

Definition at line 149 of file tools.c.

{
       const char *s;                     //* source * /
       int len = 0;                //* running total length of extracted string * /
       int current_token = 0;             //* token currently being processed * /

       s = source;

       if (dest == NULL) {
              return(-1);
       }

       //cit_backtrace();
       //lprintf (CTDL_DEBUG, "test >: n: %d sep: %c source: %s \n willi \n", parmnum, separator, source);
       dest[0] = 0;

       if (s == NULL) {
              return(-1);
       }
       
       maxlen--;

       while (*s) {
              if (*s == separator) {
                     ++current_token;
              }
              if ( (current_token == parmnum) && 
                   (*s != separator) && 
                   (len < maxlen) ) {
                     dest[len] = *s;
                     ++len;
              }
              else if ((current_token > parmnum) || (len >= maxlen)) {
                     break;
              }
              ++s;
       }

       dest[len] = '\0';
       if (current_token < parmnum) {
              //lprintf (CTDL_DEBUG,"test <!: %s\n", dest);
              return(-1);
       }
       //lprintf (CTDL_DEBUG,"test <: %d; %s\n", len, dest);
       return(len);
}

Here is the caller graph for this function:

unsigned long extract_unsigned_long ( const char *  source,
int  parmnum 
)

Definition at line 316 of file tools.c.

{
       char buf[32];

       if (extract_token(buf, source, parmnum, '|', sizeof buf) > 0)
              return strtoul(buf, NULL, 10);
       else 
              return 0;
}

Here is the call graph for this function:

void FDIOBufferDelete ( FDIOBuffer FDB)

Definition at line 3897 of file stringbuf.c.

{
#ifndef LINUX_SPLICE
       FreeStrBuf(&FDB->ChunkBuffer);
#else
       close(FDB->SplicePipe[0]);
       close(FDB->SplicePipe[1]);
       
#endif
       close(FDB->OtherFD);
       memset(FDB, 0, sizeof(FDIOBuffer));       
}

Here is the call graph for this function:

void FDIOBufferInit ( FDIOBuffer FDB,
IOBuffer IO,
int  FD,
long  TotalSendSize 
)

Definition at line 3883 of file stringbuf.c.

{
       memset(FDB, 0, sizeof(FDIOBuffer));
       FDB->ChunkSize = 
              FDB->TotalSendSize = TotalSendSize;
       FDB->IOB = IO;
#ifndef LINUX_SPLICE
       FDB->ChunkBuffer = NewStrBufPlain(NULL, TotalSendSize + 1);
#else
       pipe(FDB->SplicePipe);
#endif
       FDB->OtherFD = FD;
}

Here is the call graph for this function:

int FileMoveChunked ( FDIOBuffer FDB,
const char **  Err 
)

Definition at line 4044 of file stringbuf.c.

{
       ssize_t sent, pipesize;

#ifdef LINUX_SPLICE
       if (FDB->PipeSize == 0)
       {
              pipesize = splice(FDB->IOB->fd,
                              &FDB->TotalReadAlready, 
                              FDB->SplicePipe[1],
                              NULL, 
                              FDB->ChunkSendRemain, 
                              SPLICE_F_MORE | SPLICE_F_MOVE|SPLICE_F_NONBLOCK);

              if (pipesize == -1)
              {
                     *Err = strerror(errno);
                     return pipesize;
              }
              FDB->PipeSize = pipesize;
       }
       
       sent = splice(FDB->SplicePipe[0],
                    NULL, 
                    FDB->OtherFD,
                    &FDB->TotalSentAlready, 
                    FDB->PipeSize,
                    SPLICE_F_MORE | SPLICE_F_MOVE);

       if (sent == -1)
       {
              *Err = strerror(errno);
              return sent;
       }
       FDB->PipeSize -= sent;
       FDB->ChunkSendRemain -= sent;
       return sent;
#else
       
       sent = read(FDB->IOB->fd, FDB->ChunkBuffer->buf, FDB->ChunkSendRemain);
       if (sent > 0) {
              int nWritten = 0;
              int rc; 
              
              FDB->ChunkBuffer->BufUsed = sent;

              while (nWritten < FDB->ChunkBuffer->BufUsed) {
                     rc =  write(FDB->OtherFD, FDB->ChunkBuffer->buf + nWritten, FDB->ChunkBuffer->BufUsed - nWritten);
                     if (rc < 0) {
                            *Err = strerror(errno);
                            return rc;
                     }
                     nWritten += rc;

              }
              FDB->ChunkBuffer->BufUsed = 0;
              FDB->TotalSentAlready += sent;
              FDB->ChunkSendRemain -= sent;
              return FDB->ChunkSendRemain;
       }
       else if (sent < 0) {
              *Err = strerror(errno);
              return sent;
       }

#endif
       return 0;
}
int FileRecvChunked ( FDIOBuffer FDB,
const char **  Err 
)

Definition at line 3975 of file stringbuf.c.

{
       ssize_t sent, pipesize;

#ifdef LINUX_SPLICE
       if (FDB->PipeSize == 0)
       {
              pipesize = splice(FDB->IOB->fd,
                              NULL, 
                              FDB->SplicePipe[1],
                              NULL, 
                              FDB->ChunkSendRemain, 
                              SPLICE_F_MORE | SPLICE_F_MOVE|SPLICE_F_NONBLOCK);

              if (pipesize == -1)
              {
                     *Err = strerror(errno);
                     return pipesize;
              }
              FDB->PipeSize = pipesize;
       }
       
       sent = splice(FDB->SplicePipe[0],
                    NULL, 
                    FDB->OtherFD,
                    &FDB->TotalSentAlready, 
                    FDB->PipeSize,
                    SPLICE_F_MORE | SPLICE_F_MOVE);

       if (sent == -1)
       {
              *Err = strerror(errno);
              return sent;
       }
       FDB->PipeSize -= sent;
       FDB->ChunkSendRemain -= sent;
       return sent;
#else
       
       sent = read(FDB->IOB->fd, FDB->ChunkBuffer->buf, FDB->ChunkSendRemain);
       if (sent > 0) {
              int nWritten = 0;
              int rc; 
              
              FDB->ChunkBuffer->BufUsed = sent;

              while (nWritten < FDB->ChunkBuffer->BufUsed) {
                     rc =  write(FDB->OtherFD, FDB->ChunkBuffer->buf + nWritten, FDB->ChunkBuffer->BufUsed - nWritten);
                     if (rc < 0) {
                            *Err = strerror(errno);
                            return rc;
                     }
                     nWritten += rc;

              }
              FDB->ChunkBuffer->BufUsed = 0;
              FDB->TotalSentAlready += sent;
              FDB->ChunkSendRemain -= sent;
              return FDB->ChunkSendRemain;
       }
       else if (sent < 0) {
              *Err = strerror(errno);
              return sent;
       }

#endif
       return 0;
}
int FileSendChunked ( FDIOBuffer FDB,
const char **  Err 
)

Definition at line 3910 of file stringbuf.c.

{
       ssize_t sent, pipesize;
#ifdef LINUX_SPLICE
       if (FDB->PipeSize == 0)
       {
              pipesize = splice(FDB->OtherFD,
                              &FDB->TotalSentAlready, 
                              FDB->SplicePipe[1],
                              NULL, 
                              FDB->ChunkSendRemain, 
                              SPLICE_F_MOVE);
       
              if (pipesize == -1)
              {
                     *Err = strerror(errno);
                     return pipesize;
              }
              FDB->PipeSize = pipesize;
       }
       sent =  splice(FDB->SplicePipe[0],
                     NULL, 
                     FDB->IOB->fd,
                     NULL, 
                     FDB->PipeSize,
                     SPLICE_F_MORE | SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
       if (sent == -1)
       {
              *Err = strerror(errno);
              return sent;
       }
       FDB->PipeSize -= sent;
       FDB->ChunkSendRemain -= sent;
       return sent;
#else

       char *pRead;
       long nRead = 0;

       pRead = FDB->ChunkBuffer->buf;
       while ((FDB->ChunkBuffer->BufUsed < FDB->TotalSendSize) && (nRead >= 0))
       {
              nRead = read(FDB->OtherFD, pRead, FDB->TotalSendSize - FDB->ChunkBuffer->BufUsed);
              if (nRead > 0) {
                     FDB->ChunkBuffer->BufUsed += nRead;
                     FDB->ChunkBuffer->buf[FDB->ChunkBuffer->BufUsed] = '\0';
              }
              else if (nRead == 0) {}
              else return nRead;
              
       }

       nRead = write(FDB->IOB->fd, FDB->ChunkBuffer->buf + FDB->TotalSentAlready, FDB->ChunkSendRemain);

       if (nRead >= 0) {
              FDB->TotalSentAlready += nRead;
              FDB->ChunkSendRemain -= nRead;
              return FDB->ChunkSendRemain;
       }
       else {
              return nRead;
       }
#endif
}
char* fixed_partnum ( char *  )

Definition at line 129 of file mime_parser.c.

                                            {
       if (supplied_partnum == NULL) return "1";
       if (strlen(supplied_partnum)==0) return "1";
       return supplied_partnum;
}

Here is the caller graph for this function:

void fmt_date ( char *  buf,
size_t  n,
time_t  thetime,
int  seconds 
)

Definition at line 567 of file tools.c.

                                                                {
       struct tm tm;
       int hour;

       /* Month strings for date conversions ... this needs to be localized eventually */
       char *fmt_date_months[12] = {
              "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
       };

       strcpy(buf, "");
       localtime_r(&thetime, &tm);

       hour = tm.tm_hour;
       if (hour == 0)       hour = 12;
       else if (hour > 12) hour = hour - 12;

       if (seconds) {
              snprintf(buf, n, "%s %d %4d %d:%02d:%02d%s",
                     fmt_date_months[tm.tm_mon],
                     tm.tm_mday,
                     tm.tm_year + 1900,
                     hour,
                     tm.tm_min,
                     tm.tm_sec,
                     ( (tm.tm_hour >= 12) ? "pm" : "am" )
              );
       } else {
              snprintf(buf, n, "%s %d %4d %d:%02d%s",
                     fmt_date_months[tm.tm_mon],
                     tm.tm_mday,
                     tm.tm_year + 1900,
                     hour,
                     tm.tm_min,
                     ( (tm.tm_hour >= 12) ? "pm" : "am" )
              );
       }
}

Here is the call graph for this function:

void generate_uuid ( char *  buf)

Definition at line 875 of file tools.c.

                              {
       static int seq = (-1);
       static int no_kernel_uuid = 0;

       /* If we are running on Linux then we have a kernelspace uuid generator available */

       if (no_kernel_uuid == 0) {
              FILE *fp;
              fp = fopen("/proc/sys/kernel/random/uuid", "rb");
              if (fp) {
                     int rv;
                     rv = fread(buf, 36, 1, fp);
                     fclose(fp);
                     if (rv == 1) return;
              }
       }

       /* If the kernel didn't provide us with a uuid, we generate a pseudo-random one */

       no_kernel_uuid = 1;

       if (seq == (-1)) {
              seq = (int)rand();
       }
       ++seq;
       seq = (seq % 0x0FFF) ;

       sprintf(buf, "%08lx-%04lx-4%03x-a%03x-%012lx",
              (long)time(NULL),
              (long)getpid(),
              seq,
              seq,
              (long)rand()
       );
}
int GetCount ( HashList Hash)

Definition at line 292 of file hash.c.

{
       if(Hash==NULL) return 0;
       return Hash->nLookupTableItems;
}

Here is the caller graph for this function:

const char* GetIconFilename ( char *  MimeType,
size_t  len 
)

Definition at line 1114 of file mime_parser.c.

{
       void *vIcon;
       IconName *Icon;
       
       if(IconHash == NULL)
              return NULL;

       GetHash(IconHash, MimeType, len, &vIcon), Icon = (IconName*) vIcon;
       /* didn't find the exact mimetype? try major only. */
       if (Icon == NULL) {
              char * pMinor;
              pMinor = strchr(MimeType, '/');
              if (pMinor != NULL) {
                     *pMinor = '\0';
                     GetHash(IconHash, MimeType, pMinor - MimeType, &vIcon),
                            Icon = (IconName*) vIcon;
              }
       }
       if (Icon == NULL) {
              return NULL;
       }

       /*printf("Getting: [%s] == [%s] -> [%s]\n", MimeType, Icon->FlatName, Icon->FileName);*/
       return Icon->FileName;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int GetKey ( HashList Hash,
char *  HKey,
long  HKLen,
void **  Data 
)

Definition at line 706 of file hash.c.

{
       return 0;
}
long grab_token ( char **  dest,
const char *  source,
int  parmnum,
char  separator 
)
const char* GuessMimeByFilename ( const char *  what,
size_t  len 
)

Definition at line 970 of file mime_parser.c.

{
       /* we know some hardcoded on our own, try them... */
       if ((len > 3) && !strncasecmp(&what[len - 4], ".gif", 4))
              return "image/gif";
       else if ((len > 2) && !strncasecmp(&what[len - 3], ".js", 3))
              return  "text/javascript";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".txt", 4))
              return "text/plain";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".css", 4))
              return "text/css";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".htc", 4))
              return "text/x-component";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".jpg", 4))
              return "image/jpeg";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".png", 4))
              return "image/png";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".ico", 4))
              return "image/x-icon";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".vcf", 4))
              return "text/x-vcard";
       else if ((len > 4) && !strncasecmp(&what[len - 5], ".html", 5))
              return "text/html";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".htm", 4))
              return "text/html";
       else if ((len > 3) && !strncasecmp(&what[len - 4], ".wml", 4))
              return "text/vnd.wap.wml";
       else if ((len > 4) && !strncasecmp(&what[len - 5], ".wmls", 5))
              return "text/vnd.wap.wmlscript";
       else if ((len > 4) && !strncasecmp(&what[len - 5], ".wmlc", 5))
              return "application/vnd.wap.wmlc";
       else if ((len > 5) && !strncasecmp(&what[len - 6], ".wmlsc", 6))
              return "application/vnd.wap.wmlscriptc";
       else if ((len > 4) && !strncasecmp(&what[len - 5], ".wbmp", 5))
              return "image/vnd.wap.wbmp";
       else
              /* and let xdgmime do the fallback. */
              return xdg_mime_get_mime_type_from_file_name(what);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* GuessMimeType ( const char *  data,
size_t  dlen 
)

Definition at line 946 of file mime_parser.c.

{
       int MimeIndex = 0;

       while (MyMimes[MimeIndex].PatternLen != 0)
       {
              if ((MyMimes[MimeIndex].PatternLen + 
                   MyMimes[MimeIndex].PatternOffset < dlen) &&
                  strncmp(MyMimes[MimeIndex].Pattern, 
                         &data[MyMimes[MimeIndex].PatternOffset], 
                         MyMimes[MimeIndex].PatternLen) == 0)
              {
                     return MyMimes[MimeIndex].MimeString;
              }
              MimeIndex ++;
       }
       /* 
        * ok, our simple minded algorythm didn't find anything, 
        * let the big chegger try it, he wil default to application/octet-stream
        */
       return (xdg_mime_get_mime_type_for_data(data, dlen));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int haschar ( const char *  st,
int  ch 
)

check for the presence of a character within a string (returns count)

Parameters:
stthe string to examine
chthe char to search
Returns:
the number of times ch appears in st

Definition at line 544 of file tools.c.

{
       const char *ptr;
       int b;
       b = 0;
       ptr = st;
       while (!IsEmptyStr(ptr))
       {
              if (*ptr == ch)
                     ++b;
              ptr ++;
       }
       return (b);
}
char* html_to_ascii ( const char *  inputmsg,
int  msglen,
int  screenwidth,
int  do_citaformat 
)

Definition at line 52 of file html_to_ascii.c.

                                                                                          {
       char inbuf[SIZ];
       int inbuf_len = 0;
       char outbuf[SIZ];
       char tag[1024];
       int done_reading = 0;
       const char *inptr;
       char *outptr;
       size_t outptr_buffer_size;
       size_t output_len = 0;
       int i, j, ch, did_out, rb, scanch;
       int nest = 0;        /* Bracket nesting level */
       int blockquote = 0;  /* BLOCKQUOTE nesting level */
       int styletag = 0;    /* STYLE tag nesting level */
       int styletag_start = 0;
       int bytes_processed = 0;
       char nl[128];

       tag[0] = '\0';
       strcpy(nl, "\n");
       inptr = inputmsg;
       strcpy(inbuf, "");
       strcpy(outbuf, "");
       if (msglen == 0) msglen = strlen(inputmsg);

       outptr_buffer_size = strlen(inptr) + SIZ;
       outptr = malloc(outptr_buffer_size);
       if (outptr == NULL) return NULL;
       strcpy(outptr, "");
       output_len = 0;

       do {
              /* Fill the input buffer */
              inbuf_len = strlen(inbuf);
              if ( (done_reading == 0) && (inbuf_len < (SIZ-128)) ) {

                     ch = *inptr++;
                     if (ch != 0) {
                            inbuf[inbuf_len++] = ch;
                            inbuf[inbuf_len] = 0;
                     } 
                     else {
                            done_reading = 1;
                     }

                     ++bytes_processed;
                     if (bytes_processed > msglen) {
                            done_reading = 1;
                     }

              }

              /* Do some parsing */
              if (!IsEmptyStr(inbuf)) {


                  /* Fold in all the spacing */
                  for (i=0; !IsEmptyStr(&inbuf[i]); ++i) {
                     if (inbuf[i]==10) inbuf[i]=32;
                     if (inbuf[i]==13) inbuf[i]=32;
                     if (inbuf[i]==9) inbuf[i]=32;
                  }
                  for (i=0; !IsEmptyStr(&inbuf[i]); ++i) {
                     while ((inbuf[i]==32)&&(inbuf[i+1]==32)) {
                            strcpy(&inbuf[i], &inbuf[i+1]);
                     }
                  }

                  for (i=0; !IsEmptyStr(&inbuf[i]); ++i) {

                     ch = inbuf[i];

                     if (ch == '<') {
                            ++nest;
                            strcpy(tag, "");
                     }

                     else if (ch == '>') {       /* We have a tag. */
                            if (nest > 0) --nest;

                            /* Unqualify the tag (truncate at first space) */
                            if (strchr(tag, ' ') != NULL) {
                                   strcpy(strchr(tag, ' '), "");
                            }
                            
                            if (!strcasecmp(tag, "P")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, nl);
                            }

                            if (!strcasecmp(tag, "/DIV")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, nl);
                            }

                            if (!strcasecmp(tag, "LI")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, " * ");
                            }

                            else if (!strcasecmp(tag, "/UL")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "H1")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "H2")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "H3")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "H4")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "/H1")) {
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "/H2")) {
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "/H3")) {
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "/H4")) {
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "HR")) {
                                   strcat(outbuf, nl);
                                   strcat(outbuf, " ");
                                   for (j=0; j<screenwidth-2; ++j)
                                          strcat(outbuf, "-");
                                   strcat(outbuf, nl);
                            }

                            else if (
                                   (!strcasecmp(tag, "B"))
                                   || (!strcasecmp(tag, "/B"))
                                   || (!strcasecmp(tag, "STRONG"))
                                   || (!strcasecmp(tag, "/STRONG"))
                            ) {
                                   strcat(outbuf, "*");
                                   
                            }

                            else if (
                                   (!strcasecmp(tag, "I"))
                                   || (!strcasecmp(tag, "/I"))
                                   || (!strcasecmp(tag, "EM"))
                                   || (!strcasecmp(tag, "/EM"))
                            ) {
                                   strcat(outbuf, "/");
                                   
                            }

                            else if (
                                   (!strcasecmp(tag, "U"))
                                   || (!strcasecmp(tag, "/U"))
                            ) {
                                   strcat(outbuf, "_");
                                   
                            }

                            else if (!strcasecmp(tag, "BR")) {
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "TR")) {
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "/TABLE")) {
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "BLOCKQUOTE")) {
                                   ++blockquote;
                                   strcpy(nl, "\n");
                                   for (j=0; j<blockquote; ++j) strcat(nl, ">");
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "/BLOCKQUOTE")) {
                                   strcat(outbuf, "\n");
                                   --blockquote;
                                   strcpy(nl, "\n");
                                   for (j=0; j<blockquote; ++j) strcat(nl, ">");
                                   strcat(outbuf, nl);
                            }

                            else if (!strcasecmp(tag, "STYLE")) {
                                   ++styletag;
                                   if (styletag == 1) {
                                          styletag_start = strlen(outbuf);
                                   }
                            }

                            else if (!strcasecmp(tag, "/STYLE")) {
                                   --styletag;
                                   if (styletag == 0) {
                                          outbuf[styletag_start] = 0;
                                   }
                            }

                     }

                     else if ((nest > 0) && (strlen(tag)<(sizeof(tag)-1))) {
                            tag[strlen(tag)+1] = 0;
                            tag[strlen(tag)] = ch;
                     }
                            
                     else if (!nest) {
                            outbuf[strlen(outbuf)+1] = 0;
                            outbuf[strlen(outbuf)] = ch;
                     }
                  }
                  strcpy(inbuf, &inbuf[i]);
              }

              /* Convert &; tags to the forbidden characters */
              if (!IsEmptyStr(outbuf)) for (i=0; !IsEmptyStr(&outbuf[i]); ++i) {

                     /* Character entity references */
                     if (!strncasecmp(&outbuf[i], "&nbsp;", 6)) {
                            outbuf[i] = ' ';
                            strcpy(&outbuf[i+1], &outbuf[i+6]);
                     }

                     if (!strncasecmp(&outbuf[i], "&ensp;", 6)) {
                            outbuf[i] = ' ';
                            strcpy(&outbuf[i+1], &outbuf[i+6]);
                     }

                     if (!strncasecmp(&outbuf[i], "&emsp;", 6)) {
                            outbuf[i] = ' ';
                            strcpy(&outbuf[i+1], &outbuf[i+6]);
                     }

                     if (!strncasecmp(&outbuf[i], "&thinsp;", 8)) {
                            outbuf[i] = ' ';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&lt;", 4)) {
                            outbuf[i] = '<';
                            strcpy(&outbuf[i+1], &outbuf[i+4]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&gt;", 4)) {
                            outbuf[i] = '>';
                            strcpy(&outbuf[i+1], &outbuf[i+4]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&amp;", 5)) {
                            strcpy(&outbuf[i+1], &outbuf[i+5]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&quot;", 6)) {
                            outbuf[i] = '\"';
                            strcpy(&outbuf[i+1], &outbuf[i+6]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&lsquo;", 7)) {
                            outbuf[i] = '`';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&rsquo;", 7)) {
                            outbuf[i] = '\'';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&copy;", 6)) {
                            outbuf[i] = '(';
                            outbuf[i+1] = 'c';
                            outbuf[i+2] = ')';
                            strcpy(&outbuf[i+3], &outbuf[i+6]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&bull;", 6)) {
                            outbuf[i] = ' ';
                            outbuf[i+1] = '*';
                            outbuf[i+2] = ' ';
                            strcpy(&outbuf[i+3], &outbuf[i+6]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&hellip;", 8)) {
                            outbuf[i] = '.';
                            outbuf[i+1] = '.';
                            outbuf[i+2] = '.';
                            strcpy(&outbuf[i+3], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&trade;", 7)) {
                            outbuf[i] = '(';
                            outbuf[i+1] = 't';
                            outbuf[i+2] = 'm';
                            outbuf[i+3] = ')';
                            strcpy(&outbuf[i+4], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&reg;", 5)) {
                            outbuf[i] = '(';
                            outbuf[i+1] = 'r';
                            outbuf[i+2] = ')';
                            strcpy(&outbuf[i+3], &outbuf[i+5]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&frac14;", 8)) {
                            outbuf[i] = '1';
                            outbuf[i+1] = '/';
                            outbuf[i+2] = '4';
                            strcpy(&outbuf[i+3], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&frac12;", 8)) {
                            outbuf[i] = '1';
                            outbuf[i+1] = '/';
                            outbuf[i+2] = '2';
                            strcpy(&outbuf[i+3], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&frac34;", 8)) {
                            outbuf[i] = '3';
                            outbuf[i+1] = '/';
                            outbuf[i+2] = '4';
                            strcpy(&outbuf[i+3], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&ndash;", 7)) {
                            outbuf[i] = '-';
                            outbuf[i+1] = '-';
                            strcpy(&outbuf[i+2], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&mdash;", 7)) {
                            outbuf[i] = '-';
                            outbuf[i+1] = '-';
                            outbuf[i+2] = '-';
                            strcpy(&outbuf[i+3], &outbuf[i+7]);
                     }

                     else if (!strncmp(&outbuf[i], "&Ccedil;", 8)) {
                            outbuf[i] = 'C';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&ccedil;", 8)) {
                            outbuf[i] = 'c';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncmp(&outbuf[i], "&Egrave;", 8)) {
                            outbuf[i] = 'E';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&egrave;", 8)) {
                            outbuf[i] = 'e';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncmp(&outbuf[i], "&Ecirc;", 7)) {
                            outbuf[i] = 'E';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&ecirc;", 7)) {
                            outbuf[i] = 'e';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncmp(&outbuf[i], "&Eacute;", 8)) {
                            outbuf[i] = 'E';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&eacute;", 8)) {
                            outbuf[i] = 'e';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncmp(&outbuf[i], "&Agrave;", 8)) {
                            outbuf[i] = 'A';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&agrave;", 8)) {
                            outbuf[i] = 'a';
                            strcpy(&outbuf[i+1], &outbuf[i+8]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&ldquo;", 7)) {
                            outbuf[i] = '\"';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&rdquo;", 7)) {
                            outbuf[i] = '\"';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&acute;", 7)) {
                            outbuf[i] = '\'';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&#8217;", 7)) {
                            outbuf[i] = '\'';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     else if (!strncasecmp(&outbuf[i], "&#8211;", 7)) {
                            outbuf[i] = '-';
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

                     /* two-digit decimal equivalents */
                     else if (outbuf[i] == '&'       &&
                             outbuf[i + 1] == '#'   &&
                             isdigit(outbuf[i + 2]) && 
                             isdigit(outbuf[i + 3]) &&
                             (outbuf[i+4] == ';') ) 
                     {
                            scanch = 0;
                            sscanf(&outbuf[i+2], "%02d", &scanch);
                            outbuf[i] = scanch;
                            strcpy(&outbuf[i+1], &outbuf[i+5]);
                     }

                     /* three-digit decimal equivalents */
                     else if (outbuf[i] == '&'       &&
                             outbuf[i + 1] == '#'   &&
                             isdigit(outbuf[i + 2]) && 
                             isdigit(outbuf[i + 3]) && 
                             isdigit(outbuf[i + 4]) &&
                             (outbuf[i + 5] == ';') ) 
                     {
                            scanch = 0;
                            sscanf(&outbuf[i+2], "%03d", &scanch);
                            outbuf[i] = scanch;
                            strcpy(&outbuf[i+1], &outbuf[i+6]);
                     }

                     /* four-digit decimal equivalents */
                     else if (outbuf[i] == '&'       &&
                             outbuf[i + 1] == '#'   &&
                             isdigit(outbuf[i + 2]) && 
                             isdigit(outbuf[i + 3]) && 
                             isdigit(outbuf[i + 4]) &&
                             isdigit(outbuf[i + 5]) &&
                             (outbuf[i + 6] == ';') ) 
                     {
                            scanch = 0;
                            sscanf(&outbuf[i+2], "%04d", &scanch);
                            outbuf[i] = scanch;
                            strcpy(&outbuf[i+1], &outbuf[i+7]);
                     }

              }

              /* Make sure the output buffer is big enough */
              if ((output_len + strlen(outbuf) + SIZ) > outptr_buffer_size) {
                     outptr_buffer_size += SIZ;
                     outptr = realloc(outptr, outptr_buffer_size);
                     if (outptr == NULL) {
                            abort();
                     }
              }

              /* Output any lines terminated with hard line breaks */
              do {
                     did_out = 0;
                     if (strlen(outbuf) > 0) {
                         for (i = 0; i<strlen(outbuf); ++i) {
                            if ( (i<(screenwidth-2)) && (outbuf[i]=='\n')) {

                                   strncpy(&outptr[output_len], outbuf, i+1);
                                   output_len += (i+1);

                                   if (do_citaformat) {
                                          strcpy(&outptr[output_len], " ");
                                          ++output_len;
                                   }

                                   strcpy(outbuf, &outbuf[i+1]);
                                   i = 0;
                                   did_out = 1;
                            }
                     }
                  }
              } while (did_out);

              /* Add soft line breaks */
              if (strlen(outbuf) > (screenwidth - 2 )) {
                     rb = (-1);
                     for (i=0; i<(screenwidth-2); ++i) {
                            if (outbuf[i]==32) rb = i;
                     }
                     if (rb>=0) {
                            strncpy(&outptr[output_len], outbuf, rb);
                            output_len += rb;
                            strcpy(&outptr[output_len], nl);
                            output_len += strlen(nl);
                            if (do_citaformat) {
                                   strcpy(&outptr[output_len], " ");
                                   ++output_len;
                            }
                            strcpy(outbuf, &outbuf[rb+1]);
                     } else {
                            strncpy(&outptr[output_len], outbuf,
                                   screenwidth-2);
                            output_len += (screenwidth-2);
                            strcpy(&outptr[output_len], nl);
                            output_len += strlen(nl);
                            if (do_citaformat) {
                                   strcpy(&outptr[output_len], " ");
                                   ++output_len;
                            }
                            strcpy(outbuf, &outbuf[screenwidth-2]);
                     }
              }

       } while (done_reading == 0);

       strcpy(&outptr[output_len], outbuf);
       output_len += strlen(outbuf);

       /* Strip leading/trailing whitespace.  We can't do this with
        * striplt() because it uses too many strlen()'s
        */
       while ((output_len > 0) && (isspace(outptr[0]))) {
              strcpy(outptr, &outptr[1]);
              --output_len;
       }
       while ((output_len > 0) && (isspace(outptr[output_len-1]))) {
              outptr[output_len-1] = 0;
              --output_len;
       }

       if ((output_len > 0) && (outptr[output_len-1] != '\n')) {
              strcat(outptr, "\n");
              ++output_len;
       }

       return outptr;

}

Here is the call graph for this function:

Here is the caller graph for this function:

long IOBufferStrLength ( IOBuffer FB)

Definition at line 3873 of file stringbuf.c.

{
       if ((FB == NULL) || (FB->Buf == NULL))
              return 0;
       if (FB->ReadWritePointer == NULL)
              return StrLength(FB->Buf);
       
       return StrLength(FB->Buf) - (FB->ReadWritePointer - FB->Buf->buf);
}

Here is the call graph for this function:

int is_msg_in_mset ( const char *  mset,
long  msgnum 
)

Definition at line 1102 of file tools.c.

                                                  {
       int num_sets;
       int s;
       char setstr[SIZ], lostr[SIZ], histr[SIZ];       /* was 1024 */
       long lo, hi;

       /*
        * Now set it for all specified messages.
        */
       num_sets = num_tokens(mset, ',');
       for (s=0; s<num_sets; ++s) {
              extract_token(setstr, mset, s, ',', sizeof setstr);

              extract_token(lostr, setstr, 0, ':', sizeof lostr);
              if (num_tokens(setstr, ':') >= 2) {
                     extract_token(histr, setstr, 1, ':', sizeof histr);
                     if (!strcmp(histr, "*")) {
                            snprintf(histr, sizeof histr, "%ld", LONG_MAX);
                     }
              }
              else {
                     strcpy(histr, lostr);
              }
              lo = atol(lostr);
              hi = atol(histr);

              if ((msgnum >= lo) && (msgnum <= hi)) return(1);
       }

       return(0);
}

Here is the call graph for this function:

int is_msg_in_sequence_set ( const char *  mset,
long  msgnum 
)

Definition at line 611 of file tools.c.

                                                          {
       int num_sets;
       int s;
       char setstr[128], lostr[128], histr[128];
       long lo, hi;

       num_sets = num_tokens(mset, ',');
       for (s=0; s<num_sets; ++s) {
              extract_token(setstr, mset, s, ',', sizeof setstr);

              extract_token(lostr, setstr, 0, ':', sizeof lostr);
              if (num_tokens(setstr, ':') >= 2) {
                     extract_token(histr, setstr, 1, ':', sizeof histr);
                     if (!strcmp(histr, "*")) {
                            snprintf(histr, sizeof histr, "%ld", LONG_MAX);
                     }
              } 
              else {
                     strcpy(histr, lostr);
              }
              lo = atol(lostr);
              hi = atol(histr);

              if ((msgnum >= lo) && (msgnum <= hi)) return(1);
       }

       return(0);
}

Here is the call graph for this function:

int libcitadel_version_number ( void  )

Definition at line 55 of file libcitadel.c.

Here is the caller graph for this function:

char* libcitadel_version_string ( void  )

Definition at line 51 of file libcitadel.c.

                                      {
       return "libcitadel(unnumbered)";
}

Here is the caller graph for this function:

void LoadEntityList ( char *  FileName)
int LoadIconDir ( const char *  DirName)

Definition at line 1042 of file mime_parser.c.

{
       DIR *filedir = NULL;
       struct dirent *filedir_entry;
       int d_namelen;
       int d_without_ext;
       IconName *Icon;

       filedir = opendir (DirName);
       IconHash = NewHash(1, NULL);
       if (filedir == NULL) {
              return 0;
       }

       while ((filedir_entry = readdir(filedir)))
       {
              char *MinorPtr;
              char *PStart;
#ifdef _DIRENT_HAVE_D_NAMELEN
              d_namelen = filedir_entry->d_namelen;
#else
              d_namelen = strlen(filedir_entry->d_name);
#endif
              d_without_ext = d_namelen;
              while ((d_without_ext > 0) && (filedir_entry->d_name[d_without_ext] != '.'))
                     d_without_ext --;
              if ((d_without_ext == 0) || (d_namelen < 3))
                     continue;

              if ((sizeof(IGNORE_PREFIX_1) < d_namelen) &&
                  (strncmp(IGNORE_PREFIX_1, 
                          filedir_entry->d_name, 
                          sizeof(IGNORE_PREFIX_1) - 1) == 0)) {
                     PStart = filedir_entry->d_name + sizeof(IGNORE_PREFIX_1);
                     d_without_ext -= sizeof(IGNORE_PREFIX_1);
              }
              else {
                     PStart = filedir_entry->d_name;
              }
              Icon = malloc(sizeof(IconName));

              Icon->FileName = malloc(d_namelen + 1);
              memcpy(Icon->FileName, filedir_entry->d_name, d_namelen + 1);

              Icon->FlatName = malloc(d_without_ext + 1);
              memcpy(Icon->FlatName, PStart, d_without_ext);
              Icon->FlatName[d_without_ext] = '\0';
              /* Try to find Minor type in image-jpeg */
              MinorPtr = strchr(Icon->FlatName, '-');
              if (MinorPtr != NULL) {
                     size_t MinorLen;
                     MinorLen = 1 + d_without_ext - (MinorPtr - Icon->FlatName + 1);
                     if ((MinorLen == sizeof(GENSTR)) && 
                         (strncmp(MinorPtr + 1, GENSTR, sizeof(GENSTR)) == 0)) {
                            /* ok, we found a generic filename. cut the generic. */
                            *MinorPtr = '\0';
                            d_without_ext = d_without_ext - (MinorPtr - Icon->FlatName);
                     }
                     else { /* Map the major / minor separator to / */
                            *MinorPtr = '/';
                     }
              }

//            PrintHash(IconHash, PrintFlat, PrintFile);
//            printf("%s - %s\n", Icon->FlatName, Icon->FileName);
              Put(IconHash, Icon->FlatName, d_without_ext, Icon, DeleteIcon);
//            PrintHash(IconHash, PrintFlat, PrintFile);
       }
       closedir(filedir);
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* memreadline ( char *  start,
char *  buf,
int  maxlen 
)

Utility function to "readline" from memory.

Parameters:
startLocation in memory from which we are reading.
bufthe buffer to place the string in.
maxlenSize of string buffer
Returns:
Pointer to the source memory right after we stopped reading.

< tally our own length to avoid strlen() delays

Definition at line 647 of file tools.c.

{
       char ch;
       char *ptr;
       int len = 0;         
       ptr = start;

       while (1) {
              ch = *ptr++;
              if ((len + 1 < (maxlen)) && (ch != 13) && (ch != 10)) {
                     buf[len++] = ch;
              }
              if ((ch == 10) || (ch == 0)) {
                     buf[len] = 0;
                     return ptr;
              }
       }
}
char* memreadlinelen ( char *  start,
char *  buf,
int  maxlen,
int *  retlen 
)

Utility function to "readline" from memory.

Parameters:
startLocation in memory from which we are reading.
bufthe buffer to place the string in.
maxlenSize of string buffer
retlenthe length of the returned string
Returns:
Pointer to the source memory right after we stopped reading.

< tally our own length to avoid strlen() delays

Definition at line 676 of file tools.c.

{
       char ch;
       char *ptr;
       int len = 0;         
       ptr = start;

       while (1) {
              ch = *ptr++;
              if ((len + 1 < (maxlen)) && (ch != 13) && (ch != 10)) {
                     buf[len++] = ch;
              }
              if ((ch == 10) || (ch == 0)) {
                     buf[len] = 0;
                     *retlen = len;
                     return ptr;
              }
       }
}

Here is the caller graph for this function:

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,
MimeParserCallBackType  CallBack,
MimeParserCallBackType  PreMultiPartCallBack,
MimeParserCallBackType  PostMultiPartCallBack,
void *  userdata,
int  dont_decode 
)

Definition at line 201 of file mime_parser.c.

{

       char *decoded;
       size_t bytes_decoded = 0;

       /* Some encodings aren't really encodings */
       if (!strcasecmp(encoding, "7bit"))
              strcpy(encoding, "");
       if (!strcasecmp(encoding, "8bit"))
              strcpy(encoding, "");
       if (!strcasecmp(encoding, "binary"))
              strcpy(encoding, "");
       if (!strcasecmp(encoding, "ISO-8859-1"))
              strcpy(encoding, "");

       /* If this part is not encoded, send as-is */
       if ( (strlen(encoding) == 0) || (dont_decode)) {
              if (CallBack != NULL) {
                     CallBack(name, 
                             filename, 
                             fixed_partnum(partnum),
                             disposition, 
                             part_start,
                             content_type, 
                             charset, 
                             length, 
                             encoding, 
                             id,
                             userdata);
                     }
              return;
       }
       
       /* Fail silently if we hit an unknown encoding. */
       if ((strcasecmp(encoding, "base64"))
           && (strcasecmp(encoding, "quoted-printable"))) {
              return;
       }

       /*
        * Allocate a buffer for the decoded data.  The output buffer is slightly
        * larger than the input buffer; this assumes that the decoded data
        * will never be significantly larger than the encoded data.  This is a
        * safe assumption with base64, uuencode, and quoted-printable.
        */
       decoded = malloc(length + 32768);
       if (decoded == NULL) {
              return;
       }

       if (!strcasecmp(encoding, "base64")) {
              bytes_decoded = CtdlDecodeBase64(decoded, part_start, length);
       }
       else if (!strcasecmp(encoding, "quoted-printable")) {
              bytes_decoded = CtdlDecodeQuotedPrintable(decoded, part_start, length);
       }

       if (bytes_decoded > 0) if (CallBack != NULL) {
                     char encoding_buf[SIZ];

                     strcpy(encoding_buf, "binary");
                     CallBack(name, 
                             filename, 
                             fixed_partnum(partnum),
                             disposition, 
                             decoded,
                             content_type, 
                             charset, 
                             bytes_decoded, 
                             encoding_buf, 
                             id, 
                             userdata);
       }

       free(decoded);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int mime_decode_now ( char *  part_start,
size_t  length,
char *  encoding,
char **  decoded,
size_t *  bytes_decoded 
)

Definition at line 297 of file mime_parser.c.

{
       *bytes_decoded = 0;
       *decoded = NULL;
       /* Some encodings aren't really encodings */
       if (!strcasecmp(encoding, "7bit"))
              strcpy(encoding, "");
       if (!strcasecmp(encoding, "8bit"))
              strcpy(encoding, "");
       if (!strcasecmp(encoding, "binary"))
              strcpy(encoding, "");

       /* If this part is not encoded, send as-is */
       if (strlen(encoding) == 0) {
              return 0;
       }
       

       /* Fail if we hit an unknown encoding. */
       if ((strcasecmp(encoding, "base64"))
           && (strcasecmp(encoding, "quoted-printable"))) {
              return -1;
       }

       /*
        * Allocate a buffer for the decoded data.  The output buffer is slightly
        * larger than the input buffer; this assumes that the decoded data
        * will never be significantly larger than the encoded data.  This is a
        * safe assumption with base64, uuencode, and quoted-printable.
        */
       *decoded = malloc(length + 32768);
       if (decoded == NULL) {
              return -1;
       }

       if (!strcasecmp(encoding, "base64")) {
              *bytes_decoded = CtdlDecodeBase64(*decoded, part_start, length);
              return 1;
       }
       else if (!strcasecmp(encoding, "quoted-printable")) {
              *bytes_decoded = CtdlDecodeQuotedPrintable(*decoded, part_start, length);
              return 1;
       }
       return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mime_parser ( char *  content_start,
char *  content_end,
MimeParserCallBackType  CallBack,
MimeParserCallBackType  PreMultiPartCallBack,
MimeParserCallBackType  PostMultiPartCallBack,
void *  userdata,
int  dont_decode 
)

Definition at line 890 of file mime_parser.c.

{

       the_mime_parser("", content_start, content_end,
                     CallBack,
                     PreMultiPartCallBack,
                     PostMultiPartCallBack,
                     userdata, dont_decode);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* myfgets ( char *  s,
int  size,
FILE *  stream 
)

Definition at line 813 of file tools.c.

                                               {
       char *ret = fgets(s, size, stream);
       char *nl;

       if (ret != NULL) {
              nl = strchr(s, '\n');

              if (nl != NULL)
                     *nl = 0;
       }

       return ret;
}
int num_tokens ( const char *  source,
char  tok 
)

Definition at line 124 of file tools.c.

{
       int count = 1;
       const char *ptr = source;

       if (source == NULL) {
              return (0);
       }

       while (*ptr != '\0') {
              if (*ptr++ == tok) {
                     ++count;
              }
       }
       
       return (count);
}

Here is the caller graph for this function:

int pattern2 ( char *  search,
char *  patn 
)

Definition at line 1139 of file tools.c.

{
       int a;
       int len, plen;
       len = strlen (search);
       plen = strlen (patn);
       for (a = 0; a < len; ++a) {
              if (!strncasecmp(&search[a], patn, plen))
                     return (a);
       }
       return (-1);
}

Here is the caller graph for this function:

void remove_charset_attribute ( char *  strbuf)

Definition at line 68 of file vcard.c.

{
       int i, t;
       char compare[256];

       t = num_tokens(strbuf, ';');
       for (i=0; i<t; ++i) {
              extract_token(compare, strbuf, i, ';', sizeof compare);
              striplt(compare);
              if (!strncasecmp(compare, "charset=", 8)) {
                     remove_token(strbuf, i, ';');
              }
       }
       if (!IsEmptyStr(strbuf)) {
              if (strbuf[strlen(strbuf)-1] == ';') {
                     strbuf[strlen(strbuf)-1] = 0;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_token ( char *  source,
int  parmnum,
char  separator 
)

Definition at line 244 of file tools.c.

{
       char *d, *s;         /* dest, source */
       int count = 0;

       /* Find desired parameter */
       d = source;
       while (count < parmnum) {
              /* End of string, bail! */
              if (!*d) {
                     d = NULL;
                     break;
              }
              if (*d == separator) {
                     count++;
              }
              d++;
       }
       if (!d) return;             /* Parameter not found */

       /* Find next parameter */
       s = d;
       while (*s && *s != separator) {
              s++;
       }

       /* Hack and slash */
       if (*s)
              strcpy(d, ++s);
       else if (d == source)
              *d = 0;
       else
              *--d = 0;
       /*
       while (*s) {
              *d++ = *s++;
       }
       *d = 0;
       */
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* rfc2047encode ( char *  line,
long  length 
)

Definition at line 448 of file tools.c.

{
       char *AlreadyEncoded;
       char *result;
       long end;
#define UTF8_HEADER "=?UTF-8?B?"

       /* check if we're already done */
       AlreadyEncoded = strstr(line, "=?");
       if ((AlreadyEncoded != NULL) &&
           ((strstr(AlreadyEncoded, "?B?") != NULL)||
            (strstr(AlreadyEncoded, "?Q?") != NULL)))
       {
              return strdup(line);
       }

       result = (char*) malloc(sizeof(UTF8_HEADER) + 4 + length * 2);
       strncpy (result, UTF8_HEADER, strlen (UTF8_HEADER));
       CtdlEncodeBase64(result + strlen(UTF8_HEADER), line, length, 0);
       end = strlen (result);
        result[end]='?';
       result[end+1]='=';
       result[end+2]='\0';
       return result;
}

Here is the call graph for this function:

int safestrncpy ( char *  dest,
const char *  src,
size_t  n 
)

Definition at line 101 of file tools.c.

{
       int i = 0;

       if (dest == NULL || src == NULL) {
              fprintf(stderr, "safestrncpy: NULL argument\n");
              abort();
       }

       do {
              dest[i] = src[i];
              if (dest[i] == 0) return i;
              ++i;
       } while (i<n);
       dest[n - 1] = 0;
       return -i;
}

Here is the caller graph for this function:

void ShutDownLibCitadel ( void  )

Definition at line 64 of file libcitadel.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void StartLibCitadel ( size_t  basesize)

Definition at line 59 of file libcitadel.c.

{
       BaseStrBufSize = basesize;
}

Here is the caller graph for this function:

long StrBuf_read_one_chunk_callback ( int  fd,
short  event,
IOBuffer FB 
)

Definition at line 3651 of file stringbuf.c.

{
       long bufremain = 0;
       int n;
       
       if ((FB == NULL) || (FB->Buf == NULL))
              return -1;

       /*
        * check whether the read pointer is somewhere in a range 
        * where a cut left is inexpensive
        */

       if (FB->ReadWritePointer != NULL)
       {
              long already_read;
              
              already_read = FB->ReadWritePointer - FB->Buf->buf;
              bufremain = FB->Buf->BufSize - FB->Buf->BufUsed - 1;

              if (already_read != 0) {
                     long unread;
                     
                     unread = FB->Buf->BufUsed - already_read;

                     /* else nothing to compact... */
                     if (unread == 0) {
                            FB->ReadWritePointer = FB->Buf->buf;
                            bufremain = FB->Buf->BufSize;                    
                     }
                     else if ((unread < 64) || 
                             (bufremain < already_read))
                     {
                            /* 
                             * if its just a tiny bit remaining, or we run out of space... 
                             * lets tidy up.
                             */
                            FB->Buf->BufUsed = unread;
                            if (unread < already_read)
                                   memcpy(FB->Buf->buf, FB->ReadWritePointer, unread);
                            else
                                   memmove(FB->Buf->buf, FB->ReadWritePointer, unread);
                            FB->ReadWritePointer = FB->Buf->buf;
                            bufremain = FB->Buf->BufSize - unread - 1;
                     }
                     else if (bufremain < (FB->Buf->BufSize / 10))
                     {
                            /* get a bigger buffer */ 

                            IncreaseBuf(FB->Buf, 0, FB->Buf->BufUsed + 1);

                            FB->ReadWritePointer = FB->Buf->buf + unread;

                            bufremain = FB->Buf->BufSize - unread - 1;
/*TODO: special increase function that won't copy the already read! */
                     }
              }
              else if (bufremain < 10) {
                     IncreaseBuf(FB->Buf, 1, FB->Buf->BufUsed + 10);
                     
                     FB->ReadWritePointer = FB->Buf->buf;
                     
                     bufremain = FB->Buf->BufSize - FB->Buf->BufUsed - 1;
              }
              
       }
       else {
              FB->ReadWritePointer = FB->Buf->buf;
              bufremain = FB->Buf->BufSize - 1;
       }

       n = read(fd, FB->Buf->buf + FB->Buf->BufUsed, bufremain);

       if (n > 0) {
              FB->Buf->BufUsed += n;
              FB->Buf->buf[FB->Buf->BufUsed] = '\0';
       }
       return n;
}

Here is the call graph for this function:

int StrBuf_write_one_chunk_callback ( int  fd,
short  event,
IOBuffer FB 
)

Definition at line 3731 of file stringbuf.c.

{
       long WriteRemain;
       int n;

       if ((FB == NULL) || (FB->Buf == NULL))
              return -1;

       if (FB->ReadWritePointer != NULL)
       {
              WriteRemain = FB->Buf->BufUsed - 
                     (FB->ReadWritePointer - 
                      FB->Buf->buf);
       }
       else {
              FB->ReadWritePointer = FB->Buf->buf;
              WriteRemain = FB->Buf->BufUsed;
       }

       n = write(fd, FB->ReadWritePointer, WriteRemain);
       if (n > 0) {
              FB->ReadWritePointer += n;

              if (FB->ReadWritePointer == 
                  FB->Buf->buf + FB->Buf->BufUsed)
              {
                     FlushStrBuf(FB->Buf);
                     FB->ReadWritePointer = NULL;
                     return 0;
              }
       // check whether we've got something to write
       // get the maximum chunk plus the pointer we can send
       // write whats there
       // if not all was sent, remember the send pointer for the next time
              return FB->ReadWritePointer - FB->Buf->buf + FB->Buf->BufUsed;
       }
       return n;
}

Here is the call graph for this function:

check whether the chunk-buffer has more data waiting or not.

Parameters:
FBChunk-Buffer to inspect

Definition at line 3860 of file stringbuf.c.

{
       if (FB == NULL)
              return eReadFail;
       if (FB->Buf->BufUsed == 0)
              return eReadSuccess;
       if (FB->ReadWritePointer == NULL)
              return eBufferNotEmpty;
       if (FB->Buf->buf + FB->Buf->BufUsed > FB->ReadWritePointer)
              return eBufferNotEmpty;
       return eReadSuccess;
}
int StrBufExtract_tokenFromStr ( StrBuf dest,
const char *  Source,
long  SourceLen,
int  parmnum,
char  separator 
)

Definition at line 1348 of file stringbuf.c.

{
       const StrBuf Temp = {
              (char*)Source,
              SourceLen,
              SourceLen,
              1
#ifdef SIZE_DEBUG
              ,
              0,
              "",
              ""
#endif
       };

       return StrBufExtract_token(dest, &Temp, parmnum, separator);
}

Here is the call graph for this function:

void StrBufPrintf ( StrBuf Buf,
const char *  format,
  ... 
)

Here is the caller graph for this function:

StrBuf* StrBufSanitizeEmailRecipientVector ( const StrBuf Recp,
StrBuf UserName,
StrBuf EmailAddress,
StrBuf EncBuf 
)

QP encode parts of an email TO/CC/BCC vector, and strip/filter invalid parts.

Parameters:
RecpSource list of email recipients
UserNameTemporary buffer for internal use; Please provide valid buffer.
EmailAddressTemporary buffer for internal use; Please provide valid buffer.
EncBufTemporary buffer for internal use; Please provide valid buffer.
Returns:
encoded & sanitized buffer with the contents of Recp; Caller owns this memory.

TODO: Userfeedback??

Definition at line 2835 of file stringbuf.c.

{
       StrBuf *Target;
       const char *pch, *pche;
       const char *UserStart, *UserEnd, *EmailStart, *EmailEnd, *At;

       if ((Recp == NULL) || (StrLength(Recp) == 0))
              return NULL;

       pch = ChrPtr(Recp);
       pche = pch + StrLength(Recp);

       if (!CheckEncode(pch, -1, pche))
              return NewStrBufDup(Recp);

       Target = NewStrBufPlain(NULL, StrLength(Recp));

       while ((pch != NULL) && (pch < pche))
       {
              while (isspace(*pch)) pch++;
              UserEnd = EmailStart = EmailEnd = NULL;
              
              if ((*pch == '"') || (*pch == '\'')) {
                     UserStart = pch + 1;
                     
                     UserEnd = strchr(UserStart, *pch);
                     if (UserEnd == NULL) 
                            break; 
                     EmailStart = UserEnd + 1;
                     while (isspace(*EmailStart))
                            EmailStart++;
                     if (UserEnd == UserStart) {
                            UserStart = UserEnd = NULL;
                     }
                     
                     if (*EmailStart == '<') {
                            EmailStart++;
                            EmailEnd = strchr(EmailStart, '>');
                            if (EmailEnd == NULL)
                                   EmailEnd = strchr(EmailStart, ',');
                            
                     }
                     else {
                            EmailEnd = strchr(EmailStart, ',');
                     }
                     if (EmailEnd == NULL)
                            EmailEnd = pche;
                     pch = EmailEnd + 1;
              }
              else {
                     int gt = 0;
                     UserStart = pch;
                     EmailEnd = strchr(UserStart, ',');
                     if (EmailEnd == NULL) {
                            EmailEnd = strchr(pch, '>');
                            pch = NULL;
                            if (EmailEnd != NULL) {
                                   gt = 1;
                            }
                            else {
                                   EmailEnd = pche;
                            }
                     }
                     else {

                            pch = EmailEnd + 1;
                            while ((EmailEnd > UserStart) && !gt &&
                                   ((*EmailEnd == ',') ||
                                   (*EmailEnd == '>') ||
                                   (isspace(*EmailEnd))))
                            {
                                   if (*EmailEnd == '>')
                                          gt = 1;
                                   else 
                                          EmailEnd--;
                            }
                            if (EmailEnd == UserStart)
                                   break;
                     }
                     if (gt) {
                            EmailStart = strchr(UserStart, '<');
                            if ((EmailStart == NULL) || (EmailStart > EmailEnd))
                                   break;
                            UserEnd = EmailStart;

                            while ((UserEnd > UserStart) && 
                                   isspace (*(UserEnd - 1)))
                                   UserEnd --;
                            EmailStart ++;
                            if (UserStart >= UserEnd)
                                   UserStart = UserEnd = NULL;
                     }
                     else { /* this is a local recipient... no domain, just a realname */
                            EmailStart = UserStart;
                            At = strchr(EmailStart, '@');
                            if (At == NULL) {
                                   UserEnd = EmailEnd;
                                   EmailEnd = NULL;
                            }
                            else {
                                   EmailStart = UserStart;
                                   UserStart = NULL;
                            }
                     }
              }

              if ((UserStart != NULL) && (UserEnd != NULL))
                     StrBufPlain(UserName, UserStart, UserEnd - UserStart);
              else if ((UserStart != NULL) && (UserEnd == NULL))
                     StrBufPlain(UserName, UserStart, UserEnd - UserStart);
              else
                     FlushStrBuf(UserName);

              if ((EmailStart != NULL) && (EmailEnd != NULL))
                     StrBufPlain(EmailAddress, EmailStart, EmailEnd - EmailStart);
              else if ((EmailStart != NULL) && (EmailEnd == NULL))
                     StrBufPlain(EmailAddress, EmailStart, EmailEnd - pche);
              else 
                     FlushStrBuf(EmailAddress);

              AddRecipient(Target, UserName, EmailAddress, EncBuf);

              if (pch == NULL)
                     break;
              
              if ((pch != NULL) && (*pch == ','))
                     pch ++;
              if (pch != NULL) while (isspace(*pch))
                     pch ++;
       }
       return Target;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void StrBufStripAllBut ( StrBuf Buf,
char  leftboundary,
char  rightboundary 
)

Definition at line 1144 of file stringbuf.c.

{
       const char *pBuff;
       const char *pLeft;
       const char *pRight;

       if ((Buf == NULL) || (Buf->buf == NULL))
              return;
       pLeft = pBuff = Buf->buf;
       while (pBuff != NULL) {
              pLeft = pBuff;
              pBuff = strchr(pBuff, leftboundary);
              if (pBuff != NULL)
                     pBuff++;
       }
              
       if (pLeft != NULL)
              pBuff = pLeft;
       else
              pBuff = Buf->buf;
       pRight = strchr(pBuff, rightboundary);
       if (pRight != NULL)
              StrBufCutAt(Buf, 0, pRight);
       if (pLeft != NULL)
              StrBufCutLeft(Buf, pLeft - Buf->buf);
}

Here is the call graph for this function:

long stripallbut ( char *  str,
char  leftboundary,
char  rightboundary 
)

Definition at line 789 of file tools.c.

                                                                   {
       long len = 0;

       char *lb = NULL;
       char *rb = NULL;

       lb = strrchr(str, leftboundary);
       if (lb != NULL) {
              ++lb;
              rb = strchr(str, rightboundary);
              if ((rb != NULL) && (rb >= lb))  {
                     *rb = 0;
                     fflush(stderr);
                     len = (long)rb - (long)lb;
                     memmove(str, lb, len);
                     str[len] = 0;
                     return(len);
              }
       }

       return (long)strlen(str);
}

Here is the caller graph for this function:

size_t striplt ( char *  )

Definition at line 507 of file tools.c.

                          {
       char *first_nonspace = NULL;
       char *last_nonspace = NULL;
       char *ptr;
       size_t new_len = 0;

       if ((buf == NULL) || (*buf == '\0')) {
              return 0;
       }

       for (ptr=buf; *ptr!=0; ++ptr) {
              if (!isspace(*ptr)) {
                     if (!first_nonspace) {
                            first_nonspace = ptr;
                     }
                     last_nonspace = ptr;
              }
       }

       if ((!first_nonspace) || (!last_nonspace)) {
              buf[0] = 0;
              return 0;
       }

       new_len = last_nonspace - first_nonspace + 1;
       memmove(buf, first_nonspace, new_len);
       buf[new_len] = 0;
       return new_len;
}

Here is the caller graph for this function:

void stripltlen ( char *  ,
int *   
)

Definition at line 1158 of file tools.c.

{
       int delta = 0;
       if (*len == 0) return;
       while ((*len > delta) && (isspace(buf[delta]))){
              delta ++;
       }
       memmove (buf, &buf[delta], *len - delta + 1);
       (*len) -=delta;

       if (*len == 0) return;
       while (isspace(buf[(*len) - 1])){
              buf[--(*len)] = '\0';
       }
}
int stripout ( char *  str,
char  leftboundary,
char  rightboundary 
)

Definition at line 762 of file tools.c.

                                                               {
       int a;
        int lb = (-1);
        int rb = (-1);

        for (a = 0; a < strlen(str); ++a) {
                if (str[a] == leftboundary) lb = a;
                if (str[a] == rightboundary) rb = a;
        }

        if ( (lb > 0) && (rb > lb) ) {
                strcpy(&str[lb - 1], &str[rb + 1]);
              return 1;
        }

        else if ( (lb == 0) && (rb > lb) ) {
                strcpy(str, &str[rb + 1]);
              return 1;
        }
       return 0;
}

Here is the call graph for this function:

void StripSlashes ( char *  Dir,
int  TrailingSlash 
)

Definition at line 478 of file tools.c.

{
       char *a, *b;

       a = b = Dir;

       while (!IsEmptyStr(a)) {
              if (*a == '/') {
                     while (*a == '/')
                            a++;
                     *b = '/';
                     b++;
              }
              else {
                     *b = *a;
                     b++; a++;
              }
       }
       if ((TrailingSlash) && (*(b - 1) != '/')){
              *b = '/';
              b++;
       }
       *b = '\0';

}
int TestValidateHash ( HashList TestHash)

Definition at line 243 of file hash.c.

{
       long i;

       if (TestHash->nMembersUsed != TestHash->nLookupTableItems)
              return 1;

       if (TestHash->nMembersUsed > TestHash->MemberSize)
              return 2;

       for (i=0; i < TestHash->nMembersUsed; i++)
       {

              if (TestHash->LookupTable[i]->Position > TestHash->nMembersUsed)
                     return 3;
              
              if (TestHash->Members[TestHash->LookupTable[i]->Position] == NULL)
                     return 4;
              if (TestHash->Members[TestHash->LookupTable[i]->Position]->Data == NULL)
                     return 5;
       }
       return 0;
}
void the_mime_parser ( char *  partnum,
char *  content_start,
char *  content_end,
MimeParserCallBackType  CallBack,
MimeParserCallBackType  PreMultiPartCallBack,
MimeParserCallBackType  PostMultiPartCallBack,
void *  userdata,
int  dont_decode 
)

Definition at line 852 of file mime_parser.c.

{
       interesting_mime_headers *m;

       /* If the caller didn't supply an endpointer, generate one by measure */
       if (content_end == NULL) {
              content_end = &content_start[strlen(content_start)];
       }

       m = InitInterestingMimes();

       if (!parse_MimeHeaders(m, &content_start, content_end))
       {

              recurseable_mime_parser(partnum,
                                   content_start, content_end,
                                   CallBack,
                                   PreMultiPartCallBack,
                                   PostMultiPartCallBack,
                                   userdata,
                                   dont_decode,
                                   m);
       }
       free(m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void urlesc ( char *  outbuf,
size_t  oblen,
char *  strbuf 
)

Escape a string for feeding out as a URL.

Parameters:
outbufthe output buffer
oblenthe size of outbuf to sanitize
strbufthe input buffer

Definition at line 833 of file tools.c.

{
       int a, b, c, len, eclen, olen;
       char *ec = " +#&;`'|*?-~<>^()[]{}/$\"\\";

       strcpy(outbuf, "");
       len = strlen(strbuf);
       eclen = strlen(ec);
       olen = 0;
       for (a = 0; a < len; ++a) {
              c = 0;
              for (b = 0; b < eclen; ++b) {
                     if (strbuf[a] == ec[b])
                            c = 1;
              }
              if (c == 1) {
                     snprintf(&outbuf[olen], oblen - olen, "%%%02x", strbuf[a]);
                     olen += 3;
              }
              else 
                     outbuf[olen ++] = strbuf[a];
       }
       outbuf[olen] = '\0';
}

Here is the call graph for this function:

void vcard_add_prop ( struct vCard v,
char *  propname,
char *  propvalue 
)

Definition at line 96 of file vcard.c.

                                                                      {
       ++v->numprops;
       v->prop = realloc(v->prop,
              (v->numprops * sizeof(struct vCardProp)) );
       v->prop[v->numprops-1].name = strdup(propname);
       v->prop[v->numprops-1].value = strdup(propvalue);
}
void vcard_fn_to_n ( char *  vname,
char *  n,
size_t  vname_size 
)

Definition at line 352 of file vcard.c.

                                                            {
       char lastname[256];
       char firstname[256];
       char middlename[256];
       char honorific_prefixes[256];
       char honorific_suffixes[256];
       char buf[256];

       safestrncpy(buf, n, sizeof buf);

       /* Try to intelligently convert the screen name to a
        * fully expanded vCard name based on the number of
        * words in the name
        */
       safestrncpy(lastname, "", sizeof lastname);
       safestrncpy(firstname, "", sizeof firstname);
       safestrncpy(middlename, "", sizeof middlename);
       safestrncpy(honorific_prefixes, "", sizeof honorific_prefixes);
       safestrncpy(honorific_suffixes, "", sizeof honorific_suffixes);

       /* Honorific suffixes */
       if (num_tokens(buf, ',') > 1) {
              extract_token(honorific_suffixes, buf, (num_tokens(buf, ' ') - 1), ',',
                     sizeof honorific_suffixes);
              remove_token(buf, (num_tokens(buf, ',') - 1), ',');
       }

       /* Find a last name */
       extract_token(lastname, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof lastname);
       remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');

       /* Find honorific prefixes */
       if (num_tokens(buf, ' ') > 2) {
              extract_token(honorific_prefixes, buf, 0, ' ', sizeof honorific_prefixes);
              remove_token(buf, 0, ' ');
       }

       /* Find a middle name */
       if (num_tokens(buf, ' ') > 1) {
              extract_token(middlename, buf, (num_tokens(buf, ' ') - 1), ' ', sizeof middlename);
              remove_token(buf, (num_tokens(buf, ' ') - 1), ' ');
       }

       /* Anything left is probably the first name */
       safestrncpy(firstname, buf, sizeof firstname);
       striplt(firstname);

       /* Compose the structured name */
       snprintf(vname, vname_size, "%s;%s;%s;%s;%s", lastname, firstname, middlename,
              honorific_prefixes, honorific_suffixes);
}

Here is the call graph for this function:

void vcard_free ( struct vCard )

Definition at line 240 of file vcard.c.

                                 {
       int i;
       
       if (v->magic != CTDL_VCARD_MAGIC) return; /* Self-check */
       
       if (v->numprops) for (i=0; i<(v->numprops); ++i) {
              free(v->prop[i].name);
              free(v->prop[i].value);
       }

       if (v->prop != NULL) free(v->prop);
       
       memset(v, 0, sizeof(struct vCard));
       free(v);
}
char* vcard_get_prop ( struct vCard v,
char *  propname,
int  is_partial,
int  instance,
int  return_propname 
)

Definition at line 208 of file vcard.c.

                                                                     {
       int i;
       int found_instance = 0;

       if (v->numprops) for (i=0; i<(v->numprops); ++i) {
              if ( (!strcasecmp(v->prop[i].name, propname))
                 || (propname[0] == 0)
                 || (  (!strncasecmp(v->prop[i].name,
                                   propname, strlen(propname)))
                      && (v->prop[i].name[strlen(propname)] == ';')
                      && (is_partial) ) ) {
                     if (instance == found_instance++) {
                            if (get_propname) {
                                   return(v->prop[i].name);
                            }
                            else {
                                   return(v->prop[i].value);
                            }
                     }
              }
       }

       return NULL;
}
struct vCard* vcard_load ( char *  vtext) [read]

Definition at line 114 of file vcard.c.

                                      {
       struct vCard *v;
       int valid = 0;
       char *mycopy, *ptr;
       char *namebuf, *valuebuf;
       int i;
       int colonpos, nlpos;

       if (vtext == NULL) return vcard_new();
       mycopy = strdup(vtext);
       if (mycopy == NULL) return NULL;

       /*
        * First, fix this big pile o' vCard to make it more parseable.
        * To make it easier to parse, we convert CRLF to LF, and unfold any
        * multi-line fields into single lines.
        */
       for (i=0; !IsEmptyStr(&mycopy[i]); ++i) {
              if (!strncmp(&mycopy[i], "\r\n", 2)) {
                     strcpy(&mycopy[i], &mycopy[i+1]);
              }
              if ( (mycopy[i]=='\n') && (isspace(mycopy[i+1])) ) {
                     strcpy(&mycopy[i], &mycopy[i+1]);
              }
       }

       v = vcard_new();
       if (v == NULL) return v;

       ptr = mycopy;
       while (!IsEmptyStr(ptr)) {
              colonpos = pattern2(ptr, ":");
              nlpos = pattern2(ptr, "\n");

              if ((nlpos > colonpos) && (colonpos > 0)) {
                     namebuf = malloc(colonpos + 1);
                     valuebuf = malloc(nlpos - colonpos + 1);
                     memcpy(namebuf, ptr, colonpos);
                     namebuf[colonpos] = '\0';
                     memcpy(valuebuf, &ptr[colonpos+1], nlpos-colonpos-1);
                     valuebuf[nlpos-colonpos-1] = '\0';

                     if (!strcasecmp(namebuf, "end")) {
                            valid = 0;
                     }
                     if (   (!strcasecmp(namebuf, "begin"))
                            && (!strcasecmp(valuebuf, "vcard"))
                     ) {
                            valid = 1;
                     }

                     if ( (valid) && (strcasecmp(namebuf, "begin")) ) {
                            remove_charset_attribute(namebuf);
                            ++v->numprops;
                            v->prop = realloc(v->prop,
                                   (v->numprops * sizeof(struct vCardProp))
                            );
                            v->prop[v->numprops-1].name = namebuf;
                            v->prop[v->numprops-1].value = valuebuf;
                     } 
                     else {
                            free(namebuf);
                            free(valuebuf);
                     }

              }

              while ( (*ptr != '\n') && (!IsEmptyStr(ptr)) ) {
                     ++ptr;
              }
              if (*ptr == '\n') ++ptr;
       }

       free(mycopy);
       return v;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct vCard* vcard_new ( void  ) [read]

Definition at line 51 of file vcard.c.

                          {
       struct vCard *v;

       v = (struct vCard *) malloc(sizeof(struct vCard));
       if (v == NULL) return v;

       v->magic = CTDL_VCARD_MAGIC;
       v->numprops = 0;
       v->prop = NULL;

       return v;
}

Here is the caller graph for this function:

char* vcard_serialize ( struct vCard )

Definition at line 296 of file vcard.c.

{
       char *ser;
       int i, j;
       size_t len;
       int is_utf8 = 0;

       if (v == NULL) return NULL;               /* self check */
       if (v->magic != CTDL_VCARD_MAGIC) return NULL;   /* self check */

       /* Set the vCard version number to 2.1 at this time. */
       vcard_set_prop(v, "VERSION", "2.1", 0);

       /* Figure out how big a buffer we need to allocate */
       len = 64;     /* for begin, end, and a little padding for safety */
       if (v->numprops) for (i=0; i<(v->numprops); ++i) {
              len = len +
                     strlen(v->prop[i].name) +
                     strlen(v->prop[i].value) + 16;
       }

       ser = malloc(len);
       if (ser == NULL) return NULL;

       safestrncpy(ser, "begin:vcard\r\n", len);
       if (v->numprops) for (i=0; i<(v->numprops); ++i) {
              if ( (strcasecmp(v->prop[i].name, "end")) && (v->prop[i].value != NULL) ) {
                     is_utf8 = 0;
                     for (j=0; !IsEmptyStr(&v->prop[i].value[j]); ++j) {
                            if ( (v->prop[i].value[j] < 32) || (v->prop[i].value[j] > 126) ) {
                                   is_utf8 = 1;
                            }
                     }
                     strcat(ser, v->prop[i].name);
                     if (is_utf8) {
                            strcat(ser, ";charset=UTF-8");
                     }
                     strcat(ser, ":");
                     strcat(ser, v->prop[i].value);
                     strcat(ser, "\r\n");
              }
       }
       strcat(ser, "end:vcard\r\n");

       return ser;
}

Here is the call graph for this function:

void vcard_set_prop ( struct vCard v,
char *  name,
char *  value,
int  append 
)

Definition at line 266 of file vcard.c.

                                                                          {
       int i;

       if (v->magic != CTDL_VCARD_MAGIC) return; /* Self-check */

       /* If this key is already present, replace it */
       if (!append) if (v->numprops) for (i=0; i<(v->numprops); ++i) {
              if (!strcasecmp(v->prop[i].name, name)) {
                     free(v->prop[i].name);
                     free(v->prop[i].value);
                     v->prop[i].name = strdup(name);
                     v->prop[i].value = strdup(value);
                     return;
              }
       }

       /* Otherwise, append it */
       ++v->numprops;
       v->prop = realloc(v->prop,
              (v->numprops * sizeof(struct vCardProp)) );
       v->prop[v->numprops-1].name = strdup(name);
       v->prop[v->numprops-1].value = strdup(value);
}

Here is the caller graph for this function:

struct vCard* VCardLoad ( StrBuf vbtext) [read]

Definition at line 107 of file vcard.c.

                                        {
       return vcard_load((char*)ChrPtr(vbtext));
}

Here is the call graph for this function:

void vnote_free ( struct vnote v)

Definition at line 186 of file vnote.c.

                                 {
       if (!v) return;
       if (v->magic != CTDL_VNOTE_MAGIC) return;

       if (v->uid) free(v->uid);
       if (v->summary) free(v->summary);
       if (v->body) free(v->body);
       
       memset(v, 0, sizeof(struct vnote));
       free(v);
}
struct vnote* vnote_new ( void  ) [read]

Definition at line 47 of file vnote.c.

                              {
       struct vnote *v;

       v = (struct vnote *) malloc(sizeof(struct vnote));
       if (v) {
              memset(v, 0, sizeof(struct vnote));
              v->magic = CTDL_VNOTE_MAGIC;
              v->pos_left = rand() % 256;
              v->pos_top = rand() % 256;
              v->pos_width = 200;
              v->pos_height = 150;
              v->color_red = 0xFF;
              v->color_green = 0xFF;
              v->color_blue = 0x00;
       }
       return v;
}

Here is the caller graph for this function:

struct vnote* vnote_new_from_str ( char *  s) [read]

Definition at line 65 of file vnote.c.

                                          {
       struct vnote *v;
       char *ptr = s;
       char *nexteol;
       char *thisline;
       int thisline_len;
       char *encoded_value;
       char *decoded_value;
       int is_quoted_printable;
       int is_base64;

       v = vnote_new();
       if (!v) return NULL;

       while (*ptr) {              // keep going until we hit a null terminator
              thisline = NULL;
              nexteol = strchr(ptr, '\n');
              if (nexteol) {
                     thisline = malloc((nexteol - ptr) + 2);
                     strncpy(thisline, ptr, (nexteol-ptr));
                     thisline_len = (nexteol-ptr);
                     thisline[thisline_len] = 0;
                     ptr = nexteol + 1;
              }
              else {
                     thisline = strdup(ptr);
                     thisline_len = strlen(thisline);
                     ptr += thisline_len;
              }

              if (thisline) {
                     if (thisline_len > 1) {
                            if (thisline[thisline_len - 1] == '\r') {
                                   thisline[thisline_len - 1] = 0;
                                   --thisline_len;
                            }
                     }

                     /* locate the colon separator */
                     encoded_value = strchr(thisline, ':');
                     if (encoded_value) {
                            *encoded_value++ = 0;

                            /* any qualifiers?  (look for a semicolon) */
                            is_base64 = bmstrcasestr(thisline, "encoding=base64") ? 1 : 0;
                            is_quoted_printable = bmstrcasestr(thisline, "encoding=quoted-printable") ? 1 : 0;

                            char *semicolon_pos = strchr(thisline, ';');
                            if (semicolon_pos) {
                                   *semicolon_pos = 0;
                            }

                            decoded_value = malloc(thisline_len);
                            if (is_base64) {
                                   CtdlDecodeBase64(decoded_value,
                                                 encoded_value,
                                                 strlen(encoded_value));
                            }
                            else if (is_quoted_printable) {
                                   CtdlDecodeQuotedPrintable(decoded_value,
                                                 encoded_value,
                                                 strlen(encoded_value));
                            }
                            else {
                                   strcpy(decoded_value, encoded_value);
                            }

                            if (!strcasecmp(thisline, "UID")) {
                                   if (v->uid) free(v->uid);
                                   v->uid = decoded_value;
                            }
                            else if (!strcasecmp(thisline, "SUMMARY")) {
                                   if (v->summary) free(v->summary);
                                   v->summary = decoded_value;
                            }
                            else if ( (!strcasecmp(thisline, "NOTE"))
                                 || (!strcasecmp(thisline, "BODY")) ) {
                                   if (v->body) free(v->body);
                                   v->body = decoded_value;
                            }
                            else if (!strcasecmp(thisline, "X-OUTLOOK-WIDTH")) {
                                   v->pos_width = atoi(decoded_value);
                                   free(decoded_value);
                            }
                            else if (!strcasecmp(thisline, "X-OUTLOOK-HEIGHT")) {
                                   v->pos_height = atoi(decoded_value);
                                   free(decoded_value);
                            }
                            else if (!strcasecmp(thisline, "X-OUTLOOK-LEFT")) {
                                   v->pos_left = atoi(decoded_value);
                                   free(decoded_value);
                            }
                            else if (!strcasecmp(thisline, "X-OUTLOOK-TOP")) {
                                   v->pos_top = atoi(decoded_value);
                                   free(decoded_value);
                            }
                            else if ( (!strcasecmp(thisline, "X-OUTLOOK-COLOR"))
                                 && (strlen(decoded_value) == 7)
                                 && (decoded_value[0] == '#') ) {
                                   sscanf(&decoded_value[1], "%2x%2x%2x",
                                          &v->color_red,
                                          &v->color_green,
                                          &v->color_blue);
                                   free(decoded_value);
                            }
                            else {
                                   free(decoded_value); // throw it away
                            }

                            /* FIXME still need to handle these:
                             * X-OUTLOOK-CREATE-TIME:20070611T204615Z
                             * REV:20070611T204621Z
                             */
                     }
                     free(thisline);
              }
       }

       return(v);
}

Here is the call graph for this function:

char* vnote_serialize ( struct vnote v)

Definition at line 245 of file vnote.c.

                                       {
       char *s;
       int bytes_needed = 0;

       if (!v) return NULL;
       if (v->magic != CTDL_VNOTE_MAGIC) return NULL;

       bytes_needed = 1024;
       if (v->summary) bytes_needed += strlen(v->summary);
       if (v->body) bytes_needed += strlen(v->body);
       s = malloc(bytes_needed);
       if (!s) return NULL;

       strcpy(s, "");
       vnote_serialize_output_field(s, "vnote", "BEGIN");
       vnote_serialize_output_field(s, "//Citadel//vNote handler library//EN", "PRODID");
       vnote_serialize_output_field(s, "1.1", "VERSION");
       vnote_serialize_output_field(s, "PUBLIC", "CLASS");
       vnote_serialize_output_field(s, v->uid, "UID");
       vnote_serialize_output_field(s, v->summary, "SUMMARY");
       vnote_serialize_output_field(s, v->body, "BODY");
       vnote_serialize_output_field(s, v->body, "NOTE");
       sprintf(&s[strlen(s)], "X-OUTLOOK-COLOR:#%02X%02X%02X\r\n",
              v->color_red, v->color_green, v->color_blue);
       sprintf(&s[strlen(s)], "X-OUTLOOK-LEFT:%d\r\n", v->pos_left);
       sprintf(&s[strlen(s)], "X-OUTLOOK-TOP:%d\r\n", v->pos_top);
       sprintf(&s[strlen(s)], "X-OUTLOOK-WIDTH:%d\r\n", v->pos_width);
       sprintf(&s[strlen(s)], "X-OUTLOOK-HEIGHT:%d\r\n", v->pos_height);
       vnote_serialize_output_field(s, "vnote", "END");
       return(s);
}

Here is the call graph for this function:

void vnote_serialize_output_field ( char *  append_to,
char *  field,
char *  label 
)

Definition at line 200 of file vnote.c.

                                                                             {

       char *mydup;
       int output_len = 0;
       int is_qp = 0;
       char *ptr = field;
       unsigned char ch;
       int pos = 0;

       if (!append_to) return;
       if (!field) return;
       if (!label) return;

       mydup = malloc((strlen(field) * 3) + 1);
       if (!mydup) return;
       strcpy(mydup, "");

       while (ptr[pos] != 0) {
              ch = (unsigned char)(ptr[pos++]);

              if (ch == 9) {
                     mydup[output_len++] = ch;
              }
              else if ( (ch >= 32) && (ch <= 60) ) {
                     mydup[output_len++] = ch;
              }
              else if ( (ch >= 62) && (ch <= 126) ) {
                     mydup[output_len++] = ch;
              }
              else {
                     sprintf((char *)&mydup[output_len], "=%02X", ch);
                     output_len += 3;
                     is_qp = 1;
              }
       }
       mydup[output_len] = 0;

       sprintf(&append_to[strlen(append_to)], "%s%s:%s\r\n",
              label,
              (is_qp ? ";ENCODING=QUOTED-PRINTABLE" : ""),
              mydup);
       free(mydup);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WildFireAddArray ( JsonValue ReportBase,
JsonValue Array,
WF_MessageType  Type 
)

Definition at line 81 of file wildfire.c.

{
       JsonValue *Val;
       Val = NewJsonArray(NULL, 0);
       JsonArrayAppend(Val, 
                     NewJsonPlainString(NULL, 0, 
                                      WF_MsgStrs[Type].Key, 
                                      WF_MsgStrs[Type].len));

       JsonArrayAppend(Val, Array);
}

Here is the call graph for this function:

JsonValue* WildFireException ( const char *  Filename,
long  FileLen,
long  LineNo,
StrBuf Message,
int  StackOffset 
)

Definition at line 269 of file wildfire.c.

{
       JsonValue *ExcClass;
       JsonValue *Val;
       Val = NewJsonArray(NULL, 0);

       JsonArrayAppend(Val, WFInfo(Filename, FileLen,
                                LineNo, eEXCEPTION));

       ExcClass = NewJsonObject(WF_MsgStrs[eTRACE].Key, 
                             WF_MsgStrs[eTRACE].len);
       
       JsonArrayAppend(Val, ExcClass);
       JsonObjectAppend(ExcClass, 
                      NewJsonPlainString(HKEY("Class"), 
                                       HKEY("Exception")));
       JsonObjectAppend(ExcClass, 
                      NewJsonString(HKEY("Message"), Message));
       JsonObjectAppend(ExcClass, 
                      NewJsonPlainString(HKEY("File"), 
                                       Filename, FileLen));
/*
       JsonObjectAppend(ExcClass, 
                      NewJsonPlainString(HKEY("Type"), 
                                       HKEY("throw")));
*/
       JsonObjectAppend(ExcClass, 
                      NewJsonNumber(HKEY("Line"), LineNo));

#ifdef HAVE_BACKTRACE
       {
              void *stack_frames[100];
              size_t size;
              long i;
              char **strings;
              JsonValue *Trace;
              JsonValue *Frame;
              StrBuf *FileName;
              StrBuf *Function;
              StrBuf *Pointer;
              StrBuf *Buf;
              unsigned int FunctionLine;

              Trace = NewJsonArray(HKEY("Trace"));
              JsonObjectAppend(ExcClass, Trace);
              FileName = NewStrBuf();
              Function = NewStrBuf();
              Pointer = NewStrBuf();
              Buf = NewStrBuf();

              size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
              strings = backtrace_symbols(stack_frames, size);
              for (i = StackOffset + 1; i < size; i++) {
                     if (strings != NULL){
                            ParseBacktrace(strings[i], Function, 
                                          FileName,
                                          &FunctionLine);
                            
                     }
                     StrBufPrintf(Pointer, "%p\n", stack_frames[i]);
                     
                     addr2lineBacktrace(Function, 
                                      FileName, 
                                      Pointer, 
                                      Buf, 
                                      &FunctionLine);

                     Frame = NewJsonObject(NULL, 0);
                     JsonArrayAppend(Trace, Frame);
                     JsonObjectAppend(Frame, 
                                    NewJsonString(HKEY("function"), Function));
                     JsonObjectAppend(Frame, 
                                    NewJsonString(HKEY("file"), FileName));
                     JsonObjectAppend(Frame, 
                                    NewJsonNumber(HKEY("line"), FunctionLine));
                     JsonObjectAppend(Frame, 
                                    NewJsonArray(HKEY("args")));/* not supportet... */

                     FunctionLine = 0;
                     FlushStrBuf(FileName);
                     FlushStrBuf(Function);
                     FlushStrBuf(Pointer);
              }
              free(strings);
              FreeStrBuf(&FileName);
              FreeStrBuf(&Function);
              FreeStrBuf(&Pointer);
              FreeStrBuf(&Buf);
       }
#endif
       return Val;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WildFireInitBacktrace ( const char *  argvNull,
int  AddBaseFrameSkip 
)

Definition at line 205 of file wildfire.c.

{

#ifdef HAVE_BACKTRACE
       void *stack_frames[100];
       size_t size;
       long i;
       char **strings;
       StrBuf *FileName;
       StrBuf *Function;
       StrBuf *Pointer;
       StrBuf *Buf;
       unsigned int FunctionLine;
       struct stat filestats;

       FileName = NewStrBuf();
       Function = NewStrBuf();
       Pointer = NewStrBuf();
       Buf = NewStrBuf();

       BaseFrames = size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
       BaseFrames --;
       BaseFrames += AddBaseFrameSkip;
       strings = backtrace_symbols(stack_frames, size);
       for (i = 1; i < size; i++) {
              if (strings != NULL){
                     ParseBacktrace(strings[i], Function, 
                                   FileName, 
                                   &FunctionLine);
                     FullBinaryName = NewStrBufDup(FileName);
                     size = i;
              }
              else {
                     char path[256];
                     getcwd(path, sizeof(path));
                     FullBinaryName = NewStrBufPlain(path, -1);
                     StrBufAppendBufPlain(FullBinaryName, HKEY("/"), 0);
                     StrBufAppendBufPlain(FullBinaryName, argvNull, -1, 0);
                     i = size;
               }
       }
       if ((stat(ChrPtr(FullBinaryName), &filestats)==-1) ||
           (filestats.st_size==0)){
              FlushStrBuf(FullBinaryName);
              StrBufAppendBufPlain(FullBinaryName, argvNull, -1, 0);
              if ((stat(ChrPtr(FullBinaryName), &filestats)==-1) ||
                  (filestats.st_size==0)){
                     FlushStrBuf(FullBinaryName);
                     fprintf(stderr, "unable to open my binary for addr2line checking, verbose backtraces won't work.\n");
              }
       }
       free(strings);
       FreeStrBuf(&FileName);
       FreeStrBuf(&Function);
       FreeStrBuf(&Pointer);
       FreeStrBuf(&Buf);
       if (StrLength(FullBinaryName) > 0)
              start_addr2line_daemon(ChrPtr(FullBinaryName));
#endif


}

Here is the call graph for this function:

Here is the caller graph for this function:

JsonValue* WildFireMessage ( const char *  Filename,
long  fnlen,
long  lineno,
StrBuf Msg,
WF_MessageType  Type 
)

Definition at line 50 of file wildfire.c.

{
       JsonValue *Ret;

       Ret = NewJsonArray(NULL, 0);
       JsonArrayAppend(Ret, WFInfo(Filename, fnlen,
                                LineNo, Type));

       JsonArrayAppend(Ret, 
                     NewJsonString(NULL, 0, Msg));
       return Ret;
}

Here is the call graph for this function:

JsonValue* WildFireMessagePlain ( const char *  Filename,
long  fnlen,
long  LineNo,
const char *  Message,
long  len,
WF_MessageType  Type 
)

Definition at line 66 of file wildfire.c.

{
       JsonValue *Val;
       Val = NewJsonArray(NULL, 0);

       JsonArrayAppend(Val, WFInfo(Filename, fnlen,
                                LineNo, Type));
       JsonArrayAppend(Val, 
                     NewJsonPlainString(NULL, 0, Message, len));
       return Val;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WildFireSerializePayload ( StrBuf JsonBuffer,
StrBuf OutBuf,
int *  MsgCount,
AddHeaderFunc  AddHdr 
)

Definition at line 365 of file wildfire.c.

{
       int n = *MsgCount;
       StrBuf *Buf;
       StrBuf *HeaderName;
       StrBuf *N; 
       const char Concatenate[] = "\\";
       const char empty[] = "";
       const char *Cat;
       StrBuf *Header;

       Header = NewStrBuf();
       if (*MsgCount == 0) {
              if (OutBuf != NULL) {
                     StrBufAppendBufPlain(OutBuf, 
                                        HKEY( 
                                               "X-Wf-Protocol-1" 
                                               ": "
                                               "http://meta.wildfirehq.org/Protocol/JsonStream/0.2\r\n"), 0);
                     StrBufAppendBufPlain(OutBuf, 
                                        HKEY( 
                                               "X-Wf-1-Plugin-1" 
                                               ": " 
                                               "http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0\r\n"), 0);
                     StrBufAppendBufPlain(OutBuf, 
                                        HKEY(
                                               "X-Wf-1-Structure-1"
                                               ": "
                                               "http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1\r\n"), 0);
              }
              else {
                     AddHdr("X-Wf-Protocol-1", 
                            "http://meta.wildfirehq.org/Protocol/JsonStream/0.2");
                     AddHdr("X-Wf-1-Plugin-1",
                            "http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0");
                     AddHdr("X-Wf-1-Structure-1",
                            "http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1");
              }
       }

       N = NewStrBuf();
       StrBufPrintf(N, "%d", StrLength(JsonBuffer));
       Buf = NewStrBufPlain(NULL, 1024);
       HeaderName = NewStrBuf();

       while (StrLength(JsonBuffer) > 0) {
              FlushStrBuf(Buf);
              StrBufPrintf(HeaderName, "X-Wf-"WF_MAJOR"-"WF_STRUCTINDEX"-"WF_SUB"-%d", n);
              if (StrLength(JsonBuffer) > 800) {
                     StrBufAppendBufPlain(Buf, ChrPtr(JsonBuffer), 800, 0);
                     StrBufCutLeft(JsonBuffer, 800);
                     Cat = Concatenate;
              }
              else {
                     StrBufAppendBuf(Buf, JsonBuffer, 0);
                     FlushStrBuf(JsonBuffer);
                     Cat = empty;
              }
              if (OutBuf != NULL) {
                     StrBufAppendPrintf(OutBuf, 
                                      "%s: %s|%s|%s\r\n", 
                                      ChrPtr(HeaderName), 
                                      ChrPtr(N),
                                      ChrPtr(Buf), 
                                      Cat);
              }
              else {
                     StrBufAppendPrintf(Header, 
                                      "%s|%s|%s", 
                                      ChrPtr(N),
                                      ChrPtr(Buf), 
                                      Cat);
                     AddHdr(ChrPtr(HeaderName), ChrPtr(Header));
                     
              }

              FlushStrBuf(N);
              n++;
       }
       *MsgCount = n;
       if (OutBuf == NULL) {
              FreeStrBuf(&Header);
       }
       FreeStrBuf(&N);
       FreeStrBuf(&Buf);
       FreeStrBuf(&HeaderName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

eReadState WriteIOBAlreadyRead ( FDIOBuffer FDB,
const char **  Error 
)

Definition at line 4113 of file stringbuf.c.

{
       int IsNonBlock;
       int fdflags;
       long rlen;
       long should_write;
       int nSuccessLess = 0;
       struct timeval tv;
       fd_set rfds;

       fdflags = fcntl(FDB->OtherFD, F_GETFL);
       IsNonBlock = (fdflags & O_NONBLOCK) == O_NONBLOCK;

       while ((FDB->IOB->ReadWritePointer - FDB->IOB->Buf->buf < FDB->IOB->Buf->BufUsed) &&
              (FDB->ChunkSendRemain > 0))
       {
              if (IsNonBlock){
                     tv.tv_sec = 1; /* selectresolution; */
                     tv.tv_usec = 0;
                     
                     FD_ZERO(&rfds);
                     FD_SET(FDB->OtherFD, &rfds);
                     if (select(FDB->OtherFD + 1, NULL, &rfds, NULL, &tv) == -1) {
                            *Error = strerror(errno);
                            return eReadFail;
                     }
              }
              if (IsNonBlock && !  FD_ISSET(FDB->OtherFD, &rfds)) {
                     nSuccessLess ++;
                     continue;
              }

              should_write = FDB->IOB->Buf->BufUsed - 
                     (FDB->IOB->ReadWritePointer - FDB->IOB->Buf->buf);
              if (should_write > FDB->ChunkSendRemain)
                     should_write = FDB->ChunkSendRemain;

              rlen = write(FDB->OtherFD, 
                          FDB->IOB->ReadWritePointer, 
                          should_write);
              if (rlen < 1) {
                     *Error = strerror(errno);
                                          
                     return eReadFail;
              }
              FDB->TotalSentAlready += rlen;
              FDB->IOB->ReadWritePointer += rlen;
              FDB->ChunkSendRemain -= rlen;
       }
       if (FDB->IOB->ReadWritePointer >= FDB->IOB->Buf->buf + FDB->IOB->Buf->BufUsed)
       {
              FlushStrBuf(FDB->IOB->Buf);
              FDB->IOB->ReadWritePointer = NULL;
       }

       if (FDB->ChunkSendRemain == 0)
              return eReadSuccess;
       else 
              return eMustReadMore;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 34 of file libcitadel.c.

const char* StrBufNOTNULL

Definition at line 54 of file stringbuf.c.