KFR_SINTRIN bool bittestall(const vec<T, N>& x) { return !getmask(~x).value; }
static int gethostport(const char *f, size_t l, bool local, struct conf *c, const char *p) { char *d; // XXX: Ok to write to string. in_port_t *port = NULL; const char *pstr; if (strcmp(p, "*") == 0) { c->c_port = FSTAR; c->c_lmask = FSTAR; return 0; } if ((d = strchr(p, ']')) != NULL) { *d++ = '\0'; pstr = d; p++; } else pstr = p; if (getmask(f, l, local, &pstr, &c->c_lmask) == -1) goto out; if (d) { struct sockaddr_in6 *sin6 = (void *)&c->c_ss; if (debug) (*lfun)(LOG_DEBUG, "%s: host6 %s", __func__, p); if (strcmp(p, "*") != 0) { if (inet_pton(AF_INET6, p, &sin6->sin6_addr) == -1) goto out; sin6->sin6_family = AF_INET6; #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN sin6->sin6_len = sizeof(*sin6); #endif port = &sin6->sin6_port; } } else if (pstr != p || strchr(p, '.') || conf_is_interface(p)) { if (pstr == p) pstr = "*"; struct sockaddr_in *sin = (void *)&c->c_ss; struct sockaddr_if *sif = (void *)&c->c_ss; if (debug) (*lfun)(LOG_DEBUG, "%s: host4 %s", __func__, p); if (strcmp(p, "*") != 0) { if (conf_is_interface(p)) { if (!local) goto out2; if (debug) (*lfun)(LOG_DEBUG, "%s: interface %s", __func__, p); if (c->c_lmask != FSTAR) goto out1; sif->sif_family = AF_MAX; strlcpy(sif->sif_name, p, sizeof(sif->sif_name)); #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN sif->sif_len = sizeof(*sif); #endif port = &sif->sif_port; } else if (inet_pton(AF_INET, p, &sin->sin_addr) != -1) { sin->sin_family = AF_INET; #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN sin->sin_len = sizeof(*sin); #endif port = &sin->sin_port; } else goto out; } } if (getport(f, l, local, &c->c_port, pstr) == -1) return -1; if (port && c->c_port != FSTAR && c->c_port != FEQUAL) *port = htons((in_port_t)c->c_port); return 0; out: (*lfun)(LOG_ERR, "%s: %s, %zu: Bad address [%s]", __func__, f, l, pstr); return -1; out1: (*lfun)(LOG_ERR, "%s: %s, %zu: Can't specify mask %d with " "interface [%s]", __func__, f, l, c->c_lmask, p); return -1; out2: (*lfun)(LOG_ERR, "%s: %s, %zu: Interface spec does not make sense " "with remote config [%s]", __func__, f, l, p); return -1; }
KFR_SINTRIN bool bittestany(const vec<T, N>& x) { return getmask(x).value; }
int initsystem(void) { int r=0; int i,j; unsigned char m; int cfg[3]; srand(*(int *)0x0040006cL); clrscr(); m=*(unsigned char *)0xf000fffeL; if ((m==0xfe)||(m==0xfb)||(m==0xff)) for(i=0;i<256;i++) codekey[i]=codepcxt[i]; if ((m==0xfc)&&(!testce())) for(i=0;i<256;i++) codekey[i]=codeat[i]; initkbd(); if (bexist("speech.cfg")) { bload("speech.cfg",cfg,0L,6L); sndblast=cfg[0]; dacport=cfg[1]; speaker=cfg[2]; } else { printf("VGA 256Ko card required.\n\n"); printf(" SPEECH.CFG not found. Creating it...\n"); printf(" Erase it if you want to modify speech device.\n\n"); printf(" Please select your speech device:\n\n"); printf("0: no sound\n"); printf("1: internal speaker (only efficient on fast computers)\n"); printf("2: soundblaster card (22ch)\n"); printf("3: soundmaster+ card (22fh)\n"); printf("4: card using 'LPT1' (%xh)\n",*(int *)0x00400008L); printf("5: modify soundblaster base address\n"); printf("6: other DAC port\n"); do { r=getch(); if ((r>47)&&(r<55)) r-=48; else r=-1; } while(r==-1); if (r==1) { dacport=0x42; speaker=1; } if (r==2) { dacport=0x22c; sndblast=1; } if (r==3) dacport=0x22f; if (r==4) dacport=*(int *)0x00400008L; if (r==5) sndblast=1; if (r>4) { if (r==5) printf("soundblaster DAC port is base address + 00c\n"); else printf("Enter your EXACT DAC port (base address + correct offset)\n"); do { printf("Enter your DAC port:"); dacport=0; for(i=0;i<3;i++) { do { r=getch(); if ((r>47)&&(r<58)) r-=48; else if ((r>96)&&(r<103)) r-=87; else if ((r>64)&&(r<71)) r-=55; else r=-1; if (r!=-1) if (r<10) printf("%c",r+48); else printf("%c",r+55); } while(r==-1); dacport=dacport*16+r; } printf("\nIs %xh correct? (Yes/No)\n",dacport); r=getch(); } while((r!='y')&&(r!='Y')); } cfg[0]=sndblast; cfg[1]=dacport; cfg[2]=speaker; bmake("speech.cfg",cfg,6L); } if (initscreen()) { initmouse(); if (sndblast) sendinit(0xd1); if (speaker) inithp(); if (dacport) initspl(); r=1; for(i=0;i<16;i++) for(j=0;j<16;j++) { m=defaultmouse[i*16+j]; plot(j,i,(int)m); if (m==255) plot(j,i+16,0); else plot(j,i+16,255); } initbloc(&mousefond); initbloc(&mousebloc); getbloc(&mousebloc,0,0,16,16); getmask(&mousebloc,0,16); cls(); show(); } else { killkbd(); printf("\nVGA card not found.\n"); } return r; }
/*---------------------------------------------------------------------------- ; FUNCTION CODE ----------------------------------------------------------------------------*/ Int huffdecode( Int id_syn_ele, BITS *pInputStream, tDec_Int_File *pVars, tDec_Int_Chan *pChVars[]) { /*---------------------------------------------------------------------------- ; Define all local variables ----------------------------------------------------------------------------*/ Int ch; Int common_window; Int hasmask; Int status = SUCCESS; Int num_channels = 0; MC_Info *pMcInfo; per_chan_share_w_fxpCoef *pChLeftShare; /* Helper pointer */ per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */ /*---------------------------------------------------------------------------- ; Function body here ----------------------------------------------------------------------------*/ get9_n_lessbits( LEN_TAG, pInputStream); /* suppose an un-supported id_syn_ele will never be passed */ common_window = 0; if (id_syn_ele == ID_CPE) { common_window = get1bits(pInputStream); } pMcInfo = &pVars->mc_info; /* * check if provided info (num of channels) on audio config, * matches read bitstream data, if not, allow update only once. * In almost all cases it should match. */ #if 0 if ((pMcInfo->ch_info[0].cpe != id_syn_ele)) { if (pVars->mc_info.implicit_channeling) /* check done only once */ { pMcInfo->ch_info[0].cpe = id_syn_ele & 1; /* collect info from bitstream * implicit_channeling flag is locked * after 1st frame, to avoid toggling * parameter in the middle of the clip */ pMcInfo->nch = (id_syn_ele & 1) + 1; /* update number of channels */ } else { status = 1; /* ERROR break if syntax error persist */ } } #endif if (status == SUCCESS) { if (id_syn_ele == ID_SCE) { num_channels = 1; pVars->hasmask = 0; } else if (id_syn_ele == ID_CPE) { pChLeftShare = pChVars[LEFT]->pShareWfxpCoef; pChRightShare = pChVars[RIGHT]->pShareWfxpCoef; num_channels = 2; if (common_window != FALSE) { status = get_ics_info( (tMP4AudioObjectType) pVars->mc_info.audioObjectType, pInputStream, (Bool)common_window, (WINDOW_SEQUENCE *) & pChVars[LEFT]->wnd, (WINDOW_SHAPE *) & pChVars[LEFT]->wnd_shape_this_bk, pChLeftShare->group, (Int *) & pChLeftShare->max_sfb, pVars->winmap, (LT_PRED_STATUS *) & pChLeftShare->lt_status, (LT_PRED_STATUS *) & pChRightShare->lt_status); if (status == SUCCESS) { /* copy left channel info to right channel */ pChVars[RIGHT]->wnd = pChVars[LEFT]->wnd; pChVars[RIGHT]->wnd_shape_this_bk = pChVars[LEFT]->wnd_shape_this_bk; pChRightShare->max_sfb = pChLeftShare->max_sfb; pv_memcpy( pChRightShare->group, pChLeftShare->group, NSHORT*sizeof(pChLeftShare->group[0])); hasmask = getmask( pVars->winmap[pChVars[LEFT]->wnd], pInputStream, pChLeftShare->group, pChLeftShare->max_sfb, pVars->mask); if (hasmask == MASK_ERROR) { status = 1; /* ERROR code */ } pVars->hasmask = hasmask; } /* if (status == 0) */ } else { pVars->hasmask = 0; } /* if (common_window) */ } /* if (id_syn_ele) */ else if (id_syn_ele == ID_LFE) { num_channels = 1; pVars->hasmask = 0; } /* if (id_syn_ele) == ID_LFE */ } /* if (status) */ ch = 0; while ((ch < num_channels) && (status == SUCCESS)) { pChLeftShare = pChVars[ch]->pShareWfxpCoef; status = getics( pInputStream, common_window, pVars, pChVars[ch], pChLeftShare->group, &pChLeftShare->max_sfb, pChLeftShare->cb_map, &pChLeftShare->tns, pVars->winmap, &pVars->share.a.pulseInfo, pVars->share.a.sect); ch++; } /* while (ch) */ /*---------------------------------------------------------------------------- ; Return status ----------------------------------------------------------------------------*/ return status; } /* huffdecode */
void main(int argc, char *argv[]) { int dobroadcast, i, n; long diff; char *p; char buf[2*1024]; uint8_t raddr[Pasize]; Bnet *bn, **l; Udphdr *up; Rip *r; Ripmsg *m; Route route; static long btime; setnetmtpt(netdir, sizeof(netdir), nil); dobroadcast = 0; ARGBEGIN{ case 'b': dobroadcast++; break; case 'd': debug++; break; case 'n': readonly++; break; case 'x': p = ARGF(); if(p == nil) usage(); setnetmtpt(netdir, sizeof(netdir), p); break; default: usage(); }ARGEND /* specific broadcast nets */ l = &bnets; while(argc > 0){ bn = (Bnet*)malloc(sizeof(Bnet)); if(bn == 0) fatal(1, "out of mem"); v4parseip(bn->addr, *argv); *l = bn; l = &bn->next; argc--; argv++; dobroadcast++; } /* command returns */ if(!debug) switch(rfork(RFNOTEG|RFPROC|RFFDG|RFNOWAIT)) { case -1: fatal(1, "fork"); case 0: break; default: exits(0); } fmtinstall('E', eipfmt); fmtinstall('V', eipfmt); snprint(routefile, sizeof(routefile), "%s/iproute", netdir); snprint(buf, sizeof(buf), "%s/iproute", netdir); now = time(0); readifcs(); readroutes(); notify(ding); ripfd = openport(); for(;;) { diff = btime - time(0); if(diff <= 0){ if(dobroadcast) broadcast(); timeoutroutes(); btime = time(0) + 2*60; diff = 2*60; } alarm(diff*1000); n = read(ripfd, buf, sizeof(buf)); alarm(0); if(n <= 0) continue; n = (n - Udphdrsize - 4) / sizeof(Rip); if(n <= 0) continue; up = (Udphdr*)buf; m = (Ripmsg*)(buf+Udphdrsize); if(m->type != Response || m->vers != Version) continue; v6tov4(raddr, up->raddr); /* ignore our own messages */ for(i = 0; i < ialloc.nifc; i++) if(equivip(ialloc.ifc[i].addr, raddr)) continue; now = time(0); for(r = m->rip; r < &m->rip[n]; r++){ memmove(route.gate, raddr, Pasize); memmove(route.mask, getmask(r->addr), Pasize); v4maskip(r->addr, route.mask, route.dest); route.metric = nhgetl(r->metric) + 1; if(route.metric < 1) continue; considerroute(&route); } } /* not reached */ }
/* * read and decode the data for the next 1024 output samples * return -1 if there was an error */ int huffdecode(faacDecHandle hDecoder, int id, MC_Info *mip, byte *win, Wnd_Shape *wshape, byte **cb_map, int **factors, byte **group, byte *hasmask, byte **mask, byte *max_sfb, int **lpflag, int **prstflag, NOK_LT_PRED_STATUS **nok_ltp_status, TNS_frame_info **tns, Float **coef) { int i, tag, common_window, ch, widx, first=0, last=0; int global_gain; /* not used in this routine */ Info info; tag = faad_getbits(&hDecoder->ld, LEN_TAG); switch(id) { case ID_SCE: common_window = 0; break; case ID_CPE: common_window = faad_get1bit(&hDecoder->ld); /* common_window */ break; default: /* CommonWarning("Unknown id"); */ return(-1); } if ((ch = chn_config(hDecoder, id, tag, common_window, mip)) < 0) return -1; switch(id) { case ID_SCE: widx = mip->ch_info[ch].widx; first = ch; last = ch; hasmask[widx] = 0; break; case ID_CPE: first = ch; last = mip->ch_info[ch].paired_ch; if (common_window) { widx = mip->ch_info[ch].widx; if (!get_ics_info(hDecoder, &win[widx], &wshape[widx].this_bk, group[widx], &max_sfb[widx], lpflag[widx], prstflag[widx], nok_ltp_status[widx],nok_ltp_status[mip->ch_info[ch].paired_ch], common_window)) return -1; hasmask[widx] = getmask(hDecoder, hDecoder->winmap[win[widx]], group[widx], max_sfb[widx], mask[widx]); } else { hasmask[mip->ch_info[first].widx] = 0; hasmask[mip->ch_info[last].widx] = 0; } break; } for (i=first; i<=last; i++) { widx = mip->ch_info[i].widx; SetMemory(coef[i], 0, LN2*sizeof(Float)); if(!getics(hDecoder, &info, common_window, &win[widx], &wshape[widx].this_bk, group[widx], &max_sfb[widx], lpflag[widx], prstflag[widx], cb_map[i], coef[i], &global_gain, factors[i], nok_ltp_status[widx], tns[i])) return -1; } return 0; }