ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pvalue.c
Revision: 2.11
Committed: Wed Jan 8 08:00:23 1997 UTC (27 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.10: +87 -112 lines
Log Message:
took out file arguments from get and put value routines

File Contents

# Content
1 /* Copyright (c) 1992 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * pvalue.c - program to print pixel values.
9 *
10 * 4/23/86
11 */
12
13 #include "standard.h"
14
15 #include "color.h"
16
17 #include "resolu.h"
18
19 #define min(a,b) ((a)<(b)?(a):(b))
20
21 /* what to put out (also RED, GRN, BLU) */
22 #define ALL 3
23 #define BRIGHT 4
24
25 #define brightonly (putprim==BRIGHT)
26
27 RESOLU picres; /* resolution of picture */
28
29 int uniq = 0; /* print only unique values? */
30
31 int doexposure = 0; /* exposure change? (>100 to print) */
32
33 int dataonly = 0; /* data only format? */
34
35 int putprim = ALL; /* what to put out */
36
37 int reverse = 0; /* reverse conversion? */
38
39 int format = 'a'; /* input/output format */
40 char *fmtid = "ascii"; /* format identifier for header */
41
42 int header = 1; /* do header? */
43
44 long skipbytes = 0; /* skip bytes in input? */
45
46 int resolution = 1; /* put/get resolution string? */
47
48 int original = 0; /* convert to original values? */
49
50 int wrongformat = 0; /* wrong input format? */
51
52 double gamcor = 1.0; /* gamma correction */
53
54 int ord[3] = {RED, GRN, BLU}; /* RGB ordering */
55 int rord[4]; /* reverse ordering */
56
57 COLOR exposure = WHTCOLOR;
58
59 char *progname;
60
61 FILE *fin;
62 FILE *fin2 = NULL, *fin3 = NULL; /* for other color channels */
63
64 int (*getval)(), (*putval)();
65
66
67 main(argc, argv)
68 int argc;
69 char **argv;
70 {
71 extern int checkhead();
72 extern long atol();
73 double d, expval = 1.0;
74 int i;
75
76 progname = argv[0];
77
78 for (i = 1; i < argc; i++)
79 if (argv[i][0] == '-' || argv[i][0] == '+')
80 switch (argv[i][1]) {
81 case 'h': /* header */
82 header = argv[i][0] == '+';
83 break;
84 case 'H': /* resolution string */
85 resolution = argv[i][0] == '+';
86 break;
87 case 's': /* skip bytes in header */
88 skipbytes = atol(argv[++i]);
89 break;
90 case 'u': /* unique values */
91 uniq = argv[i][0] == '-';
92 break;
93 case 'o': /* original values */
94 original = argv[i][0] == '-';
95 break;
96 case 'g': /* gamma correction */
97 gamcor = atof(argv[i+1]);
98 if (argv[i][0] == '+')
99 gamcor = 1.0/gamcor;
100 i++;
101 break;
102 case 'e': /* exposure correction */
103 d = atof(argv[i+1]);
104 if (argv[i+1][0] == '-' || argv[i+1][0] == '+')
105 d = pow(2.0, d);
106 if (argv[i][0] == '-')
107 expval *= d;
108 scalecolor(exposure, d);
109 doexposure++;
110 i++;
111 break;
112 case 'R': /* reverse byte sequence */
113 if (argv[i][0] == '-') {
114 ord[0]=BLU; ord[1]=GRN; ord[2]=RED;
115 } else {
116 ord[0]=RED; ord[1]=GRN; ord[2]=BLU;
117 }
118 break;
119 case 'r': /* reverse conversion */
120 reverse = argv[i][0] == '-';
121 break;
122 case 'b': /* brightness values */
123 putprim = argv[i][0] == '-' ? BRIGHT : ALL;
124 break;
125 case 'p': /* put primary */
126 switch (argv[i][2]) {
127 case 'r': case 'R': putprim = RED; break;
128 case 'g': case 'G': putprim = GRN; break;
129 case 'b': case 'B': putprim = BLU; break;
130 default: goto unkopt;
131 }
132 break;
133 case 'd': /* data only (no indices) */
134 dataonly = argv[i][0] == '-';
135 switch (argv[i][2]) {
136 case '\0':
137 case 'a': /* ascii */
138 format = 'a';
139 fmtid = "ascii";
140 break;
141 case 'i': /* integer */
142 format = 'i';
143 fmtid = "ascii";
144 break;
145 case 'b': /* byte */
146 dataonly = 1;
147 format = 'b';
148 fmtid = "byte";
149 break;
150 case 'f': /* float */
151 dataonly = 1;
152 format = 'f';
153 fmtid = "float";
154 break;
155 case 'd': /* double */
156 dataonly = 1;
157 format = 'd';
158 fmtid = "double";
159 break;
160 default:
161 goto unkopt;
162 }
163 break;
164 case 'x': /* x resolution */
165 case 'X': /* x resolution */
166 resolution = 0;
167 if (argv[i][0] == '-')
168 picres.or |= XDECR;
169 picres.xr = atoi(argv[++i]);
170 break;
171 case 'y': /* y resolution */
172 case 'Y': /* y resolution */
173 resolution = 0;
174 if (argv[i][0] == '-')
175 picres.or |= YDECR;
176 if (picres.xr == 0)
177 picres.or |= YMAJOR;
178 picres.yr = atoi(argv[++i]);
179 break;
180 default:
181 unkopt:
182 fprintf(stderr, "%s: unknown option: %s\n",
183 progname, argv[i]);
184 quit(1);
185 break;
186 }
187 else
188 break;
189 /* recognize special formats */
190 if (dataonly && format == 'b')
191 if (brightonly)
192 fmtid = "8-bit_grey";
193 else
194 fmtid = "24-bit_rgb";
195 /* assign reverse ordering */
196 rord[ord[0]] = 0;
197 rord[ord[1]] = 1;
198 rord[ord[2]] = 2;
199 /* get input */
200 if (i == argc) {
201 fin = stdin;
202 } else if (i < argc) {
203 if ((fin = fopen(argv[i], "r")) == NULL) {
204 fprintf(stderr, "%s: can't open file \"%s\"\n",
205 progname, argv[i]);
206 quit(1);
207 }
208 if (skipbytes && fseek(fin, skipbytes, 0))
209 goto seekerr;
210 if (reverse && !brightonly && i == argc-3) {
211 if ((fin2 = fopen(argv[i+1], "r")) == NULL) {
212 fprintf(stderr, "%s: can't open file \"%s\"\n",
213 progname, argv[i+1]);
214 quit(1);
215 }
216 if ((fin3 = fopen(argv[i+2], "r")) == NULL) {
217 fprintf(stderr, "%s: can't open file \"%s\"\n",
218 progname, argv[i+2]);
219 quit(1);
220 }
221 if (skipbytes && (fseek(fin2, skipbytes, 0) ||
222 fseek(fin3, skipbytes, 0)))
223 goto seekerr;
224 } else if (i != argc-1)
225 fin = NULL;
226 }
227 if (fin == NULL) {
228 fprintf(stderr, "%s: bad # file arguments\n", progname);
229 quit(1);
230 }
231
232 set_io();
233
234 if (reverse) {
235 #ifdef MSDOS
236 setmode(fileno(stdout), O_BINARY);
237 if (format != 'a' && format != 'i')
238 setmode(fileno(fin), O_BINARY);
239 #endif
240 /* get header */
241 if (header) {
242 if (checkheader(fin, fmtid, stdout) < 0) {
243 fprintf(stderr, "%s: wrong input format\n",
244 progname);
245 quit(1);
246 }
247 if (fin2 != NULL) {
248 getheader(fin2, NULL, NULL);
249 getheader(fin3, NULL, NULL);
250 }
251 } else
252 newheader("RADIANCE", stdout);
253 /* get resolution */
254 if ((resolution && !fgetsresolu(&picres, fin)) ||
255 picres.xr <= 0 || picres.yr <= 0) {
256 fprintf(stderr, "%s: missing resolution\n", progname);
257 quit(1);
258 }
259 if (resolution && fin2 != NULL) {
260 RESOLU pres2;
261 if (!fgetsresolu(&pres2, fin2) ||
262 pres2.or != picres.or ||
263 pres2.xr != picres.xr ||
264 pres2.yr != picres.yr ||
265 !fgetsresolu(&pres2, fin3) ||
266 pres2.or != picres.or ||
267 pres2.xr != picres.xr ||
268 pres2.yr != picres.yr) {
269 fprintf(stderr, "%s: resolution mismatch\n",
270 progname);
271 quit(1);
272 }
273 }
274 /* add to header */
275 printargs(i, argv, stdout);
276 if (expval < .99 || expval > 1.01)
277 fputexpos(expval, stdout);
278 fputformat(COLRFMT, stdout);
279 putchar('\n');
280 fputsresolu(&picres, stdout); /* always put resolution */
281 valtopix();
282 } else {
283 #ifdef MSDOS
284 setmode(fileno(fin), O_BINARY);
285 if (format != 'a' && format != 'i')
286 setmode(fileno(stdout), O_BINARY);
287 #endif
288 /* get header */
289 getheader(fin, checkhead, NULL);
290 if (wrongformat) {
291 fprintf(stderr, "%s: input not a Radiance picture\n",
292 progname);
293 quit(1);
294 }
295 if (!fgetsresolu(&picres, fin)) {
296 fprintf(stderr, "%s: missing resolution\n", progname);
297 quit(1);
298 }
299 if (header) {
300 printargs(i, argv, stdout);
301 if (expval < .99 || expval > 1.01)
302 fputexpos(expval, stdout);
303 fputformat(fmtid, stdout);
304 putchar('\n');
305 }
306 if (resolution) /* put resolution */
307 fputsresolu(&picres, stdout);
308 pixtoval();
309 }
310
311 quit(0);
312 seekerr:
313 fprintf(stderr, "%s: cannot skip %ld bytes on input\n",
314 progname, skipbytes);
315 quit(1);
316 }
317
318
319 checkhead(line) /* deal with line from header */
320 char *line;
321 {
322 char fmt[32];
323 double d;
324 COLOR ctmp;
325
326 if (formatval(fmt, line))
327 wrongformat = strcmp(fmt, COLRFMT);
328 else if (original && isexpos(line)) {
329 d = 1.0/exposval(line);
330 scalecolor(exposure, d);
331 doexposure++;
332 } else if (original && iscolcor(line)) {
333 colcorval(ctmp, line);
334 setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED),
335 colval(exposure,GRN)/colval(ctmp,GRN),
336 colval(exposure,BLU)/colval(ctmp,BLU));
337 doexposure++;
338 } else if (header)
339 fputs(line, stdout);
340 }
341
342
343 pixtoval() /* convert picture to values */
344 {
345 register COLOR *scanln;
346 int dogamma;
347 COLOR lastc;
348 FLOAT hv[2];
349 int y;
350 register int x;
351
352 scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR));
353 if (scanln == NULL) {
354 fprintf(stderr, "%s: out of memory\n", progname);
355 quit(1);
356 }
357 dogamma = gamcor < .95 || gamcor > 1.05;
358 setcolor(lastc, 0.0, 0.0, 0.0);
359 for (y = 0; y < numscans(&picres); y++) {
360 if (freadscan(scanln, scanlen(&picres), fin) < 0) {
361 fprintf(stderr, "%s: read error\n", progname);
362 quit(1);
363 }
364 for (x = 0; x < scanlen(&picres); x++) {
365 if (uniq)
366 if ( colval(scanln[x],RED) ==
367 colval(lastc,RED) &&
368 colval(scanln[x],GRN) ==
369 colval(lastc,GRN) &&
370 colval(scanln[x],BLU) ==
371 colval(lastc,BLU) )
372 continue;
373 else
374 copycolor(lastc, scanln[x]);
375 if (doexposure)
376 multcolor(scanln[x], exposure);
377 if (dogamma)
378 setcolor(scanln[x],
379 pow(colval(scanln[x],RED), 1.0/gamcor),
380 pow(colval(scanln[x],GRN), 1.0/gamcor),
381 pow(colval(scanln[x],BLU), 1.0/gamcor));
382 if (!dataonly) {
383 pix2loc(hv, &picres, x, y);
384 printf("%7d %7d ", (int)(hv[0]*picres.xr),
385 (int)(hv[1]*picres.yr));
386 }
387 if ((*putval)(scanln[x]) < 0) {
388 fprintf(stderr, "%s: write error\n", progname);
389 quit(1);
390 }
391 }
392 }
393 free((char *)scanln);
394 }
395
396
397 valtopix() /* convert values to a pixel file */
398 {
399 int dogamma;
400 register COLOR *scanln;
401 int y;
402 register int x;
403
404 scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR));
405 if (scanln == NULL) {
406 fprintf(stderr, "%s: out of memory\n", progname);
407 quit(1);
408 }
409 dogamma = gamcor < .95 || gamcor > 1.05;
410 for (y = 0; y < numscans(&picres); y++) {
411 for (x = 0; x < scanlen(&picres); x++) {
412 if (!dataonly) {
413 fscanf(fin, "%*d %*d");
414 if (fin2 != NULL) {
415 fscanf(fin2, "%*d %*d");
416 fscanf(fin3, "%*d %*d");
417 }
418 }
419 if ((*getval)(scanln[x]) < 0) {
420 fprintf(stderr, "%s: read error\n", progname);
421 quit(1);
422 }
423 if (dogamma)
424 setcolor(scanln[x],
425 pow(colval(scanln[x],RED), gamcor),
426 pow(colval(scanln[x],GRN), gamcor),
427 pow(colval(scanln[x],BLU), gamcor));
428 if (doexposure)
429 multcolor(scanln[x], exposure);
430 }
431 if (fwritescan(scanln, scanlen(&picres), stdout) < 0) {
432 fprintf(stderr, "%s: write error\n", progname);
433 quit(1);
434 }
435 }
436 free((char *)scanln);
437 }
438
439
440 quit(code)
441 int code;
442 {
443 exit(code);
444 }
445
446
447 getcascii(col) /* get an ascii color value from stream(s) */
448 COLOR col;
449 {
450 double vd[3];
451
452 if (fin2 == NULL) {
453 if (fscanf(fin, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3)
454 return(-1);
455 } else {
456 if (fscanf(fin, "%lf", &vd[0]) != 1 ||
457 fscanf(fin2, "%lf", &vd[1]) != 1 ||
458 fscanf(fin3, "%lf", &vd[2]) != 1)
459 return(-1);
460 }
461 setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]);
462 return(0);
463 }
464
465
466 getcdouble(col) /* get a double color value from stream(s) */
467 COLOR col;
468 {
469 double vd[3];
470
471 if (fin2 == NULL) {
472 if (fread((char *)vd, sizeof(double), 3, fin) != 3)
473 return(-1);
474 } else {
475 if (fread((char *)vd, sizeof(double), 1, fin) != 1 ||
476 fread((char *)(vd+1), sizeof(double), 1, fin2) != 1 ||
477 fread((char *)(vd+2), sizeof(double), 1, fin3) != 1)
478 return(-1);
479 }
480 setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]);
481 return(0);
482 }
483
484
485 getcfloat(col) /* get a float color value from stream(s) */
486 COLOR col;
487 {
488 float vf[3];
489
490 if (fin2 == NULL) {
491 if (fread((char *)vf, sizeof(float), 3, fin) != 3)
492 return(-1);
493 } else {
494 if (fread((char *)vf, sizeof(float), 1, fin) != 1 ||
495 fread((char *)(vf+1), sizeof(float), 1, fin2) != 1 ||
496 fread((char *)(vf+2), sizeof(float), 1, fin3) != 1)
497 return(-1);
498 }
499 setcolor(col, vf[rord[RED]], vf[rord[GRN]], vf[rord[BLU]]);
500 return(0);
501 }
502
503
504 getcint(col) /* get an int color value from stream(s) */
505 COLOR col;
506 {
507 int vi[3];
508
509 if (fin2 == NULL) {
510 if (fscanf(fin, "%d %d %d", &vi[0], &vi[1], &vi[2]) != 3)
511 return(-1);
512 } else {
513 if (fscanf(fin, "%d", &vi[0]) != 1 ||
514 fscanf(fin2, "%d", &vi[1]) != 1 ||
515 fscanf(fin3, "%d", &vi[2]) != 1)
516 return(-1);
517 }
518 setcolor(col, (vi[rord[RED]]+.5)/256.,
519 (vi[rord[GRN]]+.5)/256., (vi[rord[BLU]]+.5)/256.);
520 return(0);
521 }
522
523
524 getcbyte(col) /* get a byte color value from stream(s) */
525 COLOR col;
526 {
527 BYTE vb[3];
528
529 if (fin2 == NULL) {
530 if (fread((char *)vb, sizeof(BYTE), 3, fin) != 3)
531 return(-1);
532 } else {
533 if (fread((char *)vb, sizeof(BYTE), 1, fin) != 1 ||
534 fread((char *)(vb+1), sizeof(BYTE), 1, fin2) != 1 ||
535 fread((char *)(vb+2), sizeof(BYTE), 1, fin3) != 1)
536 return(-1);
537 }
538 setcolor(col, (vb[rord[RED]]+.5)/256.,
539 (vb[rord[GRN]]+.5)/256., (vb[rord[BLU]]+.5)/256.);
540 return(0);
541 }
542
543
544 getbascii(col) /* get an ascii brightness value from fin */
545 COLOR col;
546 {
547 double vd;
548
549 if (fscanf(fin, "%lf", &vd) != 1)
550 return(-1);
551 setcolor(col, vd, vd, vd);
552 return(0);
553 }
554
555
556 getbdouble(col) /* get a double brightness value from fin */
557 COLOR col;
558 {
559 double vd;
560
561 if (fread((char *)&vd, sizeof(double), 1, fin) != 1)
562 return(-1);
563 setcolor(col, vd, vd, vd);
564 return(0);
565 }
566
567
568 getbfloat(col) /* get a float brightness value from fin */
569 COLOR col;
570 {
571 float vf;
572
573 if (fread((char *)&vf, sizeof(float), 1, fin) != 1)
574 return(-1);
575 setcolor(col, vf, vf, vf);
576 return(0);
577 }
578
579
580 getbint(col) /* get an int brightness value from fin */
581 COLOR col;
582 {
583 int vi;
584 double d;
585
586 if (fscanf(fin, "%d", &vi) != 1)
587 return(-1);
588 d = (vi+.5)/256.;
589 setcolor(col, d, d, d);
590 return(0);
591 }
592
593
594 getbbyte(col) /* get a byte brightness value from fin */
595 COLOR col;
596 {
597 BYTE vb;
598 double d;
599
600 if (fread((char *)&vb, sizeof(BYTE), 1, fin) != 1)
601 return(-1);
602 d = (vb+.5)/256.;
603 setcolor(col, d, d, d);
604 return(0);
605 }
606
607
608 putcascii(col) /* put an ascii color to stdout */
609 COLOR col;
610 {
611 fprintf(stdout, "%15.3e %15.3e %15.3e\n",
612 colval(col,ord[0]),
613 colval(col,ord[1]),
614 colval(col,ord[2]));
615
616 return(ferror(stdout) ? -1 : 0);
617 }
618
619
620 putcfloat(col) /* put a float color to stdout */
621 COLOR col;
622 {
623 float vf[3];
624
625 vf[0] = colval(col,ord[0]);
626 vf[1] = colval(col,ord[1]);
627 vf[2] = colval(col,ord[2]);
628 fwrite((char *)vf, sizeof(float), 3, stdout);
629
630 return(ferror(stdout) ? -1 : 0);
631 }
632
633
634 putcdouble(col) /* put a double color to stdout */
635 COLOR col;
636 {
637 double vd[3];
638
639 vd[0] = colval(col,ord[0]);
640 vd[1] = colval(col,ord[1]);
641 vd[2] = colval(col,ord[2]);
642 fwrite((char *)vd, sizeof(double), 3, stdout);
643
644 return(ferror(stdout) ? -1 : 0);
645 }
646
647
648 putcint(col) /* put an int color to stdout */
649 COLOR col;
650 {
651 fprintf(stdout, "%d %d %d\n",
652 (int)(colval(col,ord[0])*256.),
653 (int)(colval(col,ord[1])*256.),
654 (int)(colval(col,ord[2])*256.));
655
656 return(ferror(stdout) ? -1 : 0);
657 }
658
659
660 putcbyte(col) /* put a byte color to stdout */
661 COLOR col;
662 {
663 register int i;
664 BYTE vb[3];
665
666 i = colval(col,ord[0])*256.;
667 vb[0] = min(i,255);
668 i = colval(col,ord[1])*256.;
669 vb[1] = min(i,255);
670 i = colval(col,ord[2])*256.;
671 vb[2] = min(i,255);
672 fwrite((char *)vb, sizeof(BYTE), 3, stdout);
673
674 return(ferror(stdout) ? -1 : 0);
675 }
676
677
678 putbascii(col) /* put an ascii brightness to stdout */
679 COLOR col;
680 {
681 fprintf(stdout, "%15.3e\n", bright(col));
682
683 return(ferror(stdout) ? -1 : 0);
684 }
685
686
687 putbfloat(col) /* put a float brightness to stdout */
688 COLOR col;
689 {
690 float vf;
691
692 vf = bright(col);
693 fwrite((char *)&vf, sizeof(float), 1, stdout);
694
695 return(ferror(stdout) ? -1 : 0);
696 }
697
698
699 putbdouble(col) /* put a double brightness to stdout */
700 COLOR col;
701 {
702 double vd;
703
704 vd = bright(col);
705 fwrite((char *)&vd, sizeof(double), 1, stdout);
706
707 return(ferror(stdout) ? -1 : 0);
708 }
709
710
711 putbint(col) /* put an int brightness to stdout */
712 COLOR col;
713 {
714 fprintf(stdout, "%d\n", (int)(bright(col)*256.));
715
716 return(ferror(stdout) ? -1 : 0);
717 }
718
719
720 putbbyte(col) /* put a byte brightness to stdout */
721 COLOR col;
722 {
723 register int i;
724 BYTE vb;
725
726 i = bright(col)*256.;
727 vb = min(i,255);
728 fwrite((char *)&vb, sizeof(BYTE), 1, stdout);
729
730 return(ferror(stdout) ? -1 : 0);
731 }
732
733
734 putpascii(col) /* put an ascii primary to stdout */
735 COLOR col;
736 {
737 fprintf(stdout, "%15.3e\n", colval(col,putprim));
738
739 return(ferror(stdout) ? -1 : 0);
740 }
741
742
743 putpfloat(col) /* put a float primary to stdout */
744 COLOR col;
745 {
746 float vf;
747
748 vf = colval(col,putprim);
749 fwrite((char *)&vf, sizeof(float), 1, stdout);
750
751 return(ferror(stdout) ? -1 : 0);
752 }
753
754
755 putpdouble(col) /* put a double primary to stdout */
756 COLOR col;
757 {
758 double vd;
759
760 vd = colval(col,putprim);
761 fwrite((char *)&vd, sizeof(double), 1, stdout);
762
763 return(ferror(stdout) ? -1 : 0);
764 }
765
766
767 putpint(col) /* put an int primary to stdout */
768 COLOR col;
769 {
770 fprintf(stdout, "%d\n", (int)(colval(col,putprim)*256.));
771
772 return(ferror(stdout) ? -1 : 0);
773 }
774
775
776 putpbyte(col) /* put a byte primary to stdout */
777 COLOR col;
778 {
779 register int i;
780 BYTE vb;
781
782 i = colval(col,putprim)*256.;
783 vb = min(i,255);
784 fwrite((char *)&vb, sizeof(BYTE), 1, stdout);
785
786 return(ferror(stdout) ? -1 : 0);
787 }
788
789
790 set_io() /* set put and get functions */
791 {
792 switch (format) {
793 case 'a': /* ascii */
794 if (putprim == BRIGHT) {
795 getval = getbascii;
796 putval = putbascii;
797 } else if (putprim != ALL) {
798 getval = getbascii;
799 putval = putpascii;
800 } else {
801 getval = getcascii;
802 putval = putcascii;
803 }
804 return;
805 case 'f': /* binary float */
806 if (putprim == BRIGHT) {
807 getval = getbfloat;
808 putval = putbfloat;
809 } else if (putprim != ALL) {
810 getval = getbfloat;
811 putval = putpfloat;
812 } else {
813 getval = getcfloat;
814 putval = putcfloat;
815 }
816 return;
817 case 'd': /* binary double */
818 if (putprim == BRIGHT) {
819 getval = getbdouble;
820 putval = putbdouble;
821 } else if (putprim != ALL) {
822 getval = getbdouble;
823 putval = putpdouble;
824 } else {
825 getval = getcdouble;
826 putval = putcdouble;
827 }
828 return;
829 case 'i': /* integer */
830 if (putprim == BRIGHT) {
831 getval = getbint;
832 putval = putbint;
833 } else if (putprim != ALL) {
834 getval = getbint;
835 putval = putpint;
836 } else {
837 getval = getcint;
838 putval = putcint;
839 }
840 return;
841 case 'b': /* byte */
842 if (putprim == BRIGHT) {
843 getval = getbbyte;
844 putval = putbbyte;
845 } else if (putprim != ALL) {
846 getval = getbbyte;
847 putval = putpbyte;
848 } else {
849 getval = getcbyte;
850 putval = putcbyte;
851 }
852 return;
853 }
854 }