这篇教程C++ string_free函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中string_free函数的典型用法代码示例。如果您正苦于以下问题:C++ string_free函数的具体用法?C++ string_free怎么用?C++ string_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了string_free函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mallocPUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer, int type) { STRING *e = NULL; STRING *n = NULL; PUBLIC_KEY *key = NULL; key = malloc(sizeof(PUBLIC_KEY)); if (key == NULL) { buffer_free(buffer); return NULL; } key->type = type; key->type_c = ssh_type_to_char(key->type); e = buffer_get_ssh_string(buffer); n = buffer_get_ssh_string(buffer); buffer_free(buffer); /* we don't need it anymore */ if(e == NULL || n == NULL) { ssh_set_error(session, SSH_FATAL, "Invalid RSA public key"); goto error; }#ifdef HAVE_LIBGCRYPT gcry_sexp_build(&key->rsa_pub, NULL, "(public-key(rsa(n %b)(e %b)))", string_len(n), n->string, string_len(e),e->string); if (key->rsa_pub == NULL) { goto error; }#elif HAVE_LIBCRYPTO key->rsa_pub = RSA_new(); if (key->rsa_pub == NULL) { goto error; } key->rsa_pub->e = make_string_bn(e); key->rsa_pub->n = make_string_bn(n); if (key->rsa_pub->e == NULL || key->rsa_pub->n == NULL) { goto error; }#endif#ifdef DEBUG_CRYPTO ssh_print_hexa("e", e->string, string_len(e)); ssh_print_hexa("n", n->string, string_len(n));#endif string_burn(e); string_free(e); string_burn(n); string_free(n); return key;error: string_burn(e); string_free(e); string_burn(n); string_free(n); publickey_free(key); return NULL;}
开发者ID:BackupTheBerlios,项目名称:libssh-svn,代码行数:66,
示例2: macro_paramlist/* * macro_paramlist * * Parse a macro or structure parameter list, for declarations. * * For keyword macros and structure declarations, * handles the default value setting. * * For non-keyword macros, handles simple, conditional, and * iterative macro parameter lists. * * Returns: -1 on error * index of closing delimiter in delims[] array on success */intmacro_paramlist (expr_ctx_t ctx, scopectx_t curscope, int assign_allowed, int for_macro, lextype_t delims[], int ndelims, scopectx_t *ptable, namereflist_t *plist){ parse_ctx_t pctx = expr_parse_ctx(ctx); namectx_t namectx = scope_namectx(parser_scope_get(pctx)); lexctx_t lctx = parser_lexmemctx(pctx); lexeme_t *lex; lextype_t lt; name_t *mnp; scopectx_t pscope; lexseq_t nullseq; namedef_t ndef; int i, did1; lextype_t terms[16]; // Need a delimiter array that adds ',' to the // caller's list if (ndelims >= 16) return -1; memcpy(terms, delims, sizeof(lextype_t)*ndelims); terms[ndelims] = LEXTYPE_DELIM_COMMA; if (*ptable == 0) { pscope = scope_begin(scope_namectx(curscope), curscope); } else { pscope = *ptable; } lexseq_init(&nullseq); parser_scope_begin(pctx); memset(&ndef, 0, sizeof(ndef)); ndef.lt = LEXTYPE_NAME_MAC_PARAM; did1 = 0; while (1) { lexseq_t *pseq; strdesc_t *namestr; textpos_t pos; // Look for a parameter name if (!parse_decl_name(pctx, &namestr, &pos)) { // Null parameter list is OK, but empty parameter // after a comma is not if (did1) { expr_signal(ctx, STC__NAMEEXP); } lt = parser_next(pctx, QL_NAME, 0); break; } // Declare the parameter in the parameter name table did1 = 1; ndef.name = namestr->ptr; ndef.namelen = namestr->len; mnp = name_declare(pscope, &ndef, pos, 0, 0, &pseq); string_free(expr_strctx(ctx), namestr); if (mnp == 0) { expr_signal(ctx, STC__INTCMPERR, "macro_paramlist"); break; } namereflist_instail(plist, nameref_alloc(namectx, mnp)); // If assignment is allowed, parse the '=' and the // default value - a lexeme sequence for macros, a CTCE for // structures lt = parser_next(pctx, QL_NAME, &lex); if (assign_allowed && lt == LEXTYPE_OP_ASSIGN) { int status; lexeme_free(lctx, lex); if (for_macro) { status = parse_lexeme_seq(pctx, 0, QL_MACRO, terms, ndelims+1, pseq, <); } else { status = expr_parse_ctce(ctx, &lex, 0); if (status) lexseq_instail(pseq, lex); lt = parser_next(pctx, QL_NORMAL, 0); } if (!status) { expr_signal(ctx, STC__SYNTAXERR); break; } } else { lexeme_free(lctx, lex); } if (lt != LEXTYPE_DELIM_COMMA) { break;//.........这里部分代码省略.........
开发者ID:madisongh,项目名称:blissc,代码行数:101,
示例3: tunet_logon_recv_welcomestatic int tunet_logon_recv_welcome(){ BYTE tmpbuf[1024 * 8]; CHAR tmp[1024]; BYTE btag; UINT32 unknowntag; UINT32 datalen; BYTE *p; int len; const CHAR *WELCOME = "WELCOME TO TUNET"; //int msglen = 0; STRING *str = NULL;// BOOL sr, sw, se; if(!main_socket) return OK; // os_socket_tcp_status(main_socket, &sr, &sw, &se); if(tunet_state != TUNET_STATE_RECV_WELCOME) return OK;/* if(se) { logs_append(g_logs, "TUNET_NETWORK_ERROR", "RECV_WELCOME", NULL, 0); return ERR; } if(!sr) return OK;*/ len = os_socket_tcp_recv(main_socket, tmpbuf, sizeof(tmpbuf)); if(len == -1) { logs_append(g_logs, "TUNET_NETWORK_ERROR", "RECV_WELCOME", NULL, 0); return ERR; } if(len > 0) { main_socket_buffer = buffer_append(main_socket_buffer, tmpbuf, len); logs_append(g_logs, "TUNET_LOGON_RECV", "WELCOME", tmpbuf, len); buf2output(tmpbuf, len, tmp, 16); //dprintf("data received(recv welcome):/n%s/n", tmp); p = main_socket_buffer->data; while(buffer_fetch_BYTE(main_socket_buffer, &p, &btag)) { switch(btag) { case 0x01: if(!buffer_fetch_STRING(main_socket_buffer, &p, &str, strlen(WELCOME))) return OK; if(strncmp(str->str, WELCOME, strlen(WELCOME)) != 0) { str = string_free(str); //TODO //process such error!!!!!!!!! logs_append(g_logs, "TUNET_LOGON_WELCOME", str->str, NULL, 0); tunet_state = TUNET_STATE_ERROR; return OK; } str = string_free(str); if(!buffer_fetch_DWORD(main_socket_buffer, &p, &unknowntag)) return OK; unknowntag = htonl(unknowntag); if(!buffer_fetch_bytes(main_socket_buffer, &p, welcome_data, 8)) return OK; if(!buffer_fetch_DWORD(main_socket_buffer, &p, &datalen)) return OK; datalen = htonl(datalen); //dprintf("欢迎消息长 %d/n", datalen); if(!buffer_fetch_STRING(main_socket_buffer, &p, &str, datalen)) return OK; logs_append(g_logs, "TUNET_LOGON_WELCOME", str->str, NULL, 0); //dprintf("%s/n", str->str); str = string_free(str); main_socket_buffer = buffer_rollto(main_socket_buffer, p); p = main_socket_buffer->data; tunet_state = TUNET_STATE_REPLY_WELCOME; //.........这里部分代码省略.........
开发者ID:alick,项目名称:mytunet,代码行数:101,
示例4: free_if_neededstatic void free_if_needed(struct url_check* url){ string_free(&url->realLink); string_free(&url->displayLink); string_free(&url->pre_fixup.pre_displayLink);}
开发者ID:5432935,项目名称:crossbridge,代码行数:6,
示例5: var_definesvoidvar_defines( char *const* e, int preprocess ){ string buf[1]; string_new( buf ); for( ; *e; e++ ) { char *val;# ifdef OS_MAC /* On the mac (MPW), the var=val is actually var/0val */ /* Think different. */ if( ( val = strchr( *e, '=' ) ) || ( val = *e + strlen( *e ) ) )# else if( val = strchr( *e, '=' ) )# endif { LIST *l = L0; char *pp, *p;# ifdef OPT_NO_EXTERNAL_VARIABLE_SPLIT char split = '/0';# else# ifdef OS_MAC char split = ',';# else char split = ' ';# endif# endif size_t len = strlen(val + 1); int quoted = val[1] == '"' && val[len] == '"'; if ( quoted && preprocess ) { string_append_range( buf, val + 2, val + len ); l = list_new( l, newstr( buf->value ) ); string_truncate( buf, 0 ); } else { /* Split *PATH at :'s, not spaces */ if( val - 4 >= *e ) { if( !strncmp( val - 4, "PATH", 4 ) || !strncmp( val - 4, "Path", 4 ) || !strncmp( val - 4, "path", 4 ) ) split = SPLITPATH; } /* Do the split */ for( pp = val + 1; preprocess && (p = strchr( pp, split )) != 0; pp = p + 1 ) { string_append_range( buf, pp, p ); l = list_new( l, newstr( buf->value ) ); string_truncate( buf, 0 ); } l = list_new( l, newstr( pp ) ); } /* Get name */ string_append_range( buf, *e, val ); var_set( buf->value, l, VAR_SET ); string_truncate( buf, 0 ); } } string_free( buf );}
开发者ID:Albermg7,项目名称:boost,代码行数:76,
示例6: WndProcLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ switch(message) { case WM_FOO_GET_ACTIVE_PLAYLIST_COUNT: if(plist_api) return activeplaylist_get_item_count(&plist_api); return P_ERROR; case WM_FOO_GET_PLAYLIST_ITEM: { char title[512]; wchar_t w_title[512]; if(!ptcomp_api || !plist_api || !pback_api) return P_ERROR; if(wParam == -1 && !is_playing(&pback_api)) return P_ERROR; int tracknumb = (wParam==-1)?(int)get_playing_item_location(&plist_api):wParam; PTITLEFORMAT_OBJECT *t_obj=0; // Must be 0!!! if(!GetWindowText(p_hWnd, title, 512)) return P_ERROR; if(compile(&ptcomp_api, &t_obj, title)) { string_free(); playlist_item_format_title(&plist_api, get_active_playlist(&plist_api), tracknumb, 0, &str, &t_obj, 0, display_level_all); MultiByteToWideChar(CP_UTF8, 0, str.data, -1, w_title, 512); SetWindowTextW(p_hWnd, w_title); service_release((PSERVICE_BASE*)t_obj); return 0; } return P_ERROR; } case WM_FOO_GET_CURRENT_TRACK: if(plist_api) return get_playing_item_location(&plist_api); return P_ERROR; case WM_FOO_ORDER: if(plist_api) {playback_order_set_active(&plist_api, wParam); return 0;} return P_ERROR; case WM_FOO_OPEN: return main_open(&g_api); case WM_FOO_ADD: return main_add_files(&g_api); case WM_FOO_ADDDIR: return main_add_directory(&g_api); case WM_FOO_PLAY: if(pback_api) {start_resume(&pback_api); return 0;} return P_ERROR; case WM_FOO_STOP: if(pback_api) {stop(&pback_api); return 0;} return P_ERROR; case WM_FOO_PLAY_NEXT: if(pback_api) {start(&pback_api, track_command_next); return 0;} return P_ERROR; case WM_FOO_PLAY_PREV: if(pback_api) {start(&pback_api, track_command_prev); return 0;} return P_ERROR; case WM_FOO_PLAY_RANDOM: if(pback_api) {start(&pback_api, track_command_rand); return 0;} return P_ERROR; case WM_FOO_PAUSE: if(pback_api) {pause(&pback_api, true); return 0;} return P_ERROR; case WM_FOO_PLAY_PAUSE: if(pback_api) {play_pause(&pback_api); return 0;} return P_ERROR; case WM_FOO_VOLUME_UP: if(pback_api) {volume_up(&pback_api); return 0;} return P_ERROR; case WM_FOO_VOLUME_DOWN: if(pback_api) {volume_down(&pback_api); return 0;} return P_ERROR; case WM_FOO_GET_VOLUME: if(pback_api) return get_volume(&pback_api); return P_ERROR; case WM_FOO_SET_VOLUME: if(pback_api) {set_volume(&pback_api, wParam); return 0;} return P_ERROR; case WM_FOO_MUTE: if(pback_api) {mute(&pback_api); return 0;} return P_ERROR; case WM_FOO_IS_PLAYING: if(pback_api) return (is_playing(&pback_api) && !is_paused(&pback_api)); return P_ERROR; case WM_FOOL_IS_PAUSED: if(pback_api) return is_paused(&pback_api); return P_ERROR; case WM_FOO_GET_STOP_AFTER_CURRENT://.........这里部分代码省略.........
开发者ID:ejasiunas,项目名称:bbclean-xzero450,代码行数:101,
示例7: var_string_to_filevoid var_string_to_file( const char * in, int insize, const char * out, LOL * lol ){ const char * ine = in+insize; FILE * out_file = 0; if ( strcmp( out, "STDOUT" ) == 0 ) { out_file = stdout; } else if ( strcmp( out, "STDERR" ) == 0 ) { out_file = stderr; } else { /* Handle "path to file" filenames. */ string out_name; if ( out[0] == '"' && out[strlen(out) - 1] == '"' ) { string_copy(&out_name,out+1); string_truncate(&out_name,out_name.size-1); } else { string_copy(&out_name,out); } out_file = fopen( out_name.value, "w" ); if (!out_file) { printf( "failed to write output file '%s'!/n", out_name.value ); exit( EXITBAD ); } string_free(&out_name); } while( *in && in < ine ) { int dollar = 0; const char * output_0 = in; const char * output_1 = in; /* Copy white space */ while ( output_1 < ine && *output_1 && isspace( *output_1 ) ) { ++output_1; } if ( output_0 < output_1 ) { fwrite(output_0,output_1-output_0,1,out_file); } output_0 = output_1; /* Copy non-white space, watching for variables */ while( output_1 < ine && *output_1 && !isspace( *output_1 ) ) { if( output_1[0] == '$' && output_1[1] && output_1[1] == '(' ) { dollar++; } ++output_1; } /* If a variable encountered, expand it and and embed the */ /* space-separated members of the list in the output. */ if( dollar ) { LIST *l; l = var_expand( L0, (char*)output_0, (char*)output_1, lol, 0 ); while ( l ) { fputs( l->string, out_file ); l = list_next( l ); if ( l ) fputc( ' ', out_file ); } list_free( l ); } else if ( output_0 < output_1 ) { fwrite(output_0,output_1-output_0,1,out_file); } in = output_1; } if ( out_file != stdout && out_file != stderr ) { fflush( out_file ); fclose( out_file ); }}
开发者ID:OS2World,项目名称:DEV-UTIL-BoostJam,代码行数:95,
示例8: get_free_cmdtab_slotvoid exec_cmd( string const * cmd_orig, int flags, ExecCmdCallback func, void * closure, LIST * shell){ int const slot = get_free_cmdtab_slot(); int const is_raw_cmd = is_raw_command_request( shell ); string cmd_local[ 1 ]; /* Initialize default shell - anything more than /Q/C is non-portable. */ static LIST * default_shell; if ( !default_shell ) default_shell = list_new( object_new( "cmd.exe /Q/C" ) ); /* Specifying no shell means requesting the default shell. */ if ( list_empty( shell ) ) shell = default_shell; if ( DEBUG_EXECCMD ) if ( is_raw_cmd ) out_printf( "Executing raw command directly/n" ); else { out_printf( "Executing using a command file and the shell: " ); list_print( shell ); out_printf( "/n" ); } /* If we are running a raw command directly - trim its leading whitespaces * as well as any trailing all-whitespace lines but keep any trailing * whitespace in the final/only line containing something other than * whitespace). */ if ( is_raw_cmd ) { char const * start = cmd_orig->value; char const * p = cmd_orig->value + cmd_orig->size; char const * end = p; while ( isspace( *start ) ) ++start; while ( p > start && isspace( p[ -1 ] ) ) if ( *--p == '/n' ) end = p; string_new( cmd_local ); string_append_range( cmd_local, start, end ); assert( cmd_local->size == raw_command_length( cmd_orig->value ) ); } /* If we are not running a raw command directly, prepare a command file to * be executed using an external shell and the actual command string using * that command file. */ else { char const * const cmd_file = prepare_command_file( cmd_orig, slot ); char const * argv[ MAXARGC + 1 ]; /* +1 for NULL */ argv_from_shell( argv, shell, cmd_file, slot ); string_new_from_argv( cmd_local, argv ); } /* Catch interrupts whenever commands are running. */ if ( !intr_installed ) { intr_installed = 1; signal( SIGINT, onintr ); } cmdtab[ slot ].flags = flags; /* Save input data into the selected running commands table slot. */ cmdtab[ slot ].func = func; cmdtab[ slot ].closure = closure; /* Invoke the actual external process using the constructed command line. */ invoke_cmd( cmd_local->value, slot ); /* Free our local command string copy. */ string_free( cmd_local );}
开发者ID:DanielaE,项目名称:boost.build,代码行数:81,
示例9: buffer_new/* Signature decoding functions */static STRING *signature_to_string(SIGNATURE *sign) { unsigned char buffer[40] = {0}; BUFFER *tmpbuf = NULL; STRING *str = NULL; STRING *tmp = NULL; STRING *rs = NULL; int rc = -1;#ifdef HAVE_LIBGCRYPT const char *r = NULL; const char *s = NULL; gcry_sexp_t sexp; size_t size = 0;#elif defined HAVE_LIBCRYPTO STRING *r = NULL; STRING *s = NULL;#endif tmpbuf = buffer_new(); if (tmpbuf == NULL) { return NULL; } tmp = string_from_char(ssh_type_to_char(sign->type)); if (tmp == NULL) { buffer_free(tmpbuf); return NULL; } if (buffer_add_ssh_string(tmpbuf, tmp) < 0) { buffer_free(tmpbuf); string_free(tmp); return NULL; } string_free(tmp); switch(sign->type) { case TYPE_DSS:#ifdef HAVE_LIBGCRYPT sexp = gcry_sexp_find_token(sign->dsa_sign, "r", 0); if (sexp == NULL) { buffer_free(tmpbuf); return NULL; } r = gcry_sexp_nth_data(sexp, 1, &size); if (*r == 0) { /* libgcrypt put 0 when first bit is set */ size--; r++; } memcpy(buffer, r + size - 20, 20); gcry_sexp_release(sexp); sexp = gcry_sexp_find_token(sign->dsa_sign, "s", 0); if (sexp == NULL) { buffer_free(tmpbuf); return NULL; } s = gcry_sexp_nth_data(sexp,1,&size); if (*s == 0) { size--; s++; } memcpy(buffer+ 20, s + size - 20, 20); gcry_sexp_release(sexp);#elif defined HAVE_LIBCRYPTO r = make_bignum_string(sign->dsa_sign->r); if (r == NULL) { buffer_free(tmpbuf); return NULL; } s = make_bignum_string(sign->dsa_sign->s); if (s == NULL) { buffer_free(tmpbuf); string_free(r); return NULL; } memcpy(buffer, r->string + string_len(r) - 20, 20); memcpy(buffer + 20, s->string + string_len(s) - 20, 20); string_free(r); string_free(s);#endif /* HAVE_LIBCRYPTO */ rs = string_new(40); if (rs == NULL) { buffer_free(tmpbuf); return NULL; } string_fill(rs, buffer, 40); rc = buffer_add_ssh_string(tmpbuf, rs); string_free(rs); if (rc < 0) { buffer_free(tmpbuf); return NULL; } break; case TYPE_RSA: case TYPE_RSA1:#ifdef HAVE_LIBGCRYPT//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:libssh-svn,代码行数:101,
示例10: rsa_public_to_stringstatic int rsa_public_to_string(gcry_sexp_t key, BUFFER *buffer) {#elif defined HAVE_LIBCRYPTOstatic int rsa_public_to_string(RSA *key, BUFFER *buffer) {#endif STRING *e = NULL; STRING *n = NULL; int rc = -1;#ifdef HAVE_LIBGCRYPT const char *tmp; size_t size; gcry_sexp_t sexp; sexp = gcry_sexp_find_token(key, "n", 0); if (sexp == NULL) { goto error; } tmp = gcry_sexp_nth_data(sexp, 1, &size); n = string_new(size); if (n == NULL) { goto error; } string_fill(n, (char *) tmp, size); gcry_sexp_release(sexp); sexp = gcry_sexp_find_token(key, "e", 0); if (sexp == NULL) { goto error; } tmp = gcry_sexp_nth_data(sexp, 1, &size); e = string_new(size); if (e == NULL) { goto error; } string_fill(e, (char *) tmp, size);#elif defined HAVE_LIBCRYPTO e = make_bignum_string(key->e); n = make_bignum_string(key->n); if (e == NULL || n == NULL) { goto error; }#endif if (buffer_add_ssh_string(buffer, e) < 0) { goto error; } if (buffer_add_ssh_string(buffer, n) < 0) { goto error; } rc = 0;error:#ifdef HAVE_LIBGCRYPT gcry_sexp_release(sexp);#endif string_burn(e); string_free(e); string_burn(n); string_free(n); return rc;}
开发者ID:BackupTheBerlios,项目名称:libssh-svn,代码行数:66,
示例11: dsa_public_to_stringstatic int dsa_public_to_string(gcry_sexp_t key, BUFFER *buffer) {#elif defined HAVE_LIBCRYPTOstatic int dsa_public_to_string(DSA *key, BUFFER *buffer) {#endif STRING *p = NULL; STRING *q = NULL; STRING *g = NULL; STRING *n = NULL; int rc = -1;#ifdef HAVE_LIBGCRYPT const char *tmp = NULL; size_t size; gcry_sexp_t sexp; sexp = gcry_sexp_find_token(key, "p", 0); if (sexp == NULL) { goto error; } tmp = gcry_sexp_nth_data(sexp, 1, &size); p = string_new(size); if (p == NULL) { goto error; } string_fill(p, (char *) tmp, size); gcry_sexp_release(sexp); sexp = gcry_sexp_find_token(key, "q", 0); if (sexp == NULL) { goto error; } tmp = gcry_sexp_nth_data(sexp, 1, &size); q = string_new(size); if (q == NULL) { goto error; } string_fill(q, (char *) tmp, size); gcry_sexp_release(sexp); sexp = gcry_sexp_find_token(key, "g", 0); if (sexp == NULL) { goto error; } tmp = gcry_sexp_nth_data(sexp, 1, &size); g = string_new(size); if (g == NULL) { goto error; } string_fill(g, (char *) tmp, size); gcry_sexp_release(sexp); sexp = gcry_sexp_find_token(key, "y", 0); if (sexp == NULL) { goto error; } tmp = gcry_sexp_nth_data(sexp, 1, &size); n = string_new(size); if (n == NULL) { goto error; } string_fill(n, (char *) tmp, size); gcry_sexp_release(sexp);#elif defined HAVE_LIBCRYPTO p = make_bignum_string(key->p); q = make_bignum_string(key->q); g = make_bignum_string(key->g); n = make_bignum_string(key->pub_key); if (p == NULL || q == NULL || g == NULL || n == NULL) { goto error; }#endif /* HAVE_LIBCRYPTO */ if (buffer_add_ssh_string(buffer, p) < 0) { goto error; } if (buffer_add_ssh_string(buffer, q) < 0) { goto error; } if (buffer_add_ssh_string(buffer, g) < 0) { goto error; } if (buffer_add_ssh_string(buffer, n) < 0) { goto error; } rc = 0;error:#ifdef HAVE_LIBGCRYPT gcry_sexp_release(sexp);#endif string_burn(p); string_free(p); string_burn(q); string_free(q); string_burn(g); string_free(g); string_burn(n); string_free(n);//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:libssh-svn,代码行数:101,
示例12: ssh_msg_userauth_build_digest/* * This function concats in a buffer the values needed to do a signature * verification. */static ssh_buffer ssh_msg_userauth_build_digest(ssh_session session, ssh_message msg, const char *service){ struct ssh_crypto_struct *crypto = session->current_crypto ? session->current_crypto : session->next_crypto; ssh_buffer buffer; ssh_string str; int rc; buffer = ssh_buffer_new(); if (buffer == NULL) { return NULL; } /* Add session id */ str = ssh_string_new(crypto->digest_len); if (str == NULL) { ssh_buffer_free(buffer); return NULL; } ssh_string_fill(str, crypto->session_id, crypto->digest_len); rc = buffer_add_ssh_string(buffer, str); string_free(str); if (rc < 0) { ssh_buffer_free(buffer); return NULL; } /* Add the type */ rc = buffer_add_u8(buffer, SSH2_MSG_USERAUTH_REQUEST); if (rc < 0) { ssh_buffer_free(buffer); return NULL; } /* Add the username */ str = ssh_string_from_char(msg->auth_request.username); if (str == NULL) { ssh_buffer_free(buffer); return NULL; } rc = buffer_add_ssh_string(buffer, str); string_free(str); if (rc < 0) { ssh_buffer_free(buffer); return NULL; } /* Add the service name */ str = ssh_string_from_char(service); if (str == NULL) { ssh_buffer_free(buffer); return NULL; } rc = buffer_add_ssh_string(buffer, str); string_free(str); if (rc < 0) { ssh_buffer_free(buffer); return NULL; } /* Add the method (publickey) */ str = ssh_string_from_char("publickey"); if (str == NULL) { ssh_buffer_free(buffer); return NULL; } rc = buffer_add_ssh_string(buffer, str); string_free(str); if (rc < 0) { ssh_buffer_free(buffer); return NULL; } /* Has been signed (TRUE) */ rc = buffer_add_u8(buffer, 1); if (rc < 0) { ssh_buffer_free(buffer); return NULL; } /* Add the public key algorithm */ str = ssh_string_from_char(msg->auth_request.pubkey->type_c); if (str == NULL) { ssh_buffer_free(buffer); return NULL; } rc = buffer_add_ssh_string(buffer, str); string_free(str); if (rc < 0) { ssh_buffer_free(buffer); return NULL; }//.........这里部分代码省略.........
开发者ID:magnum,项目名称:tmate,代码行数:101,
示例13: string_renewstatic void string_renew( string * const s ){ string_free( s ); string_new( s );}
开发者ID:DanielaE,项目名称:boost.build,代码行数:5,
示例14: rest_free_inner/* begin implementations */static void rest_free_inner(t_rest *const rest) { ctw_free((struct _ctw *)rest); string_free(rest->cookie.login_path, &rest->cookie.login_path_len); string_free(rest->cookie.username, &rest->cookie.username_len); string_free(rest->cookie.password, &rest->cookie.password_len);}
开发者ID:megrimm,项目名称:PuRestJson,代码行数:7,
示例15: msg_queue_readint msg_queue_read() { struct dirent *d; DIR *dir; if (!(dir = opendir(prepare_pathf("queue")))) /* opendir() ~/.ekg2/[PROFILE/]/queue */ return -1; while ((d = readdir(dir))) { const char *fn; msg_queue_t m; struct stat st; string_t msg; char *buf; FILE *f; int filever = 0; if (!(fn = prepare_pathf("queue/%s", d->d_name))) continue; if (stat(fn, &st) || !S_ISREG(st.st_mode)) continue; if (!(f = fopen(fn, "r"))) continue; memset(&m, 0, sizeof(m)); buf = read_file(f, 0); if (buf && *buf == 'v') filever = atoi(buf+1); if (!filever || filever > 2) { fclose(f); continue; } if (!(m.session = read_file(f, 1))) { fclose(f); continue; } if (!(m.rcpts = read_file(f, 1))) { xfree(m.session); fclose(f); continue; } if (!(buf = read_file(f, 0))) { xfree(m.session); xfree(m.rcpts); fclose(f); continue; } m.time = atoi(buf); if (!(m.seq = read_file(f, 1))) { xfree(m.session); xfree(m.rcpts); fclose(f); continue; } if (filever == 2) { if (!(buf = read_file(f, 0))) { xfree(m.session); xfree(m.rcpts); fclose(f); continue; } m.mclass = atoi(buf); } else m.mclass = EKG_MSGCLASS_SENT; msg = string_init(NULL); buf = read_file(f, 0); while (buf) { string_append(msg, buf); buf = read_file(f, 0); if (buf) string_append(msg, "/r/n"); } m.message = string_free(msg, 0); msgs_queue_add(xmemdup(&m, sizeof(m))); fclose(f); unlink(fn); } closedir(dir); return 0;}
开发者ID:dmilith,项目名称:ekg2-bsd,代码行数:99,
示例16: var_stringintvar_string( char *in, char *out, int outsize, LOL *lol ){ char *out0 = out; char *oute = out + outsize - 1; while( *in ) { char *lastword; int dollar = 0; /* Copy white space */ while( isspace( *in ) ) { if( out >= oute ) return -1; *out++ = *in++; } lastword = out; /* Copy non-white space, watching for variables */ while( *in && !isspace( *in ) ) { if( out >= oute ) return -1; if( in[0] == '$' && in[1] == '(' ) dollar++; #ifdef OPT_AT_FILES else if ( in[0] == '@' && in[1] == '(' ) { int depth = 1; char *ine = in + 2; char *split = 0; /* Scan the content of the response file @() section. */ while( *ine && depth > 0 ) { switch( *ine ) { case '(': ++depth; break; case ')': --depth; break; case ':': if( depth == 1 && ine[1] == 'E' && ine[2] == '=' ) { split = ine; } break; } ++ine; } if (!split) { printf( "no file specified!/n" ); exit( EXITBAD ); } if ( depth == 0 ) { string file_name_v; int file_name_l = 0; const char * file_name_s = 0; /* expand the temporary file name var inline */ #if 0 string_copy(&file_name_v,"$("); string_append_range(&file_name_v,in+2,split); string_push_back(&file_name_v,')'); #else string_new(&file_name_v); string_append_range(&file_name_v,in+2,split); #endif file_name_l = var_string(file_name_v.value,out,oute-out+1,lol); string_free(&file_name_v); if ( file_name_l < 0 ) return -1; file_name_s = out; /* for stdout/stderr we will create a temp file and generate a command that outputs the content as needed. */ if ( strcmp( "STDOUT", out ) == 0 || strcmp( "STDERR", out ) == 0 ) { int err_redir = strcmp( "STDERR", out ) == 0; out[0] = '/0'; file_name_s = path_tmpfile(); file_name_l = strlen(file_name_s); #if defined( OS_NT ) || defined( OS_OS2 )//.........这里部分代码省略.........
开发者ID:OS2World,项目名称:DEV-UTIL-BoostJam,代码行数:101,
示例17: packet_parsevoid packet_parse(SSH_SESSION *session) { STRING *error_s = NULL; char *error = NULL; int type = session->in_packet.type; u32 tmp;#ifdef HAVE_SSH1 if (session->version == 1) { /* SSH-1 */ switch(type) { case SSH_MSG_DISCONNECT: ssh_log(session, SSH_LOG_PACKET, "Received SSH_MSG_DISCONNECT"); ssh_set_error(session, SSH_FATAL, "Received SSH_MSG_DISCONNECT"); ssh_socket_close(session->socket); session->alive = 0; return; case SSH_SMSG_STDOUT_DATA: case SSH_SMSG_STDERR_DATA: case SSH_SMSG_EXITSTATUS: channel_handle1(session,type); return; case SSH_MSG_DEBUG: case SSH_MSG_IGNORE: break; default: ssh_log(session, SSH_LOG_PACKET, "Unexpected message code %d", type); } return; } else {#endif /* HAVE_SSH1 */ switch(type) { case SSH2_MSG_DISCONNECT: buffer_get_u32(session->in_buffer, &tmp); error_s = buffer_get_ssh_string(session->in_buffer); if (error_s == NULL) { return; } error = string_to_char(error_s); string_free(error_s); if (error == NULL) { return; } ssh_log(session, SSH_LOG_PACKET, "Received SSH_MSG_DISCONNECT/n"); ssh_set_error(session, SSH_FATAL, "Received SSH_MSG_DISCONNECT: %s",error); SAFE_FREE(error); ssh_socket_close(session->socket); session->alive = 0; return; case SSH2_MSG_CHANNEL_WINDOW_ADJUST: case SSH2_MSG_CHANNEL_DATA: case SSH2_MSG_CHANNEL_EXTENDED_DATA: case SSH2_MSG_CHANNEL_REQUEST: case SSH2_MSG_CHANNEL_EOF: case SSH2_MSG_CHANNEL_CLOSE: channel_handle(session,type); case SSH2_MSG_IGNORE: case SSH2_MSG_DEBUG: return; default: ssh_log(session, SSH_LOG_RARE, "Received unhandled packet %d", type); }#ifdef HAVE_SSH1 }#endif}
开发者ID:BackupTheBerlios,项目名称:libssh-svn,代码行数:71,
|