1 /*
2 
3    xlog - GTK+ logging program for amateur radio operators
4    Copyright (C) 2012 - 2017 Andy Stewart KB1OIQ <kb1oiq@arrl.net>
5    Copyright (C) 2001 - 2010 Joop Stakenborg <pg4i@amsat.org>
6 
7    This file is part of xlog.
8 
9    Xlog is free software: you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation, either version 3 of the License, or
12    (at your option) any later version.
13 
14    Xlog is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with xlog.  If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 /*
25  * logfile.h
26  */
27 
28 #ifndef _LOGFILE_H
29 #define _LOGFILE_H 1
30 
31 #include <glib.h>
32 
33 #define FLOG_MAX_LINE_SIZE 300
34 #define MAX_VARIABLE_LEN 512
35 #define MAX_COLUMN 32
36 #define QSO_FIELDS 19
37 
38 /* fields for the qso array */
39 #define NR 0
40 #define DATE 1
41 #define GMT 2
42 #define GMTEND 3
43 #define CALL 4
44 #define BAND 5
45 #define MODE 6
46 #define RST 7
47 #define MYRST 8
48 #define AWARDS 9
49 #define QSLOUT 10
50 #define QSLIN 11
51 #define POWER 12
52 #define NAME 13
53 #define QTH 14
54 #define LOCATOR 15
55 #define U1 16
56 #define U2 17
57 #define REMARKS 18
58 
59 extern const gint qso_fields[];
60 extern const gint qso_widths[];
61 extern const gint qso_field_nr;
62 typedef gchar *qso_t;
63 
64 /* Forward struct references */
65 
66 struct log_file;
67 typedef struct log_file LOGDB;
68 
69 /* Keep enums in same order as menu in callbacks_menu.c */
70 enum log_file_type
71 {
72 	TYPE_FLOG,	/* flexible xlog format */
73 	TYPE_TWLOG,
74 	TYPE_ADIF3,     /* ADIF version 3 */
75 	TYPE_CABRILLO3, /* Cabrillo v3 */
76 	TYPE_EDITEST,	/* French contest logger */
77 	TYPE_TRLOG,
78 	TYPE_EDI,	/* Electronic Data Interchange, IARU Region 1 */
79 	TYPE_OH1AA,     /* OH1AA logbook */
80 	TYPE_LABELS,    /* Tab separated export of some fields for glabels */
81 };
82 
83 /*
84  * Here we go again, OOP in C. hi.
85  */
86 struct log_ops
87 {
88 	gint (*open) (LOGDB *);
89 	void (*close) (LOGDB *);
90 	gint (*create) (LOGDB *);
91 	gint (*add_column) (LOGDB *, gint pos, gint field, gint width);
92 	gint (*delete_column) (LOGDB *, gint pos);
93 	gint (*qso_append) (LOGDB *, const qso_t *);
94 	gint (*qso_foreach) (LOGDB *, gint (*fn) (LOGDB *, qso_t *, gpointer arg), gpointer arg);
95 	enum log_file_type type;
96 	const char *name;
97 	const char *extension;
98 };
99 
100 struct log_file
101 {
102 	enum log_file_type type;
103 	const struct log_ops *ops;
104 	gchar *path;
105 	gpointer priv;		/* for use by the log backend */
106 	gint column_nr;
107 	gint column_fields[MAX_COLUMN];
108 	gint column_widths[MAX_COLUMN];
109 };
110 
111 LOGDB *log_file_open (const gchar * path, enum log_file_type type);
112 LOGDB *log_file_create (const gchar * path, enum log_file_type type,
113 		gint columns, const gint column_field[], const gint column_width[]);
114 void log_file_close (LOGDB *);
115 gint log_file_add_column (LOGDB *, gint pos, gint field, gint width);
116 gint log_file_delete_column (LOGDB *, gint pos);
117 gint log_file_qso_append (LOGDB *, const qso_t *);
118 gint log_file_qso_foreach (LOGDB *,
119 		gint (*fn) (LOGDB *, qso_t *, gpointer arg), gpointer arg);
120 /*
121 	qso_t* get_qso_from_nr(nr)
122 	update_qso(nr, qso_t)
123 	delete_qso(nr)
124  */
125 
126 gint parse_field_name (const gchar * s);
127 gint parse_column_name (const gchar * s);
128 gint parse_field_width (const gint field);
129 const gchar *strfield (gint field);
130 const gchar *strcolumn (gint field);
131 gint scan_month (const gchar * s);
132 
133 #endif /* _LOGFILE_H */
134