static char sccsid
[] = "@(#)getlesson.c 4.1 (Berkeley) %G%";
sprintf(ans
, "%s/%s/L%s", direct
, sname
, level
);
if (access(ans
, 04) == 0) /* there is a file */
for (p
=level
; *p
; p
++) /* accept: (digit|dot)*anychar */
if (*p
!= '.' && (*p
< '0' || *p
> '9') && *(p
+1) != '\0')
while (*p
!= '.' && *p
>= '0' && *p
<= '9')
sprintf(ans
, "%s/%s/L%s", direct
, sname
, level
);
if (access(ans
, 04) == 0) { /* there is a file */
printf("There is no lesson %s; trying lesson %s instead.\n\n", line
, level
);
printf("There is no lesson %s.\n", line
);
/* fgrep through lessons for one containing the string in 'level' */
sprintf(ans
,"cd %s/%s ; fgrep '%s' L?.* L??.* L???.*", direct
, sname
, level
);
execl("/bin/csh", "csh", "-cf", ans
, 0);
fprintf(stderr
, "Getlesson: can't do %s\n", ans
);
while (fgets(line
, 200, fp
) != NULL
) {
for (p
=line
; *p
!= ':'; p
++) ;
sprintf(ans
, "%s/%s/L%s", direct
, sname
, level
);
if (access(ans
, 04) == 0) { /* there is a file */
printf("Trying lesson %s.\n\n", level
);
printf("There is no lesson containing \"%s\".\n", level
);