mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Make a few functions of static linkage
Make functions in core/file.c, core/parse.c and core/import-csv.c that were not used outside their translation unit of static linkage. parse_date is moved from core/file.c to core/import-csv.c, since it is used only there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
fa5865a566
commit
afeb2e3652
6 changed files with 43 additions and 49 deletions
|
@ -735,7 +735,6 @@ extern int parse_dlf_buffer(unsigned char *buffer, size_t size);
|
|||
extern int parse_file(const char *filename);
|
||||
extern int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate);
|
||||
extern int parse_seabear_log(const char *filename);
|
||||
extern int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate);
|
||||
extern int parse_txt_file(const char *filename, const char *csv);
|
||||
extern int parse_manual_file(const char *filename, char **params, int pnr);
|
||||
extern int save_dives(const char *filename);
|
||||
|
|
35
core/file.c
35
core/file.c
|
@ -115,7 +115,7 @@ int try_to_open_zip(const char *filename)
|
|||
return success;
|
||||
}
|
||||
|
||||
int db_test_func(void *param, int columns, char **data, char **column)
|
||||
static int db_test_func(void *param, int columns, char **data, char **column)
|
||||
{
|
||||
(void) param;
|
||||
(void) columns;
|
||||
|
@ -186,38 +186,6 @@ static int try_to_open_db(const char *filename, struct memblock *mem)
|
|||
return retval;
|
||||
}
|
||||
|
||||
timestamp_t parse_date(const char *date)
|
||||
{
|
||||
int hour, min, sec;
|
||||
struct tm tm;
|
||||
char *p;
|
||||
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
tm.tm_mday = strtol(date, &p, 10);
|
||||
if (tm.tm_mday < 1 || tm.tm_mday > 31)
|
||||
return 0;
|
||||
for (tm.tm_mon = 0; tm.tm_mon < 12; tm.tm_mon++) {
|
||||
if (!memcmp(p, monthname(tm.tm_mon), 3))
|
||||
break;
|
||||
}
|
||||
if (tm.tm_mon > 11)
|
||||
return 0;
|
||||
date = p + 3;
|
||||
tm.tm_year = strtol(date, &p, 10);
|
||||
if (date == p)
|
||||
return 0;
|
||||
if (tm.tm_year < 70)
|
||||
tm.tm_year += 2000;
|
||||
if (tm.tm_year < 100)
|
||||
tm.tm_year += 1900;
|
||||
if (sscanf(p, "%d:%d:%d", &hour, &min, &sec) != 3)
|
||||
return 0;
|
||||
tm.tm_hour = hour;
|
||||
tm.tm_min = min;
|
||||
tm.tm_sec = sec;
|
||||
return utc_mktime(&tm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cochran comma-separated values: depth in feet, temperature in F, pressure in psi.
|
||||
*
|
||||
|
@ -389,4 +357,3 @@ int parse_file(const char *filename)
|
|||
free(mem.buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ extern void ostctools_import(const char *file, struct dive_table *table);
|
|||
extern "C" {
|
||||
#endif
|
||||
extern int readfile(const char *filename, struct memblock *mem);
|
||||
extern timestamp_t parse_date(const char *date);
|
||||
extern int try_to_open_zip(const char *filename);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -14,6 +14,38 @@
|
|||
#define MATCH(buffer, pattern) \
|
||||
memcmp(buffer, pattern, strlen(pattern))
|
||||
|
||||
static timestamp_t parse_date(const char *date)
|
||||
{
|
||||
int hour, min, sec;
|
||||
struct tm tm;
|
||||
char *p;
|
||||
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
tm.tm_mday = strtol(date, &p, 10);
|
||||
if (tm.tm_mday < 1 || tm.tm_mday > 31)
|
||||
return 0;
|
||||
for (tm.tm_mon = 0; tm.tm_mon < 12; tm.tm_mon++) {
|
||||
if (!memcmp(p, monthname(tm.tm_mon), 3))
|
||||
break;
|
||||
}
|
||||
if (tm.tm_mon > 11)
|
||||
return 0;
|
||||
date = p + 3;
|
||||
tm.tm_year = strtol(date, &p, 10);
|
||||
if (date == p)
|
||||
return 0;
|
||||
if (tm.tm_year < 70)
|
||||
tm.tm_year += 2000;
|
||||
if (tm.tm_year < 100)
|
||||
tm.tm_year += 1900;
|
||||
if (sscanf(p, "%d:%d:%d", &hour, &min, &sec) != 3)
|
||||
return 0;
|
||||
tm.tm_hour = hour;
|
||||
tm.tm_min = min;
|
||||
tm.tm_sec = sec;
|
||||
return utc_mktime(&tm);
|
||||
}
|
||||
|
||||
void add_sample_data(struct sample *sample, enum csv_format type, double val)
|
||||
{
|
||||
switch (type) {
|
||||
|
@ -50,7 +82,7 @@ void add_sample_data(struct sample *sample, enum csv_format type, double val)
|
|||
}
|
||||
}
|
||||
|
||||
char *parse_dan_new_line(char *buf, const char *NL)
|
||||
static char *parse_dan_new_line(char *buf, const char *NL)
|
||||
{
|
||||
char *iter = buf;
|
||||
|
||||
|
@ -67,7 +99,8 @@ char *parse_dan_new_line(char *buf, const char *NL)
|
|||
return iter;
|
||||
}
|
||||
|
||||
int parse_dan_format(const char *filename, char **params, int pnr)
|
||||
static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, const char *tag);
|
||||
static int parse_dan_format(const char *filename, char **params, int pnr)
|
||||
{
|
||||
int ret = 0, i;
|
||||
size_t end_ptr = 0;
|
||||
|
@ -319,7 +352,7 @@ int parse_csv_file(const char *filename, char **params, int pnr, const char *csv
|
|||
}
|
||||
|
||||
|
||||
int try_to_xslt_open_csv(const char *filename, struct memblock *mem, const char *tag)
|
||||
static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, const char *tag)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
|
@ -422,7 +455,7 @@ int try_to_open_csv(struct memblock *mem, enum csv_format type)
|
|||
return 1;
|
||||
}
|
||||
|
||||
char *parse_mkvi_value(const char *haystack, const char *needle)
|
||||
static char *parse_mkvi_value(const char *haystack, const char *needle)
|
||||
{
|
||||
char *lineptr, *valueptr, *endptr, *ret = NULL;
|
||||
|
||||
|
@ -445,7 +478,7 @@ char *parse_mkvi_value(const char *haystack, const char *needle)
|
|||
return ret;
|
||||
}
|
||||
|
||||
char *next_mkvi_key(const char *haystack)
|
||||
static char *next_mkvi_key(const char *haystack)
|
||||
{
|
||||
char *valueptr, *endptr, *ret = NULL;
|
||||
|
||||
|
@ -751,6 +784,7 @@ int parse_txt_file(const char *filename, const char *csv)
|
|||
#define TIMESTR 6
|
||||
|
||||
#define SBPARAMS 40
|
||||
static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate);
|
||||
int parse_seabear_log(const char *filename)
|
||||
{
|
||||
char *params[SBPARAMS];
|
||||
|
@ -766,7 +800,7 @@ int parse_seabear_log(const char *filename)
|
|||
}
|
||||
|
||||
|
||||
int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate)
|
||||
static int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate)
|
||||
{
|
||||
int ret, i;
|
||||
struct memblock mem;
|
||||
|
|
|
@ -18,16 +18,11 @@ enum csv_format {
|
|||
#define MAXCOLDIGITS 10
|
||||
|
||||
void add_sample_data(struct sample *sample, enum csv_format type, double val);
|
||||
int parse_dan_format(const char *filename, char **params, int pnr);
|
||||
int parse_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate);
|
||||
int try_to_xslt_open_csv(const char *filename, struct memblock *mem, const char *tag);
|
||||
int try_to_open_csv(struct memblock *mem, enum csv_format type);
|
||||
char *parse_mkvi_value(const char *haystack, const char *needle);
|
||||
char *next_mkvi_key(const char *haystack);
|
||||
int parse_txt_file(const char *filename, const char *csv);
|
||||
|
||||
int parse_seabear_log(const char *filename);
|
||||
int parse_seabear_csv_file(const char *filename, char **params, int pnr, const char *csvtemplate);
|
||||
int parse_manual_file(const char *filename, char **params, int pnr);
|
||||
|
||||
#endif // IMPORTCSV_H
|
||||
|
|
|
@ -899,7 +899,7 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu
|
|||
nonmatch("sample", name, buf);
|
||||
}
|
||||
|
||||
void try_to_fill_userid(const char *name, char *buf)
|
||||
static void try_to_fill_userid(const char *name, char *buf)
|
||||
{
|
||||
(void) name;
|
||||
if (prefs.save_userid_local)
|
||||
|
@ -1557,7 +1557,7 @@ static void reset_all(void)
|
|||
* but once we decode the HTML encoded characters they turn
|
||||
* into UTF-8 instead. So skip the incorrect encoding
|
||||
* declaration and decode the HTML encoded characters */
|
||||
const char *preprocess_divelog_de(const char *buffer)
|
||||
static const char *preprocess_divelog_de(const char *buffer)
|
||||
{
|
||||
char *ret = strstr(buffer, "<DIVELOGSDATA>");
|
||||
|
||||
|
|
Loading…
Reference in a new issue