- Timestamp:
- 2009-12-07T21:54:19Z (15 years ago)
- Branches:
- master
- Children:
- 1c3008a
- Parents:
- aac4017 (diff), 36cf9fd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/events_libevent.c
raac4017 r2288705 37 37 38 38 static void b_main_restart(); 39 static guint id_next = 1; 39 static guint id_next = 1; /* Next ID to be allocated to an event handler. */ 40 static guint id_cur = 0; /* Event ID that we're currently handling. */ 41 static guint id_dead; /* Set to 1 if b_event_remove removes id_cur. */ 40 42 static GHashTable *id_hash; 41 static int quitting = 0; 43 static int quitting = 0; /* Prepare to quit, stop handling events. */ 42 44 43 45 /* Since libevent doesn't handle two event handlers for one fd-condition … … 119 121 struct b_event_data *b_ev = data; 120 122 b_input_condition cond = 0; 121 int id;123 gboolean st; 122 124 123 125 if( fd >= 0 ) … … 133 135 /* Since the called function might cancel this handler already 134 136 (which free()s b_ev), we have to remember the ID here. */ 135 id = b_ev->id; 137 id_cur = b_ev->id; 138 id_dead = 0; 136 139 137 140 if( quitting ) 138 141 { 139 b_event_remove( id );142 b_event_remove( id_cur ); 140 143 return; 141 144 } 142 145 143 if( !b_ev->function( b_ev->data, fd, cond ) ) 146 st = b_ev->function( b_ev->data, fd, cond ); 147 if( id_dead ) 148 { 149 /* This event was killed already, don't touch it! */ 150 return; 151 } 152 else if( !st ) 144 153 { 145 154 event_debug( "Handler returned FALSE: " ); 146 b_event_remove( id );155 b_event_remove( id_cur ); 147 156 } 148 157 else if( fd == -1 ) 149 158 { 159 /* fd == -1 means it was a timer. These can't be auto-repeated 160 so it has to be recreated every time. */ 150 161 struct timeval tv; 151 162 … … 236 247 if( b_ev ) 237 248 { 249 if( id == id_cur ) 250 id_dead = TRUE; 251 238 252 g_hash_table_remove( id_hash, &b_ev->id ); 239 253 if( b_ev->evinfo.ev_fd >= 0 ) -
lib/http_client.c
raac4017 r2288705 59 59 if( error ) 60 60 { 61 g_free( req );62 return ( NULL );61 http_free( req ); 62 return NULL; 63 63 } 64 64 … … 160 160 161 161 req->func( req ); 162 163 g_free( req->request ); 164 g_free( req ); 165 162 http_free( req ); 166 163 return FALSE; 167 164 } … … 444 441 445 442 req->func( req ); 446 443 http_free( req ); 444 return FALSE; 445 } 446 447 void http_free( struct http_request *req ) 448 { 447 449 g_free( req->request ); 448 450 g_free( req->reply_headers ); 449 451 g_free( req->status_string ); 450 452 g_free( req ); 451 452 return FALSE; 453 } 453 } 454 -
lib/http_client.h
raac4017 r2288705 81 81 void *http_dorequest( char *host, int port, int ssl, char *request, http_input_function func, gpointer data ); 82 82 void *http_dorequest_url( char *url_string, http_input_function func, gpointer data ); 83 84 void http_free( struct http_request *req ); -
lib/ini.c
raac4017 r2288705 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-200 5Wilmer van der Gaast and others *4 * Copyright 2002-2008 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 28 28 ini_t *ini_open( char *file ) 29 29 { 30 ini_t *ini = g_new0( ini_t, 1 ); 30 int fd; 31 ini_t *ini = NULL; 32 struct stat fi; 31 33 32 if( ( ini->fp = fopen( file, "r" ) ) == NULL ) 34 if( ( fd = open( file, O_RDONLY ) ) != -1 && 35 fstat( fd, &fi ) == 0 && 36 fi.st_size <= 16384 && 37 ( ini = g_malloc( sizeof( ini_t ) + fi.st_size + 1 ) ) && 38 read( fd, ini->file, fi.st_size ) == fi.st_size ) 33 39 { 34 g_free( ini ); 35 return( NULL ); 40 memset( ini, 0, sizeof( ini_t ) ); 41 ini->size = fi.st_size; 42 ini->file[ini->size] = 0; 43 ini->cur = ini->file; 44 ini->c_section = ""; 45 46 close( fd ); 47 48 return ini; 36 49 } 50 51 if( fd >= 0 ) 52 close( fd ); 37 53 38 return( ini ); 54 ini_close( ini ); 55 56 return NULL; 57 } 58 59 /* Strips leading and trailing whitespace and returns a pointer to the first 60 non-ws character of the given string. */ 61 static char *ini_strip_whitespace( char *in ) 62 { 63 char *e; 64 65 while( isspace( *in ) ) 66 in++; 67 68 e = in + strlen( in ) - 1; 69 while( e > in && isspace( *e ) ) 70 e--; 71 e[1] = 0; 72 73 return in; 39 74 } 40 75 41 76 int ini_read( ini_t *file ) 42 77 { 43 char key[MAX_STRING], s[MAX_STRING], *t; 44 int i; 78 char *s; 45 79 46 while( !feof( file->fp ))80 while( file->cur && file->cur < file->file + file->size ) 47 81 { 48 *s = 0;49 fscanf( file->fp, "%127[^\n#]s", s );50 f scanf( file->fp, "%*[^\n]s" );51 fgetc( file->fp ); /* Skip newline */ 52 file->line ++;53 if( strchr( s, '=' ))82 char *e, *next; 83 84 file->line++; 85 86 /* Find the end of line */ 87 if( ( e = strchr( file->cur, '\n' ) ) != NULL ) 54 88 { 55 sscanf( s, "%[^ =]s", key ); 56 if( ( t = strchr( key, '.' ) ) ) 89 *e = 0; 90 next = e + 1; 91 } 92 else 93 { 94 /* No more lines. */ 95 e = file->cur + strlen( file->cur ); 96 next = NULL; 97 } 98 99 /* Comment? */ 100 if( ( s = strchr( file->cur, '#' ) ) != NULL ) 101 *s = 0; 102 103 file->cur = ini_strip_whitespace( file->cur ); 104 105 if( *file->cur == '[' ) 106 { 107 file->cur++; 108 if( ( s = strchr( file->cur, ']' ) ) != NULL ) 57 109 { 58 *t = 0; 59 strcpy( file->section, key ); 60 t ++; 110 *s = 0; 111 file->c_section = file->cur; 112 } 113 } 114 else if( ( s = strchr( file->cur, '=' ) ) != NULL ) 115 { 116 *s = 0; 117 file->key = ini_strip_whitespace( file->cur ); 118 file->value = ini_strip_whitespace( s + 1 ); 119 120 if( ( s = strchr( file->key, '.' ) ) != NULL ) 121 { 122 *s = 0; 123 file->section = file->key; 124 file->key = s + 1; 61 125 } 62 126 else 63 127 { 64 strcpy( file->section, file->c_section ); 65 t = key; 128 file->section = file->c_section; 66 129 } 67 sscanf( t, "%s", file->key );68 t = strchr( s, '=' ) + 1;69 for( i = 0; t[i] == ' '; i ++ );70 strcpy( file->value, &t[i] );71 for( i = strlen( file->value ) - 1; file->value[i] == 32; i -- )72 file->value[i] = 0;73 130 74 return( 1 ); 131 file->cur = next; 132 return 1; 75 133 } 76 else if( ( t = strchr( s, '[' ) ) ) 77 { 78 strcpy( file->c_section, t + 1 ); 79 t = strchr( file->c_section, ']' ); 80 *t = 0; 81 } 134 /* else: noise/comment/etc, let's just ignore it. */ 135 136 file->cur = next; 82 137 } 83 return( 0 ); 138 139 return 0; 84 140 } 85 141 86 142 void ini_close( ini_t *file ) 87 143 { 88 fclose( file->fp );89 144 g_free( file ); 90 145 } -
lib/ini.h
raac4017 r2288705 29 29 typedef struct 30 30 { 31 FILE *fp;32 31 int line; 33 char c_section[MAX_STRING]; 34 char section[MAX_STRING]; 35 char key[MAX_STRING]; 36 char value[MAX_STRING]; 32 char *c_section; 33 char *section; 34 char *key; 35 char *value; 36 int size; 37 char *cur, *tok; 38 char file[]; 37 39 } ini_t; 38 40 -
lib/misc.c
raac4017 r2288705 46 46 #endif 47 47 48 #include "md5.h" 48 49 #include "ssl_client.h" 49 50 -
lib/proxy.c
raac4017 r2288705 558 558 return proxy_connect_socks5(host, port, phb); 559 559 560 if (phb->host) g_free(phb);561 560 g_free(phb); 562 561 return -1; -
lib/xmltree.c
raac4017 r2288705 472 472 } 473 473 474 struct xt_node *xt_new_node( char *name, c har *text, struct xt_node *children )474 struct xt_node *xt_new_node( char *name, const char *text, struct xt_node *children ) 475 475 { 476 476 struct xt_node *node, *c; -
lib/xmltree.h
raac4017 r2288705 90 90 char *xt_find_attr( struct xt_node *node, const char *key ); 91 91 92 struct xt_node *xt_new_node( char *name, c har *text, struct xt_node *children );92 struct xt_node *xt_new_node( char *name, const char *text, struct xt_node *children ); 93 93 void xt_add_child( struct xt_node *parent, struct xt_node *child ); 94 94 void xt_add_attr( struct xt_node *node, const char *key, const char *value );
Note: See TracChangeset
for help on using the changeset viewer.