1 |
– |
/* Copyright (c) 1987 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* ximage.c - driver for X-windows |
6 |
|
* |
15 |
|
#include <X/cursors/bcross_mask.cursor> |
16 |
|
|
17 |
|
#include <sys/types.h> |
18 |
< |
|
18 |
> |
#include <string.h> |
19 |
|
#include <ctype.h> |
20 |
+ |
#include <time.h> |
21 |
|
|
22 |
|
#include "color.h" |
25 |
– |
|
23 |
|
#include "resolu.h" |
27 |
– |
|
24 |
|
#include "xraster.h" |
29 |
– |
|
25 |
|
#include "view.h" |
31 |
– |
|
26 |
|
#include "pic.h" |
33 |
– |
|
27 |
|
#include "random.h" |
28 |
|
|
29 |
|
#define controlshift(e) (((XButtonEvent *)(e))->detail & (ShiftMask|ControlMask)) |
30 |
|
|
31 |
|
#define FONTNAME "9x15" /* text font we'll use */ |
32 |
|
|
33 |
< |
#define CTRL(c) ('c'-'@') |
33 |
> |
#define CTRL(c) ((c)-'@') |
34 |
|
|
35 |
|
#define BORWIDTH 5 /* border width */ |
36 |
|
#define BARHEIGHT 25 /* menu bar size */ |
79 |
|
|
80 |
|
char errmsg[128]; |
81 |
|
|
82 |
< |
extern long ftell(); |
82 |
> |
static gethfunc headline; |
83 |
|
|
91 |
– |
extern char *malloc(), *calloc(); |
84 |
|
|
93 |
– |
extern double pow(), log(); |
94 |
– |
|
95 |
– |
|
85 |
|
main(argc, argv) |
86 |
|
int argc; |
87 |
|
char *argv[]; |
88 |
|
{ |
89 |
< |
int headline(); |
89 |
> |
extern char *getenv(); |
90 |
> |
char *gv; |
91 |
|
int i; |
92 |
|
|
93 |
|
progname = argv[0]; |
94 |
+ |
if ((gv = getenv("DISPLAY_GAMMA")) != NULL) |
95 |
+ |
gamcor = atof(gv); |
96 |
|
|
97 |
|
for (i = 1; i < argc; i++) |
98 |
|
if (argv[i][0] == '-') |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
< |
headline(s) /* get relevant info from header */ |
163 |
< |
char *s; |
162 |
> |
static int |
163 |
> |
headline( /* get relevant info from header */ |
164 |
> |
char *s, |
165 |
> |
void *p |
166 |
> |
) |
167 |
|
{ |
173 |
– |
static char *altname[] = {"rview","rpict",VIEWSTR,NULL}; |
174 |
– |
register char **an; |
168 |
|
char fmt[32]; |
169 |
|
|
170 |
|
if (isexpos(s)) |
172 |
|
else if (isformat(s)) { |
173 |
|
formatval(fmt, s); |
174 |
|
wrongformat = strcmp(fmt, COLRFMT); |
175 |
< |
} else |
176 |
< |
for (an = altname; *an != NULL; an++) |
177 |
< |
if (!strncmp(*an, s, strlen(*an))) { |
185 |
< |
if (sscanview(&ourview, s+strlen(*an)) > 0) |
186 |
< |
gotview++; |
187 |
< |
return; |
188 |
< |
} |
175 |
> |
} else if (isview(s) && sscanview(&ourview, s) > 0) |
176 |
> |
gotview++; |
177 |
> |
return(0); |
178 |
|
} |
179 |
|
|
180 |
|
|
243 |
|
} |
244 |
|
|
245 |
|
|
246 |
+ |
void |
247 |
|
eputs(s) |
248 |
|
char *s; |
249 |
|
{ |
251 |
|
} |
252 |
|
|
253 |
|
|
254 |
+ |
void |
255 |
|
quit(code) |
256 |
|
int code; |
257 |
|
{ |
358 |
|
return(0); |
359 |
|
switch (*cp) { /* interpret command */ |
360 |
|
case 'q': |
361 |
< |
case CTRL(D): /* quit */ |
361 |
> |
case CTRL('D'): /* quit */ |
362 |
|
quit(0); |
363 |
|
case '\n': |
364 |
|
case '\r': |
428 |
|
free_raster(ourras); |
429 |
|
getras(); |
430 |
|
/* fall through */ |
431 |
< |
case CTRL(R): /* redraw */ |
432 |
< |
case CTRL(L): |
431 |
> |
case CTRL('R'): /* redraw */ |
432 |
> |
case CTRL('L'): |
433 |
|
unmap_rcolors(ourras); |
434 |
|
XClear(wind); |
435 |
|
return(redraw(0, 0, width, height)); |
565 |
|
cerr[x] = err + errp; |
566 |
|
} |
567 |
|
} |
568 |
< |
free((char *)inl); |
569 |
< |
free((char *)cerr); |
568 |
> |
free((void *)inl); |
569 |
> |
free((void *)cerr); |
570 |
|
} |
571 |
|
|
572 |
|
|
594 |
|
xr->cdefs[xr->ncolors].pixel = *p; |
595 |
|
xr->pmap[*p] = xr->ncolors++; |
596 |
|
} |
597 |
< |
xr->cdefs = (Color *)realloc((char *)xr->cdefs, xr->ncolors*sizeof(Color)); |
597 |
> |
xr->cdefs = (Color *)realloc((void *)xr->cdefs, xr->ncolors*sizeof(Color)); |
598 |
|
if (xr->cdefs == NULL) |
599 |
|
return(0); |
600 |
|
return(1); |
638 |
|
if (fseek(fin, scanpos[y], 0) == -1) |
639 |
|
quiterr("fseek error"); |
640 |
|
cury = y; |
641 |
< |
} else if (scanpos != NULL) |
641 |
> |
} else if (scanpos != NULL && scanpos[y] == -1) |
642 |
|
scanpos[y] = ftell(fin); |
643 |
|
|
644 |
|
if (freadcolrs(scanline, xmax, fin) < 0) |
671 |
|
int y; |
672 |
|
pixel *l; |
673 |
|
{ |
674 |
< |
bcopy((char *)l, (char *)ourras->data.bz+BZPixmapSize(xmax,y), BZPixmapSize(xmax,1)); |
674 |
> |
memcpy((void *)ourras->data.bz+BZPixmapSize(xmax,y), (void *)l, BZPixmapSize(xmax,1)); |
675 |
|
} |
676 |
|
|
677 |
|
|