int SFP_read_A2h(int port, oom_port_t* pptr) { int stopit; int j; char fname[18]; FILE* fp; char* retval; char inbuf[80]; stopit = 0; /* Open, read, interpret the A2/pages data file */ sprintf(fname, "./module_data/%d.pages", port); fp = fopen(fname, "r"); if (fp == NULL) { pptr->oom_class = OOM_PORT_CLASS_UNKNOWN; /* printf("module %d is not present\n", i); perror("errno:"); */ stopit = 1; } if (stopit == 0) { retval = fgets(inbuf, 80, fp); if ((retval == NULL) || (strncmp(inbuf, ";FCC SETUP", 10) != 0)) { printf("%s is not a module data file(5)\n", fname); pptr->oom_class = OOM_PORT_CLASS_UNKNOWN; stopit = 1; } } if (stopit == 0) { /* skip the next 9 lines */ for (j = 0; j < 9; j++) { retval = fgets(inbuf, 80, fp); } /* first block is A2 (lower) data */ readpage(fp, port_i2c_data[port] + 0xA2*256); /* next 32 blocks are pages 0-31 */ /* for now, just read page 0 */ for (j = 0; j < 1; j++) { stopit = readpage(fp, port_page_data[port] + j*128); } } if (stopit != 0) { /* problem somewhere in readpage() */ printf("%s is not a module data file(6z)\n", fname); pptr->oom_class = OOM_PORT_CLASS_UNKNOWN; } return(stopit); }
void threadmain(int argc, char *argv[]) { Column *c; char buf[256]; int i, ncol; rfork(RFENVG|RFNAMEG); ncol = 1; ARGBEGIN{ case 'c': ncol = atoi(EARGF(usage())); if(ncol <= 0) usage(); break; case 'm': webmountpt = EARGF(usage()); break; case 'p': procstderr++; break; case 't': charset = EARGF(usage()); break; default: usage(); break; }ARGEND snprint(buf, sizeof(buf), "%s/ctl", webmountpt); webctlfd = open(buf, ORDWR); if(webctlfd < 0) sysfatal("can't initialize webfs: %r"); snarffd = open("/dev/snarf", OREAD|OCEXEC); if(initdraw(derror, fontnames[0], "abaco") < 0) sysfatal("can't open display: %r"); memimageinit(); iconinit(); timerinit(); initfontpaths(); cexit = chancreate(sizeof(int), 0); crefresh = chancreate(sizeof(Page *), 0); if(cexit==nil || crefresh==nil) sysfatal("can't create initial channels: %r"); mousectl = initmouse(nil, screen); if(mousectl == nil) sysfatal("can't initialize mouse: %r"); mouse = mousectl; keyboardctl = initkeyboard(nil); if(keyboardctl == nil) sysfatal("can't initialize keyboard: %r"); mainpid = getpid(); plumbwebfd = plumbopen("web", OREAD|OCEXEC); if(plumbwebfd >= 0){ cplumb = chancreate(sizeof(Plumbmsg*), 0); proccreate(plumbproc, nil, STACK); } plumbsendfd = plumbopen("send", OWRITE|OCEXEC); rowinit(&row, screen->clipr); for(i=0; i<ncol; i++){ c = rowadd(&row, nil, -1); if(c==nil && i==0) error("initializing columns"); } c = row.col[row.ncol-1]; for(i=0; i<argc; i++) if(i/WPERCOL >= row.ncol) readpage(c, argv[i]); else readpage(row.col[i/WPERCOL], argv[i]); flushimage(display, 1); threadcreate(keyboardthread, nil, STACK); threadcreate(mousethread, nil, STACK); threadnotify(shutdown, 1); recvul(cexit); threadexitsall(nil); }