static int newmember(char * s) { char * t; s += 5; s += strspn(s, " "); t = strpbrk(s, " "); return loadname(s, t ? t - s : strlen(s)); }
int main(int argc, char ** argv) { char * fn; int ix; if (3 > argc) return fprintf(stderr, "Specify library file name and copy file name(s).\n"), 1; if (openout(argv[1])) return 16; if (getdir(cards * 80)) return 20; for (ix = 2; argv[ix]; ix++) { char * dot; char * slash; char * name; int namelen; int ismacro = 1; /* Assume file is macro */ char * s; fn = argv[ix]; f = fopen(fn, "r"); if (!f) return fprintf(stderr, "Cannot open %s: %s\n", fn, strerror(errno)), 16; slash = strrchr(fn, '/'); name = slash ? slash + 1 : fn; namelen = strlen(name); dot = strrchr(name, '.'); if (dot) { namelen = dot - name; if (!strcmp(dot + 1, "copy")) ismacro = 0; } s = gline(); if (!s) continue; if (!ismacro && memcmp(s, "*COPY ", 6)) ismacro = 1; /* Not stacked copy */ if (ismacro) { loadname(name, namelen); if (doline(line)) return 20; } else if (newmember(s)) return 20; for (;;) { s = gline(); if (!s) break; if (!ismacro && !memcmp(s, "*COPY ", 6)) { if (eom()) return 20; if (newmember(s)) return 20; continue; } if (doline(line)) return 20; } if (eom()) return 20; } if (wrapup(dirs, dir)) return 16; printf("%s %d files %d members.\n", fno, ix - 2, members); return 0; }
main() { float ship[XY]; long org[XY]; long size[XY]; Device dev; short val; Device mdev[XY]; short mval[XY]; long nhits; short buffer[BUFSIZE]; Boolean run; prefsize(400, 400); winopen("select1"); getorigin(&org[X], &org[Y]); getsize(&size[X], &size[Y]); mmode(MVIEWING); ortho2(-0.5, size[X] - 0.5, -0.5, size[Y] - 0.5); qdevice(LEFTMOUSE); qdevice(ESCKEY); color(BLACK); clear(); mdev[X] = MOUSEX; mdev[Y] = MOUSEY; drawplanet(); run = TRUE; while (run) { dev = qread(&val); if (val == 0) { /* on upstroke */ switch (dev) { case LEFTMOUSE: getdev(XY, mdev, mval); ship[X] = mval[X] - org[X]; ship[Y] = mval[Y] - org[Y]; color(BLUE); sbox(ship[X], ship[Y], ship[X] + SHIPWIDTH, ship[Y] + SHIPHEIGHT); /* * specify the selecting region to be a box surrounding the * rocket ship */ ortho2(ship[X], ship[X] + SHIPWIDTH, ship[Y], ship[Y] + SHIPHEIGHT); initnames(); gselect(buffer, BUFSIZE); loadname(PLANET); /* no actual drawing takes place */ drawplanet(); nhits = endselect(buffer); /* * restore the Projection matrix; NB. can't use push/popmatrix * since they only work for the ModelView matrix stack * when in MVIEWING mode */ ortho2(-0.5, size[X] - 0.5, -0.5, size[Y] - 0.5); /* * check to see if PLANET was selected; NB. nhits is NOT the * number of buffer elements written */ if (nhits < 0) { fprintf(stderr, "gselect buffer overflow\n"); run = FALSE; } else if (nhits >= 1 && buffer[0] == 1 && buffer[1] == PLANET) ringbell(); break; case ESCKEY: run = FALSE; break; } } } gexit(); return 0; }