int check(char *tetri) { int i; int j; int *tab; int count; tab = malloc(sizeof(int) * 4); newtab(tab); j = 0; count = 0; i = 0; while (j < 20) { if (tetri[j] == '#' && i <= 3) tab[i++] = counttetri(tetri, j); else if (tetri[j] == '#' && i > 3) j = 53; else if (tetri[j] == '\n') count++; else if (tetri[j] != '.') j = 53; j++; } if (j > 53 || !checkline(tetri, tab)) return (0); return (1); }
static bool readlinedata(int fd, struct expectdata *expect, int outfd) { ssize_t got; int i, linestart; got = read(fd, expect->buffer+expect->len, sizeof(expect->buffer)-expect->len); if( got == 0 ) { /* End of file */ if( expect->len > 0 ) { expect->malformed++; checkline(expect->buffer, expect->len, expect, outfd); } return true; } if( got < 0 ) { fprintf(stderr, "%s: Error reading data: %s\n", program_invocation_short_name, strerror(errno)); return true; } linestart = 0; for( i = expect->len ; i < (int)(expect->len+got) ; i++ ) { if( expect->buffer[i] == '\n' ) { if( ! expect->overrun ) checkline(expect->buffer+linestart, i-linestart+1, expect, outfd); expect->overrun = false; linestart = i+1; } if( expect->buffer[i] == '\0' ) { expect->malformed++; expect->buffer[i] = '0'; } } expect->len += got; if( linestart == 0 && expect->len == sizeof(expect->buffer) ) { expect->overrun = true; expect->overlong++; checkline(expect->buffer, expect->len, expect, outfd); expect->len = 0; } else if( linestart == (int)expect->len ) expect->len = 0; else { expect->len -= linestart; memmove(expect->buffer, expect->buffer+linestart, expect->len); } return false; }
static int iscodefence(Line *r, int size) { if ( !(r->flags & CHECKED) ) checkline(r); return (r->kind == chk_tilde) && (r->count >= size); }
static const char* skip_space(const char* s) { while ( isspace(*s) ) { checkline(*s); ++s; } return s; }
static inline int ishr(Line *t) { if ( ! (t->flags & CHECKED) ) checkline(t); if ( t->count > 2 ) return t->kind == chk_hr || t->kind == chk_dash || t->kind == chk_equal; return 0; }
static int iscodefence(Line *r, int size, line_type kind) { if ( !(r->flags & CHECKED) ) checkline(r); if ( kind ) return (r->kind == kind) && (r->count >= size); else return (r->kind == chk_tilde || r->kind == chk_backtick) && (r->count >= size); }
main() { double sum, val, atof(char []); char line[MAXLINE]; int checkline(char line[], int max); sum = 0; while (checkline(line, MAXLINE) > 0) printf("Value: %f, Summary:%f\n", val, sum += (val = atof(line))); return 0; }
static const char* copy_while( char *dest, const char* src, size_t destsize, bool (*while_expr)(const char*)) { while ( *src!='\0' && destsize-- && while_expr(src) ) { checkline(*src); *dest++ = *src++; } *dest = '\0'; return src; }
static int iscodefence(Line *r, int size, line_type kind, DWORD flags) { if ( !(flags & MKD_FENCEDCODE) ) return 0; if ( !(r->flags & CHECKED) ) checkline(r, flags); if ( kind ) return (r->kind == kind) && (r->count >= size); else return (r->kind == chk_tilde || r->kind == chk_backtick) && (r->count >= size); }
bool sbbs_t::msgabort() { static ulong counter; if(sys_status&SS_SYSPAGE && !(++counter%100)) sbbs_beep(sbbs_random(800),1); checkline(); if(sys_status&SS_ABORT) return(true); if(!online) return(true); return(false); }
int htoi(char s[]) { int answer; int i=0; if(checkline(s) != 1 ) { return (-1); } for(answer=0;ishex(s[i])/*isxdigit(s[i])*/;i++) { if(isdigit(s[i])){answer = 16 * answer + (s[i]-'0');} if(isupper(s[i])){answer = 16 * answer + (s[i]-'A') + 10;} if(islower(s[i])){answer = 16 * answer + (s[i]-'a') + 10;} } return answer; }
static int issetext(Line *t, int *htyp) { Line *n; /* check for setext-style HEADER * ====== */ if ( (n = t->next) ) { if ( !(n->flags & CHECKED) ) checkline(n); if ( n->kind == chk_dash || n->kind == chk_equal ) { *htyp = SETEXT; return 1; } } return 0; }
static int filter_frame(AVFilterLink *inlink, AVFrame *frame) { AVFilterContext *ctx = inlink->dst; CropDetectContext *s = ctx->priv; int bpp = s->max_pixsteps[0]; int w, h, x, y, shrink_by; AVDictionary **metadata; // ignore first 2 frames - they may be empty if (++s->frame_nb > 0) { metadata = avpriv_frame_get_metadatap(frame); // Reset the crop area every reset_count frames, if reset_count is > 0 if (s->reset_count > 0 && s->frame_nb > s->reset_count) { s->x1 = frame->width - 1; s->y1 = frame->height - 1; s->x2 = 0; s->y2 = 0; s->frame_nb = 1; } for (y = 0; y < s->y1; y++) { if (checkline(ctx, frame->data[0] + frame->linesize[0] * y, bpp, frame->width, bpp) > s->limit) { s->y1 = y; break; } } for (y = frame->height - 1; y > FFMAX(s->y2, s->y1); y--) { if (checkline(ctx, frame->data[0] + frame->linesize[0] * y, bpp, frame->width, bpp) > s->limit) { s->y2 = y; break; } } for (y = 0; y < s->x1; y++) { if (checkline(ctx, frame->data[0] + bpp*y, frame->linesize[0], frame->height, bpp) > s->limit) { s->x1 = y; break; } } for (y = frame->width - 1; y > FFMAX(s->x2, s->x1); y--) { if (checkline(ctx, frame->data[0] + bpp*y, frame->linesize[0], frame->height, bpp) > s->limit) { s->x2 = y; break; } } // round x and y (up), important for yuv colorspaces // make sure they stay rounded! x = (s->x1+1) & ~1; y = (s->y1+1) & ~1; w = s->x2 - x + 1; h = s->y2 - y + 1; // w and h must be divisible by 2 as well because of yuv // colorspace problems. if (s->round <= 1) s->round = 16; if (s->round % 2) s->round *= 2; shrink_by = w % s->round; w -= shrink_by; x += (shrink_by/2 + 1) & ~1; shrink_by = h % s->round; h -= shrink_by; y += (shrink_by/2 + 1) & ~1; SET_META("lavfi.cropdetect.x1", s->x1); SET_META("lavfi.cropdetect.x2", s->x2); SET_META("lavfi.cropdetect.y1", s->y1); SET_META("lavfi.cropdetect.y2", s->y2); SET_META("lavfi.cropdetect.w", w); SET_META("lavfi.cropdetect.h", h); SET_META("lavfi.cropdetect.x", x); SET_META("lavfi.cropdetect.y", y); av_log(ctx, AV_LOG_INFO, "x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pts:%"PRId64" t:%f crop=%d:%d:%d:%d\n", s->x1, s->x2, s->y1, s->y2, w, h, x, y, frame->pts, frame->pts == AV_NOPTS_VALUE ? -1 : frame->pts * av_q2d(inlink->time_base), w, h, x, y); } return ff_filter_frame(inlink->dst->outputs[0], frame); }
void sbbs_t::new_scan_ptr_cfg() { uint i,j; long s; uint32_t l; time_t t; while(online) { bputs(text[CfgGrpLstHdr]); for(i=0;i<usrgrps && !msgabort();i++) { checkline(); if(i<9) outchar(' '); if(i<99) outchar(' '); bprintf(text[CfgGrpLstFmt],i+1,cfg.grp[usrgrp[i]]->lname); } SYNC; mnemonics(text[WhichOrAll]); s=getkeys("AQ",usrgrps); if(!s || s==-1 || s=='Q') break; if(s=='A') { mnemonics("\r\nEnter number of messages from end, ~Date, ~Quit, or" " [Last Message]: "); s=getkeys("DLQ",9999); if(s==-1 || s=='Q') continue; if(s=='D') { t=time(NULL); if(inputnstime(&t) && !(sys_status&SS_ABORT)) { bputs(text[LoadingMsgPtrs]); for(i=0;i<usrgrps && online;i++) for(j=0;j<usrsubs[i] && online;j++) { checkline(); subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t); } } continue; } if(s=='L') s=0; if(s) s&=~0x80000000L; bputs(text[LoadingMsgPtrs]); for(i=0;i<usrgrps;i++) for(j=0;j<usrsubs[i] && online;j++) { checkline(); getlastmsg(usrsub[i][j],&l,0); if(s>(long)l) subscan[usrsub[i][j]].ptr=0; else subscan[usrsub[i][j]].ptr=l-s; } continue; } i=(s&~0x80000000L)-1; while(online) { l=0; bprintf(text[CfgSubLstHdr],cfg.grp[usrgrp[i]]->lname); for(j=0;j<usrsubs[i] && !msgabort();j++) { checkline(); if(j<9) outchar(' '); if(j<99) outchar(' '); t=getmsgtime(usrsub[i][j],subscan[usrsub[i][j]].ptr); if(t>(long)l) l=(uint32_t)t; bprintf(text[SubPtrLstFmt],j+1,cfg.sub[usrsub[i][j]]->lname ,timestr(t),nulstr); } SYNC; mnemonics(text[WhichOrAll]); s=getkeys("AQ",usrsubs[i]); if(sys_status&SS_ABORT) { lncntr=0; return; } if(s==-1 || !s || s=='Q') break; if(s=='A') { /* The entire group */ mnemonics("\r\nEnter number of messages from end, ~Date, ~Quit, or" " [Last Message]: "); s=getkeys("DLQ",9999); if(s==-1 || s=='Q') continue; if(s=='D') { t=l; if(inputnstime(&t) && !(sys_status&SS_ABORT)) { bputs(text[LoadingMsgPtrs]); for(j=0;j<usrsubs[i] && online;j++) { checkline(); subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t); } } continue; } if(s=='L') s=0; if(s) s&=~0x80000000L; bputs(text[LoadingMsgPtrs]); for(j=0;j<usrsubs[i] && online;j++) { checkline(); getlastmsg(usrsub[i][j],&l,0); if(s>(long)l) subscan[usrsub[i][j]].ptr=0; else subscan[usrsub[i][j]].ptr=l-s; } continue; } else { j=(s&~0x80000000L)-1; mnemonics("\r\nEnter number of messages from end, ~Date, ~Quit, or" " [Last Message]: "); s=getkeys("DLQ",9999); if(s==-1 || s=='Q') continue; if(s=='D') { t=getmsgtime(usrsub[i][j],subscan[usrsub[i][j]].ptr); if(inputnstime(&t) && !(sys_status&SS_ABORT)) { bputs(text[LoadingMsgPtrs]); subscan[usrsub[i][j]].ptr=getmsgnum(usrsub[i][j],t); } continue; } if(s=='L') s=0; if(s) s&=~0x80000000L; getlastmsg(usrsub[i][j],&l,0); if(s>(long)l) subscan[usrsub[i][j]].ptr=0; else subscan[usrsub[i][j]].ptr=l-s; } } } }
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi; int bpp=mpi->bpp/8; int w,h,x,y,shrink_by; // hope we'll get DR buffer: dmpi=vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h); dmpi->planes[0]=mpi->planes[0]; dmpi->planes[1]=mpi->planes[1]; dmpi->planes[2]=mpi->planes[2]; dmpi->stride[0]=mpi->stride[0]; dmpi->stride[1]=mpi->stride[1]; dmpi->stride[2]=mpi->stride[2]; dmpi->width=mpi->width; dmpi->height=mpi->height; if(++vf->priv->fno>0){ // ignore first 2 frames - they may be empty // Reset the crop area every reset_count frames, if reset_count is > 0 if(vf->priv->reset_count > 0 && vf->priv->fno > vf->priv->reset_count){ vf->priv->x1=mpi->w-1; vf->priv->y1=mpi->h-1; vf->priv->x2=0; vf->priv->y2=0; vf->priv->fno=1; } for(y=0;y<vf->priv->y1;y++){ if(checkline(mpi->planes[0]+mpi->stride[0]*y,bpp,mpi->w,bpp)>vf->priv->limit){ vf->priv->y1=y; break; } } for(y=mpi->h-1;y>vf->priv->y2;y--){ if(checkline(mpi->planes[0]+mpi->stride[0]*y,bpp,mpi->w,bpp)>vf->priv->limit){ vf->priv->y2=y; break; } } for(y=0;y<vf->priv->x1;y++){ if(checkline(mpi->planes[0]+bpp*y,mpi->stride[0],mpi->h,bpp)>vf->priv->limit){ vf->priv->x1=y; break; } } for(y=mpi->w-1;y>vf->priv->x2;y--){ if(checkline(mpi->planes[0]+bpp*y,mpi->stride[0],mpi->h,bpp)>vf->priv->limit){ vf->priv->x2=y; break; } } // round x and y (up), important for yuv colorspaces // make sure they stay rounded! x=(vf->priv->x1+1)&(~1); y=(vf->priv->y1+1)&(~1); w = vf->priv->x2 - x + 1; h = vf->priv->y2 - y + 1; // w and h must be divisible by 2 as well because of yuv // colorspace problems. if (vf->priv->round <= 1) vf->priv->round = 16; if (vf->priv->round % 2) vf->priv->round *= 2; shrink_by = w % vf->priv->round; w -= shrink_by; x += (shrink_by / 2 + 1) & ~1; shrink_by = h % vf->priv->round; h -= shrink_by; y += (shrink_by / 2 + 1) & ~1; mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea, vf->priv->x1,vf->priv->x2, vf->priv->y1,vf->priv->y2, w,h,x,y); } return vf_next_put_image(vf,dmpi, pts); }
void sbbs_t::new_scan_cfg(ulong misc) { long s; ulong i,j; ulong t; while(online) { bputs(text[CfgGrpLstHdr]); for(i=0;i<usrgrps && !msgabort();i++) { checkline(); if(i<9) outchar(' '); if(i<99) outchar(' '); bprintf(text[CfgGrpLstFmt],i+1,cfg.grp[usrgrp[i]]->lname); } SYNC; if(misc&SUB_CFG_NSCAN) mnemonics(text[NScanCfgWhichGrp]); else mnemonics(text[SScanCfgWhichGrp]); s=getnum(i); if(s<1) break; i=s-1; while(online) { if(misc&SUB_CFG_NSCAN) misc&=~SUB_CFG_YSCAN; bprintf(text[CfgSubLstHdr],cfg.grp[usrgrp[i]]->lname); for(j=0;j<usrsubs[i] && !msgabort();j++) { checkline(); if(j<9) outchar(' '); if(j<99) outchar(' '); bprintf(text[CfgSubLstFmt],j+1 ,cfg.sub[usrsub[i][j]]->lname ,subscan[usrsub[i][j]].cfg&misc ? (misc&SUB_CFG_NSCAN && subscan[usrsub[i][j]].cfg&SUB_CFG_YSCAN) ? "To You Only" : text[On] : text[Off]); } SYNC; if(misc&SUB_CFG_NSCAN) mnemonics(text[NScanCfgWhichSub]); else mnemonics(text[SScanCfgWhichSub]); s=getkeys("AQ",usrsubs[i]); if(sys_status&SS_ABORT) { lncntr=0; return; } if(!s || s==-1 || s=='Q') break; if(s=='A') { t=subscan[usrsub[i][0]].cfg&misc; if(misc&SUB_CFG_NSCAN && !t && !(useron.misc&FLAG('Q'))) if(!noyes("Messages to you only")) misc|=SUB_CFG_YSCAN; for(j=0;j<usrsubs[i] && online;j++) { checkline(); if(t) subscan[usrsub[i][j]].cfg&=~misc; else { if(misc&SUB_CFG_NSCAN) subscan[usrsub[i][j]].cfg&=~SUB_CFG_YSCAN; subscan[usrsub[i][j]].cfg|=misc; } } continue; } j=(s&~0x80000000L)-1; if(misc&SUB_CFG_NSCAN && !(subscan[usrsub[i][j]].cfg&misc)) { if(!(useron.rest&FLAG('Q')) && !noyes("Messages to you only")) subscan[usrsub[i][j]].cfg|=SUB_CFG_YSCAN; else subscan[usrsub[i][j]].cfg&=~SUB_CFG_YSCAN; } subscan[usrsub[i][j]].cfg^=misc; } } }
/* Important change as of Nov-16-2006, 'cmdline' may contain args */ long sbbs_t::exec_bin(const char *cmdline, csi_t *csi, const char* startup_dir) { char str[MAX_PATH+1]; char mod[MAX_PATH+1]; char modname[MAX_PATH+1]; char* p; int file; csi_t bin; SAFECOPY(mod,cmdline); p=mod; FIND_CHAR(p,' '); if(*p) { *p=0; /* terminate 'mod' */ p++; /* skip space */ SKIP_CHAR(p,' '); /* skip more spaces */ } if(*p) strcpy(main_csi.str, p); #ifdef JAVASCRIPT if((p=getfext(mod))!=NULL && stricmp(p,".js")==0) return(js_execfile(cmdline, startup_dir)); if(p==NULL && startup_dir!=NULL && *startup_dir) { SAFEPRINTF2(str,"%s%s.js", startup_dir, mod); if(fexistcase(str)) return(js_execfile(cmdline, startup_dir)); } if(cfg.mods_dir[0]) { SAFEPRINTF2(str,"%s%s.js",cfg.mods_dir,mod); if(fexistcase(str)) return(js_execfile(cmdline, startup_dir)); } #endif SAFECOPY(modname,mod); if(!strchr(modname,'.')) strcat(modname,".bin"); SAFEPRINTF2(str,"%s%s",cfg.mods_dir,modname); if(cfg.mods_dir[0]==0 || !fexistcase(str)) { #ifdef JAVASCRIPT SAFEPRINTF2(str,"%s%s.js",cfg.exec_dir,mod); if(fexistcase(str)) return(js_execfile(cmdline, startup_dir)); #endif SAFEPRINTF2(str,"%s%s",cfg.exec_dir,modname); fexistcase(str); } if((file=nopen(str,O_RDONLY))==-1) { errormsg(WHERE,ERR_OPEN,str,O_RDONLY); return(-1); } memcpy(&bin,csi,sizeof(csi_t)); clearvars(&bin); bin.length=(uint32_t)filelength(file); if((bin.cs=(uchar *)malloc(bin.length))==NULL) { close(file); errormsg(WHERE,ERR_ALLOC,str,bin.length); return(-1); } if(lread(file,bin.cs,bin.length)!=bin.length) { close(file); errormsg(WHERE,ERR_READ,str,bin.length); free(bin.cs); return(-1); } close(file); bin.ip=bin.cs; bin.rets=0; bin.cmdrets=0; bin.misc=0; while(exec(&bin)==0) if(!(bin.misc&CS_OFFLINE_EXEC)) { checkline(); if(!online) break; } freevars(&bin); free(bin.cs); csi->logic=bin.logic; return(bin.retval); }
static void end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; CropDetectContext *cd = ctx->priv; AVFilterBufferRef *picref = inlink->cur_buf; int bpp = cd->max_pixsteps[0]; int w, h, x, y, shrink_by; // ignore first 2 frames - they may be empty if (++cd->frame_nb > 0) { // Reset the crop area every reset_count frames, if reset_count is > 0 if (cd->reset_count > 0 && cd->frame_nb > cd->reset_count) { cd->x1 = picref->video->w-1; cd->y1 = picref->video->h-1; cd->x2 = 0; cd->y2 = 0; cd->frame_nb = 1; } for (y = 0; y < cd->y1; y++) { if (checkline(ctx, picref->data[0] + picref->linesize[0] * y, bpp, picref->video->w, bpp) > cd->limit) { cd->y1 = y; break; } } for (y = picref->video->h-1; y > cd->y2; y--) { if (checkline(ctx, picref->data[0] + picref->linesize[0] * y, bpp, picref->video->w, bpp) > cd->limit) { cd->y2 = y; break; } } for (y = 0; y < cd->x1; y++) { if (checkline(ctx, picref->data[0] + bpp*y, picref->linesize[0], picref->video->h, bpp) > cd->limit) { cd->x1 = y; break; } } for (y = picref->video->w-1; y > cd->x2; y--) { if (checkline(ctx, picref->data[0] + bpp*y, picref->linesize[0], picref->video->h, bpp) > cd->limit) { cd->x2 = y; break; } } // round x and y (up), important for yuv colorspaces // make sure they stay rounded! x = (cd->x1+1) & ~1; y = (cd->y1+1) & ~1; w = cd->x2 - x + 1; h = cd->y2 - y + 1; // w and h must be divisible by 2 as well because of yuv // colorspace problems. if (cd->round <= 1) cd->round = 16; if (cd->round % 2) cd->round *= 2; shrink_by = w % cd->round; w -= shrink_by; x += (shrink_by/2 + 1) & ~1; shrink_by = h % cd->round; h -= shrink_by; y += (shrink_by/2 + 1) & ~1; av_log(ctx, AV_LOG_INFO, "x1:%d x2:%d y1:%d y2:%d w:%d h:%d x:%d y:%d pos:%"PRId64" pts:%"PRId64" t:%f crop=%d:%d:%d:%d\n", cd->x1, cd->x2, cd->y1, cd->y2, w, h, x, y, picref->pos, picref->pts, picref->pts == AV_NOPTS_VALUE ? -1 : picref->pts * av_q2d(inlink->time_base), w, h, x, y); } avfilter_end_frame(inlink->dst->outputs[0]); }
// Checks for carrier loss, exit door if so void checkCarrier() { checkline(); }