rsalz@uunet.UU.NET (Rich Salz) (02/09/88)
Submitted-by: Tom Smith <analog!smith> Posting-number: Volume 13, Issue 26 Archive-name: casette-lbl [ Sigh; I thought NNTP was above these kind of things... :-) /r$ ] This is a C program that reads files containing album title, artist, and songlist, and outputs a PostScript description of a cassette label suitable for framing or inserting into a standard-issue cassette case. Documentation is provided in both manpage and README files, and a Makefile is here as well. Our site connection with hplabs gets wedged at times. Thomas Smith {hplabs, ucbvax!sun!sunncal}!analog!smith #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # input_file.c # cassette.c # output_ps.c # overhead_ps.c # cassette.h # dimensions.h # Makefile # README # cassette.1 # album1.sample # album2.sample # double.sample export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting 'input_file.c'" '(3566 characters)' if test -f 'input_file.c' then echo shar: "will not over-write existing file 'input_file.c'" else sed 's/^X//' << \SHAR_EOF > 'input_file.c' X/* X * Copyright (C) 1987, Thomas H. Smith -- San Francisco, California X * Program 'Cassette': X * Permission is granted to any individual or institution X * to use, copy, modify, or redistribute this software so long as it X * is not sold for profit and provided this copyright notice is retained. X * X * PostScript is a registered trademark of Adobe Systems, Inc. X */ X#include <stdio.h> X#include <ctype.h> X#include "cassette.h" X Xstatic char buffer[BUFSIZ]; Xstatic char *bufferlist[BUFSIZ]; Xchar *create_string(), *strip_white(); X X Xchar * Xinput_title(fd) XFILE *fd; X{ X buffer[0] = '\0'; X (void) fgets(buffer, BUFSIZ, fd); X /* nuke trailing newline */ X buffer[strlen(buffer) - 1] = '\0'; X escape_parens(buffer); X return(create_string(strip_white(buffer))); X} X X Xchar * Xinput_artist(fd) XFILE *fd; X{ X buffer[0] = '\0'; X (void) fgets(buffer, BUFSIZ, fd); X /* nuke trailing newline */ X buffer[strlen(buffer) - 1] = '\0'; X escape_parens(buffer); X return(create_string(strip_white(buffer))); X} X X Xchar * Xinput_noise_reduction(fd, noise_type) XFILE *fd; Xint *noise_type; X{ X char *noise; X X buffer[0] = '\0'; X (void) fgets(buffer, BUFSIZ, fd); X /* nuke trailing newline */ X buffer[strlen(buffer) - 1] = '\0'; X escape_parens(buffer); X noise = create_string(strip_white(buffer)); X X /* see if this is a common noise reduction type */ X if (noise[0] == '\0') { X *noise_type = NONE; X } else if ((strncmp(noise, "dolby", 5) == 0) || X (strncmp(noise, "Dolby", 5) == 0)) { X if ((noise[strlen(noise)-1] == 'c') || (noise[strlen(noise)-1] == 'C')) X *noise_type = DOLBY_C; X else X *noise_type = DOLBY_B; X } else if ((strcmp(noise, "dbx") == 0) || (strcmp(noise, "DBX") == 0)) { X *noise_type = DBX; X } else { X *noise_type = OTHER; X } X X return(noise); X} X X Xchar ** Xinput_songs(fd) XFILE *fd; X{ X register int index; X char **returnlist; X extern char *malloc(); X X buffer[0] = '\0'; X for (index = 0; index < BUFSIZ; index++) { X if (fgets(buffer, BUFSIZ, fd) == NULL) X break; X /* nuke trailing newline */ X buffer[strlen(buffer) - 1] = '\0'; X if (EMPTYSTRING(buffer)) X break; X escape_parens(buffer); X bufferlist[index] = create_string(strip_white(buffer)); X } X X returnlist = (char **) malloc((unsigned) index * sizeof(char *) + 1); X bcopy((char *) bufferlist, (char *) returnlist, index * sizeof(char *)); X returnlist[index] = (char *) NULL; X return(returnlist); X} X X Xfree_song_list(songs) Xchar **songs; X{ X register int index; X X for (index = 0; songs[index] != NULL; index++) X (void) free(songs[index]); X free((char *) songs); X} X X Xstatic Xescape_parens(srcbuffer) Xchar *srcbuffer; X{ X register char *src, *dest; X char destbuffer[BUFSIZ]; X extern char *strcpy(); X X for (src = srcbuffer, dest = destbuffer; X (dest < &(destbuffer[BUFSIZ-1])) && (*src != '\0'); X src++, dest++) { X if ((*src == '(') || (*src == ')')) X *dest++ = '\\'; X *dest = *src; X } X *dest = '\0'; X (void) strcpy(srcbuffer, destbuffer); X} X X Xstatic char * Xstrip_white(string) Xchar *string; X{ X register char *begin, *end; X X for (begin = string; isspace(*begin) && (*begin != '\0'); begin++) ; X for (end = &(begin[strlen(string) - 1]); X isspace(*end) && (end != begin); end--) ; X if (end != begin) X *++end = '\0'; X X return(begin); X} X X Xstatic char * Xcreate_string(str) Xchar *str; X{ X char *newstring; X extern char *malloc(), *strcpy(); X X newstring = malloc((unsigned) strlen(str) + 1); X (void) strcpy(newstring, str); X return(newstring); X} SHAR_EOF if test 3566 -ne "`wc -c < 'input_file.c'`" then echo shar: "error transmitting 'input_file.c'" '(should have been 3566 characters)' fi fi echo shar: "extracting 'cassette.c'" '(2411 characters)' if test -f 'cassette.c' then echo shar: "will not over-write existing file 'cassette.c'" else sed 's/^X//' << \SHAR_EOF > 'cassette.c' X/* X * Copyright (C) 1987, Thomas H. Smith -- San Francisco, California X * Program 'Cassette': X * Permission is granted to any individual or institution X * to use, copy, modify, or redistribute this software so long as it X * is not sold for profit and provided this copyright notice is retained. X * X * PostScript is a registered trademark of Adobe Systems, Inc. X */ X#include <stdio.h> X#include "cassette.h" X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ X FILE *open_file(); X char *album1, *album2; X int number_songs = FALSE; X X album1 = argv[1]; X album2 = argv[2]; X X if (argc > 1) { X if (strcmp(argv[1], "-n") == 0) { X number_songs = TRUE; X argc--; X album1 = argv[2]; X album2 = argv[3]; X } X } X X if ((argc != 3) && (argc != 2)) { X (void) fprintf(stderr, "usage: %s [-n] <album1 file> [<album2 file>]", X argv[0]); X exit(1); X } X X output_ps_globals(); X output_ps_outline(); X if (argc == 2) { X file_to_postscript(open_file(album1), number_songs, ONLY); X } else { X file_to_postscript(open_file(album1), number_songs, SIDE1); X file_to_postscript(open_file(album2), number_songs, SIDE2); X } X output_ps_trailer(); X} X X XFILE * Xopen_file(filename) Xchar *filename; X{ X FILE *fd, *fopen(); X X fd = fopen(filename, "r"); X if (fd == NULL) { X perror(filename); X exit(1); X } X return(fd); X} X X Xfile_to_postscript(file, number_songs, position) XFILE *file; Xint number_songs, position; X{ X char *title, *artist, *noise_red, **songs1, **songs2; X int noise_type; X extern char *input_title(), *input_artist(), *input_noise_reduction(); X extern char **input_songs(); X X artist = input_artist(file); X title = input_title(file); X noise_red = input_noise_reduction(file, &noise_type); X songs1 = input_songs(file); X if (position == ONLY) /* look for two-record sets */ X songs2 = input_songs(file); X X output_ps_artist(title, artist, position); X output_ps_title(title, artist, position); X output_ps_noise_reduction(noise_red, noise_type, position); X if ((position == ONLY) && (songs2[0] != NULL)) { X output_ps_songs(songs1, number_songs, SIDE1); X output_ps_songs(songs2, number_songs, SIDE2); X } else { X output_ps_songs(songs1, number_songs, position); X } X X (void) free(artist); X (void) free(title); X (void) free(noise_red); X free_song_list(songs1); X if (position == ONLY) X free_song_list(songs2); X} SHAR_EOF if test 2411 -ne "`wc -c < 'cassette.c'`" then echo shar: "error transmitting 'cassette.c'" '(should have been 2411 characters)' fi fi echo shar: "extracting 'output_ps.c'" '(5556 characters)' if test -f 'output_ps.c' then echo shar: "will not over-write existing file 'output_ps.c'" else sed 's/^X//' << \SHAR_EOF > 'output_ps.c' X/* X * Copyright (C) 1987, Thomas H. Smith -- San Francisco, California X * Program 'Cassette': X * Permission is granted to any individual or institution X * to use, copy, modify, or redistribute this software so long as it X * is not sold for profit and provided this copyright notice is retained. X * X * PostScript is a registered trademark of Adobe Systems, Inc. X */ X#include <stdio.h> X#include "dimensions.h" X#include "cassette.h" X X Xoutput_ps_artist(title, artist, position) Xchar *title, *artist; Xint position; X{ X OUTPUT("\n%%\tArtist\n"); X if (EMPTYSTRING(title)) { X OUTPUT("%%\t\tNo artist specified\n"); X return; X } X X OUTPUT("/%s findfont %.3f doscalefont setfont\n", ARTISTFONT, ARTISTSIZE); X switch (position) { X case ONLY: X OUTPUT("/linestart {\n %.3f inches\n", WIDTH / 2.0); X OUTPUT(" (%s) stringwidth pop 2 div sub\n} def\n", artist); X OUTPUT("/lineend %.3f inches %.3f sub def\n", WIDTH, HSPACE); X break; X case SIDE1: X OUTPUT("/linestart %.3f def\n", HSPACE + (BORDERWIDTH / 2)); X OUTPUT("/lineend %.3f inches %.3f sub def\n", WIDTH / 2.0, HSPACE); X break; X case SIDE2: X OUTPUT("/linestart %.3f inches def\n", WIDTH / 2.0); X OUTPUT("/lineend %.3f inches %.3f sub def\n", WIDTH, HSPACE); X break; X } X X OUTPUT("linestart %.3f inches %.3f sub moveto\n", X BODYHEIGHT + EDGEHEIGHT, X ARTISTSIZE + VSPACE + X BORDERWIDTH - CHARFUDGE); X X OUTPUT("(%s) shrinkshow\n", artist); X} X X Xoutput_ps_title(title, artist, position) Xchar *title, *artist; Xint position; X{ X OUTPUT("\n%%\tTitle\n"); X OUTPUT("/%s findfont %.3f doscalefont setfont\n", TITLEFONT, TITLESIZE); X X if (EMPTYSTRING(title)) { X /* self-titled -- use artist for title */ X title = artist; X } X X switch (position) { X case ONLY: X OUTPUT("/linestart {\n %.3f inches\n", WIDTH / 2.0); X OUTPUT(" (%s) stringwidth pop 2 div sub\n} def\n", title); X OUTPUT("/lineend %.3f inches %.3f sub def\n", WIDTH, HSPACE); X break; X case SIDE1: X OUTPUT("/linestart %.3f def\n", HSPACE + (BORDERWIDTH / 2)); X OUTPUT("/lineend %.3f inches %.3f sub def\n", WIDTH / 2.0, HSPACE); X break; X case SIDE2: X OUTPUT("/linestart %.3f inches def\n", WIDTH / 2.0); X OUTPUT("/lineend %.3f inches %.3f sub def\n", WIDTH, HSPACE); X break; X } X X OUTPUT("linestart %.3f inches %.3f add moveto\n", BODYHEIGHT, X VSPACE + BORDERWIDTH + CHARFUDGE); X X if (title == artist) { X /* if self-titled, center title vertically */ X OUTPUT("0 %.3f inches %.3f sub rmoveto\n", EDGEHEIGHT / 2.0, X VSPACE + BORDERWIDTH + (TITLESIZE / 2.0)); X } X X OUTPUT("(%s) shrinkshow\n", title); X X /* secondary title */ X OUTPUT("\n%%\tSecondary Title\n"); X OUTPUT("/%s findfont %.3f doscalefont setfont\n", TITLE2FONT, TITLE2SIZE); X X switch (position) { X case ONLY: X case SIDE1: X OUTPUT("/linestart %.3f def\n", HSPACE + (BORDERWIDTH / 2)); X OUTPUT("/lineend %.3f inches %.3f sub def\n", X (WIDTH / 2.0) - .33, HSPACE); X break; X case SIDE2: X OUTPUT("/linestart %.3f inches %.3f add def\n", WIDTH / 2.0, X HSPACE + (DASHWIDTH / 2)); X OUTPUT("/lineend %.3f inches %.3f sub def\n", WIDTH - .33, HSPACE); X break; X } X X OUTPUT("linestart %.3f inches %.3f sub moveto\n", BODYHEIGHT, X TITLE2SIZE + VSPACE + BORDERWIDTH); X OUTPUT("(%s) elipsesshow\n", title); X} X X Xoutput_ps_noise_reduction(noise_red, noise_type, position) Xchar *noise_red; Xint noise_type, position; X{ X OUTPUT("\n%%\tNoise reduction symbol\n"); X if (noise_type == NONE) { X OUTPUT("%%\t(None specified)\n"); X return; X } X X OUTPUT("/%s findfont %.3f doscalefont setfont\n", X NOISEFONT, NOISESIZE); X if ((position == ONLY) || (position == SIDE1)) { X OUTPUT("%.3f inches %.3f sub %.3f inches %.3f sub moveto\n", X WIDTH / 2.0, X HSPACE + (DASHWIDTH / 2), BODYHEIGHT, X TITLE2SIZE + VSPACE + BORDERWIDTH); X } else /* SIDE2 */ { X OUTPUT("%.3f inches %.3f sub %.3f inches %.3f sub moveto\n", X WIDTH, X HSPACE + (BORDERWIDTH / 2), BODYHEIGHT, X TITLE2SIZE + VSPACE + BORDERWIDTH); X } X X switch (noise_type) { X case DOLBY_B: X OUTPUT("dolby\n"); X return; X case DOLBY_C: X OUTPUT("( C) stringwidth pop -1 mul 0 rmoveto dolby ( C) show\n"); X return; X /* case DBX: */ X } X X /* other type of noise reduction */ X OUTPUT("(%s) stringwidth pop -1 mul 0 rmoveto\n", noise_red); X OUTPUT("(%s) show\n", noise_red); X} X X Xoutput_ps_songs(songs, number_songs, position) Xchar **songs; Xint number_songs, position; X{ X register int index; X X OUTPUT("\n%%\tSong list\n"); X OUTPUT("/%s findfont %.3f doscalefont setfont\n", SONGFONT, SONGSIZE); X X if ((position == ONLY) || (position == SIDE1)) { X OUTPUT("/linestart %.3f def\n", HSPACE + (BORDERWIDTH / 2)); X OUTPUT("/lineend %.3f inches %.3f sub def\n", X WIDTH / 2.0, HSPACE + (DASHWIDTH / 2)); X } else /* SIDE2 */ { X OUTPUT("/linestart %.3f inches %.3f add def\n", X WIDTH / 2.0, HSPACE + (DASHWIDTH / 2)); X OUTPUT("/lineend %.3f inches %.3f sub def\n", X WIDTH, HSPACE + (BORDERWIDTH / 2)); X } X X /* starting position */ X OUTPUT("\nlinestart %.3f inches %.3f sub moveto\n", BODYHEIGHT, X TITLE2SIZE + SONGSIZE + (VSPACE * 3) X + BORDERWIDTH + DASHWIDTH); X X /* array of song titles */ X OUTPUT("[\n"); X for (index = 0; songs[index] != NULL; index++) { X if (number_songs) X OUTPUT(" (%d. %s)\n", index + 1, songs[index]); X else X OUTPUT(" (%s)\n", songs[index]); X } X OUTPUT("] { dosong } forall\n"); X} SHAR_EOF if test 5556 -ne "`wc -c < 'output_ps.c'`" then echo shar: "error transmitting 'output_ps.c'" '(should have been 5556 characters)' fi fi echo shar: "extracting 'overhead_ps.c'" '(6924 characters)' if test -f 'overhead_ps.c' then echo shar: "will not over-write existing file 'overhead_ps.c'" else sed 's/^X//' << \SHAR_EOF > 'overhead_ps.c' X/* X * Copyright (C) 1987, Thomas H. Smith -- San Francisco, California X * Program 'Cassette': X * Permission is granted to any individual or institution X * to use, copy, modify, or redistribute this software so long as it X * is not sold for profit and provided this copyright notice is retained. X * X * PostScript is a registered trademark of Adobe Systems, Inc. X * The name 'Dolby' and the Dolby symbol are trademarks X * of Dolby Industries, Inc. X */ X#include <stdio.h> X#include "dimensions.h" X#include "cassette.h" X X Xoutput_ps_globals() X{ X /* global definitions */ X OUTPUT("%%\tglobals\n"); X OUTPUT("/inches { 72 mul } def\n"); X OUTPUT("/currentx { currentpoint pop } def\n"); X OUTPUT("/currenty { currentpoint exch pop } def\n"); X OUTPUT("/lowerdone { false } def\n"); X OUTPUT("/doscalefont {\n dup dup /maxfontsize exch def\n"); X OUTPUT(" /fontsize exch def scalefont\n} def\n"); X OUTPUT("/adjustfont {\n dup /fontsize exch fontsize mul def\n"); X OUTPUT(" scalefont\n} def\n"); X OUTPUT("/interline { fontsize 1.33 mul } def\n"); X OUTPUT("/creturn { linestart currenty interline sub moveto } def\n"); X X OUTPUT("/overflowsline {"); X OUTPUT(" stringwidth pop currentx add lineend ge } def\n"); X OUTPUT("/indent { %.3f inches 0 rmoveto } def\n", CONTINUEDIST); X OUTPUT("/breakline {\n {\n ( ) search exch\n"); X OUTPUT(" dup overflowsline {\n creturn pageoverflow indent\n"); X OUTPUT(" } if show\n {\t%% test of search\n show\n"); X OUTPUT(" } { exit } ifelse\n } loop\n} def\n"); X X OUTPUT("/shrinkshow {\n {\n dup overflowsline {\n"); X OUTPUT(" currentfont .9 adjustfont setfont\n"); X OUTPUT(" fontsize maxfontsize 2 div 1 add le {\n"); X OUTPUT(" /oldindent /indent load def /indent { } def\n"); X OUTPUT(" 0 fontsize rmoveto breakline\n"); X OUTPUT(" /indent /oldindent load def\n"); X OUTPUT(" exit\n } if\n"); X OUTPUT(" } {\n linestart currenty moveto\n"); X OUTPUT(" show exit\n } ifelse\n } loop\n} def\n"); X X OUTPUT("/elipsesshow {\n dup overflowsline {\n"); X OUTPUT(" {\n ( ) search exch dup overflowsline {\n"); X OUTPUT(" (...) show pop { pop } if pop exit\n"); X OUTPUT(" } {\n show\n } ifelse\n"); X OUTPUT(" {\t%%test of search\n show\n"); X OUTPUT(" } { exit } ifelse\n } loop\n"); X OUTPUT(" } { show } ifelse\n} def\n"); X X OUTPUT("/pageoverflow {\n currenty %.3f le lowerdone not and {\n", X VSPACE + BORDERWIDTH); X OUTPUT(" dolowerblock linestart -%.3f moveto\n } if\n} def\n", X SONGSIZE + VSPACE + BORDERWIDTH); X X OUTPUT("/dosong {\n pageoverflow\n"); X OUTPUT(" dup overflowsline {\n breakline\n"); X OUTPUT(" } {\n show\n } ifelse\n creturn\n"); X OUTPUT("} def\n"); X X /* extra lower outline if necessary */ X OUTPUT("%%\textra lower block outline\n"); X OUTPUT("/dolowerblock {\n"); X OUTPUT(" gsave newpath [] 0 setdash 0 0 moveto\n"); X OUTPUT(" 0 -%.3f inches lineto\n", BODYHEIGHT); X OUTPUT(" %.3f inches -%.3f inches lineto\n", WIDTH, BODYHEIGHT); X OUTPUT(" %.3f inches 0 lineto\n", WIDTH); X X OUTPUT(" %.3f setlinewidth stroke\n", BORDERWIDTH); X OUTPUT(" 0 0 moveto %.3f inches 0 lineto\n", WIDTH); X OUTPUT(" %.3f setlinewidth stroke\n", (BORDERWIDTH * 2)); X X OUTPUT(" %.3f inches -%.3f inches %.3f add moveto\n", WIDTH / 2.0, X BODYHEIGHT, VSPACE + BORDERWIDTH); X OUTPUT(" %.3f inches -%.3f lineto\n", WIDTH / 2.0, X VSPACE + (BORDERWIDTH / 2)); X OUTPUT(" [.3 1] 0 setdash %.3f setlinewidth stroke\n", DASHWIDTH); X OUTPUT(" /lowerdone { true } def\n"); X OUTPUT(" grestore\n} def\n"); X X output_ps_dolby(); X} X X Xoutput_ps_outline() X{ X OUTPUT("\n%%\toutline of label\n"); X X /* body of label */ X OUTPUT("newpath\n"); X OUTPUT("0 0 moveto\n"); X OUTPUT("0 %.3f inches lineto\n", BODYHEIGHT + EDGEHEIGHT); X OUTPUT("%.3f inches %.3f inches lineto\n", X WIDTH, BODYHEIGHT + EDGEHEIGHT); X OUTPUT("%.3f inches 0 lineto\n", WIDTH); X OUTPUT("closepath %.3f setlinewidth stroke\n", BORDERWIDTH); X X /* edge of label */ X OUTPUT("newpath\n"); X OUTPUT("0 %.3f inches moveto\n", BODYHEIGHT); X OUTPUT("%.3f inches %.3f inches lineto\n", WIDTH, BODYHEIGHT); X OUTPUT("0 %.3f inches moveto\n", BODYHEIGHT + EDGEHEIGHT); X OUTPUT("%.3f inches %.3f inches lineto\n", X WIDTH, BODYHEIGHT + EDGEHEIGHT); X OUTPUT("%.3f setlinewidth stroke\n", BORDERWIDTH * 2); X X /* overhang of label */ X OUTPUT("newpath\n"); X OUTPUT("0 %.3f inches moveto\n", BODYHEIGHT + EDGEHEIGHT); X OUTPUT("0 %.3f inches rlineto %.3f inches 0 rlineto\n", TABSHORTHEIGHT, X ((WIDTH - TABWIDTH) / 2.0) - TABDELTA); X OUTPUT("%.3f inches %.3f inches rlineto\n", TABDELTA, TABDELTA); X OUTPUT("%.3f inches 0 rlineto\n", TABWIDTH); X OUTPUT("%.3f inches -%.3f inches rlineto\n", TABDELTA, TABDELTA); X OUTPUT("%.3f inches %.3f inches lineto\n", X WIDTH, BODYHEIGHT + EDGEHEIGHT + TABSHORTHEIGHT); X OUTPUT("0 -%.3f inches rlineto\n", TABSHORTHEIGHT); X OUTPUT("%.3f setlinewidth stroke\n", BORDERWIDTH); X X /* dashed interior lines */ X OUTPUT("\n%%\tdashed interior lines\n"); X X OUTPUT("newpath\n"); X OUTPUT("0 %.3f inches %.3f sub moveto\n", BODYHEIGHT, X TITLE2SIZE + (VSPACE * 2) + BORDERWIDTH); X OUTPUT("%.3f inches %.3f inches %.3f sub lineto\n", WIDTH, BODYHEIGHT, X TITLE2SIZE + (VSPACE * 2) + BORDERWIDTH); X X OUTPUT("%.3f inches %.3f inches %.3f sub moveto\n", WIDTH / 2.0, X BODYHEIGHT, VSPACE + BORDERWIDTH); X OUTPUT("%.3f inches %.3f lineto\n", WIDTH / 2.0, X VSPACE + (BORDERWIDTH / 2)); X X OUTPUT("[.3 1] 0 setdash %.3f setlinewidth stroke\n", DASHWIDTH); X} X X Xoutput_ps_trailer() X{ X OUTPUT("showpage\n"); X} X X Xstatic Xoutput_ps_dolby() X{ X OUTPUT("%%\t\tDolby trademark symbol\n"); X OUTPUT("%%\t\t\tThe name Dolby and this symbol\n"); X OUTPUT("%%\t\t\tare trademarks of Dolby Industries, Inc.\n"); X OUTPUT("/dolby {\n"); X OUTPUT(" gsave -%.3f 0 rmoveto currentpoint newpath\n", DOLBY_WIDTH); X OUTPUT(" %.3f add %.3f -90 90 arc\n", DOLBY_RADIUS, DOLBY_RADIUS); X OUTPUT(" currentx %.3f add currenty %.3f sub %.3f 90 -90 arc\n", X DOLBY_WIDTH, DOLBY_RADIUS, DOLBY_RADIUS); X OUTPUT(" -%.3f 0 rmoveto\n", DOLBY_WIDTH); X OUTPUT(" 0 setgray currentpoint fill moveto\n"); X X /* line around it */ X OUTPUT(" 0 %.3f rlineto %.3f 0 rlineto\n", X DOLBY_HEIGHT, DOLBY_WIDTH); X OUTPUT(" 0 -%.3f rlineto -%.3f 0 rlineto\n", X DOLBY_HEIGHT, DOLBY_WIDTH); X OUTPUT(" [] 0 setdash 0 setlinewidth currentpoint stroke moveto\n"); X X /* line through center */ X OUTPUT(" %.3f 0 rmoveto 0 %.3f rlineto\n", X DOLBY_WIDTH / 2.0, DOLBY_HEIGHT); X OUTPUT(" 1 setgray stroke\n"); X OUTPUT(" grestore\n} def\n"); X} SHAR_EOF if test 6924 -ne "`wc -c < 'overhead_ps.c'`" then echo shar: "error transmitting 'overhead_ps.c'" '(should have been 6924 characters)' fi fi echo shar: "extracting 'cassette.h'" '(669 characters)' if test -f 'cassette.h' then echo shar: "will not over-write existing file 'cassette.h'" else sed 's/^X//' << \SHAR_EOF > 'cassette.h' X/* X * Copyright (C) 1987, Thomas H. Smith -- San Francisco, California X * Program 'Cassette': X * Permission is granted to any individual or institution X * to use, copy, modify, or redistribute this software so long as it X * is not sold for profit and provided this copyright notice is retained. X * X * PostScript is a registered trademark of Adobe Systems, Inc. X */ X X#define TRUE (1) X#define FALSE (0) X X/* cassette sides */ X#define ONLY 0 X#define SIDE1 1 X#define SIDE2 2 X X/* recognized noise reduction types */ X#define NONE 0 X#define DOLBY_B 1 X#define DOLBY_C 2 X#define DBX 3 X#define OTHER 4 X X#define OUTPUT (void) printf X#define EMPTYSTRING(str) (str[0] == '\0') SHAR_EOF if test 669 -ne "`wc -c < 'cassette.h'`" then echo shar: "error transmitting 'cassette.h'" '(should have been 669 characters)' fi fi echo shar: "extracting 'dimensions.h'" '(1774 characters)' if test -f 'dimensions.h' then echo shar: "will not over-write existing file 'dimensions.h'" else sed 's/^X//' << \SHAR_EOF > 'dimensions.h' X/* X * Copyright (C) 1987, Thomas H. Smith -- San Francisco, California X * Program 'Cassette': X * Permission is granted to any individual or institution X * to use, copy, modify, or redistribute this software so long as it X * is not sold for profit and provided this copyright notice is retained. X * X * PostScript is a registered trademark of Adobe Systems, Inc. X */ X X/* dimension tweaks dimensions in points */ X#define VSPACE 4.0 /* vertical whitespace border */ X#define HSPACE 6.0 /* horizontal whitespace border */ X#define BORDERWIDTH 2.0 /* width of outline border */ X#define DASHWIDTH 0.25 /* width of interior dashed lines */ X#define CHARFUDGE 1.0 /* fudge for vertically centering text */ X X/* dimensions of dolby symbol */ X#define DOLBY_HEIGHT 5.0 X#define DOLBY_WIDTH (DOLBY_HEIGHT+1.0) X#define DOLBY_RADIUS (DOLBY_HEIGHT / 2.0) X X/* font used for album title */ X#define TITLEFONT "Helvetica-Bold" X#define TITLESIZE 10.0 X X/* font used for secondary album title */ X#define TITLE2FONT "Times-Italic" X#define TITLE2SIZE 9.0 X X/* font used for album artist */ X#define ARTISTFONT "Helvetica" X#define ARTISTSIZE 10.0 X X/* font used for noise reduction */ X#define NOISEFONT "Helvetica" X#define NOISESIZE 5.0 X X/* font used for song list */ X#define SONGFONT "Times-Roman" X#define SONGSIZE 8.0 X X/* dimensions of cassette label in inches */ X#define EDGEHEIGHT 0.5 /* height of label edge */ X#define BODYHEIGHT 2.5 /* height of label body */ X#define WIDTH 4.0 /* width of entire label */ X X#define CONTINUEDIST 0.75 /* indent for long song name continuation */ X X/* width of overhang tab */ X#define TABWIDTH (WIDTH - (TABDELTA * 2.0)) X#define TABSHORTHEIGHT 0.25 /* height of short portion of overhang tab */ X#define TABDELTA 0.25 /* delta between short and tall tab portions */ SHAR_EOF if test 1774 -ne "`wc -c < 'dimensions.h'`" then echo shar: "error transmitting 'dimensions.h'" '(should have been 1774 characters)' fi fi echo shar: "extracting 'Makefile'" '(1028 characters)' if test -f 'Makefile' then echo shar: "will not over-write existing file 'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' XCFLAGS = -O XLDFLAGS = -s X XCASSETTE = cassette XPRINTLABELS = printlabels XINSTALLDIR = /usr/loc XMANDIR = /usr/man/man1 XSHARFILE = cassette.shar X XCFILES = input_file.c cassette.c output_ps.c overhead_ps.c XOFILES = input_file.o cassette.o output_ps.o overhead_ps.o XHFILES = cassette.h dimensions.h XMISCFILES = Makefile README cassette.1 \ X album1.sample album2.sample double.sample X XINSTALLFILES = $(INSTALLDIR)/$(CASSETTE) \ X $(INSTALLDIR)/$(PRINTLABELS) \ X $(MANDIR)/cassette.1 X X$(CASSETTE): $(OFILES) X cc $(CFLAGS) $(LDFLAGS) -o $@ $(OFILES) X Xinstall: $(INSTALLFILES) X X$(INSTALLDIR)/$(CASSETTE): $(CASSETTE) X cp $(CASSETTE) $@ X chmod 755 $@ X X$(INSTALLDIR)/$(PRINTLABELS): $(PRINTLABELS) X cp $(PRINTLABELS) $@ X chmod 755 $@ X X$(MANDIR)/cassette.1: cassette.1 X cp cassette.1 $@ X chmod 644 $@ X X$(SHARFILE): $(CFILES) $(HFILES) $(MISCFILES) X shar $(CFILES) $(HFILES) $(MISCFILES) > $@ X Xlint: $(CFILES) X lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) X Xclean: X /bin/rm -f $(OFILES) $(CASSETTE) $(SHARFILE) X Xtags: $(CFILES) X ctags $(CFILES) SHAR_EOF if test 1028 -ne "`wc -c < 'Makefile'`" then echo shar: "error transmitting 'Makefile'" '(should have been 1028 characters)' fi fi echo shar: "extracting 'README'" '(3893 characters)' if test -f 'README' then echo shar: "will not over-write existing file 'README'" else sed 's/^X//' << \SHAR_EOF > 'README' XCassette label formatting programs: X Build these with X % make X and install with X % make install X X Dimensions, fonts, and other tweakable parameters are in dimensions.h. X This was developed under UNIX 4.2 but ought to port to System V and X other flavors easily. Possible porting considerations are: X bcopy() -- memcpy() (or something) in System V. X fgets() -- reads line up to AND INCLUDING newline. X perror() -- prints diagnostic error message for system calls. X X Happy listening! X XCassette: X Cassette takes as input files describing the title, artist, and songs X on the sides of a cassette tape, and sends a PostScript(TM) description X of a cassette label suitable for sending to a high-resolution printer X (such as a laserprinter) to the standard output. The resulting label X may be inserted into a standard-issue cassette tape case. X X The input file format is the following: X One file for each album (collection of artist, title, and songs). X The first line of each file is the artist, the second is the title, X the third is the noise reduction scheme used, and the songs are X listed one-per-line thereafter. X X An empty title line signifies a self-titled album. X An empty noise-reduction line indicates no noise reduction used. X An empty song line divides songs on the first side of the tape X from those on the second side (a la two-record set). X X Leading and trailing white space on any line is not significant. X X The cassette program copes with: X 1) Extra-long artist, title, and song names. X 2) Recognizing Dolby(TM) B and C (and outputting the Dolby symbol). X 3) Long song list -- outputs an extended label outline. X 4) Self-titled albums X 5) One side of a tape unused. X And much, much more. X X Syntax: X cassette [-n] <album1 file> [<album2 file>] X X The '-n' option triggers numbering of the songs. X XPrintlabels: X Printlabels is a simplistic bourne-shell script that takes the output X of cassette (above) and surrounds it with PostScript(TM) commands to X orient the output for more efficient printing on an 8 1/2 by 11 page. X The output of Printlabels is sent to the standard output. X Four non-extended labels or two extended ones can fit on a page, and X page-feeds are inserted every four labels automatically. X X Syntax: X printlabels [-a] [-m] <label file> [<label file>...] X X The '-a' option places the labels adjacent to one another X for easier paper cutting. X X The '-m' option enables manual feeding of the printer (for X thick paper and such). X XKnown Bugs: X On a single tape side, titles and artists longer than about X 80 characters or songlists longer than about 20 songs overflow X the available room. X X The manual-feed option to 'printlabels' might only work on the X Apple Laserwriter Plus(TM). X X If an album has a long song list that requires an extended area to X hold it, the label must be printed with 'printlabels', or the X label definition must be offset into the page. X X 'Printlabels' automatically fits four labels to a page even if the X labels have an extension area (and thus won't fit). X X The '-a' and '-m' flags may not be reversed in order on the command line. X X XExample: X % cassette -n album1.sample album2.sample > label1.ps X % cassette -n double.sample > label2.ps X % printlabels -a -m label1.ps label2.ps | lpr -Plaser X X XBug reports/fixes or enhancements may be sent to me (Tom Smith) at X {hplabs, ucbvax!sun!sunncal}!analog!smith X X XCopyright (C) 1987, Thomas H. Smith -- San Francisco, California X Permission is granted to any individual or institution X to use, copy, modify, or redistribute this software so long as it X is not sold for profit and provided this copyright notice is retained. X X PostScript is a registered trademark of Adobe Systems, Inc. X The name 'Dolby' and the Dolby symbol are trademarks X of Dolby Industries, Inc. SHAR_EOF if test 3893 -ne "`wc -c < 'README'`" then echo shar: "error transmitting 'README'" '(should have been 3893 characters)' fi fi echo shar: "extracting 'cassette.1'" '(3398 characters)' if test -f 'cassette.1' then echo shar: "will not over-write existing file 'cassette.1'" else sed 's/^X//' << \SHAR_EOF > 'cassette.1' X.\" @(#)cassette.1 ths 87/10/1; X.TH CASSETTE 1 "1 October 1987" X.SH NAME Xcassette, printlabels \- postscript formatter for cassette labels X.SH SYNOPSIS X.B cassette X[ X.B \-n X] albumfile1 [ albumfile2 ] X.br X.B printlabels X[ X.B \-a X] [ X.B \-m X] labelfile [ labelfile \fB.\|.\|.\fP ] X.\" X.\" ************************************** X.\" X.SH DESCRIPTION X.I Cassette Xtakes as input files describing the title, artist, and songs Xon the sides of a cassette tape, and sends a PostScript(TM) description Xof a cassette label suitable for sending to a high-resolution printer X(such as a laserprinter) to the standard output. The resulting label Xmay be inserted into a standard-issue cassette tape case. X.HP 5 XInput file format: X.br XOne file for each album (collection of artist, title, and songs). X.sp XThe first line of each file is the artist, the second is the title, Xthe third is the noise reduction scheme used, and the songs are Xlisted one-per-line thereafter. X.sp XAn empty title line signifies a self-titled album. X.sp XAn empty noise-reduction line indicates no noise reduction used. X.sp XAn empty song line divides songs on the first side of the tape Xfrom those on the second side (a la two-record set). X.sp XLeading and trailing white space on any line is not significant. X.HP 5 X.I Cassette Xcopes with: X.br XExtra-long artist, title, and song names. X.sp XRecognizing Dolby(TM) B and C (and outputting the Dolby symbol). X.sp XLong song list -- outputs an extended label outline. X.sp XSelf-titled albums X.sp XOne side of a tape unused. X.sp XAnd much, much more. X.LP X.I Printlabels Xis a simplistic bourne-shell script that takes the output Xof X.I cassette Xand surrounds it with PostScript(TM) commands to Xorient the output for more efficient printing on an 8 1/2 by 11 page. XThe output of Printlabels is sent to the standard output. XFour non-extended labels or two extended ones can fit on a page, and Xpage-feeds are inserted every four labels automatically. X.\" X.\" ************************************** X.\" X.SH OPTIONS X.TP X.B \-n X.I cassette: Xtriggers numbering of the songs. X.TP X.B \-a X.I printlabels: Xplaces the labels adjacent to one another Xfor easier paper cutting. X.TP X.B \-m X.I printlabels: Xenables manual feeding of the printer (for Xthick paper and such). X.\" X.\" ************************************** X.\" X.SH EXAMPLES X% cassette -n album1.sample album2.sample > label1.ps X.br X% cassette -n double.sample > label2.ps X.br X% printlabels -a -m label1.ps label2.ps | lpr -Plaser X.br X.\" X.\" ************************************** X.\" X.SH BUGS XOn a single tape side, titles and artists longer than about X80 characters or songlists longer than about 20 songs overflow Xthe available room. X.LP XThe manual-feed option to X.I printlabels Xmight only work on the XApple Laserwriter Plus(TM). X.LP XIf an album has a long song list that requires an extended area to Xhold it, the label must be printed with X.I printlabels, Xor the Xlabel definition must be offset into the page. X.LP X.I Printlabels Xautomatically fits four labels to a page even if the Xlabels have an extension area (and thus won't fit). X.LP XThe '-a' and '-m' flags to X.I printlabels Xmay not be reversed in order on the command line. X.\" X.\" ************************************** X.\" X.SH ACKNOWLEDGEMENTS X.I PostScript Xis a registered trademark of Adobe Systems, Inc. X.br XThe name X.I Dolby Xand the Dolby symbol are trademarks of Dolby Industries, Inc. SHAR_EOF if test 3398 -ne "`wc -c < 'cassette.1'`" then echo shar: "error transmitting 'cassette.1'" '(should have been 3398 characters)' fi fi echo shar: "extracting 'album1.sample'" '(289 characters)' if test -f 'album1.sample' then echo shar: "will not over-write existing file 'album1.sample'" else sed 's/^X//' << \SHAR_EOF > 'album1.sample' XEverything But the Girl XBaby, The Stars Shine Bright XDolby C X Come On Home X Don't Leave Me Behind X A Country Mile X Cross My Heart X Don't Let the Teardrops Rust Your Shining Heart X Careless X Sugar Finneyy X Come Hell or High Water X Fighting Talk X Little Hitler SHAR_EOF if test 289 -ne "`wc -c < 'album1.sample'`" then echo shar: "error transmitting 'album1.sample'" '(should have been 289 characters)' fi fi echo shar: "extracting 'album2.sample'" '(200 characters)' if test -f 'album2.sample' then echo shar: "will not over-write existing file 'album2.sample'" else sed 's/^X//' << \SHAR_EOF > 'album2.sample' XHappy Hour X XDolby X Happy Hour X When I Say (No Giveaway) X Sunshine in the Shade X These Days X Too Late Now X Cheque in the Post X Precious Time X Sitting on a Fence X Opportunity SHAR_EOF if test 200 -ne "`wc -c < 'album2.sample'`" then echo shar: "error transmitting 'album2.sample'" '(should have been 200 characters)' fi fi echo shar: "extracting 'double.sample'" '(366 characters)' if test -f 'double.sample' then echo shar: "will not over-write existing file 'double.sample'" else sed 's/^X//' << \SHAR_EOF > 'double.sample' XLittle Feat XWaiting For Columbus XDolby C X Join the Band X Fat Man in the Bathtub X All That You Dream X Oh Atlanta X Old Folks' Boogie X Time Loves a Hero X Day or Night X Mercenary Territory X Spanish Moon X X Dixie Chicken X Tripe Face Boogie X Rocket in My Pocket X Willin' X Don't Bogart That Joint X A Apolitical Blues X Sailin' Shoes X Feats Don't Fail Me Now SHAR_EOF if test 366 -ne "`wc -c < 'double.sample'`" then echo shar: "error transmitting 'double.sample'" '(should have been 366 characters)' fi fi exit 0 # End of shell archive