danilom

csv_converter .h

Sep 8th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.93 KB | None | 0 0
  1. #ifndef __CSV_CONVERTER_H_
  2. #define __CSV_CONVERTER_H_
  3.  
  4.  
  5. #define CSVC_NUMBER_OF_FIELDS 300
  6. #define CSVC_NUMBER_OF_CHARACTERS_IN_FIELD 2000
  7.  
  8.  
  9. /*
  10.  * Structure of a record
  11.  *
  12.  * fp -> file pointer to where the catch records
  13.  * index -> current record number
  14.  * length -> number of fields
  15.  * eof -> TRUE if fp came to end
  16.  * fields -> array with values of the fields
  17.  */
  18. typedef struct {
  19.         FILE* fp;
  20.         int index;
  21.         int length;
  22.         int last_char;
  23.         char fields[CSVC_NUMBER_OF_FIELDS][CSVC_NUMBER_OF_CHARACTERS_IN_FIELD];
  24. } CSVC_RECORD;
  25.  
  26. /*
  27.  * External declaration of the variable global_record defined in c_carmentito.c
  28.  */
  29. extern CSVC_RECORD csvc_record;
  30.  
  31. /*
  32.  * Set the file pointer in global_record
  33.  *
  34.  * fp -> file pointer that will be set in global_record
  35.  *
  36.  * Returns: fp
  37.  */
  38. FILE* csvc_open_file(char* file_name);
  39.  
  40. /*
  41.  * Set NULL to the fp in global_record
  42.  *
  43.  *
  44.  *
  45.  * Returns:
  46.  * what fclose() returns
  47.  */
  48. int csvc_close_file(void);
  49.  
  50. /*
  51.  * Points to next record (after RECORD_SEPARATOR) in fp
  52.  *
  53.  * Returns:
  54.  * if csvc_record.last_char is EOF, returns EOF otherwise it returns RECORD_SEPARATOR
  55.  */
  56. int csvc_next_record(void);
  57.  
  58. /*
  59.  * Read all the record fields and stores in global_record
  60.  *
  61.  * Returns:
  62.  * if csvc_record.last_char is EOF, returns EOF otherwise it returns RECORD_SEPARATOR
  63.  */
  64. int csvc_load_record(void);
  65.  
  66. /*
  67.  * Get value of the field that is in the position field_number at the RECORD struct
  68.  *
  69.  * field_number -> position of the field
  70.  *
  71.  * Returns:
  72.  * value of the field
  73.  */
  74. char* csvc_field_value(unsigned int field_number);
  75.  
  76. /*
  77.  * Get the first non-empty field in the current record starting in field_number at the RECORD struct
  78.  *
  79.  * field_number -> variable that contains the field position
  80.  *
  81.  * Returns:
  82.  * position of the first field non-empty at this record
  83.  */
  84. int csvc_next_field_nonempty(unsigned int field_number);
  85.  
  86. #endif
Advertisement
Add Comment
Please, Sign In to add comment