+}
+
+int main(int argc, char *argv[])
+{
+ while (!feof(stdin)) {
+ char l[100]; /* bleah */
+ if (!fgets(l, sizeof(l), stdin)) {
+ break;
+ }
+ if (strlen(l) == sizeof(l)-1) {
+ fprintf(stderr, "Long input line; possible truncation; I suck\n");
+ exit(1);
+ }
+ if (strlen(l) >= 2 && l[0] == '@' && l[1] == '@') {
+ size_t n = strcspn(l+2, "\n");
+ if (strncmp(l+2, "BEDSTEAD", n) == 0) {
+ bedstead();
+ } else if (strncmp(l+2, "ICONS", n) == 0) {
+ icons();
+ } else {
+ /* Bodily insert named file on stdout. */
+ FILE *f;
+ l[n+2]='\0';
+ if (!(f = fopen(l+2, "r"))) {
+ fprintf(stderr, "Couldn't open '%s': %s\n", l+2,
+ strerror(errno));
+ exit(1);
+ } else {
+ do {
+ char buf[2048]; /* also bleah */
+ size_t n = fread(buf, 1, sizeof(buf), f);
+ fwrite(buf, 1, n, stdout);
+ } while (!feof(f) && !ferror(f));
+ if (ferror(f)) {
+ fprintf(stderr, "Error reading '%s': %s\n", l+2,
+ strerror(errno));
+ exit(1);
+ }
+ fclose(f);
+ }
+ }
+ } else {
+ printf("%s", l);
+ }
+ }
+ return 0;