~ubuntu-branches/ubuntu/lucid/gco/lucid

« back to all changes in this revision

Viewing changes to src/fileops.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2006-08-31 12:35:42 UTC
  • mfrom: (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060831123542-mc4q70vmhci7jkx7
Tags: 0.5.0-6
Update package to the last python policy, courtesy of Pierre Habouzit
(Closes: #380807).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  GNOME Comics Organizer
3
 
  Copyright (C) 1999-2000 Maxximum Software
4
 
   
5
 
  This program is free software; you can redistribute it and/or modify
6
 
  it under the terms of the GNU General Public License as published by
7
 
  the Free Software Foundation; either version 2 of the License, or
8
 
  (at your option) any later version.
9
 
  
10
 
  This program is distributed in the hope that it will be useful,
11
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
  GNU General Public License for more details.
14
 
  
15
 
  You should have received a copy of the GNU General Public License
16
 
  along with this program; if not, write to the Free Software
17
 
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 
*/
19
 
#include <sys/stat.h>
20
 
#include <sys/types.h>
21
 
#include <fcntl.h>
22
 
#include <unistd.h>
23
 
#include <ctype.h>
24
 
#include <stdlib.h>
25
 
#include <glib.h>
26
 
#include "fileops.h"
27
 
#include "fileops-helper.h"
28
 
#include "functions.h"
29
 
#include "comiclist.h"
30
 
#include "debug.h"
31
 
 
32
 
const gchar *CO19Ident     = "CO19_File";
33
 
const gchar *GCO_0_1_Ident = "GCO_0_1__";
34
 
const gchar *GCO_0_3_Ident = "GCO_0_3__";
35
 
 
36
 
GList *LoadCO19(GList *ComicList, FILE *fp)
37
 
{
38
 
  int c;
39
 
  TComic *TempComic;
40
 
  TIssue *TempIssue;
41
 
  GString * TempString;
42
 
 
43
 
  while((c=my_getc())!=EOF)
44
 
    {
45
 
      my_ungetc (c);
46
 
      TempComic = Init_Comic();
47
 
 
48
 
      while((c=my_getc())!='\x00')
49
 
        {
50
 
          TempComic->CTitle = g_string_append_c(TempComic->CTitle, c);
51
 
        }
52
 
      while((c=my_getc())!='\x00')
53
 
        {
54
 
          TempComic->CPublisher = g_string_append_c(TempComic->CPublisher, c);
55
 
        }
56
 
      while((c=my_getc())!='\x00')
57
 
        {
58
 
          TempComic->CType = g_string_append_c(TempComic->CType, c);
59
 
        }
60
 
      while((c=my_getc())!='\x00')
61
 
        {
62
 
          TempComic->CVolume = g_string_append_c(TempComic->CVolume, c);
63
 
        }
64
 
      while((c=my_getc())!='\x00')
65
 
        {
66
 
          TempComic->CGroup = g_string_append_c(TempComic->CGroup, c);
67
 
        }
68
 
      while((c=my_getc())!='\x00')
69
 
        {
70
 
          TempComic->Comment = g_string_append_c(TempComic->Comment, c);
71
 
        }
72
 
      while((c=my_getc())!='\x00')
73
 
        {
74
 
          TempComic->LinkFile = g_string_append_c(TempComic->LinkFile, c);
75
 
        }
76
 
      TempComic->IsLink = (TempComic->LinkFile->len>0);
77
 
 
78
 
      /* Now load the Issues */
79
 
      while((c=my_getc())!='\x00')
80
 
        {
81
 
          my_ungetc (c);
82
 
 
83
 
          TempIssue = Init_Issue();
84
 
 
85
 
          while((c=my_getc())!='\x01')
86
 
            { 
87
 
              TempIssue->IssueNo = g_string_append_c(TempIssue->IssueNo, c);
88
 
            } 
89
 
          while((c=my_getc())!='\x01')
90
 
            { 
91
 
              my_ungetc (c);
92
 
              TempString = g_string_new(NULL);
93
 
 
94
 
              while((c=my_getc())!='\x02')
95
 
                {
96
 
                  TempString = g_string_append_c(TempString, c);
97
 
                }
98
 
              TempIssue->Writer = g_list_append(TempIssue->Writer, TempString);
99
 
            } 
100
 
          while((c=my_getc())!='\x01')
101
 
            { 
102
 
              my_ungetc (c);
103
 
              TempString = g_string_new(NULL);
104
 
 
105
 
              while((c=my_getc())!='\x02')
106
 
                {
107
 
                  TempString = g_string_append_c(TempString, c);
108
 
                }
109
 
              TempIssue->Penciller = g_list_append(TempIssue->Penciller, TempString);
110
 
            } 
111
 
          while((c=my_getc())!='\x01')
112
 
            { 
113
 
              my_ungetc (c);
114
 
              TempString = g_string_new(NULL);
115
 
 
116
 
              while((c=my_getc())!='\x02')
117
 
                {
118
 
                  TempString = g_string_append_c(TempString, c);
119
 
                }
120
 
              TempIssue->Inker = g_list_append(TempIssue->Inker, TempString);
121
 
            } 
122
 
          while((c=my_getc())!='\x01')
123
 
            { 
124
 
              my_ungetc (c);
125
 
              TempString = g_string_new(NULL);
126
 
 
127
 
              while((c=my_getc())!='\x02')
128
 
                {
129
 
                  TempString = g_string_append_c(TempString, c);
130
 
                }
131
 
              TempIssue->Title = g_list_append(TempIssue->Title, TempString);
132
 
            } 
133
 
          while((c=my_getc())!='\x01')
134
 
            { 
135
 
              TempIssue->Location = g_string_append_c(TempIssue->Location, c);
136
 
            } 
137
 
          while((c=my_getc())!='\x01')
138
 
            { 
139
 
              TempIssue->Price = g_string_append_c(TempIssue->Price, c);
140
 
            } 
141
 
          while((c=my_getc())!='\x01')
142
 
            { 
143
 
              TempIssue->CurrentPrice = g_string_append_c(TempIssue->CurrentPrice, c);
144
 
            } 
145
 
          while((c=my_getc())!='\x01')
146
 
            { 
147
 
              TempIssue->Image = g_string_append_c(TempIssue->Image, c);
148
 
            } 
149
 
 
150
 
          TempString = g_string_new(NULL);
151
 
          while((c=my_getc())!='\x01')
152
 
            { 
153
 
              TempString = g_string_append_c(TempString, c);
154
 
            }
155
 
          if (strcmp(TempString->str, "Poor (P)")==0)
156
 
            TempIssue->Condition = 0;
157
 
          if (strcmp(TempString->str, "Fair (FR)")==0)
158
 
            TempIssue->Condition = 1;
159
 
          if (strcmp(TempString->str, "Good (G)")==0) 
160
 
            TempIssue->Condition = 2;
161
 
          if (strcmp(TempString->str, "Very Good (VG)")==0)
162
 
            TempIssue->Condition = 3;
163
 
          if (strcmp(TempString->str, "Fine (F)")==0)
164
 
            TempIssue->Condition = 4;
165
 
          if (strcmp(TempString->str, "Fine-Very Fine (VFV)")==0)
166
 
            TempIssue->Condition = 5;
167
 
          if (strcmp(TempString->str, "Very Fine (VF)")==0)
168
 
            TempIssue->Condition = 6;
169
 
          if (strcmp(TempString->str, "Near Mint (NM)")==0)
170
 
            TempIssue->Condition = 7;
171
 
          if (strcmp(TempString->str, "Mint (M)")==0)
172
 
            TempIssue->Condition = 8;
173
 
 
174
 
 
175
 
          while((c=my_getc())!='\x01')
176
 
            { 
177
 
              TempIssue->Comment = g_string_append_c(TempIssue->Comment, c);
178
 
            } 
179
 
          while((c=my_getc())!='\x01')
180
 
            { 
181
 
              /*
182
 
              TempIssue->Date = g_string_append_c(TempIssue->Date, c);
183
 
              */
184
 
 
185
 
              /* FIXME - doesn't import dates... */
186
 
            } 
187
 
 
188
 
          /* Now the TIssue structure is filled - then insert into list */
189
 
          TempComic->IssueNumbers = g_list_insert_sorted(TempComic->IssueNumbers, TempIssue,
190
 
                                                         CompareTIssue_IssueNo);
191
 
        }
192
 
      
193
 
      /* Now the TComic structure is filled - then insert into list */
194
 
      ComicList = g_list_insert_sorted(ComicList, TempComic, CompareTComic_Title);
195
 
    }
196
 
 
197
 
  return ComicList;
198
 
}
199
 
 
200
 
GList *LoadGCO_0_1(GList *ComicList, FILE *fp)
201
 
{
202
 
  /* Read largest used UID and set it using SetUID() */
203
 
  /* Read ComicList (remember to read the UIDs of the individual Comics and Issues, etc.) */
204
 
  int c;
205
 
  guint32 LargestUID;
206
 
  TComic *TempComic;
207
 
  TIssue *TempIssue;
208
 
  GString * TempString;
209
 
 
210
 
  TempString = g_string_new(NULL);
211
 
  while((c=my_getc())!='\x00')
212
 
    {
213
 
      TempString = g_string_append_c(TempString, c);
214
 
    }
215
 
  LargestUID = atof(TempString->str);
216
 
  g_string_free(TempString, TRUE);
217
 
 
218
 
  while((c=my_getc())!=EOF)
219
 
    {
220
 
      my_ungetc (c);
221
 
      TempComic = Init_Comic();
222
 
 
223
 
      while((c=my_getc())!='\x00')
224
 
        {
225
 
          TempComic->CTitle = g_string_append_c(TempComic->CTitle, c);
226
 
        }
227
 
      while((c=my_getc())!='\x00')
228
 
        {
229
 
          TempComic->CPublisher = g_string_append_c(TempComic->CPublisher, c);
230
 
        }
231
 
      while((c=my_getc())!='\x00')
232
 
        {
233
 
          TempComic->CType = g_string_append_c(TempComic->CType, c);
234
 
        }
235
 
      while((c=my_getc())!='\x00')
236
 
        {
237
 
          TempComic->CVolume = g_string_append_c(TempComic->CVolume, c);
238
 
        }
239
 
      while((c=my_getc())!='\x00')
240
 
        {
241
 
          TempComic->CGroup = g_string_append_c(TempComic->CGroup, c);
242
 
        }
243
 
      while((c=my_getc())!='\x00')
244
 
        {
245
 
          TempComic->Comment = g_string_append_c(TempComic->Comment, c);
246
 
        }
247
 
      while((c=my_getc())!='\x00')
248
 
        {
249
 
          TempComic->LinkFile = g_string_append_c(TempComic->LinkFile, c);
250
 
        }
251
 
      TempComic->IsLink = (TempComic->LinkFile->len>0);
252
 
      TempString = g_string_new(NULL);
253
 
      while((c=my_getc())!='\x00')
254
 
        {
255
 
          TempString = g_string_append_c(TempString, c);
256
 
        }
257
 
      TempComic->UID = atof(TempString->str);
258
 
      g_string_free(TempString, TRUE);
259
 
 
260
 
      /* Now load the Issues */
261
 
      while((c=my_getc())!='\x00')
262
 
        {
263
 
          my_ungetc (c);
264
 
          TempIssue = Init_Issue();
265
 
 
266
 
          while((c=my_getc())!='\x01')
267
 
            { 
268
 
              TempIssue->IssueNo = g_string_append_c(TempIssue->IssueNo, c);
269
 
            } 
270
 
          while((c=my_getc())!='\x01')
271
 
            { 
272
 
              my_ungetc (c);
273
 
              TempString = g_string_new(NULL);
274
 
 
275
 
              while((c=my_getc())!='\x02')
276
 
                {
277
 
                  TempString = g_string_append_c(TempString, c);
278
 
                }
279
 
              TempIssue->Writer = g_list_append(TempIssue->Writer, TempString);
280
 
            } 
281
 
          while((c=my_getc())!='\x01')
282
 
            { 
283
 
              my_ungetc (c);
284
 
              TempString = g_string_new(NULL);
285
 
 
286
 
              while((c=my_getc())!='\x02')
287
 
                {
288
 
                  TempString = g_string_append_c(TempString, c);
289
 
                }
290
 
              TempIssue->Penciller = g_list_append(TempIssue->Penciller, TempString);
291
 
            } 
292
 
          while((c=my_getc())!='\x01')
293
 
            { 
294
 
              my_ungetc (c);
295
 
              TempString = g_string_new(NULL);
296
 
 
297
 
              while((c=my_getc())!='\x02')
298
 
                {
299
 
                  TempString = g_string_append_c(TempString, c);
300
 
                }
301
 
              TempIssue->Inker = g_list_append(TempIssue->Inker, TempString);
302
 
            } 
303
 
          while((c=my_getc())!='\x01')
304
 
            { 
305
 
              my_ungetc (c);
306
 
              TempString = g_string_new(NULL);
307
 
 
308
 
              while((c=my_getc())!='\x02')
309
 
                {
310
 
                  TempString = g_string_append_c(TempString, c);
311
 
                }
312
 
              TempIssue->Title = g_list_append(TempIssue->Title, TempString);
313
 
            } 
314
 
          while((c=my_getc())!='\x01')
315
 
            { 
316
 
              TempIssue->Location = g_string_append_c(TempIssue->Location, c);
317
 
            } 
318
 
          while((c=my_getc())!='\x01')
319
 
            { 
320
 
              TempIssue->Price = g_string_append_c(TempIssue->Price, c);
321
 
            } 
322
 
          while((c=my_getc())!='\x01')
323
 
            { 
324
 
              TempIssue->CurrentPrice = g_string_append_c(TempIssue->CurrentPrice, c);
325
 
            } 
326
 
          while((c=my_getc())!='\x01')
327
 
            { 
328
 
              TempIssue->Image = g_string_append_c(TempIssue->Image, c);
329
 
            } 
330
 
          TempString = g_string_new(NULL);
331
 
          while((c=my_getc())!='\x01')
332
 
            { 
333
 
              TempString = g_string_append_c(TempString, c);
334
 
            }
335
 
          TempIssue->Condition = atof(TempString->str);
336
 
          g_string_free(TempString, TRUE);
337
 
          while((c=my_getc())!='\x01')
338
 
            { 
339
 
              TempIssue->Comment = g_string_append_c(TempIssue->Comment, c);
340
 
            } 
341
 
          TempString = g_string_new(NULL);
342
 
          while((c=my_getc())!='\x01')
343
 
            { 
344
 
              TempString = g_string_append_c(TempString, c);
345
 
            }
346
 
          TempIssue->Date = atof(TempString->str);
347
 
          g_string_free(TempString, TRUE);
348
 
          TempString = g_string_new(NULL);
349
 
          while((c=my_getc())!='\x01')
350
 
            { 
351
 
              TempString = g_string_append_c(TempString, c);
352
 
            }
353
 
          TempIssue->UID = atof(TempString->str);
354
 
          g_string_free(TempString, TRUE);
355
 
 
356
 
          /* Now the TIssue structure is filled - then insert into list */
357
 
          TempComic->IssueNumbers = g_list_insert_sorted(TempComic->IssueNumbers, TempIssue,
358
 
                                                         CompareTIssue_IssueNo);
359
 
        }
360
 
      /* Now the TComic structure is filled - then insert into list */
361
 
      ComicList = g_list_insert_sorted(ComicList, TempComic, CompareTComic_Title);
362
 
    }
363
 
 
364
 
  SetUID(LargestUID);
365
 
  return ComicList;
366
 
}
367
 
 
368
 
GList *LoadGCO_0_3(GList *ComicList, FILE *fp)
369
 
{
370
 
  /* Read largest used UID and set it using SetUID() */
371
 
  /* Read ComicList (remember to read the UIDs of the individual Comics and Issues, etc.) */
372
 
  int c;
373
 
  guint32 LargestUID;
374
 
  TComic *TempComic;
375
 
  TIssue *TempIssue;
376
 
  GString * TempString;
377
 
 
378
 
  TempString = g_string_new(NULL);
379
 
  while((c=my_getc())!='\x00')
380
 
    {
381
 
      TempString = g_string_append_c(TempString, c);
382
 
    }
383
 
  LargestUID = atof(TempString->str);
384
 
  g_string_free(TempString, TRUE);
385
 
 
386
 
  while((c=my_getc())!=EOF)
387
 
    {
388
 
      my_ungetc (c);
389
 
      TempComic = Init_Comic();
390
 
 
391
 
      while((c=my_getc())!='\x00')
392
 
        {
393
 
          TempComic->CTitle = g_string_append_c(TempComic->CTitle, c);
394
 
        }
395
 
      while((c=my_getc())!='\x00')
396
 
        {
397
 
          TempComic->CPublisher = g_string_append_c(TempComic->CPublisher, c);
398
 
        }
399
 
      while((c=my_getc())!='\x00')
400
 
        {
401
 
          TempComic->CType = g_string_append_c(TempComic->CType, c);
402
 
        }
403
 
      while((c=my_getc())!='\x00')
404
 
        {
405
 
          TempComic->CVolume = g_string_append_c(TempComic->CVolume, c);
406
 
        }
407
 
      while((c=my_getc())!='\x00')
408
 
        {
409
 
          TempComic->CGroup = g_string_append_c(TempComic->CGroup, c);
410
 
        }
411
 
      while((c=my_getc())!='\x00')
412
 
        {
413
 
          TempComic->Comment = g_string_append_c(TempComic->Comment, c);
414
 
        }
415
 
      while((c=my_getc())!='\x00')
416
 
        {
417
 
          TempComic->LinkFile = g_string_append_c(TempComic->LinkFile, c);
418
 
        }
419
 
      TempComic->IsLink = (TempComic->LinkFile->len>0);
420
 
      TempString = g_string_new(NULL);
421
 
      while((c=my_getc())!='\x00')
422
 
        {
423
 
          TempString = g_string_append_c(TempString, c);
424
 
        }
425
 
      TempComic->UID = atof(TempString->str);
426
 
      g_string_free(TempString, TRUE);
427
 
 
428
 
      /* Now load the Issues */
429
 
      while((c=my_getc())!='\x00')
430
 
        {
431
 
          my_ungetc (c);
432
 
          TempIssue = Init_Issue();
433
 
 
434
 
          while((c=my_getc())!='\x01')
435
 
            { 
436
 
              TempIssue->IssueNo = g_string_append_c(TempIssue->IssueNo, c);
437
 
            } 
438
 
          while((c=my_getc())!='\x01')
439
 
            { 
440
 
              my_ungetc (c);
441
 
              TempString = g_string_new(NULL);
442
 
 
443
 
              while((c=my_getc())!='\x02')
444
 
                {
445
 
                  TempString = g_string_append_c(TempString, c);
446
 
                }
447
 
              TempIssue->Writer = g_list_append(TempIssue->Writer, TempString);
448
 
            } 
449
 
          while((c=my_getc())!='\x01')
450
 
            { 
451
 
              my_ungetc (c);
452
 
              TempString = g_string_new(NULL);
453
 
 
454
 
              while((c=my_getc())!='\x02')
455
 
                {
456
 
                  TempString = g_string_append_c(TempString, c);
457
 
                }
458
 
              TempIssue->Penciller = g_list_append(TempIssue->Penciller, TempString);
459
 
            } 
460
 
          while((c=my_getc())!='\x01')
461
 
            { 
462
 
              my_ungetc (c);
463
 
              TempString = g_string_new(NULL);
464
 
 
465
 
              while((c=my_getc())!='\x02')
466
 
                {
467
 
                  TempString = g_string_append_c(TempString, c);
468
 
                }
469
 
              TempIssue->Inker = g_list_append(TempIssue->Inker, TempString);
470
 
            } 
471
 
          while((c=my_getc())!='\x01')
472
 
            { 
473
 
              my_ungetc (c);
474
 
              TempString = g_string_new(NULL);
475
 
 
476
 
              while((c=my_getc())!='\x02')
477
 
                {
478
 
                  TempString = g_string_append_c(TempString, c);
479
 
                }
480
 
              TempIssue->Title = g_list_append(TempIssue->Title, TempString);
481
 
            } 
482
 
          while((c=my_getc())!='\x01')
483
 
            { 
484
 
              TempIssue->Location = g_string_append_c(TempIssue->Location, c);
485
 
            } 
486
 
          while((c=my_getc())!='\x01')
487
 
            { 
488
 
              TempIssue->Price = g_string_append_c(TempIssue->Price, c);
489
 
            } 
490
 
          while((c=my_getc())!='\x01')
491
 
            { 
492
 
              TempIssue->CurrentPrice = g_string_append_c(TempIssue->CurrentPrice, c);
493
 
            } 
494
 
          while((c=my_getc())!='\x01')
495
 
            { 
496
 
              TempIssue->PurchasePrice = g_string_append_c(TempIssue->PurchasePrice, c);
497
 
            } 
498
 
          while((c=my_getc())!='\x01')
499
 
            { 
500
 
              TempIssue->Image = g_string_append_c(TempIssue->Image, c);
501
 
            } 
502
 
          TempString = g_string_new(NULL);
503
 
          while((c=my_getc())!='\x01')
504
 
            { 
505
 
              TempString = g_string_append_c(TempString, c);
506
 
            }
507
 
          TempIssue->Condition = atof(TempString->str);
508
 
          g_string_free(TempString, TRUE);
509
 
          while((c=my_getc())!='\x01')
510
 
            { 
511
 
              TempIssue->Comment = g_string_append_c(TempIssue->Comment, c);
512
 
            } 
513
 
          TempString = g_string_new(NULL);
514
 
          while((c=my_getc())!='\x01')
515
 
            { 
516
 
              TempString = g_string_append_c(TempString, c);
517
 
            }
518
 
          TempIssue->Date = atof(TempString->str);
519
 
          g_string_free(TempString, TRUE);
520
 
          TempString = g_string_new(NULL);
521
 
          while((c=my_getc())!='\x01')
522
 
            { 
523
 
              TempString = g_string_append_c(TempString, c);
524
 
            }
525
 
          TempIssue->UID = atof(TempString->str);
526
 
          g_string_free(TempString, TRUE);
527
 
 
528
 
          /* Now the TIssue structure is filled - then insert into list */
529
 
          TempComic->IssueNumbers = g_list_insert_sorted(TempComic->IssueNumbers, TempIssue,
530
 
                                                         CompareTIssue_IssueNo);
531
 
        }
532
 
      /* Now the TComic structure is filled - then insert into list */
533
 
      ComicList = g_list_insert_sorted(ComicList, TempComic, CompareTComic_Title);
534
 
    }
535
 
 
536
 
  SetUID(LargestUID);
537
 
  return ComicList;
538
 
}
539
 
 
540
 
GList *LoadFile(GList *ComicList, FILE *fp)
541
 
{
542
 
  switch (FileCheck(fp)) 
543
 
    {
544
 
    case CO19: 
545
 
      return LoadCO19(ComicList, fp);
546
 
      break;
547
 
    case GCO_0_1:
548
 
      return LoadGCO_0_1(ComicList, fp);
549
 
      break;
550
 
    case GCO_0_3:
551
 
      return LoadGCO_0_3(ComicList, fp);
552
 
      break;
553
 
    case NotCO: 
554
 
      dprintf("File is not a recognized filetype...\n");
555
 
      return NULL;
556
 
    default:
557
 
      dprintf("Something unexpected happened...\n");
558
 
      return NULL;
559
 
    }
560
 
}
561
 
 
562
 
void SaveFile(GList *ComicList, FILE *fp)
563
 
{
564
 
  /* Write GCO_0_3_Ident */
565
 
  /* Write largest used UID */
566
 
  /* Write ComicList (remember to save the UIDs of the individual Comics and Issues, etc.) */
567
 
  int i, j, k, l, m, n;
568
 
  TComic *TempComic;
569
 
  TIssue *TempIssue;
570
 
  GString * TempString;
571
 
 
572
 
  my_putc('\x00', fp);
573
 
  my_puts(GCO_0_3_Ident, fp);
574
 
  my_putc('\x00', fp);
575
 
  my_puts(itoa(GetUID()+1), fp); 
576
 
  my_putc('\x00', fp);
577
 
 
578
 
  j = g_list_length(ComicList);
579
 
  for (i=0;i<j;i++)
580
 
    {
581
 
      /* Save the Comic info */
582
 
      TempComic = (g_list_nth(ComicList,i))->data;
583
 
      my_puts(TempComic->CTitle->str, fp);
584
 
      my_putc('\x00', fp);
585
 
      my_puts(TempComic->CPublisher->str, fp);
586
 
      my_putc('\x00', fp);
587
 
      my_puts(TempComic->CType->str, fp);
588
 
      my_putc('\x00', fp);
589
 
      my_puts(TempComic->CVolume->str, fp);
590
 
      my_putc('\x00', fp);
591
 
      my_puts(TempComic->CGroup->str, fp);
592
 
      my_putc('\x00', fp);
593
 
      my_puts(TempComic->Comment->str, fp);
594
 
      my_putc('\x00', fp);
595
 
      my_puts(TempComic->LinkFile->str, fp);
596
 
      my_putc('\x00', fp);
597
 
      my_puts(itoa(TempComic->UID), fp); 
598
 
      my_putc('\x00', fp);
599
 
 
600
 
      /* Now save the Issues */
601
 
      k = g_list_length(TempComic->IssueNumbers);
602
 
      for (l=0;l<k;l++)
603
 
        {
604
 
          TempIssue = (g_list_nth(TempComic->IssueNumbers,l))->data;
605
 
          my_puts(TempIssue->IssueNo->str, fp);
606
 
          my_putc('\x01', fp);
607
 
 
608
 
          m = g_list_length(TempIssue->Writer);
609
 
          for (n=0;n<m;n++)
610
 
            {
611
 
              TempString = (g_list_nth(TempIssue->Writer, n)->data);
612
 
              my_puts(TempString->str, fp);
613
 
              my_putc('\x02', fp);
614
 
            }
615
 
          my_putc('\x01', fp);
616
 
 
617
 
          m = g_list_length(TempIssue->Penciller);
618
 
          for (n=0;n<m;n++)
619
 
            {
620
 
              TempString = (g_list_nth(TempIssue->Penciller, n)->data);
621
 
              my_puts(TempString->str, fp);
622
 
              my_putc('\x02', fp);
623
 
            }
624
 
          my_putc('\x01', fp);
625
 
 
626
 
          m = g_list_length(TempIssue->Inker);
627
 
          for (n=0;n<m;n++)
628
 
            {
629
 
              TempString = (g_list_nth(TempIssue->Inker, n)->data);
630
 
              my_puts(TempString->str, fp);
631
 
              my_putc('\x02', fp);
632
 
            }
633
 
          my_putc('\x01', fp);
634
 
 
635
 
          m = g_list_length(TempIssue->Title);
636
 
          for (n=0;n<m;n++)
637
 
            {
638
 
              TempString = (g_list_nth(TempIssue->Title, n)->data);
639
 
              my_puts(TempString->str, fp);
640
 
              my_putc('\x02', fp);
641
 
            }
642
 
          my_putc('\x01', fp);
643
 
 
644
 
          my_puts(TempIssue->Location->str, fp);
645
 
          my_putc('\x01', fp);
646
 
          my_puts(TempIssue->Price->str, fp);
647
 
          my_putc('\x01', fp);
648
 
          my_puts(TempIssue->CurrentPrice->str, fp);
649
 
          my_putc('\x01', fp);
650
 
          my_puts(TempIssue->PurchasePrice->str, fp);
651
 
          my_putc('\x01', fp);
652
 
          my_puts(TempIssue->Image->str, fp);
653
 
          my_putc('\x01', fp);
654
 
          my_puts(itoa(TempIssue->Condition), fp);
655
 
          my_putc('\x01', fp);
656
 
          my_puts(TempIssue->Comment->str, fp);
657
 
          my_putc('\x01', fp);
658
 
          my_puts(itoa(TempIssue->Date), fp);
659
 
          my_putc('\x01', fp);
660
 
          my_puts(itoa(TempIssue->UID), fp);
661
 
          my_putc('\x01', fp);
662
 
        }
663
 
      my_putc('\x00', fp);
664
 
    }
665
 
}
666
 
 
667
 
 
668
 
TFileType FileCheck(FILE *fp)
669
 
{
670
 
  gshort i;
671
 
  int c;
672
 
  GString *s;
673
 
 
674
 
  s = g_string_new(NULL);
675
 
  for(i=0;i<=10;i++)
676
 
    {
677
 
      if ((c=my_getc())==EOF)
678
 
        g_print("Error...\n");
679
 
      if (c!=0) /* Idents are surrounded by #0's */
680
 
        s = g_string_append_c(s, (gchar)c);
681
 
    }
682
 
 
683
 
  if (strcmp(s->str, CO19Ident)==0)
684
 
    return CO19;
685
 
  if (strcmp(s->str, GCO_0_1_Ident)==0)
686
 
    return GCO_0_1;
687
 
  if (strcmp(s->str, GCO_0_3_Ident)==0)
688
 
    return GCO_0_3;
689
 
  else
690
 
    return NotCO;
691
 
}
692
 
 
693
 
int ExportToASCIIFile(GList *clist, GString *fname)
694
 
{
695
 
  TComic *TempComic;
696
 
  TIssue *TempIssue;
697
 
  guint32 i,j,k,l,m,n;
698
 
  GString *String;
699
 
  FILE *fp;
700
 
 
701
 
  fp = fopen (fname->str, "w");
702
 
  if (fp == NULL)
703
 
    {
704
 
      /* Unable to open file */
705
 
      return 1;
706
 
    }
707
 
 
708
 
  fprintf(fp, "%i comic title(s)\n\n\n\n", j=g_list_length(clist));
709
 
  for(i=0;i<j;i++)
710
 
    {
711
 
      TempComic = (g_list_nth(clist,i))->data;
712
 
      fprintf(fp, "%s", TempComic->CTitle->str);
713
 
      if(TempComic->IsLink)
714
 
        fprintf(fp, " (is a link to %s)\n", TempComic->LinkFile->str);
715
 
      else
716
 
        fprintf(fp, " (Vol. %s, %s, %s)\n", TempComic->CVolume->str,
717
 
                TempComic->CType->str, TempComic->CPublisher->str);
718
 
      fprintf(fp, "Comment: %s\n", TempComic->Comment->str);
719
 
      fprintf(fp, "Comic UID: %i\n", TempComic->UID);
720
 
 
721
 
      if(TempComic->IssueNumbers!=NULL)
722
 
        {
723
 
          fprintf(fp, "%i issue(s)\n", l=g_list_length(TempComic->IssueNumbers));
724
 
 
725
 
          for(k=0;k<l;k++)
726
 
            {
727
 
              TempIssue = (g_list_nth(TempComic->IssueNumbers,k))->data;
728
 
 
729
 
              fprintf(fp, "  Issue #%s:\n",TempIssue->IssueNo->str);
730
 
 
731
 
              fprintf(fp, "    Writer(s)\n");
732
 
              n=g_list_length(TempIssue->Writer);
733
 
              for(m=0;m<n;m++)
734
 
                { 
735
 
                  String = g_list_nth(TempIssue->Writer, m)->data;
736
 
                  fprintf(fp, "      %s\n", String->str);
737
 
                }
738
 
 
739
 
              fprintf(fp, "    Penciller(s)\n");
740
 
              n=g_list_length(TempIssue->Penciller);
741
 
              for(m=0;m<n;m++)
742
 
                { 
743
 
                  String = g_list_nth(TempIssue->Penciller, m)->data;
744
 
                  fprintf(fp, "      %s\n", String->str);
745
 
                }
746
 
 
747
 
              fprintf(fp, "    Inker(s)\n");
748
 
              n=g_list_length(TempIssue->Inker);
749
 
              for(m=0;m<n;m++)
750
 
                { 
751
 
                  String = g_list_nth(TempIssue->Inker, m)->data;
752
 
                  fprintf(fp, "      %s\n", String->str);
753
 
                }
754
 
 
755
 
              fprintf(fp, "    StoryTitle(s)\n");
756
 
              n=g_list_length(TempIssue->Title);
757
 
              for(m=0;m<n;m++)
758
 
                { 
759
 
                  String = g_list_nth(TempIssue->Title, m)->data;
760
 
                  fprintf(fp, "      %s\n", String->str);
761
 
                }
762
 
 
763
 
              fprintf(fp, "    Location: %s\n", TempIssue->Location->str);
764
 
              fprintf(fp, "    CoverPrice: %s\n", TempIssue->Price->str);
765
 
              fprintf(fp, "    Current Price: %s\n", TempIssue->CurrentPrice->str);
766
 
              fprintf(fp, "    Purchase Price: %s\n", TempIssue->PurchasePrice->str);
767
 
              fprintf(fp, "    Image: %s\n", TempIssue->Image->str);
768
 
              fprintf(fp, "    Condition: ");
769
 
 
770
 
              switch (TempIssue->Condition)
771
 
                {
772
 
                case Mint:
773
 
                    fprintf(fp, "Mint\n");
774
 
                    break;
775
 
                case NearMint:      
776
 
                  fprintf(fp, "NearMint\n");
777
 
                  break;
778
 
                case VeryFine: 
779
 
                  fprintf(fp, "VeryFine\n");
780
 
                  break;
781
 
                case FineVeryFine: 
782
 
                  fprintf(fp, "FineVeryFine\n");
783
 
                  break;
784
 
                case Fine: 
785
 
                  fprintf(fp, "Fine\n");
786
 
                  break;
787
 
                case VeryGood:  
788
 
                  fprintf(fp, "VeryGood\n");
789
 
                  break;
790
 
                case Good:  
791
 
                  fprintf(fp, "Good\n");
792
 
                  break;
793
 
                case Fair:  
794
 
                  fprintf(fp, "Fair\n");
795
 
                  break;
796
 
                case Poor: 
797
 
                  fprintf(fp, "Poor\n");
798
 
                  break;
799
 
                default: 
800
 
                  fprintf(fp, "Unknown\n");
801
 
                  break;
802
 
                }
803
 
 
804
 
              fprintf(fp, "    Comment: %s\n", TempIssue->Comment->str);
805
 
              fprintf(fp, "    Issue UID: %i\n", TempIssue->UID);
806
 
            }
807
 
        }
808
 
      else
809
 
        {
810
 
          fprintf(fp, "no issues\n");
811
 
        }
812
 
      fprintf(fp, "\n\n");
813
 
    }
814
 
  
815
 
  fclose(fp);
816
 
  return 0;
817
 
}
818
 
 
819
 
void write_html_preamble (FILE *fp, char *title)
820
 
{
821
 
  fprintf (fp, "<html>");
822
 
  fprintf (fp, "<title>");
823
 
  fprintf (fp, title);
824
 
  fprintf (fp, "</title>");
825
 
  fprintf (fp, "<body bgcolor=\"white\">");
826
 
}
827
 
 
828
 
void write_html_end (FILE *fp)
829
 
{
830
 
  fprintf (fp, "</body>");
831
 
  fprintf (fp, "</html>");
832
 
}
833
 
 
834
 
void write_html_h1_start (FILE *fp)
835
 
{
836
 
  fprintf (fp, "<h1>");
837
 
}
838
 
 
839
 
void write_html_h1_end (FILE *fp)
840
 
{
841
 
  fprintf (fp, "</h1>");
842
 
}
843
 
 
844
 
void write_html_h2_start (FILE *fp)
845
 
{
846
 
  fprintf (fp, "<h2>");
847
 
}
848
 
 
849
 
void write_html_h2_end (FILE *fp)
850
 
{
851
 
  fprintf (fp, "</h2>");
852
 
}
853
 
 
854
 
void write_html_h3_start (FILE *fp)
855
 
{
856
 
  fprintf (fp, "<h3>");
857
 
}
858
 
 
859
 
void write_html_h3_end (FILE *fp)
860
 
{
861
 
  fprintf (fp, "</h3>");
862
 
}
863
 
 
864
 
void write_html_br (FILE *fp)
865
 
{
866
 
  fprintf (fp, "<br>");
867
 
}
868
 
 
869
 
void write_html_p (FILE *fp)
870
 
{
871
 
  fprintf (fp, "<p>");
872
 
}
873
 
 
874
 
void write_html_link (FILE *fp, GString *linkdest, GString *linkname)
875
 
{
876
 
  fprintf (fp, "<a href=\"%s\">%s</a>", linkdest->str, linkname->str);
877
 
}
878
 
 
879
 
void write_html_ul_start (FILE *fp)
880
 
{
881
 
  fprintf (fp, "<ul>");
882
 
}
883
 
 
884
 
void write_html_ul_end (FILE *fp)
885
 
{
886
 
  fprintf (fp, "</ul>");
887
 
}
888
 
 
889
 
void write_html_li_start (FILE *fp)
890
 
{
891
 
  fprintf (fp, "<li>");
892
 
}
893
 
 
894
 
void write_html_li_end (FILE *fp)
895
 
{
896
 
  fprintf (fp, "</li>");
897
 
}
898
 
 
899
 
void write_html_table_start (FILE *fp)
900
 
{
901
 
  fprintf (fp, "<table cellpadding=\"2\" cellspacing=\"2\" border=\"1\" width=\"75%%\">");
902
 
  fprintf (fp, "<tbody>");
903
 
}
904
 
 
905
 
void write_html_table_end (FILE *fp)
906
 
{
907
 
  fprintf (fp, "</table>");
908
 
}
909
 
 
910
 
void write_html_td_start (FILE *fp)
911
 
{
912
 
  fprintf (fp, "<td>");
913
 
}
914
 
 
915
 
void write_html_td_end (FILE *fp)
916
 
{
917
 
  fprintf (fp, "</td>");
918
 
}
919
 
 
920
 
void write_html_tr_start (FILE *fp)
921
 
{
922
 
  fprintf (fp, "<tr>");
923
 
}
924
 
 
925
 
void write_html_tr_end (FILE *fp)
926
 
{
927
 
  fprintf (fp, "</tr>");
928
 
}
929
 
 
930
 
void write_html_center_start (FILE *fp)
931
 
{
932
 
  fprintf (fp, "<center>");
933
 
}
934
 
 
935
 
void write_html_center_end (FILE *fp)
936
 
{
937
 
  fprintf (fp, "</center>");
938
 
}
939
 
 
940
 
void write_html_image (FILE *fp, GString *imgfile, GString *alt)
941
 
{
942
 
  if (strcmp (imgfile->str, "")!=0)
943
 
    {
944
 
      fprintf (fp, "<img src=\"%s\" alt=\"%s\">", imgfile->str, alt->str);
945
 
    }
946
 
}
947
 
 
948
 
gchar *generate_subdirname (GString *dirname, TComic *TempComic)
949
 
{
950
 
  GString *returnme;
951
 
  int i;
952
 
 
953
 
  returnme = g_string_new (NULL);
954
 
 
955
 
  g_string_append (returnme, dirname->str);
956
 
 
957
 
  /* sanitize string  */
958
 
  /* g_string_append (returnme, TempComic->CTitle->str); */
959
 
  for (i=0; i<strlen(TempComic->CTitle->str); i++)
960
 
    {
961
 
      if (TempComic->CTitle->str[i] == ':' ||
962
 
          TempComic->CTitle->str[i] == '/' ||
963
 
          TempComic->CTitle->str[i] == '\\' ||
964
 
          TempComic->CTitle->str[i] == ';' ||
965
 
          TempComic->CTitle->str[i] == '?' ||
966
 
          TempComic->CTitle->str[i] == '&' ||
967
 
          TempComic->CTitle->str[i] == ' ')
968
 
        {
969
 
          g_string_append_c (returnme, '_');
970
 
        }
971
 
      else
972
 
        {
973
 
          g_string_append_c (returnme, TempComic->CTitle->str[i]);
974
 
        }
975
 
    }
976
 
  g_string_append (returnme, "_");
977
 
  g_string_append (returnme, itoa (TempComic->UID));
978
 
 
979
 
  return returnme->str;
980
 
}
981
 
 
982
 
gchar *generate_comic_filename (GString *dirname, TComic *TempComic)
983
 
{
984
 
  /* The filename is generated from the subdirname by adding .html */
985
 
  GString *returnme;
986
 
 
987
 
  returnme = g_string_new (generate_subdirname (dirname, TempComic));
988
 
 
989
 
  g_string_append (returnme, ".html");
990
 
 
991
 
  return returnme->str;
992
 
}
993
 
 
994
 
gchar *generate_issue_filename (GString *dirname, TIssue *TempIssue)
995
 
{
996
 
  GString *returnme;
997
 
  int i;
998
 
 
999
 
  returnme = g_string_new (NULL);
1000
 
 
1001
 
  g_string_append (returnme, dirname->str);
1002
 
  g_string_append (returnme, "/");
1003
 
 
1004
 
  /* sanitize string  */
1005
 
  /* g_string_append (returnme, TempIssue->IssueNo->Str); */
1006
 
  for (i=0; i<strlen(TempIssue->IssueNo->str); i++)
1007
 
    {
1008
 
      if (TempIssue->IssueNo->str[i] == ':' ||
1009
 
          TempIssue->IssueNo->str[i] == '/' ||
1010
 
          TempIssue->IssueNo->str[i] == '\\' ||
1011
 
          TempIssue->IssueNo->str[i] == ';' ||
1012
 
          TempIssue->IssueNo->str[i] == '?' ||
1013
 
          TempIssue->IssueNo->str[i] == '&' ||
1014
 
          TempIssue->IssueNo->str[i] == ' ')
1015
 
        {
1016
 
          g_string_append_c (returnme, '_');
1017
 
        }
1018
 
      else
1019
 
        {
1020
 
          g_string_append_c (returnme, TempIssue->IssueNo->str[i]);
1021
 
        }
1022
 
    }
1023
 
  g_string_append (returnme, "_");
1024
 
  g_string_append (returnme, itoa (TempIssue->UID));
1025
 
  g_string_append (returnme, ".html");
1026
 
 
1027
 
  return returnme->str;
1028
 
}
1029
 
 
1030
 
int ExportToHTMLFile(GList *clist, GString *dirname)
1031
 
{
1032
 
  TComic *TempComic;
1033
 
  TIssue *TempIssue;
1034
 
  guint32 i,j,k,l,m,n;
1035
 
  GString *String, *indexname, *fname, *dname;
1036
 
  FILE *indexfp = NULL;
1037
 
  FILE *ifp  = NULL;
1038
 
  FILE *cfp = NULL;
1039
 
 
1040
 
  indexname = g_string_new (dirname->str);
1041
 
  g_string_append (indexname, "index.html");
1042
 
  indexfp = fopen (indexname->str, "w");
1043
 
  if (indexfp == NULL)
1044
 
    {
1045
 
      /* Unable to open file */
1046
 
      return 1;
1047
 
    }
1048
 
 
1049
 
  j=g_list_length(clist);
1050
 
 
1051
 
  write_html_preamble (indexfp, "My Comics");
1052
 
  write_html_h1_start (indexfp);
1053
 
  fprintf(indexfp, "%i comic title(s)\n\n\n\n", j);
1054
 
  write_html_h1_end (indexfp);
1055
 
  write_html_br (indexfp);
1056
 
  fprintf (indexfp, "\n");
1057
 
 
1058
 
 
1059
 
  fname = g_string_new (NULL);
1060
 
  dname = g_string_new (NULL);
1061
 
 
1062
 
  for(i=0;i<j;i++)
1063
 
    {
1064
 
      TempComic = (g_list_nth(clist,i))->data;
1065
 
 
1066
 
      /* Construct unique filename */
1067
 
      g_string_assign (fname, "");
1068
 
      g_string_append (fname, generate_comic_filename (dirname, TempComic));
1069
 
      
1070
 
      /* open file */
1071
 
      cfp = fopen (fname->str, "w");
1072
 
      if (cfp == NULL)
1073
 
        {
1074
 
          /* Unable to open file */
1075
 
          return 1;
1076
 
        }
1077
 
    
1078
 
      write_html_preamble (cfp, TempComic->CTitle->str);
1079
 
 
1080
 
      String = g_string_new (TempComic->CTitle->str);
1081
 
      g_string_append (String, " (Vol. ");
1082
 
      g_string_append (String, TempComic->CVolume->str);
1083
 
      g_string_append (String, ")");
1084
 
      write_html_link (indexfp, fname, String);
1085
 
      write_html_br (indexfp);
1086
 
      fprintf (indexfp, "\n");
1087
 
 
1088
 
      write_html_h1_start (cfp);
1089
 
      fprintf(cfp, "%s", TempComic->CTitle->str);
1090
 
      if(TempComic->IsLink)
1091
 
        fprintf(cfp, " (is a link to %s)\n", TempComic->LinkFile->str);
1092
 
      else
1093
 
        fprintf(cfp, " (Vol. %s, %s, %s)\n", TempComic->CVolume->str,
1094
 
                TempComic->CType->str, TempComic->CPublisher->str);
1095
 
      write_html_h1_end (cfp);
1096
 
      write_html_br (cfp);
1097
 
      fprintf(cfp, "Comment: %s\n", TempComic->Comment->str);
1098
 
      write_html_p (cfp);
1099
 
 
1100
 
      if(TempComic->IssueNumbers!=NULL)
1101
 
        {
1102
 
          write_html_h2_start (cfp);
1103
 
          fprintf(cfp, "%i issue(s)\n", l=g_list_length(TempComic->IssueNumbers));
1104
 
          write_html_h2_end (cfp);
1105
 
          write_html_br (cfp);
1106
 
 
1107
 
          g_string_assign (dname, "");
1108
 
          g_string_append (dname, generate_subdirname (dirname, TempComic));
1109
 
          mkdir (dname->str, 0755); /* read/write/execute by user, read/execute by anyone else - umask permitting */
1110
 
      
1111
 
          for(k=0;k<l;k++)
1112
 
            {
1113
 
              TempIssue = (g_list_nth(TempComic->IssueNumbers,k))->data;
1114
 
 
1115
 
              g_string_assign (fname, "");
1116
 
              g_string_append (fname, generate_issue_filename (dname, TempIssue));
1117
 
 
1118
 
 
1119
 
              /* open file */
1120
 
              ifp = fopen (fname->str, "w");
1121
 
              if (ifp == NULL)
1122
 
                {
1123
 
                  /* Unable to open file */
1124
 
                  return 1;
1125
 
                }
1126
 
 
1127
 
 
1128
 
              String = g_string_new ("#");
1129
 
              g_string_append (String, TempIssue->IssueNo->str);
1130
 
              write_html_link (cfp, fname, String);
1131
 
              write_html_br (cfp);
1132
 
              fprintf (cfp, "\n");
1133
 
 
1134
 
 
1135
 
              g_string_assign (String, TempComic->CTitle->str);
1136
 
              g_string_append (String, " - #");
1137
 
              g_string_append (String, TempIssue->IssueNo->str);
1138
 
              write_html_preamble (ifp, String->str);
1139
 
    
1140
 
              write_html_center_start (ifp);
1141
 
              write_html_h3_start (ifp);
1142
 
              fprintf(ifp, "  Issue #%s:\n", TempIssue->IssueNo->str);
1143
 
              write_html_h3_end (ifp);
1144
 
 
1145
 
              write_html_image (ifp, TempIssue->Image, TempIssue->IssueNo);
1146
 
 
1147
 
              write_html_table_start (ifp);
1148
 
 
1149
 
              write_html_tr_start (ifp);
1150
 
              write_html_td_start (ifp);
1151
 
              fprintf(ifp, "Writer(s)");
1152
 
              write_html_td_end (ifp);
1153
 
              write_html_td_start (ifp);
1154
 
              n=g_list_length(TempIssue->Writer);
1155
 
              for(m=0;m<n;m++)
1156
 
                { 
1157
 
                  String = g_list_nth(TempIssue->Writer, m)->data;
1158
 
                  fprintf(ifp, "      %s\n", String->str);
1159
 
                  write_html_br (ifp);
1160
 
                }
1161
 
              write_html_td_end (ifp);
1162
 
              write_html_tr_end (ifp);
1163
 
 
1164
 
              write_html_tr_start (ifp);
1165
 
              write_html_td_start (ifp);
1166
 
              fprintf(ifp, "Penciller(s)");
1167
 
              write_html_td_end (ifp);
1168
 
              write_html_td_start (ifp);
1169
 
              n=g_list_length(TempIssue->Penciller);
1170
 
              for(m=0;m<n;m++)
1171
 
                { 
1172
 
                  String = g_list_nth(TempIssue->Penciller, m)->data;
1173
 
                  fprintf(ifp, "      %s\n", String->str);
1174
 
                  write_html_br (ifp);
1175
 
                }
1176
 
              write_html_td_end (ifp);
1177
 
              write_html_tr_end (ifp);
1178
 
              
1179
 
              write_html_tr_start (ifp);
1180
 
              write_html_td_start (ifp);
1181
 
              fprintf(ifp, "Inker(s)");
1182
 
              write_html_td_end (ifp);
1183
 
              write_html_td_start (ifp);
1184
 
              n=g_list_length(TempIssue->Inker);
1185
 
              for(m=0;m<n;m++)
1186
 
                { 
1187
 
                  String = g_list_nth(TempIssue->Inker, m)->data;
1188
 
                  fprintf(ifp, "      %s\n", String->str);
1189
 
                  write_html_br (ifp);
1190
 
                }
1191
 
              write_html_td_end (ifp);
1192
 
              write_html_tr_end (ifp);
1193
 
 
1194
 
              write_html_tr_start (ifp);
1195
 
              write_html_td_start (ifp);
1196
 
              fprintf(ifp, " StoryTitle(s)");
1197
 
              write_html_td_end (ifp);
1198
 
              write_html_td_start (ifp);
1199
 
              n=g_list_length(TempIssue->Title);
1200
 
              for(m=0;m<n;m++)
1201
 
                { 
1202
 
                  String = g_list_nth(TempIssue->Title, m)->data;
1203
 
                  fprintf(ifp, "      %s\n", String->str);
1204
 
                  write_html_br (ifp);
1205
 
                }
1206
 
              write_html_td_end (ifp);
1207
 
              write_html_tr_end (ifp);
1208
 
 
1209
 
              write_html_tr_start (ifp);
1210
 
              write_html_td_start (ifp);
1211
 
              fprintf(ifp, "Location");
1212
 
              write_html_td_end (ifp);
1213
 
              write_html_td_start (ifp);
1214
 
              fprintf (ifp, "%s", TempIssue->Location->str);
1215
 
              write_html_td_end (ifp);
1216
 
              write_html_tr_end (ifp);
1217
 
 
1218
 
 
1219
 
              write_html_tr_start (ifp);
1220
 
              write_html_td_start (ifp);
1221
 
              fprintf(ifp, "CoverPrice");
1222
 
              write_html_td_end (ifp);
1223
 
              write_html_td_start (ifp);
1224
 
              fprintf(ifp, "%s", TempIssue->Price->str);
1225
 
              write_html_td_end (ifp);
1226
 
              write_html_tr_end (ifp);
1227
 
              
1228
 
              write_html_tr_start (ifp);
1229
 
              write_html_td_start (ifp);
1230
 
              fprintf(ifp, "Current Price");
1231
 
              write_html_td_end (ifp);
1232
 
              write_html_td_start (ifp);
1233
 
              fprintf(ifp, "%s", TempIssue->CurrentPrice->str);
1234
 
              write_html_td_end (ifp);
1235
 
              write_html_tr_end (ifp);
1236
 
 
1237
 
              write_html_tr_start (ifp);
1238
 
              write_html_td_start (ifp);
1239
 
              fprintf(ifp, "Purchase Price");
1240
 
              write_html_td_end (ifp);
1241
 
              write_html_td_start (ifp);
1242
 
              fprintf(ifp, "%s", TempIssue->PurchasePrice->str);
1243
 
              write_html_td_end (ifp);
1244
 
              write_html_tr_end (ifp);
1245
 
 
1246
 
              write_html_tr_start (ifp);
1247
 
              write_html_td_start (ifp);
1248
 
              fprintf(ifp, "Condition");
1249
 
              write_html_td_end (ifp);
1250
 
              write_html_td_start (ifp);
1251
 
 
1252
 
              switch (TempIssue->Condition)
1253
 
                {
1254
 
                case Mint:
1255
 
                  fprintf(ifp, "Mint\n");
1256
 
                  break;
1257
 
                case NearMint:      
1258
 
                  fprintf(ifp, "NearMint\n");
1259
 
                  break;
1260
 
                case VeryFine: 
1261
 
                  fprintf(ifp, "VeryFine\n");
1262
 
                  break;
1263
 
                case FineVeryFine: 
1264
 
                  fprintf(ifp, "FineVeryFine\n");
1265
 
                  break;
1266
 
                case Fine: 
1267
 
                  fprintf(ifp, "Fine\n");
1268
 
                  break;
1269
 
                case VeryGood:  
1270
 
                  fprintf(ifp, "VeryGood\n");
1271
 
                  break;
1272
 
                case Good:  
1273
 
                  fprintf(ifp, "Good\n");
1274
 
                  break;
1275
 
                case Fair:  
1276
 
                  fprintf(ifp, "Fair\n");
1277
 
                  break;
1278
 
                case Poor: 
1279
 
                  fprintf(ifp, "Poor\n");
1280
 
                  break;
1281
 
                default: 
1282
 
                  fprintf(ifp, "Unknown\n");
1283
 
                  break;
1284
 
                }
1285
 
              write_html_td_end (ifp);
1286
 
              write_html_tr_end (ifp);
1287
 
 
1288
 
              write_html_tr_start (ifp);
1289
 
              write_html_td_start (ifp);
1290
 
              fprintf(ifp, "Comment");
1291
 
              write_html_td_end (ifp);
1292
 
              write_html_td_start (ifp);
1293
 
              fprintf(ifp, "%s", TempIssue->Comment->str);
1294
 
              write_html_td_end (ifp);
1295
 
              write_html_tr_end (ifp);
1296
 
 
1297
 
              write_html_table_end (ifp);
1298
 
              write_html_center_end (ifp);
1299
 
 
1300
 
              write_html_end (ifp);
1301
 
              fclose(ifp);
1302
 
            }
1303
 
        }
1304
 
      else
1305
 
        {
1306
 
          write_html_ul_start (cfp);
1307
 
          write_html_li_start (cfp);
1308
 
          fprintf(ifp, "no issues\n");
1309
 
          write_html_li_end (cfp);
1310
 
          write_html_ul_end (cfp);
1311
 
        }
1312
 
      write_html_end (cfp);
1313
 
      fclose(cfp);
1314
 
    }
1315
 
  
1316
 
  write_html_end (indexfp);
1317
 
  fclose(indexfp);
1318
 
  return 0;
1319
 
}