void userinit(void) { Proc *p; Segment *s; KMap *k; char **av; Page *pg; p = newproc(); p->pgrp = newpgrp(); p->egrp = smalloc(sizeof(Egrp)); p->egrp->ref = 1; p->fgrp = dupfgrp(nil); p->rgrp = newrgrp(); p->procmode = 0640; kstrdup(&eve, ""); kstrdup(&p->text, "*init*"); kstrdup(&p->user, eve); procsetup(p); /* * Kernel Stack */ p->sched.pc = (ulong)init0; p->sched.sp = (ulong)p->kstack+KSTACK-MAXSYSARG*BY2WD; /* * User Stack, pass input arguments to boot process */ s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); p->seg[SSEG] = s; pg = newpage(1, 0, USTKTOP-BY2PG); segpage(s, pg); k = kmap(pg); for(av = (char**)argbuf; *av; av++) *av += (USTKTOP - sizeof(argbuf)) - (ulong)argbuf; memmove((uchar*)VA(k) + BY2PG - sizeof(argbuf), argbuf, sizeof argbuf); kunmap(k); /* * Text */ s = newseg(SG_TEXT, UTZERO, 1); s->flushme++; p->seg[TSEG] = s; pg = newpage(1, 0, UTZERO); pg->txtflush = ~0; segpage(s, pg); k = kmap(s->map[0]->pages[0]); memmove((uchar*)VA(k), initcode, sizeof initcode); kunmap(k); ready(p); }
/* * create the first process */ void userinit(void) { Proc *p; Segment *s; KMap *k; Page *pg; /* no processes yet */ up = nil; p = newproc(); p->pgrp = newpgrp(); p->egrp = smalloc(sizeof(Egrp)); p->egrp->ref = 1; p->fgrp = dupfgrp(nil); p->rgrp = newrgrp(); p->procmode = 0640; kstrdup(&eve, ""); kstrdup(&p->text, "*init*"); kstrdup(&p->user, eve); /* * Kernel Stack */ p->sched.pc = (ulong)init0; p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD); /* * User Stack */ s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); p->seg[SSEG] = s; pg = newpage(1, 0, USTKTOP-BY2PG); segpage(s, pg); k = kmap(pg); bootargs(VA(k)); kunmap(k); /* * Text */ s = newseg(SG_TEXT, UTZERO, 1); p->seg[TSEG] = s; pg = newpage(1, 0, UTZERO); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); k = kmap(s->map[0]->pages[0]); memmove((ulong*)VA(k), initcode, sizeof initcode); kunmap(k); ready(p); }
void userinit(void) { Proc *p; Segment *s; KMap *k; Page *pg; p = newproc(); p->pgrp = newpgrp(); p->egrp = smalloc(sizeof(Egrp)); p->egrp->ref = 1; p->fgrp = dupfgrp(nil); p->rgrp = newrgrp(); p->procmode = 0640; kstrdup(&eve, ""); kstrdup(&p->text, "*init*"); kstrdup(&p->user, eve); p->fpstate = FPinit; /* * Stack * * N.B. The -12 for the stack pointer is important. * 4 bytes for gotolabel's return PC */ p->sched.pc = (ulong)init0; p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD); /* * User Stack */ s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); p->seg[SSEG] = s; pg = newpage(1, 0, USTKTOP-BY2PG); segpage(s, pg); /* * Text */ s = newseg(SG_TEXT, UTZERO, 1); s->flushme++; p->seg[TSEG] = s; pg = newpage(1, 0, UTZERO); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); k = kmap(s->map[0]->pages[0]); memmove((ulong*)VA(k), initcode, sizeof initcode); kunmap(k); ready(p); }
int service_doc(FILE *fp, FILE *toc, int page) { char temp[PATH_MAX]; FILE *wp, *no; int j; snprintf(temp, PATH_MAX, "%s/etc/service.data", getenv("FTND_ROOT")); if ((no = fopen(temp, "r")) == NULL) return page; page = newpage(fp, page); addtoc(fp, toc, 16, 0, page, (char *)"Service manager"); j = 0; fprintf(fp, "\n"); fprintf(fp, " Service Action Active\n"); fprintf(fp, " --------------- -------- ------\n"); fread(&servhdr, sizeof(servhdr), 1, no); wp = open_webdoc((char *)"service.html", (char *)"Mail Service Manager", NULL); fprintf(wp, "<A HREF=\"index.html\">Main</A>\n"); fprintf(wp, "<UL>\n"); fprintf(wp, "<TABLE width='400' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<TBODY>\n"); fprintf(wp, "<TR><TH align='left'>Service</TH><TH align='left'>Action</TH><TH align='left'>Active</TH></TR>\n"); while ((fread(&servrec, servhdr.recsize, 1, no)) == 1) { if (j == 50) { page = newpage(fp, page); fprintf(fp, "\n"); fprintf(fp, " Service Action Active\n"); fprintf(fp, " --------------- -------- ------\n"); j = 0; } fprintf(wp, "<TR><TD>%s</TD><TD>%s</TD><TD>%s</TD></TR>\n", servrec.Service, getservice(servrec.Action), getboolean(servrec.Active)); fprintf(fp, " %-15s %-8s %s\n", servrec.Service, getservice(servrec.Action), getboolean(servrec.Active)); j++; } fclose(no); return page; }
static Page* mmupdballoc(ulong va, void *mpdb) { int s; Page *page; Page *badpages, *pg; s = splhi(); /* * All page tables must be read-only. We will mark them * readwrite later when we free them and they are no * longer used as page tables. */ if(m->pdbpool == 0){ spllo(); badpages = 0; for (;;) { page = newpage(0, 0, 0); page->va = VA(kmap(page)); if(mpdb) memmove((void*)page->va, mpdb, BY2PG); else memset((void*)page->va, 0, BY2PG); if (xenpgdpin(page->va)) break; /* * XXX Plan 9 is a bit lax about putting pages on the free list when they are * still mapped (r/w) by some process's page table. From Plan 9's point * of view this is safe because the any such process will have up->newtlb set, * so the mapping will be cleared before the process is dispatched. But the Xen * hypervisor has no way of knowing this, so it refuses to pin the page for use * as a pagetable. */ if(0) print("bad pgdpin %lux va %lux copy %lux %s\n", MFN(PADDR(page->va)), va, (ulong)mpdb, up? up->text: ""); page->next = badpages; badpages = page; } while (badpages != 0) { pg = badpages; badpages = badpages->next; putpage(pg); } } else{ page = m->pdbpool; m->pdbpool = page->next; m->pdbcnt--; if (!xenpgdpin(page->va)) panic("xenpgdpin"); } splx(s); page->next = 0; return page; }
int tic_doc(FILE *fp, FILE *toc, int page) { int next; page = newpage(fp, page); addtoc(fp, toc, 10, 0, page, (char *)"Files processing"); next = tic_group_doc(fp, toc, page); next = tic_areas_doc(fp, toc, next); next = tic_hatch_doc(fp, toc, next); next = tic_magic_doc(fp, toc, next); return next; }
void writebreak() { int q; if (assylen) writeline(0, 1); q = TXTLEN; if (o_sp) { if (o_sp + line_no > q) newpage(); else if (line_no) while (o_sp) { blankline(); o_sp--; } } }
/* fdisp: display file */ void fdisp(Finfo finfo) { char p[MAXLINE]; /* start new page if needed */ if (lcount % PAGEHEIGHT != 0) newpage(); pcount = 0; /* restart page count */ while (fgets(p, MAXLINE, finfo.fp) != NULL) /* display contents */ { if (lcount % PAGEHEIGHT == 0) /* if new page starts, then */ tpcdisp(finfo.fname); /* display title and page count */ printf("%s", p); lcount++; } }
static void paged_char(wchar_t c) { if (last_char_was_newline && number) { lineno++; printf("%6u ", lineno); } putchar(c); last_char_was_newline = c == '\n'; if (paging_enabled) { chars_remaining--; if (c == '\n' || chars_remaining == 0) { chars_remaining = console_cols; lines_remaining--; } if (lines_remaining == 0) { fflush(stdout); waitprompt(); waitkey(); newpage(); } } }
/** Low-level page function to split the current full page and return * a new page. Leaves dist in curpage. Point is moved to the new page * if required. * @param buff The buffer the Point is in. * @param dist The amount to leave in the old page (usually * HALFP). Must be <= PGSIZE. * @return The new page or NULL. */ struct page *pagesplit(struct buff *buff, unsigned dist) { struct page *curpage, *newp; struct mark *btmark; int newsize; if (dist > PGSIZE) return NULL; curpage = buff->curpage; newp = newpage(curpage); if (!newp) return NULL; newsize = curpage->plen - dist; memcpy(newp->pdata, curpage->pdata + dist, newsize); curpage->plen = dist; newp->plen = newsize; foreach_global_pagemark(btmark, curpage) if (btmark->moffset >= dist) { btmark->mpage = newp; btmark->moffset -= dist; } foreach_pagemark(buff, btmark, curpage) if (btmark->moffset >= dist) { btmark->mpage = newp; btmark->moffset -= dist; } if (buff->curchar > dist) /* new page has Point in it */ makecur(buff, newp, buff->curchar - dist); return newp; }
void writeline(int adflag, int flushflag) { int j; int q; for (j = assylen - 1; j; j--) { if (assyline[j] == ' ') assylen--; else break; } q = TXTLEN; if (line_no >= q) newpage(); for (j = 0; j < assylen; j++) spit(assyline[j]); spit('\n'); assylen = 0; assyline[0] = 0; line_no++; if (flushflag==0) { strcpy(assyline, holdword); assylen = strlen(holdword); *holdword = 0; holdp = holdword; } }
void site_docs(void) { FILE *fp, *hp, *toc; char temp[PATH_MAX], temp1[PATH_MAX]; int page = 0, line = 0; if (config_read() == -1) return; snprintf(temp, PATH_MAX, "%s/share/doc/site.doc", getenv("FTND_ROOT")); mkdirs(temp, 0755); if ((fp = fopen(temp, "w")) == NULL) return; snprintf(temp1, PATH_MAX, "%s/tmp/toc.tmp", getenv("FTND_ROOT")); if ((toc = fopen(temp1, "w+")) == NULL) { fclose(fp); return; } clr_index(); working(1, 0, 0); IsDoing("Making Sitedocs"); Syslog('+', "Start creating sitedocs"); set_color(WHITE, BLACK); ftnd_mvprintw( 5, 6, "21. CREATING SITEDOCS"); set_color(CYAN, BLACK); ftnd_mvprintw( 7,11, (char *)"Erasing directory %s/share/doc/html", getenv("FTND_ROOT")); fflush(stdout); snprintf(temp, PATH_MAX, "-r -f %s/share/doc/html", getenv("FTND_ROOT")); execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null"); if ((hp = open_webdoc((char *)"index.html", (char *)"BBS Site Documentation", NULL))) { fprintf(hp, "<UL>\n"); fprintf(hp, " <LI><A HREF=\"global.html\">Global Configuration</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"fidonet.html\">Fido Networks</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"archivers.html\">Archivers</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"virscan.html\">Virus Scanners</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"modem.html\">Modem Types</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"ttyinfo.html\">TTY Lines Info</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"nodes.html\">Fidonet Nodes</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"limits.html\">Security Limits</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"language.html\">Language Setup</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"menus.html\">BBS Menus</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"fileareas.html\">File Areas</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"protocol.html\">Transfer Protocols</A></LI>\n"); fprintf(hp, " <LI>BBS: <A HREF=\"oneliners.html\">Oneliners</A></LI>\n"); fprintf(hp, " <LI>Mail: <A HREF=\"msggroup.html\">Echomail Groups</A></LI>\n"); fprintf(hp, " <LI>Mail: <A HREF=\"msgareas.html\">Echomail Areas</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"filegroup.html\">FileEcho Groups</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"ticareas.html\">Fileecho Areas</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"hatch.html\">Hatch Manager</A></LI>\n"); fprintf(hp, " <LI>TIC: <A HREF=\"magic.html\">Magic Files</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"newgroup.html\">Newfiles Groups</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"newfiles.html\">Newfiles Reports</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"filefind.html\">Filefind Setup</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"users.html\">BBS Users</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"service.html\">Mail Service Manager</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"domain.html\">Domain translation</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"task.html\">Task Manager</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"route.html\">Network Routing</A></LI>\n"); fprintf(hp, " <LI><A HREF=\"ibcsrv.html\">Internet BBS Chat</A></LI>\n"); fprintf(hp, "</UL>\n"); close_webdoc(hp); } else { Syslog('+', "Can't create html documentation"); } ftnd_mvprintw(8,11, (char *)"Creating site documents"); fflush(stdout); horiz = 35; page = global_doc(fp, toc, page); dotter(); page = fido_doc(fp, toc, page); dotter(); page = archive_doc(fp, toc, page); dotter(); page = virus_doc(fp, toc, page); dotter(); page = modem_doc(fp, toc, page); dotter(); page = tty_doc(fp, toc, page); dotter(); page = node_doc(fp, toc, page); dotter(); page = bbs_doc(fp, toc, page); dotter(); page = mail_doc(fp, toc, page); dotter(); page = tic_doc(fp, toc, page); dotter(); page = newf_group_doc(fp, toc, page); dotter(); page = new_doc(fp, toc, page); dotter(); page = ff_doc(fp, toc, page); dotter(); page = service_doc(fp, toc, page); dotter(); page = domain_doc(fp, toc, page); dotter(); page = task_doc(fp, toc, page); dotter(); page = route_doc(fp, toc, page); dotter(); page = ibc_doc(fp, toc, page); dotter(); users_doc(); dotter(); ol_doc(); clrtoeol(); ftnd_mvprintw( 8,11, (char *)"Created site documents in %s/share/doc", getenv("FTND_ROOT")); fflush(stdout); /* * Append table of contents */ page = newpage(fp, page); addtoc(fp, toc, 21, 0, page, (char *)"Table of contents"); fprintf(fp, "\n\n"); line = 4; rewind(toc); while (fgets(temp, 256, toc) != NULL) { fprintf(fp, "%s", temp); line++; if (line == 56) { page = newpage(fp, page); line = 0; } } fprintf(fp, "\f"); fclose(fp); fclose(toc); unlink(temp1); Syslog('+', "Sitedocs created"); /* * Remove obsolete documents */ snprintf(temp, PATH_MAX, "%s/doc/xref.doc", getenv("FTND_ROOT")); unlink(temp); snprintf(temp, PATH_MAX, "%s/doc/stat.doc", getenv("FTND_ROOT")); unlink(temp); center_addstr(LINES -4, (char *)"Press any key"); readkey(LINES -4, COLS / 2 + 8, LIGHTGRAY, BLACK); return; }
int fixfault(Segment *s, uintptr addr, int read, int doputmmu) { int type; int ref; Pte **p, *etp; uintptr mmuphys=0, soff; Page **pg, *lkp, *new; Page *(*fn)(Segment*, uintptr); addr &= ~(BY2PG-1); soff = addr-s->base; p = &s->map[soff/PTEMAPMEM]; if(*p == 0) *p = ptealloc(); etp = *p; pg = &etp->pages[(soff&(PTEMAPMEM-1))/BY2PG]; type = s->type&SG_TYPE; if(pg < etp->first) etp->first = pg; if(pg > etp->last) etp->last = pg; switch(type) { default: panic("fault"); break; case SG_TEXT: /* Demand load */ if(pagedout(*pg)) pio(s, addr, soff, pg); mmuphys = PPN((*pg)->pa) | PTERONLY|PTEVALID; (*pg)->modref = PG_REF; break; case SG_BSS: case SG_SHARED: /* Zero fill on demand */ case SG_STACK: if(*pg == 0) { new = newpage(1, &s, addr); if(s == 0) return -1; *pg = new; } goto common; case SG_DATA: common: /* Demand load/pagein/copy on write */ if(pagedout(*pg)) pio(s, addr, soff, pg); /* * It's only possible to copy on write if * we're the only user of the segment. */ if(read && conf.copymode == 0 && s->ref == 1) { mmuphys = PPN((*pg)->pa)|PTERONLY|PTEVALID; (*pg)->modref |= PG_REF; break; } lkp = *pg; lock(lkp); if(lkp->image == &swapimage) ref = lkp->ref + swapcount(lkp->daddr); else ref = lkp->ref; if(ref == 1 && lkp->image){ /* save a copy of the original for the image cache */ duppage(lkp); ref = lkp->ref; } unlock(lkp); if(ref > 1){ new = newpage(0, &s, addr); if(s == 0) return -1; *pg = new; copypage(lkp, *pg); putpage(lkp); }
int fido_doc(FILE *fp, FILE *toc, int page) { char temp[PATH_MAX]; FILE *wp, *ip, *fido; int i, j; snprintf(temp, PATH_MAX, "%s/etc/fidonet.data", getenv("MBSE_ROOT")); if ((fido = fopen(temp, "r")) == NULL) return page; page = newpage(fp, page); addtoc(fp, toc, 2, 0, page, (char *)"Fidonet networks"); j = 0; fprintf(fp, "\n\n"); fread(&fidonethdr, sizeof(fidonethdr), 1, fido); ip = open_webdoc((char *)"fidonet.html", (char *)"Fidonet networks", NULL); fprintf(ip, "<A HREF=\"index.html\">Main</A>\n<P>\n"); fprintf(ip, "<TABLE border='1' cellspacing='0' cellpadding='2'>\n"); fprintf(ip, "<TBODY>\n"); fprintf(ip, "<TR><TH align='left'>Zone</TH><TH align='left'>Comment</TH><TH align='left'>Available</TH></TR>\n"); while ((fread(&fidonet, fidonethdr.recsize, 1, fido)) == 1) { if (j == 6) { page = newpage(fp, page); fprintf(fp, "\n"); j = 0; } snprintf(temp, 81, "fidonet_%d.html", fidonet.zone[0]); fprintf(ip, " <TR><TD><A HREF=\"%s\">%d</A></TD><TD>%s</TD><TD>%s</TD></TR>\n", temp, fidonet.zone[0], fidonet.comment, getboolean(fidonet.available)); if ((wp = open_webdoc(temp, (char *)"Fidonet network", fidonet.comment))) { fprintf(wp, "<A HREF=\"index.html\">Main</A> <A HREF=\"fidonet.html\">Back</A>\n"); fprintf(wp, "<P>\n"); fprintf(wp, "<TABLE width='400' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='50%%'><COL width='50%%'>\n"); fprintf(wp, "<TBODY>\n"); add_webtable(wp, (char *)"Comment", fidonet.comment); add_webtable(wp, (char *)"Domain", fidonet.domain); add_webtable(wp, (char *)"Available", getboolean(fidonet.available)); add_webtable(wp, (char *)"Nodelist", fidonet.nodelist); for (i = 0; i < 6; i++) if (strlen(fidonet.seclist[i].nodelist) || fidonet.seclist[i].zone) { snprintf(temp, 81, "%d %-8s %d:%d/%d", i+1, fidonet.seclist[i].nodelist, fidonet.seclist[i].zone, fidonet.seclist[i].net, fidonet.seclist[i].node); add_webtable(wp, (char *)"Merge list", temp); } snprintf(temp, 81, "%d", fidonet.zone[0]); for (i = 1; i < 6; i++) if (fidonet.zone[i]) snprintf(temp, 81, "%s %d", temp, fidonet.zone[i]); add_webtable(wp, (char *)"Zone(s)", temp); fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); close_webdoc(wp); } fprintf(fp, " Comment %s\n", fidonet.comment); fprintf(fp, " Domain %s\n", fidonet.domain); fprintf(fp, " Available %s\n", getboolean(fidonet.available)); fprintf(fp, " Nodelist %s\n", fidonet.nodelist); for (i = 0; i < 6; i++) if (strlen(fidonet.seclist[i].nodelist) || fidonet.seclist[i].zone) { fprintf(fp, " Merge list %d %-8s %d:%d/%d\n", i+1, fidonet.seclist[i].nodelist, fidonet.seclist[i].zone, fidonet.seclist[i].net, fidonet.seclist[i].node); } fprintf(fp, " Zone(s) "); for (i = 0; i < 6; i++) if (fidonet.zone[i]) fprintf(fp, "%d ", fidonet.zone[i]); fprintf(fp, "\n\n\n"); j++; } fprintf(ip, "</TBODY>\n"); fprintf(ip, "</TABLE>\n"); close_webdoc(ip); fclose(fido); return page; }
int newf_group_doc(FILE *fp, FILE *toc, int page) { char *temp, group[13]; FILE *ip, *wp, *no; int i, groups, refs, nr; temp = calloc(PATH_MAX, sizeof(char)); snprintf(temp, PATH_MAX, "%s/etc/ngroups.data", getenv("FTND_ROOT")); if ((no = fopen(temp, "r")) == NULL) { free(temp); return page; } wp = open_webdoc((char *)"newgroup.html", (char *)"Newfiles groups", NULL); fprintf(wp, "<A HREF=\"index.html\">Main</A>\n"); page = newpage(fp, page); addtoc(fp, toc, 11, 0, page, (char *)"Newfiles announce groups"); fprintf(fp, "\n"); fprintf(fp, " Name Act Comment\n"); fprintf(fp, " ------------ --- --------------------------------------------------\n"); fread(&ngrouphdr, sizeof(ngrouphdr), 1, no); fseek(no, 0, SEEK_SET); fread(&ngrouphdr, ngrouphdr.hdrsize, 1, no); fprintf(wp, "<P>\n"); fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='20%%'><COL width='5%%'><COL width='75%%'>\n"); fprintf(wp, "<TBODY>\n"); fprintf(wp, "<TR><TH align='left'>Name</TH><TH align='left'>Act</TH><TH align='left'>Comment</TH></TR>\n"); while ((fread(&ngroup, ngrouphdr.recsize, 1, no)) == 1) { fprintf(fp, " %-12s %s %s\n", ngroup.Name, getboolean(ngroup.Active), ngroup.Comment); fprintf(wp, "<TR><TD>%s</TD><TD>%s</TD><TD>%s</TD></TR>\n", ngroup.Name, getboolean(ngroup.Active), ngroup.Comment); } fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); fseek(no, ngrouphdr.hdrsize, SEEK_SET); while ((fread(&ngroup, ngrouphdr.recsize, 1, no)) == 1) { refs = 0; snprintf(temp, PATH_MAX, "%s/etc/fareas.data", getenv("FTND_ROOT")); if ((ip = fopen(temp, "r"))) { fread(&areahdr, sizeof(areahdr), 1, ip); nr = 0; while ((fread(&area, areahdr.recsize, 1, ip)) == 1) { nr++; if (area.Available && (strcmp(ngroup.Name, area.NewGroup) == 0)) { if (refs == 0) { fprintf(wp, "<HR>\n"); fprintf(wp, "<H3>References for group %s</H3>\n", ngroup.Name); fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n"); fprintf(wp, "<TBODY>\n"); } refs++; fprintf(wp, "<TR><TD><A HREF=\"filearea_%d.html\">File area %d</A></TD><TD>%s</TD></TR>\n", nr, nr, area.Name); } } fclose(ip); } snprintf(temp, PATH_MAX, "%s/etc/fgroups.data", getenv("FTND_ROOT")); if ((ip = fopen(temp, "r"))) { fread(&fgrouphdr, fgrouphdr.hdrsize, 1, ip); while ((fread(&fgroup, fgrouphdr.recsize, 1, ip)) == 1) { if (strcmp(ngroup.Name, fgroup.AnnGroup) == 0) { if (refs == 0) { fprintf(wp, "<HR>\n"); fprintf(wp, "<H3>References for group %s</H3>\n", ngroup.Name); fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n"); fprintf(wp, "<TBODY>\n"); } refs++; fprintf(wp, "<TR><TD><A HREF=\"filegroup_%s.html\">File group %s</A></TD><TD>%s</TD></TR>\n", fgroup.Name, fgroup.Name, fgroup.Comment); } } fclose(ip); } snprintf(temp, PATH_MAX, "%s/etc/newfiles.data", getenv("FTND_ROOT")); if ((ip = fopen(temp, "r"))) { fread(&newfileshdr, sizeof(newfileshdr), 1, ip); nr = 0; while ((fread(&newfiles, newfileshdr.recsize, 1, ip)) == 1) { nr++; groups = newfileshdr.grpsize / sizeof(group); for (i = 0; i < groups; i++) { fread(&group, sizeof(group), 1, ip); if (newfiles.Active && strlen(group) && (strcmp(ngroup.Name, group) == 0)) { if (refs == 0) { fprintf(wp, "<HR>\n"); fprintf(wp, "<H3>References for group %s</H3>\n", ngroup.Name); fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n"); fprintf(wp, "<TBODY>\n"); } refs++; fprintf(wp, "<TR><TD><A HREF=\"newfiles_%d.html\">Report %d</A></TD><TD>%s</TD></TR>\n", nr, nr, newfiles.Comment); } } } fclose(ip); } if (refs) { fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); } } close_webdoc(wp); free(temp); fclose(no); return page; }
void userinit(void) { Mach *m = machp(); Proc *p; Segment *s; KMap *k; Page *pg; int sno; p = newproc(); p->pgrp = newpgrp(); p->egrp = smalloc(sizeof(Egrp)); p->egrp->ref = 1; p->fgrp = dupfgrp(nil); p->rgrp = newrgrp(); p->procmode = 0640; kstrdup(&eve, ""); kstrdup(&p->text, "*init*"); kstrdup(&p->user, eve); /* * Kernel Stack * * N.B. make sure there's enough space for syscall to check * for valid args and * space for gotolabel's return PC * AMD64 stack must be quad-aligned. */ p->sched.pc = PTR2UINT(init0); p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(m->externup->arg)-sizeof(uintptr_t)); p->sched.sp = STACKALIGN(p->sched.sp); /* * User Stack * * Technically, newpage can't be called here because it * should only be called when in a user context as it may * try to sleep if there are no pages available, but that * shouldn't be the case here. */ sno = 0; s = newseg(SG_STACK|SG_READ|SG_WRITE, USTKTOP-USTKSIZE, USTKSIZE/ BIGPGSZ); p->seg[sno++] = s; pg = newpage(1, 0, USTKTOP-BIGPGSZ, BIGPGSZ, -1); segpage(s, pg); k = kmap(pg); bootargs(VA(k)); kunmap(k); /* * Text */ s = newseg(SG_TEXT|SG_READ|SG_EXEC, UTZERO, 1); s->flushme++; p->seg[sno++] = s; pg = newpage(1, 0, UTZERO, BIGPGSZ, -1); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); k = kmap(s->map[0]->pages[0]); /* UTZERO is only needed until we make init not have 2M block of zeros at the front. */ memmove(UINT2PTR(VA(k) + init_code_start - UTZERO), init_code_out, sizeof(init_code_out)); kunmap(k); /* * Data */ s = newseg(SG_DATA|SG_READ|SG_WRITE, UTZERO + BIGPGSZ, 1); s->flushme++; p->seg[sno++] = s; pg = newpage(1, 0, UTZERO + BIGPGSZ, BIGPGSZ, -1); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); k = kmap(s->map[0]->pages[0]); /* This depends on init having a text segment < 2M. */ memmove(UINT2PTR(VA(k) + init_data_start - (UTZERO + BIGPGSZ)), init_data_out, sizeof(init_data_out)); kunmap(k); ready(p); }
void userinit(void) { void *v; Proc *p; Segment *s; Page *pg; p = newproc(); p->pgrp = newpgrp(); p->egrp = smalloc(sizeof(Egrp)); p->egrp->ref = 1; p->fgrp = dupfgrp(nil); p->rgrp = newrgrp(); p->procmode = 0640; kstrdup(&eve, ""); kstrdup(&p->text, "*init*"); kstrdup(&p->user, eve); p->fpstate = FPinit; fpoff(); /* * Kernel Stack * * N.B. make sure there's enough space for syscall to check * for valid args and * 4 bytes for gotolabel's return PC */ p->sched.pc = (ulong)init0; p->sched.sp = (ulong)p->kstack+KSTACK-(sizeof(Sargs)+BY2WD); /* * User Stack * * N.B. cannot call newpage() with clear=1, because pc kmap * requires up != nil. use tmpmap instead. */ s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); p->seg[SSEG] = s; pg = newpage(0, 0, USTKTOP-BY2PG); v = tmpmap(pg); memset(v, 0, BY2PG); segpage(s, pg); bootargs(v); tmpunmap(v); /* * Text */ s = newseg(SG_TEXT, UTZERO, 1); s->flushme++; p->seg[TSEG] = s; pg = newpage(0, 0, UTZERO); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); v = tmpmap(pg); memset(v, 0, BY2PG); memmove(v, initcode, sizeof initcode); tmpunmap(v); ready(p); }
/* Main entry point for cat, accepts an array of arguments */ int cmd_cat(char **argv) { unsigned int argc, i, ret = 0; size_t buffer = 0; int c, opt_ind; aoff64_t head = CAT_FULL_FILE, tail = CAT_FULL_FILE; bool hex = false; bool more = false; bool tailFirst = false; sysarg_t rows, cols; int rc; /* * reset global state * TODO: move to structure? */ paging_enabled = false; chars_remaining = 0; lines_remaining = 0; console_cols = 0; console_rows = 0; should_quit = false; console = console_init(stdin, stdout); number = false; lineno = 0; /* This enables printing of the first number. */ last_char_was_newline = true; argc = cli_count_args(argv); for (c = 0, optreset = 1, optind = 0, opt_ind = 0; c != -1;) { c = getopt_long(argc, argv, "xhvmH:t:b:s:n", long_options, &opt_ind); switch (c) { case 'h': help_cmd_cat(HELP_LONG); return CMD_SUCCESS; case 'v': printf("%s\n", CAT_VERSION); return CMD_SUCCESS; case 'H': if (!optarg || str_uint64_t(optarg, NULL, 10, false, &head) != EOK ) { puts("Invalid head size\n"); return CMD_FAILURE; } break; case 't': if (!optarg || str_uint64_t(optarg, NULL, 10, false, &tail) != EOK ) { puts("Invalid tail size\n"); return CMD_FAILURE; } if (head == CAT_FULL_FILE) tailFirst = true; break; case 'b': if (!optarg || str_size_t(optarg, NULL, 10, false, &buffer) != EOK ) { puts("Invalid buffer size\n"); return CMD_FAILURE; } break; case 'm': more = true; break; case 'x': hex = true; break; case 's': dash_represents_stdin = true; break; case 'n': number = true; break; } } argc -= optind; if (argc < 1) { printf("%s - incorrect number of arguments. Try `%s --help'\n", cmdname, cmdname); return CMD_FAILURE; } if (buffer < 4) buffer = CAT_DEFAULT_BUFLEN; if (more) { rc = console_get_size(console, &cols, &rows); if (rc != EOK) { printf("%s - cannot get console size\n", cmdname); return CMD_FAILURE; } console_cols = cols; console_rows = rows; paging_enabled = true; newpage(); } for (i = optind; argv[i] != NULL && !should_quit; i++) ret += cat_file(argv[i], buffer, hex, head, tail, tailFirst); if (ret) return CMD_FAILURE; else return CMD_SUCCESS; }
/* * create the first process */ void userinit(void) { Proc *p; Segment *s; KMap *k; Page *pg; /* no processes yet */ up = nil; p = newproc(); p->pgrp = newpgrp(); p->egrp = smalloc(sizeof(Egrp)); p->egrp->ref = 1; p->fgrp = dupfgrp(nil); p->rgrp = newrgrp(); p->procmode = 0640; kstrdup(&eve, ""); kstrdup(&p->text, "*init*"); kstrdup(&p->user, eve); /* * Kernel Stack */ p->sched.pc = PTR2UINT(init0); p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr)); p->sched.sp = STACKALIGN(p->sched.sp); /* * User Stack * * Technically, newpage can't be called here because it * should only be called when in a user context as it may * try to sleep if there are no pages available, but that * shouldn't be the case here. */ s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG); p->seg[SSEG] = s; pg = newpage(1, 0, USTKTOP-BY2PG); segpage(s, pg); k = kmap(pg); bootargs(VA(k)); kunmap(k); /* * Text */ s = newseg(SG_TEXT, UTZERO, 1); s->flushme++; p->seg[TSEG] = s; pg = newpage(1, 0, UTZERO); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); k = kmap(s->map[0]->pages[0]); memmove(UINT2PTR(VA(k)), initcode, sizeof initcode); kunmap(k); ready(p); }
int main (int argc, char **argv) { int n1,n2,n1tic,n2tic,nfloats,bbox[4], i1,i2,grid1,grid2,style, i3,n3,notitle2=0, n1c,n2c,n1s,n2s,i1beg,i1end,i2beg,i2end,i1c,i2c, n1dsp=0,n2dsp=0,n3dsp=0,loopdsp, nz,iz,i1step,i2step,verbose; float labelsize,titlesize,perc,clip,bperc,wperc,bclip,wclip, d1,f1,d2,f2,*z,*temp,zscale,zoffset,zi, f3,d3,f3s, xbox,ybox,wbox,hbox, x1beg,x1end,x2beg,x2end, x1min,x1max,x2min,x2max, d1num,f1num,d2num,f2num, p1beg,p1end,p2beg,p2end,matrix[6], d1s,d2s; unsigned char *cz,*czp,*sz; char *label1="",*label2="",*title="",*title2="", *labelfont="Helvetica",*titlefont="Helvetica-Bold", *styles="seismic",*grid1s="none",*grid2s="none"; char title2s[80],c80[80]; FILE *infp=stdin; /* initialize getpar */ initargs(argc,argv); requestdoc(1); /* get parameters describing 1st dimension sampling */ if (!getparint("n1",&n1)) err("must specify n1!\n"); if (!getparfloat("d1",&d1)) d1 = 1.0; if (!getparfloat("f1",&f1)) f1 = 0.0; /* get parameters describing 2nd dimension sampling */ if (!getparint("n2",&n2)) { if (efseeko(infp,(off_t) 0,SEEK_END)!=0) err("must specify n2 if in a pipe!\n"); nfloats = (int) (eftello(infp)/((off_t) sizeof(float))); efseeko(infp,(off_t) 0,SEEK_SET); n2 = nfloats/n1; n3 = 1; } if (!getparfloat("d2",&d2)) d2 = 1.0; if (!getparfloat("f2",&f2)) f2 = 0.0; /* get parameters describing 3rd dimension sampling */ if (!getparint("n3",&n3)) { if (efseeko(infp,(off_t) 0,SEEK_END)!=0) err("must specify n3 if in a pipe!\n"); nfloats = (int) (eftello(infp)/((off_t) sizeof(float))); efseeko(infp,(off_t) 0,SEEK_SET); n3 = nfloats/n1/n2; } if (!getparfloat("d3",&d3)) d3 = 1.0; if (!getparfloat("f3",&f3)) f3 = d3; /* set up desired looping mode */ if (!getparint("loopdsp",&loopdsp)) loopdsp = 3; if (loopdsp == 3) { n1dsp = n1; n2dsp=n2; n3dsp=n3; } else if (loopdsp == 1) { n1dsp = n2; n2dsp=n3; n3dsp=n1; } else if (loopdsp == 2) { n1dsp = n1; n2dsp=n3; n3dsp=n2; } x1min = (d1>0.0)?f1:f1+(n1dsp-1)*d1; x1max = (d1<0.0)?f1:f1+(n1dsp-1)*d1; x2min = (d2>0.0)?f2:f2+(n2dsp-1)*d2; x2max = (d2<0.0)?f2:f2+(n2dsp-1)*d2; /* read binary data to be plotted */ nz = n1*n2*n3; z = ealloc1float(nz); if (fread(z,sizeof(float),nz,infp)!=nz) err("error reading input file!\n"); /* if necessary, determine clips from percentiles */ if (getparfloat("clip",&clip)) { bclip = clip; wclip = -clip; } if ((!getparfloat("bclip",&bclip) || !getparfloat("wclip",&wclip)) && !getparfloat("clip",&clip)) { perc = 100.0; getparfloat("perc",&perc); temp = ealloc1float(nz); for (iz=0; iz<nz; iz++) temp[iz] = z[iz]; if (!getparfloat("bclip",&bclip)) { bperc = perc; getparfloat("bperc",&bperc); iz = (nz*bperc/100.0); if (iz<0) iz = 0; if (iz>nz-1) iz = nz-1; qkfind(iz,nz,temp); bclip = temp[iz]; } if (!getparfloat("wclip",&wclip)) { wperc = 100.0-perc; getparfloat("wperc",&wperc); iz = (nz*wperc/100.0); if (iz<0) iz = 0; if (iz>nz-1) iz = nz-1; qkfind(iz,nz,temp); wclip = temp[iz]; } free1float(temp); } /* transpose data if needed */ if (loopdsp == 1) { temp = ealloc1float(nz); for (iz=0;iz<nz;iz++) temp[iz] = z[iz]; for (i3=0;i3<n3;i3++) { for (i2=0;i2<n2;i2++) { for(i1=0;i1<n1;i1++) { z[i2+i3*n2+i1*n2*n3] = temp[i1+i2*n1+i3*n1*n2]; } } } free1float(temp); } else if (loopdsp == 2) { temp = ealloc1float(nz); for (iz=0;iz<nz;iz++) temp[iz] = z[iz]; for (i3=0;i3<n3;i3++) { for (i2=0;i2<n2;i2++) { for(i1=0;i1<n1;i1++) { z[i1+i3*n1+i2*n1*n3] = temp[i1+i2*n1+i3*n1*n2]; } } } free1float(temp); } verbose = 1; getparint("verbose",&verbose); if (verbose) warn("bclip=%g wclip=%g",bclip,wclip); /* get scaled sampling intervals */ d1s = 1.0; getparfloat("d1s",&d1s); d2s = 1.0; getparfloat("d2s",&d2s); d1s = fabs(d1s); d1s *= d1; d2s = fabs(d2s); d2s *= d2; /* get axes parameters */ xbox = 1.0; getparfloat("xbox",&xbox); ybox = 1.5; getparfloat("ybox",&ybox); wbox = 6.0; getparfloat("wbox",&wbox); hbox = 8.0; getparfloat("hbox",&hbox); x1beg = x1min; getparfloat("x1beg",&x1beg); x1end = x1max; getparfloat("x1end",&x1end); d1num = 0.0; getparfloat("d1num",&d1num); f1num = x1min; getparfloat("f1num",&f1num); n1tic = 1; getparint("n1tic",&n1tic); getparstring("grid1",&grid1s); if (STREQ("dot",grid1s)) grid1 = DOT; else if (STREQ("dash",grid1s)) grid1 = DASH; else if (STREQ("solid",grid1s)) grid1 = SOLID; else grid1 = NONE; getparstring("label1",&label1); x2beg = x2min; getparfloat("x2beg",&x2beg); x2end = x2max; getparfloat("x2end",&x2end); d2num = 0.0; getparfloat("d2num",&d2num); f2num = 0.0; getparfloat("f2num",&f2num); n2tic = 1; getparint("n2tic",&n2tic); getparstring("grid2",&grid2s); if (STREQ("dot",grid2s)) grid2 = DOT; else if (STREQ("dash",grid2s)) grid2 = DASH; else if (STREQ("solid",grid2s)) grid2 = SOLID; else grid2 = NONE; getparstring("label2",&label2); getparstring("labelfont",&labelfont); labelsize = 18.0; getparfloat("labelsize",&labelsize); getparstring("title",&title); if (!getparstring("title2",&title2)) notitle2=1; getparstring("titlefont",&titlefont); titlesize = 24.0; getparfloat("titlesize",&titlesize); getparstring("style",&styles); if (STREQ("normal",styles)) style = NORMAL; else style = SEISMIC; /* adjust x1beg and x1end to fall on sampled values */ i1beg = NINT((x1beg-f1)/d1); i1beg = MAX(0,MIN(n1dsp-1,i1beg)); x1beg = f1+i1beg*d1; i1end = NINT((x1end-f1)/d1); i1end = MAX(0,MIN(n1dsp-1,i1end)); x1end = f1+i1end*d1; /* adjust x2beg and x2end to fall on sampled values */ i2beg = NINT((x2beg-f2)/d2); i2beg = MAX(0,MIN(n2dsp-1,i2beg)); x2beg = f2+i2beg*d2; i2end = NINT((x2end-f2)/d2); i2end = MAX(0,MIN(n2dsp-1,i2end)); x2end = f2+i2end*d2; /* allocate space for image bytes */ n1c = 1+abs(i1end-i1beg); n2c = 1+abs(i2end-i2beg); /* convert data to be imaged into unsigned characters */ zscale = (wclip!=bclip)?255.0/(wclip-bclip):1.0e10; zoffset = -bclip*zscale; i1step = (i1end>i1beg)?1:-1; i2step = (i2end>i2beg)?1:-1; /* determine sampling after scaling */ n1s = MAX(1,NINT(1+(n1c-1)*d1/d1s)); d1s = (n1s>1)?d1*(n1c-1)/(n1s-1):d1; n2s = MAX(1,NINT(1+(n2c-1)*d2/d2s)); d2s = (n2s>1)?d2*(n2c-1)/(n2s-1):d2; /* convert axes box parameters from inches to points */ xbox *= 72.0; ybox *= 72.0; wbox *= 72.0; hbox *= 72.0; /* set bounding box */ psAxesBBox3( xbox,ybox,wbox,hbox, labelfont,labelsize, titlefont,titlesize, style,bbox); boundingbox(bbox[0],bbox[1],bbox[2],bbox[3]); /* begin PostScript */ beginps(); /* loop over n3 */ for(i3=0;i3<n3dsp;i3++) { cz = ealloc1(n1c*n2c,sizeof(char)); czp = cz; for (i1c=0,i1=i1beg; i1c<n1c; i1c++,i1+=i1step) { for (i2c=0,i2=i2beg; i2c<n2c; i2c++,i2+=i2step) { zi = zoffset +z[i1+i2*n1dsp+i3*n1dsp*n2dsp]*zscale; if (zi<0.0) zi = 0.0; if (zi>255.0) zi = 255.0; *czp++ = (unsigned char)zi; } } /* if necessary, interpolate to scaled sampling intervals */ if (n1s!=n1c || n2s!=n2c) { sz = ealloc1(n1s*n2s,sizeof(char)); intl2b(n2c,d2,0.0,n1c,d1,0.0,cz, n2s,d2s,0.0,n1s,d1s,0.0,sz); free1(cz); } else { sz = cz; } /* determine axes pads */ p1beg = (x1end>x1beg)?-fabs(d1s)/2:fabs(d1s)/2; p1end = (x1end>x1beg)?fabs(d1s)/2:-fabs(d1s)/2; p2beg = (x2end>x2beg)?-fabs(d2s)/2:fabs(d2s)/2; p2end = (x2end>x2beg)?fabs(d2s)/2:-fabs(d2s)/2; newpage("1",i3+1); /* save graphics state */ gsave(); /* translate coordinate system by box offset */ translate(xbox,ybox); /* determine image matrix */ if (style==NORMAL) { matrix[0] = 0; matrix[1] = n1s; matrix[2] = n2s; matrix[3] = 0; matrix[4] = 0; matrix[5] = 0; } else { matrix[0] = n2s; matrix[1] = 0; matrix[2] = 0; matrix[3] = -n1s; matrix[4] = 0; matrix[5] = n1s; } scale(wbox,hbox); /* draw the image (before axes so grid lines are visible) */ image(n2s,n1s,8,matrix,sz); /* restore graphics state */ grestore(); /* update title2 only if n3>1*/ strcpy(title2s,title2); if ( notitle2 == 0 ) { char *nullchar=""; f3s = f3 + i3 * d3; sprintf(c80,"= %.4g %s",f3s,nullchar); strcat(title2s,c80); } /* draw axes and title */ psAxesBox3( xbox,ybox,wbox,hbox, x1beg,x1end,p1beg,p1end, d1num,f1num,n1tic,grid1,label1, x2beg,x2end,p2beg,p2end, d2num,f2num,n2tic,grid2,label2, labelfont,labelsize, title,titlefont,titlesize, style, title2s); showpage(); } /* end PostScript */ endps(); return EXIT_SUCCESS; }
int ibc_doc(FILE *fp, FILE *toc, int page) { char temp[PATH_MAX]; FILE *wp, *ip, *vir; int nr = 0, j; snprintf(temp, PATH_MAX, "%s/etc/ibcsrv.data", getenv("FTND_ROOT")); if ((vir = fopen(temp, "r")) == NULL) return page; page = newpage(fp, page); addtoc(fp, toc, 20, 0, page, (char *)"Internet BBS Chatservers"); j = 0; fprintf(fp, "\n\n"); fread(&ibcsrvhdr, sizeof(ibcsrvhdr), 1, vir); ip = open_webdoc((char *)"ibcsrv.html", (char *)"Internet BBS Chatservers", NULL); fprintf(ip, "<A HREF=\"index.html\">Main</A>\n"); fprintf(ip, "<UL>\n"); while ((fread(&ibcsrv, ibcsrvhdr.recsize, 1, vir)) == 1) { if (j == 5) { page = newpage(fp, page); fprintf(fp, "\n"); j = 0; } nr++; snprintf(temp, 81, "ibcsrv_%d.html", nr); fprintf(ip, "<LI><A HREF=\"%s\">%s</A></LI>\n", temp, ibcsrv.comment); if ((wp = open_webdoc(temp, (char *)"Internet BBS Chatserver", ibcsrv.comment))) { fprintf(wp, "<A HREF=\"index.html\">Main</A> <A HREF=\"ibcsrv.html\">Back</A>\n"); fprintf(wp, "<P>\n"); fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='30%%'><COL width='70%%'>\n"); fprintf(wp, "<TBODY>\n"); add_webtable(wp, (char *)"Server comment", ibcsrv.comment); add_webtable(wp, (char *)"Server address", ibcsrv.server); add_webtable(wp, (char *)"Uses dynamic dns", getboolean(ibcsrv.Dyndns)); add_webtable(wp, (char *)"My address", ibcsrv.myname); add_webtable(wp, (char *)"Active", getboolean(ibcsrv.Active)); add_webtable(wp, (char *)"Compresion", getboolean(ibcsrv.Compress)); fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); close_webdoc(wp); } fprintf(fp, " Comment %s\n", ibcsrv.comment); fprintf(fp, " Server %s\n", ibcsrv.server); fprintf(fp, " Dynamic dns %s\n", getboolean(ibcsrv.Dyndns)); fprintf(fp, " My name %s\n", ibcsrv.myname); fprintf(fp, " Active %s\n", getboolean(ibcsrv.Active)); fprintf(fp, " Compression %s\n", getboolean(ibcsrv.Compress)); fprintf(fp, "\n\n\n"); j++; } fprintf(ip, "</UL>\n"); close_webdoc(ip); fclose(vir); return page; }
void putmmu(uintptr va, uintptr pa, Page* page) { int x; Page *pg; PTE *l1, *pte; x = L1X(va); l1 = &m->mmul1[x]; if(*l1 == Fault){ /* wasteful - l2 pages only have 256 entries - fix */ if(up->mmul2cache == nil){ /* auxpg since we don't need much? memset if so */ pg = newpage(1, 0, 0); pg->va = VA(kmap(pg)); } else{ pg = up->mmul2cache; up->mmul2cache = pg->next; memset(UINT2PTR(pg->va), 0, BY2PG); } pg->daddr = x; pg->next = up->mmul2; up->mmul2 = pg; /* force l2 page to memory */ cachedwbse((void *)pg->va, BY2PG); *l1 = PPN(pg->pa)|Dom0|Coarse; cachedwbse(l1, sizeof *l1); if(x >= m->mmul1lo && x < m->mmul1hi){ if(x+1 - m->mmul1lo < m->mmul1hi - x) m->mmul1lo = x+1; else m->mmul1hi = x; } } pte = UINT2PTR(KADDR(PPN(*l1))); /* protection bits are * PTERONLY|PTEVALID; * PTEWRITE|PTEVALID; * PTEWRITE|PTEUNCACHED|PTEVALID; */ x = Small; if(!(pa & PTEUNCACHED)) x |= Cached|Buffered; if(pa & PTEWRITE) x |= L2AP(Urw); else x |= L2AP(Uro); pte[L2X(va)] = PPN(pa)|x; cachedwbse(&pte[L2X(va)], sizeof pte[0]); /* clear out the current entry */ mmuinvalidateaddr(PPN(va)); /* write back dirty entries - we need this because the pio() in * fault.c is writing via a different virt addr and won't clean * its changes out of the dcache. Page coloring doesn't work * on this mmu because the virtual cache is set associative * rather than direct mapped. */ cachedwbinv(); if(page->txtflush){ cacheiinv(); page->txtflush = 0; } checkmmu(va, PPN(pa)); }
void blankline() { if (line_no >= TXTLEN) newpage(); spit('\n'); line_no++; }
int tic_magic_doc(FILE *fp, FILE *toc, int page) { char temp[PATH_MAX]; FILE *wp, *ip, *no; int nr = 0i, j; snprintf(temp, PATH_MAX, "%s/etc/magic.data", getenv("FTND_ROOT")); if ((no = fopen(temp, "r")) == NULL) return page; page = newpage(fp, page); addtoc(fp, toc, 10, 4, page, (char *)"File Magic processing"); j = 0; fprintf(fp, "\n\n"); fread(&magichdr, sizeof(magichdr), 1, no); ip = open_webdoc((char *)"magic.html", (char *)"File Magic Processing", NULL); fprintf(ip, "<A HREF=\"index.html\">Main</A>\n"); fprintf(ip, "<P>\n"); fprintf(ip, "<TABLE border='1' cellspacing='0' cellpadding='2'>\n"); fprintf(ip, "<TBODY>\n"); fprintf(ip, "<TR><TH align='left'>Nr</TH><TH align='left'>Mask</TH><TH align='left'>Type</TH><TH align='left'>Active</TH></TR>\n"); while (fread(&magic, magichdr.recsize, 1, no) == 1) { if (j == 6) { page = newpage(fp, page); fprintf(fp, "\n"); j = 0; } nr++; snprintf(temp, 81, "magic_%d.html", nr); fprintf(ip, " <TR><TD><A HREF=\"%s\">%d</A></TD><TD>%s</TD><TD>%s</TD><TD>%s</TD></TR>\n", temp, nr, magic.Mask, getmagictype(magic.Attrib), getboolean(magic.Active)); if ((wp = open_webdoc(temp, (char *)"File Magic", magic.Mask))) { fprintf(wp, "<A HREF=\"index.html\">Main</A> <A HREF=\"magic.html\">Back</A>\n"); fprintf(wp, "<P>\n"); fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='30%%'><COL width='70%%'>\n"); fprintf(wp, "<TBODY>\n"); add_webtable(wp, (char *)"Filemask", magic.Mask); add_webtable(wp, (char *)"Magic type", getmagictype(magic.Attrib)); add_webtable(wp, (char *)"Active", getboolean(magic.Active)); fprintf(wp, "<TR><TH align='left'>TIC Area</TH><TD><A HREF=\"ticarea_%s.html\">%s</A></TD></TR>\n", magic.From, magic.From); fprintf(fp, " Filemask %s\n", magic.Mask); fprintf(fp, " Type %s\n", getmagictype(magic.Attrib)); fprintf(fp, " Active %s\n", getboolean(magic.Active)); fprintf(fp, " Area %s\n", magic.From); switch (magic.Attrib) { case MG_ADOPT: case MG_MOVE: fprintf(fp, " To area %s\n", magic.ToArea); fprintf(wp, "<TR><TH align='left'>TIC Area</TH><TD><A HREF=\"ticarea_%s.html\">%s</A></TD></TR>\n", magic.ToArea, magic.ToArea); break; case MG_EXEC: add_webtable(wp, (char *)"Command", magic.Cmd); add_webtable(wp, (char *)"Compile nodelist", getboolean(magic.Compile)); fprintf(fp, " Command %s\n", magic.Cmd); fprintf(fp, " Compile NL %s\n", getboolean(magic.Compile)); break; case MG_UNPACK: case MG_COPY: add_webtable(wp, (char *)"Compile nodelist", getboolean(magic.Compile)); add_webtable(wp, (char *)"Destination path", magic.Path); fprintf(fp, " Compile NL %s\n", getboolean(magic.Compile)); fprintf(fp, " Path %s\n", magic.Path); break; case MG_KEEPNUM: add_webdigit(wp, (char *)"Keep # files", magic.KeepNum); fprintf(fp, " Keep # file %d\n", magic.KeepNum); break; } fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); close_webdoc(wp); } fprintf(fp, "\n\n"); j++; } fprintf(ip, "</TBODY>\n"); fprintf(ip, "</TABLE>\n"); close_webdoc(ip); fclose(no); return page; }
void userinit(void) { Proc *p; Segment *s; KMap *k; Page *pg; p = newproc(); p->pgrp = newpgrp(); p->egrp = smalloc(sizeof(Egrp)); p->egrp->ref = 1; p->fgrp = dupfgrp(nil); p->rgrp = newrgrp(); p->procmode = 0640; kstrdup(&eve, ""); kstrdup(&p->text, "*init*"); kstrdup(&p->user, eve); /* * Kernel Stack * * N.B. make sure there's enough space for syscall to check * for valid args and * space for gotolabel's return PC * AMD64 stack must be quad-aligned. */ p->sched.pc = PTR2UINT(init0); p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->arg)-sizeof(uintptr)); p->sched.sp = STACKALIGN(p->sched.sp); /* * User Stack * * Technically, newpage can't be called here because it * should only be called when in a user context as it may * try to sleep if there are no pages available, but that * shouldn't be the case here. */ s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BIGPGSZ); p->seg[SSEG] = s; pg = newpage(1, 0, USTKTOP-BIGPGSZ, BIGPGSZ, -1); segpage(s, pg); k = kmap(pg); bootargs(VA(k)); kunmap(k); /* * Text */ s = newseg(SG_TEXT, UTZERO, 1); s->flushme++; p->seg[TSEG] = s; pg = newpage(1, 0, UTZERO, BIGPGSZ, -1); memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl)); segpage(s, pg); k = kmap(s->map[0]->pages[0]); memmove(UINT2PTR(VA(k)), initcode, sizeof initcode); kunmap(k); ready(p); }
/** * Insert a file into the buffer at the point. * Leaves the point at the start of the inserted file. * @param buff The buffer to read the file into. * @param fname The file to read. * @param[out] compressed Was the file compressed? Only if ZLIB enabled. Can be NULL. * @return 0 on success, -1 on file error, 1 on zlib error. */ int breadfile(struct buff *buff, const char *fname, int *compressed) { char buf[PGSIZE]; struct mark start; int fd, len; fd = open(fname, O_RDONLY | O_BINARY); if (fd < 0) return -errno; #if ZLIB gzFile gz = gzdopen(fd, "rb"); if (!gz) { close(fd); return 1; } if (compressed) *compressed = gzdirect(gz) == 0; #else if (compressed) *compressed = 0; #endif /* Deal with point in the middle of a page. */ if (curplen(buff) && buff->curchar < PGSIZE) { pagesplit(buff, buff->curchar); if (!newpage(buff->curpage)) return -ENOMEM; makecur(buff, buff->curpage->nextp, 0); } bmrktopnt(buff, &start); while ((len = fileread(fd, buf, PGSIZE)) > 0) { if (curplen(buff)) { if (!newpage(buff->curpage)) { fileclose(fd); return -ENOMEM; } makecur(buff, buff->curpage->nextp, 0); } memcpy(buff->curcptr, buf, len); curplen(buff) = len; } fileclose(fd); bpnttomrk(buff, &start); #if ZLIB /* Ubuntu 12.04 has a bug where zero length files are reported as * compressed. */ if (compressed && curplen(buff) == 0) *compressed = 0; #endif buff->bmodf = 0; return 0; }
int tic_hatch_doc(FILE *fp, FILE *toc, int page) { char temp[PATH_MAX], *tmp = NULL; FILE *wp, *ip, *no; int i, j, nr = 0, All; snprintf(temp, PATH_MAX, "%s/etc/hatch.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return page; page = newpage(fp, page); addtoc(fp, toc, 10, 3, page, (char *)"Hatch manager"); j = 1; fprintf(fp, "\n\n"); fread(&hatchhdr, sizeof(hatchhdr), 1, no); ip = open_webdoc((char *)"hatch.html", (char *)"File Areas", NULL); fprintf(ip, "<A HREF=\"index.html\">Main</A>\n"); fprintf(ip, "<P>\n"); fprintf(ip, "<TABLE border='1' cellspacing='0' cellpadding='2'>\n"); fprintf(ip, "<TBODY>\n"); fprintf(ip, "<TR><TH align='left'>Nr</TH><TH align='left'>Pattern</TH><TH align='left'>Active</TH></TR>\n"); while ((fread(&hatch, hatchhdr.recsize, 1, no)) == 1) { nr++; if (j == 5) { page = newpage(fp, page); fprintf(fp, "\n"); j = 0; } snprintf(temp, 81, "hatch_%d.html", nr); fprintf(ip, " <TR><TD><A HREF=\"%s\">%d</A></TD><TD>%s</TD><TD>%s</TD></TR>\n", temp, nr, hatch.Spec, getboolean(hatch.Active)); if ((wp = open_webdoc(temp, (char *)"Hatch Manager", hatch.Spec))) { fprintf(wp, "<A HREF=\"index.html\">Main</A> <A HREF=\"hatch.html\">Back</A>\n"); fprintf(wp, "<P>\n"); fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='30%%'><COL width='70%%'>\n"); fprintf(wp, "<TBODY>\n"); add_webtable(wp, (char *)"File specification", hatch.Spec); fprintf(wp, "<TR><TH align='left'>TIC File area</TH><TD><A HREF=\"ticarea_%s.html\">%s</A></TD></TR>\n", hatch.Name, hatch.Name); add_webtable(wp, (char *)"Replace file", hatch.Replace); add_webtable(wp, (char *)"Magic filename", hatch.Magic); add_webtable(wp, (char *)"File description", hatch.Desc); add_webtable(wp, (char *)"Dupe check", getboolean(hatch.DupeCheck)); add_webtable(wp, (char *)"Active", getboolean(hatch.Active)); } fprintf(fp, " File spec %s\n", hatch.Spec); fprintf(fp, " File echo %s\n", hatch.Name); fprintf(fp, " Replace file %s\n", hatch.Replace); fprintf(fp, " Magic filename %s\n", hatch.Magic); fprintf(fp, " Description %s\n", hatch.Desc); fprintf(fp, " Dupe check %s\n", getboolean(hatch.DupeCheck)); fprintf(fp, " Active %s\n", getboolean(hatch.Active)); tmp = NULL; for (i = 0; i < 7; i++) if (hatch.Days[i]) { if (tmp == NULL) { tmp = xstrcpy(Days[i]); } else { tmp = xstrcat(tmp, (char *)", "); tmp = xstrcat(tmp, Days[i]); } } if (tmp == NULL) tmp = xstrcpy((char *)"None"); if (wp != NULL) add_webtable(wp, (char *)"Hatch on days", tmp); fprintf(fp, " Hatch on days %s\n", tmp); if (tmp != NULL) { free(tmp); tmp = NULL; } All = TRUE; for (i = 0; i < 32; i++) if (!hatch.Month[i]) All = FALSE; if (!All) { for (i = 0; i < 32; i++) { if (hatch.Month[i]) { if (tmp == NULL) { tmp = xstrcpy(Month[i]); } else { tmp = xstrcat(tmp, (char *)", "); tmp = xstrcat(tmp, Month[i]); } } } } else { tmp = xstrcpy((char *)"All dates"); } if (tmp == NULL) tmp = xstrcpy((char *)"None"); if (wp != NULL) { add_webtable(wp, (char *)"Hatch on dates", tmp); fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); fprintf(wp, "<HR>\n"); fprintf(wp, "<H3>Hatch Statistics</H3>\n"); add_statcnt(wp, (char *)"hatched files", hatch.Hatched); close_webdoc(wp); } fprintf(fp, " Hatch on dates %s\n", tmp); if (tmp != NULL) { free(tmp); tmp = NULL; } fprintf(fp, "\n\n"); j++; } fprintf(ip, "</TBODY>\n"); fprintf(ip, "</TABLE>\n"); close_webdoc(ip); fclose(no); return page; }
int mail_group_doc(FILE *fp, FILE *toc, int page) { char temp[PATH_MAX], group[13]; FILE *ti, *wp, *ip, *no; int refs, i, j; time_t tt; snprintf(temp, PATH_MAX, "%s/etc/mgroups.data", getenv("MBSE_ROOT")); if ((no = fopen(temp, "r")) == NULL) return page; addtoc(fp, toc, 9, 1, page, (char *)"Mail processing groups"); j = 0; fprintf(fp, "\n"); fread(&mgrouphdr, sizeof(mgrouphdr), 1, no); fseek(no, 0, SEEK_SET); fread(&mgrouphdr, mgrouphdr.hdrsize, 1, no); ip = open_webdoc((char *)"msggroup.html", (char *)"Message Groups", NULL); fprintf(ip, "<A HREF=\"index.html\">Main</A>\n"); fprintf(ip, "<P>\n"); fprintf(ip, "<TABLE border='1' cellspacing='0' cellpadding='2'>\n"); fprintf(ip, "<TBODY>\n"); fprintf(ip, "<TR><TH align='left'>Group</TH><TH align='left'>Comment</TH><TH align='left'>Active</TH></TR>\n"); while ((fread(&mgroup, mgrouphdr.recsize, 1, no)) == 1) { if (j == 2) { page = newpage(fp, page); fprintf(fp, "\n"); j = 0; } snprintf(temp, 81, "msggroup_%s.html", mgroup.Name); fprintf(ip, " <TR><TD><A HREF=\"%s\">%s</A></TD><TD>%s</TD><TD>%s</TD></TR>\n", temp, mgroup.Name, mgroup.Comment, getboolean(mgroup.Active)); if ((wp = open_webdoc(temp, (char *)"Message group", mgroup.Comment))) { fprintf(wp, "<A HREF=\"index.html\">Main</A> <A HREF=\"msggroup.html\">Back</A>\n"); fprintf(wp, "<P>\n"); fprintf(wp, "<TABLE width='400' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='50%%'><COL width='50%%'>\n"); fprintf(wp, "<TBODY>\n"); add_webtable(wp, (char *)"Group name", mgroup.Name); add_webtable(wp, (char *)"Comment", mgroup.Comment); add_webtable(wp, (char *)"Active", getboolean(mgroup.Active)); add_webtable(wp, (char *)"Use Aka", aka2str(mgroup.UseAka)); add_webtable(wp, (char *)"Uplink", aka2str(mgroup.UpLink)); add_webtable(wp, (char *)"Areas file", mgroup.AreaFile); add_webtable(wp, (char *)"Base path", mgroup.BasePath); add_webdigit(wp, (char *)"Netmail reply area", mgroup.NetReply); add_webdigit(wp, (char *)"Start new areas at", mgroup.StartArea); web_secflags(wp, (char *)"Read security", mgroup.RDSec); web_secflags(wp, (char *)"Write security", mgroup.WRSec); web_secflags(wp, (char *)"Sysop security", mgroup.SYSec); add_webtable(wp, (char *)"Def. link security", getflag(mgroup.LinkSec.flags, mgroup.LinkSec.notflags)); add_webtable(wp, (char *)"Use aliases", getboolean(mgroup.Aliases)); add_webtable(wp, (char *)"Add quotes", getboolean(mgroup.Quotes)); add_webtable(wp, (char *)"Auto add/del areas", getboolean(mgroup.AutoChange)); add_webtable(wp, (char *)"User add/del areas", getboolean(mgroup.UserChange)); add_webtable(wp, (char *)"Default charset", getftnchrs(mgroup.Charset)); snprintf(temp, 5, "#%03d", mgroup.GoldEDgroup); add_webtable(wp, (char *)"GoldED groupid", temp); tt = (time_t)mgroup.StartDate; add_webtable(wp, (char *)"Start area date", ctime(&tt)); tt = (time_t)mgroup.LastDate; add_webtable(wp, (char *)"Last active date", ctime(&tt)); fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); fprintf(wp, "<HR>\n"); fprintf(wp, "<H3>Message Areas Reference</H3>\n"); refs = 0; snprintf(temp, PATH_MAX, "%s/etc/mareas.data", getenv("MBSE_ROOT")); if ((ti = fopen(temp, "r"))) { fread(&tichdr, sizeof(tichdr), 1, ti); fseek(ti, 0, SEEK_SET); fread(&msgshdr, msgshdr.hdrsize, 1, ti); i = 0; while ((fread(&msgs, msgshdr.recsize, 1, ti)) == 1) { i++; if (msgs.Active && (strcmp(mgroup.Name, msgs.Group) == 0)) { if (refs == 0) { fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n"); fprintf(wp, "<TBODY>\n"); } fprintf(wp, "<TR><TD><A HREF=\"msgarea_%d.html\">Area %d</A></TD><TD>%s</TD></TR>\n", i, i, msgs.Name); refs++; } fseek(ti, msgshdr.syssize, SEEK_CUR); } fclose(ti); } if (refs == 0) fprintf(wp, "No Message Areas References\n"); else { fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); } fprintf(wp, "<HR>\n"); fprintf(wp, "<H3>Nodes Reference</H3>\n"); refs = 0; snprintf(temp, PATH_MAX, "%s/etc/nodes.data", getenv("MBSE_ROOT")); if ((ti = fopen(temp, "r"))) { fread(&nodeshdr, sizeof(nodeshdr), 1, ti); fseek(ti, 0, SEEK_SET); fread(&nodeshdr, nodeshdr.hdrsize, 1, ti); while ((fread(&nodes, nodeshdr.recsize, 1, ti)) == 1) { fseek(ti, nodeshdr.filegrp, SEEK_CUR); for (i = 0; i < nodeshdr.mailgrp / sizeof(group); i++) { fread(&group, sizeof(group), 1, ti); if (strcmp(group, mgroup.Name) == 0) { if (refs == 0) { fprintf(wp, "<TABLE width='600' border='0' cellspacing='0' cellpadding='2'>\n"); fprintf(wp, "<COL width='20%%'><COL width='80%%'>\n"); fprintf(wp, "<TBODY>\n"); } fprintf(wp, "<TR><TD><A HREF=\"node_%d_%d_%d_%d_%s.html\">%s</A></TD><TD>%s</TD></TR>\n", nodes.Aka[0].zone, nodes.Aka[0].net, nodes.Aka[0].node, nodes.Aka[0].point, nodes.Aka[0].domain, aka2str(nodes.Aka[0]), nodes.Sysop); refs++; } } } fclose(ti); } if (refs == 0) fprintf(wp, "No Nodes References\n"); else { fprintf(wp, "</TBODY>\n"); fprintf(wp, "</TABLE>\n"); } fprintf(wp, "<HR>\n"); fprintf(wp, "<H3>Group Statistics</H3>\n"); add_statcnt(wp, (char *)"received messages", mgroup.MsgsRcvd); add_statcnt(wp, (char *)"sent messages", mgroup.MsgsSent); close_webdoc(wp); } fprintf(fp, " Group name %s\n", mgroup.Name); fprintf(fp, " Comment %s\n", mgroup.Comment); fprintf(fp, " Active %s\n", getboolean(mgroup.Active)); fprintf(fp, " Use Aka %s\n", aka2str(mgroup.UseAka)); fprintf(fp, " Uplink %s\n", aka2str(mgroup.UpLink)); fprintf(fp, " Areas file %s\n", mgroup.AreaFile); fprintf(fp, " Base path %s\n", mgroup.BasePath); fprintf(fp, " Netmail reply area %d\n", mgroup.NetReply); fprintf(fp, " Start new areas at %d\n", mgroup.StartArea); fprintf(fp, " Read security %s\n", get_secstr(mgroup.RDSec)); fprintf(fp, " Write security %s\n", get_secstr(mgroup.WRSec)); fprintf(fp, " Sysop security %s\n", get_secstr(mgroup.SYSec)); fprintf(fp, " Def. link security %s\n", getflag(mgroup.LinkSec.flags, mgroup.LinkSec.notflags)); fprintf(fp, " Use aliases %s\n", getboolean(mgroup.Aliases)); fprintf(fp, " Add quotes %s\n", getboolean(mgroup.Quotes)); fprintf(fp, " Auto add/del areas %s\n", getboolean(mgroup.AutoChange)); fprintf(fp, " User add/del areas %s\n", getboolean(mgroup.UserChange)); fprintf(fp, " Default charset %s\n", getftnchrs(mgroup.Charset)); fprintf(fp, " GoldED groupid #%03d\n", mgroup.GoldEDgroup); tt = (time_t)mgroup.StartDate; fprintf(fp, " Start area date %s", ctime(&tt)); tt = (time_t)mgroup.LastDate; fprintf(fp, " Last active date %s\n", ctime(&tt)); fprintf(fp, "\n\n"); j++; } fprintf(ip, "</TBODY>\n"); fprintf(ip, "</TABLE>\n"); close_webdoc(ip); fclose(no); return page; }