#include "common.h" BIO *bio_err=0; static char *pass; static int password_cb(char *buf,int num, int rwflag,void *userdata); static void sigpipe_handle(int x); /* A simple error and exit routine*/ int err_exit(string) char *string; { #ifdef DEBUG printf("[ERROR] %s\n",string); #endif fprintf(stderr,"%s\n",string); exit(0); } /* Print SSL errors and exit*/ int berr_exit(string) char *string; { #ifdef DEBUG BIO_printf(bio_err,"%s\n",string); ERR_print_errors(bio_err); #endif exit(0); } /*The password code is not thread safe*/ static int password_cb(char *buf,int num, int rwflag,void *userdata) { if(num 0) { max_token_size = max_token_size > token_size+1 ? max_token_size : token_size+1; token_size = 0; token_count += 1; } if ((*c) == '\0') { break; } } #ifdef DEBUG printf("TokenizeString: token_count=%d, max_token_size=%d\n", token_count, max_token_size); #endif (*size) = max_token_size; (*s_Token) = (char**)malloc(token_count*sizeof(char*)); char **deRef = (*s_Token); for (j = 0; j < token_count; j++) { deRef[j] = (char*)malloc(max_token_size); } j=0; for (i_Offset = 0;s_String[i_Offset] != '\0';i_Offset++){ #ifdef DEBUG printf("TokenizeString: char=%c\n", s_String[i_Offset]); #endif if (s_String[i_Offset] != c_Delimiter && s_String[i_Offset] != '\t' && s_String[i_Offset] != '\n' && s_String[i_Offset] != '\0'){ (deRef[count])[j] = s_String[i_Offset]; j++; if (j >= max_token_size) { printf("TokensizeString: token too long! exceeds 15 characters including nul terminator.\n"); } b_Flag = 1; continue; } if (b_Flag){ if (count >= token_count) { printf("TokenizeString: too many tokens! exceeds limit of 50 tokens.\n"); } (deRef[count])[j] = '\0'; #ifdef DEBUG printf("TokenizeString: token=%s, j=%d, count=%d\n", deRef[count], j, count); #endif count++; j = 0; b_Flag = 0; } } if (b_Flag || j > 0) { (deRef[count])[j] = '\0'; #ifdef DEBUG printf("TokenizeString: token=%s, j=%d, count=%d\n", deRef[count], j , count); #endif count++; } #ifdef DEBUG for (j = 0; j < token_count; j++) { printf("%s\n", deRef[j]); } #endif return count; }