VIOAPI VIO_Status initialize_tag_file_input( FILE *file, int *n_volumes_ptr ) { VIO_STR line; int n_volumes; /* parameter checking */ if( file == NULL ) { print_error( "initialize_tag_file_input(): passed NULL FILE ptr.\n"); return( VIO_ERROR ); } /* okay read the header */ if( mni_input_string( file, &line, (char) 0, (char) 0 ) != VIO_OK || !equal_strings( line, (VIO_STR) TAG_FILE_HEADER ) ) { print_error( "input_tag_points(): invalid header in file.\n"); delete_string( line ); return( VIO_ERROR ); } delete_string( line ); /* now read the number of volumes */ if( mni_input_keyword_and_equal_sign( file, VOLUMES_STRING, TRUE ) != VIO_OK ) return( VIO_ERROR ); if( mni_input_int( file, &n_volumes ) != VIO_OK ) { print_error( "input_tag_points(): expected # volumes after %s.\n", VOLUMES_STRING ); return( VIO_ERROR ); } if( mni_skip_expected_character( file, (char) ';' ) != VIO_OK ) return( VIO_ERROR ); if( n_volumes != 1 && n_volumes != 2 ) { print_error( "input_tag_points(): invalid # volumes: %d \n", n_volumes ); return( VIO_ERROR ); } /* now read the tag points header */ if( mni_input_keyword_and_equal_sign( file, TAG_POINTS_STRING, TRUE ) != VIO_OK) return( VIO_ERROR ); if( n_volumes_ptr != NULL ) *n_volumes_ptr = n_volumes; return( VIO_OK ); }
VIOAPI Status mni_input_keyword_and_equal_sign( FILE *file, const char keyword[], BOOLEAN print_error_message ) { Status status; STRING str; status = mni_input_string( file, &str, (char) '=', (char) 0 ); if( status == END_OF_FILE ) return( status ); if( status != OK || !equal_strings( str, (STRING) keyword ) || mni_skip_expected_character( file, (char) '=' ) != OK ) { if( print_error_message ) print_error( "Expected \"%s =\"\n", keyword ); status = ERROR; } delete_string( str ); return( status ); }
VIOAPI Status mni_input_line( FILE *file, STRING *string ) { Status status; char ch; *string = create_string( NULL ); status = input_character( file, &ch ); while( status == OK && ch != '\n' ) { if (ch != '\r') { /* Always ignore carriage returns */ concat_char_to_string( string, ch ); } status = input_character( file, &ch ); } if( status != OK ) { delete_string( *string ); *string = NULL; } return( status ); }
int delete_twins (char *name) { int rc; rc = delete_string( &TreeA, name); if (rc) { printf("Failed delete string for TreeA \"%s\" err=%d\n", name, rc); } rc = delete_string( &TreeB, name); if (rc) { printf("Failed delete string for TreeB \"%s\" err=%d\n", name, rc); } return rc; }
int main ( void ) { String stackS = make_string("Test string"), intString = make_string("123"), dblString = make_string(" 12.3"), *heapS = new_string("This is on the heap"); int test_int; double test_double; S_TO_NUM(intString, &test_int, NUM_INT); S_TO_NUM(dblString, &test_double, NUM_DOUBLE); destroy_string( &intString ); destroy_string( &dblString ); printf( "%s\n%s\n", TO_STRING(stackS), P_TO_STRING(heapS) ); printf( "String to int test: %d\nString to double test: %f\n", test_int, test_double ); PREPEND_CHAR( &stackS, "This is a heap-" ); printf( "\nPrepend literal:\n%s\n", TO_STRING(stackS) ); CONCAT_CHAR( heapS, "\nConcat literal" ); printf("\nConcatenated to heap:\n%s\n", P_TO_STRING(heapS)); CONCAT_CHAR( &stackS, "\n" ); PREPEND_STRING( heapS, &stackS ); puts("Prepend string to string:"); puts(P_TO_STRING(heapS)); CONCAT_STRING( heapS, &stackS ); puts("Concatenate strings:"); printf("%s\n", P_TO_STRING(heapS)); destroy_string(&stackS); delete_string(&heapS); return 0; }
static el_status_t bk_kill_word(void) { bk_word(); if (old_point != rl_point) return delete_string(old_point - rl_point); return CSstay; }
int rmv (char *name) { char key[1024]; // This is kind of dangerous. Should make a separate copy // of the name. Actually, shouldn't pass back pointers. strcpy(key, name); return delete_string(key); }
int rmv_percent (char *name, void *p) { int x = *(int *)p; if (random_percent(x)) { return delete_string(name); } return 0; }
void delete_state(State * state) { if (state) { if (state->instruments) free(state->instruments); if (state->message) delete_string(state->message); pthread_mutex_destroy(&state->mState); if (state->clockid >= 0) close(state->clockid); free(state); } }
int main(void) { char c; char str[20]; enter_string(str); printf("The delete chr is: "); scanf("%c", &c); delete_string(str, c); print_string(str); return 0; }
void main(){ extern enter_string(char str[80]); extern delete_string(char str[],char ch); extern print_string(char str[]); char c; char str[80]; printf("do %d\n",enter_string(str)); scanf("%c",&c); delete_string(str,c); print_string(str); }
int main() {extern void enter_string(char str[]); extern void delete_string(char str[],char ch); extern void print_string(char str[]); // 以上3行声明在本函数中将要调用的已在其他文件中定义的3个函数 char c,str[80]; enter_string(str); // 调用在其他文件中定义的enter_string函数 scanf("%c",&c); delete_string(str,c); // 调用在其他文件中定义的delete_string函数 print_string(str); // 调用在其他文件中定义的print_string函数 return 0; }
static el_status_t fd_kill_word(void) { int i; do_forward(CSstay); if (old_point != rl_point) { i = rl_point - old_point; rl_point = old_point; return delete_string(i); } return CSstay; }
static el_status_t bk_del_char(void) { int i; i = 0; do { if (rl_point == 0) break; left(CSmove); } while (++i < Repeat); return delete_string(i); }
int dp (int argc, char *argv[]) { int i; int rc; for (i = 1; i < argc; ++i) { rc = delete_string(argv[i]); if (rc != 0) { return rc; } } return 0; }
static void destruct_xloper (XLOPER*x) { if (NULL != x) { switch (x->xltype & xltypeType) { case xltypeNum: break; case xltypeStr: delete_string (&x->val.str); break; case xltypeBool: break; case xltypeRef: if (NULL != x->val.mref.lpmref && x->val.mref.lpmref->count != 1) { unsupported_xloper_type (x); } else { if (NULL != x->val.mref.lpmref) FREE_ARRAY (x->val.mref.lpmref, 1); x->val.mref.lpmref = NULL; } break; case xltypeErr: break; case xltypeFlow: unsupported_xloper_type (x); break; case xltypeMulti: { int n = x->val.array.rows*x->val.array.columns; int i; for (i = 0; i < n; ++i) { destruct_xloper (x->val.array.lparray+i); } FREE_ARRAY (x->val.array.lparray,n); break; } case xltypeMissing: break; case xltypeNil: break; case xltypeSRef: unsupported_xloper_type (x); break; case xltypeInt: break; default: unsupported_xloper_type (x); } x->xltype = xltypeNil; } }
static el_status_t kill_line(void) { int i; if (Repeat != NO_ARG) { if (Repeat < rl_point) { i = rl_point; rl_point = Repeat; reposition(); delete_string(i - rl_point); } else if (Repeat > rl_point) { right(CSmove); delete_string(Repeat - rl_point - 1); } return CSmove; } save_yank(rl_point, rl_end - rl_point); rl_line_buffer[rl_point] = '\0'; ceol(); rl_end = rl_point; return CSstay; }
int main() { extern void enter_string(char str[]); extern void delete_string(char str[],char ch); extern void printf_string(char str[]); char c,str[80]; enter_string(str); scanf("%c",&c); delete_string(str,c); printf_string(str); return 0; }
void remove_search_marks(char* text) // fnd [] marks and remove them { int i; if(search_marks==true) // if search marks exist then remove them and tell search marks don't exist anymore { search_marks=false; for(i=0; i<strlen(text); i++) { if(text[i]=='[' || text[i]==']') { delete_string(i,1,text); } } } }
VIOAPI Status mni_input_string( FILE *file, STRING *string, char termination_char1, char termination_char2 ) { Status status; char ch; BOOLEAN quoted; *string = create_string( NULL ); status = mni_get_nonwhite_character( file, &ch ); if( status == OK && ch == '"' ) { quoted = TRUE; status = mni_get_nonwhite_character( file, &ch ); termination_char1 = '"'; termination_char2 = '"'; } else quoted = FALSE; while( status == OK && ch != termination_char1 && ch != termination_char2 && ch != '\n' ) { if (ch != '\r') { /* Always ignore carriage returns */ concat_char_to_string( string, ch ); } status = input_character( file, &ch ); } if( !quoted ) (void) unget_character( file, ch ); while( string_length(*string) > 0 && (*string)[string_length(*string)-1] == ' ' ) (*string)[string_length(*string)-1] = END_OF_STRING; if( status != OK ) { delete_string( *string ); *string = NULL; } return( status ); }
int replace_string(char* data) { int pos, i=0, j=0, start[100], end[100],n_o_occur=0, maxchars=size; char string[500], *replace_with, ch='a'; replace_with=malloc(500*sizeof(char)); move(32, 0);deleteln(); printw("Enter String to replace: "); // take the string to replace while(ch!='\n') { ch=getch(); addch(ch); if(ch!='\n'){string[i]=ch;i++;} if(ch==27 )//escape key) { move(33,0); deleteln(); return 0; } } string[i]='\0'; ch='a'; move(33, 0); i=0;printw("Enter replacement string: "); // take the string to replace with while(ch!='\n') { ch=getch(); addch(ch); if(ch!='\n') {replace_with[i]=ch;i++;} if(ch==27 )//escape key) { move(33,0); deleteln(); return 0; } } deleteln(); replace_with[i]='\0'; while((pos=search_string(string, data))!=-1) // now search the string to be replaced and get its position { delete_string(pos, strlen(string), data); // delete the searched string dfrom its position insert_string(pos, replace_with, data); // insert the replacement string at that position } free(replace_with); return 0; }
VIOAPI void output_alloc_to_file( VIO_STR filename ) { FILE *file; VIO_STR date_str; if( alloc_checking_enabled() ) { check_initialized_alloc_list( &alloc_list ); if( memory_still_alloced( &alloc_list ) ) { print_error( "\n" ); print_error( "\n" ); print_error( "A memory leak was found in this program.\n" ); if( filename != NULL ) print_error( "A description has been recorded in the file %s.\n", filename ); print_error( "Please report this file to the author of the program.\n" ); print_error( "\n" ); if( filename != NULL && filename[0] != (char) 0 ) file = fopen( filename, "w" ); else file = stdout; if( file != NULL ) { date_str = get_date(); (void) fprintf( file, "Alloc table at %s\n", date_str ); delete_string( date_str ); output_alloc_list( file, &alloc_list ); if( file != stdout ) (void) fclose( file ); } } } }
VIOAPI Status mni_input_int( FILE *file, int *i ) { Status status; STRING str; status = mni_input_string( file, &str, (char) ' ', (char) ';' ); if( status == OK && sscanf( str, "%d", i ) != 1 ) { unget_string( file, str ); status = ERROR; } delete_string( str ); return( status ); }
VIOAPI Status mni_input_real( FILE *file, Real *d ) { Status status; STRING str; status = mni_input_string( file, &str, (char) ' ', (char) ';' ); if( status == OK && sscanf( str, "%lf", d ) != 1 ) { unget_string( file, str ); status = ERROR; } delete_string( str ); return( status ); }
char * CBasicServer::receive_string(int fd) { uint8_t length; if (receive_data(fd, &length, sizeof(length))) { char * data = (char *)malloc(((size_t)length) + 1); if (receive_data(fd, data, length)) { data[length] = 0; /* add terminating 0 */ return data; } else { delete_string(data); return NULL; } } return NULL; }
void pe_as_lit_id_map_close(struct pe_as_lit_id_map *m, void (*delete_string)(char *)) { size_t i; for (i = 0; i < m->table_size; i++) { struct pe_as_lit_id_map_node *n = m->id_table[i]; while (n != 0) { struct pe_as_lit_id_map_node *p = n; n = n->next; if (delete_string) delete_string(p->full_id); free(p); } } free(m->id_table); }
int delete_range(int f, int l) { int i; is_saved = 0; if (N == 0) { return 0; } if (f > N) { return -3; } if ((l == -1) || (l > N)) { l = N; } for (i = f; i <= l; i++) { delete_string(f); } return 0; }
static void img_clicked_del_cb(void *data, Evas_Object *obj, void *event_info) { Evas_Object *entry = data; if(confirm_flag == READY_TO_CONFIRM) { /*if(inout_flag == INCOME) elm_entry_text_style_user_push(entry, "DEFAULT='font_size=40 color=#4cffba align=center'"); else if(inout_flag == OUTGO) elm_entry_text_style_user_push(entry, "DEFAULT='font_size=40 color=#ffffff align=center'");*/ elm_entry_text_style_user_push(entry, "DEFAULT='font_size=40 color=#ffffff align=center'"); confirm_flag = DEFAULT; return; } delete_string(entry); }
VIOAPI void free_tag_points( int n_volumes, int n_tag_points, VIO_Real **tags_volume1, VIO_Real **tags_volume2, VIO_Real weights[], int structure_ids[], int patient_ids[], char **labels ) { int i; if( n_tag_points > 0 ) { free_tags( tags_volume1, n_tag_points ); if( n_volumes == 2 ) free_tags( tags_volume2, n_tag_points ); if( weights != (VIO_Real *) NULL ) FREE( weights ); if( structure_ids != (int *) NULL ) FREE( structure_ids ); if( patient_ids != (int *) NULL ) FREE( patient_ids ); if( labels != (char **) NULL ) { for( i = 0; i < n_tag_points; ++i ) delete_string( labels[i] ); if( n_tag_points > 0 ) FREE( labels ); } } }
int main(int argc, char *argv[]) { if (argc != 4) { printf ("USAGE: %s command index file\n", argv[0]); exit (1); } char *cmd = argv[1]; enum mode_t mode = MODE_NONE; if (strcmp (cmd, "rename-toks") == 0) { mode = MODE_RENAME; } else if (strcmp (cmd, "print") == 0) { mode = MODE_PRINT; } else if (strcmp (cmd, "delete-string") == 0) { mode = MODE_DELETE_STRING; } else if (strcmp (cmd, "shorten-string") == 0) { mode = MODE_SHORTEN_STRING; } else if (strcmp (cmd, "x-string") == 0) { mode = MODE_X_STRING; } else if (strcmp (cmd, "shorten-int") == 0) { mode = MODE_SHORTEN_INT; } else if (strcmp (cmd, "remove-asm-comment") == 0) { mode = MODE_REMOVE_ASM_COMMENT; } else if (strcmp (cmd, "remove-asm-line") == 0) { mode = MODE_REMOVE_ASM_LINE; } else if (strcmp (cmd, "collapse-toks") == 0) { mode = MODE_COLLAPSE_TOKS; } else if (strncmp (cmd, "reverse-", 8) == 0) { mode = MODE_REVERSE_TOKS; int res = sscanf (&cmd[8], "%d", &n_toks); assert (res==1); assert (n_toks > 0 && n_toks <= 1000); } else if (strncmp (cmd, "rm-toks-", 8) == 0) { mode = MODE_RM_TOKS; int res = sscanf (&cmd[8], "%d", &n_toks); assert (res==1); assert (n_toks > 0 && n_toks <= 1000); } else if (strncmp (cmd, "rm-tok-pattern-", 15) == 0) { mode = MODE_RM_TOK_PATTERN; int res = sscanf (&cmd[15], "%d", &n_toks); assert (res==1); assert (n_toks > 1 && n_toks <= 8); } else { printf ("error: unknown mode '%s'\n", cmd); exit (50); } int tok_index; int ret = sscanf (argv[2], "%d", &tok_index); assert (ret==1); // printf ("file = '%s'\n", argv[3]); FILE *in = fopen (argv[3], "r"); assert (in); yyin = in; max_toks = initial_length; tok_list = (struct tok_t *) malloc (max_toks * sizeof (struct tok_t)); assert (tok_list); yylex(); // these calls all exit() at the end switch (mode) { case MODE_PRINT: print_toks (); assert (0); case MODE_RENAME: rename_toks (tok_index); assert (0); case MODE_DELETE_STRING: delete_string (tok_index); assert (0); case MODE_SHORTEN_STRING: shorten_string (tok_index); assert (0); case MODE_X_STRING: x_string (tok_index); assert (0); case MODE_SHORTEN_INT: shorten_int (tok_index); assert (0); case MODE_REMOVE_ASM_COMMENT: remove_asm_comment (tok_index); assert (0); case MODE_REMOVE_ASM_LINE: remove_asm_line (tok_index); assert (0); case MODE_COLLAPSE_TOKS: collapse_toks (tok_index); assert (0); case MODE_RM_TOKS: rm_toks (tok_index); assert (0); case MODE_REVERSE_TOKS: reverse_toks (tok_index); assert (0); case MODE_RM_TOK_PATTERN: rm_tok_pattern (tok_index); assert (0); default: assert (0); } }