- Timestamp:
- 2010-04-26T00:42:37Z (15 years ago)
- Branches:
- master
- Children:
- acba168
- Parents:
- b2bc25c
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/oauth.c
rb2bc25c r508c340 175 175 } 176 176 177 GSList *oauth_params_parse( char *in ) 178 { 179 GSList *ret = NULL; 177 static void oauth_params_parse( GSList **params, char *in ) 178 { 180 179 char *amp, *eq; 181 180 … … 190 189 *amp = '\0'; 191 190 192 oauth_params_add( &ret, in, eq + 1 );191 oauth_params_add( params, in, eq + 1 ); 193 192 194 193 *eq = '='; … … 199 198 in = amp + 1; 200 199 } 201 202 return ret;203 200 } 204 201 … … 312 309 if( req->status_code == 200 ) 313 310 { 314 GSList *params ;311 GSList *params = NULL; 315 312 316 313 st->auth_params = g_strdup( req->reply_body ); 317 params = oauth_params_parse(st->auth_params );314 oauth_params_parse( ¶ms, st->auth_params ); 318 315 st->token = g_strdup( oauth_params_get( ¶ms, "oauth_token" ) ); 319 316 oauth_params_free( ¶ms ); … … 345 342 } 346 343 347 char *oauth_http_header( char *access_token, const char *method, const char *url )348 { 349 GSList *params , *l;350 char *token_secret, *sig, *params_s ;344 char *oauth_http_header( char *access_token, const char *method, const char *url, char *args ) 345 { 346 GSList *params = NULL, *l; 347 char *token_secret, *sig, *params_s, *s; 351 348 GString *ret = NULL; 352 349 353 params = oauth_params_parse(access_token );350 oauth_params_parse( ¶ms, access_token ); 354 351 if( params == NULL ) 355 352 goto err; … … 361 358 oauth_add_default_params( ¶ms ); 362 359 360 ret = g_string_new( "OAuth " ); 361 for( l = params; l; l = l->next ) 362 { 363 char *kv = l->data; 364 char *eq = strchr( kv, '=' ); 365 char esc[strlen(kv)*3+1]; 366 367 if( eq == NULL ) 368 break; /* WTF */ 369 370 strcpy( esc, eq + 1 ); 371 http_encode( esc ); 372 373 g_string_append_len( ret, kv, eq - kv + 1 ); 374 g_string_append_c( ret, '"' ); 375 g_string_append( ret, esc ); 376 g_string_append( ret, "\", " ); 377 } 378 379 if( args ) 380 oauth_params_parse( ¶ms, args ); 381 if( ( s = strchr( url, '?' ) ) ) 382 { 383 s = g_strdup( s + 1 ); 384 oauth_params_parse( ¶ms, s + 1 ); 385 g_free( s ); 386 } 387 363 388 params_s = oauth_params_string( params ); 364 389 sig = oauth_sign( method, url, params_s, token_secret ); … … 367 392 http_encode( sig ); 368 393 369 ret = g_string_new( "OAuth " );370 for( l = params; l; l = l->next )371 {372 char *kv = l->data;373 char *eq = strchr( kv, '=' );374 char esc[strlen(kv)*3+1];375 376 if( eq == NULL )377 break; /* WTF */378 379 strcpy( esc, eq + 1 );380 http_encode( esc );381 382 g_string_append_len( ret, kv, eq - kv + 1 );383 g_string_append_c( ret, '"' );384 g_string_append( ret, esc );385 g_string_append( ret, "\", " );386 }387 388 394 g_string_append_printf( ret, "oauth_signature=\"%s\"", sig ); 389 395 -
lib/oauth.h
rb2bc25c r508c340 21 21 * * 22 22 \***************************************************************************/ 23 24 char *oauth_http_header( char *access_token, const char *method, const char *url, char *args );
Note: See TracChangeset
for help on using the changeset viewer.