Annotation of researchv10no/cmd/pico/windows.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include "pico.h"
                      3: 
                      4: extern struct  SRC src[MANY];
                      5: extern short   CUROLD;
                      6: extern int     DEF_LL, DEF_NL;
                      7: 
                      8: getwindow(into, dest)
                      9:        struct SRC *into;
                     10:        char *dest;
                     11: {
                     12:        register char *z = dest + (into->sy)*DEF_LL + (into->sx);
                     13:        register int i;
                     14:        register int w = into->ex - into->sx;
                     15:        register int d = into->ey - into->sy;
                     16:        int ll = into->ll, nl = into->nl;
                     17:        int  x = into->ox,  y = into->oy;
                     18:        int fd = into->fd;
                     19: 
                     20:        lseek(fd, (y*ll + x), 1);
                     21:        for(i = 0; i < d; i++, z += DEF_LL)
                     22:        {       if (!eread(fd, z, w))
                     23:                        break;
                     24:                lseek(fd, ll-w, 1);
                     25:        }
                     26:        lseek(fd, ll-x, 1);
                     27:        lseek(fd, (nl-d-y-1)*ll, 1);
                     28: 
                     29: }
                     30: 
                     31: putwindow(fd, source, x, y, width, depth)
                     32:        char *source;
                     33: {
                     34:   register char *z = source + y*DEF_LL + x;
                     35:   register int i;
                     36: 
                     37:        for (i = 0; i < depth; i++, z += DEF_LL)
                     38:                if (!ewrite(fd, z, width))
                     39:                        break;
                     40: }
                     41: 
                     42: eopen(infile)
                     43:        char *infile;
                     44: { int from;
                     45:        if ((from = open(infile, 0)) <= 0)
                     46:        {       fprintf(stderr, "pico: cannot open %s\n", infile);
                     47:                return 0;
                     48:        }
                     49:        return from;
                     50: }
                     51: 
                     52: eread(n, m, p)
                     53:        char *m;
                     54: { int k;
                     55:        if ((k=read(n, m, p)) != p)
                     56:        {       fprintf(stderr, "pico: read error..wanted %d got %d\n", p, k);
                     57:                return 0;
                     58:        }
                     59:        return 1;
                     60: }
                     61: 
                     62: ewrite(n, m, p)
                     63:        char *m;
                     64: { int k;
                     65:        if ((k=write(n, m, p)) != p)
                     66:        {       fprintf(stderr, "pico: write error..wrote %d iso %d\n", k, p);
                     67:                return 0;
                     68:        }
                     69:        return 1;
                     70: }
                     71: 
                     72: getpix(into, infile)
                     73:        struct SRC *into;
                     74:        char *infile;
                     75: {
                     76:        fprintf(stderr, "reading %s...", into->fname);
                     77:        if (into->incore == 0)
                     78:        {       into->pixred = (unsigned char *) Emalloc(DEF_LL*DEF_NL);
                     79:                if (into->nchan >= 3)
                     80:                {       into->pixgrn = (unsigned char *) Emalloc(DEF_LL*DEF_NL);
                     81:                        into->pixblu = (unsigned char *) Emalloc(DEF_LL*DEF_NL);
                     82:                }
                     83:                into->incore = 1;
                     84:        }
                     85:        if (into->type == PICO || (into->type == DUMP && into->nchan == 1))
                     86:                getfile(into);
                     87:        else {
                     88:                fprintf(stderr, "sorry, unsupported picture format\n");
                     89:                return;
                     90:        }
                     91:        into->incore = 2;
                     92:        fprintf(stderr, "\n");
                     93: }
                     94: 
                     95: getfile(into)
                     96:        struct SRC *into;
                     97: {
                     98:        getwindow(into, into->pixred);
                     99:        if (into->nchan == 1)
                    100:                into->pixgrn = into->pixblu = into->pixred;
                    101:        else
                    102:        {       getwindow(into, into->pixgrn);
                    103:                getwindow(into, into->pixblu);
                    104:        }
                    105: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.