Path: utzoo!utgpu!cs.utexas.edu!samsung!think.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!bloom-beacon!eru!hagbard!sunic!ericom!news From: gunnar@falcon.ericsson.se (Was a Sunny day) Newsgroups: alt.sources Subject: Scantool part 2(5) (shar) Message-ID: <1991Jun18.124454.11082@ericsson.se> Date: 18 Jun 91 12:44:54 GMT Sender: news@ericsson.se Organization: The greatest Phone Company around Lines: 1210 Nntp-Posting-Host: falcon.ericsson.se #!/bin/sh # this is scan.02 (part 2 of a multipart archive) # do not concatenate these parts, unpack them in order with /bin/sh # file graphics.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 2; then echo Please unpack part "$Scheck" next! exit 1 else exit 0 fi ) < _shar_seq_.tmp || exit 1 if test ! -f _shar_wnt_.tmp; then echo 'x - still skipping graphics.c' else echo 'x - continuing file graphics.c' sed 's/^X//' << 'SHAR_EOF' >> 'graphics.c' && X } X else if (curx > butx+400 && curx < butx+400+BUTTON_WIDTH && X cury > buty+10 && cury < buty+10+BUTTON_HEIGHT) X { X state = CANCEL ; X make_button(butx+400, buty+10, "Cancel", B_INVERT) ; X finished = 1 ; X } X } X else if (type == KEYBOARD) X { X c = cur_ch ; X if (c == BACKSPACE || c == DEL) X picname[strlen(picname)-1] = '\0' ; X else if (c == RETURN || c == LINEFEED) X { X state = OK ; X finished = 1 ; X } X else if (c >= 32) STRNCAT(picname, &c, 1) ; X draw_area(butx+71, buty+11, 193, 23, GCLR) ; X nochars = (strlen(picname) <= 20) ? strlen(picname) : 20 ; X STRNCPY(dummy, &picname[strlen(picname) - nochars], nochars) ; X dummy[nochars] = '\0' ; X draw_text(butx+80, buty+27, STEN_OFF, BFONT, dummy) ; X draw_line(butx + 80 + get_strwidth(BFONT, dummy), buty + 15, X butx + 80 + get_strwidth(BFONT, dummy), buty + 30, GSET) ; X } X X if (finished) X { X if (state == CANCEL) STRCPY(picname, old_picname) ; X drawstate = DO_NOTHING ; X do_repaint() ; /* Redraw original screen. */ X } } X X make_menus() { X create_menu(BRIGHTNESS_M, "BRIGHTNESS", br_strs) ; X create_menu(CONTRAST_M, "CONTRAST", con_strs) ; X create_menu(GRAIN_M, "GRAIN", gr_strs) ; X create_menu(HELP_M, "HELP", help_strs) ; X create_menu(RESOLUTION_M, "RESOLUTION", res_strs) ; X create_menu(SET_M, "SET", set_strs) ; } X X process_event() { X enum menu_type column ; X int row, value ; X X if (type == IGNORE) return ; X else if (type == REPAINT) do_repaint() ; X else if (drawstate == DO_MESSAGE || X drawstate == DO_HELP || X drawstate == DO_SETTINGS) wait_for_ok() ; X else if (drawstate == DO_PICNAME) get_picname() ; X else X { X column = (enum menu_type) ((curx - 10) / MBAR_WIDTH) ; X row = cury / MBAR_HEIGHT ; X if (type == RIGHT_DOWN && row == 0) X { X value = display_menu(column) ; X if (value) process_menu(column, value) ; X } X else if (type == LEFT_DOWN) X { X if (curx > SCAN_WIDTH-150 && X curx < SCAN_WIDTH-90 && X cury > 4*SWITCH_HEIGHT+20 && X cury < 4*SWITCH_HEIGHT+20+BUTTON_HEIGHT) make_scan() ; X else if (curx > SCAN_WIDTH-150 && X curx < SCAN_WIDTH-90 && X cury > 4*SWITCH_HEIGHT+60 && X cury < 4*SWITCH_HEIGHT+60+BUTTON_HEIGHT) stop_scan() ; X else if (curx > SCAN_WIDTH-150 && X curx < SCAN_WIDTH-90 && X cury > 4*SWITCH_HEIGHT+100 && X cury < 4*SWITCH_HEIGHT+100+BUTTON_HEIGHT) show() ; X else test_switch(curx, cury) ; /* Test for a box switch press. */ X } X } } X X select_frame() /* Construct a new scanning window. */ { X int oldx = 0 ; X int oldy = 0 ; X int x1, y1, x2, y2 ; X int drawold = 0 ; X int found = 0 ; X X set_cursor(FRAME_CUR) ; X /* Remove current scan settings, if any. */ X draw_area(SCAN_FRAME_X+2, SCAN_FRAME_Y+2, 34*LINEGAP-4, 44*LINEGAP-4, GCLR) ; X draw_area(SCAN_FRAME_X-9, SCAN_FRAME_Y, 9, 46*LINEGAP-1, GCLR) ; X draw_area(SCAN_FRAME_X, SCAN_FRAME_Y-9, 34*LINEGAP-1, 9, GCLR) ; X X do X { X get_event() ; X handle_event() ; X if (curx > SCAN_FRAME_X && curx < SCAN_FRAME_X+34*LINEGAP && X cury > SCAN_FRAME_Y && cury < SCAN_FRAME_Y+44*LINEGAP) X { X curx = (curx / (FRAMEGAP) * (FRAMEGAP)) + 1 ; X cury = (cury / (FRAMEGAP) * (FRAMEGAP)) + 2 ; X if (type == LEFT_DOWN) found = 1 ; X if (type != MOUSE_MOVE) continue ; X if (drawold) X { X draw_line(oldx, SCAN_FRAME_Y-1, oldx, SCAN_FRAME_Y-9, GXOR) ; X draw_line(SCAN_FRAME_X-1, oldy, SCAN_FRAME_X-9, oldy, GXOR) ; X } X draw_line(curx, SCAN_FRAME_Y-1, curx, SCAN_FRAME_Y-9, GXOR) ; X draw_line(SCAN_FRAME_X-1, cury, SCAN_FRAME_X-9, cury, GXOR) ; X oldx = curx ; X oldy = cury ; X drawold++ ; X } X } X while (!found) ; X x1 = curx ; X y1 = cury ; X X found = 0 ; X drawold = 0 ; X do X { X get_event() ; X handle_event() ; X if (curx > SCAN_FRAME_X && curx < SCAN_FRAME_X+34*LINEGAP && X cury > SCAN_FRAME_Y && cury < SCAN_FRAME_Y+44*LINEGAP) X { X curx = (curx / (FRAMEGAP) * (FRAMEGAP)) + 1 ; X cury = (cury / (FRAMEGAP) * (FRAMEGAP)) + 2 ; X if (type == LEFT_UP) found = 1 ; X if (type != MOUSE_DRAG) continue ; X if (drawold) X { X draw_line(oldx, SCAN_FRAME_Y-1, oldx, SCAN_FRAME_Y-9, GXOR) ; X draw_line(SCAN_FRAME_X-1, oldy, SCAN_FRAME_X-9, oldy, GXOR) ; X draw_rect(x1, y1, oldx, oldy, GXOR) ; X } X draw_line(curx, SCAN_FRAME_Y-1, curx, SCAN_FRAME_Y-9, GXOR) ; X draw_line(SCAN_FRAME_X-1, cury, SCAN_FRAME_X-9, cury, GXOR) ; X draw_rect(x1, y1, curx, cury, GXOR) ; X oldx = curx ; X oldy = cury ; X drawold++ ; X } X } X while (!found) ; X X x2 = curx ; X y2 = cury ; X if (x1 > x2) X { X oldx = x2 ; X x2 = x1 ; X x1 = oldx ; X } X if (y1 > y2) X { X oldy = y2 ; X y2 = y1 ; X y1 = oldy ; X } X framevals[X1] = (x1 - SCAN_FRAME_X) / (FRAMEGAP) ; X framevals[Y1] = (y1 - SCAN_FRAME_Y) / (FRAMEGAP) ; X framevals[X2] = (x2 - SCAN_FRAME_X) / (FRAMEGAP) ; X framevals[Y2] = (y2 - SCAN_FRAME_Y) / (FRAMEGAP) ; X set_cursor(MAIN_CUR) ; } X X set_switch(x, y, position) int x, y, position ; { X if (position == ON) draw_image(x, y-2, 16, 16, S_INVERT) ; X else draw_image(x, y-2, 16, 16, S_NORMAL) ; } X X stop_scan() /* Stop the current scan (if there is one). */ { X if (!scanning) return ; X make_button(SCAN_WIDTH-150, 4*SWITCH_HEIGHT+60, "Cancel", B_INVERT) ; X KILL(pid, SIGHUP) ; } SHAR_EOF echo 'File graphics.c is complete' && chmod 0644 graphics.c || echo 'restore of graphics.c failed' Wc_c="`wc -c < 'graphics.c'`" test 12024 -eq "$Wc_c" || echo 'graphics.c: original size 12024, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= help.cursor ============== if test -f 'help.cursor' -a X"$1" != X"-c"; then echo 'x - skipping help.cursor (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting help.cursor (Text)' sed 's/^X//' << 'SHAR_EOF' > 'help.cursor' && /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16 X */ X 0xFFFF,0x8001,0xBFFD,0xA005,0xA385,0xA445,0xA445,0xA085, X 0xA105,0xA105,0xA005,0xA105,0xA005,0xBFFD,0x8001,0xFFFF SHAR_EOF chmod 0644 help.cursor || echo 'restore of help.cursor failed' Wc_c="`wc -c < 'help.cursor'`" test 193 -eq "$Wc_c" || echo 'help.cursor: original size 193, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= images.h ============== if test -f 'images.h' -a X"$1" != X"-c"; then echo 'x - skipping images.h (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting images.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'images.h' && X /* @(#)images.h 1.2 90/04/02 X * X * Various images used by the different versions of scantool. X * X * Copyright (c) Rich Burridge - Sun Microsystems. X * All rights reserved. X * X * Permission is given to distribute these sources, as long as the X * introductory messages are not removed, and no monies are exchanged. X * X * No responsibility is taken for any errors or inaccuracies inherent X * either to the comments or the code of this program, but if reported X * to me, then an attempt will be made to fix them. X */ X unsigned short grey_image[16] = X { X 0xAAAA, 0x5555, 0xAAAA, 0x5555, X 0xAAAA, 0x5555, 0xAAAA, 0x5555, X 0xAAAA, 0x5555, 0xAAAA, 0x5555, X 0xAAAA, 0x5555, 0xAAAA, 0x5555 X } ; X unsigned short icon_image[] = { #include "scantool.icon" } ; X unsigned short button_invert_image[] = { #include "button.invert.icon" } ; X unsigned short button_normal_image[] = { #include "button.normal.icon" } ; X unsigned short switch_invert_image[] = { #include "switch.invert.cursor" } ; X unsigned short switch_normal_image[] = { #include "switch.normal.cursor" } ; X unsigned short exclaim_image[] = { #include "exclaim.icon" } ; X unsigned short main_cursor_array[16] = { #include "main.cursor" } ; X unsigned short hour_cursor_array[16] = { #include } ; X unsigned short help_cursor_array[16] = { #include "help.cursor" } ; X unsigned short frame_cursor_array[16] = { #include "frame.cursor" } ; SHAR_EOF chmod 0644 images.h || echo 'restore of images.h failed' Wc_c="`wc -c < 'images.h'`" test 1552 -eq "$Wc_c" || echo 'images.h: original size 1552, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= main.cursor ============== if test -f 'main.cursor' -a X"$1" != X"-c"; then echo 'x - skipping main.cursor (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting main.cursor (Text)' sed 's/^X//' << 'SHAR_EOF' > 'main.cursor' && /* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16 X */ X 0x8000,0xC000,0xE000,0xF000,0xF800,0xFC00,0xFE00,0xF000, X 0xD800,0x9800,0x0C00,0x0C00,0x0600,0x0600,0x0300,0x0300 SHAR_EOF chmod 0644 main.cursor || echo 'restore of main.cursor failed' Wc_c="`wc -c < 'main.cursor'`" test 193 -eq "$Wc_c" || echo 'main.cursor: original size 193, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= make.sunview ============== if test -f 'make.sunview' -a X"$1" != X"-c"; then echo 'x - skipping make.sunview (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting make.sunview (Text)' sed 's/^X//' << 'SHAR_EOF' > 'make.sunview' && #!/bin/sh # This script does a make of the SunView tool. # make -f makefile.sunview sunview echo " " echo "Sunview tool now in file 'sv_scantool'" echo " " SHAR_EOF chmod 0555 make.sunview || echo 'restore of make.sunview failed' Wc_c="`wc -c < 'make.sunview'`" test 156 -eq "$Wc_c" || echo 'make.sunview: original size 156, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= makefile.sunview ============== if test -f 'makefile.sunview' -a X"$1" != X"-c"; then echo 'x - skipping makefile.sunview (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting makefile.sunview (Text)' sed 's/^X//' << 'SHAR_EOF' > 'makefile.sunview' && # # Makefile for the Microtek MS-300A to Sun rasterfile converter. # # @(#)Makefile 1.5 90/04/12 # # Copyright (c) Rich Burridge - Sun Microsystems Australia. # # No responsibility is taken for any errors inherent either in the comments # or the code of this program, but if reported to me then an attempt will # be made to fix them. # #========================================================================= # # There are various small changes needed when compiling faces on # different systems. These have been isolated here, and should # be uncommented if needed. #------------------------------------------------------------------------- # Scantool uses a helpfile to supply online help for various functions. # By default this file is called "scantool.help". You can also # override it's location and name at runtime with the -h option. # It can also be specified here by uncommenting the following # macro definition and setting appropriately. # HELPNAME = -DHELPNAME=\"$(LIBDIR)/scantool.help\" #------------------------------------------------------------------------- # If you not running under a BSD4.3 derived system, the parameters # to the select call are different, and this definition should be # uncommented. You need to uncomment this for SunOS v3.x. # SELTYPE = -DNO_4.3SELECT #------------------------------------------------------------------------- # Some versions of Unix use a pointer to a function returning an # integer as the return type of signal(). Newer systems use pointer to # function returning void. You need to uncomment this for SunOS v3.x. # SIGRET = -DSIGRET=int # #========================================================================= # # Default locations where scantool files will be installed. # You might wish to alter these values. # BINDIR = /usr/local/bin LIBDIR = /usr/local/lib/scantool MANDIR = /usr/local/man/manl MANSECT = l # # Compilation flags and standard macro definitions. # CFLAGS = -O $(HELPNAME) $(SELTYPE) $(SIGRET) $(XVIEWINCDIR) # #========================================================================= X BINARIES = sv_scantool scan X CC = cc X STDSTSRCS = scantool.c graphics.c misc.c STDSTOBJS = scantool.o graphics.o misc.o X STDSSRCS = scan.c scan_compress.c STDSOBJS = scan.o scan_compress.o X GSRCS = sunview.c HDRS = images.h patchlevel.h scan.h scan_extern.h \ X scantool.h scantool_extern.h OTHERS = Makefile CHANGES README black.codes white.codes \ X Imakefile scantool.help scan.1 scantool.1 IMAGES = exclaim.icon scantool.icon \ X button.normal.icon button.invert.icon \ X switch.normal.cursor switch.invert.cursor \ X frame.cursor help.cursor main.cursor X SFILES1 = $(STDSTSRCS) $(STDSSRCS) SFILES2 = $(GSRCS) $(HDRS) SFILES3 = $(OTHERS) $(IMAGES) X SVIEWLIBS = -lsuntool -lsunwindow -lpixrect X help: X @echo X @echo "You need to specify one of the following options:" X @echo X @echo " make sunview - to make the SunView version." X @echo X @echo "This should be followed by:" X @echo X @echo " make install" X @echo " make clean" X @echo X all: $(BINARIES) X sunview: sv_scantool scan X sv_scantool: $(STDSTOBJS) sunview.o X $(CC) -o sv_scantool $(CFLAGS) $(STDSTOBJS) \ X sunview.o $(SVIEWLIBS) # -cp sv_scantool scantool X scan: $(STDSOBJS) X $(CC) -o scan $(CFLAGS) $(STDSOBJS) X install: X install -s -m 751 scantool $(BINDIR) X install -s -m 751 scan $(BINDIR) X install -c -m 644 black.codes $(LIBDIR) X install -c -m 644 white.codes $(LIBDIR) X install -c -m 644 scantool.help $(LIBDIR) X install -c -m 644 scantool.1 $(MANDIR)/scantool.$(MANSECT) X install -c -m 644 scan.1 $(MANDIR)/scan.$(MANSECT) X clean:; rm -rf *.o archive.* *~ scantool $(BINARIES) core X shar:; shar.script $(SFILES1) > Part1 X shar.script $(SFILES2) > Part2 X shar.script $(SFILES3) > Part3 X lint:; lint $(STDSTSRCS) sunview.c $(SVIEWLIBS) X lint $(STDSSRCS) X lint $(STDSTSRCS) xview.c $(XVIEWLIBS) X create: SCCS X -sccs create $(STDSTSRCS) $(STDSSRCS) $(GSRCS) \ X $(HDRS) $(OTHERS) $(IMAGES) X SCCS: X mkdir SCCS X chmod 755 SCCS X graphics.o: graphics.c scantool_extern.h scantool.h misc.o: misc.c patchlevel.h scantool_extern.h scantool.h scan.o: scan.c patchlevel.h scan.h scan_compress.o: scan_compress.c scan_extern.h scan.h scantool.o: scantool.c scantool.h sunview.o: sunview.c scantool_extern.h images.h scantool.h \ X exclaim.icon scantool.icon \ X button.normal.icon button.invert.icon \ X switch.normal.cursor switch.invert.cursor \ X frame.cursor help.cursor main.cursor SHAR_EOF chmod 0644 makefile.sunview || echo 'restore of makefile.sunview failed' Wc_c="`wc -c < 'makefile.sunview'`" test 4598 -eq "$Wc_c" || echo 'makefile.sunview: original size 4598, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= misc.c ============== if test -f 'misc.c' -a X"$1" != X"-c"; then echo 'x - skipping misc.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting misc.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'misc.c' && X /* @(#)misc.c 1.4 90/04/04 X * X * Miscellaneous routines used by the scantool program. X * X * Copyright (c) Rich Burridge. X * Sun Microsystems, Australia - All rights reserved. X * X * Permission is given to distribute these sources, as long as the X * copyright messages are not removed, and no monies are exchanged. X * X * No responsibility is taken for any errors or inaccuracies inherent X * either to the comments or the code of this program, but if X * reported to me, then an attempt will be made to fix them. X */ X #include #include #include #include "scantool.h" #include "patchlevel.h" #include "scantool_extern.h" X X draw_settings() /* Display text for current scanner settings. */ { X int texty = 20 ; X int x, y ; X X x = (SCAN_WIDTH - 430) / 2 ; X y = (SCAN_HEIGHT - 100) / 2 ; X draw_frame(x, y, 430, 100) ; X X SPRINTF(output, "Brightness: %s", br_strs[brightness-1]) ; X draw_text(x+10, y+texty, STEN_OFF, NFONT, output) ; X X SPRINTF(output, "Contrast: %s", con_strs[contrast-1]) ; X draw_text(x+10, y+texty+15, STEN_OFF, NFONT, output) ; X X SPRINTF(output, "Grain: %s", gr_strs[grain]) ; X draw_text(x+10, y+texty+30, STEN_OFF, NFONT, output) ; X X SPRINTF(output, "Resolution: %s", res_strs[resolution]) ; X draw_text(x+10, y+texty+45, STEN_OFF, NFONT, output) ; X X SPRINTF(output, "Filename: %s", picname) ; X draw_text(x+10, y+texty+60, STEN_OFF, NFONT, output) ; } X X get_help() /* Read the help file and display. */ { X char help_str[MAXLINE], *p ; X int x, y ; X int length = 0 ; /* Length of longest help line. */ X int nolines = 0 ; /* Number of lines in help file. */ X char line[MAXLINE] ; /* Current line read from help file. */ X int texty = 20 ; /* Initial y coordinate for help message. */ X X if (nohelp) make_display("No help file found.") ; X else X { X SPRINTF(help_str, "%%%s%%\n", helpname) ; X rewind(hfd) ; X while (p = fgets(line, MAXLINE, hfd)) X if (*p == '%' && EQUAL(p, help_str)) break ; X X for (;;) /* Check for the length of the longest line. */ X { X FGETS(line, MAXLINE, hfd) ; X if (EQUAL(line, "%%\n")) break ; X if (strlen(line) > length) length = strlen(line) ; X nolines++ ; X } X X rewind(hfd) ; X while (p = fgets(line, MAXLINE, hfd)) X if (*p == '%' && EQUAL(p, help_str)) break ; X X set_cursor(HELP_CUR) ; X x = (SCAN_WIDTH - length*font_width - 20) / 2 ; X y = (SCAN_HEIGHT - nolines*15+texty) / 2 ; X draw_frame(x, y, length*font_width+20, nolines*15+texty) ; X X for (;;) X { X FGETS(line, MAXLINE, hfd) ; X if (EQUAL(line, "%%\n")) break ; X line[strlen(line)-1] = '\0' ; X draw_text(x+10, y+texty, STEN_OFF, NFONT, line) ; X texty += 15 ; X } X } } X X get_options(argc, argv) /* Extract command line options. */ int argc ; char *argv[] ; { X INC ; X while (argc > 0) X { X if (argv[0][0] == '-') X switch (argv[0][1]) X { X case 'h' : INC ; /* Help filename. */ X getparam(helpname, argv, "-h needs help filename") ; X break ; X case 'v' : FPRINTF(stderr, "%s version 1.4.%1d\n", X progname, PATCHLEVEL) ; X break ; X case '?' : usage() ; X } X INC ; X } } X X getparam(s, argv, errmes) char *s, *argv[], *errmes ; { X if (*argv != NULL && argv[0][0] != '-') STRCPY(s, *argv) ; X else X { X FPRINTF(stderr,"%s: %s as next argument.\n", progname, errmes) ; X exit(1) ; X } } X X make_button(x, y, text, state) /* Draw a text button. */ int x, y ; char *text ; enum image_type state ; { X enum sten_type stencil ; X X draw_image(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, state) ; X width = get_strwidth(BFONT, text) ; X if (state == B_NORMAL) stencil = STEN_ON ; X else stencil = STEN_INV ; X draw_text(x + ((64 - width) / 2), X y + FONT_HEIGHT + ((BUTTON_HEIGHT - FONT_HEIGHT) / 2) - 5, X stencil, BFONT, text) ; } X X make_display(output) /* Output message to the display window. */ char *output ; { X STRCPY(last_message, output) ; /* Save in case of a redraw. */ X make_message() ; /* Output message as popup to the canvas. */ } X X make_help(value) { X if (value) X { X STRCPY(helpname, help_strs[value-1]) ; X if (isupper(helpname[0])) helpname[0] = tolower(helpname[0]) ; X get_help() ; /* Read the help file and display. */ X drawstate = DO_HELP ; X butx = buty = 0 ; X } } X X make_message() /* Output message to the display window. */ { X int x, y ; X X width = strlen(last_message) * font_width + 20 ; X if (width < 300) width = 300 ; X x = (SCAN_WIDTH - width) / 2 ; X y = (SCAN_HEIGHT - 90) / 2 ; X draw_frame(x, y, width, 90) ; X draw_image(x + 30, y + 15, 64, 64, EXCLAIM_IMAGE) ; X butx = x + width - 90 ; X buty = y + 15 ; X make_button(x + width - 90, y + 15, "OK", B_NORMAL) ; X draw_text(x + 10, y + 65, STEN_OFF, NFONT, last_message) ; X drawstate = DO_MESSAGE ; } X X make_scan() /* Start scanning process, and wait for it to terminate. */ { X char arg_contrast[MAXLINE] ; /* Contrast value. */ X char arg_brightness[MAXLINE] ; /* Brightness value. */ X char arg_datatrans[MAXLINE] ; /* Data transfer (or blank). */ X char arg_framevals[4][MAXLINE] ; /* Scanning frame values. */ X char arg_grain[MAXLINE] ; /* Grain value. */ X char arg_mode[MAXLINE] ; /* Mode (or blank). */ X char arg_picname[MAXLINE] ; /* Picture name. */ X char arg_resolution[MAXLINE] ; /* Resolution value. */ X char arg_speed[MAXLINE] ; /* Speed of connection (or blank). */ X char arg_ttyport[MAXLINE] ; /* Tty port (or blank). */ X X SPRINTF(arg_brightness, "%1d", brightness) ; X SPRINTF(arg_contrast, "%1d", contrast) ; X SPRINTF(arg_datatrans, "%1d", switches[DATA_TRANSFER]) ; X SPRINTF(arg_framevals[X1], "%1d", framevals[X1]) ; X SPRINTF(arg_framevals[Y1], "%1d", framevals[Y1]) ; X SPRINTF(arg_framevals[X2], "%1d", framevals[X2]) ; X SPRINTF(arg_framevals[Y2], "%1d", framevals[Y2]) ; X SPRINTF(arg_grain, "%1d", grain) ; X SPRINTF(arg_mode, "%1d", switches[MODE]) ; X SPRINTF(arg_picname, "%s", picname) ; X SPRINTF(arg_resolution, "%1d", resolution) ; X SPRINTF(arg_speed, "%1d", switches[BAUD_RATE]) ; X SPRINTF(arg_ttyport, "%1d", switches[SERIAL_PORT]) ; X X if (scanning) X { X make_display("There is a scan already in progress") ; X return ; X } X scanning = 1 ; X make_button(SCAN_WIDTH-150, 4*SWITCH_HEIGHT+20, "Scan", B_INVERT) ; X if ((pid = vfork()) == 0) X { X EXECL("scan"," ","-c", arg_contrast, "-b", arg_brightness, X "-d", arg_datatrans, "-f", arg_framevals[X1], X arg_framevals[Y1], arg_framevals[X2], arg_framevals[Y2], X "-g", arg_grain, "-m", arg_mode, X "-p", arg_picname, "-r", arg_resolution, X "-s", arg_speed, "-t", arg_ttyport, X (char *) 0) ; X FPRINTF(stderr, "%s: Couldn't fork the scan process.\n", progname) ; X exit(1) ; /* Should never get here. */ X } X wait_on_child(pid) ; } X X make_set(value) int value ; { X switch (value) X { X case SET_PICTURE : STRCPY(old_picname, picname) ; X draw_picarea() ; X break ; X case SET_DEFAULTS : set_defaults() ; X break ; X case SET_CLEAR_FRAME : framevals[X1] = 0 ; X framevals[Y1] = 0 ; X framevals[X2] = 68 ; X framevals[Y2] = 88 ; X draw_area(SCAN_FRAME_X+2, SCAN_FRAME_Y+2, X 34*LINEGAP-4, 44*LINEGAP-4, GCLR) ; X draw_area(SCAN_FRAME_X-9, SCAN_FRAME_Y, X 9, 46*LINEGAP-1, GCLR) ; X draw_area(SCAN_FRAME_X, SCAN_FRAME_Y-9, X 34*LINEGAP-1, 9, GCLR) ; X break ; X case SET_NEW_FRAME : select_frame() ; X break ; X case SET_CURRENT : show_settings() ; X } } X X make_switch(x, y, title, boxa, boxb) int x, y ; char *title, *boxa, *boxb ; { X draw_text(x, y, STEN_OFF, BFONT, title) ; X set_switch(x, y+10, OFF) ; X draw_text(x+30, y+20, STEN_OFF, BFONT, boxa) ; X set_switch(x, y+30, OFF) ; X draw_text(x+30, y+40, STEN_OFF, BFONT, boxb) ; } X X process_menu(mtype, value) /* Process a menu choice. */ enum menu_type mtype ; int value ; { X switch (mtype) X { X case BRIGHTNESS_M : brightness = value ; X break ; X case CONTRAST_M : contrast = value ; X break ; X case GRAIN_M : grain = value-1 ; X break ; X case HELP_M : make_help(value) ; X break ; X case RESOLUTION_M : resolution = value-1 ; X break ; X case SET_M : make_set(value) ; X } } X X set_defaults() /* Return scanner setting to default. */ { X brightness = 7 ; /* Brightness value (no adjustment). */ X contrast = 7 ; /* Contrast value (no adjustment). */ X grain = 2 ; /* Grain value (grain size: 8x8 levels: 33). */ X resolution = 0 ; /* Resolution value (300 dpi). */ } X X show_settings() /* Display current scanner settings in a popup window. */ { X draw_settings() ; /* Display setting values. */ X drawstate = DO_SETTINGS ; X butx = buty = 0 ; } X X test_switch(x, y) /* Test for a switch box being pressed. */ int x, y ; { X int i, j ; X X if (x > SCAN_WIDTH-150 && x < SCAN_WIDTH-130) X for (i = 0; i < 2; i++) X for (j = 0; j < 4; j++) X if ((y > j*SWITCH_HEIGHT+50+i*20) && (y < j*SWITCH_HEIGHT+70+i*20)) X if (i) X { X set_switch(SCAN_WIDTH-150, j*SWITCH_HEIGHT+50, OFF) ; X set_switch(SCAN_WIDTH-150, j*SWITCH_HEIGHT+70, ON) ; X switches[j] = i ; X } X else X { X set_switch(SCAN_WIDTH-150, j*SWITCH_HEIGHT+50, ON) ; X set_switch(SCAN_WIDTH-150, j*SWITCH_HEIGHT+70, OFF) ; X switches[j] = i ; X } } X X usage() { X FPRINTF(stderr, "Usage: %s: [-h helpname] [-v] [-?]\n", progname) ; X exit(1) ; } X X wait_for_ok() /* Wait for user to acknowledge. */ { X int doexit = 0 ; X X switch (type) X { X case LEFT_DOWN : if (butx && buty) X { X if (curx > butx && curx < butx+BUTTON_WIDTH && X cury > buty && cury < buty+BUTTON_HEIGHT) X { X make_button(butx, buty, "OK", B_INVERT) ; X doexit = 1 ; X } X } X else doexit = 1 ; X break ; X case KEYBOARD : if (cur_ch == LINEFEED || cur_ch == RETURN) X doexit = 1 ; X } X X if (doexit) X { X set_cursor(MAIN_CUR) ; X drawstate = DO_NOTHING ; X do_repaint() ; X } } SHAR_EOF chmod 0644 misc.c || echo 'restore of misc.c failed' Wc_c="`wc -c < 'misc.c'`" test 11483 -eq "$Wc_c" || echo 'misc.c: original size 11483, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= notify.h ============== if test -f 'notify.h' -a X"$1" != X"-c"; then echo 'x - skipping notify.h (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting notify.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'notify.h' && X /* @(#)notify.h 20.18 90/06/19 SMI */ X /* X * (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents X * pending in the U.S. and foreign countries. See LEGAL NOTICE X * file for terms of the license. X */ X #ifndef xview_notify_DEFINED #define xview_notify_DEFINED X /* X *********************************************************************** X * Include Files X *********************************************************************** X */ X #include #include X /* X *********************************************************************** X * Definitions and Macros X *********************************************************************** X */ X /* X * PUBLIC #defines X */ X #define NOTIFY_FUNC_NULL ((Notify_func)0) X /* Macros to examine wait3/waitpid results provided for BSD rather X * than adding a lot of #ifdef'ed code in the .c's. Note that AT&T- X * style macros expect the status value (not a pointer to it). X * Also provide a dummy rusage structure in the non-BSD case. X */ #if !(defined WTERMSIG) && !(defined SVR4) #define WTERMSIG(status) ((status).w_termsig) #endif #if !(defined WSTOPSIG) && !(defined SVR4) #define WSTOPSIG(status) ((status).w_stopsig) #endif #if !(defined WEXITSTATUS) && !(defined SVR4) #define WEXITSTATUS(status) ((status).w_retcode) #endif #if !(defined WCOREDUMP) && !(defined SVR4) #define WCOREDUMP(status) ((status).w_coredump) #endif #ifdef SVR4 struct rusage { X int notused; /* to make it valid */ }; #endif SVR4 /* X * PRIVATE #defines X */ X #define NOTIFY_CLIENT_NULL ((Notify_client)0) #define NOTIFY_COPY_NULL ((Notify_copy)0) #define NOTIFY_RELEASE_NULL ((Notify_release)0) #define NOTIFY_ARG_NULL ((Notify_arg)0) X /* X * Mask bit generating macros (for prioritizer): X */ #define SIG_BIT(sig) (1 << ((sig)-1)) X /* X *********************************************************************** X * Typedefs, enumerations, and structures X *********************************************************************** X */ X /* X * Opaque client handle. X */ typedef Xv_opaque Notify_client; X #ifndef _NOTIFY_MIN_SYMBOLS /* Hack to reduce symbols in libraries. */ X /* X * Opaque client event. X */ typedef Xv_opaque Notify_event; X /* X * Opaque client event optional argument. X */ typedef Xv_opaque Notify_arg; X /* X * A pointer to a function returning a Notify_arg (used for client X * event additional argument copying). X */ typedef Notify_arg (*Notify_copy)(); X /* X * A pointer to a function returning void (used for client X * event additional argument storage releasing). X */ typedef void (*Notify_release)(); X /* X * For Debugging utility: X */ typedef enum notify_dump_type { X NOTIFY_ALL=0, X NOTIFY_DETECT=1, X NOTIFY_DISPATCH=2, } Notify_dump_type; X #endif ~_NOTIFY_MIN_SYMBOLS X /* X * Client notification function return values for notifier to client calls. X */ typedef enum notify_value { X NOTIFY_DONE = 0, /* Handled notification */ X NOTIFY_IGNORED = 1, /* Did nothing about notification */ X NOTIFY_UNEXPECTED = 2, /* Notification not expected */ } Notify_value; X /* X * A pointer to a function returning a Notify_value. X */ typedef Notify_value (*Notify_func)(); X /* X * Error codes for client to notifier calls (returned when no other X * return value or stored in notify_errno when other return value X * indicates error condition). X */ typedef enum notify_error { X NOTIFY_OK = 0, /* Success */ X NOTIFY_UNKNOWN_CLIENT = 1, /* Client argument unknown to notifier */ X NOTIFY_NO_CONDITION = 2, /* Client not registered for given X * condition X */ X NOTIFY_BAD_ITIMER = 3, /* Itimer type unknown */ X NOTIFY_BAD_SIGNAL = 4, /* Signal number out of range */ X NOTIFY_NOT_STARTED = 5, /* Notify_stop called & notifier not X * started X */ X NOTIFY_DESTROY_VETOED = 6, /* Some client didn't want to die when X * called notify_die(DESTROY_CHECKING) X */ X NOTIFY_INTERNAL_ERROR = 7, /* Something wrong in the notifier */ X NOTIFY_SRCH = 8, /* No such process */ X NOTIFY_BADF = 9, /* Bad file number */ X NOTIFY_NOMEM = 10, /* Not enough core */ X NOTIFY_INVAL = 11, /* Invalid argument */ X NOTIFY_FUNC_LIMIT = 12, /* Too many interposition functions */ } Notify_error; X X /* X * Argument types X */ typedef enum notify_signal_mode { X NOTIFY_SYNC = 0, X NOTIFY_ASYNC = 1, } Notify_signal_mode; X typedef enum notify_event_type { X NOTIFY_SAFE = 0, X NOTIFY_IMMEDIATE = 1, } Notify_event_type; X typedef enum destroy_status { X DESTROY_PROCESS_DEATH = 0, X DESTROY_CHECKING = 1, X DESTROY_CLEANUP = 2, X DESTROY_SAVE_YOURSELF = 3, } Destroy_status; X /* X *********************************************************************** X * Globals X *********************************************************************** X */ X /* X * PUBLIC variables X */ X extern struct itimerval NOTIFY_POLLING_ITIMER; /* {{0,1},{0,1}} */ X /* X * PRIVATE variables X */ X extern Notify_error notify_errno; X #ifndef _NOTIFY_MIN_SYMBOLS extern struct itimerval NOTIFY_NO_ITIMER; /* {{0,0},{0,0}} */ #endif ~_NOTIFY_MIN_SYMBOLS X /* X * PUBLIC functions X */ X #ifndef _NOTIFY_MIN_SYMBOLS X EXTERN_FUNCTION (Notify_value notify_default_wait3, (Notify_client nclient, int pid, union wait *status, struct rusage *rusage)); EXTERN_FUNCTION (Notify_error notify_dispatch, (void)); EXTERN_FUNCTION (Notify_error notify_do_dispatch, (void)); EXTERN_FUNCTION (Notify_error notify_itimer_value, (Notify_client nclient, int which, struct itimerval *value)); EXTERN_FUNCTION (Notify_value notify_next_destroy_func, (Notify_client nclient, Destroy_status status)); EXTERN_FUNCTION (Notify_value notify_next_event_func, (Notify_client nclient, Notify_event event, Notify_arg arg, Notify_event_type when)); EXTERN_FUNCTION (Notify_error notify_no_dispatch, (void)); EXTERN_FUNCTION (Notify_func notify_set_destroy_func, (Notify_client nclient, Notify_func func)); EXTERN_FUNCTION (Notify_func notify_set_exception_func, (Notify_client nclient, Notify_func func, int fd)); EXTERN_FUNCTION (Notify_func notify_set_input_func, (Notify_client nclient, Notify_func func, int fd)); EXTERN_FUNCTION (Notify_func notify_set_itimer_func, (Notify_client nclient, Notify_func func, int which, struct itimerval *value, struct itimerval *ovalue)); EXTERN_FUNCTION (Notify_func notify_set_output_func, (Notify_client nclient, Notify_func func, int fd)); EXTERN_FUNCTION (Notify_func notify_set_signal_func, (Notify_client nclient, Notify_func func, int sig, Notify_signal_mode mode)); EXTERN_FUNCTION (Notify_func notify_set_wait3_func, (Notify_client nclient, Notify_func func, int pid)); EXTERN_FUNCTION (Notify_error notify_start, (void)); EXTERN_FUNCTION (Notify_error notify_stop, (void)); EXTERN_FUNCTION (Notify_error notify_veto_destroy, (Notify_client nclient)); EXTERN_FUNCTION (void notify_perror, (char *str)); X #endif ~_NOTIFY_MIN_SYMBOLS X /* X * PRIVATE functions X */ X EXTERN_FUNCTION (Notify_func notify_set_event_func, (Notify_client nclient, Notify_func func, Notify_event_type when)); EXTERN_FUNCTION (Notify_error notify_remove, (Notify_client nclient)); X #ifndef _NOTIFY_MIN_SYMBOLS X EXTERN_FUNCTION (Notify_error notify_client, (Notify_client nclient)); EXTERN_FUNCTION (Notify_error notify_destroy, (Notify_client nclient, Destroy_status status)); EXTERN_FUNCTION (Notify_error notify_die, (Destroy_status status)); EXTERN_FUNCTION (Notify_error notify_event, (Notify_client nclient, Notify_event event, Notify_arg arg)); EXTERN_FUNCTION (Notify_error notify_exception, (Notify_client nclient, int fd)); EXTERN_FUNCTION (void notify_flush_pending, (Notify_client nclient)); EXTERN_FUNCTION (Notify_func notify_get_destroy_func, (Notify_client)); EXTERN_FUNCTION (Notify_func notify_get_event_func, (Notify_client nclient, Notify_event_type when)); EXTERN_FUNCTION (Notify_func notify_get_exception_func, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_func notify_get_input_func, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_func notify_get_itimer_func, (Notify_client nclient, int which)); EXTERN_FUNCTION (Notify_func notify_get_output_func, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_func notify_get_prioritizer_func, (Notify_client nclient)); EXTERN_FUNCTION (Notify_func notify_get_scheduler_func, (void)); EXTERN_FUNCTION (int notify_get_signal_code, (void)); #ifndef SVR4 EXTERN_FUNCTION (struct sigcontext *notify_get_signal_context, (void)); #else SVR4 EXTERN_FUNCTION (struct ucontext_t *notify_get_signal_context, (void)); #endif SVR4 EXTERN_FUNCTION (Notify_func notify_get_signal_func, (Notify_client nclient, int signal, Notify_signal_mode mode)); EXTERN_FUNCTION (Notify_func notify_get_wait3_func, (Notify_client nclient, int pid)); EXTERN_FUNCTION (Notify_error notify_input, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_error notify_interpose_destroy_func, (Notify_client nclient, Notify_func func)); EXTERN_FUNCTION (Notify_error notify_interpose_event_func, (Notify_client nclient, Notify_func func, Notify_event_type when)); EXTERN_FUNCTION (Notify_error notify_interpose_exception_func, (Notify_client nclient, Notify_func func, int fd)); EXTERN_FUNCTION (Notify_error notify_interpose_input_func, (Notify_client nclient, Notify_func func, int fd)); EXTERN_FUNCTION (Notify_error notify_interpose_itimer_func, (Notify_client nclient, Notify_func func, int which)); EXTERN_FUNCTION (Notify_error notify_interpose_output_func, (Notify_client nclient, Notify_func func, int fd)); EXTERN_FUNCTION (Notify_error notify_interpose_signal_func, (Notify_client nclient, Notify_func func, int signal, Notify_signal_mode mode)); EXTERN_FUNCTION (Notify_error notify_interpose_wait3_func, (Notify_client nclient, Notify_func func, int pid)); EXTERN_FUNCTION (Notify_error notify_itimer, (Notify_client nclient, int which)); EXTERN_FUNCTION (Notify_value notify_next_exception_func, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_value notify_next_input_func, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_value notify_next_itimer_func, (Notify_client nclient, int which)); EXTERN_FUNCTION (Notify_value notify_next_output_func, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_value notify_next_signal_func, (Notify_client nclient, int signal, Notify_signal_mode mode)); EXTERN_FUNCTION (Notify_value notify_next_wait3_func, (Notify_client nclient, int pid, union wait *status, struct rusage *rusage)); EXTERN_FUNCTION (Notify_value notify_nop, (void)); EXTERN_FUNCTION (Notify_error notify_output, (Notify_client nclient, int fd)); EXTERN_FUNCTION (Notify_error notify_post_destroy, (Notify_client nclient, Destroy_status status, Notify_event_type type)); EXTERN_FUNCTION (Notify_error notify_post_event, (Notify_client nclient, Notify_event event, Notify_event_type when_hint)); EXTERN_FUNCTION (Notify_error notify_post_event_and_arg, (Notify_client nclient, Notify_event event, Notify_event_type when_hint, Notify_copy copy_func, Notify_release release_func)); EXTERN_FUNCTION (Notify_error notify_remove_destroy_func, (Notify_client nclient, Notify_func func)); EXTERN_FUNCTION (Notify_error notify_remove_event_func, (Notify_client nclient, Notify_func func, Notify_event_type when)); SHAR_EOF true || echo 'restore of notify.h failed' fi echo 'End of part 2' echo 'File notify.h is continued in part 3' echo 3 > _shar_seq_.tmp exit 0