diff --git a/inc/ocr.h b/inc/ocr.h deleted file mode 100755 index 98b59d9..0000000 --- a/inc/ocr.h +++ /dev/null @@ -1,254 +0,0 @@ -/* $Id: ocr.h,v 1.2 1999/01/03 02:06:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ - - - - - - -/************************************************************************/ -/* */ -/* (C) Copyright 1989-96 Venue. All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/************************************************************************/ - - -#ifdef OCR - -extern int OCR_sock; -extern int OCR_sv; -extern int OCR_fd; -extern int OCR_procID; - -/* - * Device file for OCR - */ - -#define OCRDEV "/dev/ocr0" - -/* - * SUBR_OCR_COMM alpha byte - */ - -#define DO_OPEN 0 -#define DO_SCAN 1 -#define DO_IMG_INFO 2 -#define DO_IMG_UPLD 3 -#define DO_SET_RPARA 4 -#define DO_CLR_RPARA 5 -#define DO_READ 6 -#define DO_READ_INFO 7 -#define DO_GET_RESULT 8 -#define DO_ABORT 9 -#define DO_CLOSE 10 -#define DO_CODE_CONV 11 -#define DO_TEST 12 - -/* - * OCR state indicated in IL:\OCR.STATE.FLAGS - */ - -#define OCR_ST_FAIL 1 -#define OCR_ST_SCANNING 2 -#define OCR_ST_UPLDING 3 -#define OCR_ST_PROC_DEAD 4 -#define OCR_ST_READING 5 - - -/* - * OCR SCAN parameter. In Lisp, BLOCKRECORD OCR.SCAN.PARAMS - */ - -struct ocr_scan_para { - u_char size : 3, - direction : 1, - dencity : 3, - binary : 1; - u_char resolution : 3, - adf : 1, - filter : 1, - threshold : 3; - u_char noise : 3, - doc : 1, - smooth : 1, - compo : 3; -}; - -#define OCR_SIZE_A4 0 -#define OCR_SIZE_B4 1 -#define OCR_SIZE_A5 2 -#define OCR_SIZE_B5 3 -#define OCR_SIZE_LG 4 -#define OCR_SIZE_LT 5 - -#define OCR_DIRECT_VT 0 -#define OCR_DIRECT_HR 1 - -#define OCR_RES_200 0 -#define OCR_RES_240 1 -#define OCR_RES_300 2 -#define OCR_RES_400 3 - -#define OCR_DENC_0 0 -#define OCR_DENC_1 1 -#define OCR_DENC_2 2 -#define OCR_DENC_3 3 -#define OCR_DENC_4 4 -#define OCR_DENC_5 5 -#define OCR_DENC_6 6 -#define OCR_DENC_7 7 - -#define OCR_SCANNER_FL 0 -#define OCR_SCANNER_AD 1 - -#define OCR_FILTER_NR 0 -#define OCR_FILTER_BP 1 - -#define OCR_THRES_0 0 -#define OCR_THRES_1 1 -#define OCR_THRES_2 2 -#define OCR_THRES_3 3 -#define OCR_THRES_4 4 -#define OCR_THRES_5 5 - -#define OCR_NOISE_0 0 -#define OCR_NOISE_2 1 -#define OCR_NOISE_3 2 -#define OCR_NOISE_4 3 -#define OCR_NOISE_5 4 - -#define OCR_DOC_NR 0 -#define OCR_DOC_NW 1 - -#define OCR_SMTH_CH 0 -#define OCR_SMTH_IM 1 - -#define OCR_COMPO_LD 0 -#define OCR_COMPO_PN 1 -#define OCR_COMPO_PH 2 -#define OCR_COMPO_PL 3 - -/* - * OCR Image Info structure. In Lisp, BLOCKRECORD OCR.IMG.INFO - * On SPARC, the size of this structure is 20. - */ - -struct ocr_image_info { - u_short xs; - u_short ys; - u_short xe; - u_short ye; - u_short line_width; - u_int size; - u_char resolution : 3, - compress : 3, - : 2; -}; - -/* - * OCR Image Upload parameter. In Lisp, BLOCKRECORD OCR.IMG.UPLD.PARA - * On SPARC, the size of this structure is 10. - */ - -struct ocr_up_para { - u_short xs; - u_short ys; - u_short xe; - u_short ye; - u_char resolution : 3, - compress : 3, - : 2; -}; - -#define OCR_COMP_NONE 0 -#define OCR_COMP_2 1 -#define OCR_COMP_4 2 -#define OCR_COMP_8 3 - -/* - * Maximum number of regions to read per page - */ - -#define OCR_MAX_RD_PARAMS 200 - -/* - * OCR Read Parameter. In Lisp, BLOCKRECORD OCR.IMG.READ.PARA - * On SPARC, the size of this structure is 14. - */ - -struct ocr_read_para { - u_short xs; - u_short ys; - u_short xe; - u_short ye; - u_char format; - u_char csize; - u_char reject; - u_char cunit : 2, - deform : 4, - : 2; - u_char ck_num : 1, - ck_alph : 1, - ck_grk : 1, - ck_jvt : 1, - ck_jhr : 1, - ck_sym : 1, - ck_kana : 1, - ck_joyou : 1; - u_char ck_jis1 : 1, - ck_jmisc : 1, - ck_gaiji : 1, - : 5; -}; - -#define OCR_FMT_H1 0 -#define OCR_FMT_H2 1 -#define OCR_FMT_H3 2 -#define OCR_FMT_H4 3 -#define OCR_FMT_V1 4 -#define OCR_FMT_V2 5 -#define OCR_FMT_V3 6 -#define OCR_FMT_V4 7 - -#define OCR_CUNIT_PO 0 -#define OCR_CUNIT_KY 1 -#define OCR_CUNIT_MM 2 - -#define OCR_REJ_0 0 -#define OCR_REJ_1 1 -#define OCR_REJ_2 2 -#define OCR_REJ_3 3 -#define OCR_REJ_4 4 -#define OCR_REJ_5 5 - -#define OCR_DFRM_1 0 -#define OCR_DFRM_2 1 -#define OCR_DFRM_3 2 -#define OCR_DFRM_4 3 -#define OCR_DFRM_NR 4 -#define OCR_DFRM_6 5 -#define OCR_DFRM_7 6 -#define OCR_DFRM_8 7 -#define OCR_DFRM_9 8 - -/* - * Header for bulk data transfer - */ - -struct bd_header { - u_int len; - u_int cont; -}; - -#define BD_LAST 0 -#define BD_CONT 1 - -/* - * The comm/res packet length used by OCR process - */ - -#define PKTLEN 3 -#define EPKTLEN 65536 - -#endif /* OCR */ - diff --git a/src/ocr.c b/src/ocr.c deleted file mode 100644 index e2924f0..0000000 --- a/src/ocr.c +++ /dev/null @@ -1,1453 +0,0 @@ -/* $Id: ocr.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ - -/************************************************************************/ -/* */ -/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/************************************************************************/ - -#include "version.h" - -#ifdef OCR - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "adr68k.h" -#include "lispmap.h" -#include "lispemul.h" -#include "lsptypes.h" -#include "lspglob.h" -#include "cell.h" -#include "arith.h" -#include "timeout.h" -#include "ocr.h" - -/* - * Socket descriptor to communicate with the OCR process - */ - -int OCR_sock = -1; -u_int shifted_OCR_sock; - -/* - * OCR process ID - */ - -int OCR_procID = -1; - -/* - * Lisp I/F to indicate wait status. - * Points to the value cell of IL:\OCR.STATE.FLAGS - */ - -LispPTR *OCR_state_word = NULL; - -/* - * Other Lisp I/F area - */ - -struct ocr_image_info *OCR_iminfo_block = NULL; - -/* - * Image size cache - */ - -static u_int OCR_image_size = 0; - -/* - * Local Definitions for clarify code - */ - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#define NULL_STATE_WORD (OCR_state_word == NULL) - -#define WAITING_REASON (*(u_int *)Addr68k_from_LADDR(*OCR_state_word)) - -#define INIT_STATE_WORD \ - { \ - DLword an; \ - extern int get_package_atom(); \ - an = get_package_atom("\\OCR.STATE.FLAGS", 16, "INTERLISP", 9, NIL); \ - OCR_state_word = GetDEFCELL68k(an); \ - } - -#define SET_WAIT_FLG(reason) \ - { \ - u_int *flagp; \ - flagp = (u_int *)Addr68k_from_LADDR(*OCR_state_word); \ - *flagp = reason; \ - } - -#define CLR_WAIT_FLG \ - { \ - u_int *flagp; \ - flagp = (u_int *)Addr68k_from_LADDR(*OCR_state_word); \ - *flagp = 0; \ - } - -#define FD_BLOCK 1 -#define FD_NON_BLOCK 0 - -/* - * Local Functions - */ - -static int ocr_open(), ocr_scan(), ocr_iminfo(), ocr_fork(); -static int ocr_block_mode(), ocr_bulk_read(), ocr_wait(); -static int ocr_set_rpara(), ocr_read(); -static void ocr_close(), ocr_sig_handler(), ocr_irq(), ocr_set_handler(); -static void ocr_clr_handler(), ocr_device_reset(); -static void ocr_scan_finish(), ocr_img_upld_finish(), ocr_read_finish(); -static void ocr_code_conv(); -static LispPTR ocr_get_read_result(); - -/* - * Subr OCR_COMM: - * - * According to the command indicated by args[0], dispatch to the appropriate - * routines. Each subroutine should return one of 1, 0 and -1 as its value. - * 1 means the command is completed successfully. 0 means the command is failed - * but the OCR process is still alive. -1 means the command is failed and - * OCR process seems dead. In -1 case, issue an interrupt request with interrupt - * mode OCR_ST_PROC_DEAD. This causes Lisp fall into a debugger after establishing - * unwind protected contour to reset OCR. - */ - -int ocr_comm(LispPTR *args) -{ - int com; - LispPTR val; - - N_GETNUMBER(args[0], com, INVAL); - switch (com) { - case DO_OPEN: - if (OCR_sock >= 0) { - val = GetSmallp(0); - } else { - val = ocr_open(); - if (val > 0) { - val = GetSmallp(val); - } else { - val = GetSmallp(0); - } - } - break; - - case DO_SCAN: { - switch (ocr_scan((struct ocr_scan_para *)Addr68k_from_LADDR(args[1]))) { - case 1: val = ATOM_T; break; - - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; - - case 0: - default: val = NIL; - } - } break; - - case DO_IMG_INFO: - if (OCR_sock < 0) { - val = NIL; - } else { - OCR_iminfo_block = (struct ocr_image_info *)Addr68k_from_LADDR(args[2]); - - switch (ocr_iminfo((struct ocr_up_para *)Addr68k_from_LADDR(args[1]))) { - case 1: val = ATOM_T; break; - - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; - - case 0: - default: val = NIL; - } - } - break; - - case DO_IMG_UPLD: { - BITMAP *bmp; - int len; - - bmp = (BITMAP *)Addr68k_from_LADDR(args[1]); - - len = ocr_bulk_read(OCR_sock, (char *)Addr68k_from_LADDR(bmp->bmbase), 10); - val = (len < 0) ? NIL : ATOM_T; - } break; - - case DO_SET_RPARA: { - int cnt; - u_char *pp; - - pp = (u_char *)Addr68k_from_LADDR(args[1]); - N_GETNUMBER(args[2], cnt, INVAL); - - switch (ocr_set_rpara(pp, cnt)) { - case 1: val = ATOM_T; break; - - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; - - case 0: - default: val = NIL; - } - } break; - - case DO_CLR_RPARA: { - switch (ocr_clr_rpara()) { - case 1: val = ATOM_T; break; - - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; - - case 0: - default: val = NIL; - } - } break; - - case DO_READ: { - switch (ocr_read()) { - case 1: val = ATOM_T; break; - - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; - - case 0: - default: val = NIL; - } - } break; - - case DO_GET_RESULT: - if (OCR_sock < 0) { - val = NIL; - } else { - val = ocr_get_read_result(OCR_sock); - } - break; - - case DO_CLOSE: - if (OCR_sock < 0) { - val = NIL; - } else { - ocr_close(); - val = ATOM_T; - } - break; - - case DO_CODE_CONV: { - int len; - N_GETNUMBER(args[1], len, INVAL); - ocr_code_conv((u_char *)Addr68k_from_LADDR(args[2]), len); - val = ATOM_T; - } break; - - case DO_TEST: { - extern DLword *createcell68k(); - u_char *np, *np2; - LispPTR lp; - - np = (u_char *)createcell68k(TYPE_VMEMPAGEP); - np2 = (u_char *)createcell68k(TYPE_VMEMPAGEP); - lp = cons(LADDR_from_68k(np2), NIL); - lp = cons(LADDR_from_68k(np), lp); - val = lp; - } break; - - default: error("ocr_comm: Invalid Comm byte"); - } - return (val); -INVAL: - return (NIL); -} - -/* - * Subr OCR_COMM: comm = OCR_OPEN - * - * Fork OCR process and issue 'O' command to open OCR device. - */ - -static int ocr_open() { - int cnt; - u_char pkt[PKTLEN]; - - OCR_sock = ocr_fork(); - if (OCR_sock < 0) { - return 0; - } else { - if (!ocr_block_mode(OCR_sock, FD_BLOCK)) return 0; - pkt[0] = 'O'; - pkt[1] = pkt[2] = 0; - if (write(OCR_sock, pkt, sizeof(pkt)) < 0) { - ocr_close(); - return 0; - } - - SETJMP(0); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 20); - if (cnt == sizeof(pkt) && pkt[0] == 1) { - if (NULL_STATE_WORD) INIT_STATE_WORD; - ocr_set_handler(); - shifted_OCR_sock = 1 << OCR_sock; - return (OCR_sock); - } else { - return 0; - } - } -} - -/* - * Ask the pre-forked small emulator process to fork the OCR process - */ - -static int ocr_fork() { - int sfd, nsfd; - char *addr; - int len, flag; - struct sockaddr_un sock; - u_char pkt[4]; - extern char *build_socket_pathname(); - extern int UnixPipeIn, UnixPipeOut; - - sfd = socket(AF_UNIX, SOCK_STREAM, 0); - if (sfd < 0) { - perror("ocr_fork: socket open"); - return -1; - } - - addr = build_socket_pathname(sfd); - sock.sun_family = AF_UNIX; - strcpy(sock.sun_path, addr); - - unlink(addr); - len = sizeof(sock.sun_family) + strlen(addr); - if (bind(sfd, &sock, len) < 0) { - perror("ocr_fork: bind"); - close(sfd); - return -1; - } - - if (listen(sfd, 1) < 0) { - perror("ocr_fork: listen"); - unlink(addr); - close(sfd); - return -1; - } - - pkt[0] = 'O'; - pkt[3] = sfd; - write(UnixPipeOut, pkt, 4); - - read(UnixPipeIn, pkt, 4); - if (pkt[3] == 1) { - retry: - SETJMP(-1); - S_TOUT_TIME(nsfd = accept(sfd, NULL, NULL), 20); - if (nsfd < 0) { - if (errno == EINTR) { - goto retry; - } else { - perror("ocr_fork: accept"); - unlink(addr); - close(sfd); - return -1; - } - } - close(sfd); - unlink(addr); - OCR_procID = pkt[1] << 8 | pkt[2]; - return (nsfd); - } else { - close(sfd); - unlink(addr); - return -1; - } -} - -/* - * Change blocking mode of a file descriptor. - */ - -static int ocr_block_mode(fd, doblock) int fd; -int doblock; -{ - int flags; - - if (fd < 0) return 0; - - flags = fcntl(fd, F_GETFL, 0); - if (flags < 0) return 0; - - if (doblock) { - flags &= ~O_NONBLOCK; - } else { - flags |= O_NONBLOCK; - } - - if (fcntl(fd, F_SETFL, flags) < 0) return 0; - - return 1; -} - -/* - * Cleanup routines - */ - -static void ocr_device_reset() { - if (OCR_sock >= 0) { - u_char pkt[PKTLEN]; - - pkt[0] = 'A'; - pkt[1] = pkt[2] = 0; - write(OCR_sock, pkt, sizeof(pkt)); - - sleep(1); - } - return; -} - -static int ocr_wait() { - u_char pkt[4]; - int status; - - if (OCR_procID > 0) { - pkt[0] = 'w'; - pkt[1] = OCR_procID >> 8 & 0xFF; - pkt[2] = OCR_procID & 0xFF; - - write(UnixPipeOut, pkt, sizeof(pkt)); - read(UnixPipeIn, pkt, sizeof(pkt)); - - status = pkt[0] << 24 | pkt[1] << 16 | pkt[2] << 8 | pkt[3]; - - if (status != 0 && (WIFSIGNALED(status) || WIFEXITED(status))) { - return 1; - } else { - return 0; - } - } - return 1; -} - -static void ocr_close() { - int status, pid; - - if (OCR_sock >= 0) { - ocr_device_reset(); - (void)shutdown(OCR_sock, 2); - } - - OCR_sock = shifted_OCR_sock = -1; - ocr_clr_handler(); - - if (OCR_procID > 0) { - if (ocr_wait() == 0) { - int i; - kill(OCR_procID, SIGUSR1); - for (i = 0; i < 10; i++) { - if (ocr_wait()) break; - } - } - OCR_procID = -1; - } - return; -} - -/* - * Subr OCR_COMM: comm = OCR_SCAN - * - * Issue 'S' command to start scanning. 'S' command returns immediately - * without waiting device to finish scanning. - */ - -static int ocr_scan(sp) struct ocr_scan_para *sp; -{ - int cnt; - u_char pkt[PKTLEN]; - - pkt[0] = 'S'; - pkt[1] = 0; - pkt[2] = sizeof(struct ocr_scan_para); - - if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { return 0; } - if (write(OCR_sock, (char *)sp, sizeof(struct ocr_scan_para)) != sizeof(struct ocr_scan_para)) { - return 0; - } - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - SET_WAIT_FLG(OCR_ST_SCANNING); - return 1; - } else { - return 0; - } -} - -/* - * Subr OCR_COMM: comm = OCR_IMG_INFO - * - * Issue 'I' command to get an information about the image being uploaded. - * 'I' command returns immediately without waiting OCR process to - * finish its work. - */ - -static int ocr_iminfo(up) struct ocr_up_para *up; -{ - int i, cnt; - u_char pkt[PKTLEN]; - - pkt[0] = 'I'; - pkt[1] = 0; - pkt[2] = sizeof(struct ocr_up_para); - - if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { return 0; } - if (write(OCR_sock, (char *)up, sizeof(struct ocr_up_para)) != sizeof(struct ocr_up_para)) { - return 0; - } - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - SET_WAIT_FLG(OCR_ST_UPLDING); - return 1; - } else { - return 0; - } -} - -/* - * Subr OCR_COMM: comm = OCR_SET_RPARA - * - * Issue 'P' command to set read parameters. - */ - -static int ocr_set_rpara(pp, num) register u_char *pp; -register int num; -{ - register int cnt; - u_char pkt[PKTLEN]; - - pkt[0] = 'P'; - num = num * sizeof(struct ocr_read_para); - pkt[1] = num >> 8 & 0xFF; - pkt[2] = num & 0xFF; - - if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { return 0; } - do { - cnt = write(OCR_sock, (char *)pp, num); - if (cnt < 0) { - return 0; - } else { - num -= cnt; - pp += cnt; - } - } while (num > 0); - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - return 1; - } else { - return 0; - } -} - -/* - * Subr OCR_COMM: comm = OCR_CLR_RPARA - * - * Issue 'C' command to clear all read parameters. - */ - -static int ocr_clr_rpara() { - register int cnt; - u_char pkt[PKTLEN]; - - pkt[0] = 'C'; - pkt[1] = pkt[2] = 0; - - if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { return 0; } - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - return 1; - } else { - return 0; - } -} - -/* - * Subr OCR_COMM: comm = OCR_READ - * - * Issue 'R' command to start reading. - * 'R' command returns immediately without waiting OCR process to - * finish its work. - */ - -static int ocr_read() { - register int cnt; - u_char pkt[PKTLEN]; - - pkt[0] = 'R'; - pkt[1] = pkt[2] = 0; - - if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { return 0; } - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - SET_WAIT_FLG(OCR_ST_READING) - return 1; - } else { - return 0; - } -} - -/* - * SIGUSR1 handler. - * - * If one of time consuming work is finished by OCR process, SIGUSR1 is signalled. - * According to the waiting reason, do appropriate work, then to notify Lisp. - */ - -static void ocr_sig_handler(sig, code, scp) int sig, code; -struct sigcontext *scp; -{ - if (OCR_sock < 0) return; - - switch (WAITING_REASON) { - case OCR_ST_SCANNING: ocr_scan_finish(); break; - - case OCR_ST_UPLDING: ocr_img_upld_finish(); break; - - case OCR_ST_READING: ocr_read_finish(); break; - - default: SET_WAIT_FLG(OCR_ST_FAIL); - } - ocr_irq(); - return; -} - -static void ocr_set_handler() { - struct sigvec sv; - - sv.sv_flags = sv.sv_mask = 0; - sv.sv_handler = ocr_sig_handler; - sigvec(SIGUSR1, &sv, NULL); - return; -} - -static void ocr_clr_handler() { - struct sigvec sv; - extern void panicuraid(); - - sv.sv_flags = sv.sv_mask = 0; - sv.sv_handler = panicuraid; - sigvec(SIGUSR1, &sv, NULL); - return; -} - -/* - * Handle SIGUSR1 interrupt if state is scanning - */ - -static void ocr_scan_finish() { - int cnt; - u_char pkt[PKTLEN]; - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) { - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - break; - } - } - return; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - CLR_WAIT_FLG; - } else { - SET_WAIT_FLG(OCR_ST_FAIL); - } - return; -} - -/* - * Handle SIGUSR1 interrupt if state is image uploading - */ - -static void ocr_img_upld_finish() { - int cnt; - u_char pkt[PKTLEN]; - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) { - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - break; - } - } - return; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - S_TOUT_TIME(cnt = read(OCR_sock, (char *)OCR_iminfo_block, sizeof(struct ocr_image_info)), 5); - if (cnt == sizeof(struct ocr_image_info)) { - CLR_WAIT_FLG; - OCR_image_size = OCR_iminfo_block->size; - } else { - SET_WAIT_FLG(OCR_ST_FAIL); - } - } else { - SET_WAIT_FLG(OCR_ST_FAIL); - } - return; -} - -/* - * Handle SIGUSR1 interrupt if state is reading - */ - -static void ocr_read_finish() { - int cnt; - u_char pkt[PKTLEN]; - - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) { - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - break; - } - } - return; - }); - - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 5); - - if (cnt == sizeof(pkt) && pkt[0] == 1) { - CLR_WAIT_FLG; - } else { - SET_WAIT_FLG(OCR_ST_FAIL); - } - return; -} - -/* - * Set up the interrupt stuff and issue a request. - */ - -static void ocr_irq() { - u_int *flagp; - extern LispPTR *IOINTERRUPTFLAGS_word; - extern LispPTR *IOINTERRUPTSTATE_word; - extern LispPTR *PENDINGINTERRUPT68k; - - if (OCR_sock < 0) return; - - flagp = (u_int *)Addr68k_from_LADDR(*IOINTERRUPTFLAGS_word); - *flagp = shifted_OCR_sock; - - ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->IOInterrupt = 1; - - *PENDINGINTERRUPT68k = ATOM_T; - Irq_Stk_End = Irq_Stk_Check = 0; - - return; -} - -/* - * Bulk data transfer - */ - -static int ocr_bulk_read(fd, buf, tout) int fd, tout; -register char *buf; -{ - register u_int cnt, len = 0; - struct bd_header hd; - - SETJMP(-1); - - while (1) { - S_TOUT_TIME(cnt = read(fd, &hd, sizeof(struct bd_header)), tout); - if (cnt < 0) return -1; - if (hd.len == 0) return ((hd.cont == BD_LAST) ? len : -1); - do { - S_TOUT_TIME(cnt = read(fd, buf, hd.len), tout); - if (cnt < 0) return -1; - hd.len -= cnt; - len += cnt; - buf += cnt; - } while (hd.len > 0); - if (hd.cont == BD_LAST) return len; - } -} - -static LispPTR ocr_get_read_result(fd) int fd; -{ - register u_int cnt, len, buflen; - struct bd_header hd; - u_char *buf, *ptr; - LispPTR val; - - SETJMP(NIL); - - S_TOUT_TIME(cnt = read(fd, &hd, sizeof(struct bd_header)), 1); - val = 0; - ptr = buf = NULL; - buflen = 0; - - while (hd.len > 0) { - if (buflen > 0) { - len = MIN(hd.len, buflen); - do { - S_TOUT_TIME(cnt = read(fd, ptr, len), 10); - if (cnt < 0) return (NIL); - hd.len -= cnt; - len -= cnt; - buflen -= cnt; - ptr += cnt; - } while (len > 0); - if (hd.len > 0) { - continue; - } else if (hd.cont != BD_CONT) { - break; - } else { - S_TOUT_TIME(cnt = read(fd, &hd, sizeof(struct bd_header)), 1); - continue; - } - } else { - ptr = buf = (u_char *)createcell68k(TYPE_VMEMPAGEP); - if (buf == NULL) { - return (NIL); - } else { - val = cons(LADDR_from_68k(buf), val); - buflen = 512; - } - } - } - return (val); -} - -/* - * OCR specific code conversion - */ - -static u_short jis0[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027, 0x0028, - 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, - - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, - 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, - - 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, - 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, - - 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, - 0x0059, 0x005A, 0x005B, 0x00A5, 0x005D, 0x005E, 0x005F, - - 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, - 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, - - 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, - 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2123, 0x2156, 0x2157, 0x2122, 0x00B7, 0x2572, 0x2521, 0x2523, - 0x2525, 0x2527, 0x2529, 0x2563, 0x2565, 0x2567, 0x2544, - - 0x213C, 0x2522, 0x2524, 0x2526, 0x2528, 0x252A, 0x252B, 0x252D, 0x252F, - 0x2531, 0x2533, 0x2535, 0x2537, 0x2539, 0x253B, 0x253D, - - 0x253F, 0x2541, 0x2544, 0x2546, 0x2548, 0x254A, 0x254B, 0x254C, 0x254D, - 0x254E, 0x254F, 0x2552, 0x2555, 0x2558, 0x255B, 0x255E, - - 0x255F, 0x2560, 0x2561, 0x2562, 0x2564, 0x2566, 0x2568, 0x2569, 0x256A, - 0x256B, 0x256C, 0x256D, 0x256F, 0x2573, 0x212B, 0x212C, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis1[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2121, 0x2122, 0x2123, 0x002C, 0x002E, 0x00B7, 0x003A, 0x003B, - 0x003F, 0x0021, 0x212B, 0x212C, 0x00C2, 0x00C1, 0x00C8, - - 0x00C3, 0x2223, 0x00CC, 0x2133, 0x2134, 0x2135, 0x2136, 0x2137, 0x2138, - 0x2139, 0x213A, 0x213B, 0x213C, 0xEF24, 0x213E, 0x002F, - - 0x005C, 0x007E, 0x003D, 0x007C, 0x2144, 0x003A, 0x00A9, 0x0027, 0x00AA, - 0x00BA, 0x0028, 0x0029, 0x214C, 0x214D, 0x005B, 0x005D, - - 0x007B, 0x007D, 0xEF32, 0xEF33, 0x00AB, 0x00BB, 0x2156, 0x2157, 0x2158, - 0x2159, 0x215A, 0x215B, 0x002B, 0x002D, 0x00B1, 0x00B4, - - 0x00B8, 0x003D, 0x2162, 0x003C, 0x003E, 0x2165, 0x2166, 0x2167, 0x2168, - 0x2169, 0x216A, 0x00B0, 0x216C, 0x216D, 0x216E, 0x00A5, - - 0x00A4, 0x00A2, 0x00A3, 0x0025, 0x0023, 0x0026, 0x002A, 0x0040, 0x00A7, - 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis2[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2221, 0x2222, 0x2223, 0x2224, 0x2225, 0x2226, 0x2227, 0x2228, - 0x2229, 0x00AE, 0x00AC, 0x00AD, 0x00AF, 0x222E, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0xEF4A, 0xEF4C, 0xEF59, 0xEF58, 0xEF5B, 0xEF5A, - - 0xEF57, 0xEF56, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0xEFB6, 0xEFB7, 0xEF6A, 0xEF4F, 0xEF4E, 0xEFB5, - - 0xEFB4, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0xEF6C, 0xEF70, 0x2223, 0xEFBA, - - 0xEFB9, 0xEF72, 0x2223, 0xEF42, 0xEF43, 0x2223, 0x2223, 0xEF71, 0xEF6F, - 0xEF75, 0x226A, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0xF128, 0xEF41, 0x2223, 0x2223, 0x2223, 0xEF30, 0xEF31, - 0x00B0, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis3[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, - 0x0039, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, - 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, - - 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, - 0x0059, 0x005A, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, - 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, - - 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, - 0x0079, 0x007A, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis6[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2641, 0x2642, 0x2644, 0x2645, 0x2646, 0x2649, 0x264A, 0x264B, - 0x264C, 0x264D, 0x264E, 0x264F, 0x2650, 0x2651, 0x2652, - - 0x2653, 0x2655, 0x2656, 0x2658, 0x2659, 0x265A, 0x265B, 0x265C, 0x265D, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2661, 0x2662, 0x2664, 0x2665, 0x2666, 0x2669, 0x266A, 0x266B, - 0x266C, 0x266D, 0x266E, 0x266F, 0x2670, 0x2671, 0x2672, - - 0x2673, 0x2675, 0x2676, 0x2678, 0x2679, 0x267A, 0x267B, 0x267C, 0x267D, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis84[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x7521, 0x7522, 0x7523, 0x7524, 0x7525, 0x7526, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis8[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0xEF69, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0xF128, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x7421, 0x7421, 0xEFFC, 0xEFFC, 0x2220, - 0x2220, 0xEFA8, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis9[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0xEFD1, 0xEFD2, 0xEFD3, 0xEFD4, 0xEFD5, - 0xEFD6, 0xEFD7, 0xEFD8, 0xEFD9, 0xEFDA, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0xEFD1, 0xEFD2, 0xEFD3, 0xEFD4, 0xEFD5, 0xEFD6, 0xEFD7, - - 0xEFD8, 0xEFD9, 0xEFDA, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0xEFC2, - - 0xEFC3, 0xEFC4, 0x2223, 0xEFC6, 0xEFC7, 0xEFC8, 0xEFC9, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis10[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x7409, 0x7421, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -static u_short jis14[256] = {0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2122, 0x2123, 0x2124, 0x2125, 0x2223, 0x2223, 0x213C, 0xEF24, - 0x213E, 0x213B, 0x2223, 0x2223, 0x2144, 0x2145, 0x00A9, - - 0x0027, 0x00AA, 0x00BA, 0x0028, 0x0029, 0x214C, 0x214D, 0x005B, 0x005D, - 0x007B, 0x007D, 0xEF32, 0xEF33, 0x00AB, 0x00BB, 0x2156, - - 0x2157, 0x2223, 0x2223, 0x215A, 0x215B, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223 - -}; - -#define SJIS_TO_JIS(hp, lp) \ - { \ - *(hp) -= (*(hp) > 0x9F) ? 0xB1 : 0x71; \ - *(hp) = (*(hp) << 1) + 1; \ - if (*(lp) > 0x9E) { \ - *(lp) -= 0x7E; \ - *(hp) += 1; \ - } else if (*(lp) > 0x7E) { \ - *(lp) -= 0x20; \ - } else { \ - *(lp) -= 0x1F; \ - } \ - } - -static void ocr_code_conv(ptr, len) register u_char *ptr; -register int len; -{ - while (len > 0) { - if (*ptr == 0xFF) { /* ASCII & Hankaku-kana */ - *(u_short *)ptr = jis0[*(ptr + 1)]; - } else { - SJIS_TO_JIS(ptr, ptr + 1); - switch (*ptr) { - case 0X21: /* 1 Ku */ *(u_short *)ptr = jis1[*(ptr + 1)]; break; - case 0X22: /* 2 Ku */ *(u_short *)ptr = jis2[*(ptr + 1)]; break; - case 0X23: /* 3 Ku */ *(u_short *)ptr = jis3[*(ptr + 1)]; break; - case 0X26: /* 6 Ku */ *(u_short *)ptr = jis6[*(ptr + 1)]; break; - case 0X28: /* 8 Ku */ *(u_short *)ptr = jis8[*(ptr + 1)]; break; - case 0X29: /* 9 Ku */ *(u_short *)ptr = jis9[*(ptr + 1)]; break; - case 0X2A: /* 10 Ku */ *(u_short *)ptr = jis10[*(ptr + 1)]; break; - case 0X2E: /* 14 Ku */ *(u_short *)ptr = jis14[*(ptr + 1)]; break; - case 0X74: /* 84 Ku */ *(u_short *)ptr = jis84[*(ptr + 1)]; break; - default: break; - } - } - ptr += 2; - len--; - } -} - -#endif /* OCR */ diff --git a/src/ocrproc.c b/src/ocrproc.c deleted file mode 100644 index 92ae002..0000000 --- a/src/ocrproc.c +++ /dev/null @@ -1,904 +0,0 @@ -/* $Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved - */ - -/************************************************************************/ -/* */ -/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/************************************************************************/ - -#include "version.h" - -#ifdef OCR - -#include -#include -#include -#include -#include -#include -#include "ocr.h" - -/* - * Cache parameter passed from Subr to postpone time consuming work - */ - -static struct ocr_scan_para OCR_scan_para; -static struct ocr_up_para OCR_up_para; - -/* - * Image size cache - */ - -static int OCR_image_size = 0; - -/* - * Number of regions to be read - */ - -static int OCR_read_regions = 0; - -/* - * Socket fd to communicate the primary emulator process - */ - -int OCR_sv = -1; - -/* - * Fd for the OCR device file - */ - -int OCR_fd = -1; - -/* - * Local definitions for clarify code - */ - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -/* - * Local functions - */ - -static int ocr_handle_comm(), ocr_init_sv(); -static int ocr_proc_scan(), ocr_proc_iminfo(), ocr_proc_set_rpara(); -static int ocr_proc_clr_rpara(), ocr_proc_read(), ocr_conv_read_data(); -static void ocr_do_postponed_work(), ocr_proc_img_upload(); -static void ocr_proc_exit(), ocr_init_signal(), notify_ready(); -static void ocr_proc_post_read(); - -/* - * OCR process - * - * Keep waiting 3 byte length command packet from the primary emulator process. - * The first byte of the packet indicates the work requested. The second and - * third byte indicate the extra packet length. The contents of the extra packet - * is command dependent. - * - * After finishing the work, sends back the another 3 byte length packet. The - * first byte of the returned packet indicates how the work has been done. 1 is - * success, and 0 is failure. - * - * If the work requested will take a long time, the packet with state 1 is just - * returned and the actual work will be postponed, After finishing the postponed - * work, another 3 byte length packet which indicates the result of the work - * is sent back to the primary emulator process, and SIGUSR1 is signalled to - * notify the completion of the initial request. - */ - -void ocr_proc(pid_t ppid) -{ - int len, postponed = 0; - u_char pkt[PKTLEN]; - static u_char epkt[EPKTLEN]; /* Maximum size of extra packet */ - - if (!ocr_init_sv()) return; - ocr_init_signal(); - - while (1) { - if (postponed) { - ocr_do_postponed_work(postponed, ppid); - postponed = 0; - } else { - len = read(OCR_sv, pkt, sizeof(pkt)); - if (len == 0) { - /* - * Broken socket will return size 0. - * Assumes the parent dies - */ - ocr_proc_exit(); - } else if (len != sizeof(pkt)) { - pkt[0] = 0; - (void)write(OCR_sv, pkt, sizeof(pkt)); - } else { - if (pkt[1] == 0 && pkt[2] == 0) { - ocr_handle_comm(pkt, NULL, &postponed); - } else { - int elen; - - elen = pkt[1] << 8 | pkt[2]; - len = read(OCR_sv, epkt, elen); - if (len != elen) { - pkt[0] = 0; - (void)write(OCR_sv, pkt, sizeof(pkt)); - } else { - ocr_handle_comm(pkt, epkt, &postponed); - } - } - } - } - } -} - -/* - * Try to resett the device then exit. - */ - -static void ocr_proc_exit() { - if (OCR_fd > 0) { - ioctl(OCR_fd, OCR_ABORT); - close(OCR_fd); - OCR_fd = -1; - } - exit(1); -} - -/* - * Handle the work requested from the primary emulator process - */ - -static int ocr_handle_comm(u_char pkt[], u_char epkt[], int *reasonp) -{ - int len; - - *reasonp = 0; - switch (pkt[0]) { - case 'O': /* Open */ - if (OCR_fd > 0) { - pkt[0] = 0; - } else { - OCR_fd = open(OCRDEV, O_RDWR); - if (OCR_fd < 0) { - perror("ocr_proc : OPEN"); - pkt[0] = 0; - } else { - pkt[0] = 1; - } - } - break; - - case 'S': /* Start scanning */ - { - if ((pkt[1] << 8 | pkt[2]) == sizeof(struct ocr_scan_para)) { - bcopy(epkt, (char *)&OCR_scan_para, sizeof(struct ocr_scan_para)); - *reasonp = OCR_ST_SCANNING; - pkt[0] = 1; - } else { - pkt[0] = 0; - } - } break; - - case 'I': /* Start getting image info */ - { - if ((pkt[1] << 8 | pkt[2]) == sizeof(struct ocr_up_para)) { - bcopy(epkt, (char *)&OCR_up_para, sizeof(struct ocr_up_para)); - *reasonp = OCR_ST_UPLDING; - pkt[0] = 1; - } else { - pkt[0] = 0; - } - } break; - - case 'P': /* Set read params */ - { - int len; - - len = pkt[1] << 8 | pkt[2]; - if (len % sizeof(struct ocr_read_para)) { - pkt[0] = 0; - } else { - len = len / sizeof(struct ocr_read_para); - if (len + OCR_read_regions > OCR_MAX_RD_PARAMS) { - pkt[0] = 0; - } else if (ocr_proc_set_rpara((struct ocr_read_para *)epkt, len)) { - pkt[0] = 1; - } else { - pkt[0] = 0; - } - } - } break; - - case 'C': /* Clear read params */ - { - if (ocr_proc_clr_rpara()) { - pkt[0] = 1; - } else { - pkt[0] = 0; - } - } break; - - case 'R': /* Start reading */ - { - if (OCR_read_regions < 0) { - pkt[0] = 0; - } else { - *reasonp = OCR_ST_READING; - pkt[0] = 1; - } - } break; - - case 'A': - if (OCR_fd > 0) ioctl(OCR_fd, OCR_ABORT); - exit(1); - - default: return 0; - } - if (write(OCR_sv, pkt, PKTLEN) < 0) - return 0; - else - return 1; -} - -/* - * Handle postponed time consuming work. - */ - -static void ocr_do_postponed_work(int reason, pid_t ppid) -{ - u_char pkt[PKTLEN]; - - switch (reason) { - case OCR_ST_SCANNING: - if (ocr_proc_scan(&OCR_scan_para)) { - pkt[0] = 1; - } else { - pkt[0] = 0; - } - write(OCR_sv, pkt, sizeof(pkt)); - notify_ready(ppid); - break; - - case OCR_ST_UPLDING: { - struct ocr_image_info iminfo; - - if (!ocr_proc_iminfo(&OCR_up_para, &iminfo)) { - pkt[0] = 0; - write(OCR_sv, pkt, sizeof(pkt)); - notify_ready(ppid); - } else { - ocr_proc_img_upload(&iminfo, ppid); - } - } break; - - case OCR_ST_READING: - if (ocr_proc_read()) { - ocr_proc_post_read(ppid); - } else { - pkt[0] = 0; - write(OCR_sv, pkt, sizeof(pkt)); - notify_ready(ppid); - } - break; - - default: - pkt[0] = 0; - write(OCR_sv, pkt, sizeof(pkt)); - notify_ready(ppid); - break; - } - return; -} - -/* - * Notify primary emulator process that time consuming work has been done. - */ - -static void notify_ready(pid_t ppid) -{ kill(ppid, SIGUSR1); } - -/* - * Put the socket descriptor into blocking mode, and extend - * the buffer size. - */ - -static int ocr_init_sv() { - int flags; - - if (OCR_sv < 0) return 0; - - flags = fcntl(OCR_sv, F_GETFL, 0); - if (flags < 0) { - perror("ocr_init_sv: fcntl"); - return 0; - } - flags &= ~O_NONBLOCK; - if (fcntl(OCR_sv, F_SETFL, flags) < 0) { - perror("ocr_init_sv: fcntl 2"); - return 0; - } - return 1; -} - -/* - * Make sure the fatal signall initialize the device then exit - */ - -static void ocr_init_signal() { - struct sigvec sv; - - sv.sv_flags = sv.sv_mask = 0; - sv.sv_handler = ocr_proc_exit; - - sigvec(SIGHUP, &sv, NULL); - sigvec(SIGINT, &sv, NULL); - sigvec(SIGQUIT, &sv, NULL); - sigvec(SIGILL, &sv, NULL); - sigvec(SIGTRAP, &sv, NULL); - sigvec(SIGABRT, &sv, NULL); - sigvec(SIGEMT, &sv, NULL); - sigvec(SIGBUS, &sv, NULL); - sigvec(SIGSEGV, &sv, NULL); - sigvec(SIGSYS, &sv, NULL); - sigvec(SIGPIPE, &sv, NULL); - sigvec(SIGTERM, &sv, NULL); - sigvec(SIGLOST, &sv, NULL); - sigvec(SIGUSR1, &sv, NULL); - sigvec(SIGUSR2, &sv, NULL); - return; -} - -/* - * Scan image - */ - -static int ocr_proc_scan(struct ocr_scan_para *spp) -{ - struct scan_params sp; - - switch (spp->size) { - case OCR_SIZE_A4: sp.size = SIZE_A4; break; - case OCR_SIZE_B4: sp.size = SIZE_B4; break; - case OCR_SIZE_A5: sp.size = SIZE_A5; break; - case OCR_SIZE_B5: sp.size = SIZE_B5; break; - case OCR_SIZE_LG: sp.size = SIZE_LG; break; - case OCR_SIZE_LT: sp.size = SIZE_LT; break; - default: return 0; - } - switch (spp->direction) { - case OCR_DIRECT_VT: sp.direction = DIRECT_VT; break; - case OCR_DIRECT_HR: sp.direction = DIRECT_HR; break; - default: return 0; - } - switch (spp->resolution) { - case OCR_RES_200: sp.resolution = RES_200; break; - case OCR_RES_240: sp.resolution = RES_240; break; - case OCR_RES_300: sp.resolution = RES_300; break; - case OCR_RES_400: sp.resolution = RES_400; break; - default: return 0; - } - if (spp->adf) { - sp.scanner = SCANNER_AD; - } else { - sp.scanner = SCANNER_FL; - } - if (spp->binary) { - sp.dencity = DENC_AT; - switch (spp->filter) { - case OCR_FILTER_NR: sp.filter = FILTER_NR; break; - case OCR_FILTER_BP: sp.filter = FILTER_BP; break; - default: return 0; - } - switch (spp->threshold) { - case OCR_THRES_0: sp.threshold = THRES_0; break; - case OCR_THRES_1: sp.threshold = THRES_1; break; - case OCR_THRES_2: sp.threshold = THRES_2; break; - case OCR_THRES_3: sp.threshold = THRES_3; break; - case OCR_THRES_4: sp.threshold = THRES_4; break; - case OCR_THRES_5: sp.threshold = THRES_5; break; - default: return 0; - } - switch (spp->noise) { - case OCR_NOISE_0: sp.noise = NOISE_0; break; - case OCR_NOISE_2: sp.noise = NOISE_2; break; - case OCR_NOISE_3: sp.noise = NOISE_3; break; - case OCR_NOISE_4: sp.noise = NOISE_4; break; - case OCR_NOISE_5: sp.noise = NOISE_5; break; - default: return 0; - } - switch (spp->doc) { - case OCR_DOC_NR: sp.doc = DOC_NR; break; - case OCR_DOC_NW: sp.doc = DOC_NW; break; - default: return 0; - } - switch (spp->smooth) { - case OCR_SMTH_CH: sp.smooth = SMTH_CH; break; - case OCR_SMTH_IM: sp.smooth = SMTH_IM; break; - default: return 0; - } - switch (spp->compo) { - case OCR_COMPO_LD: sp.compo = COMPO_LD; break; - case OCR_COMPO_PN: sp.compo = COMPO_PN; break; - case OCR_COMPO_PH: sp.compo = COMPO_PH; break; - case OCR_COMPO_PL: sp.compo = COMPO_PL; break; - default: return 0; - } - } else { - switch (spp->dencity) { - case OCR_DENC_0: sp.dencity = DENC_0; break; - case OCR_DENC_1: sp.dencity = DENC_1; break; - case OCR_DENC_2: sp.dencity = DENC_2; break; - case OCR_DENC_3: sp.dencity = DENC_3; break; - case OCR_DENC_4: sp.dencity = DENC_4; break; - case OCR_DENC_5: sp.dencity = DENC_5; break; - case OCR_DENC_6: sp.dencity = DENC_6; break; - case OCR_DENC_7: sp.dencity = DENC_7; break; - default: return 0; - } - sp.filter = FILTER_NR; - sp.threshold = THRES_0; - sp.noise = NOISE_0; - sp.doc = DOC_NR; - sp.smooth = SMTH_CH; - sp.compo = COMPO_LD; - } - if (ioctl(OCR_fd, OCR_SCAN, &sp) < 0) { - /* - * We could return detailed info about error - * by examining the state field in sp. - */ - return 0; - } else { - return 1; - } -} - -/* - * Kick start the image uploading and place the information about the - * image being uploaded into the ocr_image_infor structure. - */ - -static int ocr_proc_iminfo(struct ocr_up_para *upp, struct ocr_image_info *infop) -{ - struct img_params upara; - struct ocr_stat st; - - switch (upp->resolution) { - case OCR_RES_200: upara.resolution = RES_200; break; - case OCR_RES_240: upara.resolution = RES_240; break; - case OCR_RES_300: upara.resolution = RES_300; break; - case OCR_RES_400: upara.resolution = RES_400; break; - default: return 0; - } - switch (upp->compress) { - case OCR_COMP_NONE: upara.compress = COMP_NONE; break; - case OCR_COMP_2: upara.compress = COMP_2; break; - case OCR_COMP_4: upara.compress = COMP_4; break; - case OCR_COMP_8: upara.compress = COMP_8; break; - default: return 0; - } - upara.region.xs = upp->xs; - upara.region.ys = upp->ys; - upara.region.xe = upp->xe; - upara.region.ye = upp->ye; - - if (ioctl(OCR_fd, OCR_IMG_UPLOAD, &upara) < 0) return 0; - { - int i; - i = ioctl(OCR_fd, OCR_STAT, &st); - if (i < 0) { - return 0; - } else if (st.state != STATE_UPLDING) { - return 0; - } - } - /* if (!ioctl(OCR_fd, OCR_STAT, &st) || st.state != STATE_UPLDING) return 0; */ - - switch (st.data.image.resolution) { - case RES_200: infop->resolution = OCR_RES_200; break; - case RES_240: infop->resolution = OCR_RES_240; break; - case RES_300: infop->resolution = OCR_RES_300; break; - case RES_400: infop->resolution = OCR_RES_400; break; - default: return 0; - } - switch (st.data.image.compress) { - case COMP_NONE: infop->compress = OCR_COMP_NONE; break; - case COMP_2: infop->compress = OCR_COMP_2; break; - case COMP_4: infop->compress = OCR_COMP_4; break; - case COMP_8: infop->compress = OCR_COMP_8; break; - default: return 0; - } - infop->line_width = (u_int)st.data.image.line_width; - infop->size = (u_int)st.data.image.size; - infop->xs = st.data.image.region.xs; - infop->ys = st.data.image.region.ys; - infop->xe = st.data.image.region.xe; - infop->ye = st.data.image.region.ye; - - OCR_image_size = (int)st.data.image.size; - - return 1; -} - -/* - * Set Read Parameters - */ - -static int ocr_proc_set_rpara(register struct ocr_read_para *rpp, int len) -{ - register int cnt = len; - struct read_params rpara; - - if (OCR_fd < 0) { - return 0; - } else { - for (; cnt > 0; cnt--, rpp++) { - switch (rpp->format) { - case OCR_FMT_H1: rpara.format = FMT_H1; break; - case OCR_FMT_H2: rpara.format = FMT_H2; break; - case OCR_FMT_H3: rpara.format = FMT_H3; break; - case OCR_FMT_H4: rpara.format = FMT_H4; break; - case OCR_FMT_V1: rpara.format = FMT_V1; break; - case OCR_FMT_V2: rpara.format = FMT_V2; break; - case OCR_FMT_V3: rpara.format = FMT_V3; break; - case OCR_FMT_V4: rpara.format = FMT_V4; break; - default: return 0; - } - rpara.cunit = CUNIT_PO; - rpara.csize = CSIZE_DFLT; - rpara.ckind = 0; - rpara.ckind |= (rpp->ck_num) ? CK_NUM : 0; - rpara.ckind |= (rpp->ck_alph) ? CK_ALPH : 0; - rpara.ckind |= (rpp->ck_grk) ? CK_GRK : 0; - rpara.ckind |= (rpp->ck_jvt) ? CK_JVT : 0; - rpara.ckind |= (rpp->ck_jhr) ? CK_JHR : 0; - rpara.ckind |= (rpp->ck_sym) ? CK_SYM : 0; - rpara.ckind |= (rpp->ck_kana) ? CK_KANA : 0; - rpara.ckind |= (rpp->ck_joyou) ? CK_JOYOU : 0; - rpara.ckind |= (rpp->ck_jis1) ? CK_JIS1 : 0; - rpara.ckind |= (rpp->ck_jmisc) ? CK_JMISC : 0; - rpara.ckind |= (rpp->ck_gaiji) ? CK_GAIJI : 0; - switch (rpp->deform) { - case OCR_DFRM_1: rpara.cprop |= DFRM_1; break; - case OCR_DFRM_2: rpara.cprop |= DFRM_2; break; - case OCR_DFRM_3: rpara.cprop |= DFRM_3; break; - case OCR_DFRM_4: rpara.cprop |= DFRM_4; break; - case OCR_DFRM_NR: rpara.cprop |= DFRM_NR; break; - case OCR_DFRM_6: rpara.cprop |= DFRM_6; break; - case OCR_DFRM_7: rpara.cprop |= DFRM_7; break; - case OCR_DFRM_8: rpara.cprop |= DFRM_8; break; - case OCR_DFRM_9: - rpara.cprop |= DFRM_9; - break; - defaul: - return 0; - } - if (OCR_REJ_0 <= rpp->reject && rpp->reject <= OCR_REJ_5) { - rpara.cprop |= rpp->reject; - } else { - return 0; - } - rpara.region.xs = rpp->xs; - rpara.region.ys = rpp->ys; - rpara.region.xe = rpp->xe; - rpara.region.ye = rpp->ye; - - if (ioctl(OCR_fd, OCR_READ_PARA, &rpara) < 0) { return 0; } - } - OCR_read_regions += len; - return 1; - } -} - -/* - * Clear Read Parameters - */ - -static int ocr_proc_clr_rpara() { - if (OCR_fd < 0 || ioctl(OCR_fd, OCR_READ_CLR) < 0) { - return 0; - } else { - return 1; - } -} - -/* - * Read - */ - -static int ocr_proc_read() { - if (OCR_fd < 0 || ioctl(OCR_fd, OCR_READ) < 0) { - return 0; - } else { - return 1; - } -} - -/* - * Upload and transfer image data. Data transfer is done in such way that is - * compatible with ocr_bulk_read in 'ocr.c'. - */ - -static void ocr_proc_img_upload(struct ocr_image_info *iminfop, pid_t ppid) -{ - register int len, resid, firsttime = 1; - int cnt; - char rbuf[65536], pkt[PKTLEN]; - register char *ptr; - struct bd_header hd; - - resid = OCR_image_size; - - while (resid > 0) { - len = MIN(resid, sizeof(rbuf)); - cnt = read(OCR_fd, rbuf, len); - if (cnt < 0) { - pkt[0] = 0; - write(OCR_sv, pkt, sizeof(pkt)); - return; - } - resid -= cnt; - hd.len = (u_int)cnt; - hd.cont = (resid > 0) ? BD_CONT : BD_LAST; - if (firsttime) { - pkt[0] = 1; - write(OCR_sv, pkt, sizeof(pkt)); - write(OCR_sv, (char *)iminfop, sizeof(struct ocr_image_info)); - write(OCR_sv, &hd, sizeof(struct bd_header)); - notify_ready(ppid); - firsttime = 0; - } else { - write(OCR_sv, &hd, sizeof(struct bd_header)); - } - for (ptr = rbuf; cnt > 0; cnt -= len, ptr += len) { len = write(OCR_sv, ptr, cnt); } - } - return; -} - -/* - * Get the read result from the device driver. The format of the data - * is converted to make it easy Lisp to use it. After converting the data, - * transfer data. Data transfer is done in such way that is - * compatible with ocr_bulk_read in 'ocr.c'. - */ - -static void ocr_proc_post_read(pid_t ppid) -{ - static u_char rbuf[65536]; - static u_char fbuf[65536]; - register u_char *ptr; - struct ocr_stat st; - register int cnt, len; - int amt, firsttime = 1; - struct bd_header hd; - - if (OCR_fd < 0) goto fail; - - if (ioctl(OCR_fd, OCR_STAT, &st) < 0 || st.state != STATE_RDING) goto fail; - - while (st.state == STATE_RDING) { - if (sizeof(rbuf) - 2048 > st.data.rd_resid) { - /* - * 2048 is a margin to reformat the data. - */ - amt = len = st.data.rd_resid; - } else { - amt = len = sizeof(rbuf) - 2048; - } - ptr = rbuf; - do { - cnt = read(OCR_fd, ptr, len); - if (cnt < 0) { - goto fail; - } else { - len -= cnt; - ptr += cnt; - } - } while (len > 0); - - if (ioctl(OCR_fd, OCR_STAT, &st) < 0) goto fail; - - len = ocr_conv_read_data(rbuf, fbuf, amt); - if (len < 0) { - goto fail; - } else if (firsttime) { - u_char pkt[PKTLEN]; - - pkt[0] = 1; - write(OCR_sv, pkt, sizeof(pkt)); - notify_ready(ppid); - firsttime = 0; - } - - hd.len = (u_int)len; - hd.cont = (st.state == STATE_RDING) ? BD_CONT : BD_LAST; - - write(OCR_sv, &hd, sizeof(struct bd_header)); - for (ptr = fbuf; len > 0; len -= cnt, ptr += cnt) { cnt = write(OCR_sv, ptr, len); } - } - return; - -fail : { - u_char pkt[PKTLEN]; - pkt[0] = 0; - write(OCR_sv, pkt, sizeof(pkt)); - notify_ready(ppid); - return; -} -} - -/* - * Reformat the read data to make a life of Lisp tremendously easy - */ - -static int ocr_conv_read_data(register u_char *sp, u_char *dp, register int len) -{ - bcopy(sp, dp, len); - return (len); -} - -/**************************************************** - **************************************************** - -#define INC_SP(pos) {\ - if (--len == 0) {\ - statep->jmp = (pos);\ - return(amt);\ - } else {\ - sp++;\ - }\ -} - -#define CONV_CODE_BLOCK { - static int pos, hi, lo; - - pos = 0; - - if (*sp == 0xEB) { - INC_SP(POS16); - pos16: - if (*sp == 0xA0) { - - if (*sp == 0x9F) { - /+ Lower certencity +/ - *dp++ = REJECT; - INC_SP(POS17); - pos17: - pos += 2; - hi = *sp; - INC_SP - - - -static int -ocr_conv_read_data(u_char *sp, u_char *dp, int len, struct parse_state *statep) -{ - /+ - * for now... - +/ - - bcopy(sp, dp, len); - return(len); - - switch (statep->jmp) { - case POS1: goto pos1; - } - - amt = 0; - while (1) { - if (*sp == '0') { - INC_SP(POS1); - pos1: - if (*sp == '0') { - /+ Region start +/ - *dp++ = REG_START_CODE; - /+ Skip region number +/ - INC_SP(POS2); - pos2: - INC_SP(POS3); - pos3: - INC_SP(POS4); - pos4: - if (*sp == 0xFC) { - INC_SP(POS5); - pos5: - if (*sp == 0xFA) { - /+ Blank region +/ - *dp++ = REG_END_CODE; - continue; - } - } - /+ Skip a region header +/ - INC_SP(POS6); - pos6: - INC_SP(POS7); - pos7: - INC_SP(POS8); - pos8: - INC_SP(POS9); - pos9: - INC_SP(POS10); - pos10: - INC_SP(POS11); - pos11: - INC_SP(POS12); - pos12: - while (1) { - if (*sp == 0xFC) { - INC_SP(POS13); - pos13: - if (*sp == 0xFA) { - /+ Region end +/ - *dp++ = REG_END_CODE; - break; - } - } - /+ Skip a line number +/ - INC_SP(POS14); - pos14: - /+ Process a line +/ - while (1) { - if (*sp == 0xFC) { - INC_SP(POS15); - pos15: - if (*sp == 0xFB) { - /+ EOL +/ - break; - } - } - /+ Some code exists +/ - CONV_CODE_BLOCK; - } - if (statep.cr_line) *dp++ = EOL_CODE; - } - } - } - /+ Page end +/ - return(1) - } -} - - - if (*sp == '0' && *(sp + 1) == '0') { - /+ Region start +/ - *dp++ = REG_START_CODE; - /+ Skip region number +/ - sp += 4; - if (*sp == 0xFC && *(sp + 1) == 0xFA) { - /+ Blank region +/ - *dp++ = REG_END_CODE; - continue; - } else { - /+ Skip a region header +/ - sp += 8; - } - while (1) { - if (*sp == 0xFC && *(sp + 1) == 0xFA) { - /+ Region end +/ - *dp++ = REG_END_CODE; - break; - } else { - /+ Skip a line number +/ - sp += 2; - /+ Process one line +/ - while (*sp != 0xFC || *(sp + 1) != 0xFB) { - /+ Some codes exists +/ - CONV_CODE_BLOCK(sp, bp); - } - if (statep.cr_line) *dp++ = EOL_CODE; - } - } - } else { - /+ Page end +/ - } - } -} -********************************************* -*********************************************/ - -#endif /* OCR */ diff --git a/src/subr.c b/src/subr.c index d7695c0..4d93c5e 100644 --- a/src/subr.c +++ b/src/subr.c @@ -517,13 +517,6 @@ void OP_subrcall(int subr_no, int argnum) { #endif /* DOS */ break; -#ifdef OCR - case sb_OCR_COMM: - POP_SUBR_ARGS; - TopOfStack = ocr_comm(args); - break; -#endif /* OCR */ - /* case 0166: POP_SUBR_ARGS; error("called SUBR 0166, not defined!!"); diff --git a/src/unixfork.c b/src/unixfork.c index 329c65d..6e404bc 100644 --- a/src/unixfork.c +++ b/src/unixfork.c @@ -162,8 +162,6 @@ int ForkUnixShell(int slot, char *PtySlave, char *termtype, char *shellarg) K: Kill process E: Exit (kill all subprocesses) C: Close stdin to subprocess - W: call WAIT3 & get one process's close info. - O: Fork OCR process. Byte 1: Process number (0 to NPROCS - 1) Not used for S, F, and E commands [For S&P, pty letter] @@ -193,9 +191,6 @@ of the packet received except: Byte 3 is 1 if an exit status was available. E: Always the same C: Always the same - O: Byte 3 is 1 if successful, 0 if not - Byte 1 and Byte 2 are the process ID of OCR process - */ int fork_Unix() { @@ -403,10 +398,6 @@ int fork_Unix() { { int status; -#ifdef OCR - int slot; -#endif - status = 0; IOBuf[0] = 0; @@ -432,73 +423,6 @@ int fork_Unix() { case 'C': /* Close stdin to subprocess */ break; case 'K': /* Kill subprocess */ break; - -#ifdef OCR - case 'w': /* Wait paticular process to die */ - { - int pid, res, status; - - pid = IOBuf[1] << 8 | IOBuf[2]; - - retry: - res = waitpid(pid, &status, WNOHANG); - if (res == -1 && errno == EINTR) goto retry; - - if (res == pid) { - IOBuf[0] = res >> 24 & 0xFF; - IOBuf[1] = res >> 16 & 0xFF; - IOBuf[2] = res >> 8 & 0xFF; - IOBuf[3] = res & 0xFF; - } else { - IOBuf[0] = IOBuf[1] = IOBuf[2] = IOBuf[3] = 0; - } - } break; - - case 'O': /* Fork OCR process */ - if (slot >= 0) { - pid_t ppid; - ppid = getppid(); - pid = fork(); - if (pid == 0) { - int i; - int status, len; - struct sockaddr_un addr; - char PipeName[40]; - extern int OCR_sv; - - OCR_sv = socket(AF_UNIX, SOCK_STREAM, 0); - if (OCR_sv < 0) { - perror("slave socket"); - exit(0); - } - sprintf(PipeName, "/tmp/LispPipe%d-%d", StartTime, slot); - addr.sun_family = AF_UNIX; - strcpy(addr.sun_path, PipeName); - len = strlen(PipeName) + sizeof(addr.sun_family); - status = connect(OCR_sv, &addr, len); - if (status < 0) { - perror("OCR slave connect"); - OCR_sv = -1; - exit(0); - } - - (void)ocr_proc(ppid); - OCR_sv = -1; - exit(1); - } - - if (pid == -1) { - perror("unixcomm: fork OCR"); - IOBuf[3] = 0; - } else { - IOBuf[1] = (pid >> 8) & 0xFF; - IOBuf[2] = pid & 0xFF; - } - } else - IOBuf[3] = 0; - break; -#endif /* OCR */ - } /* End of switch */ /* Return the status/data packet */