static void scbox_get_hseg(Clipbox *cb,void *pbuf,Coor x,Coor y, Ucoor width) { Coor rwid; Raster *root; root = cb->root; if(((Ucoor)(y += cb->y)) >= root->height) goto clear_seg; if((x += cb->x) < 0) { if(width < (x = -x)) goto clear_seg; pj_stuff_bytes(0,pbuf,x); pbuf = OPTR(pbuf,x); width -= x; x = 0; } if(((Coor)width) <= 0) return; if(x < (rwid = root->width)) { if(width < rwid) rwid = width; GET_HSEG(root, pbuf, x, y, rwid); if((width -= rwid) == 0) return; pbuf = OPTR(pbuf,rwid); } clear_seg: pj_stuff_bytes(0,pbuf,width); }
Type_info *po_new_type_info(Poco_cb *pcb, Type_info *old, int extras) /***************************************************************************** * allocate and init a new type_info structure, based on an old one. * typically, the old one will be allocated on somebody's local stack; they * call here when ready to allocate a permenant type_info to tie to a symbol. ****************************************************************************/ { Type_info *newt; int lsize,csize; int noff; int ocount; ocount = old->comp_count + extras; lsize = ocount*sizeof(Pt_long); csize = ocount*sizeof(TypeComp); newt = po_memzalloc(pcb, sizeof(*newt) + lsize + csize); *newt = *old; newt->comp_count = old->comp_count; newt->comp_alloc = ocount; noff = sizeof(*newt); newt->sdims = OPTR(newt,noff); poco_copy_bytes(old->sdims, newt->sdims, lsize); noff += lsize; newt->comp = OPTR(newt,noff); poco_copy_bytes(old->comp, newt->comp, csize); return(newt); }
static void scbox_get_vseg(Clipbox *cb,void *pbuf,Coor x,Coor y, Ucoor height) { Coor rht; Raster *root; root = cb->root; if(((Ucoor)(x += cb->x)) >= root->width) goto clear_seg; if((y += cb->y) < 0) { if(height < (y = -y)) goto clear_seg; pj_stuff_bytes(0,pbuf,y); pbuf = OPTR(pbuf,y); height -= y; y = 0; } if(((Coor)height) <= 0) return; if(x < (rht = root->height)) { if(height < rht) rht = height; GET_VSEG(root, pbuf, x, y, rht); if((height -= rht) == 0) return; pbuf = OPTR(pbuf,rht); } clear_seg: pj_stuff_bytes(0,pbuf,height); }
void copy_fhead_common(Fli_head *sh, Fli_head *dh) { /* copys all but magic, filesize, or user lock fields between * two fli headers */ copy_mem(OPTR(sh,sizeof(Chunk_id)), OPTR(dh,sizeof(Chunk_id)), FLIH_COMMONSIZE - sizeof(Chunk_id)); }
static Errcode read_abort_rec() { Errcode err; int readsize; Mcb.ar.flags = Mcb.next.b[0]; if(0 != (readsize = Mcb.ar.flags & AR_ABORTLEVEL)) { ((UBYTE *)(&Mcb.ar))[1] = Mcb.next.b[1]; /* readsize = num levels counts - one byte + sizeof next */ Mcb.mab_level = (readsize /= ABORTLEVEL_1) - 1; readsize = (readsize * sizeof(USHORT)) - 1 + sizeof(USHORT); if((err = ffread(Mcb.fp,OPTR(Mcb.ar.counts,1),readsize)) < Success) return(macro_write_error(err)); Mcb.sizeleft -= readsize; Mcb.next.flags = *((USHORT *)(OPTR(&Mcb.ar,readsize))); } else /* one byte non abort poll end record move last byte * to first and fetch next byte in file */ { Mcb.next.b[0] = Mcb.next.b[1]; Mcb.next.b[1] = ffgetc(Mcb.fp); --Mcb.sizeleft; } return(Success); }
static int po_dir_list(Popot ppdest, Popot ppat, int get_dirs) /***************************************************************************** * int DirList(char ***list, char *wild, Boolean get dirs); ****************************************************************************/ { Popot *pdest; char *pat; Names *wld, *w; int name_count; long mem_size; Popot result; int slen; char *spt; Popot *ppp; if ((pdest = ppdest.pt) == NULL || (pat = ppat.pt) == NULL) return(builtin_err = Err_null_ref); result.min = result.max = result.pt = NULL; build_wild_list(&wld,pat,get_dirs); mem_size = 0; name_count = 0; w = wld; while (w != NULL) { mem_size += sizeof(Popot)+strlen(w->name)+1; name_count += 1; w = w->next; } if (name_count == 0) goto OUT; result = po_malloc(mem_size); if (result.pt == NULL) { name_count = Err_no_memory; goto OUT; } ppp = result.pt; spt = OPTR(result.pt,name_count*sizeof(Popot)); /* set pointer bounds to just Popot array, not string space */ result.max = OPTR(spt,-1); w = wld; while (w != NULL) { slen = strlen(w->name); ppp->min = ppp->max = ppp->pt = spt; ppp->max = OPTR(ppp->max,slen); ppp += 1; slen += 1; pj_copy_bytes(w->name, spt, slen); spt += slen; w = w->next; } OUT: free_wild_list(&wld); *pdest = result; return(name_count); }
static Errcode rnd_read_first_frame(Image_file *ifile, Rcel *screen) /* Now that we know the rnd file has a depth <= 8 bits draw it in the * screen */ { Rfile *rf = (Rfile *)ifile; if(rf->lasterr < Success) /* open and scan must have failed */ return(rf->lasterr); cleanup_buffers(rf); if((rf->pktbuf = malloc(PKT_BUFSIZE+rf->ainfo.width)) == NULL) return(Err_no_memory); rf->pixbuf = OPTR(rf->pktbuf,PKT_BUFSIZE); rewind(rf->file); /* clear errors and re-init */ rf->lasterr = Success; rf->screen = screen; if(rf_seek(rf,sizeof(Rndhdr),SEEK_SET) < Success) goto error; return(read_256_color_frame(rf)); error: return(rf->lasterr); }
static Cliphead *link_free_clips(Cliphead *first,LONG clipsize,LONG allocsize) { register Cliphead *clip; register Cliphead *max_clip; clip = first; max_clip = OPTR(clip,allocsize); for(;;) { if((clip->nextfree = OPTR(clip,clipsize)) >= max_clip) break; clip = clip->nextfree; } clip->nextfree = NULL; return(first); }
void zero_lots(void *pt, LONG size) { int lsize; size >>=1; /* convert to word count */ while (size > 0) { if (size > 32000) lsize = 32000; else lsize = size; pj_stuff_words(0, pt, lsize); pt = norm_pointer(OPTR(pt,lsize)); pt = norm_pointer(OPTR(pt,lsize)); size -= lsize; } }
static char geta_ftextfchar(Ftextfarg *fa) { char retchar; char *tend; Ft_arginfo *ai; unsigned long argnum; get_another_char: if((retchar = *(fa->text)++) != '!' || *fa->text != '[') return(retchar); if((argnum = strtol(fa->text + 1, &tend,10)) <= 0) goto error; if(argnum > fa->numargs) goto error; if(*tend != ']') goto error; fa->text = tend + 1; /* set to next text buffer char */ ai = &(fa->ai[argnum-1]); fa->fa.fmt = (char *)OPTR(fa->formats,ai->fmt_oset); /* you can see that if the va_list isn't a pointer to the stack this will * not work */ *((void **)&(fa->fa.args)) = OPTR(*((void **)&(fa->va_root)),ai->va_oset); /* if we exaust this format we still continue so we go back (to top of * this function) and check the next char in the higfh level format */ if((retchar = geta_fmtchar(&fa->fa)) == 0) goto get_another_char; return(retchar); error: fa->fa.fmt = --fa->text; fa->fa.error = Err_bad_argnum; return(0); }
static void bym_put_rectpix(Bytemap *r,void *pixbuf, Coor x,Coor y,Ucoor width,Ucoor height) /* loads all pixels from a linear pixel buffer into a screen rectangle * on a line by line basis (could be faster) */ { while(height--) { pj_bym_put_hseg(r,pixbuf,x,y++,width); pixbuf = OPTR(pixbuf,width); } }
void dump_code(Poco_cb *pcb, FILE *file, void *code, long csize) /***************************************************************************** * disassmble lots of ops. ****************************************************************************/ { void *end; end = OPTR(code,csize); while (code < end) { code = po_disasm(file, code, (C_frame *)(pcb->run.protos)); } fflush(file); }
static int shrink_uncompfli(Rcel *f,Chunk_id *chunk,int count,int sw,int sh, int dw, int dh, Boolean do_colors) /* returns compression type of frame found and decompressed. does not do * anything for a FLI_COLOR_0 record */ { int type = 0; while(count-- > 0) { switch (chunk->type) { case FLI_COLOR: if(do_colors) pj_fcuncomp64(chunk+1,f->cmap->ctab); break; case FLI_COLOR256: if(do_colors) pj_fcuncomp(chunk+1,f->cmap->ctab); break; /* case FPS_BRUN: note value is FPS_BRUN */ case FLI_BRUN: { type = chunk->type; pj_unbrun_scale_rect(f,chunk + 1, sw, sh, 0,0,dw,dh); break; } /* case FPS_COPY: note value is FLI_COPY */ case FLI_COPY: { Bytemap bm; Rasthdr spec; type = chunk->type; spec.width = sw; spec.height = sh; spec.pdepth = 8; pj_build_bytemap(&spec,(Raster *)&bm,(UBYTE *)(chunk + 1)); pj_scale_blit(&bm,0,0,sw,sh,f,0,0,dw,dh,NULL); break; } case FLI_COLOR_0: /* note that this does nothing but set type */ type = chunk->type; default: break; } chunk = (Chunk_id *)OPTR(chunk,chunk->size); } return(type); }
static void bym_get_rectpix(Bytemap *r,void *pixbuf, Coor x,Coor y,Ucoor width,Ucoor height) /* loads all pixels from a screen rectangle into a linear buffer * on a line by line basis. * For now assumes pixsize is 1 if the rectangle is clipped garbage will * be in the clipped off section of the buffer (could be faster) */ { while(height--) { pj_bym_get_hseg(r,pixbuf,x,y++,width); pixbuf = OPTR(pixbuf,width); } }
static void _wr1os_put_rectpix(Wndo *w,void *pixbuf, Coor x,Coor y,Ucoor width,Ucoor height) { Raster *r = w->rasts[w->onerast]; x += w->behind.x - r->x; y += w->behind.y - r->y; while(height-- > 0) { PUT_HSEG(r,pixbuf,x,y++,width); pixbuf = OPTR(pixbuf,width); } }
static void _grc_get_rectpix(Raster *v, Pixel *pixbuf, Coor x, Coor y, Ucoor width, Ucoor height) /* Move a rectangular area of raster into a memory buffer. (Much like a blit, but assumes destination is memory and that the width and height of the move are the same size as the memory buffer. */ /* (Clipped.) */ { while(height-- > 0) { GET_HSEG(v,pixbuf,x,y++,width); pixbuf = OPTR(pixbuf,width); } }
static void grc_put_rectpix(Raster *v, Pixel *pixbuf, Coor x, Coor y, Ucoor width, Ucoor height) /* Move pixels from a memory buffer into a rectangular area of the destination raster. (Much like a blit, but assumes source is in memory, and all of source is used.) */ /* (Clipped.) */ { assert(x >= 0 && y >= 0); while(height--) { pj_put_hseg(v,pixbuf,x,y++,width); pixbuf = OPTR(pixbuf,width); } }
Errcode update_parsed_chunk(Chunkparse_data *pd, void *buf) /* rewrites but does not alter size of parsed chunk must have same type and * size fields This depends on the version field following the size and type * fields in the Fat_chunk */ { if(((Fat_chunk *)buf)->size != pd->fchunk.size || ((Fat_chunk *)buf)->type != pd->fchunk.type) { return(Err_bad_input); } if(pd->data_size <= 0) return(Success); return(pj_write_ecode(pd->fd,OPTR(buf,sizeof(Chunk_id)),pd->data_size)); }
void default_common_str() /* make 'ok', 'continue', etc same as they're symbol names so will * appear in English ok at least in error conditions */ { Smu_name_scats *ss = common_keys; Smu_name_scats *maxss = OPTR(common_keys,sizeof(common_keys)); while(ss < maxss) { *(ss->toload.ps) = ss->name; /* reasonable default on error */ ++ss; } any_continue = "Any key to continue >"; enter_choice = "Enter choice >"; please_wait_str = "Please Wait:"; }
static void _wr1os_get_rectpix(Raster *wndo, Pixel *pixbuf, Coor x, Coor y, Ucoor width, Ucoor height) { Wndo *w = (Wndo *)wndo; Raster *r = w->rasts[w->onerast]; x += w->behind.x - r->x; y += w->behind.y - r->y; while(height-- > 0) { GET_HSEG(r,pixbuf,x,y++,width); pixbuf = OPTR(pixbuf,width); } }
void pj_put_vseg(Raster *v,void *pixbuf, Coor x,Coor y,Ucoor height) /* Move pixels from memory to a vertical line of destination raster. */ /* (Clipped will put pixels in destination that overlap) */ { if(y >= (Coor)(v->height)) return; if(((Ucoor)x) >= v->width) return; if(y < 0) { height += y; pixbuf = OPTR(pixbuf,-y); y = 0; } if(((Coor)height) <= 0) return; height += y; if (height > v->height) height = v->height; PUT_VSEG(v, pixbuf, x, y, height - y); return; }
static Popot po_stristr(Popot s1, Popot s2) /***************************************************************************** * char *stristr(char *string, char *substring) ****************************************************************************/ { char *p1 = NULL, *p2 = NULL; char *res; if (s1.pt == NULL || s2.pt == NULL) { builtin_err = Err_null_ref; goto ERR; } if ((p1 = clone_string(s1.pt)) == NULL) { builtin_err = Err_no_memory; goto ERR; } if ((p2 = clone_string(s2.pt)) == NULL) { builtin_err = Err_no_memory; goto ERR; } upc(p1); upc(p2); if ((res = strstr(p1,p2)) == NULL) goto ERR; s1.pt = OPTR(s1.pt,res-p1); goto OUT; ERR: s1.pt = s1.min = s1.max = NULL; OUT: pj_gentle_free(p1); pj_gentle_free(p2); return(s1); }
void pj_put_hseg(Raster *v, void *pixbuf, Coor x, Coor y, Ucoor width) /* Move pixels from memory to a horizontal line of destination raster. * this will clip and put pixels in from parts of buffer that overlap * destination buffer */ { if(((Ucoor)y) >= v->height) return; if(x >= (Coor)(v->width)) return; if(x < 0) { width += x; pixbuf = OPTR(pixbuf,-x); x = 0; } if(((Coor)width) <= 0) return; width += x; if (width > v->width) width = v->width; PUT_HSEG(v, pixbuf, x, y, width - x); return; }
Errcode alloc_dev_sels(Button *hanger, /* where to install device buttons */ Rectangle *size, /* width and height is size * x,y spacing UNSCALED referenced * to 320 X 200 */ int numcols,int numrows, char *drawer, /* string to put directory into */ /* function and data to call after drawer is changed */ Errcode (*on_newdrawer)(void *), void *ond_data ) /* * Allocate and initialized one button on a file menu for each logical drive. * Store the button list on hanger->children. Also allocates ".." and "\" * buttons at the start. * * The buttons will all have the same seeme & feelme. The drive # will * be stored in the identity field, or -1 or -2 for the ".." and "\". * The seeme & feelme do a little switch on the identity to decide * how to process it if a drive or not. */ { Errcode err; UBYTE devices[MAX_DEVICES]; int dev_count; Dsel_group *dg; long bsize; Button *sel; int i,ix; if((dev_count = pj_get_devices(devices)) < 0) return(dev_count); bsize = (dev_count+2)*sizeof(Button); /* Allocate enough space for all buttons and a Dsel_group. */ if ((err = ealloc((void **)&(hanger->children), bsize + sizeof(Dsel_group))) < Success) return(err); sel = hanger->children; dg = (Dsel_group *)OPTR(sel,bsize); /* Point dg to after buttons */ dg->drawer = drawer; dg->on_newd_data = ond_data; if (on_newdrawer) { dg->on_newdrawer = on_newdrawer; } else { /* just in case it's not supplied */ dg->on_newdrawer = (Errcode (*)(void *))pj_errdo_unimpl; } hanger->seeme = hang_dev_sels; ix = 0; --sel; for(i = -2; i < dev_count;++i) { ++sel; clear_struct(sel); sel->next = sel+1; sel->orig_rect.width = size->width; sel->orig_rect.height = size->height; sel->orig_rect.x = size->x * (ix%numcols); sel->orig_rect.y = size->y * (ix/numcols); sel->seeme = see_device; sel->feelme = new_dev; sel->group = dg; if(i >= 0) { sel->identity = devices[i]; sel->key_equiv = devices[i]+'a'; sel->flags = MB_GHILITE; } else sel->identity = i; if(++ix >= (numcols*numrows)) break; } sel->next = NULL; return(Success); }
char * expmatch(char *s, char *re, char *mstring) /* s - string to check for a match in */ /* re - a converted irregular expression */ /* mstring - where to put whatever matches a \p */ { char *cs; /* the current symbol */ char *ptr, *s1; /* temporary pointer */ boolean matched; /* a temporary boolean */ /* initial conditions */ if (re == NIL) return (NIL); cs = re; matched = FALSE; /* loop till expression string is exhausted (or at least pretty tired) */ while (*cs) { switch (*cs & (OPER | STR | META)) { /* try to match a string */ case STR: matched = !STRNCMP (s, SSTR(cs), SCNT(cs)); if (matched) { /* hoorah it matches */ s += SCNT(cs); cs = SNEXT(cs); } else if (*cs & ALT) { /* alternation, skip to next expression */ cs = SNEXT(cs); } else if (*cs & OPT) { /* the match is optional */ cs = SNEXT(cs); matched = 1; /* indicate a successful match */ } else { /* no match, error return */ return (NIL); } break; /* an operator, do something fancy */ case OPER: switch (OSYM(cs)) { /* this is an alternation */ case '|': if (matched) /* last thing in the alternation was a match, skip ahead */ cs = OPTR(cs); else /* no match, keep trying */ cs = ONEXT(cs); break; /* this is a grouping, recurse */ case '(': ptr = expmatch (s, ONEXT(cs), mstring); if (ptr != NIL) { /* the subexpression matched */ matched = 1; s = ptr; } else if (*cs & ALT) { /* alternation, skip to next expression */ matched = 0; } else if (*cs & OPT) { /* the match is optional */ matched = 1; /* indicate a successful match */ } else { /* no match, error return */ return (NIL); } cs = OPTR(cs); break; } break; /* try to match a metasymbol */ case META: switch (MSYM(cs)) { /* try to match anything and remember what was matched */ case 'p': /* * This is really the same as trying the match the * remaining parts of the expression to any subset * of the string. */ s1 = s; do { ptr = expmatch (s1, MNEXT(cs), mstring); if (ptr != NIL && s1 != s) { /* we have a match, remember the match */ strncpy (mstring, s, s1 - s); mstring[s1 - s] = '\0'; return (ptr); } else if (ptr != NIL && (*cs & OPT)) { /* it was aoptional so no match is ok */ return (ptr); } else if (ptr != NIL) { /* not optional and we still matched */ return (NIL); } if (!isidchr(*s1)) return (NIL); if (*s1 == '\\') _escaped = _escaped ? FALSE : TRUE; else _escaped = FALSE; } while (*s1++); return (NIL); /* try to match anything */ case 'a': /* * This is really the same as trying the match the * remaining parts of the expression to any subset * of the string. */ s1 = s; do { ptr = expmatch (s1, MNEXT(cs), mstring); if (ptr != NIL && s1 != s) { /* we have a match */ return (ptr); } else if (ptr != NIL && (*cs & OPT)) { /* it was aoptional so no match is ok */ return (ptr); } else if (ptr != NIL) { /* not optional and we still matched */ return (NIL); } if (*s1 == '\\') _escaped = _escaped ? FALSE : TRUE; else _escaped = FALSE; } while (*s1++); return (NIL); /* fail if we are currently _escaped */ case 'e': if (_escaped) return(NIL); cs = MNEXT(cs); break; /* match any number of tabs and spaces */ case 'd': ptr = s; while (*s == ' ' || *s == '\t') s++; if (s != ptr || s == Start) { /* match, be happy */ matched = 1; cs = MNEXT(cs); } else if (*s == '\n' || *s == '\0') { /* match, be happy */ matched = 1; cs = MNEXT(cs); } else if (*cs & ALT) { /* try the next part */ matched = 0; cs = MNEXT(cs); } else if (*cs & OPT) { /* doesn't matter */ matched = 1; cs = MNEXT(cs); } else /* no match, error return */ return (NIL); break; /* check for end of line */ case '$': if (*s == '\0' || *s == '\n') { /* match, be happy */ s++; matched = 1; cs = MNEXT(cs); } else if (*cs & ALT) { /* try the next part */ matched = 0; cs = MNEXT(cs); } else if (*cs & OPT) { /* doesn't matter */ matched = 1; cs = MNEXT(cs); } else /* no match, error return */ return (NIL); break; /* check for start of line */ case '^': if (s == Start) { /* match, be happy */ matched = 1; cs = MNEXT(cs); } else if (*cs & ALT) { /* try the next part */ matched = 0; cs = MNEXT(cs); } else if (*cs & OPT) { /* doesn't matter */ matched = 1; cs = MNEXT(cs); } else /* no match, error return */ return (NIL); break; /* end of a subexpression, return success */ case ')': return (s); } break; } } return (s); }
LONG pj_build_rect_pstamp(Rcel *screen, void *cbuf, SHORT x,SHORT y,USHORT width,USHORT height) { Brundat brd; Pstamp_chunk *chunk = (Pstamp_chunk *)cbuf; LONG square; pj_get_stampsize(PSTAMP_W,PSTAMP_H,width,height, &chunk->width,&chunk->height); chunk->xlat_type = PSTAMP_SIXCUBE; pj_make_pstamp_xlat(screen->cmap->ctab,brd.xlat, COLORS); /* a little one only needs the color translation table */ square = width*height; if( (chunk->width * chunk->height) > (square - (square/3)) ) { brd.dst = OPTR(chunk,(sizeof(*chunk)+256)); chunk->data.type = FPS_XLAT256; pj_copy_bytes(brd.xlat,chunk+1,256); goto chunk_done; } /* try to do a brun, if too big do a copy */ chunk->data.type = FPS_BRUN; brd.screen = screen; brd.sx = x; brd.sw = width; brd.comp_line = pj_brun_comp_line; brd.dstmax = (BYTE *)(chunk+1) + PSTAMP_W*(PSTAMP_H-1); for(;;) { brd.srcline = (Pixel *)(brd.dstmax); brd.last_sy = y - 1; brd.dw = chunk->width; pj_make_scale_table(width,brd.dw,brd.xtable); brd.dst = (BYTE *)(chunk + 1); pj_do_linscale(y,height,0,chunk->height,comp_pstamp_line,&brd); if(brd.dst != NULL) break; chunk->data.type = FPS_COPY; brd.comp_line = copy_line; brd.dstmax = (BYTE *)(chunk+1) + PSTAMP_W*(PSTAMP_H+1); } chunk_done: chunk->type = FLI_PSTAMP; chunk->size = SIZE(chunk,brd.dst); if(chunk->size & 1) /* make sure it's an even size */ { ++chunk->size; ++brd.dst; } chunk->data.size = SIZE(&chunk->data,brd.dst); return(chunk->size); }
void *po_disasm(FILE *f, void *code, C_frame *cframes) /***************************************************************************** * disassemble a single instruction. ****************************************************************************/ { int op; Func_frame *fuf; Poco_op_table *pta; op = ((int *)code)[0]; code = OPTR(code, sizeof(op) ); if (op >= 0 && op < po_ins_table_els) { pta = po_ins_table + op; fprintf(f, "\t%-15s\t", pta->op_name); switch (pta->op_ext) { case OEX_NONE: break; case OEX_VAR: case OEX_INT: case OEX_LABEL: fprintf(f, "\t%d", ((int *)code)[0]); break; case OEX_ADDRESS: fprintf(f, "\tvar %d size %ld", ((int *)OPTR(code,0))[0], ((long *)OPTR(code,sizeof(int)))[0]); break; case OEX_LONG: fprintf(f, "\t%ld", ((LONG *)code)[0] ); break; case OEX_POINTER: fprintf(f, "\tmin 0x%p max 0x%p pt 0x%p", ((Popot *)code)->min, ((Popot *)code)->max, ((Popot *)code)->pt); break; case OEX_DOUBLE: fprintf(f, "\t%f", ((double *)code)[0]); break; case OEX_FUNCTION: fuf = ((Func_frame **)code)[0]; fprintf(f, "\t%s", fuf->name); break; case OEX_CFUNCTION: if (cframes != NULL) fprintf(f, "\t%s", find_c_name(cframes, ((void **)code)[0])); break; } code = OPTR(code, pta->op_size); fprintf(f, "\n"); } else { fprintf(f, "Wild op %d 0x%d\n", op); code = OPTR(code, sizeof(op)); } return(code); }
Errcode open_wndo(Wndo **pw, WndoInit *wi) /* * Open a window. Returns window in *pw. * (pw == NULL is valid input, but should only be used by * open_wscreen()). */ { Errcode err; Wndo *w = NULL; Wscreen *ws; Boolean was_mouse; LONG allocsize; LONG ydotsize; LONG ptrsize; SHORT screen_wndo; SHORT is_backdrop; SHORT max_wins; was_mouse = hide_mouse(); is_backdrop = wi->flags & WNDO_BACKDROP; screen_wndo = (pw == NULL); ws = wi->screen; max_wins = ws->max_wins; if(screen_wndo) { w = &ws->wndo; w->type = RT_ROOTWNDO; w->cmap = ws->viscel->cmap; w->W_rastid = NULL_RASTID; } else { *pw = NULL; if(!is_backdrop) { if(ws->num_wins >= max_wins) { err = Err_tomany_wins; goto error; } --max_wins; /* these windows can't be behind backdrops */ } if((w = pj_zalloc(sizeof(Wndo) + wi->extrabuf)) == NULL) goto nomem_error; w->type = RT_WINDOW; w->rasts = ws->wndo.rasts; w->cmap = ws->wndo.cmap; if(is_backdrop) w->W_rastid = NULL_RASTID; /* the initial null raster */ else { w->W_rastid = get_newid(ws); w->rasts[w->W_rastid] = &(w->behind); } } if(wi->cursor == NULL) w->cursor = ws->cursor; else w->cursor = wi->cursor; w->W_screen = ws; /* must get to here ok if window is allocated */ /* move in raster header fields from root screen raster */ w->aspect_dx = ws->viscel->aspect_dx; w->aspect_dy = ws->viscel->aspect_dy; w->pdepth = ws->viscel->pdepth; copy_rectfields(wi,w); /* copy in rectangle fields for initial size */ /* none too small */ if(w->width < WNDO_MINWIDTH) w->width = WNDO_MINWIDTH; if(w->height < WNDO_MINHEIGHT) w->height = WNDO_MINHEIGHT; #ifdef DOESNTWORK /* no window ports bigger than screen !! */ /* this should be a and cliprects type of clip to get common rect * if needed */ sclip_rect((Rectangle *)&(w->RECTSTART), (Rectangle *)&(ws->viscel->RECTSTART)); #endif /* DOESNTWORK */ /* load cliprect variables for window port position and size */ w->W_xmax = w->x + w->width; w->W_ymax = w->y + w->height; /* increase width and height of window to be the maximum size * requested if greater than port size */ if(wi->maxw > w->width) w->width = wi->maxw; if(wi->maxh > w->height) w->height = wi->maxh; /* initialize and copy in window maxsize rectangle fields to behind rast * the width and height for both shall NEVER be changed until window is * closed */ copy_rasthdr(ws->viscel,&w->behind); copy_rectfields(w,&w->behind); if(is_backdrop) { if((err = pj_open_nullrast(&w->behind)) < 0) /* dummy backup area */ goto error; } else { if((err = pj_open_bytemap((Rasthdr *)&w->behind,(Bytemap *)&w->behind)) < 0) goto error; } /* size of one column array of ydots */ ydotsize = (w->height /* one byte for each dot */ + (w->height & 1) /* even word size */ + sizeof(Cliphead)); /* cliphead for range and freelist */ /* size of all ydots buffers */ allocsize = (ydotsize * ((max_wins * 2) - 1)); /* size of pointer array for ydots */ /* size of pointer array */ ptrsize = w->width * sizeof(PTR); if((w->ydots = pj_malloc(allocsize + ptrsize)) == NULL) goto nomem_error; w->free_ydots = link_free_clips(OPTR(w->ydots,ptrsize),ydotsize,allocsize); w->ydots[0] = get_free_clip(&w->free_ydots); NEXTX(w->ydots[0]) = w->width; free_init_ydots(w); /* allocate vchanes */ if((w->vchanges = pj_malloc(w->height * sizeof(SHORT))) == NULL) goto nomem_error; pj_stuff_words(w->height,w->vchanges,w->height); w->lib = get_window_lib(); /******** add window to screen ********/ if(screen_wndo) { add_head(&ws->wilist,&w->W_node); build_all_clips(ws,0); ++ws->num_wins; return(0); } w->flags |= wi->flags & ~(WNDO_NOCLEAR); if(is_backdrop) { #ifdef WASTHISWAY insert_before(&(w->W_node),&(ws->wndo.W_node)); #endif if( (wi->over != NULL) && (find_header(&(wi->over->W_node)) == &(ws->wilist))) { insert_before(&(w->W_node),&(wi->over->W_node)); } else { add_head(&ws->wilist,&w->W_node); } build_all_clips(ws,1); if(!(wi->flags & WNDO_NOCLEAR)) pj_set_rast((Raster *)w, 0); /* clear window */ } else { ++ws->num_wins; if( (wi->over != NULL) && (find_header(&(wi->over->W_node)) == &(ws->wilist))) { insert_before(&(w->W_node),&(wi->over->W_node)); } else { add_head(&ws->wilist,&w->W_node); } build_all_clips(ws,1); if(wi->flags & WNDO_NOCLEAR) { /* only blit in parts that are backups */ blit_behind(w,blit_saveonly); } else { pj_set_rast(&w->behind,0); /* clear backup raster */ blit_behind(w,pj__swaprect); /* swap window raster onto screen */ } } *pw = w; err = Success; goto done; nomem_error: err = Err_no_memory; error: _close_wndo(w); done: if(was_mouse) show_mouse(); return(err); }
JViewObj* JFocusSet::extract(JObject* obj) { return (JViewObj*)OPTR(obj);}
Errcode put_macro(Boolean ishit) { Errcode err; char buf[36]; USHORT *oflags; void *macbuf; #define Flags (*((USHORT *)buf)) if(!ishit) /* just checking increment check count */ { ++Mcb.iocount; return(Success); } macbuf = buf; VPUTVAL(macbuf,USHORT,icb.state & MACSTATE); if(Mcb.iocount > 0) { oflags = macbuf; *oflags = icb.ostate & MACSTATE; macbuf = OPTR(macbuf,sizeof(USHORT)); if(Mcb.iocount <= 0x0FF) { VPUTVAL(macbuf,UBYTE,Mcb.iocount); } else if(Mcb.iocount <= 0x0FFFF) { VPUTVAL(macbuf,USHORT,Mcb.iocount); *oflags |= CCOUNT_SHORT; } else { VPUTVAL(macbuf,ULONG,Mcb.iocount); *oflags |= CCOUNT_LONG; } if(icb.lastsx != Mcb.lastmouse.x) { VPUTVAL(macbuf,SHORT,icb.lastsx); *oflags |= HAS_MOUSEX; } if(icb.lastsy != Mcb.lastmouse.y) { VPUTVAL(macbuf,SHORT,icb.lastsy); *oflags |= HAS_MOUSEY; } if(HISTATE_BITS(icb.ostate) != Mcb.last_histate) { VPUTVAL(macbuf,USHORT,HISTATE_BITS(icb.ostate)); *oflags |= HAS_HISTATE; } Flags |= HAS_CCOUNT; } Mcb.iocount = 0; if(Flags & KEYHIT) { VPUTVAL(macbuf,USHORT,icb.inkey); } if(icb.pressure != Mcb.last_pressure) { VPUTVAL(macbuf,UBYTE,icb.pressure); Mcb.last_pressure = icb.pressure; Flags |= HAS_PRESSURE; } if(icb.sx != Mcb.lastmouse.x) { VPUTVAL(macbuf,SHORT,icb.sx); Flags |= HAS_MOUSEX; } if(icb.sy != Mcb.lastmouse.y) { VPUTVAL(macbuf,SHORT,icb.sy); Flags |= HAS_MOUSEY; } Mcb.lastmouse = *((Short_xy *)&icb.sx); if(HISTATE_BITS(icb.state) != Mcb.last_histate) { Mcb.last_histate = HISTATE_BITS(icb.state); VPUTVAL(macbuf,USHORT,Mcb.last_histate); Flags |= HAS_HISTATE; } if((err = ffwrite(Mcb.fp,buf,SIZE(buf,macbuf))) < Success) macro_write_error(err); return(err); #undef Flags }