home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / casette-lbl / cassette.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-31  |  2.4 KB  |  99 lines

  1. /*
  2.  * Copyright (C) 1987, Thomas H. Smith -- San Francisco, California
  3.  *   Program 'Cassette':
  4.  *    Permission is granted to any individual or institution
  5.  *    to use, copy, modify, or redistribute this software so long as it
  6.  *    is not sold for profit and provided this copyright notice is retained.
  7.  *
  8.  *   PostScript is a registered trademark of Adobe Systems, Inc.
  9.  */
  10. #include <stdio.h>
  11. #include "cassette.h"
  12.  
  13. main(argc, argv)
  14. int argc;
  15. char *argv[];
  16. {
  17.     FILE *open_file();
  18.     char *album1, *album2;
  19.     int number_songs = FALSE;
  20.  
  21.     album1 = argv[1];
  22.     album2 = argv[2];
  23.  
  24.     if (argc > 1) {
  25.     if (strcmp(argv[1], "-n") == 0) {
  26.         number_songs = TRUE;
  27.         argc--;
  28.         album1 = argv[2];
  29.         album2 = argv[3];
  30.     }
  31.     }
  32.  
  33.     if ((argc != 3) && (argc != 2)) {
  34.     (void) fprintf(stderr, "usage: %s  [-n] <album1 file> [<album2 file>]",
  35.                                     argv[0]);
  36.     exit(1);
  37.     }
  38.  
  39.     output_ps_globals();
  40.     output_ps_outline();
  41.     if (argc == 2) {
  42.     file_to_postscript(open_file(album1), number_songs, ONLY);
  43.     } else {
  44.     file_to_postscript(open_file(album1), number_songs, SIDE1);
  45.     file_to_postscript(open_file(album2), number_songs, SIDE2);
  46.     }
  47.     output_ps_trailer();
  48. }
  49.  
  50.  
  51. FILE *
  52. open_file(filename)
  53. char *filename;
  54. {
  55.     FILE *fd, *fopen();
  56.  
  57.     fd = fopen(filename, "r");
  58.     if (fd == NULL) {
  59.     perror(filename);
  60.     exit(1);
  61.     }
  62.     return(fd);
  63. }
  64.  
  65.  
  66. file_to_postscript(file, number_songs, position)
  67. FILE *file;
  68. int number_songs, position;
  69. {
  70.     char *title, *artist, *noise_red, **songs1, **songs2;
  71.     int noise_type;
  72.     extern char *input_title(), *input_artist(), *input_noise_reduction();
  73.     extern char **input_songs();
  74.  
  75.     artist = input_artist(file);
  76.     title = input_title(file);
  77.     noise_red = input_noise_reduction(file, &noise_type);
  78.     songs1 = input_songs(file);
  79.     if (position == ONLY)        /* look for two-record sets */
  80.     songs2 = input_songs(file);
  81.  
  82.     output_ps_artist(title, artist, position);
  83.     output_ps_title(title, artist, position);
  84.     output_ps_noise_reduction(noise_red, noise_type, position);
  85.     if ((position == ONLY) && (songs2[0] != NULL)) {
  86.     output_ps_songs(songs1, number_songs, SIDE1);
  87.     output_ps_songs(songs2, number_songs, SIDE2);
  88.     } else {
  89.     output_ps_songs(songs1, number_songs, position);
  90.     }
  91.  
  92.     (void) free(artist);
  93.     (void) free(title);
  94.     (void) free(noise_red);
  95.     free_song_list(songs1);
  96.     if (position == ONLY)
  97.     free_song_list(songs2);
  98. }
  99.