aboutsummaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeLines
* interpret 'Sven Moritz Hallberg2008-02-14-0/+1
|
* - add support for setting ops/voice according to OTR msgstateSven Moritz Hallberg2008-02-09-1/+11
| | | | | | | | | | | - add 'otr trust' user command - support non-otr messages during keygen - run otr messages through strip_html - interpret <b> and <i> tags in html messages - record max message size in prpl - add 'encrypted' flag to user_t - cosmetics
* Fixed two valgrind warnings (partially uninitialized "struct tm" vars.)Wilmer van der Gaast2008-01-24-0/+2
|
* Added byte swapping code to the new MD5 checksumming code to make it workWilmer van der Gaast2008-01-19-69/+96
| | | | | | | | on big-endian machines. (If someone thinks BitlBee should work on PDPs, send me the fix. I don't care. :-P) This fixes bug #351 (MSN challenge- response failure) but might break backward compatibility if the broken MD5 code was used to save settings. (Somewhere between rev 266 and now.)
* Fixing some Solaris compiler warnings (u_int->uint, adding some typecastsWilmer van der Gaast2008-01-17-14/+15
| | | | | for pid_t variables).
* Killed info_string_append() and now showing the IP address of ICQ usersWilmer van der Gaast2008-01-12-7/+0
| | | | | in the "info" command response.
* Removed closure->result. I was planning to add some more stuff, but willWilmer van der Gaast2008-01-05-5/+5
| | | | | do that later.
* Fixed return value check in proxy_connect(), since on some systemsWilmer van der Gaast2007-12-28-11/+10
| | | | | | a non-blocking connect() can return immediately (when connecting to localhost, for example). Closes bug #233 and #340.
* Checking conn->xcred before trying to clean it up since GnuTLS doesn'tWilmer van der Gaast2007-12-12-2/+4
| | | | | seem to check for NULL pointers here. (Closes #257)
* Fixed sockerr_again() usage in Jabber module to (hopefully) fix a 100% CPUWilmer van der Gaast2007-12-12-0/+12
| | | | | usage bug.
* printf() in daemons considered harmful.Wilmer van der Gaast2007-11-29-7/+5
|
* Fixed the epoll+ForkDaemon combination. The libevent event handlingWilmer van der Gaast2007-11-28-8/+41
| | | | | | didn't work very well on Linux 2.6 (and possibly others) in ForkDaemon mode.
* Replaced GPL-incompatible SHA1 hashing code (and renamed the files in caseWilmer van der Gaast2007-11-23-195/+442
| | | | | I ever need SHA256 ;-)).
* Replaced GPL-incompatible MD5 hashing code.Wilmer van der Gaast2007-11-23-440/+239
|
* Some changes to get rid of compiler warnings. (And disabling strictWilmer van der Gaast2007-11-22-1/+9
| | | | | aliasing because there are too many warnings about it. :-P)
* Merging from Jelmer.Wilmer van der Gaast2007-11-05-4/+2
|\
| * Use standard functions for dealing with both IPv6 and IPv4. Jelmer Vernooij2007-10-18-43/+0
| |
| * Fix GCC warning.Jelmer Vernooij2007-10-12-2/+2
|/
* Added word_wrap() function to misc.c and using it at the right places soWilmer van der Gaast2007-10-12-0/+50
| | | | | | that long messages in groupchats also get wrapped properly (instead of truncated).
* "Changed" the ArcFour implementation. I'm afraid this was a waste of time,Wilmer van der Gaast2007-10-07-5/+13
| | | | | but at least I added a neat unittest...
* Renaming RC4 to ArcFour (possible trademark issues).Wilmer van der Gaast2007-10-07-50/+53
|
* Merge from Jelmer (making GCC4 happy by sanitizing some typecasting messWilmer van der Gaast2007-07-15-9/+14
|\ | | | | | | | | around the RC4/B64 code).
| * Fix ssl_bogus.Jelmer Vernooij2007-07-07-0/+5
| |
| * Fix some warnings in storage.c.Jelmer Vernooij2007-07-07-9/+9
| |
* | Merge from Jelmer (mainly unit testing things).Wilmer van der Gaast2007-07-01-0/+1
|\ \ | |/ |/|
| * Add lcov targetJelmer Vernooij2007-01-22-0/+1
| |
| * Add tests for set_url(). Fixed a bug where the default port wasn't Jelmer Vernooij2006-12-24-1/+1
| | | | | | | | | | set when socks5 was used.
* | Little fix copied from Jelmer's integration branch, want to import the restWilmer van der Gaast2007-02-18-1/+1
| | | | | | | | | | | | after doing this devel release because there are quite a lot of changes in it.
* | Merging new Jabber module. See the massive changelog for all the coolWilmer van der Gaast2007-02-18-58/+191
|\ \ | |/ |/| | | | | improvements. :-)
| * Added starttls code to ssl_openssl.c so GnuTLS isn't the only supportedWilmer van der Gaast2006-10-19-42/+77
| | | | | | | | | | SSL module in this branch anymore.
| * Merging from devel and storage-xml.Wilmer van der Gaast2006-10-15-10/+10
| |\
| * | Added SRV lookups to automatically find out the correct server for aWilmer van der Gaast2006-10-07-0/+67
| | | | | | | | | | | | | | | domain.
| * | No more double free()/crashes when trying to set up an SSL connection toWilmer van der Gaast2006-10-02-6/+18
| | | | | | | | | | | | | | | | | | | | | a non-SSL server, and better handling of TLS connection setup by initializing the TLS session from a callback function (which guarantees a valid return value from ssl_starttls() before any error callback could be called).
| * | Added support for SSL- and TLS-connections. Checking of the "tls" userWilmer van der Gaast2006-09-24-15/+34
| | | | | | | | | | | | | | | | | | setting has to be finished, plus an ssl_starttls() function for the other SSL libraries (this code will only compile with GnuTLS for now).
* | | Fix gcov.Jelmer Vernooij2006-12-06-2/+3
| | |
* | | Fix testsuite.Jelmer Vernooij2006-12-06-0/+2
| |/ |/|
* | Using LGPL for generic parts, where possible.Wilmer van der Gaast2006-09-20-10/+10
|/
* add_cr() is not used anymore, and HTML entity handling got UTFized some timeWilmer van der Gaast2006-09-17-34/+2
| | | | | ago already, so no need for that FIXME comment.
* Just a little typo in rc4.cWilmer van der Gaast2006-08-14-1/+1
|
* Added some (more) comments to .h files in lib/ and some minor fixes/cleanups.Wilmer van der Gaast2006-07-19-15/+93
|
* Fixed a broken call to set_get() (CRASH), shut up a compiler warning inWilmer van der Gaast2006-07-15-2/+5
| | | | | events_glib and now using the right evaluator for acc->"auto_reconnect".
* Added "account set" command.Wilmer van der Gaast2006-07-01-1/+38
|
* Added random_bytes() function for better/more reliable randomization andWilmer van der Gaast2006-06-28-19/+78
| | | | | moved set_eval_ops() to a slightly more suitable place.
* Merging from devel/Jelmer.Wilmer van der Gaast2006-06-25-4/+0
|
* Added versioning information to the XML-file (convenient for later formatWilmer van der Gaast2006-06-25-0/+6
| | | | | | | changes), got rid of confusing "Password successfully changed" message when the user uses the identify-command and protected rc4_decode() against short inputs.
* Moved Base64-related functions to a separate file and added decode funtions.Wilmer van der Gaast2006-06-25-49/+188
|
* Moving all generic files to lib/ instead of having some in / and some inWilmer van der Gaast2006-06-25-0/+4023
protocols/, and adding RC4 code.
ss="w"> NTYPE_CDATA && name == NULL) return NULL; if (p == NULL) { p = pool_heap(1*1024); } /* Allocate & zero memory */ result = (xmlnode)pmalloco(p, sizeof(_xmlnode)); /* Initialize fields */ if (type != NTYPE_CDATA) result->name = pstrdup(p,name); result->type = type; result->p = p; return result; } static xmlnode _xmlnode_append_sibling(xmlnode lastsibling, const char* name, unsigned int type) { xmlnode result; result = _xmlnode_new(xmlnode_pool(lastsibling), name, type); if (result != NULL) { /* Setup sibling pointers */ result->prev = lastsibling; lastsibling->next = result; } return result; } static xmlnode _xmlnode_insert(xmlnode parent, const char* name, unsigned int type) { xmlnode result; if(parent == NULL || (type != NTYPE_CDATA && name == NULL)) return NULL; /* If parent->firstchild is NULL, simply create a new node for the first child */ if (parent->firstchild == NULL) { result = _xmlnode_new(parent->p, name, type); parent->firstchild = result; } /* Otherwise, append this to the lastchild */ else { result= _xmlnode_append_sibling(parent->lastchild, name, type); } result->parent = parent; parent->lastchild = result; return result; } static xmlnode _xmlnode_search(xmlnode firstsibling, const char* name, unsigned int type) { xmlnode current; /* Walk the sibling list, looking for a NTYPE_TAG xmlnode with the specified name */ current = firstsibling; while (current != NULL) { if ((current->type == type) && (j_strcmp(current->name, name) == 0)) return current; else current = current->next; } return NULL; } static void _xmlnode_merge(xmlnode data) { xmlnode cur; char *merge, *scur; int imerge; /* get total size of all merged cdata */ imerge = 0; for(cur = data; cur != NULL && cur->type == NTYPE_CDATA; cur = cur->next) imerge += cur->data_sz; /* copy in current data and then spin through all of them and merge */ scur = merge = pmalloc(data->p,imerge + 1); for(cur = data; cur != NULL && cur->type == NTYPE_CDATA; cur = cur->next) { memcpy(scur,cur->data,cur->data_sz); scur += cur->data_sz; } *scur = '\0'; /* this effectively hides all of the merged-in chunks */ data->next = cur; if(cur == NULL) data->parent->lastchild = data; else cur->prev = data; /* reset data */ data->data = merge; data->data_sz = imerge; } static void _xmlnode_hide_sibling(xmlnode child) { if(child == NULL) return; if(child->prev != NULL) child->prev->next = child->next; if(child->next != NULL) child->next->prev = child->prev; } static void _xmlnode_tag2str(spool s, xmlnode node, int flag) { xmlnode tmp; if(flag==0 || flag==1) { spooler(s,"<",xmlnode_get_name(node),s); tmp = xmlnode_get_firstattrib(node); while(tmp) { spooler(s," ",xmlnode_get_name(tmp),"='",strescape(xmlnode_pool(node),xmlnode_get_data(tmp)),"'",s); tmp = xmlnode_get_nextsibling(tmp); } if(flag==0) spool_add(s,"/>"); else spool_add(s,">"); } else { spooler(s,"</",xmlnode_get_name(node),">",s); } } static spool _xmlnode2spool(xmlnode node) { spool s; int level=0,dir=0; xmlnode tmp; if(!node || xmlnode_get_type(node)!=NTYPE_TAG) return NULL; s = spool_new(xmlnode_pool(node)); if(!s) return(NULL); while(1) { if(dir==0) { if(xmlnode_get_type(node) == NTYPE_TAG) { if(xmlnode_has_children(node)) { _xmlnode_tag2str(s,node,1); node = xmlnode_get_firstchild(node); level++; continue; }else{ _xmlnode_tag2str(s,node,0); } }else{ spool_add(s,strescape(xmlnode_pool(node),xmlnode_get_data(node))); } } tmp = xmlnode_get_nextsibling(node); if(!tmp) { node = xmlnode_get_parent(node); level--; if(level>=0) _xmlnode_tag2str(s,node,2); if(level<1) break; dir = 1; }else{ node = tmp; dir = 0; } } return s; } /* External routines */ /* * xmlnode_new_tag -- create a tag node * Automatically creates a memory pool for the node. * * parameters * name -- name of the tag * * returns * a pointer to the tag node * or NULL if it was unsuccessfull */ xmlnode xmlnode_new_tag(const char* name) { return _xmlnode_new(NULL, name, NTYPE_TAG); } /* * xmlnode_insert_tag -- append a child tag to a tag * * parameters * parent -- pointer to the parent tag * name -- name of the child tag * * returns * a pointer to the child tag node * or NULL if it was unsuccessfull */ xmlnode xmlnode_insert_tag(xmlnode parent, const char* name) { return _xmlnode_insert(parent, name, NTYPE_TAG); } /* * xmlnode_insert_cdata -- append character data to a tag * * parameters * parent -- parent tag * CDATA -- character data * size -- size of CDATA * or -1 for null-terminated CDATA strings * * returns * a pointer to the child CDATA node * or NULL if it was unsuccessfull */ xmlnode xmlnode_insert_cdata(xmlnode parent, const char* CDATA, unsigned int size) { xmlnode result; if(CDATA == NULL || parent == NULL) return NULL; if(size == -1) size = strlen(CDATA); result = _xmlnode_insert(parent, NULL, NTYPE_CDATA); if (result != NULL) { result->data = (char*)pmalloc(result->p, size + 1); memcpy(result->data, CDATA, size); result->data[size] = '\0'; result->data_sz = size; } return result; } /* * xmlnode_get_tag -- find given tag in an xmlnode tree * * parameters * parent -- pointer to the parent tag * name -- "name" for the child tag of that name * "name/name" for a sub child (recurses) * "?attrib" to match the first tag with that attrib defined * "?attrib=value" to match the first tag with that attrib and value * "=cdata" to match the cdata contents of the child * or any combination: "name/name/?attrib", "name=cdata", etc * * results * a pointer to the tag matching search criteria * or NULL if search was unsuccessfull */ xmlnode xmlnode_get_tag(xmlnode parent, const char* name) { char *str, *slash, *qmark, *equals; xmlnode step, ret; if(parent == NULL || parent->firstchild == NULL || name == NULL || name == '\0') return NULL; if(strstr(name, "/") == NULL && strstr(name,"?") == NULL && strstr(name, "=") == NULL) return _xmlnode_search(parent->firstchild, name, NTYPE_TAG); str = g_strdup(name); slash = strstr(str, "/"); qmark = strstr(str, "?"); equals = strstr(str, "="); if(equals != NULL && (slash == NULL || equals < slash) && (qmark == NULL || equals < qmark)) { /* of type =cdata */ *equals = '\0'; equals++; for(step = parent->firstchild; step != NULL; step = xmlnode_get_nextsibling(step)) { if(xmlnode_get_type(step) != NTYPE_TAG) continue; if(*str != '\0') if(j_strcmp(xmlnode_get_name(step),str) != 0) continue; if(j_strcmp(xmlnode_get_data(step),equals) != 0) continue; break; } g_free(str); return step; } if(qmark != NULL && (slash == NULL || qmark < slash)) { /* of type ?attrib */ *qmark = '\0'; qmark++; if(equals != NULL) { *equals = '\0'; equals++; } for(step = parent->firstchild; step != NULL; step = xmlnode_get_nextsibling(step)) { if(xmlnode_get_type(step) != NTYPE_TAG) continue; if(*str != '\0') if(j_strcmp(xmlnode_get_name(step),str) != 0) continue; if(xmlnode_get_attrib(step,qmark) == NULL) continue; if(equals != NULL && j_strcmp(xmlnode_get_attrib(step,qmark),equals) != 0) continue; break; } g_free(str); return step; } *slash = '\0'; ++slash; for(step = parent->firstchild; step != NULL; step = xmlnode_get_nextsibling(step)) { if(xmlnode_get_type(step) != NTYPE_TAG) continue; if(j_strcmp(xmlnode_get_name(step),str) != 0) continue; ret = xmlnode_get_tag(step, slash); if(ret != NULL) { g_free(str); return ret; } } g_free(str); return NULL; } /* return the cdata from any tag */ char *xmlnode_get_tag_data(xmlnode parent, const char *name) { xmlnode tag; tag = xmlnode_get_tag(parent, name); if(tag == NULL) return NULL; return xmlnode_get_data(tag); } void xmlnode_put_attrib(xmlnode owner, const char* name, const char* value) { xmlnode attrib; if(owner == NULL || name == NULL || value == NULL) return; /* If there are no existing attributs, allocate a new one to start the list */ if (owner->firstattrib == NULL) { attrib = _xmlnode_new(owner->p, name, NTYPE_ATTRIB); owner->firstattrib = attrib; owner->lastattrib = attrib; } else { attrib = _xmlnode_search(owner->firstattrib, name, NTYPE_ATTRIB); if(attrib == NULL) { attrib = _xmlnode_append_sibling(owner->lastattrib, name, NTYPE_ATTRIB); owner->lastattrib = attrib; } } /* Update the value of the attribute */ attrib->data_sz = strlen(value); attrib->data = pstrdup(owner->p, value); } char* xmlnode_get_attrib(xmlnode owner, const char* name) { xmlnode attrib; if (owner != NULL && owner->firstattrib != NULL) { attrib = _xmlnode_search(owner->firstattrib, name, NTYPE_ATTRIB); if (attrib != NULL) return (char*)attrib->data; } return NULL; } static xmlnode xmlnode_get_firstattrib(xmlnode parent) { if (parent != NULL) return parent->firstattrib; return NULL; } xmlnode xmlnode_get_firstchild(xmlnode parent) { if (parent != NULL) return parent->firstchild; return NULL; } xmlnode xmlnode_get_nextsibling(xmlnode sibling) { if (sibling != NULL) return sibling->next; return NULL; } xmlnode xmlnode_get_parent(xmlnode node) { if (node != NULL) return node->parent; return NULL; } char* xmlnode_get_name(xmlnode node) { if (node != NULL) return node->name; return NULL; } char* xmlnode_get_data(xmlnode node) { if(xmlnode_get_type(node) == NTYPE_TAG) /* loop till we find a CDATA in the children */ for(node = xmlnode_get_firstchild(node); node != NULL; node = xmlnode_get_nextsibling(node)) if(xmlnode_get_type(node) == NTYPE_CDATA) break; if(node == NULL) return NULL; /* check for a dirty node w/ unassembled cdata chunks */ if(xmlnode_get_type(node->next) == NTYPE_CDATA) _xmlnode_merge(node); return node->data; } static int xmlnode_get_datasz(xmlnode node) { if(xmlnode_get_type(node) != NTYPE_CDATA) return 0; /* check for a dirty node w/ unassembled cdata chunks */ if(xmlnode_get_type(node->next) == NTYPE_CDATA) _xmlnode_merge(node); return node->data_sz; } static int xmlnode_get_type(xmlnode node) { if (node != NULL) return node->type; return NTYPE_UNDEF; } int xmlnode_has_children(xmlnode node) { if ((node != NULL) && (node->firstchild != NULL)) return 1; return 0; } static int xmlnode_has_attribs(xmlnode node) { if ((node != NULL) && (node->firstattrib != NULL)) return 1; return 0; } pool xmlnode_pool(xmlnode node) { if (node != NULL) return node->p; return (pool)NULL; } void xmlnode_hide_attrib(xmlnode parent, const char *name) { xmlnode attrib; if(parent == NULL || parent->firstattrib == NULL || name == NULL) return; attrib = _xmlnode_search(parent->firstattrib, name, NTYPE_ATTRIB); if(attrib == NULL) return; /* first fix up at the child level */ _xmlnode_hide_sibling(attrib); /* next fix up at the parent level */ if(parent->firstattrib == attrib) parent->firstattrib = attrib->next; if(parent->lastattrib == attrib) parent->lastattrib = attrib->prev; } /* * xmlnode2str -- convert given xmlnode tree into a string * * parameters * node -- pointer to the xmlnode structure * * results * a pointer to the created string * or NULL if it was unsuccessfull */ char *xmlnode2str(xmlnode node) { return spool_print(_xmlnode2spool(node)); } /* loop through both a and b comparing everything, attribs, cdata, children, etc */ static int xmlnode_cmp(xmlnode a, xmlnode b) { int ret = 0; while(1) { if(a == NULL && b == NULL) return 0; if(a == NULL || b == NULL) return -1; if(xmlnode_get_type(a) != xmlnode_get_type(b)) return -1; switch(xmlnode_get_type(a)) { case NTYPE_ATTRIB: ret = j_strcmp(xmlnode_get_name(a), xmlnode_get_name(b)); if(ret != 0) return -1; ret = j_strcmp(xmlnode_get_data(a), xmlnode_get_data(b)); if(ret != 0) return -1; break; case NTYPE_TAG: ret = j_strcmp(xmlnode_get_name(a), xmlnode_get_name(b)); if(ret != 0) return -1; ret = xmlnode_cmp(xmlnode_get_firstattrib(a), xmlnode_get_firstattrib(b)); if(ret != 0) return -1; ret = xmlnode_cmp(xmlnode_get_firstchild(a), xmlnode_get_firstchild(b)); if(ret != 0) return -1; break; case NTYPE_CDATA: ret = j_strcmp(xmlnode_get_data(a), xmlnode_get_data(b)); if(ret != 0) return -1; } a = xmlnode_get_nextsibling(a); b = xmlnode_get_nextsibling(b); } } xmlnode xmlnode_insert_tag_node(xmlnode parent, xmlnode node) { xmlnode child; child = xmlnode_insert_tag(parent, xmlnode_get_name(node)); if (xmlnode_has_attribs(node)) xmlnode_insert_node(child, xmlnode_get_firstattrib(node)); if (xmlnode_has_children(node)) xmlnode_insert_node(child, xmlnode_get_firstchild(node)); return child; } /* places copy of node and node's siblings in parent */ static void xmlnode_insert_node(xmlnode parent, xmlnode node) { if(node == NULL || parent == NULL) return; while(node != NULL) { switch(xmlnode_get_type(node)) { case NTYPE_ATTRIB: xmlnode_put_attrib(parent, xmlnode_get_name(node), xmlnode_get_data(node)); break; case NTYPE_TAG: xmlnode_insert_tag_node(parent, node); break; case NTYPE_CDATA: xmlnode_insert_cdata(parent, xmlnode_get_data(node), xmlnode_get_datasz(node)); } node = xmlnode_get_nextsibling(node); } } void xmlnode_free(xmlnode node) { if(node == NULL) return; pool_free(node->p); }