Show
Ignore:
Timestamp:
10/03/07 16:43:01 (5 years ago)
Author:
andi
Message:

design updates

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/openmct/packages/system/owi/src/file.c

    r421 r468  
    261261         /* Reallocate new index array */ 
    262262         file_line = (char**)realloc(file_line, 
    263                                                     sizeof(char *) * 
    264                                                     (file_line_counter + 1)); 
     263                                     sizeof(char *) * 
     264                                     (file_line_counter + 1)); 
    265265         /* Move pointers */ 
    266266         for (i = file_line_counter - 1; i > line_index; i--) { 
     
    289289   return (strstr(string, match) - string) + strlen(match); 
    290290} 
     291 
     292/* \fn proc_read_line(command, index) 
     293 * \param[in] proc command to execute 
     294 * \param[in] index return this line 
     295 * \return string 
     296 */ 
     297char *proc_read_line(char *command, int index) { 
     298   int lines = proc_open(command); 
     299   char *line = NULL; 
     300 
     301   if (lines >= 0) { 
     302      if (index <= lines) { 
     303         line = (char*)malloc(strlen(file_line_get(index)) + 1); 
     304         if (line) { 
     305            strcpy(line, file_line_get(index)); 
     306         } 
     307      } 
     308      file_free(); 
     309   } 
     310 
     311   return line; 
     312} 
     313 
     314/* \fn file_read_line(command, index) 
     315 * \param[in] file to be read 
     316 * \param[in] index return this line 
     317 * \return string 
     318 */ 
     319char *file_read_line(char *file, int index) { 
     320   int lines = file_open(file); 
     321   char *line = NULL; 
     322 
     323   if (lines >= 0) { 
     324      if (index <= lines) { 
     325         line = (char*)malloc(strlen(file_line_get(index)) + 1); 
     326         if (line) { 
     327            strcpy(line, file_line_get(index)); 
     328         } 
     329      } 
     330      file_free(); 
     331   } 
     332 
     333   return line; 
     334}