File: csv_util.h

package info (click to toggle)
gpsbabel 1.3.2-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 15,956 kB
  • ctags: 9,083
  • sloc: ansic: 87,514; xml: 13,640; pascal: 6,981; sh: 3,770; makefile: 811; perl: 754; tcl: 74; objc: 7
file content (141 lines) | stat: -rw-r--r-- 4,129 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
    Copyright (C) 2002 Alex Mottram (geo_alexm at cox-internet.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA

 */

/* function prototypes */

char *
#ifndef DEBUG_MEM
csv_stringtrim(const char *string, const char *enclosure, int strip_max);
#else
CSV_STRINGTRIM(const char *string, const char *enclosure, int strip_max, DEBUG_PARAMS);
#define csv_stringtrim( s, e,m ) CSV_STRINGTRIM( s, e, m, __FILE__, __LINE__)
#endif

char *
csv_lineparse(const char *stringstart, const char *delimited_by, const char *enclosed_in, const int line_no);

void
human_to_dec( const char *instr, double *outlat, double *outlon, int which );

char *
#ifndef DEBUG_MEM
csv_stringclean(const char *string, const char *chararray);
#else
CSV_STRINGCLEAN(const char *string, const char *chararray,DEBUG_PARAMS);
#define csv_stringclean(s,c) CSV_STRINGCLEAN(s,c,__FILE__,__LINE__)
#endif

void 
xcsv_data_read(void);

void 
xcsv_data_write(void);

void 
xcsv_file_init(void); 

void 
xcsv_prologue_add(char *);

void 
xcsv_epilogue_add(char *);

void 
xcsv_ifield_add(char *, char *, char *);

void 
xcsv_ofield_add(char *, char *, char *, int options);

void 
xcsv_destroy_style(void);

const char *
xcsv_get_char_from_constant_table(char *key);

/****************************************************************************/
/* types required for various xcsv functions                                */
/****************************************************************************/

/* something to map fields to waypts */
#define OPTIONS_NODELIM 1
#define OPTIONS_ABSOLUTE 2
#define OPTIONS_OPTIONAL 3
typedef struct field_map {
	queue Q;
	char * key;
	char * val;
	char * printfc;
	int options;
} field_map_t;

/* a queuing struct for prologues / epilogues */
typedef struct ogue {
	queue Q;
	char * val;
} ogue_t;

/* something to map config file constants to chars */
typedef struct char_map {
	const char * key;
	const char * chars;
} char_map_t;

/* 
 * a type describing all the wonderful elements of xcsv files, in a 
 * nutshell.
 */
typedef struct {
    int is_internal;		/* bool - is internal (1) or parsed (0) */

    int prologue_lines;		/* # of lines to ignore at top of the file */
    int epilogue_lines;		/* # of lines to ignore at bottom of file */

    /* header lines for writing at the top of the file. */
    queue prologue;

    /* footer lines for writing at the bottom of the file. */
    queue epilogue;

    char * field_delimiter; 	/* comma, quote, etc... */
    char * record_delimiter;	/* newline, c/r, etc... */

    char * badchars;		/* characters we never write to output */
    
    queue ifield;		/* input field mapping */
    queue * ofield;    		/* output field mapping */
    
    int ifield_ct;		/* actual # of ifields */
    int ofield_ct;		/* actual # of ofields */
    
    gbfile * xcsvfp;		/* ptr to current *open* data file */
    char * fname;                /* ptr to filename of above. */

    char * description;		/* Description for help text */
    char * extension;		/* preferred filename extension (for wrappers)*/
    
    short_handle mkshort_handle;/* handle for mkshort() */
    ff_type type;		/* format type for GUI wrappers. */
    
} xcsv_file_t;


/****************************************************************************/
/* obligatory global struct                                                 */
/****************************************************************************/
extern xcsv_file_t xcsv_file;