int gscsio_probe(struct device *parent, void *match, void *aux) { struct isa_attach_args *ia = aux; bus_space_tag_t iot; bus_space_handle_t ioh; int iobase; int rv = 0; iot = ia->ia_iot; iobase = ia->ipa_io[0].base; if (bus_space_map(iot, iobase, GSCSIO_IOSIZE, 0, &ioh)) return (0); if (idxread(iot, ioh, GSCSIO_ID) == GSCSIO_ID_SC1100) rv = 1; bus_space_unmap(iot, ioh, GSCSIO_IOSIZE); if (rv) { ia->ipa_nio = 1; ia->ipa_io[0].length = GSCSIO_IOSIZE; ia->ipa_nmem = 0; ia->ipa_nirq = 0; ia->ipa_ndrq = 0; } return (rv); }
int xrd_SL (unit *ftnunit) { int n; if (ftnunit->uacc == KEYED) { if (n = idxread(ftnunit)) return n; } else { if (ftnunit->ufmt == 2) { if (fread ((char *) &ftnunit->f77recend, sizeof (int), 1, ftnunit->ufd) != 1) { clearerr(ftnunit->ufd); return (errno); } /* make sure there is enough buffer space */ check_buflen (ftnunit, ftnunit->f77recend + (int) sizeof(int)); if (fread (ftnunit->f77fio_buf, ftnunit->f77recend + sizeof (int), 1, ftnunit->ufd) != 1) { clearerr(ftnunit->ufd); return (errno); } ftnunit->f77cursor = ftnunit->f77recpos = 0; return (0); } /* For regular formatted file */ #ifdef I90 /* f77recpos cannot be used as a flag for all f77donewrec functions ** since it could point to y_rdXL to skip to the end of the ** current record and destroying the current f77recpos by ** resetting it to 0 would amke that impossible. My guess ** is that the whole reason for this setting of f77recpos to 0 ** in the first place is simply to deal with the NOADVACE ** feature in F90 when reaching the end of a FORMAT specification ** (and the function x_rev is called. */ if (ftnunit->f90nadv != NOADVANCE_AT_REV) { #endif ftnunit->f77recend = 0; while ((n = getc (ftnunit->ufd)) != EOF && n != '\n') { ftnunit->f77fio_buf[ftnunit->f77recend] = (char) n; if (++ftnunit->f77recend == ftnunit->f77fio_size) ftnunit->f77fio_buf = realloc (ftnunit->f77fio_buf, ftnunit->f77fio_size += FIO_ALLOC); } #ifdef I90 } #endif ftnunit->f77fio_buf[ftnunit->f77recend] = '\0';/* replace '\n' with null */ if (n == EOF && ftnunit->f77recend == 0) { ftnunit->uend = 1; return (EOF); } } ftnunit->f77cursor = ftnunit->f77recpos = 0; return (0); }
static int s_rsue_com (cilist64 *a, unit **fu) { int n; unit *ftnunit; int f77reclen_32bit; if (!f77init) f_init (); n = c_sue (a, fu); ftnunit = *fu; if (n) { if (n > 0) { errret(a->cierr, n, "s_rsue"); } else { errret(a->ciend, n, "s_rsue"); } } ftnunit->f77recpos = ftnunit->f77reclen = 0; #ifdef I90 if (ftnunit->uaction == WRITEONLY ) errret(ftnunit->f77errlist.cierr,180,"startread"); #endif /* * The direct unformatted case, yup, in the sequential unformatted * file. */ if ((ftnunit->uacc == DIRECT) && (ftnunit->ufmt == 0)) { if (ftnunit->url != 1) { ftnunit->f77do_unf = do_ud; ftnunit->f77reclen = ftnunit->url; } else { /* For 'SYSTEM' file set a very large MAX_INT value for record length so it cannot be exceeded */ #if (_MIPS_SIM == _MIPS_SIM_ABI64) ftnunit->f77reclen = LONGLONG_MAX; #else ftnunit->f77reclen = LONG_MAX; #endif ftnunit->f77do_unf = do_ud; } _fio_seq_pos( ftnunit->ufd, ftnunit ); ftnunit->uwrt &= ~WR_OP; return (0); } else { if (ftnunit->uwrt & WR_OP) (void) f77nowreading (ftnunit); } /* The normal case. */ if (ftnunit->uacc == KEYED) { ftnunit->f77do_unf = do_ui; ftnunit->f77idxlist.cimatch = a->cimatch; ftnunit->f77idxlist.cikeytype = a->cikeytype; ftnunit->f77idxlist.cikeyval.cicharval = a->cikeyval.cicharval; ftnunit->f77idxlist.cikeyid = a->cikeyid; ftnunit->f77idxlist.cinml = a->cinml; ftnunit->f77idxlist.cikeyvallen = a->cikeyvallen; if (n = idxread(ftnunit)) { if (n > 0) { errret(a->cierr, n, "s_rsue"); } else { errret(a->ciend, n, "s_rsue"); } } } else if (ftnunit->url != 1) { ftnunit->f77do_unf = do_us; if (ftnunit->uerror) unf_position (ftnunit->ufd, ftnunit); if (fread ((char *) &f77reclen_32bit, sizeof (int), 1, ftnunit->ufd) != 1) { if (feof (ftnunit->ufd)) { ftnunit->uend = 1; errret(a->ciend, EOF, "start"); } clearerr(ftnunit->ufd); errret(a->cierr, errno, "start"); } ftnunit->f77reclen = f77reclen_32bit; } else { ftnunit->f77reclen = INT_MAX; ftnunit->f77do_unf = do_ud; } return (0); }
int main(int argc, char **argv) { int i,j,cc=0,startpagenum=-1,ecount=0,chkopt=1; const char *envbuff; UVersionInfo icuVersion; char icu_version[U_MAX_VERSION_STRING_LENGTH] = ""; #ifdef WIN32 char **av; int ac; _setmaxstdio(2048); #endif kpse_set_program_name(argv[0], "upmendex"); #ifdef WIN32 file_system_codepage = CP_UTF8; is_cp932_system = 0; if (get_command_line_args_utf8("utf-8", &ac, &av)) { argv = av; argc = ac; } #endif kp_ist.var_name = "INDEXSTYLE"; kp_ist.path = DEFAULT_INDEXSTYLES; /* default path. */ kp_ist.suffix = "ist"; KP_entry_filetype(&kp_ist); kp_dict.var_name = "INDEXDICTIONARY"; kp_dict.path = DEFAULT_INDEXDICTS; /* default path */ kp_dict.suffix = "dict"; KP_entry_filetype(&kp_dict); /* check options */ for (i=1,j=0; i<argc && j<256; i++) { if ((argv[i][0]=='-')&&(strlen(argv[i])>=2)&&chkopt) { switch (argv[i][1]) { case 'c': bcomp=1; break; case 'd': if ((argv[i][2]=='\0')&&(i+1<argc)) { dicfile=xstrdup(argv[++i]); } else { dicfile=xstrdup(&argv[i][2]); } break; case 'f': force=1; break; case 'g': gflg=1; break; case 'i': fsti=1; break; case 'l': lorder=1; break; case 'o': if ((argv[i][2]=='\0')&&(i+1<argc)) { indfile=xstrdup(argv[++i]); } else { indfile=xstrdup(&argv[i][2]); } break; case 'p': if ((argv[i][2]=='\0')&&(i+1<argc)) { i++; if (strcmp(argv[i],"any")==0) fpage=2; else if (strcmp(argv[i],"odd")==0) fpage=3; else if (strcmp(argv[i],"even")==0) fpage=4; else { fpage=1; startpagenum=atoi(argv[i]); } } else { if (strcmp(&argv[i][2],"any")==0) fpage=2; else if (strcmp(&argv[i][2],"odd")==0) fpage=3; else if (strcmp(&argv[i][2],"even")==0) fpage=4; else { fpage=1; startpagenum=atoi(&argv[i][2]); } } break; case 'q': verb=0; break; case 't': if ((argv[i][2]=='\0')&&(i+1<argc)) { logfile=xstrdup(argv[++i]); } else { logfile=xstrdup(&argv[i][2]); } break; case 'r': prange=0; break; case 's': if ((argv[i][2]=='\0')&&(i+1<argc)) { styfile=xstrdup(argv[++i]); } else { styfile=xstrdup(&argv[i][2]); } break; case 'v': debug=1; break; case '-': if (strlen(argv[i])==2) chkopt=0; if (strcmp(argv[i],"--help")!=0) break; default: u_getVersion(icuVersion); u_versionToString(icuVersion, icu_version); fprintf(stderr,"upmendex - index processor, %s (%s).\n",VERSION, TL_VERSION); fprintf(stderr," Copyright 2009 ASCII MEDIA WORKS, 2015-2016 TANAKA Takuji\n"); fprintf(stderr," using ICU version %s\n",icu_version); fprintf(stderr,"usage:\n"); fprintf(stderr,"%% upmendex [-ilqrcgf] [-s sty] [-d dic] [-o ind] [-t log] [-p no] [--] [idx0 idx1 ...]\n"); fprintf(stderr,"options:\n"); fprintf(stderr,"-i use stdin as the input file.\n"); fprintf(stderr,"-l use letter ordering.\n"); fprintf(stderr,"-q quiet mode.\n"); fprintf(stderr,"-r disable implicit page formation.\n"); fprintf(stderr,"-c compress blanks. (ignore leading and trailing blanks.)\n"); fprintf(stderr,"-g make Japanese index head <%s>.\n", AKASATANAutf8); fprintf(stderr,"-f force to output unknown scripts.\n"); fprintf(stderr,"-s sty take sty as style file.\n"); fprintf(stderr,"-d dic take dic as dictionary file.\n"); fprintf(stderr,"-o ind take ind as the output index file.\n"); fprintf(stderr,"-t log take log as the error log file.\n"); fprintf(stderr,"-p no set the starting page number of index.\n"); fprintf(stderr,"idx... input files.\n"); exit(0); break; } } else { cc=strlen(argv[i]); if (cc<4) cc+=4; else if (strcmp(&argv[i][cc-4],".idx")) cc+=4; idxfile[j]=xmalloc(cc+1); strcpy(idxfile[j++],argv[i]); } } idxcount=j+fsti; /* check option errors */ if (idxcount==0) idxcount=fsti=1; if (styfile==NULL) { envbuff=kpse_var_value("INDEXDEFAULTSTYLE"); if (envbuff!=NULL) { styfile=xstrdup(envbuff); } } /* init hangul tumunja table */ u_strcpy(tumunja,GANADA); if (styfile!=NULL) styread(styfile); if (!indfile &&(idxcount-fsti>0)) { indfile=xmalloc(strlen(idxfile[0]+6)); for (i=strlen(idxfile[0]); i>=0; i--) { if (idxfile[0][i]=='.') { strncpy(indfile,idxfile[0],i); sprintf(&indfile[i],".ind"); break; } } if (i==-1) sprintf(indfile,"%s.ind",idxfile[0]); } if (!logfile && (idxcount-fsti > 0)) { logfile=xmalloc(strlen(idxfile[0]+6)); for (i=strlen(idxfile[0]); i>=0; i--) { if (idxfile[0][i]=='.') { strncpy(logfile,idxfile[0],i); sprintf(&logfile[i],".ilg"); break; } } if (i==-1) sprintf(logfile,"%s.ilg",idxfile[0]); } if (logfile && kpse_out_name_ok(logfile)) efp=fopen(logfile,"wb"); if(efp == NULL) { efp=stderr; logfile=xstrdup("stderr"); } set_icu_attributes(); if (strcmp(argv[0],"makeindex")==0) { verb_printf(efp,"This is Not `MAKEINDEX\', But `UPMENDEX\' %s (%s).\n", VERSION, TL_VERSION); } else { verb_printf(efp,"This is upmendex %s (%s).\n", VERSION, TL_VERSION); } /* init kanatable */ initkanatable(); /* read dictionary */ ecount+=dicread(dicfile); switch (letter_head) { case 0: case 1: if (gflg==1) { u_strcpy(atama,akasatana); } else { u_strcpy(atama,aiueo); } break; case 2: if (gflg==1) { u_strcpy(atama,AKASATANA); } else { u_strcpy(atama,AIUEO); } break; default: break; } /* read idx file */ lines=0; ecount=0; ind=xmalloc(sizeof(struct index)); for (i=0; i<idxcount-fsti; i++) { ecount+=idxread(idxfile[i],lines); } if (fsti==1) { ecount+=idxread(NULL,lines); } verb_printf(efp,"%d entries accepted, %d rejected.\n",acc,reject); if (ecount!=0) { verb_printf(efp,"%d errors, written in %s.\n",ecount,logfile); lines=0; } if (lines==0) { verb_printf(efp,"Nothing written in output file.\n"); if (efp!=stderr) fclose(efp); exit(255); } /* sort index */ verb_printf(efp,"Sorting index."); scount=0; wsort(ind,lines); verb_printf(efp,"...done(%d comparisons).\n",scount); /* sort pages */ verb_printf(efp,"Sorting pages."); scount=0; pagesort(ind,lines); verb_printf(efp,"...done(%d comparisons).\n",scount); /* get last page */ if ((fpage>1)&&(idxcount-fsti>0)) cc=lastpage(idxfile[0]); switch (fpage) { case 2: startpagenum=cc+1; break; case 3: if ((cc+1)%2==0) startpagenum=cc+2; else startpagenum=cc+1; break; case 4: if ((cc+1)%2==1) startpagenum=cc+2; else startpagenum=cc+1; break; default: break; } /* write indfile */ verb_printf(efp,"Making index file."); indwrite(indfile,ind,startpagenum); verb_printf(efp,"...done.\n"); if (idxcount-fsti==0) indfile=xstrdup("stdout"); verb_printf(efp,"%d warnings, written in %s.\n",warn,logfile); verb_printf(efp,"Output written in %s.\n",indfile); if (efp!=stderr) fclose(efp); return 0; }
void gscsio_attach(struct device *parent, struct device *self, void *aux) { struct gscsio_softc *sc = (void *)self; struct isa_attach_args *ia = aux; int i; int iobase; sc->sc_iot = ia->ia_iot; if (bus_space_map(sc->sc_iot, ia->ipa_io[0].base, GSCSIO_IOSIZE, 0, &sc->sc_ioh)) { printf(": can't map i/o space\n"); return; } printf(": SC1100 SIO rev %d:", idxread(sc->sc_iot, sc->sc_ioh, GSCSIO_REV)); /* Configure all supported logical devices */ for (i = 0; i < sizeof (gscsio_ld) / sizeof(gscsio_ld[0]); i++) { sc->sc_ld_en[gscsio_ld[i].ld_num] = 0; /* Select the device and check if it's activated */ idxwrite(sc->sc_iot, sc->sc_ioh, GSCSIO_LDN, gscsio_ld[i].ld_num); if ((idxread(sc->sc_iot, sc->sc_ioh, GSCSIO_ACT) & GSCSIO_ACT_EN) == 0) continue; /* Map I/O space 0 if necessary */ if (gscsio_ld[i].ld_iosize0 != 0) { iobase = idxread(sc->sc_iot, sc->sc_ioh, GSCSIO_IO0_MSB); iobase <<= 8; iobase |= idxread(sc->sc_iot, sc->sc_ioh, GSCSIO_IO0_LSB); if (bus_space_map(sc->sc_iot, iobase, gscsio_ld[i].ld_iosize0, 0, &sc->sc_ld_ioh0[gscsio_ld[i].ld_num])) continue; } /* Map I/O space 1 if necessary */ if (gscsio_ld[i].ld_iosize1 != 0) { iobase = idxread(sc->sc_iot, sc->sc_ioh, GSCSIO_IO1_MSB); iobase <<= 8; iobase |= idxread(sc->sc_iot, sc->sc_ioh, GSCSIO_IO1_LSB); if (bus_space_map(sc->sc_iot, iobase, gscsio_ld[i].ld_iosize1, 0, &sc->sc_ld_ioh0[gscsio_ld[i].ld_num])) { bus_space_unmap(sc->sc_iot, sc->sc_ld_ioh0[gscsio_ld[i].ld_num], gscsio_ld[i].ld_iosize0); continue; } } sc->sc_ld_en[gscsio_ld[i].ld_num] = 1; printf(" %s", gscsio_ld[i].ld_name); } printf("\n"); /* Initialize ACCESS.bus 1 */ if (sc->sc_ld_en[GSCSIO_LDN_ACB1]) { sc->sc_acb[0].sc = sc; sc->sc_acb[0].ioh = sc->sc_ld_ioh0[GSCSIO_LDN_ACB1]; rw_init(&sc->sc_acb[0].buslock, "iiclk"); gscsio_acb_init(&sc->sc_acb[0], &sc->sc_acb1_tag); } /* Initialize ACCESS.bus 2 */ if (sc->sc_ld_en[GSCSIO_LDN_ACB2]) { sc->sc_acb[1].sc = sc; sc->sc_acb[1].ioh = sc->sc_ld_ioh0[GSCSIO_LDN_ACB2]; rw_init(&sc->sc_acb[1].buslock, "iiclk"); gscsio_acb_init(&sc->sc_acb[1], &sc->sc_acb2_tag); } }