/[xlog]/xlog/src/logfile/trlog.c
ViewVC logotype

Diff of /xlog/src/logfile/trlog.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by pa4tu, Sat Aug 21 14:25:09 2004 UTC revision 1.9 by pa4tu, Mon Sep 20 19:42:53 2004 UTC
# Line 37  Line 37 
37  /*  /*
38   * file fields   * file fields
39   */   */
40  const gint trlog_fields[] = { BAND, MODE, DATE, GMT, RST /* exch */, CALL, RST, MYRST, MYRST /* exch */ };  const gint trlog_fields[] = { BAND, MODE, DATE, GMT, RST /* exch */,
41  const gint trlog_widths[] = { 3, 3, 9, 5, 5, 14, 4, 4, 4 };          CALL, RST, MYRST, MYRST /* exch */, REMARKS };
42  const gint trlog_field_nr = 9;  const gint trlog_widths[] = { 3, 3, 9, 5, 5, 14, 4, 4, 4, 80 };
43    const gint trlog_field_nr = 10;
44    
45  static gint trlog_open (LOGDB *);  static gint trlog_open (LOGDB *);
46  static void trlog_close (LOGDB *);  static void trlog_close (LOGDB *);
# Line 65  gint Line 66  gint
66  trlog_open (LOGDB * handle)  trlog_open (LOGDB * handle)
67  {  {
68          FILE *fp;          FILE *fp;
69          const gint xlog_fields [] = {DATE, GMT, CALL, BAND, MODE, RST, MYRST};          const gint xlog_fields [] = {DATE, GMT, CALL, BAND, MODE, RST, MYRST, REMARKS};
70    
71          fp = fopen (handle->path, "r");          fp = fopen (handle->path, "r");
72          if (!fp) return -1;          if (!fp) return -1;
73          handle->priv = (gpointer) fp;          handle->priv = (gpointer) fp;
74    
75          /* set columns to be used in xlog */          /* set columns to be used in xlog */
76          handle->column_nr = 7;          handle->column_nr = 8;
77          memcpy (handle->column_fields, xlog_fields, sizeof (xlog_fields));          memcpy (handle->column_fields, xlog_fields, sizeof (xlog_fields));
78          /* TODO: set and use handle->column_widths */          /* TODO: set and use handle->column_widths */
79          return 0;          return 0;
# Line 137  gint trlog_qso_foreach Line 138  gint trlog_qso_foreach
138          FILE *fp = (FILE *) handle->priv;          FILE *fp = (FILE *) handle->priv;
139          gint i, ret;          gint i, ret;
140          qso_t q[QSO_FIELDS];          qso_t q[QSO_FIELDS];
141          gchar *field, *end, buffer[MAXROWLEN+1], *d, *res = NULL, buf[20];          gchar *field, *end, buffer[MAXROWLEN+1], *d, *res = NULL, buf[20], *remark,
142                    **split, rembuffer[MAXROWLEN+1];
143          const gint *widths = trlog_widths;          const gint *widths = trlog_widths;
144          struct tm tm_trlog;          struct tm tm_trlog;
145    
146          /* get current language settings and set environment for trlog import */          /* set environment for trlog import */
147          setlocale (LC_TIME, "C");          setlocale (LC_TIME, "C");
148    
149          while (!feof (fp))          while (!feof (fp))
150          {          {
151                  if (!fgets (buffer, MAXROWLEN - 1, fp)) break;                  remark = g_strdup ("");
152                    if (!fgets (buffer, MAXROWLEN - 1, fp)) break;
153                    /* check of there is a comment on the next line and read it */
154                    if (fgets (rembuffer, MAXROWLEN - 1, fp))
155                    {
156                            if (rembuffer[0] == ';')
157                            {
158                                    if  (g_strrstr (rembuffer, ":"))
159                                    {
160                                            split = g_strsplit (rembuffer, ":", 2);
161                                            remark = g_strdup (g_strstrip(split[1]));
162                                            g_strfreev (split);
163                                    }
164                                    else
165                                    {
166                                            split = g_strsplit (rembuffer, ";", 2);
167                                            remark = g_strdup (g_strstrip(split[1]));
168                                            g_strfreev (split);
169                                    }
170                            }
171                            /* go back */
172                            fseek (fp, -81, SEEK_CUR);
173                    }
174    
175                  memset (q, 0, sizeof (q));                  memset (q, 0, sizeof (q));
176                    q[trlog_fields[9]] = g_strdup (remark);
177                    g_free (remark);
178                  field = buffer;                  field = buffer;
179    
180                  /* comment line */                  /* comment line */
# Line 159  gint trlog_qso_foreach Line 185  gint trlog_qso_foreach
185                  memmove (buffer+4, buffer+3, MAXROWLEN);                  memmove (buffer+4, buffer+3, MAXROWLEN);
186                  buffer[3] = ' ';                  buffer[3] = ' ';
187    
188                  for (i = 0; i < trlog_field_nr; i++)                  for (i = 0; i < trlog_field_nr - 1; i++)
189                  {                  {
190    
191  // 80CW 21-Feb-04 23:41 0053    VY2LZ                                   599     599     PEI                                      PEI                    3        // 40CW  21-Aug-04 11:04 0001  OH1XX          599  599                OH       3  
192                          end = field + widths[i];                          end = field + widths[i];
193                          *end = '\0';                          *end = '\0';
194    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26