Changeset c88999c
- Timestamp:
- 2005-12-27T15:20:35Z (19 years ago)
- Branches:
- master
- Children:
- a252c1a
- Parents:
- e62762b
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
re62762b rc88999c 199 199 return FALSE; 200 200 } 201 202 return TRUE;203 201 204 202 /* Very naughty, go read the RFCs! >:) */ … … 348 346 return( 1 ); 349 347 } 350 351 /* Decode%20a%20file%20name */352 void http_decode( char *s )353 {354 char *t;355 int i, j, k;356 357 t = g_new( char, strlen( s ) + 1 );358 359 for( i = j = 0; s[i]; i ++, j ++ )360 {361 if( s[i] == '%' )362 {363 if( sscanf( s + i + 1, "%2x", &k ) )364 {365 t[j] = k;366 i += 2;367 }368 else369 {370 *t = 0;371 break;372 }373 }374 else375 {376 t[j] = s[i];377 }378 }379 t[j] = 0;380 381 strcpy( s, t );382 g_free( t );383 }384 385 /* Warning: This one explodes the string. Worst-cases can make the string 3x its original size! */386 /* This fuction is safe, but make sure you call it safely as well! */387 void http_encode( char *s )388 {389 char *t;390 int i, j;391 392 t = g_strdup( s );393 394 for( i = j = 0; t[i]; i ++, j ++ )395 {396 if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' )397 {398 sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] );399 j += 2;400 }401 else402 {403 s[j] = t[i];404 }405 }406 s[j] = 0;407 408 g_free( t );409 }410 411 /* Strip newlines from a string. Modifies the string passed to it. */412 char *strip_newlines( char *source )413 {414 int i;415 416 for( i = 0; source[i] != '\0'; i ++ )417 if( source[i] == '\n' || source[i] == '\r' )418 source[i] = 32;419 420 return source;421 } -
util.c
re62762b rc88999c 6 6 7 7 /* 8 * nogaim 9 * 10 * Gaim without gaim - for BitlBee 8 * Various utility functions. Some are copied from Gaim to support the 9 * IM-modules, most are from BitlBee. 11 10 * 12 11 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> 13 12 * (and possibly other members of the Gaim team) 14 * Copyright 2002-200 4 Wilmer van der Gaast <lintux@lintux.cx>13 * Copyright 2002-2005 Wilmer van der Gaast <wilmer@gaast.net> 15 14 */ 16 15 … … 32 31 */ 33 32 34 /* Parts from util.c from gaim needed by nogaim */35 33 #define BITLBEE_CORE 36 34 #include "nogaim.h" … … 412 410 g_string_sprintfa( str, "%s%s: %s", newline, name, value ); 413 411 } 412 413 /* Decode%20a%20file%20name */ 414 void http_decode( char *s ) 415 { 416 char *t; 417 int i, j, k; 418 419 t = g_new( char, strlen( s ) + 1 ); 420 421 for( i = j = 0; s[i]; i ++, j ++ ) 422 { 423 if( s[i] == '%' ) 424 { 425 if( sscanf( s + i + 1, "%2x", &k ) ) 426 { 427 t[j] = k; 428 i += 2; 429 } 430 else 431 { 432 *t = 0; 433 break; 434 } 435 } 436 else 437 { 438 t[j] = s[i]; 439 } 440 } 441 t[j] = 0; 442 443 strcpy( s, t ); 444 g_free( t ); 445 } 446 447 /* Warning: This one explodes the string. Worst-cases can make the string 3x its original size! */ 448 /* This fuction is safe, but make sure you call it safely as well! */ 449 void http_encode( char *s ) 450 { 451 char *t; 452 int i, j; 453 454 t = g_strdup( s ); 455 456 for( i = j = 0; t[i]; i ++, j ++ ) 457 { 458 if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' ) 459 { 460 sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] ); 461 j += 2; 462 } 463 else 464 { 465 s[j] = t[i]; 466 } 467 } 468 s[j] = 0; 469 470 g_free( t ); 471 } 472 473 /* Strip newlines from a string. Modifies the string passed to it. */ 474 char *strip_newlines( char *source ) 475 { 476 int i; 477 478 for( i = 0; source[i] != '\0'; i ++ ) 479 if( source[i] == '\n' || source[i] == '\r' ) 480 source[i] = ' '; 481 482 return source; 483 }
Note: See TracChangeset
for help on using the changeset viewer.