1: #ifndef lint
   2: static char sccsid[] = "@(#)start.c	4.5	(Berkeley)	5/15/86";
   3: #endif not lint
   4: 
   5: #include "stdio.h"
   6: #include "lrnref.h"
   7: #include <sys/types.h>
   8: #ifndef DIR
   9: #include <sys/dir.h>
  10: #endif
  11: 
  12: start(lesson)
  13: char *lesson;
  14: {
  15:     struct direct dbuf;
  16:     register struct direct *ep = &dbuf; /* directory entry pointer */
  17:     int c, n;
  18:     char where [100];
  19: 
  20: #ifdef BSD4_2
  21:     DIR *dp;
  22: #define OPENDIR(s)  ((dp = opendir(s)) != NULL)
  23: #define DIRLOOP(s)  for (s = readdir(dp); s != NULL; s = readdir(dp))
  24: #define EPSTRLEN    ep->d_namlen
  25: #define CLOSEDIR    closedir(dp)
  26: #else
  27:     int f;
  28: #define OPENDIR(s)  ((f = open(s, 0)) >= 0)
  29: #define DIRLOOP(s)  while (read(f, s, sizeof *s) == sizeof *s)
  30: #define EPSTRLEN    strlen(ep->d_name)
  31: #define CLOSEDIR    close(f)
  32: #endif
  33: 
  34:     if (!OPENDIR(".")) {        /* clean up play directory */
  35:         perror("Start:  play directory");
  36:         wrapup(1);
  37:     }
  38:     DIRLOOP(ep) {
  39:         if (ep->d_ino == 0)
  40:             continue;
  41:         n = EPSTRLEN;
  42:         if (ep->d_name[n-2] == '.' && ep->d_name[n-1] == 'c')
  43:             continue;
  44:         c = ep->d_name[0];
  45:         if (c>='a' && c<= 'z')
  46:             unlink(ep->d_name);
  47:     }
  48:     CLOSEDIR;
  49:     if (ask)
  50:         return;
  51:     sprintf(where, "%s/%s/L%s", direct, sname, lesson);
  52:     if (access(where, 04)==0)   /* there is a file */
  53:         return;
  54:     perror(where);
  55:     fprintf(stderr, "Start:  no lesson %s\n",lesson);
  56:     wrapup(1);
  57: }
  58: 
  59: fcopy(new,old)
  60: char *new, *old;
  61: {
  62:     char b[BUFSIZ];
  63:     int n, fn, fo;
  64:     fn = creat(new, 0666);
  65:     fo = open(old,0);
  66:     if (fo<0) return;
  67:     if (fn<0) return;
  68:     while ( (n=read(fo, b, BUFSIZ)) > 0)
  69:         write(fn, b, n);
  70:     close(fn);
  71:     close(fo);
  72: }

Defined functions

fcopy defined in line 59; used 1 times
start defined in line 12; used 1 times

Defined variables

sccsid defined in line 2; never used

Defined macros

CLOSEDIR defined in line 31; used 1 times
  • in line 48
DIRLOOP defined in line 29; used 1 times
  • in line 38
EPSTRLEN defined in line 30; used 1 times
  • in line 41
OPENDIR defined in line 28; used 1 times
  • in line 34
Last modified: 1986-05-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3025
Valid CSS Valid XHTML 1.0 Strict