1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)railmag.c	5.1 (Berkeley) 5/15/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * tell vcat which fonts are loaded on the "typesetter"
  13:  */
  14: 
  15: #define MAGIC_NUMBER 0436
  16: #define RAILMAG_FILE "/usr/lib/vfont/railmag"
  17: 
  18: char    *concat();
  19: int rmfd;
  20: char    *rm[4];
  21: char    tbuf[256];
  22: 
  23: main(argc, argv)
  24:     int argc;
  25:     char *argv[];
  26: {
  27:     register int fnum;
  28:     char cbuf[4][50];
  29: 
  30:     readrm();
  31:     if (argc <= 1) {
  32:         printrm();
  33:         exit(0);
  34:     }
  35:     while (--argc) {
  36:         argv++;
  37:         fnum = argv[0][0] - '0';
  38:         if (fnum < 1 || fnum > 4)
  39:             error("Invalid font number");
  40:         checkfont(argv[1]);
  41:         if (argv[1][0] == '/')
  42:             rm[fnum-1] = argv[1];
  43:         else
  44:             rm[fnum-1] = concat(cbuf[fnum-1], "/usr/lib/vfont/", argv[1]);
  45:         argv++; argc--;
  46:     }
  47:     writerm();
  48: }
  49: 
  50: error(str)
  51:     char *str;
  52: {
  53:     write(2, "Railmag: ", 9);
  54:     write(2, str, strlen(str));
  55:     write(2, "\n", 1);
  56:     exit();
  57: }
  58: 
  59: checkfont(file)
  60:     char *file;
  61: {
  62:     register int fd;
  63:     char cbuf[80];
  64:     char cbuf2[80];
  65:     short word;
  66: 
  67:     if ((fd = open(concat(cbuf, file, ".10"), 0)) < 0)
  68:         if ((fd = open(concat(cbuf2, "/usr/lib/vfont/", cbuf), 0)) < 0)
  69:             error("cant open font");
  70:     if (read(fd, &word, 2) != 2)
  71:         error("cant read font");
  72:     if (word != MAGIC_NUMBER)
  73:         error("font has no magic number");
  74:     close(fd);
  75: }
  76: 
  77: readrm()
  78: {
  79:     register int i;
  80:     register char *cp;
  81:     char c;
  82: 
  83:     if ((rmfd = open(RAILMAG_FILE, 0)) < 0)
  84:         error("No railmag file");
  85:     cp = tbuf;
  86:     for (i = 0; i < 4; i++) {
  87:         rm[i] = cp;
  88:         while (read(rmfd, &c, 1) == 1 && c != '\n')
  89:             *cp++ = c;
  90:         *cp++ = '\0';
  91:     }
  92: }
  93: 
  94: printrm()
  95: {
  96:     register int i;
  97: 
  98:     for (i = 0; i < 4; i++)
  99:         printf("%s on %d\n", rm[i], i+1);
 100: }
 101: 
 102: writerm()
 103: {
 104:     register int i;
 105:     register char *cp;
 106: 
 107:     unlink(RAILMAG_FILE);
 108:     if ((rmfd = creat(RAILMAG_FILE, 0644)) < 0)
 109:         error("cant recreate railmag file");
 110:     for (i = 0; i < 4; i++) {
 111:         cp = rm[i];
 112:         while (*cp != '\0')
 113:             write(rmfd, cp++, 1);
 114:         write(rmfd, "\n", 1);
 115:     }
 116: }
 117: 
 118: char *
 119: concat(outbuf, in1, in2)
 120:     register char *outbuf, *in1, *in2;
 121: {
 122:     char *save;
 123: 
 124:     save = outbuf;
 125:     while (*in1)
 126:         *outbuf++ = *in1++;
 127:     while (*in2)
 128:         *outbuf++ = *in2++;
 129:     return(save);
 130: }

Defined functions

checkfont defined in line 59; used 1 times
  • in line 40
concat defined in line 118; used 76 times
error defined in line 50; used 6 times
main defined in line 23; never used
printrm defined in line 94; used 1 times
  • in line 32
readrm defined in line 77; used 1 times
  • in line 30
writerm defined in line 102; used 1 times
  • in line 47

Defined variables

rm defined in line 20; used 5 times
rmfd defined in line 19; used 5 times
sccsid defined in line 8; never used
tbuf defined in line 21; used 1 times
  • in line 85

Defined macros

MAGIC_NUMBER defined in line 15; used 1 times
  • in line 72
RAILMAG_FILE defined in line 16; used 3 times
Last modified: 1985-05-15
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1278
Valid CSS Valid XHTML 1.0 Strict