38 |
static gint labels_create (LOGDB *); |
static gint labels_create (LOGDB *); |
39 |
static gint labels_qso_append (LOGDB *, const qso_t *); |
static gint labels_qso_append (LOGDB *, const qso_t *); |
40 |
static gint labels_qso_foreach (LOGDB *, |
static gint labels_qso_foreach (LOGDB *, |
41 |
gint (*fn) (LOGDB *, qso_t *, gpointer arg), gpointer arg); |
gint (*fn) (LOGDB *, qso_t *, gpointer arg), gpointer arg); |
42 |
|
|
43 |
|
extern preferencestype preferences; |
44 |
|
|
45 |
const struct log_ops labels_ops = { |
const struct log_ops labels_ops = { |
46 |
.open = labels_open, |
.open = labels_open, |
47 |
.close = labels_close, |
.close = labels_close, |
48 |
.create = labels_create, |
.create = labels_create, |
49 |
.qso_append = labels_qso_append, |
.qso_append = labels_qso_append, |
50 |
.qso_foreach = labels_qso_foreach, |
.qso_foreach = labels_qso_foreach, |
51 |
.type = TYPE_LABELS, |
.type = TYPE_LABELS, |
52 |
.name = "Labels", |
.name = "Labels", |
53 |
.extension = ".labels", |
.extension = ".labels", |
54 |
}; |
}; |
55 |
|
|
56 |
/* |
/* |
59 |
gint |
gint |
60 |
labels_open (LOGDB * handle) |
labels_open (LOGDB * handle) |
61 |
{ |
{ |
62 |
FILE *fp; |
FILE *fp; |
63 |
|
|
64 |
fp = fopen (handle->path, "r"); |
fp = fopen (handle->path, "r"); |
65 |
if (!fp) |
if (!fp) |
66 |
return -1; |
return -1; |
67 |
handle->priv = (gpointer) fp; |
handle->priv = (gpointer) fp; |
68 |
|
|
69 |
return 0; |
return 0; |
70 |
} |
} |
71 |
|
|
72 |
/* |
/* |
75 |
gint |
gint |
76 |
labels_create (LOGDB * handle) |
labels_create (LOGDB * handle) |
77 |
{ |
{ |
78 |
FILE *fp; |
FILE *fp; |
79 |
|
|
80 |
fp = fopen (handle->path, "w"); |
fp = fopen (handle->path, "w"); |
81 |
if (!fp) |
if (!fp) |
82 |
return -1; |
return -1; |
83 |
handle->priv = (gpointer) fp; |
handle->priv = (gpointer) fp; |
84 |
return 0; |
return 0; |
85 |
} |
} |
86 |
|
|
87 |
void |
void |
88 |
labels_close (LOGDB * handle) |
labels_close (LOGDB * handle) |
89 |
{ |
{ |
90 |
FILE *fp = (FILE *) handle->priv; |
FILE *fp = (FILE *) handle->priv; |
91 |
fclose (fp); |
fclose (fp); |
92 |
} |
} |
93 |
|
|
94 |
gint |
gint |
95 |
labels_qso_append (LOGDB * handle, const qso_t * q) |
labels_qso_append (LOGDB * handle, const qso_t * q) |
96 |
{ |
{ |
97 |
FILE *fp = (FILE *) handle->priv; |
FILE *fp = (FILE *) handle->priv; |
98 |
|
|
99 |
fprintf (fp, "%s\t%s\t%s\t%s\t%s\t%s\n", |
if (preferences.saveaslabels == 0) |
100 |
q[DATE], q[GMT], q[CALL], q[BAND], q[MODE], q[RST]); |
fprintf (fp, "%s\t%s\t%s\t%s\t%s\t%s\n", |
101 |
return 0; |
q[DATE], q[GMT], q[CALL], q[BAND], q[MODE], q[RST]); |
102 |
|
else if (preferences.saveaslabels == 1) |
103 |
|
fprintf (fp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", |
104 |
|
q[DATE], q[GMT], q[CALL], q[BAND], q[MODE], q[RST], q[U1]); |
105 |
|
else if (preferences.saveaslabels == 2) |
106 |
|
fprintf (fp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", |
107 |
|
q[DATE], q[GMT], q[CALL], q[BAND], q[MODE], q[RST], q[U2]); |
108 |
|
else |
109 |
|
fprintf (fp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", |
110 |
|
q[DATE], q[GMT], q[CALL], q[BAND], q[MODE], q[RST], q[U1], q[U2]); |
111 |
|
return 0; |
112 |
} |
} |
113 |
|
|
114 |
gint labels_qso_foreach |
gint labels_qso_foreach |
115 |
(LOGDB * handle, gint (*fn) (LOGDB *, qso_t *, gpointer arg), gpointer arg) |
(LOGDB * handle, gint (*fn) (LOGDB *, qso_t *, gpointer arg), gpointer arg) |
116 |
{ |
{ |
117 |
return 1; |
return 1; |
118 |
} |
} |