diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..450dbcd --- /dev/null +++ b/.clang-format @@ -0,0 +1,96 @@ +--- +Language: Cpp +BasedOnStyle: Google + +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: true +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +TabWidth: 8 +UseTab: Never +... + diff --git a/src/Cldeetr.c b/src/Cldeetr.c old mode 100755 new mode 100644 index 505bffe..284adb7 --- a/src/Cldeetr.c +++ b/src/Cldeetr.c @@ -1,4 +1,5 @@ -/* $Id: Cldeetr.c,v 1.3 1999/01/03 02:06:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: Cldeetr.c,v 1.3 1999/01/03 02:06:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: Cldeetr.c,v 1.3 1999/01/03 02:06:30 sybalsky Exp $ Copyright (C) Venue"; /* @@ -7,8 +8,6 @@ static char *id = "$Id: Cldeetr.c,v 1.3 1999/01/03 02:06:30 sybalsky Exp $ Copyr * Kick starter for COLOR emulator */ - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -48,140 +47,139 @@ static char *id = "$Id: Cldeetr.c,v 1.3 1999/01/03 02:06:30 sybalsky Exp $ Copyr #include #include -int ether_fd = -1; /* file descriptor for ether socket */ -unsigned char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address */ +int ether_fd = -1; /* file descriptor for ether socket */ +unsigned char ether_host[6] = {0, 0, 0, 0, 0, 0}; /* 48 bit address */ char filetorun[30] = "ldecolor"; -main(argc, argv, envp) int argc; char **argv, **envp; +main(argc, argv, envp) int argc; +char **argv, **envp; { - char Earg[30], Ename[30], **newargv; - int i; - int flags; -/* Kickstart program for the Lisp Development Environment (LDE). - Run this as setuid root to open the LDE ether socket. - Passes all arguments through to LDE plus -E - to communicate open ether socket. + char Earg[30], Ename[30], **newargv; + int i; + int flags; + /* Kickstart program for the Lisp Development Environment (LDE). + Run this as setuid root to open the LDE ether socket. + Passes all arguments through to LDE plus -E + to communicate open ether socket. - looks like this: - ::::::: + looks like this: + ::::::: - where is the number of the open - socket (decimal), and - are hex of the socket's - 48-bit Ethernet address, and is the name of the - Ethernet device as found by SIOCGIFCONF. -*/ + where is the number of the open + socket (decimal), and - are hex of the socket's + 48-bit Ethernet address, and is the name of the + Ethernet device as found by SIOCGIFCONF. + */ -if (!geteuid()){ + if (!geteuid()) { #ifndef OS4 - if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { -#else /* OS4 */ + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { +#else /* OS4 */ - if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { + if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { #endif /* OS4 */ - /* it's open, now query it and find out its name and address */ - /* JRB - must document that LDE uses the first net board as found - by SIOCGIFCONF (see if(4)). Maybe we need an option to specify - which net board (suspect more than one net board on an LDE machine - will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as found + by SIOCGIFCONF (see if(4)). Maybe we need an option to specify + which net board (suspect more than one net board on an LDE machine + will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; #ifdef OS4 - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if(ioctl(ether_fd, I_PUSH, "pf") < 0) { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } + if (ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } #endif /* OS4 */ - if_data.ifc_len = sizeof(ifbuf); - if_data.ifc_req = ifbuf; + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; #ifndef OS4 - if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { - perror("Couldn't GIFCONF socket; Net is off"); -#else /* OS4 */ + if (ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ - bzero(ifbuf, sizeof(ifbuf)); - { - /* we have to get the interface name from another socket, since - /dev/nit doesn't know anything until it gets bound, and we - can't bind it without knowing the interface name... */ - int s; + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("No socket for interface name"); - close(s); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { - perror("Couldn't get interface name from socket"); - close(s); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - (void) close(s); - } - if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { - perror("Couldn't NIOCBIND socket: Net is off"); + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + (void)close(s); + } + if (ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); #endif /* OS4 */ - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - /* now for the address */ - if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { - perror("Couldn't GIFADDR socket: Net is off"); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); - strcpy(Ename, if_data.ifc_req[0].ifr_name); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if (ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + strcpy(Ename, if_data.ifc_req[0].ifr_name); - flags = fcntl(ether_fd, F_GETFL, 0); - flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); - -#ifdef DEBUG - printf("init_ether: **** Ethernet starts ****\n"); +#ifdef DEBUG + printf("init_ether: **** Ethernet starts ****\n"); #endif - } else { -I_Give_Up: - perror("init_ether: can't open NIT socket\n"); - ether_fd = -1; - /* exit(); */ - } - seteuid(getuid()); - } + } else { + I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + /* exit(); */ + } + seteuid(getuid()); + } -/* OK, right here do other stuff like scan args */ -/* finally crank up LDE; first copy the original args */ + /* OK, right here do other stuff like scan args */ + /* finally crank up LDE; first copy the original args */ -newargv = (char **) malloc((argc + 1 + (ether_fd > 0)*2) * sizeof (char **)); -newargv[0] = filetorun; /* or whatever... */ -for(i=1; i 0) * 2) * sizeof(char **)); + newargv[0] = filetorun; /* or whatever... */ + for (i = 1; i < argc; i++) newargv[i] = argv[i]; -/* then if the net is active, spit out the ether info */ -if(ether_fd > 0) { - newargv[i++] = "-E"; - sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, - ether_host[0], ether_host[1], ether_host[2], - ether_host[3], ether_host[4], ether_host[5], Ename); - newargv[i++] = Earg; -} -newargv[i] = 0; - -/* then execve the LDE executable */ -execvp(filetorun, newargv); -perror(filetorun); -exit(1); + /* then if the net is active, spit out the ether info */ + if (ether_fd > 0) { + newargv[i++] = "-E"; + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); + newargv[i++] = Earg; + } + newargv[i] = 0; + + /* then execve the LDE executable */ + execvp(filetorun, newargv); + perror(filetorun); + exit(1); } diff --git a/src/allocmds.c b/src/allocmds.c old mode 100755 new mode 100644 index 42f65c3..19eec46 --- a/src/allocmds.c +++ b/src/allocmds.c @@ -1,9 +1,7 @@ -/* $Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-98 Venue. All Rights Reserved. */ @@ -18,19 +16,17 @@ static char *id = "$Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ Copy #include "version.h" - - /**********************************************************************/ /* - File Name : allocmds.c + File Name : allocmds.c - Allocate Data Type(MDS) + Allocate Data Type(MDS) - Date : August 18, 1987 - Edited by : Takeshi Shimizu + Date : August 18, 1987 + Edited by : Takeshi Shimizu - Including : initmdspage - alloc_mdspage + Including : initmdspage + alloc_mdspage */ /**********************************************************************/ @@ -45,11 +41,6 @@ static char *id = "$Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ Copy #include "sysatms.h" #include "lspglob.h" - - - - - /************************************************************************/ /* */ /* Make_MDSEntry */ @@ -61,41 +52,36 @@ static char *id = "$Id: allocmds.c,v 1.4 1999/05/31 23:35:20 sybalsky Exp $ Copy /* I consider that there is no case the variable named \GCDISABLED is set to T */ /* #define Make_MDSentry(page,pattern) GETWORD((DLword *)MDStypetbl+(page>>1)) = (DLword)pattern */ -static void __inline__ -Make_MDSentry( UNSIGNED page, DLword pattern) -{ - GETWORD((DLword *)MDStypetbl+(page>>1)) = (DLword)pattern; +static void __inline__ Make_MDSentry(UNSIGNED page, DLword pattern) { + GETWORD((DLword *)MDStypetbl + (page >> 1)) = (DLword)pattern; } - - /**********************************************************************/ /* - Func name : initmdspage + Func name : initmdspage - Write the specified MDSTT entry with specified pattern. - returns Top entry for free chain lisp address + Write the specified MDSTT entry with specified pattern. + returns Top entry for free chain lisp address - Date : December 24, 1986 - Edited by : Takeshi Shimizu - Changed : Jun. 5 87 take + Date : December 24, 1986 + Edited by : Takeshi Shimizu + Changed : Jun. 5 87 take */ /**********************************************************************/ -LispPTR -initmdspage(register LispPTR *base, register DLword size, register LispPTR prev) - /* MDS page base */ - /* object cell size you need (WORD) */ - /* keeping top of previous MDS cell */ +LispPTR initmdspage(register LispPTR *base, register DLword size, register LispPTR prev) +/* MDS page base */ +/* object cell size you need (WORD) */ +/* keeping top of previous MDS cell */ { extern DLword *MDStypetbl; - register int remain_size; /* (IREMAINDER WORDSPERPAGE SIZE) */ + register int remain_size; /* (IREMAINDER WORDSPERPAGE SIZE) */ register short num_pages; register int limit; - int used; /* used space in MDS page */ + int used; /* used space in MDS page */ register int i; #ifdef TRACE2 @@ -104,109 +90,85 @@ initmdspage(register LispPTR *base, register DLword size, register LispPTR prev) remain_size = DLWORDSPER_PAGE % size; - if( (remain_size != 0) - && (remain_size < (size >> 1) - && (size < DLWORDSPER_PAGE))) - { - num_pages = MDSINCREMENT / DLWORDSPER_PAGE; /* on 1121 maybe 2 */ - limit = DLWORDSPER_PAGE; - } - else - { - num_pages = 1; - limit = MDSINCREMENT; - } - - for(i=0; i< num_pages; i++) - { - used=0; - while((used += size)<= limit) - { - *base = prev; /* write prev MDS address to the top of MDS page */ - prev =LADDR_from_68k( base ); /* exchanging pointers */ - base = (LispPTR *)((DLword *)base + size); - } /* while end */ - - base = (LispPTR *)((DLword *)base + remain_size ); - - } /* for end */ - + if ((remain_size != 0) && (remain_size < (size >> 1) && (size < DLWORDSPER_PAGE))) { + num_pages = MDSINCREMENT / DLWORDSPER_PAGE; /* on 1121 maybe 2 */ + limit = DLWORDSPER_PAGE; + } else { + num_pages = 1; + limit = MDSINCREMENT; + } + + for (i = 0; i < num_pages; i++) { + used = 0; + while ((used += size) <= limit) { + *base = prev; /* write prev MDS address to the top of MDS page */ + prev = LADDR_from_68k(base); /* exchanging pointers */ + base = (LispPTR *)((DLword *)base + size); + } /* while end */ + + base = (LispPTR *)((DLword *)base + remain_size); + + } /* for end */ + return (prev); } /* initmdspage end */ - - /**********************************************************************/ /* - Func name : alloc_mdspage + Func name : alloc_mdspage - This version works only for KATANA-SUN + This version works only for KATANA-SUN - Date : January 13, 1987 - Edited by : Takeshi Shimizu - Changed : 3-Apr-87 (take) - 20-Aug-87(take) ifdef - 08-Oct-87(take) checkfull - 22-Dec-87(Take) + Date : January 13, 1987 + Edited by : Takeshi Shimizu + Changed : 3-Apr-87 (take) + 20-Aug-87(take) ifdef + 08-Oct-87(take) checkfull + 22-Dec-87(Take) */ /**********************************************************************/ +LispPTR *alloc_mdspage(register short int type) { + extern LispPTR *MDS_free_page_word; /* Free MDS page number */ -LispPTR * -alloc_mdspage(register short int type) -{ - - extern LispPTR *MDS_free_page_word; /* Free MDS page number */ - - extern DLword *Next_MDSpage; /* next vacant(new) MDS page */ + extern DLword *Next_MDSpage; /* next vacant(new) MDS page */ extern LispPTR *Next_MDSpage_word; extern LispPTR *Next_Array_word; LispPTR newpage(LispPTR base); - register LispPTR *ptr; /* points Top 32 bit of the MDS page */ + register LispPTR *ptr; /* points Top 32 bit of the MDS page */ LispPTR next_page; /* Next_Array=(DLword *)Addr68k_from_LADDR(((*Next_Array_word)& 0xffff ) << 8); */ + if (LOLOC(*MDS_free_page_word) != NIL) { + ptr = (LispPTR *)Addr68k_from_LPAGE(LOLOC(*MDS_free_page_word)); - if(LOLOC(*MDS_free_page_word )!=NIL) - { - ptr= (LispPTR *)Addr68k_from_LPAGE(LOLOC(*MDS_free_page_word )); - - if( ((next_page= LOLOC(*ptr))!=0 ) - && (GetTypeNumber((*ptr))!= TYPE_SMALLP)) - error("alloc_mdspage: Bad Free Page Link"); - else { - *MDS_free_page_word = S_POSITIVE | next_page; - } + if (((next_page = LOLOC(*ptr)) != 0) && (GetTypeNumber((*ptr)) != TYPE_SMALLP)) + error("alloc_mdspage: Bad Free Page Link"); + else { + *MDS_free_page_word = S_POSITIVE | next_page; } - else - { - /* I guess Next_MDSpage is redundant */ - checkfor_storagefull(NIL); + } else { + /* I guess Next_MDSpage is redundant */ + checkfor_storagefull(NIL); #ifdef BIGVM - Next_MDSpage= (DLword *)Addr68k_from_LADDR(((*Next_MDSpage_word) ) << 8); + Next_MDSpage = (DLword *)Addr68k_from_LADDR(((*Next_MDSpage_word)) << 8); #else - Next_MDSpage= (DLword *)Addr68k_from_LADDR(((*Next_MDSpage_word)& 0xffff ) << 8); + Next_MDSpage = (DLword *)Addr68k_from_LADDR(((*Next_MDSpage_word) & 0xffff) << 8); #endif - ptr = (LispPTR *)Next_MDSpage; /* Get Pointer to First Page */ - Next_MDSpage -= DLWORDSPER_PAGE * 2; /* decrement MDS count */ + ptr = (LispPTR *)Next_MDSpage; /* Get Pointer to First Page */ + Next_MDSpage -= DLWORDSPER_PAGE * 2; /* decrement MDS count */ #ifdef BIGVM - *Next_MDSpage_word= LPAGE_from_68k(Next_MDSpage); + *Next_MDSpage_word = LPAGE_from_68k(Next_MDSpage); #else - *Next_MDSpage_word=S_POSITIVE| LPAGE_from_68k(Next_MDSpage); + *Next_MDSpage_word = S_POSITIVE | LPAGE_from_68k(Next_MDSpage); #endif - newpage(newpage(LADDR_from_68k(ptr)) + DLWORDSPER_PAGE); - } - - Make_MDSentry(LPAGE_from_68k(ptr),type); + newpage(newpage(LADDR_from_68k(ptr)) + DLWORDSPER_PAGE); + } + + Make_MDSentry(LPAGE_from_68k(ptr), type); return (ptr); } /* alloc_mdspage end */ - - - - - - diff --git a/src/arith2.c b/src/arith2.c old mode 100755 new mode 100644 index d7f35c9..f76a18b --- a/src/arith2.c +++ b/src/arith2.c @@ -1,8 +1,7 @@ -/* $Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ Copyri #include "version.h" - #include #include "lispemul.h" #include "lspglob.h" @@ -27,48 +25,45 @@ static char *id = "$Id: arith2.c,v 1.4 2001/12/24 01:08:58 sybalsky Exp $ Copyri #include "medleyfp.h" #include "arith.h" -DLword *createcell68k(unsigned int type); +DLword *createcell68k(unsigned int type); LispPTR N_OP_flpus2(); LispPTR N_OP_fdifference(LispPTR parg1, LispPTR parg2); LispPTR N_OP_fgreaterp(LispPTR parg1, LispPTR parg2); /************************************************************ N_OP_plus2 - entry PLUS2 OPCODE[0324] - entry IPLUS2 OPCODE[0330] - return(tos + b) + entry PLUS2 OPCODE[0324] + entry IPLUS2 OPCODE[0330] + return(tos + b) ************************************************************/ -LispPTR N_OP_plus2(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; +LispPTR N_OP_plus2(int tosm1, int tos) { + register int arg1, arg2; + register int result; - N_GETNUMBER( tos, arg1, doufn ); - N_GETNUMBER( tosm1, arg2, doufn ); + N_GETNUMBER(tos, arg1, doufn); + N_GETNUMBER(tosm1, arg2, doufn); #ifdef USE_INLINE_ARITH - result = plus32(arg1, arg2); - N_ARITH_SWITCH(result); + result = plus32(arg1, arg2); + N_ARITH_SWITCH(result); -doufn2: plus_err_label(); - ERROR_EXIT(tos); +doufn2: + plus_err_label(); + ERROR_EXIT(tos); #else - result = arg1 + arg2; - if ( ((arg1>=0) == (arg2>=0)) && ((result>=0) != (arg1>=0)) ) - {ERROR_EXIT(tos);} - N_ARITH_SWITCH(result); + result = arg1 + arg2; + if (((arg1 >= 0) == (arg2 >= 0)) && ((result >= 0) != (arg1 >= 0))) { ERROR_EXIT(tos); } + N_ARITH_SWITCH(result); #endif /* USE_INLINE_ARITH */ -doufn: return(N_OP_fplus2(tosm1, tos)); - +doufn: + return (N_OP_fplus2(tosm1, tos)); } - - /************************************************************************/ /* */ /* N _ O P _ i p l u s 2 */ @@ -78,235 +73,207 @@ doufn: return(N_OP_fplus2(tosm1, tos)); /* */ /************************************************************************/ -LispPTR N_OP_iplus2(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; +LispPTR N_OP_iplus2(int tosm1, int tos) { + register int arg1, arg2; + register int result; - N_IGETNUMBER( tos, arg1, doufn ); - N_IGETNUMBER( tosm1, arg2, doufn ); + N_IGETNUMBER(tos, arg1, doufn); + N_IGETNUMBER(tosm1, arg2, doufn); #ifdef USE_INLINE_ARITH - result = iplus32(arg1, arg2); - N_ARITH_SWITCH(result); -dummy: iplus_err_label(); + result = iplus32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: + iplus_err_label(); #else - result = arg1 + arg2; - if ( ((arg1>=0) == (arg2>=0)) && ((result>=0) != (arg1>=0)) ) - {ERROR_EXIT(tos);} - N_ARITH_SWITCH(result); + result = arg1 + arg2; + if (((arg1 >= 0) == (arg2 >= 0)) && ((result >= 0) != (arg1 >= 0))) { ERROR_EXIT(tos); } + N_ARITH_SWITCH(result); #endif /* USE_INLINE_ARITH */ -doufn: ERROR_EXIT(tos); - +doufn: + ERROR_EXIT(tos); } - /************************************************************ N_OP_difference - entry DIFFERENCE OPCODE[0325] - entry IDIFFERENCE OPCODE[0331] - return(a - tos) + entry DIFFERENCE OPCODE[0325] + entry IDIFFERENCE OPCODE[0331] + return(a - tos) ************************************************************/ -LispPTR N_OP_difference(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; +LispPTR N_OP_difference(int tosm1, int tos) { + register int arg1, arg2; + register int result; - N_GETNUMBER( tosm1, arg1, doufn ); - N_GETNUMBER( tos, arg2, doufn ); + N_GETNUMBER(tosm1, arg1, doufn); + N_GETNUMBER(tos, arg2, doufn); #ifdef USE_INLINE_ARITH - result = sub32(arg1, arg2); - N_ARITH_SWITCH(result); + result = sub32(arg1, arg2); + N_ARITH_SWITCH(result); -doufn2: diff_err_label(); - ERROR_EXIT(tos); +doufn2: + diff_err_label(); + ERROR_EXIT(tos); #else - result = arg1 - arg2; - if ( ((arg1>=0) == (arg2<0)) && ((result>=0) != (arg1>=0)) ) - {ERROR_EXIT(tos);} - N_ARITH_SWITCH(result); + result = arg1 - arg2; + if (((arg1 >= 0) == (arg2 < 0)) && ((result >= 0) != (arg1 >= 0))) { ERROR_EXIT(tos); } + N_ARITH_SWITCH(result); #endif -doufn: return(N_OP_fdifference(tosm1, tos)); - +doufn: + return (N_OP_fdifference(tosm1, tos)); } +LispPTR N_OP_idifference(int tosm1, int tos) { + register int arg1, arg2; + register int result; -LispPTR N_OP_idifference(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; - - N_IGETNUMBER( tosm1, arg1, doufn ); - N_IGETNUMBER( tos, arg2, doufn ); + N_IGETNUMBER(tosm1, arg1, doufn); + N_IGETNUMBER(tos, arg2, doufn); #ifdef USE_INLINE_ARITH - result = isub32(arg1, arg2); - N_ARITH_SWITCH(result); -dummy: idiff_err_label(); + result = isub32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: + idiff_err_label(); #else - result = arg1 - arg2; - if ( ((arg1>=0) == (arg2<0)) && ((result>=0) != (arg1>=0)) ) - {ERROR_EXIT(tos);} - N_ARITH_SWITCH(result); + result = arg1 - arg2; + if (((arg1 >= 0) == (arg2 < 0)) && ((result >= 0) != (arg1 >= 0))) { ERROR_EXIT(tos); } + N_ARITH_SWITCH(result); #endif -doufn: ERROR_EXIT(tos); - +doufn: + ERROR_EXIT(tos); } - - /************************************************************ N_OP_logxor - entry LOGXOR2 OPCODE[0346] - return(tosm1 ^ tos) + entry LOGXOR2 OPCODE[0346] + return(tosm1 ^ tos) ************************************************************/ -LispPTR N_OP_logxor(int tosm1, int tos) -{ - N_IARITH_BODY_2(tosm1, tos, ^); -} - - +LispPTR N_OP_logxor(int tosm1, int tos) { N_IARITH_BODY_2(tosm1, tos, ^); } /************************************************************ N_OP_logand - entry LOGAND2 OPCODE[0345] - return(tosm1 & tos) + entry LOGAND2 OPCODE[0345] + return(tosm1 & tos) ************************************************************/ -LispPTR N_OP_logand(int tosm1, int tos) -{ - N_IARITH_BODY_2(tosm1, tos, &); -} - - +LispPTR N_OP_logand(int tosm1, int tos) { N_IARITH_BODY_2(tosm1, tos, &); } /************************************************************ N_OP_logor - entry LOGOR2 OPCODE[0344] - return(tosm1 | tos) + entry LOGOR2 OPCODE[0344] + return(tosm1 | tos) ************************************************************/ -LispPTR N_OP_logor(int tosm1, int tos) -{ - N_IARITH_BODY_2(tosm1, tos, |); -} +LispPTR N_OP_logor(int tosm1, int tos) { N_IARITH_BODY_2(tosm1, tos, |); } /************************************************************ N_OP_greaterp - entry GREATERP OPCODE[0363] - entry IGREATERP OPCODE[0361] - return(tosm1 > tos) + entry GREATERP OPCODE[0363] + entry IGREATERP OPCODE[0361] + return(tosm1 > tos) ************************************************************/ -LispPTR N_OP_greaterp(int tosm1, int tos) -{ -register int arg1,arg2; +LispPTR N_OP_greaterp(int tosm1, int tos) { + register int arg1, arg2; - N_GETNUMBER( tosm1, arg1, do_ufn); - N_GETNUMBER( tos, arg2, do_ufn); + N_GETNUMBER(tosm1, arg1, do_ufn); + N_GETNUMBER(tos, arg2, do_ufn); - if(arg1 > arg2) - return(ATOM_T); - else - return(NIL_PTR); + if (arg1 > arg2) + return (ATOM_T); + else + return (NIL_PTR); -do_ufn: return(N_OP_fgreaterp(tosm1, tos)); +do_ufn: + return (N_OP_fgreaterp(tosm1, tos)); } +LispPTR N_OP_igreaterp(int tosm1, int tos) { + register int arg1, arg2; -LispPTR N_OP_igreaterp(int tosm1, int tos) -{ -register int arg1,arg2; + N_IGETNUMBER(tosm1, arg1, do_ufn); + N_IGETNUMBER(tos, arg2, do_ufn); - N_IGETNUMBER( tosm1, arg1, do_ufn); - N_IGETNUMBER( tos, arg2, do_ufn); + if (arg1 > arg2) + return (ATOM_T); + else + return (NIL_PTR); - if(arg1 > arg2) - return(ATOM_T); - else - return(NIL_PTR); - -do_ufn: ERROR_EXIT(tos); +do_ufn: + ERROR_EXIT(tos); } - - /************************************************************ N_OP_iplusn - entry IPLUS.N OPCODE[0335] - return(tos + n) + entry IPLUS.N OPCODE[0335] + return(tos + n) ************************************************************/ -LispPTR N_OP_iplusn(int tos, int n) -{ +LispPTR N_OP_iplusn(int tos, int n) { + register int arg1; + register int result; -register int arg1; -register int result; - - N_IGETNUMBER( tos, arg1, do_ufn ); + N_IGETNUMBER(tos, arg1, do_ufn); #ifdef USE_INLINE_ARITH - result = iplus32n(arg1, n); - N_ARITH_SWITCH(result); -dummy: iplusn_err_label(); + result = iplus32n(arg1, n); + N_ARITH_SWITCH(result); +dummy: + iplusn_err_label(); #else - result = arg1 + n; - if ((result < 0) && (arg1 >= 0)) {ERROR_EXIT(tos);} - N_ARITH_SWITCH(result); + result = arg1 + n; + if ((result < 0) && (arg1 >= 0)) { ERROR_EXIT(tos); } + N_ARITH_SWITCH(result); #endif -do_ufn: ERROR_EXIT(tos); - +do_ufn: + ERROR_EXIT(tos); } - - /************************************************************ N_OP_idifferencen - entry IDIFFERENCE.N OPCODE[0336] - return(tos - n) + entry IDIFFERENCE.N OPCODE[0336] + return(tos - n) ************************************************************/ -LispPTR N_OP_idifferencen(int tos, int n) -{ -register int arg1; -register int result; +LispPTR N_OP_idifferencen(int tos, int n) { + register int arg1; + register int result; - N_IGETNUMBER( tos, arg1, do_ufn ); + N_IGETNUMBER(tos, arg1, do_ufn); #ifdef USE_INLINE_ARITH - result = sub32n(arg1, n); - N_ARITH_SWITCH(result); -dummy: idiffn_err_label(); + result = sub32n(arg1, n); + N_ARITH_SWITCH(result); +dummy: + idiffn_err_label(); #else - result = arg1 - n; - if ((result >= 0) && (arg1 < 0)) {ERROR_EXIT(tos);} - N_ARITH_SWITCH(result); + result = arg1 - n; + if ((result >= 0) && (arg1 < 0)) { ERROR_EXIT(tos); } + N_ARITH_SWITCH(result); #endif -do_ufn: ERROR_EXIT(tos); - +do_ufn: + ERROR_EXIT(tos); } - - diff --git a/src/arith3.c b/src/arith3.c old mode 100755 new mode 100644 index 2f8d33e..60e82e6 --- a/src/arith3.c +++ b/src/arith3.c @@ -1,10 +1,7 @@ -/* $Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,11 +14,8 @@ static char *id = "$Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyri /* */ /************************************************************************/ - #include "version.h" - - /************************************************************************/ /* */ /* A R I T H 3 . C */ @@ -33,7 +27,6 @@ static char *id = "$Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyri /* */ /************************************************************************/ - #include "lispemul.h" #include "lispmap.h" #include "lspglob.h" @@ -43,9 +36,6 @@ static char *id = "$Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyri #include "cell.h" #include "arith.h" - - - /************************************************************************/ /* */ /* N _ O P _ m a k e n u m b e r */ @@ -55,18 +45,14 @@ static char *id = "$Id: arith3.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyri /* */ /************************************************************************/ -LispPTR N_OP_makenumber(int tosm1, int tos) -{ +LispPTR N_OP_makenumber(int tosm1, int tos) { register int result; - if(((tosm1 & 0xFFFF0000) != S_POSITIVE) || ((tos & 0xFFFF0000) != S_POSITIVE)) - ERROR_EXIT(tos); + if (((tosm1 & 0xFFFF0000) != S_POSITIVE) || ((tos & 0xFFFF0000) != S_POSITIVE)) ERROR_EXIT(tos); result = ((tosm1 & 0xffff) << 16) | (tos & 0xffff); N_ARITH_SWITCH(result); } /* end OP_makenumber */ - - /************************************************************************/ /* */ /* N _ O P _ b o x i p l u s */ @@ -76,22 +62,19 @@ LispPTR N_OP_makenumber(int tosm1, int tos) /* */ /************************************************************************/ -LispPTR N_OP_boxiplus(register int a, int tos) -{ - register int arg2; +LispPTR N_OP_boxiplus(register int a, int tos) { + register int arg2; - if( GetTypeNumber(a) == TYPE_FIXP ) - { - N_GETNUMBER(tos, arg2, bad); - *((LispPTR *)Addr68k_from_LADDR(a)) += arg2; - return(a); - } -bad: ERROR_EXIT(tos); + if (GetTypeNumber(a) == TYPE_FIXP) { + N_GETNUMBER(tos, arg2, bad); + *((LispPTR *)Addr68k_from_LADDR(a)) += arg2; + return (a); + } +bad: + ERROR_EXIT(tos); } /* OP_boxiplus */ - - /************************************************************************/ /* */ /* O P _ b o x i d i f f */ @@ -102,18 +85,15 @@ bad: ERROR_EXIT(tos); /* */ /************************************************************************/ -LispPTR N_OP_boxidiff(register int a, int tos) -{ - register int arg2; +LispPTR N_OP_boxidiff(register int a, int tos) { + register int arg2; - if( GetTypeNumber(a) == TYPE_FIXP ) - { - N_GETNUMBER(tos, arg2, bad); - *((LispPTR *)Addr68k_from_LADDR(a)) -= arg2; - return(a); - } - bad: ERROR_EXIT(tos); + if (GetTypeNumber(a) == TYPE_FIXP) { + N_GETNUMBER(tos, arg2, bad); + *((LispPTR *)Addr68k_from_LADDR(a)) -= arg2; + return (a); + } +bad: + ERROR_EXIT(tos); } /* end OP_boxidiff */ - - diff --git a/src/arith4.c b/src/arith4.c old mode 100755 new mode 100644 index 7dff7c4..efb87b0 --- a/src/arith4.c +++ b/src/arith4.c @@ -1,8 +1,7 @@ -/* $Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -15,20 +14,16 @@ static char *id = "$Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyri /* */ /************************************************************************/ - #include "version.h" - - - /***********************************************************************/ /* - File Name : arith4.c + File Name : arith4.c - Including : OP_times2 326Q(OP_itimes2 332Q) + Including : OP_times2 326Q(OP_itimes2 332Q) - OP_quot 327Q(OP_iquot 333Q) - OP_reminder 334Q + OP_quot 327Q(OP_iquot 333Q) + OP_reminder 334Q */ /**********************************************************************/ @@ -43,168 +38,161 @@ static char *id = "$Id: arith4.c,v 1.3 1999/05/31 23:35:21 sybalsky Exp $ Copyri #include "medleyfp.h" #include "arith.h" - - /**********************************************************************/ /* - Func name : N_OP_times2(itimes2) + Func name : N_OP_times2(itimes2) */ /**********************************************************************/ -int N_OP_times2(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; +int N_OP_times2(int tosm1, int tos) { + register int arg1, arg2; + register int result; - - - N_GETNUMBER( tosm1, arg1, doufn ); - N_GETNUMBER( tos, arg2, doufn ); + N_GETNUMBER(tosm1, arg1, doufn); + N_GETNUMBER(tos, arg2, doufn); #ifdef SUN3_OS3_OR_OS4_IL - result = mpy32(arg1, arg2); - N_ARITH_SWITCH(result); -dummy: mpy_err_label(); + result = mpy32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: + mpy_err_label(); #else - result = arg1 * arg2; - if ((arg2 !=0) &&((result / arg2) != arg1) ) goto doufn2; - N_ARITH_SWITCH(result); + result = arg1 * arg2; + if ((arg2 != 0) && ((result / arg2) != arg1)) goto doufn2; + N_ARITH_SWITCH(result); #endif -doufn2: ERROR_EXIT(tos); -doufn: return(N_OP_ftimes2(tosm1, tos)); - +doufn2: + ERROR_EXIT(tos); +doufn: + return (N_OP_ftimes2(tosm1, tos)); } /* end N_OP_times2 */ -int N_OP_itimes2(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; +int N_OP_itimes2(int tosm1, int tos) { + register int arg1, arg2; + register int result; - - N_IGETNUMBER( tosm1, arg1, doufn ); - N_IGETNUMBER( tos, arg2, doufn ); + N_IGETNUMBER(tosm1, arg1, doufn); + N_IGETNUMBER(tos, arg2, doufn); #ifdef SUN3_OS3_OR_OS4_IL - result = impy32(arg1, arg2); - N_ARITH_SWITCH(result); -dummy: impy_err_label(); + result = impy32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: + impy_err_label(); #else - result = arg1 * arg2; - if ((arg2 !=0) &&( (result / arg2) != arg1) ) {goto doufn;} - N_ARITH_SWITCH(result); + result = arg1 * arg2; + if ((arg2 != 0) && ((result / arg2) != arg1)) { goto doufn; } + N_ARITH_SWITCH(result); #endif -doufn: ERROR_EXIT(tos); - +doufn: + ERROR_EXIT(tos); } /* end N_OP_itimes2 */ +/**********************************************************************/ +/* + Func name : N_OP_quot(iquot) + +*/ +/**********************************************************************/ +int N_OP_quot(int tosm1, int tos) { + register int arg1, arg2; + register int result; + + N_GETNUMBER(tosm1, arg1, doufn); + N_GETNUMBER(tos, arg2, doufn); + if (arg2 == 0) goto doufn2; + +#ifdef SUN3_OS3_OR_OS4_IL + + result = quot32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: + quot_err_label(); + +#else + + result = arg1 / arg2; /* lmm: note: no error case!! */ + N_ARITH_SWITCH(result); +#endif +doufn2: + ERROR_EXIT(tos); +doufn: + return (N_OP_fquotient(tosm1, tos)); + +} /* end N_OP_quot */ + +int N_OP_iquot(int tosm1, int tos) { + register int arg1, arg2; + register int result; + + N_IGETNUMBER(tosm1, arg1, doufn); + N_IGETNUMBER(tos, arg2, doufn); + if (arg2 == 0) goto doufn; + +#ifdef SUN3_OS3_OR_OS4_IL + + result = iquot32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: + iquot_err_label(); + +#else + + result = arg1 / arg2; + N_ARITH_SWITCH(result); + +#endif + +doufn: + ERROR_EXIT(tos); + +} /* end N_OP_quot */ /**********************************************************************/ /* - Func name : N_OP_quot(iquot) - -*/ -/**********************************************************************/ -int N_OP_quot(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; - - - N_GETNUMBER( tosm1, arg1, doufn ); - N_GETNUMBER( tos, arg2, doufn ); - if (arg2 == 0) goto doufn2; - -#ifdef SUN3_OS3_OR_OS4_IL - - result = quot32(arg1, arg2); - N_ARITH_SWITCH(result); -dummy: quot_err_label(); - -#else - - result = arg1/arg2; /* lmm: note: no error case!! */ - N_ARITH_SWITCH(result); -#endif -doufn2: ERROR_EXIT(tos); -doufn: return(N_OP_fquotient(tosm1, tos)); - -} /* end N_OP_quot */ - -int N_OP_iquot(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; - - - N_IGETNUMBER( tosm1, arg1, doufn ); - N_IGETNUMBER( tos, arg2, doufn ); - if (arg2 == 0) goto doufn; - -#ifdef SUN3_OS3_OR_OS4_IL - - result = iquot32(arg1, arg2); - N_ARITH_SWITCH(result); -dummy: iquot_err_label(); - -#else - - result = arg1/arg2; - N_ARITH_SWITCH(result); - -#endif - -doufn: ERROR_EXIT(tos); - -} /* end N_OP_quot */ - - -/**********************************************************************/ -/* - - Func name : N_OP_iremainder + Func name : N_OP_iremainder */ /**********************************************************************/ -int N_OP_iremainder(int tosm1, int tos) -{ -register int arg1,arg2; -register int result; +int N_OP_iremainder(int tosm1, int tos) { + register int arg1, arg2; + register int result; - - N_IGETNUMBER( tosm1, arg1, doufn ); - N_IGETNUMBER( tos, arg2, doufn ); - if (arg2 == 0) goto doufn; + N_IGETNUMBER(tosm1, arg1, doufn); + N_IGETNUMBER(tos, arg2, doufn); + if (arg2 == 0) goto doufn; #ifdef SUN3_OS3_OR_OS4_IL - result = irem32(arg1, arg2); - N_ARITH_SWITCH(result); -dummy: irem_err_label(); + result = irem32(arg1, arg2); + N_ARITH_SWITCH(result); +dummy: + irem_err_label(); #else - result = arg1 % arg2; - N_ARITH_SWITCH(result); + result = arg1 % arg2; + N_ARITH_SWITCH(result); #endif -doufn: ERROR_EXIT(tos); +doufn: + ERROR_EXIT(tos); } /* end N_OP_iremainder */ - diff --git a/src/array.c b/src/array.c old mode 100755 new mode 100644 index 6e534b9..223e095 --- a/src/array.c +++ b/src/array.c @@ -1,10 +1,6 @@ /* @(#) array.c Version 2.8 (12/23/88). copyright envos & Fuji Xerox */ static char *id = "@(#) array.c 2.8 12/23/88 (envos & Fuji Xerox)"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,7 +15,6 @@ static char *id = "@(#) array.c 2.8 12/23/88 (envos & Fuji Xerox)"; #include "version.h" - #include #include "lispemul.h" #include "lspglob.h" @@ -49,27 +44,26 @@ type size typenumber ***********************************************************/ /*** N_OP_misc3 -- op 372/9 (base typenumber index) ***/ -LispPTR N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha) -{ - register int result; - register int index, type; - register DLword *wordp; +LispPTR N_OP_misc3(LispPTR baseL, LispPTR typenumber, LispPTR inx, int alpha) { + register int result; + register int index, type; + register DLword *wordp; - /* for CREATECELL */ - DLword *createcell68k(unsigned int type); + /* for CREATECELL */ + DLword *createcell68k(unsigned int type); - if (alpha != 9) ERROR_EXIT(inx); - /* test and setup index */ - N_GetPos(inx, index, inx); + if (alpha != 9) ERROR_EXIT(inx); + /* test and setup index */ + N_GetPos(inx, index, inx); - /* test and setup typenumber */ - N_GetPos(typenumber, type, inx); + /* test and setup typenumber */ + N_GetPos(typenumber, type, inx); - /* disp on type */ +/* disp on type */ #ifdef OS4 - aref_switch(type, inx, baseL, index); + aref_switch(type, inx, baseL, index); #else - return ( aref_switch(type, inx, baseL, index) ); + return (aref_switch(type, inx, baseL, index)); #endif - } /* end N_OP_misc3() */ +} /* end N_OP_misc3() */ diff --git a/src/array2.c b/src/array2.c old mode 100755 new mode 100644 index 0ece787..c74d7ad --- a/src/array2.c +++ b/src/array2.c @@ -1,9 +1,6 @@ /* This is G-file @(#) array2.c Version 2.9 (10/12/88). copyright Xerox & Fuji Xerox */ static char *id = "@(#) array2.c 2.9 10/12/88"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,8 +15,6 @@ static char *id = "@(#) array2.c 2.9 10/12/88"; #include "version.h" - - /************************************************************************/ /* */ /* A R R A Y 2 . C */ @@ -39,8 +34,6 @@ static char *id = "@(#) array2.c 2.9 10/12/88"; #include "arith.h" #include "my.h" - - /************************************************************************/ /* */ /* N _ O P _ m i s c 4 */ @@ -49,23 +42,23 @@ static char *id = "@(#) array2.c 2.9 10/12/88"; /* */ /************************************************************************/ -LispPTR N_OP_misc4(register LispPTR data, register LispPTR base, register LispPTR typenumber, register LispPTR inx, int alpha) -{ - register int new; - register int index; - int type; +LispPTR N_OP_misc4(register LispPTR data, register LispPTR base, register LispPTR typenumber, + register LispPTR inx, int alpha) { + register int new; + register int index; + int type; - if (alpha != 7) ERROR_EXIT(inx); + if (alpha != 7) ERROR_EXIT(inx); - /* test and setup index */ - N_GetPos(inx, index, inx); - - /* test and setup typenumber */ - N_GetPos(typenumber, type, inx); + /* test and setup index */ + N_GetPos(inx, index, inx); - aset_switch(type, inx); + /* test and setup typenumber */ + N_GetPos(typenumber, type, inx); -doufn: ERROR_EXIT(inx); + aset_switch(type, inx); - } /* end N_OP_misc4() */ +doufn: + ERROR_EXIT(inx); +} /* end N_OP_misc4() */ diff --git a/src/array3.c b/src/array3.c old mode 100755 new mode 100644 index 2643dce..f3a76ed --- a/src/array3.c +++ b/src/array3.c @@ -1,9 +1,6 @@ /* This is G-file @(#) array3.c Version 2.9 (10/12/88). copyright Xerox & Fuji Xerox */ static char *id = "@(#) array3.c 2.9 10/12/88"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,8 +15,6 @@ static char *id = "@(#) array3.c 2.9 10/12/88"; #include "version.h" - - /************************************************************************/ /* */ /* A R R A Y 3 . C */ @@ -39,41 +34,37 @@ static char *id = "@(#) array3.c 2.9 10/12/88"; #include "my.h" /*** N_OP_aref1 -- op 266 (array index) ***/ -LispPTR N_OP_aref1(register LispPTR arrayarg, register LispPTR inx) -{ +LispPTR N_OP_aref1(register LispPTR arrayarg, register LispPTR inx) { + register LispPTR baseL; + register int type, index; + register OneDArray *arrayblk; + LispPTR temp; + register int result; - register LispPTR baseL; - register int type, index; - register OneDArray *arrayblk; - LispPTR temp; - register int result; - - /* for CREATECELL */ - register DLword *wordp; - DLword *createcell68k(unsigned int type); + /* for CREATECELL */ + register DLword *wordp; + DLword *createcell68k(unsigned int type); /* verify array */ - if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) ERROR_EXIT(inx); - arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); + if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) ERROR_EXIT(inx); + arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); /* test and setup index */ - N_GetPos(inx, index, inx); - if (index >= arrayblk->totalsize) ERROR_EXIT(inx); - index += arrayblk->offset; + N_GetPos(inx, index, inx); + if (index >= arrayblk->totalsize) ERROR_EXIT(inx); + index += arrayblk->offset; /* setup typenumber */ - type = 0xFF & arrayblk->typenumber; + type = 0xFF & arrayblk->typenumber; /* setup base */ - baseL = arrayblk->base; + baseL = arrayblk->base; - /* disp on type */ +/* disp on type */ #ifdef OS4 - aref_switch(type, inx, baseL, index); + aref_switch(type, inx, baseL, index); #else - return ( aref_switch(type, inx, baseL, index) ); + return (aref_switch(type, inx, baseL, index)); #endif } /* end N_OP_aref1() */ - - diff --git a/src/array4.c b/src/array4.c old mode 100755 new mode 100644 index fc641f2..53c4ca9 --- a/src/array4.c +++ b/src/array4.c @@ -1,10 +1,6 @@ /* This is G-file @(#) array4.c Version 2.7 (10/12/88). copyright Xerox & Fuji Xerox */ static char *id = "@(#) array4.c 2.7 10/12/88"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,9 +15,6 @@ static char *id = "@(#) array4.c 2.7 10/12/88"; #include "version.h" - - - /************************************************************************/ /* */ /* A R R A Y 4 . C */ @@ -42,7 +35,6 @@ static char *id = "@(#) array4.c 2.7 10/12/88"; /*** N_OP_aset1 -- op 267 (new-value array index) ***/ - /************************************************************************/ /* */ /* N _ O P _ a s e t 1 */ @@ -51,34 +43,32 @@ static char *id = "@(#) array4.c 2.7 10/12/88"; /* */ /************************************************************************/ -LispPTR N_OP_aset1(register LispPTR data, LispPTR arrayarg, register int inx) -{ - register int type; - register OneDArray *arrayblk; - register LispPTR base; - register int new; - register int index; +LispPTR N_OP_aset1(register LispPTR data, LispPTR arrayarg, register int inx) { + register int type; + register OneDArray *arrayblk; + register LispPTR base; + register int new; + register int index; - /* verify array */ - if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) ERROR_EXIT(inx); - arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); + /* verify array */ + if (GetTypeNumber(arrayarg) != TYPE_ONED_ARRAY) ERROR_EXIT(inx); + arrayblk = (OneDArray *)Addr68k_from_LADDR(arrayarg); - /* test and setup index */ - N_GetPos(inx, index, inx); - if (index >= arrayblk->totalsize) ERROR_EXIT(inx); - index += arrayblk->offset; + /* test and setup index */ + N_GetPos(inx, index, inx); + if (index >= arrayblk->totalsize) ERROR_EXIT(inx); + index += arrayblk->offset; - /* setup typenumber */ - type = 0xFF & arrayblk->typenumber; + /* setup typenumber */ + type = 0xFF & arrayblk->typenumber; - /* setup base */ - base = arrayblk->base; + /* setup base */ + base = arrayblk->base; + /* disp on type */ + aset_switch(type, inx); - /* disp on type */ - aset_switch(type, inx); - -doufn: ERROR_EXIT(inx); - - } /* end N_OP_aset1() */ +doufn: + ERROR_EXIT(inx); +} /* end N_OP_aset1() */ diff --git a/src/array5.c b/src/array5.c old mode 100755 new mode 100644 index b6f3c7d..a726153 --- a/src/array5.c +++ b/src/array5.c @@ -1,10 +1,6 @@ /* This is G-file @(#) array5.c Version 2.7 (10/12/88). copyright Xerox & Fuji Xerox */ static char *id = "@(#) array5.c 2.7 10/12/88"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,9 +15,6 @@ static char *id = "@(#) array5.c 2.7 10/12/88"; #include "version.h" - - - /************************************************************************/ /* */ /* A R R A Y 5 . C */ @@ -40,8 +33,6 @@ static char *id = "@(#) array5.c 2.7 10/12/88"; #include "arith.h" #include "my.h" - - /************************************************************************/ /* */ /* N _ O P _ a r e f 2 */ @@ -50,40 +41,37 @@ static char *id = "@(#) array5.c 2.7 10/12/88"; /* */ /************************************************************************/ -LispPTR N_OP_aref2(LispPTR arrayarg, LispPTR inx0, LispPTR inx1) -{ +LispPTR N_OP_aref2(LispPTR arrayarg, LispPTR inx0, LispPTR inx1) { #define REG - LispPTR baseL; - int type; - int arindex, temp; - LispArray *arrayblk; - int j; - /* for CREATECELL */ - DLword *createcell68k(unsigned int type); + LispPTR baseL; + int type; + int arindex, temp; + LispArray *arrayblk; + int j; + /* for CREATECELL */ + DLword *createcell68k(unsigned int type); - /* verify array */ - if (GetTypeNumber(arrayarg) != TYPE_TWOD_ARRAY) ERROR_EXIT(inx1); - arrayblk = (LispArray *)Addr68k_from_LADDR(arrayarg); - baseL = arrayblk->base; + /* verify array */ + if (GetTypeNumber(arrayarg) != TYPE_TWOD_ARRAY) ERROR_EXIT(inx1); + arrayblk = (LispArray *)Addr68k_from_LADDR(arrayarg); + baseL = arrayblk->base; - /* test and setup index */ - N_GetPos(inx1, temp, inx1); - if (temp >= (j = arrayblk->Dim1)) ERROR_EXIT(inx1); - N_GetPos(inx0, arindex, inx1); - if (arindex >= arrayblk->Dim0) ERROR_EXIT(inx1); - arindex *= j; - arindex += temp; + /* test and setup index */ + N_GetPos(inx1, temp, inx1); + if (temp >= (j = arrayblk->Dim1)) ERROR_EXIT(inx1); + N_GetPos(inx0, arindex, inx1); + if (arindex >= arrayblk->Dim0) ERROR_EXIT(inx1); + arindex *= j; + arindex += temp; - /* setup typenumber */ - type = 0xFF & arrayblk->typenumber; + /* setup typenumber */ + type = 0xFF & arrayblk->typenumber; - /* disp on type */ +/* disp on type */ #ifdef OS4 - aref_switch(type, inx1, baseL, arindex); + aref_switch(type, inx1, baseL, arindex); #else - return ( aref_switch(type, inx1, baseL, arindex) ); + return (aref_switch(type, inx1, baseL, arindex)); #endif } /* end N_OP_aref2() */ - - diff --git a/src/array6.c b/src/array6.c old mode 100755 new mode 100644 index 3d488a6..8606326 --- a/src/array6.c +++ b/src/array6.c @@ -1,9 +1,6 @@ /* This is G-file @(#) array6.c Version 2.10 (4/21/92). copyright Xerox & Fuji Xerox */ static char *id = "@(#) array6.c 2.10 4/21/92"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,9 +15,6 @@ static char *id = "@(#) array6.c 2.10 4/21/92"; #include "version.h" - - - #include #include "lispemul.h" #include "lspglob.h" @@ -33,36 +27,34 @@ static char *id = "@(#) array6.c 2.10 4/21/92"; #include "my.h" /*** N_OP_aset2 -- op 357 (new-value array index0 index1) ***/ -LispPTR N_OP_aset2(register LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1) -{ +LispPTR N_OP_aset2(register LispPTR data, LispPTR arrayarg, LispPTR inx0, LispPTR inx1) { + register int type; + register LispArray *arrayblk; + register LispPTR base; + register int new; + register int index, temp; + int j; -register int type; -register LispArray *arrayblk; -register LispPTR base; -register int new; -register int index, temp; -int j; + /* verify array */ + if (GetTypeNumber(arrayarg) != TYPE_TWOD_ARRAY) ERROR_EXIT(inx1); + arrayblk = (LispArray *)Addr68k_from_LADDR(arrayarg); + base = arrayblk->base; - /* verify array */ - if (GetTypeNumber(arrayarg) != TYPE_TWOD_ARRAY) ERROR_EXIT(inx1); - arrayblk = (LispArray *)Addr68k_from_LADDR(arrayarg); - base = arrayblk->base; + /* test and setup index */ + N_GetPos(inx1, temp, inx1); + if (temp >= (j = arrayblk->Dim1)) ERROR_EXIT(inx1); + N_GetPos(inx0, index, inx1); + if (index >= arrayblk->Dim0) ERROR_EXIT(inx1); + index *= j; + index += temp; - /* test and setup index */ - N_GetPos(inx1, temp, inx1); - if (temp >= (j = arrayblk->Dim1)) ERROR_EXIT(inx1); - N_GetPos(inx0, index, inx1); - if (index >= arrayblk->Dim0) ERROR_EXIT(inx1); - index *= j; - index += temp; + /* setup typenumber */ + type = 0xFF & arrayblk->typenumber; - /* setup typenumber */ - type = 0xFF & arrayblk->typenumber; + /* disp on type */ + aset_switch(type, inx1); - /* disp on type */ - aset_switch(type, inx1); - -doufn: ERROR_EXIT(inx1); +doufn: + ERROR_EXIT(inx1); } /* end N_OP_aset2() */ - diff --git a/src/asmbbt.c b/src/asmbbt.c old mode 100755 new mode 100644 index 837e612..6abedef --- a/src/asmbbt.c +++ b/src/asmbbt.c @@ -1,4 +1,5 @@ -/* $Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ @@ -13,10 +14,6 @@ static char *id = "$Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyri /* */ /************************************************************************/ - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -31,9 +28,6 @@ static char *id = "$Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyri #include "version.h" - - - #include "lispemul.h" #include "lspglob.h" #include "lispmap.h" @@ -46,14 +40,11 @@ static char *id = "$Id: asmbbt.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyri #include "cell.h" #include "gc.h" - #include "bb.h" #include "bitblt.h" #include "pilotbbt.h" - -void bitblt(DLword *srcbase, DLword dstbase, int sx, int dx, int w, int h, int srcbpl, int dstbpl, int backwardflg, int src_comp, int op, int gray, int num_gray, int curr_gray_line) -{ - new_bitblt_code; - } - +void bitblt(DLword *srcbase, DLword dstbase, int sx, int dx, int w, int h, int srcbpl, int dstbpl, + int backwardflg, int src_comp, int op, int gray, int num_gray, int curr_gray_line) { + new_bitblt_code; +} diff --git a/src/asmbitblt.c b/src/asmbitblt.c old mode 100755 new mode 100644 index b39f46c..a4a0cc4 --- a/src/asmbitblt.c +++ b/src/asmbitblt.c @@ -1,4 +1,5 @@ -/* $Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ @@ -13,10 +14,6 @@ static char *id = "$Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ Cop /* */ /************************************************************************/ - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -31,9 +28,6 @@ static char *id = "$Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ Cop #include "version.h" - - - #include "lispemul.h" #include "lispglobal.h" #include "lispmap.h" @@ -46,21 +40,15 @@ static char *id = "$Id: asmbitblt.c,v 1.3 2001/12/24 01:08:58 sybalsky Exp $ Cop #include "cell.h" #include "gc.h" - #include "bb.h" #include "bitblt.h" #include "pilotbbt.h" +void bitblt(DLword *srcbase, DLword *dstbase, int sx, int dx, int w, int h, int srcbpl, int dstbpl, + int backwardflg, int src_comp, int op, int gray, int num_gray, int curr_gray_line) -void -bitblt(DLword *srcbase, DLword *dstbase, int sx, int dx, int w, int h, - int srcbpl, int dstbpl, int backwardflg, int src_comp, - int op, int gray, int num_gray, int curr_gray_line) - - DLword * srcbase, dstbase; - int sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, op, gray, num_gray, curr_gray_line; - - { - new_bitblt_code; - } + DLword *srcbase, + dstbase; +int sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, op, gray, num_gray, curr_gray_line; +{ new_bitblt_code; } diff --git a/src/atom.c b/src/atom.c old mode 100755 new mode 100644 index 5702729..32672aa --- a/src/atom.c +++ b/src/atom.c @@ -1,10 +1,6 @@ /* $Id: atom.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: atom.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,19 +15,16 @@ static char *id = "$Id: atom.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyrigh #include "version.h" - - - /**********************************************************************/ /* - File Name : atom.c + File Name : atom.c - Desc : implement opcode ATOMCELL.N + Desc : implement opcode ATOMCELL.N - Date : Apr 13, 1987 - Edited by : Naoyuki Mitani + Date : Apr 13, 1987 + Edited by : Naoyuki Mitani - Including : OP_atomcellN + Including : OP_atomcellN */ /**********************************************************************/ @@ -40,52 +33,43 @@ static char *id = "$Id: atom.c,v 1.3 1999/05/31 23:35:23 sybalsky Exp $ Copyrigh #include "lispmap.h" #include "emlglob.h" - #ifndef BIGATOMS -N_OP_atomcellN(tos, n) - register int tos; - int n; - { +N_OP_atomcellN(tos, n) register int tos; +int n; +{ + if ((tos & 0xffff0000) != 0) ERROR_EXIT(tos); - if ((tos & 0xffff0000) != 0) ERROR_EXIT(tos); + tos = (tos << 1); - tos = (tos << 1); - - switch(n) - { - case D_DEFSHI : return(DEFS_OFFSET + tos); - case D_VALSHI : return(VALS_OFFSET + tos); - case D_PLISHI : return(PLIS_OFFSET + tos); - case D_PNHI : return(PNP_OFFSET + tos); - default : ERROR_EXIT(tos); - } + switch (n) { + case D_DEFSHI: return (DEFS_OFFSET + tos); + case D_VALSHI: return (VALS_OFFSET + tos); + case D_PLISHI: return (PLIS_OFFSET + tos); + case D_PNHI: return (PNP_OFFSET + tos); + default: ERROR_EXIT(tos); + } } #else -N_OP_atomcellN(register int tos, int n) -{ +N_OP_atomcellN(register int tos, int n) { + if ((tos & 0xffff0000) == 0) { /* XeroxLisp traditional symbol */ + tos = (tos << 1); + switch (n) { + case D_DEFSHI: return (DEFS_OFFSET + tos); + case D_VALSHI: return (VALS_OFFSET + tos); + case D_PLISHI: return (PLIS_OFFSET + tos); + case D_PNHI: return (PNP_OFFSET + tos); + default: ERROR_EXIT(tos); + } + } else { /* New Symbol */ + switch (n) { + case D_DEFSHI: return (NEWATOM_DEFN_OFFSET + tos); + case D_VALSHI: return (NEWATOM_VALUE_OFFSET + tos); + case D_PLISHI: return (NEWATOM_PLIST_OFFSET + tos); + case D_PNHI: return (NEWATOM_PNAME_OFFSET + tos); + default: ERROR_EXIT(tos); + } + } +} - if ((tos & 0xffff0000) == 0){ /* XeroxLisp traditional symbol */ - tos = (tos << 1); - switch(n) - { - case D_DEFSHI : return(DEFS_OFFSET + tos); - case D_VALSHI : return(VALS_OFFSET + tos); - case D_PLISHI : return(PLIS_OFFSET + tos); - case D_PNHI : return(PNP_OFFSET + tos); - default : ERROR_EXIT(tos); - } - } - else{ /* New Symbol */ - switch(n) - { - case D_DEFSHI : return(NEWATOM_DEFN_OFFSET + tos); - case D_VALSHI : return(NEWATOM_VALUE_OFFSET + tos); - case D_PLISHI : return(NEWATOM_PLIST_OFFSET + tos); - case D_PNHI : return(NEWATOM_PNAME_OFFSET + tos); - default : ERROR_EXIT(tos); - } - } - } - #endif diff --git a/src/bbtsub.c b/src/bbtsub.c index 15565b4..fac5be6 100644 --- a/src/bbtsub.c +++ b/src/bbtsub.c @@ -151,28 +151,28 @@ extern int ScreenLocked; /* for mouse tracking */ (EQ Operation (QUOTE ERASE))) 0) (T 1)))))) *****************************************************************/ -#define PixOperationLisp(SRCTYPE, OPERATION) \ - (SRCTYPE == INVERT_atom \ - ? (OPERATION == REPLACE_atom \ - ? PIX_NOT(PIX_SRC) \ - : (OPERATION == PAINT_atom \ - ? PIX_NOT(PIX_SRC) | PIX_DST \ - : (OPERATION == ERASE_atom \ - ? PIX_SRC & PIX_DST \ - : (OPERATION == INVERT_atom ? PIX_NOT(PIX_SRC) ^ PIX_DST : ERROR)))) \ - : /* SRCTYPE == INPUT, TEXTURE */ \ - (OPERATION == REPLACE_atom \ - ? PIX_SRC \ - : (OPERATION == PAINT_atom \ - ? PIX_SRC | PIX_DST \ - : (OPERATION == ERASE_atom \ - ? PIX_NOT(PIX_SRC) & PIX_DST \ +#define PixOperationLisp(SRCTYPE, OPERATION) \ + (SRCTYPE == INVERT_atom \ + ? (OPERATION == REPLACE_atom \ + ? PIX_NOT(PIX_SRC) \ + : (OPERATION == PAINT_atom \ + ? PIX_NOT(PIX_SRC) | PIX_DST \ + : (OPERATION == ERASE_atom \ + ? PIX_SRC & PIX_DST \ + : (OPERATION == INVERT_atom ? PIX_NOT(PIX_SRC) ^ PIX_DST : ERROR)))) \ + : /* SRCTYPE == INPUT, TEXTURE */ \ + (OPERATION == REPLACE_atom \ + ? PIX_SRC \ + : (OPERATION == PAINT_atom \ + ? PIX_SRC | PIX_DST \ + : (OPERATION == ERASE_atom \ + ? PIX_NOT(PIX_SRC) & PIX_DST \ : (OPERATION == INVERT_atom ? PIX_SRC ^ PIX_DST : ERROR))))) -#define bbop(SRCTYPE, OPERATION) \ - (OPERATION == PAINT_atom \ - ? op_fn_or \ - : (OPERATION == ERASE_atom ? op_fn_and \ +#define bbop(SRCTYPE, OPERATION) \ + (OPERATION == PAINT_atom \ + ? op_fn_or \ + : (OPERATION == ERASE_atom ? op_fn_and \ : (OPERATION == INVERT_atom ? op_fn_xor : op_repl_src))) /********************************************************/ @@ -186,14 +186,14 @@ extern int ScreenLocked; /* for mouse tracking */ /* */ /********************************************************/ -#define bbsrc_type(SRCTYPE, OPERATION) \ - (SRCTYPE == INVERT_atom ? (OPERATION == ERASE_atom ? 0 : 1) /* SRCTYPE == INPUT, TEXTURE */ \ +#define bbsrc_type(SRCTYPE, OPERATION) \ + (SRCTYPE == INVERT_atom ? (OPERATION == ERASE_atom ? 0 : 1) /* SRCTYPE == INPUT, TEXTURE */ \ : (OPERATION == ERASE_atom ? 1 : 0)) -#define init_kbd_startup \ - if (!kbd_for_makeinit) { \ - init_keyboard(0); \ - kbd_for_makeinit = 1; \ +#define init_kbd_startup \ + if (!kbd_for_makeinit) { \ + init_keyboard(0); \ + kbd_for_makeinit = 1; \ }; extern struct pixrect *SrcePixRect, *DestPixRect, *TexturePixRect; @@ -273,8 +273,7 @@ void bitbltsub(LispPTR *argv) { w = pbt->pbtwidth; h = pbt->pbtheight; - if ((h <= 0) || (w <= 0)) - return; + if ((h <= 0) || (w <= 0)) return; src_comp = bbsrc_type(sourcetype, operation); op = bbop(sourcetype, operation); @@ -372,8 +371,7 @@ do_it_now: #ifdef REALCURSOR displayflg |= n_new_cursorin(dstbase, dx, dty, w, h); - if (displayflg) - HideCursor; + if (displayflg) HideCursor; #endif /* REALCURSOR */ #ifdef NEWBITBLT @@ -397,8 +395,7 @@ do_it_now: #ifdef XWINDOW XLOCK; - if (in_display_segment(dstbase)) - flush_display_region(dx, dty, w, h); + if (in_display_segment(dstbase)) flush_display_region(dx, dty, w, h); XFlush(currentdsp->display_id); XUNLOCK; #endif /* XWINDOW */ @@ -412,8 +409,7 @@ do_it_now: #endif /* DOS */ #ifdef REALCURSOR - if (displayflg) - ShowCursor; + if (displayflg) ShowCursor; #endif /* REALCURSOR */ #ifdef DOS @@ -503,18 +499,18 @@ LispPTR n_new_cursorin(DLword *baseaddr, int dx, int dy, int w, int h) { #endif /* COLOR */ #define BITBLTBITMAP_argnum 14 -#define PUNT_TO_BITBLTBITMAP \ - { \ - if (BITBLTBITMAP_index == 0xffffffff) { \ - BITBLTBITMAP_index = get_package_atom("\\PUNT.BITBLT.BITMAP", 19, "INTERLISP", 9, NIL); \ - if (BITBLTBITMAP_index == 0xffffffff) { \ - error("BITBLTBITMAP install failed"); \ - return (NIL); \ - } \ - } \ - CurrentStackPTR += (BITBLTBITMAP_argnum - 1) * DLWORDSPER_CELL; \ - ccfuncall(BITBLTBITMAP_index, BITBLTBITMAP_argnum, 3); \ - return (T); \ +#define PUNT_TO_BITBLTBITMAP \ + { \ + if (BITBLTBITMAP_index == 0xffffffff) { \ + BITBLTBITMAP_index = get_package_atom("\\PUNT.BITBLT.BITMAP", 19, "INTERLISP", 9, NIL); \ + if (BITBLTBITMAP_index == 0xffffffff) { \ + error("BITBLTBITMAP install failed"); \ + return (NIL); \ + } \ + } \ + CurrentStackPTR += (BITBLTBITMAP_argnum - 1) * DLWORDSPER_CELL; \ + ccfuncall(BITBLTBITMAP_index, BITBLTBITMAP_argnum, 3); \ + return (T); \ } LispPTR BITBLTBITMAP_index; @@ -576,9 +572,7 @@ LispPTR bitblt_bitmap(LispPTR *args) { sourcetype = args[8]; /* sourcetype == MERGE_atom case must be handled in Lisp func \\BITMAP.BITBLT */ - if (sourcetype == MERGE_atom) { - PUNT_TO_BITBLTBITMAP; - } + if (sourcetype == MERGE_atom) { PUNT_TO_BITBLTBITMAP; } N_GETNUMBER(args[1], sleft, bad_arg); N_GETNUMBER(args[2], sbottom, bad_arg); @@ -641,8 +635,7 @@ LispPTR bitblt_bitmap(LispPTR *args) { top = min(temp, min(top - stody, clipbottom + height)); } - if ((right <= left) || (top <= bottom)) - return (NIL); + if ((right <= left) || (top <= bottom)) return (NIL); /*** PUT SOURCETYPE MERGE special code HERE ***/ /**** See avobe, earler in this code check @@ -650,26 +643,26 @@ LispPTR bitblt_bitmap(LispPTR *args) { if (sourcebits == destbits) { /* not 1-bit-per-pixel, so adjust limits by pixel size */ switch (sourcebits) { - case 4: - left = left * 4; - right = right * 4; - stodx = stodx * 4; - /* Put color texture merge case here */ - break; + case 4: + left = left * 4; + right = right * 4; + stodx = stodx * 4; + /* Put color texture merge case here */ + break; - case 8: - left = left * 8; - right = right * 8; - stodx = stodx * 8; - /* Put color texture merge case here */ - break; + case 8: + left = left * 8; + right = right * 8; + stodx = stodx * 8; + /* Put color texture merge case here */ + break; - case 24: - left = left * 24; - right = right * 24; - stodx = stodx * 24; - /* Put color texture merge case here */ - break; + case 24: + left = left * 24; + right = right * 24; + stodx = stodx * 24; + /* Put color texture merge case here */ + break; } } else { /* DBPRINT(("BITBLT between bitmaps of different sizes, unimplemented.")); */ @@ -723,8 +716,7 @@ do_it_now: #ifdef REALCURSOR displayflg |= n_new_cursorin(dstbase, dlx, dty, width, height); - if (displayflg) - HideCursor; + if (displayflg) HideCursor; #endif /* REALCURSOR */ #ifdef NEWBITBLT @@ -762,8 +754,7 @@ do_it_now: #ifdef XWINDOW XLOCK; - if (in_display_segment(dstbase)) - flush_display_region(dlx, dty, width, height); + if (in_display_segment(dstbase)) flush_display_region(dlx, dty, width, height); XFlush(currentdsp->display_id); XUNLOCK; #endif /* XWINDOW */ @@ -777,8 +768,7 @@ do_it_now: #endif /* DOS */ #ifdef REALCURSOR - if (displayflg) - ShowCursor; + if (displayflg) ShowCursor; #endif /* REALCURSOR */ UNLOCKSCREEN; @@ -790,18 +780,18 @@ bad_arg: } /* end of bitblt_bitmap */ #define BLTSHADEBITMAP_argnum 8 -#define PUNT_TO_BLTSHADEBITMAP \ - { \ - if (BLTSHADEBITMAP_index == 0xffffffff) { \ - BLTSHADEBITMAP_index = get_package_atom("\\PUNT.BLTSHADE.BITMAP", 21, "INTERLISP", 9, NIL); \ - if (BLTSHADEBITMAP_index == 0xffffffff) { \ - error("BLTSHADEBITMAP install failed"); \ - return (NIL); \ - } \ - } \ - CurrentStackPTR += (BLTSHADEBITMAP_argnum - 1) * DLWORDSPER_CELL; \ - ccfuncall(BLTSHADEBITMAP_index, BLTSHADEBITMAP_argnum, 3); \ - return (T); \ +#define PUNT_TO_BLTSHADEBITMAP \ + { \ + if (BLTSHADEBITMAP_index == 0xffffffff) { \ + BLTSHADEBITMAP_index = get_package_atom("\\PUNT.BLTSHADE.BITMAP", 21, "INTERLISP", 9, NIL); \ + if (BLTSHADEBITMAP_index == 0xffffffff) { \ + error("BLTSHADEBITMAP install failed"); \ + return (NIL); \ + } \ + } \ + CurrentStackPTR += (BLTSHADEBITMAP_argnum - 1) * DLWORDSPER_CELL; \ + ccfuncall(BLTSHADEBITMAP_index, BLTSHADEBITMAP_argnum, 3); \ + return (T); \ } LispPTR BLTSHADEBITMAP_index; @@ -856,9 +846,7 @@ LispPTR bitshade_bitmap(LispPTR *args) { } DestBitmap = (BITMAP *)Addr68k_from_LADDR(args[1]); - if ((destbits = DestBitmap->bmbitperpixel) != 1) { - PUNT_TO_BLTSHADEBITMAP; - } + if ((destbits = DestBitmap->bmbitperpixel) != 1) { PUNT_TO_BLTSHADEBITMAP; } N_GETNUMBER(args[2], dleft, bad_arg); N_GETNUMBER(args[3], dbottom, bad_arg); @@ -904,19 +892,15 @@ LispPTR bitshade_bitmap(LispPTR *args) { top = min(top, dbottom + height); } - if ((right <= left) || (top <= bottom)) - return (NIL); + if ((right <= left) || (top <= bottom)) return (NIL); height = top - bottom; width = right - left; dty = DestBitmap->bmheight - top; - if ((dty < 0) || ((dty + height) > DestBitmap->bmheight)) - error("dty bad."); - if ((bottom < 0)) - error("bottom bad."); - if ((bottom > 2048)) - error("bottom suspicious"); + if ((dty < 0) || ((dty + height) > DestBitmap->bmheight)) error("dty bad."); + if ((bottom < 0)) error("bottom bad."); + if ((bottom > 2048)) error("bottom suspicious"); /*** Stolen from bitbltsub, to avoid the call overhead: ***/ src_comp = bbsrc_type(0, operation); @@ -924,8 +908,7 @@ LispPTR bitshade_bitmap(LispPTR *args) { dstbpl = rasterwidth << 4; - if ((left < 0) || (right > dstbpl)) - error("left/right bad."); + if ((left < 0) || (right > dstbpl)) error("left/right bad."); slx = left % BITSPERWORD; @@ -980,8 +963,7 @@ do_it_now: #ifdef REALCURSOR displayflg |= n_new_cursorin(dstbase, left, dty, width, height); - if (displayflg) - HideCursor; + if (displayflg) HideCursor; #endif /* REALCURSOR */ #ifdef NEWBITBLT @@ -1019,8 +1001,7 @@ do_it_now: #ifdef XWINDOW XLOCK; - if (in_display_segment(dstbase)) - flush_display_region(left, dty, width, height); + if (in_display_segment(dstbase)) flush_display_region(left, dty, width, height); XFlush(currentdsp->display_id); XUNLOCK; #endif /* XWINDOW */ @@ -1034,8 +1015,7 @@ do_it_now: #endif /* DOS */ #ifdef REALCURSOR - if (displayflg) - ShowCursor; + if (displayflg) ShowCursor; #endif /* REALCURSOR */ UNLOCKSCREEN; @@ -1176,8 +1156,7 @@ void bltchar(register BLTC *args) dstbpl = abs(pbt->pbtdestbpl); h = pbt->pbtheight; w = args->right - args->left; - if ((h <= 0) || (w <= 0)) - return; + if ((h <= 0) || (w <= 0)) return; base = GETWORD(Addr68k_from_LADDR(dspdata->ddoffsetscache + args->char8code)); sx = base + args->left - args->curx; @@ -1197,8 +1176,7 @@ void bltchar(register BLTC *args) LOCKSCREEN; #ifdef REALCURSOR - if (displayflg) - HideCursor; + if (displayflg) HideCursor; #endif /* REALCURSOR */ #ifdef NEWBITBLT @@ -1213,26 +1191,21 @@ void bltchar(register BLTC *args) if (MonoOrColor == MONO_SCREEN) #endif /* COLOR */ - if (in_display_segment(dstbase)) { - flush_display_lineregion(dx, dstbase, w, h); - } + if (in_display_segment(dstbase)) { flush_display_lineregion(dx, dstbase, w, h); } #endif #ifdef XWINDOW XLOCK; - if (in_display_segment(dstbase)) - flush_display_lineregion(dx, dstbase, w, h); + if (in_display_segment(dstbase)) flush_display_lineregion(dx, dstbase, w, h); XUNLOCK; #endif /* XWINDOW */ #ifdef DOS - if (in_display_segment(dstbase)) - flush_display_lineregion(dx, dstbase, w, h); + if (in_display_segment(dstbase)) flush_display_lineregion(dx, dstbase, w, h); #endif /* DOS */ #ifdef REALCURSOR - if (displayflg) - ShowCursor; + if (displayflg) ShowCursor; #endif /* REALCURSOR */ UNLOCKSCREEN; @@ -1307,8 +1280,7 @@ LispPTR bltchar(register BLTC *args) LOCKSCREEN; #ifdef REALCURSOR - if (displayflg) - HideCursor; + if (displayflg) HideCursor; #endif /* REALCURSOR */ if (pr_rop(DestPixRect, args->left, 0, (args->right - args->left), pbt->pbtheight, pix_op, @@ -1336,13 +1308,11 @@ LispPTR bltchar(register BLTC *args) #endif /* XWINDOW */ #ifdef DOS - if (in_display_segment(dstbase)) - flush_display_lineregion(dx, dstbase, w, h); + if (in_display_segment(dstbase)) flush_display_lineregion(dx, dstbase, w, h); #endif /* DOS */ #ifdef REALCURSOR - if (displayflg) - ShowCursor; + if (displayflg) ShowCursor; #endif /* REALCURSOR */ ScreenLocked = NIL; @@ -1364,69 +1334,69 @@ LispPTR bltchar(register BLTC *args) #define BLTCHAR_argnum 3 #ifndef INIT -#define PUNT_TO_BLTCHAR \ - { \ - if ((BLTCHAR_index == 0)) { \ - BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR", 18, "INTERLISP", 9, NIL); \ - if (BLTCHAR_index == 0xffffffff) { \ - error("\\MAIKO.PUNTBLTCHAR install failed"); \ - return; \ - } \ - } \ - CurrentStackPTR += (BLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ - ccfuncall(BLTCHAR_index, BLTCHAR_argnum, 3); \ - return; \ +#define PUNT_TO_BLTCHAR \ + { \ + if ((BLTCHAR_index == 0)) { \ + BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR", 18, "INTERLISP", 9, NIL); \ + if (BLTCHAR_index == 0xffffffff) { \ + error("\\MAIKO.PUNTBLTCHAR install failed"); \ + return; \ + } \ + } \ + CurrentStackPTR += (BLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ + ccfuncall(BLTCHAR_index, BLTCHAR_argnum, 3); \ + return; \ } #else -#define PUNT_TO_BLTCHAR \ - { /* Version that is silent instead of erroring for init */ \ - if ((BLTCHAR_index == 0)) { \ - BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR", 18, "INTERLISP", 9, NIL); \ - if (BLTCHAR_index == 0xffffffff) { \ - /* error("\\MAIKO.PUNTBLTCHAR install failed"); */ \ - return; \ - } \ - } \ - CurrentStackPTR += (BLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ - ccfuncall(BLTCHAR_index, BLTCHAR_argnum, 3); \ - return; \ +#define PUNT_TO_BLTCHAR \ + { /* Version that is silent instead of erroring for init */ \ + if ((BLTCHAR_index == 0)) { \ + BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR", 18, "INTERLISP", 9, NIL); \ + if (BLTCHAR_index == 0xffffffff) { \ + /* error("\\MAIKO.PUNTBLTCHAR install failed"); */ \ + return; \ + } \ + } \ + CurrentStackPTR += (BLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ + ccfuncall(BLTCHAR_index, BLTCHAR_argnum, 3); \ + return; \ } #endif /* INIT */ #define TEDIT_BLTCHAR_argnum 6 -#define PUNT_TO_TEDIT_BLTCHAR \ - { \ - if (TEDIT_BLTCHAR_index == 0xffffffff) { \ - TEDIT_BLTCHAR_index = get_package_atom("\\TEDIT.BLTCHAR", 14, "INTERLISP", 9, NIL); \ - if (TEDIT_BLTCHAR_index == 0xffffffff) { \ - error("TEDIT install failed"); \ - return; \ - } \ - } \ - CurrentStackPTR += (TEDIT_BLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ - ccfuncall(TEDIT_BLTCHAR_index, TEDIT_BLTCHAR_argnum, 3); \ - return; \ +#define PUNT_TO_TEDIT_BLTCHAR \ + { \ + if (TEDIT_BLTCHAR_index == 0xffffffff) { \ + TEDIT_BLTCHAR_index = get_package_atom("\\TEDIT.BLTCHAR", 14, "INTERLISP", 9, NIL); \ + if (TEDIT_BLTCHAR_index == 0xffffffff) { \ + error("TEDIT install failed"); \ + return; \ + } \ + } \ + CurrentStackPTR += (TEDIT_BLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ + ccfuncall(TEDIT_BLTCHAR_index, TEDIT_BLTCHAR_argnum, 3); \ + return; \ } -#define FGetNum(ptr, place) \ - { \ - if (((ptr)&SEGMASK) == S_POSITIVE) { \ - (place) = ((ptr)&0xffff); \ - } else if (((ptr)&SEGMASK) == S_NEGATIVE) { \ - (place) = (int)((ptr) | 0xffff0000); \ - } else { \ - PUNT_TO_BLTCHAR; \ - } \ +#define FGetNum(ptr, place) \ + { \ + if (((ptr)&SEGMASK) == S_POSITIVE) { \ + (place) = ((ptr)&0xffff); \ + } else if (((ptr)&SEGMASK) == S_NEGATIVE) { \ + (place) = (int)((ptr) | 0xffff0000); \ + } else { \ + PUNT_TO_BLTCHAR; \ + } \ } -#define FGetNum2(ptr, place) \ - { \ - if (((ptr)&SEGMASK) == S_POSITIVE) { \ - (place) = ((ptr)&0xffff); \ - } else if (((ptr)&SEGMASK) == S_NEGATIVE) { \ - (place) = (int)((ptr) | 0xffff0000); \ - } else { \ - return (-1); \ - } \ +#define FGetNum2(ptr, place) \ + { \ + if (((ptr)&SEGMASK) == S_POSITIVE) { \ + (place) = ((ptr)&0xffff); \ + } else if (((ptr)&SEGMASK) == S_NEGATIVE) { \ + (place) = (int)((ptr) | 0xffff0000); \ + } else { \ + return (-1); \ + } \ } LispPTR *TOPWDS68k; /* Top of window stack's DS */ @@ -1484,9 +1454,7 @@ void newbltchar(register BLTARG *args) { PUNT_TO_BLTCHAR; } - if (displaydata68k->ddslowprintingcase) { - PUNT_TO_BLTCHAR; /** \SLOWBLTCHAR--return;**/ - } + if (displaydata68k->ddslowprintingcase) { PUNT_TO_BLTCHAR; /** \SLOWBLTCHAR--return;**/ } FGetNum(displaydata68k->ddxposition, curx); FGetNum(displaydata68k->ddrightmargin, rmargin); @@ -1497,10 +1465,8 @@ void newbltchar(register BLTARG *args) { curx + GETWORD((DLword *)Addr68k_from_LADDR(displaydata68k->ddcharimagewidths + args->char8code)); - if ((right > rmargin) && (curx > lmargin)) - PUNT_TO_BLTCHAR; - if (args->displaystream != *TOPWDS68k) - PUNT_TO_BLTCHAR; + if ((right > rmargin) && (curx > lmargin)) PUNT_TO_BLTCHAR; + if (args->displaystream != *TOPWDS68k) PUNT_TO_BLTCHAR; { register int newpos; @@ -1518,8 +1484,7 @@ void newbltchar(register BLTARG *args) { curx += xoff; right += xoff; - if (right > (int)(displaydata68k->ddclippingright)) - right = displaydata68k->ddclippingright; + if (right > (int)(displaydata68k->ddclippingright)) right = displaydata68k->ddclippingright; if (curx > (int)(displaydata68k->ddclippingleft)) left = curx; @@ -1529,8 +1494,7 @@ void newbltchar(register BLTARG *args) { pbt = (PILOTBBT *)Addr68k_from_LADDR(displaydata68k->ddpilotbbt); h = pbt->pbtheight; w = right - left; - if ((h <= 0) || (w <= 0)) - return; + if ((h <= 0) || (w <= 0)) return; srcbase = (DLword *)Addr68k_from_LADDR(VAG2(pbt->pbtsourcehi, pbt->pbtsourcelo)); @@ -1550,8 +1514,7 @@ void newbltchar(register BLTARG *args) { #ifdef REALCURSOR displayflg = (cursorin(pbt->pbtdesthi, (pbt->pbtdestlo + (left >> 4)), (right - left), pbt->pbtheight, pbt->pbtbackward)); - if (displayflg) - HideCursor; + if (displayflg) HideCursor; #endif /* REALCURSOR */ #ifdef NEWBITBLT @@ -1573,17 +1536,14 @@ void newbltchar(register BLTARG *args) { #endif #ifdef XWINDOW - if (in_display_segment(dstbase)) - flush_display_lineregion(dx, dstbase, w, h); + if (in_display_segment(dstbase)) flush_display_lineregion(dx, dstbase, w, h); #endif /* XWINDOW */ #ifdef DOS - if (in_display_segment(dstbase)) - flush_display_lineregion(dx, dstbase, w, h); + if (in_display_segment(dstbase)) flush_display_lineregion(dx, dstbase, w, h); #endif /* DOS */ #ifdef REALCURSOR - if (displayflg) - ShowCursor; + if (displayflg) ShowCursor; #endif /* REALCURSOR */ UNLOCKSCREEN; @@ -1614,9 +1574,7 @@ LispPTR newbltchar(register BLTARG *args) { { PUNT_TO_BLTCHAR; } } - if (displaydata68k->ddslowprintingcase) { - PUNT_TO_BLTCHAR; /** \SLOWBLTCHAR--return;**/ - } + if (displaydata68k->ddslowprintingcase) { PUNT_TO_BLTCHAR; /** \SLOWBLTCHAR--return;**/ } FGetNum(displaydata68k->ddxposition, curx); FGetNum(displaydata68k->ddrightmargin, rmargin); @@ -1627,10 +1585,8 @@ LispPTR newbltchar(register BLTARG *args) { curx + GETWORD((DLword *)Addr68k_from_LADDR(displaydata68k->ddcharimagewidths + args->char8code)); - if ((right > rmargin) && (curx > lmargin)) - PUNT_TO_BLTCHAR; - if (args->displaystream != *TOPWDS68k) - PUNT_TO_BLTCHAR; + if ((right > rmargin) && (curx > lmargin)) PUNT_TO_BLTCHAR; + if (args->displaystream != *TOPWDS68k) PUNT_TO_BLTCHAR; { register int newpos; newpos = curx + @@ -1647,8 +1603,7 @@ LispPTR newbltchar(register BLTARG *args) { curx += xoff; right += xoff; - if (right > (int)(displaydata68k->ddclippingright)) - right = displaydata68k->ddclippingright; + if (right > (int)(displaydata68k->ddclippingright)) right = displaydata68k->ddclippingright; if (curx > (int)(displaydata68k->ddclippingleft)) left = curx; @@ -1712,8 +1667,7 @@ LispPTR newbltchar(register BLTARG *args) { * (right - left), pbt->pbtheight)); */ flush_display_lineregion(left, dstbase, (right - left), pbt->pbtheight); - if (displayflg) - ShowCursor; /* because hide is done earlier */ + if (displayflg) ShowCursor; /* because hide is done earlier */ } #endif #endif /* SUNDISPLAY */ @@ -1729,10 +1683,8 @@ LispPTR newbltchar(register BLTARG *args) { #endif /* XWINDOW */ #ifdef DOS - if (in_display_segment(dstbase)) - flush_display_lineregion(dx, dstbase, w, h); - if (displayflg) - ShowCursor; + if (in_display_segment(dstbase)) flush_display_lineregion(dx, dstbase, w, h); + if (displayflg) ShowCursor; #endif /* DOS */ ScreenLocked = NIL; @@ -1865,8 +1817,7 @@ typedef struct { /** changecharset_display,sfffixy are not tested *****I don't use TAKE **/ -LispPTR sfffixy(displaydata68k, csinfo68k, pbt68k) -DISPLAYDATA *displaydata68k; +LispPTR sfffixy(displaydata68k, csinfo68k, pbt68k) DISPLAYDATA *displaydata68k; CHARSETINFO *csinfo68k; PILOTBBT *pbt68k; @@ -1918,9 +1869,7 @@ LispPTR changecharset_display(register DISPLAYDATA *displaydata68k, DLword chars fontd68k = (FONTDESC *)Addr68k_from_LADDR(displaydata68k->ddfont); base68k = (LispPTR *)Addr68k_from_LADDR(fontd68k->FONTCHARSETVECTOR); - if ((csinfo = *(base68k + charset)) == NIL) { - return (-1); /* punt case */ - } + if ((csinfo = *(base68k + charset)) == NIL) { return (-1); /* punt case */ } csinfo68k = (CHARSETINFO *)Addr68k_from_LADDR(csinfo); /* REF CNT */ @@ -1949,14 +1898,14 @@ LispPTR changecharset_display(register DISPLAYDATA *displaydata68k, DLword chars } } /* changecharset_display */ - /******************************************************************/ -void ccfuncall(atom_index, argnum, - bytenum) register unsigned int atom_index; /* Atomindex for Function you want to invoke */ -register int argnum; /* Number of ARGS on TOS and STK */ -register int bytenum; /* Number of bytes of Caller's - OPCODE(including multi-byte) */ +void ccfuncall( + atom_index, argnum, + bytenum) register unsigned int atom_index; /* Atomindex for Function you want to invoke */ +register int argnum; /* Number of ARGS on TOS and STK */ +register int bytenum; /* Number of bytes of Caller's + OPCODE(including multi-byte) */ { register struct definition_cell *defcell68k; /* Definition Cell PTR */ register short pv_num; /* scratch for pv */ @@ -2220,8 +2169,7 @@ register int x, w, h, y; else return (NIL); - if (backward) - y -= h; + if (backward) y -= h; if ((x < MOUSEXR) && (x + w > MOUSEXL) && (y < MOUSEYH) && (y + h > MOUSEYL)) return (T); @@ -2250,8 +2198,7 @@ register int x, w, h, y; else return (NIL); - if (backward) - y -= h; + if (backward) y -= h; if ((x < MOUSEXR) && (x + w > MOUSEXL) && (y < MOUSEYH) && (y + h > MOUSEYL)) return (T); @@ -2265,8 +2212,7 @@ register int x, w, h, y; } else return (NIL); - if (backward) - y -= h; + if (backward) y -= h; /* printf("old_c:x=%d,y=%d,w=%d,h=%d\n",x,y,w,h);*/ if ((x < MOUSEXR) && ((x + (w >> 3)) > MOUSEXL) && (y < MOUSEYH) && (y + h > MOUSEYL)) { /* printf("old_c T\n");*/ diff --git a/src/bin.c b/src/bin.c old mode 100755 new mode 100644 index fa88cde..ce4f92d --- a/src/bin.c +++ b/src/bin.c @@ -1,10 +1,6 @@ /* $Id: bin.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: bin.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,21 +15,19 @@ static char *id = "$Id: bin.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright #include "version.h" - - /***********************************************************************/ /* - File Name : bin.c + File Name : bin.c + + Desc : + + Date : Jul. 22, 1987 + Edited by : Takeshi Shimizu + Changed : + + Including : OP_bin + - Desc : - - Date : Jul. 22, 1987 - Edited by : Takeshi Shimizu - Changed : - - Including : OP_bin - - */ /**********************************************************************/ @@ -44,28 +38,25 @@ static char *id = "$Id: bin.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright #include "lsptypes.h" #include "address.h" #include "adr68k.h" -#include "cell.h" -#include "stream.h" - -LispPTR N_OP_bin(register int tos) -{ - register Stream *stream68k; /* stream instance on TOS */ - register char *buff68k; /* pointer to BUFF */ +#include "cell.h" +#include "stream.h" - if(GetTypeNumber(tos) == TYPE_STREAM) - { - stream68k=(Stream *) Addr68k_from_LADDR(tos); +LispPTR N_OP_bin(register int tos) { + register Stream *stream68k; /* stream instance on TOS */ + register char *buff68k; /* pointer to BUFF */ - if(!stream68k->BINABLE) ERROR_EXIT(tos); + if (GetTypeNumber(tos) == TYPE_STREAM) { + stream68k = (Stream *)Addr68k_from_LADDR(tos); - if(stream68k->COFFSET >= stream68k->CBUFSIZE) ERROR_EXIT(tos); - - /* get BUFFER instance */ - buff68k =(char *)Addr68k_from_LADDR(stream68k->CBUFPTR); + if (!stream68k->BINABLE) ERROR_EXIT(tos); - /* get BYTE data and set it to TOS */ - return(S_POSITIVE | (Get_BYTE(buff68k + (stream68k->COFFSET)++)) ); - } - else ERROR_EXIT(tos); - + if (stream68k->COFFSET >= stream68k->CBUFSIZE) ERROR_EXIT(tos); + + /* get BUFFER instance */ + buff68k = (char *)Addr68k_from_LADDR(stream68k->CBUFPTR); + + /* get BYTE data and set it to TOS */ + return (S_POSITIVE | (Get_BYTE(buff68k + (stream68k->COFFSET)++))); + } else + ERROR_EXIT(tos); } diff --git a/src/binds.c b/src/binds.c old mode 100755 new mode 100644 index 50fbb7f..f98650e --- a/src/binds.c +++ b/src/binds.c @@ -1,10 +1,6 @@ -/* $Id: binds.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: binds.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: binds.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,149 +15,135 @@ static char *id = "$Id: binds.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyrig #include "version.h" - -#include -#include "lispemul.h" -#include "lspglob.h" -#include "emlglob.h" +#include +#include "lispemul.h" +#include "lspglob.h" +#include "emlglob.h" /************************************************** N_OP_bind(stack_pointer, tos, n1, n2) - Entry: BIND opcode[021] + Entry: BIND opcode[021] - 1. bind PVAR slot to NIL. (n1 times) - 2. bind PVAR slot to value of slot in Evaluation stack. (n2 times) - or push TopOfStack to Evaluation stack. - 3. Push [upper word] 1's complement of bind slots - [lower word] 2word offset from PVar + 1. bind PVAR slot to NIL. (n1 times) + 2. bind PVAR slot to value of slot in Evaluation stack. (n2 times) + or push TopOfStack to Evaluation stack. + 3. Push [upper word] 1's complement of bind slots + [lower word] 2word offset from PVar ***************************************************/ -LispPTR *N_OP_bind(register LispPTR *stack_pointer, register LispPTR tos, int byte1, int byte2) -{ - register int n1; /* # slots to bind to NIL (0, 0) */ - register int n2; /* # slots to bind to value in stack */ - register LispPTR *ppvar; /* pointer to argued slot in Pvar area */ - register int i; /* temporary for control */ +LispPTR *N_OP_bind(register LispPTR *stack_pointer, register LispPTR tos, int byte1, int byte2) { + register int n1; /* # slots to bind to NIL (0, 0) */ + register int n2; /* # slots to bind to value in stack */ + register LispPTR *ppvar; /* pointer to argued slot in Pvar area */ + register int i; /* temporary for control */ -#ifdef TRACE - printPC(); - printf("TRACE: N_OP_bind()\n"); +#ifdef TRACE + printPC(); + printf("TRACE: N_OP_bind()\n"); #endif - n1 = byte1 >> 4; - n2 = byte1 & 0xf; - ppvar = (LispPTR *) PVar + 1 + byte2; + n1 = byte1 >> 4; + n2 = byte1 & 0xf; + ppvar = (LispPTR *)PVar + 1 + byte2; - for(i=0; i> 16); - ppvar = (LispPTR *) (PVar + 2 + GetLoWord(value)); - value = 0xffffffff; - for(i=0; i> 16); + ppvar = (LispPTR *)(PVar + 2 + GetLoWord(value)); + value = 0xffffffff; + for (i = 0; i < num; i++) { *--ppvar = value; } + return (stack_pointer); +} /************************************************** N_OP_dunbind - Entry: DUNBIND opcode[023] + Entry: DUNBIND opcode[023] - 1. if TopOfStack is unbound - unbind num slots from PVar. - if TopOfStack is bound - pop CurrentStack until the slot (num, lastpvar) is found. - unbind num slots from lastpvar. - 2. pop the top of CurrentStackPTR to TopOfStack. + 1. if TopOfStack is unbound + unbind num slots from PVar. + if TopOfStack is bound + pop CurrentStack until the slot (num, lastpvar) is found. + unbind num slots from lastpvar. + 2. pop the top of CurrentStackPTR to TopOfStack. ***************************************************/ -LispPTR *N_OP_dunbind(register LispPTR *stack_pointer, register LispPTR tos) -{ - register DLword num; /* number of unbind sot */ - register LispPTR *ppvar; /* pointer to last PVAR slot. */ - register DLword i; /* temporary for control */ - register LispPTR value; +LispPTR *N_OP_dunbind(register LispPTR *stack_pointer, register LispPTR tos) { + register DLword num; /* number of unbind sot */ + register LispPTR *ppvar; /* pointer to last PVAR slot. */ + register DLword i; /* temporary for control */ + register LispPTR value; -#ifdef TRACE - printPC(); - printf("TRACE: N_OP_dunbind()\n"); +#ifdef TRACE + printPC(); + printf("TRACE: N_OP_dunbind()\n"); #endif - if(tos & 0x80000000) - { - /* check MSB bit of High word in tos, 1: unbound, 0: bound */ + if (tos & 0x80000000) { + /* check MSB bit of High word in tos, 1: unbound, 0: bound */ - /* tos is unbound */ - num = ~(GetHiWord(tos)); - value = 0xffffffff; - if(num != 0) - { - ppvar = (LispPTR *) (PVar + 2 + GetLoWord(tos)); - for(i=0;i #ifndef NOPIXRECT @@ -34,11 +31,10 @@ static char *id = "$Id: bitblt.c,v 1.2 1999/01/03 02:06:47 sybalsky Exp $ Copyri #include #endif -#ifdef XWINDOW +#ifdef XWINDOW #define DISPLAYBUFFER #endif /* XWINDOW */ - #include "lispemul.h" #include "lspglob.h" #include "lispmap.h" @@ -65,7 +61,6 @@ extern int kbd_for_makeinit; extern int MonoOrColor; #endif /* COLOR */ - /*****************************************************************************/ /** **/ /** N_OP_pilotbitblt **/ @@ -75,114 +70,99 @@ extern int MonoOrColor; /** **/ /*****************************************************************************/ - -LispPTR N_OP_pilotbitblt(pilot_bt_tbl, tos) - LispPTR pilot_bt_tbl; - int tos; - { - PILOTBBT *pbt; - DLword *srcbase, *dstbase; - int displayflg; - int sx, dx, w, h, srcbpl, dstbpl, backwardflg; - int src_comp, op, gray, num_gray, curr_gray_line; +LispPTR N_OP_pilotbitblt(pilot_bt_tbl, tos) LispPTR pilot_bt_tbl; +int tos; +{ + PILOTBBT *pbt; + DLword *srcbase, *dstbase; + int displayflg; + int sx, dx, w, h, srcbpl, dstbpl, backwardflg; + int src_comp, op, gray, num_gray, curr_gray_line; #ifdef INIT - /* for init, we have to initialize the pointers at the - first call to pilotbitblt or we die. If we do it - earlier we die also. We set a new flag so we don't - do it more than once which is a lose also. + /* for init, we have to initialize the pointers at the + first call to pilotbitblt or we die. If we do it + earlier we die also. We set a new flag so we don't + do it more than once which is a lose also. - I put this in an ifdef so there won't be any extra - code when making a regular LDE. */ - - if (!kbd_for_makeinit) - { - init_keyboard(0); - kbd_for_makeinit = 1; - }; + I put this in an ifdef so there won't be any extra + code when making a regular LDE. */ + if (!kbd_for_makeinit) { + init_keyboard(0); + kbd_for_makeinit = 1; + }; #endif - pbt = (PILOTBBT *)Addr68k_from_LADDR(pilot_bt_tbl); + pbt = (PILOTBBT *)Addr68k_from_LADDR(pilot_bt_tbl); - w = pbt->pbtwidth; - h = pbt->pbtheight; - if ((h <= 0) || (w <= 0)) return(pilot_bt_tbl); - dx = pbt->pbtdestbit; - sx = pbt->pbtsourcebit; - backwardflg = pbt->pbtbackward; - /* if displayflg != 0 then source or destination is DisplayBitMap */ + w = pbt->pbtwidth; + h = pbt->pbtheight; + if ((h <= 0) || (w <= 0)) return (pilot_bt_tbl); + dx = pbt->pbtdestbit; + sx = pbt->pbtsourcebit; + backwardflg = pbt->pbtbackward; +/* if displayflg != 0 then source or destination is DisplayBitMap */ #ifdef DOS - currentdsp->device.locked++; + currentdsp->device.locked++; #else - ScreenLocked = T; + ScreenLocked = T; #endif /* DOS */ #if SUNDISPLAY || DOS - displayflg = cursorin(pbt->pbtdesthi, (pbt->pbtdestlo + (dx >> 4)), - w, h, backwardflg) || - cursorin(pbt->pbtsourcehi, (pbt->pbtsourcelo + (sx >> 4)), - w, h, backwardflg); + displayflg = cursorin(pbt->pbtdesthi, (pbt->pbtdestlo + (dx >> 4)), w, h, backwardflg) || + cursorin(pbt->pbtsourcehi, (pbt->pbtsourcelo + (sx >> 4)), w, h, backwardflg); #endif /* SUNDISPLAY */ + srcbase = (DLword *)Addr68k_from_LADDR(VAG2(pbt->pbtsourcehi, pbt->pbtsourcelo)); + dstbase = (DLword *)Addr68k_from_LADDR(VAG2(pbt->pbtdesthi, pbt->pbtdestlo)); - srcbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtsourcehi, - pbt->pbtsourcelo)); - dstbase = (DLword *)Addr68k_from_LADDR( VAG2( pbt->pbtdesthi, - pbt->pbtdestlo )); - - srcbpl = pbt->pbtsourcebpl; - dstbpl = pbt->pbtdestbpl; - src_comp = pbt->pbtsourcetype; - op = pbt->pbtoperation; - gray = pbt->pbtusegray; - num_gray = ((TEXTUREBBT *)pbt)->pbtgrayheightlessone + 1; - curr_gray_line = ((TEXTUREBBT *)pbt)->pbtgrayoffset; + srcbpl = pbt->pbtsourcebpl; + dstbpl = pbt->pbtdestbpl; + src_comp = pbt->pbtsourcetype; + op = pbt->pbtoperation; + gray = pbt->pbtusegray; + num_gray = ((TEXTUREBBT *)pbt)->pbtgrayheightlessone + 1; + curr_gray_line = ((TEXTUREBBT *)pbt)->pbtgrayoffset; #ifdef SUNDISPLAY - if( displayflg ) HideCursor; + if (displayflg) HideCursor; #elif DOS - if( displayflg ) (currentdsp->mouse_invissible)( currentdsp, IOPage68K );; + if (displayflg) (currentdsp->mouse_invissible)(currentdsp, IOPage68K); + ; #endif /* SUNDISPLAY / DOS */ - - new_bitblt_code + new_bitblt_code #ifdef SUNDISPLAY #ifdef DISPLAYBUFFER #ifdef COLOR - if( MonoOrColor == MONO_SCREEN ) + if (MonoOrColor == MONO_SCREEN) #endif /* COLOR */ - if (in_display_segment(dstbase)) - flush_display_lineregion(dx, dstbase, w, h); + if (in_display_segment(dstbase)) flush_display_lineregion(dx, dstbase, w, h); #endif - if( displayflg) ShowCursor; + if (displayflg) ShowCursor; #elif DOS - flush_display_lineregion(dx, dstbase, w, h); - if( displayflg) (currentdsp->mouse_vissible)( IOPage68K->dlmousex, - IOPage68K->dlmousey ); + flush_display_lineregion(dx, dstbase, w, h); + if (displayflg) (currentdsp->mouse_vissible)(IOPage68K->dlmousex, IOPage68K->dlmousey); #endif /* SUNDISPLAY / DOS */ - #ifdef XWINDOW - flush_display_lineregion(dx, dstbase, w, h); + flush_display_lineregion(dx, dstbase, w, h); #endif /* XWINDOW */ - #ifdef DOS - currentdsp->device.locked--; + currentdsp->device.locked--; #else - ScreenLocked = NIL; + ScreenLocked = NIL; #endif /* DOS */ - return(pilot_bt_tbl); - - } /* end of N_OP_pilotbitblt */ - + return (pilot_bt_tbl); +} /* end of N_OP_pilotbitblt */ /************************************************************************/ /* */ @@ -194,82 +174,74 @@ LispPTR N_OP_pilotbitblt(pilot_bt_tbl, tos) #ifndef COLOR /* for MONO only */ -int cursorin (addrhi, addrlo, w, h, backward) - DLword addrhi; /* Lisp addr hi-word */ - DLword addrlo; /* Lisp addr lo-word */ - register int w, h; - { - register int x, y; - if (addrhi == DISPLAY_HI) - { - y = addrlo / DisplayRasterWidth; - x = (addrlo - y * DisplayRasterWidth) << 4; - } - else if (addrhi == DISPLAY_HI+1) - { - y = (addrlo + DLWORDSPER_SEGMENT) / DisplayRasterWidth; - x = ((addrlo + DLWORDSPER_SEGMENT) - y * DisplayRasterWidth) << 4; - } - else return( NIL ); +int cursorin(addrhi, addrlo, w, h, backward) DLword addrhi; /* Lisp addr hi-word */ +DLword addrlo; /* Lisp addr lo-word */ +register int w, h; +{ + register int x, y; + if (addrhi == DISPLAY_HI) { + y = addrlo / DisplayRasterWidth; + x = (addrlo - y * DisplayRasterWidth) << 4; + } else if (addrhi == DISPLAY_HI + 1) { + y = (addrlo + DLWORDSPER_SEGMENT) / DisplayRasterWidth; + x = ((addrlo + DLWORDSPER_SEGMENT) - y * DisplayRasterWidth) << 4; + } else + return (NIL); - if(backward) y -= h; - - if((x < MOUSEXR)&&(x + w > MOUSEXL)&&(y < MOUSEYH)&&(y + h > MOUSEYL)) - return( T ); - else return( NIL ); - } + if (backward) y -= h; + + if ((x < MOUSEXR) && (x + w > MOUSEXL) && (y < MOUSEYH) && (y + h > MOUSEYL)) + return (T); + else + return (NIL); +} #else /* for COLOR & MONO */ -int cursorin (addrhi, addrlo, w, h, backward) - DLword addrhi; /* Lisp addr hi-word */ - DLword addrlo; /* Lisp addr lo-word */ - register int w, h; - { - register int x, y; - register DLword *base68k; - extern int MonoOrColor; - extern int displaywidth; - extern DLword *ColorDisplayRegion68k; +int cursorin(addrhi, addrlo, w, h, backward) DLword addrhi; /* Lisp addr hi-word */ +DLword addrlo; /* Lisp addr lo-word */ +register int w, h; +{ + register int x, y; + register DLword *base68k; + extern int MonoOrColor; + extern int displaywidth; + extern DLword *ColorDisplayRegion68k; - if(MonoOrColor == MONO_SCREEN) { /* On MONO screen */ - if (addrhi == DISPLAY_HI) - { - y = addrlo / DisplayRasterWidth; - x = (addrlo - y * DisplayRasterWidth) << 4; - } - else if (addrhi == DISPLAY_HI+1) - { - y = (addrlo + DLWORDSPER_SEGMENT) / DisplayRasterWidth; - x = ((addrlo + DLWORDSPER_SEGMENT) - y * DisplayRasterWidth) << 4; - } - else return( NIL ); + if (MonoOrColor == MONO_SCREEN) { /* On MONO screen */ + if (addrhi == DISPLAY_HI) { + y = addrlo / DisplayRasterWidth; + x = (addrlo - y * DisplayRasterWidth) << 4; + } else if (addrhi == DISPLAY_HI + 1) { + y = (addrlo + DLWORDSPER_SEGMENT) / DisplayRasterWidth; + x = ((addrlo + DLWORDSPER_SEGMENT) - y * DisplayRasterWidth) << 4; + } else + return (NIL); - if(backward) y -= h; - - if((x < MOUSEXR)&&(x + w > MOUSEXL)&&(y < MOUSEYH)&&(y + h > MOUSEYL)) - return( T ); - else - return( NIL ); - } - else { - base68k=(DLword*)Addr68k_from_LADDR(addrhi << 16 | addrlo); - if ((ColorDisplayRegion68k<=base68k) && - (base68k <= COLOR_MAX_Address)){ - y =(base68k - ColorDisplayRegion68k) /displaywidth ; - x = (UNSIGNED)(base68k - ColorDisplayRegion68k) -(y * displaywidth ); - /* printf("cursorin: IN COLOR mx=%d my=%d x=%d y%d w=%d h=%d\n" - ,*EmMouseX68K,*EmMouseY68K,x,y,w,h); */ - } - else return( NIL ); + if (backward) y -= h; - if(backward) y -= h; + if ((x < MOUSEXR) && (x + w > MOUSEXL) && (y < MOUSEYH) && (y + h > MOUSEYL)) + return (T); + else + return (NIL); + } else { + base68k = (DLword *)Addr68k_from_LADDR(addrhi << 16 | addrlo); + if ((ColorDisplayRegion68k <= base68k) && (base68k <= COLOR_MAX_Address)) { + y = (base68k - ColorDisplayRegion68k) / displaywidth; + x = (UNSIGNED)(base68k - ColorDisplayRegion68k) - (y * displaywidth); + /* printf("cursorin: IN COLOR mx=%d my=%d x=%d y%d w=%d h=%d\n" + ,*EmMouseX68K,*EmMouseY68K,x,y,w,h); */ + } else + return (NIL); - if((x < MOUSEXR)&&((x + (w >> 3)) > MOUSEXL)&&(y < MOUSEYH)&&(y + h > MOUSEYL)) - { /* printf("cursorin T\n"); */ return( T );} - else - return( NIL ); + if (backward) y -= h; - } /* on COLOR screen */ - } + if ((x < MOUSEXR) && ((x + (w >> 3)) > MOUSEXL) && (y < MOUSEYH) && + (y + h > MOUSEYL)) { /* printf("cursorin T\n"); */ + return (T); + } else + return (NIL); + + } /* on COLOR screen */ +} #endif /* COLOR */ diff --git a/src/blt.c b/src/blt.c old mode 100755 new mode 100644 index 1a808c3..8cb766f --- a/src/blt.c +++ b/src/blt.c @@ -1,10 +1,6 @@ /* $Id: blt.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: blt.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,8 +15,6 @@ static char *id = "$Id: blt.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright #include "version.h" - - /* * * Author : Takeshi Shimizu @@ -28,10 +22,10 @@ static char *id = "$Id: blt.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright */ /******************************************************************/ /* - File Name : blt.c - Including : OP_blt + File Name : blt.c + Including : OP_blt - Created : jul 9, 1987 by T.Shimizu + Created : jul 9, 1987 by T.Shimizu */ /******************************************************************/ @@ -47,29 +41,26 @@ static char *id = "$Id: blt.c,v 1.3 1999/05/31 23:35:24 sybalsky Exp $ Copyright /* N_OP_blt takes 3 arguments. - STK-1 has destination's pointer. - STK has source's pointer. - TOS has number of words to be translated. + STK-1 has destination's pointer. + STK has source's pointer. + TOS has number of words to be translated. */ +LispPTR N_OP_blt(LispPTR destptr, LispPTR sourceptr, register LispPTR wordcount) { + register DLword *source68k; + register DLword *dest68k; + register int nw; -LispPTR N_OP_blt(LispPTR destptr, LispPTR sourceptr, register LispPTR wordcount) -{ - register DLword *source68k; - register DLword *dest68k ; - register int nw; - - if((wordcount & SEGMASK) != S_POSITIVE) ERROR_EXIT(wordcount); - nw = wordcount & 0xffff ; - - source68k = Addr68k_from_LADDR(sourceptr) + nw; - dest68k = Addr68k_from_LADDR(destptr) + nw; - - while(nw) { (GETWORD(--dest68k))= GETWORD(--source68k) ; nw--; } - - return(wordcount); - } /* end N_OP_blt */ - + if ((wordcount & SEGMASK) != S_POSITIVE) ERROR_EXIT(wordcount); + nw = wordcount & 0xffff; + source68k = Addr68k_from_LADDR(sourceptr) + nw; + dest68k = Addr68k_from_LADDR(destptr) + nw; + while (nw) { + (GETWORD(--dest68k)) = GETWORD(--source68k); + nw--; + } + return (wordcount); +} /* end N_OP_blt */ diff --git a/src/byteswap.c b/src/byteswap.c old mode 100755 new mode 100644 index 2615e17..c8174d6 --- a/src/byteswap.c +++ b/src/byteswap.c @@ -1,10 +1,7 @@ -/* $Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,10 +14,8 @@ static char *id = "$Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ Copy /* */ /************************************************************************/ - #include "version.h" - /***************************************************************************/ /* */ /* byteswap.c */ @@ -30,7 +25,6 @@ static char *id = "$Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ Copy /* */ /***************************************************************************/ - #include "hdw_conf.h" #include "lispemul.h" #include "lispmap.h" @@ -41,8 +35,6 @@ static char *id = "$Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ Copy #include "inlnPS2.h" #else - - /****************************************************************/ /* */ /* Byte-swap a single 2-byte word */ @@ -50,22 +42,18 @@ static char *id = "$Id: byteswap.c,v 1.5 2002/01/02 08:15:16 sybalsky Exp $ Copy /* than for fixing up byte-swapped machines) */ /* */ /****************************************************************/ -unsigned int swapx(unsigned int word) -{ - return( ((word>>16)&0xffff)+((word&0xffff)<<16) ); - } - +unsigned int swapx(unsigned int word) { + return (((word >> 16) & 0xffff) + ((word & 0xffff) << 16)); +} /****************************************************************/ /* */ /* Byte-swap a single 2-byte word */ /* */ /****************************************************************/ -unsigned short byte_swap_word(short unsigned int word) -{ - return( ((word>>8)&0xff)+((word&0xff)<<8) ); - } - +unsigned short byte_swap_word(short unsigned int word) { + return (((word >> 8) & 0xff) + ((word & 0xff) << 8)); +} /****************************************************************/ /* */ @@ -80,25 +68,20 @@ unsigned int word_swap_longword(word) return( ((word>>16)&0xffff)+((word&0xffff)<<16) ); } ***/ #ifndef I386 -#define word_swap_longword(word) ( ((word>>16)&0xffff)+((word&0xffff)<<16) ) +#define word_swap_longword(word) (((word >> 16) & 0xffff) + ((word & 0xffff) << 16)) #endif #endif /* AIXPS2 */ - /****************************************************************/ /* */ /* Byte-swap a region wordcount words long */ /* This does NOT swap words in a long-word! */ /* */ /****************************************************************/ -void byte_swap_page(short unsigned int *page, int wordcount) -{ - int i; - for (i = 0; i < wordcount; i++) - { - *(page+i) = byte_swap_word(*(page+i)); - } - } +void byte_swap_page(short unsigned int *page, int wordcount) { + int i; + for (i = 0; i < wordcount; i++) { *(page + i) = byte_swap_word(*(page + i)); } +} #ifndef GCC386 /****************************************************************/ @@ -106,79 +89,57 @@ void byte_swap_page(short unsigned int *page, int wordcount) /* Byte- & word-swap a region wordcount long-words long */ /* */ /****************************************************************/ -void word_swap_page(short unsigned int *page, int longwordcount) -{ - register int i; - register unsigned int *longpage; - longpage = (unsigned int *) page; - for (i = 0; i < (longwordcount+longwordcount); i++) - { - *(page+i) = byte_swap_word(*(page+i)); - } - for (i = 0; i < longwordcount; i++) - { - *(longpage+i) = word_swap_longword(*(longpage+i)); - } - } +void word_swap_page(short unsigned int *page, int longwordcount) { + register int i; + register unsigned int *longpage; + longpage = (unsigned int *)page; + for (i = 0; i < (longwordcount + longwordcount); i++) { + *(page + i) = byte_swap_word(*(page + i)); + } + for (i = 0; i < longwordcount; i++) { *(longpage + i) = word_swap_longword(*(longpage + i)); } +} #endif /* GCC386 */ - /****************************************************************/ /* */ /* Bit-reverse all the words in a region */ /* */ /****************************************************************/ - unsigned char reversedbits[256] = - { /* table of bytes with their bits reversed */ - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, +unsigned char reversedbits[256] = { + /* table of bytes with their bits reversed */ + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, - }; + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +}; /*unsigned short reverse_bits(word) unsigned short word; @@ -186,28 +147,19 @@ void word_swap_page(short unsigned int *page, int longwordcount) return ((reversedbits[(word>>8) & 0xFF] <<8) | reversedbits[word & 0xff]); } ******/ -#define reverse_bits(word) ((reversedbits[((word)>>8) & 0xFF] <<8) | reversedbits[(word) & 0xff]) +#define reverse_bits(word) ((reversedbits[((word) >> 8) & 0xFF] << 8) | reversedbits[(word)&0xff]) -void bit_reverse_region(register short unsigned int *top, int width, int height, int rasterwidth) -{ - register int i, j, wordwid = ((width+31)>>5)<<1; - register unsigned short *word; - - for (i = 0; i < height; i++) - { - word = top; - for (j = 0; j < wordwid; j++) - { - GETWORD(word+j) = reverse_bits(GETWORD(word+j)); - } - word_swap_page((unsigned short *)((UNSIGNED)word&0xFFFFFFFE), (wordwid+1)>>1); - top += rasterwidth; - } +void bit_reverse_region(register short unsigned int *top, int width, int height, int rasterwidth) { + register int i, j, wordwid = ((width + 31) >> 5) << 1; + register unsigned short *word; + for (i = 0; i < height; i++) { + word = top; + for (j = 0; j < wordwid; j++) { GETWORD(word + j) = reverse_bits(GETWORD(word + j)); } + word_swap_page((unsigned short *)((UNSIGNED)word & 0xFFFFFFFE), (wordwid + 1) >> 1); + top += rasterwidth; } - - - +} /************************************************************************/ /* */ @@ -221,16 +173,15 @@ void bit_reverse_region(register short unsigned int *top, int width, int height, /************************************************************************/ #ifdef RESWAPPEDDCODESTREAM -unsigned int byte_swap_code_block (unsigned int *base) -{ - UNSIGNED startpc, len; +unsigned int byte_swap_code_block(unsigned int *base) { + UNSIGNED startpc, len; - startpc = ((UNSIGNED)base) + ((struct fnhead *)base)->startpc; - len = code_block_size(base); + startpc = ((UNSIGNED)base) + ((struct fnhead *)base)->startpc; + len = code_block_size(base); - word_swap_page((unsigned short *)startpc, (len+3)>>2); + word_swap_page((unsigned short *)startpc, (len + 3) >> 2); - return (UNSIGNED)base; - - } /* end of byte_swap_code_block */ + return (UNSIGNED)base; + +} /* end of byte_swap_code_block */ #endif /* RESWAPPEDCODESTREAM */ diff --git a/src/call-c.c b/src/call-c.c old mode 100755 new mode 100644 index f48e727..2762733 --- a/src/call-c.c +++ b/src/call-c.c @@ -1,9 +1,7 @@ -/* $Id: call-c.c,v 1.2 1999/01/03 02:06:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: call-c.c,v 1.2 1999/01/03 02:06:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: call-c.c,v 1.2 1999/01/03 02:06:48 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,8 +16,6 @@ static char *id = "$Id: call-c.c,v 1.2 1999/01/03 02:06:48 sybalsky Exp $ Copyri #include "version.h" - - /************************************************************************/ /* */ /* F O R E I G N - F U N C T I O N C A L L I N T E R F A C E */ @@ -30,10 +26,9 @@ static char *id = "$Id: call-c.c,v 1.2 1999/01/03 02:06:48 sybalsky Exp $ Copyri #include "lispemul.h" - lispPTR call_c_fn(args); - { - void() *fn = args[0]; - (*fn)(); - return(NIL); - } +{ + void() *fn = args[0]; + (*fn)(); + return (NIL); +} diff --git a/src/car-cdr.c b/src/car-cdr.c old mode 100755 new mode 100644 index e9df86c..dfb4e7a --- a/src/car-cdr.c +++ b/src/car-cdr.c @@ -1,10 +1,7 @@ -/* $Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,25 +16,23 @@ static char *id = "$Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyr #include "version.h" - - /***********************************************************************/ /* - File Name : car-cdr.c + File Name : car-cdr.c - Desc : car-cdr management + Desc : car-cdr management - Date : Apr 24, 1987 - Edited by : Naoyuki Mitani + Date : Apr 24, 1987 + Edited by : Naoyuki Mitani - Including : car - cdr - rplaca - rplacd - OP_car - OP_cdr - OP_rplaca - OP_rplacd + Including : car + cdr + rplaca + rplacd + OP_car + OP_cdr + OP_rplaca + OP_rplacd */ /**********************************************************************/ @@ -50,8 +45,6 @@ static char *id = "$Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyr #include "gc.h" #include "cell.h" - - /************************************************************************/ /* */ /* c a r */ @@ -61,37 +54,33 @@ static char *id = "$Id: car-cdr.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyr /************************************************************************/ LispPTR car(register LispPTR datum) - /* datum must be LISP pointer(word offset) */ - { - register ConsCell *datum68k; - register ConsCell *temp; +/* datum must be LISP pointer(word offset) */ +{ + register ConsCell *datum68k; + register ConsCell *temp; - datum68k = (ConsCell *)(Addr68k_from_LADDR(datum)); - if (Listp(datum)) - { - if (datum68k->cdr_code == CDR_INDIRECT) - { - temp = (ConsCell *)Addr68k_from_LADDR(datum68k->car_field); - return((LispPTR)temp->car_field); - } - else return((LispPTR)datum68k->car_field); - } + datum68k = (ConsCell *)(Addr68k_from_LADDR(datum)); + if (Listp(datum)) { + if (datum68k->cdr_code == CDR_INDIRECT) { + temp = (ConsCell *)Addr68k_from_LADDR(datum68k->car_field); + return ((LispPTR)temp->car_field); + } else + return ((LispPTR)datum68k->car_field); + } - else if (datum==NIL_PTR) return((LispPTR)NIL_PTR); + else if (datum == NIL_PTR) + return ((LispPTR)NIL_PTR); + else { + if (datum == ATOM_T) return (ATOM_T); + + /** We assume CAR/CDRERR is CDR ***/ + else if ((datum & SEGMASK) == 0) /* LITATOM */ + return (NIL); else - { - if(datum == ATOM_T) return(ATOM_T); - - /** We assume CAR/CDRERR is CDR ***/ - else if ((datum & SEGMASK)==0) /* LITATOM */ - return(NIL); - else error("car : ARG not list"); - } - } /* end of car */ - - - + error("car : ARG not list"); + } +} /* end of car */ /************************************************************************/ /* */ @@ -102,442 +91,389 @@ LispPTR car(register LispPTR datum) /************************************************************************/ LispPTR cdr(register LispPTR datum) - /* datum must be LISP pointer(word offset) */ - { - register ConsCell *datum68k; - register DLword cdr_code; - register ConsCell *temp; +/* datum must be LISP pointer(word offset) */ +{ + register ConsCell *datum68k; + register DLword cdr_code; + register ConsCell *temp; - datum68k = (ConsCell *)(Addr68k_from_LADDR(datum)); - cdr_code = datum68k->cdr_code; + datum68k = (ConsCell *)(Addr68k_from_LADDR(datum)); + cdr_code = datum68k->cdr_code; - if (Listp(datum)) - { - if (cdr_code == CDR_NIL) return(NIL_PTR); /* cdr is nil */ + if (Listp(datum)) { + if (cdr_code == CDR_NIL) + return (NIL_PTR); /* cdr is nil */ - else if ((cdr_code & CDR_ONPAGE) != 0) /* cdr-samepage */ + else if ((cdr_code & CDR_ONPAGE) != 0) /* cdr-samepage */ #ifdef NEWCDRCODING - return(datum + ((cdr_code & 7) << 1)); + return (datum + ((cdr_code & 7) << 1)); #else - return(POINTER_PAGEBASE(datum) + ((cdr_code & 127) << 1)); -#endif /* NEWCDRCODING */ - else if (cdr_code == CDR_INDIRECT) /* cdr_code > CDR_ONPAGE */ - /* cdr-indirect */ - return(cdr ((LispPTR)(datum68k->car_field))); + return (POINTER_PAGEBASE(datum) + ((cdr_code & 127) << 1)); +#endif /* NEWCDRCODING */ + else if (cdr_code == CDR_INDIRECT) /* cdr_code > CDR_ONPAGE */ + /* cdr-indirect */ + return (cdr((LispPTR)(datum68k->car_field))); - else - { - /* cdr isn't a CONS, but is stored on this page. */ + else { +/* cdr isn't a CONS, but is stored on this page. */ #ifdef NEWCDRCODING - temp = (ConsCell *)(Addr68k_from_LADDR - (datum + (cdr_code << 1))); + temp = (ConsCell *)(Addr68k_from_LADDR(datum + (cdr_code << 1))); #else - temp = (ConsCell *)(Addr68k_from_LADDR - (POINTER_PAGEBASE(datum) + (cdr_code << 1))); + temp = (ConsCell *)(Addr68k_from_LADDR(POINTER_PAGEBASE(datum) + (cdr_code << 1))); #endif /* NEWCDRCODING */ - return((LispPTR)temp->car_field); - } - } - else if (datum==NIL_PTR) return(NIL_PTR); - - /**** We assume CAR/CDRERR is CDR ****************/ - else error("cdr : ARG not list"); - - } /* end of cdr */ + return ((LispPTR)temp->car_field); + } + } else if (datum == NIL_PTR) + return (NIL_PTR); + /**** We assume CAR/CDRERR is CDR ****************/ + else + error("cdr : ARG not list"); +} /* end of cdr */ /**********************************************************************/ /* - Func name : rplaca + Func name : rplaca - Called from C program. + Called from C program. - Date : Apr 15, 1987 - Edited by : Naoyuki Mitani + Date : Apr 15, 1987 + Edited by : Naoyuki Mitani */ /**********************************************************************/ LispPTR rplaca(register LispPTR x, register LispPTR y) - /* car of x will be smashed */ - /* y is a newly car object */ - { - register ConsCell *x_68k; - register ConsCell *temp; +/* car of x will be smashed */ +/* y is a newly car object */ +{ + register ConsCell *x_68k; + register ConsCell *temp; #ifdef TRACE2 - printf("TRACE: rplaca()\n"); + printf("TRACE: rplaca()\n"); #endif - if (Listp(x) == NIL) - { /* arg isn't a CONS cell, might be NIL */ - if (x == NIL_PTR) - { - if (y != NIL_PTR) error("Attempt to RPLACA NIL"); - else return(NIL_PTR); - } - else error("ARG not List"); - } + if (Listp(x) == NIL) { /* arg isn't a CONS cell, might be NIL */ + if (x == NIL_PTR) { + if (y != NIL_PTR) + error("Attempt to RPLACA NIL"); + else + return (NIL_PTR); + } else + error("ARG not List"); + } - else - { - x_68k = (ConsCell *)Addr68k_from_LADDR(x); - - GCLOOKUP(car(x), DELREF); /* set up reference count */ - GCLOOKUP(y, ADDREF); - - if (x_68k->cdr_code == CDR_INDIRECT) - { - temp = (ConsCell *)Addr68k_from_LADDR((LispPTR)x_68k->car_field); - temp->car_field = y; - } - else x_68k->car_field = y; - - return(x); - } - } /* end of rplaca */ + else { + x_68k = (ConsCell *)Addr68k_from_LADDR(x); + GCLOOKUP(car(x), DELREF); /* set up reference count */ + GCLOOKUP(y, ADDREF); + if (x_68k->cdr_code == CDR_INDIRECT) { + temp = (ConsCell *)Addr68k_from_LADDR((LispPTR)x_68k->car_field); + temp->car_field = y; + } else + x_68k->car_field = y; + return (x); + } +} /* end of rplaca */ /**********************************************************************/ /* - Func name : rplacd + Func name : rplacd - Called from C program. + Called from C program. - Date : Apr 16, 1987 - Edited by : Naoyuki Mitani + Date : Apr 16, 1987 + Edited by : Naoyuki Mitani */ /**********************************************************************/ #ifdef NEWCDRCODING -ConsCell *find_cdrable_pair(LispPTR carpart, LispPTR cdrpart); /* below... */ +ConsCell *find_cdrable_pair(LispPTR carpart, LispPTR cdrpart); /* below... */ #endif -extern struct conspage *next_conspage(void); /* conspage.c */ +extern struct conspage *next_conspage(void); /* conspage.c */ LispPTR rplacd(LispPTR x, register LispPTR y) - /* cdr of x will be smashed */ - /* y is a newly cdr object */ - { - register ConsCell *x_68k; - register ConsCell *temp68k; - register ConsCell *cdr_cell68k; - LispPTR cdr_cell; - LispPTR rp_page; - DLword cdr_code; - register struct conspage *cons68k; - ConsCell * find_close_cell(struct conspage *page, LispPTR oldcell); +/* cdr of x will be smashed */ +/* y is a newly cdr object */ +{ + register ConsCell *x_68k; + register ConsCell *temp68k; + register ConsCell *cdr_cell68k; + LispPTR cdr_cell; + LispPTR rp_page; + DLword cdr_code; + register struct conspage *cons68k; + ConsCell *find_close_cell(struct conspage * page, LispPTR oldcell); - if (Listp(x) == NIL) - { - if (x == NIL_PTR) - { - if (y != NIL_PTR) error("Attempt to RPLACD NIL"); - else return(NIL_PTR); - } - else error("ARG not List"); + if (Listp(x) == NIL) { + if (x == NIL_PTR) { + if (y != NIL_PTR) + error("Attempt to RPLACD NIL"); + else + return (NIL_PTR); + } else + error("ARG not List"); + } + + else { + x_68k = (ConsCell *)Addr68k_from_LADDR(x); + + GCLOOKUP(cdr(x), DELREF); /* set up reference count */ + GCLOOKUP(y, ADDREF); + + cdr_code = x_68k->cdr_code; + + if (cdr_code == CDR_INDIRECT) { + /* cdr-indirect */ + + rp_page = (LispPTR)x_68k->car_field; + temp68k = (ConsCell *)Addr68k_from_LADDR(rp_page); +#ifdef NEWCDRCODING + cdr_cell = (rp_page) + (temp68k->cdr_code << 1); +#else + cdr_cell = POINTER_PAGEBASE(rp_page) + (temp68k->cdr_code << 1); +#endif /* NEWCDRCODING */ + + cdr_cell68k = (ConsCell *)Addr68k_from_LADDR(cdr_cell); + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code is set to 0 */ + } else if (cdr_code <= CDR_MAXINDIRECT) { +/* cdr-differentpage */ +#ifdef NEWCDRCODING + cdr_cell = x + (cdr_code << 1); +#else + cdr_cell = POINTER_PAGEBASE(x) + (cdr_code << 1); +#endif /* NEWCDRCODING */ + cdr_cell68k = (ConsCell *)Addr68k_from_LADDR(cdr_cell); + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code is set to 0 */ + + } else if (y == NIL_PTR) + /* cdr-samepage & y is nil */ + x_68k->cdr_code = CDR_NIL; +#ifdef NEWCDRCODING + else if (((rp_page = POINTER_PAGEBASE(x)) == POINTER_PAGEBASE(y)) && (y > x) && (y <= (x + 14))) + /* cdr-samepage & x and y are on same page */ + x_68k->cdr_code = CDR_ONPAGE + ((y - x) >> 1); +#else + else if ((rp_page = POINTER_PAGEBASE(x)) == POINTER_PAGEBASE(y)) + /* cdr-samepage & x and y are on same page */ + x_68k->cdr_code = CDR_ONPAGE + ((y & 0xff) >> 1); +#endif /* NEWCDRCODING */ + else { + /* cdr-samepage & x and y are on different page */ + + cons68k = (struct conspage *)(Addr68k_from_LADDR(rp_page)); +#ifdef NEWCDRCODING + if ((cons68k->count > 0) && (cdr_cell68k = find_close_cell(cons68k, x))) { + /* at least one free-cell on x's conspage */ + /* AND it's within CDR-code range of x. */ + + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ + + x_68k->cdr_code = (LADDR_from_68k(cdr_cell68k) - x) >> 1; } - - else - { - x_68k = (ConsCell *)Addr68k_from_LADDR(x); - - GCLOOKUP(cdr(x), DELREF); /* set up reference count */ - GCLOOKUP(y, ADDREF); - - cdr_code = x_68k->cdr_code; - - if (cdr_code == CDR_INDIRECT) - { - /* cdr-indirect */ - - rp_page = (LispPTR)x_68k->car_field; - temp68k = (ConsCell *)Addr68k_from_LADDR(rp_page); -#ifdef NEWCDRCODING - cdr_cell = (rp_page) + (temp68k->cdr_code << 1); #else - cdr_cell = POINTER_PAGEBASE(rp_page) + - (temp68k->cdr_code << 1); -#endif /* NEWCDRCODING */ + if (cons68k->count > 0) { + /* at least one free-cell on x's conspage */ + cdr_cell68k = GetNewCell_68k(cons68k); + cons68k->count--; + cons68k->next_cell = ((freecons *)cdr_cell68k)->next_free; - cdr_cell68k = (ConsCell *)Addr68k_from_LADDR(cdr_cell); - *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code is set to 0 */ - } - else if (cdr_code <= CDR_MAXINDIRECT) - { - /* cdr-differentpage */ -#ifdef NEWCDRCODING - cdr_cell = x + (cdr_code << 1); -#else - cdr_cell = POINTER_PAGEBASE(x) + (cdr_code << 1); -#endif /* NEWCDRCODING */ - cdr_cell68k = (ConsCell *)Addr68k_from_LADDR(cdr_cell); - *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code is set to 0 */ + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ - } - else if (y == NIL_PTR) - /* cdr-samepage & y is nil */ - x_68k->cdr_code = CDR_NIL; -#ifdef NEWCDRCODING - else if (((rp_page = POINTER_PAGEBASE(x)) == POINTER_PAGEBASE(y)) - && (y > x) && (y <= (x+14))) - /* cdr-samepage & x and y are on same page */ - x_68k->cdr_code = CDR_ONPAGE + ((y-x) >> 1); -#else - else if ((rp_page = POINTER_PAGEBASE(x)) == POINTER_PAGEBASE(y)) - /* cdr-samepage & x and y are on same page */ - x_68k->cdr_code = CDR_ONPAGE + ((y & 0xff) >> 1); -#endif /* NEWCDRCODING */ - else - { - /* cdr-samepage & x and y are on different page */ - - cons68k = (struct conspage *)(Addr68k_from_LADDR(rp_page)); -#ifdef NEWCDRCODING - if ((cons68k->count > 0) - && (cdr_cell68k = find_close_cell(cons68k, x))) - { - /* at least one free-cell on x's conspage */ - /* AND it's within CDR-code range of x. */ - - *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ - - x_68k->cdr_code = (LADDR_from_68k(cdr_cell68k) - x) >> 1; - } -#else - if (cons68k->count > 0) - { - /* at least one free-cell on x's conspage */ - cdr_cell68k = GetNewCell_68k(cons68k); - cons68k->count--; - cons68k->next_cell = ((freecons *)cdr_cell68k)->next_free; - - *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ - - x_68k->cdr_code = (LADDR_from_68k(cdr_cell68k) - - rp_page) >> 1; - } -#endif /* NEWCDRCODING */ - else - { - /* no more free-cell on x's conspage */ -#ifdef NEWCDRCODING - temp68k = (ConsCell *)find_cdrable_pair(x, y); - temp68k->car_field = x_68k->car_field; - x_68k->car_field = LADDR_from_68k(temp68k); - x_68k->cdr_code = CDR_INDIRECT; -#else - cons68k = next_conspage(); - - cdr_cell68k = GetNewCell_68k(cons68k); - cons68k->next_cell = ((freecons *)cdr_cell68k)->next_free; - temp68k = GetNewCell_68k(cons68k); - cons68k->next_cell = ((freecons *)temp68k)->next_free; - - cons68k->count -= 2; - - *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ - - temp68k->car_field = x_68k->car_field; - x_68k->car_field = LADDR_from_68k(temp68k); - - temp68k->cdr_code = (LADDR_from_68k(cdr_cell68k) & 0xff) >> 1; - - x_68k->cdr_code = CDR_INDIRECT; -#endif /* NEWCDRCODING */ - } - } + x_68k->cdr_code = (LADDR_from_68k(cdr_cell68k) - rp_page) >> 1; } - return(x); +#endif /* NEWCDRCODING */ + else { +/* no more free-cell on x's conspage */ +#ifdef NEWCDRCODING + temp68k = (ConsCell *)find_cdrable_pair(x, y); + temp68k->car_field = x_68k->car_field; + x_68k->car_field = LADDR_from_68k(temp68k); + x_68k->cdr_code = CDR_INDIRECT; +#else + cons68k = next_conspage(); - }/* end of rplacd */ + cdr_cell68k = GetNewCell_68k(cons68k); + cons68k->next_cell = ((freecons *)cdr_cell68k)->next_free; + temp68k = GetNewCell_68k(cons68k); + cons68k->next_cell = ((freecons *)temp68k)->next_free; + cons68k->count -= 2; + *(LispPTR *)cdr_cell68k = y & POINTERMASK; /* cdr_code set to 0 */ + temp68k->car_field = x_68k->car_field; + x_68k->car_field = LADDR_from_68k(temp68k); + + temp68k->cdr_code = (LADDR_from_68k(cdr_cell68k) & 0xff) >> 1; + + x_68k->cdr_code = CDR_INDIRECT; +#endif /* NEWCDRCODING */ + } + } + } + return (x); + +} /* end of rplacd */ /**********************************************************************/ /* - Func name : N_OP_car + Func name : N_OP_car - car management + car management - Date : March 21, 1988 - Edited by : Robert Krivacic + Date : March 21, 1988 + Edited by : Robert Krivacic */ /**********************************************************************/ -LispPTR N_OP_car(register LispPTR tos) -{ - register ConsCell *datum68k; - register ConsCell *temp; - - datum68k = (ConsCell *)(Addr68k_from_LADDR(tos)); - if (Listp(tos)) - { - if (datum68k->cdr_code == CDR_INDIRECT) - { - temp = (ConsCell *)Addr68k_from_LADDR(datum68k->car_field); - return((LispPTR) temp->car_field); - } - else return((LispPTR) datum68k->car_field); - } - else if (tos == NIL_PTR) return(tos); - else if ( tos == ATOM_T) return(tos); - else - { - ERROR_EXIT(tos); - } - } /* end of N_OP_car */ - - +LispPTR N_OP_car(register LispPTR tos) { + register ConsCell *datum68k; + register ConsCell *temp; + datum68k = (ConsCell *)(Addr68k_from_LADDR(tos)); + if (Listp(tos)) { + if (datum68k->cdr_code == CDR_INDIRECT) { + temp = (ConsCell *)Addr68k_from_LADDR(datum68k->car_field); + return ((LispPTR)temp->car_field); + } else + return ((LispPTR)datum68k->car_field); + } else if (tos == NIL_PTR) + return (tos); + else if (tos == ATOM_T) + return (tos); + else { + ERROR_EXIT(tos); + } +} /* end of N_OP_car */ /**********************************************************************/ /* - Func name : N_OP_cdr + Func name : N_OP_cdr - cdr management + cdr management - Date : March 21, 1988 - Edited by : Robert Krivacic + Date : March 21, 1988 + Edited by : Robert Krivacic */ /**********************************************************************/ -LispPTR N_OP_cdr(register LispPTR tos) -{ - register ConsCell *datum68k; - register DLword cdr_code; - register ConsCell *temp; +LispPTR N_OP_cdr(register LispPTR tos) { + register ConsCell *datum68k; + register DLword cdr_code; + register ConsCell *temp; - datum68k = (ConsCell *)(Addr68k_from_LADDR(tos)); - cdr_code = datum68k->cdr_code; + datum68k = (ConsCell *)(Addr68k_from_LADDR(tos)); + cdr_code = datum68k->cdr_code; - if (Listp(tos)) - { - if (cdr_code == CDR_NIL) return(NIL_PTR); /* cdr-nil */ + if (Listp(tos)) { + if (cdr_code == CDR_NIL) + return (NIL_PTR); /* cdr-nil */ - else if (cdr_code > CDR_ONPAGE) /* cdr-samepage */ + else if (cdr_code > CDR_ONPAGE) /* cdr-samepage */ #ifdef NEWCDRCODING - return(tos + ((cdr_code & 7) << 1)); + return (tos + ((cdr_code & 7) << 1)); #else - return(POINTER_PAGEBASE(tos) + ((cdr_code & 127) << 1)); + return (POINTER_PAGEBASE(tos) + ((cdr_code & 127) << 1)); +#endif /*NEWCDRCODING */ + else if (cdr_code == CDR_INDIRECT) /* cdr_code < CDR_ONPAGE */ + /* cdr-indirect */ + return (cdr((LispPTR)(datum68k->car_field))); + + else { +/* cdr-differentpage */ + +#ifdef NEWCDRCODING + return ((LispPTR)((ConsCell *)(Addr68k_from_LADDR(tos + (cdr_code << 1))))->car_field); +#else + return ((LispPTR)((ConsCell *)(Addr68k_from_LADDR(POINTER_PAGEBASE(tos) + (cdr_code << 1)))) + ->car_field); #endif /*NEWCDRCODING */ - else if (cdr_code == CDR_INDIRECT) /* cdr_code < CDR_ONPAGE */ - /* cdr-indirect */ - return(cdr ((LispPTR)(datum68k->car_field))); - - else - { - /* cdr-differentpage */ - -#ifdef NEWCDRCODING - return((LispPTR) - ((ConsCell *) - (Addr68k_from_LADDR - (tos+(cdr_code << 1))))->car_field); -#else - return((LispPTR) - ((ConsCell *) - (Addr68k_from_LADDR - (POINTER_PAGEBASE(tos)+(cdr_code << 1))))->car_field); -#endif /*NEWCDRCODING */ - } - } - else if (tos == NIL_PTR) return(tos); - else - { - ERROR_EXIT(tos); - } - - - } /* end of N_OP_cdr */ - - + } + } else if (tos == NIL_PTR) + return (tos); + else { + ERROR_EXIT(tos); + } +} /* end of N_OP_cdr */ /**********************************************************************/ /* - Func name : N_OP_rplaca + Func name : N_OP_rplaca - rplaca management + rplaca management - Date : March 21, 1988 - Edited by : Robert Krivacic + Date : March 21, 1988 + Edited by : Robert Krivacic */ /**********************************************************************/ -LispPTR N_OP_rplaca(register LispPTR tosm1, register LispPTR tos) -{ - register ConsCell *x_68k; - register ConsCell *temp; +LispPTR N_OP_rplaca(register LispPTR tosm1, register LispPTR tos) { + register ConsCell *x_68k; + register ConsCell *temp; - if (Listp(tosm1) == NIL) - { - if (tosm1 == NIL_PTR) - { - if (tos != NIL_PTR) ERROR_EXIT(tos) - else return(tosm1); - } - else ERROR_EXIT(tos); - } + if (Listp(tosm1) == NIL) { + if (tosm1 == NIL_PTR) { + if (tos != NIL_PTR) + ERROR_EXIT(tos) + else + return (tosm1); + } else + ERROR_EXIT(tos); + } - else - { - x_68k = (ConsCell *)Addr68k_from_LADDR(tosm1); - - GCLOOKUP(car(tosm1), DELREF); /* set up reference count */ - GCLOOKUP(tos, ADDREF); - - if (x_68k->cdr_code == CDR_INDIRECT) - { - temp = (ConsCell *)Addr68k_from_LADDR - ((LispPTR)x_68k->car_field); - temp->car_field = tos; - } - else x_68k->car_field = tos ; - - return(tosm1); - } - } /* end of N_OP_rplaca */ + else { + x_68k = (ConsCell *)Addr68k_from_LADDR(tosm1); + GCLOOKUP(car(tosm1), DELREF); /* set up reference count */ + GCLOOKUP(tos, ADDREF); + if (x_68k->cdr_code == CDR_INDIRECT) { + temp = (ConsCell *)Addr68k_from_LADDR((LispPTR)x_68k->car_field); + temp->car_field = tos; + } else + x_68k->car_field = tos; + return (tosm1); + } +} /* end of N_OP_rplaca */ /**********************************************************************/ /* - Func name : N_OP_rplacd + Func name : N_OP_rplacd - rplacd management + rplacd management - Date : March 21, 1988 - Edited by : Robert Krivacic + Date : March 21, 1988 + Edited by : Robert Krivacic */ /**********************************************************************/ -LispPTR N_OP_rplacd(register LispPTR tosm1, register LispPTR tos) -{ +LispPTR N_OP_rplacd(register LispPTR tosm1, register LispPTR tos) { + if (Listp(tosm1) == NIL) { + if (tosm1 == NIL_PTR) { + if (tos != NIL_PTR) + ERROR_EXIT(tos) + else + return (tosm1); + } else + ERROR_EXIT(tos); + } - if (Listp(tosm1) == NIL) - { - if (tosm1 == NIL_PTR) - { - if (tos != NIL_PTR) ERROR_EXIT(tos) - else return(tosm1); - } - else ERROR_EXIT(tos); - } - - else rplacd(tosm1, tos); - - return(tosm1); - - }/* end of N_OP_rplacd */ + else + rplacd(tosm1, tos); + return (tosm1); +} /* end of N_OP_rplacd */ /************************************************************************/ /* */ @@ -553,32 +489,27 @@ LispPTR N_OP_rplacd(register LispPTR tosm1, register LispPTR tos) /* */ /************************************************************************/ -ConsCell * find_close_cell(struct conspage *page, LispPTR oldcell) -{ - unsigned oldoffset = oldcell & 0xFF; - unsigned offset = page->next_cell; - unsigned prior = 0; +ConsCell *find_close_cell(struct conspage *page, LispPTR oldcell) { + unsigned oldoffset = oldcell & 0xFF; + unsigned offset = page->next_cell; + unsigned prior = 0; - while (offset) - { - if ((offset > oldoffset) && (offset <= (oldoffset+14))) - { - if (prior) - ((freecons *) ((DLword *)page + prior))->next_free - = ((freecons *) ((DLword *)page + offset))->next_free; - else page->next_cell - = ((freecons *) ((DLword *)page + offset))->next_free; - page->count -= 1; - return(ConsCell *)((DLword *)page + offset); - } + while (offset) { + if ((offset > oldoffset) && (offset <= (oldoffset + 14))) { + if (prior) + ((freecons *)((DLword *)page + prior))->next_free = + ((freecons *)((DLword *)page + offset))->next_free; + else + page->next_cell = ((freecons *)((DLword *)page + offset))->next_free; + page->count -= 1; + return (ConsCell *)((DLword *)page + offset); + } - prior = offset; - offset = ((freecons *) ((DLword *)page + offset))->next_free; - } - return((ConsCell *)0); /* No cell close enough */ + prior = offset; + offset = ((freecons *)((DLword *)page + offset))->next_free; } - - + return ((ConsCell *)0); /* No cell close enough */ +} /************************************************************************/ /* */ @@ -594,47 +525,39 @@ ConsCell * find_close_cell(struct conspage *page, LispPTR oldcell) /* */ /************************************************************************/ -ConsCell * find_close_prior_cell(struct conspage *page, LispPTR oldcell) -{ - unsigned oldoffset = oldcell & 0xFF; - unsigned offset = page->next_cell; - unsigned prior = 0; - unsigned noffset, poffset; - unsigned nprior = 0; - ConsCell *cell; +ConsCell *find_close_prior_cell(struct conspage *page, LispPTR oldcell) { + unsigned oldoffset = oldcell & 0xFF; + unsigned offset = page->next_cell; + unsigned prior = 0; + unsigned noffset, poffset; + unsigned nprior = 0; + ConsCell *cell; - while (offset) - { - if ((offset < oldoffset) && (offset >= (oldoffset-14))) - { - poffset = offset; - noffset = FREECONS(page, offset)->next_free; - while ((noffset>offset) && (noffset < oldoffset)) - { - prior = offset; - offset = noffset; - noffset = FREECONS(page, offset)->next_free; - } - cell = (ConsCell *)((DLword *)page + offset); - if (prior) - FREECONS(page, prior)->next_free = - FREECONS(page,offset)->next_free; - else page->next_cell - = FREECONS(page,offset)->next_free; - page->count -= 1; - cell->cdr_code = CDR_ONPAGE | ((oldoffset - offset)>>1); - if (254 < (offset + ((cell->cdr_code&7)<<1))) error("in fcpc, page overflow."); - return(cell); - } - - prior = offset; - offset = ((freecons *) ((DLword *)page + offset))->next_free; + while (offset) { + if ((offset < oldoffset) && (offset >= (oldoffset - 14))) { + poffset = offset; + noffset = FREECONS(page, offset)->next_free; + while ((noffset > offset) && (noffset < oldoffset)) { + prior = offset; + offset = noffset; + noffset = FREECONS(page, offset)->next_free; } - return((ConsCell *)0); /* No cell close enough */ + cell = (ConsCell *)((DLword *)page + offset); + if (prior) + FREECONS(page, prior)->next_free = FREECONS(page, offset)->next_free; + else + page->next_cell = FREECONS(page, offset)->next_free; + page->count -= 1; + cell->cdr_code = CDR_ONPAGE | ((oldoffset - offset) >> 1); + if (254 < (offset + ((cell->cdr_code & 7) << 1))) error("in fcpc, page overflow."); + return (cell); + } + + prior = offset; + offset = ((freecons *)((DLword *)page + offset))->next_free; } - - - + return ((ConsCell *)0); /* No cell close enough */ +} /************************************************************************/ /* */ @@ -644,76 +567,71 @@ ConsCell * find_close_prior_cell(struct conspage *page, LispPTR oldcell) /* */ /************************************************************************/ -ConsCell *find_cdrpair_in_page(struct conspage *pg, LispPTR carpart, LispPTR cdrpart) -{ - ConsCell *cell; - unsigned offset, prior, priorprior, nprior, poffset, noffset; +ConsCell *find_cdrpair_in_page(struct conspage *pg, LispPTR carpart, LispPTR cdrpart) { + ConsCell *cell; + unsigned offset, prior, priorprior, nprior, poffset, noffset; - prior = priorprior = nprior = 0; + prior = priorprior = nprior = 0; - if (pg->count < 2) return (ConsCell * ) 0; + if (pg->count < 2) return (ConsCell *)0; - offset = pg->next_cell; + offset = pg->next_cell; - while (offset) - { - if (prior && (offset < prior) && (prior <= offset+14)) - { - ConsCell *carcell, *cdrcell; + while (offset) { + if (prior && (offset < prior) && (prior <= offset + 14)) { + ConsCell *carcell, *cdrcell; - poffset = offset; - noffset = FREECONS(pg, offset)->next_free; - while ((noffset>offset) && (noffset < prior)) - { - nprior = offset; - poffset = prior; - offset = noffset; - noffset = FREECONS(pg, offset)->next_free; - } - - carcell = (ConsCell *) (((DLword *)pg) + offset); - cdrcell = (ConsCell *) (((DLword *)pg) + prior); - if (priorprior) - FREECONS(pg, priorprior)->next_free = FREECONS(pg,poffset)->next_free; - else pg->next_cell = FREECONS(pg,poffset)->next_free; - - if (nprior) FREECONS(pg,nprior)->next_free = - FREECONS(pg,offset)->next_free; - - pg->count -= 2; - - *(LispPTR *)carcell = carpart; - *(LispPTR *)cdrcell = cdrpart; - - carcell->cdr_code = (cdrcell-carcell); - return(carcell); - } - else if (prior && (offset > prior) && (offset <= prior+14)) - { - ConsCell *carcell, *cdrcell; - - carcell = (ConsCell *) (((DLword *)pg) + prior); - cdrcell = (ConsCell *) (((DLword *)pg) + offset); - if (priorprior) - FREECONS(pg, priorprior)->next_free = ((freecons *)cdrcell)->next_free; - else pg->next_cell = ((freecons *)cdrcell)->next_free; - - pg->count -= 2; - - *(LispPTR *)carcell = carpart; - *(LispPTR *)cdrcell = cdrpart; - - carcell->cdr_code = (cdrcell-carcell); - return(carcell); - } - priorprior = prior; - prior = offset; - offset = FREECONS(pg, offset)->next_free; + poffset = offset; + noffset = FREECONS(pg, offset)->next_free; + while ((noffset > offset) && (noffset < prior)) { + nprior = offset; + poffset = prior; + offset = noffset; + noffset = FREECONS(pg, offset)->next_free; } - return(0); /* found no entries in this page, so return failure code */ + carcell = (ConsCell *)(((DLword *)pg) + offset); + cdrcell = (ConsCell *)(((DLword *)pg) + prior); + if (priorprior) + FREECONS(pg, priorprior)->next_free = FREECONS(pg, poffset)->next_free; + else + pg->next_cell = FREECONS(pg, poffset)->next_free; + + if (nprior) FREECONS(pg, nprior)->next_free = FREECONS(pg, offset)->next_free; + + pg->count -= 2; + + *(LispPTR *)carcell = carpart; + *(LispPTR *)cdrcell = cdrpart; + + carcell->cdr_code = (cdrcell - carcell); + return (carcell); + } else if (prior && (offset > prior) && (offset <= prior + 14)) { + ConsCell *carcell, *cdrcell; + + carcell = (ConsCell *)(((DLword *)pg) + prior); + cdrcell = (ConsCell *)(((DLword *)pg) + offset); + if (priorprior) + FREECONS(pg, priorprior)->next_free = ((freecons *)cdrcell)->next_free; + else + pg->next_cell = ((freecons *)cdrcell)->next_free; + + pg->count -= 2; + + *(LispPTR *)carcell = carpart; + *(LispPTR *)cdrcell = cdrpart; + + carcell->cdr_code = (cdrcell - carcell); + return (carcell); + } + priorprior = prior; + prior = offset; + offset = FREECONS(pg, offset)->next_free; } + return (0); /* found no entries in this page, so return failure code */ +} + /************************************************************************/ /* */ /* */ @@ -722,17 +640,15 @@ ConsCell *find_cdrpair_in_page(struct conspage *pg, LispPTR carpart, LispPTR cdr /* */ /************************************************************************/ -ConsCell *find_cdrable_pair(LispPTR carpart, LispPTR cdrpart) -{ - unsigned offset, prior, priorprior, pgno; - struct conspage *pg; - ConsCell *cell; +ConsCell *find_cdrable_pair(LispPTR carpart, LispPTR cdrpart) { + unsigned offset, prior, priorprior, pgno; + struct conspage *pg; + ConsCell *cell; - for ( pg = (struct conspage *)Addr68k_from_LPAGE(pgno = ListpDTD->dtd_nextpage); - pgno; pg = (struct conspage *)Addr68k_from_LPAGE(pgno = pg->next_page)) - { - if ((cell = find_cdrpair_in_page(pg, carpart, cdrpart))) return (cell); - } - - return (find_cdrpair_in_page(next_conspage(), carpart, cdrpart)); + for (pg = (struct conspage *)Addr68k_from_LPAGE(pgno = ListpDTD->dtd_nextpage); pgno; + pg = (struct conspage *)Addr68k_from_LPAGE(pgno = pg->next_page)) { + if ((cell = find_cdrpair_in_page(pg, carpart, cdrpart))) return (cell); } + + return (find_cdrpair_in_page(next_conspage(), carpart, cdrpart)); +} diff --git a/src/cdaudio.c b/src/cdaudio.c old mode 100755 new mode 100644 index caf211b..a49c35e --- a/src/cdaudio.c +++ b/src/cdaudio.c @@ -1,8 +1,7 @@ -/* $Id: cdaudio.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: cdaudio.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: cdaudio.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,10 +16,9 @@ static char *id = "$Id: cdaudio.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyr #include "version.h" - /*********************************** - file: cdaudio.c + file: cdaudio.c ***********************************/ @@ -36,346 +34,279 @@ static char *id = "$Id: cdaudio.c,v 1.3 1999/05/31 23:35:25 sybalsky Exp $ Copyr #include "arith.h" #include "cdrom.h" +int cdaudio(LispPTR *args) { + int request; + int res; -int cdaudio(LispPTR *args) -{ - int request; - int res; - - - N_GETNUMBER(args[0], request, BAD_ARG); + N_GETNUMBER(args[0], request, BAD_ARG); #ifdef DEBUG - printf("CD-ROM function called. function = %d\n",request); + printf("CD-ROM function called. function = %d\n", request); #endif - switch(request){ - case CD_OPEN: - res = cd_open(args); - break; - case CD_CLOSE: - res = cd_close(args); - break; - case CD_READ: - res = cd_read(args); - break; - case CD_DISK_INFO: - res = cd_disk_info(args); - break; - case CD_TRACK_INFO: - res = cd_track_info(args); - break; - case CD_START: - res = cd_start(args); - break; - case CD_STOP: - res = cd_stop(args); - break; - case CD_PLAY: - res = cd_play(args); - break; - case CD_Q_READ: - res = cd_q_read(args); - break; - case CD_PAUSE: - res = cd_pause(args); - break; - case CD_RESUME: - res = cd_resume(args); - break; - case CD_VOLUME: - res = cd_volume(args); - break; - case CD_EJECT: - res = cd_eject(args); - break; - default: - return(NIL); - break; - } + switch (request) { + case CD_OPEN: res = cd_open(args); break; + case CD_CLOSE: res = cd_close(args); break; + case CD_READ: res = cd_read(args); break; + case CD_DISK_INFO: res = cd_disk_info(args); break; + case CD_TRACK_INFO: res = cd_track_info(args); break; + case CD_START: res = cd_start(args); break; + case CD_STOP: res = cd_stop(args); break; + case CD_PLAY: res = cd_play(args); break; + case CD_Q_READ: res = cd_q_read(args); break; + case CD_PAUSE: res = cd_pause(args); break; + case CD_RESUME: res = cd_resume(args); break; + case CD_VOLUME: res = cd_volume(args); break; + case CD_EJECT: res = cd_eject(args); break; + default: return (NIL); break; + } #ifdef DEBUG - printf( "Result = %d\n",res ); + printf("Result = %d\n", res); #endif - if ( res == 0 ) { - return(ATOM_T); - } else { - return( GetSmallp(res) ); - } + if (res == 0) { + return (ATOM_T); + } else { + return (GetSmallp(res)); + } - BAD_ARG: - return(NIL); +BAD_ARG: + return (NIL); } int cd_open(LispPTR *args) - + /* - args[0] function number - args[1] CD-ROM drive path name string + args[0] function number + args[1] CD-ROM drive path name string */ { - char drive[80]; + char drive[80]; - LispStringToCString(args[1], drive, 80); + LispStringToCString(args[1], drive, 80); #ifdef DEBUG - printf( "cd_open called. drive = %s\n", drive ); + printf("cd_open called. drive = %s\n", drive); #endif - return( CDopen(drive) ); + return (CDopen(drive)); } int cd_close(LispPTR *args) - + /* - args[0] function number + args[0] function number */ { #ifdef DEBUG - printf("cd_close is called\n"); + printf("cd_close is called\n"); #endif - return( CDclose() ); + return (CDclose()); } int cd_read(LispPTR *args) - + /* - args[0] function number - args[1] Logical block number - args[2] number of blocks to read - args[3] data buffer + args[0] function number + args[1] Logical block number + args[2] number of blocks to read + args[3] data buffer */ { - DWORD blk; - int num; - BYTE *buf; - LispPTR *naddress; - char *base; - int offset; + DWORD blk; + int num; + BYTE *buf; + LispPTR *naddress; + char *base; + int offset; - switch( GetTypeNumber(args[1]) ) { - case TYPE_SMALLP: - N_GETNUMBER( args[1], blk, BAD_ARG ); - break; - case TYPE_FIXP: - blk = *(DWORD *)(Addr68k_from_LADDR(args[1])); - break; - default: - return(1); - break; - } - switch( GetTypeNumber(args[2]) ) { - case TYPE_SMALLP: - N_GETNUMBER( args[2], num, BAD_ARG ); - break; - case TYPE_FIXP: - num = *(DWORD *)(Addr68k_from_LADDR(args[2])); - break; - default: - return(1); - break; - } - if (GetTypeNumber(args[3]) == TYPE_ONED_ARRAY ){ - naddress = (LispPTR *)(Addr68k_from_LADDR(args[3])); - base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); - offset = (int)(((OneDArray *)naddress)->offset); - buf = base + offset; - } else - return(1); + switch (GetTypeNumber(args[1])) { + case TYPE_SMALLP: N_GETNUMBER(args[1], blk, BAD_ARG); break; + case TYPE_FIXP: blk = *(DWORD *)(Addr68k_from_LADDR(args[1])); break; + default: return (1); break; + } + switch (GetTypeNumber(args[2])) { + case TYPE_SMALLP: N_GETNUMBER(args[2], num, BAD_ARG); break; + case TYPE_FIXP: num = *(DWORD *)(Addr68k_from_LADDR(args[2])); break; + default: return (1); break; + } + if (GetTypeNumber(args[3]) == TYPE_ONED_ARRAY) { + naddress = (LispPTR *)(Addr68k_from_LADDR(args[3])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buf = base + offset; + } else + return (1); #ifdef DEBUG - printf("call CDread()\n"); - printf("blk = %d, num = %d buff = %d\n",blk,num,buf); + printf("call CDread()\n"); + printf("blk = %d, num = %d buff = %d\n", blk, num, buf); #endif - return( CDread(blk, num, buf) ); - BAD_ARG: - return(1); + return (CDread(blk, num, buf)); +BAD_ARG: + return (1); } int cd_disk_info(LispPTR *args) - + /* - args[0] function number - args[1] min tune number - args[2] max tune number + args[0] function number + args[1] min tune number + args[2] max tune number */ { - BYTE min_no, max_no; - int res; + BYTE min_no, max_no; + int res; - res = CDdisk_info(&min_no, &max_no); + res = CDdisk_info(&min_no, &max_no); #ifdef DEBUG - printf( "min = %d, max = %d",min_no,max_no); + printf("min = %d, max = %d", min_no, max_no); #endif - *(int *)(Addr68k_from_LADDR(args[1])) = (int)min_no; - *(int *)(Addr68k_from_LADDR(args[2])) = (int)max_no; - return(res); + *(int *)(Addr68k_from_LADDR(args[1])) = (int)min_no; + *(int *)(Addr68k_from_LADDR(args[2])) = (int)max_no; + return (res); } int cd_track_info(LispPTR *args) - + /* - args[0] function number (in: smallp) - args[1] tune number (in: fixp) - args[2] start address(LBN) (out: fixp) - args[3] control data (out: fixp) + args[0] function number (in: smallp) + args[1] tune number (in: fixp) + args[2] start address(LBN) (out: fixp) + args[3] control data (out: fixp) */ { - int tno; - DWORD blk; - BYTE cntl; - int res; + int tno; + DWORD blk; + BYTE cntl; + int res; - switch( GetTypeNumber(args[1]) ) { - case TYPE_SMALLP: - N_GETNUMBER( args[1], tno, BAD_ARG ); - break; - case TYPE_FIXP: - tno = *(DWORD *)(Addr68k_from_LADDR(args[1])); - break; - } - res = CDtrack_info(tno, &blk, &cntl); - *(int *)(Addr68k_from_LADDR(args[2])) = (int)blk; - *(int *)(Addr68k_from_LADDR(args[3])) = (int)cntl; - return(res); + switch (GetTypeNumber(args[1])) { + case TYPE_SMALLP: N_GETNUMBER(args[1], tno, BAD_ARG); break; + case TYPE_FIXP: tno = *(DWORD *)(Addr68k_from_LADDR(args[1])); break; + } + res = CDtrack_info(tno, &blk, &cntl); + *(int *)(Addr68k_from_LADDR(args[2])) = (int)blk; + *(int *)(Addr68k_from_LADDR(args[3])) = (int)cntl; + return (res); - BAD_ARG: - return( -1 ); +BAD_ARG: + return (-1); } int cd_start(LispPTR *args) - + /* - args[0] function number + args[0] function number */ { - return( CDstart() ); + return (CDstart()); } int cd_stop(LispPTR *args) - + /* - args[0] function number + args[0] function number */ { - return( CDstop() ); + return (CDstop()); } int cd_play(LispPTR *args) - + /* - args[0] function number - args[1] play start address(LBN) - args[2] play end address(LBN) + args[0] function number + args[1] play start address(LBN) + args[2] play end address(LBN) */ { - DWORD sblk, eblk; + DWORD sblk, eblk; - switch( GetTypeNumber(args[1])) { - case TYPE_SMALLP: - N_GETNUMBER(args[1], sblk, BAD_ARG); - break; - case TYPE_FIXP: - sblk = *(DWORD *)(Addr68k_from_LADDR(args[1])); - break; - } - switch( GetTypeNumber(args[2])) { - case TYPE_SMALLP: - N_GETNUMBER(args[2], eblk, BAD_ARG); - break; - case TYPE_FIXP: - eblk = *(DWORD *)(Addr68k_from_LADDR(args[2])); - break; - } - return( CDplay(sblk, eblk) ); + switch (GetTypeNumber(args[1])) { + case TYPE_SMALLP: N_GETNUMBER(args[1], sblk, BAD_ARG); break; + case TYPE_FIXP: sblk = *(DWORD *)(Addr68k_from_LADDR(args[1])); break; + } + switch (GetTypeNumber(args[2])) { + case TYPE_SMALLP: N_GETNUMBER(args[2], eblk, BAD_ARG); break; + case TYPE_FIXP: eblk = *(DWORD *)(Addr68k_from_LADDR(args[2])); break; + } + return (CDplay(sblk, eblk)); - BAD_ARG: - return(1); +BAD_ARG: + return (1); } int cd_q_read(LispPTR *args) - + /* - args[0] function number - args[1] audio status - args[2] tune number - args[3] current position min - args[4] current position sec - args[5] current position frame + args[0] function number + args[1] audio status + args[2] tune number + args[3] current position min + args[4] current position sec + args[5] current position frame */ { - BYTE ast, tno, mm, ss, ff; - int res; - - res = CDqread(&ast, &tno, &mm, &ss, &ff); - if ( !res ) { - *(int *)(Addr68k_from_LADDR(args[1])) = (int)ast; - *(int *)(Addr68k_from_LADDR(args[2])) = (int)tno; - *(int *)(Addr68k_from_LADDR(args[3])) = (int)mm; - *(int *)(Addr68k_from_LADDR(args[4])) = (int)ss; - *(int *)(Addr68k_from_LADDR(args[5])) = (int)ff; - } - return(res); - + BYTE ast, tno, mm, ss, ff; + int res; + res = CDqread(&ast, &tno, &mm, &ss, &ff); + if (!res) { + *(int *)(Addr68k_from_LADDR(args[1])) = (int)ast; + *(int *)(Addr68k_from_LADDR(args[2])) = (int)tno; + *(int *)(Addr68k_from_LADDR(args[3])) = (int)mm; + *(int *)(Addr68k_from_LADDR(args[4])) = (int)ss; + *(int *)(Addr68k_from_LADDR(args[5])) = (int)ff; + } + return (res); } int cd_pause(LispPTR *args) - + /* - args[0] function number + args[0] function number */ { - return( CDpause() ); + return (CDpause()); } int cd_resume(LispPTR *args) - + /* - args[0] function number + args[0] function number */ { - return( CDresume() ); + return (CDresume()); } int cd_volume(LispPTR *args) - + /* - args[0] function number - args[1] right volume - args[2] left volume + args[0] function number + args[1] right volume + args[2] left volume */ { - int right, left; + int right, left; - switch( GetTypeNumber(args[1])) { - case TYPE_SMALLP: - N_GETNUMBER(args[1], right, BAD_ARG); - break; - case TYPE_FIXP: - right = *(DWORD *)(Addr68k_from_LADDR(args[1])); - break; - } - switch( GetTypeNumber(args[2])) { - case TYPE_SMALLP: - N_GETNUMBER(args[2], left, BAD_ARG); - break; - case TYPE_FIXP: - left = *(DWORD *)(Addr68k_from_LADDR(args[2])); - break; - } - return( CDvolume(right, left) ); + switch (GetTypeNumber(args[1])) { + case TYPE_SMALLP: N_GETNUMBER(args[1], right, BAD_ARG); break; + case TYPE_FIXP: right = *(DWORD *)(Addr68k_from_LADDR(args[1])); break; + } + switch (GetTypeNumber(args[2])) { + case TYPE_SMALLP: N_GETNUMBER(args[2], left, BAD_ARG); break; + case TYPE_FIXP: left = *(DWORD *)(Addr68k_from_LADDR(args[2])); break; + } + return (CDvolume(right, left)); - BAD_ARG: - return(1); +BAD_ARG: + return (1); } int cd_eject(LispPTR *args) - + /* - args[0] function number + args[0] function number */ { #ifdef DEBUG - printf( "cd_eject called.\n"); + printf("cd_eject called.\n"); #endif - return( CDeject() ); + return (CDeject()); } - - diff --git a/src/cdrom.c b/src/cdrom.c old mode 100755 new mode 100644 index 7b5349c..37733c2 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -1,8 +1,6 @@ -/* $Id: cdrom.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: cdrom.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: cdrom.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,10 +15,9 @@ static char *id = "$Id: cdrom.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyrig #include "version.h" - /*********************************** - file: cdrom.c + file: cdrom.c ***********************************/ @@ -36,215 +33,190 @@ static char *id = "$Id: cdrom.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyrig #include "arith.h" #include "cdrom.h" +int cdrom(LispPTR *args) { + int request; + int res; -int cdrom(LispPTR *args) -{ - int request; - int res; - - - N_GETNUMBER(args[0], request, BAD_ARG); + N_GETNUMBER(args[0], request, BAD_ARG); #ifdef DEBUG - printf("CD-ROM function called. function = %d\n",request); + printf("CD-ROM function called. function = %d\n", request); #endif - switch(request){ - case CDROM_INIT_DRV: - res = cdrom_init_drv(args); - break; - case CDROM_KEN_INT: - res = cdrom_ken_int(args); - break; - case CDROM_CHOSAKU: - res = cdrom_chosaku(args); - break; - case CDROM_MIKANA: - res = cdrom_mikana(args); - break; - case CDROM_MIKANAT: - res = cdrom_mikanat(args); - break; - case CDROM_SYURYO: - res = cdrom_syuryo(args); - break; - default: - return(NIL); - break; - } + switch (request) { + case CDROM_INIT_DRV: res = cdrom_init_drv(args); break; + case CDROM_KEN_INT: res = cdrom_ken_int(args); break; + case CDROM_CHOSAKU: res = cdrom_chosaku(args); break; + case CDROM_MIKANA: res = cdrom_mikana(args); break; + case CDROM_MIKANAT: res = cdrom_mikanat(args); break; + case CDROM_SYURYO: res = cdrom_syuryo(args); break; + default: return (NIL); break; + } #ifdef DEBUG - printf( "Result = %d\n",res ); + printf("Result = %d\n", res); #endif - if ( res == 0 ) { - return(ATOM_T); - } else { - return( GetSmallp(res) ); - } + if (res == 0) { + return (ATOM_T); + } else { + return (GetSmallp(res)); + } - BAD_ARG: - return(NIL); +BAD_ARG: + return (NIL); } static int cdrom_init_drv(LispPTR *args) - + /* - args[0] function number - args[1] pointer to buffer - args[2] device name + args[0] function number + args[1] pointer to buffer + args[2] device name */ { - int res; - char *buff; - char drive[80]; - LispPTR *naddress; - char *base; - int offset; + int res; + char *buff; + char drive[80]; + LispPTR *naddress; + char *base; + int offset; - if (GetTypeNumber(args[1]) == TYPE_ONED_ARRAY ){ - naddress = (LispPTR *)(Addr68k_from_LADDR(args[1])); - base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); - offset = (int)(((OneDArray *)naddress)->offset); - buff = &base[offset]; - } else - return(1); - LispStringToCString(args[2], drive, 80); + if (GetTypeNumber(args[1]) == TYPE_ONED_ARRAY) { + naddress = (LispPTR *)(Addr68k_from_LADDR(args[1])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return (1); + LispStringToCString(args[2], drive, 80); - return( init_drv(buff, drive) ); + return (init_drv(buff, drive)); } - static int cdrom_ken_int(LispPTR *args) - + /* - args[0] function number - args[1] shoseki number - args[2] flag for index and sort + args[0] function number + args[1] shoseki number + args[2] flag for index and sort */ { - int bunno; - int flg; + int bunno; + int flg; - N_GETNUMBER(args[1], bunno, BAD_ARG); - N_GETNUMBER(args[2], flg, BAD_ARG); + N_GETNUMBER(args[1], bunno, BAD_ARG); + N_GETNUMBER(args[2], flg, BAD_ARG); #ifdef DEBUG - printf( "bunno = %x\n",bunno ); - printf( "flg = %d\n",flg ); + printf("bunno = %x\n", bunno); + printf("flg = %d\n", flg); #endif - return( ken_int(bunno, flg) ); + return (ken_int(bunno, flg)); - BAD_ARG: - return(1); +BAD_ARG: + return (1); } - static int cdrom_chosaku(LispPTR *args) - + /* - args[0] function number - args[1] buffer for copy right data - args[2] real data size + args[0] function number + args[1] buffer for copy right data + args[2] real data size */ { - char *buff; - int size; - int *data_size; - LispPTR *naddress; - char *base; - int offset; - - if (GetTypeNumber(args[1]) == TYPE_ONED_ARRAY ){ - naddress = (LispPTR *)(Addr68k_from_LADDR(args[1])); - base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); - offset = (int)(((OneDArray *)naddress)->offset); - buff = &base[offset]; - } else - return(1); - size = (int)(((OneDArray *)naddress)->totalsize); -#ifdef DEBUG - printf( "size = %d\n",size ); -#endif - data_size = (int *)(Addr68k_from_LADDR(args[2])); - return( chosaku(buff, size, data_size) ); -} + char *buff; + int size; + int *data_size; + LispPTR *naddress; + char *base; + int offset; + if (GetTypeNumber(args[1]) == TYPE_ONED_ARRAY) { + naddress = (LispPTR *)(Addr68k_from_LADDR(args[1])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return (1); + size = (int)(((OneDArray *)naddress)->totalsize); +#ifdef DEBUG + printf("size = %d\n", size); +#endif + data_size = (int *)(Addr68k_from_LADDR(args[2])); + return (chosaku(buff, size, data_size)); +} static int cdrom_mikana(LispPTR *args) - + /* - args[0] function number - args[1] relative id number - args[2] pointer to retrieve data - args[3] size of retrieve data + args[0] function number + args[1] relative id number + args[2] pointer to retrieve data + args[3] size of retrieve data */ { - int hyono; - char *buff; - int buff_size; - int *data_size; - LispPTR *naddress; - char *base; - int offset; + int hyono; + char *buff; + int buff_size; + int *data_size; + LispPTR *naddress; + char *base; + int offset; - - N_GETNUMBER(args[1], hyono, BAD_ARG); - if (GetTypeNumber(args[2]) == TYPE_ONED_ARRAY ){ - naddress = (LispPTR *)(Addr68k_from_LADDR(args[2])); - base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); - offset = (int)(((OneDArray *)naddress)->offset); - buff = &base[offset]; - } else - return(1); - buff_size = (int)(((OneDArray *)naddress)->totalsize); - data_size = (int *)(Addr68k_from_LADDR(args[3])); - return( mikana(hyono, buff, buff_size, data_size) ); + N_GETNUMBER(args[1], hyono, BAD_ARG); + if (GetTypeNumber(args[2]) == TYPE_ONED_ARRAY) { + naddress = (LispPTR *)(Addr68k_from_LADDR(args[2])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return (1); + buff_size = (int)(((OneDArray *)naddress)->totalsize); + data_size = (int *)(Addr68k_from_LADDR(args[3])); + return (mikana(hyono, buff, buff_size, data_size)); - BAD_ARG: - return(1); +BAD_ARG: + return (1); } - static int cdrom_mikanat(LispPTR *args) - + /* - args[0] function number - args[1] pointer to a search key - args[2] pointer to buffer - args[3] size of searched data - args[4] nuber of items matched to the search key + args[0] function number + args[1] pointer to a search key + args[2] pointer to buffer + args[3] size of searched data + args[4] nuber of items matched to the search key */ { - char key[65]; - char *buff; - int buff_size; - int *data_size; - int *hitn; - LispPTR *naddress; - char *base; - int offset; + char key[65]; + char *buff; + int buff_size; + int *data_size; + int *hitn; + LispPTR *naddress; + char *base; + int offset; - - LispStringToCString2(args[1], key, 65); - if (GetTypeNumber(args[2]) == TYPE_ONED_ARRAY ){ - naddress = (LispPTR *)(Addr68k_from_LADDR(args[2])); - base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); - offset = (int)(((OneDArray *)naddress)->offset); - buff = &base[offset]; - } else - return(1); - buff_size = (((OneDArray *)naddress)->totalsize); - data_size = (int *)(Addr68k_from_LADDR(args[3])); - hitn = (int *)(Addr68k_from_LADDR(args[4])); + LispStringToCString2(args[1], key, 65); + if (GetTypeNumber(args[2]) == TYPE_ONED_ARRAY) { + naddress = (LispPTR *)(Addr68k_from_LADDR(args[2])); + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); + offset = (int)(((OneDArray *)naddress)->offset); + buff = &base[offset]; + } else + return (1); + buff_size = (((OneDArray *)naddress)->totalsize); + data_size = (int *)(Addr68k_from_LADDR(args[3])); + hitn = (int *)(Addr68k_from_LADDR(args[4])); - return( mikanat(key, buff, buff_size, data_size, hitn) ); + return (mikanat(key, buff, buff_size, data_size, hitn)); } - static int cdrom_syuryo(LispPTR *args) - + /* - args[0] function number + args[0] function number */ { - return( syuryo() ); + return (syuryo()); } - diff --git a/src/chardev.c b/src/chardev.c old mode 100755 new mode 100644 index 452b133..6b79b6e --- a/src/chardev.c +++ b/src/chardev.c @@ -1,9 +1,7 @@ -/* $Id: chardev.c,v 1.2 1999/01/03 02:06:50 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: chardev.c,v 1.2 1999/01/03 02:06:50 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: chardev.c,v 1.2 1999/01/03 02:06:50 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,7 +16,6 @@ static char *id = "$Id: chardev.c,v 1.2 1999/01/03 02:06:50 sybalsky Exp $ Copyr #include "version.h" - /************************************************************************/ /* */ /* C H A R A C T E R - D E V I C E S U P P O R T */ @@ -27,53 +24,49 @@ static char *id = "$Id: chardev.c,v 1.2 1999/01/03 02:06:50 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #ifndef DOS #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifndef OS5 #ifndef FREEBSD -#include +#include #endif /* FREEBSD */ #endif /* OS5 */ #ifndef HPUX #ifndef OS5 -#include +#include #endif /* OS5 */ #endif /* HPUX */ -#include +#include #else /* DOS */ #include #endif /* DOS */ -#include -#include -#include -#include +#include +#include +#include +#include #include "lispemul.h" -#include "lispmap.h" -#include "adr68k.h" -#include "lsptypes.h" -#include "arith.h" -#include "timeout.h" -#include "locfile.h" -#include "osmsg.h" -#include "dbprint.h" - +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "timeout.h" +#include "locfile.h" +#include "osmsg.h" +#include "dbprint.h" #if defined(ISC) || defined(FREEBSD) -#include +#include #endif -extern int* Lisp_errno; -extern int Dummy_errno; - - +extern int *Lisp_errno; +extern int Dummy_errno; /************************************************************************/ /* */ @@ -90,79 +83,63 @@ extern int Dummy_errno; /* */ /************************************************************************/ -LispPTR CHAR_openfile(args) - register LispPTR *args; - /* args[0] fullname */ - /* args[1] access */ - /* args[2] errno */ - { +LispPTR CHAR_openfile(args) register LispPTR *args; +/* args[0] fullname */ +/* args[1] access */ +/* args[2] errno */ +{ #ifndef DOS - register int id; /* return value of open system call. */ - register int flags; /* open system call's argument */ - register int rval; - register int linkflag =0; - register int *bufp; - struct stat statbuf; - char pathname[MAXPATHLEN]; + register int id; /* return value of open system call. */ + register int flags; /* open system call's argument */ + register int rval; + register int linkflag = 0; + register int *bufp; + struct stat statbuf; + char pathname[MAXPATHLEN]; #if (defined(RS6000) || defined(HPUX)) - static int one=1; /* Used in charopenfile, etc. */ + static int one = 1; /* Used in charopenfile, etc. */ #endif + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - - LispStringToCString(args[0], pathname, MAXPATHLEN); - flags = O_NDELAY; - ERRSETJMP(NIL); -/* TIMEOUT( rval=stat(pathname, &statbuf) ); - if(rval == 0){ } */ - switch(args[1]) - { - case ACCESS_INPUT: - flags |= O_RDONLY; - break; - case ACCESS_OUTPUT: - flags |= (O_WRONLY | O_CREAT); - break; - case ACCESS_APPEND: - flags |= (O_APPEND | O_RDWR | O_CREAT); - break; - case ACCESS_BOTH: - flags |= (O_RDWR | O_CREAT); - break; - default: - return(NIL); - } - TIMEOUT( id=open(pathname, flags) ); - if(id == -1) - { - err_mess("open", errno); - *Lisp_errno = errno; - return(NIL); - } - /* Prevent I/O requests from blocking -- make them error */ - /* if no char is available, or there's no room in pipe. */ + LispStringToCString(args[0], pathname, MAXPATHLEN); + flags = O_NDELAY; + ERRSETJMP(NIL); + /* TIMEOUT( rval=stat(pathname, &statbuf) ); + if(rval == 0){ } */ + switch (args[1]) { + case ACCESS_INPUT: flags |= O_RDONLY; break; + case ACCESS_OUTPUT: flags |= (O_WRONLY | O_CREAT); break; + case ACCESS_APPEND: flags |= (O_APPEND | O_RDWR | O_CREAT); break; + case ACCESS_BOTH: flags |= (O_RDWR | O_CREAT); break; + default: return (NIL); + } + TIMEOUT(id = open(pathname, flags)); + if (id == -1) { + err_mess("open", errno); + *Lisp_errno = errno; + return (NIL); + } +/* Prevent I/O requests from blocking -- make them error */ +/* if no char is available, or there's no room in pipe. */ #ifdef RS6000 - ioctl(id, FIONBIO, &one); - fcntl(id, F_SETOWN, getpid()); + ioctl(id, FIONBIO, &one); + fcntl(id, F_SETOWN, getpid()); #else #ifdef HPUX - ioctl(id, FIOSNBIO, &one); + ioctl(id, FIOSNBIO, &one); #else - rval = fcntl(id, F_GETFL, 0); - rval |= FNDELAY; - rval = fcntl(id, F_SETFL, rval); + rval = fcntl(id, F_GETFL, 0); + rval |= FNDELAY; + rval = fcntl(id, F_SETFL, rval); #endif /* HPUX */ #endif /* RS6000 */ - return(GetSmallp(id)); + return (GetSmallp(id)); #endif /* DOS */ - - } - - +} /************************************************************************/ /* */ @@ -178,40 +155,34 @@ LispPTR CHAR_openfile(args) /* */ /************************************************************************/ -LispPTR CHAR_closefile(args) - register LispPTR *args; - /* args[0] id */ - /* args[1] errno */ - { +LispPTR CHAR_closefile(args) register LispPTR *args; +/* args[0] id */ +/* args[1] errno */ +{ #ifndef DOS - register int id; /* FileID */ - register int rval; - char pathname[MAXPATHLEN]; - Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); - id = LispNumToCInt(args[0]); - ERRSETJMP(NIL); - TIMEOUT( rval=close(id) ); - if( rval == -1) - { - /** This if is a patch for an apparent problem **/ - /** in SunOS 4 that causes a close on /dev/ttya **/ - /** to error with 'not owner' **/ - if (errno == 1) - { - DBPRINT(("Got errno 1 on a CLOSE!")); - return(ATOM_T); - } - DBPRINT(("Closing char device descriptor #%d.\n", id)); - err_mess("close", errno); - *Lisp_errno = errno; - return(NIL); - } - return(ATOM_T); -#endif /* DOS */ - + register int id; /* FileID */ + register int rval; + char pathname[MAXPATHLEN]; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); + id = LispNumToCInt(args[0]); + ERRSETJMP(NIL); + TIMEOUT(rval = close(id)); + if (rval == -1) { + /** This if is a patch for an apparent problem **/ + /** in SunOS 4 that causes a close on /dev/ttya **/ + /** to error with 'not owner' **/ + if (errno == 1) { + DBPRINT(("Got errno 1 on a CLOSE!")); + return (ATOM_T); + } + DBPRINT(("Closing char device descriptor #%d.\n", id)); + err_mess("close", errno); + *Lisp_errno = errno; + return (NIL); } - - + return (ATOM_T); +#endif /* DOS */ +} /************************************************************************/ /* */ @@ -231,33 +202,28 @@ LispPTR CHAR_closefile(args) /* */ /************************************************************************/ -LispPTR CHAR_ioctl(args) - LispPTR *args; - { +LispPTR CHAR_ioctl(args) LispPTR *args; +{ #ifndef DOS - int id, request, data; - register int rval; - char *base; - struct stat sbuf; - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - id = LispNumToCInt(args[0]); - request = LispNumToCInt(args[1]); - data = (int)(Addr68k_from_LADDR(args[2])); - ERRSETJMP(NIL); - TIMEOUT(rval=ioctl(id, request, data)); - if(rval != 0) - { - err_mess("ioctl", errno); - *Lisp_errno = errno; - return(NIL); - } - return(ATOM_T); + int id, request, data; + register int rval; + char *base; + struct stat sbuf; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + id = LispNumToCInt(args[0]); + request = LispNumToCInt(args[1]); + data = (int)(Addr68k_from_LADDR(args[2])); + ERRSETJMP(NIL); + TIMEOUT(rval = ioctl(id, request, data)); + if (rval != 0) { + err_mess("ioctl", errno); + *Lisp_errno = errno; + return (NIL); + } + return (ATOM_T); #endif /* DOS */ - } - - /************************************************************************/ /* */ /* C H A R _ b i n */ @@ -269,34 +235,28 @@ LispPTR CHAR_ioctl(args) /* */ /************************************************************************/ -LispPTR CHAR_bin(id, errn) - register int id; - register LispPTR errn; - { +LispPTR CHAR_bin(id, errn) register int id; +register LispPTR errn; +{ #ifndef DOS - register int rval, size; - unsigned char ch[4]; - Lisp_errno = (int *)(Addr68k_from_LADDR(errn)); - ERRSETJMP(NIL); - id = LispNumToCInt(id); - /* Read PAGE_SIZE bytes file contents from filepointer. */ - TIMEOUT( rval=read(id, ch, 1) ); - if ( rval == 0 ) - { - *Lisp_errno = EWOULDBLOCK; - return(NIL); - } - if ( rval == -1 ) - { - *Lisp_errno = errno; - return(NIL); - } - return(GetSmallp(ch[0])); -#endif /* DOS */ - + register int rval, size; + unsigned char ch[4]; + Lisp_errno = (int *)(Addr68k_from_LADDR(errn)); + ERRSETJMP(NIL); + id = LispNumToCInt(id); + /* Read PAGE_SIZE bytes file contents from filepointer. */ + TIMEOUT(rval = read(id, ch, 1)); + if (rval == 0) { + *Lisp_errno = EWOULDBLOCK; + return (NIL); } - - + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + return (GetSmallp(ch[0])); +#endif /* DOS */ +} /************************************************************************/ /* */ @@ -308,36 +268,31 @@ LispPTR CHAR_bin(id, errn) /* */ /************************************************************************/ -LispPTR CHAR_bout(id, ch, errn) - register int id; - register LispPTR ch, errn; - { +LispPTR CHAR_bout(id, ch, errn) register int id; +register LispPTR ch, errn; +{ #ifndef DOS - register int rval; - char buf[4]; - Lisp_errno = (int *)(Addr68k_from_LADDR(errn)); - ERRSETJMP(NIL); - id = LispNumToCInt(id); - buf[0] = LispNumToCInt(ch); - /* Write PAGE_SIZE bytes file contents from filepointer. */ + register int rval; + char buf[4]; + Lisp_errno = (int *)(Addr68k_from_LADDR(errn)); + ERRSETJMP(NIL); + id = LispNumToCInt(id); + buf[0] = LispNumToCInt(ch); + /* Write PAGE_SIZE bytes file contents from filepointer. */ - TIMEOUT( rval=write(id, buf, 1) ); - - if (rval == -1) - { - *Lisp_errno = errno; - return(NIL); - } - if (rval == 0) - { - *Lisp_errno = EWOULDBLOCK; - return(NIL); - } - return(ATOM_T); -#endif /* DOS */ + TIMEOUT(rval = write(id, buf, 1)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); } - + if (rval == 0) { + *Lisp_errno = EWOULDBLOCK; + return (NIL); + } + return (ATOM_T); +#endif /* DOS */ +} /************************************************************************/ /* */ @@ -360,42 +315,35 @@ LispPTR CHAR_bout(id, ch, errn) /* */ /************************************************************************/ -LispPTR CHAR_bins(args) - register LispPTR *args; - { +LispPTR CHAR_bins(args) register LispPTR *args; +{ #ifndef DOS - register int id, rval; - char *buffer; - int offset, nbytes; - Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); - ERRSETJMP(NIL); - id = LispNumToCInt(args[0]); - buffer = ((char *) (Addr68k_from_LADDR(args[1]))) + LispNumToCInt(args[2]); - nbytes = LispNumToCInt(args[3]); - /* Read PAGE_SIZE bytes file contents from filepointer. */ - TIMEOUT( rval=read(id, buffer, nbytes) ); - if ( rval == 0 ) - { - *Lisp_errno = EWOULDBLOCK; - return(NIL); - } - if ( rval == -1 ) - { - *Lisp_errno = errno; - return(NIL); - } - -#ifdef BYTESWAP - word_swap_page(buffer, (nbytes+3)>>2); -#endif /* BYTESWAP */ - - - return(GetSmallp(rval)); -#endif /* DOS */ - + register int id, rval; + char *buffer; + int offset, nbytes; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); + ERRSETJMP(NIL); + id = LispNumToCInt(args[0]); + buffer = ((char *)(Addr68k_from_LADDR(args[1]))) + LispNumToCInt(args[2]); + nbytes = LispNumToCInt(args[3]); + /* Read PAGE_SIZE bytes file contents from filepointer. */ + TIMEOUT(rval = read(id, buffer, nbytes)); + if (rval == 0) { + *Lisp_errno = EWOULDBLOCK; + return (NIL); + } + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); } +#ifdef BYTESWAP + word_swap_page(buffer, (nbytes + 3) >> 2); +#endif /* BYTESWAP */ + return (GetSmallp(rval)); +#endif /* DOS */ +} /************************************************************************/ /* */ @@ -418,39 +366,35 @@ LispPTR CHAR_bins(args) /* */ /************************************************************************/ -LispPTR CHAR_bouts(args) - register LispPTR *args; - { +LispPTR CHAR_bouts(args) register LispPTR *args; +{ #ifndef DOS - register int id, rval; - char *buffer; - int nbytes, offset; - Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); - ERRSETJMP(NIL); - id = LispNumToCInt(args[0]); - buffer = ((char *)(Addr68k_from_LADDR(args[1]))) + LispNumToCInt(args[2]); - nbytes = LispNumToCInt(args[3]); - /* Write PAGE_SIZE bytes file contents from filepointer. */ + register int id, rval; + char *buffer; + int nbytes, offset; + Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); + ERRSETJMP(NIL); + id = LispNumToCInt(args[0]); + buffer = ((char *)(Addr68k_from_LADDR(args[1]))) + LispNumToCInt(args[2]); + nbytes = LispNumToCInt(args[3]); +/* Write PAGE_SIZE bytes file contents from filepointer. */ #ifdef BYTESWAP - word_swap_page(buffer, (nbytes+3)>>2); + word_swap_page(buffer, (nbytes + 3) >> 2); #endif /* BYTESWAP */ - TIMEOUT( rval=write(id, buffer, nbytes) ); + TIMEOUT(rval = write(id, buffer, nbytes)); #ifdef BYTESWAP - word_swap_page(buffer, (nbytes+3)>>2); + word_swap_page(buffer, (nbytes + 3) >> 2); #endif /* BYTESWAP */ - if (rval == -1) - { - *Lisp_errno = errno; - return(NIL); - } - if (rval == 0) - { - *Lisp_errno = EWOULDBLOCK; - return(NIL); - } - return(GetSmallp(rval)); -#endif /* DOS */ - + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); } + if (rval == 0) { + *Lisp_errno = EWOULDBLOCK; + return (NIL); + } + return (GetSmallp(rval)); +#endif /* DOS */ +} diff --git a/src/chatter.c b/src/chatter.c old mode 100755 new mode 100644 index 971d27a..ddb057a --- a/src/chatter.c +++ b/src/chatter.c @@ -1,8 +1,7 @@ -/* $Id: chatter.c,v 1.2 1999/01/03 02:06:51 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: chatter.c,v 1.2 1999/01/03 02:06:51 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: chatter.c,v 1.2 1999/01/03 02:06:51 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: chatter.c,v 1.2 1999/01/03 02:06:51 sybalsky Exp $ Copyr #include "version.h" - #include #include #include @@ -37,213 +35,187 @@ static char *id = "$Id: chatter.c,v 1.2 1999/01/03 02:06:51 sybalsky Exp $ Copyr #define CHAR_MAXLEN 512 #define BYTESIZE 256 -int chatter_fd; +int chatter_fd; -#define LStringToCString(Lisp, C, MaxLen ,Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int i; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((UNSIGNED)Lisp)); \ - Len = min(MaxLen, arrayp->totalsize); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(i=0;ibase))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(i=0;itotalsize); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *)(Addr68k_from_LADDR((UNSIGNED)arrayp->base))) + ((int)(arrayp->offset)); \ + for (i = 0; i < Len; i++) C[i] = base[i]; \ + C[Len] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *)(Addr68k_from_LADDR((UNSIGNED)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (i = 0; i < Len * 2; i++) C[i] = base[i]; \ + C[Len * 2] = '\0'; \ + break; \ + \ + default: error("LStringToCString can not handle\n"); \ + } \ } -#define CStringToLString(C, Lisp, Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int id; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((UNSIGNED)Lisp)); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(id=0;idfillpointer = Len; \ - break; \ - \ - case FAT_CHAR_TYPENUMBER: \ - sbase = ((short *) \ - (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(id=0;idfillpointer = Len; \ - break; \ - \ - default: \ - error("CStringToLString can not handle\n"); \ - } \ +#define CStringToLString(C, Lisp, Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int id; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((UNSIGNED)Lisp)); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = ((char *)(Addr68k_from_LADDR((UNSIGNED)arrayp->base))) + ((int)(arrayp->offset)); \ + for (id = 0; id < Len; id++) base[id] = C[id]; \ + arrayp->fillpointer = Len; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = ((short *)(Addr68k_from_LADDR((UNSIGNED)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (id = 0; id < Len * 2; id++) base[id] = C[id]; \ + arrayp->fillpointer = Len; \ + break; \ + \ + default: error("CStringToLString can not handle\n"); \ + } \ } -#define IntToFixp(C, Lisp) \ - { \ - int *base; \ - \ - base = (int *) Addr68k_from_LADDR((UNSIGNED)Lisp); \ - *base = C; \ +#define IntToFixp(C, Lisp) \ + { \ + int *base; \ + \ + base = (int *)Addr68k_from_LADDR((UNSIGNED)Lisp); \ + *base = C; \ } - -chatter(args) - int args[]; + +chatter(args) int args[]; { - int result; - int length; - int number; - unsigned char data[(CHAR_MAXLEN+1)*2]; - unsigned char tmp[(CHAR_MAXLEN+1)*2]; + int result; + int length; + int number; + unsigned char data[(CHAR_MAXLEN + 1) * 2]; + unsigned char tmp[(CHAR_MAXLEN + 1) * 2]; - int i; + int i; - N_GETNUMBER(args[0], number, ERROR); - switch (number) { - case 1: - LStringToCString(args[1], data, CHAR_MAXLEN,length); - result = chatter_open(data); - break; + N_GETNUMBER(args[0], number, ERROR); + switch (number) { + case 1: + LStringToCString(args[1], data, CHAR_MAXLEN, length); + result = chatter_open(data); + break; - case 2: - result = chatter_close(); - break; + case 2: result = chatter_close(); break; - case 3: - LStringToCString(args[1], data, CHAR_MAXLEN, length); - result = chatter_write_string(data , length); - break; + case 3: + LStringToCString(args[1], data, CHAR_MAXLEN, length); + result = chatter_write_string(data, length); + break; - case 4: - result = chatter_read(data,1); - number = data[0]; - IntToFixp(number, args[1]); - break; + case 4: + result = chatter_read(data, 1); + number = data[0]; + IntToFixp(number, args[1]); + break; + case 5: + N_GETNUMBER(args[1], number, ERROR); + data[0] = number & 0xff; + result = chatter_write_code(data[0]); + break; - case 5: - N_GETNUMBER(args[1], number, ERROR); - data[0] = number & 0xff; - result = chatter_write_code(data[0]); - break; - -ERROR: - result = 9999; - break; - } - - if (result == 0) - return (ATOM_T); - else - return(NIL); + ERROR: + result = 9999; + break; + } + if (result == 0) + return (ATOM_T); + else + return (NIL); } -chatter_open(dev) - char dev[]; +chatter_open(dev) char dev[]; { - struct termios termdata; + struct termios termdata; - if ((chatter_fd = open(dev, O_RDWR)) < 0) { - perror("CHATTER OPEN ERROR"); - return (-1); - } - if (ioctl(chatter_fd, TCGETS, &termdata) < 0) { - perror("CHATTER GET PARAMS ERROR"); - return (-1); - } - termdata.c_iflag &= ~IXON; - termdata.c_iflag &= ~IXANY; - termdata.c_iflag &= ~IXOFF; + if ((chatter_fd = open(dev, O_RDWR)) < 0) { + perror("CHATTER OPEN ERROR"); + return (-1); + } + if (ioctl(chatter_fd, TCGETS, &termdata) < 0) { + perror("CHATTER GET PARAMS ERROR"); + return (-1); + } + termdata.c_iflag &= ~IXON; + termdata.c_iflag &= ~IXANY; + termdata.c_iflag &= ~IXOFF; - termdata.c_cflag &= ~CBAUD; - termdata.c_cflag |= B4800; - termdata.c_cflag &= ~CSIZE; - termdata.c_cflag |= CS8; - termdata.c_cflag &= ~CSTOPB; - termdata.c_cflag &= ~PARODD; - termdata.c_cflag &= ~CIBAUD; + termdata.c_cflag &= ~CBAUD; + termdata.c_cflag |= B4800; + termdata.c_cflag &= ~CSIZE; + termdata.c_cflag |= CS8; + termdata.c_cflag &= ~CSTOPB; + termdata.c_cflag &= ~PARODD; + termdata.c_cflag &= ~CIBAUD; - termdata.c_lflag = 0; + termdata.c_lflag = 0; - termdata.c_cc[VMIN] = 256; - termdata.c_cc[VTIME] = 1; + termdata.c_cc[VMIN] = 256; + termdata.c_cc[VTIME] = 1; - if (ioctl(chatter_fd, TCSETS, &termdata) < 0) { - perror("CHATTER SET PARAMS ERROR:"); - return (-1); - } - return (0); + if (ioctl(chatter_fd, TCSETS, &termdata) < 0) { + perror("CHATTER SET PARAMS ERROR:"); + return (-1); + } + return (0); } -chatter_close() -{ - if (close(chatter_fd) < 0) { - perror("CHATTER CLOSE ERROR"); - return (-1); - } - return (0); +chatter_close() { + if (close(chatter_fd) < 0) { + perror("CHATTER CLOSE ERROR"); + return (-1); + } + return (0); } -chatter_write_string(data, len) - char data[]; - int len; +chatter_write_string(data, len) char data[]; +int len; { - if (write(chatter_fd, data, len) < 0) { - perror("WRITE ERROR"); - return (-1); - } - return (0); + if (write(chatter_fd, data, len) < 0) { + perror("WRITE ERROR"); + return (-1); + } + return (0); } -chatter_write_code(code) - unsigned char code; +chatter_write_code(code) unsigned char code; { - if (write(chatter_fd, &code, 1) < 0) { - perror("WRITE ERROR"); - return (-1); - } - return (0); + if (write(chatter_fd, &code, 1) < 0) { + perror("WRITE ERROR"); + return (-1); + } + return (0); } -chatter_read(data, len) - unsigned char *data; - int len; +chatter_read(data, len) unsigned char *data; +int len; { - if (read(chatter_fd, data, len) < 0) { - perror("READ ERROR"); - return (-1); - } - return (0); + if (read(chatter_fd, data, len) < 0) { + perror("READ ERROR"); + return (-1); + } + return (0); } diff --git a/src/codeconv.c b/src/codeconv.c old mode 100755 new mode 100644 index 049a65b..3fe5fc3 --- a/src/codeconv.c +++ b/src/codeconv.c @@ -1,8 +1,7 @@ -/* $Id: codeconv.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: codeconv.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: codeconv.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: codeconv.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copy #include "version.h" - /*************************************************/ /* NSFatchar string <-> EUC character string */ /* conversion program */ @@ -32,179 +30,164 @@ static char *id = "$Id: codeconv.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copy #include -#define EUCMASK 0x80 -#define EUCUNMASK 0x7F -#define MASK8BIT 0x00FF -#define TABLESIZE 256 +#define EUCMASK 0x80 +#define EUCUNMASK 0x7F +#define MASK8BIT 0x00FF +#define TABLESIZE 256 -int -FatcharNStoEUC(unsigned char *ns_ptr, int ns_len, unsigned char *euc_ptr) -{ - int i; - int euc_len; - unsigned short ns, euc; - unsigned short ns_euc(short unsigned int ns); +int FatcharNStoEUC(unsigned char *ns_ptr, int ns_len, unsigned char *euc_ptr) { + int i; + int euc_len; + unsigned short ns, euc; + unsigned short ns_euc(short unsigned int ns); #ifdef DEBUG - unsigned char *ptr; - ptr = euc_ptr; - printf("FatcharNStoEUC start\n"); - printf("ns_len = %d\n", ns_len); - for (i = 0; i < ns_len*2; i++) - printf("%x ", ns_ptr[i]); - printf("\n"); + unsigned char *ptr; + ptr = euc_ptr; + printf("FatcharNStoEUC start\n"); + printf("ns_len = %d\n", ns_len); + for (i = 0; i < ns_len * 2; i++) printf("%x ", ns_ptr[i]); + printf("\n"); #endif - /* ns_len convert to byte count */ - ns_len *= 2; + /* ns_len convert to byte count */ + ns_len *= 2; - for (i = euc_len = 0; i < ns_len; i += 2) { - ns = *ns_ptr++ * TABLESIZE; - ns += *ns_ptr++; - euc = ns_euc(ns); - if (euc / TABLESIZE) { - /* 16 bit charactor */ - *euc_ptr++ = euc / TABLESIZE; - *euc_ptr++ = euc % TABLESIZE; - euc_len += 2; - } else { - /* ASCII charactor */ - *euc_ptr++ = euc % TABLESIZE; - ++euc_len; - } - } + for (i = euc_len = 0; i < ns_len; i += 2) { + ns = *ns_ptr++ * TABLESIZE; + ns += *ns_ptr++; + euc = ns_euc(ns); + if (euc / TABLESIZE) { + /* 16 bit charactor */ + *euc_ptr++ = euc / TABLESIZE; + *euc_ptr++ = euc % TABLESIZE; + euc_len += 2; + } else { + /* ASCII charactor */ + *euc_ptr++ = euc % TABLESIZE; + ++euc_len; + } + } - *euc_ptr++ = '\0'; + *euc_ptr++ = '\0'; #ifdef DEBUG - printf("FatcharNStoEUC end\n"); - printf("euc_len = %d\n", euc_len); - for (i = 0; i < euc_len; i++) - printf("%x ", ptr[i]); - printf("\n"); + printf("FatcharNStoEUC end\n"); + printf("euc_len = %d\n", euc_len); + for (i = 0; i < euc_len; i++) printf("%x ", ptr[i]); + printf("\n"); #endif - return (euc_len); + return (euc_len); } -int -ThincharNStoEUC(unsigned char *ns_ptr, int ns_len, unsigned char *euc_ptr) -{ - int i; - int euc_len = 0; - unsigned short ns, euc; - unsigned short ns_euc(short unsigned int ns); +int ThincharNStoEUC(unsigned char *ns_ptr, int ns_len, unsigned char *euc_ptr) { + int i; + int euc_len = 0; + unsigned short ns, euc; + unsigned short ns_euc(short unsigned int ns); #ifdef DEBUG - unsigned char *ptr; - ptr = euc_ptr; - printf("ThincharNStoEUC start\n"); - printf("ns_len = %d\n", ns_len); - for (i = 0; i < ns_len; i++) - printf("%x ", ns_ptr[i]); - printf("\n"); + unsigned char *ptr; + ptr = euc_ptr; + printf("ThincharNStoEUC start\n"); + printf("ns_len = %d\n", ns_len); + for (i = 0; i < ns_len; i++) printf("%x ", ns_ptr[i]); + printf("\n"); #endif - /* ns_len convert to byte count */ - for (i = euc_len = 0; i < ns_len; i++) { - ns = *ns_ptr++; - euc = ns_euc(ns); - if (euc / TABLESIZE) { - /* 16 bit charactor */ - *euc_ptr++ = euc / TABLESIZE; - *euc_ptr++ = euc % TABLESIZE; - euc_len += 2; - } else { - /* ASCII charactor */ - *euc_ptr++ = euc % TABLESIZE; - ++euc_len; - } - } + /* ns_len convert to byte count */ + for (i = euc_len = 0; i < ns_len; i++) { + ns = *ns_ptr++; + euc = ns_euc(ns); + if (euc / TABLESIZE) { + /* 16 bit charactor */ + *euc_ptr++ = euc / TABLESIZE; + *euc_ptr++ = euc % TABLESIZE; + euc_len += 2; + } else { + /* ASCII charactor */ + *euc_ptr++ = euc % TABLESIZE; + ++euc_len; + } + } - *euc_ptr++ = '\0'; + *euc_ptr++ = '\0'; #ifdef DEBUG - printf("ThincharNStoEUC end\n"); - printf("euc_len = %d\n", euc_len); - for (i = 0; i < euc_len; i++) - printf("%x ", ptr[i]); - printf("\n"); + printf("ThincharNStoEUC end\n"); + printf("euc_len = %d\n", euc_len); + for (i = 0; i < euc_len; i++) printf("%x ", ptr[i]); + printf("\n"); #endif - return (euc_len); + return (euc_len); } -int -EUCtoFatcharNS(unsigned char *euc_ptr, unsigned char *ns_ptr) -{ - int i; - int ns_len; - unsigned short euc, ns; - unsigned short euc_ns(short unsigned int euc); +int EUCtoFatcharNS(unsigned char *euc_ptr, unsigned char *ns_ptr) { + int i; + int ns_len; + unsigned short euc, ns; + unsigned short euc_ns(short unsigned int euc); #ifdef DEBUG - printf("EUCtoFatcharNS start\n"); - for (i = 0; i < strlen(euc_ptr); i++) - printf("%x ", euc_ptr[i]); - printf("\n"); + printf("EUCtoFatcharNS start\n"); + for (i = 0; i < strlen(euc_ptr); i++) printf("%x ", euc_ptr[i]); + printf("\n"); #endif - i = 0; - while (euc = *euc_ptr++) { - if (euc & EUCMASK) { - /* 16 bit charactor */ - euc *= TABLESIZE; - euc += *euc_ptr++; - } + i = 0; + while (euc = *euc_ptr++) { + if (euc & EUCMASK) { + /* 16 bit charactor */ + euc *= TABLESIZE; + euc += *euc_ptr++; + } - ns = euc_ns(euc); + ns = euc_ns(euc); - ns_ptr[i++] = ns / TABLESIZE; - ns_ptr[i++] = ns % TABLESIZE; - } - ns_len = i / 2; + ns_ptr[i++] = ns / TABLESIZE; + ns_ptr[i++] = ns % TABLESIZE; + } + ns_len = i / 2; #ifdef DEBUG - printf("EUCtoFatcharNS end\n"); - printf("ns_len = %d\n", ns_len); - for (i = 0; i < ns_len*2; i++) - printf("%x ", ns_ptr[i]); - printf("\n"); + printf("EUCtoFatcharNS end\n"); + printf("ns_len = %d\n", ns_len); + for (i = 0; i < ns_len * 2; i++) printf("%x ", ns_ptr[i]); + printf("\n"); #endif - return (ns_len); + return (ns_len); } -int -EUCstrlen(char *euc_ptr) -{ - int len = 0; +int EUCstrlen(char *euc_ptr) { + int len = 0; #ifdef DEBUG - int i; + int i; - printf("EUCstrlen start\n"); - for (i = 0; i < strlen(euc_ptr); i++) - printf("%x ", euc_ptr[i]); - printf("\n"); + printf("EUCstrlen start\n"); + for (i = 0; i < strlen(euc_ptr); i++) printf("%x ", euc_ptr[i]); + printf("\n"); #endif - while (*euc_ptr) - if (*euc_ptr & EUCMASK) { - /* 16 bit charactor */ - len += 2; - *euc_ptr++; - *euc_ptr++; - } else { - /* ASCII charactor */ - len++; - *euc_ptr++; - } + while (*euc_ptr) + if (*euc_ptr & EUCMASK) { + /* 16 bit charactor */ + len += 2; + *euc_ptr++; + *euc_ptr++; + } else { + /* ASCII charactor */ + len++; + *euc_ptr++; + } #ifdef DEBUG - printf("EUCstrlen end\n"); - printf("len = %d\n", len); + printf("EUCstrlen end\n"); + printf("len = %d\n", len); #endif - return (len); + return (len); } diff --git a/src/codetbl.c b/src/codetbl.c old mode 100755 new mode 100644 index 3a62dae..97217b8 --- a/src/codetbl.c +++ b/src/codetbl.c @@ -1,8 +1,7 @@ -/* $Id: codetbl.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: codetbl.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: codetbl.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: codetbl.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyr #include "version.h" - /***************************************************/ /* NS <-> EUC character code converstion program */ /* file name : nstables.c */ @@ -31,552 +29,345 @@ static char *id = "$Id: codetbl.c,v 1.3 1999/05/31 23:35:26 sybalsky Exp $ Copyr /***************************************************/ #define TABLESIZE 256 -#define EUCBITS 0x8080 -#define NSBITS 0x7F7F - +#define EUCBITS 0x8080 +#define NSBITS 0x7F7F + static unsigned short eucA1[TABLESIZE] = { - 41216, 41217, 41218, 41219, 41220, 41221, 41222, 41223, - 41224, 41225, 41226, 41227, 41228, 41229, 41230, 41231, - 41232, 41233, 41234, 41235, 41236, 41237, 41238, 41239, - 41240, 41241, 41242, 41243, 41244, 41245, 41246, 41247, - 41248, 41249, 41250, 41251, 41252, 41253, 41254, 41255, - 41256, 41257, 41258, 41259, 41260, 41261, 41262, 41263, - 41264, 41265, 41266, 41267, 41268, 41269, 41270, 41271, - 41272, 41273, 41274, 41275, 41276, 41277, 41278, 41279, - 41280, 41281, 41282, 41283, 41284, 41285, 41286, 41287, - 41288, 41289, 41290, 41291, 41292, 41293, 41294, 41295, - 41296, 41297, 41298, 41299, 41300, 41301, 41302, 41303, - 41304, 41305, 41306, 41307, 41308, 41309, 41310, 41311, - 41312, 41313, 41314, 41315, 41316, 41317, 41318, 41319, - 41320, 41321, 41322, 41323, 41324, 41325, 41326, 41327, - 41328, 41329, 41330, 41331, 41332, 41333, 41334, 41335, - 41336, 41337, 41338, 41339, 41340, 41341, 41342, 41343, - 41344, 41345, 41346, 41347, 41348, 41349, 41350, 41351, - 41352, 41353, 41354, 41355, 41356, 41357, 41358, 41359, - 41360, 41361, 41362, 41363, 41364, 41365, 41366, 41367, - 41368, 41369, 41370, 41371, 41372, 41373, 41374, 41375, - 41376, 8481, 8482, 8483, 44, 46, 183, 58, - 59, 63, 33, 8491, 8492, 194, 193, 200, - 195, 9155, 204, 8499, 8500, 8501, 8502, 8503, - 8504, 8505, 8506, 8507, 8508, 61220, 8510, 47, - 92, 126, 8514, 124, 8516, 8517, 169, 39, - 170, 186, 40, 41, 8524, 8525, 91, 93, - 123, 125, 61234, 61235, 171, 187, 8534, 8535, - 8536, 8537, 8538, 8539, 43, 45, 177, 180, - 184, 61, 8546, 60, 62, 8549, 8550, 8551, - 8552, 8553, 8554, 176, 8556, 8557, 8558, 165, - 164, 162, 163, 37, 35, 38, 42, 64, - 167, 8569, 8570, 8571, 8572, 8573, 8574, 41471 -}; - + 41216, 41217, 41218, 41219, 41220, 41221, 41222, 41223, 41224, 41225, 41226, 41227, 41228, + 41229, 41230, 41231, 41232, 41233, 41234, 41235, 41236, 41237, 41238, 41239, 41240, 41241, + 41242, 41243, 41244, 41245, 41246, 41247, 41248, 41249, 41250, 41251, 41252, 41253, 41254, + 41255, 41256, 41257, 41258, 41259, 41260, 41261, 41262, 41263, 41264, 41265, 41266, 41267, + 41268, 41269, 41270, 41271, 41272, 41273, 41274, 41275, 41276, 41277, 41278, 41279, 41280, + 41281, 41282, 41283, 41284, 41285, 41286, 41287, 41288, 41289, 41290, 41291, 41292, 41293, + 41294, 41295, 41296, 41297, 41298, 41299, 41300, 41301, 41302, 41303, 41304, 41305, 41306, + 41307, 41308, 41309, 41310, 41311, 41312, 41313, 41314, 41315, 41316, 41317, 41318, 41319, + 41320, 41321, 41322, 41323, 41324, 41325, 41326, 41327, 41328, 41329, 41330, 41331, 41332, + 41333, 41334, 41335, 41336, 41337, 41338, 41339, 41340, 41341, 41342, 41343, 41344, 41345, + 41346, 41347, 41348, 41349, 41350, 41351, 41352, 41353, 41354, 41355, 41356, 41357, 41358, + 41359, 41360, 41361, 41362, 41363, 41364, 41365, 41366, 41367, 41368, 41369, 41370, 41371, + 41372, 41373, 41374, 41375, 41376, 8481, 8482, 8483, 44, 46, 183, 58, 59, + 63, 33, 8491, 8492, 194, 193, 200, 195, 9155, 204, 8499, 8500, 8501, + 8502, 8503, 8504, 8505, 8506, 8507, 8508, 61220, 8510, 47, 92, 126, 8514, + 124, 8516, 8517, 169, 39, 170, 186, 40, 41, 8524, 8525, 91, 93, + 123, 125, 61234, 61235, 171, 187, 8534, 8535, 8536, 8537, 8538, 8539, 43, + 45, 177, 180, 184, 61, 8546, 60, 62, 8549, 8550, 8551, 8552, 8553, + 8554, 176, 8556, 8557, 8558, 165, 164, 162, 163, 37, 35, 38, 42, + 64, 167, 8569, 8570, 8571, 8572, 8573, 8574, 41471}; + static unsigned short eucA2[TABLESIZE] = { - 41472, 41473, 41474, 41475, 41476, 41477, 41478, 41479, - 41480, 41481, 41482, 41483, 41484, 41485, 41486, 41487, - 41488, 41489, 41490, 41491, 41492, 41493, 41494, 41495, - 41496, 41497, 41498, 41499, 41500, 41501, 41502, 41503, - 41504, 41505, 41506, 41507, 41508, 41509, 41510, 41511, - 41512, 41513, 41514, 41515, 41516, 41517, 41518, 41519, - 41520, 41521, 41522, 41523, 41524, 41525, 41526, 41527, - 41528, 41529, 41530, 41531, 41532, 41533, 41534, 41535, - 41536, 41537, 41538, 41539, 41540, 41541, 41542, 41543, - 41544, 41545, 41546, 41547, 41548, 41549, 41550, 41551, - 41552, 41553, 41554, 41555, 41556, 41557, 41558, 41559, - 41560, 41561, 41562, 41563, 41564, 41565, 41566, 41567, - 41568, 41569, 41570, 41571, 41572, 41573, 41574, 41575, - 41576, 41577, 41578, 41579, 41580, 41581, 41582, 41583, - 41584, 41585, 41586, 41587, 41588, 41589, 41590, 41591, - 41592, 41593, 41594, 41595, 41596, 41597, 41598, 41599, - 41600, 41601, 41602, 41603, 41604, 41605, 41606, 41607, - 41608, 41609, 41610, 41611, 41612, 41613, 41614, 41615, - 41616, 41617, 41618, 41619, 41620, 41621, 41622, 41623, - 41624, 41625, 41626, 41627, 41628, 41629, 41630, 41631, - 41632, 8737, 8738, 8739, 8740, 8741, 8742, 8743, - 8744, 8745, 174, 172, 173, 175, 8750, 8751, - 8752, 8753, 8754, 8755, 8756, 8757, 8758, 8759, - 8760, 8761, 61258, 61260, 61273, 61272, 61275, 61274, - 61271, 61270, 8770, 8771, 8772, 8773, 8774, 8775, - 8776, 8777, 61366, 61367, 61290, 61263, 61262, 61365, - 61364, 8785, 8786, 8787, 8788, 8789, 8790, 8791, - 8792, 8793, 8794, 8795, 61292, 61296, 61376, 61370, - 61369, 61298, 8802, 61250, 61251, 61308, 64894, 61297, - 61295, 61301, 8810, 8811, 8812, 8813, 8814, 8815, - 8816, 8817, 61736, 61249, 9148, 9132, 213, 61232, - 61233, 182, 8826, 8827, 8828, 8829, 8830, 41727 -}; - + 41472, 41473, 41474, 41475, 41476, 41477, 41478, 41479, 41480, 41481, 41482, 41483, 41484, + 41485, 41486, 41487, 41488, 41489, 41490, 41491, 41492, 41493, 41494, 41495, 41496, 41497, + 41498, 41499, 41500, 41501, 41502, 41503, 41504, 41505, 41506, 41507, 41508, 41509, 41510, + 41511, 41512, 41513, 41514, 41515, 41516, 41517, 41518, 41519, 41520, 41521, 41522, 41523, + 41524, 41525, 41526, 41527, 41528, 41529, 41530, 41531, 41532, 41533, 41534, 41535, 41536, + 41537, 41538, 41539, 41540, 41541, 41542, 41543, 41544, 41545, 41546, 41547, 41548, 41549, + 41550, 41551, 41552, 41553, 41554, 41555, 41556, 41557, 41558, 41559, 41560, 41561, 41562, + 41563, 41564, 41565, 41566, 41567, 41568, 41569, 41570, 41571, 41572, 41573, 41574, 41575, + 41576, 41577, 41578, 41579, 41580, 41581, 41582, 41583, 41584, 41585, 41586, 41587, 41588, + 41589, 41590, 41591, 41592, 41593, 41594, 41595, 41596, 41597, 41598, 41599, 41600, 41601, + 41602, 41603, 41604, 41605, 41606, 41607, 41608, 41609, 41610, 41611, 41612, 41613, 41614, + 41615, 41616, 41617, 41618, 41619, 41620, 41621, 41622, 41623, 41624, 41625, 41626, 41627, + 41628, 41629, 41630, 41631, 41632, 8737, 8738, 8739, 8740, 8741, 8742, 8743, 8744, + 8745, 174, 172, 173, 175, 8750, 8751, 8752, 8753, 8754, 8755, 8756, 8757, + 8758, 8759, 8760, 8761, 61258, 61260, 61273, 61272, 61275, 61274, 61271, 61270, 8770, + 8771, 8772, 8773, 8774, 8775, 8776, 8777, 61366, 61367, 61290, 61263, 61262, 61365, + 61364, 8785, 8786, 8787, 8788, 8789, 8790, 8791, 8792, 8793, 8794, 8795, 61292, + 61296, 61376, 61370, 61369, 61298, 8802, 61250, 61251, 61308, 64894, 61297, 61295, 61301, + 8810, 8811, 8812, 8813, 8814, 8815, 8816, 8817, 61736, 61249, 9148, 9132, 213, + 61232, 61233, 182, 8826, 8827, 8828, 8829, 8830, 41727}; + static unsigned short eucA3[TABLESIZE] = { - 41728, 41729, 41730, 41731, 41732, 41733, 41734, 41735, - 41736, 41737, 41738, 41739, 41740, 41741, 41742, 41743, - 41744, 41745, 41746, 41747, 41748, 41749, 41750, 41751, - 41752, 41753, 41754, 41755, 41756, 41757, 41758, 41759, - 41760, 41761, 41762, 41763, 41764, 41765, 41766, 41767, - 41768, 41769, 41770, 41771, 41772, 41773, 41774, 41775, - 41776, 41777, 41778, 41779, 41780, 41781, 41782, 41783, - 41784, 41785, 41786, 41787, 41788, 41789, 41790, 41791, - 41792, 41793, 41794, 41795, 41796, 41797, 41798, 41799, - 41800, 41801, 41802, 41803, 41804, 41805, 41806, 41807, - 41808, 41809, 41810, 41811, 41812, 41813, 41814, 41815, - 41816, 41817, 41818, 41819, 41820, 41821, 41822, 41823, - 41824, 41825, 41826, 41827, 41828, 41829, 41830, 41831, - 41832, 41833, 41834, 41835, 41836, 41837, 41838, 41839, - 41840, 41841, 41842, 41843, 41844, 41845, 41846, 41847, - 41848, 41849, 41850, 41851, 41852, 41853, 41854, 41855, - 41856, 41857, 41858, 41859, 41860, 41861, 41862, 41863, - 41864, 41865, 41866, 41867, 41868, 41869, 41870, 41871, - 41872, 41873, 41874, 41875, 41876, 41877, 41878, 41879, - 41880, 41881, 41882, 41883, 41884, 41885, 41886, 41887, - 41888, 8993, 8994, 8995, 8996, 8997, 8998, 8999, - 9000, 9001, 9002, 9003, 9004, 9005, 9006, 9007, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 9018, 9019, 9020, 9021, 9022, 9023, - 9024, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 9051, 9052, 9053, 9054, 9055, - 9056, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 9083, 9084, 9085, 9086, 41983 -}; - + 41728, 41729, 41730, 41731, 41732, 41733, 41734, 41735, 41736, 41737, 41738, 41739, 41740, + 41741, 41742, 41743, 41744, 41745, 41746, 41747, 41748, 41749, 41750, 41751, 41752, 41753, + 41754, 41755, 41756, 41757, 41758, 41759, 41760, 41761, 41762, 41763, 41764, 41765, 41766, + 41767, 41768, 41769, 41770, 41771, 41772, 41773, 41774, 41775, 41776, 41777, 41778, 41779, + 41780, 41781, 41782, 41783, 41784, 41785, 41786, 41787, 41788, 41789, 41790, 41791, 41792, + 41793, 41794, 41795, 41796, 41797, 41798, 41799, 41800, 41801, 41802, 41803, 41804, 41805, + 41806, 41807, 41808, 41809, 41810, 41811, 41812, 41813, 41814, 41815, 41816, 41817, 41818, + 41819, 41820, 41821, 41822, 41823, 41824, 41825, 41826, 41827, 41828, 41829, 41830, 41831, + 41832, 41833, 41834, 41835, 41836, 41837, 41838, 41839, 41840, 41841, 41842, 41843, 41844, + 41845, 41846, 41847, 41848, 41849, 41850, 41851, 41852, 41853, 41854, 41855, 41856, 41857, + 41858, 41859, 41860, 41861, 41862, 41863, 41864, 41865, 41866, 41867, 41868, 41869, 41870, + 41871, 41872, 41873, 41874, 41875, 41876, 41877, 41878, 41879, 41880, 41881, 41882, 41883, + 41884, 41885, 41886, 41887, 41888, 8993, 8994, 8995, 8996, 8997, 8998, 8999, 9000, + 9001, 9002, 9003, 9004, 9005, 9006, 9007, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 9018, 9019, 9020, 9021, 9022, 9023, 9024, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 9051, 9052, + 9053, 9054, 9055, 9056, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 9083, 9084, 9085, 9086, 41983}; + static unsigned short eucA6[TABLESIZE] = { - 42496, 42497, 42498, 42499, 42500, 42501, 42502, 42503, - 42504, 42505, 42506, 42507, 42508, 42509, 42510, 42511, - 42512, 42513, 42514, 42515, 42516, 42517, 42518, 42519, - 42520, 42521, 42522, 42523, 42524, 42525, 42526, 42527, - 42528, 42529, 42530, 42531, 42532, 42533, 42534, 42535, - 42536, 42537, 42538, 42539, 42540, 42541, 42542, 42543, - 42544, 42545, 42546, 42547, 42548, 42549, 42550, 42551, - 42552, 42553, 42554, 42555, 42556, 42557, 42558, 42559, - 42560, 42561, 42562, 42563, 42564, 42565, 42566, 42567, - 42568, 42569, 42570, 42571, 42572, 42573, 42574, 42575, - 42576, 42577, 42578, 42579, 42580, 42581, 42582, 42583, - 42584, 42585, 42586, 42587, 42588, 42589, 42590, 42591, - 42592, 42593, 42594, 42595, 42596, 42597, 42598, 42599, - 42600, 42601, 42602, 42603, 42604, 42605, 42606, 42607, - 42608, 42609, 42610, 42611, 42612, 42613, 42614, 42615, - 42616, 42617, 42618, 42619, 42620, 42621, 42622, 42623, - 42624, 42625, 42626, 42627, 42628, 42629, 42630, 42631, - 42632, 42633, 42634, 42635, 42636, 42637, 42638, 42639, - 42640, 42641, 42642, 42643, 42644, 42645, 42646, 42647, - 42648, 42649, 42650, 42651, 42652, 42653, 42654, 42655, - 42656, 9793, 9794, 9796, 9797, 9798, 9801, 9802, - 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, - 9811, 9813, 9814, 9816, 9817, 9818, 9819, 9820, - 9821, 9785, 9786, 9787, 9788, 9789, 9790, 9791, - 9792, 9825, 9826, 9828, 9829, 9830, 9833, 9834, - 9835, 9836, 9837, 9838, 9839, 9840, 9841, 9842, - 9843, 9845, 9846, 9848, 9849, 9850, 9851, 9852, - 9853, 42713, 42714, 42715, 42716, 42717, 42718, 42719, - 42720, 42721, 42722, 42723, 42724, 42725, 42726, 42727, - 42728, 42729, 42730, 42731, 42732, 42733, 42734, 42735, - 42736, 42737, 42738, 42739, 42740, 42741, 42742, 42743, - 42744, 42745, 42746, 42747, 42748, 42749, 42750, 42751 -}; - + 42496, 42497, 42498, 42499, 42500, 42501, 42502, 42503, 42504, 42505, 42506, 42507, 42508, + 42509, 42510, 42511, 42512, 42513, 42514, 42515, 42516, 42517, 42518, 42519, 42520, 42521, + 42522, 42523, 42524, 42525, 42526, 42527, 42528, 42529, 42530, 42531, 42532, 42533, 42534, + 42535, 42536, 42537, 42538, 42539, 42540, 42541, 42542, 42543, 42544, 42545, 42546, 42547, + 42548, 42549, 42550, 42551, 42552, 42553, 42554, 42555, 42556, 42557, 42558, 42559, 42560, + 42561, 42562, 42563, 42564, 42565, 42566, 42567, 42568, 42569, 42570, 42571, 42572, 42573, + 42574, 42575, 42576, 42577, 42578, 42579, 42580, 42581, 42582, 42583, 42584, 42585, 42586, + 42587, 42588, 42589, 42590, 42591, 42592, 42593, 42594, 42595, 42596, 42597, 42598, 42599, + 42600, 42601, 42602, 42603, 42604, 42605, 42606, 42607, 42608, 42609, 42610, 42611, 42612, + 42613, 42614, 42615, 42616, 42617, 42618, 42619, 42620, 42621, 42622, 42623, 42624, 42625, + 42626, 42627, 42628, 42629, 42630, 42631, 42632, 42633, 42634, 42635, 42636, 42637, 42638, + 42639, 42640, 42641, 42642, 42643, 42644, 42645, 42646, 42647, 42648, 42649, 42650, 42651, + 42652, 42653, 42654, 42655, 42656, 9793, 9794, 9796, 9797, 9798, 9801, 9802, 9803, + 9804, 9805, 9806, 9807, 9808, 9809, 9810, 9811, 9813, 9814, 9816, 9817, 9818, + 9819, 9820, 9821, 9785, 9786, 9787, 9788, 9789, 9790, 9791, 9792, 9825, 9826, + 9828, 9829, 9830, 9833, 9834, 9835, 9836, 9837, 9838, 9839, 9840, 9841, 9842, + 9843, 9845, 9846, 9848, 9849, 9850, 9851, 9852, 9853, 42713, 42714, 42715, 42716, + 42717, 42718, 42719, 42720, 42721, 42722, 42723, 42724, 42725, 42726, 42727, 42728, 42729, + 42730, 42731, 42732, 42733, 42734, 42735, 42736, 42737, 42738, 42739, 42740, 42741, 42742, + 42743, 42744, 42745, 42746, 42747, 42748, 42749, 42750, 42751}; + static unsigned short eucA8[TABLESIZE] = { - 43008, 43009, 43010, 43011, 43012, 43013, 43014, 43015, - 43016, 43017, 43018, 43019, 43020, 43021, 43022, 43023, - 43024, 43025, 43026, 43027, 43028, 43029, 43030, 43031, - 43032, 43033, 43034, 43035, 43036, 43037, 43038, 43039, - 43040, 43041, 43042, 43043, 43044, 43045, 43046, 43047, - 43048, 43049, 43050, 43051, 43052, 43053, 43054, 43055, - 43056, 43057, 43058, 43059, 43060, 43061, 43062, 43063, - 43064, 43065, 43066, 43067, 43068, 43069, 43070, 43071, - 43072, 43073, 43074, 43075, 43076, 43077, 43078, 43079, - 43080, 43081, 43082, 43083, 43084, 43085, 43086, 43087, - 43088, 43089, 43090, 43091, 43092, 43093, 43094, 43095, - 43096, 43097, 43098, 43099, 43100, 43101, 43102, 43103, - 43104, 43105, 43106, 43107, 43108, 43109, 43110, 43111, - 43112, 43113, 43114, 43115, 43116, 43117, 43118, 43119, - 43120, 43121, 43122, 43123, 43124, 43125, 43126, 43127, - 43128, 43129, 43130, 43131, 43132, 43133, 43134, 43135, - 43136, 43137, 43138, 43139, 43140, 43141, 43142, 43143, - 43144, 43145, 43146, 43147, 43148, 43149, 43150, 43151, - 43152, 43153, 43154, 43155, 43156, 43157, 43158, 43159, - 43160, 43161, 43162, 43163, 43164, 43165, 43166, 43167, - 43168, 61413, 61412, 10275, 10276, 10277, 10278, 10279, - 10280, 10281, 10282, 61414, 61410, 61409, 10286, 10287, - 10288, 10289, 10290, 10291, 10292, 10293, 61411, 10295, - 10296, 10297, 10298, 10299, 10300, 10301, 10302, 10303, - 10304, 43201, 43202, 43203, 43204, 43205, 43206, 43207, - 43208, 43209, 43210, 43211, 43212, 43213, 43214, 43215, - 43216, 43217, 43218, 43219, 43220, 43221, 43222, 43223, - 43224, 43225, 43226, 43227, 43228, 43229, 43230, 43231, - 43232, 43233, 43234, 43235, 43236, 43237, 43238, 43239, - 43240, 43241, 43242, 43243, 43244, 43245, 43246, 43247, - 43248, 43249, 43250, 43251, 43252, 43253, 43254, 43255, - 43256, 43257, 43258, 43259, 43260, 43261, 43262, 43263 -}; - - + 43008, 43009, 43010, 43011, 43012, 43013, 43014, 43015, 43016, 43017, 43018, 43019, 43020, + 43021, 43022, 43023, 43024, 43025, 43026, 43027, 43028, 43029, 43030, 43031, 43032, 43033, + 43034, 43035, 43036, 43037, 43038, 43039, 43040, 43041, 43042, 43043, 43044, 43045, 43046, + 43047, 43048, 43049, 43050, 43051, 43052, 43053, 43054, 43055, 43056, 43057, 43058, 43059, + 43060, 43061, 43062, 43063, 43064, 43065, 43066, 43067, 43068, 43069, 43070, 43071, 43072, + 43073, 43074, 43075, 43076, 43077, 43078, 43079, 43080, 43081, 43082, 43083, 43084, 43085, + 43086, 43087, 43088, 43089, 43090, 43091, 43092, 43093, 43094, 43095, 43096, 43097, 43098, + 43099, 43100, 43101, 43102, 43103, 43104, 43105, 43106, 43107, 43108, 43109, 43110, 43111, + 43112, 43113, 43114, 43115, 43116, 43117, 43118, 43119, 43120, 43121, 43122, 43123, 43124, + 43125, 43126, 43127, 43128, 43129, 43130, 43131, 43132, 43133, 43134, 43135, 43136, 43137, + 43138, 43139, 43140, 43141, 43142, 43143, 43144, 43145, 43146, 43147, 43148, 43149, 43150, + 43151, 43152, 43153, 43154, 43155, 43156, 43157, 43158, 43159, 43160, 43161, 43162, 43163, + 43164, 43165, 43166, 43167, 43168, 61413, 61412, 10275, 10276, 10277, 10278, 10279, 10280, + 10281, 10282, 61414, 61410, 61409, 10286, 10287, 10288, 10289, 10290, 10291, 10292, 10293, + 61411, 10295, 10296, 10297, 10298, 10299, 10300, 10301, 10302, 10303, 10304, 43201, 43202, + 43203, 43204, 43205, 43206, 43207, 43208, 43209, 43210, 43211, 43212, 43213, 43214, 43215, + 43216, 43217, 43218, 43219, 43220, 43221, 43222, 43223, 43224, 43225, 43226, 43227, 43228, + 43229, 43230, 43231, 43232, 43233, 43234, 43235, 43236, 43237, 43238, 43239, 43240, 43241, + 43242, 43243, 43244, 43245, 43246, 43247, 43248, 43249, 43250, 43251, 43252, 43253, 43254, + 43255, 43256, 43257, 43258, 43259, 43260, 43261, 43262, 43263}; + static unsigned short eucF4[TABLESIZE] = { - 62464, 62465, 62466, 62467, 62468, 62469, 62470, 62471, - 62472, 62473, 62474, 62475, 62476, 62477, 62478, 62479, - 62480, 62481, 62482, 62483, 62484, 62485, 62486, 62487, - 62488, 62489, 62490, 62491, 62492, 62493, 62494, 62495, - 62496, 62497, 62498, 62499, 62500, 62501, 62502, 62503, - 62504, 62505, 62506, 62507, 62508, 62509, 62510, 62511, - 62512, 62513, 62514, 62515, 62516, 62517, 62518, 62519, - 62520, 62521, 62522, 62523, 62524, 62525, 62526, 62527, - 62528, 62529, 62530, 62531, 62532, 62533, 62534, 62535, - 62536, 62537, 62538, 62539, 62540, 62541, 62542, 62543, - 62544, 62545, 62546, 62547, 62548, 62549, 62550, 62551, - 62552, 62553, 62554, 62555, 62556, 62557, 62558, 62559, - 62560, 62561, 62562, 62563, 62564, 62565, 62566, 62567, - 62568, 62569, 62570, 62571, 62572, 62573, 62574, 62575, - 62576, 62577, 62578, 62579, 62580, 62581, 62582, 62583, - 62584, 62585, 62586, 62587, 62588, 62589, 62590, 62591, - 62592, 62593, 62594, 62595, 62596, 62597, 62598, 62599, - 62600, 62601, 62602, 62603, 62604, 62605, 62606, 62607, - 62608, 62609, 62610, 62611, 62612, 62613, 62614, 62615, - 62616, 62617, 62618, 62619, 62620, 62621, 62622, 62623, - 62624, 29985, 29986, 29987, 29988, 62629, 62630, 62631, - 62632, 62633, 62634, 62635, 62636, 62637, 62638, 62639, - 62640, 62641, 62642, 62643, 62644, 62645, 62646, 62647, - 62648, 62649, 62650, 62651, 62652, 62653, 62654, 62655, - 62656, 62657, 62658, 62659, 62660, 62661, 62662, 62663, - 62664, 62665, 62666, 62667, 62668, 62669, 62670, 62671, - 62672, 62673, 62674, 62675, 62676, 62677, 62678, 62679, - 62680, 62681, 62682, 62683, 62684, 62685, 62686, 62687, - 62688, 62689, 62690, 62691, 62692, 62693, 62694, 62695, - 62696, 62697, 62698, 62699, 62700, 62701, 62702, 62703, - 62704, 62705, 62706, 62707, 62708, 62709, 62710, 62711, - 62712, 62713, 62714, 62715, 62716, 62717, 62718, 62719 -}; - - - + 62464, 62465, 62466, 62467, 62468, 62469, 62470, 62471, 62472, 62473, 62474, 62475, 62476, + 62477, 62478, 62479, 62480, 62481, 62482, 62483, 62484, 62485, 62486, 62487, 62488, 62489, + 62490, 62491, 62492, 62493, 62494, 62495, 62496, 62497, 62498, 62499, 62500, 62501, 62502, + 62503, 62504, 62505, 62506, 62507, 62508, 62509, 62510, 62511, 62512, 62513, 62514, 62515, + 62516, 62517, 62518, 62519, 62520, 62521, 62522, 62523, 62524, 62525, 62526, 62527, 62528, + 62529, 62530, 62531, 62532, 62533, 62534, 62535, 62536, 62537, 62538, 62539, 62540, 62541, + 62542, 62543, 62544, 62545, 62546, 62547, 62548, 62549, 62550, 62551, 62552, 62553, 62554, + 62555, 62556, 62557, 62558, 62559, 62560, 62561, 62562, 62563, 62564, 62565, 62566, 62567, + 62568, 62569, 62570, 62571, 62572, 62573, 62574, 62575, 62576, 62577, 62578, 62579, 62580, + 62581, 62582, 62583, 62584, 62585, 62586, 62587, 62588, 62589, 62590, 62591, 62592, 62593, + 62594, 62595, 62596, 62597, 62598, 62599, 62600, 62601, 62602, 62603, 62604, 62605, 62606, + 62607, 62608, 62609, 62610, 62611, 62612, 62613, 62614, 62615, 62616, 62617, 62618, 62619, + 62620, 62621, 62622, 62623, 62624, 29985, 29986, 29987, 29988, 62629, 62630, 62631, 62632, + 62633, 62634, 62635, 62636, 62637, 62638, 62639, 62640, 62641, 62642, 62643, 62644, 62645, + 62646, 62647, 62648, 62649, 62650, 62651, 62652, 62653, 62654, 62655, 62656, 62657, 62658, + 62659, 62660, 62661, 62662, 62663, 62664, 62665, 62666, 62667, 62668, 62669, 62670, 62671, + 62672, 62673, 62674, 62675, 62676, 62677, 62678, 62679, 62680, 62681, 62682, 62683, 62684, + 62685, 62686, 62687, 62688, 62689, 62690, 62691, 62692, 62693, 62694, 62695, 62696, 62697, + 62698, 62699, 62700, 62701, 62702, 62703, 62704, 62705, 62706, 62707, 62708, 62709, 62710, + 62711, 62712, 62713, 62714, 62715, 62716, 62717, 62718, 62719}; + /* initializeNSToeucConversionTables */ - + static unsigned short ns00[TABLESIZE] = { - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 41904, 41905, 41906, 41907, 41908, 41909, 41910, 41911, - 41912, 41913, 58, 59, 60, 61, 62, 63, - 64, 41921, 41922, 41923, 41924, 41925, 41926, 41927, - 41928, 41929, 41930, 41931, 41932, 41933, 41934, 41935, - 41936, 41937, 41938, 41939, 41940, 41941, 41942, 41943, - 41944, 41945, 41946, 91, 92, 93, 94, 95, - 96, 41953, 41954, 41955, 41956, 41957, 41958, 41959, - 41960, 41961, 41962, 41963, 41964, 41965, 41966, 41967, - 41968, 41969, 41970, 41971, 41972, 41973, 41974, 41975, - 41976, 41977, 41978, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 41457, 41458, 41456, 41455, 166, 41464, - 168, 41414, 41416, 41428, 41643, 41644, 41642, 41645, - 41451, 41438, 178, 179, 41439, 181, 41721, 41382, - 41440, 41415, 41417, 41429, 188, 189, 190, 191, - 192, 41390, 41389, 41392, 196, 197, 198, 199, - 41391, 201, 202, 203, 41394, 205, 206, 207, - 208, 209, 210, 211, 212, 41718, 214, 215, - 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, - 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, - 248, 249, 250, 251, 252, 253, 254, 255 -}; - + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 41904, 41905, 41906, 41907, + 41908, 41909, 41910, 41911, 41912, 41913, 58, 59, 60, 61, 62, 63, 64, + 41921, 41922, 41923, 41924, 41925, 41926, 41927, 41928, 41929, 41930, 41931, 41932, 41933, + 41934, 41935, 41936, 41937, 41938, 41939, 41940, 41941, 41942, 41943, 41944, 41945, 41946, + 91, 92, 93, 94, 95, 96, 41953, 41954, 41955, 41956, 41957, 41958, 41959, + 41960, 41961, 41962, 41963, 41964, 41965, 41966, 41967, 41968, 41969, 41970, 41971, 41972, + 41973, 41974, 41975, 41976, 41977, 41978, 123, 124, 125, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, + 156, 157, 158, 159, 160, 161, 41457, 41458, 41456, 41455, 166, 41464, 168, + 41414, 41416, 41428, 41643, 41644, 41642, 41645, 41451, 41438, 178, 179, 41439, 181, + 41721, 41382, 41440, 41415, 41417, 41429, 188, 189, 190, 191, 192, 41390, 41389, + 41392, 196, 197, 198, 199, 41391, 201, 202, 203, 41394, 205, 206, 207, + 208, 209, 210, 211, 212, 41718, 214, 215, 216, 217, 218, 219, 220, + 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, + 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, + 247, 248, 249, 250, 251, 252, 253, 254, 255}; + static unsigned short ns23[TABLESIZE] = { - 8960, 8961, 8962, 8963, 8964, 8965, 8966, 8967, - 8968, 8969, 8970, 8971, 8972, 8973, 8974, 8975, - 8976, 8977, 8978, 8979, 8980, 8981, 8982, 8983, - 8984, 8985, 8986, 8987, 8988, 8989, 8990, 8991, - 8992, 8993, 8994, 8995, 8996, 8997, 8998, 8999, - 9000, 9001, 9002, 9003, 9004, 9005, 9006, 9007, - 9008, 9009, 9010, 9011, 9012, 9013, 9014, 9015, - 9016, 9017, 9018, 9019, 9020, 9021, 9022, 9023, - 9024, 9025, 9026, 9027, 9028, 9029, 9030, 9031, - 9032, 9033, 9034, 9035, 9036, 9037, 9038, 9039, - 9040, 9041, 9042, 9043, 9044, 9045, 9046, 9047, - 9048, 9049, 9050, 9051, 9052, 9053, 9054, 9055, - 9056, 9057, 9058, 9059, 9060, 9061, 9062, 9063, - 9064, 9065, 9066, 9067, 9068, 9069, 9070, 9071, - 9072, 9073, 9074, 9075, 9076, 9077, 9078, 9079, - 9080, 9081, 9082, 9083, 9084, 9085, 9086, 9087, - 9088, 9089, 9090, 9091, 9092, 9093, 9094, 9095, - 9096, 9097, 9098, 9099, 9100, 9101, 9102, 9103, - 9104, 9105, 9106, 9107, 9108, 9109, 9110, 9111, - 9112, 9113, 9114, 9115, 9116, 9117, 9118, 9119, - 9120, 9121, 9122, 9123, 9124, 9125, 9126, 9127, - 9128, 9129, 9130, 9131, 41717, 9133, 9134, 9135, - 9136, 9137, 9138, 9139, 9140, 9141, 9142, 9143, - 9144, 9145, 9146, 9147, 41716, 9149, 9150, 9151, - 9152, 9153, 9154, 41393, 9156, 9157, 9158, 9159, - 9160, 9161, 9162, 9163, 9164, 9165, 9166, 9167, - 9168, 9169, 9170, 9171, 9172, 9173, 9174, 9175, - 9176, 9177, 9178, 9179, 9180, 9181, 9182, 9183, - 9184, 9185, 9186, 9187, 9188, 9189, 9190, 9191, - 9192, 9193, 9194, 9195, 9196, 9197, 9198, 9199, - 9200, 9201, 9202, 9203, 9204, 9205, 9206, 9207, - 9208, 9209, 9210, 9211, 9212, 9213, 9214, 9215 -}; - + 8960, 8961, 8962, 8963, 8964, 8965, 8966, 8967, 8968, 8969, 8970, 8971, 8972, 8973, 8974, + 8975, 8976, 8977, 8978, 8979, 8980, 8981, 8982, 8983, 8984, 8985, 8986, 8987, 8988, 8989, + 8990, 8991, 8992, 8993, 8994, 8995, 8996, 8997, 8998, 8999, 9000, 9001, 9002, 9003, 9004, + 9005, 9006, 9007, 9008, 9009, 9010, 9011, 9012, 9013, 9014, 9015, 9016, 9017, 9018, 9019, + 9020, 9021, 9022, 9023, 9024, 9025, 9026, 9027, 9028, 9029, 9030, 9031, 9032, 9033, 9034, + 9035, 9036, 9037, 9038, 9039, 9040, 9041, 9042, 9043, 9044, 9045, 9046, 9047, 9048, 9049, + 9050, 9051, 9052, 9053, 9054, 9055, 9056, 9057, 9058, 9059, 9060, 9061, 9062, 9063, 9064, + 9065, 9066, 9067, 9068, 9069, 9070, 9071, 9072, 9073, 9074, 9075, 9076, 9077, 9078, 9079, + 9080, 9081, 9082, 9083, 9084, 9085, 9086, 9087, 9088, 9089, 9090, 9091, 9092, 9093, 9094, + 9095, 9096, 9097, 9098, 9099, 9100, 9101, 9102, 9103, 9104, 9105, 9106, 9107, 9108, 9109, + 9110, 9111, 9112, 9113, 9114, 9115, 9116, 9117, 9118, 9119, 9120, 9121, 9122, 9123, 9124, + 9125, 9126, 9127, 9128, 9129, 9130, 9131, 41717, 9133, 9134, 9135, 9136, 9137, 9138, 9139, + 9140, 9141, 9142, 9143, 9144, 9145, 9146, 9147, 41716, 9149, 9150, 9151, 9152, 9153, 9154, + 41393, 9156, 9157, 9158, 9159, 9160, 9161, 9162, 9163, 9164, 9165, 9166, 9167, 9168, 9169, + 9170, 9171, 9172, 9173, 9174, 9175, 9176, 9177, 9178, 9179, 9180, 9181, 9182, 9183, 9184, + 9185, 9186, 9187, 9188, 9189, 9190, 9191, 9192, 9193, 9194, 9195, 9196, 9197, 9198, 9199, + 9200, 9201, 9202, 9203, 9204, 9205, 9206, 9207, 9208, 9209, 9210, 9211, 9212, 9213, 9214, + 9215}; + static unsigned short ns26[TABLESIZE] = { - 9728, 9729, 9730, 9731, 9732, 9733, 9734, 9735, - 9736, 9737, 9738, 9739, 9740, 9741, 9742, 9743, - 9744, 9745, 9746, 9747, 9748, 9749, 9750, 9751, - 9752, 9753, 9754, 9755, 9756, 9757, 9758, 9759, - 9760, 9761, 9762, 9763, 9764, 9765, 9766, 9767, - 9768, 9769, 9770, 9771, 9772, 9773, 9774, 9775, - 9776, 9777, 9778, 9779, 9780, 9781, 9782, 9783, - 9784, 42681, 42682, 42683, 42684, 42685, 42686, 42687, - 42688, 42657, 42658, 9795, 42659, 42660, 42661, 9799, - 9800, 42662, 42663, 42664, 42665, 42666, 42667, 42668, - 42669, 42670, 42671, 42672, 9812, 42673, 42674, 9815, - 42675, 42676, 42677, 42678, 42679, 42680, 9822, 9823, - 9824, 42689, 42690, 9827, 42691, 42692, 42693, 9831, - 9832, 42694, 42695, 42696, 42697, 42698, 42699, 42700, - 42701, 42702, 42703, 42704, 9844, 42705, 42706, 9847, - 42707, 42708, 42709, 42710, 42711, 42712, 9854, 9855, - 9856, 9857, 9858, 9859, 9860, 9861, 9862, 9863, - 9864, 9865, 9866, 9867, 9868, 9869, 9870, 9871, - 9872, 9873, 9874, 9875, 9876, 9877, 9878, 9879, - 9880, 9881, 9882, 9883, 9884, 9885, 9886, 9887, - 9888, 9889, 9890, 9891, 9892, 9893, 9894, 9895, - 9896, 9897, 9898, 9899, 9900, 9901, 9902, 9903, - 9904, 9905, 9906, 9907, 9908, 9909, 9910, 9911, - 9912, 9913, 9914, 9915, 9916, 9917, 9918, 9919, - 9920, 9921, 9922, 9923, 9924, 9925, 9926, 9927, - 9928, 9929, 9930, 9931, 9932, 9933, 9934, 9935, - 9936, 9937, 9938, 9939, 9940, 9941, 9942, 9943, - 9944, 9945, 9946, 9947, 9948, 9949, 9950, 9951, - 9952, 9953, 9954, 9955, 9956, 9957, 9958, 9959, - 9960, 9961, 9962, 9963, 9964, 9965, 9966, 9967, - 9968, 9969, 9970, 9971, 9972, 9973, 9974, 9975, - 9976, 9977, 9978, 9979, 9980, 9981, 9982, 9983 -}; - + 9728, 9729, 9730, 9731, 9732, 9733, 9734, 9735, 9736, 9737, 9738, 9739, 9740, + 9741, 9742, 9743, 9744, 9745, 9746, 9747, 9748, 9749, 9750, 9751, 9752, 9753, + 9754, 9755, 9756, 9757, 9758, 9759, 9760, 9761, 9762, 9763, 9764, 9765, 9766, + 9767, 9768, 9769, 9770, 9771, 9772, 9773, 9774, 9775, 9776, 9777, 9778, 9779, + 9780, 9781, 9782, 9783, 9784, 42681, 42682, 42683, 42684, 42685, 42686, 42687, 42688, + 42657, 42658, 9795, 42659, 42660, 42661, 9799, 9800, 42662, 42663, 42664, 42665, 42666, + 42667, 42668, 42669, 42670, 42671, 42672, 9812, 42673, 42674, 9815, 42675, 42676, 42677, + 42678, 42679, 42680, 9822, 9823, 9824, 42689, 42690, 9827, 42691, 42692, 42693, 9831, + 9832, 42694, 42695, 42696, 42697, 42698, 42699, 42700, 42701, 42702, 42703, 42704, 9844, + 42705, 42706, 9847, 42707, 42708, 42709, 42710, 42711, 42712, 9854, 9855, 9856, 9857, + 9858, 9859, 9860, 9861, 9862, 9863, 9864, 9865, 9866, 9867, 9868, 9869, 9870, + 9871, 9872, 9873, 9874, 9875, 9876, 9877, 9878, 9879, 9880, 9881, 9882, 9883, + 9884, 9885, 9886, 9887, 9888, 9889, 9890, 9891, 9892, 9893, 9894, 9895, 9896, + 9897, 9898, 9899, 9900, 9901, 9902, 9903, 9904, 9905, 9906, 9907, 9908, 9909, + 9910, 9911, 9912, 9913, 9914, 9915, 9916, 9917, 9918, 9919, 9920, 9921, 9922, + 9923, 9924, 9925, 9926, 9927, 9928, 9929, 9930, 9931, 9932, 9933, 9934, 9935, + 9936, 9937, 9938, 9939, 9940, 9941, 9942, 9943, 9944, 9945, 9946, 9947, 9948, + 9949, 9950, 9951, 9952, 9953, 9954, 9955, 9956, 9957, 9958, 9959, 9960, 9961, + 9962, 9963, 9964, 9965, 9966, 9967, 9968, 9969, 9970, 9971, 9972, 9973, 9974, + 9975, 9976, 9977, 9978, 9979, 9980, 9981, 9982, 9983}; + static unsigned short ns75[TABLESIZE] = { - 29952, 29953, 29954, 29955, 29956, 29957, 29958, 29959, - 29960, 29961, 29962, 29963, 29964, 29965, 29966, 29967, - 29968, 29969, 29970, 29971, 29972, 29973, 29974, 29975, - 29976, 29977, 29978, 29979, 29980, 29981, 29982, 29983, - 29984, 62625, 62626, 62627, 62628, 62885, 62886, 62887, - 62888, 62889, 62890, 62891, 62892, 62893, 62894, 62895, - 62896, 62897, 62898, 62899, 62900, 62901, 62902, 62903, - 62904, 62905, 62906, 62907, 62908, 62909, 62910, 62911, - 62912, 62913, 62914, 62915, 62916, 62917, 62918, 62919, - 62920, 62921, 62922, 62923, 62924, 62925, 62926, 62927, - 62928, 62929, 62930, 62931, 62932, 62933, 62934, 62935, - 62936, 62937, 62938, 62939, 62940, 62941, 62942, 62943, - 62944, 62945, 62946, 62947, 62948, 62949, 62950, 62951, - 62952, 62953, 62954, 62955, 62956, 62957, 62958, 62959, - 62960, 62961, 62962, 62963, 62964, 62965, 62966, 62967, - 62968, 62969, 62970, 62971, 62972, 62973, 62974, 30079, - 30080, 30081, 30082, 30083, 30084, 30085, 30086, 30087, - 30088, 30089, 30090, 30091, 30092, 30093, 30094, 30095, - 30096, 30097, 30098, 30099, 30100, 30101, 30102, 30103, - 30104, 30105, 30106, 30107, 30108, 30109, 30110, 30111, - 30112, 30113, 30114, 30115, 30116, 30117, 30118, 30119, - 30120, 30121, 30122, 30123, 30124, 30125, 30126, 30127, - 30128, 30129, 30130, 30131, 30132, 30133, 30134, 30135, - 30136, 30137, 30138, 30139, 30140, 30141, 30142, 30143, - 30144, 30145, 30146, 30147, 30148, 30149, 30150, 30151, - 30152, 30153, 30154, 30155, 30156, 30157, 30158, 30159, - 30160, 30161, 30162, 30163, 30164, 30165, 30166, 30167, - 30168, 30169, 30170, 30171, 30172, 30173, 30174, 30175, - 30176, 30177, 30178, 30179, 30180, 30181, 30182, 30183, - 30184, 30185, 30186, 30187, 30188, 30189, 30190, 30191, - 30192, 30193, 30194, 30195, 30196, 30197, 30198, 30199, - 30200, 30201, 30202, 30203, 30204, 30205, 30206, 30207 -}; - + 29952, 29953, 29954, 29955, 29956, 29957, 29958, 29959, 29960, 29961, 29962, 29963, 29964, + 29965, 29966, 29967, 29968, 29969, 29970, 29971, 29972, 29973, 29974, 29975, 29976, 29977, + 29978, 29979, 29980, 29981, 29982, 29983, 29984, 62625, 62626, 62627, 62628, 62885, 62886, + 62887, 62888, 62889, 62890, 62891, 62892, 62893, 62894, 62895, 62896, 62897, 62898, 62899, + 62900, 62901, 62902, 62903, 62904, 62905, 62906, 62907, 62908, 62909, 62910, 62911, 62912, + 62913, 62914, 62915, 62916, 62917, 62918, 62919, 62920, 62921, 62922, 62923, 62924, 62925, + 62926, 62927, 62928, 62929, 62930, 62931, 62932, 62933, 62934, 62935, 62936, 62937, 62938, + 62939, 62940, 62941, 62942, 62943, 62944, 62945, 62946, 62947, 62948, 62949, 62950, 62951, + 62952, 62953, 62954, 62955, 62956, 62957, 62958, 62959, 62960, 62961, 62962, 62963, 62964, + 62965, 62966, 62967, 62968, 62969, 62970, 62971, 62972, 62973, 62974, 30079, 30080, 30081, + 30082, 30083, 30084, 30085, 30086, 30087, 30088, 30089, 30090, 30091, 30092, 30093, 30094, + 30095, 30096, 30097, 30098, 30099, 30100, 30101, 30102, 30103, 30104, 30105, 30106, 30107, + 30108, 30109, 30110, 30111, 30112, 30113, 30114, 30115, 30116, 30117, 30118, 30119, 30120, + 30121, 30122, 30123, 30124, 30125, 30126, 30127, 30128, 30129, 30130, 30131, 30132, 30133, + 30134, 30135, 30136, 30137, 30138, 30139, 30140, 30141, 30142, 30143, 30144, 30145, 30146, + 30147, 30148, 30149, 30150, 30151, 30152, 30153, 30154, 30155, 30156, 30157, 30158, 30159, + 30160, 30161, 30162, 30163, 30164, 30165, 30166, 30167, 30168, 30169, 30170, 30171, 30172, + 30173, 30174, 30175, 30176, 30177, 30178, 30179, 30180, 30181, 30182, 30183, 30184, 30185, + 30186, 30187, 30188, 30189, 30190, 30191, 30192, 30193, 30194, 30195, 30196, 30197, 30198, + 30199, 30200, 30201, 30202, 30203, 30204, 30205, 30206, 30207}; + static unsigned short nsEE[TABLESIZE] = { - 60928, 60929, 60930, 60931, 60932, 60933, 60934, 60935, - 60936, 60937, 60938, 60939, 60940, 60941, 60942, 60943, - 60944, 60945, 60946, 60947, 60948, 60949, 60950, 60951, - 60952, 60953, 60954, 60955, 60956, 60957, 60958, 60959, - 60960, 60961, 60962, 60963, 60964, 60965, 60966, 60967, - 60968, 60969, 60970, 60971, 60972, 60973, 60974, 60975, - 60976, 60977, 60978, 60979, 60980, 60981, 60982, 60983, - 60984, 60985, 60986, 60987, 60988, 60989, 60990, 60991, - 60992, 60993, 60994, 60995, 60996, 60997, 60998, 60999, - 61000, 61001, 61002, 61003, 61004, 61005, 61006, 61007, - 61008, 61009, 61010, 61011, 61012, 61013, 61014, 61015, - 61016, 61017, 61018, 61019, 61020, 61021, 61022, 61023, - 61024, 61025, 61026, 61027, 61028, 61029, 61030, 61031, - 61032, 61033, 61034, 61035, 61036, 61037, 61038, 61039, - 61040, 61041, 61042, 61043, 61044, 61045, 61046, 61047, - 61048, 61049, 61050, 61051, 61052, 61053, 41409, 61055, - 61056, 61057, 61058, 61059, 61060, 61061, 61062, 61063, - 61064, 61065, 61066, 61067, 61068, 61069, 61070, 61071, - 61072, 61073, 61074, 61075, 61076, 61077, 61078, 61079, - 61080, 61081, 61082, 61083, 61084, 61085, 61086, 61087, - 61088, 61089, 61090, 61091, 61092, 61093, 61094, 61095, - 61096, 61097, 61098, 61099, 61100, 61101, 61102, 61103, - 61104, 61105, 61106, 61107, 61108, 61109, 61110, 61111, - 61112, 61113, 61114, 61115, 61116, 61117, 61118, 61119, - 61120, 61121, 61122, 61123, 61124, 61125, 61126, 61127, - 61128, 61129, 61130, 61131, 61132, 61133, 61134, 61135, - 61136, 61137, 61138, 61139, 61140, 61141, 61142, 61143, - 61144, 61145, 61146, 61147, 61148, 61149, 61150, 61151, - 61152, 61153, 61154, 61155, 61156, 61157, 61158, 61159, - 61160, 61161, 61162, 61163, 61164, 61165, 61166, 61167, - 61168, 61169, 61170, 61171, 61172, 61173, 61174, 61175, - 61176, 61177, 61178, 61179, 61180, 61181, 61182, 61183 -}; - + 60928, 60929, 60930, 60931, 60932, 60933, 60934, 60935, 60936, 60937, 60938, 60939, 60940, + 60941, 60942, 60943, 60944, 60945, 60946, 60947, 60948, 60949, 60950, 60951, 60952, 60953, + 60954, 60955, 60956, 60957, 60958, 60959, 60960, 60961, 60962, 60963, 60964, 60965, 60966, + 60967, 60968, 60969, 60970, 60971, 60972, 60973, 60974, 60975, 60976, 60977, 60978, 60979, + 60980, 60981, 60982, 60983, 60984, 60985, 60986, 60987, 60988, 60989, 60990, 60991, 60992, + 60993, 60994, 60995, 60996, 60997, 60998, 60999, 61000, 61001, 61002, 61003, 61004, 61005, + 61006, 61007, 61008, 61009, 61010, 61011, 61012, 61013, 61014, 61015, 61016, 61017, 61018, + 61019, 61020, 61021, 61022, 61023, 61024, 61025, 61026, 61027, 61028, 61029, 61030, 61031, + 61032, 61033, 61034, 61035, 61036, 61037, 61038, 61039, 61040, 61041, 61042, 61043, 61044, + 61045, 61046, 61047, 61048, 61049, 61050, 61051, 61052, 61053, 41409, 61055, 61056, 61057, + 61058, 61059, 61060, 61061, 61062, 61063, 61064, 61065, 61066, 61067, 61068, 61069, 61070, + 61071, 61072, 61073, 61074, 61075, 61076, 61077, 61078, 61079, 61080, 61081, 61082, 61083, + 61084, 61085, 61086, 61087, 61088, 61089, 61090, 61091, 61092, 61093, 61094, 61095, 61096, + 61097, 61098, 61099, 61100, 61101, 61102, 61103, 61104, 61105, 61106, 61107, 61108, 61109, + 61110, 61111, 61112, 61113, 61114, 61115, 61116, 61117, 61118, 61119, 61120, 61121, 61122, + 61123, 61124, 61125, 61126, 61127, 61128, 61129, 61130, 61131, 61132, 61133, 61134, 61135, + 61136, 61137, 61138, 61139, 61140, 61141, 61142, 61143, 61144, 61145, 61146, 61147, 61148, + 61149, 61150, 61151, 61152, 61153, 61154, 61155, 61156, 61157, 61158, 61159, 61160, 61161, + 61162, 61163, 61164, 61165, 61166, 61167, 61168, 61169, 61170, 61171, 61172, 61173, 61174, + 61175, 61176, 61177, 61178, 61179, 61180, 61181, 61182, 61183}; + static unsigned short nsEF[TABLESIZE] = { - 61184, 61185, 61186, 61187, 61188, 61189, 61190, 61191, - 61192, 61193, 61194, 61195, 61196, 61197, 61198, 61199, - 61200, 61201, 61202, 61203, 61204, 61205, 61206, 61207, - 61208, 61209, 61210, 61211, 61212, 61213, 61214, 61215, - 61216, 61217, 61218, 61219, 41405, 41405, 61222, 61223, - 61224, 61225, 41426, 41427, 61228, 61229, 61230, 61231, - 41719, 41720, 41426, 41427, 61236, 61237, 61238, 61239, - 61240, 61241, 61242, 61243, 61244, 61245, 61246, 61247, - 61248, 41715, 41699, 41700, 61252, 61253, 61254, 61255, - 61256, 61257, 41658, 61259, 41659, 61261, 41678, 41677, - 61264, 61265, 61266, 61267, 61268, 61269, 41665, 41664, - 41661, 41660, 41663, 41662, 61276, 61277, 61278, 61279, - 61280, 61281, 61282, 61283, 61284, 61285, 61286, 61287, - 61288, 61289, 41676, 61291, 41692, 61293, 61294, 41704, - 41693, 41703, 41697, 61299, 61300, 41705, 61302, 61303, - 61304, 61305, 61306, 61307, 41701, 61309, 61310, 61311, - 61312, 61313, 61314, 61315, 61316, 61317, 61318, 61319, - 61320, 61321, 61322, 61323, 61324, 61325, 61326, 61327, - 61328, 61329, 61330, 61331, 61332, 61333, 61334, 61335, - 61336, 61337, 61338, 61339, 61340, 61341, 61342, 61343, - 61344, 61345, 61346, 61347, 61348, 61349, 61350, 61351, - 61352, 61353, 61354, 61355, 61356, 61357, 61358, 61359, - 61360, 61361, 61362, 61363, 41680, 41679, 41674, 41675, - 61368, 41696, 41695, 61371, 61372, 61373, 61374, 61375, - 41694, 61377, 61378, 61379, 61380, 61381, 61382, 61383, - 61384, 61385, 61386, 61387, 61388, 61389, 61390, 61391, - 61392, 61393, 61394, 61395, 61396, 61397, 61398, 61399, - 61400, 61401, 61402, 61403, 61404, 61405, 61406, 61407, - 61408, 43181, 43180, 43190, 43170, 43169, 43179, 61415, - 61416, 61417, 61418, 61419, 61420, 61421, 61422, 61423, - 61424, 61425, 61426, 61427, 61428, 61429, 61430, 61431, - 61432, 61433, 61434, 61435, 61436, 61437, 61438, 61439 -}; - + 61184, 61185, 61186, 61187, 61188, 61189, 61190, 61191, 61192, 61193, 61194, 61195, 61196, + 61197, 61198, 61199, 61200, 61201, 61202, 61203, 61204, 61205, 61206, 61207, 61208, 61209, + 61210, 61211, 61212, 61213, 61214, 61215, 61216, 61217, 61218, 61219, 41405, 41405, 61222, + 61223, 61224, 61225, 41426, 41427, 61228, 61229, 61230, 61231, 41719, 41720, 41426, 41427, + 61236, 61237, 61238, 61239, 61240, 61241, 61242, 61243, 61244, 61245, 61246, 61247, 61248, + 41715, 41699, 41700, 61252, 61253, 61254, 61255, 61256, 61257, 41658, 61259, 41659, 61261, + 41678, 41677, 61264, 61265, 61266, 61267, 61268, 61269, 41665, 41664, 41661, 41660, 41663, + 41662, 61276, 61277, 61278, 61279, 61280, 61281, 61282, 61283, 61284, 61285, 61286, 61287, + 61288, 61289, 41676, 61291, 41692, 61293, 61294, 41704, 41693, 41703, 41697, 61299, 61300, + 41705, 61302, 61303, 61304, 61305, 61306, 61307, 41701, 61309, 61310, 61311, 61312, 61313, + 61314, 61315, 61316, 61317, 61318, 61319, 61320, 61321, 61322, 61323, 61324, 61325, 61326, + 61327, 61328, 61329, 61330, 61331, 61332, 61333, 61334, 61335, 61336, 61337, 61338, 61339, + 61340, 61341, 61342, 61343, 61344, 61345, 61346, 61347, 61348, 61349, 61350, 61351, 61352, + 61353, 61354, 61355, 61356, 61357, 61358, 61359, 61360, 61361, 61362, 61363, 41680, 41679, + 41674, 41675, 61368, 41696, 41695, 61371, 61372, 61373, 61374, 61375, 41694, 61377, 61378, + 61379, 61380, 61381, 61382, 61383, 61384, 61385, 61386, 61387, 61388, 61389, 61390, 61391, + 61392, 61393, 61394, 61395, 61396, 61397, 61398, 61399, 61400, 61401, 61402, 61403, 61404, + 61405, 61406, 61407, 61408, 43181, 43180, 43190, 43170, 43169, 43179, 61415, 61416, 61417, + 61418, 61419, 61420, 61421, 61422, 61423, 61424, 61425, 61426, 61427, 61428, 61429, 61430, + 61431, 61432, 61433, 61434, 61435, 61436, 61437, 61438, 61439}; + static unsigned short nsF1[TABLESIZE] = { - 61696, 61697, 61698, 61699, 61700, 61701, 61702, 61703, - 61704, 61705, 61706, 61707, 61708, 61709, 61710, 61711, - 61712, 61713, 61714, 61715, 61716, 61717, 61718, 61719, - 61720, 61721, 61722, 61723, 61724, 61725, 61726, 61727, - 61728, 61729, 61730, 61731, 61732, 61733, 61734, 61735, - 41714, 61737, 61738, 61739, 61740, 61741, 61742, 61743, - 61744, 61745, 61746, 61747, 61748, 61749, 61750, 61751, - 61752, 61753, 61754, 61755, 61756, 61757, 61758, 61759, - 61760, 61761, 61762, 61763, 61764, 61765, 61766, 61767, - 61768, 61769, 61770, 61771, 61772, 61773, 61774, 61775, - 61776, 61777, 61778, 61779, 61780, 61781, 61782, 61783, - 61784, 61785, 61786, 61787, 61788, 61789, 61790, 61791, - 61792, 61793, 61794, 61795, 61796, 61797, 61798, 61799, - 61800, 61801, 61802, 61803, 61804, 61805, 61806, 61807, - 61808, 61809, 61810, 61811, 61812, 61813, 61814, 61815, - 61816, 61817, 61818, 61819, 61820, 61821, 61822, 61823, - 61824, 61825, 61826, 61827, 61828, 61829, 61830, 61831, - 61832, 61833, 61834, 61835, 61836, 61837, 61838, 61839, - 61840, 61841, 61842, 61843, 61844, 61845, 61846, 61847, - 61848, 61849, 61850, 61851, 61852, 61853, 61854, 61855, - 61856, 61857, 61858, 61859, 61860, 61861, 61862, 61863, - 61864, 61865, 61866, 61867, 61868, 61869, 61870, 61871, - 61872, 61873, 61874, 61875, 61876, 61877, 61878, 61879, - 61880, 61881, 61882, 61883, 61884, 61885, 61886, 61887, - 61888, 61889, 61890, 61891, 61892, 61893, 61894, 61895, - 61896, 61897, 61898, 61899, 61900, 61901, 61902, 61903, - 61904, 61905, 61906, 61907, 61908, 61909, 61910, 61911, - 61912, 61913, 61914, 61915, 61916, 61917, 61918, 61919, - 61920, 61921, 61922, 61923, 61924, 61925, 61926, 61927, - 61928, 61929, 61930, 61931, 61932, 61933, 61934, 61935, - 61936, 61937, 61938, 61939, 61940, 61941, 61942, 61943, - 61944, 61945, 61946, 61947, 61948, 61949, 61950, 61951 -}; + 61696, 61697, 61698, 61699, 61700, 61701, 61702, 61703, 61704, 61705, 61706, 61707, 61708, + 61709, 61710, 61711, 61712, 61713, 61714, 61715, 61716, 61717, 61718, 61719, 61720, 61721, + 61722, 61723, 61724, 61725, 61726, 61727, 61728, 61729, 61730, 61731, 61732, 61733, 61734, + 61735, 41714, 61737, 61738, 61739, 61740, 61741, 61742, 61743, 61744, 61745, 61746, 61747, + 61748, 61749, 61750, 61751, 61752, 61753, 61754, 61755, 61756, 61757, 61758, 61759, 61760, + 61761, 61762, 61763, 61764, 61765, 61766, 61767, 61768, 61769, 61770, 61771, 61772, 61773, + 61774, 61775, 61776, 61777, 61778, 61779, 61780, 61781, 61782, 61783, 61784, 61785, 61786, + 61787, 61788, 61789, 61790, 61791, 61792, 61793, 61794, 61795, 61796, 61797, 61798, 61799, + 61800, 61801, 61802, 61803, 61804, 61805, 61806, 61807, 61808, 61809, 61810, 61811, 61812, + 61813, 61814, 61815, 61816, 61817, 61818, 61819, 61820, 61821, 61822, 61823, 61824, 61825, + 61826, 61827, 61828, 61829, 61830, 61831, 61832, 61833, 61834, 61835, 61836, 61837, 61838, + 61839, 61840, 61841, 61842, 61843, 61844, 61845, 61846, 61847, 61848, 61849, 61850, 61851, + 61852, 61853, 61854, 61855, 61856, 61857, 61858, 61859, 61860, 61861, 61862, 61863, 61864, + 61865, 61866, 61867, 61868, 61869, 61870, 61871, 61872, 61873, 61874, 61875, 61876, 61877, + 61878, 61879, 61880, 61881, 61882, 61883, 61884, 61885, 61886, 61887, 61888, 61889, 61890, + 61891, 61892, 61893, 61894, 61895, 61896, 61897, 61898, 61899, 61900, 61901, 61902, 61903, + 61904, 61905, 61906, 61907, 61908, 61909, 61910, 61911, 61912, 61913, 61914, 61915, 61916, + 61917, 61918, 61919, 61920, 61921, 61922, 61923, 61924, 61925, 61926, 61927, 61928, 61929, + 61930, 61931, 61932, 61933, 61934, 61935, 61936, 61937, 61938, 61939, 61940, 61941, 61942, + 61943, 61944, 61945, 61946, 61947, 61948, 61949, 61950, 61951}; static unsigned short nsFD[TABLESIZE] = { - 64768, 64769, 64770, 64771, 64772, 64773, 64774, 64775, - 64776, 64777, 64778, 64779, 64780, 64781, 64782, 64783, - 64784, 64785, 64786, 64787, 64788, 64789, 64790, 64791, - 64792, 64793, 64794, 64795, 64796, 64797, 64798, 64799, - 64800, 64801, 64802, 64803, 64804, 64805, 64806, 64807, - 64808, 64809, 64810, 64811, 64812, 64813, 64814, 64815, - 64816, 64817, 64818, 64819, 64820, 64821, 64822, 64823, - 64824, 64825, 64826, 64827, 64828, 64829, 64830, 64831, - 64832, 64833, 64834, 64835, 64836, 64837, 64838, 64839, - 64840, 64841, 64842, 64843, 64844, 64845, 64846, 64847, - 64848, 64849, 64850, 64851, 64852, 64853, 64854, 64855, - 64856, 64857, 64858, 64859, 64860, 64861, 64862, 64863, - 64864, 64865, 64866, 64867, 64868, 64869, 64870, 64871, - 64872, 64873, 64874, 64875, 64876, 64877, 64878, 64879, - 64880, 64881, 64882, 64883, 64884, 64885, 64886, 64887, - 64888, 64889, 64890, 64891, 41701, 64893, 41702, 64895, - 64896, 64897, 64898, 64899, 64900, 64901, 64902, 64903, - 64904, 64905, 64906, 64907, 64908, 64909, 64910, 64911, - 64912, 64913, 64914, 64915, 64916, 64917, 64918, 64919, - 64920, 64921, 64922, 64923, 64924, 64925, 64926, 64927, - 64928, 64929, 64930, 64931, 64932, 64933, 64934, 64935, - 64936, 64937, 64938, 64939, 64940, 64941, 64942, 64943, - 64944, 64945, 64946, 64947, 64948, 64949, 64950, 64951, - 64952, 64953, 64954, 64955, 64956, 64957, 64958, 64959, - 64960, 64961, 64962, 64963, 64964, 64965, 64966, 64967, - 64968, 64969, 64970, 64971, 64972, 64973, 64974, 64975, - 64976, 64977, 64978, 64979, 64980, 64981, 64982, 64983, - 64984, 64985, 64986, 64987, 64988, 64989, 64990, 64991, - 64992, 64993, 64994, 64995, 64996, 64997, 64998, 64999, - 65000, 65001, 65002, 65003, 65004, 65005, 65006, 65007, - 65008, 65009, 65010, 65011, 65012, 65013, 65014, 65015, - 65016, 65017, 65018, 65019, 65020, 65021, 65022, 65023 -}; + 64768, 64769, 64770, 64771, 64772, 64773, 64774, 64775, 64776, 64777, 64778, 64779, 64780, + 64781, 64782, 64783, 64784, 64785, 64786, 64787, 64788, 64789, 64790, 64791, 64792, 64793, + 64794, 64795, 64796, 64797, 64798, 64799, 64800, 64801, 64802, 64803, 64804, 64805, 64806, + 64807, 64808, 64809, 64810, 64811, 64812, 64813, 64814, 64815, 64816, 64817, 64818, 64819, + 64820, 64821, 64822, 64823, 64824, 64825, 64826, 64827, 64828, 64829, 64830, 64831, 64832, + 64833, 64834, 64835, 64836, 64837, 64838, 64839, 64840, 64841, 64842, 64843, 64844, 64845, + 64846, 64847, 64848, 64849, 64850, 64851, 64852, 64853, 64854, 64855, 64856, 64857, 64858, + 64859, 64860, 64861, 64862, 64863, 64864, 64865, 64866, 64867, 64868, 64869, 64870, 64871, + 64872, 64873, 64874, 64875, 64876, 64877, 64878, 64879, 64880, 64881, 64882, 64883, 64884, + 64885, 64886, 64887, 64888, 64889, 64890, 64891, 41701, 64893, 41702, 64895, 64896, 64897, + 64898, 64899, 64900, 64901, 64902, 64903, 64904, 64905, 64906, 64907, 64908, 64909, 64910, + 64911, 64912, 64913, 64914, 64915, 64916, 64917, 64918, 64919, 64920, 64921, 64922, 64923, + 64924, 64925, 64926, 64927, 64928, 64929, 64930, 64931, 64932, 64933, 64934, 64935, 64936, + 64937, 64938, 64939, 64940, 64941, 64942, 64943, 64944, 64945, 64946, 64947, 64948, 64949, + 64950, 64951, 64952, 64953, 64954, 64955, 64956, 64957, 64958, 64959, 64960, 64961, 64962, + 64963, 64964, 64965, 64966, 64967, 64968, 64969, 64970, 64971, 64972, 64973, 64974, 64975, + 64976, 64977, 64978, 64979, 64980, 64981, 64982, 64983, 64984, 64985, 64986, 64987, 64988, + 64989, 64990, 64991, 64992, 64993, 64994, 64995, 64996, 64997, 64998, 64999, 65000, 65001, + 65002, 65003, 65004, 65005, 65006, 65007, 65008, 65009, 65010, 65011, 65012, 65013, 65014, + 65015, 65016, 65017, 65018, 65019, 65020, 65021, 65022, 65023}; -unsigned short euc_ns(short unsigned int euc) -{ - unsigned short table; +unsigned short euc_ns(short unsigned int euc) { + unsigned short table; - table = euc / TABLESIZE; - switch ( table ) { - case 0xA1: - return( eucA1[ euc % TABLESIZE ] ); - case 0xA2: - return( eucA2[ euc % TABLESIZE ] ); - case 0xA3: - return( eucA3[ euc % TABLESIZE ] ); - case 0xA6: - return( eucA6[ euc % TABLESIZE ] ); - case 0xA8: - return( eucA8[ euc % TABLESIZE ] ); - case 0xF4: - return( eucF4[ euc % TABLESIZE ] ); - default: - return( euc & NSBITS ); - } + table = euc / TABLESIZE; + switch (table) { + case 0xA1: return (eucA1[euc % TABLESIZE]); + case 0xA2: return (eucA2[euc % TABLESIZE]); + case 0xA3: return (eucA3[euc % TABLESIZE]); + case 0xA6: return (eucA6[euc % TABLESIZE]); + case 0xA8: return (eucA8[euc % TABLESIZE]); + case 0xF4: return (eucF4[euc % TABLESIZE]); + default: return (euc & NSBITS); + } } -unsigned short ns_euc(short unsigned int ns) -{ - unsigned short table; +unsigned short ns_euc(short unsigned int ns) { + unsigned short table; - table = ns / TABLESIZE; - switch ( table ) { - case 0x00: - return( ns00[ ns % TABLESIZE ] ); - case 0x23: - return( ns23[ ns % TABLESIZE ] ); - case 0x26: - return( ns26[ ns % TABLESIZE ] ); - case 0x75: - return( ns75[ ns % TABLESIZE ] ); - case 0xEE: - return( nsEE[ ns % TABLESIZE ] ); - case 0xEF: - return( nsEF[ ns % TABLESIZE ] ); - case 0xF1: - return( nsF1[ ns % TABLESIZE ] ); - case 0xFD: - return( nsFD[ ns % TABLESIZE ] ); - default: - return( ns | EUCBITS ); - } + table = ns / TABLESIZE; + switch (table) { + case 0x00: return (ns00[ns % TABLESIZE]); + case 0x23: return (ns23[ns % TABLESIZE]); + case 0x26: return (ns26[ns % TABLESIZE]); + case 0x75: return (ns75[ns % TABLESIZE]); + case 0xEE: return (nsEE[ns % TABLESIZE]); + case 0xEF: return (nsEF[ns % TABLESIZE]); + case 0xF1: return (nsF1[ns % TABLESIZE]); + case 0xFD: return (nsFD[ns % TABLESIZE]); + default: return (ns | EUCBITS); + } } - - diff --git a/src/colorbltfns.c b/src/colorbltfns.c old mode 100755 new mode 100644 index 00cb054..4e4d67d --- a/src/colorbltfns.c +++ b/src/colorbltfns.c @@ -1,7 +1,7 @@ -/* $Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* C O L O R B I T B L T / G R A P H I C S S U P P O R T */ @@ -10,12 +10,6 @@ static char *id = "$Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ C /* */ /************************************************************************/ - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -30,8 +24,6 @@ static char *id = "$Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ C #include "version.h" - - #include #include "lispemul.h" #include "lispglobal.h" @@ -47,78 +39,85 @@ static char *id = "$Id: colorbltfns.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ C #include "bitblt.h" #include "lldisplay.h" -#define IMIN(x,y) (((x) > (y)) ? (y) : (x)) -#define IMAX(x,y) (((x) > (y)) ? (x) : (y)) +#define IMIN(x, y) (((x) > (y)) ? (y) : (x)) +#define IMAX(x, y) (((x) > (y)) ? (x) : (y)) - /*******************************/ - /* A LISP Big-bitmap structure */ - /*******************************/ -typedef struct - { - LispPTR bigbmwidth; - LispPTR bigbmheight; - LispPTR bigbmlist; - } BIGBM; +/*******************************/ +/* A LISP Big-bitmap structure */ +/*******************************/ +typedef struct { + LispPTR bigbmwidth; + LispPTR bigbmheight; + LispPTR bigbmlist; +} BIGBM; - - -#define GetNewFragment(list,frag,type) \ - frag = (type)Addr68k_from_LADDR( car(list) ); \ - list = cdr( list ); +#define GetNewFragment(list, frag, type) \ + frag = (type)Addr68k_from_LADDR(car(list)); \ + list = cdr(list); LispPTR SLOWBLTCHAR_index; #define SLOWBLTCHAR_argnum 2 -#define PUNT_TO_SLOWBLTCHAR {\ - if(SLOWBLTCHAR_index==0xffffffff)\ - SLOWBLTCHAR_index= get_package_atom("\\PUNT.SLOWBLTCHAR", \ - 17, "INTERLISP", 9, NIL);\ - if(SLOWBLTCHAR_index==0xffffffff)\ - {error("SLOWBLTCHAR install fail"); return;} \ - CurrentStackPTR +=(SLOWBLTCHAR_argnum-1)*DLWORDSPER_CELL; \ - ccfuncall(SLOWBLTCHAR_index,SLOWBLTCHAR_argnum,3);return;} +#define PUNT_TO_SLOWBLTCHAR \ + { \ + if (SLOWBLTCHAR_index == 0xffffffff) \ + SLOWBLTCHAR_index = get_package_atom("\\PUNT.SLOWBLTCHAR", 17, "INTERLISP", 9, NIL); \ + if (SLOWBLTCHAR_index == 0xffffffff) { \ + error("SLOWBLTCHAR install fail"); \ + return; \ + } \ + CurrentStackPTR += (SLOWBLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ + ccfuncall(SLOWBLTCHAR_index, SLOWBLTCHAR_argnum, 3); \ + return; \ + } /***********************************************************/ /* - C_slowbltchar + C_slowbltchar - by Takeshi - June 6, 1989 + by Takeshi + June 6, 1989 */ /***********************************************************/ /* I'll merge this macro with FGetNum later */ -#define SFGetNum(ptr, place) { \ - if(((ptr) & 0xff0000)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ - else if(((ptr) & 0xff0000)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ - else {PUNT_TO_SLOWBLTCHAR;}} +#define SFGetNum(ptr, place) \ + { \ + if (((ptr)&0xff0000) == S_POSITIVE) { \ + (place) = ((ptr)&0xffff); \ + } else if (((ptr)&0xff0000) == S_NEGATIVE) { \ + (place) = (int)((ptr) | 0xffff0000); \ + } else { \ + PUNT_TO_SLOWBLTCHAR; \ + } \ + } - -/* place: native pointer +/* place: native pointer val: native value(should be smallp) puntcase: punt descriptions */ -#define FReplaceSmallp(place,val,puntcase) {\ - if ((0 <= (val)) && ((val) <= MAX_SMALL)) \ - (LispPTR)(place) = (LispPTR)(S_POSITIVE | (val));\ - else if(MIN_SMALL <= val)\ - (LispPTR)(place) = (LispPTR)(S_NEGATIVE | (0xffff & (val)));\ - else {puntcase;}} +#define FReplaceSmallp(place, val, puntcase) \ + { \ + if ((0 <= (val)) && ((val) <= MAX_SMALL)) \ + (LispPTR)(place) = (LispPTR)(S_POSITIVE | (val)); \ + else if (MIN_SMALL <= val) \ + (LispPTR)(place) = (LispPTR)(S_NEGATIVE | (0xffff & (val))); \ + else { \ + puntcase; \ + } \ + } /* charcode should be pos. smallp */ -#define charcode (args[0] & 0xffff) -#define displaystream args[1] -#define Char8Code(x) ((u_char)((x) & 0xff)) -#define CharSet(x) ((x) >> 8) +#define charcode (args[0] & 0xffff) +#define displaystream args[1] +#define Char8Code(x) ((u_char)((x)&0xff)) +#define CharSet(x) ((x) >> 8) #define PSEUDO_BLACK 255 #define PSEUDO_WHITE 0 LispPTR *SCREENBITMAPS68k; /* Initialized in initsysout.c */ -LispPTR *COLORSCREEN68k; /* Initialized in initsysout.c */ +LispPTR *COLORSCREEN68k; /* Initialized in initsysout.c */ LispPTR COLORSCREEN_index; /* if it's 0xffffffff, not yet initialized */ - - - /************************************************************************/ /* */ /* C _ s l o w b l t c h a r */ @@ -129,191 +128,158 @@ LispPTR COLORSCREEN_index; /* if it's 0xffffffff, not yet initialized */ /* */ /************************************************************************/ -C_slowbltchar(args) - register LispPTR *args; - { - Stream *n_dstream; - DISPLAYDATA *n_dd; - FONTDESC *n_fontd; - CHARSETINFO *n_csinfo; - BITMAP *n_destbitmap; - int dest_bpp; - LispPTR csinfo; - int curx,cury,newx,rmargin,lmargin,xoff,yoff; - DLword cl_left, cl_right, cl_bottom, cl_top; - DLword src_w, src_h, src_x, src_y, dst_x, dst_y, w, h; +C_slowbltchar(args) register LispPTR *args; +{ + Stream *n_dstream; + DISPLAYDATA *n_dd; + FONTDESC *n_fontd; + CHARSETINFO *n_csinfo; + BITMAP *n_destbitmap; + int dest_bpp; + LispPTR csinfo; + int curx, cury, newx, rmargin, lmargin, xoff, yoff; + DLword cl_left, cl_right, cl_bottom, cl_top; + DLword src_w, src_h, src_x, src_y, dst_x, dst_y, w, h; + u_char forecolor, backcolor; + register int displayflg; - u_char forecolor,backcolor; - register int displayflg; + extern LispPTR *TOPWDS68k; + n_dstream = (Stream *)Addr68k_from_LADDR(displaystream); + n_dd = (DISPLAYDATA *)Addr68k_from_LADDR(n_dstream->IMAGEDATA); + n_fontd = (FONTDESC *)Addr68k_from_LADDR(n_dd->ddfont); + n_destbitmap = (BITMAP *)Addr68k_from_LADDR(n_dd->dddestination); - extern LispPTR *TOPWDS68k; + if ((n_fontd->ROTATION & 0xffff) == 0) { + if ((csinfo = *(((LispPTR *)Addr68k_from_LADDR(n_fontd->FONTCHARSETVECTOR)) + + CharSet(charcode))) == NIL) + PUNT_TO_SLOWBLTCHAR; /* CSINFO is not cached */ - n_dstream=(Stream*)Addr68k_from_LADDR(displaystream); - n_dd=(DISPLAYDATA*)Addr68k_from_LADDR(n_dstream->IMAGEDATA); - n_fontd=(FONTDESC*)Addr68k_from_LADDR(n_dd->ddfont); - n_destbitmap=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); + n_csinfo = (CHARSETINFO *)Addr68k_from_LADDR(csinfo); - if((n_fontd->ROTATION & 0xffff) == 0) - { + SFGetNum(n_dd->ddxposition, curx); + SFGetNum(n_dd->ddyposition, cury); + SFGetNum(n_dd->ddrightmargin, rmargin); + SFGetNum(n_dd->ddleftmargin, lmargin); + SFGetNum(n_dd->ddxoffset, xoff); + SFGetNum(n_dd->ddyoffset, yoff); + cl_left = n_dd->ddclippingleft; + cl_right = n_dd->ddclippingright; + cl_bottom = n_dd->ddclippingbottom; + cl_top = n_dd->ddclippingtop; - if((csinfo= - *(((LispPTR*)Addr68k_from_LADDR(n_fontd->FONTCHARSETVECTOR)) - + CharSet(charcode) )) == NIL ) - PUNT_TO_SLOWBLTCHAR; /* CSINFO is not cached */ + newx = curx + *(DLword *)Addr68k_from_LADDR(n_dd->ddwidthscache + Char8Code(charcode)); - n_csinfo =(CHARSETINFO*)Addr68k_from_LADDR(csinfo); - - SFGetNum(n_dd->ddxposition, curx); - SFGetNum(n_dd->ddyposition, cury); - SFGetNum(n_dd->ddrightmargin, rmargin); - SFGetNum(n_dd->ddleftmargin, lmargin); - SFGetNum(n_dd->ddxoffset, xoff); - SFGetNum(n_dd->ddyoffset, yoff); - cl_left = n_dd->ddclippingleft; - cl_right = n_dd->ddclippingright; - cl_bottom = n_dd->ddclippingbottom; - cl_top = n_dd->ddclippingtop; + if (newx > rmargin) PUNT_TO_SLOWBLTCHAR; /* do \DSPPRINTCR/LF */ - newx = curx + *(DLword*)Addr68k_from_LADDR(n_dd->ddwidthscache - + Char8Code(charcode)); - - if(newx > rmargin) - PUNT_TO_SLOWBLTCHAR; /* do \DSPPRINTCR/LF */ - - /* If we care about TOPW then it's too slow to create Menu etc. - But,if we don't,it causes some error **/ - { - WINDOW *window; - SCREEN *ColorScreenData; - if(COLORSCREEN_index==0xffffffff) - { /* Make sure COLOR lives? */ - COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); - COLORSCREEN68k = (LispPTR *)Addr68k_from_LADDR(VALS_OFFSET + - (COLORSCREEN_index << 1)); - } - ColorScreenData=(SCREEN*)Addr68k_from_LADDR(*COLORSCREEN68k); - window = (WINDOW*)Addr68k_from_LADDR(ColorScreenData->SCTOPW); - if((displaystream != ColorScreenData->SCTOPW) && - (displaystream != window->DSP) && - (displaystream != *TOPWDS68k) && - ((fmemb(n_dd->dddestination,*SCREENBITMAPS68k)) != NIL)) - PUNT_TO_SLOWBLTCHAR; - } - - FReplaceSmallp( n_dd->ddxposition, newx, PUNT_TO_SLOWBLTCHAR); - - /* make curx abs coord */ - curx += xoff; - cury += yoff; - - { register PILOTBBT *pbt; - register BITMAP *n_destBM,*n_srcBM; - register BIGBM *n_destBIGBM; - register int destYOffset; - register int width,sourceBitOffset; - extern int ScreenLocked; - extern int displayheight; - - n_srcBM=(BITMAP*)Addr68k_from_LADDR(n_csinfo->CHARSETBITMAP); - src_h = n_srcBM->bmheight; - src_w = n_srcBM->bmwidth; - - src_x = *((DLword*)Addr68k_from_LADDR( n_dd->ddoffsetscache - + Char8Code(charcode))); - src_y = 0; - w = *(DLword*)Addr68k_from_LADDR(n_dd->ddcharimagewidths - + Char8Code(charcode)); - h = src_h; - - (short)dst_x = (short)curx; - (short)dst_y = (short)cury - (short)n_csinfo->CHARSETDESCENT; - - { /* clipping */ - short left,right,bottom,top; - short stodx,stody; - - left = (short)IMAX( (short)dst_x, (short)cl_left ); - right = (short)IMIN( (short)dst_x+w, (short)cl_right ); - bottom = (short)IMAX( (short)dst_y, (short)cl_bottom ); - top = (short)IMIN( (short)dst_y+h, (short)cl_top ); - stodx = (short)dst_x - (short)src_x; - stody = (short)dst_y - (short)src_y; - left = IMAX( (short)src_x, IMAX( left-stodx, 0 ) ); - bottom = IMAX( (short)src_y, IMAX( bottom-stody , 0 ) ); - right = IMIN( (short)src_w, IMIN( (short)(src_x+w), right-stodx ) ); - top = IMIN( (short)src_h, IMIN( (short)(src_y+h), top-stody ) ); - if ( (right<=left) || (top<=bottom) ) return; - w = (DLword)(right - left); - h = (DLword)(top - bottom); - dst_x = (DLword)(left + stodx); - dst_y = (DLword)(bottom + stody); - src_x = (DLword)left; - src_y = (DLword)bottom; - } - - /* forground and bacground color */ - - if(n_dd->ddcolor ==NIL_PTR) - { - forecolor = PSEUDO_BLACK; - backcolor = PSEUDO_WHITE; - } - else - { - backcolor = 0xff & cdr(n_dd->ddcolor); - forecolor = 0xff & car(n_dd->ddcolor); - } - - if(GetTypeNumber( n_dd->dddestination ) == TYPE_BITMAP) - { /* Bitap */ - n_destBM=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); - ScreenLocked=T; - /* xposition is shifted 3 Kludge for cursorin - in color(8bpp) ** x's meaning is different from - bitbltsub's. For now,I use this func with Kludge */ - displayflg=n_new_cursorin( - Addr68k_from_LADDR(n_destBM->bmbase),dst_x<<3, - /* Kludge:YCoordination upside down*/ - displayheight-cury,w,h); - if(displayflg) HideCursor; - - ColorizeFont8(n_srcBM, src_x, src_y - , n_destBM, dst_x, dst_y - , w, h - , backcolor,forecolor - , n_dd->ddsourcetype,n_dd->ddoperation); - - - if(displayflg) ShowCursor; - ScreenLocked=NIL; - - } - else - { /* BIGBM */ - ScreenLocked=T; - n_destBIGBM = (BIGBM*)n_destbitmap; - ColorizeFont8_BIGBM(n_srcBM, src_x, src_y - , n_destBIGBM, dst_x, dst_y - , w, h - , backcolor,forecolor - , n_dd->ddsourcetype,n_dd->ddoperation); - ScreenLocked=NIL; - } /* end if( TYPE_BITMAP ) */ - - - } + /* If we care about TOPW then it's too slow to create Menu etc. + But,if we don't,it causes some error **/ + { + WINDOW *window; + SCREEN *ColorScreenData; + if (COLORSCREEN_index == 0xffffffff) { /* Make sure COLOR lives? */ + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = (LispPTR *)Addr68k_from_LADDR(VALS_OFFSET + (COLORSCREEN_index << 1)); } - else - { - /* ROTATE case ,do-PUNT */ - PUNT_TO_SLOWBLTCHAR; + ColorScreenData = (SCREEN *)Addr68k_from_LADDR(*COLORSCREEN68k); + window = (WINDOW *)Addr68k_from_LADDR(ColorScreenData->SCTOPW); + if ((displaystream != ColorScreenData->SCTOPW) && (displaystream != window->DSP) && + (displaystream != *TOPWDS68k) && ((fmemb(n_dd->dddestination, *SCREENBITMAPS68k)) != NIL)) + PUNT_TO_SLOWBLTCHAR; + } + + FReplaceSmallp(n_dd->ddxposition, newx, PUNT_TO_SLOWBLTCHAR); + + /* make curx abs coord */ + curx += xoff; + cury += yoff; + + { + register PILOTBBT *pbt; + register BITMAP *n_destBM, *n_srcBM; + register BIGBM *n_destBIGBM; + register int destYOffset; + register int width, sourceBitOffset; + extern int ScreenLocked; + extern int displayheight; + + n_srcBM = (BITMAP *)Addr68k_from_LADDR(n_csinfo->CHARSETBITMAP); + src_h = n_srcBM->bmheight; + src_w = n_srcBM->bmwidth; + + src_x = *((DLword *)Addr68k_from_LADDR(n_dd->ddoffsetscache + Char8Code(charcode))); + src_y = 0; + w = *(DLword *)Addr68k_from_LADDR(n_dd->ddcharimagewidths + Char8Code(charcode)); + h = src_h; + + (short)dst_x = (short)curx; + (short)dst_y = (short)cury - (short)n_csinfo->CHARSETDESCENT; + + { /* clipping */ + short left, right, bottom, top; + short stodx, stody; + + left = (short)IMAX((short)dst_x, (short)cl_left); + right = (short)IMIN((short)dst_x + w, (short)cl_right); + bottom = (short)IMAX((short)dst_y, (short)cl_bottom); + top = (short)IMIN((short)dst_y + h, (short)cl_top); + stodx = (short)dst_x - (short)src_x; + stody = (short)dst_y - (short)src_y; + left = IMAX((short)src_x, IMAX(left - stodx, 0)); + bottom = IMAX((short)src_y, IMAX(bottom - stody, 0)); + right = IMIN((short)src_w, IMIN((short)(src_x + w), right - stodx)); + top = IMIN((short)src_h, IMIN((short)(src_y + h), top - stody)); + if ((right <= left) || (top <= bottom)) return; + w = (DLword)(right - left); + h = (DLword)(top - bottom); + dst_x = (DLword)(left + stodx); + dst_y = (DLword)(bottom + stody); + src_x = (DLword)left; + src_y = (DLword)bottom; } - - } /* end C_slowbltchar */ + /* forground and bacground color */ + if (n_dd->ddcolor == NIL_PTR) { + forecolor = PSEUDO_BLACK; + backcolor = PSEUDO_WHITE; + } else { + backcolor = 0xff & cdr(n_dd->ddcolor); + forecolor = 0xff & car(n_dd->ddcolor); + } + + if (GetTypeNumber(n_dd->dddestination) == TYPE_BITMAP) { /* Bitap */ + n_destBM = (BITMAP *)Addr68k_from_LADDR(n_dd->dddestination); + ScreenLocked = T; + /* xposition is shifted 3 Kludge for cursorin + in color(8bpp) ** x's meaning is different from + bitbltsub's. For now,I use this func with Kludge */ + displayflg = n_new_cursorin(Addr68k_from_LADDR(n_destBM->bmbase), dst_x << 3, + /* Kludge:YCoordination upside down*/ + displayheight - cury, w, h); + if (displayflg) HideCursor; + + ColorizeFont8(n_srcBM, src_x, src_y, n_destBM, dst_x, dst_y, w, h, backcolor, forecolor, + n_dd->ddsourcetype, n_dd->ddoperation); + + if (displayflg) ShowCursor; + ScreenLocked = NIL; + + } else { /* BIGBM */ + ScreenLocked = T; + n_destBIGBM = (BIGBM *)n_destbitmap; + ColorizeFont8_BIGBM(n_srcBM, src_x, src_y, n_destBIGBM, dst_x, dst_y, w, h, backcolor, + forecolor, n_dd->ddsourcetype, n_dd->ddoperation); + ScreenLocked = NIL; + } /* end if( TYPE_BITMAP ) */ + } + } else { + /* ROTATE case ,do-PUNT */ + PUNT_TO_SLOWBLTCHAR; + } + +} /* end C_slowbltchar */ /************************************************************************/ /* */ @@ -327,50 +293,39 @@ C_slowbltchar(args) /************************************************************************/ #define MAXFONTHEIGHT 48 -#define MAXFONTWIDTH 48 -#define BITSPERNIBBLE 4 +#define MAXFONTWIDTH 48 +#define BITSPERNIBBLE 4 #define BITSPERDLWORD 16 -#define BPP 8 +#define BPP 8 -u_int ColorizedFont8CACHE[MAXFONTHEIGHT/BITSPERNIBBLE * - MAXFONTWIDTH/BITSPERNIBBLE]; +u_int ColorizedFont8CACHE[MAXFONTHEIGHT / BITSPERNIBBLE * MAXFONTWIDTH / BITSPERNIBBLE]; - -ColorizeFont8(sBM,sXOffset,sYOffset,dBM,dXOffset, - dYOffset,width,height,col0,col1,sourcetype,operation) - register BITMAP *sBM; - register DLword sXOffset,sYOffset, width, height; - register BITMAP *dBM; - DLword dYOffset,dXOffset; - u_char col0,col1; - LispPTR sourcetype; - LispPTR operation; +ColorizeFont8(sBM, sXOffset, sYOffset, dBM, dXOffset, dYOffset, width, height, col0, col1, + sourcetype, operation) register BITMAP *sBM; +register DLword sXOffset, sYOffset, width, height; +register BITMAP *dBM; +DLword dYOffset, dXOffset; +u_char col0, col1; +LispPTR sourcetype; +LispPTR operation; { register DLword *nbase; register u_char *dbase; register int i; - sYOffset = sBM->bmheight - (sYOffset+height); - dYOffset = dBM->bmheight - (dYOffset+height); + sYOffset = sBM->bmheight - (sYOffset + height); + dYOffset = dBM->bmheight - (dYOffset + height); - nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) - + (sBM->bmrasterwidth * sYOffset); - (DLword*)dbase= (DLword*)Addr68k_from_LADDR(dBM->bmbase) - + (dBM->bmrasterwidth * dYOffset); - for(i=0, dbase += dXOffset;/* 8bpp */ - i < height; - i++,nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dBM->bmrasterwidth) - { - lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); - } /* for end */ + nbase = (DLword *)Addr68k_from_LADDR(sBM->bmbase) + (sBM->bmrasterwidth * sYOffset); + (DLword *)dbase = (DLword *)Addr68k_from_LADDR(dBM->bmbase) + (dBM->bmrasterwidth * dYOffset); + for (i = 0, dbase += dXOffset; /* 8bpp */ + i < height; i++, nbase += sBM->bmrasterwidth, ((DLword *)dbase) += dBM->bmrasterwidth) { + lineBlt8(nbase, (int)sXOffset, dbase, (int)width, col0, col1, sourcetype, operation); + } /* for end */ } /* ColorizeFont8 end */ - - - - /************************************************************************/ /* */ /* C o l o r i z e d F o n t 8 _ B I G B M */ @@ -382,93 +337,82 @@ ColorizeFont8(sBM,sXOffset,sYOffset,dBM,dXOffset, /* */ /************************************************************************/ -ColorizeFont8_BIGBM(sBM,sXOffset,sYOffset,dBM,dXOffset,dYOffset,width,height,col0,col1,sourcetype,operation) -register BITMAP *sBM; -register DLword sXOffset,sYOffset,width,height; +ColorizeFont8_BIGBM(sBM, sXOffset, sYOffset, dBM, dXOffset, dYOffset, width, height, col0, col1, + sourcetype, operation) register BITMAP *sBM; +register DLword sXOffset, sYOffset, width, height; register BIGBM *dBM; DLword dXOffset, dYOffset; -u_char col0,col1; +u_char col0, col1; LispPTR sourcetype; LispPTR operation; - { register DLword *nbase; register u_char *dbase; register int i; - int dest_bottom - , dest_bigbmheight - , dest_fragtop - , dest_fragbottom - , dest_yoffset - , dest_h; + int dest_bottom, dest_bigbmheight, dest_fragtop, dest_fragbottom, dest_yoffset, dest_h; LispPTR dest_bmlist; BITMAP *dest_frag; - SFGetNum( dBM->bigbmheight, dest_bigbmheight ); + SFGetNum(dBM->bigbmheight, dest_bigbmheight); - sYOffset = sBM->bmheight - ( sYOffset+height ); - dYOffset = dest_bigbmheight - ( dYOffset+height ); + sYOffset = sBM->bmheight - (sYOffset + height); + dYOffset = dest_bigbmheight - (dYOffset + height); - dest_bottom = dYOffset + height; - dest_bmlist = (LispPTR)dBM->bigbmlist; - GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); - dest_fragtop = 0; - dest_fragbottom = dest_frag->bmheight; + dest_bottom = dYOffset + height; + dest_bmlist = (LispPTR)dBM->bigbmlist; + GetNewFragment(dest_bmlist, dest_frag, BITMAP *); + dest_fragtop = 0; + dest_fragbottom = dest_frag->bmheight; -/* search fragment of bitmaps including the desitnation top. */ - while( dest_fragbottom <= dYOffset ) { - GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); - if( dest_frag == (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) return; - dest_fragtop = dest_fragbottom; - dest_fragbottom += dest_frag->bmheight; - } /* end while */ - -/* y offset form bitmap top. */ - dest_yoffset = dYOffset - dest_fragtop; + /* search fragment of bitmaps including the desitnation top. */ + while (dest_fragbottom <= dYOffset) { + GetNewFragment(dest_bmlist, dest_frag, BITMAP *); + if (dest_frag == (BITMAP *)Addr68k_from_LADDR(NIL_PTR)) return; + dest_fragtop = dest_fragbottom; + dest_fragbottom += dest_frag->bmheight; + } /* end while */ + + /* y offset form bitmap top. */ + dest_yoffset = dYOffset - dest_fragtop; loop: -/* height of lineBlt8 */ - if( dest_fragbottom > dest_bottom ) { - /* this fragment inludes dest bottom. */ - dest_h = dest_bottom - (dest_fragtop + dest_yoffset); - } else { - /* remaining fragments include dest bottom. */ - dest_h = dest_fragbottom - (dest_fragtop + dest_yoffset); - } /* end if */ + /* height of lineBlt8 */ + if (dest_fragbottom > dest_bottom) { + /* this fragment inludes dest bottom. */ + dest_h = dest_bottom - (dest_fragtop + dest_yoffset); + } else { + /* remaining fragments include dest bottom. */ + dest_h = dest_fragbottom - (dest_fragtop + dest_yoffset); + } /* end if */ - dbase= (DLword*)Addr68k_from_LADDR(dest_frag->bmbase) - + (dest_frag->bmrasterwidth * dest_yoffset); - nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) - + (sBM->bmrasterwidth * sYOffset); + dbase = + (DLword *)Addr68k_from_LADDR(dest_frag->bmbase) + (dest_frag->bmrasterwidth * dest_yoffset); + nbase = (DLword *)Addr68k_from_LADDR(sBM->bmbase) + (sBM->bmrasterwidth * sYOffset); - sYOffset += (DLword)dest_h; /* next src yoffset */ + sYOffset += (DLword)dest_h; /* next src yoffset */ - for(i=0, dbase += dXOffset; - i < dest_h; - i++, nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dest_frag->bmrasterwidth) - { - lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); - } - -/* remaining height */ - height -= dest_h; - if( height > 0 ) { - GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); - if( dest_frag != (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) { - dest_fragtop = dest_fragbottom; - dest_fragbottom = dest_fragtop + dest_frag->bmheight; - dest_yoffset = 0; /* y offset must be zero. */ - nbase += sBM->bmrasterwidth; - goto loop; - } /* end if(dest_frag) */ - } /* end if(height) */ + for (i = 0, dbase += dXOffset; i < dest_h; + i++, nbase += sBM->bmrasterwidth, ((DLword *)dbase) += dest_frag->bmrasterwidth) { + lineBlt8(nbase, (int)sXOffset, dbase, (int)width, col0, col1, sourcetype, operation); + } + + /* remaining height */ + height -= dest_h; + if (height > 0) { + GetNewFragment(dest_bmlist, dest_frag, BITMAP *); + if (dest_frag != (BITMAP *)Addr68k_from_LADDR(NIL_PTR)) { + dest_fragtop = dest_fragbottom; + dest_fragbottom = dest_fragtop + dest_frag->bmheight; + dest_yoffset = 0; /* y offset must be zero. */ + nbase += sBM->bmrasterwidth; + goto loop; + } /* end if(dest_frag) */ + } /* end if(height) */ } /* end ColorizeFont8_BIGBM() */ - - /************************************************************************/ /* */ /* n e w C o l o r i z e F o n t 8 */ @@ -477,32 +421,23 @@ loop: /* */ /************************************************************************/ -newColorizeFont8(pbt,backcolor,forecolor,srctype,ope) - PILOTBBT *pbt; - u_char backcolor,forecolor; - LispPTR srctype,ope; +newColorizeFont8(pbt, backcolor, forecolor, srctype, ope) PILOTBBT *pbt; +u_char backcolor, forecolor; +LispPTR srctype, ope; { - register DLword *nbase; - register u_char *dbase; - register int i; - - nbase=(DLword*)Addr68k_from_LADDR - ((pbt->pbtsourcehi << 16 ) | (pbt->pbtsourcelo)) ; - (DLword*)dbase= (DLword*)Addr68k_from_LADDR( - (pbt->pbtdesthi << 16 ) | (pbt->pbtdestlo)) ; - dbase += pbt->pbtdestbit; - for(i=0; i < pbt->pbtheight; - i++,nbase += pbt->pbtsourcebpl/16 - , dbase += pbt->pbtdestbpl/8) - { - lineBlt8(nbase,pbt->pbtsourcebit,dbase,pbt->pbtwidth,backcolor,forecolor,srctype,ope); - } /* for end */ - + register DLword *nbase; + register u_char *dbase; + register int i; + nbase = (DLword *)Addr68k_from_LADDR((pbt->pbtsourcehi << 16) | (pbt->pbtsourcelo)); + (DLword *)dbase = (DLword *)Addr68k_from_LADDR((pbt->pbtdesthi << 16) | (pbt->pbtdestlo)); + dbase += pbt->pbtdestbit; + for (i = 0; i < pbt->pbtheight; + i++, nbase += pbt->pbtsourcebpl / 16, dbase += pbt->pbtdestbpl / 8) { + lineBlt8(nbase, pbt->pbtsourcebit, dbase, pbt->pbtwidth, backcolor, forecolor, srctype, ope); + } /* for end */ } - - /************************************************************************/ /* */ /* U n c o l o r i z e _ B i t m a p */ @@ -511,83 +446,74 @@ newColorizeFont8(pbt,backcolor,forecolor,srctype,ope) /* */ /************************************************************************/ -Uncolorize_Bitmap( args ) -LispPTR args[]; +Uncolorize_Bitmap(args) LispPTR args[]; { - BITMAP *s_bitmap - , *d_bitmap; - register DLword* OnOff; + BITMAP *s_bitmap, *d_bitmap; + register DLword *OnOff; - register u_char *s_base; - register DLword *d_base; - register int y; - int s_height - , s_width - , s_bitsperpixel - , s_rasterwidth - , d_rasterwidth; + register u_char *s_base; + register DLword *d_base; + register int y; + int s_height, s_width, s_bitsperpixel, s_rasterwidth, d_rasterwidth; - s_bitmap = (BITMAP*)Addr68k_from_LADDR( args[0] ); - d_bitmap = (BITMAP*)Addr68k_from_LADDR( args[1] ); - OnOff = (DLword*)Addr68k_from_LADDR( args[2] ); + s_bitmap = (BITMAP *)Addr68k_from_LADDR(args[0]); + d_bitmap = (BITMAP *)Addr68k_from_LADDR(args[1]); + OnOff = (DLword *)Addr68k_from_LADDR(args[2]); - s_height = s_bitmap->bmheight; - s_width = s_bitmap->bmwidth; - s_bitsperpixel = s_bitmap->bmbitperpixel; + s_height = s_bitmap->bmheight; + s_width = s_bitmap->bmwidth; + s_bitsperpixel = s_bitmap->bmbitperpixel; - if( s_bitsperpixel != 8 ) return; + if (s_bitsperpixel != 8) return; - s_base = (u_char*)Addr68k_from_LADDR(s_bitmap->bmbase); - d_base = (DLword*)Addr68k_from_LADDR(d_bitmap->bmbase); - s_rasterwidth = s_bitmap->bmrasterwidth; - d_rasterwidth = d_bitmap->bmrasterwidth; + s_base = (u_char *)Addr68k_from_LADDR(s_bitmap->bmbase); + d_base = (DLword *)Addr68k_from_LADDR(d_bitmap->bmbase); + s_rasterwidth = s_bitmap->bmrasterwidth; + d_rasterwidth = d_bitmap->bmrasterwidth; - for( y=0; ybmbase ) - + s_bitmap->bmrasterwidth * (s_bitmap->bmheight - (s_bottom + height)); - (DLword*)d_base = (DLword*)Addr68k_from_LADDR( d_bitmap->bmbase ) - + d_bitmap->bmrasterwidth * (d_bitmap->bmheight - (d_bottom + height)); + s_base = (DLword *)Addr68k_from_LADDR(s_bitmap->bmbase) + + s_bitmap->bmrasterwidth * (s_bitmap->bmheight - (s_bottom + height)); + (DLword *)d_base = (DLword *)Addr68k_from_LADDR(d_bitmap->bmbase) + + d_bitmap->bmrasterwidth * (d_bitmap->bmheight - (d_bottom + height)); - for( i=0, d_base += d_left; ibmrasterwidth - , (DLword*)d_base += d_bitmap->bmrasterwidth ) { + for (i = 0, d_base += d_left; i < height; + i++, s_base += s_bitmap->bmrasterwidth, (DLword *)d_base += d_bitmap->bmrasterwidth) { + lineBlt8(s_base, s_left, d_base, width, (u_char)color0, (u_char)color1, INPUT_atom, + REPLACE_atom); - lineBlt8( s_base, s_left, d_base, width - , (u_char)color0, (u_char)color1 - , INPUT_atom, REPLACE_atom ); + } /* end for(i) */ - } /* end for(i) */ - - bad_arg: return( NIL ); +bad_arg: + return (NIL); } /* end Colorize_Bitmap() */ - - /************************************************************************/ /* */ /* D r a w _ 8 B p p C o l o r L i n e */ @@ -661,127 +571,106 @@ LispPTR args[]; /* */ /************************************************************************/ -#define op_replace -#define op_erase & -#define op_invert ^ -#define op_paint | +#define op_replace +#define op_erase & +#define op_invert ^ +#define op_paint | -#define draw8bpplinex(op) \ - while( (x0 <= xlimit) && ( y0 <= ylimit ) ) { \ - *(base++) op= color; ++x0; cdl += dy; \ - if( dx <= cdl ) { \ - cdl -= dx; \ - base += yinc; ++y0; \ - } \ - } - -#define draw8bppliney(op) \ - while( (x0 <= xlimit) && (y0 <= ylimit ) ) { \ - *base op= color; base += yinc; ++y0; cdl += dx; \ - if( dy <= cdl ) { \ - cdl -= dy; \ - ++ base; ++x0; \ - } \ - } +#define draw8bpplinex(op) \ + while ((x0 <= xlimit) && (y0 <= ylimit)) { \ + *(base++)op = color; \ + ++x0; \ + cdl += dy; \ + if (dx <= cdl) { \ + cdl -= dx; \ + base += yinc; \ + ++y0; \ + } \ + } -Draw_8BppColorLine( args ) - register LispPTR *args; - { - extern DLword REPLACE_atom - , INVERT_atom - , PAINT_atom - , ERASE_atom; +#define draw8bppliney(op) \ + while ((x0 <= xlimit) && (y0 <= ylimit)) { \ + *base op = color; \ + base += yinc; \ + ++y0; \ + cdl += dx; \ + if (dy <= cdl) { \ + cdl -= dy; \ + ++base; \ + ++x0; \ + } \ + } - register u_char color; - register u_char *base; - register short x0 - , y0 - , xlimit - , ylimit - , dx - , dy - , cdl - , yinc - , raster_width; - int mode - , displayflg; - u_char *n_bmbase; +Draw_8BppColorLine(args) register LispPTR *args; +{ + extern DLword REPLACE_atom, INVERT_atom, PAINT_atom, ERASE_atom; - x0 = (short)( args[0] &0xffff ); - y0 = (short)( args[1] &0xffff ); - xlimit = (short)( args[2] &0xffff ); - ylimit = (short)( args[3] &0xffff ); - dx = (short)( args[4] &0xffff ); - dy = (short)( args[5] &0xffff ); - cdl = (short)( args[6] &0xffff ); - yinc = (short)( args[7] &0xffff ); yinc *= 2; /* for byte addressing */ + register u_char color; + register u_char *base; + register short x0, y0, xlimit, ylimit, dx, dy, cdl, yinc, raster_width; + int mode, displayflg; + u_char *n_bmbase; - if ( args[8] == PAINT_atom ) mode = 3; - else if( args[8] == INVERT_atom ) mode = 2; - else if( args[8] == ERASE_atom ) mode = 1; - else mode = 0; /* REPLACE_atom */ + x0 = (short)(args[0] & 0xffff); + y0 = (short)(args[1] & 0xffff); + xlimit = (short)(args[2] & 0xffff); + ylimit = (short)(args[3] & 0xffff); + dx = (short)(args[4] & 0xffff); + dy = (short)(args[5] & 0xffff); + cdl = (short)(args[6] & 0xffff); + yinc = (short)(args[7] & 0xffff); + yinc *= 2; /* for byte addressing */ - n_bmbase = (u_char*)Addr68k_from_LADDR( args[9] ); - raster_width = (short) ( args[10] &0xffff ); - color = (u_char)( args[11] & 0xff ); + if (args[8] == PAINT_atom) + mode = 3; + else if (args[8] == INVERT_atom) + mode = 2; + else if (args[8] == ERASE_atom) + mode = 1; + else + mode = 0; /* REPLACE_atom */ - if( yinc >= 0 ) - { - displayflg = n_new_cursorin( (DLword*)n_bmbase - , (int)(x0<<3), (int)y0, (int)(xlimit<<3), (int)ylimit ); - } - else - { - displayflg = - n_new_cursorin( (DLword*)n_bmbase, - (int)(x0<<3), (int)(y0-ylimit), - (int)(xlimit<<3), (int)ylimit ); - } + n_bmbase = (u_char *)Addr68k_from_LADDR(args[9]); + raster_width = (short)(args[10] & 0xffff); + color = (u_char)(args[11] & 0xff); - base = n_bmbase + y0 * (raster_width << 1) + x0; - x0 = y0 = 0; + if (yinc >= 0) { + displayflg = n_new_cursorin((DLword *)n_bmbase, (int)(x0 << 3), (int)y0, (int)(xlimit << 3), + (int)ylimit); + } else { + displayflg = n_new_cursorin((DLword *)n_bmbase, (int)(x0 << 3), (int)(y0 - ylimit), + (int)(xlimit << 3), (int)ylimit); + } - if( displayflg ) - { - ScreenLocked = T; - HideCursor; - } + base = n_bmbase + y0 * (raster_width << 1) + x0; + x0 = y0 = 0; - if( dx >= dy ) - { /* .draw8bpplinex */ - switch( mode ) - { - case 0: draw8bpplinex( op_replace ); - break; - case 1: draw8bpplinex( op_erase ); - break; - case 2: draw8bpplinex( op_invert ); - break; - case 3: draw8bpplinex( op_paint ); - break; - } /* end switch */ + if (displayflg) { + ScreenLocked = T; + HideCursor; + } - } - else - { /* .draw8bppliney */ - switch( mode ) - { - case 0: draw8bppliney( op_replace ); - break; - case 1: draw8bppliney( op_erase ); - break; - case 2: draw8bppliney( op_invert ); - break; - case 3: draw8bppliney( op_paint ); - break; - } /* end switch */ + if (dx >= dy) { /* .draw8bpplinex */ + switch (mode) { + case 0: draw8bpplinex(op_replace); break; + case 1: draw8bpplinex(op_erase); break; + case 2: draw8bpplinex(op_invert); break; + case 3: draw8bpplinex(op_paint); break; + } /* end switch */ - } /* end if( dx >= dy ) */ + } else { /* .draw8bppliney */ + switch (mode) { + case 0: draw8bppliney(op_replace); break; + case 1: draw8bppliney(op_erase); break; + case 2: draw8bppliney(op_invert); break; + case 3: draw8bppliney(op_paint); break; + } /* end switch */ - if( displayflg ) - { - ShowCursor; - ScreenLocked = NIL; - } - - } /* end Draw_8BppColorLine */ + } /* end if( dx >= dy ) */ + + if (displayflg) { + ShowCursor; + ScreenLocked = NIL; + } + +} /* end Draw_8BppColorLine */ diff --git a/src/common.c b/src/common.c old mode 100755 new mode 100644 index 1ed33d1..06beddf --- a/src/common.c +++ b/src/common.c @@ -1,4 +1,5 @@ -/* $Id: common.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: common.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: common.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ @@ -14,13 +15,11 @@ static char *id = "$Id: common.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ Copyri /* */ /************************************************************************/ - #include "version.h" - -#include -#include -#include +#include +#include +#include #include /* for memset */ #include "lispemul.h" #include "lispmap.h" @@ -34,49 +33,41 @@ static char *id = "$Id: common.c,v 1.2 1999/01/03 02:06:52 sybalsky Exp $ Copyri #include #endif -void stab() - { - DBPRINT(("Now in stab\n")); - } - - - +void stab() { DBPRINT(("Now in stab\n")); } /*************************************************************** error - common sub-routine. + common sub-routine. - Printout error message. - Enter URAID. - And exit.(takeshi) + Printout error message. + Enter URAID. + And exit.(takeshi) ******************************************************************/ -#define URMAXFXNUM 100 +#define URMAXFXNUM 100 -extern unsigned int LispReadFds,LispWindowFd,LispKbdFd; +extern unsigned int LispReadFds, LispWindowFd, LispKbdFd; extern struct screen LispScreen; -extern int displaywidth,displayheight; +extern int displaywidth, displayheight; extern DLword *DisplayRegion68k; extern int FrameBufferFd; - extern char URaid_inputstring[]; - extern char URaid_comm; - extern char URaid_arg1[256]; - extern char URaid_arg2[10]; - extern int URaid_argnum; - extern char *URaid_errmess; - extern int URaid_currentFX; - extern FX *URaid_FXarray[]; - extern jmp_buf BT_jumpbuf; - extern jmp_buf SD_jumpbuf; - extern int BT_temp; /* holds the continue-character the user typed */ +extern char URaid_inputstring[]; +extern char URaid_comm; +extern char URaid_arg1[256]; +extern char URaid_arg2[10]; +extern int URaid_argnum; +extern char *URaid_errmess; +extern int URaid_currentFX; +extern FX *URaid_FXarray[]; +extern jmp_buf BT_jumpbuf; +extern jmp_buf SD_jumpbuf; +extern int BT_temp; /* holds the continue-character the user typed */ - LispPTR Uraid_mess=NIL; +LispPTR Uraid_mess = NIL; /* Currentry Don't care Ether re-initial */ /* Medley only */ - - /************************************************************************/ /* */ /* e r r o r */ @@ -85,65 +76,59 @@ extern int FrameBufferFd; /* */ /************************************************************************/ -#define URMAXCOMM 512 -int error(char *cp) - { - char *ptr; - if(device_before_raid()<0) - { - printf("Can't Enter URAID.\n"); - exit(-1); - } - /* comm read */ - URaid_errmess=cp; - printf("\n*Error* %s\n",cp); - fflush(stdin); - printf("Enter the URaid\n"); - print(Uraid_mess); putchar('\n'); - URaid_currentFX=URMAXFXNUM +1; - memset(URaid_FXarray, 0, URMAXFXNUM *4); +#define URMAXCOMM 512 +int error(char *cp) { + char *ptr; + if (device_before_raid() < 0) { + printf("Can't Enter URAID.\n"); + exit(-1); + } + /* comm read */ + URaid_errmess = cp; + printf("\n*Error* %s\n", cp); + fflush(stdin); + printf("Enter the URaid\n"); + print(Uraid_mess); + putchar('\n'); + URaid_currentFX = URMAXFXNUM + 1; + memset(URaid_FXarray, 0, URMAXFXNUM * 4); #ifndef DOS - { - int stat = fcntl(fileno(stdin), F_GETFL, 0); - if (stat != O_RDONLY && stat != O_RDWR) - if (freopen("/dev/tty", "r", stdin) == NULL) - { - perror("Reopen of stdin failed."); - exit(0); - } + { + int stat = fcntl(fileno(stdin), F_GETFL, 0); + if (stat != O_RDONLY && stat != O_RDWR) + if (freopen("/dev/tty", "r", stdin) == NULL) { + perror("Reopen of stdin failed."); + exit(0); } + } #endif /* DOS */ uraidloop: - if(setjmp(BT_jumpbuf) == 1) goto uraidloop; - if(setjmp(SD_jumpbuf) == 1) goto uraidloop; - for(;;) - { /* URAID LOOP */ + if (setjmp(BT_jumpbuf) == 1) goto uraidloop; + if (setjmp(SD_jumpbuf) == 1) goto uraidloop; + for (;;) { /* URAID LOOP */ - uraid_commclear(); - BT_temp = 0; /* So we get the "more" option on screen-full */ - printf("\n< "); - for( ptr=URaid_inputstring;( *ptr= getchar() ) != '\n' ; ptr++) {} - URaid_argnum = sscanf(URaid_inputstring, - "%1s%s%s",&URaid_comm, URaid_arg1, URaid_arg2); + uraid_commclear(); + BT_temp = 0; /* So we get the "more" option on screen-full */ + printf("\n< "); + for (ptr = URaid_inputstring; (*ptr = getchar()) != '\n'; ptr++) {} + URaid_argnum = sscanf(URaid_inputstring, "%1s%s%s", &URaid_comm, URaid_arg1, URaid_arg2); - if(uraid_commands()==NIL) break; - } /* for end */ + if (uraid_commands() == NIL) break; + } /* for end */ - /**TopOfStack = NIL;if error is called from subr TOS will be set NIL**/ - if(device_after_raid() <0) - { - printf("Can't return to Lisp. Return to UNIX?"); - { int c; - c= getchar(); - if((c=='Y')||(c=='y')) exit(-1); - } - fflush(stdin); - goto uraidloop; - } - return (0); + /**TopOfStack = NIL;if error is called from subr TOS will be set NIL**/ + if (device_after_raid() < 0) { + printf("Can't return to Lisp. Return to UNIX?"); + { + int c; + c = getchar(); + if ((c == 'Y') || (c == 'y')) exit(-1); + } + fflush(stdin); + goto uraidloop; } - - + return (0); +} /************************************************************************/ /* */ @@ -153,51 +138,41 @@ uraidloop: /* */ /************************************************************************/ -void warn(s) - char *s; - { printf("\nWARN: %s \n",s); } - - - +void warn(s) char *s; +{ printf("\nWARN: %s \n", s); } /***************************************************************** stackcheck - common sub-routine. + common sub-routine. - Not Implemented. + Not Implemented. - 1.check Stack overflow. - (check CurrentStackPTR) - 2.if overflow, return T (not 0). - Otherwise, return F (0). + 1.check Stack overflow. + (check CurrentStackPTR) + 2.if overflow, return T (not 0). + Otherwise, return F (0). ******************************************************************/ -int stackcheck() - { -#ifdef TRACE2 - printf("TRACE:stackcheck()\n"); +int stackcheck() { +#ifdef TRACE2 + printf("TRACE:stackcheck()\n"); #endif - return(0); - } - - - + return (0); +} /***************************************************************** stackoverflow - common sub-routine. + common sub-routine. - Not Implemented. + Not Implemented. - 1.error handling of stack overflow. + 1.error handling of stack overflow. ******************************************************************/ -void stackoverflow() - { -#ifdef TRACE2 - printf("TRACE:stackoverflow()\n"); +void stackoverflow() { +#ifdef TRACE2 + printf("TRACE:stackoverflow()\n"); #endif - printf("stackoverflow \n"); - } - + printf("stackoverflow \n"); +} diff --git a/src/conspage.c b/src/conspage.c old mode 100755 new mode 100644 index deb18d0..5fbd06e --- a/src/conspage.c +++ b/src/conspage.c @@ -1,8 +1,7 @@ -/* $Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-94 Venue. All Rights Reserved. */ @@ -15,13 +14,11 @@ static char *id = "$Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copy /* */ /************************************************************************/ - #include "version.h" - /***********************************************************************/ /* - File Name :conspage.c + File Name :conspage.c */ /************************************************************************/ #include "lispemul.h" @@ -33,8 +30,6 @@ static char *id = "$Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copy #include "lspglob.h" #include "gc.h" - - /************************************************************************/ /* */ /* i n i t _ c o n s p a g e */ @@ -62,9 +57,11 @@ static char *id = "$Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copy /* using the word offset within page as the chain. Cells */ /* are chained from the top of the page down. */ /* */ -/* Experimental version goes nxtcell = 248 */ -/* count/nxtcell in cell 4, next_page in cell 6 */ -/* Chain up 4 down 8 ( ^ 6 into word count) */ +/* Experimental version goes nxtcell = 248 */ +/* count/nxtcell in cell 4, next_page in cell 6 + */ +/* Chain up 4 down 8 ( ^ 6 into word count) + */ /* */ /* */ /* */ @@ -72,120 +69,112 @@ static char *id = "$Id: conspage.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copy /************************************************************************/ void init_conspage(register struct conspage *base, unsigned int link) - /* Page Base */ - /* Prev Link page number DL->int*/ - { - register ConsCell *cell ; - register int j ; /* DL-> int */ +/* Page Base */ +/* Prev Link page number DL->int*/ +{ + register ConsCell *cell; + register int j; /* DL-> int */ #ifdef TRACE2 - printf("TRACE: init_conspage()\n"); + printf("TRACE: init_conspage()\n"); #endif - #ifdef NEWCDRCODING - base -> next_cell= 6^(j = 254) ; - while (j > 8) - { - cell = (ConsCell *)((DLword *)base + (6 ^ j) ); - cell->car_field = NIL_PTR ; - j -= 2; - ((freecons *)cell)->next_free = (6^j) ; - } - base -> count = 124; + base->next_cell = 6 ^ (j = 254); + while (j > 8) { + cell = (ConsCell *)((DLword *)base + (6 ^ j)); + cell->car_field = NIL_PTR; + j -= 2; + ((freecons *)cell)->next_free = (6 ^ j); + } + base->count = 124; #else - base -> next_cell= j = 254 ; - while(j != 0) - { - cell = (ConsCell *)((DLword *)base + (j) ); - cell->car_field = NIL_PTR ; - j -= 2; - ((freecons *)cell)->next_free = (j) ; - } - base -> count = 127 ; + base->next_cell = j = 254; + while (j != 0) { + cell = (ConsCell *)((DLword *)base + (j)); + cell->car_field = NIL_PTR; + j -= 2; + ((freecons *)cell)->next_free = (j); + } + base->count = 127; #endif /* NEWCDRCODING */ - base -> next_page = link ; + base->next_page = link; - } /* init_conspage end */ +} /* init_conspage end */ /**********************************************************************/ /* - Func name : next_conspage + Func name : next_conspage - GET NEXT CONS PAGE . + GET NEXT CONS PAGE . - Date : January 13, 1987 - Edited by : Takeshi Shimizu - Changed : January 20, 1987 (take) - Changed : Feb-12-87 take - Changed : Feb-13-87 take + Date : January 13, 1987 + Edited by : Takeshi Shimizu + Changed : January 20, 1987 (take) + Changed : Feb-12-87 take + Changed : Feb-13-87 take */ /**********************************************************************/ -struct conspage *next_conspage(void) -{ - extern struct dtd *ListpDTD ; +struct conspage *next_conspage(void) { + extern struct dtd *ListpDTD; - register struct conspage *page1 ; /* Allocated 1st MDS page */ - register struct conspage *page2 ; /* Allocated 2nd MDS page */ - struct conspage *pg, *priorpg; - register int next, prior; + register struct conspage *page1; /* Allocated 1st MDS page */ + register struct conspage *page2; /* Allocated 2nd MDS page */ + struct conspage *pg, *priorpg; + register int next, prior; #ifdef NEWCDRCODING - /* Alloc 2 Conspages and get 1st page base */ - page1 = (struct conspage *)alloc_mdspage(TYPE_LISTP) ; - /* Culc. next Conspage's Base address */ - page2 = (struct conspage *)((DLword *)page1 + DLWORDSPER_PAGE) ; + /* Alloc 2 Conspages and get 1st page base */ + page1 = (struct conspage *)alloc_mdspage(TYPE_LISTP); + /* Culc. next Conspage's Base address */ + page2 = (struct conspage *)((DLword *)page1 + DLWORDSPER_PAGE); - init_conspage(page2 , 0); /* Doesn't exst next page */ - init_conspage(page1 , LPAGE_from_68k(page2) ) ; + init_conspage(page2, 0); /* Doesn't exst next page */ + init_conspage(page1, LPAGE_from_68k(page2)); - prior = 0; - for (pg = (struct conspage *)Addr68k_from_LPAGE(next=ListpDTD->dtd_nextpage); - next && (next != CONSPAGE_LAST); - pg = (struct conspage *)Addr68k_from_LPAGE(next = pg->next_page)) - { priorpg = pg; prior = next; } + prior = 0; + for (pg = (struct conspage *)Addr68k_from_LPAGE(next = ListpDTD->dtd_nextpage); + next && (next != CONSPAGE_LAST); + pg = (struct conspage *)Addr68k_from_LPAGE(next = pg->next_page)) { + priorpg = pg; + prior = next; + } - if (prior) priorpg->next_page = LPAGE_from_68k(page1); - else ListpDTD->dtd_nextpage = LPAGE_from_68k(page1) ; - - if (page2->next_page) error("page2 has a next page??"); - if (page2 == priorpg) error("loop in conspage next_pages"); + if (prior) + priorpg->next_page = LPAGE_from_68k(page1); + else + ListpDTD->dtd_nextpage = LPAGE_from_68k(page1); + + if (page2->next_page) error("page2 has a next page??"); + if (page2 == priorpg) error("loop in conspage next_pages"); #else - for(next =(int) ListpDTD->dtd_nextpage ; /* getnext free conspage */ - ; ListpDTD -> dtd_nextpage = next = page1 -> next_page , - page1->next_page = 0xffff ) - { - if(next ==0) - { - /* Alloc 2 Conspages and get 1st page base */ - page1 = (struct conspage *)alloc_mdspage(TYPE_LISTP) ; + for (next = (int)ListpDTD->dtd_nextpage; /* getnext free conspage */ + ; ListpDTD->dtd_nextpage = next = page1->next_page, page1->next_page = 0xffff) { + if (next == 0) { + /* Alloc 2 Conspages and get 1st page base */ + page1 = (struct conspage *)alloc_mdspage(TYPE_LISTP); - /* Culc. next Conspage's Base address */ - page2 = (struct conspage *)((DLword *)page1 + DLWORDSPER_PAGE) ; + /* Culc. next Conspage's Base address */ + page2 = (struct conspage *)((DLword *)page1 + DLWORDSPER_PAGE); - init_conspage(page2 , ListpDTD->dtd_nextpage); /* Doesn't exst next page */ - init_conspage(page1 , LPAGE_from_68k(page2) ) ; + init_conspage(page2, ListpDTD->dtd_nextpage); /* Doesn't exst next page */ + init_conspage(page1, LPAGE_from_68k(page2)); - ListpDTD->dtd_nextpage = LPAGE_from_68k(page1) ; - goto ex ; /* replaced break */ - } - else - { - page1 =(struct conspage *) Addr68k_from_LPAGE(next) ; /*Jan-21*/ - } + ListpDTD->dtd_nextpage = LPAGE_from_68k(page1); + goto ex; /* replaced break */ + } else { + page1 = (struct conspage *)Addr68k_from_LPAGE(next); /*Jan-21*/ + } - if (page1->count > 1) break ; + if (page1->count > 1) break; - } /* for loop end */ + } /* for loop end */ #endif /* NEWCDRCODING */ -ex : - return(page1) ; - } /* next_conspage end */ - - - +ex: + return (page1); +} /* next_conspage end */ /************************************************************************/ /* */ @@ -193,302 +182,263 @@ ex : /* */ /* Find a pair of CONS cells that are close enough (within 7) */ /* that the second can be cdr-coded as the cdr of the first. */ -/* Set up the cdr code in the first cell, and return it. */ +/* Set up the cdr code in the first cell, and return it. + */ /* */ /* First searches the CONS page given, then the free-page chain */ /* finally, calls conspage to get a fresh (and guaranteed useful) page. */ /* */ /************************************************************************/ -ConsCell * find_pair_in_page(struct conspage *pg, LispPTR cdrval) -{ - ConsCell *carcell, *cdrcell; - unsigned int offset, prior, priorprior, ppriorprior, noffset, nprior, poffset; +ConsCell *find_pair_in_page(struct conspage *pg, LispPTR cdrval) { + ConsCell *carcell, *cdrcell; + unsigned int offset, prior, priorprior, ppriorprior, noffset, nprior, poffset; - if (pg->count < 2) return((ConsCell *)0); + if (pg->count < 2) return ((ConsCell *)0); - ppriorprior = priorprior = prior = nprior = 0; + ppriorprior = priorprior = prior = nprior = 0; - for (offset = pg->next_cell; offset; offset = FREECONS(pg, offset)->next_free) - { - if (prior) - { - /* if ((6^prior) <= (6^offset)) error("free list in CONS page corrupt."); */ - if ((prior>offset) && (prior <= offset+14)) - { - poffset = offset; - noffset = FREECONS(pg,offset)->next_free; - while ((noffset>offset) && (noffset < prior)) - { - nprior = offset; - poffset = prior; - offset = noffset; - noffset = FREECONS(pg,offset)->next_free; - } - carcell = (ConsCell *) ((DLword *)pg + offset); - cdrcell = (ConsCell *) ((DLword *)pg + prior); - if (priorprior) - FREECONS(pg,priorprior)->next_free = - FREECONS(pg,poffset) ->next_free; - else pg->next_cell = FREECONS(pg,poffset) ->next_free; - if (nprior) FREECONS(pg,nprior)->next_free = FREECONS(pg,offset)->next_free; - carcell -> cdr_code = cdrcell - carcell; -#ifdef NEWCDRCODING - if ((cdrcell-carcell) > 7) error("in find_pair_in_page, cdr code too big."); - if (254 < (offset + (carcell->cdr_code << 1))) error ("in fpip, page overflow."); -#endif /* NEWCDRCODING */ - pg->count -= 2; - *((LispPTR *)cdrcell) = cdrval; - return(carcell); - } - else if ((offset>prior) && (offset <= prior+14)) - { - - carcell = (ConsCell *) ((DLword *)pg + prior); - cdrcell = (ConsCell *) ((DLword *)pg + offset); - if (priorprior) - FREECONS(pg,priorprior)->next_free = - ((freecons *)cdrcell) ->next_free; - else pg->next_cell = ((freecons *)cdrcell) ->next_free; - carcell -> cdr_code = cdrcell - carcell; -#ifdef NEWCDRCODING - if ((cdrcell-carcell) > 7) error("in find_pair_in_page, cdr code too big."); - if (254 < (prior + (carcell->cdr_code << 1))) error ("in fpip, page overflow."); -#endif /* NEWCDRCODING */ - pg->count -= 2; - *((LispPTR *)cdrcell) = cdrval; - return(carcell); - } - } - ppriorprior = priorprior; - priorprior = prior; - prior = offset; - - } - return((ConsCell *)0); - } - - - -ConsCell * find_cdrcodable_pair(LispPTR cdrval) -{ - ConsCell * cell; - struct conspage *pg; - unsigned pgno = ListpDTD->dtd_nextpage; - - for (pg = (struct conspage *)Addr68k_from_LPAGE(pgno); pgno; - pg = (struct conspage *)Addr68k_from_LPAGE(pgno = pg->next_page)) - if ((cell = find_pair_in_page(pg, cdrval))) return(cell); - - pg = next_conspage(); - cell = find_pair_in_page(pg,cdrval); - return(cell); - } /* end of find_cdrcodable_pair */ - - - - -ConsCell * find_free_cons_cell(void) -{ - ConsCell * cell; - struct conspage *pg, *priorpg; - unsigned pgno = ListpDTD->dtd_nextpage; - - - for (pg = (struct conspage *)Addr68k_from_LPAGE(pgno); pgno; - pg = (struct conspage *)Addr68k_from_LPAGE(pgno)) - if (pg->count) - { - pg->count--; - cell =(ConsCell *) (((DLword *)pg)+(pg->next_cell)); - pg->next_cell = ((freecons *)cell)->next_free; - return(cell); - } - else - { /* remove the empty page from the free chain */ - pgno = ListpDTD->dtd_nextpage = pg->next_page; - pg->next_page = CONSPAGE_LAST; + for (offset = pg->next_cell; offset; offset = FREECONS(pg, offset)->next_free) { + if (prior) { + /* if ((6^prior) <= (6^offset)) error("free list in CONS page corrupt."); */ + if ((prior > offset) && (prior <= offset + 14)) { + poffset = offset; + noffset = FREECONS(pg, offset)->next_free; + while ((noffset > offset) && (noffset < prior)) { + nprior = offset; + poffset = prior; + offset = noffset; + noffset = FREECONS(pg, offset)->next_free; } + carcell = (ConsCell *)((DLword *)pg + offset); + cdrcell = (ConsCell *)((DLword *)pg + prior); + if (priorprior) + FREECONS(pg, priorprior)->next_free = FREECONS(pg, poffset)->next_free; + else + pg->next_cell = FREECONS(pg, poffset)->next_free; + if (nprior) FREECONS(pg, nprior)->next_free = FREECONS(pg, offset)->next_free; + carcell->cdr_code = cdrcell - carcell; +#ifdef NEWCDRCODING + if ((cdrcell - carcell) > 7) error("in find_pair_in_page, cdr code too big."); + if (254 < (offset + (carcell->cdr_code << 1))) error("in fpip, page overflow."); +#endif /* NEWCDRCODING */ + pg->count -= 2; + *((LispPTR *)cdrcell) = cdrval; + return (carcell); + } else if ((offset > prior) && (offset <= prior + 14)) { + carcell = (ConsCell *)((DLword *)pg + prior); + cdrcell = (ConsCell *)((DLword *)pg + offset); + if (priorprior) + FREECONS(pg, priorprior)->next_free = ((freecons *)cdrcell)->next_free; + else + pg->next_cell = ((freecons *)cdrcell)->next_free; + carcell->cdr_code = cdrcell - carcell; +#ifdef NEWCDRCODING + if ((cdrcell - carcell) > 7) error("in find_pair_in_page, cdr code too big."); + if (254 < (prior + (carcell->cdr_code << 1))) error("in fpip, page overflow."); +#endif /* NEWCDRCODING */ + pg->count -= 2; + *((LispPTR *)cdrcell) = cdrval; + return (carcell); + } + } + ppriorprior = priorprior; + priorprior = prior; + prior = offset; + } + return ((ConsCell *)0); +} - return((ConsCell *)0); - } /* end of find_free_cons_cell */ +ConsCell *find_cdrcodable_pair(LispPTR cdrval) { + ConsCell *cell; + struct conspage *pg; + unsigned pgno = ListpDTD->dtd_nextpage; + for (pg = (struct conspage *)Addr68k_from_LPAGE(pgno); pgno; + pg = (struct conspage *)Addr68k_from_LPAGE(pgno = pg->next_page)) + if ((cell = find_pair_in_page(pg, cdrval))) return (cell); + pg = next_conspage(); + cell = find_pair_in_page(pg, cdrval); + return (cell); +} /* end of find_cdrcodable_pair */ + +ConsCell *find_free_cons_cell(void) { + ConsCell *cell; + struct conspage *pg, *priorpg; + unsigned pgno = ListpDTD->dtd_nextpage; + + for (pg = (struct conspage *)Addr68k_from_LPAGE(pgno); pgno; + pg = (struct conspage *)Addr68k_from_LPAGE(pgno)) + if (pg->count) { + pg->count--; + cell = (ConsCell *)(((DLword *)pg) + (pg->next_cell)); + pg->next_cell = ((freecons *)cell)->next_free; + return (cell); + } else { /* remove the empty page from the free chain */ + pgno = ListpDTD->dtd_nextpage = pg->next_page; + pg->next_page = CONSPAGE_LAST; + } + + return ((ConsCell *)0); +} /* end of find_free_cons_cell */ /**********************************************************************/ /* - Func name :N_OP_cons - Execute CONS OPCODE + Func name :N_OP_cons + Execute CONS OPCODE - Date : March 29 1988 - Edited by : Bob Krivacic + Date : March 29 1988 + Edited by : Bob Krivacic */ /**********************************************************************/ -LispPTR N_OP_cons(register int cons_car, register int cons_cdr) -{ - extern struct dtd *ListpDTD ; +LispPTR N_OP_cons(register int cons_car, register int cons_cdr) { + extern struct dtd *ListpDTD; - register struct conspage *new_conspage ; - register ConsCell *new_cell ; - register ConsCell *temp_cell ; - register int new_page ; /* hold the return val of nextconspage ,DL->int */ + register struct conspage *new_conspage; + register ConsCell *new_cell; + register ConsCell *temp_cell; + register int new_page; /* hold the return val of nextconspage ,DL->int */ - extern ConsCell * find_close_prior_cell(struct conspage *page, LispPTR oldcell); + extern ConsCell *find_close_prior_cell(struct conspage * page, LispPTR oldcell); - GCLOOKUP(cons_cdr &= POINTERMASK, ADDREF); - GCLOOKUP(cons_car, ADDREF); + GCLOOKUP(cons_cdr &= POINTERMASK, ADDREF); + GCLOOKUP(cons_car, ADDREF); - - if(cons_cdr == NIL_PTR) - { + if (cons_cdr == NIL_PTR) { #ifdef NEWCDRCODING - if ((new_cell = find_free_cons_cell())) - { /* next page has 1 or more free cells */ + if ((new_cell = find_free_cons_cell())) { /* next page has 1 or more free cells */ #else - if ((ListpDTD->dtd_nextpage != 0) - && (GetCONSCount(ListpDTD->dtd_nextpage) > 0)) - { /* next page has 1 or more free cells */ - new_page = ListpDTD->dtd_nextpage; - new_conspage = (struct conspage *)Addr68k_from_LPAGE(new_page); - if (new_conspage->next_cell == 0) error("count ne 0, but nothing on free chain."); - new_cell = GetNewCell_68k(new_conspage); /* get new cell */ + if ((ListpDTD->dtd_nextpage != 0) && + (GetCONSCount(ListpDTD->dtd_nextpage) > 0)) { /* next page has 1 or more free cells */ + new_page = ListpDTD->dtd_nextpage; + new_conspage = (struct conspage *)Addr68k_from_LPAGE(new_page); + if (new_conspage->next_cell == 0) error("count ne 0, but nothing on free chain."); + new_cell = GetNewCell_68k(new_conspage); /* get new cell */ - new_conspage->count --; /* decrement free cnt. */ - new_conspage->next_cell - = ((freecons *)new_cell)->next_free ; /* update free cell chain */ + new_conspage->count--; /* decrement free cnt. */ + new_conspage->next_cell = ((freecons *)new_cell)->next_free; /* update free cell chain */ #endif /* NEWCDRCODING */ - /* filling new cell with the data */ - new_cell->car_field = cons_car ; - new_cell->cdr_code = CDR_NIL ; + /* filling new cell with the data */ + new_cell->car_field = cons_car; + new_cell->cdr_code = CDR_NIL; - ListpDTD->dtd_cnt0++; + ListpDTD->dtd_cnt0++; - } /* if (ListpDTD.. end */ - else - { /* Need to get a new CONS page */ - new_conspage=next_conspage(); + } /* if (ListpDTD.. end */ + else { /* Need to get a new CONS page */ + new_conspage = next_conspage(); - new_cell = GetNewCell_68k( new_conspage ) ; + new_cell = GetNewCell_68k(new_conspage); - new_conspage->count --; /* decrement free cnt. */ - new_conspage->next_cell - = ((freecons *)new_cell)->next_free ; /* update free cell chain */ + new_conspage->count--; /* decrement free cnt. */ + new_conspage->next_cell = ((freecons *)new_cell)->next_free; /* update free cell chain */ - /* filling new cell with the data */ - new_cell->car_field = cons_car ; - new_cell->cdr_code = CDR_NIL ; + /* filling new cell with the data */ + new_cell->car_field = cons_car; + new_cell->cdr_code = CDR_NIL; - ListpDTD->dtd_oldcnt++; + ListpDTD->dtd_oldcnt++; - } /* else 1 end */ - } /* if(cons_cdr.. end */ - else /* cons_cdr != NIL */ - { - new_page = POINTER_PAGE(cons_cdr); /* Y's page num */ - new_conspage= (struct conspage *)Addr68k_from_LPAGE(new_page); + } /* else 1 end */ + } /* if(cons_cdr.. end */ + else /* cons_cdr != NIL */ + { + new_page = POINTER_PAGE(cons_cdr); /* Y's page num */ + new_conspage = (struct conspage *)Addr68k_from_LPAGE(new_page); #ifdef NEWCDRCODING - if (Listp(cons_cdr) && (new_conspage->count > 0 ) - && (new_cell = find_close_prior_cell(new_conspage, cons_cdr))) + if (Listp(cons_cdr) && (new_conspage->count > 0) && + (new_cell = find_close_prior_cell(new_conspage, cons_cdr))) #else - if(Listp(cons_cdr) && (new_conspage->count > 0 )) + if (Listp(cons_cdr) && (new_conspage->count > 0)) #endif /* NEWCDRCODING */ - { /* The cdr is itself a CONS cell, and can be */ - /* represented using CDR_ONPAGE representation */ + { /* The cdr is itself a CONS cell, and can be */ + /* represented using CDR_ONPAGE representation */ #ifndef NEWCDRCODING - new_cell = GetNewCell_68k( new_conspage ) ; + new_cell = GetNewCell_68k(new_conspage); #ifdef DEBUG - if(new_cell->car_field != NIL) - { - printf("CELL 0x%x has non-NIL car = 0x%x \n", - LADDR_from_68k(new_cell), new_cell->car_field); - error("QUIT from N_OP_cons"); - } + if (new_cell->car_field != NIL) { + printf("CELL 0x%x has non-NIL car = 0x%x \n", LADDR_from_68k(new_cell), + new_cell->car_field); + error("QUIT from N_OP_cons"); + } #endif - new_conspage->count --; /* decrement free cnt. */ - new_conspage->next_cell - = ((freecons *)new_cell)->next_free ; /* update free cell chain */ -#endif /*NEWCDRCODING */ + new_conspage->count--; /* decrement free cnt. */ + new_conspage->next_cell = ((freecons *)new_cell)->next_free; /* update free cell chain */ +#endif /*NEWCDRCODING */ - new_cell->car_field = cons_car ; - /* cdr_onpage + cell offset in this conspage */ + new_cell->car_field = cons_car; +/* cdr_onpage + cell offset in this conspage */ #ifdef NEWCDRCODING #else - new_cell->cdr_code = CDR_ONPAGE | ((cons_cdr&0xff)>>1) ; + new_cell->cdr_code = CDR_ONPAGE | ((cons_cdr & 0xff) >> 1); #endif /* NEWCDRCODING */ - ListpDTD->dtd_cnt0++; + ListpDTD->dtd_cnt0++; - - } /* if (listp.. end */ - else - { - /* UFN case : CDR_INDIRECT */ + } /* if (listp.. end */ + else { +/* UFN case : CDR_INDIRECT */ #ifdef NEWCDRCODING - new_cell = find_cdrcodable_pair(cons_cdr); + new_cell = find_cdrcodable_pair(cons_cdr); #else - new_conspage = next_conspage(); + new_conspage = next_conspage(); - /* get 2 cells from conspage */ - temp_cell = GetNewCell_68k( new_conspage ) ; + /* get 2 cells from conspage */ + temp_cell = GetNewCell_68k(new_conspage); #ifdef DEBUG - if(temp_cell->car_field != NIL) { - printf("CDR indirect CELL 0x%x has non-NIL car 0x%x \n", - LADDR_from_68k(new_cell), temp_cell->car_field); - error("QUIT from N_OP_cons"); - } + if (temp_cell->car_field != NIL) { + printf("CDR indirect CELL 0x%x has non-NIL car 0x%x \n", LADDR_from_68k(new_cell), + temp_cell->car_field); + error("QUIT from N_OP_cons"); + } #endif - new_conspage->next_cell - = ((freecons *)temp_cell)->next_free ; /* update free cell chain */ - new_cell = GetNewCell_68k( new_conspage ) ; + new_conspage->next_cell = ((freecons *)temp_cell)->next_free; /* update free cell chain */ + new_cell = GetNewCell_68k(new_conspage); #ifdef DEBUG - if(new_cell->car_field != NIL) { - printf("CDR ind-2 CELL 0x%x has non-NIL car = 0x%x \n", - LADDR_from_68k(new_cell), new_cell->car_field); - error("QUIT from N_OP_cons"); - } + if (new_cell->car_field != NIL) { + printf("CDR ind-2 CELL 0x%x has non-NIL car = 0x%x \n", LADDR_from_68k(new_cell), + new_cell->car_field); + error("QUIT from N_OP_cons"); + } #endif - new_conspage->next_cell - = ((freecons *)new_cell)->next_free ; /* update free cell chain */ - new_conspage->count -= 2; /* decrement free cnt. */ + new_conspage->next_cell = ((freecons *)new_cell)->next_free; /* update free cell chain */ + new_conspage->count -= 2; /* decrement free cnt. */ - /* filling cell */ - *((LispPTR *)temp_cell) = cons_cdr ; /* Indirect CDR ptr */ + /* filling cell */ + *((LispPTR *)temp_cell) = cons_cdr; /* Indirect CDR ptr */ #endif /* NEWCDRCODING */ - new_cell->car_field = cons_car ; + new_cell->car_field = cons_car; #ifndef NEWCDRCODING - /* culc. cdr code */ - new_cell->cdr_code = (((LispPTR)LADDR_from_68k(temp_cell)) & 0xff) >> 1; + /* culc. cdr code */ + new_cell->cdr_code = (((LispPTR)LADDR_from_68k(temp_cell)) & 0xff) >> 1; #endif /* NEWCDRCODING */ - ListpDTD->dtd_oldcnt++ ; /* added feb-12 take */ + ListpDTD->dtd_oldcnt++; /* added feb-12 take */ + } /* else end */ - } /* else end */ + } /* else (cons_cdr==NIL end) */ - } /* else (cons_cdr==NIL end) */ - - - new_page = LADDR_from_68k(new_cell) ; - GCLOOKUP(new_page, DELREF); + new_page = LADDR_from_68k(new_cell); + GCLOOKUP(new_page, DELREF); #ifdef NEWCDRCODING - if (254 < ((new_page & 0xff) + ((new_cell->cdr_code & 7)<<1))) error("in CONS, cdr code too big."); + if (254 < ((new_page & 0xff) + ((new_cell->cdr_code & 7) << 1))) + error("in CONS, cdr code too big."); #endif /* NEWCDROCDING */ - return(new_page); + return (new_page); - } /* N_OP_cons() end */ +} /* N_OP_cons() end */ /**********************************************************************/ /* function cons same as N_OP_cons */ /**********************************************************************/ -LispPTR cons(LispPTR cons_car, LispPTR cons_cdr) -{ - return(N_OP_cons(cons_car, cons_cdr)); -} +LispPTR cons(LispPTR cons_car, LispPTR cons_cdr) { return (N_OP_cons(cons_car, cons_cdr)); } diff --git a/src/dbgtool.c b/src/dbgtool.c old mode 100755 new mode 100644 index 37fe80d..18349a1 --- a/src/dbgtool.c +++ b/src/dbgtool.c @@ -1,8 +1,7 @@ -/* $Id: dbgtool.c,v 1.4 2001/12/24 01:09:00 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: dbgtool.c,v 1.4 2001/12/24 01:09:00 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: dbgtool.c,v 1.4 2001/12/24 01:09:00 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -17,24 +16,23 @@ static char *id = "$Id: dbgtool.c,v 1.4 2001/12/24 01:09:00 sybalsky Exp $ Copyr #include "version.h" - /***************************************************************/ /* - file name : Kdbgtool.c + file name : Kdbgtool.c - For Debugging Aids + For Debugging Aids - Including : - get_ivar_name(fx_addr68k , offset) + Including : + get_ivar_name(fx_addr68k , offset) - date : 25 Aug 1987 NMitani - changed: 09 Sep 1987 NMitani + date : 25 Aug 1987 NMitani + changed: 09 Sep 1987 NMitani */ /***************************************************************/ #include #include -#include +#include #include "lispemul.h" #include "lispmap.h" #include "adr68k.h" @@ -44,26 +42,26 @@ static char *id = "$Id: dbgtool.c,v 1.4 2001/12/24 01:09:00 sybalsky Exp $ Copyr #include "cell.h" #include "stack.h" -#define LOCAL_PVAR 0xFFFF +#define LOCAL_PVAR 0xFFFF #ifdef BIGATOMS -#define VTY_IVAR 0x00000000 -#define VTY_PVAR 0x80000000 -#define VTY_FVAR 0xC0000000 -#define NT_OFFSET_MASK 0xFFFFFFF -#define GetNTEntry(X) GetLongWord(X) -#define NAMETABLE LispPTR +#define VTY_IVAR 0x00000000 +#define VTY_PVAR 0x80000000 +#define VTY_FVAR 0xC0000000 +#define NT_OFFSET_MASK 0xFFFFFFF +#define GetNTEntry(X) GetLongWord(X) +#define NAMETABLE LispPTR #else -#define VTY_IVAR 0x0000 -#define VTY_PVAR 0x8000 -#define VTY_FVAR 0xC000 -#define NT_OFFSET_MASK 0xFF -#define GetNTEntry(X) GETWORD(X) -#define NAMETABLE DLword +#define VTY_IVAR 0x0000 +#define VTY_PVAR 0x8000 +#define VTY_FVAR 0xC000 +#define NT_OFFSET_MASK 0xFF +#define GetNTEntry(X) GETWORD(X) +#define NAMETABLE DLword #endif -#define URMAXFXNUM 2000 -#define URSCAN_ALINK 0 -#define URSCAN_CLINK 1 +#define URMAXFXNUM 2000 +#define URSCAN_ALINK 0 +#define URSCAN_CLINK 1 extern int URaid_scanlink; extern int URaid_currentFX; extern FX *URaid_FXarray[]; @@ -73,168 +71,153 @@ int BT_temp; jmp_buf BT_jumpbuf; #ifdef DOS #define BTMAXLINE 24 - /* DOS has a 25-line screen, and getchar discards ESC for some reason */ -#define BT_morep if((BT_temp != '!') && (++BT_lines>BTMAXLINE)){\ - printf("Press Return(Esc & Ret to quit, ! don't stop):");\ - BT_temp=getch();\ - fflush(stdin);\ - BT_lines=0; \ - if(BT_temp==27)longjmp(BT_jumpbuf,1) ; \ - } +/* DOS has a 25-line screen, and getchar discards ESC for some reason */ +#define BT_morep \ + if ((BT_temp != '!') && (++BT_lines > BTMAXLINE)) { \ + printf("Press Return(Esc & Ret to quit, ! don't stop):"); \ + BT_temp = getch(); \ + fflush(stdin); \ + BT_lines = 0; \ + if (BT_temp == 27) longjmp(BT_jumpbuf, 1); \ + } #else /* DOS */ #define BTMAXLINE 30 -#define BT_morep if(++BT_lines>BTMAXLINE){\ - printf("Press Return(to quit Esc and Ret):");\ - BT_temp=getchar();\ - fflush(stdin);\ - BT_lines=0; \ - if(BT_temp==27)longjmp(BT_jumpbuf,1) ; \ - } +#define BT_morep \ + if (++BT_lines > BTMAXLINE) { \ + printf("Press Return(to quit Esc and Ret):"); \ + BT_temp = getchar(); \ + fflush(stdin); \ + BT_lines = 0; \ + if (BT_temp == 27) longjmp(BT_jumpbuf, 1); \ + } #endif /* DOS */ - /***************************************************************/ /* - Func Name : get_ivar_name + Func Name : get_ivar_name - Desc : returns atom index of ivar on the given - FX. - If ivar is localvars then set *localivar - 1 otherwize 0. + Desc : returns atom index of ivar on the given + FX. + If ivar is localvars then set *localivar + 1 otherwize 0. - Changed 25 Aug 1987 NMitani + Changed 25 Aug 1987 NMitani */ /***************************************************************/ -LispPTR get_ivar_name(struct frameex1 *fx_addr68k, DLword offset, int *localivar) -{ - NAMETABLE *first_table; - NAMETABLE *second_table; - struct fnhead *fnobj; - int i; +LispPTR get_ivar_name(struct frameex1 *fx_addr68k, DLword offset, int *localivar) { + NAMETABLE *first_table; + NAMETABLE *second_table; + struct fnhead *fnobj; + int i; #ifdef BIGVM - fnobj = (struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader); + fnobj = (struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader); #else - fnobj = (struct fnhead *)Addr68k_from_LADDR( - ((int)(fx_addr68k)->hi2fnheader << 16) | (fx_addr68k)->lofnheader); + fnobj = (struct fnhead *)Addr68k_from_LADDR(((int)(fx_addr68k)->hi2fnheader << 16) | + (fx_addr68k)->lofnheader); #endif /* BIGVM */ - if (fnobj->ntsize > 0) - { - /* name table exists */ - first_table = (NAMETABLE *)(fnobj + 1); - second_table =(NAMETABLE *)((DLword *)first_table + fnobj->ntsize); - - for(i = 0; (i < fnobj->ntsize) && (GetNTEntry(second_table) != offset) ; - first_table++ , second_table++ , i++) ; - if ((i < fnobj->ntsize) && (GetNTEntry(first_table) != 0)) - { - /* target ivar was in name table */ - *localivar = 0 ; - return((LispPTR)(GetNTEntry(first_table))); - } - else - { - /* Target ivar is in locar vars table */ -#ifdef BIGATOMS - first_table = (NAMETABLE *)(fnobj + 1) + (fnobj->ntsize ); - second_table = first_table + (((DLword *)fnobj - + (fnobj->startpc >> 1) - - (DLword *)first_table) >> 2); -#else - first_table = (NAMETABLE *)(fnobj + 1) + (fnobj->ntsize << 1); - second_table = first_table + (((DLword *)fnobj + - (fnobj->startpc >> 1) - first_table) >> 1); -#endif - } - } - else - { - /* name table doesn't exist, so all ivars are in locar vars table */ -#ifdef BIGATOMS - int delta; - first_table = (NAMETABLE *)(fnobj + 1) + (4>>1); - delta = (DLword *)(((DLword *)fnobj) - + (fnobj->startpc >> 1)) - - (DLword *)first_table; - second_table = first_table + (delta >> 2); -#else - first_table = (NAMETABLE *)(fnobj + 1) + 4; - second_table = first_table + - (((DLword *)fnobj + (fnobj->startpc >> 1) - first_table) >> 1); -#endif - } -#ifdef BIGATOMS - while (*(second_table) != (VTY_IVAR |offset)) -#else - while (GETWORD(second_table) != (VTY_IVAR |offset)) -#endif /* BIGATOMS */ - - { - first_table++ ; - second_table++ ; - } - *localivar = 1 ; - -#ifdef BIGATOMS - return((LispPTR)( *(first_table))); -#else - return((LispPTR)(GETWORD(first_table))); -#endif /* BIGATOMS */ - - - }/* end get_ivar_name */ - - - -/***************************************************************/ -/* - Func Name : get_pvar_name - - Desc : returns atom index of pvar on the given - FX or LOCAL_PVAR if that pvar is localvars. - - Changed 26 Aug 1987 NMitani - -*/ -/***************************************************************/ - -LispPTR get_pvar_name(struct frameex1 *fx_addr68k, DLword offset) -{ - NAMETABLE *first_table; - NAMETABLE *second_table; - struct fnhead *fnobj; - int i; - -#ifdef BIGVM - fnobj = (struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader); -#else - fnobj = (struct fnhead *)Addr68k_from_LADDR( - ((int)(fx_addr68k)->hi2fnheader << 16) | (fx_addr68k)->lofnheader); -#endif /* BIGVM */ - + if (fnobj->ntsize > 0) { + /* name table exists */ first_table = (NAMETABLE *)(fnobj + 1); - second_table =(NAMETABLE *)((DLword *)first_table + fnobj->ntsize); - if (first_table == second_table) return(LOCAL_PVAR); /* no name table */ + second_table = (NAMETABLE *)((DLword *)first_table + fnobj->ntsize); - for(i = 0; + for (i = 0; (i < fnobj->ntsize) && (GetNTEntry(second_table) != offset); + first_table++, second_table++, i++) + ; + if ((i < fnobj->ntsize) && (GetNTEntry(first_table) != 0)) { + /* target ivar was in name table */ + *localivar = 0; + return ((LispPTR)(GetNTEntry(first_table))); + } else { +/* Target ivar is in locar vars table */ #ifdef BIGATOMS - i < (fnobj->ntsize >> 1) && *(second_table) != (VTY_PVAR | offset); + first_table = (NAMETABLE *)(fnobj + 1) + (fnobj->ntsize); + second_table = + first_table + (((DLword *)fnobj + (fnobj->startpc >> 1) - (DLword *)first_table) >> 2); #else - i < fnobj->ntsize && GETWORD(second_table) != (VTY_PVAR | offset); + first_table = (NAMETABLE *)(fnobj + 1) + (fnobj->ntsize << 1); + second_table = first_table + (((DLword *)fnobj + (fnobj->startpc >> 1) - first_table) >> 1); #endif - first_table++ , second_table++ , i++) /* Do nothing */; + } + } else { +/* name table doesn't exist, so all ivars are in locar vars table */ +#ifdef BIGATOMS + int delta; + first_table = (NAMETABLE *)(fnobj + 1) + (4 >> 1); + delta = (DLword *)(((DLword *)fnobj) + (fnobj->startpc >> 1)) - (DLword *)first_table; + second_table = first_table + (delta >> 2); +#else + first_table = (NAMETABLE *)(fnobj + 1) + 4; + second_table = first_table + (((DLword *)fnobj + (fnobj->startpc >> 1) - first_table) >> 1); +#endif + } +#ifdef BIGATOMS + while (*(second_table) != (VTY_IVAR | offset)) +#else + while (GETWORD(second_table) != (VTY_IVAR | offset)) +#endif /* BIGATOMS */ + + { + first_table++; + second_table++; + } + *localivar = 1; #ifdef BIGATOMS - if (i < (fnobj->ntsize >> 1)) return((LispPTR) *(first_table)); + return ((LispPTR)(*(first_table))); #else - if (i < fnobj->ntsize) return((LispPTR)GETWORD(first_table)); + return ((LispPTR)(GETWORD(first_table))); +#endif /* BIGATOMS */ + +} /* end get_ivar_name */ + +/***************************************************************/ +/* + Func Name : get_pvar_name + + Desc : returns atom index of pvar on the given + FX or LOCAL_PVAR if that pvar is localvars. + + Changed 26 Aug 1987 NMitani + +*/ +/***************************************************************/ + +LispPTR get_pvar_name(struct frameex1 *fx_addr68k, DLword offset) { + NAMETABLE *first_table; + NAMETABLE *second_table; + struct fnhead *fnobj; + int i; + +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR(((int)(fx_addr68k)->hi2fnheader << 16) | + (fx_addr68k)->lofnheader); +#endif /* BIGVM */ + + first_table = (NAMETABLE *)(fnobj + 1); + second_table = (NAMETABLE *)((DLword *)first_table + fnobj->ntsize); + if (first_table == second_table) return (LOCAL_PVAR); /* no name table */ + + for (i = 0; +#ifdef BIGATOMS + i < (fnobj->ntsize >> 1) && *(second_table) != (VTY_PVAR | offset); +#else + i < fnobj->ntsize && GETWORD(second_table) != (VTY_PVAR | offset); #endif - else return(LOCAL_PVAR); /* Pvar was local */ - }/* end get_pvar_name */ - - + first_table++, second_table++, i++) /* Do nothing */ + ; +#ifdef BIGATOMS + if (i < (fnobj->ntsize >> 1)) return ((LispPTR) * (first_table)); +#else + if (i < fnobj->ntsize) return ((LispPTR)GETWORD(first_table)); +#endif + else + return (LOCAL_PVAR); /* Pvar was local */ +} /* end get_pvar_name */ /************************************************************************/ /* */ @@ -244,34 +227,29 @@ LispPTR get_pvar_name(struct frameex1 *fx_addr68k, DLword offset) /* */ /************************************************************************/ -LispPTR get_fn_fvar_name(struct fnhead *fnobj, DLword offset) -{ - NAMETABLE *first_table; - NAMETABLE *second_table; +LispPTR get_fn_fvar_name(struct fnhead *fnobj, DLword offset) { + NAMETABLE *first_table; + NAMETABLE *second_table; - first_table = (NAMETABLE *)((DLword *)fnobj + fnobj->fvaroffset); - second_table =(NAMETABLE *)((DLword *)first_table + fnobj->ntsize); + first_table = (NAMETABLE *)((DLword *)fnobj + fnobj->fvaroffset); + second_table = (NAMETABLE *)((DLword *)first_table + fnobj->ntsize); #ifdef BIGATOMS - while (*(second_table) != (VTY_FVAR | offset)) + while (*(second_table) != (VTY_FVAR | offset)) #else - while (GETWORD(second_table) != (VTY_FVAR | offset)) + while (GETWORD(second_table) != (VTY_FVAR | offset)) #endif /* BIGATOMS */ - { - first_table++ ; - second_table++; - } + { + first_table++; + second_table++; + } #ifdef BIGATOMS - return((LispPTR) *(first_table)); + return ((LispPTR) * (first_table)); #else - return((LispPTR)GETWORD(first_table)); + return ((LispPTR)GETWORD(first_table)); #endif /* BIGATOMS */ - - }/* end get_fvar_name */ - - - +} /* end get_fvar_name */ /************************************************************************/ /* */ @@ -281,17 +259,15 @@ LispPTR get_fn_fvar_name(struct fnhead *fnobj, DLword offset) /* */ /************************************************************************/ -LispPTR get_fvar_name(struct frameex1 *fx_addr68k, DLword offset) -{ +LispPTR get_fvar_name(struct frameex1 *fx_addr68k, DLword offset) { #ifdef BIGVM return (get_fn_fvar_name((struct fnhead *)Addr68k_from_LADDR((fx_addr68k)->fnheader), offset)); #else - return (get_fn_fvar_name( - (struct fnhead *)Addr68k_from_LADDR(((int)(fx_addr68k)->hi2fnheader << 16) | (fx_addr68k)->lofnheader), offset)); + return (get_fn_fvar_name((struct fnhead *)Addr68k_from_LADDR( + ((int)(fx_addr68k)->hi2fnheader << 16) | (fx_addr68k)->lofnheader), + offset)); #endif /* BIGVM */ - }/* end get_fvar_name */ - - +} /* end get_fvar_name */ /************************************************************************/ /* */ @@ -304,285 +280,288 @@ LispPTR get_fvar_name(struct frameex1 *fx_addr68k, DLword offset) /* */ /************************************************************************/ -int sf(struct frameex1 *fx_addr68k) -{ - Bframe *bf; - DLword *next68k ; - DLword *ptr ; - DLword *ptrhi ; - DLword *ptrlo ; - LispPTR atomindex ; - int i; - DLword npvar; - DLword max_npvar; - LispPTR pvarindex ; - DLword nfvar; - struct fnhead *fnobj; - int localivar; - LispPTR ivarindex ; +int sf(struct frameex1 *fx_addr68k) { + Bframe *bf; + DLword *next68k; + DLword *ptr; + DLword *ptrhi; + DLword *ptrlo; + LispPTR atomindex; + int i; + DLword npvar; + DLword max_npvar; + LispPTR pvarindex; + DLword nfvar; + struct fnhead *fnobj; + int localivar; + LispPTR ivarindex; - BT_lines=0; - - if((UNSIGNED)fx_addr68k == 0) return(-1); - if((fx_addr68k)->flags != STK_FX) - { - printf("Invalid FX 0x%x, flags = 0x%x.\n", - LADDR_from_68k(fx_addr68k), - (fx_addr68k)->flags); - return(-1); - } - - if(((fx_addr68k)->alink & 1)==0) - { /* FAST */ - bf = (Bframe *)(((DLword *)fx_addr68k) - 2 ); - } - else - { /* SLOW */ - bf =(Bframe *) Addr68k_from_LADDR(((fx_addr68k)->blink+ STK_OFFSET)) ; - } - - /* Print IVARs */ - printf("IVAR -------\n");BT_morep; - - ptr = Addr68k_from_LADDR( STK_OFFSET + bf->ivar); - i=0; - while(ptr!=(DLword *)bf) - { - ptrhi = ptr; - ptrlo = ptr + 1 ; - printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr), - GETWORD(ptr) , GETWORD(ptrlo)); - ivarindex = get_ivar_name(fx_addr68k , i++ , &localivar); - if (localivar == 1) printf("*local* "); - print_atomname(ivarindex); - printf(" "); - print(*(LispPTR *)ptr); - putchar('\n');BT_morep; - ptr += 2 ; - } - putchar('\n');BT_morep; - printf("## STACK BF at 0x%x ##\n",(LispPTR)LADDR_from_68k(bf));BT_morep; - - /* print BF */ - if(bf->flags != 4) {printf("Invalid frame, NOT a BX\n");return(-1);} - putchar('['); - if (bf->residual) printf("Res, "); - if (bf->padding) printf("Pad, "); - printf("cnt=%d ]\n",bf->usecnt);BT_morep; - printf("ivar : 0x%x\n",bf->ivar);BT_morep; - - printf(">> Bf's ivar says 0x%x vs. IVar says 0x%x\n", - bf->ivar+STK_OFFSET,LADDR_from_68k(IVar));BT_morep; - - - atomindex = get_framename(fx_addr68k); - printf("Fname is "); - print(atomindex); - printf("\n");BT_morep; - - /***** printout FX ****/ - printf("## STACK FX at 0x%x ##\n",LADDR_from_68k(fx_addr68k));BT_morep; - - if((fx_addr68k)->flags != 6) - { printf("Invalid frame, NOT FX\n");return(-1);} - - putchar('['); - if((fx_addr68k)->fast) printf("F, "); - if((fx_addr68k)->incall) printf("incall, "); - if(fx_addr68k->validnametable) printf("V, "); - printf("cnt = %d ]\n",fx_addr68k->usecount);BT_morep; - - printf(" #alink 0x%x ",fx_addr68k->alink); - - if(fx_addr68k->alink & 1) printf("[SLOWP]\n"); - else printf("\n"); - - BT_morep; - -#ifdef BIGVM - printf(" fnhead 0x%x \n", fx_addr68k->fnheader);BT_morep; -#else - printf(" fnheadlo 0x%x \n",fx_addr68k->lofnheader);BT_morep; - printf(" hi1,hi2 fnhead 0x%x , 0x%x \n", - fx_addr68k->hi1fnheader,fx_addr68k->hi2fnheader);BT_morep; -#endif /* BIGVM */ - printf(" nextblock 0x%x \n",fx_addr68k->nextblock);BT_morep; - printf(" pc 0x%x \n",fx_addr68k->pc);BT_morep; -#ifdef BIGVM - printf(" nametbl 0x%x \n", fx_addr68k->nametable);BT_morep; -#else - printf(" lonametbl 0x%x \n",fx_addr68k->lonametable);BT_morep; - printf(" hi1,hi2 nametbl 0x%x , 0x%x \n", - fx_addr68k->hi1nametable,fx_addr68k->hi2nametable);BT_morep; -#endif /* BIGVM */ - printf(" #blink 0x%x \n",fx_addr68k->blink);BT_morep; - printf(" #clink 0x%x \n",fx_addr68k->clink);BT_morep; - - /* added by NMitani 26 Aug 87 */ - -#ifdef BIGVM - fnobj = (struct fnhead *)Addr68k_from_LADDR(fx_addr68k->fnheader); -#else - fnobj = (struct fnhead *)Addr68k_from_LADDR( - ((int)fx_addr68k->hi2fnheader << 16) | fx_addr68k->lofnheader); -#endif /* BIGVM */ - max_npvar = npvar = fnobj->nlocals; /* npvar is number of Pvars */ - if (fnobj->fvaroffset) -#ifdef BIGATOMS - nfvar = *((NAMETABLE *) - ((DLword *)fnobj + fnobj->fvaroffset + fnobj->ntsize)) & NT_OFFSET_MASK; -#else - nfvar = GETWORD((NAMETABLE *) - ((DLword *)fnobj + fnobj->fvaroffset + fnobj->ntsize)) & NT_OFFSET_MASK; -#endif /* BIGATOMS */ - - else nfvar = 0; - - if (fx_addr68k == CURRENTFX) - { - ptr=PVar; - i = 0; - while(npvar-- > 0) - { - ptrhi = ptr; - ptrlo = ptr + 1 ; - printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , - GETWORD(ptrlo)); - if ((pvarindex = get_pvar_name(fx_addr68k , i++)) == LOCAL_PVAR) - printf("*local* [pvar%d] " , (i - 1)); - else - print_atomname(pvarindex); - if (GETWORD(ptr) == 0xFFFF) - { - printf(" [variable not bound]\n");BT_morep; - } - else - { - printf(" "); - print(*(LispPTR *)ptr); - putchar('\n'); BT_morep; - } - ptr += 2 ; - } - i = max_npvar; - while(nfvar && nfvar-- >= max_npvar) - { - ptrhi = ptr; - ptrlo = ptr + 1 ; - printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , - GETWORD(ptrlo)); - if (0xFFFF == GETWORD(ptrhi)) - { - printf("[not looked up] "); - print_atomname(get_fvar_name(fx_addr68k , i)); - putchar('\n');BT_morep; - } - else if ((0xFFFF & GETWORD(ptrlo)) == 1) - { - printf("[fvar "); - print_atomname(get_fvar_name(fx_addr68k , i)); - printf(" on stack] "); - print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); - putchar('\n');BT_morep; - } - else - { - printf("[fvar "); - print_atomname(get_fvar_name(fx_addr68k , i)); - printf(" top value ] "); - print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0xFFF & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); - putchar('\n');BT_morep; - } - ptr += 2 ; - i++; - } - if (fx_addr68k->alink == 11) /* for contextsw */ - next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock+STK_OFFSET)) ; - - else next68k = CurrentStackPTR; - while(ptr < next68k) - { - ptrhi = ptr; - ptrlo = ptr + 1 ; - printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , - GETWORD(ptrlo)); - print(*(LispPTR *)ptr); - ptr += 2 ; - putchar('\n');BT_morep; - } - printf("this frame is last !!\n");BT_morep; - return(-1); - } - - next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock+STK_OFFSET)) ; - ptr =(DLword *)(fx_addr68k+1) ; - - i = 0; - while(npvar-- > 0) - { - ptrhi = ptr; - ptrlo = ptr + 1 ; - printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , - GETWORD(ptrlo)); - if ((pvarindex = get_pvar_name(fx_addr68k , i++)) == LOCAL_PVAR) - printf("*local* [pvar%d] " , (i - 1)); - else - print_atomname(pvarindex); - if (GETWORD(ptr) == 0xFFFF){ - printf(" [variable not bound]\n");BT_morep; - } - else{ - printf(" "); - print(*(LispPTR *)ptr); - putchar('\n'); BT_morep; - } - ptr += 2 ; - } - i = max_npvar; - - while(nfvar && nfvar-- >= max_npvar) - { - ptrhi = ptr; - ptrlo = ptr + 1 ; - printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptrhi) , - GETWORD(ptrlo)); - if (0xFFFF == GETWORD(ptrhi)) - { - printf("[not looked up] "); - print_atomname(get_fvar_name(fx_addr68k , i)); - putchar('\n');BT_morep; - } - else if ((0xFFFF & GETWORD(ptrlo)) == 1) - { - printf("[fvar "); - print_atomname(get_fvar_name(fx_addr68k , i)); - printf(" on stack] "); - print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); - putchar('\n');BT_morep; - } - else - { - printf("[fvar "); - print_atomname(get_fvar_name(fx_addr68k , i)); - printf(" top value ] "); - print(*(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); - putchar('\n');BT_morep; - } - ptr += 2 ; - i++; - } - - while(next68k > ptr) - { - printf(" %6x : 0x%4x 0x%4x ",LADDR_from_68k(ptr),GETWORD(ptr++) , - GETWORD(ptr++)); - putchar('\n');BT_morep; - } - return (0); + BT_lines = 0; + if ((UNSIGNED)fx_addr68k == 0) return (-1); + if ((fx_addr68k)->flags != STK_FX) { + printf("Invalid FX 0x%x, flags = 0x%x.\n", LADDR_from_68k(fx_addr68k), (fx_addr68k)->flags); + return (-1); } + if (((fx_addr68k)->alink & 1) == 0) { /* FAST */ + bf = (Bframe *)(((DLword *)fx_addr68k) - 2); + } else { /* SLOW */ + bf = (Bframe *)Addr68k_from_LADDR(((fx_addr68k)->blink + STK_OFFSET)); + } + /* Print IVARs */ + printf("IVAR -------\n"); + BT_morep; + + ptr = Addr68k_from_LADDR(STK_OFFSET + bf->ivar); + i = 0; + while (ptr != (DLword *)bf) { + ptrhi = ptr; + ptrlo = ptr + 1; + printf(" %6x : 0x%4x 0x%4x ", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptrlo)); + ivarindex = get_ivar_name(fx_addr68k, i++, &localivar); + if (localivar == 1) printf("*local* "); + print_atomname(ivarindex); + printf(" "); + print(*(LispPTR *)ptr); + putchar('\n'); + BT_morep; + ptr += 2; + } + putchar('\n'); + BT_morep; + printf("## STACK BF at 0x%x ##\n", (LispPTR)LADDR_from_68k(bf)); + BT_morep; + + /* print BF */ + if (bf->flags != 4) { + printf("Invalid frame, NOT a BX\n"); + return (-1); + } + putchar('['); + if (bf->residual) printf("Res, "); + if (bf->padding) printf("Pad, "); + printf("cnt=%d ]\n", bf->usecnt); + BT_morep; + printf("ivar : 0x%x\n", bf->ivar); + BT_morep; + + printf(">> Bf's ivar says 0x%x vs. IVar says 0x%x\n", bf->ivar + STK_OFFSET, + LADDR_from_68k(IVar)); + BT_morep; + + atomindex = get_framename(fx_addr68k); + printf("Fname is "); + print(atomindex); + printf("\n"); + BT_morep; + + /***** printout FX ****/ + printf("## STACK FX at 0x%x ##\n", LADDR_from_68k(fx_addr68k)); + BT_morep; + + if ((fx_addr68k)->flags != 6) { + printf("Invalid frame, NOT FX\n"); + return (-1); + } + + putchar('['); + if ((fx_addr68k)->fast) printf("F, "); + if ((fx_addr68k)->incall) printf("incall, "); + if (fx_addr68k->validnametable) printf("V, "); + printf("cnt = %d ]\n", fx_addr68k->usecount); + BT_morep; + + printf(" #alink 0x%x ", fx_addr68k->alink); + + if (fx_addr68k->alink & 1) + printf("[SLOWP]\n"); + else + printf("\n"); + + BT_morep; + +#ifdef BIGVM + printf(" fnhead 0x%x \n", fx_addr68k->fnheader); + BT_morep; +#else + printf(" fnheadlo 0x%x \n", fx_addr68k->lofnheader); + BT_morep; + printf(" hi1,hi2 fnhead 0x%x , 0x%x \n", fx_addr68k->hi1fnheader, fx_addr68k->hi2fnheader); + BT_morep; +#endif /* BIGVM */ + printf(" nextblock 0x%x \n", fx_addr68k->nextblock); + BT_morep; + printf(" pc 0x%x \n", fx_addr68k->pc); + BT_morep; +#ifdef BIGVM + printf(" nametbl 0x%x \n", fx_addr68k->nametable); + BT_morep; +#else + printf(" lonametbl 0x%x \n", fx_addr68k->lonametable); + BT_morep; + printf(" hi1,hi2 nametbl 0x%x , 0x%x \n", fx_addr68k->hi1nametable, fx_addr68k->hi2nametable); + BT_morep; +#endif /* BIGVM */ + printf(" #blink 0x%x \n", fx_addr68k->blink); + BT_morep; + printf(" #clink 0x%x \n", fx_addr68k->clink); + BT_morep; + +/* added by NMitani 26 Aug 87 */ + +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR(fx_addr68k->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR(((int)fx_addr68k->hi2fnheader << 16) | + fx_addr68k->lofnheader); +#endif /* BIGVM */ + max_npvar = npvar = fnobj->nlocals; /* npvar is number of Pvars */ + if (fnobj->fvaroffset) +#ifdef BIGATOMS + nfvar = *((NAMETABLE *)((DLword *)fnobj + fnobj->fvaroffset + fnobj->ntsize)) & NT_OFFSET_MASK; +#else + nfvar = GETWORD((NAMETABLE *)((DLword *)fnobj + fnobj->fvaroffset + fnobj->ntsize)) & + NT_OFFSET_MASK; +#endif /* BIGATOMS */ + + else + nfvar = 0; + + if (fx_addr68k == CURRENTFX) { + ptr = PVar; + i = 0; + while (npvar-- > 0) { + ptrhi = ptr; + ptrlo = ptr + 1; + printf(" %6x : 0x%4x 0x%4x ", LADDR_from_68k(ptr), GETWORD(ptrhi), GETWORD(ptrlo)); + if ((pvarindex = get_pvar_name(fx_addr68k, i++)) == LOCAL_PVAR) + printf("*local* [pvar%d] ", (i - 1)); + else + print_atomname(pvarindex); + if (GETWORD(ptr) == 0xFFFF) { + printf(" [variable not bound]\n"); + BT_morep; + } else { + printf(" "); + print(*(LispPTR *)ptr); + putchar('\n'); + BT_morep; + } + ptr += 2; + } + i = max_npvar; + while (nfvar && nfvar-- >= max_npvar) { + ptrhi = ptr; + ptrlo = ptr + 1; + printf(" %6x : 0x%4x 0x%4x ", LADDR_from_68k(ptr), GETWORD(ptrhi), GETWORD(ptrlo)); + if (0xFFFF == GETWORD(ptrhi)) { + printf("[not looked up] "); + print_atomname(get_fvar_name(fx_addr68k, i)); + putchar('\n'); + BT_morep; + } else if ((0xFFFF & GETWORD(ptrlo)) == 1) { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k, i)); + printf(" on stack] "); + print(*( + LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n'); + BT_morep; + } else { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k, i)); + printf(" top value ] "); + print(*( + LispPTR *)(Addr68k_from_LADDR(((int)(0xFFF & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n'); + BT_morep; + } + ptr += 2; + i++; + } + if (fx_addr68k->alink == 11) /* for contextsw */ + next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock + STK_OFFSET)); + + else + next68k = CurrentStackPTR; + while (ptr < next68k) { + ptrhi = ptr; + ptrlo = ptr + 1; + printf(" %6x : 0x%4x 0x%4x ", LADDR_from_68k(ptr), GETWORD(ptrhi), GETWORD(ptrlo)); + print(*(LispPTR *)ptr); + ptr += 2; + putchar('\n'); + BT_morep; + } + printf("this frame is last !!\n"); + BT_morep; + return (-1); + } + + next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock + STK_OFFSET)); + ptr = (DLword *)(fx_addr68k + 1); + + i = 0; + while (npvar-- > 0) { + ptrhi = ptr; + ptrlo = ptr + 1; + printf(" %6x : 0x%4x 0x%4x ", LADDR_from_68k(ptr), GETWORD(ptrhi), GETWORD(ptrlo)); + if ((pvarindex = get_pvar_name(fx_addr68k, i++)) == LOCAL_PVAR) + printf("*local* [pvar%d] ", (i - 1)); + else + print_atomname(pvarindex); + if (GETWORD(ptr) == 0xFFFF) { + printf(" [variable not bound]\n"); + BT_morep; + } else { + printf(" "); + print(*(LispPTR *)ptr); + putchar('\n'); + BT_morep; + } + ptr += 2; + } + i = max_npvar; + + while (nfvar && nfvar-- >= max_npvar) { + ptrhi = ptr; + ptrlo = ptr + 1; + printf(" %6x : 0x%4x 0x%4x ", LADDR_from_68k(ptr), GETWORD(ptrhi), GETWORD(ptrlo)); + if (0xFFFF == GETWORD(ptrhi)) { + printf("[not looked up] "); + print_atomname(get_fvar_name(fx_addr68k, i)); + putchar('\n'); + BT_morep; + } else if ((0xFFFF & GETWORD(ptrlo)) == 1) { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k, i)); + printf(" on stack] "); + print( + *(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n'); + BT_morep; + } else { + printf("[fvar "); + print_atomname(get_fvar_name(fx_addr68k, i)); + printf(" top value ] "); + print( + *(LispPTR *)(Addr68k_from_LADDR(((int)(0x0F & GETWORD(ptrlo)) << 16) | GETWORD(ptrhi)))); + putchar('\n'); + BT_morep; + } + ptr += 2; + i++; + } + + while (next68k > ptr) { + printf(" %6x : 0x%4x 0x%4x ", LADDR_from_68k(ptr), GETWORD(ptr++), GETWORD(ptr++)); + putchar('\n'); + BT_morep; + } + return (0); +} /************************************************************************/ /* */ @@ -596,90 +575,80 @@ int sf(struct frameex1 *fx_addr68k) /* */ /************************************************************************/ -void bt1(FX *startFX) -{ - FX *fx ; - struct fnhead *fnobj; - FX *get_nextFX(FX *fx); - int fnum=0; - BT_lines=0; - fx = startFX ; - URaid_FXarray[fnum]=fx; - printf("%3d : ",fnum++); +void bt1(FX *startFX) { + FX *fx; + struct fnhead *fnobj; + FX *get_nextFX(FX * fx); + int fnum = 0; + BT_lines = 0; + fx = startFX; + URaid_FXarray[fnum] = fx; + printf("%3d : ", fnum++); +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR(fx->fnheader); +#else + fnobj = (struct fnhead *)Addr68k_from_LADDR(((int)fx->hi2fnheader << 16) | fx->lofnheader); +#endif /* BIGVM */ + printf(" 0x%x : ", LADDR_from_68k(fx)); + print(fnobj->framename); + putchar('\n'); + BT_morep; + while ((fnobj->framename != ATOM_T) && (fx->alink != 11)) { + if (fnum > URMAXFXNUM - 1) { + /* Internal buf overflow,more than 100 stacks */ + printf("***There are more than 100 stack frames.\n"); + printf( + "If you want to continue, Uraid will smash its internal table for FX pointer. Do you " + "accept?(Y or N)\n"); + { + int c; + c = getchar(); + fflush(stdin); + if ((c == 'Y') || (c == 'y')) { + fnum = 0; + memset(URaid_FXarray, 0, URMAXFXNUM * 4); + } else + goto bt1_exit; + } + } + + fx = get_nextFX(fx); #ifdef BIGVM fnobj = (struct fnhead *)Addr68k_from_LADDR(fx->fnheader); #else - fnobj = (struct fnhead *)Addr68k_from_LADDR( - ((int)fx->hi2fnheader << 16) | fx->lofnheader); + fnobj = (struct fnhead *)Addr68k_from_LADDR(((int)fx->hi2fnheader << 16) | fx->lofnheader); #endif /* BIGVM */ - printf(" 0x%x : " , LADDR_from_68k(fx)); + URaid_FXarray[fnum] = fx; + printf("%3d : ", fnum++); + printf(" 0x%x : ", LADDR_from_68k(fx)); print(fnobj->framename); - putchar('\n');BT_morep; - while((fnobj->framename != ATOM_T) && (fx->alink != 11)) - { - if(fnum >URMAXFXNUM-1) - { - /* Internal buf overflow,more than 100 stacks */ - printf("***There are more than 100 stack frames.\n"); - printf("If you want to continue, Uraid will smash its internal table for FX pointer. Do you accept?(Y or N)\n"); - { - int c; - c= getchar();fflush(stdin); - if((c=='Y')||(c=='y')) - { - fnum=0; - memset(URaid_FXarray, 0, URMAXFXNUM *4); - } - else goto bt1_exit; - - } - } - - fx= get_nextFX(fx); -#ifdef BIGVM - fnobj = (struct fnhead *)Addr68k_from_LADDR(fx->fnheader); -#else - fnobj = (struct fnhead *)Addr68k_from_LADDR( - ((int)fx->hi2fnheader << 16) | fx->lofnheader); -#endif /* BIGVM */ - URaid_FXarray[fnum]=fx; - printf("%3d : ",fnum++); - printf(" 0x%x : " , LADDR_from_68k(fx)); - print(fnobj->framename); - putchar('\n');BT_morep; - } - if (fnobj->framename != ATOM_T) - { - printf(">>root frame for contextsw<<\n"); - putchar('\n');BT_morep; - } - -bt1_exit: URaid_ArrMAXIndex=fnum-1; - URaid_currentFX=0; - }/* end bt */ - -void bt(void) -{ - bt1(CURRENTFX); + putchar('\n'); + BT_morep; + } + if (fnobj->framename != ATOM_T) { + printf(">>root frame for contextsw<<\n"); + putchar('\n'); + BT_morep; } +bt1_exit: + URaid_ArrMAXIndex = fnum - 1; + URaid_currentFX = 0; +} /* end bt */ - - +void bt(void) { bt1(CURRENTFX); } /***************************************************************/ /* - Func Name : btvv + Func Name : btvv - Desc : dumps the all stack frame name. + Desc : dumps the all stack frame name. - Changed 4 Sep 1987 NMitani + Changed 4 Sep 1987 NMitani */ /***************************************************************/ - - /************************************************************************/ /* */ /* b t v v */ @@ -691,34 +660,27 @@ void bt(void) /* */ /************************************************************************/ -void btvv(void) -{ - struct frameex1 *fx_addr68k; - LispPTR atomindex ; - FX *get_nextFX(FX *fx); +void btvv(void) { + struct frameex1 *fx_addr68k; + LispPTR atomindex; + FX *get_nextFX(FX * fx); - fx_addr68k = CURRENTFX ; + fx_addr68k = CURRENTFX; - atomindex = get_framename(fx_addr68k); + atomindex = get_framename(fx_addr68k); - while((atomindex != ATOM_T) && (fx_addr68k->alink != 11)) - { - sf(fx_addr68k); - fx_addr68k= get_nextFX(fx_addr68k); - atomindex = get_framename(fx_addr68k); + while ((atomindex != ATOM_T) && (fx_addr68k->alink != 11)) { + sf(fx_addr68k); + fx_addr68k = get_nextFX(fx_addr68k); + atomindex = get_framename(fx_addr68k); + } - } - - sf(fx_addr68k); - - printf("\n BTV! end ********\n"); + sf(fx_addr68k); + printf("\n BTV! end ********\n"); } /*end btvv*/ - - - /************************************************************************/ /* */ /* s f f */ @@ -730,12 +692,9 @@ void btvv(void) /* NMitani */ /************************************************************************/ -void sff(LispPTR laddr) -{ - sf((FX *)Addr68k_from_LADDR(laddr)); - } +void sff(LispPTR laddr) { sf((FX *)Addr68k_from_LADDR(laddr)); } -#ifdef BIGATOMS +#ifdef BIGATOMS /*****************************************************************/ /* Nametable debugging aid */ /* */ @@ -749,85 +708,77 @@ void nt1(LispPTR *start, int size, char *str); void ntheader(struct fnhead *fnobj); - void nt(LispPTR index) - /* atom index */ - { - struct fnhead *fnobj; - DefCell *defcell68k; - LispPTR cell; - DLbyte *scratch; - int i; - LispPTR *localnt1; - int localntsize; - DLword fnobj_lisp; - - defcell68k = (DefCell *)GetDEFCELL68k(index); - fnobj = (struct fnhead *)Addr68k_from_LADDR(defcell68k->defpointer); - - /* check if it's the same index ??*/ - if (index != (fnobj->framename)) - { - printf("DEFCELL says it is "); - print_atomname(index); - printf("\n But Func OBJ says "); - print_atomname(fnobj->framename); - putchar('\n'); - return; - } - - printf("***DUMP Func Header << "); - printf("start at 0x%x lisp address(0x%x 68k)\n", - LADDR_from_68k(fnobj),fnobj); - print(index); - putchar('\n'); - - ntheader(fnobj); -} - -void ntheader(struct fnhead *fnobj) +void nt(LispPTR index) +/* atom index */ { - LispPTR *localnt1; - int localntsize; - LispPTR *fnobj_lisp; + struct fnhead *fnobj; + DefCell *defcell68k; + LispPTR cell; + DLbyte *scratch; + int i; + LispPTR *localnt1; + int localntsize; + DLword fnobj_lisp; - fnobj_lisp = (LispPTR *)LADDR_from_68k((DLword *)fnobj); - printf("0x%06x: 0x%08x stkmin\n",fnobj_lisp,fnobj->stkmin); - printf("0x%06x: 0x%08x na\n",fnobj_lisp+1, fnobj->na); - printf("0x%06x: 0x%08x pv\n",fnobj_lisp+2, fnobj->pv); - printf("0x%06x: 0x%08x startpc\n",fnobj_lisp+3,fnobj->startpc); - printf("0x%06x: 0x%08x argtype\n",fnobj_lisp+4,fnobj->argtype); - printf("0x%06x: 0x%08x framename ",fnobj_lisp+5,fnobj->framename); - print(fnobj->framename); + defcell68k = (DefCell *)GetDEFCELL68k(index); + fnobj = (struct fnhead *)Addr68k_from_LADDR(defcell68k->defpointer); + + /* check if it's the same index ??*/ + if (index != (fnobj->framename)) { + printf("DEFCELL says it is "); + print_atomname(index); + printf("\n But Func OBJ says "); + print_atomname(fnobj->framename); putchar('\n'); - printf("0x%06x: 0x%08x ntsize\n",fnobj_lisp+6,fnobj->ntsize); - printf("0x%06x: 0x%08x nlocals",fnobj_lisp+7,fnobj->nlocals); - printf(" 0x%08x fvaroffset\n",fnobj->fvaroffset); - - nt1((LispPTR *)((DLword *)fnobj + FNOVERHEADWORDS), fnobj->ntsize, "Name Table" ); - localnt1= (LispPTR *)((DLword *)fnobj + FNOVERHEADWORDS + (fnobj->ntsize ? (2 * fnobj->ntsize) : 4)); - localntsize = ((DLword *)fnobj + (fnobj->startpc >> 1) - (DLword *)localnt1) >> 1; - nt1(localnt1,localntsize,"Local args"); - + return; } -void nts(struct frameex1 *fxp) -{ + printf("***DUMP Func Header << "); + printf("start at 0x%x lisp address(0x%x 68k)\n", LADDR_from_68k(fnobj), fnobj); + print(index); + putchar('\n'); + + ntheader(fnobj); +} + +void ntheader(struct fnhead *fnobj) { + LispPTR *localnt1; + int localntsize; + LispPTR *fnobj_lisp; + + fnobj_lisp = (LispPTR *)LADDR_from_68k((DLword *)fnobj); + printf("0x%06x: 0x%08x stkmin\n", fnobj_lisp, fnobj->stkmin); + printf("0x%06x: 0x%08x na\n", fnobj_lisp + 1, fnobj->na); + printf("0x%06x: 0x%08x pv\n", fnobj_lisp + 2, fnobj->pv); + printf("0x%06x: 0x%08x startpc\n", fnobj_lisp + 3, fnobj->startpc); + printf("0x%06x: 0x%08x argtype\n", fnobj_lisp + 4, fnobj->argtype); + printf("0x%06x: 0x%08x framename ", fnobj_lisp + 5, fnobj->framename); + print(fnobj->framename); + putchar('\n'); + printf("0x%06x: 0x%08x ntsize\n", fnobj_lisp + 6, fnobj->ntsize); + printf("0x%06x: 0x%08x nlocals", fnobj_lisp + 7, fnobj->nlocals); + printf(" 0x%08x fvaroffset\n", fnobj->fvaroffset); + + nt1((LispPTR *)((DLword *)fnobj + FNOVERHEADWORDS), fnobj->ntsize, "Name Table"); + localnt1 = + (LispPTR *)((DLword *)fnobj + FNOVERHEADWORDS + (fnobj->ntsize ? (2 * fnobj->ntsize) : 4)); + localntsize = ((DLword *)fnobj + (fnobj->startpc >> 1) - (DLword *)localnt1) >> 1; + nt1(localnt1, localntsize, "Local args"); +} + +void nts(struct frameex1 *fxp) { struct fnhead *nt; #ifdef BIGVM - if(fxp->validnametable) - nt = (struct fnhead *) (Addr68k_from_LADDR(fxp->nametable )); + if (fxp->validnametable) + nt = (struct fnhead *)(Addr68k_from_LADDR(fxp->nametable)); else - nt = (struct fnhead *) (Addr68k_from_LADDR(fxp->fnheader )); + nt = (struct fnhead *)(Addr68k_from_LADDR(fxp->fnheader)); #else - if(fxp->validnametable) - nt = (struct fnhead *) - (Addr68k_from_LADDR(((fxp->hi2nametable)<<16 | - fxp->lonametable ))); + if (fxp->validnametable) + nt = (struct fnhead *)(Addr68k_from_LADDR(((fxp->hi2nametable) << 16 | fxp->lonametable))); else - nt = (struct fnhead *) - (Addr68k_from_LADDR(((fxp->hi2fnheader)<<16 | - fxp->lofnheader ))); + nt = (struct fnhead *)(Addr68k_from_LADDR(((fxp->hi2fnheader) << 16 | fxp->lofnheader))); #endif /* BIGVM */ ntheader(nt); } @@ -838,30 +789,27 @@ void nts(struct frameex1 *fxp) #define VAROFFSET(X) (X & 0xFFFFFFF) -void nt1(LispPTR *start, int size, char *str) -{ +void nt1(LispPTR *start, int size, char *str) { LispPTR *endp, *entry2p; printf("\n---- %s ----\n", str); size = size >> 1; /* originally size is # of word. now size is # of int */ endp = start + size; - while( start < endp ){ - entry2p = start+size; - printf("0x%06x: 0x%08x", - LADDR_from_68k((DLword *)start), *start); - printf(" 0x%06x: 0x%08x", - LADDR_from_68k((DLword *)entry2p), *entry2p); - if(*start != 0){ - if((*entry2p >> 30)== VARTYPE_FVAR) + while (start < endp) { + entry2p = start + size; + printf("0x%06x: 0x%08x", LADDR_from_68k((DLword *)start), *start); + printf(" 0x%06x: 0x%08x", LADDR_from_68k((DLword *)entry2p), *entry2p); + if (*start != 0) { + if ((*entry2p >> 30) == VARTYPE_FVAR) printf(" FVAR"); - else if((*entry2p >> 30)== VARTYPE_PVAR) + else if ((*entry2p >> 30) == VARTYPE_PVAR) printf(" PVAR"); - else if((*entry2p >> 30)== VARTYPE_IVAR) + else if ((*entry2p >> 30) == VARTYPE_IVAR) printf(" IVAR"); else printf(" ????"); - printf("%2d ", VAROFFSET(*entry2p)); - print_atomname(*start); + printf("%2d ", VAROFFSET(*entry2p)); + print_atomname(*start); } putchar('\n'); start++; diff --git a/src/dir.c b/src/dir.c old mode 100755 new mode 100644 index 7171df3..17c18d1 --- a/src/dir.c +++ b/src/dir.c @@ -1,8 +1,6 @@ /* $Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -15,25 +13,23 @@ static char *id = "$Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ Copyright /* */ /************************************************************************/ - #include "version.h" - -#include +#include #include #ifndef DOS -#include +#include #ifndef OS5 #ifndef FREEBSD -#include +#include #endif /* FREEBSD */ #endif /* OS5 */ -#include -#include -#include +#include +#include +#include #ifndef SYSVONLY -#include +#include /* #else */ /* #include */ #endif /* SYSVONLY */ @@ -47,14 +43,14 @@ static char *id = "$Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ Copyright #endif #ifdef RISCOS -#include +#include #define direct dirent #endif /* RISCOS */ #ifdef ISC -#include -#include -#include +#include +#include +#include #define direct dirent #endif /* ISC */ @@ -72,7 +68,6 @@ static char *id = "$Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ Copyright #define alarm(x) 1 #endif /* DOS */ - #ifdef SYSVONLY #include #endif /* SYSVONLY */ @@ -82,29 +77,28 @@ static char *id = "$Id: dir.c,v 1.4 2001/12/26 22:17:01 sybalsky Exp $ Copyright #define direct dirent #endif +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "lspglob.h" +#include "timeout.h" +#include "locfile.h" -#include -#include -#include "lispemul.h" -#include "lispmap.h" -#include "adr68k.h" -#include "lsptypes.h" -#include "arith.h" -#include "lspglob.h" -#include "timeout.h" -#include "locfile.h" +extern int *Lisp_errno; +extern int Dummy_errno; -extern int* Lisp_errno; -extern int Dummy_errno; - -#define DIRCHAR '>' +#define DIRCHAR '>' /************************************************************************ - SUBROUTINES - For pattern matching check + SUBROUTINES + For pattern matching check ************************************************************************/ -/* +/* * Name: SetupMatch * * Argument: char *tname Target name including name ,extension and version. @@ -126,65 +120,62 @@ extern int Dummy_errno; * routine. */ -#define SetupMatch(tname, pname, text, pext, tver) { \ - register char *pp; \ - \ - separate_version(tname, tver, 0); \ - \ - if ((pp = (char *)rindex(tname, '.')) == NULL) { \ - *text = '\0'; \ - } else { \ - *pp = '\0'; \ - strcpy(text, pp + 1); \ - } \ - \ - if ((pp = (char *)rindex(pname, '.')) == NULL) { \ - *pext = '\0'; \ - } else { \ - *pp = '\0'; \ - strcpy(pext, pp + 1); \ - } \ +#define SetupMatch(tname, pname, text, pext, tver) \ + { \ + register char *pp; \ + \ + separate_version(tname, tver, 0); \ + \ + if ((pp = (char *)rindex(tname, '.')) == NULL) { \ + *text = '\0'; \ + } else { \ + *pp = '\0'; \ + strcpy(text, pp + 1); \ + } \ + \ + if ((pp = (char *)rindex(pname, '.')) == NULL) { \ + *pext = '\0'; \ + } else { \ + *pp = '\0'; \ + strcpy(pext, pp + 1); \ + } \ } -#define MatchP(target, name, ver, matchtag, unmatchtag) { \ - \ - char tname[MAXNAMLEN], text[MAXNAMLEN], tver[VERSIONLEN]; \ - char pname[MAXNAMLEN], pext[MAXNAMLEN]; \ - \ - strcpy(tname, target); \ - DOWNCASE(tname); \ - strcpy(pname, name); \ - DOWNCASE(pname); \ - \ - SetupMatch(tname, pname, text, pext, tver); \ - \ - if (match_pattern(tname, pname) && \ - match_pattern(text, pext) && \ - match_pattern(tver, ver)) \ - goto matchtag; \ - else \ - goto unmatchtag; \ -} +#define MatchP(target, name, ver, matchtag, unmatchtag) \ + { \ + char tname[MAXNAMLEN], text[MAXNAMLEN], tver[VERSIONLEN]; \ + char pname[MAXNAMLEN], pext[MAXNAMLEN]; \ + \ + strcpy(tname, target); \ + DOWNCASE(tname); \ + strcpy(pname, name); \ + DOWNCASE(pname); \ + \ + SetupMatch(tname, pname, text, pext, tver); \ + \ + if (match_pattern(tname, pname) && match_pattern(text, pext) && match_pattern(tver, ver)) \ + goto matchtag; \ + else \ + goto unmatchtag; \ + } -#define MatchP_Case(target, name, ver, matchtag, unmatchtag) { \ - \ - char tname[MAXNAMLEN], text[MAXNAMLEN], tver[VERSIONLEN]; \ - char pname[MAXNAMLEN], pext[MAXNAMLEN]; \ - \ - strcpy(tname, target); \ - strcpy(pname, name); \ - \ - SetupMatch(tname, pname, text, pext, tver); \ - \ - if (match_pattern(tname, pname) && \ - match_pattern(text, pext) && \ - match_pattern(tver, ver)) \ - goto matchtag; \ - else \ - goto unmatchtag; \ -} +#define MatchP_Case(target, name, ver, matchtag, unmatchtag) \ + { \ + char tname[MAXNAMLEN], text[MAXNAMLEN], tver[VERSIONLEN]; \ + char pname[MAXNAMLEN], pext[MAXNAMLEN]; \ + \ + strcpy(tname, target); \ + strcpy(pname, name); \ + \ + SetupMatch(tname, pname, text, pext, tver); \ + \ + if (match_pattern(tname, pname) && match_pattern(text, pext) && match_pattern(tver, ver)) \ + goto matchtag; \ + else \ + goto unmatchtag; \ + } -/* +/* * Name: match_pattern * * Argument: char *tp String which is matched against pattern. @@ -200,85 +191,80 @@ extern int Dummy_errno; * number of characters. */ -int match_pattern(tp, pp) - register char *tp; - register char *pp; +int match_pattern(tp, pp) register char *tp; +register char *pp; { - register char *tsp, *psp; - register int inastr; - + register char *tsp, *psp; + register int inastr; + #ifdef DOS - /* % is not allowed in DOS names for Medley. */ - if (strchr(tp, '%')) return 0; + /* % is not allowed in DOS names for Medley. */ + if (strchr(tp, '%')) return 0; #endif /* DOS */ - for (tsp = tp, psp = pp, inastr = 0;;tp++, pp++) { - switch (*pp) { + for (tsp = tp, psp = pp, inastr = 0;; tp++, pp++) { + switch (*pp) { + case '\0': return ((*tp == '\0') ? 1 : 0); - case '\0': - return ((*tp == '\0') ? 1 : 0); + case '*': + while (*pp == '*') pp++; /* Skip successive '*'s. */ + if (*pp == '\0') return (1); - case '*': - while (*pp == '*') pp++; /* Skip successive '*'s. */ - if (*pp == '\0') return(1); + psp = pp; + while (*tp != *pp && *tp != '\0') tp++; - psp = pp; - while (*tp != *pp && *tp != '\0') tp++; + if (*tp == '\0') return (0); - if (*tp == '\0') return(0); + tsp = tp; + inastr = 1; - tsp = tp; - inastr = 1; + continue; - continue; + default: + if (*tp == *pp) continue; - default: - if (*tp == *pp) continue; - - if (inastr) { - /* - * Try to find a character which match to - * a character psp points from a charcter - * next to tsp. If found retry from there. - */ - for (tp = tsp + 1; - *tp != '\0' && *tp != *psp; - tp++) {} - if (*tp == '\0') return(0); - pp = psp; - tsp = tp; - continue; - } else { - return(0); - } - } - } + if (inastr) { + /* + * Try to find a character which match to + * a character psp points from a charcter + * next to tsp. If found retry from there. + */ + for (tp = tsp + 1; *tp != '\0' && *tp != *psp; tp++) {} + if (*tp == '\0') return (0); + pp = psp; + tsp = tp; + continue; + } else { + return (0); + } + } + } } - - #ifdef DOS -int make_old_version(old, file) - char *old, *file; - { - int len = (int)strlen(file)-1; - if(file[len] == DIRCHAR) return 0; - /* look up old versions of files for version # 0's */ - strcpy(old, file); +int make_old_version(old, file) char *old, *file; +{ + int len = (int)strlen(file) - 1; + if (file[len] == DIRCHAR) return 0; + /* look up old versions of files for version # 0's */ + strcpy(old, file); - if (old[len] == '.') strcat(old, "%"); - else if ( (len > 0) && old[len-1] == '.') strcat(old, "%"); - else if ( (len > 1) && old[len-2] == '.') strcat(old, "%"); - else if ( (len > 2) && old[len-3] == '.') old[len] = '%'; - else strcat(old, ".%"); - return 1; - } + if (old[len] == '.') + strcat(old, "%"); + else if ((len > 0) && old[len - 1] == '.') + strcat(old, "%"); + else if ((len > 1) && old[len - 2] == '.') + strcat(old, "%"); + else if ((len > 2) && old[len - 3] == '.') + old[len] = '%'; + else + strcat(old, ".%"); + return 1; +} #endif /* DOS */ - - /************************************************************************/ /******** E N D O F P A T T E R N - M A T C H I N G C O D E *******/ /************************************************************************/ @@ -309,95 +295,95 @@ int make_old_version(old, file) */ typedef struct fprop { - unsigned length; /* Byte length of this file. */ - unsigned wdate; /* Written (Creation) date in Lisp sense. */ - unsigned rdate; /* Read date in Lisp sense. */ - unsigned protect; /* Protect mode of this file. */ - char author[256]; /* Author in Lisp sense. */ - u_short au_len; /* Byte length of author. */ - unsigned long nil; /* padding to 8-byte multiple */ + unsigned length; /* Byte length of this file. */ + unsigned wdate; /* Written (Creation) date in Lisp sense. */ + unsigned rdate; /* Read date in Lisp sense. */ + unsigned protect; /* Protect mode of this file. */ + char author[256]; /* Author in Lisp sense. */ + u_short au_len; /* Byte length of author. */ + unsigned long nil; /* padding to 8-byte multiple */ } FPROP; - /* This structure has a pointer at each end to force alignment to - be correct when a pointer is 8 bytes long. */ +/* This structure has a pointer at each end to force alignment to + be correct when a pointer is 8 bytes long. */ typedef struct finfo { - FPROP *prop; /* File properties Lisp needs. */ - char lname[MAXNAMLEN]; /* Name in Lisp Format. */ - u_short lname_len; /* Byte length of lname. */ - char no_ver_name[MAXNAMLEN]; - /* - * Name in UNIX Format. Does not - * include Version field. - * All lower case. - */ - ino_t ino; /* I-node number of this file. */ - unsigned version; /* Version in Lisp sense. */ - u_short dirp; /* If 1, this file is a directory. */ - struct finfo *next; /* - * Link to a next entry. Last entry is - * indicated by NULL pointer. - */ + FPROP *prop; /* File properties Lisp needs. */ + char lname[MAXNAMLEN]; /* Name in Lisp Format. */ + u_short lname_len; /* Byte length of lname. */ + char no_ver_name[MAXNAMLEN]; + /* + * Name in UNIX Format. Does not + * include Version field. + * All lower case. + */ + ino_t ino; /* I-node number of this file. */ + unsigned version; /* Version in Lisp sense. */ + u_short dirp; /* If 1, this file is a directory. */ + struct finfo *next; /* + * Link to a next entry. Last entry is + * indicated by NULL pointer. + */ } FINFO; typedef struct dfinfo { - FINFO *head; /* Head of the linked FINFO structures. */ - FINFO *next; /* FINFO structure generated next time. */ + FINFO *head; /* Head of the linked FINFO structures. */ + FINFO *next; /* FINFO structure generated next time. */ } DFINFO; -FINFO *FreeFinfoList; -#define INITFINFONUM 1024 +FINFO *FreeFinfoList; +#define INITFINFONUM 1024 -DFINFO *FinfoArray; -#define INITFINFOARRAY 32 +DFINFO *FinfoArray; +#define INITFINFOARRAY 32 -unsigned MAXFINFO; +unsigned MAXFINFO; -#define FINFOARRAYRSIZE 16 +#define FINFOARRAYRSIZE 16 -#define AllocFinfo(fp) { \ - if (FreeFinfoList != (FINFO *)NULL) { \ - fp = FreeFinfoList; \ - FreeFinfoList = fp->next; \ - } else if ((fp = (FINFO *)calloc(1, sizeof(FINFO))) == NULL) { \ - fp = (FINFO *)NULL; \ - } else if ((fp->prop = (FPROP *)calloc(1, sizeof(FPROP))) == NULL) { \ - free(fp); \ - fp = (FINFO *)NULL; \ - } \ -} +#define AllocFinfo(fp) \ + { \ + if (FreeFinfoList != (FINFO *)NULL) { \ + fp = FreeFinfoList; \ + FreeFinfoList = fp->next; \ + } else if ((fp = (FINFO *)calloc(1, sizeof(FINFO))) == NULL) { \ + fp = (FINFO *)NULL; \ + } else if ((fp->prop = (FPROP *)calloc(1, sizeof(FPROP))) == NULL) { \ + free(fp); \ + fp = (FINFO *)NULL; \ + } \ + } -#define FreeFinfo(fp) { \ - register FINFO *lastp; \ - for (lastp = fp; lastp->next != (FINFO *)NULL; lastp = lastp->next) {} \ - lastp->next = FreeFinfoList; \ - FreeFinfoList = fp; \ -} +#define FreeFinfo(fp) \ + { \ + register FINFO *lastp; \ + for (lastp = fp; lastp->next != (FINFO *)NULL; lastp = lastp->next) {} \ + lastp->next = FreeFinfoList; \ + FreeFinfoList = fp; \ + } /* * For debug aid. */ #ifdef FSDEBUG -void print_finfo(fp) - FINFO *fp; +void print_finfo(fp) FINFO *fp; { - FINFO *sp; - sp = fp; + FINFO *sp; + sp = fp; - if (fp != (FINFO *)NULL) { - do { - printf("%s -> ", fp->lname); - printf("%d\n", fp->version); - fp = fp->next; - } while (fp != (FINFO *)NULL && fp != sp); + if (fp != (FINFO *)NULL) { + do { + printf("%s -> ", fp->lname); + printf("%d\n", fp->version); + fp = fp->next; + } while (fp != (FINFO *)NULL && fp != sp); - if (fp = sp) printf("Circular detected!\n"); - } + if (fp = sp) printf("Circular detected!\n"); + } } #endif /* FSDEBUG */ - -/* +/* * Name: init_finfo * * Argument: None. @@ -414,36 +400,33 @@ void print_finfo(fp) * This routine is invoked at very first stage of emulator start up. */ -int init_finfo() -{ - register FINFO *cp; - register int n; +int init_finfo() { + register FINFO *cp; + register int n; - if ((FreeFinfoList = - (FINFO *)calloc(sizeof(FINFO) + sizeof(FPROP), INITFINFONUM)) - == (FINFO *)NULL) { - *Lisp_errno = errno; - return(0); - } - for (cp = FreeFinfoList, n = INITFINFONUM; n > 1; n--) { - cp->prop = (FPROP *)(cp + 1); - cp->next = (FINFO *)((char *)cp + sizeof(FINFO) + sizeof(FPROP)); - cp = cp->next; - } - cp->prop = (FPROP *)(cp + 1); - cp->next = (FINFO *)NULL; + if ((FreeFinfoList = (FINFO *)calloc(sizeof(FINFO) + sizeof(FPROP), INITFINFONUM)) == + (FINFO *)NULL) { + *Lisp_errno = errno; + return (0); + } + for (cp = FreeFinfoList, n = INITFINFONUM; n > 1; n--) { + cp->prop = (FPROP *)(cp + 1); + cp->next = (FINFO *)((char *)cp + sizeof(FINFO) + sizeof(FPROP)); + cp = cp->next; + } + cp->prop = (FPROP *)(cp + 1); + cp->next = (FINFO *)NULL; - if ((FinfoArray = (DFINFO *)calloc(sizeof(DFINFO), INITFINFOARRAY)) - == (DFINFO *)NULL) { - *Lisp_errno = errno; - return(0); - } - MAXFINFO = INITFINFOARRAY; + if ((FinfoArray = (DFINFO *)calloc(sizeof(DFINFO), INITFINFOARRAY)) == (DFINFO *)NULL) { + *Lisp_errno = errno; + return (0); + } + MAXFINFO = INITFINFOARRAY; - return(1); + return (1); } -/* +/* * Name: get_finfo_id * * Argument: None. @@ -465,30 +448,28 @@ int init_finfo() * FINFOARRAYRSIZE. */ -int get_finfo_id() -{ - register int i; - DFINFO *dfap; +int get_finfo_id() { + register int i; + DFINFO *dfap; - for (i = 0; i < MAXFINFO; i++) if (FinfoArray[i].head == (FINFO *)0) - return (i); + for (i = 0; i < MAXFINFO; i++) + if (FinfoArray[i].head == (FINFO *)0) return (i); - if ((dfap = (DFINFO *)calloc(sizeof(DFINFO), MAXFINFO + FINFOARRAYRSIZE)) - == (DFINFO *)NULL) { - *Lisp_errno = errno; - return(-1); - } - for (i = 0; i < MAXFINFO; i++) { - dfap[i].head = FinfoArray[i].head; - dfap[i].next = FinfoArray[i].next; - } - free(FinfoArray); - MAXFINFO += FINFOARRAYRSIZE; - FinfoArray = dfap; - return(i); + if ((dfap = (DFINFO *)calloc(sizeof(DFINFO), MAXFINFO + FINFOARRAYRSIZE)) == (DFINFO *)NULL) { + *Lisp_errno = errno; + return (-1); + } + for (i = 0; i < MAXFINFO; i++) { + dfap[i].head = FinfoArray[i].head; + dfap[i].next = FinfoArray[i].next; + } + free(FinfoArray); + MAXFINFO += FINFOARRAYRSIZE; + FinfoArray = dfap; + return (i); } -/* +/* * Name: enum_dsk_prop * * Argument: char *dir Absolute path of directory in UNIX format. @@ -508,282 +489,276 @@ int get_finfo_id() * Enumerates files and directories matching to the pattern on the specified * directory. The pattern matching is done in case insensitive manner. * File properties Lisp will need later are also stored in the result linked list - * of FINFO structures. + * of FINFO structures. */ #ifdef DOS -int enum_dsk_prop(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; +int enum_dsk_prop(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval, res, isslash = 0, drive = 0; - struct find_t dirp; - register struct passwd *pwd; - struct stat sbuf; - char namebuf[MAXPATHLEN]; - char fver[VERSIONLEN]; - char old[MAXNAMLEN]; + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval, res, isslash = 0, drive = 0; + struct find_t dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; + char old[MAXNAMLEN]; + /* The null directory has to be special cased */ + /* because adjacent \'s in the pathname don't match anything */ + if (dir[1] == DRIVESEP) drive = dir[0]; + if (strcmp(dir, "\\") == 0) + isslash = 1; + else if (drive && (strcmp(dir + 2, "\\") == 0)) + isslash = 1; - /* The null directory has to be special cased */ - /* because adjacent \'s in the pathname don't match anything */ - if (dir[1] == DRIVESEP) drive = dir[0]; + if (!isslash) + strcpy(namebuf, dir); /* Only add the dir if it's real */ + else if (drive) { + namebuf[0] = drive; + namebuf[1] = DRIVESEP; + namebuf[2] = '\0'; + } else + *namebuf = '\0'; - if (strcmp(dir, "\\")==0) isslash = 1; - else if (drive && (strcmp(dir+2, "\\")==0)) isslash = 1; + strcat(namebuf, DIRSEPSTR); + strcat(namebuf, name); - if (!isslash) strcpy(namebuf, dir); /* Only add the dir if it's real */ - else if (drive) - { - namebuf[0] = drive; - namebuf[1] = DRIVESEP; - namebuf[2] = '\0'; - } - else *namebuf = '\0'; + TIMEOUT(res = _dos_findfirst(namebuf, _A_NORMAL | _A_SUBDIR, &dirp)); + if (res < 0) { + *Lisp_errno = errno; + return (-1); + } - strcat(namebuf,DIRSEPSTR); - strcat(namebuf, name); + for (nextp = prevp = (FINFO *)NULL, n = 0; res == 0; + S_TOUT(res = _dos_findnext(&dirp)), prevp = nextp) { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0) continue; + MatchP(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + if (isslash) { + if (drive) + sprintf(namebuf, "%c:\\%s", drive, dirp.name); + else + sprintf(namebuf, "\\%s", dirp.name); + } else + sprintf(namebuf, "%s\\%s", dir, dirp.name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return (-1); + } - TIMEOUT(res = _dos_findfirst(namebuf, _A_NORMAL|_A_SUBDIR, &dirp)); - if (res < 0) { - *Lisp_errno = errno; - return(-1); - } + strcpy(namebuf, dirp.name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + strcat(namebuf, ".~1~"); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } - for (nextp = prevp = (FINFO *)NULL, n = 0; - res == 0; - S_TOUT(res = _dos_findnext(&dirp)), prevp = nextp) { - if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; - MatchP(dirp.name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - if (isslash) - { - if (drive) sprintf(namebuf,"%c:\\%s", drive, dirp.name); - else sprintf(namebuf, "\\%s", dirp.name); - } - else sprintf(namebuf, "%s\\%s", dir, dirp.name); + strcpy(namebuf, dirp.name); + len = strlen(namebuf); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + nextp->version = 1; + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; + /* TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } */ + n++; + } - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dirp.name); - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - strcat(namebuf,".~1~"); - quote_fname(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } + /***********************/ + /* Now go looking for version-0 entries */ + /***********************/ - strcpy(namebuf, dirp.name); - len = strlen(namebuf); - DOWNCASE(namebuf); - strcpy(nextp->no_ver_name, namebuf); - nextp->version = 1; - nextp->ino = sbuf.st_ino; - nextp->prop->length = (unsigned)sbuf.st_size; - nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); - nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); - nextp->prop->protect = (unsigned)sbuf.st_mode; - /* TIMEOUT(pwd = getpwuid(sbuf.st_uid)); - if (pwd == (struct passwd *)NULL) { - nextp->prop->au_len = 0; - } else { - len = strlen(pwd->pw_name); - strcpy(nextp->prop->author, pwd->pw_name); - *(nextp->prop->author + len) = '\0'; - nextp->prop->au_len = len; - } */ - n++; - } + for (nextp = prevp; nextp; nextp = nextp->next) { + FINFO *newp; + if (!make_old_version(old, nextp->no_ver_name)) continue; - /***********************/ - /* Now go looking for version-0 entries */ - /***********************/ + if (isslash) { + if (drive) + sprintf(namebuf, "%c:\\%s", drive, old); + else + sprintf(namebuf, "\\%s", old); + } else + sprintf(namebuf, "%s\\%s", dir, old); + TIMEOUT(rval = stat(namebuf, &sbuf)); - for (nextp = prevp; nextp; nextp = nextp -> next) - { - FINFO *newp; + if (rval == -1) continue; - if (!make_old_version(old, nextp->no_ver_name)) continue; + AllocFinfo(newp); + newp->next = prevp; + /* All other types than directory. */ + newp->dirp = 0; + sprintf(namebuf, "%s.~00~", nextp->no_ver_name); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(newp->lname, namebuf); + *(newp->lname + len) = '\0'; + newp->lname_len = len; - if (isslash) - { - if (drive) sprintf(namebuf,"%c:\\%s", drive, old); - else sprintf(namebuf, "\\%s", old); - } - else sprintf(namebuf, "%s\\%s", dir, old); - TIMEOUT(rval = stat(namebuf, &sbuf)); - - if (rval == -1 ) continue; - - AllocFinfo(newp); - newp->next = prevp; - /* All other types than directory. */ - newp->dirp = 0; - sprintf(namebuf, "%s.~00~", nextp->no_ver_name); - quote_fname(namebuf); - len = strlen(namebuf); - strcpy(newp->lname, namebuf); - *(newp->lname + len) = '\0'; - newp->lname_len = len; - - strcpy(newp->no_ver_name, old); - newp->version = 0; - newp->ino = sbuf.st_ino; - newp->prop->length = (unsigned)sbuf.st_size; - newp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); - newp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); - newp->prop->protect = (unsigned)sbuf.st_mode; - n++; - prevp = newp; - } - if (n > 0) *finfo_buf = prevp; - return(n); + strcpy(newp->no_ver_name, old); + newp->version = 0; + newp->ino = sbuf.st_ino; + newp->prop->length = (unsigned)sbuf.st_size; + newp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + newp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + newp->prop->protect = (unsigned)sbuf.st_mode; + n++; + prevp = newp; + } + if (n > 0) *finfo_buf = prevp; + return (n); } -#else /* DOS */ -int enum_dsk_prop(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; +#else /* DOS */ +int enum_dsk_prop(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval; - DIR *dirp; - register struct passwd *pwd; - struct stat sbuf; - char namebuf[MAXPATHLEN]; - char fver[VERSIONLEN]; - - errno=0; - TIMEOUT0(dirp = opendir(dir)); - if (dirp == NULL) { - *Lisp_errno = errno; - return(-1); - } + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; - for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; - dp != (struct direct *)NULL || errno == EINTR; - errno=0, S_TOUT(dp = readdir(dirp)), prevp = nextp) - if (dp) - { - if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || - dp->d_ino == 0) continue; - MatchP((char *)dp->d_name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - sprintf(namebuf, "%s/%s", dir, dp->d_name); - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dp->d_name); - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - quote_fname(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } + errno = 0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return (-1); + } - strcpy(namebuf, dp->d_name); - len = strlen(namebuf); - separate_version(namebuf, fver, 1); - DOWNCASE(namebuf); - strcpy(nextp->no_ver_name, namebuf); - if (*fver == '\0') - nextp->version = 0; - else - nextp->version = atoi(fver); - nextp->ino = sbuf.st_ino; - nextp->prop->length = (unsigned)sbuf.st_size; - nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); - nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); - nextp->prop->protect = (unsigned)sbuf.st_mode; - TIMEOUT(pwd = getpwuid(sbuf.st_uid)); - if (pwd == (struct passwd *)NULL) { - nextp->prop->au_len = 0; - } else { - len = strlen(pwd->pw_name); - strcpy(nextp->prop->author, pwd->pw_name); - *(nextp->prop->author + len) = '\0'; - nextp->prop->au_len = len; - } - n++; - } - closedir(dirp); - if (n > 0) *finfo_buf = prevp; - return(n); + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || dp->d_ino == 0) continue; + MatchP((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } + + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + separate_version(namebuf, fver, 1); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + if (*fver == '\0') + nextp->version = 0; + else + nextp->version = atoi(fver); + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return (n); } #endif /* DOS */ -/* +/* * Name: enum_dsk * * Argument: char *dir Absolute path of directory in UNIX format. @@ -803,248 +778,242 @@ int enum_dsk_prop(dir, name, ver, finfo_buf) * Similar to enum_dsk_prop, but file properties are not stored. */ #ifdef DOS -int enum_dsk(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; +int enum_dsk(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval, isslash = 0, drive = 0; - struct find_t dirp; - struct stat sbuf; - char namebuf[MAXPATHLEN]; - char fver[VERSIONLEN]; - char old[MAXPATHLEN]; + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval, isslash = 0, drive = 0; + struct find_t dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; + char old[MAXPATHLEN]; + /* The null directory has to be special cased */ + /* because adjacent \'s in the pathname don't match anything */ + if (dir[1] == DRIVESEP) drive = dir[0]; - /* The null directory has to be special cased */ - /* because adjacent \'s in the pathname don't match anything */ - if (dir[1] == DRIVESEP) drive = dir[0]; + if (strcmp(dir, "\\") == 0) + isslash = 1; + else if (drive && (strcmp(dir + 2, "\\") == 0)) + isslash = 1; - if (strcmp(dir, "\\")==0) isslash = 1; - else if (drive && (strcmp(dir+2, "\\")==0)) isslash = 1; + if (!isslash) + strcpy(namebuf, dir); /* Only add the dir if it's real */ + else if (drive) { + namebuf[0] = drive; + namebuf[1] = DRIVESEP; + namebuf[2] = '\0'; + } else + *namebuf = '\0'; - if (!isslash) strcpy(namebuf, dir); /* Only add the dir if it's real */ - else if (drive) - { - namebuf[0] = drive; - namebuf[1] = DRIVESEP; - namebuf[2] = '\0'; - } - else *namebuf = '\0'; + strcat(namebuf, DIRSEPSTR); + strcat(namebuf, name); - strcat(namebuf,DIRSEPSTR); - strcat(namebuf, name); - - - TIMEOUT(rval = _dos_findfirst(namebuf, _A_NORMAL|_A_SUBDIR, &dirp)); - if (rval != 0) - { - *Lisp_errno = errno; - return(-1); - } - - for (nextp = prevp = (FINFO *)NULL, n = 0; - rval == 0; - S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) - { - if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; - MatchP(dirp.name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - if (isslash) - { - if (drive) sprintf(namebuf,"%c:\\%s", drive, dirp.name); - else sprintf(namebuf, "\\%s", dirp.name); - } - else sprintf(namebuf, "%s\\%s", dir, dirp.name); - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dirp.name); /* moved from below 2/26/93 */ - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - strcat(namebuf,".~1~"); - quote_fname(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } - - strcpy(namebuf, dirp.name); /* to get real versionless name */ - len = strlen(namebuf); - DOWNCASE(namebuf); - strcpy(nextp->no_ver_name, namebuf); - nextp->version = 1; - nextp->ino = sbuf.st_ino; - n++; - } - - /***********************/ - /* Now go looking for version-0 entries */ - /***********************/ - - for (nextp = prevp; nextp; nextp = nextp -> next) - { - FINFO *newp; - - if (!make_old_version(old, nextp->no_ver_name)) continue; - - if (isslash) - { - if (drive) sprintf(namebuf,"%c:\\%s", drive, old); - else sprintf(namebuf, "\\%s", old); - } - else sprintf(namebuf, "%s\\%s", dir, old); - TIMEOUT(rval = stat(namebuf, &sbuf)); - - if (rval == -1 ) continue; - - AllocFinfo(newp); - newp->next = prevp; - /* All other types than directory. */ - newp->dirp = 0; - sprintf(namebuf, "%s.~00~", nextp->no_ver_name); - quote_fname(namebuf); - len = strlen(namebuf); - strcpy(newp->lname, namebuf); - *(newp->lname + len) = '\0'; - newp->lname_len = len; - - strcpy(newp->no_ver_name, old); - newp->version = 0; - newp->ino = sbuf.st_ino; - n++; - prevp = newp; - } - - if (n > 0) *finfo_buf = prevp; - return(n); + TIMEOUT(rval = _dos_findfirst(namebuf, _A_NORMAL | _A_SUBDIR, &dirp)); + if (rval != 0) { + *Lisp_errno = errno; + return (-1); } -#else /* DOS */ + for (nextp = prevp = (FINFO *)NULL, n = 0; rval == 0; + S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0) continue; + MatchP(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + if (isslash) { + if (drive) + sprintf(namebuf, "%c:\\%s", drive, dirp.name); + else + sprintf(namebuf, "\\%s", dirp.name); + } else + sprintf(namebuf, "%s\\%s", dir, dirp.name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return (-1); + } -int enum_dsk(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; + strcpy(namebuf, dirp.name); /* moved from below 2/26/93 */ + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + strcat(namebuf, ".~1~"); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dirp.name); /* to get real versionless name */ + len = strlen(namebuf); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + nextp->version = 1; + nextp->ino = sbuf.st_ino; + n++; + } + + /***********************/ + /* Now go looking for version-0 entries */ + /***********************/ + + for (nextp = prevp; nextp; nextp = nextp->next) { + FINFO *newp; + + if (!make_old_version(old, nextp->no_ver_name)) continue; + + if (isslash) { + if (drive) + sprintf(namebuf, "%c:\\%s", drive, old); + else + sprintf(namebuf, "\\%s", old); + } else + sprintf(namebuf, "%s\\%s", dir, old); + TIMEOUT(rval = stat(namebuf, &sbuf)); + + if (rval == -1) continue; + + AllocFinfo(newp); + newp->next = prevp; + /* All other types than directory. */ + newp->dirp = 0; + sprintf(namebuf, "%s.~00~", nextp->no_ver_name); + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(newp->lname, namebuf); + *(newp->lname + len) = '\0'; + newp->lname_len = len; + + strcpy(newp->no_ver_name, old); + newp->version = 0; + newp->ino = sbuf.st_ino; + n++; + prevp = newp; + } + + if (n > 0) *finfo_buf = prevp; + return (n); +} + +#else /* DOS */ + +int enum_dsk(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval; - DIR *dirp; - struct stat sbuf; - char namebuf[MAXPATHLEN]; - char fver[VERSIONLEN]; + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; + char fver[VERSIONLEN]; - errno=0; - TIMEOUT0(dirp = opendir(dir)); - if (dirp == NULL) { - *Lisp_errno = errno; - return(-1); - } + errno = 0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return (-1); + } - for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; - dp != (struct direct *)NULL || errno == EINTR; - errno=0, S_TOUT(dp = readdir(dirp)), prevp = nextp) - if (dp) - { - if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || - dp->d_ino == 0) continue; - MatchP((char *)dp->d_name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - sprintf(namebuf, "%s/%s", dir, dp->d_name); - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dp->d_name); - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - quote_fname(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || dp->d_ino == 0) continue; + MatchP((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } - strcpy(namebuf, dp->d_name); - len = strlen(namebuf); - separate_version(namebuf, fver, 1); - DOWNCASE(namebuf); - strcpy(nextp->no_ver_name, namebuf); - if (*fver == '\0') - nextp->version = 0; - else - nextp->version = atoi(fver); - nextp->ino = sbuf.st_ino; - n++; - } - closedir(dirp); - if (n > 0) *finfo_buf = prevp; - return(n); + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + separate_version(namebuf, fver, 1); + DOWNCASE(namebuf); + strcpy(nextp->no_ver_name, namebuf); + if (*fver == '\0') + nextp->version = 0; + else + nextp->version = atoi(fver); + nextp->ino = sbuf.st_ino; + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return (n); } #endif /* DOS */ -/* +/* * Name: enum_ufs_prop * * Argument: char *dir Absolute path of directory in UNIX format. @@ -1064,200 +1033,195 @@ int enum_dsk(dir, name, ver, finfo_buf) * Enumerates files and directories matching to the pattern on the specified * directory. The pattern matching is done in case sensitive manner. * File properties Lisp will need later are also stored in the result linked list - * of FINFO structures. + * of FINFO structures. */ #ifdef DOS -int enum_ufs_prop(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; +int enum_ufs_prop(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval; - struct find_t dirp; - register struct passwd *pwd; - struct stat sbuf; - char namebuf[MAXPATHLEN]; - - TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); - if (rval != 0) { - *Lisp_errno = errno; - return(-1); - } + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + struct find_t dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; - for (nextp = prevp = (FINFO *)NULL, n = 0; - rval == 0; - S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) { - if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; - MatchP_Case(dirp.name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - sprintf(namebuf, "%s\\%s", dir, dirp.name); - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dirp.name); - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - quote_fname_ufs(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } + TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); + if (rval != 0) { + *Lisp_errno = errno; + return (-1); + } - strcpy(namebuf, dirp.name); - len = strlen(namebuf); - nextp->ino = sbuf.st_ino; - nextp->prop->length = (unsigned)sbuf.st_size; - nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); - nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); - nextp->prop->protect = (unsigned)sbuf.st_mode; -/* - TIMEOUT(pwd = getpwuid(sbuf.st_uid)); - if (pwd == (struct passwd *)NULL) { - nextp->prop->au_len = 0; - } else { - len = strlen(pwd->pw_name); - strcpy(nextp->prop->author, pwd->pw_name); - *(nextp->prop->author + len) = '\0'; - nextp->prop->au_len = len; - } -*/ - n++; - } - if (n > 0) *finfo_buf = prevp; - return(n); + for (nextp = prevp = (FINFO *)NULL, n = 0; rval == 0; + S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0) continue; + MatchP_Case(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s\\%s", dir, dirp.name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return (-1); + } + + strcpy(namebuf, dirp.name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dirp.name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; + /* + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } + */ + n++; + } + if (n > 0) *finfo_buf = prevp; + return (n); } -#else /* DOS */ -int enum_ufs_prop(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; +#else /* DOS */ +int enum_ufs_prop(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval; - DIR *dirp; - register struct passwd *pwd; - struct stat sbuf; - char namebuf[MAXPATHLEN]; + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + register struct passwd *pwd; + struct stat sbuf; + char namebuf[MAXPATHLEN]; - errno = 0; - TIMEOUT(dirp = opendir(dir)); - if (dirp == NULL) { - *Lisp_errno = errno; - return(-1); - } + errno = 0; + TIMEOUT(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return (-1); + } - for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; - dp != (struct direct *)NULL || errno == EINTR; - errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) - if (dp) - { - if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || - dp->d_ino == 0) continue; - MatchP_Case((char *)dp->d_name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - sprintf(namebuf, "%s/%s", dir, dp->d_name); - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dp->d_name); - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - quote_fname_ufs(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || dp->d_ino == 0) continue; + MatchP_Case((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } - strcpy(namebuf, dp->d_name); - len = strlen(namebuf); - nextp->ino = sbuf.st_ino; - nextp->prop->length = (unsigned)sbuf.st_size; - nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); - nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); - nextp->prop->protect = (unsigned)sbuf.st_mode; -/* - TIMEOUT(pwd = getpwuid(sbuf.st_uid)); - if (pwd == (struct passwd *)NULL) { - nextp->prop->au_len = 0; - } else { - len = strlen(pwd->pw_name); - strcpy(nextp->prop->author, pwd->pw_name); - *(nextp->prop->author + len) = '\0'; - nextp->prop->au_len = len; - } -*/ - n++; - } - closedir(dirp); - if (n > 0) *finfo_buf = prevp; - return(n); + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + nextp->prop->length = (unsigned)sbuf.st_size; + nextp->prop->wdate = (unsigned)ToLispTime(sbuf.st_mtime); + nextp->prop->rdate = (unsigned)ToLispTime(sbuf.st_atime); + nextp->prop->protect = (unsigned)sbuf.st_mode; + /* + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + nextp->prop->au_len = 0; + } else { + len = strlen(pwd->pw_name); + strcpy(nextp->prop->author, pwd->pw_name); + *(nextp->prop->author + len) = '\0'; + nextp->prop->au_len = len; + } + */ + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return (n); } #endif /* DOS */ -/* +/* * Name: enum_ufs * * Argument: char *dir Absolute path of directory in UNIX format. @@ -1277,167 +1241,160 @@ int enum_ufs_prop(dir, name, ver, finfo_buf) * Similar to enum_ufs_prop, but file properties are not stored. */ #ifdef DOS -int enum_ufs(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; +int enum_ufs(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval; - struct find_t dirp; - struct stat sbuf; - char namebuf[MAXPATHLEN]; - - TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); - if (rval != 0) { - *Lisp_errno = errno; - return(-1); - } + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + struct find_t dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; - for (nextp = prevp = (FINFO *)NULL, n = 0; - rval == 0; - S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) { - if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0 ) continue; - MatchP_Case(dirp.name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - sprintf(namebuf, "%s\\%s", dir, dirp.name); - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dirp.name); - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - quote_fname_ufs(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } + TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); + if (rval != 0) { + *Lisp_errno = errno; + return (-1); + } - strcpy(namebuf, dirp.name); - len = strlen(namebuf); - nextp->ino = sbuf.st_ino; - n++; - } - if (n > 0) *finfo_buf = prevp; - return(n); + for (nextp = prevp = (FINFO *)NULL, n = 0; rval == 0; + S_TOUT(rval = _dos_findnext(&dirp)), prevp = nextp) { + if (strcmp(dirp.name, ".") == 0 || strcmp(dirp.name, "..") == 0) continue; + MatchP_Case(dirp.name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s\\%s", dir, dirp.name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + *Lisp_errno = errno; + return (-1); + } + + strcpy(namebuf, dirp.name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dirp.name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + n++; + } + if (n > 0) *finfo_buf = prevp; + return (n); } -#else /* DOS */ -int enum_ufs(dir, name, ver, finfo_buf) - char *dir; - char *name; - char *ver; - FINFO **finfo_buf; +#else /* DOS */ +int enum_ufs(dir, name, ver, finfo_buf) char *dir; +char *name; +char *ver; +FINFO **finfo_buf; { - register struct direct *dp; - register FINFO *prevp; - register FINFO *nextp; - int n, len, rval; - DIR *dirp; - struct stat sbuf; - char namebuf[MAXPATHLEN]; + register struct direct *dp; + register FINFO *prevp; + register FINFO *nextp; + int n, len, rval; + DIR *dirp; + struct stat sbuf; + char namebuf[MAXPATHLEN]; - errno = 0; - TIMEOUT(dirp = opendir(dir)); - if (dirp == NULL) { - *Lisp_errno = errno; - return(-1); - } + errno = 0; + TIMEOUT(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return (-1); + } - for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; - dp != (struct direct *)NULL || errno == EINTR; - errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) - if (dp) - { - if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || - dp->d_ino == 0) continue; - MatchP_Case((char *)dp->d_name, name, ver, match, unmatch); - unmatch: - continue; - match: - AllocFinfo(nextp); - if (nextp == (FINFO *)NULL) { - FreeFinfo(prevp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - nextp->next = prevp; - sprintf(namebuf, "%s/%s", dir, dp->d_name); - TIMEOUT(rval = stat(namebuf, &sbuf)); - if (rval == -1 && errno != ENOENT) { - /* - * ENOENT error might be caused by missing symbolic - * link. We should ignore such error here. - */ - FreeFinfo(nextp); - closedir(dirp); - *Lisp_errno = errno; - return(-1); - } - - strcpy(namebuf, dp->d_name); - if (sbuf.st_mode & S_IFDIR) { - nextp->dirp = 1; - quote_dname(namebuf); - strcpy(nextp->lname, namebuf); - len = strlen(namebuf); - *(nextp->lname + len) = DIRCHAR; - *(nextp->lname + len + 1) = '\0'; - nextp->lname_len = len + 1; - } else { - /* All other types than directory. */ - nextp->dirp = 0; - quote_fname_ufs(namebuf); - len = strlen(namebuf); - strcpy(nextp->lname, namebuf); - *(nextp->lname + len) = '\0'; - nextp->lname_len = len; - } + for (S_TOUT(dp = readdir(dirp)), nextp = prevp = (FINFO *)NULL, n = 0; + dp != (struct direct *)NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp)), prevp = nextp) + if (dp) { + if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0 || dp->d_ino == 0) continue; + MatchP_Case((char *)dp->d_name, name, ver, match, unmatch); + unmatch: + continue; + match: + AllocFinfo(nextp); + if (nextp == (FINFO *)NULL) { + FreeFinfo(prevp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } + nextp->next = prevp; + sprintf(namebuf, "%s/%s", dir, dp->d_name); + TIMEOUT(rval = stat(namebuf, &sbuf)); + if (rval == -1 && errno != ENOENT) { + /* + * ENOENT error might be caused by missing symbolic + * link. We should ignore such error here. + */ + FreeFinfo(nextp); + closedir(dirp); + *Lisp_errno = errno; + return (-1); + } - strcpy(namebuf, dp->d_name); - len = strlen(namebuf); - nextp->ino = sbuf.st_ino; - n++; - } - closedir(dirp); - if (n > 0) *finfo_buf = prevp; - return(n); + strcpy(namebuf, dp->d_name); + if (sbuf.st_mode & S_IFDIR) { + nextp->dirp = 1; + quote_dname(namebuf); + strcpy(nextp->lname, namebuf); + len = strlen(namebuf); + *(nextp->lname + len) = DIRCHAR; + *(nextp->lname + len + 1) = '\0'; + nextp->lname_len = len + 1; + } else { + /* All other types than directory. */ + nextp->dirp = 0; + quote_fname_ufs(namebuf); + len = strlen(namebuf); + strcpy(nextp->lname, namebuf); + *(nextp->lname + len) = '\0'; + nextp->lname_len = len; + } + + strcpy(namebuf, dp->d_name); + len = strlen(namebuf); + nextp->ino = sbuf.st_ino; + n++; + } + closedir(dirp); + if (n > 0) *finfo_buf = prevp; + return (n); } #endif /* DOS*/ - - -/* +/* * Name: trim_finfo * * Argument: FINFO **fp Linked list of the numerated FINFO structures. @@ -1455,121 +1412,121 @@ int enum_ufs(dir, name, ver, finfo_buf) * This routine is only used by DSK codes. */ -int trim_finfo(fp) - FINFO **fp; +int trim_finfo(fp) FINFO **fp; { #ifndef DOS - register FINFO *tp, *sp, *mp, *cp, *pp; - register int num, pnum; - int linkp; - char ver[VERSIONLEN]; + register FINFO *tp, *sp, *mp, *cp, *pp; + register int num, pnum; + int linkp; + char ver[VERSIONLEN]; - sp = mp = cp = *fp; - pp = (FINFO *)NULL; - num = pnum = 0; + sp = mp = cp = *fp; + pp = (FINFO *)NULL; + num = pnum = 0; - do { - if (cp->dirp) { - pp = cp; - sp = cp = cp->next; - pnum++; - num++; - continue; - } + do { + if (cp->dirp) { + pp = cp; + sp = cp = cp->next; + pnum++; + num++; + continue; + } - if (cp->next != (FINFO *)NULL && - strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { - mp = cp = cp->next; - num++; - while (cp->next != (FINFO *)NULL && - strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { - cp = cp->next; - num++; - } - } else { - mp = cp; - } + if (cp->next != (FINFO *)NULL && strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + mp = cp = cp->next; + num++; + while (cp->next != (FINFO *)NULL && strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + cp = cp->next; + num++; + } + } else { + mp = cp; + } - if (sp->version == 0) { - if (cp != sp) { - /* - * Both versionless and versioned files exists. - */ - linkp = 0; - tp = sp; - do { - tp = tp->next; - if (tp->ino == sp->ino) { - linkp = 1; - break; - } - } while (cp != tp); + if (sp->version == 0) { + if (cp != sp) { + /* + * Both versionless and versioned files exists. + */ + linkp = 0; + tp = sp; + do { + tp = tp->next; + if (tp->ino == sp->ino) { + linkp = 1; + break; + } + } while (cp != tp); - if (!linkp) { - /* - * Versionless is not linked to any versioned - * file. - */ - sprintf(ver, ";%d", mp->version + 1); - strcat(sp->lname, ver); - sp->lname_len = strlen(sp->lname); - pnum = ++num; - pp = cp; - sp = cp = cp->next; - } else { - /* - * Versionless is linked to one of versionless - * files. We can remove it. - */ - sp->next = (FINFO *)NULL; - FreeFinfo(sp); - pnum = num; - if (pp != (FINFO *)NULL) - pp->next = mp; - else - *fp = mp; - pp = cp; - sp = cp = cp->next; - } - } else { - /* - * Only versionless file exists. It is regarded as - * version 1. - */ - strcat(cp->lname, ";1"); - cp->lname_len += 2; - pp = cp; - sp = cp = cp->next; - num = ++pnum; - } - } else { - if (cp != sp) { - /* - * All files are versioned. - */ - pnum = ++num; - } else { - /* - * A versioned file only exists. - */ - num = ++pnum; - } - pp = cp; - sp = cp = cp->next; - } - } while (sp != (FINFO *)NULL) ; + if (!linkp) { + /* + * Versionless is not linked to any versioned + * file. + */ + sprintf(ver, ";%d", mp->version + 1); + strcat(sp->lname, ver); + sp->lname_len = strlen(sp->lname); + pnum = ++num; + pp = cp; + sp = cp = cp->next; + } else { + /* + * Versionless is linked to one of versionless + * files. We can remove it. + */ + sp->next = (FINFO *)NULL; + FreeFinfo(sp); + pnum = num; + if (pp != (FINFO *)NULL) + pp->next = mp; + else + *fp = mp; + pp = cp; + sp = cp = cp->next; + } + } else { + /* + * Only versionless file exists. It is regarded as + * version 1. + */ + strcat(cp->lname, ";1"); + cp->lname_len += 2; + pp = cp; + sp = cp = cp->next; + num = ++pnum; + } + } else { + if (cp != sp) { + /* + * All files are versioned. + */ + pnum = ++num; + } else { + /* + * A versioned file only exists. + */ + num = ++pnum; + } + pp = cp; + sp = cp = cp->next; + } + } while (sp != (FINFO *)NULL); -#else /* DOS version */ - int num = 0; - FINFO *tp; - tp = *fp; - while (tp) { num++; tp = tp->next; } +#else /* DOS version */ + int num = 0; + FINFO *tp; + tp = *fp; + while (tp) { + num++; + tp = tp->next; + } #endif /* DOS */ - return(num); + return (num); } -/* +/* * Name: trim_finfo_highest * * Argument: FINFO **fp Linked list of the numerated FINFO structures. @@ -1584,133 +1541,130 @@ int trim_finfo(fp) * of. */ -int trim_finfo_highest(fp, highestp) - FINFO **fp; - int highestp; +int trim_finfo_highest(fp, highestp) FINFO **fp; +int highestp; { - register FINFO *tp, *sp, *mp, *cp, *pp; - register int num, pnum; - int linkp; - char ver[VERSIONLEN]; + register FINFO *tp, *sp, *mp, *cp, *pp; + register int num, pnum; + int linkp; + char ver[VERSIONLEN]; - sp = mp = cp = *fp; - pp = (FINFO *)NULL; - num = pnum = 0; + sp = mp = cp = *fp; + pp = (FINFO *)NULL; + num = pnum = 0; - do { - if (cp->dirp) { - pp = cp; - sp = cp = cp->next; - pnum++; - num++; - continue; - } + do { + if (cp->dirp) { + pp = cp; + sp = cp = cp->next; + pnum++; + num++; + continue; + } - if (cp->next != (FINFO *)NULL && - strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { - mp = cp = cp->next; - num++; - while (cp->next != (FINFO *)NULL && - strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { - cp = cp->next; - num++; - } - } else { - mp = cp; - } + if (cp->next != (FINFO *)NULL && strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + mp = cp = cp->next; + num++; + while (cp->next != (FINFO *)NULL && strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + cp = cp->next; + num++; + } + } else { + mp = cp; + } - if (sp->version == 0) { - if (cp != sp) { - /* - * Both versionless and versioned files exists. - */ - linkp = 0; - tp = sp; - do { - tp = tp->next; - if (tp->ino == sp->ino) { - linkp = 1; - break; - } - } while (cp != tp); + if (sp->version == 0) { + if (cp != sp) { + /* + * Both versionless and versioned files exists. + */ + linkp = 0; + tp = sp; + do { + tp = tp->next; + if (tp->ino == sp->ino) { + linkp = 1; + break; + } + } while (cp != tp); - if (!linkp) { - /* - * Versionless is not linked to any versioned - * file. - */ - sprintf(ver, ";%d", mp->version + 1); - strcat(sp->lname, ver); - sp->lname_len = strlen(sp->lname); - /* - * Lower versioned files, mp to cp - * inclusive, should be removed. - */ - sp->next = cp->next; - cp->next = (FINFO *)NULL; - FreeFinfo(mp); - num = ++pnum; - pp = sp; - sp = cp = pp->next; - } else { - /* - * Versionless is linked to one of versionless - * files. We can remove it. - */ + if (!linkp) { + /* + * Versionless is not linked to any versioned + * file. + */ + sprintf(ver, ";%d", mp->version + 1); + strcat(sp->lname, ver); + sp->lname_len = strlen(sp->lname); + /* + * Lower versioned files, mp to cp + * inclusive, should be removed. + */ + sp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(mp); + num = ++pnum; + pp = sp; + sp = cp = pp->next; + } else { + /* + * Versionless is linked to one of versionless + * files. We can remove it. + */ - if (mp != cp) { - sp->next = mp->next; - mp->next = cp->next; - cp->next = (FINFO *)NULL; - } else { - sp->next = (FINFO *)NULL; - } - FreeFinfo(sp); - num = ++pnum; - if (pp != (FINFO *)NULL) - pp->next = mp; - else - *fp = mp; - pp = mp; - sp = cp = mp->next; - } - } else { - /* - * Only versionless file exists. It is regared as - * version 1. - */ - strcat(cp->lname, ";1"); - cp->lname_len += 2; - pp = cp; - sp = cp = cp->next; - num = ++pnum; - } - } else { - if (cp != sp) { - /* - * All files are versioned. - * Lower versioned files can be removed. - */ - tp = sp->next; - sp->next = cp->next; - cp->next = (FINFO *)NULL; - FreeFinfo(tp); - num = ++pnum; - } else { - /* - * A versioned file only exists. - */ - num = ++pnum; - } - pp = sp; - sp = cp = sp->next; - } - } while (sp != (FINFO *)NULL) ; + if (mp != cp) { + sp->next = mp->next; + mp->next = cp->next; + cp->next = (FINFO *)NULL; + } else { + sp->next = (FINFO *)NULL; + } + FreeFinfo(sp); + num = ++pnum; + if (pp != (FINFO *)NULL) + pp->next = mp; + else + *fp = mp; + pp = mp; + sp = cp = mp->next; + } + } else { + /* + * Only versionless file exists. It is regared as + * version 1. + */ + strcat(cp->lname, ";1"); + cp->lname_len += 2; + pp = cp; + sp = cp = cp->next; + num = ++pnum; + } + } else { + if (cp != sp) { + /* + * All files are versioned. + * Lower versioned files can be removed. + */ + tp = sp->next; + sp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(tp); + num = ++pnum; + } else { + /* + * A versioned file only exists. + */ + num = ++pnum; + } + pp = sp; + sp = cp = sp->next; + } + } while (sp != (FINFO *)NULL); - return(num); + return (num); } -/* +/* * Name: trim_finfo_version * * Argument: FINFO **fp Linked list of the numerated FINFO structures. @@ -1726,174 +1680,170 @@ int trim_finfo_highest(fp, highestp) * are got rid of. */ -int trim_finfo_version(fp, rver) - FINFO **fp; - int rver; +int trim_finfo_version(fp, rver) FINFO **fp; +int rver; { - register FINFO *tp, *sp, *mp, *cp, *pp, *vp; - register int num, pnum; - int linkp; - char ver[VERSIONLEN]; + register FINFO *tp, *sp, *mp, *cp, *pp, *vp; + register int num, pnum; + int linkp; + char ver[VERSIONLEN]; - sp = mp = cp = *fp; - pp = (FINFO *)NULL; - num = pnum = 0; + sp = mp = cp = *fp; + pp = (FINFO *)NULL; + num = pnum = 0; - do { - if (cp->dirp) { - /* - * Directory has no version, thus they should be remvoed. - */ - sp = cp = cp->next; - continue; - } - - if (cp->next != (FINFO *)NULL && - strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { - mp = cp = cp->next; - num++; - while (cp->next != (FINFO *)NULL && - strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { - cp = cp->next; - num++; - } - } else { - mp = cp; - } + do { + if (cp->dirp) { + /* + * Directory has no version, thus they should be remvoed. + */ + sp = cp = cp->next; + continue; + } - for (tp = sp, vp = (FINFO *)NULL; tp != cp->next; tp = tp->next) { - if (tp->version == rver) { - vp = tp; - break; - } - } + if (cp->next != (FINFO *)NULL && strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + mp = cp = cp->next; + num++; + while (cp->next != (FINFO *)NULL && strcmp(cp->next->no_ver_name, cp->no_ver_name) == 0) { + cp = cp->next; + num++; + } + } else { + mp = cp; + } - if (vp != (FINFO *)NULL) { - /* - * Specified version file exists. Other files should be - * removed. - */ - if (vp == sp) { - if (cp != sp) { - vp->next = cp->next; - cp->next = (FINFO *)NULL; - FreeFinfo(mp); - } - } else { - for (tp = sp; tp->next != vp; tp = tp->next) {} - if (vp != cp) { - tp->next = vp->next; - vp->next = cp->next; - cp->next = (FINFO *)NULL; - } else { - tp->next = (FINFO *)NULL; - } - if (pp != (FINFO *)NULL) - pp->next = vp; - else - *fp = vp; - FreeFinfo(sp); - } - pp = vp; - sp = cp = vp->next; - num = ++pnum; - continue; + for (tp = sp, vp = (FINFO *)NULL; tp != cp->next; tp = tp->next) { + if (tp->version == rver) { + vp = tp; + break; + } + } - } + if (vp != (FINFO *)NULL) { + /* + * Specified version file exists. Other files should be + * removed. + */ + if (vp == sp) { + if (cp != sp) { + vp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(mp); + } + } else { + for (tp = sp; tp->next != vp; tp = tp->next) {} + if (vp != cp) { + tp->next = vp->next; + vp->next = cp->next; + cp->next = (FINFO *)NULL; + } else { + tp->next = (FINFO *)NULL; + } + if (pp != (FINFO *)NULL) + pp->next = vp; + else + *fp = vp; + FreeFinfo(sp); + } + pp = vp; + sp = cp = vp->next; + num = ++pnum; + continue; + } - /* - * Although there is no file with specified version, versionless - * file might be interpreted the specified version. - */ - if (sp->version == 0) { - if (cp != sp) { - /* - * Both versionless and versioned files exists. - */ - linkp = 0; - tp = sp; - do { - tp = tp->next; - if (tp->ino == sp->ino) { - linkp = 1; - break; - } - } while (cp != tp); + /* + * Although there is no file with specified version, versionless + * file might be interpreted the specified version. + */ + if (sp->version == 0) { + if (cp != sp) { + /* + * Both versionless and versioned files exists. + */ + linkp = 0; + tp = sp; + do { + tp = tp->next; + if (tp->ino == sp->ino) { + linkp = 1; + break; + } + } while (cp != tp); - if (!linkp) { - /* - * Versionless is not linked to any versioned - * file. - */ - if (mp->version + 1 == rver) { - sprintf(ver, ";%d", rver); - strcat(sp->lname, ver); - sp->lname_len = strlen(sp->lname); - /* - * Lower versioned files, mp to cp - * inclusive, should be removed. - */ - sp->next = cp->next; - cp->next = (FINFO *)NULL; - FreeFinfo(mp); - num = ++pnum; - pp = sp; - sp = cp = pp->next; - } else { - /* - * sp to cp inclusive, all files, - * should be removed. - */ - tp = cp->next; - if (pp != (FINFO *)NULL) - pp->next = tp; - else - *fp = tp; - cp->next = (FINFO *)NULL; - FreeFinfo(sp); - sp = cp = tp; - } - } else { - /* - * Versionless is linked to one of versionless - * files. We can remove all files, because - * no versioned file match with rver. - */ - tp = cp->next; - if (pp != (FINFO *)NULL) - pp->next = tp; - else - *fp = tp; - cp->next = (FINFO *)NULL; - FreeFinfo(sp); - sp = cp = tp; - } - } else { - /* - * Only versionless file exists. It is regared as - * version 1. Unless rver is 1, we can remove it. - */ - if (rver != 1) { - cp = sp->next; - if (pp != (FINFO *)NULL) - pp->next = cp; - else - *fp = cp; - sp->next = (FINFO *)NULL; - FreeFinfo(sp); - sp = cp; - } else { - strcat(cp->lname, ";1"); - cp->lname_len += 2; - pp = cp; - sp = cp = cp->next; - num = ++pnum; - } - } - } - } while (sp != (FINFO *)NULL) ; + if (!linkp) { + /* + * Versionless is not linked to any versioned + * file. + */ + if (mp->version + 1 == rver) { + sprintf(ver, ";%d", rver); + strcat(sp->lname, ver); + sp->lname_len = strlen(sp->lname); + /* + * Lower versioned files, mp to cp + * inclusive, should be removed. + */ + sp->next = cp->next; + cp->next = (FINFO *)NULL; + FreeFinfo(mp); + num = ++pnum; + pp = sp; + sp = cp = pp->next; + } else { + /* + * sp to cp inclusive, all files, + * should be removed. + */ + tp = cp->next; + if (pp != (FINFO *)NULL) + pp->next = tp; + else + *fp = tp; + cp->next = (FINFO *)NULL; + FreeFinfo(sp); + sp = cp = tp; + } + } else { + /* + * Versionless is linked to one of versionless + * files. We can remove all files, because + * no versioned file match with rver. + */ + tp = cp->next; + if (pp != (FINFO *)NULL) + pp->next = tp; + else + *fp = tp; + cp->next = (FINFO *)NULL; + FreeFinfo(sp); + sp = cp = tp; + } + } else { + /* + * Only versionless file exists. It is regared as + * version 1. Unless rver is 1, we can remove it. + */ + if (rver != 1) { + cp = sp->next; + if (pp != (FINFO *)NULL) + pp->next = cp; + else + *fp = cp; + sp->next = (FINFO *)NULL; + FreeFinfo(sp); + sp = cp; + } else { + strcat(cp->lname, ";1"); + cp->lname_len += 2; + pp = cp; + sp = cp = cp->next; + num = ++pnum; + } + } + } + } while (sp != (FINFO *)NULL); - return(num); + return (num); } /************************************************************************/ @@ -1904,7 +1854,7 @@ int trim_finfo_version(fp, rver) /********* B E G I N O F F I L E - S O R T I N G C O D E ***********/ /************************************************************************/ -/* +/* * Name: prepare_sort_buf * * Argument: FINFO *fp Linked list of FINFO structures being sorted. @@ -1922,24 +1872,22 @@ int trim_finfo_version(fp, rver) * Caller have to free the area after sorting done. */ -FINFO ** -prepare_sort_buf(fp, n) - register FINFO *fp; - register int n; +FINFO **prepare_sort_buf(fp, n) register FINFO *fp; +register int n; { - register FINFO **bp; - register FINFO **bufp; - - if ((bufp = (FINFO **)malloc(sizeof(FINFO *) * n)) == NULL) { - *Lisp_errno = errno; - return((FINFO **)NULL); - } - for (bp = bufp; fp != (FINFO *)NULL; fp = fp->next, bp++) *bp = fp; + register FINFO **bp; + register FINFO **bufp; - return(bufp); + if ((bufp = (FINFO **)malloc(sizeof(FINFO *) * n)) == NULL) { + *Lisp_errno = errno; + return ((FINFO **)NULL); + } + for (bp = bufp; fp != (FINFO *)NULL; fp = fp->next, bp++) *bp = fp; + + return (bufp); } -/* +/* * Name: dsk_filecmp * * Argument: FINFO *fp1 A FINFO structure, a file name in it is being compared. @@ -1958,24 +1906,22 @@ prepare_sort_buf(fp, n) * Note that the result is in the reversed order. */ -int dsk_filecmp(fp1, fp2) - FINFO **fp1; - FINFO **fp2; +int dsk_filecmp(fp1, fp2) FINFO **fp1; +FINFO **fp2; { - register int res, v1, v2; + register int res, v1, v2; - if ((res = strcmp((*fp1)->no_ver_name, (*fp2)->no_ver_name)) != 0) - return(res); + if ((res = strcmp((*fp1)->no_ver_name, (*fp2)->no_ver_name)) != 0) return (res); - if ((*fp1)->version == (*fp2)->version) return(0); + if ((*fp1)->version == (*fp2)->version) return (0); #ifndef DOS - if ((v1 = (*fp1)->version) == 0) return(-1); - if ((v2 = (*fp2)->version) == 0) return(1); + if ((v1 = (*fp1)->version) == 0) return (-1); + if ((v2 = (*fp2)->version) == 0) return (1); #endif /* DOS */ - return((v1 < v2) ? 1 : -1); + return ((v1 < v2) ? 1 : -1); } -/* +/* * Name: unix_filecmp * * Argument: FINFO *f1 A FINFO structure, a file name in it is being compared. @@ -1992,14 +1938,11 @@ int dsk_filecmp(fp1, fp2) * Note that the result is in the reversed order. */ -int unix_filecmp(f1, f2) - register FINFO **f1; - register FINFO **f2; -{ - return(strcmp((*f1)->lname, (*f2)->lname)); -} +int unix_filecmp(f1, f2) register FINFO **f1; +register FINFO **f2; +{ return (strcmp((*f1)->lname, (*f2)->lname)); } -/* +/* * Name: file_sort * * Argument: FINFO **fpp A pointer to a pointer adressing the linked FINFO @@ -2018,29 +1961,28 @@ int unix_filecmp(f1, f2) * used for {DSK} and {UNIX} device respectively as a sort function. */ -int file_sort(fpp, n, sortfn) - register FINFO **fpp; - register int n; - register int (*sortfn)(); +int file_sort(fpp, n, sortfn) register FINFO **fpp; +register int n; +register int (*sortfn)(); { - register FINFO **fp; - register FINFO **sort_bufp; + register FINFO **fp; + register FINFO **sort_bufp; - if ((sort_bufp = prepare_sort_buf(*fpp, n)) == (FINFO **)NULL) return(0); + if ((sort_bufp = prepare_sort_buf(*fpp, n)) == (FINFO **)NULL) return (0); - qsort(sort_bufp, n, sizeof(FINFO *), sortfn); + qsort(sort_bufp, n, sizeof(FINFO *), sortfn); - /* - * Relink FINFO structures in a buffer. - */ - for (fp = sort_bufp; n > 1; fp++, n--) (*fp)->next = *(fp + 1); - (*fp)->next = (FINFO *)NULL; + /* + * Relink FINFO structures in a buffer. + */ + for (fp = sort_bufp; n > 1; fp++, n--) (*fp)->next = *(fp + 1); + (*fp)->next = (FINFO *)NULL; - *fpp = *sort_bufp; + *fpp = *sort_bufp; - free((char *)sort_bufp); + free((char *)sort_bufp); - return(1); + return (1); } /************************************************************************/ @@ -2050,41 +1992,41 @@ int file_sort(fpp, n, sortfn) #ifndef BYTESWAP #ifdef BIGVM typedef struct ufsgfs { - unsigned finfoid; - unsigned fileid; - unsigned totalnum; - LispPTR directory; - unsigned propp : 1; - unsigned padding : 3; - unsigned dev :28; - LispPTR thisfile; - int errnum; - LispPTR name; - unsigned length; - unsigned wdate; - unsigned rdate; - unsigned protection; - LispPTR author; - unsigned aulen; + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned propp : 1; + unsigned padding : 3; + unsigned dev : 28; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; } UFSGFS; #else typedef struct ufsgfs { - unsigned finfoid; - unsigned fileid; - unsigned totalnum; - LispPTR directory; - unsigned propp : 1; - unsigned padding : 7; - unsigned dev :24; - LispPTR thisfile; - int errnum; - LispPTR name; - unsigned length; - unsigned wdate; - unsigned rdate; - unsigned protection; - LispPTR author; - unsigned aulen; + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned propp : 1; + unsigned padding : 7; + unsigned dev : 24; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; } UFSGFS; #endif /* BIGVM */ @@ -2092,47 +2034,46 @@ typedef struct ufsgfs { #ifdef BIGVM typedef struct ufsgfs { - unsigned finfoid; - unsigned fileid; - unsigned totalnum; - LispPTR directory; - unsigned dev :28; - unsigned padding : 3; - unsigned propp : 1; - LispPTR thisfile; - int errnum; - LispPTR name; - unsigned length; - unsigned wdate; - unsigned rdate; - unsigned protection; - LispPTR author; - unsigned aulen; + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned dev : 28; + unsigned padding : 3; + unsigned propp : 1; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; } UFSGFS; #else typedef struct ufsgfs { - unsigned finfoid; - unsigned fileid; - unsigned totalnum; - LispPTR directory; - unsigned dev :24; - unsigned padding : 7; - unsigned propp : 1; - LispPTR thisfile; - int errnum; - LispPTR name; - unsigned length; - unsigned wdate; - unsigned rdate; - unsigned protection; - LispPTR author; - unsigned aulen; + unsigned finfoid; + unsigned fileid; + unsigned totalnum; + LispPTR directory; + unsigned dev : 24; + unsigned padding : 7; + unsigned propp : 1; + LispPTR thisfile; + int errnum; + LispPTR name; + unsigned length; + unsigned wdate; + unsigned rdate; + unsigned protection; + LispPTR author; + unsigned aulen; } UFSGFS; #endif /* BIGVM */ #endif /* BYTESWAP */ - -/* +/* * Name: COM_gen_files * * Argument: LispPTR *args args[0] @@ -2156,151 +2097,146 @@ typedef struct ufsgfs { * Enumerates files matching pattern. */ -LispPTR COM_gen_files(args) - register LispPTR *args; +LispPTR COM_gen_files(args) register LispPTR *args; { - char fbuf[MAXPATHLEN + 5], dir[MAXPATHLEN], pattern[MAXPATHLEN]; - char host[MAXNAMLEN], name[MAXNAMLEN], ver[VERSIONLEN], drive[1]; - int dskp, count, highestp, propp, id, version; - register char *cp; - FINFO *fp; - int dsk_filecmp(), unix_filecmp(); + char fbuf[MAXPATHLEN + 5], dir[MAXPATHLEN], pattern[MAXPATHLEN]; + char host[MAXNAMLEN], name[MAXNAMLEN], ver[VERSIONLEN], drive[1]; + int dskp, count, highestp, propp, id, version; + register char *cp; + FINFO *fp; + int dsk_filecmp(), unix_filecmp(); - ERRSETJMP(GetSmallp(-1)); - - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - - LispStringLength(args[0], count, dskp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - count = dskp ? count + 4 + 1 : count + 2 + 1; - /* Add 5 for the host name field in Lisp format. */ - if (count > MAXPATHLEN + 5) FileNameTooLong((GetSmallp(-1))); + ERRSETJMP(GetSmallp(-1)); - LispStringToCString(args[0], fbuf, MAXPATHLEN); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + + LispStringLength(args[0], count, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + count = dskp ? count + 4 + 1 : count + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (count > MAXPATHLEN + 5) FileNameTooLong((GetSmallp(-1))); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); #ifdef DOS - separate_host(fbuf, host, drive); + separate_host(fbuf, host, drive); #else - separate_host(fbuf, host); + separate_host(fbuf, host); #endif /* DOS */ - UPCASE(host); - if (strcmp(host, "DSK") == 0) - dskp = 1; - else if (strcmp(host, "UNIX") == 0) - dskp = 0; - else - return(NIL); + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); - if (args[1] == NIL) - propp = 0; - else - propp = 1; + if (args[1] == NIL) + propp = 0; + else + propp = 1; - /* - * The way to deal with the version field in file enumeration is a little - * bit tricky because of the bad specification of original {UNIX} device. - * - * According to the Medley 1.1 release note, in the representation - * "{UNIX}name.ext;3", ';' and '3' are regarded as a part of the - * file name, not its version. On the other hand, in 1.1 implementation, - * in the pattern "{UNIX}*.*;*", the ';' and the last '*' are regarded - * as a version field, not part of the file name. Actually the pattern - * "{UNIX}*.*;*" enumerates all of the files on /tmp directory - * even if they never include ';' character in its name, as well as '.'. - * - * Thus I beleive, the specification should be clean upped as like, - * "UNIX device always ignores the version field in it file name representation - * even if a user specifies it expricitly". - * But to keep a compatibility to an already released version, we have - * to do some trick here. - */ +/* + * The way to deal with the version field in file enumeration is a little + * bit tricky because of the bad specification of original {UNIX} device. + * + * According to the Medley 1.1 release note, in the representation + * "{UNIX}name.ext;3", ';' and '3' are regarded as a part of the + * file name, not its version. On the other hand, in 1.1 implementation, + * in the pattern "{UNIX}*.*;*", the ';' and the last '*' are regarded + * as a version field, not part of the file name. Actually the pattern + * "{UNIX}*.*;*" enumerates all of the files on /tmp directory + * even if they never include ';' character in its name, as well as '.'. + * + * Thus I beleive, the specification should be clean upped as like, + * "UNIX device always ignores the version field in it file name representation + * even if a user specifies it expricitly". + * But to keep a compatibility to an already released version, we have + * to do some trick here. + */ #ifdef DOS - if (!unixpathname(fbuf, pattern, 1, 1, drive, 0, 0)) { + if (!unixpathname(fbuf, pattern, 1, 1, drive, 0, 0)) { #else - if (!unixpathname(fbuf, pattern, 1, 1)) { + if (!unixpathname(fbuf, pattern, 1, 1)) { #endif /* DOS */ - /* Yes, always dskp is on */ - return(GetSmallp(-1)); - } + /* Yes, always dskp is on */ + return (GetSmallp(-1)); + } - if (!unpack_filename(pattern, dir, name, ver, 0)) return(GetSmallp(-1)); + if (!unpack_filename(pattern, dir, name, ver, 0)) return (GetSmallp(-1)); - if (dskp) { - /* - * On {DSK}, we have to make sure dir is case insensitively exisiting - * directory. - */ - if (true_name(dir) != -1) return(GetSmallp(-1)); + if (dskp) { + /* + * On {DSK}, we have to make sure dir is case insensitively exisiting + * directory. + */ + if (true_name(dir) != -1) return (GetSmallp(-1)); - if (*ver != '\0') { - highestp = 0; - version = atoi(ver); - if (version > 0) strcpy(ver, "*"); - } else { - version = 0; - for (cp = fbuf; *cp; cp++) {} - if (*(cp - 1) == ';' && *(cp - 2) != '\'') { - /* - * An empty version is interpreted as wanting the - * highest version. In this case, at first enumerate - * all version. trim_finfo_highest will get rid of - * lower versions. - */ - strcpy(ver, "*"); - highestp = 1; - } else { - highestp = 0; - } - } - if (propp) - count = enum_dsk_prop(dir, name, ver, &fp); - else - count = enum_dsk(dir, name, ver, &fp); - } else { - /* Makes UNIX device matchts any version. */ - strcpy(ver, "*"); + if (*ver != '\0') { + highestp = 0; + version = atoi(ver); + if (version > 0) strcpy(ver, "*"); + } else { + version = 0; + for (cp = fbuf; *cp; cp++) {} + if (*(cp - 1) == ';' && *(cp - 2) != '\'') { + /* + * An empty version is interpreted as wanting the + * highest version. In this case, at first enumerate + * all version. trim_finfo_highest will get rid of + * lower versions. + */ + strcpy(ver, "*"); + highestp = 1; + } else { + highestp = 0; + } + } + if (propp) + count = enum_dsk_prop(dir, name, ver, &fp); + else + count = enum_dsk(dir, name, ver, &fp); + } else { + /* Makes UNIX device matchts any version. */ + strcpy(ver, "*"); - if (propp) - count = enum_ufs_prop(dir, name, ver, &fp); - else - count = enum_ufs(dir, name, ver, &fp); - } - - switch (count) { + if (propp) + count = enum_ufs_prop(dir, name, ver, &fp); + else + count = enum_ufs(dir, name, ver, &fp); + } - case -1: - return(GetSmallp(-1)); + switch (count) { + case -1: return (GetSmallp(-1)); - case 0: - return(GetSmallp(0)); + case 0: return (GetSmallp(0)); - default: - if (!file_sort(&fp, count, dskp ? dsk_filecmp : unix_filecmp)) - return(GetSmallp(-1)); - if (dskp) { - if (highestp) - count = trim_finfo_highest(&fp, highestp); - else if (version > 0 && count > 0) - count = trim_finfo_version(&fp, version); - else - count = trim_finfo(&fp); - } + default: + if (!file_sort(&fp, count, dskp ? dsk_filecmp : unix_filecmp)) return (GetSmallp(-1)); + if (dskp) { + if (highestp) + count = trim_finfo_highest(&fp, highestp); + else if (version > 0 && count > 0) + count = trim_finfo_version(&fp, version); + else + count = trim_finfo(&fp); + } - if ((id = get_finfo_id()) < 0) return(GetSmallp(-1)); - *(int *)(Addr68k_from_LADDR(args[2])) = id; - FinfoArray[id].head = fp; - FinfoArray[id].next = fp; - return(GetSmallp(count)); - } + if ((id = get_finfo_id()) < 0) return (GetSmallp(-1)); + *(int *)(Addr68k_from_LADDR(args[2])) = id; + FinfoArray[id].head = fp; + FinfoArray[id].next = fp; + return (GetSmallp(count)); + } } -/* +/* * Name: COM_next_file * * Argument: LispPTR *args args[0] @@ -2318,65 +2254,61 @@ LispPTR COM_gen_files(args) * name. */ -LispPTR COM_next_file(args) - register LispPTR *args; +LispPTR COM_next_file(args) register LispPTR *args; { - register LispPTR laddr; - register FPROP *pp; - register FINFO *fp; - register char *base; - register DFINFO *dfp; - register UFSGFS *gfsp; - int finfoid, propp; + register LispPTR laddr; + register FPROP *pp; + register FINFO *fp; + register char *base; + register DFINFO *dfp; + register UFSGFS *gfsp; + int finfoid, propp; - ERRSETJMP(-1); - Lisp_errno = &Dummy_errno; + ERRSETJMP(-1); + Lisp_errno = &Dummy_errno; - gfsp = (UFSGFS *)(Addr68k_from_LADDR(args[0])); + gfsp = (UFSGFS *)(Addr68k_from_LADDR(args[0])); - finfoid = (int)gfsp->finfoid; + finfoid = (int)gfsp->finfoid; - if (finfoid < 0 || MAXFINFO - 1 < finfoid) return(GetSmallp(-1)); + if (finfoid < 0 || MAXFINFO - 1 < finfoid) return (GetSmallp(-1)); - propp = gfsp->propp; + propp = gfsp->propp; - dfp = &FinfoArray[finfoid]; - if (dfp->head == (FINFO *)0 || (fp = dfp->next) == (FINFO *)0) - return(GetSmallp(-1)); - dfp->next = fp->next; + dfp = &FinfoArray[finfoid]; + if (dfp->head == (FINFO *)0 || (fp = dfp->next) == (FINFO *)0) return (GetSmallp(-1)); + dfp->next = fp->next; - laddr = gfsp->name; - STRING_BASE(laddr, base); + laddr = gfsp->name; + STRING_BASE(laddr, base); #ifndef BYTESWAP - strncpy(base, fp->lname, fp->lname_len); + strncpy(base, fp->lname, fp->lname_len); #else - StrNCpyFromCToLisp(base, fp->lname, fp->lname_len); + StrNCpyFromCToLisp(base, fp->lname, fp->lname_len); #endif /* BYTESWAP */ + if (!propp) return (GetSmallp(fp->lname_len)); - if (!propp) return(GetSmallp(fp->lname_len)); + pp = fp->prop; + gfsp->length = pp->length; + gfsp->wdate = pp->wdate; + gfsp->rdate = pp->rdate; + gfsp->protection = pp->protect; - pp = fp->prop; - gfsp->length = pp->length; - gfsp->wdate = pp->wdate; - gfsp->rdate = pp->rdate; - gfsp->protection = pp->protect; - - laddr = gfsp->author; - STRING_BASE(laddr, base); + laddr = gfsp->author; + STRING_BASE(laddr, base); #ifndef BYTESWAP - strncpy(base, pp->author, pp->au_len); + strncpy(base, pp->author, pp->au_len); #else - StrNCpyFromCToLisp(base, pp->author, pp->au_len); + StrNCpyFromCToLisp(base, pp->author, pp->au_len); #endif /* BYTESWAP */ + gfsp->aulen = pp->au_len; - gfsp->aulen = pp->au_len; - - return(GetSmallp(fp->lname_len)); + return (GetSmallp(fp->lname_len)); } -/* +/* * Name: COM_finish_finfo * * Argument: LispPTR *args args[0] @@ -2393,30 +2325,29 @@ LispPTR COM_next_file(args) * Abandon all cached information corresponding to the generator. */ -LispPTR COM_finish_finfo(args) - register LispPTR *args; +LispPTR COM_finish_finfo(args) register LispPTR *args; { - register DFINFO *dfp; - register FINFO *fp; - register int finfoid; + register DFINFO *dfp; + register FINFO *fp; + register int finfoid; - ERRSETJMP(NIL); - - Lisp_errno = &Dummy_errno; + ERRSETJMP(NIL); - finfoid = LispNumToCInt(args[0]); + Lisp_errno = &Dummy_errno; - if (finfoid < 0 || MAXFINFO - 1 < finfoid) return(NIL); + finfoid = LispNumToCInt(args[0]); - dfp = &FinfoArray[finfoid]; - if ((fp = dfp->head) == (FINFO *)0) { - dfp->next = (FINFO *)0; - return(NIL); - } + if (finfoid < 0 || MAXFINFO - 1 < finfoid) return (NIL); - dfp->head = (FINFO *)0; - dfp->next = (FINFO *)0; - FreeFinfo(fp); + dfp = &FinfoArray[finfoid]; + if ((fp = dfp->head) == (FINFO *)0) { + dfp->next = (FINFO *)0; + return (NIL); + } - return(ATOM_T); + dfp->head = (FINFO *)0; + dfp->next = (FINFO *)0; + FreeFinfo(fp); + + return (ATOM_T); } diff --git a/src/dlpi.c b/src/dlpi.c old mode 100755 new mode 100644 index ed7d751..5e2d1fa --- a/src/dlpi.c +++ b/src/dlpi.c @@ -1,7 +1,8 @@ /* $Id: dlpi.c,v 1.3 2001/12/24 01:09:00 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: dlpi.c,v 1.3 2001/12/24 01:09:00 sybalsky Exp $ Copyright (C) Venue"; #ifndef lint -static char *RCSid = "$Header: /disk/disk3/cvsroot/medley/src/dlpi.c,v 1.3 2001/12/24 01:09:00 sybalsky Exp $"; +static char *RCSid = + "$Header: /disk/disk3/cvsroot/medley/src/dlpi.c,v 1.3 2001/12/24 01:09:00 sybalsky Exp $"; #endif #include "os.h" @@ -79,16 +80,16 @@ static char *RCSid = "$Header: /disk/disk3/cvsroot/medley/src/dlpi.c,v 1.3 2001/ #include "nfswatch.h" #include "externs.h" -static void dlbindreq(); -static void dlinforeq(); -static void dlattachreq(); -static void dlpromisconreq(); -static void sigalrm(); -static int dlokack(); -static int dlinfoack(); -static int dlbindack(); -static int expecting(); -static int strgetmsg(); +static void dlbindreq(); +static void dlinforeq(); +static void dlattachreq(); +static void dlpromisconreq(); +static void sigalrm(); +static int dlokack(); +static int dlinfoack(); +static int dlbindack(); +static int expecting(); +static int strgetmsg(); static char *pname; extern unsigned char ether_host[6]; @@ -97,624 +98,562 @@ int truncation = 1500; /* * setup_dlpi_dev - set up the data link provider interface. */ -int -setup_dlpi_dev(device) -char *device; +int setup_dlpi_dev(device) char *device; { - char *p; - u_int chunksz; - char cbuf[BUFSIZ]; - struct ifconf ifc; - struct ifreq *ifrp; - struct strioctl si; - char devname[BUFSIZ]; - int n, s, fd, devppa; - struct timeval timeout; - long buf[DLPI_MAXDLBUF]; + char *p; + u_int chunksz; + char cbuf[BUFSIZ]; + struct ifconf ifc; + struct ifreq *ifrp; + struct strioctl si; + char devname[BUFSIZ]; + int n, s, fd, devppa; + struct timeval timeout; + long buf[DLPI_MAXDLBUF]; - /* - * If the interface device was not specified, - * get the default one. - */ - if ((device == NULL) || *device == NULL) { - /* - * Grab a socket. - */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("socket"); - return(-1); - } + /* + * If the interface device was not specified, + * get the default one. + */ + if ((device == NULL) || *device == NULL) { + /* + * Grab a socket. + */ + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("socket"); + return (-1); + } - ifc.ifc_buf = cbuf; - ifc.ifc_len = sizeof(cbuf); + ifc.ifc_buf = cbuf; + ifc.ifc_len = sizeof(cbuf); - /* - * See what devices we've got. - */ - if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) { - perror("ioctl: SIOCGIFCONF"); - return(-1); - } + /* + * See what devices we've got. + */ + if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { + perror("ioctl: SIOCGIFCONF"); + return (-1); + } - /* - * Take the first device we encounter. - */ - ifrp = ifc.ifc_req; - for (n = ifc.ifc_len/sizeof(struct ifreq); n > 0; n--,ifrp++) { - /* - * Skip the loopback interface. - */ - if (strcmp(ifrp->ifr_name, "lo0") == 0) - continue; + /* + * Take the first device we encounter. + */ + ifrp = ifc.ifc_req; + for (n = ifc.ifc_len / sizeof(struct ifreq); n > 0; n--, ifrp++) { + /* + * Skip the loopback interface. + */ + if (strcmp(ifrp->ifr_name, "lo0") == 0) continue; - device = savestr(ifrp->ifr_name); - break; - } + device = savestr(ifrp->ifr_name); + break; + } - (void) close(s); - } + (void)close(s); + } - /* - * Split the device name into type and unit number. - */ - if ((p = strpbrk(device, "0123456789")) == NULL) - return(-1); + /* + * Split the device name into type and unit number. + */ + if ((p = strpbrk(device, "0123456789")) == NULL) return (-1); - strcpy(devname, DLPI_DEVDIR); - strncat(devname, device, p - device); - devppa = atoi(p); + strcpy(devname, DLPI_DEVDIR); + strncat(devname, device, p - device); + devppa = atoi(p); - /* - * Open the device. - */ - if ((fd = open(devname, O_RDWR)) < 0) { - if (errno == ENOENT || errno == ENXIO) - return(-1); + /* + * Open the device. + */ + if ((fd = open(devname, O_RDWR)) < 0) { + if (errno == ENOENT || errno == ENXIO) return (-1); - /*perror(devname);*/ - return(-1); - } + /*perror(devname);*/ + return (-1); + } - /* - * Attach to the device. If this fails, the device - * does not exist. - */ - dlattachreq(fd, devppa); + /* + * Attach to the device. If this fails, the device + * does not exist. + */ + dlattachreq(fd, devppa); - if (dlokack(fd, buf) < 0) { - close(fd); - return(-1); - } + if (dlokack(fd, buf) < 0) { + close(fd); + return (-1); + } + /* + * Bind to the specific unit. + */ + dlbindreq(fd, 0x0600, 0, DL_CLDLS, 0, 0); - /* - * Bind to the specific unit. - */ - dlbindreq(fd, 0x0600 , 0, DL_CLDLS, 0, 0); - - if (dlbindack(fd, buf) < 0) { - fprintf(stderr, "%s: dlbindack failed.\n", pname); - return(-1); - } + if (dlbindack(fd, buf) < 0) { + fprintf(stderr, "%s: dlbindack failed.\n", pname); + return (-1); + } #ifdef OS5 - /* - * We really want all types of packets. However, the SVR4 DLPI does - * not let you have the packet frame header, so we won't be able to - * distinguish protocol types. But SunOS5 gives you the DLIOCRAW - * ioctl to get the frame headers, so we can do this on SunOS5. - */ - dlpromisconreq(fd, DL_PROMISC_SAP); + /* + * We really want all types of packets. However, the SVR4 DLPI does + * not let you have the packet frame header, so we won't be able to + * distinguish protocol types. But SunOS5 gives you the DLIOCRAW + * ioctl to get the frame headers, so we can do this on SunOS5. + */ + dlpromisconreq(fd, DL_PROMISC_SAP); - if (dlokack(fd, buf) < 0) { - fprintf(stderr, "%s: DL_PROMISC_SAP failed.\n", pname); - return(-1); - } + if (dlokack(fd, buf) < 0) { + fprintf(stderr, "%s: DL_PROMISC_SAP failed.\n", pname); + return (-1); + } - dlpromisconreq(fd, DL_PROMISC_MULTI); + dlpromisconreq(fd, DL_PROMISC_MULTI); - if (dlokack(fd, buf) < 0) { - fprintf(stderr, "%s: DL_PROMISC_MULTI failed.\n", pname); - return(-1); - } + if (dlokack(fd, buf) < 0) { + fprintf(stderr, "%s: DL_PROMISC_MULTI failed.\n", pname); + return (-1); + } - /* - * We want raw packets with the packet frame header. But we can - * only get this in SunOS5 with the DLIOCRAW ioctl; it's not in - * standard SVR4. - */ - si.ic_cmd = DLIOCRAW; - si.ic_timout = -1; - si.ic_len = 0; - si.ic_dp = 0; + /* + * We want raw packets with the packet frame header. But we can + * only get this in SunOS5 with the DLIOCRAW ioctl; it's not in + * standard SVR4. + */ + si.ic_cmd = DLIOCRAW; + si.ic_timout = -1; + si.ic_len = 0; + si.ic_dp = 0; - if (ioctl(fd, I_STR, &si) < 0) { - perror("ioctl: I_STR DLIOCRAW"); - return(-1); - } + if (ioctl(fd, I_STR, &si) < 0) { + perror("ioctl: I_STR DLIOCRAW"); + return (-1); + } #endif /* OS5 */ - /* - * Arrange to get discrete messages. - */ - if (ioctl(fd, I_SRDOPT, (char *) RMSGD) < 0) { - perror("ioctl: I_SRDOPT RMSGD"); - return(-1); - } + /* + * Arrange to get discrete messages. + */ + if (ioctl(fd, I_SRDOPT, (char *)RMSGD) < 0) { + perror("ioctl: I_SRDOPT RMSGD"); + return (-1); + } #ifdef OS5 - /* - * Push and configure the streams buffering module. This is once - * again SunOS-specific. - */ +/* + * Push and configure the streams buffering module. This is once + * again SunOS-specific. + */ #ifdef NEVER - if (ioctl(fd, I_PUSH, DLPI_BUFMOD) < 0) { - perror("ioctl: I_PUSH BUFMOD"); - return(-1); - } - /* - * Set the read timeout. - */ - timeout.tv_sec = 1; - timeout.tv_usec = 0; + if (ioctl(fd, I_PUSH, DLPI_BUFMOD) < 0) { + perror("ioctl: I_PUSH BUFMOD"); + return (-1); + } + /* + * Set the read timeout. + */ + timeout.tv_sec = 1; + timeout.tv_usec = 0; - si.ic_cmd = SBIOCSTIME; - si.ic_timout = INFTIM; - si.ic_len = sizeof(timeout); - si.ic_dp = (char *) &timeout; + si.ic_cmd = SBIOCSTIME; + si.ic_timout = INFTIM; + si.ic_len = sizeof(timeout); + si.ic_dp = (char *)&timeout; - if (ioctl(fd, I_STR, (char *) &si) < 0) { - perror("ioctl: I_STR SBIOCSTIME"); - return(-1); - } + if (ioctl(fd, I_STR, (char *)&si) < 0) { + perror("ioctl: I_STR SBIOCSTIME"); + return (-1); + } - /* - * Set the chunk size. - */ - chunksz = DLPI_CHUNKSIZE; + /* + * Set the chunk size. + */ + chunksz = DLPI_CHUNKSIZE; - si.ic_cmd = SBIOCSCHUNK; - si.ic_len = sizeof(chunksz); - si.ic_dp = (char *) &chunksz; + si.ic_cmd = SBIOCSCHUNK; + si.ic_len = sizeof(chunksz); + si.ic_dp = (char *)&chunksz; - if (ioctl(fd, I_STR, (char *) &si) < 0) { - perror("ioctl: I_STR SBIOCSCHUNK"); - return(-1); - } + if (ioctl(fd, I_STR, (char *)&si) < 0) { + perror("ioctl: I_STR SBIOCSCHUNK"); + return (-1); + } - /* - * Set snapshot mode. - */ - si.ic_cmd = SBIOCSSNAP; - si.ic_len = sizeof(truncation); - si.ic_dp = (char *) &truncation; + /* + * Set snapshot mode. + */ + si.ic_cmd = SBIOCSSNAP; + si.ic_len = sizeof(truncation); + si.ic_dp = (char *)&truncation; - if (ioctl(fd, I_STR, (char *) &si) < 0) { - perror("ioctl: I_STR SBIOCSSNAP"); - return(-1); - } + if (ioctl(fd, I_STR, (char *)&si) < 0) { + perror("ioctl: I_STR SBIOCSSNAP"); + return (-1); + } #endif /* NEVER */ #endif /* OS5 */ - return(fd); + return (fd); } /* * flush_dlpi - flush data from the dlpi. */ -void -flush_dlpi(fd) -int fd; +void flush_dlpi(fd) int fd; { - if (ioctl(fd, I_FLUSH, (char *) FLUSHR) < 0) { - perror("ioctl: I_FLUSH"); - return; - } + if (ioctl(fd, I_FLUSH, (char *)FLUSHR) < 0) { + perror("ioctl: I_FLUSH"); + return; + } } /* * dlpi_devtype - determine the type of device we're looking at. */ -int -dlpi_devtype(fd) -int fd; +int dlpi_devtype(fd) int fd; { - long buf[DLPI_MAXDLBUF]; - union DL_primitives *dlp; + long buf[DLPI_MAXDLBUF]; + union DL_primitives *dlp; - dlp = (union DL_primitives *) buf; + dlp = (union DL_primitives *)buf; - dlinforeq(fd); + dlinforeq(fd); - if (dlinfoack(fd, buf) < 0) - return(DLT_EN10MB); + if (dlinfoack(fd, buf) < 0) return (DLT_EN10MB); - bcopy((char *)dlp+dlp->info_ack.dl_addr_offset, ether_host, 6); + bcopy((char *)dlp + dlp->info_ack.dl_addr_offset, ether_host, 6); - switch (dlp->info_ack.dl_mac_type) { - case DL_CSMACD: - case DL_ETHER: - return(DLT_EN10MB); + switch (dlp->info_ack.dl_mac_type) { + case DL_CSMACD: + case DL_ETHER: return (DLT_EN10MB); #ifdef DL_FDDI - case DL_FDDI: - return(DLT_FDDI); + case DL_FDDI: return (DLT_FDDI); #endif - default: - fprintf(stderr, "%s: DLPI MACtype %d unknown, ", pname, - dlp->info_ack.dl_mac_type); - fprintf(stderr, "assuming ethernet.\n"); - return(DLT_EN10MB); - } + default: + fprintf(stderr, "%s: DLPI MACtype %d unknown, ", pname, dlp->info_ack.dl_mac_type); + fprintf(stderr, "assuming ethernet.\n"); + return (DLT_EN10MB); + } } /* * dlinforeq - request information about the data link provider. */ -static void -dlinforeq(fd) -int fd; +static void dlinforeq(fd) int fd; { - dl_info_req_t info_req; - struct strbuf ctl; - int flags; + dl_info_req_t info_req; + struct strbuf ctl; + int flags; - info_req.dl_primitive = DL_INFO_REQ; + info_req.dl_primitive = DL_INFO_REQ; - ctl.maxlen = 0; - ctl.len = sizeof (info_req); - ctl.buf = (char *) &info_req; + ctl.maxlen = 0; + ctl.len = sizeof(info_req); + ctl.buf = (char *)&info_req; - flags = RS_HIPRI; + flags = RS_HIPRI; - if (putmsg(fd, &ctl, (struct strbuf *) NULL, flags) < 0) { - perror("putmsg"); - return; - } + if (putmsg(fd, &ctl, (struct strbuf *)NULL, flags) < 0) { + perror("putmsg"); + return; + } } /* * dlattachreq - send a request to attach. */ -static void -dlattachreq(fd, ppa) -u_long ppa; +static void dlattachreq(fd, ppa) u_long ppa; int fd; { - dl_attach_req_t attach_req; - struct strbuf ctl; - int flags; + dl_attach_req_t attach_req; + struct strbuf ctl; + int flags; - attach_req.dl_primitive = DL_ATTACH_REQ; - attach_req.dl_ppa = ppa; + attach_req.dl_primitive = DL_ATTACH_REQ; + attach_req.dl_ppa = ppa; - ctl.maxlen = 0; - ctl.len = sizeof (attach_req); - ctl.buf = (char *) &attach_req; + ctl.maxlen = 0; + ctl.len = sizeof(attach_req); + ctl.buf = (char *)&attach_req; - flags = 0; + flags = 0; - if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0) { - perror("putmsg"); - return; - } + if (putmsg(fd, &ctl, (struct strbuf *)NULL, flags) < 0) { + perror("putmsg"); + return; + } } #ifdef DL_PROMISCON_REQ /* * dlpromisconreq - send a request to turn promiscuous mode on. */ -static void -dlpromisconreq(fd, level) -u_long level; +static void dlpromisconreq(fd, level) u_long level; int fd; { - dl_promiscon_req_t promiscon_req; - struct strbuf ctl; - int flags; + dl_promiscon_req_t promiscon_req; + struct strbuf ctl; + int flags; - promiscon_req.dl_primitive = DL_PROMISCON_REQ; - promiscon_req.dl_level = level; + promiscon_req.dl_primitive = DL_PROMISCON_REQ; + promiscon_req.dl_level = level; - ctl.maxlen = 0; - ctl.len = sizeof (promiscon_req); - ctl.buf = (char *) &promiscon_req; + ctl.maxlen = 0; + ctl.len = sizeof(promiscon_req); + ctl.buf = (char *)&promiscon_req; - flags = 0; + flags = 0; - if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0) { - perror("putmsg"); - return; - } + if (putmsg(fd, &ctl, (struct strbuf *)NULL, flags) < 0) { + perror("putmsg"); + return; + } } #endif /* DL_PROMISCON_REQ */ /* * dlbindreq - send a request to bind. */ -static void -dlbindreq(fd, sap, max_conind, service_mode, conn_mgmt, xidtest) -u_long sap, max_conind, service_mode, conn_mgmt, xidtest; +static void dlbindreq(fd, sap, max_conind, service_mode, conn_mgmt, xidtest) u_long sap, max_conind, + service_mode, conn_mgmt, xidtest; int fd; { - dl_bind_req_t bind_req; - struct strbuf ctl; - int flags; + dl_bind_req_t bind_req; + struct strbuf ctl; + int flags; - bind_req.dl_primitive = DL_BIND_REQ; - bind_req.dl_sap = sap; - bind_req.dl_max_conind = max_conind; - bind_req.dl_service_mode = service_mode; - bind_req.dl_conn_mgmt = conn_mgmt; + bind_req.dl_primitive = DL_BIND_REQ; + bind_req.dl_sap = sap; + bind_req.dl_max_conind = max_conind; + bind_req.dl_service_mode = service_mode; + bind_req.dl_conn_mgmt = conn_mgmt; #ifdef DL_PROMISC_PHYS - /* - * DLPI 2.0 only? - */ - bind_req.dl_xidtest_flg = xidtest; + /* + * DLPI 2.0 only? + */ + bind_req.dl_xidtest_flg = xidtest; #endif - ctl.maxlen = 0; - ctl.len = sizeof (bind_req); - ctl.buf = (char *) &bind_req; + ctl.maxlen = 0; + ctl.len = sizeof(bind_req); + ctl.buf = (char *)&bind_req; - flags = 0; + flags = 0; - if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0) { - perror("putmsg"); - return; - } + if (putmsg(fd, &ctl, (struct strbuf *)NULL, flags) < 0) { + perror("putmsg"); + return; + } } /* * dlokack - general acknowledgement reception. */ -static int -dlokack(fd, bufp) -char *bufp; +static int dlokack(fd, bufp) char *bufp; int fd; { - union DL_primitives *dlp; - struct strbuf ctl; - int flags; + union DL_primitives *dlp; + struct strbuf ctl; + int flags; - ctl.maxlen = DLPI_MAXDLBUF; - ctl.len = 0; - ctl.buf = bufp; + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; - if (strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlokack") < 0) - return(-1); + if (strgetmsg(fd, &ctl, (struct strbuf *)NULL, &flags, "dlokack") < 0) return (-1); - dlp = (union DL_primitives *) ctl.buf; + dlp = (union DL_primitives *)ctl.buf; - if (expecting(DL_OK_ACK, dlp) < 0) - return(-1); + if (expecting(DL_OK_ACK, dlp) < 0) return (-1); - if (ctl.len < sizeof (dl_ok_ack_t)) - return(-1); + if (ctl.len < sizeof(dl_ok_ack_t)) return (-1); - if (flags != RS_HIPRI) - return(-1); + if (flags != RS_HIPRI) return (-1); - if (ctl.len < sizeof (dl_ok_ack_t)) - return(-1); + if (ctl.len < sizeof(dl_ok_ack_t)) return (-1); - return(0); + return (0); } /* * dlinfoack - receive an ack to a dlinforeq. */ -static int -dlinfoack(fd, bufp) -char *bufp; +static int dlinfoack(fd, bufp) char *bufp; int fd; { - union DL_primitives *dlp; - struct strbuf ctl; - int flags; + union DL_primitives *dlp; + struct strbuf ctl; + int flags; - ctl.maxlen = DLPI_MAXDLBUF; - ctl.len = 0; - ctl.buf = bufp; + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; - if (strgetmsg(fd, &ctl, (struct strbuf *)NULL, &flags, "dlinfoack") < 0) - return(-1); + if (strgetmsg(fd, &ctl, (struct strbuf *)NULL, &flags, "dlinfoack") < 0) return (-1); - dlp = (union DL_primitives *) ctl.buf; + dlp = (union DL_primitives *)ctl.buf; - if (expecting(DL_INFO_ACK, dlp) < 0) - return(-1); + if (expecting(DL_INFO_ACK, dlp) < 0) return (-1); - if (ctl.len < sizeof (dl_info_ack_t)) - return(-1); + if (ctl.len < sizeof(dl_info_ack_t)) return (-1); - if (flags != RS_HIPRI) - return(-1); + if (flags != RS_HIPRI) return (-1); - if (ctl.len < sizeof (dl_info_ack_t)) - return(-1); + if (ctl.len < sizeof(dl_info_ack_t)) return (-1); - return(0); + return (0); } /* * dlbindack - receive an ack to a dlbindreq. */ -static int -dlbindack(fd, bufp) -char *bufp; +static int dlbindack(fd, bufp) char *bufp; int fd; { - union DL_primitives *dlp; - struct strbuf ctl; - int flags; + union DL_primitives *dlp; + struct strbuf ctl; + int flags; - ctl.maxlen = DLPI_MAXDLBUF; - ctl.len = 0; - ctl.buf = bufp; + ctl.maxlen = DLPI_MAXDLBUF; + ctl.len = 0; + ctl.buf = bufp; - if (strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlbindack") < 0) - return(-1); + if (strgetmsg(fd, &ctl, (struct strbuf *)NULL, &flags, "dlbindack") < 0) return (-1); - dlp = (union DL_primitives *) ctl.buf; + dlp = (union DL_primitives *)ctl.buf; - if (expecting(DL_BIND_ACK, dlp) < 0) - return(-1); + if (expecting(DL_BIND_ACK, dlp) < 0) return (-1); - if (flags != RS_HIPRI) - return(-1); + if (flags != RS_HIPRI) return (-1); - if (ctl.len < sizeof (dl_bind_ack_t)) - return(-1); + if (ctl.len < sizeof(dl_bind_ack_t)) return (-1); - return(0); + return (0); } /* * expecting - see if we got what we wanted. */ -static int -expecting(prim, dlp) -union DL_primitives *dlp; +static int expecting(prim, dlp) union DL_primitives *dlp; int prim; { - if (dlp->dl_primitive != (u_long)prim) - return(-1); + if (dlp->dl_primitive != (u_long)prim) return (-1); - return(0); + return (0); } /* * strgetmsg - get a message from a stream, with timeout. */ -static int -strgetmsg(fd, ctlp, datap, flagsp, caller) -struct strbuf *ctlp, *datap; +static int strgetmsg(fd, ctlp, datap, flagsp, caller) struct strbuf *ctlp, *datap; char *caller; int *flagsp; int fd; { - int rc; - void sigalrm(); + int rc; + void sigalrm(); - /* - * Start timer. - */ - (void) sigset(SIGALRM, sigalrm); + /* + * Start timer. + */ + (void)sigset(SIGALRM, sigalrm); - if (alarm(DLPI_MAXWAIT) < 0) { - perror("alarm"); - return(-1); - } + if (alarm(DLPI_MAXWAIT) < 0) { + perror("alarm"); + return (-1); + } - /* - * Set flags argument and issue getmsg(). - */ - *flagsp = 0; - if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) { - perror("getmsg"); - return(-1); - } + /* + * Set flags argument and issue getmsg(). + */ + *flagsp = 0; + if ((rc = getmsg(fd, ctlp, datap, flagsp)) < 0) { + perror("getmsg"); + return (-1); + } - /* - * Stop timer. - */ - if (alarm(0) < 0) { - perror("alarm"); - return(-1); - } + /* + * Stop timer. + */ + if (alarm(0) < 0) { + perror("alarm"); + return (-1); + } - /* - * Check for MOREDATA and/or MORECTL. - */ - if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) - return(-1); - if (rc & MORECTL) - return(-1); - if (rc & MOREDATA) - return(-1); + /* + * Check for MOREDATA and/or MORECTL. + */ + if ((rc & (MORECTL | MOREDATA)) == (MORECTL | MOREDATA)) return (-1); + if (rc & MORECTL) return (-1); + if (rc & MOREDATA) return (-1); - /* - * Check for at least sizeof (long) control data portion. - */ - if (ctlp->len < sizeof (long)) - return(-1); + /* + * Check for at least sizeof (long) control data portion. + */ + if (ctlp->len < sizeof(long)) return (-1); - return(0); + return (0); } /* * sigalrm - handle alarms. */ -static void -sigalrm() -{ - (void) fprintf(stderr, "dlpi: timeout\n"); -} - - - +static void sigalrm() { (void)fprintf(stderr, "dlpi: timeout\n"); } /* * savestr - save string in dynamic memory. */ -char * -savestr(s) -char *s; +char *savestr(s) char *s; { - char *t; - char *malloc(); + char *t; + char *malloc(); - if ((t = malloc(strlen(s) + 1)) == NULL) { - (void) fprintf(stderr, "%s: out of memory.\n", pname); - (void) exit(1); - } + if ((t = malloc(strlen(s) + 1)) == NULL) { + (void)fprintf(stderr, "%s: out of memory.\n", pname); + (void)exit(1); + } - (void) strcpy(t, s); + (void)strcpy(t, s); - return(t); + return (t); } - - - -dlunitdatareq(fd, addrp, addrlen, minpri, maxpri, datap, datalen) -int fd; -u_char *addrp; -int addrlen; -u_long minpri, maxpri; -u_char *datap; -int datalen; +dlunitdatareq(fd, addrp, addrlen, minpri, maxpri, datap, datalen) int fd; +u_char *addrp; +int addrlen; +u_long minpri, maxpri; +u_char *datap; +int datalen; { - long buf[DLPI_MAXDLBUF]; - union DL_primitives *dlp; - struct strbuf data, ctl; + long buf[DLPI_MAXDLBUF]; + union DL_primitives *dlp; + struct strbuf data, ctl; - dlp = (union DL_primitives*) buf; + dlp = (union DL_primitives *)buf; - dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ; - dlp->unitdata_req.dl_dest_addr_length = addrlen+2; - dlp->unitdata_req.dl_dest_addr_offset = sizeof (dl_unitdata_req_t); - dlp->unitdata_req.dl_priority.dl_min = minpri; - dlp->unitdata_req.dl_priority.dl_max = maxpri; + dlp->unitdata_req.dl_primitive = DL_UNITDATA_REQ; + dlp->unitdata_req.dl_dest_addr_length = addrlen + 2; + dlp->unitdata_req.dl_dest_addr_offset = sizeof(dl_unitdata_req_t); + dlp->unitdata_req.dl_priority.dl_min = minpri; + dlp->unitdata_req.dl_priority.dl_max = maxpri; - (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)), addrp, addrlen); - (void) memcpy(OFFADDR(dlp, sizeof (dl_unitdata_req_t)+addrlen), (char *)addrp + 12, 2); + (void)memcpy(OFFADDR(dlp, sizeof(dl_unitdata_req_t)), addrp, addrlen); + (void)memcpy(OFFADDR(dlp, sizeof(dl_unitdata_req_t) + addrlen), (char *)addrp + 12, 2); - ctl.maxlen = 0; - ctl.len = sizeof (dl_unitdata_req_t) + addrlen +2; - ctl.buf = (char *) buf; + ctl.maxlen = 0; + ctl.len = sizeof(dl_unitdata_req_t) + addrlen + 2; + ctl.buf = (char *)buf; - data.maxlen = 0; - data.len = datalen; - data.buf = (char *) datap; + data.maxlen = 0; + data.len = datalen; + data.buf = (char *)datap; #ifdef NEVER - if (putmsg(fd, &ctl, &data, 0) < 0) + if (putmsg(fd, &ctl, &data, 0) < 0) #else - if (putmsg(fd, (char *) NULL, &data, 0) < 0) + if (putmsg(fd, (char *)NULL, &data, 0) < 0) #endif /* NEVER tst on 9/30/96 jds to see if raw out works */ - return -1; else return 0; + return -1; + else + return 0; } #endif /* USE_DLPI */ - diff --git a/src/doscomm.c b/src/doscomm.c old mode 100755 new mode 100644 index ae25af4..1e77140 --- a/src/doscomm.c +++ b/src/doscomm.c @@ -1,9 +1,7 @@ -/* $Id: doscomm.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: doscomm.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: doscomm.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -17,10 +15,6 @@ static char *id = "$Id: doscomm.c,v 1.3 1999/05/31 23:35:27 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - -DOS_handlecomm(int args) -{ -} +DOS_handlecomm(int args) {} diff --git a/src/doskbd.c b/src/doskbd.c old mode 100755 new mode 100644 index 12124fb..474279b --- a/src/doskbd.c +++ b/src/doskbd.c @@ -1,5 +1,6 @@ -/* $Id: doskbd.c,v 1.2 1999/01/03 02:06:55 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ -static char *id = "$Id: doskbd.c,v 1.2 1999/01/03 02:06:55 sybalsky Exp $ Copyright (C) Venue"; +/* $Id: doskbd.c,v 1.2 1999/01/03 02:06:55 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ +static char *id = "$Id: doskbd.c,v 1.2 1999/01/03 02:06:55 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ /* */ /* D O S K E Y B O A R D H A N D L E R */ @@ -7,29 +8,23 @@ static char *id = "$Id: doskbd.c,v 1.2 1999/01/03 02:06:55 sybalsky Exp $ Copyri /* */ /************************************************************************/ +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ - - -/************************************************************************/ -/* */ -/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ -/* All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/* The contents of this file are proprietary information */ -/* belonging to Venue, and are provided to you under license. */ -/* They may not be further distributed or disclosed to third */ -/* parties without the specific permission of Venue. */ -/* */ -/************************************************************************/ - - - -#include "version.h" - - -#include /* defines REGS & other structs */ -#include /* "#pragma interrupt" & '_chain_intr'*/ +#include "version.h" + +#include /* defines REGS & other structs */ +#include /* "#pragma interrupt" & '_chain_intr'*/ #include #include @@ -51,60 +46,56 @@ extern keybuffer *CTopKeyevent; extern LispPTR *LASTUSERACTION68k; extern LispPTR *KEYBUFFERING68k; - /************************************************/ - /* Keyboard-Interface Registers, Status Codes */ - /************************************************/ -#define KBD_COMMAND_PORT 0x64 /* I/O port commands go out on */ -#define KBD_ENABLE 0xAE -#define KBD_DISABLE 0xAD -#define KBD_RESET 0xF6 +/************************************************/ +/* Keyboard-Interface Registers, Status Codes */ +/************************************************/ +#define KBD_COMMAND_PORT 0x64 /* I/O port commands go out on */ +#define KBD_ENABLE 0xAE +#define KBD_DISABLE 0xAD +#define KBD_RESET 0xF6 -#define PORT_8042 0x60 /* Port scan codes come in on */ -#define KBD_SCAN_CODE_PORT 0x60 -#define KBD_resend 0xFE /* KBD asked for resend */ -#define KBD_ack 0xFA /* KBD ack's our command */ -#define KBD_echo_response 0xEE /* KBD responds to echo req */ -#define KBD_failure 0xFD /* Failure code */ -#define KBD_prefix 0xE0 /* Prefix for extended chars */ -#define KBD_pause_prefix 0xE1 /* Pause prefix?? */ -#define KBD_overflow 0x00 /* Overflow of some kind */ -#define KBD_overrun 0xFF /* KBD buffer overrun */ +#define PORT_8042 0x60 /* Port scan codes come in on */ +#define KBD_SCAN_CODE_PORT 0x60 +#define KBD_resend 0xFE /* KBD asked for resend */ +#define KBD_ack 0xFA /* KBD ack's our command */ +#define KBD_echo_response 0xEE /* KBD responds to echo req */ +#define KBD_failure 0xFD /* Failure code */ +#define KBD_prefix 0xE0 /* Prefix for extended chars */ +#define KBD_pause_prefix 0xE1 /* Pause prefix?? */ +#define KBD_overflow 0x00 /* Overflow of some kind */ +#define KBD_overrun 0xFF /* KBD buffer overrun */ +#define KBD_STATUS_PORT 0x64 /* Port KBD status comes in on */ +#define KBD_INP_FULL 0x02 /* input buffer full */ -#define KBD_STATUS_PORT 0x64 /* Port KBD status comes in on */ -#define KBD_INP_FULL 0x02 /* input buffer full */ +#define INTA00 0x20 /* The 8259 port, to reset irq */ +#define ENDOFINTERRUPT 0x20 +#define PRTSC_KEY 0x37 /* Keyboard codes for extended chars */ +#define HOME_KEY 0x47 +#define UPARROW_KEY 0x48 +#define PGUP_KEY 0x49 +#define LEFTARROW_KEY 0x4b +#define RIGHTARROW_KEY 0x4d +#define END_KEY 0x4f +#define DOWNARROW_KEY 0x50 +#define PGDOWN_KEY 0x51 +#define INS_KEY 0x52 +#define DEL_KEY 0x53 -#define INTA00 0x20 /* The 8259 port, to reset irq */ -#define ENDOFINTERRUPT 0x20 - -#define PRTSC_KEY 0x37 /* Keyboard codes for extended chars */ -#define HOME_KEY 0x47 -#define UPARROW_KEY 0x48 -#define PGUP_KEY 0x49 -#define LEFTARROW_KEY 0x4b -#define RIGHTARROW_KEY 0x4d -#define END_KEY 0x4f -#define DOWNARROW_KEY 0x50 -#define PGDOWN_KEY 0x51 -#define INS_KEY 0x52 -#define DEL_KEY 0x53 - - /******************************************************/ - /* Tell the Interrupt-dispatch IC we're done, and */ - /* Tell the keyboard itself that we're ready again. */ - /* */ - /* (This process is critical to the proper function */ - /* of the handler, so let's do it once, correctly.) */ - /******************************************************/ -#define ENABLE_KBD \ - { \ - outp(INTA00, ENDOFINTERRUPT); \ - outp( KBD_COMMAND_PORT, KBD_ENABLE); /* Turn kbd on again. */ \ +/******************************************************/ +/* Tell the Interrupt-dispatch IC we're done, and */ +/* Tell the keyboard itself that we're ready again. */ +/* */ +/* (This process is critical to the proper function */ +/* of the handler, so let's do it once, correctly.) */ +/******************************************************/ +#define ENABLE_KBD \ + { \ + outp(INTA00, ENDOFINTERRUPT); \ + outp(KBD_COMMAND_PORT, KBD_ENABLE); /* Turn kbd on again. */ \ } - - /************************************************************************/ /* */ /* K B D _ E V E N T */ @@ -115,149 +106,138 @@ extern DLword *DisplayRegion68k; #pragma interrupt(Kbd_event) -void Kbd_event() - { - - _XSTACK *ebp; /* Real-mode handler stack frame */ - DLword w,r; - KBEVENT *kbevent; - unsigned char keycode, tmpkey; +void Kbd_event() { + _XSTACK *ebp; /* Real-mode handler stack frame */ + DLword w, r; + KBEVENT *kbevent; + unsigned char keycode, tmpkey; - ebp = (_XSTACK *) _get_stk_frame(); /* Get stack frame address */ - ebp->opts |= _STK_NOINT; /* Bypass real-mode handler */ + ebp = (_XSTACK *)_get_stk_frame(); /* Get stack frame address */ + ebp->opts |= _STK_NOINT; /* Bypass real-mode handler */ - /*************************************************/ - /* First, get the scan code from the keyboard. */ - /* Handle exceptional conditions & errors, and */ - /* the extended-character prefix, 0xE0 */ - /* generated for, e.g., the INSERT key. */ - /*************************************************/ + /*************************************************/ + /* First, get the scan code from the keyboard. */ + /* Handle exceptional conditions & errors, and */ + /* the extended-character prefix, 0xE0 */ + /* generated for, e.g., the INSERT key. */ + /*************************************************/ - _disable(); /* prevent further interrupts from killing us */ - outp( KBD_COMMAND_PORT, KBD_DISABLE); /* Turn the kbd off. */ - do { tmpkey = inp( KBD_STATUS_PORT); } while (tmpkey & KBD_INP_FULL); - - /* Finite state machine that either returns or goes to label handle: */ - switch ( tmpkey = inp( KBD_SCAN_CODE_PORT ) ) - { - case KBD_overflow: /* Ignore these. */ - case KBD_pause_prefix: - case KBD_echo_response: - case KBD_ack: - case KBD_failure: - case KBD_resend: - case KBD_overrun: ENABLE_KBD; - return; - break; + _disable(); /* prevent further interrupts from killing us */ + outp(KBD_COMMAND_PORT, KBD_DISABLE); /* Turn the kbd off. */ + do { tmpkey = inp(KBD_STATUS_PORT); } while (tmpkey & KBD_INP_FULL); - case KBD_prefix: /* It's a prefix, so really use next char. */ - /* Remember that we saw the prefix: */ - currentkbd->lastbyte = tmpkey; - ENABLE_KBD; - return; - break; + /* Finite state machine that either returns or goes to label handle: */ + switch (tmpkey = inp(KBD_SCAN_CODE_PORT)) { + case KBD_overflow: /* Ignore these. */ + case KBD_pause_prefix: + case KBD_echo_response: + case KBD_ack: + case KBD_failure: + case KBD_resend: + case KBD_overrun: + ENABLE_KBD; + return; + break; - default: tmpkey = inp( KBD_SCAN_CODE_PORT ); - if (currentkbd->lastbyte == KBD_prefix) - switch (tmpkey) /* deal with prefixed characters */ - { - case 0x2A: /* by ignoring some (what are they??) */ - case 0xAA: - case 0xB6: - case 0x36: ENABLE_KBD; - return; - break; + case KBD_prefix: /* It's a prefix, so really use next char. */ + /* Remember that we saw the prefix: */ + currentkbd->lastbyte = tmpkey; + ENABLE_KBD; + return; + break; - default: /* and passing the rest thru as-is */ - currentkbd->lastbyte = tmpkey; /* Set the state. */ - goto handle; - break; - } - else - { - currentkbd->lastbyte = tmpkey; /* Set the state. */ - goto handle; - } + default: + tmpkey = inp(KBD_SCAN_CODE_PORT); + if (currentkbd->lastbyte == KBD_prefix) + switch (tmpkey) /* deal with prefixed characters */ + { + case 0x2A: /* by ignoring some (what are they??) */ + case 0xAA: + case 0xB6: + case 0x36: + ENABLE_KBD; + return; + break; + + default: /* and passing the rest thru as-is */ + currentkbd->lastbyte = tmpkey; /* Set the state. */ + goto handle; + break; + } + else { + currentkbd->lastbyte = tmpkey; /* Set the state. */ + goto handle; } + } - return; /* Don't have anything to handle yet, so just return */ + return; /* Don't have anything to handle yet, so just return */ - /*****************************************************/ - /* Second, translate the scan code into a LISP key */ - /* transition, add it to the ring buffer, and set */ - /* the interrupt-request flags so lisp sees it. */ - /*****************************************************/ - handle: +/*****************************************************/ +/* Second, translate the scan code into a LISP key */ +/* transition, add it to the ring buffer, and set */ +/* the interrupt-request flags so lisp sees it. */ +/*****************************************************/ +handle: /* The upflag is the eight bit in the char ie. upflag = currentkbd->lastbyte >> 7 */ /* The event is the lower seven bits of the byte */ - keycode=currentkbd->KeyMap[currentkbd->lastbyte & 0x7f]; + keycode = currentkbd->KeyMap[currentkbd->lastbyte & 0x7f]; - if(keycode !=0xff) - { - if( keycode < 64 ) - { - PUTBASEBIT68K( &(IOPage68K->dlkbdad0), keycode, - (currentkbd->lastbyte >> 7)&1 ); - } - else if( keycode >= 80 ) - { - PUTBASEBIT68K( &(IOPage68K->dlkbdad0), keycode-16, - (currentkbd->lastbyte >> 7)&1); - } - else - { - PUTBASEBIT68K( &(IOPage68K->dlutilin), (keycode & 0xf), - (currentkbd->lastbyte >> 7)&1 ); - PUTBASEBIT68K( &(InterfacePage->fakemousebits), (keycode & 0xf), - (currentkbd->lastbyte >> 7)&1 ); - } + if (keycode != 0xff) { + if (keycode < 64) { + PUTBASEBIT68K(&(IOPage68K->dlkbdad0), keycode, (currentkbd->lastbyte >> 7) & 1); + } else if (keycode >= 80) { + PUTBASEBIT68K(&(IOPage68K->dlkbdad0), keycode - 16, (currentkbd->lastbyte >> 7) & 1); + } else { + PUTBASEBIT68K(&(IOPage68K->dlutilin), (keycode & 0xf), (currentkbd->lastbyte >> 7) & 1); + PUTBASEBIT68K(&(InterfacePage->fakemousebits), (keycode & 0xf), + (currentkbd->lastbyte >> 7) & 1); } + } - /* In DOS we can't enter uraid inside an exception handler. */ - /* Uraid may touch a swapped out address and that dumps Medley */ - if(((IOPage68K->dlkbdad2 & 2113) == 0) || /* Ctrl-shift-NEXT */ - ((IOPage68K->dlkbdad2 & 2114) == 0)) - { /* Ctrl-shift-DEL */ - currentkbd->URaid = TRUE; /* Tell the dispatch loop about it. */ - return; - } - - r=CTopKeyevent->ring.vectorindex.read; - w=CTopKeyevent->ring.vectorindex.write; - - if(r!=w) - { - kbevent=(KBEVENT*)((DLword *)CTopKeyevent + w); - /* Copy the Hardware bits. */ - kbevent->W0= IOPage68K->dlkbdad0; - kbevent->W1= IOPage68K->dlkbdad1; - kbevent->W2= IOPage68K->dlkbdad2; - kbevent->W3= IOPage68K->dlkbdad3; - kbevent->W4= IOPage68K->dlkbdad4; - kbevent->W5= IOPage68K->dlkbdad5; - kbevent->WU= IOPage68K->dlutilin; - - /* If queue was empty, update the read pointer */ - if(r==0) CTopKeyevent->ring.vectorindex.read=w; - - /* Update the write pointer */ - if(w >= currentkbd->maxkeyevent) CTopKeyevent->ring.vectorindex.write = MINKEYEVENT; - else CTopKeyevent->ring.vectorindex.write += currentkbd->keyeventsize; - } - if(*KEYBUFFERING68k ==NIL) *KEYBUFFERING68k=ATOM_T; - - KBDEventFlg++; - Irq_Stk_End=0; - Irq_Stk_Check=0; - - ENABLE_KBD; + /* In DOS we can't enter uraid inside an exception handler. */ + /* Uraid may touch a swapped out address and that dumps Medley */ + if (((IOPage68K->dlkbdad2 & 2113) == 0) || /* Ctrl-shift-NEXT */ + ((IOPage68K->dlkbdad2 & 2114) == 0)) { /* Ctrl-shift-DEL */ + currentkbd->URaid = TRUE; /* Tell the dispatch loop about it. */ return; + } + + r = CTopKeyevent->ring.vectorindex.read; + w = CTopKeyevent->ring.vectorindex.write; + + if (r != w) { + kbevent = (KBEVENT *)((DLword *)CTopKeyevent + w); + /* Copy the Hardware bits. */ + kbevent->W0 = IOPage68K->dlkbdad0; + kbevent->W1 = IOPage68K->dlkbdad1; + kbevent->W2 = IOPage68K->dlkbdad2; + kbevent->W3 = IOPage68K->dlkbdad3; + kbevent->W4 = IOPage68K->dlkbdad4; + kbevent->W5 = IOPage68K->dlkbdad5; + kbevent->WU = IOPage68K->dlutilin; + + /* If queue was empty, update the read pointer */ + if (r == 0) CTopKeyevent->ring.vectorindex.read = w; + + /* Update the write pointer */ + if (w >= currentkbd->maxkeyevent) + CTopKeyevent->ring.vectorindex.write = MINKEYEVENT; + else + CTopKeyevent->ring.vectorindex.write += currentkbd->keyeventsize; + } + if (*KEYBUFFERING68k == NIL) *KEYBUFFERING68k = ATOM_T; + + KBDEventFlg++; + Irq_Stk_End = 0; + Irq_Stk_Check = 0; + + ENABLE_KBD; + return; } extern u_char DOSLispKeyMap_101[]; - /************************************************************************/ /* */ /* E X I T D O S K B D */ @@ -266,32 +246,29 @@ extern u_char DOSLispKeyMap_101[]; /* normal DOS handler. */ /************************************************************************/ -ExitDosKbd(kbd) - KbdInterface kbd; - { - if (kbd->device.active == TRUE) - { - kbd->device.active = FALSE; +ExitDosKbd(kbd) KbdInterface kbd; +{ + if (kbd->device.active == TRUE) { + kbd->device.active = FALSE; - _dpmi_unlockregion((void *)¤tkbd, sizeof(currentkbd)); - _dpmi_unlockregion((void *)kbd, sizeof(*kbd)); - _dpmi_unlockregion((void *)&InterfacePage, sizeof(InterfacePage)); - _dpmi_unlockregion((void *)InterfacePage, sizeof(IFPAGE)); - _dpmi_unlockregion((void *)&IOPage68K, sizeof(IOPage68K)); - _dpmi_unlockregion((void *)IOPage68K, sizeof(IOPAGE)); + _dpmi_unlockregion((void *)¤tkbd, sizeof(currentkbd)); + _dpmi_unlockregion((void *)kbd, sizeof(*kbd)); + _dpmi_unlockregion((void *)&InterfacePage, sizeof(InterfacePage)); + _dpmi_unlockregion((void *)InterfacePage, sizeof(IFPAGE)); + _dpmi_unlockregion((void *)&IOPage68K, sizeof(IOPage68K)); + _dpmi_unlockregion((void *)IOPage68K, sizeof(IOPAGE)); - _dpmi_unlockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); - _dpmi_unlockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); + _dpmi_unlockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); + _dpmi_unlockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); - _dpmi_unlockregion((void *)&MachineState, sizeof(MachineState)); - _dpmi_unlockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); - _dpmi_unlockregion((void *)&ExitDosKbd, 4096); - _dpmi_unlockregion((void *)&Kbd_event, 4096); + _dpmi_unlockregion((void *)&MachineState, sizeof(MachineState)); + _dpmi_unlockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); + _dpmi_unlockregion((void *)&ExitDosKbd, 4096); + _dpmi_unlockregion((void *)&Kbd_event, 4096); - _dos_setvect(0x09, kbd->prev_handler); /* unhook our handlr, install previous*/ - } + _dos_setvect(0x09, kbd->prev_handler); /* unhook our handlr, install previous*/ } - +} /************************************************************************/ /* */ @@ -301,45 +278,43 @@ ExitDosKbd(kbd) /* */ /************************************************************************/ -EnterDosKbd(kbd) - KbdInterface kbd; - { - int i; +EnterDosKbd(kbd) KbdInterface kbd; +{ + int i; - if (kbd->device.active == FALSE) - { - kbd->device.active = TRUE; - for(i =0 ; i < 0x80; i++) - kbd->KeyMap[i] = DOSLispKeyMap_101[i]; + if (kbd->device.active == FALSE) { + kbd->device.active = TRUE; + for (i = 0; i < 0x80; i++) kbd->KeyMap[i] = DOSLispKeyMap_101[i]; - if (eurokbd) kbd->keyeventsize = EUROKEYEVENTSIZE; - else kbd->keyeventsize = NOEUROKEYEVENTSIZE; - kbd->eurokbd = eurokbd; + if (eurokbd) + kbd->keyeventsize = EUROKEYEVENTSIZE; + else + kbd->keyeventsize = NOEUROKEYEVENTSIZE; + kbd->eurokbd = eurokbd; - /* Offset of the end of the ring buffer */ - kbd->maxkeyevent = (MINKEYEVENT + (NUMBEROFKEYEVENTS * kbd->keyeventsize)); + /* Offset of the end of the ring buffer */ + kbd->maxkeyevent = (MINKEYEVENT + (NUMBEROFKEYEVENTS * kbd->keyeventsize)); - _dpmi_lockregion((void *)¤tkbd, sizeof(currentkbd)); - _dpmi_lockregion((void *)kbd, sizeof(*kbd)); - _dpmi_lockregion((void *)&InterfacePage, sizeof(InterfacePage)); - _dpmi_lockregion((void *)InterfacePage, sizeof(IFPAGE)); - _dpmi_lockregion((void *)&IOPage68K, sizeof(IOPage68K)); - _dpmi_lockregion((void *)IOPage68K, sizeof(IOPAGE)); - _dpmi_lockregion((void *)&MachineState, sizeof(MachineState)); + _dpmi_lockregion((void *)¤tkbd, sizeof(currentkbd)); + _dpmi_lockregion((void *)kbd, sizeof(*kbd)); + _dpmi_lockregion((void *)&InterfacePage, sizeof(InterfacePage)); + _dpmi_lockregion((void *)InterfacePage, sizeof(IFPAGE)); + _dpmi_lockregion((void *)&IOPage68K, sizeof(IOPage68K)); + _dpmi_lockregion((void *)IOPage68K, sizeof(IOPAGE)); + _dpmi_lockregion((void *)&MachineState, sizeof(MachineState)); - _dpmi_lockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); - _dpmi_lockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); + _dpmi_lockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); + _dpmi_lockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); - _dpmi_lockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); - _dpmi_lockregion((void *)&ExitDosKbd , 4096); - _dpmi_lockregion((void *)&Kbd_event, 4096); + _dpmi_lockregion((void *)&KEYBUFFERING68k, sizeof(KEYBUFFERING68k)); + _dpmi_lockregion((void *)&ExitDosKbd, 4096); + _dpmi_lockregion((void *)&Kbd_event, 4096); - /* Don't hook in our handler if the user flagged he wants to run */ - /* without a kbd. */ - if (!nokbdflag) - { - kbd->prev_handler = _dos_getvect(0x09); /* get addr of currnt 09 hndlr */ - _dos_setvect(0x09, kbd->device_event); /* hook our int handler to interrupt */ - } - } + /* Don't hook in our handler if the user flagged he wants to run */ + /* without a kbd. */ + if (!nokbdflag) { + kbd->prev_handler = _dos_getvect(0x09); /* get addr of currnt 09 hndlr */ + _dos_setvect(0x09, kbd->device_event); /* hook our int handler to interrupt */ + } } +} diff --git a/src/dosmouse.c b/src/dosmouse.c old mode 100755 new mode 100644 index 07bc340..cd4de8f --- a/src/dosmouse.c +++ b/src/dosmouse.c @@ -1,8 +1,7 @@ -/* $Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -16,15 +15,11 @@ static char *id = "$Id: dosmouse.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copy /* */ /************************************************************************/ - #include "version.h" - - - -#include /* Defines "#pragma interrupt" */ -#include /* _XSTACK struct definition */ -#include /* Defines REGS & other structs */ +#include /* Defines "#pragma interrupt" */ +#include /* _XSTACK struct definition */ +#include /* Defines REGS & other structs */ #include "lispemul.h" #include "display.h" @@ -46,20 +41,19 @@ extern KbdInterface currentkbd; extern keybuffer *CTopKeyevent; extern DLword *DisplayRegion68k; -extern DLword *Lisp_world ; +extern DLword *Lisp_world; extern LispPTR *KEYBOARDEVENTQUEUE68k; extern LispPTR *KEYBUFFERING68k; extern LispPTR *LASTUSERACTION68k; -#define MOUSE_MV 0x01 /* Mouse movement occurred */ -#define LB_PRESS 0x02 /* Left button pressed */ -#define LB_OFF 0x04 /* Left button released */ -#define RB_PRESS 0x08 /* Right button pressed */ -#define RB_OFF 0x10 /* Right button released */ -#define CB_PRESS 0x20 /* Center button released */ -#define CB_OFF 0x40 /* Center button pressed */ - +#define MOUSE_MV 0x01 /* Mouse movement occurred */ +#define LB_PRESS 0x02 /* Left button pressed */ +#define LB_OFF 0x04 /* Left button released */ +#define RB_PRESS 0x08 /* Right button pressed */ +#define RB_OFF 0x10 /* Right button released */ +#define CB_PRESS 0x20 /* Center button released */ +#define CB_OFF 0x40 /* Center button pressed */ #pragma interrupt(TwoButtonHandler) #pragma interrupt(ThreeButtonHandler) @@ -67,26 +61,23 @@ extern LispPTR *LASTUSERACTION68k; void ButtonTimer(); void MouseButtonSignal(); - - - - -void EnterDosMouse(mouse, dsp) - MouseInterface mouse; - DspInterface dsp; +void EnterDosMouse(mouse, dsp) MouseInterface mouse; +DspInterface dsp; { union REGS regs; probemouse(); _dpmi_lockregion((void *)&MouseButtonSignal, 4096); /* Set up the ringbuffer */ - if (eurokbd) mouse->keyeventsize = EUROKEYEVENTSIZE; - else mouse->keyeventsize = NOEUROKEYEVENTSIZE; + if (eurokbd) + mouse->keyeventsize = EUROKEYEVENTSIZE; + else + mouse->keyeventsize = NOEUROKEYEVENTSIZE; mouse->eurokbd = eurokbd; /* Offset of the end of the ring buffer */ - mouse->maxkeyevent = (MINKEYEVENT + (NUMBEROFKEYEVENTS * mouse->keyeventsize)); + mouse->maxkeyevent = (MINKEYEVENT + (NUMBEROFKEYEVENTS * mouse->keyeventsize)); /* Lock myself */ _dpmi_lockregion((void *)mouse, sizeof(*mouse)); @@ -95,9 +86,7 @@ void EnterDosMouse(mouse, dsp) /* Lock the handler routines */ _dpmi_lockregion((void *)mouse->Handler, 4096); - if(mouse->Button.TwoButtonP) { - _dpmi_lockregion((void *)&ButtonTimer, 4096); - } + if (mouse->Button.TwoButtonP) { _dpmi_lockregion((void *)&ButtonTimer, 4096); } /* Lock the structures used, both pointers to 'em & the whole structure. */ _dpmi_lockregion((void *)&IOPage68K, sizeof(IOPage68K)); @@ -123,49 +112,47 @@ void EnterDosMouse(mouse, dsp) _dpmi_lockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); /* Now Lock the lastuseraction machine. */ -/* _dpmi_lockregion(mouse->timestamp, sizeof(LispPTR)); */ /* Lisp_world itself */ + /* _dpmi_lockregion(mouse->timestamp, sizeof(LispPTR)); */ /* Lisp_world itself */ - regs.w.eax = 0x0001; /* Function 1 = turn on mouse cursor */ + regs.w.eax = 0x0001; /* Function 1 = turn on mouse cursor */ int86(0x33, ®s, ®s); - regs.w.eax = 0x0002; /* Function 2 = hide mouse cursor */ + regs.w.eax = 0x0002; /* Function 2 = hide mouse cursor */ int86(0x33, ®s, ®s); - regs.w.eax = 0x0C; /* Function 0C = set user-defined mouse handler */ - regs.w.ecx = LB_PRESS | LB_OFF | CB_PRESS | CB_OFF | RB_PRESS | RB_OFF | MOUSE_MV ; + regs.w.eax = 0x0C; /* Function 0C = set user-defined mouse handler */ + regs.w.ecx = LB_PRESS | LB_OFF | CB_PRESS | CB_OFF | RB_PRESS | RB_OFF | MOUSE_MV; regs.w.edx = FP_OFF(*(mouse->Handler)); /* Address of our mouse handler routine */ - int86(0x33, ®s, ®s); /* Install our handler to process events */ + int86(0x33, ®s, ®s); /* Install our handler to process events */ if (regs.w.eax == 'MERR') VESA_errorexit("Unable to install mouse handler - not enough low memory.\n", -1); - regs.x.ax = 0x7; /* Set mouse horizontal range */ + regs.x.ax = 0x7; /* Set mouse horizontal range */ regs.x.cx = 0x0; - regs.x.dx = (short)( dsp->Display.width - 1); + regs.x.dx = (short)(dsp->Display.width - 1); int86(0x33, ®s, ®s); - regs.x.ax = 0x8; /* Set mouse vertical range */ + regs.x.ax = 0x8; /* Set mouse vertical range */ regs.x.cx = 0x0; - regs.x.dx = (short)( dsp->Display.height - 1 ); + regs.x.dx = (short)(dsp->Display.height - 1); int86(0x33, ®s, ®s); /* See if turning this off fixes the "mouse granularity" problem */ /* Nope. It didn't. */ - regs.x.ax = 0xf; /* Set mickey per pixel range */ + regs.x.ax = 0xf; /* Set mickey per pixel range */ regs.x.cx = 0x8; regs.x.dx = 0x8; int86(0x33, ®s, ®s); mouse->Button.NextHandler = _dos_getvect(0x1c); _dos_setvect(0x1c, ButtonTimer); - + mouse->device.active = TRUE; } -void ExitDosMouse(mouse) - MouseInterface mouse; +void ExitDosMouse(mouse) MouseInterface mouse; { - - if( mouse->device.active ){ + if (mouse->device.active) { /* Unlock myself */ _dpmi_unlockregion((void *)mouse, sizeof(*mouse)); _dpmi_unlockregion((void *)¤tmouse, sizeof(currentmouse)); @@ -175,7 +162,6 @@ void ExitDosMouse(mouse) _dpmi_unlockregion((void *)&ButtonTimer, 4096); _dpmi_unlockregion((void *)&MouseButtonSignal, 4096); - /* Unlock the structures used. */ _dpmi_unlockregion((void *)&IOPage68K, sizeof(IOPage68K)); _dpmi_unlockregion((void *)&InterfacePage, sizeof(InterfacePage)); @@ -195,41 +181,35 @@ void ExitDosMouse(mouse) _dpmi_unlockregion((void *)&CTopKeyevent, sizeof(CTopKeyevent)); _dpmi_unlockregion((void *)CTopKeyevent, sizeof(*CTopKeyevent)); -/* _dpmi_unlockregion(mouse->timestamp, sizeof(LispPTR)); */ + /* _dpmi_unlockregion(mouse->timestamp, sizeof(LispPTR)); */ _dos_setvect(0x1c, mouse->Button.NextHandler); mouse->device.active = FALSE; } } -void DosMouseAfterRaid(mouse, dsp) - MouseInterface mouse; - DspInterface dsp; +void DosMouseAfterRaid(mouse, dsp) MouseInterface mouse; +DspInterface dsp; { union REGS regs; /* Screen mode changed. We have to reinit the ranges. */ - regs.x.ax = 0x7; /* Set mouse horizontal range */ + regs.x.ax = 0x7; /* Set mouse horizontal range */ regs.x.cx = 0x0; - regs.x.dx = (short)( dsp->Display.width - 1); + regs.x.dx = (short)(dsp->Display.width - 1); int86(0x33, ®s, ®s); - regs.x.ax = 0x8; /* Set mouse vertical range */ + regs.x.ax = 0x8; /* Set mouse vertical range */ regs.x.cx = 0x0; - regs.x.dx = (short)( dsp->Display.height - 1 ); + regs.x.dx = (short)(dsp->Display.height - 1); int86(0x33, ®s, ®s); mouse->device.active = TRUE; } -void DosMouseBeforeRaid(mouse, dsp) - MouseInterface mouse; - DspInterface dsp; -{ - mouse->device.active = FALSE; -} - - +void DosMouseBeforeRaid(mouse, dsp) MouseInterface mouse; +DspInterface dsp; +{ mouse->device.active = FALSE; } /***************************************************************/ /* d o s _ c u r s o r _ i n v i s s i b l e */ @@ -237,17 +217,10 @@ void DosMouseBeforeRaid(mouse, dsp) /* and not to the emulator displaybuffer we can make the cursor*/ /* invissible just by updateing the area under the cursor! */ /***************************************************************/ -void dos_cursor_invissible(dsp, iop) - DspInterface dsp; - IOPAGE *iop; +void dos_cursor_invissible(dsp, iop) DspInterface dsp; +IOPAGE *iop; -{ - (dsp->bitblt_to_screen) (dsp, - DisplayRegion68k, - iop->dlcursorx, - iop->dlcursory, - 16, 16); -} +{ (dsp->bitblt_to_screen)(dsp, DisplayRegion68k, iop->dlcursorx, iop->dlcursory, 16, 16); } /***************************************************************/ /* d o s _ c u r s o r _ v i s s i b l e */ @@ -263,10 +236,8 @@ void dos_cursor_invissible(dsp, iop) /* */ /***************************************************************/ - -set_DOSmouseposition(dsp, x, y) - DspInterface dsp; - int x, y; +set_DOSmouseposition(dsp, x, y) DspInterface dsp; +int x, y; { union REGS regs; @@ -276,7 +247,7 @@ set_DOSmouseposition(dsp, x, y) #ifdef NEVER /* int 33h, case 0004, cx=col, dx = row */ - regs.w.eax = 4; /* Function 4 = move cursor */ + regs.w.eax = 4; /* Function 4 = move cursor */ regs.w.ecx = x; regs.w.edx = y; int86(0x33, ®s, ®s); @@ -286,79 +257,77 @@ set_DOSmouseposition(dsp, x, y) IOPage68K->dlmousex = x; IOPage68K->dlmousey = y; -/* *(currentmouse->timestamp) = MiscStats->secondstmp; */ + /* *(currentmouse->timestamp) = MiscStats->secondstmp; */ - (currentdsp->mouse_invissible)( currentdsp, IOPage68K ); + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); currentmouse->Cursor.New.x = IOPage68K->dlcursorx = x; currentmouse->Cursor.New.y = IOPage68K->dlcursory = y; - (currentdsp->mouse_vissible)( x, y ); + (currentdsp->mouse_vissible)(x, y); dsp->device.locked--; currentmouse->device.active--; } -void docopy(newx, newy) - int newx, newy; +void docopy(newx, newy) int newx, newy; { - register DLword *srcbase, *dstbase; - static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + register DLword *srcbase, *dstbase; + static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; srcbase = IOPage68K->dlcursorbitmap; - dstbase= DisplayRegion68k + ( newy * currentdsp->Display.width/16) ; + dstbase = DisplayRegion68k + (newy * currentdsp->Display.width / 16); sx = 0; dx = newx; w = currentmouse->Cursor.Last.width; h = currentmouse->Cursor.Last.height; srcbpl = 16; dstbpl = currentdsp->Display.width; - op = 2; /* OR-in */ + op = 2; /* OR-in */ #ifdef NEWBITBLT - bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, - src_comp, 2, 0, 0, 0); + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, 2, 0, 0, 0); #else - new_bitblt_code; + new_bitblt_code; #endif /* NEWBITBLT */ } - -dostaking_mouse_up(newx, newy) - int newx, newy; +dostaking_mouse_up(newx, newy) int newx, newy; { /* save hidden bitmap */ - register DLword *srcbase, *dstbase; - static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + register DLword *srcbase, *dstbase; + static int sx, dx, w = 16, h = 16, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; /* newx and newy are hotspot coordinates. */ /* newx -= currentmouse->Cursor.Hotspot.x; */ /* newy -= ( 15 - currentmouse->Cursor.Hotspot.y); */ - /* save image */ - srcbase = DisplayRegion68k + ( newy * currentdsp->Display.width/16); + srcbase = DisplayRegion68k + (newy * currentdsp->Display.width / 16); dstbase = currentmouse->Cursor.Savebitmap; sx = newx; dx = 0; - if( currentdsp->Display.width < (newx + 16)) - { currentmouse->Cursor.Last.width = w = currentdsp->Display.width-newx; } - else { currentmouse->Cursor.Last.width = w = 16; }; + if (currentdsp->Display.width < (newx + 16)) { + currentmouse->Cursor.Last.width = w = currentdsp->Display.width - newx; + } else { + currentmouse->Cursor.Last.width = w = 16; + }; - if(currentdsp->Display.height < (newy + 16)) - { currentmouse->Cursor.Last.height = h = currentdsp->Display.height - newy;} - else - { currentmouse->Cursor.Last.height = h = 16;}; + if (currentdsp->Display.height < (newy + 16)) { + currentmouse->Cursor.Last.height = h = currentdsp->Display.height - newy; + } else { + currentmouse->Cursor.Last.height = h = 16; + }; srcbpl = currentdsp->Display.width; dstbpl = 16; - op= 0; /* replace */ + op = 0; /* replace */ #ifdef NEWBITBLT - bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, - src_comp, 0, gray, num_gray, curr_gray_line); + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, 0, gray, num_gray, + curr_gray_line); #else new_bitblt_code; #endif /* NEWBITBLT */ @@ -369,46 +338,39 @@ dostaking_mouse_up(newx, newy) currentmouse->Cursor.Last.x = newx; currentmouse->Cursor.Last.y = newy; - (currentdsp->bitblt_to_screen) - (currentdsp, DisplayRegion68k, - currentmouse->Cursor.Last.x, - currentmouse->Cursor.Last.y, w, h); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, currentmouse->Cursor.Last.x, + currentmouse->Cursor.Last.y, w, h); } -dostaking_mouse_down(dsp, iop) - DspInterface dsp; - IOPAGE *iop; +dostaking_mouse_down(dsp, iop) DspInterface dsp; +IOPAGE *iop; { - register DLword *srcbase, *dstbase; - static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; - /* restore saved image */ - srcbase = currentmouse->Cursor.Savebitmap; - dstbase = DisplayRegion68k + ( (currentmouse->Cursor.Last.y) * (dsp->Display.width/16)); /* old y */ - sx = 0; - dx = currentmouse->Cursor.Last.x; /* old x */ - w = currentmouse->Cursor.Last.width; - h = currentmouse->Cursor.Last.height; - srcbpl = 16; - dstbpl = dsp->Display.width; - op=0; + /* restore saved image */ + srcbase = currentmouse->Cursor.Savebitmap; + dstbase = + DisplayRegion68k + ((currentmouse->Cursor.Last.y) * (dsp->Display.width / 16)); /* old y */ + sx = 0; + dx = currentmouse->Cursor.Last.x; /* old x */ + w = currentmouse->Cursor.Last.width; + h = currentmouse->Cursor.Last.height; + srcbpl = 16; + dstbpl = dsp->Display.width; + op = 0; #ifdef NEWBITBLT - bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, - src_comp, 0, 0, 0, 0); + bitblt(srcbase, dstbase, sx, dx, w, h, srcbpl, dstbpl, backwardflg, src_comp, 0, 0, 0, 0); #else - new_bitblt_code; + new_bitblt_code; #endif /* NEWBITBLT */ - (dsp->bitblt_to_screen) - (dsp, DisplayRegion68k, - currentmouse->Cursor.Last.x, - currentmouse->Cursor.Last.y, w, h); + (dsp->bitblt_to_screen)(dsp, DisplayRegion68k, currentmouse->Cursor.Last.x, + currentmouse->Cursor.Last.y, w, h); } - - /************************************************************************/ /* */ /* M o u s e B u t t o n S i g n a l */ @@ -419,51 +381,49 @@ dostaking_mouse_down(dsp, iop) /* */ /************************************************************************/ -void MouseButtonSignal(mouse) - MouseInterface mouse; - { - DLword w,r; - KBEVENT *kbevent; +void MouseButtonSignal(mouse) MouseInterface mouse; +{ + DLword w, r; + KBEVENT *kbevent; - /* In the mouse device TRUE means button pressed */ - /* In the IOPage 0 means button pressed */ - /* Hence the ! in the lines below. */ - PUTBASEBIT68K( &(IOPage68K->dlutilin), MOUSE_LEFT, !mouse->Button.Left); - PUTBASEBIT68K( &(IOPage68K->dlutilin), MOUSE_MIDDLE, !mouse->Button.Middle); - PUTBASEBIT68K( &(IOPage68K->dlutilin), MOUSE_RIGHT, !mouse->Button.Right); + /* In the mouse device TRUE means button pressed */ + /* In the IOPage 0 means button pressed */ + /* Hence the ! in the lines below. */ + PUTBASEBIT68K(&(IOPage68K->dlutilin), MOUSE_LEFT, !mouse->Button.Left); + PUTBASEBIT68K(&(IOPage68K->dlutilin), MOUSE_MIDDLE, !mouse->Button.Middle); + PUTBASEBIT68K(&(IOPage68K->dlutilin), MOUSE_RIGHT, !mouse->Button.Right); - r=CTopKeyevent->ring.vectorindex.read; - w=CTopKeyevent->ring.vectorindex.write; - - if(r!=w) - { - kbevent=(KBEVENT*)((DLword *)CTopKeyevent+ w); + r = CTopKeyevent->ring.vectorindex.read; + w = CTopKeyevent->ring.vectorindex.write; - /* Copy the Hardware bits. */ - kbevent->W0= IOPage68K->dlkbdad0; - kbevent->W1= IOPage68K->dlkbdad1; - kbevent->W2= IOPage68K->dlkbdad2; - kbevent->W3= IOPage68K->dlkbdad3; - kbevent->W4= IOPage68K->dlkbdad4; - kbevent->W5= IOPage68K->dlkbdad5; - kbevent->WU= IOPage68K->dlutilin; + if (r != w) { + kbevent = (KBEVENT *)((DLword *)CTopKeyevent + w); - /* If queue was empty, update the read pointer */ - if(r==0) CTopKeyevent->ring.vectorindex.read=w; + /* Copy the Hardware bits. */ + kbevent->W0 = IOPage68K->dlkbdad0; + kbevent->W1 = IOPage68K->dlkbdad1; + kbevent->W2 = IOPage68K->dlkbdad2; + kbevent->W3 = IOPage68K->dlkbdad3; + kbevent->W4 = IOPage68K->dlkbdad4; + kbevent->W5 = IOPage68K->dlkbdad5; + kbevent->WU = IOPage68K->dlutilin; - /* Update the write pointer */ - if(w >= mouse->maxkeyevent) CTopKeyevent->ring.vectorindex.write = MINKEYEVENT; - else CTopKeyevent->ring.vectorindex.write += mouse->keyeventsize; - } + /* If queue was empty, update the read pointer */ + if (r == 0) CTopKeyevent->ring.vectorindex.read = w; - if(*KEYBUFFERING68k ==NIL) *KEYBUFFERING68k=ATOM_T; - - KBDEventFlg++; /* Signal the emulator to tell Lisp */ - Irq_Stk_Check = 0; - Irq_Stk_End = 0; + /* Update the write pointer */ + if (w >= mouse->maxkeyevent) + CTopKeyevent->ring.vectorindex.write = MINKEYEVENT; + else + CTopKeyevent->ring.vectorindex.write += mouse->keyeventsize; } + if (*KEYBUFFERING68k == NIL) *KEYBUFFERING68k = ATOM_T; + KBDEventFlg++; /* Signal the emulator to tell Lisp */ + Irq_Stk_Check = 0; + Irq_Stk_End = 0; +} /***************************************************************/ /* B u t t o n T i m e r */ @@ -473,46 +433,41 @@ void MouseButtonSignal(mouse) /* timeout happens. We will thus obtain the ``rubbery feeling''*/ /* that proponents of chording so desire. */ /***************************************************************/ -void ButtonTimer() - { - if(currentmouse->Button.RunTimer) - if(currentmouse->Button.tick-- <= 0) - { - currentmouse->Button.RunTimer = FALSE; /* Turn the timer off. */ - currentmouse->Button.Left |= currentmouse->Button.StateLeft; - currentmouse->Button.Right |= currentmouse->Button.StateRight; +void ButtonTimer() { + if (currentmouse->Button.RunTimer) + if (currentmouse->Button.tick-- <= 0) { + currentmouse->Button.RunTimer = FALSE; /* Turn the timer off. */ + currentmouse->Button.Left |= currentmouse->Button.StateLeft; + currentmouse->Button.Right |= currentmouse->Button.StateRight; - /* Mouse chording code. If at the end of the timeout - the left and right buttons are down we signal middle - button and bring the others up. */ - /* Are L & R down? */ + /* Mouse chording code. If at the end of the timeout + the left and right buttons are down we signal middle + button and bring the others up. */ + /* Are L & R down? */ - if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight) - { - currentmouse->Button.Left = FALSE; - currentmouse->Button.Right = FALSE; - currentmouse->Button.Middle = TRUE; - } - - currentmouse->Button.StateLeft = FALSE; - currentmouse->Button.StateRight = FALSE; - - /* Did L & R go up after a simulated M */ -/* if((currentmouse->Button.Middle && - !(currentmouse->Button.StateLeft || - currentmouse->Button.StateRight))) - { - currentmouse->Button.Left = FALSE; - currentmouse->Button.Right = FALSE; - currentmouse->Button.Middle = FALSE; - } -*/ - MouseButtonSignal(currentmouse); - } - _chain_intr(currentmouse->Button.NextHandler); - } + if (currentmouse->Button.StateLeft && currentmouse->Button.StateRight) { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = TRUE; + } + currentmouse->Button.StateLeft = FALSE; + currentmouse->Button.StateRight = FALSE; + /* Did L & R go up after a simulated M */ + /* if((currentmouse->Button.Middle && + !(currentmouse->Button.StateLeft || + currentmouse->Button.StateRight))) + { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = FALSE; + } + */ + MouseButtonSignal(currentmouse); + } + _chain_intr(currentmouse->Button.NextHandler); +} /***************************************************************/ /* T w o B u t t o n H a n d l e r */ @@ -521,141 +476,122 @@ void ButtonTimer() /* signals the dispatch loop to care of the matter. This */ /* akward solution is due to the severe braindamage in DOS. */ /***************************************************************/ -void TwoButtonHandler(void) - { - _XSTACK *stk_ptr; +void TwoButtonHandler(void) { + _XSTACK *stk_ptr; - /* First save the stack frame. */ - stk_ptr = (_XSTACK *)_get_stk_frame(); /* Get ptr to V86 _XSTACK frame */ - stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */ + /* First save the stack frame. */ + stk_ptr = (_XSTACK *)_get_stk_frame(); /* Get ptr to V86 _XSTACK frame */ + stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */ - if(!currentmouse->device.active) return; + if (!currentmouse->device.active) return; - if (stk_ptr->eax & LB_PRESS) - if (currentmouse->Button.RunTimer) /* Prior right-down seen... */ - { - currentmouse->Button.RunTimer = FALSE; - currentmouse->Button.FakeMiddle = TRUE; - currentmouse->Button.Middle = TRUE; - currentmouse->Button.StateLeft = TRUE; - MouseButtonSignal(currentmouse); - } - else if (currentmouse->Button.Right) - { - currentmouse->Button.Left = TRUE; - currentmouse->Button.StateLeft = TRUE; - MouseButtonSignal(currentmouse); - } - else /* No other button down... */ - { - currentmouse->Button.StateLeft = TRUE; - currentmouse->Button.tick = currentmouse->Button.StartTime; - currentmouse->Button.RunTimer = TRUE; - } - if (stk_ptr->eax & LB_OFF) /* Left button released, and */ - if (currentmouse->Button.RunTimer) /* Timer had been running */ - { - currentmouse->Button.RunTimer = FALSE; - currentmouse->Button.Left = TRUE; - MouseButtonSignal(currentmouse); - currentmouse->Button.StateLeft = FALSE; - /* currentmouse->Button.Left = FALSE; - MouseButtonSignal(currentmouse); */ - } - else /* timer wasn't running */ - { - currentmouse->Button.StateLeft = FALSE; - currentmouse->Button.Left = FALSE; - currentmouse->Button.FakeMiddle = FALSE; - currentmouse->Button.Middle = currentmouse->Button.StateMiddle; - MouseButtonSignal(currentmouse); - } + if (stk_ptr->eax & LB_PRESS) + if (currentmouse->Button.RunTimer) /* Prior right-down seen... */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.FakeMiddle = TRUE; + currentmouse->Button.Middle = TRUE; + currentmouse->Button.StateLeft = TRUE; + MouseButtonSignal(currentmouse); + } else if (currentmouse->Button.Right) { + currentmouse->Button.Left = TRUE; + currentmouse->Button.StateLeft = TRUE; + MouseButtonSignal(currentmouse); + } else /* No other button down... */ + { + currentmouse->Button.StateLeft = TRUE; + currentmouse->Button.tick = currentmouse->Button.StartTime; + currentmouse->Button.RunTimer = TRUE; + } + if (stk_ptr->eax & LB_OFF) /* Left button released, and */ + if (currentmouse->Button.RunTimer) /* Timer had been running */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.Left = TRUE; + MouseButtonSignal(currentmouse); + currentmouse->Button.StateLeft = FALSE; + /* currentmouse->Button.Left = FALSE; + MouseButtonSignal(currentmouse); */ + } else /* timer wasn't running */ + { + currentmouse->Button.StateLeft = FALSE; + currentmouse->Button.Left = FALSE; + currentmouse->Button.FakeMiddle = FALSE; + currentmouse->Button.Middle = currentmouse->Button.StateMiddle; + MouseButtonSignal(currentmouse); + } - if((stk_ptr->eax & CB_PRESS) || (stk_ptr->eax & CB_OFF)) - { - currentmouse->Button.Middle = ((stk_ptr->eax & CB_PRESS) && TRUE) - || currentmouse->Button.FakeMiddle; - currentmouse->Button.StateMiddle = (stk_ptr->eax & CB_PRESS) && TRUE; - currentmouse->Button.RunTimer = FALSE; - MouseButtonSignal(currentmouse); - } + if ((stk_ptr->eax & CB_PRESS) || (stk_ptr->eax & CB_OFF)) { + currentmouse->Button.Middle = + ((stk_ptr->eax & CB_PRESS) && TRUE) || currentmouse->Button.FakeMiddle; + currentmouse->Button.StateMiddle = (stk_ptr->eax & CB_PRESS) && TRUE; + currentmouse->Button.RunTimer = FALSE; + MouseButtonSignal(currentmouse); + } - if(stk_ptr->eax & RB_PRESS) /* Right button pressed, and */ - if (currentmouse->Button.RunTimer) /* Timer was running... */ - { - currentmouse->Button.RunTimer = FALSE; - currentmouse->Button.FakeMiddle = TRUE; - currentmouse->Button.Middle = TRUE; - currentmouse->Button.StateRight = TRUE; - MouseButtonSignal(currentmouse); - } - else if (currentmouse->Button.Left) - { - currentmouse->Button.Right = TRUE; - currentmouse->Button.StateRight = TRUE; - MouseButtonSignal(currentmouse); - } - else - { - currentmouse->Button.StateRight = TRUE; - currentmouse->Button.tick = currentmouse->Button.StartTime; - currentmouse->Button.RunTimer = TRUE; - } - if (stk_ptr->eax & RB_OFF) /* Right button released */ - if (currentmouse->Button.RunTimer) /* Timer had been running */ - { - currentmouse->Button.RunTimer = FALSE; - currentmouse->Button.Right = TRUE; - MouseButtonSignal(currentmouse); - currentmouse->Button.StateRight = FALSE; - /* currentmouse->Button.Right = FALSE; - MouseButtonSignal(currentmouse); */ - } - else - { - currentmouse->Button.StateRight = FALSE; - currentmouse->Button.Right = FALSE; - currentmouse->Button.FakeMiddle = FALSE; - currentmouse->Button.Middle = currentmouse->Button.StateMiddle; - MouseButtonSignal(currentmouse); - } - + if (stk_ptr->eax & RB_PRESS) /* Right button pressed, and */ + if (currentmouse->Button.RunTimer) /* Timer was running... */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.FakeMiddle = TRUE; + currentmouse->Button.Middle = TRUE; + currentmouse->Button.StateRight = TRUE; + MouseButtonSignal(currentmouse); + } else if (currentmouse->Button.Left) { + currentmouse->Button.Right = TRUE; + currentmouse->Button.StateRight = TRUE; + MouseButtonSignal(currentmouse); + } else { + currentmouse->Button.StateRight = TRUE; + currentmouse->Button.tick = currentmouse->Button.StartTime; + currentmouse->Button.RunTimer = TRUE; + } + if (stk_ptr->eax & RB_OFF) /* Right button released */ + if (currentmouse->Button.RunTimer) /* Timer had been running */ + { + currentmouse->Button.RunTimer = FALSE; + currentmouse->Button.Right = TRUE; + MouseButtonSignal(currentmouse); + currentmouse->Button.StateRight = FALSE; + /* currentmouse->Button.Right = FALSE; + MouseButtonSignal(currentmouse); */ + } else { + currentmouse->Button.StateRight = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.FakeMiddle = FALSE; + currentmouse->Button.Middle = currentmouse->Button.StateMiddle; + MouseButtonSignal(currentmouse); + } + /* The dude moved the mouse. Set the chordstate NOW. */ + /* And turn the timer off. */ + if ((stk_ptr->eax & MOUSE_MV) && (!currentdsp->device.locked)) { + currentmouse->Button.RunTimer = FALSE; - /* The dude moved the mouse. Set the chordstate NOW. */ - /* And turn the timer off. */ - if ((stk_ptr->eax & MOUSE_MV)&&(!currentdsp->device.locked)) - { - currentmouse->Button.RunTimer = FALSE; + /* Are L & R down? */ + /* if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight) + { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = TRUE; + } + */ + /* currentmouse->Cursor.New.x = (DLword)stk_ptr->ecx & 0xFFFF; + currentmouse->Cursor.New.y = (DLword)stk_ptr->edx & 0xFFFF; */ + currentmouse->Cursor.Moved = TRUE; - /* Are L & R down? */ -/* if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight) - { - currentmouse->Button.Left = FALSE; - currentmouse->Button.Right = FALSE; - currentmouse->Button.Middle = TRUE; - } -*/ - /* currentmouse->Cursor.New.x = (DLword)stk_ptr->ecx & 0xFFFF; - currentmouse->Cursor.New.y = (DLword)stk_ptr->edx & 0xFFFF; */ - currentmouse->Cursor.Moved = TRUE; + if (currentmouse->Button.StateLeft && currentmouse->Button.StateRight) { + currentmouse->Button.Left = FALSE; + currentmouse->Button.Right = FALSE; + currentmouse->Button.Middle = TRUE; + } else { + currentmouse->Button.Left |= currentmouse->Button.StateLeft; + currentmouse->Button.Right |= currentmouse->Button.StateRight; + } - if(currentmouse->Button.StateLeft && currentmouse->Button.StateRight) - { - currentmouse->Button.Left = FALSE; - currentmouse->Button.Right = FALSE; - currentmouse->Button.Middle = TRUE; - } - else - { - currentmouse->Button.Left |= currentmouse->Button.StateLeft; - currentmouse->Button.Right |= currentmouse->Button.StateRight; - } - - currentmouse->Button.StateLeft = currentmouse->Button.StateRight = FALSE; - MouseButtonSignal(currentmouse); - } - + currentmouse->Button.StateLeft = currentmouse->Button.StateRight = FALSE; + MouseButtonSignal(currentmouse); + } } /***************************************************************/ @@ -668,14 +604,14 @@ void TwoButtonHandler(void) void ThreeButtonHandler() { - _XSTACK *stk_ptr; + _XSTACK *stk_ptr; unsigned long mouse_flags; /* First save the stack frame. */ stk_ptr = (_XSTACK *)_get_stk_frame(); /* Get ptr to V86 _XSTACK frame */ - stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */ + stk_ptr->opts |= _STK_NOINT; /* Bypass real-mode handler */ - if(currentmouse->device.active){ + if (currentmouse->device.active) { mouse_flags = stk_ptr->eax; /* Save event flags from mouse driver */ /* Decode the transition bits. */ @@ -688,14 +624,13 @@ void ThreeButtonHandler() if (mouse_flags & RB_PRESS) currentmouse->Button.Right = TRUE; if (mouse_flags & RB_OFF) currentmouse->Button.Right = FALSE; - if ((!currentdsp->device.locked) && (mouse_flags & MOUSE_MV)) - { - currentmouse->Cursor.Moved = TRUE; - Irq_Stk_Check = 0; - Irq_Stk_End = 0; - } + if ((!currentdsp->device.locked) && (mouse_flags & MOUSE_MV)) { + currentmouse->Cursor.Moved = TRUE; + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + } - if (mouse_flags & (LB_PRESS|LB_OFF|CB_PRESS|CB_OFF|RB_PRESS|RB_OFF)) + if (mouse_flags & (LB_PRESS | LB_OFF | CB_PRESS | CB_OFF | RB_PRESS | RB_OFF)) MouseButtonSignal(currentmouse); } } diff --git a/src/draw.c b/src/draw.c old mode 100755 new mode 100644 index db6e5ea..c4a5aa3 --- a/src/draw.c +++ b/src/draw.c @@ -1,7 +1,6 @@ /* $Id: draw.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: draw.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* D R A W . C */ @@ -10,9 +9,6 @@ static char *id = "$Id: draw.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copyrigh /* */ /************************************************************************/ - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -25,11 +21,8 @@ static char *id = "$Id: draw.c,v 1.2 1999/01/03 02:06:56 sybalsky Exp $ Copyrigh /* */ /************************************************************************/ - #include "version.h" - - #include #ifndef NOPIXRECT @@ -64,16 +57,14 @@ extern int ScreenLocked; extern int MonoOrColor; #endif /* COLOR */ - -#ifdef DISPLAYBUFFER -LispPTR n_new_cursorin_CG6( dx, dy, w, h ) -register int dx, dy, w, h; - { - if((dx < MOUSEXR)&&(dx + w > MOUSEXL)&&(dy < MOUSEYH)&&(dy + h > MOUSEYL)) - return(T); - else - return(NIL); - } +#ifdef DISPLAYBUFFER +LispPTR n_new_cursorin_CG6(dx, dy, w, h) register int dx, dy, w, h; +{ + if ((dx < MOUSEXR) && (dx + w > MOUSEXL) && (dy < MOUSEYH) && (dy + h > MOUSEYL)) + return (T); + else + return (NIL); +} #endif /************************************************************ @@ -86,9 +77,9 @@ takes 9 (!) args from top of stack, does line draw inner loop SP-0 --> Maximum number of X steps allowed {uXCount} SP-2 --> Initial Delta {Delta} SP-4 --> Function number: {L2} - 0: Set pixel - 1: Reset Pixel - 2: Invert Pixel + 0: Set pixel + 1: Reset Pixel + 2: Invert Pixel SP-6 --> Relative Y coordinate of end of line (for the bucket) {uYT} SP-8 --> Width of bitmap (in words), signed to indicate Y direction {uYIncHi , uYIncLo} SP-10 -> Relative X coordinate of end of line (for the bucket) {uXT} @@ -102,60 +93,59 @@ takes 9 (!) args from top of stack, does line draw inner loop /* op = draw operation: 0/paint, 1/erase, 2/invert */ /***** plot: - if x = xmax or y = ymax then exit - data = data op curbit; - if (ymax > xmax) then {movex(-), if delta neg, then movey(+), goto plot} - else {movey(-), if delta neg, then movex(+), goto plot} + if x = xmax or y = ymax then exit + data = data op curbit; + if (ymax > xmax) then {movex(-), if delta neg, then movey(+), goto plot} + else {movey(-), if delta neg, then movex(+), goto plot} - movex = { - xmax-- - delta = delta +/- ysize - curbit >>= 1 - if curbit = 0 then {curbit = 0x8000, incx} - } - movey = { - ymax-- - delta = delta +/- xsize - incy - } + movex = { + xmax-- + delta = delta +/- ysize + curbit >>= 1 + if curbit = 0 then {curbit = 0x8000, incx} + } + movey = { + ymax-- + delta = delta +/- xsize + incy + } *****/ /* - ptr pointer to "first word of bitmap" - curbit bit index to start with, and tracks therefrom. - xsize Rel X coord - width width of bitmap, in words - ysize Rel Y coord of end of line - op operation - delta initial delta - numx step count for X steps - numy step count for Y steps + ptr pointer to "first word of bitmap" + curbit bit index to start with, and tracks therefrom. + xsize Rel X coord + width width of bitmap, in words + ysize Rel Y coord of end of line + op operation + delta initial delta + numx step count for X steps + numy step count for Y steps */ #ifdef XWINDOW #define DISPLAYBUFFER #endif /* XWINDOW */ - -int N_OP_drawline(ptr, curbit, xsize, width, ysize, op, delta, numx, numy) - register int curbit, xsize; - int width; - register int ysize; - int op; - register int delta, numx, numy; - LispPTR ptr; - { - register DLword *dataptr; - ScreenLocked=T; +int N_OP_drawline(ptr, curbit, xsize, width, ysize, op, delta, numx, numy) register int curbit, + xsize; +int width; +register int ysize; +int op; +register int delta, numx, numy; +LispPTR ptr; +{ + register DLword *dataptr; + ScreenLocked = T; #ifdef COLOR - if( MonoOrColor == MONO_SCREEN ) + if (MonoOrColor == MONO_SCREEN) #endif /* COLOR */ #ifdef SUNDISPLAY #ifndef DISPLAYBUFFER - HideCursor; /** Figure out how to be smart later **/ -#else /* DISPLAYBUFFER */ + HideCursor; /** Figure out how to be smart later **/ +#else /* DISPLAYBUFFER */ #ifndef OLD_CURSOR HideCursor; #endif /* OLD_CURSOR */ @@ -164,145 +154,142 @@ int N_OP_drawline(ptr, curbit, xsize, width, ysize, op, delta, numx, numy) #endif /* SUNDISPLAY */ - - delta &= 0xFFFF; - op &= 3; + delta &= 0xFFFF; + op &= 3; - if ((SEGMASK & width) == S_POSITIVE) width &= 0xFFFF; - else if ((SEGMASK & width) == S_NEGATIVE) width |= 0xFFFF0000; - else ERROR_EXIT(numy); + if ((SEGMASK & width) == S_POSITIVE) + width &= 0xFFFF; + else if ((SEGMASK & width) == S_NEGATIVE) + width |= 0xFFFF0000; + else + ERROR_EXIT(numy); - curbit = 0x8000 >> (curbit & 0xFFFF); - dataptr = Addr68k_from_LADDR(ptr); - numy &= 0xFFFF; - numx &= 0xFFFF; - ysize &= 0xFFFF; - xsize &= 0xFFFF; - if (xsize > ysize) - { - delta = xsize - delta - 1; - switch (op) - { - case 0: - while (numx && numy) - { - if (!curbit) - { - curbit = 0x8000; - dataptr++; - } /* end if curbit */ - GETWORD(dataptr) |= curbit; - numx--; - delta -= ysize; - curbit >>= 1; - if (delta < 0) - { - numy--; - delta += xsize; - dataptr += width; - } /* end if delta */ - }/* end while */ - break; - case 1: - while (numx && numy) - { - if (!curbit) { - curbit = 0x8000; - dataptr++; - } /* end if curbit */ - GETWORD(dataptr) &= ~curbit; - numx--; - delta -= ysize; - curbit >>= 1; - if (delta < 0) - { - numy--; - delta += xsize; - dataptr += width; - } /* end if delta */ - }/* end while */ - break; - case 2: - while (numx && numy) - { - if (!curbit) { curbit = 0x8000; dataptr++; } - GETWORD(dataptr) ^= curbit; - numx--; - delta -= ysize; - curbit >>= 1; - if (delta < 0) - { - numy--; - delta += xsize; - dataptr += width; - } /* end if delta */ - }/* end while */ - break; - } /* end switch */ - }/* end if */ - else - { /* yfirst */ - delta = ysize - delta - 1; - switch (op) - { - case 0: - while (numx && numy) - { - GETWORD(dataptr) |= curbit; - numy--; - delta -= xsize; - dataptr += width; - if (delta < 0) - { - numx--; - delta += ysize; - curbit >>= 1; - if (!curbit) { curbit = 0x8000; dataptr++; } - } /* end if delta */ - }/* end while */ - break; - case 1: - while (numx && numy) - { - GETWORD(dataptr) &= ~curbit; - numy--; - delta -= xsize; - dataptr += width; - if (delta < 0) - { - numx--; - delta += ysize; - curbit >>= 1; - if (!curbit) { curbit = 0x8000; dataptr++; } - } /* end if delta */ - }/* end while */ - break; - case 2: - while (numx && numy) - { - GETWORD(dataptr) ^= curbit; - numy--; - delta -= xsize; - dataptr += width; - if (delta < 0) - { - numx--; - delta += ysize; - curbit >>= 1; - if (!curbit) { curbit = 0x8000; dataptr++; } - } /* end if delta */ - }/* end while */ - break; - } /* end switch */ - } /* end else */ + curbit = 0x8000 >> (curbit & 0xFFFF); + dataptr = Addr68k_from_LADDR(ptr); + numy &= 0xFFFF; + numx &= 0xFFFF; + ysize &= 0xFFFF; + xsize &= 0xFFFF; + if (xsize > ysize) { + delta = xsize - delta - 1; + switch (op) { + case 0: + while (numx && numy) { + if (!curbit) { + curbit = 0x8000; + dataptr++; + } /* end if curbit */ + GETWORD(dataptr) |= curbit; + numx--; + delta -= ysize; + curbit >>= 1; + if (delta < 0) { + numy--; + delta += xsize; + dataptr += width; + } /* end if delta */ + } /* end while */ + break; + case 1: + while (numx && numy) { + if (!curbit) { + curbit = 0x8000; + dataptr++; + } /* end if curbit */ + GETWORD(dataptr) &= ~curbit; + numx--; + delta -= ysize; + curbit >>= 1; + if (delta < 0) { + numy--; + delta += xsize; + dataptr += width; + } /* end if delta */ + } /* end while */ + break; + case 2: + while (numx && numy) { + if (!curbit) { + curbit = 0x8000; + dataptr++; + } + GETWORD(dataptr) ^= curbit; + numx--; + delta -= ysize; + curbit >>= 1; + if (delta < 0) { + numy--; + delta += xsize; + dataptr += width; + } /* end if delta */ + } /* end while */ + break; + } /* end switch */ + } /* end if */ + else { /* yfirst */ + delta = ysize - delta - 1; + switch (op) { + case 0: + while (numx && numy) { + GETWORD(dataptr) |= curbit; + numy--; + delta -= xsize; + dataptr += width; + if (delta < 0) { + numx--; + delta += ysize; + curbit >>= 1; + if (!curbit) { + curbit = 0x8000; + dataptr++; + } + } /* end if delta */ + } /* end while */ + break; + case 1: + while (numx && numy) { + GETWORD(dataptr) &= ~curbit; + numy--; + delta -= xsize; + dataptr += width; + if (delta < 0) { + numx--; + delta += ysize; + curbit >>= 1; + if (!curbit) { + curbit = 0x8000; + dataptr++; + } + } /* end if delta */ + } /* end while */ + break; + case 2: + while (numx && numy) { + GETWORD(dataptr) ^= curbit; + numy--; + delta -= xsize; + dataptr += width; + if (delta < 0) { + numx--; + delta += ysize; + curbit >>= 1; + if (!curbit) { + curbit = 0x8000; + dataptr++; + } + } /* end if delta */ + } /* end while */ + break; + } /* end switch */ + } /* end else */ #ifdef COLOR - if( MonoOrColor == MONO_SCREEN ) + if (MonoOrColor == MONO_SCREEN) #endif /* COLOR */ #ifdef SUNDISPLAY #ifndef DISPLAYBUFFER - ShowCursor; /** figure how to be smart later **/ -#else + ShowCursor; /** figure how to be smart later **/ +#else #ifndef OLD_CURSOR ShowCursor; #endif /* OLD_CURSOR */ @@ -311,81 +298,63 @@ int N_OP_drawline(ptr, curbit, xsize, width, ysize, op, delta, numx, numy) #endif /* SUNDISPLAY */ - #ifdef DISPLAYBUFFER #ifdef COLOR - if( MonoOrColor == MONO_SCREEN ) + if (MonoOrColor == MONO_SCREEN) #endif /* COLOR */ - { - DLword *start_addr - , *temp_s - , *temp_e; + { + DLword *start_addr, *temp_s, *temp_e; - start_addr = (DLword*)Addr68k_from_LADDR(ptr); + start_addr = (DLword *)Addr68k_from_LADDR(ptr); - if( ((int)(temp_s = (DLword*)(start_addr - DisplayRegion68k)) >= 0 ) - && (start_addr < DisplayRegion68k_end_addr) - && ((int)(temp_e = (DLword*)(dataptr - DisplayRegion68k)) >= 0 ) - && ((DLword*)dataptr < DisplayRegion68k_end_addr) ) - { + if (((int)(temp_s = (DLword *)(start_addr - DisplayRegion68k)) >= 0) && + (start_addr < DisplayRegion68k_end_addr) && + ((int)(temp_e = (DLword *)(dataptr - DisplayRegion68k)) >= 0) && + ((DLword *)dataptr < DisplayRegion68k_end_addr)) { + int start_x, start_y, end_x, end_y, w, h, displayflg; - int start_x - , start_y - , end_x - , end_y - , w - , h - , displayflg; + start_y = (int)temp_s / DisplayRasterWidth; + start_x = ((int)temp_s % DisplayRasterWidth) * BITSPER_DLWORD; - start_y = (int)temp_s / DisplayRasterWidth; - start_x = ((int)temp_s % DisplayRasterWidth) * BITSPER_DLWORD; + end_y = (int)temp_e / DisplayRasterWidth; + end_x = ((int)temp_e % DisplayRasterWidth) * BITSPER_DLWORD + (BITSPER_DLWORD - 1); - end_y = (int)temp_e / DisplayRasterWidth ; - end_x = ((int)temp_e % DisplayRasterWidth) * BITSPER_DLWORD - + (BITSPER_DLWORD - 1); + w = abs(start_x - end_x) + 1; + h = abs(start_y - end_y) + 1; - w = abs(start_x - end_x) + 1; - h = abs(start_y - end_y) + 1; - - if(start_x > end_x) start_x = end_x; - if(start_y > end_y) start_y = end_y; + if (start_x > end_x) start_x = end_x; + if (start_y > end_y) start_y = end_y; #if defined(SUNDISPLAY) && !defined(BYTESWAP) #ifdef OLD_CURSOR - if( (displayflg = n_new_cursorin_CG6( start_x, start_y, w, h )) ) - HideCursor; + if ((displayflg = n_new_cursorin_CG6(start_x, start_y, w, h))) HideCursor; #endif /* OLD_CURSOR */ - pr_rop(ColorDisplayPixrect, start_x, start_y, w, h, - PIX_SRC,DisplayRegionPixrect, start_x, start_y ); + pr_rop(ColorDisplayPixrect, start_x, start_y, w, h, PIX_SRC, DisplayRegionPixrect, start_x, + start_y); #ifdef OLD_CURSOR - if( displayflg ) ShowCursor; + if (displayflg) ShowCursor; #endif /* OLD_CURSOR */ #endif /* SUNDISPLAY */ - #if defined(XWINDOW) || defined(BYTESWAP) - flush_display_region( start_x, start_y, w, h); + flush_display_region(start_x, start_y, w, h); #endif /* XWINDOW */ - - - } - } + } + } #endif /* DISPLAYBUFFER */ + ScreenLocked = NIL; - ScreenLocked=NIL; + return (0); /* return a value for the error test to check. */ - return(0); /* return a value for the error test to check. */ - - } /* end N_OP_drawline() */ +} /* end N_OP_drawline() */ #ifdef XWINDOW #undef DISPLAYBUFFER #endif /* XWINDOW */ - /* end module */ diff --git a/src/dsk.c b/src/dsk.c old mode 100755 new mode 100644 index b170a20..86474b8 --- a/src/dsk.c +++ b/src/dsk.c @@ -1,7 +1,6 @@ /* $Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ @@ -14,35 +13,34 @@ static char *id = "$Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright /* */ /************************************************************************/ - #include "version.h" #if defined(MACOSX) || defined(FREEBSD) #include #endif -#include +#include #ifndef DOS -#include -#include +#include +#include #ifndef OS5 -#include +#include #endif /* OS5 Solaris doesn't need strings.h */ #ifndef SYSVONLY #ifndef MACOSX #ifndef FREEBSD -#include +#include #endif /* FREEBSD */ #endif /* MACOSX */ #endif /* SYSVONLY */ -#include -#include +#include +#include #ifdef sun -#include +#include #endif /* sun */ #ifdef HPUX -#include +#include #endif /* HPUX */ #else /* DOS */ @@ -63,34 +61,30 @@ static char *id = "$Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright #define alarm(x) 0 #endif /* DOS */ - #ifdef RISCOS -#include -#include +#include +#include #define direct dirent #define d_namlen d_reclen #endif /* RISCOS */ - #ifdef OS5 #define index strchr #define rindex strrchr #define L_SET SEEK_SET #endif /* OS5 */ - #ifdef ISC -#include -#include +#include +#include #define direct dirent #define d_namlen d_reclen #define L_SET SEEK_SET #endif /* ISC */ - #if defined(SYSVONLY) || defined(MACOSX) || defined(FREEBSD) -#include -#include +#include +#include #define direct dirent #define d_namlen d_reclen #ifndef LINUX @@ -99,35 +93,35 @@ static char *id = "$Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright #endif /* SYSVONLY */ #ifndef DOS -#include +#include #endif /* DOS */ -#include -#include -#include -#include -#include "lispemul.h" -#include "lispmap.h" -#include "adr68k.h" -#include "lsptypes.h" -#include "lspglob.h" -#include "arith.h" -#include "stream.h" -#include "timeout.h" -#include "locfile.h" -#include "osmsg.h" -#include "dbprint.h" +#include +#include +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "arith.h" +#include "stream.h" +#include "timeout.h" +#include "locfile.h" +#include "osmsg.h" +#include "dbprint.h" #if defined(ULTRIX) || defined(MACOSX) || defined(FREEBSD) -#include +#include #elif OSF1 -#include +#include #else #ifdef AIX #if (!defined(AIXPS2) && !defined(HPUX)) #ifdef LINUX -#include +#include #else -#include +#include #endif #endif /* AIXPS2 | HPUX */ @@ -136,44 +130,39 @@ static char *id = "$Id: dsk.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright #endif /* ULTRIX */ - #ifdef APOLLO -#include +#include #define d_fileno d_ino #define f_bavail f_bfree -#endif /* APOLLO */ - +#endif /* APOLLO */ #ifdef GCC386 #include "inlnPS2.h" -#endif /* GCC386 */ +#endif /* GCC386 */ +extern int *Lisp_errno; +extern int Dummy_errno; -extern int* Lisp_errno; -extern int Dummy_errno; +typedef struct filename_entry { + char name[MAXPATHLEN]; /* With version, foo.~3~ or foo */ + int version_no; +} FileName; -typedef struct filename_entry - { - char name[MAXPATHLEN]; /* With version, foo.~3~ or foo */ - int version_no; - } FileName; +typedef struct current_varray { + char path[MAXPATHLEN]; /* pathname of directory */ + char file[MAXPATHLEN]; /* file name (down cased name) */ + time_t mtime; +} CurrentVArray; -typedef struct current_varray - { - char path[MAXPATHLEN]; /* pathname of directory */ - char file[MAXPATHLEN]; /* file name (down cased name) */ - time_t mtime; - } CurrentVArray; - -FileName VersionArray[VERSIONARRAYLENGTH]; -CurrentVArray VArrayInfo; +FileName VersionArray[VERSIONARRAYLENGTH]; +CurrentVArray VArrayInfo; FileName *GetHighestVersion(); FileName *GetNextHighestVersion(); FileName *GetLowestVersion(); FileName *VersionlessP(); -/* +/* * Name: separate_host * * Argument: char *lfname Lisp full file name including host field. @@ -196,69 +185,68 @@ FileName *VersionlessP(); */ #ifdef DOS -void separate_host(lfname, host, drive) - char *drive; +void separate_host(lfname, host, drive) char *drive; #else void separate_host(lfname, host) #endif /* DOS */ - register char *lfname; - register char *host; +register char *lfname; +register char *host; { - register char *cp; - register int diff; + register char *cp; + register int diff; - cp = lfname + 1; /* Skip the initial "{". */ - - while (*cp != '}') *host++ = *cp++; - *host = '\0'; + cp = lfname + 1; /* Skip the initial "{". */ - cp++; /* Now, *cp == '<' or drive letter. */ + while (*cp != '}') *host++ = *cp++; + *host = '\0'; + + cp++; /* Now, *cp == '<' or drive letter. */ #ifdef DOS - /* Check if there's a drive specified. */ - - if (*(cp+1) == DRIVESEP) - { - *drive = *cp; /* copy the drive letter, if there is one */ - cp++; cp++; /* Move to the real `<`/ */ - } - else *drive = '\0'; /* no drive */ -#endif /* DOS */ + /* Check if there's a drive specified. */ - if (*(cp + 1) == '\0') { - /* Root directory is specified. */ - *lfname = '<'; - *(lfname + 1) = '\0'; - } else { - diff = (int)cp - (int)lfname; - if (*cp == '<' || *cp == DIRSEP + if (*(cp + 1) == DRIVESEP) { + *drive = *cp; /* copy the drive letter, if there is one */ + cp++; + cp++; /* Move to the real `<`/ */ + } else + *drive = '\0'; /* no drive */ +#endif /* DOS */ + + if (*(cp + 1) == '\0') { + /* Root directory is specified. */ + *lfname = '<'; + *(lfname + 1) = '\0'; + } else { + diff = (int)cp - (int)lfname; + if (*cp == '<' || *cp == DIRSEP #ifdef DOS - || *cp == UNIXDIRSEP + || *cp == UNIXDIRSEP #endif /* DOS */ - ) { - /* - * Skip the initial directory delimiter. - */ - cp++; - diff++; - } - while (*cp) { - *(cp - diff) = *cp; - cp++; - } - if (*(cp - 1) == '>' && *(cp - 2) != '\'') { - /* - * The last character is a not quoted directory - * delimiter. We have to remove it from the result - * lfname for the convenience of unixpathname. - */ - *(cp - diff - 1) = '\0'; - } else { - *(cp - diff) = '\0'; - } - } + ) { + /* + * Skip the initial directory delimiter. + */ + cp++; + diff++; + } + while (*cp) { + *(cp - diff) = *cp; + cp++; + } + if (*(cp - 1) == '>' && *(cp - 2) != '\'') { + /* + * The last character is a not quoted directory + * delimiter. We have to remove it from the result + * lfname for the convenience of unixpathname. + */ + *(cp - diff - 1) = '\0'; + } else { + *(cp - diff) = '\0'; + } + } } -/* +/* * Name: COM_openfile * * Argument: LispPTR *args args[0] @@ -285,333 +273,317 @@ void separate_host(lfname, host) * open a specified file. */ -LispPTR COM_openfile(args) - register LispPTR *args; +LispPTR COM_openfile(args) register LispPTR *args; { - char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; - char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; - register int fatp, dskp, rval, fd, link_check_flg, flags, *bufp; - struct stat sbuf; + char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + register int fatp, dskp, rval, fd, link_check_flg, flags, *bufp; + struct stat sbuf; #ifdef DOS - char drive[1]; /* Drive designator */ - int extlen; /* length of the raw file extension */ - char rawname[MAXNAMLEN]; + char drive[1]; /* Drive designator */ + int extlen; /* length of the raw file extension */ + char rawname[MAXNAMLEN]; #endif /* DOS */ - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[5])); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[5])); - LispStringLength(args[0], rval, fatp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = fatp ? rval + 4 + 1 : rval + 2 + 1; - /* Add five for the host name field in Lisp format. */ - if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - - LispStringToCString(args[0], lfname, MAXPATHLEN); + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + /* Add five for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); #ifdef DOS - separate_host(lfname, host, drive); + separate_host(lfname, host, drive); #else - separate_host(lfname, host); + separate_host(lfname, host); #endif /* DOS */ - UPCASE(host); + UPCASE(host); - if (strcmp(host, "DSK") == 0) dskp = 1; - else if (strcmp(host, "UNIX") == 0) dskp = 0; - else return(NIL); - - /* - * Convert a Lisp file name to UNIX one. If host is DSK, we also have to - * convert a version field. - */ + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); + +/* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ #ifdef DOS - unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); + unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); #else - unixpathname(lfname, file, dskp, 0); + unixpathname(lfname, file, dskp, 0); #endif - /* - * Set up the flags argument for open system call. - * And we have to handle the non existing directory case if the device is - * DSK. - * link_check_flg is used to determine wheter we have to check a hard-link - * based version control after opening a file. - */ - link_check_flg = 0; - switch (args[1]) { - - case RECOG_OLD: - case RECOG_OLDEST: - switch (args[2]) { + /* + * Set up the flags argument for open system call. + * And we have to handle the non existing directory case if the device is + * DSK. + * link_check_flg is used to determine wheter we have to check a hard-link + * based version control after opening a file. + */ + link_check_flg = 0; + switch (args[1]) { + case RECOG_OLD: + case RECOG_OLDEST: + switch (args[2]) { + case ACCESS_INPUT: flags = O_RDONLY; break; - case ACCESS_INPUT: - flags = O_RDONLY; - break; + case ACCESS_OUTPUT: + /* + * The current implementation of Lisp page mapped device requires + * that the output stream being "readable"! + */ + flags = O_RDWR | O_TRUNC; + break; - case ACCESS_OUTPUT: - /* - * The current implementation of Lisp page mapped device requires - * that the output stream being "readable"! - */ - flags = O_RDWR | O_TRUNC; - break; + case ACCESS_BOTH: flags = O_RDWR; break; - case ACCESS_BOTH: - flags = O_RDWR; - break; + case ACCESS_APPEND: + /* + * Should be O_WRONLY | O_APPEND. But Lisp needs it. + */ + flags = O_RDWR; + break; + } + break; + case RECOG_NEW: + case RECOG_OLD_NEW: + /* + * In DSK device, the not exsting yet file can be recognized. In this + * case, if there is a chance to create a new file, we have to make + * sure that all directory to reach the recognized file exists. + * Also we have to check the versionless file is collectly maintained + * or not when we have a chance to create a new file. + */ + switch (args[2]) { + case ACCESS_INPUT: + if (args[1] == RECOG_NEW) { + /* + * Opening a input stream to a new, not yet + * existing, file does not make sense. + */ + return (NIL); + } else { + /* + * Even if OLD/NEW recoginition, opening a input + * stream never try to create a new file. Thus, + * without O_CREAT. + */ + flags = O_RDONLY; + } + break; - case ACCESS_APPEND: - /* - * Should be O_WRONLY | O_APPEND. But Lisp needs it. - */ - flags = O_RDWR; - break; - } - break; - case RECOG_NEW: - case RECOG_OLD_NEW: - /* - * In DSK device, the not exsting yet file can be recognized. In this - * case, if there is a chance to create a new file, we have to make - * sure that all directory to reach the recognized file exists. - * Also we have to check the versionless file is collectly maintained - * or not when we have a chance to create a new file. - */ - switch (args[2]) { + case ACCESS_OUTPUT: + flags = O_RDWR | O_TRUNC | O_CREAT; + if (dskp) { + unpack_filename(file, dir, name, ver, 1); + if (make_directory(dir) == 0) return (NIL); + link_check_flg = 1; + } + break; - case ACCESS_INPUT: - if (args[1] == RECOG_NEW) { - /* - * Opening a input stream to a new, not yet - * existing, file does not make sense. - */ - return(NIL); - } else { - /* - * Even if OLD/NEW recoginition, opening a input - * stream never try to create a new file. Thus, - * without O_CREAT. - */ - flags = O_RDONLY; - } - break; + case ACCESS_BOTH: + flags = O_RDWR | O_CREAT; + if (dskp) { + unpack_filename(file, dir, name, ver, 1); + if (make_directory(dir) == 0) return (NIL); + link_check_flg = 1; + } + break; - case ACCESS_OUTPUT: - flags = O_RDWR | O_TRUNC | O_CREAT; - if (dskp) { - unpack_filename(file, dir, name, ver, 1); - if (make_directory(dir) == 0) return(NIL); - link_check_flg = 1; - } - break; + case ACCESS_APPEND: + flags = O_RDWR | O_CREAT; + if (dskp) { + unpack_filename(file, dir, name, ver, 1); + if (make_directory(dir) == 0) return (NIL); + link_check_flg = 1; + } + break; + } + break; - case ACCESS_BOTH: - flags = O_RDWR | O_CREAT; - if (dskp) { - unpack_filename(file, dir, name, ver, 1); - if (make_directory(dir) == 0) return(NIL); - link_check_flg = 1; - } - break; + default: return (NIL); + } - case ACCESS_APPEND: - flags = O_RDWR | O_CREAT; - if (dskp) { - unpack_filename(file, dir, name, ver, 1); - if (make_directory(dir) == 0) return(NIL); - link_check_flg = 1; - } - break; - } - break; + /* + * The file name which has been passed from Lisp is sometimes different + * from the actual file name on DSK, even after the Lisp name is converted + * to UNIX form with unixpathname. Lisp always recognize a file on DSK + * with version. If the versionless file exists and it is not correctly + * maintained, that is it is not hard linked to the exisiting highest + * versioned file, Lisp regards such link missing versionless file as + * the highest versioned file, but the actual name on the file system + * is still versionless. + * get_old, get_oldest, get_new, get_old_new routines handle all of the + * complicated cases correctly and let us know the "Lisp recognizing" + * name and "Real" name. Both of them are UNIX format. + * At this point, we will use one of the four routines and get the + * real name. We can use it to open a file which is requeste from Lisp + * with the "Lisp recognizing" name. + */ - default: - return(NIL); - } + if (dskp) { + if (unpack_filename(file, dir, name, ver, 1) == 0) return (NIL); + if (true_name(dir) != -1) return (0); + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) return (NIL); + ConcNameAndVersion(name, ver, file); - /* - * The file name which has been passed from Lisp is sometimes different - * from the actual file name on DSK, even after the Lisp name is converted - * to UNIX form with unixpathname. Lisp always recognize a file on DSK - * with version. If the versionless file exists and it is not correctly - * maintained, that is it is not hard linked to the exisiting highest - * versioned file, Lisp regards such link missing versionless file as - * the highest versioned file, but the actual name on the file system - * is still versionless. - * get_old, get_oldest, get_new, get_old_new routines handle all of the - * complicated cases correctly and let us know the "Lisp recognizing" - * name and "Real" name. Both of them are UNIX format. - * At this point, we will use one of the four routines and get the - * real name. We can use it to open a file which is requeste from Lisp - * with the "Lisp recognizing" name. - */ + switch (args[1]) { + case RECOG_OLD: + if (get_old(dir, VersionArray, file, name) == 0) return (NIL); + break; - if (dskp) { - if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); - if (true_name(dir) != -1) return(0); - if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) - return(NIL); - ConcNameAndVersion(name, ver, file); - - switch (args[1]) { - - case RECOG_OLD: - if (get_old(dir, VersionArray, file, name) == 0) - return(NIL); - break; + case RECOG_OLDEST: + if (get_oldest(dir, VersionArray, file, name) == 0) return (NIL); + break; - case RECOG_OLDEST: - if (get_oldest(dir, VersionArray, file, name) == 0) - return(NIL); - break; + case RECOG_NEW: + if (get_new(dir, VersionArray, file, name) == 0) return (NIL); + break; - case RECOG_NEW: - if (get_new(dir, VersionArray, file, name) == 0) - return(NIL); - break; + case RECOG_OLD_NEW: + if (get_old_new(dir, VersionArray, file, name) == 0) return (NIL); + break; - case RECOG_OLD_NEW: - if (get_old_new(dir, VersionArray, file, name) == 0) - return(NIL); - break; + default: return (NIL); + } + } - default: - return(NIL); - } - } - - /* - * DSK device only allow to open a regular file. - */ - if (dskp) { - TIMEOUT(rval = stat(file, &sbuf)); - if (rval == 0) { - if ((sbuf.st_mode & S_IFMT) != S_IFREG) { - /* - * The Lisp code handles this case as same as "file table - * overflow" error. Final error message is "File won't - * open". - */ - *Lisp_errno = ENFILE; - return(NIL); - } - } else { - /* - * When stat failed, only if the reason is "file does not - * exist" and we are trying to open a file with a mode we can - * create a new file, we can proceed. - */ - if (errno != ENOENT || !link_check_flg) { - *Lisp_errno = errno; - return(NIL); - } - } - } - if (dskp && link_check_flg) { - /* - * When we are opening a file with a mode we might create a new file, - * we have to make sure that versionless file is maintaied - * correctly before we actually creating a new file, because a - * created new file will change the status and the recognition on - * the same file with the same recognition mode will return the - * different result. - * At this point, the third argument for maintain_version, forcep is - * 1, because a lonly versionless file should be linked to version 1. - * If we are opening a file recognized with new mode, version 2, - * without pre-linking a versionless to version 1, the final - * clean up maintain_version will link the versionless to version 3. - */ - TIMEOUT(rval = access(file, F_OK)); - if (rval == -1) { - if (errno == ENOENT) { - /* - * Actually we are creating a new file. We have to - * maintain a version status. - */ - if (maintain_version(file, (FileName *)NULL, 1) == 0) { - TIMEOUT(rval = close(fd)); - *Lisp_errno = errno; - return(NIL); - } - } else { - /* - * Because of other reason, access call failed. - */ - *Lisp_errno = errno; - return(NIL); - } - } else { - /* - * The subjective file has already existed. We don't need - * to maintain a version. - */ + /* + * DSK device only allow to open a regular file. + */ + if (dskp) { + TIMEOUT(rval = stat(file, &sbuf)); + if (rval == 0) { + if ((sbuf.st_mode & S_IFMT) != S_IFREG) { + /* + * The Lisp code handles this case as same as "file table + * overflow" error. Final error message is "File won't + * open". + */ + *Lisp_errno = ENFILE; + return (NIL); + } + } else { + /* + * When stat failed, only if the reason is "file does not + * exist" and we are trying to open a file with a mode we can + * create a new file, we can proceed. + */ + if (errno != ENOENT || !link_check_flg) { + *Lisp_errno = errno; + return (NIL); + } + } + } + if (dskp && link_check_flg) { + /* + * When we are opening a file with a mode we might create a new file, + * we have to make sure that versionless file is maintaied + * correctly before we actually creating a new file, because a + * created new file will change the status and the recognition on + * the same file with the same recognition mode will return the + * different result. + * At this point, the third argument for maintain_version, forcep is + * 1, because a lonly versionless file should be linked to version 1. + * If we are opening a file recognized with new mode, version 2, + * without pre-linking a versionless to version 1, the final + * clean up maintain_version will link the versionless to version 3. + */ + TIMEOUT(rval = access(file, F_OK)); + if (rval == -1) { + if (errno == ENOENT) { + /* + * Actually we are creating a new file. We have to + * maintain a version status. + */ + if (maintain_version(file, (FileName *)NULL, 1) == 0) { + TIMEOUT(rval = close(fd)); + *Lisp_errno = errno; + return (NIL); + } + } else { + /* + * Because of other reason, access call failed. + */ + *Lisp_errno = errno; + return (NIL); + } + } else { +/* + * The subjective file has already existed. We don't need + * to maintain a version. + */ #ifdef DOS - if (args[1] == RECOG_NEW) - { - char old[MAXPATHLEN]; - make_old_version(old, file); - unlink(old); - rename(file, old); /* make old version */ - } + if (args[1] == RECOG_NEW) { + char old[MAXPATHLEN]; + make_old_version(old, file); + unlink(old); + rename(file, old); /* make old version */ + } #endif /* DOS */ + } + } - } - } + /* + * If a new file is created, its actual mode is computed from the + * third argument for open and the process's umask. I'm pretty sure + * 0666 would be most appropriate mode to specify here. + */ + TIMEOUT(fd = open(file, flags, 0666)); + if (fd == -1) { + *Lisp_errno = errno; + return (NIL); + } - /* - * If a new file is created, its actual mode is computed from the - * third argument for open and the process's umask. I'm pretty sure - * 0666 would be most appropriate mode to specify here. - */ - TIMEOUT(fd = open(file, flags, 0666)); - if (fd == -1) { - *Lisp_errno = errno; - return(NIL); - } + if (dskp && link_check_flg) { + /* + * Again we have to maintain version to clean up the directory. + * This time we invoke maintain_version with forcep off, because + * the entirely newly created file, versionless file, should not + * be linked to any file. + */ + if (maintain_version(file, (FileName *)NULL, 0) == 0) { + TIMEOUT(close(fd)); + *Lisp_errno = errno; + return (NIL); + } + } - if (dskp && link_check_flg) { - /* - * Again we have to maintain version to clean up the directory. - * This time we invoke maintain_version with forcep off, because - * the entirely newly created file, versionless file, should not - * be linked to any file. - */ - if (maintain_version(file, (FileName *)NULL, 0) == 0) { - TIMEOUT(close(fd)); - *Lisp_errno = errno; - return(NIL); - } - } + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + TIMEOUT(close(fd)); + *Lisp_errno = errno; + return (NIL); + } - TIMEOUT(rval = fstat(fd, &sbuf)); - if (rval == -1) { - TIMEOUT(close(fd)); - *Lisp_errno = errno; - return(NIL); - } + bufp = (int *)(Addr68k_from_LADDR(args[3])); + *bufp = ToLispTime(sbuf.st_mtime); - bufp = (int *)(Addr68k_from_LADDR(args[3])); - *bufp = ToLispTime(sbuf.st_mtime); + bufp = (int *)(Addr68k_from_LADDR(args[4])); + if (!dskp && ((sbuf.st_mode & S_IFMT) != S_IFREG) && ((sbuf.st_mode & S_IFMT) != S_IFDIR)) { + /* + * Not a regular file or directory file. Put on a marker. + */ + *bufp = SPECIALFILEMARK; + } else { + *bufp = sbuf.st_size; + } - bufp = (int *)(Addr68k_from_LADDR(args[4])); - if (!dskp && ((sbuf.st_mode & S_IFMT) != S_IFREG) && - ((sbuf.st_mode & S_IFMT) != S_IFDIR)) { - /* - * Not a regular file or directory file. Put on a marker. - */ - *bufp = SPECIALFILEMARK; - } else { - *bufp = sbuf.st_size; - } - - return(GetSmallp(fd)); + return (GetSmallp(fd)); } -/* +/* * Name: COM_closefile * * Argument: LispPTR *args args[0] @@ -640,287 +612,282 @@ LispPTR COM_openfile(args) * Lisp and it is passed to COM_closefile. */ -LispPTR COM_closefile(args) - register LispPTR *args; +LispPTR COM_closefile(args) register LispPTR *args; { - #ifdef DOS - register int fd, dskp, rval; - time_t cdate; - char lfname[MAXPATHLEN + 5], host[MAXNAMLEN]; - char file[MAXPATHLEN], dir[MAXPATHLEN], name[MAXNAMLEN + 1]; - char ver[VERSIONLEN], drive[1]; - struct find_t dirp; - int dp; - struct stat sbuf; - ino_t ino; - int extlen; - char rawname[MAXNAMLEN]; + register int fd, dskp, rval; + time_t cdate; + char lfname[MAXPATHLEN + 5], host[MAXNAMLEN]; + char file[MAXPATHLEN], dir[MAXPATHLEN], name[MAXNAMLEN + 1]; + char ver[VERSIONLEN], drive[1]; + struct find_t dirp; + int dp; + struct stat sbuf; + ino_t ino; + int extlen; + char rawname[MAXNAMLEN]; - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - LispStringLength(args[0], rval, dskp); + LispStringLength(args[0], rval, dskp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = dskp ? rval + 4 + 1 : rval + 2 + 1; - /* Add five for the host name field in Lisp format. */ - if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add five for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - LispStringToCString(args[0], lfname, MAXPATHLEN); + LispStringToCString(args[0], lfname, MAXPATHLEN); - separate_host(lfname, host, drive); + separate_host(lfname, host, drive); - UPCASE(host); - if (strcmp(host, "DSK") == 0) - dskp = 1; - else if (strcmp(host, "UNIX") == 0) - dskp = 0; - else - return(NIL); + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); - /* - * Convert a Lisp file name to UNIX one. If host is DSK, we also have to - * convert a version field. - */ - dskp ? unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) : unixpathname(lfname, file, 0, 0, drive, &extlen, rawname); - fd = LispNumToCInt(args[1]); - cdate = (time_t)LispNumToCInt(args[2]); - if (!dskp) { - TIMEOUT(rval = fstat(fd, &sbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - } + /* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ + dskp ? unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) + : unixpathname(lfname, file, 0, 0, drive, &extlen, rawname); + fd = LispNumToCInt(args[1]); + cdate = (time_t)LispNumToCInt(args[2]); + if (!dskp) { + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + } - if (cdate == 0) { - /* Just close. */ - TIMEOUT(rval = close(fd)); - if (rval == -1) { - if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) { - /* - * On {UNIX} device, closing a special file we are not - * the owner of it. Although I don't think close fails - * because of EPERM, in honor of Medley 1.1 code, I put - * this segment here. - */ - return(ATOM_T); - } else { - *Lisp_errno = errno; - return(NIL); - } - } else { - return(ATOM_T); - } - } + if (cdate == 0) { + /* Just close. */ + TIMEOUT(rval = close(fd)); + if (rval == -1) { + if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) { + /* + * On {UNIX} device, closing a special file we are not + * the owner of it. Although I don't think close fails + * because of EPERM, in honor of Medley 1.1 code, I put + * this segment here. + */ + return (ATOM_T); + } else { + *Lisp_errno = errno; + return (NIL); + } + } else { + return (ATOM_T); + } + } - if (!unpack_filename(file, dir, name, ver, 1)) return(NIL); + if (!unpack_filename(file, dir, name, ver, 1)) return (NIL); - if (dskp) { - /* - * On {DSK}, we have to make sure dir is case sensitively exisiting - * directory. - */ - if (true_name(dir) != -1) return(NIL); + if (dskp) { + /* + * On {DSK}, we have to make sure dir is case sensitively exisiting + * directory. + */ + if (true_name(dir) != -1) return (NIL); - /* - * There is a very troublesom problem here. The file name Lisp - * recognizes is not always the same as the name which COM_openfile - * used to open the file. Sometimes COM_openfile uses the versionless - * file name to open a file, although Lisp always recognizes with - * *versioned* file name. - * Thus, we compare i-node number of the requested file with ones of all - * of files on the directory. This is time spending implementation. - * More clean up work is needed. - */ - TIMEOUT(rval = fstat(fd, &sbuf)); - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } - ino = sbuf.st_ino; - TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); - if (rval < 0) { - *Lisp_errno = errno; - return(NIL); - } + /* + * There is a very troublesom problem here. The file name Lisp + * recognizes is not always the same as the name which COM_openfile + * used to open the file. Sometimes COM_openfile uses the versionless + * file name to open a file, although Lisp always recognizes with + * *versioned* file name. + * Thus, we compare i-node number of the requested file with ones of all + * of files on the directory. This is time spending implementation. + * More clean up work is needed. + */ + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } + ino = sbuf.st_ino; + TIMEOUT(rval = _dos_findfirst(dir, _A_SUBDIR, &dirp)); + if (rval < 0) { + *Lisp_errno = errno; + return (NIL); + } - for (; rval == 0; - S_TOUT(rval = _dos_findnext(&dirp))) { - sprintf(file, "%s\\%s", dir, dirp.name); - } - } -#ifndef DOS /* effectively NEVER, since we're in an ifdef DOS */ - time[0].tv_sec = (long)sbuf.st_atime; - time[0].tv_usec = 0L; - time[1].tv_sec = (long)ToUnixTime(cdate); - time[1].tv_usec = 0L; + for (; rval == 0; S_TOUT(rval = _dos_findnext(&dirp))) { + sprintf(file, "%s\\%s", dir, dirp.name); + } + } +#ifndef DOS /* effectively NEVER, since we're in an ifdef DOS */ + time[0].tv_sec = (long)sbuf.st_atime; + time[0].tv_usec = 0L; + time[1].tv_sec = (long)ToUnixTime(cdate); + time[1].tv_usec = 0L; #endif /* DOS */ - TIMEOUT(rval = close(fd)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } + TIMEOUT(rval = close(fd)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } #ifndef DOS - TIMEOUT(rval = utimes(file, time)); - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } + TIMEOUT(rval = utimes(file, time)); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } #endif /* DOS, internal */ #else /* UNIX version of CLOSEFILE */ - register int fd, fatp, dskp, rval; - time_t cdate; - char lfname[MAXPATHLEN + 5], host[MAXNAMLEN]; - char file[MAXPATHLEN], dir[MAXPATHLEN], name[MAXNAMLEN + 1]; - char ver[VERSIONLEN]; - register DIR *dirp; - register struct direct *dp; - struct stat sbuf; - struct timeval time[2]; - ino_t ino; + register int fd, fatp, dskp, rval; + time_t cdate; + char lfname[MAXPATHLEN + 5], host[MAXNAMLEN]; + char file[MAXPATHLEN], dir[MAXPATHLEN], name[MAXNAMLEN + 1]; + char ver[VERSIONLEN]; + register DIR *dirp; + register struct direct *dp; + struct stat sbuf; + struct timeval time[2]; + ino_t ino; - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - LispStringLength(args[0], rval, fatp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = fatp ? rval + 4 + 1 : rval + 2 + 1; - /* Add five for the host name field in Lisp format. */ - if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + /* Add five for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - LispStringToCString(args[0], lfname, MAXPATHLEN); - - separate_host(lfname, host); - UPCASE(host); - if (strcmp(host, "DSK") == 0) - dskp = 1; - else if (strcmp(host, "UNIX") == 0) - dskp = 0; - else - return(NIL); + LispStringToCString(args[0], lfname, MAXPATHLEN); - /* - * Convert a Lisp file name to UNIX one. If host is DSK, we also have to - * convert a version field. - */ - dskp ? unixpathname(lfname, file, 1, 0) : unixpathname(lfname, file, 0, 0); + separate_host(lfname, host); + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); - fd = LispNumToCInt(args[1]); - cdate = (time_t)LispNumToCInt(args[2]); + /* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ + dskp ? unixpathname(lfname, file, 1, 0) : unixpathname(lfname, file, 0, 0); - if (!dskp) { - TIMEOUT(rval = fstat(fd, &sbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - } - - if (cdate == 0) { - /* Just close. */ - TIMEOUT(rval = close(fd)); - if (rval == -1) { - if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) { - /* - * On {UNIX} device, closing a special file we are not - * the owner of it. Although I don't think close fails - * because of EPERM, in honor of Medley 1.1 code, I put - * this segment here. - */ - return(ATOM_T); - } else { - *Lisp_errno = errno; - return(NIL); - } - } else { - return(ATOM_T); - } - } + fd = LispNumToCInt(args[1]); + cdate = (time_t)LispNumToCInt(args[2]); - if (!unpack_filename(file, dir, name, ver, 1)) return(NIL); + if (!dskp) { + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + } - if (dskp) { - /* - * On {DSK}, we have to make sure dir is case sensitively exisiting - * directory. - */ - if (true_name(dir) != -1) return(NIL); + if (cdate == 0) { + /* Just close. */ + TIMEOUT(rval = close(fd)); + if (rval == -1) { + if (!dskp && errno == EPERM && (sbuf.st_mode & S_IFREG) == 0) { + /* + * On {UNIX} device, closing a special file we are not + * the owner of it. Although I don't think close fails + * because of EPERM, in honor of Medley 1.1 code, I put + * this segment here. + */ + return (ATOM_T); + } else { + *Lisp_errno = errno; + return (NIL); + } + } else { + return (ATOM_T); + } + } - /* - * There is a very troublesom problem here. The file name Lisp - * recognizes is not always the same as the name which COM_openfile - * used to open the file. Sometimes COM_openfile uses the versionless - * file name to open a file, although Lisp always recognizes with - * *versioned* file name. - * Thus, we compare i-node number of the requested file with ones of all - * of files on the directory. This is time spending implementation. - * More clean up work is needed. - */ - TIMEOUT(rval = fstat(fd, &sbuf)); - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } - ino = sbuf.st_ino; + if (!unpack_filename(file, dir, name, ver, 1)) return (NIL); - errno=0; - TIMEOUT0(dirp = opendir(dir)); - if (dirp == (DIR *)NULL) { - *Lisp_errno = errno; - return(NIL); - } + if (dskp) { + /* + * On {DSK}, we have to make sure dir is case sensitively exisiting + * directory. + */ + if (true_name(dir) != -1) return (NIL); - for (S_TOUT(dp = readdir(dirp)); dp != (struct direct*)NULL || errno == EINTR; - errno=0, S_TOUT(dp = readdir(dirp))) - if (dp) - { - if (ino == (ino_t)dp->d_fileno) - sprintf(file, "%s/%s", dir, dp->d_name); - } - TIMEOUT(closedir(dirp)); - } + /* + * There is a very troublesom problem here. The file name Lisp + * recognizes is not always the same as the name which COM_openfile + * used to open the file. Sometimes COM_openfile uses the versionless + * file name to open a file, although Lisp always recognizes with + * *versioned* file name. + * Thus, we compare i-node number of the requested file with ones of all + * of files on the directory. This is time spending implementation. + * More clean up work is needed. + */ + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } + ino = sbuf.st_ino; - time[0].tv_sec = (long)sbuf.st_atime; - time[0].tv_usec = 0L; - time[1].tv_sec = (long)ToUnixTime(cdate); - time[1].tv_usec = 0L; + errno = 0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == (DIR *)NULL) { + *Lisp_errno = errno; + return (NIL); + } - TIMEOUT(rval = close(fd)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } + for (S_TOUT(dp = readdir(dirp)); dp != (struct direct *)NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp))) + if (dp) { + if (ino == (ino_t)dp->d_fileno) sprintf(file, "%s/%s", dir, dp->d_name); + } + TIMEOUT(closedir(dirp)); + } + + time[0].tv_sec = (long)sbuf.st_atime; + time[0].tv_usec = 0L; + time[1].tv_sec = (long)ToUnixTime(cdate); + time[1].tv_usec = 0L; + + TIMEOUT(rval = close(fd)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } #ifdef USE_UTIME - TIMEOUT(rval = utime(file, time)); + TIMEOUT(rval = utime(file, time)); #else - TIMEOUT(rval = utimes(file, time)); + TIMEOUT(rval = utimes(file, time)); #endif - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } #endif /* DOS */ - return(ATOM_T); - + return (ATOM_T); } -/* +/* * Name: DSK_getfilename * * Argument: LispPTR *args args[0] Full file name in Lisp format. @@ -933,7 +900,7 @@ LispPTR COM_closefile(args) * Value: If succeed, returns the Lisp smallp which represents the length * of the recognized full file name, otherwise Lisp NIL. * - * Side Effect: If succeed, name area (args[2]) will be replaced with the + * Side Effect: If succeed, name area (args[2]) will be replaced with the * recognized full file name. * * Description: @@ -943,292 +910,275 @@ LispPTR COM_closefile(args) * can open the file with the specified mode or not. */ -LispPTR DSK_getfilename(args) - register LispPTR *args; +LispPTR DSK_getfilename(args) register LispPTR *args; { - register char *base; - register int len, dirp, rval; - int fatp; - char lfname[MAXPATHLEN]; - char aname[MAXNAMLEN]; - char vname[MAXPATHLEN]; - char file[MAXPATHLEN]; - char dir[MAXPATHLEN]; - char name[MAXNAMLEN]; - char ver[VERSIONLEN]; + register char *base; + register int len, dirp, rval; + int fatp; + char lfname[MAXPATHLEN]; + char aname[MAXNAMLEN]; + char vname[MAXPATHLEN]; + char file[MAXPATHLEN]; + char dir[MAXPATHLEN]; + char name[MAXNAMLEN]; + char ver[VERSIONLEN]; #ifdef DOS - char drive[1], rawname[MAXNAMLEN]; - int extlen; /* len of extension, for making backup filename */ -#endif /* DOS */ + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + LispStringLength(args[0], len, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + len = fatp ? len + 4 + 1 : len + 2 + 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); - LispStringLength(args[0], len, fatp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - len = fatp ? len + 4 + 1 : len + 2 + 1; - if (len > MAXPATHLEN) FileNameTooLong(NIL); + LispStringToCString(args[0], lfname, MAXPATHLEN); - LispStringToCString(args[0], lfname, MAXPATHLEN); - #ifdef DOS - separate_drive(lfname, drive); + separate_drive(lfname, drive); #endif - /* - * Convert a Lisp file name to UNIX one. This is a DSK device method. - * Thus we have to convert a version field too. Third argument for - * unixpathname specifies it. - */ +/* + * Convert a Lisp file name to UNIX one. This is a DSK device method. + * Thus we have to convert a version field too. Third argument for + * unixpathname specifies it. + */ #ifdef DOS - if (unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) == 0) - return(NIL); + if (unixpathname(lfname, file, 1, 0, drive, &extlen, rawname) == 0) return (NIL); #else - if (unixpathname(lfname, file, 1, 0) == 0) return(NIL); + if (unixpathname(lfname, file, 1, 0) == 0) return (NIL); #endif - if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); + if (unpack_filename(file, dir, name, ver, 1) == 0) return (NIL); - switch (args[1]) { + switch (args[1]) { + case RECOG_OLD: + /* + * "Old" file means the "newest existing" file. Thus, we have to + * check dir is an existing directory or not. The serach have to + * be done in case insensitive manner. true_name does this work. + */ - case RECOG_OLD: - /* - * "Old" file means the "newest existing" file. Thus, we have to - * check dir is an existing directory or not. The serach have to - * be done in case insensitive manner. true_name does this work. - */ + if (true_name(dir) != -1) { + /* No such directory. */ + return (NIL); + } + /* + * At this point, true_name has converted dir to the "true" name + * of the directory. + */ + if (strcmp(name, "") == 0) { + /* + * The file name is specified with a trail directory delimitor. + * We should recognize it as a directory. + */ + strcpy(aname, dir); + strcpy(vname, dir); + dirp = 1; + } else { + /* + * Recognizing a file on DSK device needs the version information. + * We gather version information in a version array first. + */ + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) return (NIL); - if (true_name(dir) != -1) - { - /* No such directory. */ - return(NIL); - } - /* - * At this point, true_name has converted dir to the "true" name - * of the directory. - */ - if (strcmp(name, "") == 0) { - /* - * The file name is specified with a trail directory delimitor. - * We should recognize it as a directory. - */ - strcpy(aname, dir); - strcpy(vname, dir); - dirp = 1; - } else { - /* - * Recognizing a file on DSK device needs the version information. - * We gather version information in a version array first. - */ - if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) - return(NIL); + ConcNameAndVersion(name, ver, aname); + if (get_old(dir, VersionArray, aname, vname) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); - if (get_old(dir, VersionArray, aname, vname) == 0) return(NIL); - - if ((rval = true_name(aname)) == 0) return(NIL); - if (rval == -1) { - /* - * The specified file is a directory file. - */ - strcpy(vname, aname); - dirp = 1; - } else { + if ((rval = true_name(aname)) == 0) return (NIL); + if (rval == -1) { + /* + * The specified file is a directory file. + */ + strcpy(vname, aname); + dirp = 1; + } else { #ifdef DOS - strcpy(vname, aname); + strcpy(vname, aname); #endif - dirp = 0; - } - } + dirp = 0; + } + } - break; + break; - case RECOG_OLDEST: - /* - * "Oldest" file means the "oldest existing" file. Thus, we have to - * check dir is an existing directory or not. - */ - if (true_name(dir) != -1) { - /* No such directory. */ - return(NIL); - } - if (strcmp(name, "") == 0) { - /* - * The file name is specified with a trail directory delimitor. - * We should recognize it as a directory. - */ - strcpy(aname, dir); - strcpy(vname, dir); - dirp = 1; - } else { - if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) - return(NIL); + case RECOG_OLDEST: + /* + * "Oldest" file means the "oldest existing" file. Thus, we have to + * check dir is an existing directory or not. + */ + if (true_name(dir) != -1) { + /* No such directory. */ + return (NIL); + } + if (strcmp(name, "") == 0) { + /* + * The file name is specified with a trail directory delimitor. + * We should recognize it as a directory. + */ + strcpy(aname, dir); + strcpy(vname, dir); + dirp = 1; + } else { + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); - if (get_oldest(dir, VersionArray, aname, vname) == 0) return(NIL); + ConcNameAndVersion(name, ver, aname); + if (get_oldest(dir, VersionArray, aname, vname) == 0) return (NIL); - if ((rval = true_name(aname)) == 0) return(NIL); - if (rval == -1) { - /* - * The specified file is a directory file. - */ - strcpy(vname, aname); - dirp = 1; - } else { + if ((rval = true_name(aname)) == 0) return (NIL); + if (rval == -1) { + /* + * The specified file is a directory file. + */ + strcpy(vname, aname); + dirp = 1; + } else { #ifdef DOS - strcpy(vname, aname); + strcpy(vname, aname); #endif - dirp = 0; - } - } - break; + dirp = 0; + } + } + break; - case RECOG_NEW: - /* - * "New" file means the "not existing" file. Thus it is not - * necessary that dir is an existing directory. If dir is not - * an exisiting directory, we returns the specified file name - * as if, the subsequent OPENFILE will find the truth. - */ - if (true_name(dir) != -1) { - strcpy(vname, file); - dirp = 0; - } else if (strcmp(name, "") == 0) { - /* - * The file name is specified with a trail directory delimitor. - * We should recognize it as a directory. - */ - strcpy(aname, dir); - strcpy(vname, dir); - dirp = 1; - } else { - ConcDirAndName(dir, name, aname); - if ((rval = true_name(aname)) == -1) { - strcpy(vname, aname); - dirp = 1; - } else { - /* - * Here, dir is an existing directory. We have to perform - * "new" recognition with the version information. - */ - if (get_version_array(dir, name, VersionArray, - &VArrayInfo) == 0) - return(NIL); + case RECOG_NEW: + /* + * "New" file means the "not existing" file. Thus it is not + * necessary that dir is an existing directory. If dir is not + * an exisiting directory, we returns the specified file name + * as if, the subsequent OPENFILE will find the truth. + */ + if (true_name(dir) != -1) { + strcpy(vname, file); + dirp = 0; + } else if (strcmp(name, "") == 0) { + /* + * The file name is specified with a trail directory delimitor. + * We should recognize it as a directory. + */ + strcpy(aname, dir); + strcpy(vname, dir); + dirp = 1; + } else { + ConcDirAndName(dir, name, aname); + if ((rval = true_name(aname)) == -1) { + strcpy(vname, aname); + dirp = 1; + } else { + /* + * Here, dir is an existing directory. We have to perform + * "new" recognition with the version information. + */ + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); - if (get_new(dir, VersionArray, aname, vname) == 0) - return(NIL); - dirp = 0; - } - } - break; + ConcNameAndVersion(name, ver, aname); + if (get_new(dir, VersionArray, aname, vname) == 0) return (NIL); + dirp = 0; + } + } + break; - case RECOG_OLD_NEW: - /* - * "Old/new" file means the "newest existing" or "not existing" file. - * Thus, if dir is not an existing directory, we can return the - * specified file name. If it is an existing one, we have to - * try "old" recognition on the directory first. If the recognition - * fails, we try "new" recognition. - */ - if (true_name(dir) != -1) { - strcpy(vname, file); - dirp = 0; - } else { - ConcDirAndName(dir, name, aname); - if ((rval = true_name(aname)) == -1) { - strcpy(vname, aname); - dirp = 1; - } else { - if (get_version_array(dir, name, VersionArray, - &VArrayInfo) == 0) - return(NIL); + case RECOG_OLD_NEW: + /* + * "Old/new" file means the "newest existing" or "not existing" file. + * Thus, if dir is not an existing directory, we can return the + * specified file name. If it is an existing one, we have to + * try "old" recognition on the directory first. If the recognition + * fails, we try "new" recognition. + */ + if (true_name(dir) != -1) { + strcpy(vname, file); + dirp = 0; + } else { + ConcDirAndName(dir, name, aname); + if ((rval = true_name(aname)) == -1) { + strcpy(vname, aname); + dirp = 1; + } else { + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) return (NIL); - ConcNameAndVersion(name, ver, aname); - if (get_old_new(dir, VersionArray, aname, vname) == 0) - return(NIL); - dirp = 0; - } - } - break; + ConcNameAndVersion(name, ver, aname); + if (get_old_new(dir, VersionArray, aname, vname) == 0) return (NIL); + dirp = 0; + } + } + break; - case RECOG_NON: - /* - * "Non" recognition is used to recognize a sysout file. The sysout - * file is dealt with specially, it does not have any version, even - * if it is on {DSK} device. Only we have to do here is to make - * sure the path to reach to the specified file is an existing - * directories. The file name itself is recognized as if. - */ - if (true_name(dir) != -1) return(NIL); - ConcDirAndName(dir, name, vname); - strcpy(aname, vname); - if (true_name(aname) == -1) { - strcpy(vname, aname); - dirp = 1; - } else { - dirp = 0; - } - if (lisppathname(vname, lfname, dirp, 0) == 0) return(NIL); - STRING_BASE(args[2], base); - len = strlen(lfname); + case RECOG_NON: + /* + * "Non" recognition is used to recognize a sysout file. The sysout + * file is dealt with specially, it does not have any version, even + * if it is on {DSK} device. Only we have to do here is to make + * sure the path to reach to the specified file is an existing + * directories. The file name itself is recognized as if. + */ + if (true_name(dir) != -1) return (NIL); + ConcDirAndName(dir, name, vname); + strcpy(aname, vname); + if (true_name(aname) == -1) { + strcpy(vname, aname); + dirp = 1; + } else { + dirp = 0; + } + if (lisppathname(vname, lfname, dirp, 0) == 0) return (NIL); + STRING_BASE(args[2], base); + len = strlen(lfname); #ifndef BYTESWAP - strncpy(base, lfname, len + 1); + strncpy(base, lfname, len + 1); #else - StrNCpyFromCToLisp(base, lfname, len + 1); + StrNCpyFromCToLisp(base, lfname, len + 1); #endif /* BYTESWAP */ - return(GetSmallp(len)); - } + return (GetSmallp(len)); + } - /* - * DSK device does not recognize a directory file as a file. Thus we should - * return NIL when the recognized file is a directory. - */ - if (dirp) return(NIL); + /* + * DSK device does not recognize a directory file as a file. Thus we should + * return NIL when the recognized file is a directory. + */ + if (dirp) return (NIL); - /* - * Now, vname holds the "versioned" full name of the recognized file in UNIX - * format. We have to convert it back to Lisp format. The version field - * have to be converted. The fourth argument for lisppathname specifies it. - */ +/* + * Now, vname holds the "versioned" full name of the recognized file in UNIX + * format. We have to convert it back to Lisp format. The version field + * have to be converted. The fourth argument for lisppathname specifies it. + */ #ifdef DOS /* For DOS, have to assure we use the name asked for, not the */ /* faked-up oversion-0 name, so reported names match. */ - { - char dver[VERSIONLEN]; - separate_version(vname, dver, 0); - ConcDirAndName(dir, name, aname); - ConcNameAndVersion(aname, dver, vname); - } + { + char dver[VERSIONLEN]; + separate_version(vname, dver, 0); + ConcDirAndName(dir, name, aname); + ConcNameAndVersion(aname, dver, vname); + } #endif /* DOS */ - if (lisppathname(vname, lfname, dirp, (dirp ? 0 : 1)) == 0) return(NIL); + if (lisppathname(vname, lfname, dirp, (dirp ? 0 : 1)) == 0) return (NIL); - STRING_BASE(args[2], base); - len = strlen(lfname); + STRING_BASE(args[2], base); + len = strlen(lfname); #ifndef BYTESWAP - strncpy(base, lfname, len + 1); + strncpy(base, lfname, len + 1); #else - StrNCpyFromCToLisp(base, lfname, len + 1); + StrNCpyFromCToLisp(base, lfname, len + 1); #endif /* BYTESWAP */ - - return(GetSmallp(len)); + return (GetSmallp(len)); } - - - -/* +/* * Name: DSK_deletefile * * Argument: LispPTR *args args[0] @@ -1247,135 +1197,130 @@ LispPTR DSK_getfilename(args) * a specified file. */ -LispPTR DSK_deletefile(args) - register LispPTR *args; +LispPTR DSK_deletefile(args) register LispPTR *args; { - char file[MAXPATHLEN], fbuf[MAXPATHLEN], vless[MAXPATHLEN]; - char dir[MAXPATHLEN], ver[VERSIONLEN]; - int rval, fatp; - register FileName *varray; + char file[MAXPATHLEN], fbuf[MAXPATHLEN], vless[MAXPATHLEN]; + char dir[MAXPATHLEN], ver[VERSIONLEN]; + int rval, fatp; + register FileName *varray; #ifdef DOS - char drive[1], rawname[MAXNAMLEN]; - int extlen; /* len of extension, for making backup filename */ -#endif /* DOS */ - - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ - LispStringLength(args[0], rval, fatp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = fatp ? rval + 4 + 1 : rval + 2 + 1; - if (rval > MAXPATHLEN) FileNameTooLong(NIL); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); - LispStringToCString(args[0], fbuf, MAXPATHLEN); + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + if (rval > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); #ifdef DOS - separate_drive(fbuf, drive); - unixpathname(fbuf, file, 1, 0, drive, &extlen, rawname); + separate_drive(fbuf, drive); + unixpathname(fbuf, file, 1, 0, drive, &extlen, rawname); #else - unixpathname(fbuf, file, 1, 0); + unixpathname(fbuf, file, 1, 0); #endif + if (unpack_filename(file, dir, fbuf, ver, 1) == 0) return (NIL); + if (get_version_array(dir, fbuf, VersionArray, &VArrayInfo) == 0) return (NIL); + varray = VersionArray; - if (unpack_filename(file, dir, fbuf, ver, 1) == 0) return(NIL); - if (get_version_array(dir, fbuf, VersionArray, &VArrayInfo) == 0) return(NIL); - varray = VersionArray; - - if (NoFileP(varray)) return(NIL); /* - * If the specified file is deleted from - * outside of Lisp during the last time - * Lisp recognize it and now, this case - * will occure. - */ + if (NoFileP(varray)) + return (NIL); /* + * If the specified file is deleted from + * outside of Lisp during the last time + * Lisp recognize it and now, this case + * will occure. + */ - /* - * Although the file should have been recognized with "oldest" mode in Lisp - * code, we have to recognize it again to know the "real" accessible name - * of it. - */ + /* + * Although the file should have been recognized with "oldest" mode in Lisp + * code, we have to recognize it again to know the "real" accessible name + * of it. + */ - ConcNameAndVersion(fbuf, ver, file); - if (get_oldest(dir, varray, file, fbuf) == 0) return(NIL); + ConcNameAndVersion(fbuf, ver, file); + if (get_oldest(dir, varray, file, fbuf) == 0) return (NIL); - if (get_versionless(varray, vless, dir) == 0) { - /* - * There is no versionless file. All we have to do is to simply - * try to unlink the specified file. - */ - TIMEOUT(rval = unlink(file)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - return(ATOM_T); - } + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file. All we have to do is to simply + * try to unlink the specified file. + */ + TIMEOUT(rval = unlink(file)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + return (ATOM_T); + } - /* - * If a versionless file exists, we have to check the link status of it, - * because deleting a versionless file or a file to which a versionless - * file is linked will destroy the concistency of the version status. - */ + /* + * If a versionless file exists, we have to check the link status of it, + * because deleting a versionless file or a file to which a versionless + * file is linked will destroy the concistency of the version status. + */ - if (check_vless_link(vless, varray, fbuf, &rval) == 0) return(NIL); + if (check_vless_link(vless, varray, fbuf, &rval) == 0) return (NIL); - if (strcmp(file, vless) == 0 || strcmp(file, fbuf) == 0) { - if (*fbuf != '\0') { - /* - * Both of the versionless file and the file to which the - * versionless file is linked have to be unlinked. - */ - TIMEOUT(rval = unlink(vless)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - TIMEOUT(rval = unlink(fbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - /* - * Finally, we have to maintain the version status. - */ - if (maintain_version(vless, (FileName *)NULL, 0) == 0) - return(NIL); - return(ATOM_T); - } else { - /* - * Although the versionfile is specified, it is not linked - * to any file in varray. We should not maintain the version - * status after deleting the versionless file, because - * we cannot say wheter the versionless file is actually under - * control of the Medley DSK file system or not. - */ - TIMEOUT(rval = unlink(vless)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - return(ATOM_T); - } - } else { - /* - * Just unlink the specified file. - */ - TIMEOUT(rval = unlink(file)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - return(ATOM_T); - } + if (strcmp(file, vless) == 0 || strcmp(file, fbuf) == 0) { + if (*fbuf != '\0') { + /* + * Both of the versionless file and the file to which the + * versionless file is linked have to be unlinked. + */ + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + TIMEOUT(rval = unlink(fbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + /* + * Finally, we have to maintain the version status. + */ + if (maintain_version(vless, (FileName *)NULL, 0) == 0) return (NIL); + return (ATOM_T); + } else { + /* + * Although the versionfile is specified, it is not linked + * to any file in varray. We should not maintain the version + * status after deleting the versionless file, because + * we cannot say wheter the versionless file is actually under + * control of the Medley DSK file system or not. + */ + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + return (ATOM_T); + } + } else { + /* + * Just unlink the specified file. + */ + TIMEOUT(rval = unlink(file)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + return (ATOM_T); + } } - - - -/* +/* * Name: DSK_renamefile * * Argument: LispPTR *args args[0] @@ -1398,206 +1343,199 @@ LispPTR DSK_deletefile(args) * a specified file. */ -LispPTR DSK_renamefile(args) - register LispPTR *args; +LispPTR DSK_renamefile(args) register LispPTR *args; { - char src[MAXPATHLEN], dst[MAXPATHLEN]; - char fbuf[MAXPATHLEN], vless[MAXPATHLEN], svless[MAXPATHLEN]; - char dir[MAXPATHLEN], ver[VERSIONLEN]; - int rval, fatp; - register int need_maintain_flg; - register FileName *varray; + char src[MAXPATHLEN], dst[MAXPATHLEN]; + char fbuf[MAXPATHLEN], vless[MAXPATHLEN], svless[MAXPATHLEN]; + char dir[MAXPATHLEN], ver[VERSIONLEN]; + int rval, fatp; + register int need_maintain_flg; + register FileName *varray; #ifdef DOS - char drive1[1], drive2[1]; - int extlen1, extlen2; /* len of extension */ - char rawname1[MAXNAMLEN], rawname2[MAXNAMLEN]; + char drive1[1], drive2[1]; + int extlen1, extlen2; /* len of extension */ + char rawname1[MAXNAMLEN], rawname2[MAXNAMLEN]; #endif /* DOS */ - - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - - LispStringLength(args[0], rval, fatp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = fatp ? rval + 4 + 1 : rval + 2 + 1; - if (rval > MAXPATHLEN) FileNameTooLong(NIL); - LispStringLength(args[1], rval, fatp); - rval = fatp ? rval + 4 + 1 : rval + 2 + 1; - if (rval > MAXPATHLEN) FileNameTooLong(NIL); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - LispStringToCString(args[0], fbuf, MAXPATHLEN); + LispStringLength(args[0], rval, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + if (rval > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringLength(args[1], rval, fatp); + rval = fatp ? rval + 4 + 1 : rval + 2 + 1; + if (rval > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); #ifdef DOS separate_drive(fbuf, drive1); unixpathname(fbuf, src, 1, 0, drive1, &extlen1, rawname1); -#else /* DOS */ +#else /* DOS */ unixpathname(fbuf, src, 1, 0); #endif /* DOS */ - LispStringToCString(args[1], fbuf, MAXPATHLEN); + LispStringToCString(args[1], fbuf, MAXPATHLEN); #ifdef DOS separate_drive(fbuf, drive2); unixpathname(fbuf, dst, 1, 0, drive2, &extlen2, rawname2); -#else /* DOS */ +#else /* DOS */ unixpathname(fbuf, dst, 1, 0); #endif /* DOS */ + if (unpack_filename(dst, dir, fbuf, ver, 1) == 0) return (NIL); + /* + * The destination file has been recognized as new file. Thus we have + * to make sure that the directory exisits. + */ + if (make_directory(dir) == 0) return (NIL); + /* + * We maintain the destination to handle the link damaged case correctly. + */ + ConcDirAndName(dir, fbuf, dst); + if (maintain_version(dst, (FileName *)NULL, 0) == 0) return (NIL); - if (unpack_filename(dst, dir, fbuf, ver, 1) == 0) return(NIL); - /* - * The destination file has been recognized as new file. Thus we have - * to make sure that the directory exisits. - */ - if (make_directory(dir) == 0) return(NIL); + if (get_version_array(dir, fbuf, VersionArray, &VArrayInfo) == 0) return (NIL); + varray = VersionArray; - /* - * We maintain the destination to handle the link damaged case correctly. - */ - ConcDirAndName(dir, fbuf, dst); - if (maintain_version(dst, (FileName *)NULL, 0) == 0) return(NIL); + /* + * Although the file should have been recognized with "new" mode in Lisp + * code, we have to recognize it again to know the "real" accessible name + * of it. + */ - if (get_version_array(dir, fbuf, VersionArray, &VArrayInfo) == 0) return(NIL); - varray = VersionArray; - - /* - * Although the file should have been recognized with "new" mode in Lisp - * code, we have to recognize it again to know the "real" accessible name - * of it. - */ + ConcNameAndVersion(fbuf, ver, dst); + if (get_new(dir, varray, dst, fbuf) == 0) return (NIL); - ConcNameAndVersion(fbuf, ver, dst); - if (get_new(dir, varray, dst, fbuf) == 0) return(NIL); + /* + * At this point, there are three cases for the destination. If there is + * no member of the destination family, there is nothing to do. If there + * is only a versionless file and, if the "real" destination is not the + * versionless, we have to rename it to version 1. And last case, if the + * "real" destination file is the file to which the versinless file is linked, + * we have to unlink the versionless file. + */ + if (!NoFileP(varray)) { + if (OnlyVersionlessP(varray)) { + get_versionless(varray, vless, dir); + if (strcmp(dst, vless) != 0) { + ConcNameAndVersion(vless, "1", fbuf); + TIMEOUT(rval = rename(vless, fbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + } + } else { + /* + * We are sure that the versionless file is linked to one of + * the higher versioned file here. + */ + get_versionless(varray, vless, dir); + if (check_vless_link(vless, varray, fbuf, &rval) == 0) { return (NIL); } + if (strcmp(dst, fbuf) == 0) { + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + } + } + } - /* - * At this point, there are three cases for the destination. If there is - * no member of the destination family, there is nothing to do. If there - * is only a versionless file and, if the "real" destination is not the - * versionless, we have to rename it to version 1. And last case, if the - * "real" destination file is the file to which the versinless file is linked, - * we have to unlink the versionless file. - */ - if (!NoFileP(varray)) { - if (OnlyVersionlessP(varray)) { - get_versionless(varray, vless, dir); - if (strcmp(dst, vless) != 0) { - ConcNameAndVersion(vless, "1", fbuf); - TIMEOUT(rval = rename(vless, fbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - } - } else { - /* - * We are sure that the versionless file is linked to one of - * the higher versioned file here. - */ - get_versionless(varray, vless, dir); - if (check_vless_link(vless, varray, fbuf, &rval) == 0) { - return(NIL); - } - if (strcmp(dst, fbuf) == 0) { - TIMEOUT(rval = unlink(vless)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - } - } - } + if (unpack_filename(src, dir, fbuf, ver, 1) == 0) return (NIL); + if (get_version_array(dir, fbuf, varray, &VArrayInfo) == 0) return (NIL); - if (unpack_filename(src, dir, fbuf, ver, 1) == 0) return(NIL); - if (get_version_array(dir, fbuf, varray, &VArrayInfo) == 0) return(NIL); - - if (NoFileP(varray)) return(NIL); /* - * If the specified file is deleted from - * outside of Lisp during the last time - * Lisp recognize it and now, this case - * will occure. - */ + if (NoFileP(varray)) + return (NIL); /* + * If the specified file is deleted from + * outside of Lisp during the last time + * Lisp recognize it and now, this case + * will occure. + */ - /* - * Although the file should have been recognized with "old" mode in Lisp - * code, we have to recognize it again to know the "real" accessible name - * of it. - */ - ConcNameAndVersion(fbuf, ver, src); - if (get_old(dir, varray, src, fbuf) == 0) return(NIL); + /* + * Although the file should have been recognized with "old" mode in Lisp + * code, we have to recognize it again to know the "real" accessible name + * of it. + */ + ConcNameAndVersion(fbuf, ver, src); + if (get_old(dir, varray, src, fbuf) == 0) return (NIL); - if (get_versionless(varray, vless, dir) == 0) { - /* - * There is no versionless file. All we have to do is to simply - * try to rename the specified file. - */ - need_maintain_flg = 0; - } else { - /* - * If a versionless file exists, we have to check the link status - * of it, because renaming a versionless file or a file to which a - * versionless file is linked will destroy the concistency of the - * version status. - */ - if (check_vless_link(vless, varray, fbuf, &rval) == 0) return(NIL); + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file. All we have to do is to simply + * try to rename the specified file. + */ + need_maintain_flg = 0; + } else { + /* + * If a versionless file exists, we have to check the link status + * of it, because renaming a versionless file or a file to which a + * versionless file is linked will destroy the concistency of the + * version status. + */ + if (check_vless_link(vless, varray, fbuf, &rval) == 0) return (NIL); - if (strcmp(src, vless) == 0 && *fbuf != '\0') { - /* - * At this point, we only unlink the file to which the - * versionless is linked. The versionless fill will be - * renamed later. - */ - TIMEOUT(rval = unlink(fbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - need_maintain_flg = 1; - } else if (strcmp(src, fbuf) == 0) { - TIMEOUT(rval = unlink(vless)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - need_maintain_flg = 1; - } else { - need_maintain_flg = 0; - } - strcpy(svless, vless); - } + if (strcmp(src, vless) == 0 && *fbuf != '\0') { + /* + * At this point, we only unlink the file to which the + * versionless is linked. The versionless fill will be + * renamed later. + */ + TIMEOUT(rval = unlink(fbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + need_maintain_flg = 1; + } else if (strcmp(src, fbuf) == 0) { + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + need_maintain_flg = 1; + } else { + need_maintain_flg = 0; + } + strcpy(svless, vless); + } - /* - * At this point, src holds the full file name to be renamed, and dst holds - * the full file name to which src will be renamed. - */ + /* + * At this point, src holds the full file name to be renamed, and dst holds + * the full file name to which src will be renamed. + */ - TIMEOUT(rval = rename(src, dst)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } + TIMEOUT(rval = rename(src, dst)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } - /* - * The destination directory always have to be maintained, because it is - * now under control of DSK device. - * The source directory have to be maintained only if need_maintain_flg - * is on. - */ + /* + * The destination directory always have to be maintained, because it is + * now under control of DSK device. + * The source directory have to be maintained only if need_maintain_flg + * is on. + */ - if (maintain_version(dst, (FileName *)NULL, 0) == 0) return(NIL); - if (need_maintain_flg) { - if (maintain_version(src, (FileName *)NULL, 0) == 0) return(NIL); - } + if (maintain_version(dst, (FileName *)NULL, 0) == 0) return (NIL); + if (need_maintain_flg) { + if (maintain_version(src, (FileName *)NULL, 0) == 0) return (NIL); + } - return(ATOM_T); + return (ATOM_T); } - - - /* * Name: DSK_directorynamep * @@ -1630,64 +1568,59 @@ LispPTR DSK_renamefile(args) * the directory name representation. */ -LispPTR DSK_directorynamep(args) - register LispPTR *args; +LispPTR DSK_directorynamep(args) register LispPTR *args; { - char dirname[MAXPATHLEN]; - char fullname[MAXPATHLEN]; - register int len, fatp; - register char *base; + char dirname[MAXPATHLEN]; + char fullname[MAXPATHLEN]; + register int len, fatp; + register char *base; #ifdef DOS - char drive[1], rawname[MAXNAMLEN]; - int extlen; /* len of extension, for making backup filename */ -#endif /* DOS */ + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - LispStringLength(args[0], len, fatp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - len = fatp ? len + 4 + 1 : len + 2 + 1; - /* -2 for the initial and trail directory delimitor. */ - if (len > MAXPATHLEN - 2) FileNameTooLong(NIL); + LispStringLength(args[0], len, fatp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + len = fatp ? len + 4 + 1 : len + 2 + 1; + /* -2 for the initial and trail directory delimitor. */ + if (len > MAXPATHLEN - 2) FileNameTooLong(NIL); - LispStringToCString(args[0], dirname, MAXPATHLEN); + LispStringToCString(args[0], dirname, MAXPATHLEN); - /* Convert Xerox Lisp file naming convention to Unix one. */ +/* Convert Xerox Lisp file naming convention to Unix one. */ #ifdef DOS separate_drive(dirname, drive); - if (unixpathname(dirname, fullname, 1, 0, drive, 0, 0) == 0) return(NIL); -#else /* DOS*/ - if (unixpathname(dirname, fullname, 1, 0) == 0) return(NIL); + if (unixpathname(dirname, fullname, 1, 0, drive, 0, 0) == 0) return (NIL); +#else /* DOS*/ + if (unixpathname(dirname, fullname, 1, 0) == 0) return (NIL); #endif /* DOS */ - - if (true_name(fullname) != -1) return(NIL); - - /* Convert Unix file naming convention to Xerox Lisp one. */ - if (lisppathname(fullname, dirname, 1, 0) == 0) return(NIL); - - len = strlen(dirname); - STRING_BASE(args[1], base); - -#ifndef BYTESWAP - strncpy(base, dirname, len + 1); + + if (true_name(fullname) != -1) return (NIL); + + /* Convert Unix file naming convention to Xerox Lisp one. */ + if (lisppathname(fullname, dirname, 1, 0) == 0) return (NIL); + + len = strlen(dirname); + STRING_BASE(args[1], base); + +#ifndef BYTESWAP + strncpy(base, dirname, len + 1); #else - StrNCpyFromCToLisp(base, dirname, len + 1); + StrNCpyFromCToLisp(base, dirname, len + 1); #endif /* BYTESWAP */ - - return(GetSmallp(len)); + return (GetSmallp(len)); } - - - -/* +/* * Name: COM_getfileinfo * * Argument: LispPTR *args args[0] @@ -1720,187 +1653,177 @@ LispPTR DSK_directorynamep(args) * Lisp sense. */ -LispPTR COM_getfileinfo(args) - register LispPTR *args; +LispPTR COM_getfileinfo(args) register LispPTR *args; { - register int dskp, rval; - register unsigned *bufp; + register int dskp, rval; + register unsigned *bufp; #ifndef DOS - register struct passwd *pwd; + register struct passwd *pwd; #endif - register char *base; - char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; - char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; - struct stat sbuf; - LispPTR laddr; + register char *base; + char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + struct stat sbuf; + LispPTR laddr; #ifdef DOS - char drive[1], rawname[MAXNAMLEN]; - int extlen; /* len of extension, for making backup filename */ -#endif /* DOS */ + char drive[1], rawname[MAXNAMLEN]; + int extlen; /* len of extension, for making backup filename */ +#endif /* DOS */ - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - - LispStringLength(args[0], rval, dskp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = dskp ? rval + 4 + 1 : rval + 2 + 1; - /* Add 5 for the host name field in Lisp format. */ - if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - LispStringToCString(args[0], lfname, MAXPATHLEN); + LispStringLength(args[0], rval, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); #ifdef DOS - separate_host(lfname, host, drive); + separate_host(lfname, host, drive); #else - separate_host(lfname, host); + separate_host(lfname, host); #endif - UPCASE(host); - if (strcmp(host, "DSK") == 0) - dskp = 1; - else if (strcmp(host, "UNIX") == 0) - dskp = 0; - else - return(NIL); - - /* - * Convert a Lisp file name to UNIX one. If host is DSK, we also have to - * convert a version field. - */ + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); + +/* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ #ifdef DOS - unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname) ; -#else /* DOS */ - unixpathname(lfname, file, dskp, 0); + unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); +#else /* DOS */ + unixpathname(lfname, file, dskp, 0); #endif /* DOS */ - /* - * The file name which has been passed from Lisp is sometimes different - * from the actual file name on DSK, even after the Lisp name is converted - * to UNIX form with unixpathname. The Lisp code for GETFILEINFO always - * recognizes a file with old mode. Thus, we recognize it again using - * get_old routine. It will let us know the "real accessible" name of - * the file. - */ - if (dskp) { - if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); - if (true_name(dir) != -1) return(0); - if (strcmp(name, "") == 0) { - /* - * The directory is specified. - */ - strcpy(file, dir); - } else { - if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) - return(NIL); - ConcNameAndVersion(name, ver, file); - if (get_old(dir, VersionArray, file, name) == 0) - return(NIL); - } - } + /* + * The file name which has been passed from Lisp is sometimes different + * from the actual file name on DSK, even after the Lisp name is converted + * to UNIX form with unixpathname. The Lisp code for GETFILEINFO always + * recognizes a file with old mode. Thus, we recognize it again using + * get_old routine. It will let us know the "real accessible" name of + * the file. + */ + if (dskp) { + if (unpack_filename(file, dir, name, ver, 1) == 0) return (NIL); + if (true_name(dir) != -1) return (0); + if (strcmp(name, "") == 0) { + /* + * The directory is specified. + */ + strcpy(file, dir); + } else { + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) return (NIL); + ConcNameAndVersion(name, ver, file); + if (get_old(dir, VersionArray, file, name) == 0) return (NIL); + } + } - TIMEOUT(rval = stat(file, &sbuf)); - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } + TIMEOUT(rval = stat(file, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } - switch (args[1]) { + switch (args[1]) { + case LENGTH: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = (unsigned)sbuf.st_size; + return (ATOM_T); - case LENGTH: - bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); - *bufp = (unsigned)sbuf.st_size; - return(ATOM_T); + case WDATE: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = (unsigned)ToLispTime(sbuf.st_mtime); + return (ATOM_T); - case WDATE: - bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); - *bufp = (unsigned)ToLispTime(sbuf.st_mtime); - return(ATOM_T); + case RDATE: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = (unsigned)ToLispTime(sbuf.st_atime); + return (ATOM_T); - case RDATE: - bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); - *bufp = (unsigned)ToLispTime(sbuf.st_atime); - return(ATOM_T); + case PROTECTION: + bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); + *bufp = sbuf.st_mode; + return (ATOM_T); - case PROTECTION: - bufp = (unsigned *)(Addr68k_from_LADDR(args[2])); - *bufp = sbuf.st_mode; - return(ATOM_T); - - case AUTHOR: + case AUTHOR: #ifndef DOS - TIMEOUT(pwd = getpwuid(sbuf.st_uid)); - if (pwd == (struct passwd *)NULL) { - /* - * Returns Lisp 0. Lisp code handles this case as author - * unknown. The returned value from Lisp GETFILEINFO - * function would be "". - */ - return(GetSmallp(0)); - } - STRING_BASE(args[2], base); - rval = strlen(pwd->pw_name); + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { + /* + * Returns Lisp 0. Lisp code handles this case as author + * unknown. The returned value from Lisp GETFILEINFO + * function would be "". + */ + return (GetSmallp(0)); + } + STRING_BASE(args[2], base); + rval = strlen(pwd->pw_name); #ifndef BYTESWAP - strncpy(base, pwd->pw_name, rval); + strncpy(base, pwd->pw_name, rval); #else - StrNCpyFromCToLisp(base, pwd->pw_name, rval); + StrNCpyFromCToLisp(base, pwd->pw_name, rval); #endif /* BYTESWAP */ #endif /* DOS */ - return(GetSmallp(rval)); + return (GetSmallp(rval)); - case ALL: - /* - * The format of the buffer which has been allocated by Lisp - * is as follows. - * ((LENGTH . fixp) - * (WDATE . fixp) - * (RDATE . fixp) - * (PROTECTION . fixp) - * (AUTHOR . string)) - */ - laddr = cdr(car(args[2])); - bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); - *bufp= sbuf.st_size; + case ALL: + /* + * The format of the buffer which has been allocated by Lisp + * is as follows. + * ((LENGTH . fixp) + * (WDATE . fixp) + * (RDATE . fixp) + * (PROTECTION . fixp) + * (AUTHOR . string)) + */ + laddr = cdr(car(args[2])); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp = sbuf.st_size; - laddr = cdr(car(cdr(args[2]))); - bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); - *bufp = ToLispTime(sbuf.st_mtime); + laddr = cdr(car(cdr(args[2]))); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp = ToLispTime(sbuf.st_mtime); - laddr = cdr(car(cdr(cdr(args[2])))); - bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); - *bufp= ToLispTime(sbuf.st_atime); + laddr = cdr(car(cdr(cdr(args[2])))); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp = ToLispTime(sbuf.st_atime); - laddr = cdr(car(cdr(cdr(cdr(args[2]))))); - bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); - *bufp= sbuf.st_mode; + laddr = cdr(car(cdr(cdr(cdr(args[2]))))); + bufp = (unsigned *)(Addr68k_from_LADDR(laddr)); + *bufp = sbuf.st_mode; #ifndef DOS - TIMEOUT(pwd = getpwuid(sbuf.st_uid)); - if(pwd == (struct passwd *)NULL) { - return(GetSmallp(0)); - } - laddr = cdr(car(cdr(cdr(cdr(cdr(args[2])))))); - STRING_BASE(laddr, base); - rval = strlen(pwd->pw_name); + TIMEOUT(pwd = getpwuid(sbuf.st_uid)); + if (pwd == (struct passwd *)NULL) { return (GetSmallp(0)); } + laddr = cdr(car(cdr(cdr(cdr(cdr(args[2])))))); + STRING_BASE(laddr, base); + rval = strlen(pwd->pw_name); #ifndef BYTESWAP - strncpy(base, pwd->pw_name, rval); + strncpy(base, pwd->pw_name, rval); #else - StrNCpyFromCToLisp(base, pwd->pw_name, rval); + StrNCpyFromCToLisp(base, pwd->pw_name, rval); #endif /* BYTESWAP */ #endif /* DOS */ - return(GetSmallp(rval)); + return (GetSmallp(rval)); - default: - return(NIL); - } + default: return (NIL); + } } - - - -/* +/* * Name: COM_setfileinfo * * Argument: LispPTR *args args[0] @@ -1929,122 +1852,113 @@ LispPTR COM_getfileinfo(args) * make sense. */ -LispPTR COM_setfileinfo(args) - register LispPTR *args; +LispPTR COM_setfileinfo(args) register LispPTR *args; { - register int dskp, rval, date; - char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; - char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; - struct stat sbuf; + register int dskp, rval, date; + char lfname[MAXPATHLEN + 5], file[MAXPATHLEN], host[MAXNAMLEN]; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + struct stat sbuf; #ifndef DOS - struct timeval time[2]; + struct timeval time[2]; #else - char drive[1], rawname[MAXNAMLEN]; - int extlen; + char drive[1], rawname[MAXNAMLEN]; + int extlen; #endif /* DOS */ - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - LispStringLength(args[0], rval, dskp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = dskp ? rval + 4 + 1 : rval + 2 + 1; - /* Add 5 for the host name field in Lisp format. */ - if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); + LispStringLength(args[0], rval, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - LispStringToCString(args[0], lfname, MAXPATHLEN); + LispStringToCString(args[0], lfname, MAXPATHLEN); #ifdef DOS - separate_host(lfname, host, drive); + separate_host(lfname, host, drive); #else - separate_host(lfname, host); + separate_host(lfname, host); #endif /* DOS */ - UPCASE(host); - if (strcmp(host, "DSK") == 0) - dskp = 1; - else if (strcmp(host, "UNIX") == 0) - dskp = 0; - else - return(NIL); - - /* - * Convert a Lisp file name to UNIX one. If host is DSK, we also have to - * convert a version field. - */ + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); + +/* + * Convert a Lisp file name to UNIX one. If host is DSK, we also have to + * convert a version field. + */ #ifdef DOS - unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); -#else /* DOS */ - unixpathname(lfname, file, dskp, 0); + unixpathname(lfname, file, dskp, 0, drive, &extlen, rawname); +#else /* DOS */ + unixpathname(lfname, file, dskp, 0); #endif /* DOS */ - /* - * The file name which has been passed from Lisp is sometimes different - * from the actual file name on DSK, even after the Lisp name is converted - * to UNIX form with unixpathname. The Lisp code for SETFILEINFO always - * recognizes a file with old mode. Thus, we recognize it again using - * get_old routine. It will let us know the "real accessible" name of - * the file. - */ - if (dskp) { - if (unpack_filename(file, dir, name, ver, 1) == 0) return(NIL); - if (true_name(dir) != -1) return(0); - if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) - return(NIL); - ConcNameAndVersion(name, ver, file); - if (get_old(dir, VersionArray, file, name) == 0) - return(NIL); - } + /* + * The file name which has been passed from Lisp is sometimes different + * from the actual file name on DSK, even after the Lisp name is converted + * to UNIX form with unixpathname. The Lisp code for SETFILEINFO always + * recognizes a file with old mode. Thus, we recognize it again using + * get_old routine. It will let us know the "real accessible" name of + * the file. + */ + if (dskp) { + if (unpack_filename(file, dir, name, ver, 1) == 0) return (NIL); + if (true_name(dir) != -1) return (0); + if (get_version_array(dir, name, VersionArray, &VArrayInfo) == 0) return (NIL); + ConcNameAndVersion(name, ver, file); + if (get_old(dir, VersionArray, file, name) == 0) return (NIL); + } - - switch (args[1]) { - - case WDATE: - TIMEOUT(rval = stat(file, &sbuf)); - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } + switch (args[1]) { + case WDATE: + TIMEOUT(rval = stat(file, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } #ifndef DOS - date = LispNumToCInt(args[2]); - time[0].tv_sec = (long)sbuf.st_atime; - time[0].tv_usec = 0L; - time[1].tv_sec = (long)ToUnixTime(date); - time[1].tv_usec = 0L; + date = LispNumToCInt(args[2]); + time[0].tv_sec = (long)sbuf.st_atime; + time[0].tv_usec = 0L; + time[1].tv_sec = (long)ToUnixTime(date); + time[1].tv_usec = 0L; #ifdef USE_UTIME - TIMEOUT(rval = utime(file, time)); -#else - TIMEOUT(rval = utimes(file, time)); + TIMEOUT(rval = utime(file, time)); +#else + TIMEOUT(rval = utimes(file, time)); #endif /* HPUX */ #endif /* DOS */ - if(rval != 0) { - *Lisp_errno = errno; - return(NIL); - } - return(ATOM_T); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } + return (ATOM_T); - case PROTECTION: - rval = LispNumToCInt(args[2]); - TIMEOUT(rval = chmod(file, rval)); - if(rval != 0) { - *Lisp_errno = errno; - return(NIL); - } - return(ATOM_T); + case PROTECTION: + rval = LispNumToCInt(args[2]); + TIMEOUT(rval = chmod(file, rval)); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } + return (ATOM_T); - default: - return(NIL); - } + default: return (NIL); + } } - - - -/* +/* * Name: COM_readpage * * Argument: LispPTR *args args[0] @@ -2073,63 +1987,60 @@ LispPTR COM_setfileinfo(args) * remaining region of a buffer will be zero outed. The size of a page is 512 bytes. */ -LispPTR COM_readpage(args) - register LispPTR *args; +LispPTR COM_readpage(args) register LispPTR *args; { - register char *bufp; - register char *bp; - register int count, fd, npage, rval; - struct stat sbuf; + register char *bufp; + register char *bp; + register int count, fd, npage, rval; + struct stat sbuf; - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - - fd = LispNumToCInt(args[0]); - npage = LispNumToCInt(args[1]); - bufp = (char*)(Addr68k_from_LADDR(args[2])); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - TIMEOUT(rval = fstat(fd, &sbuf)); - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } + fd = LispNumToCInt(args[0]); + npage = LispNumToCInt(args[1]); + bufp = (char *)(Addr68k_from_LADDR(args[2])); - if((sbuf.st_mode & S_IFREG) != 0){ - /* - * The request file is a regular file. We have to make sure that - * next byte read is at the beggning of the requested page of the - * file. If the request file is special file, lseek is not needed. - */ -sklp: TIMEOUT(rval = lseek(fd, (npage * FDEV_PAGE_SIZE), L_SET)); - if(rval == -1) { - if (errno == EINTR) goto sklp; /* interrupted, retry */ - *Lisp_errno = errno; - return(NIL); - } - } + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } -rdlp: TIMEOUT(count = read(fd, bufp, FDEV_PAGE_SIZE)); - if(count == -1) { - if (errno == EINTR) goto rdlp; /* interrupted; retry */ - *Lisp_errno = errno; - return(NIL); - } + if ((sbuf.st_mode & S_IFREG) != 0) { + /* + * The request file is a regular file. We have to make sure that + * next byte read is at the beggning of the requested page of the + * file. If the request file is special file, lseek is not needed. + */ + sklp: + TIMEOUT(rval = lseek(fd, (npage * FDEV_PAGE_SIZE), L_SET)); + if (rval == -1) { + if (errno == EINTR) goto sklp; /* interrupted, retry */ + *Lisp_errno = errno; + return (NIL); + } + } - /* O out the remaining part of the buffer. */ - for(bp = &bufp[count], rval = count; rval < FDEV_PAGE_SIZE; ++rval) *bp++ = 0; +rdlp: + TIMEOUT(count = read(fd, bufp, FDEV_PAGE_SIZE)); + if (count == -1) { + if (errno == EINTR) goto rdlp; /* interrupted; retry */ + *Lisp_errno = errno; + return (NIL); + } + + /* O out the remaining part of the buffer. */ + for (bp = &bufp[count], rval = count; rval < FDEV_PAGE_SIZE; ++rval) *bp++ = 0; #ifdef BYTESWAP - word_swap_page(bufp, FDEV_PAGE_SIZE / 4); + word_swap_page(bufp, FDEV_PAGE_SIZE / 4); #endif /* BYTESWAP */ - - return(GetSmallp(count)); + return (GetSmallp(count)); } - - - -/* +/* * Name: COM_writepage * * Argument: LispPTR *args args[0] @@ -2159,63 +2070,60 @@ rdlp: TIMEOUT(count = read(fd, bufp, FDEV_PAGE_SIZE)); * The actual size of data written is specified with args[3]. */ -LispPTR COM_writepage(args) - register LispPTR *args; +LispPTR COM_writepage(args) register LispPTR *args; { - register int fd; - register int npage; - register char *bufp; - register int rval, count; + register int fd; + register int npage; + register char *bufp; + register int rval, count; - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); - - fd = LispNumToCInt(args[0]); - npage = LispNumToCInt(args[1]); - bufp = (char*)(Addr68k_from_LADDR(args[2])); - count = LispNumToCInt(args[3]); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[4])); -sklp2: TIMEOUT(rval = lseek(fd, (npage*FDEV_PAGE_SIZE), L_SET)); - if (rval == -1) { - if (errno == EINTR) goto sklp2; /* interrupted; retry */ - *Lisp_errno = errno; - return(NIL); - } + fd = LispNumToCInt(args[0]); + npage = LispNumToCInt(args[1]); + bufp = (char *)(Addr68k_from_LADDR(args[2])); + count = LispNumToCInt(args[3]); + +sklp2: + TIMEOUT(rval = lseek(fd, (npage * FDEV_PAGE_SIZE), L_SET)); + if (rval == -1) { + if (errno == EINTR) goto sklp2; /* interrupted; retry */ + *Lisp_errno = errno; + return (NIL); + } #ifdef DEMO - /* Do nothing if this is a demo emulator--not allowed to write files. */ +/* Do nothing if this is a demo emulator--not allowed to write files. */ #else - /* OK to write the page. */ +/* OK to write the page. */ #ifdef BYTESWAP - word_swap_page(bufp, (count + 3) >> 2); + word_swap_page(bufp, (count + 3) >> 2); #endif /* BYTESWAP */ - -wlp: TIMEOUT(rval = write(fd, bufp, count)); - if ( rval == -1) { - if (errno == EINTR) goto wlp; /* interrupted; retry */ - *Lisp_errno = errno; +wlp: + TIMEOUT(rval = write(fd, bufp, count)); + if (rval == -1) { + if (errno == EINTR) goto wlp; /* interrupted; retry */ + *Lisp_errno = errno; #ifdef BYTESWAP - word_swap_page(bufp, (count + 3) >> 2); + word_swap_page(bufp, (count + 3) >> 2); #endif /* BYTESWAP */ - return(NIL); - } + return (NIL); + } #ifdef BYTESWAP - word_swap_page(bufp, (count + 3) >> 2); + word_swap_page(bufp, (count + 3) >> 2); #endif /* BYTESWAP */ #endif /* DEMO */ - return(ATOM_T); + return (ATOM_T); } - - - -/* +/* * Name: COM_truncatefile * * Argument: LispPTR *args args[0] @@ -2237,74 +2145,69 @@ wlp: TIMEOUT(rval = write(fd, bufp, count)); * truncate a file. */ -LispPTR COM_truncatefile(args) - register LispPTR *args; +LispPTR COM_truncatefile(args) register LispPTR *args; { - register int fd; - register int length; - register int rval; - struct stat sbuf; + register int fd; + register int length; + register int rval; + struct stat sbuf; - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - - fd = LispNumToCInt(args[0]); - length = LispNumToCInt(args[1]); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - TIMEOUT(rval = fstat(fd, &sbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } + fd = LispNumToCInt(args[0]); + length = LispNumToCInt(args[1]); - if((sbuf.st_mode & S_IFREG) == 0){ - /* - * The request file is not a regular file. We don't need to - * truncate such file. - */ - return(ATOM_T); - } - if ((off_t)length != sbuf.st_size) - { -#ifndef ISC /* ISC has no ftruncate; sigh */ + TIMEOUT(rval = fstat(fd, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + + if ((sbuf.st_mode & S_IFREG) == 0) { + /* + * The request file is not a regular file. We don't need to + * truncate such file. + */ + return (ATOM_T); + } + if ((off_t)length != sbuf.st_size) { +#ifndef ISC /* ISC has no ftruncate; sigh */ #ifdef DOS - TIMEOUT(rval = chsize(fd, (off_t)length)); + TIMEOUT(rval = chsize(fd, (off_t)length)); #else - TIMEOUT(rval = ftruncate(fd, (off_t)length)); + TIMEOUT(rval = ftruncate(fd, (off_t)length)); #endif /* DOS */ - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } #endif /* ISC */ - /* - * TRUNCATEFILE FDEV method is invoked from FORCEOUTPUT Lisp function. - * Thus we have to sync the file state here. - */ +/* + * TRUNCATEFILE FDEV method is invoked from FORCEOUTPUT Lisp function. + * Thus we have to sync the file state here. + */ #ifdef INDIGO - TIMEOUT(rval = fsync(fd)); + TIMEOUT(rval = fsync(fd)); #elif OS5 - TIMEOUT(rval = fsync(fd)); + TIMEOUT(rval = fsync(fd)); #elif DOS #elif SYSVONLY - TIMEOUT(rval = fsync(fd)); + TIMEOUT(rval = fsync(fd)); #else - TIMEOUT(rval = fsync(fd)); + TIMEOUT(rval = fsync(fd)); #endif /* INDIGO */ - if (rval != 0) { - *Lisp_errno = errno; - return(NIL); - } - } - return(ATOM_T); + if (rval != 0) { + *Lisp_errno = errno; + return (NIL); + } + } + return (ATOM_T); } - - - -/* +/* * Name: COM_changedir * * Argument: LispPTR *args args[0] @@ -2321,75 +2224,71 @@ LispPTR COM_truncatefile(args) * Change the current directory of the process to the specified directory. */ -LispPTR COM_changedir(args) - register LispPTR *args; +LispPTR COM_changedir(args) register LispPTR *args; { - register int dskp, rval; - char lfname[MAXPATHLEN + 5], dir[MAXPATHLEN], host[MAXNAMLEN]; + register int dskp, rval; + char lfname[MAXPATHLEN + 5], dir[MAXPATHLEN], host[MAXNAMLEN]; #ifdef DOS - char drive[1], rawname[MAXNAMLEN]; - int extlen; + char drive[1], rawname[MAXNAMLEN]; + int extlen; #endif /* DOS */ + ERRSETJMP(NIL); + Lisp_errno = &Dummy_errno; - ERRSETJMP(NIL); - Lisp_errno = &Dummy_errno; + LispStringLength(args[0], rval, dskp); + /* + * Because of the version number convention, Lisp pathname might + * be shorter than UNIX one. For THIN string, the difference + * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL + * terminating character. + */ + rval = dskp ? rval + 4 + 1 : rval + 2 + 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - LispStringLength(args[0], rval, dskp); - /* - * Because of the version number convention, Lisp pathname might - * be shorter than UNIX one. For THIN string, the difference - * is 2 bytes, for FAT string, 4 bytes. Add 1 byte for NULL - * terminating character. - */ - rval = dskp ? rval + 4 + 1 : rval + 2 + 1; - /* Add 5 for the host name field in Lisp format. */ - if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - - LispStringToCString(args[0], lfname, MAXPATHLEN); + LispStringToCString(args[0], lfname, MAXPATHLEN); #ifdef DOS - separate_host(lfname, host, drive); -#else - separate_host(lfname, host); + separate_host(lfname, host, drive); +#else + separate_host(lfname, host); #endif /* DOS */ - UPCASE(host); - if (strcmp(host, "DSK") == 0) - dskp = 1; - else if (strcmp(host, "UNIX") == 0) - dskp = 0; - else - return(NIL); - + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); + #ifdef DOS - if (!unixpathname(lfname, dir, 0, 0, drive, 0, 0)) return(NIL); -#else /* DOS */ - if (!unixpathname(lfname, dir, 0, 0)) return(NIL); + if (!unixpathname(lfname, dir, 0, 0, drive, 0, 0)) return (NIL); +#else /* DOS */ + if (!unixpathname(lfname, dir, 0, 0)) return (NIL); #endif /* DOS */ - if (dskp) { - /* - * If {DSK} device, the directory name can be specified in a case - * insensitive manner. We have to convert it into a right case. - */ - if (true_name(dir) != -1) return(NIL); - } + if (dskp) { + /* + * If {DSK} device, the directory name can be specified in a case + * insensitive manner. We have to convert it into a right case. + */ + if (true_name(dir) != -1) return (NIL); + } - TIMEOUT(rval = chdir(dir)); - if (rval != 0) return(NIL); + TIMEOUT(rval = chdir(dir)); + if (rval != 0) return (NIL); #ifdef DOS - if (*drive) - { - - if (*drive <= 'Z') rval = _chdrive(*drive - ('A'-1)); - else rval = _chdrive(*drive-('a'-1)); - if (rval != 0) return(NIL); + if (*drive) { + if (*drive <= 'Z') + rval = _chdrive(*drive - ('A' - 1)); + else + rval = _chdrive(*drive - ('a' - 1)); + if (rval != 0) return (NIL); } #endif /* DOS */ - return(ATOM_T); + return (ATOM_T); } - - /************************************************************************/ /* */ /* C O M _ g e t f r e e b l o c k */ @@ -2398,7 +2297,7 @@ LispPTR COM_changedir(args) /* */ /************************************************************************/ -/* +/* * Name: COM_getfreeblock * * Argument: LispPTR *args args[0] @@ -2421,164 +2320,152 @@ LispPTR COM_changedir(args) * \MAIKO.CHECKFREESPACE in MOD44IO. * The version controll based on a file naming convention is not applicable to a * sysout file, even if the sysout file is specified on {DSK} device. The Lisp code - * strips the version field by invoking DSK_getfilename with NON recognition mode. + * strips the version field by invoking DSK_getfilename with NON recognition mode. */ -LispPTR COM_getfreeblock(args) - register LispPTR *args; +LispPTR COM_getfreeblock(args) register LispPTR *args; { - register int dskp, rval, *buf; - char lfname[MAXPATHLEN + 5], dir[MAXPATHLEN], host[MAXNAMLEN]; - char name[MAXNAMLEN + 1], file[MAXPATHLEN], ver[VERSIONLEN]; - char drive[2]; + register int dskp, rval, *buf; + char lfname[MAXPATHLEN + 5], dir[MAXPATHLEN], host[MAXNAMLEN]; + char name[MAXNAMLEN + 1], file[MAXPATHLEN], ver[VERSIONLEN]; + char drive[2]; #ifdef ULTRIX - struct fs_data sfsbuf; + struct fs_data sfsbuf; #else #ifndef AIXPS2 #ifndef DOS - struct statfs sfsbuf; + struct statfs sfsbuf; #endif /* DOS */ #endif /* AIXPS2 */ #endif /* ULTRIX */ #ifdef DOS - struct diskfree_t sfsbuf; + struct diskfree_t sfsbuf; #endif /* DOS */ + ERRSETJMP(NIL); + Lisp_errno = &Dummy_errno; + LispStringLength(args[0], rval, dskp); + /* + * Add 1 byte for NULL terminating character. + */ + rval += 1; + /* Add 5 for the host name field in Lisp format. */ + if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - ERRSETJMP(NIL); - Lisp_errno = &Dummy_errno; - - LispStringLength(args[0], rval, dskp); - /* - * Add 1 byte for NULL terminating character. - */ - rval += 1; - /* Add 5 for the host name field in Lisp format. */ - if (rval > MAXPATHLEN + 5) FileNameTooLong(NIL); - - LispStringToCString(args[0], lfname, MAXPATHLEN); - buf = (int *)(Addr68k_from_LADDR(args[1])); + LispStringToCString(args[0], lfname, MAXPATHLEN); + buf = (int *)(Addr68k_from_LADDR(args[1])); #ifdef DOS - separate_host(lfname, host, drive); + separate_host(lfname, host, drive); #else - separate_host(lfname, host); + separate_host(lfname, host); #endif /* DOS */ - UPCASE(host); - if (strcmp(host, "DSK") == 0) - dskp = 1; - else if (strcmp(host, "UNIX") == 0) - dskp = 0; - else - return(NIL); - + UPCASE(host); + if (strcmp(host, "DSK") == 0) + dskp = 1; + else if (strcmp(host, "UNIX") == 0) + dskp = 0; + else + return (NIL); + #ifdef DOS - if (!unixpathname(lfname, file, 0, 0, drive, 0, 0)) return(NIL); -#else /* DOS */ - if (!unixpathname(lfname, file, 0, 0)) return(NIL); + if (!unixpathname(lfname, file, 0, 0, drive, 0, 0)) return (NIL); +#else /* DOS */ + if (!unixpathname(lfname, file, 0, 0)) return (NIL); #endif /* DOS */ - if (!unpack_filename(file, dir, name, ver, 0)) return(NIL); - - if (dskp) { - /* - * Although Lisp code gurantees the directory is an existing one, - * by calling DSK_getfilename, we check it again for safety. - */ - if (true_name(dir) != -1) return(NIL); - } + if (!unpack_filename(file, dir, name, ver, 0)) return (NIL); - /* - * The specified file itself might be a file being created newly. Thus, - * we check the available block size, using the directory on which the file - * will be exist. - */ + if (dskp) { + /* + * Although Lisp code gurantees the directory is an existing one, + * by calling DSK_getfilename, we check it again for safety. + */ + if (true_name(dir) != -1) return (NIL); + } + +/* + * The specified file itself might be a file being created newly. Thus, + * we check the available block size, using the directory on which the file + * will be exist. + */ #ifdef DOS - /* For DOS, we have to use either the disk drive the file - will be on, or the default drive. */ + /* For DOS, we have to use either the disk drive the file + will be on, or the default drive. */ - if (drive[0]) - { - drive[1] = 0; - UPCASE(drive); - if (_dos_getdiskfree((unsigned)drive[0] - (int)'@', &sfsbuf)) - return(NIL); /* call failed, so name is invalid */ + if (drive[0]) { + drive[1] = 0; + UPCASE(drive); + if (_dos_getdiskfree((unsigned)drive[0] - (int)'@', &sfsbuf)) + return (NIL); /* call failed, so name is invalid */ - *buf = sfsbuf.avail_clusters * sfsbuf.sectors_per_cluster - * sfsbuf.bytes_per_sector; - } - else - { - if (_dos_getdiskfree(0, &sfsbuf)) - return(NIL); /* call failed, so name is invalid */ + *buf = sfsbuf.avail_clusters * sfsbuf.sectors_per_cluster * sfsbuf.bytes_per_sector; + } else { + if (_dos_getdiskfree(0, &sfsbuf)) return (NIL); /* call failed, so name is invalid */ - *buf = sfsbuf.avail_clusters * sfsbuf.sectors_per_cluster - * sfsbuf.bytes_per_sector; - - } + *buf = sfsbuf.avail_clusters * sfsbuf.sectors_per_cluster * sfsbuf.bytes_per_sector; + } #else #ifdef ULTRIX - TIMEOUT(rval = getmnt(0, &sfsbuf, 0, STAT_ONE, dir)); - if (rval <= 0) { + TIMEOUT(rval = getmnt(0, &sfsbuf, 0, STAT_ONE, dir)); + if (rval <= 0) { #elif OSF1 - TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs))); - if (rval <= 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs))); + if (rval <= 0) { #elif defined(ISC) - TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); - if (rval != 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { #elif APOLLO - TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); - if (rval != 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { #elif defined(LINUX) - TIMEOUT(rval = statfs(dir, &sfsbuf)); - if (rval != 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf)); + if (rval != 0) { #elif defined(MACOSX) || defined(FREEBSD) - TIMEOUT(rval = statfs(dir, &sfsbuf)); - if (rval != 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf)); + if (rval != 0) { #elif HPUX - TIMEOUT(rval = statfs(dir, &sfsbuf)); - if (rval != 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf)); + if (rval != 0) { #elif INDIGO - TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); - if (rval != 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { #elif SYSVONLY - TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); - if (rval != 0) { + TIMEOUT(rval = statfs(dir, &sfsbuf, sizeof(struct statfs), 0)); + if (rval != 0) { #else #ifndef AIXPS2 - TIMEOUT(rval = statfs(dir, &sfsbuf)); + TIMEOUT(rval = statfs(dir, &sfsbuf)); #endif /* AIXPS2 */ - if (rval != 0) { + if (rval != 0) { #endif /* ULTRIX */ - *Lisp_errno = errno; - return(NIL); - } + *Lisp_errno = errno; + return (NIL); + } #ifdef ULTRIX - *buf = sfsbuf.fd_req.bfree; + *buf = sfsbuf.fd_req.bfree; #elif defined(RS6000) - *buf = (sfsbuf.f_bavail) * 4; /* AIX 3.1 returns no. of 4K blocks */ + *buf = (sfsbuf.f_bavail) * 4; /* AIX 3.1 returns no. of 4K blocks */ #elif defined(ISC) - *buf = (sfsbuf.f_bfree)/2; /* ISC claims 1K blocks, but it's really 512b */ + *buf = (sfsbuf.f_bfree) / 2; /* ISC claims 1K blocks, but it's really 512b */ #elif defined(SYSVONLY) - *buf = sfsbuf.f_bfree; + *buf = sfsbuf.f_bfree; #elif (!defined(AIXPS2)) - *buf = sfsbuf.f_bavail; + *buf = sfsbuf.f_bavail; #else - *buf = 200000; /* FAKE - pretend we have 200,000 blocks free! */ + *buf = 200000; /* FAKE - pretend we have 200,000 blocks free! */ #endif /* ULTRIX */ #endif /* DOS */ - return(ATOM_T); + return (ATOM_T); } - - /******************************************** - Subroutines + Subroutines ********************************************/ -/* +/* * Name: separate_version * * Argument: char *name UNIX file name. It is recommended to pass only @@ -2608,97 +2495,89 @@ LispPTR COM_getfreeblock(args) * */ -void separate_version(name, ver, checkp) - register char *name; - register char *ver; - register int checkp; +void separate_version(name, ver, checkp) register char *name; +register char *ver; +register int checkp; { - register char *start, *end, *cp; - register int len, ver_no; - char ver_buf[VERSIONLEN]; + register char *start, *end, *cp; + register int len, ver_no; + char ver_buf[VERSIONLEN]; - if ((end = (char *)strchr(name, '~')) != (char *)NULL) { - start = end; - cp = end + 1; - while (*cp) { - if (*cp == '~') { - start = end; - end = cp; - } - cp++; - } - - if (start != end && *(start - 1) == '.' && end == (cp - 1)) { - /* - * name ends in the form ".~###~". But we have to check - * ### are all numbers or not, if checkp is 1. - */ - len = (int)end - (int)start - 1; - strncpy(ver_buf, start + 1, len); - ver_buf[len] = '\0'; - if (checkp) { - NumericStringP(ver_buf, YES, NO); - YES: - /* - * name contains a valid version field. - */ - *(start - 1) = '\0'; - *end = '\0'; - /* - * Use atoi to eliminate leading 0s. - */ - ver_no = atoi(start + 1); - sprintf(ver_buf, "%d", ver_no); - strcpy(ver, ver_buf); - return; - } else { - *(start - 1) = '\0'; - strcpy(ver, ver_buf); - return; - } - } + if ((end = (char *)strchr(name, '~')) != (char *)NULL) { + start = end; + cp = end + 1; + while (*cp) { + if (*cp == '~') { + start = end; + end = cp; + } + cp++; } - else if (strchr(name,'%')) { strcpy(ver,"0"); return;} - NO: - /* name does not contain a valid version field. */ - *ver = '\0'; + + if (start != end && *(start - 1) == '.' && end == (cp - 1)) { + /* + * name ends in the form ".~###~". But we have to check + * ### are all numbers or not, if checkp is 1. + */ + len = (int)end - (int)start - 1; + strncpy(ver_buf, start + 1, len); + ver_buf[len] = '\0'; + if (checkp) { + NumericStringP(ver_buf, YES, NO); + YES: + /* + * name contains a valid version field. + */ + *(start - 1) = '\0'; + *end = '\0'; + /* + * Use atoi to eliminate leading 0s. + */ + ver_no = atoi(start + 1); + sprintf(ver_buf, "%d", ver_no); + strcpy(ver, ver_buf); + return; + } else { + *(start - 1) = '\0'; + strcpy(ver, ver_buf); + return; + } + } + } else if (strchr(name, '%')) { + strcpy(ver, "0"); + return; + } +NO: + /* name does not contain a valid version field. */ + *ver = '\0'; } - - - - - #ifdef DOS -void separate_drive(lfname, drive) - register char *lfname; - char *drive; +void separate_drive(lfname, drive) register char *lfname; +char *drive; { - register char *cp; + register char *cp; - cp = lfname ; - - /* Check if there's a drive specified. */ - - if (*(cp+1) == DRIVESEP) - { - *drive = *cp; /* copy the drive letter, if there is one */ - cp++; cp++; /* Move to the real `<`/ */ - while (*cp) /* Move the rest to the left to cover. */ - { - *(cp - 2) = *cp; - cp++; - } - *(cp-2) = '\0'; - } - else *drive = '\0'; /* no drive */ + cp = lfname; + /* Check if there's a drive specified. */ + if (*(cp + 1) == DRIVESEP) { + *drive = *cp; /* copy the drive letter, if there is one */ + cp++; + cp++; /* Move to the real `<`/ */ + while (*cp) /* Move the rest to the left to cover. */ + { + *(cp - 2) = *cp; + cp++; + } + *(cp - 2) = '\0'; + } else + *drive = '\0'; /* no drive */ } #endif /* DOS */ - -/* +/* * Name: unpack_filename * * Argument: char *file UNIX file name in the UNIX format. It must be an @@ -2724,41 +2603,38 @@ void separate_drive(lfname, drive) * */ -int unpack_filename(file, dir, name, ver, checkp) - register char *file; - register char *dir; - register char *name; - register char *ver; - register int checkp; +int unpack_filename(file, dir, name, ver, checkp) register char *file; +register char *dir; +register char *name; +register char *ver; +register int checkp; { - register char *cp; + register char *cp; #ifdef DOS - if ((cp =(char *) max((UNSIGNED) rindex(file, DIRSEP), - (UNSIGNED) rindex(file,UNIXDIRSEP))) == 0) - return(0); + if ((cp = (char *)max((UNSIGNED)rindex(file, DIRSEP), (UNSIGNED)rindex(file, UNIXDIRSEP))) == 0) + return (0); - if (file[1] == DRIVESEP) - { /* There's a drive spec; copy it and ignore it from here on. */ - *dir++ = *file++; - *dir++ = *file++; - } -#else /* DOS */ - if ((cp = (char *) rindex(file,UNIXDIRSEP)) == NULL) return(0); + if (file[1] == DRIVESEP) { /* There's a drive spec; copy it and ignore it from here on. */ + *dir++ = *file++; + *dir++ = *file++; + } +#else /* DOS */ + if ((cp = (char *)rindex(file, UNIXDIRSEP)) == NULL) return (0); #endif /* DOS */ - if (cp == file) { - /* File is on a root directory. */ - *dir = '/'; - *(dir + 1) = '\0'; - } else { - while (file != cp) *dir++ = *file++; - *dir = '\0'; - } + if (cp == file) { + /* File is on a root directory. */ + *dir = '/'; + *(dir + 1) = '\0'; + } else { + while (file != cp) *dir++ = *file++; + *dir = '\0'; + } - strcpy(name, cp + 1); - separate_version(name, ver, checkp); - return(1); + strcpy(name, cp + 1); + separate_version(name, ver, checkp); + return (1); } /* @@ -2769,7 +2645,7 @@ int unpack_filename(file, dir, name, ver, checkp) * Whether a tail directory delimiter is included * in path or not is not a matter. true_name handles * both case correctly. - * + * * Value: If the pathname is recognized as an existing directory, returns * -1, recognized as an existing file, returns 1, otherwise 0. * @@ -2782,87 +2658,79 @@ int unpack_filename(file, dir, name, ver, checkp) * */ -int true_name(path) - register char *path; +int true_name(path) register char *path; { - char dir[MAXPATHLEN]; - char name[MAXNAMLEN], drive[1]; - register char *sp, *cp; - register int type, c; + char dir[MAXPATHLEN]; + char name[MAXNAMLEN], drive[1]; + register char *sp, *cp; + register int type, c; + + if (strcmp(path, "/") == 0) return (-1); - if (strcmp(path, "/") == 0) return(-1); - #ifdef DOS - if (*(path+1) == DRIVESEP) - { - drive[0] = *path; - dir[0] = drive[0]; /* but copy it to the working dir string */ - dir[1] = DRIVESEP; - dir[2] = '\0'; - cp = path + 3; /* skip the drive spec & 1st dir delimiter */ - } - else - { -#endif /* DOS */ - *dir = '\0'; /* - * locate_file does not accept the directory with - * the trail delimiter. Thus, for the root - * directory, we have to set the null character - * as directory. - */ - cp = path + 1; + if (*(path + 1) == DRIVESEP) { + drive[0] = *path; + dir[0] = drive[0]; /* but copy it to the working dir string */ + dir[1] = DRIVESEP; + dir[2] = '\0'; + cp = path + 3; /* skip the drive spec & 1st dir delimiter */ + } else { +#endif /* DOS */ + *dir = '\0'; /* + * locate_file does not accept the directory with + * the trail delimiter. Thus, for the root + * directory, we have to set the null character + * as directory. + */ + cp = path + 1; #ifdef DOS - } + } #endif /* DOS */ - /* If all there was was the root /, succeed easily */ - if (strcmp((cp-1), DIRSEPSTR) == 0) return (-1); + /* If all there was was the root /, succeed easily */ + if (strcmp((cp - 1), DIRSEPSTR) == 0) return (-1); - while (*cp) { - /* - * Copy the next subdirectory to name. - * And examine if it is an existing subdirectory or the file on the - * dir. - * At this point dir has been guaranteed to be exist. - */ - sp = name; - for (c= *cp++, *sp++ = c; c != '/' && c != '\0' && c != DIRSEP ;c= *cp++, *sp++ = c) {} - if (c == '/') { - /* Remove the trail delimiter */ - *(sp - 1) = '\0'; - } else { - /* Move back cp to '\0' character to finish the loop. */ - cp--; - } - - /* Try to locate name on dir*/ - if ((type = locate_file(dir, name)) == 0) { - /* - * No directory or file named name has been found on - * dir. - */ - return(0); - } - /* - * Now, the true name including the name has been set - * to dir by locate_file. - */ - } - strcpy(path, dir); - return(type); + while (*cp) { + /* + * Copy the next subdirectory to name. + * And examine if it is an existing subdirectory or the file on the + * dir. + * At this point dir has been guaranteed to be exist. + */ + sp = name; + for (c = *cp++, *sp++ = c; c != '/' && c != '\0' && c != DIRSEP; c = *cp++, *sp++ = c) {} + if (c == '/') { + /* Remove the trail delimiter */ + *(sp - 1) = '\0'; + } else { + /* Move back cp to '\0' character to finish the loop. */ + cp--; + } + /* Try to locate name on dir*/ + if ((type = locate_file(dir, name)) == 0) { + /* + * No directory or file named name has been found on + * dir. + */ + return (0); + } + /* + * Now, the true name including the name has been set + * to dir by locate_file. + */ + } + strcpy(path, dir); + return (type); } - - - /* * Name: locate_file * * Argument: char *dir The existing directory name. Does not include * the trail delimiter. - * + * * char *name The name which is searched on dir. - * + * * Value: If name is recognized as an existing diretory, returns -1, * recognized as an existing file, returns 1, otherwise 0. * @@ -2876,101 +2744,97 @@ int true_name(path) * */ -int locate_file(dir, name) - register char *dir; - register char *name; +int locate_file(dir, name) register char *dir; +register char *name; { #ifdef DOS - char path[MAXPATHLEN]; - char nb1[MAXNAMLEN], nb2[MAXNAMLEN]; - register int type, len; - struct find_t dirp; - struct direct *dp; - - /* First of all, recognize as if. */ - sprintf(path, "%s\\%s", dir, name); - DIR_OR_FILE_P(path, type); - if (type != 0) - { - strcpy(dir, path); - return(type); - } - - return(0); + char path[MAXPATHLEN]; + char nb1[MAXNAMLEN], nb2[MAXNAMLEN]; + register int type, len; + struct find_t dirp; + struct direct *dp; -#else /* UNIX code follows */ + /* First of all, recognize as if. */ + sprintf(path, "%s\\%s", dir, name); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + return (type); + } - char path[MAXPATHLEN]; - char nb1[MAXNAMLEN], nb2[MAXNAMLEN]; - register int type, len; - DIR *dirp; - struct direct *dp; + return (0); - /* First of all, recognize as if. */ - sprintf(path, "%s/%s", dir, name); - DIR_OR_FILE_P(path, type); - if (type != 0) { - strcpy(dir, path); - return(type); - } +#else /* UNIX code follows */ - /* Next try with all lower case name. */ - strcpy(nb1, name); - DOWNCASE(nb1); - sprintf(path, "%s/%s", dir, nb1); - DIR_OR_FILE_P(path, type); - if (type != 0) { - strcpy(dir, path); - return(type); - } + char path[MAXPATHLEN]; + char nb1[MAXNAMLEN], nb2[MAXNAMLEN]; + register int type, len; + DIR *dirp; + struct direct *dp; - /* Next try with all upper case name. */ - UPCASE(nb1); - sprintf(path, "%s/%s", dir, nb1); - DIR_OR_FILE_P(path, type); - if (type != 0) { - strcpy(dir, path); - return(type); - } + /* First of all, recognize as if. */ + sprintf(path, "%s/%s", dir, name); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + return (type); + } - /* No way. Read dir and compare with name. */ - len = strlen(name); - errno=0; - TIMEOUT0(dirp = opendir(dir)); - if (dirp == NULL) { - *Lisp_errno = errno; - return(0); - } - for(S_TOUT(dp = readdir(dirp)); dp != NULL || errno == EINTR; errno=0, S_TOUT(dp = readdir(dirp))) - if (dp) - { - if (dp->d_namlen == len) { - strcpy(nb2, dp->d_name); - UPCASE(nb2); - if (strcmp(nb1, nb2) == 0) { - sprintf(path, "%s/%s", dir, dp->d_name); - DIR_OR_FILE_P(path, type); - if (type != 0) { - strcpy(dir, path); - TIMEOUT(closedir(dirp)); - return(type); - } - } - } - } - TIMEOUT(closedir(dirp)); - return(0); + /* Next try with all lower case name. */ + strcpy(nb1, name); + DOWNCASE(nb1); + sprintf(path, "%s/%s", dir, nb1); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + return (type); + } + + /* Next try with all upper case name. */ + UPCASE(nb1); + sprintf(path, "%s/%s", dir, nb1); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + return (type); + } + + /* No way. Read dir and compare with name. */ + len = strlen(name); + errno = 0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return (0); + } + for (S_TOUT(dp = readdir(dirp)); dp != NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp))) + if (dp) { + if (dp->d_namlen == len) { + strcpy(nb2, dp->d_name); + UPCASE(nb2); + if (strcmp(nb1, nb2) == 0) { + sprintf(path, "%s/%s", dir, dp->d_name); + DIR_OR_FILE_P(path, type); + if (type != 0) { + strcpy(dir, path); + TIMEOUT(closedir(dirp)); + return (type); + } + } + } + } + TIMEOUT(closedir(dirp)); + return (0); #endif /* DOS */ } - - /* * Name: make_directory * * Argument: char *dir The full directory name in UNIX format. It does * not include a tail delimiter. - * + * * Value: If succeed, returns 1, otherwise 0. * * Side Effect: The directory specified as dir will be created in the file system. @@ -2982,115 +2846,109 @@ int locate_file(dir, name) * */ -int make_directory(dir) - register char *dir; +int make_directory(dir) register char *dir; { - register char *cp, *dp; - register int maked, rval; - char dir_buf[MAXPATHLEN]; + register char *cp, *dp; + register int maked, rval; + char dir_buf[MAXPATHLEN]; - maked = 0; - - dp = dir_buf; - cp = dir; + maked = 0; + + dp = dir_buf; + cp = dir; #ifdef DOS - if (DRIVESEP == *(cp+1)) - { - *dp++ - *cp++; /* copy the drive letter and colon */ - *dp++ = *cp++; - } + if (DRIVESEP == *(cp + 1)) { + *dp++ - *cp++; /* copy the drive letter and colon */ + *dp++ = *cp++; + } #endif /* DOS */ + *dp++ = DIRSEP; /* For a root directory. */ + cp++; /* Skip a root directory in dir. */ - *dp++ = DIRSEP; /* For a root directory. */ - cp++; /* Skip a root directory in dir. */ - - for (;;) { - switch (*cp) { + for (;;) { + switch (*cp) { #ifdef DOS - case DIRSEP: + case DIRSEP: #endif - case '/': - case '\0': - *dp = '\0'; - /* - * Now, dir_buf contains the absolute path to the next - * subdirectory or file. If one of the parent directories - * are created, we have to create a new subdirectory - * anyway. If all of the parent directories are exisiting - * directories, we have to check this subdirectory is an - * exisiting or not. - */ - if (maked) { + case '/': + case '\0': + *dp = '\0'; + /* + * Now, dir_buf contains the absolute path to the next + * subdirectory or file. If one of the parent directories + * are created, we have to create a new subdirectory + * anyway. If all of the parent directories are exisiting + * directories, we have to check this subdirectory is an + * exisiting or not. + */ + if (maked) { #ifdef DOS - TIMEOUT(rval = mkdir(dir_buf)); + TIMEOUT(rval = mkdir(dir_buf)); #else - TIMEOUT(rval = mkdir(dir_buf, 0777)); + TIMEOUT(rval = mkdir(dir_buf, 0777)); #endif /* DOS */ - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } - if (*cp == '\0') { - strcpy(dir, dir_buf); - return(1); - } - *dp++ = DIRSEP; - cp++; - } else { - switch (true_name(dir_buf)) { + if (rval == -1) { + *Lisp_errno = errno; + return (0); + } + if (*cp == '\0') { + strcpy(dir, dir_buf); + return (1); + } + *dp++ = DIRSEP; + cp++; + } else { + switch (true_name(dir_buf)) { + case -1: /* Directory */ + if (*cp == '\0') { + /* Every subdirectories are examined. */ + strcpy(dir, dir_buf); + return (1); + } else { + dp = dir_buf; + while (*dp) dp++; + *dp++ = DIRSEP; + cp++; + } + break; - case -1: /* Directory */ - if (*cp == '\0') { - /* Every subdirectories are examined. */ - strcpy(dir, dir_buf); - return(1); - } else { - dp = dir_buf; - while (*dp) dp++; - *dp++ = DIRSEP; - cp++; - } - break; + case 1: /* Regular File */ + /* + * UNIX does not allow to make a directory + * and a file in the same name on a directory. + */ + return (0); - case 1: /* Regular File */ - /* - * UNIX does not allow to make a directory - * and a file in the same name on a directory. - */ - return(0); - - default: - /* - * Should handle other cases. (special file). - */ + default: +/* + * Should handle other cases. (special file). + */ #ifdef DOS - TIMEOUT(rval = mkdir(dir_buf)); + TIMEOUT(rval = mkdir(dir_buf)); #else - TIMEOUT(rval = mkdir(dir_buf, 0777)); + TIMEOUT(rval = mkdir(dir_buf, 0777)); #endif /* DOS */ - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } - if (*cp == '\0') return(1); - *dp++ = DIRSEP; - cp++; - maked = 1; - break; - } - } - break; + if (rval == -1) { + *Lisp_errno = errno; + return (0); + } + if (*cp == '\0') return (1); + *dp++ = DIRSEP; + cp++; + maked = 1; + break; + } + } + break; - default: - *dp++ = *cp++; - break; - } - } + default: *dp++ = *cp++; break; + } + } } -/* +/* * Name: FindHighestVersion * * Argument: FileName *varray @@ -3115,34 +2973,30 @@ int make_directory(dir) * */ #ifdef DOS -#define FindHighestVersion(varray, mentry, max_no){ \ - \ - register FileName *centry; \ - for (centry = varray, max_no = -1; centry->version_no != LASTVERSIONARRAY; \ - centry++) { \ - if (centry->version_no > max_no) { \ - max_no = centry->version_no; \ - mentry = centry; \ - } \ - } \ -} +#define FindHighestVersion(varray, mentry, max_no) \ + { \ + register FileName *centry; \ + for (centry = varray, max_no = -1; centry->version_no != LASTVERSIONARRAY; centry++) { \ + if (centry->version_no > max_no) { \ + max_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ + } #else -#define FindHighestVersion(varray, mentry, max_no){ \ - \ - register FileName *centry; \ - for (centry = varray, max_no = 0; centry->version_no != LASTVERSIONARRAY; \ - centry++) { \ - if (centry->version_no > max_no) { \ - max_no = centry->version_no; \ - mentry = centry; \ - } \ - } \ -} +#define FindHighestVersion(varray, mentry, max_no) \ + { \ + register FileName *centry; \ + for (centry = varray, max_no = 0; centry->version_no != LASTVERSIONARRAY; centry++) { \ + if (centry->version_no > max_no) { \ + max_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ + } #endif /* DOS */ - - -/* +/* * Name: FindLowestVersion * * Argument: FileName *varray @@ -3167,34 +3021,30 @@ int make_directory(dir) * */ #ifdef DOS -#define FindLowestVersion(varray, mentry, min_no){ \ - \ - register FileName *centry; \ - for (centry = varray, min_no = MAXVERSION; \ - centry->version_no != LASTVERSIONARRAY; centry++) { \ - if (centry->version_no < min_no ) { \ - min_no = centry->version_no; \ - mentry = centry; \ - } \ - } \ -} +#define FindLowestVersion(varray, mentry, min_no) \ + { \ + register FileName *centry; \ + for (centry = varray, min_no = MAXVERSION; centry->version_no != LASTVERSIONARRAY; centry++) { \ + if (centry->version_no < min_no) { \ + min_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ + } #else -#define FindLowestVersion(varray, mentry, min_no){ \ - \ - register FileName *centry; \ - for (centry = varray, min_no = MAXVERSION; \ - centry->version_no != LASTVERSIONARRAY; centry++) { \ - if (centry->version_no < min_no && centry->version_no != 0) { \ - min_no = centry->version_no; \ - mentry = centry; \ - } \ - } \ -} +#define FindLowestVersion(varray, mentry, min_no) \ + { \ + register FileName *centry; \ + for (centry = varray, min_no = MAXVERSION; centry->version_no != LASTVERSIONARRAY; centry++) { \ + if (centry->version_no < min_no && centry->version_no != 0) { \ + min_no = centry->version_no; \ + mentry = centry; \ + } \ + } \ + } #endif /* DOS */ - - -/* +/* * Name: FindSpecifiedVersion * * Argument: FileName *varray @@ -3212,28 +3062,23 @@ int make_directory(dir) * * Description: * - * Find the specified versioned entry in varray. Varray has to include at least + * Find the specified versioned entry in varray. Varray has to include at least * one versioned file, that is varray has to satisfy (!NoFileP(varray) && * !OnlyVersionlessP(varray)). * */ -#define FindSpecifiedVersion(varray, sentry, ver_no){ \ - \ - register FileName *centry; \ - \ - sentry = (FileName *)NULL; \ - for (centry = varray; centry->version_no != LASTVERSIONARRAY; centry++) \ - if (centry->version_no == ver_no) { \ - sentry = centry; \ - break; \ - } \ -} - - - - - +#define FindSpecifiedVersion(varray, sentry, ver_no) \ + { \ + register FileName *centry; \ + \ + sentry = (FileName *)NULL; \ + for (centry = varray; centry->version_no != LASTVERSIONARRAY; centry++) \ + if (centry->version_no == ver_no) { \ + sentry = centry; \ + break; \ + } \ + } /************************************************************************/ /* */ @@ -3256,230 +3101,220 @@ int make_directory(dir) /* */ /************************************************************************/ -int get_version_array(dir, file, varray, cache) - register char *dir; - register char *file; - register FileName *varray; - register CurrentVArray *cache; - { +int get_version_array(dir, file, varray, cache) register char *dir; +register char *file; +register FileName *varray; +register CurrentVArray *cache; +{ #ifdef DOS - char lcased_file[MAXPATHLEN]; - char old_file[MAXPATHLEN]; - char name[MAXNAMLEN]; - char ver[VERSIONLEN]; - register FileName *svarray; - struct find_t dirp; - register struct direct *dp; - register int rval, drive = 0, isslash = 0; - struct stat sbuf; - int res; - + char lcased_file[MAXPATHLEN]; + char old_file[MAXPATHLEN]; + char name[MAXNAMLEN]; + char ver[VERSIONLEN]; + register FileName *svarray; + struct find_t dirp; + register struct direct *dp; + register int rval, drive = 0, isslash = 0; + struct stat sbuf; + int res; /* * First of all, prepare a lower cased file name for the case insensitve * serch. Also we have to separate file name from its version field. */ - if (dir[1] == DRIVESEP) drive = dir[0]; + if (dir[1] == DRIVESEP) drive = dir[0]; - if (strcmp(dir, "\\")==0) isslash = 1; - else if (drive && (strcmp(dir+2, "\\")==0)) isslash = 1; + if (strcmp(dir, "\\") == 0) + isslash = 1; + else if (drive && (strcmp(dir + 2, "\\") == 0)) + isslash = 1; - if (!isslash) strcpy(lcased_file, dir); /* Only add the dir if it's real */ - else if (drive) - { - lcased_file[0] = drive; - lcased_file[1] = DRIVESEP; - lcased_file[2] = '\0'; - } - else *lcased_file = '\0'; + if (!isslash) + strcpy(lcased_file, dir); /* Only add the dir if it's real */ + else if (drive) { + lcased_file[0] = drive; + lcased_file[1] = DRIVESEP; + lcased_file[2] = '\0'; + } else + *lcased_file = '\0'; /* strcpy(lcased_file, dir); removed when above code added 3/4/93 */ - strcat(lcased_file, DIRSEPSTR); - strcat(lcased_file, file); - separate_version(lcased_file, ver, 1); - DOWNCASE(lcased_file); + strcat(lcased_file, DIRSEPSTR); + strcat(lcased_file, file); + separate_version(lcased_file, ver, 1); + DOWNCASE(lcased_file); - /*************************************************/ - /* First, look up the backup version of the file */ - /*************************************************/ + /*************************************************/ + /* First, look up the backup version of the file */ + /*************************************************/ - /* First, make the "backup-file-name" for this file */ + /* First, make the "backup-file-name" for this file */ - make_old_version(old_file, lcased_file); + make_old_version(old_file, lcased_file); - svarray = varray; + svarray = varray; - TIMEOUT(res = _dos_findfirst(old_file,_A_NORMAL|_A_SUBDIR,&dirp)); - if (res == 0) - { - strcpy(name, dirp.name); - strcpy(svarray->name, name); - svarray -> version_no = 0; - svarray++; - } + TIMEOUT(res = _dos_findfirst(old_file, _A_NORMAL | _A_SUBDIR, &dirp)); + if (res == 0) { + strcpy(name, dirp.name); + strcpy(svarray->name, name); + svarray->version_no = 0; + svarray++; + } - /*******************************/ - /* Now look up the file itself */ - /*******************************/ + /*******************************/ + /* Now look up the file itself */ + /*******************************/ - TIMEOUT(res = _dos_findfirst(lcased_file,_A_NORMAL|_A_SUBDIR,&dirp)); -/* if (res != 0) - { - *Lisp_errno = errno; - return(0); - } -*/ - for ( ; res == 0 ; S_TOUT(res = _dos_findnext(&dirp))) - { - strcpy(name, dirp.name); - separate_version(name, ver, 1); - DOWNCASE(name); + TIMEOUT(res = _dos_findfirst(lcased_file, _A_NORMAL | _A_SUBDIR, &dirp)); + /* if (res != 0) + { + *Lisp_errno = errno; + return(0); + } + */ + for (; res == 0; S_TOUT(res = _dos_findnext(&dirp))) { + strcpy(name, dirp.name); + separate_version(name, ver, 1); + DOWNCASE(name); - strcpy(svarray->name, dirp.name); - if (*ver == '\0') - { - /* Versionless file */ - svarray->version_no = 1; - } - else - { - /* - * separater_version guranteeds ver is a numeric - * string. - */ - svarray->version_no = atoi(ver); - } - svarray++; - } + strcpy(svarray->name, dirp.name); + if (*ver == '\0') { + /* Versionless file */ + svarray->version_no = 1; + } else { + /* + * separater_version guranteeds ver is a numeric + * string. + */ + svarray->version_no = atoi(ver); + } + svarray++; + } - /* - * The last entry of varray is indicated by setting LASTVERSIONARRAY into - * version_no field. - */ - svarray->version_no = LASTVERSIONARRAY; + /* + * The last entry of varray is indicated by setting LASTVERSIONARRAY into + * version_no field. + */ + svarray->version_no = LASTVERSIONARRAY; - /* - * If more than one files have been stored in varray, we store the name - * without version in the last marker entry. - */ - if (!NoFileP(varray)) - { - strcpy(name, varray->name); - separate_version(name, ver, 1); - strcpy(svarray->name, name); - } + /* + * If more than one files have been stored in varray, we store the name + * without version in the last marker entry. + */ + if (!NoFileP(varray)) { + strcpy(name, varray->name); + separate_version(name, ver, 1); + strcpy(svarray->name, name); + } - return(1); + return (1); #else - /* UNIX version-array builder */ - char lcased_file[MAXNAMLEN]; - char name[MAXNAMLEN]; - char ver[VERSIONLEN]; - register FileName *svarray; - register DIR *dirp; - register struct direct *dp; - register int rval; - struct stat sbuf; - - /* - * First of all, prepare a lower cased file name for the case insensitve - * serch. Also we have to separate file name from its version field. - */ - strcpy(lcased_file, file); - separate_version(lcased_file, ver, 1); - DOWNCASE(lcased_file); + /* UNIX version-array builder */ + char lcased_file[MAXNAMLEN]; + char name[MAXNAMLEN]; + char ver[VERSIONLEN]; + register FileName *svarray; + register DIR *dirp; + register struct direct *dp; + register int rval; + struct stat sbuf; -/* - TIMEOUT(rval = stat(dir, &sbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } -*/ + /* + * First of all, prepare a lower cased file name for the case insensitve + * serch. Also we have to separate file name from its version field. + */ + strcpy(lcased_file, file); + separate_version(lcased_file, ver, 1); + DOWNCASE(lcased_file); - /* - * If the cached version array is still valid, we can return immediately. - */ + /* + TIMEOUT(rval = stat(dir, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return(0); + } + */ - /* - * Cache machaisme is not used now, because of the bug of Sun OS. - * Sometimes just after unlinking a file on a directory, the st_mtime - * of the directory does not change. This will make Maiko beleive - * cached version array is still valid, although it is already invalid. - * sync(2) has no effect on such case. - */ + /* + * If the cached version array is still valid, we can return immediately. + */ -/* - if ((sbuf.st_mtime == cache->mtime) && strcmp(dir, cache->path) == 0 - && strcmp(lcased_file, cache->file) == 0) return(1); -*/ - errno=0; - TIMEOUT0(dirp = opendir(dir)); - if (dirp == NULL) { - *Lisp_errno = errno; - return(0); - } + /* + * Cache machaisme is not used now, because of the bug of Sun OS. + * Sometimes just after unlinking a file on a directory, the st_mtime + * of the directory does not change. This will make Maiko beleive + * cached version array is still valid, although it is already invalid. + * sync(2) has no effect on such case. + */ - for (S_TOUT(dp = readdir(dirp)), svarray = varray; dp != NULL || errno == EINTR; - errno=0, S_TOUT(dp = readdir(dirp))) - if(dp) - { - strcpy(name, dp->d_name); - separate_version(name, ver, 1); - DOWNCASE(name); - if (strcmp(name, lcased_file) == 0) { - /* - * This file can be regarded as a same file in Lisp sense. - */ - strcpy(svarray->name, dp->d_name); - if (*ver == '\0') { - /* Versionless file */ - svarray->version_no = 0; - } else { - /* - * separater_version guranteeds ver is a numeric - * string. - */ - svarray->version_no = atoi(ver); - } - svarray++; - } - } - /* - * The last entry of varray is indicated by setting LASTVERSIONARRAY into - * version_no field. - */ - svarray->version_no = LASTVERSIONARRAY; + /* + if ((sbuf.st_mtime == cache->mtime) && strcmp(dir, cache->path) == 0 + && strcmp(lcased_file, cache->file) == 0) return(1); + */ + errno = 0; + TIMEOUT0(dirp = opendir(dir)); + if (dirp == NULL) { + *Lisp_errno = errno; + return (0); + } - /* - * If more than one files have been stored in varray, we store the name - * without version in the last marker entry. - */ - if (!NoFileP(varray)) { - strcpy(name, varray->name); - separate_version(name, ver, 1); - strcpy(svarray->name, name); - } + for (S_TOUT(dp = readdir(dirp)), svarray = varray; dp != NULL || errno == EINTR; + errno = 0, S_TOUT(dp = readdir(dirp))) + if (dp) { + strcpy(name, dp->d_name); + separate_version(name, ver, 1); + DOWNCASE(name); + if (strcmp(name, lcased_file) == 0) { + /* + * This file can be regarded as a same file in Lisp sense. + */ + strcpy(svarray->name, dp->d_name); + if (*ver == '\0') { + /* Versionless file */ + svarray->version_no = 0; + } else { + /* + * separater_version guranteeds ver is a numeric + * string. + */ + svarray->version_no = atoi(ver); + } + svarray++; + } + } + /* + * The last entry of varray is indicated by setting LASTVERSIONARRAY into + * version_no field. + */ + svarray->version_no = LASTVERSIONARRAY; - /* - * Update cache information. - */ -/* - strcpy(cache->path, dir); - strcpy(cache->file, lcased_file); - cache->mtime = sbuf.st_mtime; -*/ - TIMEOUT(closedir(dirp)); - return(1); + /* + * If more than one files have been stored in varray, we store the name + * without version in the last marker entry. + */ + if (!NoFileP(varray)) { + strcpy(name, varray->name); + separate_version(name, ver, 1); + strcpy(svarray->name, name); + } + + /* + * Update cache information. + */ + /* + strcpy(cache->path, dir); + strcpy(cache->file, lcased_file); + cache->mtime = sbuf.st_mtime; + */ + TIMEOUT(closedir(dirp)); + return (1); #endif /* DOS */ } - - - -/* +/* * Name: maintain_version * * Argument: char *file The full file name in UNIX format. @@ -3505,152 +3340,147 @@ int get_version_array(dir, file, varray, cache) * to maintain the directory on which a file is being created. */ -int maintain_version(file, varray, forcep) - register char *file; - register FileName *varray; - register int forcep; +int maintain_version(file, varray, forcep) register char *file; +register FileName *varray; +register int forcep; { - char dir[MAXPATHLEN], fname[MAXNAMLEN], ver[VERSIONLEN]; - char old_file[MAXPATHLEN], vless[MAXPATHLEN]; - int highest_p; - register int rval, max_no; - register FileName *entry; + char dir[MAXPATHLEN], fname[MAXNAMLEN], ver[VERSIONLEN]; + char old_file[MAXPATHLEN], vless[MAXPATHLEN]; + int highest_p; + register int rval, max_no; + register FileName *entry; - if (varray == (FileName *)NULL) { - if (unpack_filename(file, dir, fname, ver, 1) == 0) return(0); - /* - * We have to make sure that dir is the existing directory. - */ - if (true_name(dir) != -1) return(0); - if (get_version_array(dir, fname, VersionArray, &VArrayInfo) == 0) - return(0); - varray = VersionArray; - } + if (varray == (FileName *)NULL) { + if (unpack_filename(file, dir, fname, ver, 1) == 0) return (0); + /* + * We have to make sure that dir is the existing directory. + */ + if (true_name(dir) != -1) return (0); + if (get_version_array(dir, fname, VersionArray, &VArrayInfo) == 0) return (0); + varray = VersionArray; + } - if (NoFileP(varray)) { - /* - * We don't need to care about such case that there is no such file - * or an only versionless file exists. - */ - return(1); - } + if (NoFileP(varray)) { + /* + * We don't need to care about such case that there is no such file + * or an only versionless file exists. + */ + return (1); + } - if (OnlyVersionlessP(varray)) { - if (forcep) { - /* - * If forcep, we link the versionless file to the version - * 1 file. - */ + if (OnlyVersionlessP(varray)) { + if (forcep) { +/* + * If forcep, we link the versionless file to the version + * 1 file. + */ #ifndef DOS - get_versionless(varray, vless, dir); - ConcNameAndVersion(vless, "1", fname); - TIMEOUT(rval = link(vless, fname)); - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } + get_versionless(varray, vless, dir); + ConcNameAndVersion(vless, "1", fname); + TIMEOUT(rval = link(vless, fname)); + if (rval == -1) { + *Lisp_errno = errno; + return (0); + } #endif /* DOS */ - } - return(1); - } + } + return (1); + } - /* - * At this point, we are sure that at least one file with version number - * exists. Thus, FindHighestVersion works fine from now on. - */ + /* + * At this point, we are sure that at least one file with version number + * exists. Thus, FindHighestVersion works fine from now on. + */ - if (get_versionless(varray, vless, dir) == 0) { - /* - * There is not a versionless file, but at least one versioned file. - * Thus, the thing we have to do is to link a versionless file - * to the existing highest versioned file. - */ - FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, old_file); - /* - * The versionless file should have the same case name as the old - * file. - */ + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is not a versionless file, but at least one versioned file. + * Thus, the thing we have to do is to link a versionless file + * to the existing highest versioned file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, old_file); +/* + * The versionless file should have the same case name as the old + * file. + */ #ifndef DOS - strcpy(fname, entry->name); - separate_version(fname, ver, 1); - ConcDirAndName(dir, fname, vless); - TIMEOUT(rval = link(old_file, vless)); - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } + strcpy(fname, entry->name); + separate_version(fname, ver, 1); + ConcDirAndName(dir, fname, vless); + TIMEOUT(rval = link(old_file, vless)); + if (rval == -1) { + *Lisp_errno = errno; + return (0); + } #endif /* DOS */ - return(1); - } + return (1); + } - if (check_vless_link(vless, varray, old_file, &highest_p) == 0) return(0); + if (check_vless_link(vless, varray, old_file, &highest_p) == 0) return (0); - if (*old_file == '\0') { - /* - * The versionless file is not linked to any file in varray. - * Thus, we have to link the versionless file to the file which - * is versioned one higher than the exisiting highest version. - */ - FindHighestVersion(varray, entry, max_no); - sprintf(ver, "%d", max_no + 1); - /* - * The old file should have the same case name as the versionless - * file. - */ -#ifndef DOS - ConcNameAndVersion(vless, ver, old_file); - TIMEOUT(rval = link(vless, old_file)); - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } -#endif /* DOS */ - return(1); - } - - if (highest_p) { - /* - * The versionless file has been already linked to the highest - * versioned file. Thus, there is nothing to do. - */ - return(1); - } else { - /* - * Although the versionless file is linked to a file in varray, - * the file is not the highest versioned file. We have to unlink - * the wrongly linked versionless file, and link the highest versioned - * file to a versionless file. - */ - TIMEOUT(rval = unlink(vless)); - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } - FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, old_file); - /* - * The versionless file should have the same case name as the old - * file. - */ + if (*old_file == '\0') { + /* + * The versionless file is not linked to any file in varray. + * Thus, we have to link the versionless file to the file which + * is versioned one higher than the exisiting highest version. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(ver, "%d", max_no + 1); +/* + * The old file should have the same case name as the versionless + * file. + */ #ifndef DOS - strcpy(fname, entry->name); - separate_version(fname, ver, 1); - ConcDirAndName(dir, fname, vless); - TIMEOUT(rval = link(old_file, vless)); - if (rval == -1) { - *Lisp_errno = errno; - return(0); - } + ConcNameAndVersion(vless, ver, old_file); + TIMEOUT(rval = link(vless, old_file)); + if (rval == -1) { + *Lisp_errno = errno; + return (0); + } #endif /* DOS */ - return(1); - } + return (1); + } + + if (highest_p) { + /* + * The versionless file has been already linked to the highest + * versioned file. Thus, there is nothing to do. + */ + return (1); + } else { + /* + * Although the versionless file is linked to a file in varray, + * the file is not the highest versioned file. We have to unlink + * the wrongly linked versionless file, and link the highest versioned + * file to a versionless file. + */ + TIMEOUT(rval = unlink(vless)); + if (rval == -1) { + *Lisp_errno = errno; + return (0); + } + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, old_file); +/* + * The versionless file should have the same case name as the old + * file. + */ +#ifndef DOS + strcpy(fname, entry->name); + separate_version(fname, ver, 1); + ConcDirAndName(dir, fname, vless); + TIMEOUT(rval = link(old_file, vless)); + if (rval == -1) { + *Lisp_errno = errno; + return (0); + } +#endif /* DOS */ + return (1); + } } - - - -/* +/* * Name: get_versionless * * Argument: FileName *varray @@ -3673,28 +3503,26 @@ int maintain_version(file, varray, forcep) * */ -int get_versionless(varray, file, dir) - register FileName *varray; - register char *file; - register char *dir; +int get_versionless(varray, file, dir) register FileName *varray; +register char *file; +register char *dir; { #ifdef DOS -return(0); + return (0); #endif /* DOS */ - if (NoFileP(varray)) return (0); - - while (varray->version_no != LASTVERSIONARRAY) { - if (varray->version_no == 0) { - ConcDirAndName(dir, varray->name, file); - return(1); - } else - varray++; - } - return(0); + if (NoFileP(varray)) return (0); + + while (varray->version_no != LASTVERSIONARRAY) { + if (varray->version_no == 0) { + ConcDirAndName(dir, varray->name, file); + return (1); + } else + varray++; + } + return (0); } - -/* +/* * Name: check_vless_link * * Argument: char *vless The full file name of the versionless file in @@ -3730,73 +3558,71 @@ return(0); * */ -int check_vless_link(vless, varray, to_file, highest_p) - register char *vless; - register FileName *varray; - register char *to_file; - register int *highest_p; +int check_vless_link(vless, varray, to_file, highest_p) register char *vless; +register FileName *varray; +register char *to_file; +register int *highest_p; { - register int rval, max_no, found; - ino_t vless_ino; - struct stat sbuf; - char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; - register FileName *max_entry, *linked_entry; + register int rval, max_no, found; + ino_t vless_ino; + struct stat sbuf; + char dir[MAXPATHLEN], name[MAXNAMLEN], ver[VERSIONLEN]; + register FileName *max_entry, *linked_entry; - TIMEOUT(rval = stat(vless, &sbuf)); - if (rval != 0) { - *Lisp_errno = errno; - return(0); - } + TIMEOUT(rval = stat(vless, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return (0); + } - if (sbuf.st_nlink == 1) { - /* There is no file to which vless is hard linked. */ - *to_file = '\0'; - return(1); - } - vless_ino = sbuf.st_ino; + if (sbuf.st_nlink == 1) { + /* There is no file to which vless is hard linked. */ + *to_file = '\0'; + return (1); + } + vless_ino = sbuf.st_ino; - if (unpack_filename(vless, dir, name, ver, 1) == 0) return(0); - - max_no = 0; - found = 0; - max_entry = NULL; - linked_entry = NULL; - - while (varray->version_no != LASTVERSIONARRAY) { - if (varray->version_no > max_no) { - max_no = varray->version_no; - max_entry = varray; - } - if (!found && varray->version_no != 0) { - ConcDirAndName(dir, varray->name, name); - TIMEOUT(rval = stat(name, &sbuf)); - if (rval != 0) { - *Lisp_errno = errno; - return(0); - } - if (sbuf.st_ino == vless_ino) { - found = 1; - linked_entry = varray; - } - } - varray++; - } - - if (linked_entry != NULL) { - if (linked_entry == max_entry) { - *highest_p = 1; - } else { - *highest_p = 0; - } - strcpy(to_file, name); - } else { - *to_file = '\0'; - } - return(1); + if (unpack_filename(vless, dir, name, ver, 1) == 0) return (0); + + max_no = 0; + found = 0; + max_entry = NULL; + linked_entry = NULL; + + while (varray->version_no != LASTVERSIONARRAY) { + if (varray->version_no > max_no) { + max_no = varray->version_no; + max_entry = varray; + } + if (!found && varray->version_no != 0) { + ConcDirAndName(dir, varray->name, name); + TIMEOUT(rval = stat(name, &sbuf)); + if (rval != 0) { + *Lisp_errno = errno; + return (0); + } + if (sbuf.st_ino == vless_ino) { + found = 1; + linked_entry = varray; + } + } + varray++; + } + + if (linked_entry != NULL) { + if (linked_entry == max_entry) { + *highest_p = 1; + } else { + *highest_p = 0; + } + strcpy(to_file, name); + } else { + *to_file = '\0'; + } + return (1); } - -/* +/* * Name: get_old * * Argument: char *dir Directory absolute path following the UNIX @@ -3836,169 +3662,169 @@ int check_vless_link(vless, varray, to_file, highest_p) * */ -int get_old(dir, varray, afile, vfile) - register char *dir; - register FileName *varray; - register char *afile; - register char *vfile; +int get_old(dir, varray, afile, vfile) register char *dir; +register FileName *varray; +register char *afile; +register char *vfile; { - char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; - char ver[VERSIONLEN], vbuf[VERSIONLEN]; - register int ver_no, max_no; - int highest_p; - register FileName *entry; - - - /* "Old" file have to be existing, thus varray should not be empty. */ - if (NoFileP(varray)) return(0); + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, max_no; + int highest_p; + register FileName *entry; - strcpy(name, afile); - separate_version(name, ver, 1); - - if (get_versionless(varray, vless, dir) == 0) { - /* - * There is no versionless file, but at least one vernsioned - * file exists. - */ - if (*ver == '\0') { - /* - * No version is specified. The highest versioned file - * is an old file. - */ - FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else return(0); - } - } else if (OnlyVersionlessP(varray)) { - /* - * There is only versionless file in varray. - * If the specified version is 1 the versionless file is regarded - * as version 1 file. - */ - if (*ver == '\0') { - /* - * No version is specified. The versionless file is dealt - * with as version 1. - */ - ConcNameAndVersion(vless, "1", vfile); - strcpy(afile, vless); - return(1); - } else { - ver_no = atoi(ver); - if (ver_no == 1) { - /* - * Version 1 is specified. The versionless file is - * dealt with as a version 1 file. - */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * Other versions than 1 are not recognized as an old - * file. - */ - return(0); - } - } - } else { - if (check_vless_link(vless, varray, to_file, &highest_p) == 0) - return(0); - if (*to_file == '\0') { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is not linked - * to any file in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The one higher than an - * exisiting maximum version is dealt with as the - * old version, and it should be a version of the - * link missing versionless file. - */ - FindHighestVersion(varray, entry, max_no); - sprintf(vbuf, "%d", max_no + 1); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); - return(1); - } else { - /* A version is specified. */ - ver_no = atoi(ver); - FindHighestVersion(varray, entry, max_no); - if (ver_no == max_no + 1) { - /* - * If the version is one higher than the - * existing highest version is specified, it - * is dealt with as a version of the link - * missing versionless file. - */ - sprintf(vbuf, "%d", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * We have to walk through varray and try - * to find the file with the specified version. - */ - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else return(0); - } - } - } else { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is linked to - * one of files in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The highest versioned file - * in varray is an old file. - */ - FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else return(0); - } - } - } + /* "Old" file have to be existing, thus varray should not be empty. */ + if (NoFileP(varray)) return (0); + + strcpy(name, afile); + separate_version(name, ver, 1); + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else + return (0); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. + */ + ConcNameAndVersion(vless, "1", vfile); + strcpy(afile, vless); + return (1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * Other versions than 1 are not recognized as an old + * file. + */ + return (0); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) return (0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The one higher than an + * exisiting maximum version is dealt with as the + * old version, and it should be a version of the + * link missing versionless file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return (1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, max_no); + if (ver_no == max_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else + return (0); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * in varray is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else + return (0); + } + } + } } -/* +/* * Name: get_oldeset * * Argument: char *dir Directory absolute path following the UNIX @@ -4038,167 +3864,166 @@ int get_old(dir, varray, afile, vfile) * */ -int get_oldest(dir, varray, afile, vfile) - register char *dir; - register FileName *varray; - register char *afile; - register char *vfile; +int get_oldest(dir, varray, afile, vfile) register char *dir; +register FileName *varray; +register char *afile; +register char *vfile; { - char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; - char ver[VERSIONLEN], vbuf[VERSIONLEN]; - register int ver_no, min_no; - int highest_p; - register FileName *entry; - - - /* "Oldest" file have to be existing, thus varray should not be empty. */ - if (NoFileP(varray)) return(0); + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, min_no; + int highest_p; + register FileName *entry; - strcpy(name, afile); - separate_version(name, ver, 1); - - if (get_versionless(varray, vless, dir) == 0) { - /* - * There is no versionless file, but at least one vernsioned - * file exists. - */ - if (*ver == '\0') { - /* - * No version is specified. The lowest versioned file - * is an oldest file. - */ - FindLowestVersion(varray, entry, min_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else return(0); - } - } else if (OnlyVersionlessP(varray)) { - /* - * There is only versionless file in varray. - * If the specified version is 1 the versionless file is regarded - * as version 1 file. - */ - if (*ver == '\0') { - /* - * No version is specified. The versionless file is dealt - * with as version 1. - */ - ConcNameAndVersion(vless, "1", vfile); - strcpy(afile, vless); - return(1); - } else { - ver_no = atoi(ver); - if (ver_no == 1) { - /* - * Version 1 is specified. The versionless file is - * dealt with as a version 1 file. - */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * Other versions than 1 are not recognized as an - * oldest file. - */ - return(0); - } - } - } else { - if (check_vless_link(vless, varray, to_file, &highest_p) == 0) - return(0); - if (*to_file == '\0') { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is not linked - * to any file in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The lowest version is - * dealt with as the oldest version. - */ - FindLowestVersion(varray, entry, min_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else { - /* A version is specified. */ - ver_no = atoi(ver); - FindHighestVersion(varray, entry, min_no); - if (ver_no == min_no + 1) { - /* - * If the version is one higher than the - * existing highest version is specified, it - * is dealt with as a version of the link - * missing versionless file. - */ - sprintf(vbuf, "%d", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * We have to walk through varray and try - * to find the file with the specified version. - */ - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else return(0); - } - } - } else { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is linked to - * one of files in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The lowest versioned file - * in varray is an old file. - */ - FindLowestVersion(varray, entry, min_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else return(0); - } - } - } + /* "Oldest" file have to be existing, thus varray should not be empty. */ + if (NoFileP(varray)) return (0); + + strcpy(name, afile); + separate_version(name, ver, 1); + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The lowest versioned file + * is an oldest file. + */ + FindLowestVersion(varray, entry, min_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else + return (0); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. + */ + ConcNameAndVersion(vless, "1", vfile); + strcpy(afile, vless); + return (1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * Other versions than 1 are not recognized as an + * oldest file. + */ + return (0); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) return (0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The lowest version is + * dealt with as the oldest version. + */ + FindLowestVersion(varray, entry, min_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, min_no); + if (ver_no == min_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else + return (0); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The lowest versioned file + * in varray is an old file. + */ + FindLowestVersion(varray, entry, min_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else + return (0); + } + } + } } - -/* +/* * Name: get_new * * Argument: char *dir Directory absolute path following the UNIX @@ -4239,266 +4064,263 @@ int get_oldest(dir, varray, afile, vfile) * */ -int get_new(dir, varray, afile, vfile) - register char *dir; - register FileName *varray; - register char *afile; - register char *vfile; +int get_new(dir, varray, afile, vfile) register char *dir; +register FileName *varray; +register char *afile; +register char *vfile; { - char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; - char ver[VERSIONLEN], vbuf[VERSIONLEN]; - register int ver_no, max_no; - int highest_p; - register FileName *entry; - - strcpy(name, afile); - separate_version(name, ver, 1); + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, max_no; + int highest_p; + register FileName *entry; + + strcpy(name, afile); + separate_version(name, ver, 1); #ifndef DOS - if (NoFileP(varray)) { - /* - * If there is no file with such name, "new" file is always - * recognized. - */ - if (*ver == '\0' || strcmp(ver, "1") == 0) + if (NoFileP(varray)) { + /* + * If there is no file with such name, "new" file is always + * recognized. + */ + if (*ver == '\0' || strcmp(ver, "1") == 0) #endif /* DOS */ - { - /* - * If version is not specified or 1 is specified, - * we can return versionless file as afile. - */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - ConcDirAndName(dir, name, afile); - return(1); - } + { + /* + * If version is not specified or 1 is specified, + * we can return versionless file as afile. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + ConcDirAndName(dir, name, afile); + return (1); + } #ifndef DOS - else { - /* - * A version other than 1 is specified. "New" file - * is recognized as if. - */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } - - if (get_versionless(varray, vless, dir) == 0) { - /* - * There is no versionless file, but at least one vernsioned - * file exists. - */ - if (*ver == '\0') { - /* - * No version is specified. The new file is one higher than - * the existing highest version. - */ - FindHighestVersion(varray, entry, max_no); - sprintf(vbuf, "%d", max_no + 1); - /* - * We weill use the file name of the exisiting highest - * versioned file as the name of the new file, so that - * new file is as the same case as old. - */ - strcpy(name, entry->name); - separate_version(name, ver, 1); - ConcDirAndName(dir, name, afile); - ConcNameAndVersion(afile, vbuf, vfile); - strcpy(afile, vfile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } - /* - * There is not a file with the specified version in varray. - * The specified file can be recognized as if. - * Most user will hope to create a new file in same case as - * old. One of case sensitive names in the files are stored - * in the trail marker entry in varray by get_version_array - * routine. - * We will use it, although we cannot say all of the gathered - * files has the name in same case. - */ - while (varray->version_no != LASTVERSIONARRAY) varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } else if (OnlyVersionlessP(varray)) { - /* - * There is only versionless file in varray. - * If the specified version is 1 the versionless file is regarded - * as version 1 file. - */ - if (*ver == '\0') { - /* - * No version is specified. The versionless file is dealt - * with as version 1. Thus new version is 2. - */ - ConcNameAndVersion(vless, "2", vfile); - strcpy(afile, vfile); - return(1); - } else { - ver_no = atoi(ver); - if (ver_no == 1) { - /* - * Version 1 is specified. The versionless file is - * dealt with as a version 1 file. - */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * Other versions than 1 are recognized as if. - */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } - } else { - if (check_vless_link(vless, varray, to_file, &highest_p) == 0) - return(0); - if (*to_file == '\0') { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is not linked - * to any file in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The two higher than an - * exisiting maximum version is dealt with as the - * new version, because the one higher version is - * dealt with as the actual version of the link - * missing versionless file. - */ - FindHighestVersion(varray, entry, max_no); - sprintf(vbuf, "%d", max_no + 2); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vfile); - return(1); - } else { - /* A version is specified. */ - ver_no = atoi(ver); - FindHighestVersion(varray, entry, max_no); - if (ver_no == max_no + 1) { - /* - * If the version is one higher than the - * existing highest version is specified, it - * is dealt with as a version of the link - * missing versionless file. - */ - sprintf(vbuf, "%d", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * We have to walk through varray and try - * to find the file with the specified version. - */ - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } - /* - * There is not a file with the specified - * version in varray. The specified file can - * be recognized as if. - * Most user will hope to create a new file in - * same case as old. One of case sensitive - * names in the files are stored in the trail - * marker entry in varray by get_version_array - * routine. - * We will use it, although we cannot say all - * of the gathered files has the name in same - * case. - */ - while (varray->version_no != LASTVERSIONARRAY) - varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } - } else { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is linked to - * one of files in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The one higher than the - * exisiting highest versioned file in varray is a - * new file. - */ - FindHighestVersion(varray, entry, max_no); - sprintf(vbuf, "%d", max_no + 1); - /* - * We will use the name of the highest versioned file - * as the name of the new file. - */ - strcpy(vless, entry->name); - separate_version(vless, ver, 1); - ConcDirAndName(dir, vless, afile); - ConcNameAndVersion(afile, vbuf, vfile); - strcpy(afile, vfile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } - /* - * There is not a file with the specified - * version in varray. The specified file can - * be recognized as if. - * Most user will hope to create a new file in - * same case as old. We will use the name of - * the highest versioned file as the name of the - * new file. - */ - FindHighestVersion(varray, entry, max_no); - strcpy(vless, entry->name); - separate_version(vless, vbuf, 1); - ConcDirAndName(dir, vless, afile); - ConcNameAndVersion(afile, ver, vfile); - strcpy(afile, vfile); - return(1); - } - } - } + else { + /* + * A version other than 1 is specified. "New" file + * is recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The new file is one higher than + * the existing highest version. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + /* + * We weill use the file name of the exisiting highest + * versioned file as the name of the new file, so that + * new file is as the same case as old. + */ + strcpy(name, entry->name); + separate_version(name, ver, 1); + ConcDirAndName(dir, name, afile); + ConcNameAndVersion(afile, vbuf, vfile); + strcpy(afile, vfile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } + /* + * There is not a file with the specified version in varray. + * The specified file can be recognized as if. + * Most user will hope to create a new file in same case as + * old. One of case sensitive names in the files are stored + * in the trail marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all of the gathered + * files has the name in same case. + */ + while (varray->version_no != LASTVERSIONARRAY) varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. Thus new version is 2. + */ + ConcNameAndVersion(vless, "2", vfile); + strcpy(afile, vfile); + return (1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * Other versions than 1 are recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) return (0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The two higher than an + * exisiting maximum version is dealt with as the + * new version, because the one higher version is + * dealt with as the actual version of the link + * missing versionless file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 2); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vfile); + return (1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, max_no); + if (ver_no == max_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. One of case sensitive + * names in the files are stored in the trail + * marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all + * of the gathered files has the name in same + * case. + */ + while (varray->version_no != LASTVERSIONARRAY) varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The one higher than the + * exisiting highest versioned file in varray is a + * new file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + /* + * We will use the name of the highest versioned file + * as the name of the new file. + */ + strcpy(vless, entry->name); + separate_version(vless, ver, 1); + ConcDirAndName(dir, vless, afile); + ConcNameAndVersion(afile, vbuf, vfile); + strcpy(afile, vfile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. We will use the name of + * the highest versioned file as the name of the + * new file. + */ + FindHighestVersion(varray, entry, max_no); + strcpy(vless, entry->name); + separate_version(vless, vbuf, 1); + ConcDirAndName(dir, vless, afile); + ConcNameAndVersion(afile, ver, vfile); + strcpy(afile, vfile); + return (1); + } + } + } #endif /* DOS */ } -/* +/* * Name: get_old_new * * Argument: char *dir Directory absolute path following the UNIX @@ -4539,236 +4361,233 @@ int get_new(dir, varray, afile, vfile) * */ -int get_old_new(dir, varray, afile, vfile) - register char *dir; - register FileName *varray; - register char *afile; - register char *vfile; +int get_old_new(dir, varray, afile, vfile) register char *dir; +register FileName *varray; +register char *afile; +register char *vfile; { - char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; - char ver[VERSIONLEN], vbuf[VERSIONLEN]; - register int ver_no, max_no; - int highest_p; - register FileName *entry; - - strcpy(name, afile); - separate_version(name, ver, 1); + char name[MAXPATHLEN], vless[MAXPATHLEN], to_file[MAXPATHLEN]; + char ver[VERSIONLEN], vbuf[VERSIONLEN]; + register int ver_no, max_no; + int highest_p; + register FileName *entry; - if (NoFileP(varray)) { - /* - * If there is no file with such name, "old/new" file is always - * recognized. - */ - if (*ver == '\0' || strcmp(ver, "1") == 0) { - /* - * If version is not specified or 1 is specified, - * we can return versionless file as afile. - */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - ConcDirAndName(dir, name, afile); - return(1); - } else { - /* - * A version other than 1 is specified. "New" file - * is recognized as if. - */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } - - if (get_versionless(varray, vless, dir) == 0) { - /* - * There is no versionless file, but at least one vernsioned - * file exists. - */ - if (*ver == '\0') { - /* - * No version is specified. The highest versioned file - * is an old file. - */ - FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } - /* - * There is not a file with the specified version in varray. - * The specified file can be recognized as if. - * Most user will hope to create a new file in same case as - * old. One of case sensitive names in the files are stored - * in the trail marker entry in varray by get_version_array - * routine. - * We will use it, although we cannot say all of the gathered - * files has the name in same case. - */ - while (varray->version_no != LASTVERSIONARRAY) varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } else if (OnlyVersionlessP(varray)) { - /* - * There is only versionless file in varray. - * If the specified version is 1 the versionless file is regarded - * as version 1 file. - */ - if (*ver == '\0') { - /* - * No version is specified. The versionless file is dealt - * with as version 1. - */ - ConcNameAndVersion(vless, "1", vfile); - strcpy(afile, vless); - return(1); - } else { - ver_no = atoi(ver); - if (ver_no == 1) { - /* - * Version 1 is specified. The versionless file is - * dealt with as a version 1 file. - */ - ConcNameAndVersion(name, "1", afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * Other versions than 1 are recognized as if. - */ - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } - } else { - if (check_vless_link(vless, varray, to_file, &highest_p) == 0) - return(0); - if (*to_file == '\0') { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is not linked - * to any file in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The one higher than an - * exisiting maximum version is dealt with as the - * old version, and it should be a version of the - * link missing versionless file. - */ - FindHighestVersion(varray, entry, max_no); - sprintf(vbuf, "%d", max_no + 1); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); - return(1); - } else { - /* A version is specified. */ - ver_no = atoi(ver); - FindHighestVersion(varray, entry, max_no); - if (ver_no == max_no + 1) { - /* - * If the version is one higher than the - * existing highest version is specified, it - * is dealt with as a version of the link - * missing versionless file. - */ - sprintf(vbuf, "%d", ver_no); - ConcNameAndVersion(vless, vbuf, vfile); - strcpy(afile, vless); - return(1); - } else { - /* - * We have to walk through varray and try - * to find the file with the specified version. - */ - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } - /* - * There is not a file with the specified - * version in varray. The specified file can - * be recognized as if. - * Most user will hope to create a new file in - * same case as old. One of case sensitive - * names in the files are stored in the trail - * marker entry in varray by get_version_array - * routine. - * We will use it, although we cannot say all - * of the gathered files has the name in same - * case. - */ - while (varray->version_no != LASTVERSIONARRAY) - varray++; - ConcNameAndVersion(varray->name, ver, afile); - ConcDirAndName(dir, afile, vfile); - strcpy(afile, vfile); - return(1); - } - } - } else { - /* - * There is a versionless file in varray and at least one - * versioned file exists. The versionless file is linked to - * one of files in varray. - */ - if (*ver == '\0') { - /* - * No version is specified. The highest versioned file - * in varray is an old file. - */ - FindHighestVersion(varray, entry, max_no); - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } else { - /* - * A version is specified. We have to walk thorough - * varray and try to find the file with the specified - * version. - */ - ver_no = atoi(ver); - FindSpecifiedVersion(varray, entry, ver_no); - if (entry != NULL) { - ConcDirAndName(dir, entry->name, afile); - strcpy(vfile, afile); - return(1); - } - /* - * There is not a file with the specified - * version in varray. The specified file can - * be recognized as if. - * Most user will hope to create a new file in - * same case as old. We will use the name of - * the highest versioned file as the name of the - * new file. - */ - FindHighestVersion(varray, entry, max_no); - strcpy(vless, entry->name); - separate_version(vless, vbuf, 1); - ConcDirAndName(dir, vless, afile); - ConcNameAndVersion(afile, ver, vfile); - strcpy(afile, vfile); - return(1); - } - } - } + strcpy(name, afile); + separate_version(name, ver, 1); + + if (NoFileP(varray)) { + /* + * If there is no file with such name, "old/new" file is always + * recognized. + */ + if (*ver == '\0' || strcmp(ver, "1") == 0) { + /* + * If version is not specified or 1 is specified, + * we can return versionless file as afile. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + ConcDirAndName(dir, name, afile); + return (1); + } else { + /* + * A version other than 1 is specified. "New" file + * is recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } + + if (get_versionless(varray, vless, dir) == 0) { + /* + * There is no versionless file, but at least one vernsioned + * file exists. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } + /* + * There is not a file with the specified version in varray. + * The specified file can be recognized as if. + * Most user will hope to create a new file in same case as + * old. One of case sensitive names in the files are stored + * in the trail marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all of the gathered + * files has the name in same case. + */ + while (varray->version_no != LASTVERSIONARRAY) varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } else if (OnlyVersionlessP(varray)) { + /* + * There is only versionless file in varray. + * If the specified version is 1 the versionless file is regarded + * as version 1 file. + */ + if (*ver == '\0') { + /* + * No version is specified. The versionless file is dealt + * with as version 1. + */ + ConcNameAndVersion(vless, "1", vfile); + strcpy(afile, vless); + return (1); + } else { + ver_no = atoi(ver); + if (ver_no == 1) { + /* + * Version 1 is specified. The versionless file is + * dealt with as a version 1 file. + */ + ConcNameAndVersion(name, "1", afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * Other versions than 1 are recognized as if. + */ + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } + } else { + if (check_vless_link(vless, varray, to_file, &highest_p) == 0) return (0); + if (*to_file == '\0') { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is not linked + * to any file in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The one higher than an + * exisiting maximum version is dealt with as the + * old version, and it should be a version of the + * link missing versionless file. + */ + FindHighestVersion(varray, entry, max_no); + sprintf(vbuf, "%d", max_no + 1); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return (1); + } else { + /* A version is specified. */ + ver_no = atoi(ver); + FindHighestVersion(varray, entry, max_no); + if (ver_no == max_no + 1) { + /* + * If the version is one higher than the + * existing highest version is specified, it + * is dealt with as a version of the link + * missing versionless file. + */ + sprintf(vbuf, "%d", ver_no); + ConcNameAndVersion(vless, vbuf, vfile); + strcpy(afile, vless); + return (1); + } else { + /* + * We have to walk through varray and try + * to find the file with the specified version. + */ + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. One of case sensitive + * names in the files are stored in the trail + * marker entry in varray by get_version_array + * routine. + * We will use it, although we cannot say all + * of the gathered files has the name in same + * case. + */ + while (varray->version_no != LASTVERSIONARRAY) varray++; + ConcNameAndVersion(varray->name, ver, afile); + ConcDirAndName(dir, afile, vfile); + strcpy(afile, vfile); + return (1); + } + } + } else { + /* + * There is a versionless file in varray and at least one + * versioned file exists. The versionless file is linked to + * one of files in varray. + */ + if (*ver == '\0') { + /* + * No version is specified. The highest versioned file + * in varray is an old file. + */ + FindHighestVersion(varray, entry, max_no); + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } else { + /* + * A version is specified. We have to walk thorough + * varray and try to find the file with the specified + * version. + */ + ver_no = atoi(ver); + FindSpecifiedVersion(varray, entry, ver_no); + if (entry != NULL) { + ConcDirAndName(dir, entry->name, afile); + strcpy(vfile, afile); + return (1); + } + /* + * There is not a file with the specified + * version in varray. The specified file can + * be recognized as if. + * Most user will hope to create a new file in + * same case as old. We will use the name of + * the highest versioned file as the name of the + * new file. + */ + FindHighestVersion(varray, entry, max_no); + strcpy(vless, entry->name); + separate_version(vless, vbuf, 1); + ConcDirAndName(dir, vless, afile); + ConcNameAndVersion(afile, ver, vfile); + strcpy(afile, vfile); + return (1); + } + } + } } diff --git a/src/dspif.c b/src/dspif.c old mode 100755 new mode 100644 index 848b9a0..1d7380e --- a/src/dspif.c +++ b/src/dspif.c @@ -1,8 +1,7 @@ -/* $Id: dspif.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: dspif.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: dspif.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyright (C) Venue"; /* This is the display interface */ - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, */ @@ -17,11 +16,8 @@ static char *id = "$Id: dspif.c,v 1.4 2001/12/24 01:09:01 sybalsky Exp $ Copyrig /* */ /************************************************************************/ - #include "version.h" - - #include #include "lispemul.h" #include "dbprint.h" @@ -36,67 +32,55 @@ DspInterface colordsp = &_coldsp; extern int LispDisplayRequestedWidth; extern int LispDisplayRequestedHeight; -extern DspInterface X_init( DspInterface dsp, - char *lispbitmap, - int width_hint, - int height_hint, - int depth_hint ); +extern DspInterface X_init(DspInterface dsp, char *lispbitmap, int width_hint, int height_hint, + int depth_hint); #endif /* XWINDOW */ #ifdef DOS extern int dosdisplaymode; #endif /* DOS */ -void make_dsp_instance(DspInterface dsp, char *lispbitmap, int width_hint, int height_hint, int depth_hint) -{ +void make_dsp_instance(DspInterface dsp, char *lispbitmap, int width_hint, int height_hint, + int depth_hint) { #ifdef DOS TPRINT(("Enter make_dsp_instance, dosdisplaymode is: %d\n", dosdisplaymode)); if (depth_hint == 0) depth_hint = 1; - switch(dosdisplaymode) { - case 1: - VGA_init( dsp ,0, 0, 0, depth_hint ); - break; - case 0x102: - case 0x104: - VESA_init( dsp ,0, 0, 0, depth_hint ); - break; - default: - if (VESA_p()) { - VESA_init( dsp ,0, 0, 0, depth_hint ); - } else if (VGA_p()){ - VGA_init( dsp ,0, 0, 0, depth_hint ); - } else { /* Can't set *ANY* video mode! */ - (void)fprintf(stderr, "No portable graphics mode supported by this host.\n"); - (void)fprintf(stderr, "\n-Expected VESA or VGA.\n"); - exit(1); - } - break; + switch (dosdisplaymode) { + case 1: VGA_init(dsp, 0, 0, 0, depth_hint); break; + case 0x102: + case 0x104: VESA_init(dsp, 0, 0, 0, depth_hint); break; + default: + if (VESA_p()) { + VESA_init(dsp, 0, 0, 0, depth_hint); + } else if (VGA_p()) { + VGA_init(dsp, 0, 0, 0, depth_hint); + } else { /* Can't set *ANY* video mode! */ + (void)fprintf(stderr, "No portable graphics mode supported by this host.\n"); + (void)fprintf(stderr, "\n-Expected VESA or VGA.\n"); + exit(1); + } + break; } #elif XWINDOW /* lispbitmap is 0 when we call X_init the first time. */ - if ( X_init( dsp, 0, LispDisplayRequestedWidth, - LispDisplayRequestedHeight, depth_hint ) == NULL) { + if (X_init(dsp, 0, LispDisplayRequestedWidth, LispDisplayRequestedHeight, depth_hint) == NULL) { fprintf(stderr, "Can't open display."); exit(-1); } -#endif /* DOS | XWINDOW */ -} /* Now we know the Maxi-MooM capabillities of the hardware. */ +#endif /* DOS | XWINDOW */ +} /* Now we know the Maxi-MooM capabillities of the hardware. */ #ifdef DOS -VESA_p() -{ +VESA_p() { /* Magic. Do a vesa call to determine the current mode. */ - return(VESA_call( 3 , 0 )); + return (VESA_call(3, 0)); } -VGA_p() -{ - return( TRUE ); -} +VGA_p() { return (TRUE); } #endif /* DOS */ /*********************************************************************/ @@ -106,39 +90,31 @@ VGA_p() /* Utility function that just returns T */ /* */ /*********************************************************************/ -unsigned long -GenericReturnT(void) -{ - return(T); -} +unsigned long GenericReturnT(void) { return (T); } -void GenericPanic(DspInterface dsp) -{ +void GenericPanic(DspInterface dsp) { TPRINT(("Enter GenericPanic\n")); - fprintf( stderr, "Panic! Call to uninitialized display slot!" ); + fprintf(stderr, "Panic! Call to uninitialized display slot!"); exit(0); } - -LispPTR SwitchDisplay(LispPTR display) -{ - DspInterface tmp; /* Switch-a-roo! */ +LispPTR SwitchDisplay(LispPTR display) { + DspInterface tmp; /* Switch-a-roo! */ TPRINT(("Enter SwitchDisplay\n")); tmp = currentdsp; currentdsp = colordsp; colordsp = tmp; TPRINT(("Exit SwitchDisplay\n")); - return( display ); + return (display); } -void describedsp(DspInterface dsp) -{ - if ( dsp == 0 ){ +void describedsp(DspInterface dsp) { + if (dsp == 0) { printf("describedsp: Not a dsp!\n"); return; } - if ( dsp == &_curdsp ) + if (dsp == &_curdsp) printf("dsp is B/W display\n"); else printf("dsp is COLOR display\n"); diff --git a/src/dspsubrs.c b/src/dspsubrs.c old mode 100755 new mode 100644 index 6399fcb..1c318d5 --- a/src/dspsubrs.c +++ b/src/dspsubrs.c @@ -1,12 +1,8 @@ -/* $Id: dspsubrs.c,v 1.3 2001/12/26 22:17:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: dspsubrs.c,v 1.3 2001/12/26 22:17:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: dspsubrs.c,v 1.3 2001/12/26 22:17:02 sybalsky Exp $ Copyright (C) Venue"; /*** ADOPTED NEW VERSION ***/ - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-2000 Venue. All Rights Reserved. */ @@ -21,14 +17,12 @@ static char *id = "$Id: dspsubrs.c,v 1.3 2001/12/26 22:17:02 sybalsky Exp $ Copy #include "version.h" - #include #ifndef NOPIXRECT #include #include #endif /* NOPIXRECT */ - #include "lispemul.h" #include "lsptypes.h" #include "lispmap.h" @@ -41,7 +35,6 @@ extern int displaywidth, displayheight; extern int Mouse_Included; #endif /* XWINDOW */ - /**************************************************** * * DSP_dspbout() entry of SUBRCALL 9 1 @@ -49,13 +42,8 @@ extern int Mouse_Included; * ****************************************************/ -void DSP_dspbout( args ) -LispPTR *args; /* args[0] : charcode */ - { - putc( (args[0] & 0xFFFF) & 0x7f, BCPLDISPLAY ); - } - - +void DSP_dspbout(args) LispPTR *args; /* args[0] : charcode */ +{ putc((args[0] & 0xFFFF) & 0x7f, BCPLDISPLAY); } /**************************************************** * @@ -64,15 +52,10 @@ LispPTR *args; /* args[0] : charcode */ * ****************************************************/ -extern int DisplayInitialized ; - -void DSP_showdisplay( args ) -LispPTR *args; -{ - DisplayInitialized = 1; -} - +extern int DisplayInitialized; +void DSP_showdisplay(args) LispPTR *args; +{ DisplayInitialized = 1; } /**************************************************** * @@ -81,105 +64,92 @@ LispPTR *args; * ****************************************************/ -LispPTR DSP_VideoColor( args ) -LispPTR *args; /* args[0] : black flag */ +LispPTR DSP_VideoColor(args) LispPTR *args; /* args[0] : black flag */ { - int invert; + int invert; #ifdef SUNDISPLAY - return NIL; + return NIL; #endif /* SUNDISPLAY */ - #ifdef XWINDOW - invert = args[0] & 0xFFFF; - lisp_Xvideocolor( invert ); - if( invert ) - return ATOM_T; - else - return NIL; + invert = args[0] & 0xFFFF; + lisp_Xvideocolor(invert); + if (invert) + return ATOM_T; + else + return NIL; #endif /* XWINDOW */ - } - - extern struct cursor CurrentCursor; extern int LispWindowFd; extern int errno; - /**************************************************** * * DSP_Cursor() entry of SUBRCALL 64 2 * called from \HARDCURSORUP etc. * ****************************************************/ -void DSP_Cursor( args , argnum) -LispPTR *args; int argnum; - /* args[0] : hot sopt X - * args[1] : hot spot Y - */ +void DSP_Cursor(args, argnum) LispPTR *args; +int argnum; +/* args[0] : hot sopt X + * args[1] : hot spot Y + */ { - extern int ScreenLocked; - extern DLword *EmCursorX68K,*EmCursorY68K; - extern int LastCursorX,LastCursorY; - static int Init=T; + extern int ScreenLocked; + extern DLword *EmCursorX68K, *EmCursorY68K; + extern int LastCursorX, LastCursorY; + static int Init = T; #ifdef SUNDISPLAY - if (argnum == 2) { - CurrentCursor.cur_xhot=args[0] & 0xffff; - CurrentCursor.cur_yhot=args[1] & 0xffff; - }; + if (argnum == 2) { + CurrentCursor.cur_xhot = args[0] & 0xffff; + CurrentCursor.cur_yhot = args[1] & 0xffff; + }; #ifdef OLD_CURSOR - win_setcursor( LispWindowFd, &CurrentCursor ); + win_setcursor(LispWindowFd, &CurrentCursor); #else #ifndef INIT - ScreenLocked =T; - if(!Init){ - taking_mouse_down(); - taking_mouse_up(*EmCursorX68K,*EmCursorY68K); - } - else{ - Init=NIL; - cursor_hidden_bitmap(0,0); - taking_mouse_up(0,0); - *EmCursorX68K=LastCursorX=0; - *EmCursorY68K=LastCursorY=0; - } + ScreenLocked = T; + if (!Init) { + taking_mouse_down(); + taking_mouse_up(*EmCursorX68K, *EmCursorY68K); + } else { + Init = NIL; + cursor_hidden_bitmap(0, 0); + taking_mouse_up(0, 0); + *EmCursorX68K = LastCursorX = 0; + *EmCursorY68K = LastCursorY = 0; + } - ScreenLocked=NIL; + ScreenLocked = NIL; #else -/* Init specific lde only */ - ScreenLocked =T; - if(!Init){ - taking_mouse_down(); - taking_mouse_up(0,0); - } - else{ - Init=NIL; - cursor_hidden_bitmap(0,0); - taking_mouse_up(0,0); - } + /* Init specific lde only */ + ScreenLocked = T; + if (!Init) { + taking_mouse_down(); + taking_mouse_up(0, 0); + } else { + Init = NIL; + cursor_hidden_bitmap(0, 0); + taking_mouse_up(0, 0); + } - ScreenLocked=NIL; + ScreenLocked = NIL; #endif /* INIT */ #endif #endif /* SUNDISPLAY */ - #ifdef XWINDOW - /* For X-Windows, set the cursor the the given location. */ - Set_XCursor( (int)(args[0]&0xFFFF), (int)(args[1]&0xFFFF) ); + /* For X-Windows, set the cursor the the given location. */ + Set_XCursor((int)(args[0] & 0xFFFF), (int)(args[1] & 0xFFFF)); #endif /* XWINDOW */ - - } - - /**************************************************** * * DSP_SetMousePos() entry of SUBRCALL 65 2 @@ -187,46 +157,41 @@ LispPTR *args; int argnum; * ****************************************************/ -void DSP_SetMousePos( args ) -register LispPTR *args; /* args[0] : X pos - * args[1] : Y pos - */ +void DSP_SetMousePos(args) register LispPTR *args; /* args[0] : X pos + * args[1] : Y pos + */ { #ifdef SUNDISPLAY #ifdef OLD_CURSOR - register int x ,y; - x=GetSmalldata(args[0]); - y=GetSmalldata(args[1]); /* debug */ - win_setmouseposition(LispWindowFd, GetSmalldata(args[0]), - GetSmalldata(args[1])); + register int x, y; + x = GetSmalldata(args[0]); + y = GetSmalldata(args[1]); /* debug */ + win_setmouseposition(LispWindowFd, GetSmalldata(args[0]), GetSmalldata(args[1])); #else - extern int ScreenLocked; - extern DLword *EmCursorX68K,*EmCursorY68K,*EmMouseX68K,*EmMouseY68K; - register int x ,y; - ScreenLocked=T; - x=GetSmalldata(args[0]); - y=GetSmalldata(args[1]); - /* for Suntool's invisible cursor */ - win_setmouseposition(LispWindowFd, x,y); - /* for REAL cursor image */ - taking_mouse_down(); - taking_mouse_up(x,y); + extern int ScreenLocked; + extern DLword *EmCursorX68K, *EmCursorY68K, *EmMouseX68K, *EmMouseY68K; + register int x, y; + ScreenLocked = T; + x = GetSmalldata(args[0]); + y = GetSmalldata(args[1]); + /* for Suntool's invisible cursor */ + win_setmouseposition(LispWindowFd, x, y); + /* for REAL cursor image */ + taking_mouse_down(); + taking_mouse_up(x, y); #ifndef INIT - *EmMouseX68K=x; - *EmMouseY68K=y; + *EmMouseX68K = x; + *EmMouseY68K = y; #endif - ScreenLocked=NIL; + ScreenLocked = NIL; #endif #endif /* SUNDISPLAY */ - #ifdef XWINDOW - if( Mouse_Included ) - set_Xmouseposition( (int)(GetSmalldata(args[0])) - , (int)(GetSmalldata(args[1])) ); + if (Mouse_Included) + set_Xmouseposition((int)(GetSmalldata(args[0])), (int)(GetSmalldata(args[1]))); #endif /* XWINDOW */ - } /**************************************************** @@ -235,11 +200,8 @@ register LispPTR *args; /* args[0] : X pos * called from \Katana.DisplayWidth. * ****************************************************/ -LispPTR DSP_ScreenWidth( args ) -LispPTR *args; -{ - return( S_POSITIVE | (0xFFFF & displaywidth) ); -} +LispPTR DSP_ScreenWidth(args) LispPTR *args; +{ return (S_POSITIVE | (0xFFFF & displaywidth)); } /**************************************************** * @@ -247,11 +209,8 @@ LispPTR *args; * called from \Katana.DisplayHeight. * ****************************************************/ -LispPTR DSP_ScreenHight( args ) -LispPTR *args; -{ - return( S_POSITIVE | (0xFFFF & displayheight) ); -} +LispPTR DSP_ScreenHight(args) LispPTR *args; +{ return (S_POSITIVE | (0xFFFF & displayheight)); } /**************************************************** * @@ -266,63 +225,54 @@ extern int for_makeinit; extern int Current_Hot_X, Current_Hot_Y; #endif /* XWINDOW */ -void flip_cursor() - { - register DLword *word; - register int cnt; - extern int ScreenLocked; - extern DLword *EmCursorX68K,*EmCursorY68K; +void flip_cursor() { + register DLword *word; + register int cnt; + extern int ScreenLocked; + extern DLword *EmCursorX68K, *EmCursorY68K; - word = EmCursorBitMap68K; + word = EmCursorBitMap68K; #ifdef INIT - /* since this is called frequently, and you don't want to have - to build a different LDE to run the 2 parts of a Loadup, there is - an ifdef AND a test. This way we don't generate - extra code for anybody elses building an LDE - except those who want to try building loadups. */ + /* since this is called frequently, and you don't want to have + to build a different LDE to run the 2 parts of a Loadup, there is + an ifdef AND a test. This way we don't generate + extra code for anybody elses building an LDE + except those who want to try building loadups. */ - if (!for_makeinit){ - for (cnt = CURSORHEIGHT;(cnt--);) - { - GETWORD(word++) ^= 0xFFFF; - }; - }; + if (!for_makeinit) { + for (cnt = CURSORHEIGHT; (cnt--);) { GETWORD(word++) ^= 0xFFFF; }; + }; #else - for (cnt = CURSORHEIGHT;(cnt--);) - { - GETWORD(word++) ^= 0xFFFF; - }; + for (cnt = CURSORHEIGHT; (cnt--);) { GETWORD(word++) ^= 0xFFFF; }; #endif #ifdef SUNDISPLAY #ifdef OLD_CURSOR - win_setcursor( LispWindowFd, &CurrentCursor ); + win_setcursor(LispWindowFd, &CurrentCursor); #else - ScreenLocked=T; - taking_mouse_down(); + ScreenLocked = T; + taking_mouse_down(); #ifndef INIT - taking_mouse_up(*EmCursorX68K,*EmCursorY68K); + taking_mouse_up(*EmCursorX68K, *EmCursorY68K); #else - if(!for_makeinit) - taking_mouse_up(*EmCursorX68K,*EmCursorY68K); - else - taking_mouse_up(0,0); + if (!for_makeinit) + taking_mouse_up(*EmCursorX68K, *EmCursorY68K); + else + taking_mouse_up(0, 0); #endif /* INIT */ - ScreenLocked=NIL; + ScreenLocked = NIL; #endif #endif /* SUNDISPLAY */ - #ifdef XWINDOW - /* JDS 011213: 15- cur y, as function does same! */ - Set_XCursor( Current_Hot_X, 15-Current_Hot_Y ); + /* JDS 011213: 15- cur y, as function does same! */ + Set_XCursor(Current_Hot_X, 15 - Current_Hot_Y); #endif /* XWINDOW */ - } diff --git a/src/ejlisp.c b/src/ejlisp.c old mode 100755 new mode 100644 index 6a1cf22..5d6c909 --- a/src/ejlisp.c +++ b/src/ejlisp.c @@ -1,8 +1,7 @@ -/* $Id: ejlisp.c,v 1.2 1999/01/03 02:06:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: ejlisp.c,v 1.2 1999/01/03 02:06:58 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: ejlisp.c,v 1.2 1999/01/03 02:06:58 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: ejlisp.c,v 1.2 1999/01/03 02:06:58 sybalsky Exp $ Copyri #include "version.h" - #include #include @@ -40,935 +38,873 @@ static char *id = "$Id: ejlisp.c,v 1.2 1999/01/03 02:06:58 sybalsky Exp $ Copyri #include "timeout.h" -#define CHAR_MAXLEN 512 -#define TABLE_MAX 100 -#define CHAR_SIZE CHAR_MAXLEN*(sizeof(char)/sizeof(int)) +#define CHAR_MAXLEN 512 +#define TABLE_MAX 100 +#define CHAR_SIZE CHAR_MAXLEN *(sizeof(char) / sizeof(int)) -#define LStringToCString(Lisp, C, MaxLen ,Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int i,j; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ - Len = min(MaxLen, arrayp->totalsize); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(i=0;ibase))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(i=0;itotalsize); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = \ + ((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + for (i = 0; i < Len; i++) { C[i] = base[i]; } \ + C[Len] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = \ + ((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (i = 0; i < Len * 2; i++) C[i] = base[i]; \ + C[Len * 2] = '\0'; \ + break; \ + \ + default: error("LStringToCString can not handle\n"); \ + } \ } -#define CStringToLString(C, Lisp, Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int id; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(id=0;idfillpointer = Len; \ - break; \ - \ - case FAT_CHAR_TYPENUMBER: \ - sbase = ((short *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(id=0;idfillpointer = Len; \ - break; \ - \ - default: \ - error("CStringToLString can not handle\n"); \ - } \ +#define CStringToLString(C, Lisp, Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int id; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = \ + ((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + for (id = 0; id < Len; id++) base[id] = C[id]; \ + arrayp->fillpointer = Len; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = \ + ((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (id = 0; id < Len * 2; id++) base[id] = C[id]; \ + arrayp->fillpointer = Len; \ + break; \ + \ + default: error("CStringToLString can not handle\n"); \ + } \ } -#define IntToFixp(C, Lisp) \ - { \ - int *base; \ - \ - base = (int *) Addr68k_from_LADDR((unsigned int)Lisp); \ - *base = C; \ +#define IntToFixp(C, Lisp) \ + { \ + int *base; \ + \ + base = (int *)Addr68k_from_LADDR((unsigned int)Lisp); \ + *base = C; \ } -#define ZeroFix(C) \ - { \ - int k,j; \ - \ - if (C[0] == 0 && C[1] != 0) { \ - for (k = j = 0 ; C[k] != 0 || C[k+1] != 0;k++) { \ - if (C[k] != 0) C[j++] = C[k]; \ - } \ - C[j] = 0; \ - } \ +#define ZeroFix(C) \ + { \ + int k, j; \ + \ + if (C[0] == 0 && C[1] != 0) { \ + for (k = j = 0; C[k] != 0 || C[k + 1] != 0; k++) { \ + if (C[k] != 0) C[j++] = C[k]; \ + } \ + C[j] = 0; \ + } \ } - -#define EJLISP_SETJMP(x) \ - { \ - if (setjmp(jmpbuf) != 0) { \ - ejlisp_buf = NULL; \ - return(x); \ - } \ + +#define EJLISP_SETJMP(x) \ + { \ + if (setjmp(jmpbuf) != 0) { \ + ejlisp_buf = NULL; \ + return (x); \ + } \ } - + typedef struct first_array { - unsigned int orig : 1 ; - unsigned int nil1 : 1 ; - unsigned int rdonly : 1 ; - unsigned int nil2 : 1 ; - unsigned int type : 4 ; - unsigned int base : 24 ; - unsigned short length; - unsigned short offset ; } FirstArray; + unsigned int orig : 1; + unsigned int nil1 : 1; + unsigned int rdonly : 1; + unsigned int nil2 : 1; + unsigned int type : 4; + unsigned int base : 24; + unsigned short length; + unsigned short offset; +} FirstArray; struct wnn_buf *ejlisp_buf = NULL; struct wnn_jdata *ejlisp_jdp; -int ejlisp_jdp_num; -int ejlisp_kouho_max; -int ejlisp_kouho_num; -int ejlisp_kouho_next; +int ejlisp_jdp_num; +int ejlisp_kouho_max; +int ejlisp_kouho_num; +int ejlisp_kouho_next; -#define WNN_OPEN 1 -#define WNN_CLOSE 2 -#define WNN_CONV 3 -#define WNN_RECONV 4 -#define WNN_SELECT_BUNSETSU 5 -#define WNN_GET_KOUHO 6 -#define WNN_SELECT_KOUHO 7 -#define WNN_GET_YOMI 8 -#define WNN_CONV_END 9 -#define WNN_ADD_USERDIC 10 -#define WNN_DEL_USERDIC 11 -#define WNN_SEARCH_USERDIC 12 -#define WNN_GET_USERDIC 13 -#define WNN_GET_USERDIC_NAME 14 -#define WNN_BUNSETSU_KANJI 15 -#define WNN_BUNSETSU_YOMI 16 +#define WNN_OPEN 1 +#define WNN_CLOSE 2 +#define WNN_CONV 3 +#define WNN_RECONV 4 +#define WNN_SELECT_BUNSETSU 5 +#define WNN_GET_KOUHO 6 +#define WNN_SELECT_KOUHO 7 +#define WNN_GET_YOMI 8 +#define WNN_CONV_END 9 +#define WNN_ADD_USERDIC 10 +#define WNN_DEL_USERDIC 11 +#define WNN_SEARCH_USERDIC 12 +#define WNN_GET_USERDIC 13 +#define WNN_GET_USERDIC_NAME 14 +#define WNN_BUNSETSU_KANJI 15 +#define WNN_BUNSETSU_YOMI 16 -ejlisp(args) - int args[]; +ejlisp(args) int args[]; { - int result; - int i,j,length; + int result; + int i, j, length; - int c_number1, c_number2, c_number3, c_number4; - int c_number5[TABLE_MAX], c_number6[TABLE_MAX]; + int c_number1, c_number2, c_number3, c_number4; + int c_number5[TABLE_MAX], c_number6[TABLE_MAX]; - unsigned char c_char1[(CHAR_MAXLEN+1)*2]; - unsigned char c_char2[(CHAR_MAXLEN+1)*2]; - unsigned char c_char3[TABLE_MAX][(CHAR_MAXLEN+1)*2]; - unsigned char tmp[(CHAR_MAXLEN+1)*2]; + unsigned char c_char1[(CHAR_MAXLEN + 1) * 2]; + unsigned char c_char2[(CHAR_MAXLEN + 1) * 2]; + unsigned char c_char3[TABLE_MAX][(CHAR_MAXLEN + 1) * 2]; + unsigned char tmp[(CHAR_MAXLEN + 1) * 2]; - FirstArray *a_ptr; - unsigned int *base1; - unsigned int *base2; - unsigned int *base3; + FirstArray *a_ptr; + unsigned int *base1; + unsigned int *base2; + unsigned int *base3; - N_GETNUMBER(args[0], c_number1, ERROR); + N_GETNUMBER(args[0], c_number1, ERROR); #ifdef DEBUG - printf("ejlisp start\n"); - printf("case = %d\n", c_number1); + printf("ejlisp start\n"); + printf("case = %d\n", c_number1); #endif - switch (c_number1) { - case WNN_OPEN: - LStringToCString(args[1], c_char1, CHAR_MAXLEN,length); - N_GETNUMBER(args[2], c_number1, ERROR); - LStringToCString(args[3], c_char2, CHAR_MAXLEN,length); - result = ejlisp_open(c_char1, c_number1, c_char2); - break; + switch (c_number1) { + case WNN_OPEN: + LStringToCString(args[1], c_char1, CHAR_MAXLEN, length); + N_GETNUMBER(args[2], c_number1, ERROR); + LStringToCString(args[3], c_char2, CHAR_MAXLEN, length); + result = ejlisp_open(c_char1, c_number1, c_char2); + break; - case WNN_CLOSE: - result = ejlisp_close(); - break; + case WNN_CLOSE: result = ejlisp_close(); break; - case WNN_CONV: - LStringToCString(args[1], tmp, CHAR_MAXLEN, length); - if (strlen(tmp) == length) { - for (i = length - 1 ; i >= 0 ; i--) { - tmp[i*2+1] = tmp[i]; - tmp[i*2] = 0; - } - tmp[length*2] = '\0'; - } - length = FatcharNStoEUC(tmp, length, c_char1); - for (i = length; i < (CHAR_MAXLEN+1)*2; i++) - c_char1[i] = NULL; + case WNN_CONV: + LStringToCString(args[1], tmp, CHAR_MAXLEN, length); + if (strlen(tmp) == length) { + for (i = length - 1; i >= 0; i--) { + tmp[i * 2 + 1] = tmp[i]; + tmp[i * 2] = 0; + } + tmp[length * 2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char1); + for (i = length; i < (CHAR_MAXLEN + 1) * 2; i++) c_char1[i] = NULL; - result = ejlisp_conv(c_char1, c_char2, &c_number1, &c_number2); - if (result != 0) break; + result = ejlisp_conv(c_char1, c_char2, &c_number1, &c_number2); + if (result != 0) break; - ZeroFix(c_char2); - length = EUCtoFatcharNS(c_char2, tmp); - CStringToLString(tmp, args[2], length); + ZeroFix(c_char2); + length = EUCtoFatcharNS(c_char2, tmp); + CStringToLString(tmp, args[2], length); - IntToFixp(c_number1, args[3]); - IntToFixp(c_number2, args[4]); + IntToFixp(c_number1, args[3]); + IntToFixp(c_number2, args[4]); - break; + break; - case WNN_RECONV: - N_GETNUMBER(args[1], c_number1, ERROR); - N_GETNUMBER(args[2], c_number2, ERROR); + case WNN_RECONV: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); - result = ejlisp_reconv(c_number1, c_number2, c_char1, &c_number3, &c_number4); - if (result != 0) break; + result = ejlisp_reconv(c_number1, c_number2, c_char1, &c_number3, &c_number4); + if (result != 0) break; - ZeroFix(c_char1); - length = EUCtoFatcharNS(c_char1, tmp); - CStringToLString(tmp, args[3], length); + ZeroFix(c_char1); + length = EUCtoFatcharNS(c_char1, tmp); + CStringToLString(tmp, args[3], length); - IntToFixp(c_number3, args[4]); - IntToFixp(c_number4, args[5]); + IntToFixp(c_number3, args[4]); + IntToFixp(c_number4, args[5]); - break; + break; - case WNN_SELECT_BUNSETSU: - N_GETNUMBER(args[1], c_number1, ERROR); + case WNN_SELECT_BUNSETSU: + N_GETNUMBER(args[1], c_number1, ERROR); - result = ejlisp_select_bunsetsu(c_number1, &c_number2); - if (result != 0) break; + result = ejlisp_select_bunsetsu(c_number1, &c_number2); + if (result != 0) break; - IntToFixp(c_number2, args[2]); + IntToFixp(c_number2, args[2]); - break; + break; - case WNN_GET_KOUHO: - N_GETNUMBER(args[1], c_number1, ERROR); + case WNN_GET_KOUHO: + N_GETNUMBER(args[1], c_number1, ERROR); - result = ejlisp_get_kouho(c_number1, c_char3, &c_number2); - if (result != 0) break; + result = ejlisp_get_kouho(c_number1, c_char3, &c_number2); + if (result != 0) break; - a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[2])); - base1 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + a_ptr = (FirstArray *)(Addr68k_from_LADDR((unsigned int)args[2])); + base1 = + ((unsigned int *)(Addr68k_from_LADDR((unsigned int)a_ptr->base))) + (int)(a_ptr->offset); + for (i = 0; i < ejlisp_kouho_max; i++, base1++, base2++) { + ZeroFix(c_char3[i]); + length = EUCtoFatcharNS(c_char3[i], tmp); + CStringToLString(tmp, *base1, length); + } - for(i=0;i= 0; i--) { + tmp[i * 2 + 1] = tmp[i]; + tmp[i * 2] = 0; + } + tmp[length * 2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char1); + for (i = length; i < (CHAR_MAXLEN + 1) * 2; i++) c_char1[i] = NULL; - LStringToCString(args[2], tmp, CHAR_MAXLEN,length); - if (strlen(tmp) == length) { - for (i = length - 1 ; i >= 0 ; i--) { - tmp[i*2+1] = tmp[i]; - tmp[i*2] = 0; - } - tmp[length*2] = '\0'; - } - length = FatcharNStoEUC(tmp, length, c_char1); - for (i = length; i < (CHAR_MAXLEN+1)*2; i++) - c_char1[i] = NULL; + LStringToCString(args[3], tmp, CHAR_MAXLEN, length); + if (strlen(tmp) == length) { + for (i = length - 1; i >= 0; i--) { + tmp[i * 2 + 1] = tmp[i]; + tmp[i * 2] = 0; + } + tmp[length * 2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char2); + for (i = length; i < (CHAR_MAXLEN + 1) * 2; i++) c_char2[i] = NULL; - LStringToCString(args[3], tmp, CHAR_MAXLEN,length); - if (strlen(tmp) == length) { - for (i = length - 1 ; i >= 0 ; i--) { - tmp[i*2+1] = tmp[i]; - tmp[i*2] = 0; - } - tmp[length*2] = '\0'; - } - length = FatcharNStoEUC(tmp, length, c_char2); - for (i = length; i < (CHAR_MAXLEN+1)*2; i++) - c_char2[i] = NULL; + N_GETNUMBER(args[4], c_number2, ERROR); - N_GETNUMBER(args[4], c_number2, ERROR); + result = ejlisp_add_userdic(c_number1, c_char1, c_char2, c_number2); + if (result != 0) break; - result = ejlisp_add_userdic(c_number1, c_char1, c_char2, c_number2); - if (result != 0) break; + break; - break; + case WNN_DEL_USERDIC: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); - case WNN_DEL_USERDIC: - N_GETNUMBER(args[1], c_number1, ERROR); - N_GETNUMBER(args[2], c_number2, ERROR); + result = ejlisp_del_userdic(c_number1, c_number2); + if (result != 0) break; - result = ejlisp_del_userdic(c_number1, c_number2); - if (result != 0) break; + break; - break; + case WNN_SEARCH_USERDIC: + N_GETNUMBER(args[1], c_number1, ERROR); - case WNN_SEARCH_USERDIC: - N_GETNUMBER(args[1], c_number1, ERROR); + LStringToCString(args[2], tmp, CHAR_MAXLEN, length); + if (strlen(tmp) == length) { + for (i = length - 1; i >= 0; i--) { + tmp[i * 2 + 1] = tmp[i]; + tmp[i * 2] = 0; + } + tmp[length * 2] = '\0'; + } + length = FatcharNStoEUC(tmp, length, c_char1); + for (i = length; i < (CHAR_MAXLEN + 1) * 2; i++) c_char1[i] = NULL; - LStringToCString(args[2], tmp, CHAR_MAXLEN,length); - if (strlen(tmp) == length) { - for (i = length - 1 ; i >= 0 ; i--) { - tmp[i*2+1] = tmp[i]; - tmp[i*2] = 0; - } - tmp[length*2] = '\0'; - } - length = FatcharNStoEUC(tmp, length, c_char1); - for (i = length; i < (CHAR_MAXLEN+1)*2; i++) - c_char1[i] = NULL; + result = ejlisp_search_userdic(c_number1, c_char1); + if (result != 0) break; - result = ejlisp_search_userdic(c_number1, c_char1); - if (result != 0) break; + IntToFixp(ejlisp_jdp_num, args[3]); - IntToFixp(ejlisp_jdp_num, args[3]); + break; - break; + case WNN_GET_USERDIC: - case WNN_GET_USERDIC: + result = ejlisp_get_userdic(c_char3, c_number5, c_number6); + if (result != 0) break; - result = ejlisp_get_userdic(c_char3, c_number5, c_number6); - if (result != 0) break; + a_ptr = (FirstArray *)(Addr68k_from_LADDR((unsigned int)args[1])); + base1 = + ((unsigned int *)(Addr68k_from_LADDR((unsigned int)a_ptr->base))) + (int)(a_ptr->offset); - a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[1])); - base1 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + a_ptr = (FirstArray *)(Addr68k_from_LADDR((unsigned int)args[2])); + base2 = + ((unsigned int *)(Addr68k_from_LADDR((unsigned int)a_ptr->base))) + (int)(a_ptr->offset); - a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[2])); - base2 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + a_ptr = (FirstArray *)(Addr68k_from_LADDR((unsigned int)args[3])); + base3 = + ((unsigned int *)(Addr68k_from_LADDR((unsigned int)a_ptr->base))) + (int)(a_ptr->offset); - a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[3])); - base3 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + for (i = 0; i < ejlisp_jdp_num; i++, base1++, base2++, base3++) { + ZeroFix(c_char3[i]); + length = EUCtoFatcharNS(c_char3[i], tmp); + CStringToLString(tmp, *base1, length); + *base2 = length; + *base3 = c_number6[i]; + } - for(i=0;ibase))) + (int)(a_ptr->offset); - a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[1])); - base1 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + a_ptr = (FirstArray *)(Addr68k_from_LADDR((unsigned int)args[2])); + base2 = + ((unsigned int *)(Addr68k_from_LADDR((unsigned int)a_ptr->base))) + (int)(a_ptr->offset); - a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[2])); - base2 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + a_ptr = (FirstArray *)(Addr68k_from_LADDR((unsigned int)args[3])); + base3 = + ((unsigned int *)(Addr68k_from_LADDR((unsigned int)a_ptr->base))) + (int)(a_ptr->offset); - a_ptr = (FirstArray *) (Addr68k_from_LADDR((unsigned int) args[3])); - base3 = ((unsigned int *) (Addr68k_from_LADDR((unsigned int) a_ptr->base))) + (int)(a_ptr->offset); + for (i = 0; c_char3[i][0] != NULL; i++, base1++, base2++, base3++) { + ZeroFix(c_char3[i]); + length = EUCtoFatcharNS(c_char3[i], tmp); + CStringToLString(tmp, *base1, length); + *base2 = c_number5[i]; + *base3 = c_number6[i]; + } - for(i=0;c_char3[i][0] != NULL;i++,base1++,base2++,base3++) { - ZeroFix(c_char3[i]); - length = EUCtoFatcharNS(c_char3[i], tmp); - CStringToLString(tmp, *base1, length); - *base2 = c_number5[i]; - *base3 = c_number6[i]; - } + break; - break; + case WNN_BUNSETSU_KANJI: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); - case WNN_BUNSETSU_KANJI: - N_GETNUMBER(args[1], c_number1, ERROR); - N_GETNUMBER(args[2], c_number2, ERROR); + result = ejlisp_bunsetsu_kanji(c_number1, c_number2, &c_number3); + if (result != 0) break; - result = ejlisp_bunsetsu_kanji(c_number1, c_number2, &c_number3); - if (result != 0) break; + IntToFixp(c_number3, args[3]); + break; - IntToFixp(c_number3, args[3]); - break; + case WNN_BUNSETSU_YOMI: + N_GETNUMBER(args[1], c_number1, ERROR); + N_GETNUMBER(args[2], c_number2, ERROR); - case WNN_BUNSETSU_YOMI: - N_GETNUMBER(args[1], c_number1, ERROR); - N_GETNUMBER(args[2], c_number2, ERROR); + result = ejlisp_bunsetsu_yomi(c_number1, c_number2, &c_number3); + if (result != 0) break; - result = ejlisp_bunsetsu_yomi(c_number1, c_number2, &c_number3); - if (result != 0) break; + IntToFixp(c_number3, args[3]); + break; - IntToFixp(c_number3, args[3]); - break; - -ERROR: - result = 9999; - break; - - } + ERROR: + result = 9999; + break; + } #ifdef DEBUG - printf("ejlisp end\n"); - printf("result = %d\n", result); + printf("ejlisp end\n"); + printf("result = %d\n", result); #endif - return (GetSmallp(result)); + return (GetSmallp(result)); } -ejlisp_add_userdic (dic_no,kanji,yomi,hinshi) -int dic_no; -unsigned short *kanji; -unsigned short *yomi; -int hinshi; +ejlisp_add_userdic(dic_no, kanji, yomi, hinshi) int dic_no; +unsigned short *kanji; +unsigned short *yomi; +int hinshi; { - int result; + int result; #ifdef DEBUG - printf("ejlisp_add_userdic start\n"); - printf("dic_no = %d,kanji = %s,yomi = %s,hinshi = %d\n",dic_no,kanji,yomi,hinshi); + printf("ejlisp_add_userdic start\n"); + printf("dic_no = %d,kanji = %s,yomi = %s,hinshi = %d\n", dic_no, kanji, yomi, hinshi); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - TIMEOUT(result = jl_word_add(ejlisp_buf,dic_no,yomi,kanji,NULL,hinshi,0)); - if (result == 0) { - TIMEOUT(jl_dic_save (ejlisp_buf,dic_no)); - } + wnn_errorno = 0; + TIMEOUT(result = jl_word_add(ejlisp_buf, dic_no, yomi, kanji, NULL, hinshi, 0)); + if (result == 0) { TIMEOUT(jl_dic_save(ejlisp_buf, dic_no)); } #ifdef DEBUG - printf("ejlisp_add_userdic end\n"); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_add_userdic end\n"); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_bunsetsu_kanji(bunsetsu_no,bunsetsu_no2,kanji_len) -int bunsetsu_no,bunsetsu_no2; -int *kanji_len; -{ - -#ifdef DEBUG - printf("ejlisp_bunsetsu_kanji start\n"); - printf("bunsetsu_no = %d\n",bunsetsu_no); -#endif - - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); - - wnn_errorno = 0; - TIMEOUT(*kanji_len = jl_kanji_len (ejlisp_buf,bunsetsu_no,bunsetsu_no2)) ; - -#ifdef DEBUG - printf("ejlisp_bunsetsu_kanji end\n"); - if (wnn_errorno == 0) - printf("kanji_len = %d\n",*kanji_len); - printf("wnn_errorno = %d\n",wnn_errorno); -#endif - - return (wnn_errorno) ; -} - -ejlisp_bunsetsu_yomi(bunsetsu_no,bunsetsu_no2,yomi_len) -int bunsetsu_no,bunsetsu_no2; -int *yomi_len; -{ - -#ifdef DEBUG - printf("ejlisp_bunsetsu_yomi start\n"); - printf("bunsetsu_no = %d\n",bunsetsu_no); -#endif - - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); - - wnn_errorno = 0; - TIMEOUT(*yomi_len = jl_yomi_len (ejlisp_buf,bunsetsu_no,bunsetsu_no2)) ; - -#ifdef DEBUG - printf("ejlisp_bunsetsu_yomi end\n"); - printf("yomi_len = %d\n",*yomi_len); - printf("wnn_errorno = %d\n",wnn_errorno); -#endif - - return (wnn_errorno) ; -} - -ejlisp_close () -{ - -#ifdef DEBUG - printf("ejlisp_close start\n"); -#endif - - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); - - wnn_errorno = 0; - TIMEOUT(jl_close (ejlisp_buf)) ; - ejlisp_buf = NULL; - -#ifdef DEBUG - printf("ejlisp_close end\n"); - printf("wnn_errorno = %d\n",wnn_errorno); -#endif - - return (wnn_errorno) ; -} - -ejlisp_conv(yomi,kanji,kanji_len,bunsetsu_suu) -unsigned short *yomi; -unsigned short *kanji; -int *kanji_len,*bunsetsu_suu; -{ - -#ifdef DEBUG - printf("ejlisp_conv start\n"); - printf("yomi = %s\n",yomi); -#endif - - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); - - wnn_errorno = 0; - TIMEOUT(*bunsetsu_suu = jl_ren_conv (ejlisp_buf,yomi,0,-1,WNN_USE_MAE)); - if (*bunsetsu_suu != -1) { - TIMEOUT(*kanji_len = jl_get_kanji (ejlisp_buf,0,-1,kanji)) ; - } - -#ifdef DEBUG - printf("ejlisp_conv end\n"); - if (wnn_errorno == 0) - printf("kanji = %s, kanji_len = %d, bunsetsu_suu = %d\n", - kanji,*kanji_len,*bunsetsu_suu); - printf("wnn_errorno = %d\n",wnn_errorno); -#endif - - return (wnn_errorno) ; -} - -ejlisp_conv_end () +ejlisp_bunsetsu_kanji(bunsetsu_no, bunsetsu_no2, kanji_len) int bunsetsu_no, bunsetsu_no2; +int *kanji_len; { #ifdef DEBUG - printf("ejlisp_conv_end start\n"); + printf("ejlisp_bunsetsu_kanji start\n"); + printf("bunsetsu_no = %d\n", bunsetsu_no); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - TIMEOUT(jl_update_hindo (ejlisp_buf,0,99)); - if (wnn_errorno == 0) { - TIMEOUT(jl_dic_save_all (ejlisp_buf)); - } + wnn_errorno = 0; + TIMEOUT(*kanji_len = jl_kanji_len(ejlisp_buf, bunsetsu_no, bunsetsu_no2)); #ifdef DEBUG - printf("ejlisp_conv_end end\n"); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_bunsetsu_kanji end\n"); + if (wnn_errorno == 0) printf("kanji_len = %d\n", *kanji_len); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_del_userdic (dic_no,entry) +ejlisp_bunsetsu_yomi(bunsetsu_no, bunsetsu_no2, yomi_len) int bunsetsu_no, bunsetsu_no2; +int *yomi_len; { #ifdef DEBUG - printf("ejlisp_del_userdic start\n"); - printf("dic_no = %d,entry = %d\n",dic_no,entry); + printf("ejlisp_bunsetsu_yomi start\n"); + printf("bunsetsu_no = %d\n", bunsetsu_no); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - TIMEOUT(jl_word_delete (ejlisp_buf,dic_no,entry)); - if (wnn_errorno == 0) { - TIMEOUT(jl_dic_save (ejlisp_buf,dic_no)); - } + wnn_errorno = 0; + TIMEOUT(*yomi_len = jl_yomi_len(ejlisp_buf, bunsetsu_no, bunsetsu_no2)); #ifdef DEBUG - printf("ejlisp_del_userdic end\n"); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_bunsetsu_yomi end\n"); + printf("yomi_len = %d\n", *yomi_len); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_get_kouho(pos,kouho_arrey,kouho_num) -unsigned short kouho_arrey[TABLE_MAX][CHAR_MAXLEN+1]; -int pos,*kouho_num; +ejlisp_close() { +#ifdef DEBUG + printf("ejlisp_close start\n"); +#endif + + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); + + wnn_errorno = 0; + TIMEOUT(jl_close(ejlisp_buf)); + ejlisp_buf = NULL; + +#ifdef DEBUG + printf("ejlisp_close end\n"); + printf("wnn_errorno = %d\n", wnn_errorno); +#endif + + return (wnn_errorno); +} + +ejlisp_conv(yomi, kanji, kanji_len, bunsetsu_suu) unsigned short *yomi; +unsigned short *kanji; +int *kanji_len, *bunsetsu_suu; { - int i,j; - #ifdef DEBUG - int num; - - printf("ejlisp_get_kouho start\n"); - printf("pos = %d\n",pos); - num = ejlisp_kouho_next; - + printf("ejlisp_conv start\n"); + printf("yomi = %s\n", yomi); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - i = ejlisp_kouho_next; - if (pos < 0) { - if ((i -= ejlisp_kouho_max) < 0) - i = ejlisp_kouho_num - - (ejlisp_kouho_num % ejlisp_kouho_max); - if ((i -= ejlisp_kouho_max) < 0) - i = ejlisp_kouho_num - - (ejlisp_kouho_num % ejlisp_kouho_max); - } + wnn_errorno = 0; + TIMEOUT(*bunsetsu_suu = jl_ren_conv(ejlisp_buf, yomi, 0, -1, WNN_USE_MAE)); + if (*bunsetsu_suu != -1) { TIMEOUT(*kanji_len = jl_get_kanji(ejlisp_buf, 0, -1, kanji)); } - for(j=0;j= ejlisp_kouho_num) - ejlisp_kouho_next = 0; - else - ejlisp_kouho_next = i; - } - #ifdef DEBUG - printf("ejlisp_get_kouho end\n"); - if (wnn_errorno == 0) { - for(i=0;ikanji); - kouho_len_arrey[i] = strlen(kouho_arrey[i])/2; - kouho_entry_arrey[i] = ejlisp_jdp->serial; - } + wnn_errorno = 0; + i = ejlisp_kouho_next; + if (pos < 0) { + if ((i -= ejlisp_kouho_max) < 0) i = ejlisp_kouho_num - (ejlisp_kouho_num % ejlisp_kouho_max); + if ((i -= ejlisp_kouho_max) < 0) i = ejlisp_kouho_num - (ejlisp_kouho_num % ejlisp_kouho_max); + } + + for (j = 0; j < ejlisp_kouho_max && i < ejlisp_kouho_num; i++, j++) { + TIMEOUT(jl_get_zenkouho_kanji(ejlisp_buf, i, &kouho_arrey[j][0])); + if (wnn_errorno != 0) break; + } + if (wnn_errorno == 0) { + *kouho_num = j; + for (; j < ejlisp_kouho_max; j++) { + kouho_arrey[j][0] = NULL; + kouho_arrey[j][1] = NULL; + } + + if (i >= ejlisp_kouho_num) + ejlisp_kouho_next = 0; + else + ejlisp_kouho_next = i; + } #ifdef DEBUG - printf("ejlisp_get_userdic end\n"); - for(i=0;ifname[0] == '!') { - strcpy(&dic_name_array[j][0],&(dip->fname[1])); - dic_name_len_array[j] = strlen(&dic_name_array[j][0]); - dic_no_array[j] = dip->dic_no; - j++; - } - } - dic_name_array[j][0] = NULL; - } + for (i = 0; i < ejlisp_jdp_num; i++, ejlisp_jdp++) { + strcpy(&kouho_arrey[i][0], ejlisp_jdp->kanji); + kouho_len_arrey[i] = strlen(kouho_arrey[i]) / 2; + kouho_entry_arrey[i] = ejlisp_jdp->serial; + } #ifdef DEBUG - printf("ejlisp_get_userdic_name end\n"); - if (wnn_errorno == 0) { - for(i=0;ifname[0] == '!') { + strcpy(&dic_name_array[j][0], &(dip->fname[1])); + dic_name_len_array[j] = strlen(&dic_name_array[j][0]); + dic_no_array[j] = dip->dic_no; + j++; + } + } + dic_name_array[j][0] = NULL; + } #ifdef DEBUG - printf("ejlisp_get_yomi end\n"); - if (wnn_errorno == 0) - printf("yomi = %s,yomi_len = %d\n",yomi,*yomi_len); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_get_userdic_name end\n"); + if (wnn_errorno == 0) { + for (i = 0; i < j; i++) { + printf("dic_no_array = %d,dic_name_len_array = %d,dic_name_array = %s\n", dic_no_array[i], + dic_name_len_array[i], &dic_name_array[i][0]); + } + } + printf("wnn_errorno = %d", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_open (wnn_env,kouho_max,server_name) -char *wnn_env,*server_name; -int kouho_max; +ejlisp_get_yomi(bunsetsu_no, yomi, yomi_len) int bunsetsu_no; +char *yomi; +int *yomi_len; { - char username[L_cuserid] ; - char *env_name ; - #ifdef DEBUG - printf("ejlisp_open start\n"); - printf("wnn_env = %s, kouho_max = %d,server_name = %s\n",wnn_env,kouho_max,server_name); + printf("ejlisp_get_yomi start\n"); + printf("bunsetsu_no = %d\n", bunsetsu_no); #endif - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - - if (ejlisp_buf != NULL) { - TIMEOUT(jl_close (ejlisp_buf)) ; - ejlisp_buf = NULL; - } - - if (wnn_errorno == 0) { - env_name = cuserid(username) ; - TIMEOUT(ejlisp_buf = jl_open (env_name, server_name, wnn_env, WNN_CREATE, NULL, NULL,20)) ; - - if (ejlisp_buf != NULL) { - ejlisp_kouho_max = kouho_max; - } - } + wnn_errorno = 0; + TIMEOUT(*yomi_len = jl_get_yomi(ejlisp_buf, bunsetsu_no, bunsetsu_no + 1, yomi)); #ifdef DEBUG - printf("ejlisp_open end\n"); - printf("wnn_errorno = %d\n", wnn_errorno); + printf("ejlisp_get_yomi end\n"); + if (wnn_errorno == 0) printf("yomi = %s,yomi_len = %d\n", yomi, *yomi_len); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_reconv(bunsetsu_no,bunsetsu_len,kanji,kanji_len,bunsetsu_suu) -int bunsetsu_no,bunsetsu_len; -unsigned short kanji[]; -int *kanji_len,*bunsetsu_suu; +ejlisp_open(wnn_env, kouho_max, server_name) char *wnn_env, *server_name; +int kouho_max; { + char username[L_cuserid]; + char *env_name; #ifdef DEBUG - printf("ejlisp_reconv start\n"); - printf("bunsetsu_no = %d, bunsetsu_len = %d\n",bunsetsu_no,bunsetsu_len); + printf("ejlisp_open start\n"); + printf("wnn_env = %s, kouho_max = %d,server_name = %s\n", wnn_env, kouho_max, server_name); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - TIMEOUT(*bunsetsu_suu = jl_nobi_conv (ejlisp_buf,bunsetsu_no,bunsetsu_len,-1,WNN_USE_MAE,WNN_SHO)); - if (wnn_errorno == 0) { - TIMEOUT(*kanji_len = jl_get_kanji (ejlisp_buf,0,-1,kanji)) ; - } + wnn_errorno = 0; + + if (ejlisp_buf != NULL) { + TIMEOUT(jl_close(ejlisp_buf)); + ejlisp_buf = NULL; + } + + if (wnn_errorno == 0) { + env_name = cuserid(username); + TIMEOUT(ejlisp_buf = jl_open(env_name, server_name, wnn_env, WNN_CREATE, NULL, NULL, 20)); + + if (ejlisp_buf != NULL) { ejlisp_kouho_max = kouho_max; } + } #ifdef DEBUG - printf("ejlisp_reconv end\n"); - if (wnn_errorno == 0) - printf("kanji = %s, kanji_len = %d, bunsetsu_suu = %d\n", - kanji,*kanji_len,*bunsetsu_suu); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_open end\n"); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_search_userdic (dic_no,yomi) -int dic_no; -unsigned short *yomi; +ejlisp_reconv(bunsetsu_no, bunsetsu_len, kanji, kanji_len, bunsetsu_suu) int bunsetsu_no, + bunsetsu_len; +unsigned short kanji[]; +int *kanji_len, *bunsetsu_suu; { - #ifdef DEBUG - printf("ejlisp_search_userdic start\n"); - printf("dic_no = %d,yomi = %s\n",dic_no,yomi); + printf("ejlisp_reconv start\n"); + printf("bunsetsu_no = %d, bunsetsu_len = %d\n", bunsetsu_no, bunsetsu_len); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - TIMEOUT(ejlisp_jdp_num = jl_word_search(ejlisp_buf,dic_no,yomi,&ejlisp_jdp)); + wnn_errorno = 0; + TIMEOUT(*bunsetsu_suu = + jl_nobi_conv(ejlisp_buf, bunsetsu_no, bunsetsu_len, -1, WNN_USE_MAE, WNN_SHO)); + if (wnn_errorno == 0) { TIMEOUT(*kanji_len = jl_get_kanji(ejlisp_buf, 0, -1, kanji)); } #ifdef DEBUG - printf("ejlisp_search_userdic end\n"); - if (wnn_errorno == 0) - printf("kouho_no = %d\n",ejlisp_jdp_num); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_reconv end\n"); + if (wnn_errorno == 0) + printf("kanji = %s, kanji_len = %d, bunsetsu_suu = %d\n", kanji, *kanji_len, *bunsetsu_suu); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_select_bunsetsu(bunsetsu_no,bunsetsu_len) -int bunsetsu_no,*bunsetsu_len; +ejlisp_search_userdic(dic_no, yomi) int dic_no; +unsigned short *yomi; { - #ifdef DEBUG - printf("ejlisp_select_bunsetsu start\n"); - printf("bunsetsu_no = %d\n",bunsetsu_no); + printf("ejlisp_search_userdic start\n"); + printf("dic_no = %d,yomi = %s\n", dic_no, yomi); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - wnn_errorno = 0; - TIMEOUT(*bunsetsu_len = jl_kanji_len (ejlisp_buf,bunsetsu_no,bunsetsu_no+1)); - if (wnn_errorno == 0) { - TIMEOUT(jl_zenkouho (ejlisp_buf,bunsetsu_no,WNN_USE_MAE,WNN_NO_UNIQ)); - } - if (wnn_errorno == 0) { - TIMEOUT(ejlisp_kouho_num = jl_zenkouho_suu (ejlisp_buf)); - ejlisp_kouho_next = 0; - } + wnn_errorno = 0; + TIMEOUT(ejlisp_jdp_num = jl_word_search(ejlisp_buf, dic_no, yomi, &ejlisp_jdp)); #ifdef DEBUG - printf("ejlisp_select_bunsetsu end\n"); - if (wnn_errorno == 0) - printf("bunsetsu_len = %d\n",*bunsetsu_len); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_search_userdic end\n"); + if (wnn_errorno == 0) printf("kouho_no = %d\n", ejlisp_jdp_num); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } -ejlisp_select_kouho (kouho_no,kanji) -int kouho_no; -unsigned short *kanji; +ejlisp_select_bunsetsu(bunsetsu_no, bunsetsu_len) int bunsetsu_no, *bunsetsu_len; { - int no,i,c; - #ifdef DEBUG - printf("ejlisp_select_kouho start\n"); - printf("kouho_no = %d\n",kouho_no); + printf("ejlisp_select_bunsetsu start\n"); + printf("bunsetsu_no = %d\n", bunsetsu_no); #endif - if (ejlisp_buf == NULL) return(72); - EJLISP_SETJMP(-1); + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); - if (kouho_no != 0) { - if (kouho_no < 0) - no = ejlisp_kouho_num + kouho_no; - else if (ejlisp_kouho_num <= ejlisp_kouho_max) - no = kouho_no-1; - else if (ejlisp_kouho_next == 0) - no = ejlisp_kouho_num-(ejlisp_kouho_num % ejlisp_kouho_max)+kouho_no-1; - else - no = ejlisp_kouho_next-ejlisp_kouho_max+kouho_no-1; - wnn_errorno = 0; - TIMEOUT(jl_set_jikouho(ejlisp_buf,no)); - } - if (wnn_errorno == 0) { - TIMEOUT(jl_get_zenkouho_kanji(ejlisp_buf,no,kanji)); - } + wnn_errorno = 0; + TIMEOUT(*bunsetsu_len = jl_kanji_len(ejlisp_buf, bunsetsu_no, bunsetsu_no + 1)); + if (wnn_errorno == 0) { TIMEOUT(jl_zenkouho(ejlisp_buf, bunsetsu_no, WNN_USE_MAE, WNN_NO_UNIQ)); } + if (wnn_errorno == 0) { + TIMEOUT(ejlisp_kouho_num = jl_zenkouho_suu(ejlisp_buf)); + ejlisp_kouho_next = 0; + } #ifdef DEBUG - printf("ejlisp_select_kouho end\n"); - if (wnn_errorno == 0) - printf("kanji = %s\n",kanji); - printf("wnn_errorno = %d\n",wnn_errorno); + printf("ejlisp_select_bunsetsu end\n"); + if (wnn_errorno == 0) printf("bunsetsu_len = %d\n", *bunsetsu_len); + printf("wnn_errorno = %d\n", wnn_errorno); #endif - return (wnn_errorno) ; + return (wnn_errorno); } +ejlisp_select_kouho(kouho_no, kanji) int kouho_no; +unsigned short *kanji; +{ + int no, i, c; + +#ifdef DEBUG + printf("ejlisp_select_kouho start\n"); + printf("kouho_no = %d\n", kouho_no); +#endif + + if (ejlisp_buf == NULL) return (72); + EJLISP_SETJMP(-1); + + if (kouho_no != 0) { + if (kouho_no < 0) + no = ejlisp_kouho_num + kouho_no; + else if (ejlisp_kouho_num <= ejlisp_kouho_max) + no = kouho_no - 1; + else if (ejlisp_kouho_next == 0) + no = ejlisp_kouho_num - (ejlisp_kouho_num % ejlisp_kouho_max) + kouho_no - 1; + else + no = ejlisp_kouho_next - ejlisp_kouho_max + kouho_no - 1; + wnn_errorno = 0; + TIMEOUT(jl_set_jikouho(ejlisp_buf, no)); + } + if (wnn_errorno == 0) { TIMEOUT(jl_get_zenkouho_kanji(ejlisp_buf, no, kanji)); } + +#ifdef DEBUG + printf("ejlisp_select_kouho end\n"); + if (wnn_errorno == 0) printf("kanji = %s\n", kanji); + printf("wnn_errorno = %d\n", wnn_errorno); +#endif + + return (wnn_errorno); +} diff --git a/src/eqf.c b/src/eqf.c old mode 100755 new mode 100644 index fb010c9..f4c2501 --- a/src/eqf.c +++ b/src/eqf.c @@ -9,10 +9,6 @@ static char *id = "$Id: eqf.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyright /* */ /************************************************************************/ - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -27,7 +23,6 @@ static char *id = "$Id: eqf.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyright #include "version.h" - #include #include "lispemul.h" #include "lspglob.h" @@ -38,7 +33,6 @@ static char *id = "$Id: eqf.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyright #include "my.h" #include "arith.h" - /************************************************************ op 072 N_OP_eqlop EQL op 0314 N_OP_clequal CL:EQUAL @@ -51,14 +45,14 @@ op 0377 N_OP_eqq CL:= EQ is a strict pointer comparision, equivalent to C's == EQL (common lisp) does no conversions before comparision, but will - compare equal FIXPs or equal FLOATPs. + compare equal FIXPs or equal FLOATPs. CL:= will do a numeric comparison and will compare floats. If given integers, it will convert - to floating point first. + to floating point first. IL:EQUAL is a recursive comparison which will compare 1 = 1.0 - it work like code with CL:= for the most part + it work like code with CL:= for the most part CL:EQUAL is a recursive comparision which uses EQL at the leaves @@ -69,7 +63,7 @@ number types include: SMALLP (immediate with S_POSITIVE or S_NEGATIVE) FIXP (32 bit boxed value, handled in C. Usually canonical, i.e., - will be SMALLP. (IPLUS x 0) will always canonicallize.) + will be SMALLP. (IPLUS x 0) will always canonicallize.) FLOATP (32 bit boxed value, handled in C, usually) RATIO (a/b. Always canonical, i.e., b doesn't divide a evenly) COMPLEX (a+bi. Not handled in C) @@ -77,16 +71,13 @@ BIGNUM (integer that can't be represented bigger than 32 bits) */ -#define IF_IMMEDIATE(arg, doit, doitsmall) \ - switch(SEGMASK & arg) { \ - case ATOM_OFFSET: doit; \ - case S_CHARACTER: doit; \ - case S_POSITIVE: doitsmall; \ - case S_NEGATIVE: doitsmall; \ - } - - - +#define IF_IMMEDIATE(arg, doit, doitsmall) \ + switch (SEGMASK & arg) { \ + case ATOM_OFFSET: doit; \ + case S_CHARACTER: doit; \ + case S_POSITIVE: doitsmall; \ + case S_NEGATIVE: doitsmall; \ + } /************************************************************************/ /* */ @@ -96,46 +87,46 @@ BIGNUM (integer that can't be represented bigger than 32 bits) /* */ /************************************************************************/ -LispPTR N_OP_clequal(register int arg1, register int arg2) -{ - register int type; +LispPTR N_OP_clequal(register int arg1, register int arg2) { + register int type; - if (arg2 == arg1) return(ATOM_T); - IF_IMMEDIATE(arg1, return(NIL), return(NIL)); - IF_IMMEDIATE(arg2, return(NIL), return(NIL)); + if (arg2 == arg1) return (ATOM_T); + IF_IMMEDIATE(arg1, return (NIL), return (NIL)); + IF_IMMEDIATE(arg2, return (NIL), return (NIL)); - /* CL:EQUAL is true for two strings that have different Interlisp - type numbers; cannot currently handle it here. */ + /* CL:EQUAL is true for two strings that have different Interlisp + type numbers; cannot currently handle it here. */ - /* can return NIL if one is a number and the other isn't */ + /* can return NIL if one is a number and the other isn't */ - if (IsNumber(arg1)) { if(!IsNumber(arg2)) return(NIL); } - else {if (IsNumber(arg2)) {return(NIL);} - else ERROR_EXIT(arg2)} + if (IsNumber(arg1)) { + if (!IsNumber(arg2)) return (NIL); + } else { + if (IsNumber(arg2)) { + return (NIL); + } else + ERROR_EXIT(arg2) + } - /* now we know both are numbers */ + /* now we know both are numbers */ - if ((type = GetTypeNumber(arg1)) != (GetTypeNumber(arg2))) return(NIL); + if ((type = GetTypeNumber(arg1)) != (GetTypeNumber(arg2))) return (NIL); - /* now we know both are the same type. Shouldn't see any SMALLPs */ + /* now we know both are the same type. Shouldn't see any SMALLPs */ - switch (type) - { - case TYPE_FIXP: if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) - {return(ATOM_T);} - return(NIL); - - case TYPE_FLOATP: if(FLOATP_VALUE(arg1) == FLOATP_VALUE(arg2)) - {return(ATOM_T);} - return(NIL); - - default: ERROR_EXIT(arg2); - } - - }/* end N_OP_clequal */ + switch (type) { + case TYPE_FIXP: + if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) { return (ATOM_T); } + return (NIL); + case TYPE_FLOATP: + if (FLOATP_VALUE(arg1) == FLOATP_VALUE(arg2)) { return (ATOM_T); } + return (NIL); + default: ERROR_EXIT(arg2); + } +} /* end N_OP_clequal */ /************************************************************************/ /* */ @@ -145,41 +136,38 @@ LispPTR N_OP_clequal(register int arg1, register int arg2) /* */ /************************************************************************/ -LispPTR N_OP_eqlop(register int arg1, register int arg2) -{ - register int type; +LispPTR N_OP_eqlop(register int arg1, register int arg2) { + register int type; - if (arg2 == arg1) return(ATOM_T); - IF_IMMEDIATE(arg1, return(NIL), return(NIL)); - IF_IMMEDIATE(arg2, return(NIL), return(NIL)); + if (arg2 == arg1) return (ATOM_T); + IF_IMMEDIATE(arg1, return (NIL), return (NIL)); + IF_IMMEDIATE(arg2, return (NIL), return (NIL)); - /* EQL is true if EQ or both are numbers, the same type, and EQUAL */ + /* EQL is true if EQ or both are numbers, the same type, and EQUAL */ - /* can return NIL if one is a number and the other isn't */ + /* can return NIL if one is a number and the other isn't */ - if ((type = GetTypeNumber(arg1)) != (GetTypeNumber(arg2))) return(NIL); + if ((type = GetTypeNumber(arg1)) != (GetTypeNumber(arg2))) return (NIL); - /* now we know both are the same type. Shouldn't see any SMALLPs */ + /* now we know both are the same type. Shouldn't see any SMALLPs */ - switch (type) - { - case TYPE_FIXP: if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) - {return(ATOM_T);} - return(NIL); - - case TYPE_FLOATP: if(FLOATP_VALUE(arg1) == FLOATP_VALUE(arg2)) - {return(ATOM_T);} - return(NIL); - - default: if(IsNumber(arg1)) {ERROR_EXIT(arg2); } - else return(NIL); - - } - - } /* end N_OP_eqlop */ + switch (type) { + case TYPE_FIXP: + if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) { return (ATOM_T); } + return (NIL); + case TYPE_FLOATP: + if (FLOATP_VALUE(arg1) == FLOATP_VALUE(arg2)) { return (ATOM_T); } + return (NIL); + default: + if (IsNumber(arg1)) { + ERROR_EXIT(arg2); + } else + return (NIL); + } +} /* end N_OP_eqlop */ /************************************************************************/ /* */ @@ -189,60 +177,59 @@ LispPTR N_OP_eqlop(register int arg1, register int arg2) /* */ /************************************************************************/ -LispPTR N_OP_equal(register int arg1, register int arg2) -{ - register int type, type2; +LispPTR N_OP_equal(register int arg1, register int arg2) { + register int type, type2; - if (arg2 == arg1) return(ATOM_T); + if (arg2 == arg1) return (ATOM_T); - IF_IMMEDIATE(arg1, return(NIL), goto arg1_small); - IF_IMMEDIATE(arg2, return(NIL), goto arg2_small); - goto arg2_small; + IF_IMMEDIATE(arg1, return (NIL), goto arg1_small); + IF_IMMEDIATE(arg2, return (NIL), goto arg2_small); + goto arg2_small; arg1_small: - IF_IMMEDIATE(arg2, return(NIL), return(NIL)); /* arg2 atom or both small */ + IF_IMMEDIATE(arg2, return (NIL), return (NIL)); /* arg2 atom or both small */ arg2_small: - if (IsNumber(arg1)) { if(!IsNumber(arg2)) return(NIL) ;} - else {if (IsNumber(arg2)) {return(NIL);} - else ERROR_EXIT(arg2)} + if (IsNumber(arg1)) { + if (!IsNumber(arg2)) return (NIL); + } else { + if (IsNumber(arg2)) { + return (NIL); + } else + ERROR_EXIT(arg2) + } - /* now we know both are numbers */ + /* now we know both are numbers */ - type = GetTypeNumber(arg1); - type2 = GetTypeNumber(arg2); - - if (type == type2) - { - switch (GetTypeNumber(arg1)) - { - case TYPE_SMALLP: return(NIL); - case TYPE_FIXP: if(FIXP_VALUE(arg1)==FIXP_VALUE(arg2)) - {return(ATOM_T);} - return(NIL); - case TYPE_FLOATP: if(FLOATP_VALUE(arg1)==FLOATP_VALUE(arg2)) - {return(ATOM_T);} - return(NIL); - default: ERROR_EXIT(arg2); - - } - } - - if ((type == TYPE_FLOATP) || (type2 == TYPE_FLOATP)) - { - register float f1, f2; - N_MakeFloat(arg1, f1, arg2); - N_MakeFloat(arg2, f2, arg2); - if ((f1 + 0.0) == (f2 + 0.0)) return(ATOM_T); - else return(NIL); - } - else return(NIL); /* neither is float, types are different */ - - } /* end N_OP_equal */ + type = GetTypeNumber(arg1); + type2 = GetTypeNumber(arg2); + if (type == type2) { + switch (GetTypeNumber(arg1)) { + case TYPE_SMALLP: return (NIL); + case TYPE_FIXP: + if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) { return (ATOM_T); } + return (NIL); + case TYPE_FLOATP: + if (FLOATP_VALUE(arg1) == FLOATP_VALUE(arg2)) { return (ATOM_T); } + return (NIL); + default: ERROR_EXIT(arg2); + } + } + if ((type == TYPE_FLOATP) || (type2 == TYPE_FLOATP)) { + register float f1, f2; + N_MakeFloat(arg1, f1, arg2); + N_MakeFloat(arg2, f2, arg2); + if ((f1 + 0.0) == (f2 + 0.0)) + return (ATOM_T); + else + return (NIL); + } else + return (NIL); /* neither is float, types are different */ +} /* end N_OP_equal */ /************************************************************************/ /* */ @@ -254,62 +241,55 @@ arg2_small: /************************************************************************/ LispPTR N_OP_eqq(register int arg1, register int arg2) /* CL:= opcode 0377 */ - - { - register int type1, type2; - register float f1, f2; +{ + register int type1, type2; + register float f1, f2; - if (!((type1 = GetTypeEntry(arg1)) & TT_NUMBERP)) ERROR_EXIT(arg2); - if (arg2 == arg1) return(ATOM_T); - if (!((type2 = GetTypeEntry(arg2)) & TT_NUMBERP)) ERROR_EXIT(arg2); - type1 &= 0x7ff; - type2 &= 0x7ff; + if (!((type1 = GetTypeEntry(arg1)) & TT_NUMBERP)) ERROR_EXIT(arg2); + if (arg2 == arg1) return (ATOM_T); + if (!((type2 = GetTypeEntry(arg2)) & TT_NUMBERP)) ERROR_EXIT(arg2); + type1 &= 0x7ff; + type2 &= 0x7ff; - switch ( type1 ) - { - case TYPE_SMALLP : - switch ( type2 ) - { - case TYPE_SMALLP : return(NIL); - case TYPE_FIXP : return(NIL); - case TYPE_FLOATP : goto checkfloats; - default : ERROR_EXIT(arg2); - } - - case TYPE_FIXP : - switch ( type2 ) - { - case TYPE_SMALLP : return(NIL); - case TYPE_FIXP : - if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) - return(ATOM_T); - else return(NIL); - case TYPE_FLOATP : goto checkfloats; - default : ERROR_EXIT(arg2); - } - - case TYPE_FLOATP : - switch ( type2 ) - { - case TYPE_SMALLP : goto checkfloats; - case TYPE_FIXP : goto checkfloats; - case TYPE_FLOATP : goto checkfloats; - default : ERROR_EXIT(arg2); - } - - default : ERROR_EXIT(arg2); + switch (type1) { + case TYPE_SMALLP: + switch (type2) { + case TYPE_SMALLP: return (NIL); + case TYPE_FIXP: return (NIL); + case TYPE_FLOATP: goto checkfloats; + default: ERROR_EXIT(arg2); } - checkfloats: + case TYPE_FIXP: + switch (type2) { + case TYPE_SMALLP: return (NIL); + case TYPE_FIXP: + if (FIXP_VALUE(arg1) == FIXP_VALUE(arg2)) + return (ATOM_T); + else + return (NIL); + case TYPE_FLOATP: goto checkfloats; + default: ERROR_EXIT(arg2); + } - N_MakeFloat(arg1, f1, arg2); - N_MakeFloat(arg2, f2, arg2); - if (f1 == f2) return(ATOM_T); - if ((f1 == -0.0) && (f2 == 0.0)) return(ATOM_T); - if ((f1 == 0.0) && (f2 == -0.0)) return(ATOM_T); - return(NIL); - } /* end N_OP_eqq() */ + case TYPE_FLOATP: + switch (type2) { + case TYPE_SMALLP: goto checkfloats; + case TYPE_FIXP: goto checkfloats; + case TYPE_FLOATP: goto checkfloats; + default: ERROR_EXIT(arg2); + } + default: ERROR_EXIT(arg2); + } +checkfloats: + N_MakeFloat(arg1, f1, arg2); + N_MakeFloat(arg2, f2, arg2); + if (f1 == f2) return (ATOM_T); + if ((f1 == -0.0) && (f2 == 0.0)) return (ATOM_T); + if ((f1 == 0.0) && (f2 == -0.0)) return (ATOM_T); + return (NIL); +} /* end N_OP_eqq() */ diff --git a/src/ether.c b/src/ether.c old mode 100755 new mode 100644 index 3837842..ac30fd3 --- a/src/ether.c +++ b/src/ether.c @@ -1,4 +1,4 @@ -/* $Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ @@ -15,7 +15,6 @@ static char *id = "$Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyrig #include "version.h" - #ifdef USE_DLPI #define PKTFILTER 1 #define NIOCSFLAGS SBIOCSFLAGS @@ -24,7 +23,6 @@ static char *id = "$Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyrig #define PKTFILTER 1 #endif - #include #include #ifndef DOS @@ -78,65 +76,80 @@ static char *id = "$Id: ether.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyrig #define NIOCSETF PFIOCSETF #endif +u_int EtherReadFds; -u_int EtherReadFds; - -int ether_fd = -1; /* file descriptor for ether socket */ +int ether_fd = -1; /* file descriptor for ether socket */ int ether_intf_type = 0; -u_char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address of this node */ +u_char ether_host[6] = {0, 0, 0, 0, 0, 0}; /* 48 bit address of this node */ u_char broadcast[6] = {255, 255, 255, 255, 255, 255}; -int ether_bsize = 0; /* if nonzero then a receive is pending */ -u_char *ether_buf; /* address of receive buffer */ -u_char nit_buf[3000]; /* the current chunk read from NIT (one packet) */ +int ether_bsize = 0; /* if nonzero then a receive is pending */ +u_char *ether_buf; /* address of receive buffer */ +u_char nit_buf[3000]; /* the current chunk read from NIT (one packet) */ extern LispPTR *PENDINGINTERRUPT68k; -extern u_int LispReadFds; +extern u_int LispReadFds; int ETHEREventCount = 0; -#define PacketTypeIP 0x0800 -#define PacketTypeARP 0x0806 -#define PacketTypeRARP 0x8035 -#define PacketTypeXNS 0x0600 -#define PacketTypePUP 0x0200 -#define PacketType3TO10 0x0201 +#define PacketTypeIP 0x0800 +#define PacketTypeARP 0x0806 +#define PacketTypeRARP 0x8035 +#define PacketTypeXNS 0x0600 +#define PacketTypePUP 0x0200 +#define PacketType3TO10 0x0201 #ifndef NOETHER #ifdef PKTFILTER /* the receiving packetfilter structure */ /* if this is changed, be sure to get the references to it in init_ether - and check the length (the second entry in the structure) */ -struct packetfilt goodpf = {0, 29,{ -ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeIP, /* punt if PacketTypeIP */ -ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeARP, /* or PacketTypeARP */ -ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 8, /* check our addr */ -ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 11, /* which is filled in */ -ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 14, /* in init_ether */ -ENF_AND, ENF_AND, -ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* check broadcast */ -ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* which is all ones */ -ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 0xFFFF, -ENF_AND, ENF_AND, -ENF_OR}}; + and check the length (the second entry in the structure) */ +struct packetfilt goodpf = {0, + 29, + {ENF_PUSHWORD + 6, + ENF_PUSHLIT + ENF_CNOR, + PacketTypeIP, /* punt if PacketTypeIP */ + ENF_PUSHWORD + 6, + ENF_PUSHLIT + ENF_CNOR, + PacketTypeARP, /* or PacketTypeARP */ + ENF_PUSHWORD, + ENF_PUSHLIT + ENF_EQ, + 8, /* check our addr */ + ENF_PUSHWORD + 1, + ENF_PUSHLIT + ENF_EQ, + 11, /* which is filled in */ + ENF_PUSHWORD + 2, + ENF_PUSHLIT + ENF_EQ, + 14, /* in init_ether */ + ENF_AND, + ENF_AND, + ENF_PUSHWORD, + ENF_PUSHLIT + ENF_EQ, + 0xFFFF, /* check broadcast */ + ENF_PUSHWORD + 1, + ENF_PUSHLIT + ENF_EQ, + 0xFFFF, /* which is all ones */ + ENF_PUSHWORD + 2, + ENF_PUSHLIT + ENF_EQ, + 0xFFFF, + ENF_AND, + ENF_AND, + ENF_OR}}; /* struct packetfilt allpf = {0, 1, {ENF_PUSHFFFF}}; */ /* a filter that rejects all packets to be used by ether_suspend and the - initial routine to flush out ether_fd */ + initial routine to flush out ether_fd */ struct packetfilt nopf = {0, 1, {ENF_PUSHZERO}}; #endif /* PKTFILTER */ -int ether_in = 0; /* number of packets received */ -int ether_out = 0; /* number of packets sent */ +int ether_in = 0; /* number of packets received */ +int ether_out = 0; /* number of packets sent */ #ifndef PKTFILTER static struct nit_ioc nioc; #endif /* PKTFILTER */ #endif /* NOETHER */ - - - /************************************************************************/ /* */ /* e t h e r _ s u s p e n d */ @@ -146,54 +159,48 @@ static struct nit_ioc nioc; /* */ /************************************************************************/ -LispPTR ether_suspend(args) - LispPTR args[]; - { +LispPTR ether_suspend(args) LispPTR args[]; +{ #ifndef NOETHER #ifdef PKTFILTER - static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; - struct strioctl si; + static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; + struct strioctl si; #endif /* PKTFILTER */ - if (ether_fd == -1) return(NIL); + if (ether_fd == -1) return (NIL); #ifndef PKTFILTER - nioc.nioc_typetomatch = NT_NOTYPES; - if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) - { - printf("ether_suspend: ioctl failed\n"); - return(NIL); - } + nioc.nioc_typetomatch = NT_NOTYPES; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("ether_suspend: ioctl failed\n"); + return (NIL); + } #else /* PKTFILTER */ - /* The trick here is to install a packet filter */ - /* that rejects all packets, I think... */ +/* The trick here is to install a packet filter */ +/* that rejects all packets, I think... */ #ifdef USE_DLPI - si.ic_cmd = PFIOCSETF; - si.ic_timout = -1; - si.ic_len = sizeof(nopf); - si.ic_dp = (char *)𝕟 + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(nopf); + si.ic_dp = (char *)𝕟 - if (ioctl(ether_fd, I_STR, &si) < 0) { - perror("ether_suspend nopf ioctl: I_STR PFIOCSETF"); - return(NIL); - } + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ether_suspend nopf ioctl: I_STR PFIOCSETF"); + return (NIL); + } #else - if ( ioctl(ether_fd, NIOCSETF, &nopf) != 0) - { - perror("ether_suspend: NIOCSETF failed\n"); - return(NIL); - } + if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { + perror("ether_suspend: NIOCSETF failed\n"); + return (NIL); + } #endif /* USE_DLPI */ #endif /* PKTFILTER */ #endif /* NOETHER */ - return(ATOM_T); - } /* ether_suspend */ - - - + return (ATOM_T); +} /* ether_suspend */ /************************************************************************/ /* */ @@ -203,49 +210,44 @@ LispPTR ether_suspend(args) /* */ /************************************************************************/ -LispPTR ether_resume(args) - LispPTR args[]; - { +LispPTR ether_resume(args) LispPTR args[]; +{ #ifndef NOETHER - struct strioctl si; - if (ether_fd == -1) return(NIL); + struct strioctl si; + if (ether_fd == -1) return (NIL); #ifndef PKTFILTER - nioc.nioc_typetomatch = NT_ALLTYPES; - if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) - { - printf("ether_resume: ioctl failed\n"); - return(NIL); - } + nioc.nioc_typetomatch = NT_ALLTYPES; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("ether_resume: ioctl failed\n"); + return (NIL); + } #else /* PKTFILTER */ /* Install a packet filter that accepts all packets we want */ #ifdef USE_DLPI - si.ic_cmd = PFIOCSETF; - si.ic_timout = -1; - si.ic_len = sizeof(goodpf); - si.ic_dp = (char *)&goodpf; + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(goodpf); + si.ic_dp = (char *)&goodpf; - if (ioctl(ether_fd, I_STR, &si) < 0) { - perror("ether_resume goodpf ioctl: I_STR PFIOCSETF"); - return(NIL); - } + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ether_resume goodpf ioctl: I_STR PFIOCSETF"); + return (NIL); + } #else - if ( ioctl(ether_fd, NIOCSETF, &goodpf) != 0) - { - perror("ether_resume: NIOCSETF failed\n"); - return(NIL); - } + if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { + perror("ether_resume: NIOCSETF failed\n"); + return (NIL); + } #endif /* USE_DLPI */ #endif /* PKTFILTER */ #endif /* NOETHER */ - return(ATOM_T); - } /* ether_resume */ - - + return (ATOM_T); +} /* ether_resume */ /************************************************************************/ /* */ @@ -255,33 +257,27 @@ LispPTR ether_resume(args) /* */ /************************************************************************/ -LispPTR ether_ctrlr(args) - LispPTR args[]; - { - if (ether_fd < 0) return(NIL); - return(ATOM_T); - } - - +LispPTR ether_ctrlr(args) LispPTR args[]; +{ + if (ether_fd < 0) return (NIL); + return (ATOM_T); +} /********************************************************************** * ether_reset(args) 175/73/0 * reset ether controller and disable receipt of packets **********************************************************************/ -LispPTR ether_reset(args) - LispPTR args[]; - { - int i; - char hostnumber[6]; - - if (ether_fd < 0) {return(NIL);} - /* JRB - host number check removed here; if ether_fd is open here, - net is on... */ - ether_bsize = 0; /* deactivate receiver */ - return(ATOM_T); - } /* ether_reset */ - +LispPTR ether_reset(args) LispPTR args[]; +{ + int i; + char hostnumber[6]; + if (ether_fd < 0) { return (NIL); } + /* JRB - host number check removed here; if ether_fd is open here, + net is on... */ + ether_bsize = 0; /* deactivate receiver */ + return (ATOM_T); +} /* ether_reset */ /************************************************************************/ /* */ @@ -302,42 +298,37 @@ LispPTR ether_reset(args) /* */ /************************************************************************/ -LispPTR ether_get(args) - LispPTR args[]; - { - LispPTR MaxByteCount; - LispPTR result = NIL; - int interrupt_mask; +LispPTR ether_get(args) LispPTR args[]; +{ + LispPTR MaxByteCount; + LispPTR result = NIL; + int interrupt_mask; #ifndef NOETHER - MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ - DBPRINT(("Ether Get. ")); + DBPRINT(("Ether Get. ")); #ifdef SYSVSIGNALS - sighold(SIGIO); + sighold(SIGIO); #else - interrupt_mask = sigblock(sigmask(SIGIO)); /* turn off ENET interrupts */ + interrupt_mask = sigblock(sigmask(SIGIO)); /* turn off ENET interrupts */ #endif /* SYSVSIGNALS */ - if (ether_fd > 0 && (MaxByteCount > 0)) - { - ether_buf = (u_char *)Addr68k_from_LADDR(args[1]); - ether_bsize = MaxByteCount; /* do this LAST; it enables reads */ - result = get_packet(); -/* check_ether(); for old behavior, move comment to above line */ - } + if (ether_fd > 0 && (MaxByteCount > 0)) { + ether_buf = (u_char *)Addr68k_from_LADDR(args[1]); + ether_bsize = MaxByteCount; /* do this LAST; it enables reads */ + result = get_packet(); + /* check_ether(); for old behavior, move comment to above line */ + } #ifdef SYSVSIGNALS - sigrelse(SIGIO); + sigrelse(SIGIO); #else - sigsetmask(interrupt_mask); /* interrupts back on */ + sigsetmask(interrupt_mask); /* interrupts back on */ #endif /* SYSVISGNALS */ #endif /* NOETHER */ - - return (result); - } /* ether_get */ - - + return (result); +} /* ether_get */ /********************************************************************** * ether_send(args) 175/75/2 max_words,buffer_addr @@ -345,85 +336,73 @@ LispPTR ether_get(args) **********************************************************************/ #define OFFSET sizeof(sa.sa_data) -LispPTR ether_send(args) -LispPTR args[]; +LispPTR ether_send(args) LispPTR args[]; { #ifndef NOETHER - /* - * Send a packet. - */ - struct sockaddr sa; + /* + * Send a packet. + */ + struct sockaddr sa; - LispPTR MaxByteCount; - char *BufferAddr; /* buffer address pointer(in native address) */ + LispPTR MaxByteCount; + char *BufferAddr; /* buffer address pointer(in native address) */ - MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ - BufferAddr = (char *)Addr68k_from_LADDR(args[1]); + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + BufferAddr = (char *)Addr68k_from_LADDR(args[1]); - if (ether_fd > 0) { + if (ether_fd > 0) { #ifdef PKTFILTER - struct strbuf ctl,data; + struct strbuf ctl, data; #endif /* PKTFILTER */ - sa.sa_family = AF_UNSPEC; /* required for the NIT protocol */ - bcopy(BufferAddr, sa.sa_data, OFFSET); + sa.sa_family = AF_UNSPEC; /* required for the NIT protocol */ + bcopy(BufferAddr, sa.sa_data, OFFSET); #ifndef PKTFILTER - if ( sendto(ether_fd, BufferAddr+OFFSET, MaxByteCount-OFFSET, 0, - &sa, sizeof(sa)) == (MaxByteCount-OFFSET) ); - else perror("Lisp Ether: sendto"); - ether_out++; + if (sendto(ether_fd, BufferAddr + OFFSET, MaxByteCount - OFFSET, 0, &sa, sizeof(sa)) == + (MaxByteCount - OFFSET)) + ; + else + perror("Lisp Ether: sendto"); + ether_out++; #elif defined(USE_DLPI) - if (dlunitdatareq(ether_fd, BufferAddr, 6, 0, 0, BufferAddr, MaxByteCount)) - { - perror("unitdatareq"); - return(NIL); - } - ether_out++; - ioctl(ether_fd, I_FLUSH, FLUSHW); + if (dlunitdatareq(ether_fd, BufferAddr, 6, 0, 0, BufferAddr, MaxByteCount)) { + perror("unitdatareq"); + return (NIL); + } + ether_out++; + ioctl(ether_fd, I_FLUSH, FLUSHW); -#else /* PKTFILTER */ +#else /* PKTFILTER */ - ctl.maxlen = ctl.len = sizeof(sa); - ctl.buf = (char *)&sa; - data.maxlen = data.len = MaxByteCount - OFFSET; - data.buf = BufferAddr + OFFSET; - if(putmsg(ether_fd, &ctl, &data, 0)<0) { - perror("Ether_send lost"); - return(NIL); - } - else { - ether_out++; - /* flush the buffers to make sure the packet leaves */ - /* maybe we'll use the buffering module some day... */ - ioctl(ether_fd, I_FLUSH, FLUSHW); - } + ctl.maxlen = ctl.len = sizeof(sa); + ctl.buf = (char *)&sa; + data.maxlen = data.len = MaxByteCount - OFFSET; + data.buf = BufferAddr + OFFSET; + if (putmsg(ether_fd, &ctl, &data, 0) < 0) { + perror("Ether_send lost"); + return (NIL); + } else { + ether_out++; + /* flush the buffers to make sure the packet leaves */ + /* maybe we'll use the buffering module some day... */ + ioctl(ether_fd, I_FLUSH, FLUSHW); + } #endif /* PKTFILTER */ - - } + } #endif /* NOETHER */ - - return(ATOM_T); + return (ATOM_T); } /* ether_send */ - - - /********************************************************************** * ether_setfilter(args) 175/75/1 filterbits * check whether a packet has come. if does, notify iocb **********************************************************************/ -LispPTR ether_setfilter(args) - LispPTR args[]; - { - return(NIL); - } /* ether_setfilter */ - - - +LispPTR ether_setfilter(args) LispPTR args[]; +{ return (NIL); } /* ether_setfilter */ /********************************************************************** * ether_debug() @@ -432,157 +411,135 @@ LispPTR ether_setfilter(args) int estat[3]; -int *ether_debug() - { +int *ether_debug() { #ifndef NOETHER - estat[0] = 0; - if (ether_fd < 0) return(NIL); - printf("fd %d bsize %d buf %X icb %X in %d out %d\n ", - ether_fd, ether_bsize, (int)ether_buf, - IOPage->dlethernet[3],ether_in,ether_out); + estat[0] = 0; + if (ether_fd < 0) return (NIL); + printf("fd %d bsize %d buf %X icb %X in %d out %d\n ", ether_fd, ether_bsize, (int)ether_buf, + IOPage->dlethernet[3], ether_in, ether_out); #endif /* NOETHER */ - return(estat); - } /* end ether_debug */ + return (estat); +} /* end ether_debug */ #ifndef NOETHER -static struct timeval EtherTimeout = { - 0, 0 -}; +static struct timeval EtherTimeout = {0, 0}; #endif /* NOETHER */ - /********************************************************************** * check_ether() * checks an incoming packet **********************************************************************/ #ifndef PKTFILTER -static int nitpos=0, nitlen=0; /* for NIT read buffer in OS3 */ +static int nitpos = 0, nitlen = 0; /* for NIT read buffer in OS3 */ #endif -LispPTR check_ether() - { - /* - * If receiver active then check if any packets are - * available from the ethernet. If so, read the packet - * and signal the icb and return T. - */ +LispPTR check_ether() { +/* + * If receiver active then check if any packets are + * available from the ethernet. If so, read the packet + * and signal the icb and return T. + */ #ifndef NOETHER #ifndef PKTFILTER - static int rfds; - int result, fromlen; - struct nit_hdr header; - int posi, i; -#else /* PKTFILTER */ + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* PKTFILTER */ - static int rfds; - int result; - int i; - int plen; - struct strbuf ctl, data; - char ctlbuf[2000]; + static int rfds; + int result; + int i; + int plen; + struct strbuf ctl, data; + char ctlbuf[2000]; #endif /* PKTFILTER */ - - rfds = EtherReadFds; + rfds = EtherReadFds; #ifndef PKTFILTER - i = 2; - if(/* select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 ) */ (1)) - { - if( (ether_fd >= 0) && (ether_bsize > 0) ) - { - while ( (select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0) - && (i-- > 0) ) - { - if (nitpos>=nitlen) - { /* Used up last NIT buffer full; read another. */ - nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); - nitpos = 0; - } - /* enumerate the NIT headers until the packet is found */ - while (nitpos < nitlen) - { - bcopy(&nit_buf[nitpos], &header, sizeof(header)); - nitpos += sizeof(header); - switch (header.nh_state) - { - case NIT_CATCH: - fromlen = header.nh_datalen; - if (check_filter(&nit_buf[nitpos])) - { - bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); - ether_bsize = 0; /* deactivate receiver */ - ether_in++; - IOPage->dlethernet[3] = fromlen; - DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); - nitpos += fromlen; - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; - ETHEREventCount++; - Irq_Stk_Check = Irq_Stk_End=0; - *PENDINGINTERRUPT68k = ATOM_T; - /* return(NIL); */ - return(ATOM_T); - } - nitpos += fromlen; - break; + i = 2; + if (/* select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 ) */ (1)) { + if ((ether_fd >= 0) && (ether_bsize > 0)) { + while ((select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0) && (i-- > 0)) { + if (nitpos >= nitlen) { /* Used up last NIT buffer full; read another. */ + nitlen = read(ether_fd, nit_buf, sizeof(nit_buf)); + nitpos = 0; + } + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT( + ("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); + nitpos += fromlen; + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End = 0; + *PENDINGINTERRUPT68k = ATOM_T; + /* return(NIL); */ + return (ATOM_T); + } + nitpos += fromlen; + break; - /* ignore all the other header types */ - case NIT_QUIET: break; - case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; - case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; - case NIT_NOSPACE: DBPRINT(("No Space\n")); break; - case NIT_SEQNO: break; - } - } - } - } + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; + } + } } -#else /* PKTFILTER */ + } + } +#else /* PKTFILTER */ - if(ether_fd >= 0 && ether_bsize > 0 -/* && select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 - * -- [on '90/02/14: getsignsldata() chech this] */ - && (rfds & (1 << ether_fd))) - { - data.maxlen = sizeof(nit_buf); - data.len = 0; - data.buf = (char *)nit_buf; - ctl.maxlen = sizeof(ctlbuf); - ctl.len = 0; - ctl.buf = ctlbuf; - plen = 0; - result = getmsg(ether_fd, &ctl, &data, &plen); - if(result >= 0 ) - { - if(data.len <= ether_bsize - && data.len > 0) - { - bcopy(nit_buf, ðer_buf[0], data.len); - ether_bsize = 0; - ether_in++; - IOPage->dlethernet[3] = data.len; - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; - ETHEREventCount++; - Irq_Stk_Check = Irq_Stk_End=0; - *PENDINGINTERRUPT68k = ATOM_T; - return(NIL); /* return(ATOM_T); */ - } - } - else if (errno != EWOULDBLOCK) - { - perror("Check_ether read error:\n"); - } + if (ether_fd >= 0 && ether_bsize > 0 + /* && select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 + * -- [on '90/02/14: getsignsldata() chech this] */ + && (rfds & (1 << ether_fd))) { + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if (result >= 0) { + if (data.len <= ether_bsize && data.len > 0) { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End = 0; + *PENDINGINTERRUPT68k = ATOM_T; + return (NIL); /* return(ATOM_T); */ } + } else if (errno != EWOULDBLOCK) { + perror("Check_ether read error:\n"); + } + } #endif /* PKTFILTER */ #endif /* NOETHER */ - - return(NIL); - } /* end check_ether */ - + return (NIL); +} /* end check_ether */ /************************************************************************/ /* */ @@ -593,103 +550,87 @@ LispPTR check_ether() /* */ /************************************************************************/ -LispPTR get_packet() - { +LispPTR get_packet() { #ifndef NOETHER #ifndef PKTFILTER - static int rfds; - int result, fromlen; - struct nit_hdr header; - int posi, i; -#else /* PKTFILTER */ + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* PKTFILTER */ - static int rfds; - int result; - int i; - int plen; - struct strbuf ctl, data; - char ctlbuf[2000]; + static int rfds; + int result; + int i; + int plen; + struct strbuf ctl, data; + char ctlbuf[2000]; #endif /* PKTFILTER */ - #ifndef PKTFILTER - while (1) - { - if (nitpos>=nitlen) - { /* Used up last NIT buffer full; read another. */ - nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); - if (nitlen < 0) return(NIL); /* No more packets to try. */ - nitpos = 0; - } + while (1) { + if (nitpos >= nitlen) { /* Used up last NIT buffer full; read another. */ + nitlen = read(ether_fd, nit_buf, sizeof(nit_buf)); + if (nitlen < 0) return (NIL); /* No more packets to try. */ + nitpos = 0; + } - /* enumerate the NIT headers until the packet is found */ - while (nitpos < nitlen) - { - bcopy(&nit_buf[nitpos], &header, sizeof(header)); - nitpos += sizeof(header); - switch (header.nh_state) - { - case NIT_CATCH: - fromlen = header.nh_datalen; - if (check_filter(&nit_buf[nitpos])) - { - bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); - ether_bsize = 0; /* deactivate receiver */ - ether_in++; - IOPage->dlethernet[3] = fromlen; - DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", - fromlen, nitpos, nitlen)); - nitpos += fromlen; - return(ATOM_T); - } - nitpos += fromlen; - break; + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); + nitpos += fromlen; + return (ATOM_T); + } + nitpos += fromlen; + break; - /* ignore all the other header types */ - case NIT_QUIET: break; - case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; - case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; - case NIT_NOSPACE: DBPRINT(("No Space\n")); break; - case NIT_SEQNO: break; - } - } + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; } + } + } -#else /* PKTFILTER */ +#else /* PKTFILTER */ - data.maxlen = sizeof(nit_buf); - data.len = 0; - data.buf = (char *)nit_buf; - ctl.maxlen = sizeof(ctlbuf); - ctl.len = 0; - ctl.buf = ctlbuf; - plen = 0; - result = getmsg(ether_fd, &ctl, &data, &plen); - if(result >= 0 ) - { - if (ctl.len > 0) - printf("ctl msg rcvd.\n"); - if(data.len <= ether_bsize && data.len > 0) - { - bcopy(nit_buf, ðer_buf[0], data.len); - ether_bsize = 0; - ether_in++; - IOPage->dlethernet[3] = data.len; - return(ATOM_T); - } - } - else if (errno != EWOULDBLOCK) perror("Check_ether read error:\n"); + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if (result >= 0) { + if (ctl.len > 0) printf("ctl msg rcvd.\n"); + if (data.len <= ether_bsize && data.len > 0) { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + return (ATOM_T); + } + } else if (errno != EWOULDBLOCK) + perror("Check_ether read error:\n"); #endif /* PKTFILTER */ #endif /* NOETHER */ - - return(NIL); - } /* end get_packet */ - - - - + return (NIL); +} /* end get_packet */ /********************************************************************** * check_filter(buffer) @@ -697,29 +638,22 @@ LispPTR get_packet() * This is believed obsolete with packet filtering enabled **********************************************************************/ -int check_filter(buffer) - u_char* buffer; - { - /* broadcast packets */ - if (ether_addr_equal(buffer, broadcast)) - switch(((short*)buffer)[6]) - { - case PacketTypeIP: return(0); - case PacketTypeARP: return(0); - default: return(1); - }; - /* my address */ - if (ether_addr_equal(buffer, ether_host)) - switch(((short*)buffer)[6]) - { - case PacketTypeIP: return(0); - case PacketTypeARP: return(0); - default: return(1); - }; - return(0); - } - - +int check_filter(buffer) u_char *buffer; +{ + /* broadcast packets */ + if (ether_addr_equal(buffer, broadcast)) switch (((short *)buffer)[6]) { + case PacketTypeIP: return (0); + case PacketTypeARP: return (0); + default: return (1); + }; + /* my address */ + if (ether_addr_equal(buffer, ether_host)) switch (((short *)buffer)[6]) { + case PacketTypeIP: return (0); + case PacketTypeARP: return (0); + default: return (1); + }; + return (0); +} /********************************************************************** * ether_addr_equal(add1, add2) @@ -729,29 +663,26 @@ int check_filter(buffer) int ether_addr_equal(add1, add2) -u_char add1[], add2[]; - { - register int i; - for(i=0; i<6; i++) if (add1[i] != add2[i]) return(0); - return(1); - } - - + u_char add1[], + add2[]; +{ + register int i; + for (i = 0; i < 6; i++) + if (add1[i] != add2[i]) return (0); + return (1); +} /********************************************************************** * init_uid() * sets effective user-id to real user-id **********************************************************************/ -void init_uid() - { +void init_uid() { #ifndef NOETHER - int rid; - rid = getuid(); - seteuid(rid); + int rid; + rid = getuid(); + seteuid(rid); #endif /* NOETHER */ - } - - +} /************************************************************************/ /* i n i t _ i f p a g e _ e t h e r */ @@ -761,390 +692,344 @@ void init_uid() /* */ /************************************************************************/ -void init_ifpage_ether() - { - InterfacePage->nshost0 = (DLword)((ether_host[0] << 8) + ether_host[1]); - InterfacePage->nshost1 = (DLword)((ether_host[2] << 8) + ether_host[3]); - InterfacePage->nshost2 = (DLword)((ether_host[4] << 8) + ether_host[5]); - } - +void init_ifpage_ether() { + InterfacePage->nshost0 = (DLword)((ether_host[0] << 8) + ether_host[1]); + InterfacePage->nshost1 = (DLword)((ether_host[2] << 8) + ether_host[3]); + InterfacePage->nshost2 = (DLword)((ether_host[4] << 8) + ether_host[5]); +} #ifndef NOETHER - /* this needs to be a global so the name can be set by main() in Ctest */ - /* But NOETHER doesn't support NIT, so dyke it out for NOETHER */ +/* this needs to be a global so the name can be set by main() in Ctest */ +/* But NOETHER doesn't support NIT, so dyke it out for NOETHER */ #ifndef USE_DLPI struct sockaddr_nit snit; #endif /* USE_DLPI */ #endif /* NOETHER */ - - - - /************************************************************************/ /* i n i t _ e t h e r */ /* */ /* open nit socket, called from main before starting BCE. */ /* */ /************************************************************************/ -void init_ether() - { - +void init_ether() { #ifndef NOETHER - /* JRB - This code will have to be a bit different for SUN 4.0; the probable differences are in commented-out code below - (not ifdefed because they're untested...) - */ - int flags; - struct strioctl si; - unsigned long snaplen = 0; - - /* ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 0; - ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->handledmask = 0; -*/ - - if (ether_fd < 0) - { - /* it's not open yet, try and open it; - if it's already open here, it was opened by ldeether and - all the appropriate stuff was done to it there. - */ -#ifdef USE_DLPI - /* Use DLPI to connect to the ethernet. This code is stolen - from NFSWATCH4.3 + /* JRB - This code will have to be a bit different for SUN 4.0; the probable + differences are in commented-out code below + (not ifdefed because they're untested...) */ + int flags; + struct strioctl si; + unsigned long snaplen = 0; - /* if (getuid() != geteuid()) */ - { - if ( (ether_fd = setup_dlpi_dev(NULL)) > 0) { /* Open an ether interface */ + /* ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 0; + ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->handledmask = 0; + */ - ether_intf_type = dlpi_devtype(ether_fd); + if (ether_fd < 0) { +/* it's not open yet, try and open it; + if it's already open here, it was opened by ldeether and + all the appropriate stuff was done to it there. +*/ +#ifdef USE_DLPI + /* Use DLPI to connect to the ethernet. This code is stolen + from NFSWATCH4.3 + */ - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + /* if (getuid() != geteuid()) */ + { + if ((ether_fd = setup_dlpi_dev(NULL)) > 0) { /* Open an ether interface */ - if(ioctl(ether_fd, I_PUSH, "pfmod") < 0) { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } + ether_intf_type = dlpi_devtype(ether_fd); - - si.ic_cmd = PFIOCSETF; - si.ic_timout = -1; - si.ic_len = sizeof(nopf); - si.ic_dp = (char *)𝕟 + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if (ioctl(ether_fd, I_STR, &si) < 0) { - perror("ioctl: I_STR PFIOCSETF"); - return; - } + if (ioctl(ether_fd, I_PUSH, "pfmod") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } - flags = fcntl(ether_fd, F_GETFL, 0); - flags = fcntl(ether_fd, F_SETFL, flags | O_NDELAY ); + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(nopf); + si.ic_dp = (char *)𝕟 + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ioctl: I_STR PFIOCSETF"); + return; + } + + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | O_NDELAY); + + } else { + I_Give_Up: + /* JDS 991228 remove perror("Can't open network; XNS unavailable.\n"); */ + ether_fd = -1; } - else - { -I_Give_Up: -/* JDS 991228 remove perror("Can't open network; XNS unavailable.\n"); */ - ether_fd = -1; - - } - seteuid(getuid()); - } + seteuid(getuid()); + } #else - /* N O T D L P I C O D E */ - - +/* N O T D L P I C O D E */ #ifndef OS4 - if (getuid() != geteuid()) - { - if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) - { - /* 4.0: socket -> open("/dev/nit", O_BOTH) */ - /* it's open, now query it and find out its name and address */ - /* JRB - must document that Maiko uses the first net board as - found by SIOCGIFCONF (see if(4)). Maybe we need an option to - specify which net board (suspect more than one net board on a - Maiko machine will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + if (getuid() != geteuid()) { + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { + /* 4.0: socket -> open("/dev/nit", O_BOTH) */ + /* it's open, now query it and find out its name and address */ + /* JRB - must document that Maiko uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option to + specify which net board (suspect more than one net board on a + Maiko machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; - if_data.ifc_len = sizeof(ifbuf); - if_data.ifc_req = ifbuf; - /* 4.0 - before the SIOCGIFCONF, do: - bzero(ifbuf, sizeof(ifbuf)) - */ - if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) - { - perror("Couldn't GIFCONF socket; Net is off"); -#else /* OS4 */ + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + /* 4.0 - before the SIOCGIFCONF, do: + bzero(ifbuf, sizeof(ifbuf)) + */ + if (ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ - if (getuid() != geteuid()) - { - if ((ether_fd = open("/dev/nit", O_RDWR|FASYNC)) >= 0) - { - /* it's open, now query it and find out its name and address */ - /* JRB - must document that LDE uses the first net board as - found by SIOCGIFCONF (see if(4)). Maybe we need an option - to specify which net board (suspect more than one net - board on an LDE machine will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + if (getuid() != geteuid()) { + if ((ether_fd = open("/dev/nit", O_RDWR | FASYNC)) >= 0) { + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option + to specify which net board (suspect more than one net + board on an LDE machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if(ioctl(ether_fd, I_PUSH, "pf") < 0) - { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } - if_data.ifc_len = sizeof(ifbuf); - if_data.ifc_req = ifbuf; - bzero(ifbuf, sizeof(ifbuf)); - { - /* we have to get the interface name from another socket, since - /dev/nit doesn't know anything until it gets bound, and we - can't bind it without knowing the interface name... */ - int s; + if (ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - { - perror("No socket for interface name"); - close(s); + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); #endif /* OS4 */ - close(ether_fd); - ether_fd = -1; + close(ether_fd); + ether_fd = -1; #ifndef OS4 - return; -#else /* OS4 */ + return; +#else /* OS4 */ - goto I_Give_Up; + goto I_Give_Up; #endif /* OS4 */ - - } + } #ifndef OS4 - /* got its name, copy it into snit */ - strcpy(snit.snit_ifname, if_data.ifc_req[0].ifr_name); - /* 4.0, before the SIOCGIFADDR, do: - ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) - */ - /* now for the address */ - if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) - { - perror("Couldn't GIFADDR socket: Net is off"); -#else /* OS4 */ + /* got its name, copy it into snit */ + strcpy(snit.snit_ifname, if_data.ifc_req[0].ifr_name); + /* 4.0, before the SIOCGIFADDR, do: + ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) + */ + /* now for the address */ + if (ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); +#else /* OS4 */ - if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) - { - perror("Couldn't get interface name from socket"); - close(s); + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); #endif /* OS4 */ - close(ether_fd); - ether_fd = -1; + close(ether_fd); + ether_fd = -1; #ifndef OS4 - return(NIL); -#else /* OS4 */ + return (NIL); +#else /* OS4 */ - goto I_Give_Up; + goto I_Give_Up; #endif /* OS4 */ - - } + } #ifndef OS4 - bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); - init_uid(); - } -#else /* OS4 */ + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + init_uid(); + } +#else /* OS4 */ - (void) close(s); + (void)close(s); #endif /* OS4 */ - - } + } #ifdef OS4 - if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) - { - perror("Couldn't NIOCBIND socket: Net is off"); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - /* now for the address */ - if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) - { - perror("Couldn't GIFADDR socket: Net is off"); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); - DBPRINT(("init_ether: **** Ethernet starts ****\n")); - } - else - { -I_Give_Up: - perror("Can't open network; XNS unavailable.\n"); - ether_fd = -1; - - } - seteuid(getuid()); + if (ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if (ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + DBPRINT(("init_ether: **** Ethernet starts ****\n")); + } else { + I_Give_Up: + perror("Can't open network; XNS unavailable.\n"); + ether_fd = -1; } + seteuid(getuid()); +} #endif /* OS4 */ #endif /* USE_DLPI */ + } -} + /******************************/ + /* Have now either opened enet here, or in ldeether */ + /***************************************************/ - - /******************************/ - /* Have now either opened enet here, or in ldeether */ - /***************************************************/ - -if (ether_fd >= 0) { + if (ether_fd >= 0) { #ifndef PKTFILTER - /* bind the socket to an interface */ - snit.snit_family = AF_NIT; - bind(ether_fd, &snit, sizeof(snit)); -#else /* PKTFILTER */ + /* bind the socket to an interface */ + snit.snit_family = AF_NIT; + bind(ether_fd, &snit, sizeof(snit)); +#else /* PKTFILTER */ -/* I think all you really have to do here is set the SNAP length, flags, - and configure the buffering module */ - struct timeval zerotime; + /* I think all you really have to do here is set the SNAP length, flags, + and configure the buffering module */ + struct timeval zerotime; #endif /* PKTFILTER */ - #ifndef PKTFILTER - /* establish the operating modes */ - bzero(&nioc, sizeof(nioc)); - nioc.nioc_bufspace = 20000; - nioc.nioc_chunksize = 50; /* small chunks so each packet read */ - nioc.nioc_typetomatch = NT_ALLTYPES; - nioc.nioc_snaplen = 32767; - nioc.nioc_flags = 0; - if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { - printf("init_ether: ioctl failed\n"); + /* establish the operating modes */ + bzero(&nioc, sizeof(nioc)); + nioc.nioc_bufspace = 20000; + nioc.nioc_chunksize = 50; /* small chunks so each packet read */ + nioc.nioc_typetomatch = NT_ALLTYPES; + nioc.nioc_snaplen = 32767; + nioc.nioc_flags = 0; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("init_ether: ioctl failed\n"); - close(ether_fd); - ether_fd = -1; - return; - } + close(ether_fd); + ether_fd = -1; + return; + } #else /* PKTFILTER */ - EtherReadFds |= (1 << ether_fd); + EtherReadFds |= (1 << ether_fd); /* first and foremost, flush out ether_fd's buffers and filter it */ /* install packetfilter that rejects everything */ #ifdef USE_DLPI - si.ic_cmd = PFIOCSETF; - si.ic_timout = -1; - si.ic_len = sizeof(nopf); - si.ic_dp = (char *)𝕟 + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(nopf); + si.ic_dp = (char *)𝕟 - if (ioctl(ether_fd, I_STR, &si) < 0) { - perror("init_ether nopf ioctl: I_STR PFIOCSETF"); - close(ether_fd); - ether_fd = -1; - return; - } + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("init_ether nopf ioctl: I_STR PFIOCSETF"); + close(ether_fd); + ether_fd = -1; + return; + } #else - if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { - perror("init_ether: nopf NIOCSETF failed:\n"); + if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { + perror("init_ether: nopf NIOCSETF failed:\n"); - close(ether_fd); - ether_fd = -1; - return; - } + close(ether_fd); + ether_fd = -1; + return; + } #endif /* USE_DLPI */ #endif /* PKTFILTER -- jds 23 sep 96 unmatched if fix */ #ifndef PKTFILTER - EtherReadFds |= (1 << ether_fd); - if (fcntl(ether_fd, F_SETFL, - fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY)<0) - perror("Ether setup SETFLAGS fcntl"); - if( fcntl(ether_fd, F_SETOWN, getpid()) < 0) - perror("Ether setup SETOWN"); + EtherReadFds |= (1 << ether_fd); + if (fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY) < 0) + perror("Ether setup SETFLAGS fcntl"); + if (fcntl(ether_fd, F_SETOWN, getpid()) < 0) perror("Ether setup SETOWN"); #else /* PKTFILTER */ /* then throw away everything that's currently buffered there; - this descriptor may have been open since ldeether ran, with - no filtering; a busy net will have stuffed it full */ + this descriptor may have been open since ldeether ran, with + no filtering; a busy net will have stuffed it full */ #ifdef USE_DLPI - if (ioctl(ether_fd, I_FLUSH, (char *)FLUSHR) < 0) - { - perror("init_ether I_FLUSH"); - } + if (ioctl(ether_fd, I_FLUSH, (char *)FLUSHR) < 0) { perror("init_ether I_FLUSH"); } #else - {int rfds = EtherReadFds; - while(select(32, &rfds, NULL, NULL, &EtherTimeout) > 0) - read(ether_fd, nit_buf, sizeof(nit_buf)); - } + { + int rfds = EtherReadFds; + while (select(32, &rfds, NULL, NULL, &EtherTimeout) > 0) + read(ether_fd, nit_buf, sizeof(nit_buf)); + } #endif /* USE_DLPI */ - -/* put the address into the packetfilter structure */ -/* DANGER! Vulnerable to byte ordering! DANGER! */ - goodpf.Pf_Filter[8]= (DLword)((ether_host[0] << 8) + ether_host[1]); - goodpf.Pf_Filter[11]= (DLword)((ether_host[2] << 8) + ether_host[3]); - goodpf.Pf_Filter[14]= (DLword)((ether_host[4] << 8) + ether_host[5]); + /* put the address into the packetfilter structure */ + /* DANGER! Vulnerable to byte ordering! DANGER! */ + goodpf.Pf_Filter[8] = (DLword)((ether_host[0] << 8) + ether_host[1]); + goodpf.Pf_Filter[11] = (DLword)((ether_host[2] << 8) + ether_host[3]); + goodpf.Pf_Filter[14] = (DLword)((ether_host[4] << 8) + ether_host[5]); /* and set up the packetfilter */ #ifdef USE_DLPI - si.ic_cmd = PFIOCSETF; - si.ic_timout = -1; - si.ic_len = sizeof(goodpf); - si.ic_dp = (char *)&goodpf; + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(goodpf); + si.ic_dp = (char *)&goodpf; - if (ioctl(ether_fd, I_STR, &si) < 0) { - perror("init_ether goodpf ioctl: I_STR PFIOCSETF"); - close(ether_fd); - ether_fd = -1; - return; - } + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("init_ether goodpf ioctl: I_STR PFIOCSETF"); + close(ether_fd); + ether_fd = -1; + return; + } #else - if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { - perror("init_ether: NIOCSETF failed:\n"); - close(ether_fd); - ether_fd = -1; - return; - } + if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { + perror("init_ether: NIOCSETF failed:\n"); + close(ether_fd); + ether_fd = -1; + return; + } #endif /* USE_DLPI */ #ifndef USE_DLPI - DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); - if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) - { - perror("init_ether: I_SETSIG failed:\n"); - close(ether_fd); - ether_fd = -1; - return; - } + DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); + if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) { + perror("init_ether: I_SETSIG failed:\n"); + close(ether_fd); + ether_fd = -1; + return; + } #endif /* USE_DLPI */ #endif /* PKTFILTER */ - if (EtherReadFds == 0) - error("EtherReadFds is zero, but enet opened??"); - LispReadFds |= EtherReadFds; - - DBPRINT(("init_ether: **** Ethernet starts ****\n")); - } -#endif /* NOETHER */ + if (EtherReadFds == 0) error("EtherReadFds is zero, but enet opened??"); + LispReadFds |= EtherReadFds; + DBPRINT(("init_ether: **** Ethernet starts ****\n")); } +#endif /* NOETHER */ +} - - - -#define MASKWORD1 0xffff - +#define MASKWORD1 0xffff /************************************************************************/ /* */ @@ -1160,31 +1045,33 @@ if (ether_fd >= 0) { /* */ /************************************************************************/ -LispPTR check_sum(args) - register LispPTR *args; - { - register LispPTR checksum; - register DLword *address; - register int nwords; +LispPTR check_sum(args) register LispPTR *args; +{ + register LispPTR checksum; + register DLword *address; + register int nwords; - address=(DLword*)Addr68k_from_LADDR(*args++); - nwords = *args ++; + address = (DLword *)Addr68k_from_LADDR(*args++); + nwords = *args++; - if( *args != NIL) checksum = (*args) & MASKWORD1; - else checksum = 0; + if (*args != NIL) + checksum = (*args) & MASKWORD1; + else + checksum = 0; - for(;nwords > (S_POSITIVE); address++,nwords--) - { - checksum= checksum + GETWORD(address); - if(checksum > 0xffff) - checksum = (checksum & 0xffff) +1; /* add carry */ + for (; nwords > (S_POSITIVE); address++, nwords--) { + checksum = checksum + GETWORD(address); + if (checksum > 0xffff) checksum = (checksum & 0xffff) + 1; /* add carry */ - if(checksum >0x7fff) /* ROTATE LEFT 1 */ - checksum= ((checksum & 0x7fff)<<1) | 1 ; - else checksum = checksum << 1; - } + if (checksum > 0x7fff) /* ROTATE LEFT 1 */ + checksum = ((checksum & 0x7fff) << 1) | 1; + else + checksum = checksum << 1; + } - if(checksum == MASKWORD1) return(S_POSITIVE);/* ret 0 */ - else return(S_POSITIVE|checksum); + if (checksum == MASKWORD1) + return (S_POSITIVE); /* ret 0 */ + else + return (S_POSITIVE | checksum); - } /*check_sum */ +} /*check_sum */ diff --git a/src/findkey.c b/src/findkey.c old mode 100755 new mode 100644 index 4c830fa..bca6b1d --- a/src/findkey.c +++ b/src/findkey.c @@ -1,10 +1,7 @@ -/* $Id: findkey.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: findkey.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: findkey.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,8 +16,6 @@ static char *id = "$Id: findkey.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyr #include "version.h" - - #include "lispemul.h" #include "lispmap.h" #include "emlglob.h" @@ -28,57 +23,47 @@ static char *id = "$Id: findkey.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyr #include "lspglob.h" #include "adr68k.h" - /***********************************************************************/ /* - File Name : findkey.c + File Name : findkey.c - Desc : + Desc : - Date : Mar. 29 88 - Edited by : Bob Krivacic - Including : N_OP_findkey + Date : Mar. 29 88 + Edited by : Bob Krivacic + Including : N_OP_findkey */ /**********************************************************************/ - -LispPTR N_OP_findkey(register LispPTR tos, register int byte) -{ - LispPTR *ptr ; - DLword *find_end ; - DLword arg_nth ; +LispPTR N_OP_findkey(register LispPTR tos, register int byte) { + LispPTR *ptr; + DLword *find_end; + DLword arg_nth; #ifdef TRACE - printPC(); - printf("TRACE : N_OP_findkey \n"); + printPC(); + printf("TRACE : N_OP_findkey \n"); #endif - if(CURRENTFX->alink & 1) - { /* slow case */ - find_end = (DLword *)Addr68k_from_LADDR(STK_OFFSET | (CURRENTFX->blink-4)) ; - } - else - { /* Fast cae */ - find_end = ((DLword *)CURRENTFX) -2-4; - } + if (CURRENTFX->alink & 1) { /* slow case */ + find_end = (DLword *)Addr68k_from_LADDR(STK_OFFSET | (CURRENTFX->blink - 4)); + } else { /* Fast cae */ + find_end = ((DLword *)CURRENTFX) - 2 - 4; + } - arg_nth =byte + 1 ; + arg_nth = byte + 1; - for ( ptr =(LispPTR *) (IVar + ((byte * 2) - 2)); - (unsigned)find_end >= (unsigned) ptr ; ptr += 2, arg_nth +=2) - { - if (*ptr == tos) - { /* KEY founded */ - return(S_POSITIVE | arg_nth); - } - } /* for end */ + for (ptr = (LispPTR *)(IVar + ((byte * 2) - 2)); (unsigned)find_end >= (unsigned)ptr; + ptr += 2, arg_nth += 2) { + if (*ptr == tos) { /* KEY founded */ + return (S_POSITIVE | arg_nth); + } + } /* for end */ -/* No matched */ - - return(NIL_PTR); - - }/* end N_OP_findkey() */ + /* No matched */ + return (NIL_PTR); +} /* end N_OP_findkey() */ diff --git a/src/foreign.c b/src/foreign.c old mode 100755 new mode 100644 index 70da4a6..ff8faf4 --- a/src/foreign.c +++ b/src/foreign.c @@ -1,8 +1,7 @@ -/* $Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyr #include "version.h" - #ifndef NOFORN #include #include "dld.h" @@ -32,48 +30,40 @@ static char *id = "$Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyr #include "arith.h" #include "stack.h" +/***********************************************************/ +/* L S t r i n g T o C S t r i n g */ +/* */ +/* Convert a lisp string to a C string up to MaxLen long. */ +/***********************************************************/ - - /***********************************************************/ - /* L S t r i n g T o C S t r i n g */ - /* */ - /* Convert a lisp string to a C string up to MaxLen long. */ - /***********************************************************/ - -#define LStringToCString(Lisp, C, MaxLen ,Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int i; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ - Len = min(MaxLen, arrayp->fillpointer); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(i=0;ibase))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(i=0;ifillpointer); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = \ + ((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + for (i = 0; i < Len; i++) C[i] = base[i]; \ + C[Len] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = \ + ((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (i = 0; i < Len * 2; i++) C[i] = base[i]; \ + C[Len * 2] = '\0'; \ + break; \ + \ + default: error("LStringToCString can not handle\n"); \ + } \ } /************************************************************************/ @@ -90,11 +80,11 @@ static char *id = "$Id: foreign.c,v 1.3 1999/05/31 23:35:28 sybalsky Exp $ Copyr #define VOIDTYPE 0 -typedef void (*PFV)(); /* Pointer to Function returning Void */ -typedef int (*PFI)(); /* Pointer to Function returning Int */ -typedef char (*PFC)(); /* Pointer to Function returning Char */ -typedef float (*PFF)(); /* Pointer to Function returning Float */ -typedef int (*PFP)(); /* Pointer to Function returning a Pointer */ +typedef void (*PFV)(); /* Pointer to Function returning Void */ +typedef int (*PFI)(); /* Pointer to Function returning Int */ +typedef char (*PFC)(); /* Pointer to Function returning Char */ +typedef float (*PFF)(); /* Pointer to Function returning Float */ +typedef int (*PFP)(); /* Pointer to Function returning a Pointer */ /************************************************************************/ /* */ @@ -114,276 +104,250 @@ typedef int (*PFP)(); /* Pointer to Function returning a Pointer */ /************************************************************************/ #define Max_Arg 32 -LispPTR call_c_fn(LispPTR *args) -{ - int intarg[Max_Arg], result, i, j; - int fnaddr, resulttype, *errorflag, *smasher, arglistlength, *descriptorblock; - PFI pickapart1, pickapart2, pickapart3, pickapart4; - float fresult; +LispPTR call_c_fn(LispPTR *args) { + int intarg[Max_Arg], result, i, j; + int fnaddr, resulttype, *errorflag, *smasher, arglistlength, *descriptorblock; + PFI pickapart1, pickapart2, pickapart3, pickapart4; + float fresult; - DLword *fword, *createcell68k(unsigned int type); + DLword *fword, *createcell68k(unsigned int type); - FX2 *caller; - struct fnhead *fnhead; - ByteCode *pc; + FX2 *caller; + struct fnhead *fnhead; + ByteCode *pc; - /* Initialize the variables from the descriptorblock */ - descriptorblock = (int *)Addr68k_from_LADDR(args[0]); - fnaddr=*descriptorblock++; - resulttype=*descriptorblock++; - errorflag=descriptorblock++; - arglistlength=*descriptorblock++; - smasher=descriptorblock++; + /* Initialize the variables from the descriptorblock */ + descriptorblock = (int *)Addr68k_from_LADDR(args[0]); + fnaddr = *descriptorblock++; + resulttype = *descriptorblock++; + errorflag = descriptorblock++; + arglistlength = *descriptorblock++; + smasher = descriptorblock++; - /* initialize the errorflag */ - *errorflag=0; + /* initialize the errorflag */ + *errorflag = 0; - /* Initialize the argvector */ - for(i=0; ifnheader)); - pc = (ByteCode *)fnhead+(caller->pc); - break; - case TYPE_SMALLP: - case TYPE_FIXP: - { int tmp; - tmp = ((PFI)fnaddr) - (intarg[0], intarg[1], intarg[2], intarg[3], - intarg[4], intarg[5], intarg[6], intarg[7], - intarg[8], intarg[9], intarg[10], intarg[11], - intarg[12], intarg[13], intarg[14], intarg[15], - intarg[16], intarg[17], intarg[18], intarg[19], - intarg[20], intarg[21], intarg[22], intarg[23], - intarg[24], intarg[25], intarg[26], intarg[27], - intarg[28], intarg[29], intarg[30], intarg[31] - ); - return(CIntToLispInt(tmp)); - }; - break; - case TYPE_CHARACTERP: - { int tmp; - tmp = ((PFC)fnaddr) - (intarg[0], intarg[1], intarg[2], intarg[3], - intarg[4], intarg[5], intarg[6], intarg[7], - intarg[8], intarg[9], intarg[10], intarg[11], - intarg[12], intarg[13], intarg[14], intarg[15], - intarg[16], intarg[17], intarg[18], intarg[19], - intarg[20], intarg[21], intarg[22], intarg[23], - intarg[24], intarg[25], intarg[26], intarg[27], - intarg[28], intarg[29], intarg[30], intarg[31] - ); - return(S_CHAR | tmp); - }; - break; - case TYPE_FLOATP: - fresult = ((PFF)fnaddr) - (intarg[0], intarg[1], intarg[2], intarg[3], - intarg[4], intarg[5], intarg[6], intarg[7], - intarg[8], intarg[9], intarg[10], intarg[11], - intarg[12], intarg[13], intarg[14], intarg[15], - intarg[16], intarg[17], intarg[18], intarg[19], - intarg[20], intarg[21], intarg[22], intarg[23], - intarg[24], intarg[25], intarg[26], intarg[27], - intarg[28], intarg[29], intarg[30], intarg[31] - ); - fword = createcell68k(TYPE_FLOATP); - *((float *)fword) = fresult; - return(LADDR_from_68k(fword)); - break; - default: - *errorflag=-2; - break; + *errorflag = i; + return (NIL); + break; } } + switch (resulttype) { + case VOIDTYPE: + ((PFV)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], intarg[6], + intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], intarg[12], intarg[13], + intarg[14], intarg[15], intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], intarg[24], intarg[25], + intarg[26], intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]); + caller = (FX2 *)CURRENTFX; /* Don't return values, just continue. */ + fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & swapx((int)caller->fnheader)); + pc = (ByteCode *)fnhead + (caller->pc); + break; + case TYPE_SMALLP: + case TYPE_FIXP: { + int tmp; + tmp = ((PFI)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], + intarg[6], intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], intarg[16], intarg[17], + intarg[18], intarg[19], intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], intarg[28], intarg[29], + intarg[30], intarg[31]); + return (CIntToLispInt(tmp)); + }; break; + case TYPE_CHARACTERP: { + int tmp; + tmp = ((PFC)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], + intarg[6], intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], intarg[16], intarg[17], + intarg[18], intarg[19], intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], intarg[28], intarg[29], + intarg[30], intarg[31]); + return (S_CHAR | tmp); + }; break; + case TYPE_FLOATP: + fresult = ((PFF)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], + intarg[6], intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], intarg[16], + intarg[17], intarg[18], intarg[19], intarg[20], intarg[21], + intarg[22], intarg[23], intarg[24], intarg[25], intarg[26], + intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]); + fword = createcell68k(TYPE_FLOATP); + *((float *)fword) = fresult; + return (LADDR_from_68k(fword)); + break; + default: *errorflag = -2; break; + } +} /************************************************************************/ /* */ @@ -408,260 +372,237 @@ LispPTR call_c_fn(LispPTR *args) /* If it is not we are on the road to hell. /jarl nilsson */ /* */ /************************************************************************/ -LispPTR smashing_c_fn(LispPTR *args) -{ - int intarg[Max_Arg], result, i, j; - int fnaddr, resulttype, *errorflag, arglistlength, *descriptorblock; - PFI pickapart1, pickapart2, pickapart3, pickapart4; - float fresult; +LispPTR smashing_c_fn(LispPTR *args) { + int intarg[Max_Arg], result, i, j; + int fnaddr, resulttype, *errorflag, arglistlength, *descriptorblock; + PFI pickapart1, pickapart2, pickapart3, pickapart4; + float fresult; - int *valueplace; - DLword *fword, *createcell68k(unsigned int type); + int *valueplace; + DLword *fword, *createcell68k(unsigned int type); - FX2 *caller; - struct fnhead *fnhead; - ByteCode *pc; + FX2 *caller; + struct fnhead *fnhead; + ByteCode *pc; - /* Initialize the variables from the descriptorblock */ - descriptorblock = (int *)Addr68k_from_LADDR(args[0]); - fnaddr=*descriptorblock++; - resulttype=*descriptorblock++; - errorflag=descriptorblock++; - arglistlength=*descriptorblock++; + /* Initialize the variables from the descriptorblock */ + descriptorblock = (int *)Addr68k_from_LADDR(args[0]); + fnaddr = *descriptorblock++; + resulttype = *descriptorblock++; + errorflag = descriptorblock++; + arglistlength = *descriptorblock++; - /* initialize the errorflag */ - *errorflag=0; + /* initialize the errorflag */ + *errorflag = 0; - /* Initialize the valueplace */ - valueplace = (int *)Addr68k_from_LADDR(args[1]); + /* Initialize the valueplace */ + valueplace = (int *)Addr68k_from_LADDR(args[1]); - /* Initialize the argvector */ - for(i=0; ifnheader)); - pc = (ByteCode *)fnhead+(caller->pc); - break; - case TYPE_SMALLP: - case TYPE_FIXP: - { int tmp; - tmp = ((PFI)fnaddr) - (intarg[0], intarg[1], intarg[2], intarg[3], - intarg[4], intarg[5], intarg[6], intarg[7], - intarg[8], intarg[9], intarg[10], intarg[11], - intarg[12], intarg[13], intarg[14], intarg[15], - intarg[16], intarg[17], intarg[18], intarg[19], - intarg[20], intarg[21], intarg[22], intarg[23], - intarg[24], intarg[25], intarg[26], intarg[27], - intarg[28], intarg[29], intarg[30], intarg[31] - ); - *valueplace=tmp; - return(NIL); - }; - break; - case TYPE_CHARACTERP: - return(S_CHAR | (((PFC)fnaddr) - (intarg[0], intarg[1], intarg[2], intarg[3], - intarg[4], intarg[5], intarg[6], intarg[7], - intarg[8], intarg[9], intarg[10], intarg[11], - intarg[12], intarg[13], intarg[14], intarg[15], - intarg[16], intarg[17], intarg[18], intarg[19], - intarg[20], intarg[21], intarg[22], intarg[23], - intarg[24], intarg[25], intarg[26], intarg[27], - intarg[28], intarg[29], intarg[30], intarg[31] - ))); - break; - case TYPE_FLOATP: - fresult = ((PFF)fnaddr) - (intarg[0], intarg[1], intarg[2], intarg[3], - intarg[4], intarg[5], intarg[6], intarg[7], - intarg[8], intarg[9], intarg[10], intarg[11], - intarg[12], intarg[13], intarg[14], intarg[15], - intarg[16], intarg[17], intarg[18], intarg[19], - intarg[20], intarg[21], intarg[22], intarg[23], - intarg[24], intarg[25], intarg[26], intarg[27], - intarg[28], intarg[29], intarg[30], intarg[31] - ); - *valueplace=fresult; - return(NIL); - break; - default: - *errorflag=-2; - break; + *errorflag = i; + return (NIL); + break; } } + switch (resulttype) { + case VOIDTYPE: + ((PFV)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], intarg[6], + intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], intarg[12], intarg[13], + intarg[14], intarg[15], intarg[16], intarg[17], intarg[18], intarg[19], + intarg[20], intarg[21], intarg[22], intarg[23], intarg[24], intarg[25], + intarg[26], intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]); + caller = (FX2 *)CURRENTFX; /* Don't return values, just continue. */ + fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & swapx((int)caller->fnheader)); + pc = (ByteCode *)fnhead + (caller->pc); + break; + case TYPE_SMALLP: + case TYPE_FIXP: { + int tmp; + tmp = ((PFI)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], + intarg[6], intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], intarg[16], intarg[17], + intarg[18], intarg[19], intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], intarg[28], intarg[29], + intarg[30], intarg[31]); + *valueplace = tmp; + return (NIL); + }; break; + case TYPE_CHARACTERP: + return (S_CHAR | + (((PFC)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], + intarg[6], intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], intarg[16], intarg[17], + intarg[18], intarg[19], intarg[20], intarg[21], intarg[22], intarg[23], + intarg[24], intarg[25], intarg[26], intarg[27], intarg[28], intarg[29], + intarg[30], intarg[31]))); + break; + case TYPE_FLOATP: + fresult = ((PFF)fnaddr)(intarg[0], intarg[1], intarg[2], intarg[3], intarg[4], intarg[5], + intarg[6], intarg[7], intarg[8], intarg[9], intarg[10], intarg[11], + intarg[12], intarg[13], intarg[14], intarg[15], intarg[16], + intarg[17], intarg[18], intarg[19], intarg[20], intarg[21], + intarg[22], intarg[23], intarg[24], intarg[25], intarg[26], + intarg[27], intarg[28], intarg[29], intarg[30], intarg[31]); + *valueplace = fresult; + return (NIL); + break; + default: *errorflag = -2; break; + } +} /************************************************************************/ /* */ @@ -673,23 +614,22 @@ LispPTR smashing_c_fn(LispPTR *args) /* */ /************************************************************************/ -int Mdld_link(LispPTR *args) -{ +int Mdld_link(LispPTR *args) { char filename[MAXPATHLEN]; int result, leng; #ifdef TRACE - printf( "TRACE: dld_link(" ); + printf("TRACE: dld_link("); #endif - LStringToCString( args[0], filename, MAXPATHLEN, leng); + LStringToCString(args[0], filename, MAXPATHLEN, leng); #ifdef TRACE - printf( "%s)\n", filename ); + printf("%s)\n", filename); #endif - result = dld_link( filename ); - N_ARITH_SWITCH ( result ); + result = dld_link(filename); + N_ARITH_SWITCH(result); }; /************************************************************************/ @@ -704,26 +644,25 @@ int Mdld_link(LispPTR *args) /* */ /************************************************************************/ -int Mdld_unlink_by_file(LispPTR *args) -{ +int Mdld_unlink_by_file(LispPTR *args) { char filename[MAXPATHLEN]; int hard, result, leng; #ifdef TRACE - printf( "TRACE: dld_unlink_by_file(" ); + printf("TRACE: dld_unlink_by_file("); #endif - LStringToCString( args[0], filename, MAXPATHLEN, leng ); - hard = GetSmalldata( args[1] ); + LStringToCString(args[0], filename, MAXPATHLEN, leng); + hard = GetSmalldata(args[1]); #ifdef TRACE - printf( "%s, %d)\n", filename, hard ); + printf("%s, %d)\n", filename, hard); #endif - result = dld_unlink_by_file( filename, hard ); - N_ARITH_SWITCH ( result ); + result = dld_unlink_by_file(filename, hard); + N_ARITH_SWITCH(result); }; - + /************************************************************************/ /* */ /* M d l d _ u n l i n k _ b y _ s y m b o l */ @@ -736,24 +675,23 @@ int Mdld_unlink_by_file(LispPTR *args) /* */ /************************************************************************/ -int Mdld_unlink_by_symbol(LispPTR *args) -{ +int Mdld_unlink_by_symbol(LispPTR *args) { char symbolname[MAXPATHLEN]; int hard, result, leng; #ifdef TRACE - printf( "TRACE: dld_unlink_by_symbol(" ); + printf("TRACE: dld_unlink_by_symbol("); #endif - LStringToCString( args[0], symbolname, MAXPATHLEN, leng ); - hard = GetSmalldata( args[1] ); + LStringToCString(args[0], symbolname, MAXPATHLEN, leng); + hard = GetSmalldata(args[1]); #ifdef TRACE - printf( "%s, %d)\n", symbolname, hard ); + printf("%s, %d)\n", symbolname, hard); #endif - result = dld_unlink_by_symbol( symbolname, hard ); - N_ARITH_SWITCH ( result ); + result = dld_unlink_by_symbol(symbolname, hard); + N_ARITH_SWITCH(result); }; /************************************************************************/ @@ -764,24 +702,23 @@ int Mdld_unlink_by_symbol(LispPTR *args) /* Return value - a pointer to the symbol or 0 */ /* */ /************************************************************************/ - -unsigned long Mdld_get_symbol(LispPTR *args) -{ + +unsigned long Mdld_get_symbol(LispPTR *args) { char symbolname[MAXPATHLEN]; int result, leng; #ifdef TRACE - printf( "TRACE: dld_get_symbol(" ); + printf("TRACE: dld_get_symbol("); #endif - LStringToCString( args[0], symbolname, MAXPATHLEN, leng ); + LStringToCString(args[0], symbolname, MAXPATHLEN, leng); #ifdef TRACE - printf( "%s, %d)\n", symbolname ); + printf("%s, %d)\n", symbolname); #endif - result = dld_get_symbol( symbolname ); - N_ARITH_SWITCH ( result ); + result = dld_get_symbol(symbolname); + N_ARITH_SWITCH(result); }; /************************************************************************/ @@ -792,23 +729,22 @@ unsigned long Mdld_get_symbol(LispPTR *args) /* Return value - a pointer to the function or 0. */ /* */ /************************************************************************/ -unsigned long Mdld_get_func(LispPTR *args) -{ +unsigned long Mdld_get_func(LispPTR *args) { char funcname[MAXPATHLEN]; int result, leng; #ifdef TRACE - printf( "TRACE: dld_get_func(" ); + printf("TRACE: dld_get_func("); #endif - LStringToCString( args[0], funcname, MAXPATHLEN, leng ); + LStringToCString(args[0], funcname, MAXPATHLEN, leng); #ifdef TRACE - printf( "%s )\n", funcname ); + printf("%s )\n", funcname); #endif - result = dld_get_func( funcname ); - N_ARITH_SWITCH ( result ); + result = dld_get_func(funcname); + N_ARITH_SWITCH(result); }; /************************************************************************/ @@ -818,23 +754,22 @@ unsigned long Mdld_get_func(LispPTR *args) /* args[0] - The lisp string name of the function. */ /* */ /************************************************************************/ -int Mdld_function_executable_p(LispPTR *args) -{ +int Mdld_function_executable_p(LispPTR *args) { char funcname[MAXPATHLEN]; int result, leng; #ifdef TRACE - printf( "TRACE: dld_function_executable_p(" ); + printf("TRACE: dld_function_executable_p("); #endif - LStringToCString( args[0], funcname, MAXPATHLEN, leng ); + LStringToCString(args[0], funcname, MAXPATHLEN, leng); #ifdef TRACE - printf( "%s, %d)\n", funcname ); + printf("%s, %d)\n", funcname); #endif - result = dld_function_executable_p( funcname ); - N_ARITH_SWITCH ( result ); + result = dld_function_executable_p(funcname); + N_ARITH_SWITCH(result); }; /************************************************************************/ @@ -843,22 +778,19 @@ int Mdld_function_executable_p(LispPTR *args) /* */ /* */ /************************************************************************/ -int Mdld_list_undefined_sym(void) -{ +int Mdld_list_undefined_sym(void) { char **dld_list_undefined_sym(); int temp; extern int dld_undefined_sym_count; #ifdef TRACE - printf( "TRACE: dld_list_undefined_sym()\n" ); + printf("TRACE: dld_list_undefined_sym()\n"); #endif - if (dld_undefined_sym_count == 0) { - return (NIL); - } + if (dld_undefined_sym_count == 0) { return (NIL); } - temp = (int)dld_list_undefined_sym( ); - N_ARITH_SWITCH ( temp ); + temp = (int)dld_list_undefined_sym(); + N_ARITH_SWITCH(temp); }; /************************************************************************/ @@ -867,10 +799,9 @@ int Mdld_list_undefined_sym(void) /* */ /* */ /************************************************************************/ -int c_malloc (LispPTR *args) -{ - printf ("malloc!\n"); - return(NIL); +int c_malloc(LispPTR *args) { + printf("malloc!\n"); + return (NIL); } /************************************************************************/ @@ -879,10 +810,9 @@ int c_malloc (LispPTR *args) /* */ /* */ /************************************************************************/ -int c_free (LispPTR *args) -{ - printf ("free!\n"); - return(NIL); +int c_free(LispPTR *args) { + printf("free!\n"); + return (NIL); } /************************************************************************/ @@ -907,37 +837,32 @@ int c_free (LispPTR *args) /* This makes it easy to set values in arrays. */ /* */ /************************************************************************/ -int put_c_basebyte (LispPTR *args) -{ +int put_c_basebyte(LispPTR *args) { int addr, offset, newval; addr = LispIntToCInt(args[0]); offset = LispIntToCInt(args[1]); - newval= LispIntToCInt(args[3]); + newval = LispIntToCInt(args[3]); switch (LispIntToCInt(args[2])) { - case 0: /* bit */ - if (newval == 0) { - GETBYTE((char *)(addr + (offset >> 3))) &= (~(1 << (0x7 & offset))); - } else { - GETBYTE((char *)(addr + (offset >> 3))) |= (1 << (0x7 & offset)); - }; - break; - case 1: /* byte */ - GETBYTE((char*)(addr + offset)) = 0xFF & newval; - break; - case 2: /* word */ - newval &= 0xFFFF; - (*((short *) ((addr & 0xFFFFFFFE) + (offset << 1)))) = newval; - break; - case 3: /* int */ - (*((int *) ((addr & 0xFFFFFFFE) + (offset << 2)))) = newval; - break; - case 4: /* float */ - (*((float *) ((addr & 0xFFFFFFFE) + (offset << 2)))) = FLOATP_VALUE(args[3]); - break; + case 0: /* bit */ + if (newval == 0) { + GETBYTE((char *)(addr + (offset >> 3))) &= (~(1 << (0x7 & offset))); + } else { + GETBYTE((char *)(addr + (offset >> 3))) |= (1 << (0x7 & offset)); + }; + break; + case 1: /* byte */ GETBYTE((char *)(addr + offset)) = 0xFF & newval; break; + case 2: /* word */ + newval &= 0xFFFF; + (*((short *)((addr & 0xFFFFFFFE) + (offset << 1)))) = newval; + break; + case 3: /* int */ (*((int *)((addr & 0xFFFFFFFE) + (offset << 2)))) = newval; break; + case 4: /* float */ + (*((float *)((addr & 0xFFFFFFFE) + (offset << 2)))) = FLOATP_VALUE(args[3]); + break; } - return(NIL); + return (NIL); } /************************************************************************/ @@ -961,37 +886,34 @@ int put_c_basebyte (LispPTR *args) /* This makes it easy to access arrays. */ /* */ /************************************************************************/ -int get_c_basebyte(LispPTR *args) -{ +int get_c_basebyte(LispPTR *args) { int addr, offset, type; DLword *fword, *createcell68k(unsigned int type); - addr = LispIntToCInt(args[0]); + addr = LispIntToCInt(args[0]); offset = LispIntToCInt(args[1]); switch (LispIntToCInt(args[2])) { - case 0: /* bit */ - if ((GETBYTE((char *)(addr + (offset >> 3)))) & (1 << (0x7 & offset))) { - /* ^get bitmask from offset ^get the byte at the byteaddress */ - return(ATOM_T); + case 0: /* bit */ + if ((GETBYTE((char *)(addr + (offset >> 3)))) & (1 << (0x7 & offset))) { + /* ^get bitmask from offset ^get the byte at the byteaddress */ + return (ATOM_T); } else { - return(NIL); + return (NIL); }; - break; - case 1: /* byte */ - return((0xFF & (GETBYTE((char *)(addr + offset)))) | S_POSITIVE); - break; - case 2: /* word */ - return( CIntToLispInt (0xFFFF & (*((short *) ((addr & 0xFFFFFFFE) + (offset << 1)))))); - break; - case 3: /* int */ - return( CIntToLispInt (*((int *) ((addr & 0xFFFFFFFE) + (offset << 2))))); - break; - case 4: /* float */ - fword = createcell68k(TYPE_FLOATP); - *((float *)fword) = *(float *)((addr & 0xFFFFFFFE) + (offset << 2)); - return(LADDR_from_68k(fword)); - break; + break; + case 1: /* byte */ return ((0xFF & (GETBYTE((char *)(addr + offset)))) | S_POSITIVE); break; + case 2: /* word */ + return (CIntToLispInt(0xFFFF & (*((short *)((addr & 0xFFFFFFFE) + (offset << 1)))))); + break; + case 3: /* int */ + return (CIntToLispInt(*((int *)((addr & 0xFFFFFFFE) + (offset << 2))))); + break; + case 4: /* float */ + fword = createcell68k(TYPE_FLOATP); + *((float *)fword) = *(float *)((addr & 0xFFFFFFFE) + (offset << 2)); + return (LADDR_from_68k(fword)); + break; } } #endif /* NOFORN */ diff --git a/src/fp.c b/src/fp.c old mode 100755 new mode 100644 index 10eccb5..e98d97b --- a/src/fp.c +++ b/src/fp.c @@ -1,9 +1,6 @@ /* $Id: fp.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: fp.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,10 +13,8 @@ static char *id = "$Id: fp.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright /* */ /************************************************************************/ - #include "version.h" - /************************************************************************/ /* */ /* F P . C */ @@ -38,17 +33,15 @@ static char *id = "$Id: fp.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright #include "medleyfp.h" /************************************************************ - N_OP_fplus2 -- op 350 - N_OP_fdifference -- op 351 - N_OP_ftimes2 -- op 352 - N_OP_fquotient -- op 353 - N_OP_fgreaterp -- op 362 + N_OP_fplus2 -- op 350 + N_OP_fdifference -- op 351 + N_OP_ftimes2 -- op 352 + N_OP_fquotient -- op 353 + N_OP_fgreaterp -- op 362 ***********************************************************/ DLword *createcell68k(unsigned int type); - - /************************************************************************/ /* */ /* N _ O P _ f p l u s 2 */ @@ -57,27 +50,24 @@ DLword *createcell68k(unsigned int type); /* */ /************************************************************************/ -LispPTR N_OP_fplus2(LispPTR parg1, LispPTR parg2) -{ - REGISTER float arg1; - REGISTER float arg2; - REGISTER float result; - register DLword *wordp; +LispPTR N_OP_fplus2(LispPTR parg1, LispPTR parg2) { + REGISTER float arg1; + REGISTER float arg2; + REGISTER float result; + register DLword *wordp; - N_MakeFloat(parg1, arg1, parg2); - N_MakeFloat(parg2, arg2, parg2); - FPCLEAR; + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; #ifdef I386 - I386Round; + I386Round; #endif - result = arg1 + arg2; - if (FPTEST(result)) ERROR_EXIT(parg2); - wordp = createcell68k(TYPE_FLOATP); - *((float *)wordp) = result; - return(LADDR_from_68k(wordp)); - } /* end N_OP_fplus2() */ - - + result = arg1 + arg2; + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return (LADDR_from_68k(wordp)); +} /* end N_OP_fplus2() */ /************************************************************************/ /* */ @@ -87,27 +77,23 @@ LispPTR N_OP_fplus2(LispPTR parg1, LispPTR parg2) /* */ /************************************************************************/ -LispPTR N_OP_fdifference(LispPTR parg1, LispPTR parg2) -{ - REGISTER float arg1, arg2; - REGISTER float result; - register DLword *wordp; +LispPTR N_OP_fdifference(LispPTR parg1, LispPTR parg2) { + REGISTER float arg1, arg2; + REGISTER float result; + register DLword *wordp; - N_MakeFloat(parg1, arg1, parg2); - N_MakeFloat(parg2, arg2, parg2); - FPCLEAR; + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; #ifdef I386 - I386Round; + I386Round; #endif - result = arg1 - arg2; - if (FPTEST(result)) ERROR_EXIT(parg2); - wordp = createcell68k(TYPE_FLOATP); - *((float *)wordp) = result; - return(LADDR_from_68k(wordp)); - } /* end N_OP_fdifference() */ - - - + result = arg1 - arg2; + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return (LADDR_from_68k(wordp)); +} /* end N_OP_fdifference() */ /************************************************************************/ /* */ @@ -117,27 +103,23 @@ LispPTR N_OP_fdifference(LispPTR parg1, LispPTR parg2) /* */ /************************************************************************/ -LispPTR N_OP_ftimes2(LispPTR parg1, LispPTR parg2) -{ - REGISTER float arg1, arg2; - REGISTER float result; - register DLword *wordp; +LispPTR N_OP_ftimes2(LispPTR parg1, LispPTR parg2) { + REGISTER float arg1, arg2; + REGISTER float result; + register DLword *wordp; - N_MakeFloat(parg1, arg1, parg2); - N_MakeFloat(parg2, arg2, parg2); - FPCLEAR; + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; #ifdef I386 - I386Round; + I386Round; #endif - result = arg1 * arg2; - if (FPTEST(result)) ERROR_EXIT(parg2); - wordp = createcell68k(TYPE_FLOATP); - *((float *)wordp) = result; - return(LADDR_from_68k(wordp)); - } /* end N_OP_ftimes2() */ - - - + result = arg1 * arg2; + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return (LADDR_from_68k(wordp)); +} /* end N_OP_ftimes2() */ /************************************************************************/ /* */ @@ -147,27 +129,24 @@ LispPTR N_OP_ftimes2(LispPTR parg1, LispPTR parg2) /* */ /************************************************************************/ -LispPTR N_OP_fquotient(LispPTR parg1, LispPTR parg2) -{ - REGISTER float arg1, arg2; - REGISTER float result; - register DLword *wordp; +LispPTR N_OP_fquotient(LispPTR parg1, LispPTR parg2) { + REGISTER float arg1, arg2; + REGISTER float result; + register DLword *wordp; - N_MakeFloat(parg1, arg1, parg2); - N_MakeFloat(parg2, arg2, parg2); - FPCLEAR; + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + FPCLEAR; #ifdef I386 - I386Round; + I386Round; #endif - result = arg1 / arg2; - - if (FPTEST(result)) ERROR_EXIT(parg2); - wordp = createcell68k(TYPE_FLOATP); - *((float *)wordp) = result; - return(LADDR_from_68k(wordp)); - } /* end N_OP_fquotient() */ - + result = arg1 / arg2; + if (FPTEST(result)) ERROR_EXIT(parg2); + wordp = createcell68k(TYPE_FLOATP); + *((float *)wordp) = result; + return (LADDR_from_68k(wordp)); +} /* end N_OP_fquotient() */ /************************************************************************/ /* */ @@ -177,16 +156,15 @@ LispPTR N_OP_fquotient(LispPTR parg1, LispPTR parg2) /* */ /************************************************************************/ -LispPTR N_OP_fgreaterp(LispPTR parg1, LispPTR parg2) -{ - REGISTER float arg1, arg2; - register DLword *wordp; - register LispPTR lptr; - - N_MakeFloat(parg1, arg1, parg2); - N_MakeFloat(parg2, arg2, parg2); - if (arg1 > arg2) return(ATOM_T); - else return(NIL_PTR); - } /* end N_OP_fgreaterp() */ - +LispPTR N_OP_fgreaterp(LispPTR parg1, LispPTR parg2) { + REGISTER float arg1, arg2; + register DLword *wordp; + register LispPTR lptr; + N_MakeFloat(parg1, arg1, parg2); + N_MakeFloat(parg2, arg2, parg2); + if (arg1 > arg2) + return (ATOM_T); + else + return (NIL_PTR); +} /* end N_OP_fgreaterp() */ diff --git a/src/fvar.c b/src/fvar.c old mode 100755 new mode 100644 index 9f4cb18..97f540a --- a/src/fvar.c +++ b/src/fvar.c @@ -1,10 +1,6 @@ /* $Id: fvar.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: fvar.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,7 +15,6 @@ static char *id = "$Id: fvar.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyrigh #include "version.h" - #include #include "lispemul.h" #include "lspglob.h" @@ -32,581 +27,563 @@ static char *id = "$Id: fvar.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyrigh #ifdef GCC386 #include "inlnPS2.h" -#endif - -#define MaskShift(x) (((x) << 16) & SEGMASK) - - -#ifdef BIGATOMS -#define NT_OFFSET_MASK 0xFFFFFFF -#define NT_TYPE_MASK 0xFF000000 -#define GetNTEntry(X) GetLongWord(X) -#define NAMETABLE LispPTR -#else -#define NT_OFFSET_MASK 0xFF -#define NT_TYPE_MASK 0xFF00 -#define GetNTEntry(X) GETWORD(X) -#define NAMETABLE DLword #endif -#define FVSTACK 2 -#define FVGLOBAL 6 +#define MaskShift(x) (((x) << 16) & SEGMASK) #ifdef BIGATOMS -#define FVIVARHI 0x0 -#define FVPVARHI (0x80000000) -#define FVFVARHI (0xC0000000) +#define NT_OFFSET_MASK 0xFFFFFFF +#define NT_TYPE_MASK 0xFF000000 +#define GetNTEntry(X) GetLongWord(X) +#define NAMETABLE LispPTR #else -#define FVIVARHI 0x0 -#define FVPVARHI 0x8000 -#define FVFVARHI 0xC000 +#define NT_OFFSET_MASK 0xFF +#define NT_TYPE_MASK 0xFF00 +#define GetNTEntry(X) GETWORD(X) +#define NAMETABLE DLword #endif -#define ENDSTACKMARK 0xb - +#define FVSTACK 2 +#define FVGLOBAL 6 +#ifdef BIGATOMS +#define FVIVARHI 0x0 +#define FVPVARHI (0x80000000) +#define FVFVARHI (0xC0000000) +#else +#define FVIVARHI 0x0 +#define FVPVARHI 0x8000 +#define FVFVARHI 0xC000 +#endif +#define ENDSTACKMARK 0xb /****************************************************************************** nnewframe - This routine is used by fvlookup and OP_stkscan. + This routine is used by fvlookup and OP_stkscan. - 1. scan Name table in new function header. - 2. if found, set address of searching variable to chain address. - 3. return the type of var, on stack, or global. (fs: unused, removed) + 1. scan Name table in new function header. + 2. if found, set address of searching variable to chain address. + 3. return the type of var, on stack, or global. (fs: unused, removed) ******************************************************************************/ void nnewframe(register struct frameex1 *newpfra2, register DLword *achain, register int name) - /* pointer to new frame extension */ - /* pointer to 1st word of the searching - FVAR slot in CurrentFrameExtension */ - /* Atom index num. of target FVAR slot. */ - { +/* pointer to new frame extension */ +/* pointer to 1st word of the searching + FVAR slot in CurrentFrameExtension */ +/* Atom index num. of target FVAR slot. */ +{ + register NAMETABLE *pindex; /* '90/06/06 osamu changed from DLword * + * index to indexs of new name table */ + register UNSIGNED i; /* temp for control */ + register int nametablesize; /* NameTable size of current function header. */ + register int ph; /* alink temp, also phase */ + struct frameex1 *onewpfra2, *oonewpfra2, *ooonewpfra2; - register NAMETABLE *pindex; /* '90/06/06 osamu changed from DLword * - * index to indexs of new name table */ - register UNSIGNED i; /* temp for control */ - register int nametablesize; /* NameTable size of current function header. */ - register int ph; /* alink temp, also phase */ -struct frameex1 *onewpfra2, *oonewpfra2, *ooonewpfra2; - - newframe: +newframe: #ifdef SUN3_OS3_OR_OS4_IL - newframe_setup_label(); + newframe_setup_label(); #endif - /* assume that apframe1 points to the next frame to be scanned */ - ph = newpfra2->alink; -if (ph==0) error("alink = 0 in nnewframe"); - if(ph == ENDSTACKMARK) - { - /* endStack */ + /* assume that apframe1 points to the next frame to be scanned */ + ph = newpfra2->alink; + if (ph == 0) error("alink = 0 in nnewframe"); + if (ph == ENDSTACKMARK) { +/* endStack */ #ifdef BIGATOMS - if ((name&SEGMASK) != 0) /* New symbol */ - { - register int result = name+NEWATOM_VALUE_OFFSET; - /* printf("NEW-SYMBOL in nnewframe, 0x%x, result = 0x%x\n", name, result); */ - GETBASEWORD(achain,1) = result>>16; - GETBASEWORD(achain,0) = result & 0xFFFF; - } - else + if ((name & SEGMASK) != 0) /* New symbol */ + { + register int result = name + NEWATOM_VALUE_OFFSET; + /* printf("NEW-SYMBOL in nnewframe, 0x%x, result = 0x%x\n", name, result); */ + GETBASEWORD(achain, 1) = result >> 16; + GETBASEWORD(achain, 0) = result & 0xFFFF; + } else #endif /* BIGATOMS */ #ifdef BIGVM - if (name & SEGMASK) - { /* It's a big-atom, so just offset from the base to get value */ - register int result = name + NEWATOM_VALUE_OFFSET; - GETBASEWORD(achain,1) = result>>16; - GETBASEWORD(achain,0) = result & 0xFFFF; - } - else - { /* It's an "old" atom, so offset into the table of atoms */ - register int result = (ATOMS_HI << 16) + (10*name) + NEWATOM_VALUE_OFFSET; - GETBASEWORD(achain,1) = result>>16; - GETBASEWORD(achain,0) = result & 0xFFFF; - } -#else - if(name >= 0x8000) - { - GETBASEWORD(achain,1) = VALS_HI + 1; - GETBASEWORD(achain,0) = name*2; - } - else - { - GETBASEWORD(achain,1) = VALS_HI; - GETBASEWORD(achain,0) = name*2; - } -#endif /* BIGVM */ - return; - } - - ph &= 0xFFFE; /* to mask off SLOW bit */ -ooonewpfra2 = oonewpfra2; -oonewpfra2 = onewpfra2; -onewpfra2 = newpfra2; - newpfra2 = (struct frameex1 *)(-FRAMESIZE + Stackspace + ph); - - { /* open new block to try and conserve address register */ - register struct fnhead *newpfn2; /* ptr to new fn header */ - - if(newpfra2->validnametable) /* check VALIDNAMETABLE */ -#ifdef BIGVM - newpfn2 = (struct fnhead *) - (Addr68k_from_LADDR(newpfra2->nametable)); - else - newpfn2 = (struct fnhead *) - (Addr68k_from_LADDR(newpfra2->fnheader)); -#else - newpfn2 = (struct fnhead *) - (Addr68k_from_LADDR(((newpfra2->hi2nametable)<<16 | - newpfra2->lonametable ))); - else - newpfn2 = (struct fnhead *) - (Addr68k_from_LADDR(((newpfra2->hi2fnheader)<<16 | - newpfra2->lofnheader ))); -#endif /* BIGVM */ - pindex = (NAMETABLE *)((DLword *)newpfn2 + FNHEADSIZE); - /* now pindex points 1st word of Nametable. */ -#ifdef BIGATOMS - nametablesize = (newpfn2->ntsize >> 1); /* ntsize is # of words in NT - not # of element */ -#else - nametablesize = newpfn2->ntsize; -#endif + if (name & SEGMASK) { /* It's a big-atom, so just offset from the base to get value */ + register int result = name + NEWATOM_VALUE_OFFSET; + GETBASEWORD(achain, 1) = result >> 16; + GETBASEWORD(achain, 0) = result & 0xFFFF; + } else { /* It's an "old" atom, so offset into the table of atoms */ + register int result = (ATOMS_HI << 16) + (10 * name) + NEWATOM_VALUE_OFFSET; + GETBASEWORD(achain, 1) = result >> 16; + GETBASEWORD(achain, 0) = result & 0xFFFF; } +#else + if (name >= 0x8000) { + GETBASEWORD(achain, 1) = VALS_HI + 1; + GETBASEWORD(achain, 0) = name * 2; + } else { + GETBASEWORD(achain, 1) = VALS_HI; + GETBASEWORD(achain, 0) = name * 2; + } +#endif /* BIGVM */ + return; + } + + ph &= 0xFFFE; /* to mask off SLOW bit */ + ooonewpfra2 = oonewpfra2; + oonewpfra2 = onewpfra2; + onewpfra2 = newpfra2; + newpfra2 = (struct frameex1 *)(-FRAMESIZE + Stackspace + ph); + + { /* open new block to try and conserve address register */ + register struct fnhead *newpfn2; /* ptr to new fn header */ + + if (newpfra2->validnametable) /* check VALIDNAMETABLE */ +#ifdef BIGVM + newpfn2 = (struct fnhead *)(Addr68k_from_LADDR(newpfra2->nametable)); + else + newpfn2 = (struct fnhead *)(Addr68k_from_LADDR(newpfra2->fnheader)); +#else + newpfn2 = (struct fnhead *)(Addr68k_from_LADDR( + ((newpfra2->hi2nametable) << 16 | newpfra2->lonametable))); + else + newpfn2 = (struct fnhead *)(Addr68k_from_LADDR( + ((newpfra2->hi2fnheader) << 16 | newpfra2->lofnheader))); +#endif /* BIGVM */ + pindex = (NAMETABLE *)((DLword *)newpfn2 + FNHEADSIZE); +/* now pindex points 1st word of Nametable. */ +#ifdef BIGATOMS + nametablesize = (newpfn2->ntsize >> 1); /* ntsize is # of words in NT + not # of element */ +#else + nametablesize = newpfn2->ntsize; +#endif + } #ifdef SUN3_OS3_OR_OS4_IL - newframe_loop_label(); + newframe_loop_label(); #endif - i = (UNSIGNED) (pindex + nametablesize); - for(; (UNSIGNED)i > (UNSIGNED) pindex;) - { /* searching in NewFuncHeader */ + i = (UNSIGNED)(pindex + nametablesize); + for (; (UNSIGNED)i > (UNSIGNED)pindex;) { /* searching in NewFuncHeader */ #ifdef BIGATOMS - /* These used to be GETWORDs, but NAMETABLE is a CELL in 3-byte */ +/* These used to be GETWORDs, but NAMETABLE is a CELL in 3-byte */ #if 1 - if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=1; goto foundit;} -cont2: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=0; goto foundit;} + if ((int)*((NAMETABLE *)pindex++) == (int)name) { + ph = 1; + goto foundit; + } + cont2: + if ((int)*((NAMETABLE *)pindex++) == (int)name) { + ph = 0; + goto foundit; + } #else - if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=1; goto foundit;} -cont2: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=2; goto foundit;} -cont3: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=3; goto foundit;} -cont4: if((int)*((NAMETABLE *)pindex++) == (int)name) {ph=0; goto foundit;} + if ((int)*((NAMETABLE *)pindex++) == (int)name) { + ph = 1; + goto foundit; + } + cont2: + if ((int)*((NAMETABLE *)pindex++) == (int)name) { + ph = 2; + goto foundit; + } + cont3: + if ((int)*((NAMETABLE *)pindex++) == (int)name) { + ph = 3; + goto foundit; + } + cont4: + if ((int)*((NAMETABLE *)pindex++) == (int)name) { + ph = 0; + goto foundit; + } #endif /* ISC */ #else - if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=1; goto foundit;} -cont2: if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=2; goto foundit;} -cont3: if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=3; goto foundit;} -cont4: if(GETWORD((NAMETABLE *)pindex++) == (DLword)name) {ph=0; goto foundit;} + if (GETWORD((NAMETABLE *)pindex++) == (DLword)name) { + ph = 1; + goto foundit; + } + cont2: + if (GETWORD((NAMETABLE *)pindex++) == (DLword)name) { + ph = 2; + goto foundit; + } + cont3: + if (GETWORD((NAMETABLE *)pindex++) == (DLword)name) { + ph = 3; + goto foundit; + } + cont4: + if (GETWORD((NAMETABLE *)pindex++) == (DLword)name) { + ph = 0; + goto foundit; + } #endif - continue; -foundit: - { - register int fvartype; /* probing fvar vartype */ - register int fvaroffset; /* probing fvar varoffset */ - register DLword *ppvar; /* ptr to probing var candidate */ + continue; + foundit : { + register int fvartype; /* probing fvar vartype */ + register int fvaroffset; /* probing fvar varoffset */ + register DLword *ppvar; /* ptr to probing var candidate */ #ifdef BIGATOMS - fvartype = (int) *(pindex + nametablesize - 1); + fvartype = (int)*(pindex + nametablesize - 1); #else - fvartype = GETWORD(pindex + nametablesize - 1); + fvartype = GETWORD(pindex + nametablesize - 1); #endif /* BIGATOMS */ - fvaroffset = NT_OFFSET_MASK & fvartype; - fvaroffset <<= 1; - fvartype &= NT_TYPE_MASK; - switch( fvartype ) - { - case FVPVARHI: /* 0x8000 or 0x80000000(BIGATOMS) */ - ppvar = FRAMESIZE+(DLword *)newpfra2+fvaroffset; - /* ppvar points to argued Pvar */ - if(WBITSPTR(ppvar)->xMSB) - /* check UNBOUND (if *ppvar is negative , unbound) */ - switch ( ph ) - { - case 0 : continue; - case 1 : goto cont2; - /* case 2 : goto cont3; - case 3 : goto cont4; */ - } - GETBASEWORD(achain,1) = STK_HI; - GETBASEWORD(achain,0) = 0xFFFF & LADDR_from_68k(ppvar); - /* save High word of PVAR slot address to FVAR slot */ - /* achain points to target FVAR slot */ - return; - case FVFVARHI: /* 0xC000 or 0xC0000000(BIGATOMS) */ - ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; - if( WBITSPTR(ppvar)->LSB ) goto endlookfor; - /* Not Found in new FnHeader, scan next one. */ - *((int *)achain) = *((int *)ppvar); - /* save address of FX to FVAR slot */ - /* achain points to target FVAR slot */ - return; - case FVIVARHI: /* 0x000: */ - ppvar = -1 + (DLword *)newpfra2; - /* ppvar points to IVAR field in Basic frame */ - GETBASEWORD(achain,1) = STK_HI; - GETBASEWORD(achain,0) = GETWORD(ppvar) + fvaroffset; - return; - default:error("Stack corrupted: bad value in name table"); - }/* end switch */ - }/* end if */ - }/* end for */ + fvaroffset = NT_OFFSET_MASK & fvartype; + fvaroffset <<= 1; + fvartype &= NT_TYPE_MASK; + switch (fvartype) { + case FVPVARHI: /* 0x8000 or 0x80000000(BIGATOMS) */ + ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; + /* ppvar points to argued Pvar */ + if (WBITSPTR(ppvar)->xMSB) /* check UNBOUND (if *ppvar is negative , unbound) */ + switch (ph) { + case 0: continue; + case 1: + goto cont2; + /* case 2 : goto cont3; + case 3 : goto cont4; */ + } + GETBASEWORD(achain, 1) = STK_HI; + GETBASEWORD(achain, 0) = 0xFFFF & LADDR_from_68k(ppvar); + /* save High word of PVAR slot address to FVAR slot */ + /* achain points to target FVAR slot */ + return; + case FVFVARHI: /* 0xC000 or 0xC0000000(BIGATOMS) */ + ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; + if (WBITSPTR(ppvar)->LSB) goto endlookfor; + /* Not Found in new FnHeader, scan next one. */ + *((int *)achain) = *((int *)ppvar); + /* save address of FX to FVAR slot */ + /* achain points to target FVAR slot */ + return; + case FVIVARHI: /* 0x000: */ + ppvar = -1 + (DLword *)newpfra2; + /* ppvar points to IVAR field in Basic frame */ + GETBASEWORD(achain, 1) = STK_HI; + GETBASEWORD(achain, 0) = GETWORD(ppvar) + fvaroffset; + return; + default: error("Stack corrupted: bad value in name table"); + } /* end switch */ + } /* end if */ + } /* end for */ endlookfor: - goto newframe; /* scan the next one */ - - } + goto newframe; /* scan the next one */ +} /************************************************************************** nfvlookup: - This routine is used by only OP_fvarn. - ( in addition to N_OP_fvar_() ) - 1. get Atom index number of target fvar slot. - 2. call fvlookfor. + This routine is used by only OP_fvarn. + ( in addition to N_OP_fvar_() ) + 1. get Atom index number of target fvar slot. + 2. call fvlookfor. ****************************************************************************/ -void -nfvlookup(struct frameex1 *apframe1, register DLword *achain, register struct fnhead *apfnhead1) - /* pointer to current frame extension */ - /* pointer to 1st word of the searching - FVAR slot in CurrentFrameExtension */ - /* pointer to current function heaer */ - { - register DLword *pfh; /* pointer to current function header */ - register int paoffset; /* 2word offset in PVAR AREA */ +void nfvlookup(struct frameex1 *apframe1, register DLword *achain, + register struct fnhead *apfnhead1) +/* pointer to current frame extension */ +/* pointer to 1st word of the searching + FVAR slot in CurrentFrameExtension */ +/* pointer to current function heaer */ +{ + register DLword *pfh; /* pointer to current function header */ + register int paoffset; /* 2word offset in PVAR AREA */ - pfh = (DLword *)apfnhead1; - paoffset = ((UNSIGNED)achain - (UNSIGNED)PVar)>>2; - /* slot to looked for, 2word offset from PVar */ + pfh = (DLword *)apfnhead1; + paoffset = ((UNSIGNED)achain - (UNSIGNED)PVar) >> 2; +/* slot to looked for, 2word offset from PVar */ #ifdef BIGATOMS - nnewframe(apframe1, achain, - (*((LispPTR *) - ((DLword *)pfh + apfnhead1->fvaroffset) + paoffset - - apfnhead1->nlocals))); + nnewframe(apframe1, achain, (*((LispPTR *)((DLword *)pfh + apfnhead1->fvaroffset) + paoffset - + apfnhead1->nlocals))); #else - nnewframe(apframe1, achain, - (GETWORD(pfh + (apfnhead1->fvaroffset + paoffset - - apfnhead1->nlocals)))); + nnewframe(apframe1, achain, + (GETWORD(pfh + (apfnhead1->fvaroffset + paoffset - apfnhead1->nlocals)))); #endif - } - +} /************************************************************************* N_OP_fvarn - entry of OPCODE[120b-127b]: FVAR, FVARX + entry of OPCODE[120b-127b]: FVAR, FVARX - 1. save TopOfStack to evaluation stack. - 2. set address of searching FVAR slot to chain. - 3. call lookfor. (It sets some content to FVAR slot) - 4. get some address by caluculation of content of FVAR slot. - 5. set the address to TopOfStack. + 1. save TopOfStack to evaluation stack. + 2. set address of searching FVAR slot to chain. + 3. call lookfor. (It sets some content to FVAR slot) + 4. get some address by caluculation of content of FVAR slot. + 5. set the address to TopOfStack. **************************************************************************/ LispPTR N_OP_fvarn(register int n) - /* n is word offset */ - - { - register DLword *chain; /* keep FVAR slot2 in CurrentFrameExtension */ +/* n is word offset */ + +{ + register DLword *chain; /* keep FVAR slot2 in CurrentFrameExtension */ chain = PVar + n; - if(WBITSPTR(chain)->LSB) - { - /* check 15bit of FVAR slot1 in CurrentFrameExtension. - 0: bound - 1: unbound */ - nfvlookup(CURRENTFX, chain, FuncObj); - } - - return(GetLongWord(Addr68k_from_LADDR(POINTERMASK & - (((GETBASEWORD(chain,1))<<16) | - GETBASEWORD(chain,0))))); + if (WBITSPTR(chain)->LSB) { + /* check 15bit of FVAR slot1 in CurrentFrameExtension. + 0: bound + 1: unbound */ + nfvlookup(CURRENTFX, chain, FuncObj); } - - + return (GetLongWord( + Addr68k_from_LADDR(POINTERMASK & (((GETBASEWORD(chain, 1)) << 16) | GETBASEWORD(chain, 0))))); +} /****************************************************************************** N_OP_stkscan - entry STKSCAN OPCODE[057] + entry STKSCAN OPCODE[057] - <> - TopOfStack: Low word - Atom index number of variable to be saned. - <> - TopOfStack: Address of found value. + <> + TopOfStack: Low word - Atom index number of variable to be saned. + <> + TopOfStack: Address of found value. - 1. call fvlookup. - 2. Set *chain to TopOfStack. - 3. Increment Pc by 1. + 1. call fvlookup. + 2. Set *chain to TopOfStack. + 3. Increment Pc by 1. ******************************************************************************/ -LispPTR N_OP_stkscan(LispPTR tos) -{ +LispPTR N_OP_stkscan(LispPTR tos) { #ifdef I386 - int scratchx[3]; - int *scratch = (int *)(0xFFFFFFFC & (3+(UNSIGNED)scratchx)); - *scratch = tos; - nnewframe(CURRENTFX, (DLword *)scratch, POINTERMASK & *scratch ); - return(swapx(*scratch)); + int scratchx[3]; + int *scratch = (int *)(0xFFFFFFFC & (3 + (UNSIGNED)scratchx)); + *scratch = tos; + nnewframe(CURRENTFX, (DLword *)scratch, POINTERMASK & *scratch); + return (swapx(*scratch)); #else - int scratch; - scratch = tos; - nnewframe(CURRENTFX, (DLword *)&scratch, POINTERMASK & scratch ); - return(swapx(scratch)); + int scratch; + scratch = tos; + nnewframe(CURRENTFX, (DLword *)&scratch, POINTERMASK & scratch); + return (swapx(scratch)); #endif /* I386 */ - - } - - - +} /************************************************** N_OP_fvar_ - Entry: FVAR_ opcode[0143] + Entry: FVAR_ opcode[0143] ***************************************************/ -LispPTR N_OP_fvar_(register LispPTR tos, register int n) -{ - register DLword *ppvar; /* pointer to argued Fvar slot in pvar area */ - register DLword *pfreeval; /* pointer to argued free value */ - register int l1; /* return value of fvlookup() */ +LispPTR N_OP_fvar_(register LispPTR tos, register int n) { + register DLword *ppvar; /* pointer to argued Fvar slot in pvar area */ + register DLword *pfreeval; /* pointer to argued free value */ + register int l1; /* return value of fvlookup() */ - ppvar = PVar + n; + ppvar = PVar + n; - if(WBITSPTR(ppvar)->LSB) /* check unbound ? */ - { /* unbound */ - nfvlookup(CURRENTFX, ppvar, FuncObj); - } - - pfreeval =Addr68k_from_LADDR( MaskShift((GETWORD(ppvar+1))) | - GETWORD(ppvar) ); - - if( ((0xFF & GETWORD(ppvar+1)) != STK_HI)) - { - GCLOOKUP(*((LispPTR *)pfreeval), DELREF); - GCLOOKUP(tos, ADDREF); - } - - *((LispPTR *)pfreeval) = tos; - return(tos); + if (WBITSPTR(ppvar)->LSB) /* check unbound ? */ + { /* unbound */ + nfvlookup(CURRENTFX, ppvar, FuncObj); } + pfreeval = Addr68k_from_LADDR(MaskShift((GETWORD(ppvar + 1))) | GETWORD(ppvar)); + + if (((0xFF & GETWORD(ppvar + 1)) != STK_HI)) { + GCLOOKUP(*((LispPTR *)pfreeval), DELREF); + GCLOOKUP(tos, ADDREF); + } + + *((LispPTR *)pfreeval) = tos; + return (tos); +} + #ifndef BIGATOMS #ifdef SUN3_OS3_OR_OS4_IL -#define VALS_HI_RET(x) newframe_vals_hi_ret(x) -#define STK_HI_RET(x) newframe_stk_hi_ret(x) +#define VALS_HI_RET(x) newframe_vals_hi_ret(x) +#define STK_HI_RET(x) newframe_stk_hi_ret(x) #else -#define VALS_HI_RET(x) \ - ((int) (x) << 17) + VALS_HI + ((unsigned short) (x) >> 15) +#define VALS_HI_RET(x) ((int)(x) << 17) + VALS_HI + ((unsigned short)(x) >> 15) -#define STK_HI_RET(x) \ - ((int) (x) << 16) | 1 | ((unsigned int) (x) >> 16) +#define STK_HI_RET(x) ((int)(x) << 16) | 1 | ((unsigned int)(x) >> 16) #endif /* SUN3_IL */ #else #ifdef BIGVM -#define VALS_HI_RET(x) ((((int) (x) & SEGMASK) == 0) ? \ - (swapx((ATOMS_HI<<16) + (10 * (int) (x)) + NEWATOM_VALUE_OFFSET)) : \ - (swapx((int)(x) + NEWATOM_VALUE_OFFSET))) +#define VALS_HI_RET(x) \ + ((((int)(x)&SEGMASK) == 0) ? (swapx((ATOMS_HI << 16) + (10 * (int)(x)) + NEWATOM_VALUE_OFFSET)) \ + : (swapx((int)(x) + NEWATOM_VALUE_OFFSET))) #else -#define VALS_HI_RET(x) ((((int)(x)& SEGMASK) == 0) ? \ - (((int)(x) << 17) + VALS_HI + ((unsigned short)(x) >> 15)) : \ - (swapx((int)(x) + NEWATOM_VALUE_OFFSET))) +#define VALS_HI_RET(x) \ + ((((int)(x)&SEGMASK) == 0) ? (((int)(x) << 17) + VALS_HI + ((unsigned short)(x) >> 15)) \ + : (swapx((int)(x) + NEWATOM_VALUE_OFFSET))) #endif /* BIGVM */ -#define STK_HI_RET(x) ((int)(x) << 16) | 1 | ((unsigned int)(x) >> 16) +#define STK_HI_RET(x) ((int)(x) << 16) | 1 | ((unsigned int)(x) >> 16) #endif /* BIGATOMS */ - - - - /****************************************************************************** native_newframe - 1. scan Name table in new function header. - 2. if found, set address of searching variable to chain address. - 3. return the pointer + 1. scan Name table in new function header. + 2. if found, set address of searching variable to chain address. + 3. return the pointer ******************************************************************************/ LispPTR native_newframe(int slot) - /* index of FVAR slot. */ +/* index of FVAR slot. */ +{ + register struct frameex2 *newpfra2; /* pointer to new frame extension */ + register DLword *achain; /* pointer to 1st word of the searching + FVAR slot in CurrentFrameExtension */ + register int name; /* Atom# of target FVAR slot. */ + struct frameex2 *onewpfra2, *oonewpfra2, *ooonewpfra2; + + { /* LOCAL temp regs */ + register int rslot = slot; + register struct fnhead *fnobj = FuncObj; + register LispPTR *pvar = (LispPTR *)PVar; + +#ifdef BIGATOMS + name = (int)*((LispPTR *)((DLword *)fnobj + fnobj->fvaroffset) + rslot - fnobj->nlocals); +#else + name = GETWORD((DLword *)fnobj + (fnobj->fvaroffset + rslot - fnobj->nlocals)); +#endif + + newpfra2 = (struct frameex2 *)((DLword *)pvar - FRAMESIZE); + achain = (DLword *)(pvar + rslot); + } + { - register struct frameex2 *newpfra2; /* pointer to new frame extension */ - register DLword *achain; /* pointer to 1st word of the searching - FVAR slot in CurrentFrameExtension */ - register int name; /* Atom# of target FVAR slot. */ -struct frameex2 *onewpfra2, *oonewpfra2, *ooonewpfra2; + register NAMETABLE *pindex; /* index to indexs of new name table */ + register int i; /* temp for control */ + register int nametablesize; /* NameTable size of current fnhdr */ + register int alink; - { /* LOCAL temp regs */ - register int rslot = slot; - register struct fnhead *fnobj = FuncObj; - register LispPTR *pvar = (LispPTR *) PVar; - -#ifdef BIGATOMS - name = (int) *((LispPTR *) - ((DLword *)fnobj + fnobj->fvaroffset) - + rslot - fnobj->nlocals); -#else - name = GETWORD((DLword *)fnobj + - (fnobj->fvaroffset + rslot - fnobj->nlocals)); -#endif - - newpfra2 = (struct frameex2 *) ((DLword *) pvar - FRAMESIZE); - achain = (DLword *) (pvar + rslot); - - } - - { - register NAMETABLE *pindex; /* index to indexs of new name table */ - register int i; /* temp for control */ - register int nametablesize; /* NameTable size of current fnhdr */ - register int alink; - -natnewframe: + natnewframe: #ifdef SUN3_OS3_OR_OS4_IL - natnewframe_label(); + natnewframe_label(); #endif - /* assume that apframe1 points to the next frame to be scanned */ + /* assume that apframe1 points to the next frame to be scanned */ - alink = newpfra2->alink; -if (alink == 0) error("alink is 0 in native_newframe"); - if(alink == ENDSTACKMARK) - { /* End of stack, so return top-level-value */ -/* if (name & SEGMASK) printf("native_newframe returning name 0x%x, result 0x%x.\n", - name, VALS_HI_RET(name)); */ - return(*((LispPTR *)achain) = VALS_HI_RET(name)); - } -ooonewpfra2 = oonewpfra2; -oonewpfra2 = onewpfra2; -onewpfra2 = newpfra2; - newpfra2 = (struct frameex2 *)(-FRAMESIZE + Stackspace + (alink & 0xFFFE)); + alink = newpfra2->alink; + if (alink == 0) error("alink is 0 in native_newframe"); + if (alink == ENDSTACKMARK) { /* End of stack, so return top-level-value */ + /* if (name & SEGMASK) printf("native_newframe returning name 0x%x, result + 0x%x.\n", + name, VALS_HI_RET(name)); */ + return (*((LispPTR *)achain) = VALS_HI_RET(name)); + } + ooonewpfra2 = oonewpfra2; + oonewpfra2 = onewpfra2; + onewpfra2 = newpfra2; + newpfra2 = (struct frameex2 *)(-FRAMESIZE + Stackspace + (alink & 0xFFFE)); + { /* open new block to try and conserve address register */ + register struct fnhead *newpfn2; /* ptr to new fn header */ - { /* open new block to try and conserve address register */ - register struct fnhead *newpfn2; /* ptr to new fn header */ + newpfn2 = GETNAMETABLE(newpfra2); - newpfn2 = GETNAMETABLE(newpfra2); - - pindex = (NAMETABLE *)(((DLword *)newpfn2) + FNHEADSIZE); - /* now pindex points 1st word of Nametable. */ + pindex = (NAMETABLE *)(((DLword *)newpfn2) + FNHEADSIZE); +/* now pindex points 1st word of Nametable. */ #ifdef BIGATOMS - nametablesize = (newpfn2->ntsize >> 1); /* ntsize is # of words in NT - nametablesize is # of items in NT */ + nametablesize = (newpfn2->ntsize >> 1); /* ntsize is # of words in NT + nametablesize is # of items in NT */ #else - nametablesize = newpfn2->ntsize; + nametablesize = newpfn2->ntsize; #endif /* */ - - } + } #ifdef SUN4_OS4_IL - i = (UNSIGNED) (pindex + nametablesize); -lookup: + i = (UNSIGNED)(pindex + nametablesize); + lookup: #ifdef BIGATOMS - pindex = (LispPTR *) name_scan2((UNSIGNED)pindex, i, name); + pindex = (LispPTR *)name_scan2((UNSIGNED)pindex, i, name); #else - pindex = (DLword *) name_scan((UNSIGNED)pindex, i, name | (name<<16)); + pindex = (DLword *)name_scan((UNSIGNED)pindex, i, name | (name << 16)); #endif - if (!pindex) goto natnewframe; + if (!pindex) goto natnewframe; + { { - { #else #ifdef SUN3_OS3_OR_OS4_IL - i = nametablesize; - if (--i < 0) goto natnewframe; + i = nametablesize; + if (--i < 0) goto natnewframe; - - /* **** assumes: - d7 = name - d6 = i - a3 = pindex - *** */ +/* **** assumes: + d7 = name + d6 = i + a3 = pindex +*** */ #ifdef BIGATOMS -lookup: fvar_lookup_loop2(); + lookup: + fvar_lookup_loop2(); #else -lookup: fvar_lookup_loop(); + lookup: + fvar_lookup_loop(); #endif -{ -{ + { + { #else - for(i=nametablesize; --i >= 0;){ - /* searching in NewFuncHeader */ + for (i = nametablesize; --i >= 0;) { +/* searching in NewFuncHeader */ #ifdef BIGATOMS - if((LispPTR) *((NAMETABLE *)pindex++) == (LispPTR)name){ + if ((LispPTR) * ((NAMETABLE *)pindex++) == (LispPTR)name) { #else - if(GETWORD((NAMETABLE *)pindex++) == (DLword)name){ + if (GETWORD((NAMETABLE *)pindex++) == (DLword)name) { #endif /* BIGATOMS */ #endif #endif - register int fvartype; /* probing fvar vartype */ - register int fvaroffset; /* probing fvar varoffset */ - register DLword *ppvar; /* ptr to probing var candidate */ + register int fvartype; /* probing fvar vartype */ + register int fvaroffset; /* probing fvar varoffset */ + register DLword *ppvar; /* ptr to probing var candidate */ #ifdef BIGATOMS - fvartype = (int) *(pindex + nametablesize - 1); + fvartype = (int)*(pindex + nametablesize - 1); #else - fvartype = GETWORD(pindex + nametablesize - 1); + fvartype = GETWORD(pindex + nametablesize - 1); #endif /* BIGATOMS */ - fvaroffset = (NT_OFFSET_MASK & fvartype) << 1; - fvartype &= NT_TYPE_MASK; - switch( fvartype ){ - case FVPVARHI: /* 0x8000 or 0x80000000(NEWATOM): */ - ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; - /* ppvar points to argued Pvar */ - if(WBITSPTR(ppvar)->xMSB) - /* check UNBOUND (if *ppvar is negative , unbound) */ + fvaroffset = (NT_OFFSET_MASK & fvartype) << 1; + fvartype &= NT_TYPE_MASK; + switch (fvartype) { + case FVPVARHI: /* 0x8000 or 0x80000000(NEWATOM): */ + ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; + /* ppvar points to argued Pvar */ + if (WBITSPTR(ppvar)->xMSB) /* check UNBOUND (if *ppvar is negative , unbound) */ #ifdef SUN4_OS4_IL - goto lookup; + goto lookup; #else #ifdef SUN3_OS3_OR_OS4_IL - goto lookup; + goto lookup; #else - { - continue; - } + { + continue; + } #endif #endif - /* save High word of PVAR slot address to FVAR slot */ - /* achain points to target FVAR slot */ - return(*((LispPTR *)achain) = - STK_HI_RET( LADDR_from_68k( ppvar ))); - case FVFVARHI: /* 0xC000 or 0xC0000000(NEWATOM S) */ - ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; - if( WBITSPTR(ppvar)->LSB ) - { - goto endlookfor; - } - /* Not Found in new FuncHeader, scan next one. */ - /* save address of frame extension to FVAR slot */ - /* achain points to target FVAR slot */ - return(*((int *)achain) = *((int *)ppvar)); - case FVIVARHI: /* 0x0000000: */ - ppvar = (DLword *)newpfra2 - 1; - /* ppvar points to IVAR field in Basic frame */ - return(*((LispPTR *)achain) = - STK_HI_RET(GETWORD(ppvar)+fvaroffset));; - default:error("Stack corrupted: bad value in name table"); - }/* end switch */ - }/* end if */ - }/* end for */ + /* save High word of PVAR slot address to FVAR slot */ + /* achain points to target FVAR slot */ + return (*((LispPTR *)achain) = STK_HI_RET(LADDR_from_68k(ppvar))); + case FVFVARHI: /* 0xC000 or 0xC0000000(NEWATOM S) */ + ppvar = FRAMESIZE + (DLword *)newpfra2 + fvaroffset; + if (WBITSPTR(ppvar)->LSB) { goto endlookfor; } + /* Not Found in new FuncHeader, scan next one. */ + /* save address of frame extension to FVAR slot */ + /* achain points to target FVAR slot */ + return (*((int *)achain) = *((int *)ppvar)); + case FVIVARHI: /* 0x0000000: */ + ppvar = (DLword *)newpfra2 - 1; + /* ppvar points to IVAR field in Basic frame */ + return (*((LispPTR *)achain) = STK_HI_RET(GETWORD(ppvar) + fvaroffset)); + ; + default: error("Stack corrupted: bad value in name table"); + } /* end switch */ + } /* end if */ + } /* end for */ -endlookfor: - goto natnewframe; /* scan the next one */ -} + endlookfor: + goto natnewframe; /* scan the next one */ + } } diff --git a/src/gc.c b/src/gc.c old mode 100755 new mode 100644 index 1dbd65b..ec3ba30 --- a/src/gc.c +++ b/src/gc.c @@ -1,8 +1,6 @@ /* $Id: gc.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: gc.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +15,6 @@ static char *id = "$Id: gc.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright #include "version.h" - #include #include "lispemul.h" #include "lspglob.h" @@ -26,27 +23,25 @@ static char *id = "$Id: gc.c,v 1.3 1999/05/31 23:35:29 sybalsky Exp $ Copyright #include "gc.h" /************************************************************ - - entry OP_gcref OPCODE[025] - 1. alpha is ADDREF or DELREF, STKREF. - TopOfStack is argued slot address. - 2. call gclookup with alpha and TopOfStack. - 3. if stk=0 and refcnt=0 of entry of HashMainTable, - TopOfStack left alone. - else replace TopOfStack with 0. - 4. increment PC by 2. + entry OP_gcref OPCODE[025] + + 1. alpha is ADDREF or DELREF, STKREF. + TopOfStack is argued slot address. + 2. call gclookup with alpha and TopOfStack. + 3. if stk=0 and refcnt=0 of entry of HashMainTable, + TopOfStack left alone. + else replace TopOfStack with 0. + 4. increment PC by 2. ***********************************************************/ - -void OP_gcref(void) -{ -#ifdef TRACE - printPC(); - printf("TRACE:OP_gcref()\n"); -#endif - GCLOOKUPV(TopOfStack, Get_code_BYTE(PC+1), TopOfStack); - PC+=2; - return; -} +void OP_gcref(void) { +#ifdef TRACE + printPC(); + printf("TRACE:OP_gcref()\n"); +#endif + GCLOOKUPV(TopOfStack, Get_code_BYTE(PC + 1), TopOfStack); + PC += 2; + return; +} diff --git a/src/gc2.c b/src/gc2.c old mode 100755 new mode 100644 index 2c802d2..5be1472 --- a/src/gc2.c +++ b/src/gc2.c @@ -1,8 +1,6 @@ /* $Id: gc2.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: gc2.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,17 +15,16 @@ static char *id = "$Id: gc2.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright #include "version.h" - /**********************************************************************/ /* - File Name: gc2.c - Desc: implement opcode SCAN1,SCAN2,GCRECLAIMCELL - - - Including : OP_scan1 - OP_scan2 - OP_gcreccell - + File Name: gc2.c + Desc: implement opcode SCAN1,SCAN2,GCRECLAIMCELL + + + Including : OP_scan1 + OP_scan2 + OP_gcreccell + */ /**********************************************************************/ @@ -43,54 +40,38 @@ static char *id = "$Id: gc2.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright #include "inlnPS2.h" #endif /* GCC386 */ - - - - /**********************************************************************/ /* - Func Name : OP_gcscan1 + Func Name : OP_gcscan1 */ /**********************************************************************/ -void OP_gcscan1(void) -{ - DLword gcscan1(register int probe); +void OP_gcscan1(void) { + DLword gcscan1(register int probe); #ifdef TRACE - printPC(); - printf("TRACE: OP_gcscan1()\n"); + printPC(); + printf("TRACE: OP_gcscan1()\n"); #endif - if((TopOfStack & SEGMASK)==S_POSITIVE) - { - TopOfStack=gcscan1(LOLOC(TopOfStack)); - } - if(TopOfStack != NIL) TopOfStack |= S_POSITIVE ; - PC++; - } /* OP_gcscan1 end */ - - - + if ((TopOfStack & SEGMASK) == S_POSITIVE) { TopOfStack = gcscan1(LOLOC(TopOfStack)); } + if (TopOfStack != NIL) TopOfStack |= S_POSITIVE; + PC++; +} /* OP_gcscan1 end */ /**********************************************************************/ /* - Func Name : OP_gcscan2 + Func Name : OP_gcscan2 */ /**********************************************************************/ -void OP_gcscan2(void) -{ - DLword gcscan2(register int probe); +void OP_gcscan2(void) { + DLword gcscan2(register int probe); #ifdef TRACE - printPC(); - printf("TRACE: OP_gcscan2()\n"); + printPC(); + printf("TRACE: OP_gcscan2()\n"); #endif - if((TopOfStack & SEGMASK)==S_POSITIVE) - { - TopOfStack=gcscan2(LOLOC(TopOfStack)); - } - if(TopOfStack != NIL) TopOfStack |= S_POSITIVE ; - PC++; - } /* OP_gcscan2 end */ - + if ((TopOfStack & SEGMASK) == S_POSITIVE) { TopOfStack = gcscan2(LOLOC(TopOfStack)); } + if (TopOfStack != NIL) TopOfStack |= S_POSITIVE; + PC++; +} /* OP_gcscan2 end */ diff --git a/src/gcarray.c b/src/gcarray.c old mode 100755 new mode 100644 index 4edaa3b..f211d4b --- a/src/gcarray.c +++ b/src/gcarray.c @@ -1,9 +1,7 @@ -/* $Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ @@ -16,10 +14,8 @@ static char *id = "$Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - /*************************************************************************/ /* */ /* File Name : gcarray.c */ @@ -52,7 +48,6 @@ static char *id = "$Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyr /* \Tomtom */ /*************************************************************************/ - #include "lispemul.h" #include "lsptypes.h" #include "address.h" @@ -68,19 +63,16 @@ static char *id = "$Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyr #include /*** not currently used -FS - #define min(a,b) ((a > b)?b:a) - #define Trailer(ldatum,datum68) (ldatum+2*(datum68->arlen - ARRAYBLOCKTRAILERCELLS)) - #define BucketIndex(n) min(integerlength(n),MAXBUCKETINDEX) - #define FreeBlockChainN(n) ((POINTERMASK & *FreeBlockBuckets_word)+2*BucketIndex(n)) + #define min(a,b) ((a > b)?b:a) + #define Trailer(ldatum,datum68) (ldatum+2*(datum68->arlen - ARRAYBLOCKTRAILERCELLS)) + #define BucketIndex(n) min(integerlength(n),MAXBUCKETINDEX) + #define FreeBlockChainN(n) ((POINTERMASK & *FreeBlockBuckets_word)+2*BucketIndex(n)) ***/ -#define Rehash_factor(hash,tablelen) \ - (((hash) % ((tablelen) - 2)) + 1) -#define Symbol_hash_reprobe(hash,rehashfactor,tablelen) \ - (((hash) + (rehashfactor)) % (tablelen)) -#define Entry_hash(strlen,sxhash) \ - (((((((strlen)^(sxhash))^((sxhash) >> 8)) \ - ^((sxhash) >> 16))^((sxhash) >> 19)) % 254) + 2) +#define Rehash_factor(hash, tablelen) (((hash) % ((tablelen)-2)) + 1) +#define Symbol_hash_reprobe(hash, rehashfactor, tablelen) (((hash) + (rehashfactor)) % (tablelen)) +#define Entry_hash(strlen, sxhash) \ + (((((((strlen) ^ (sxhash)) ^ ((sxhash) >> 8)) ^ ((sxhash) >> 16)) ^ ((sxhash) >> 19)) % 254) + 2) /************************************************************************/ /* */ @@ -90,22 +82,16 @@ static char *id = "$Id: gcarray.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyr /* */ /************************************************************************/ -struct hashtable - { - LispPTR table; - LispPTR hash; - LispPTR size; - LispPTR free; - LispPTR deleted; - }; - - - +struct hashtable { + LispPTR table; + LispPTR hash; + LispPTR size; + LispPTR free; + LispPTR deleted; +}; /* The end of macros & structure for medley version */ - - /************************************************************************/ /* */ /* */ @@ -114,61 +100,50 @@ struct hashtable /* */ /************************************************************************/ -LispPTR aref1(LispPTR array, int index) -{ - register LispPTR retval; - register LispPTR base; - register short typenumber; - register struct arrayheader *actarray; +LispPTR aref1(LispPTR array, int index) { + register LispPTR retval; + register LispPTR base; + register short typenumber; + register struct arrayheader *actarray; - actarray = (struct arrayheader *)Addr68k_from_LADDR(array); - if (index >= actarray->totalsize) - { - printf("Invalid index in GC's AREF1: 0x%x\n", index); - printf(" Array size limit: 0x%x\n", actarray->totalsize); - printf(" Array ptr: 0x%x\n", (UNSIGNED)array); - printf(" Array 68K ptr: 0x%x\n", (UNSIGNED) actarray); - printf("base: 0x%x\n", actarray->base); - printf("offset: 0x%x\n", actarray->offset); - printf("type #: 0x%x\n", actarray->typenumber); - printf("fill ptr: 0x%x\n", actarray->fillpointer); - error("index out of range in GC's AREF1."); - } - index += actarray->offset; - typenumber = actarray->typenumber; - base = actarray->base; - switch(typenumber) - { - case 3: /* unsigned 8bits */ - /* the following code confuses the Apollo compiler; */ - /* its equivalent doesn't */ -#ifndef APOLLO - retval = (GETBYTE(((char *)Addr68k_from_LADDR(base)) - + index)) & 0x0ff; -#else - { - register char *eightbitbase = - (char *)Addr68k_from_LADDR(base); - retval = GETBYTE(eightbitbase + index) & 0xff; - } -#endif - retval |= S_POSITIVE; - break; - case 4: /* unsigned 16bits */ - retval = (GETWORD(((DLword *)Addr68k_from_LADDR(base)) - + index)) & 0x0ffff; - retval |= S_POSITIVE; - break; - case 38: - retval = (*(((LispPTR *)Addr68k_from_LADDR(base)) - + index)); - break; - default: error("Not Implemented in gc's aref1 (other types)"); - }; - return(retval); + actarray = (struct arrayheader *)Addr68k_from_LADDR(array); + if (index >= actarray->totalsize) { + printf("Invalid index in GC's AREF1: 0x%x\n", index); + printf(" Array size limit: 0x%x\n", actarray->totalsize); + printf(" Array ptr: 0x%x\n", (UNSIGNED)array); + printf(" Array 68K ptr: 0x%x\n", (UNSIGNED)actarray); + printf("base: 0x%x\n", actarray->base); + printf("offset: 0x%x\n", actarray->offset); + printf("type #: 0x%x\n", actarray->typenumber); + printf("fill ptr: 0x%x\n", actarray->fillpointer); + error("index out of range in GC's AREF1."); } - - + index += actarray->offset; + typenumber = actarray->typenumber; + base = actarray->base; + switch (typenumber) { + case 3: /* unsigned 8bits */ +/* the following code confuses the Apollo compiler; */ +/* its equivalent doesn't */ +#ifndef APOLLO + retval = (GETBYTE(((char *)Addr68k_from_LADDR(base)) + index)) & 0x0ff; +#else + { + register char *eightbitbase = (char *)Addr68k_from_LADDR(base); + retval = GETBYTE(eightbitbase + index) & 0xff; + } +#endif + retval |= S_POSITIVE; + break; + case 4: /* unsigned 16bits */ + retval = (GETWORD(((DLword *)Addr68k_from_LADDR(base)) + index)) & 0x0ffff; + retval |= S_POSITIVE; + break; + case 38: retval = (*(((LispPTR *)Addr68k_from_LADDR(base)) + index)); break; + default: error("Not Implemented in gc's aref1 (other types)"); + }; + return (retval); +} /************************************************************************/ /* */ @@ -178,110 +153,101 @@ LispPTR aref1(LispPTR array, int index) /* */ /************************************************************************/ -LispPTR find_symbol(char *char_base, DLword offset, DLword length, LispPTR hashtbl, DLword fatp, DLword lispp) - - - - - /* T => the "chars" coming in are 16-bit */ - /* T => the incoming chars are in LISP space */ - { - DLword hashval, ehashval, h2, ehash, indexvar; - int arraylen; - struct hashtable *hashtbladdr; +LispPTR find_symbol(char *char_base, DLword offset, DLword length, LispPTR hashtbl, DLword fatp, + DLword lispp) + +/* T => the "chars" coming in are 16-bit */ +/* T => the incoming chars are in LISP space */ +{ + DLword hashval, ehashval, h2, ehash, indexvar; + int arraylen; + struct hashtable *hashtbladdr; #ifdef BIGATOMS - LispPTR vecs, hashes; + LispPTR vecs, hashes; #endif /* BIGATOMS */ - LispPTR vec,hash; - struct arrayheader *vec68k; - int fatpnamep; + LispPTR vec, hash; + struct arrayheader *vec68k; + int fatpnamep; - if (!hashtbl) return(0xffffffff); + if (!hashtbl) return (0xffffffff); - if (lispp) hashval = compute_lisp_hash(char_base, offset, length, fatp); - else hashval = compute_hash(char_base, offset, length); + if (lispp) + hashval = compute_lisp_hash(char_base, offset, length, fatp); + else + hashval = compute_hash(char_base, offset, length); - ehashval = Entry_hash(length, hashval); - hashtbladdr = (struct hashtable *)Addr68k_from_LADDR(hashtbl); - - /* Move our string ptr up by offset, allowing for fatness */ - if (fatp) char_base += (offset << 1); else char_base += offset; + ehashval = Entry_hash(length, hashval); + hashtbladdr = (struct hashtable *)Addr68k_from_LADDR(hashtbl); + /* Move our string ptr up by offset, allowing for fatness */ + if (fatp) + char_base += (offset << 1); + else + char_base += offset; #ifdef BIGATOMS - vecs = hashtbladdr->table; - hashes = hashtbladdr->hash; + vecs = hashtbladdr->table; + hashes = hashtbladdr->hash; loop_thru_hashtables: - vec = car(vecs); - vecs = cdr(vecs); - hash = car(hashes); - hashes = cdr(hashes); - vec68k = (struct arrayheader *)Addr68k_from_LADDR(vec); - arraylen = vec68k->totalsize; - if(arraylen==0) return(0xffffffff);/*kludge TAKE*/ - h2 = Rehash_factor(hashval, arraylen); - indexvar = (hashval % arraylen); + vec = car(vecs); + vecs = cdr(vecs); + hash = car(hashes); + hashes = cdr(hashes); + vec68k = (struct arrayheader *)Addr68k_from_LADDR(vec); + arraylen = vec68k->totalsize; + if (arraylen == 0) return (0xffffffff); /*kludge TAKE*/ + h2 = Rehash_factor(hashval, arraylen); + indexvar = (hashval % arraylen); #else - vec = hashtbladdr->table; - hash = hashtbladdr->hash; - vec68k = (struct arrayheader *)Addr68k_from_LADDR(vec); - arraylen = vec68k->totalsize; - if(arraylen==0) return(0xffffffff);/*kludge TAKE*/ - h2 = Rehash_factor(hashval, arraylen); - indexvar = (hashval % arraylen); + vec = hashtbladdr->table; + hash = hashtbladdr->hash; + vec68k = (struct arrayheader *)Addr68k_from_LADDR(vec); + arraylen = vec68k->totalsize; + if (arraylen == 0) return (0xffffffff); /*kludge TAKE*/ + h2 = Rehash_factor(hashval, arraylen); + indexvar = (hashval % arraylen); #endif /* BIGATOMS */ - retry: - /* the aref1 returns a smallp, which is always <256, so trim it */ - while (ehashval != (ehash = 0xFF & aref1(hash, indexvar))) - { - if(ehash==NIL) - { /* Ran out of entries in this table; try next or fail */ + /* the aref1 returns a smallp, which is always <256, so trim it */ + while (ehashval != (ehash = 0xFF & aref1(hash, indexvar))) { + if (ehash == NIL) { /* Ran out of entries in this table; try next or fail */ #ifdef BIGATOMS - if (hashes == NIL) return(0xffffffff); /* Last table. Fail. */ - goto loop_thru_hashtables; + if (hashes == NIL) return (0xffffffff); /* Last table. Fail. */ + goto loop_thru_hashtables; #else - return(0xffffffff); + return (0xffffffff); #endif /* BIGATOMS */ - - } - indexvar = Symbol_hash_reprobe(indexvar, h2, arraylen); } - /* if ((indexvar&0xffff) != NIL) */ - { - LispPTR index; - PNCell *pnptr; - char *pname_base; - - index = aref1(vec, indexvar); - if ((index & SEGMASK) == S_POSITIVE) index &= 0xFFFF; - - pnptr = (PNCell *)GetPnameCell(index); - fatpnamep = ((PLCell *)GetPropCell(index))->fatpnamep; - pname_base= (char *)Addr68k_from_LADDR(pnptr->pnamebase); - if((length == GETBYTE(pname_base)) && - (T == ((lispp) ? - compare_lisp_chars((pname_base+1+fatpnamep), char_base, - length, fatpnamep, fatp) : - compare_chars((pname_base+1+fatpnamep), char_base, length))) ) - { - return(index); - } - else - { - indexvar = Symbol_hash_reprobe(indexvar, h2, arraylen); - goto retry; - } - } - /* else return(0xffffffff); */ /* can't find */ + indexvar = Symbol_hash_reprobe(indexvar, h2, arraylen); } + /* if ((indexvar&0xffff) != NIL) */ + { + LispPTR index; + PNCell *pnptr; + char *pname_base; + index = aref1(vec, indexvar); + if ((index & SEGMASK) == S_POSITIVE) index &= 0xFFFF; - + pnptr = (PNCell *)GetPnameCell(index); + fatpnamep = ((PLCell *)GetPropCell(index))->fatpnamep; + pname_base = (char *)Addr68k_from_LADDR(pnptr->pnamebase); + if ((length == GETBYTE(pname_base)) && + (T == ((lispp) ? compare_lisp_chars((pname_base + 1 + fatpnamep), char_base, length, + fatpnamep, fatp) + : compare_chars((pname_base + 1 + fatpnamep), char_base, length)))) { + return (index); + } else { + indexvar = Symbol_hash_reprobe(indexvar, h2, arraylen); + goto retry; + } + } + /* else return(0xffffffff); */ /* can't find */ +} /************************************************************************/ /* */ @@ -294,54 +260,50 @@ retry: /* */ /************************************************************************/ -LispPTR get_package_atom(char *char_base, DLword charlen, char *packname, DLword packlen, int externalp) -{ - int packindex; - PACKAGE *packaddr; - LispPTR hashtbladdr; - LispPTR index; - extern LispPTR find_package_from_name(char *packname, int len); +LispPTR get_package_atom(char *char_base, DLword charlen, char *packname, DLword packlen, + int externalp) { + int packindex; + PACKAGE *packaddr; + LispPTR hashtbladdr; + LispPTR index; + extern LispPTR find_package_from_name(char *packname, int len); - /* For convenience, recognize the common package nicknames: */ + /* For convenience, recognize the common package nicknames: */ - if (0 == strncmp(packname, "XCL", packlen)) - packindex = find_package_from_name("XEROX-COMMON-LISP",17); - else if (0 == strncmp(packname, "SI", packlen)) - packindex = find_package_from_name("SYSTEM",6); - else if (0 == strncmp(packname, "CL", packlen)) - packindex = find_package_from_name("LISP",4); - else if (0 == strncmp(packname, "XCLC", packlen)) - packindex = find_package_from_name("COMPILER",8); + if (0 == strncmp(packname, "XCL", packlen)) + packindex = find_package_from_name("XEROX-COMMON-LISP", 17); + else if (0 == strncmp(packname, "SI", packlen)) + packindex = find_package_from_name("SYSTEM", 6); + else if (0 == strncmp(packname, "CL", packlen)) + packindex = find_package_from_name("LISP", 4); + else if (0 == strncmp(packname, "XCLC", packlen)) + packindex = find_package_from_name("COMPILER", 8); -/**** else if (0 == strncmp(packname, "KEYWORD", packlen)) - packindex = 7;***/ + /**** else if (0 == strncmp(packname, "KEYWORD", packlen)) + packindex = 7;***/ - else packindex=find_package_from_name(packname, packlen); + else + packindex = find_package_from_name(packname, packlen); - if (packindex <0) - { - printf("getting package index is failed \n"); - return(0xffffffff); - } + if (packindex < 0) { + printf("getting package index is failed \n"); + return (0xffffffff); + } -/* if (packindex != 7) Not necessary (Take)*/ - packaddr = (PACKAGE *)Addr68k_from_LADDR( - aref1(*Package_from_Index_word, packindex)); -/* else packaddr = (PACKAGE *)Addr68k_from_LADDR( - *Keyword_Package_word); */ -/* hashtbladdr = ((externalp == T)?(packaddr->EXTERNAL_SYMBOLS): - (packaddr->INTERNAL_SYMBOLS)); - return( find_symbol(char_base, 0, charlen, hashtbladdr, 0, 0) );*/ - - if ((index=find_symbol(char_base, 0, charlen,packaddr->EXTERNAL_SYMBOLS, 0, 0)) != - 0xffffffff) - return(index); - else - return(find_symbol(char_base, 0, charlen,packaddr->INTERNAL_SYMBOLS, 0, 0)); + /* if (packindex != 7) Not necessary (Take)*/ + packaddr = (PACKAGE *)Addr68k_from_LADDR(aref1(*Package_from_Index_word, packindex)); + /* else packaddr = (PACKAGE *)Addr68k_from_LADDR( + *Keyword_Package_word); */ + /* hashtbladdr = ((externalp == T)?(packaddr->EXTERNAL_SYMBOLS): + (packaddr->INTERNAL_SYMBOLS)); + return( find_symbol(char_base, 0, charlen, hashtbladdr, 0, 0) );*/ + if ((index = find_symbol(char_base, 0, charlen, packaddr->EXTERNAL_SYMBOLS, 0, 0)) != 0xffffffff) + return (index); + else + return (find_symbol(char_base, 0, charlen, packaddr->INTERNAL_SYMBOLS, 0, 0)); } - /************************************************************************/ /* */ /* */ @@ -350,23 +312,22 @@ LispPTR get_package_atom(char *char_base, DLword charlen, char *packname, DLword /* */ /************************************************************************/ -LispPTR with_symbol(LispPTR char_base, LispPTR offset, LispPTR charlen, LispPTR fatp, LispPTR hashtbl, LispPTR result) -{ - char * charbase68k = (char *) Addr68k_from_LADDR(char_base); - LispPTR *resultptr = (LispPTR *) Addr68k_from_LADDR(result); - DLword chars = charlen & 0xFFFF; /* charlen must be a SMALLP! */ - DLword offst = offset & 0xFFFF; - int symbol; /* Where the symbol goes pro tem */ - - symbol = find_symbol(charbase68k, offst, chars, hashtbl, (DLword)fatp, (DLword)1); +LispPTR with_symbol(LispPTR char_base, LispPTR offset, LispPTR charlen, LispPTR fatp, + LispPTR hashtbl, LispPTR result) { + char *charbase68k = (char *)Addr68k_from_LADDR(char_base); + LispPTR *resultptr = (LispPTR *)Addr68k_from_LADDR(result); + DLword chars = charlen & 0xFFFF; /* charlen must be a SMALLP! */ + DLword offst = offset & 0xFFFF; + int symbol; /* Where the symbol goes pro tem */ - if (symbol == -1) - { /* Not found. Signal that with -1 in result fixp */ - *resultptr = -1; - return(NIL); - } + symbol = find_symbol(charbase68k, offst, chars, hashtbl, (DLword)fatp, (DLword)1); - *resultptr = 3; - return(symbol); + if (symbol == -1) { /* Not found. Signal that with -1 in result fixp */ + *resultptr = -1; + return (NIL); + } - } /* End of with_symbol */ + *resultptr = 3; + return (symbol); + +} /* End of with_symbol */ diff --git a/src/gccode.c b/src/gccode.c old mode 100755 new mode 100644 index ed4f92f..9dd3a51 --- a/src/gccode.c +++ b/src/gccode.c @@ -1,9 +1,7 @@ -/* $Id: gccode.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gccode.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gccode.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,11 +14,8 @@ static char *id = "$Id: gccode.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyri /* */ /************************************************************************/ - #include "version.h" - - /************************************************************************/ /* File Name : gccode.c */ /* */ @@ -53,160 +48,76 @@ static char *id = "$Id: gccode.c,v 1.3 1999/05/31 23:35:30 sybalsky Exp $ Copyri #include "array.h" #include -#define min(a,b) ((a > b)?b:a) +#define min(a, b) ((a > b) ? b : a) +#define ENDOFX 0 +#define GCONST 111 -#define ENDOFX 0 -#define GCONST 111 - -#define Reprobefn(bits, index) (((bits^((bits) >> 8)) & min(63, index)) | 1) -#define Fn16bits(a, b) ((a + b) & 0x0ffff) -#define Hashingbits(item) (HILOC(item)^( \ - ((LOLOC(item) & 0x1fff) << 3)^(LOLOC(item) >> 9))) -#define Getikvalue(base, index) \ - (*( LispPTR *)Addr68k_from_LADDR(base + (index << 1))) +#define Reprobefn(bits, index) (((bits ^ ((bits) >> 8)) & min(63, index)) | 1) +#define Fn16bits(a, b) ((a + b) & 0x0ffff) +#define Hashingbits(item) (HILOC(item) ^ (((LOLOC(item) & 0x1fff) << 3) ^ (LOLOC(item) >> 9))) +#define Getikvalue(base, index) (*(LispPTR *)Addr68k_from_LADDR(base + (index << 1))) #ifndef BYTESWAP -typedef -struct implicit_key_hash_table { - LispPTR base; - unsigned last_index : 16; - unsigned num_slots : 16; - unsigned num_keys : 16; - unsigned null_slots : 16; - LispPTR key_accessor; +typedef struct implicit_key_hash_table { + LispPTR base; + unsigned last_index : 16; + unsigned num_slots : 16; + unsigned num_keys : 16; + unsigned null_slots : 16; + LispPTR key_accessor; } Ikhashtbl; #else -typedef -struct implicit_key_hash_table { - LispPTR base; - unsigned num_slots : 16; - unsigned last_index : 16; - unsigned null_slots : 16; - unsigned num_keys : 16; - LispPTR key_accessor; +typedef struct implicit_key_hash_table { + LispPTR base; + unsigned num_slots : 16; + unsigned last_index : 16; + unsigned null_slots : 16; + unsigned num_keys : 16; + LispPTR key_accessor; } Ikhashtbl; #endif - #ifdef BIGVM /* Table of opcode lengths for 4-byte atom opcode cases */ #define LONGEST_OPCODE 5 unsigned int oplength[256] = { -0,0,0,0,0,1,4,2, -4,4,4,4,4,5,0,0, -0,2,0,0,1,1,0,4, -0,0,0,0,0,0,1,0, -0,0,0,1,2,9,0,0, -9,9,9,9,0,0,0,0, -1,1,1,1,0,0,0,0, -1,1,0,0,1,1,0,0, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -4,0,1,1,0,0,0,4, -0,0,0,0,1,1,2,4, -9,0,0,0,0,0,0,0, -1,1,0,0,0,2,0,4, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -1,2,1,1,1,1,0,0, -0,0,0,0,0,0,0,0, -1,1,0,4,0,1,1,0, -1,1,2,9,0,1,1,2, -0,0,0,0,0,0,0,0, -0,0,0,0,0,1,1,0, -0,0,0,0,0,0,0,0, -0,0,0,0,1,1,0,0, -0,0,0,0,0,0,0,0, -1,0,1,1,0,0,0,0 -}; + 0, 0, 0, 0, 0, 1, 4, 2, 4, 4, 4, 4, 4, 5, 0, 0, 0, 2, 0, 0, 1, 1, 0, 4, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 1, 2, 9, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, + 4, 0, 1, 1, 0, 0, 0, 4, 0, 0, 0, 0, 1, 1, 2, 4, 9, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 2, 0, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 4, 0, 1, 1, 0, 1, 1, 2, 9, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0}; #elif defined(BIGATOMS) /* Table of opcode lengths for 3-byte atom opcode cases */ #define LONGEST_OPCODE 4 unsigned int oplength[256] = { -0,0,0,0,0,1,3,2, -3,3,3,3,3,4,0,0, -0,2,0,0,1,1,0,3, -0,0,0,0,0,0,1,0, -0,0,0,1,2,9,0,0, -9,9,9,9,0,0,0,0, -1,1,1,1,0,0,0,0, -1,1,0,0,1,1,0,0, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -3,0,1,1,0,0,0,3, -0,0,0,0,1,1,2,3, -9,0,0,0,0,0,0,0, -1,1,0,0,0,2,0,3, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -1,2,1,1,1,1,0,0, -0,0,0,0,0,0,0,0, -1,1,0,3,0,1,1,0, -1,1,2,9,0,1,1,2, -0,0,0,0,0,0,0,0, -0,0,0,0,0,1,1,0, -0,0,0,0,0,0,0,0, -0,0,0,0,1,1,0,0, -0,0,0,0,0,0,0,0, -1,0,1,1,0,0,0,0 -}; + 0, 0, 0, 0, 0, 1, 3, 2, 3, 3, 3, 3, 3, 4, 0, 0, 0, 2, 0, 0, 1, 1, 0, 3, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 1, 2, 9, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, + 3, 0, 1, 1, 0, 0, 0, 3, 0, 0, 0, 0, 1, 1, 2, 3, 9, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 2, 0, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 3, 0, 1, 1, 0, 1, 1, 2, 9, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0}; #else /* Table of opcode lengths for old, 2-byte atom opcodes. */ #define LONGEST_OPCODE 3 unsigned int oplength[256] = { -0,0,0,0,0,1,2,2, -2,2,2,2,2,3,0,0, -0,2,0,0,1,1,0,2, -0,0,0,0,0,0,1,0, -0,0,0,1,2,9,0,0, -9,9,9,9,0,0,0,0, -1,1,1,1,0,0,0,0, -1,1,0,0,1,1,0,0, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -0,0,0,0,0,0,0,1, -2,0,1,1,0,0,0,2, -0,0,0,0,1,1,2,3, -9,0,0,0,0,0,0,0, -1,1,0,0,0,2,0,3, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0, -1,2,1,1,1,1,0,0, -0,0,0,0,0,0,0,0, -1,1,0,2,0,1,1,0, -1,1,2,9,0,1,1,2, -0,0,0,0,0,0,0,0, -0,0,0,0,0,1,1,0, -0,0,0,0,0,0,0,0, -0,0,0,0,1,1,0,0, -0,0,0,0,0,0,0,0, -1,0,1,1,0,0,0,0 -}; + 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 2, 0, 0, 1, 1, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 1, 2, 9, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, + 2, 0, 1, 1, 0, 0, 0, 2, 0, 0, 0, 0, 1, 1, 2, 3, 9, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 2, 0, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 2, 0, 1, 1, 0, 1, 1, 2, 9, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0}; #endif /* BIGATOMS */ - typedef ByteCode *InstPtr; - - /************************************************************************/ /* */ /* m a p _ c o d e _ p o i n t e r s */ @@ -218,55 +129,53 @@ typedef ByteCode *InstPtr; /* */ /************************************************************************/ -LispPTR map_code_pointers(LispPTR codeblock, short int casep) -{ - InstPtr codeptr; - register unsigned int opnum; - register unsigned int len; - struct fnhead *fnbase; - fnbase = (struct fnhead *) Addr68k_from_LADDR(codeblock); - codeptr = ((InstPtr) fnbase) + fnbase->startpc; +LispPTR map_code_pointers(LispPTR codeblock, short int casep) { + InstPtr codeptr; + register unsigned int opnum; + register unsigned int len; + struct fnhead *fnbase; + fnbase = (struct fnhead *)Addr68k_from_LADDR(codeblock); + codeptr = ((InstPtr)fnbase) + fnbase->startpc; #ifdef RESWAPPEDCODESTREAM - if (!fnbase->byteswapped) byte_swap_code_block(fnbase); + if (!fnbase->byteswapped) byte_swap_code_block(fnbase); #endif - while (T) - { - switch (opnum=Get_code_BYTE(codeptr)) - { - case ENDOFX: /* -X- */ - return (NIL); - case GCONST: /* GCONST */ + while (T) { + switch (opnum = Get_code_BYTE(codeptr)) { + case ENDOFX: /* -X- */ return (NIL); + case GCONST: /* GCONST */ #ifdef BIGVM - {LispPTR reclaimed = (Get_code_BYTE(codeptr + 1) << 24) | - (Get_code_BYTE(codeptr + 2) << 16) | - (Get_code_BYTE(codeptr + 3) << 8) | - Get_code_BYTE(codeptr + 4); + { + LispPTR reclaimed = (Get_code_BYTE(codeptr + 1) << 24) | + (Get_code_BYTE(codeptr + 2) << 16) | (Get_code_BYTE(codeptr + 3) << 8) | + Get_code_BYTE(codeptr + 4); #else - {LispPTR reclaimed = (Get_code_BYTE(codeptr + 1) << 16) | - (Get_code_BYTE(codeptr + 2) << 8) | - Get_code_BYTE(codeptr + 3); + { + LispPTR reclaimed = (Get_code_BYTE(codeptr + 1) << 16) | (Get_code_BYTE(codeptr + 2) << 8) | + Get_code_BYTE(codeptr + 3); #endif /* BIGVM */ - if (reclaimed != codeblock) -/* {htfind(reclaimed, casep);} */ - {REC_GCLOOKUP(reclaimed, casep);} - }; - }; - if ((len = oplength[opnum]) > LONGEST_OPCODE) - { /* len > biggest possible marks an unknown opcode */ - char errtext[200]; - sprintf(errtext, - "Unrecognized bytecode (0%o) at offset 0%o in code block x%x,x%x; continue to use UFN length", opnum, codeptr-(InstPtr)fnbase, (codeblock>>16)&0xFF, codeblock&0xFFFF); - error(errtext); - oplength[opnum] = len =(((UFN *)UFNTable) + (opnum))->byte_num; - } - codeptr += len + 1; - }; + if (reclaimed != codeblock) + /* {htfind(reclaimed, casep);} */ + { + REC_GCLOOKUP(reclaimed, casep); + } + }; + }; + if ((len = oplength[opnum]) > + LONGEST_OPCODE) { /* len > biggest possible marks an unknown opcode */ + char errtext[200]; + sprintf(errtext, + "Unrecognized bytecode (0%o) at offset 0%o in code block x%x,x%x; continue to use " + "UFN length", + opnum, codeptr - (InstPtr)fnbase, (codeblock >> 16) & 0xFF, codeblock & 0xFFFF); + error(errtext); + oplength[opnum] = len = (((UFN *)UFNTable) + (opnum))->byte_num; + } + codeptr += len + 1; + }; } - - /************************************************************************/ /* */ /* r e m i m p l i c i t k e y h a s h */ @@ -276,57 +185,47 @@ LispPTR map_code_pointers(LispPTR codeblock, short int casep) /************************************************************************/ /* JRB - These values are xpointers; their high bytes are not set and - shouldn't be looked at */ + shouldn't be looked at */ #define getikkey(value) ((*(LispPTR *)Addr68k_from_LADDR(value)) & POINTERMASK) -LispPTR remimplicitkeyhash(LispPTR item, LispPTR ik_hash_table) -{Ikhashtbl *ik_htable; - LispPTR reprobe, bits, limits, index, - base, value, key_accessor; - ik_htable = (Ikhashtbl *)Addr68k_from_LADDR(ik_hash_table); - bits = Hashingbits(item); - limits = ik_htable->last_index; - index = (bits & limits); - base = ik_htable->base; - value = Getikvalue(base, index); - if (value != *Deleted_Implicit_Hash_Slot_word) - { if (value != NIL) - {if (item == - getikkey(value)) - {goto found;}; - } - else - return(NIL); - }; - reprobe = Reprobefn(bits, limits); - lp: - index = Fn16bits(index, reprobe) & limits; - value = Getikvalue(base, index); - if (value != *Deleted_Implicit_Hash_Slot_word) - { if (value != NIL) - {if (item == - getikkey(value)) - {goto found;}; - } - else - return(NIL); - }; - goto lp; - found: -/* - htfind(*Deleted_Implicit_Hash_Slot_word, ADDREF); - htfind(Getikvalue(base, index), DELREF); -*/ - REC_GCLOOKUP(*Deleted_Implicit_Hash_Slot_word, ADDREF); - REC_GCLOOKUP(Getikvalue(base, index), DELREF); - Getikvalue(base, index) = *Deleted_Implicit_Hash_Slot_word; - (ik_htable->num_keys)--; - return (T); +LispPTR remimplicitkeyhash(LispPTR item, LispPTR ik_hash_table) { + Ikhashtbl *ik_htable; + LispPTR reprobe, bits, limits, index, base, value, key_accessor; + ik_htable = (Ikhashtbl *)Addr68k_from_LADDR(ik_hash_table); + bits = Hashingbits(item); + limits = ik_htable->last_index; + index = (bits & limits); + base = ik_htable->base; + value = Getikvalue(base, index); + if (value != *Deleted_Implicit_Hash_Slot_word) { + if (value != NIL) { + if (item == getikkey(value)) { goto found; }; + } else + return (NIL); + }; + reprobe = Reprobefn(bits, limits); +lp: + index = Fn16bits(index, reprobe) & limits; + value = Getikvalue(base, index); + if (value != *Deleted_Implicit_Hash_Slot_word) { + if (value != NIL) { + if (item == getikkey(value)) { goto found; }; + } else + return (NIL); + }; + goto lp; +found: + /* + htfind(*Deleted_Implicit_Hash_Slot_word, ADDREF); + htfind(Getikvalue(base, index), DELREF); + */ + REC_GCLOOKUP(*Deleted_Implicit_Hash_Slot_word, ADDREF); + REC_GCLOOKUP(Getikvalue(base, index), DELREF); + Getikvalue(base, index) = *Deleted_Implicit_Hash_Slot_word; + (ik_htable->num_keys)--; + return (T); } - - - /************************************************************************/ /* */ /* r e c l a i m c o d e b l o c k */ @@ -340,20 +239,17 @@ LispPTR remimplicitkeyhash(LispPTR item, LispPTR ik_hash_table) /* */ /************************************************************************/ -LispPTR reclaimcodeblock(LispPTR codebase) -{ struct fnhead *fnbase; - if ((*Closure_Cache_Enabled_word != NIL) && - (remimplicitkeyhash(codebase, *Closure_Cache_word) != NIL)) - { return(T); - }; - fnbase = (struct fnhead *)Addr68k_from_LADDR(codebase); - REC_GCLOOKUP((POINTERMASK & fnbase->framename), DELREF); - if (fnbase->startpc != 0) map_code_pointers(codebase,DELREF); - return(NIL); - } - - - +LispPTR reclaimcodeblock(LispPTR codebase) { + struct fnhead *fnbase; + if ((*Closure_Cache_Enabled_word != NIL) && + (remimplicitkeyhash(codebase, *Closure_Cache_word) != NIL)) { + return (T); + }; + fnbase = (struct fnhead *)Addr68k_from_LADDR(codebase); + REC_GCLOOKUP((POINTERMASK & fnbase->framename), DELREF); + if (fnbase->startpc != 0) map_code_pointers(codebase, DELREF); + return (NIL); +} /************************************************************************/ /* */ @@ -363,29 +259,27 @@ LispPTR reclaimcodeblock(LispPTR codebase) /* */ /************************************************************************/ -int code_block_size(long unsigned int codeblock68k) -{ - InstPtr codeptr, initcodeptr; - register unsigned int opnum; - register unsigned int len; - struct fnhead *fnbase; - fnbase = (struct fnhead *) codeblock68k; - initcodeptr = codeptr = ((InstPtr) fnbase) + fnbase->startpc; - while (T) - { - switch (opnum=Get_BYTE(codeptr)) - { - case ENDOFX: /* -X- */ - return (codeptr-initcodeptr); - }; - if ((len = oplength[opnum]) > LONGEST_OPCODE) - { /* len > biggest possible marks an unknown opcode */ - char errtext[200]; - sprintf(errtext, - "Unrecognized bytecode (0%o) at offset 0%o in code block x%x,x%x; continue to use UFN length", opnum, codeptr-(InstPtr)fnbase, (codeblock68k>>16)&0xFF, codeblock68k&0xFFFF); - error(errtext); - oplength[opnum] = len =(((UFN *)UFNTable) + (opnum))->byte_num; - } - codeptr += len + 1; - }; +int code_block_size(long unsigned int codeblock68k) { + InstPtr codeptr, initcodeptr; + register unsigned int opnum; + register unsigned int len; + struct fnhead *fnbase; + fnbase = (struct fnhead *)codeblock68k; + initcodeptr = codeptr = ((InstPtr)fnbase) + fnbase->startpc; + while (T) { + switch (opnum = Get_BYTE(codeptr)) { + case ENDOFX: /* -X- */ return (codeptr - initcodeptr); + }; + if ((len = oplength[opnum]) > + LONGEST_OPCODE) { /* len > biggest possible marks an unknown opcode */ + char errtext[200]; + sprintf(errtext, + "Unrecognized bytecode (0%o) at offset 0%o in code block x%x,x%x; continue to use " + "UFN length", + opnum, codeptr - (InstPtr)fnbase, (codeblock68k >> 16) & 0xFF, codeblock68k & 0xFFFF); + error(errtext); + oplength[opnum] = len = (((UFN *)UFNTable) + (opnum))->byte_num; + } + codeptr += len + 1; + }; } diff --git a/src/gcfinal.c b/src/gcfinal.c old mode 100755 new mode 100644 index 3f468b0..cd3075c --- a/src/gcfinal.c +++ b/src/gcfinal.c @@ -1,10 +1,7 @@ -/* $Id: gcfinal.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gcfinal.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gcfinal.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,10 +14,8 @@ static char *id = "$Id: gcfinal.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - /*************************************************************************/ /*************************************************************************/ /* */ @@ -67,58 +62,55 @@ static char *id = "$Id: gcfinal.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copyr #ifdef NEVER #define GetSegnuminColl(entry1) ((entry1 & 0x01fe) >> 1) /* segnum field */ -#define GetLinkptr(entry) (entry & 0x0fffe) -#define GetCountinColl(entry1) ((entry1 & 0x0fc00) >> 10) -#define Oddp(num) (((num % 2) != 0)?1:0) -#define Evenp(num) (((num % 2) != 0)?0:1) -#define STK_HI 1 /* This value also */ -#define WORDSPERCELL 2 -#define PADDING 4 -#define Boundp(frame_field) ((frame_field == 0)?1:0) +#define GetLinkptr(entry) (entry & 0x0fffe) +#define GetCountinColl(entry1) ((entry1 & 0x0fc00) >> 10) +#define Oddp(num) (((num % 2) != 0) ? 1 : 0) +#define Evenp(num) (((num % 2) != 0) ? 0 : 1) +#define STK_HI 1 /* This value also */ +#define WORDSPERCELL 2 +#define PADDING 4 +#define Boundp(frame_field) ((frame_field == 0) ? 1 : 0) #endif /* NEVER */ - -#define min(a,b) ((a > b)?b:a) -#define Trailer(ldatum,datum68) (ldatum+2*(datum68->arlen - \ - ARRAYBLOCKTRAILERCELLS)) -#define BucketIndex(n) min(integerlength(n),MAXBUCKETINDEX) -#define FreeBlockChainN(n) ((POINTERMASK & *FreeBlockBuckets_word)+ \ - 2*BucketIndex(n)) +#define min(a, b) ((a > b) ? b : a) +#define Trailer(ldatum, datum68) (ldatum + 2 * (datum68->arlen - ARRAYBLOCKTRAILERCELLS)) +#define BucketIndex(n) min(integerlength(n), MAXBUCKETINDEX) +#define FreeBlockChainN(n) ((POINTERMASK & *FreeBlockBuckets_word) + 2 * BucketIndex(n)) #ifndef BYTESWAP #ifdef BIGVM struct buf { - LispPTR filepage; - LispPTR vmempage; - LispPTR buffernext; - unsigned noreference :1; - unsigned usermapped :1; - unsigned iodirty :1; - unsigned unused :1; - unsigned sysnext :28; + LispPTR filepage; + LispPTR vmempage; + LispPTR buffernext; + unsigned noreference : 1; + unsigned usermapped : 1; + unsigned iodirty : 1; + unsigned unused : 1; + unsigned sysnext : 28; }; #else struct buf { - LispPTR filepage; - LispPTR vmempage; - LispPTR buffernext; - unsigned noreference :1; - unsigned usermapped :1; - unsigned iodirty :1; - unsigned unused :5; - unsigned sysnext :24; + LispPTR filepage; + LispPTR vmempage; + LispPTR buffernext; + unsigned noreference : 1; + unsigned usermapped : 1; + unsigned iodirty : 1; + unsigned unused : 5; + unsigned sysnext : 24; }; #endif /* BIGVM */ #else struct buf { - LispPTR filepage; - LispPTR vmempage; - LispPTR buffernext; - unsigned sysnext :24; - unsigned unused :5; - unsigned iodirty :1; - unsigned usermapped :1; - unsigned noreference :1; + LispPTR filepage; + LispPTR vmempage; + LispPTR buffernext; + unsigned sysnext : 24; + unsigned unused : 5; + unsigned iodirty : 1; + unsigned usermapped : 1; + unsigned noreference : 1; }; #endif /* BYTESWAP */ @@ -126,24 +118,22 @@ void printarrayblock(LispPTR base); /************* The following procedure is common !! **************************/ -int integerlength(unsigned int n) -{int cnt; - if (n <= 2) - return(n); - else - {cnt = 1; - do - {cnt++; - n = (n >> 1); - }while(n != 1); - return(cnt); - }; +int integerlength(unsigned int n) { + int cnt; + if (n <= 2) + return (n); + else { + cnt = 1; + do { + cnt++; + n = (n >> 1); + } while (n != 1); + return (cnt); + }; } /************* The above procedure is common !! **************************/ - - /************************************************************************/ /* */ /* f i n d p t r s b u f f e r */ @@ -154,18 +144,18 @@ int integerlength(unsigned int n) /* */ /************************************************************************/ -LispPTR findptrsbuffer(LispPTR ptr) -{ struct buf *bptr; - bptr = (struct buf *)Addr68k_from_LADDR(*System_Buffer_List_word); - while(LADDR_from_68k(bptr) != NIL) - {if (ptr == bptr->vmempage) - return(LADDR_from_68k(bptr)); - else bptr = (struct buf *)Addr68k_from_LADDR(bptr->sysnext);}; - return(NIL); +LispPTR findptrsbuffer(LispPTR ptr) { + struct buf *bptr; + bptr = (struct buf *)Addr68k_from_LADDR(*System_Buffer_List_word); + while (LADDR_from_68k(bptr) != NIL) { + if (ptr == bptr->vmempage) + return (LADDR_from_68k(bptr)); + else + bptr = (struct buf *)Addr68k_from_LADDR(bptr->sysnext); + }; + return (NIL); } - - /************************************************************************/ /* */ /* r e l e a s i n g v m e m p a g e */ @@ -177,19 +167,16 @@ LispPTR findptrsbuffer(LispPTR ptr) /* */ /************************************************************************/ -LispPTR releasingvmempage(LispPTR ptr) -{ - register struct buf *bptr; - register LispPTR bufferptr = findptrsbuffer(ptr); - - if (bufferptr == NIL) return(NIL); /* Not in use, OK to reclaim it */ - - bptr = (struct buf *)Addr68k_from_LADDR(bufferptr); - bptr->noreference = T; /* Mark the buffer free to use ?? */ - return(ATOM_T); - } +LispPTR releasingvmempage(LispPTR ptr) { + register struct buf *bptr; + register LispPTR bufferptr = findptrsbuffer(ptr); + if (bufferptr == NIL) return (NIL); /* Not in use, OK to reclaim it */ + bptr = (struct buf *)Addr68k_from_LADDR(bufferptr); + bptr->noreference = T; /* Mark the buffer free to use ?? */ + return (ATOM_T); +} /************************************************************************/ /* */ @@ -199,228 +186,60 @@ LispPTR releasingvmempage(LispPTR ptr) /* */ /************************************************************************/ -LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist) -{struct arrayblock *bbase, *btrailer; - struct arrayblock *bfwd, *bbwd, *rbase; - LispPTR fbl; - LispPTR *rover, *tmprover; +LispPTR checkarrayblock(LispPTR base, LispPTR free, LispPTR onfreelist) { + struct arrayblock *bbase, *btrailer; + struct arrayblock *bfwd, *bbwd, *rbase; + LispPTR fbl; + LispPTR *rover, *tmprover; #ifdef ARRAYCHECK - if (T) + if (T) #else - if (*Array_Block_Checking_word != NIL) + if (*Array_Block_Checking_word != NIL) #endif - { - bbase = (struct arrayblock *)Addr68k_from_LADDR(base); - btrailer=(struct arrayblock *)Addr68k_from_LADDR(Trailer(base,bbase)); - bfwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->fwd); - bbwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->bkwd); - if (bbase->password != ARRAYBLOCKPASSWORD) - { - printarrayblock(base); - error("ARRAYBLOCK password wrong\n"); - } - else if (bbase->inuse == free) - { - printarrayblock(base); - error("ARRAYBLOCK INUSE bit set wrong\n"); - } - else if (btrailer->password != ARRAYBLOCKPASSWORD) - { - printarrayblock(base); - error("ARRAYBLOCK trailer password wrong\n"); - } - else if (bbase->arlen != btrailer->arlen) - { - printarrayblock(base); - error("ARRAYBLOCK Header and Trailer length don't match\n"); - } - else if (btrailer->inuse == free) - /* This is not original source.(in original, - btrailer -> bbase) maybe, this is correction. */ - { - printarrayblock(base); - error("ARRAYBLOCK Trailer INUSE bit set wrong\n"); - } - else if (!onfreelist || (bbase->arlen < MINARRAYBLOCKSIZE)) - /* Remaining tests only for free list. */ - return(NIL); - else if ((bbwd->fwd != base) || (bfwd->bkwd != base)) - { - error("ARRAYBLOCK links fouled\n"); - } - else - {fbl = FreeBlockChainN(bbase->arlen); - rover = tmprover = (LispPTR *)Addr68k_from_LADDR(fbl); - /* GETBASEPTR */ - if ((*rover & POINTERMASK) == NIL) - error("Free Block's bucket empty\n"); - do - {if ((*rover & POINTERMASK) == base) - return(NIL); - checkarrayblock((*rover & POINTERMASK), T, NIL); - rbase = (struct arrayblock *)Addr68k_from_LADDR( - *rover & POINTERMASK); - }while(((*rover = rbase->fwd)& POINTERMASK) != - (*tmprover & POINTERMASK)); - return(NIL); - }; - }; - return(NIL); -} - - - -/************************************************************************/ -/* */ -/* */ -/* */ -/* */ -/* */ -/************************************************************************/ - -LispPTR deleteblock(LispPTR base) -{ struct arrayblock *bbase, *fbbase, *bbbase; - LispPTR fwd,bkwd,fbl,freeblocklsp; - LispPTR *freeblock; - bbase = (struct arrayblock *)Addr68k_from_LADDR(base); - if ((bbase->arlen >= MINARRAYBLOCKSIZE) && (bbase->fwd != NIL)) - {fwd = bbase->fwd; - fbbase = (struct arrayblock *)Addr68k_from_LADDR(fwd); - bkwd = bbase->bkwd; - bbbase = (struct arrayblock *)Addr68k_from_LADDR(bkwd); - fbl = FreeBlockChainN(bbase->arlen); - freeblock = (LispPTR *)Addr68k_from_LADDR(fbl); - freeblocklsp = POINTERMASK & *freeblock; - if (base == fwd) - {if (base == freeblocklsp) - *freeblock = NIL; - else error("GC error:deleting last list # FREEBLOCKLIST\n"); - return(NIL); - } - else - if (base == freeblocklsp) - *freeblock = fwd; - fbbase->bkwd = bkwd; - bbbase->fwd = fwd; - } - return(NIL); -} - - - -/************************************************************************/ -/* */ -/* */ -/* */ -/* */ -/* */ -/************************************************************************/ - -LispPTR linkblock(LispPTR base) -{ struct arrayblock *bbase,*fbbase,*tmpbase; - LispPTR fbl,freeblocklsp; - LispPTR *freeblock; - if (*FreeBlockBuckets_word != NIL) - { bbase = (struct arrayblock *)Addr68k_from_LADDR(base); - if (bbase->arlen < MINARRAYBLOCKSIZE) - checkarrayblock(base, T, NIL); - else - {fbl = FreeBlockChainN(bbase->arlen); - freeblock = (LispPTR *)Addr68k_from_LADDR(POINTERMASK & fbl); - freeblocklsp = POINTERMASK & (*freeblock); - if (freeblocklsp == NIL) - {bbase->fwd = base; - bbase->bkwd = base; - } - else - {fbbase = (struct arrayblock *)Addr68k_from_LADDR(freeblocklsp); - bbase->fwd = freeblocklsp; - bbase->bkwd = fbbase->bkwd; - tmpbase = (struct arrayblock *) - Addr68k_from_LADDR(fbbase->bkwd); - tmpbase->fwd = base; - fbbase->bkwd = base; - }; - *freeblock = base; - checkarrayblock(base, T, T); - }; - }; - return(base); -} - - - - - - -/************************************************************************/ -/* */ -/* */ -/* */ -/* */ -/* */ -/************************************************************************/ - -LispPTR makefreearrayblock(LispPTR block, DLword length) -{ LispPTR trailer; - struct arrayblock *bbase; - struct abdum *dbase; - bbase = (struct arrayblock *)Addr68k_from_LADDR(block); - dbase = (struct abdum *)WORDPTR(bbase); - dbase->abflags = FREEARRAYFLAGWORD; - bbase->arlen = length; - trailer = Trailer(block,bbase); - bbase = (struct arrayblock *)Addr68k_from_LADDR(trailer); - dbase = (struct abdum *)WORDPTR(bbase); - dbase->abflags = FREEARRAYFLAGWORD; - bbase->arlen = length; - return(block); -} - - - - - -/************************************************************************/ -/* */ -/* */ -/* */ -/* */ -/* */ -/************************************************************************/ - - -LispPTR arrayblockmerger(LispPTR base, LispPTR nbase) -{ DLword arlens, narlens, secondbite, minblocksize, shaveback; - struct arrayblock *bbase, *bnbase; + { bbase = (struct arrayblock *)Addr68k_from_LADDR(base); - bnbase = (struct arrayblock *)Addr68k_from_LADDR(nbase); - arlens = bbase->arlen; - narlens = bnbase->arlen; - secondbite = MAXARRAYBLOCKSIZE - arlens; - if (narlens > secondbite) - {arlens = MAXARRAYBLOCKSIZE; - narlens = narlens - secondbite; - minblocksize = ((*Hunk_word == ATOM_T) ? - (ARRAYBLOCKOVERHEADCELLS+MAXCELLSPERHUNK) : - MINARRAYBLOCKSIZE); - if (narlens < minblocksize) - {shaveback = narlens - minblocksize; - narlens = minblocksize; - arlens += shaveback; - secondbite += shaveback; - }; - linkblock(makefreearrayblock(nbase+2*secondbite, narlens)); - narlens = 0; - }; - return(linkblock(makefreearrayblock(base, arlens+narlens))); + btrailer = (struct arrayblock *)Addr68k_from_LADDR(Trailer(base, bbase)); + bfwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->fwd); + bbwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->bkwd); + if (bbase->password != ARRAYBLOCKPASSWORD) { + printarrayblock(base); + error("ARRAYBLOCK password wrong\n"); + } else if (bbase->inuse == free) { + printarrayblock(base); + error("ARRAYBLOCK INUSE bit set wrong\n"); + } else if (btrailer->password != ARRAYBLOCKPASSWORD) { + printarrayblock(base); + error("ARRAYBLOCK trailer password wrong\n"); + } else if (bbase->arlen != btrailer->arlen) { + printarrayblock(base); + error("ARRAYBLOCK Header and Trailer length don't match\n"); + } else if (btrailer->inuse == free) + /* This is not original source.(in original, + btrailer -> bbase) maybe, this is correction. */ + { + printarrayblock(base); + error("ARRAYBLOCK Trailer INUSE bit set wrong\n"); + } else if (!onfreelist || (bbase->arlen < MINARRAYBLOCKSIZE)) + /* Remaining tests only for free list. */ + return (NIL); + else if ((bbwd->fwd != base) || (bfwd->bkwd != base)) { + error("ARRAYBLOCK links fouled\n"); + } else { + fbl = FreeBlockChainN(bbase->arlen); + rover = tmprover = (LispPTR *)Addr68k_from_LADDR(fbl); + /* GETBASEPTR */ + if ((*rover & POINTERMASK) == NIL) error("Free Block's bucket empty\n"); + do { + if ((*rover & POINTERMASK) == base) return (NIL); + checkarrayblock((*rover & POINTERMASK), T, NIL); + rbase = (struct arrayblock *)Addr68k_from_LADDR(*rover & POINTERMASK); + } while (((*rover = rbase->fwd) & POINTERMASK) != (*tmprover & POINTERMASK)); + return (NIL); + }; + }; + return (NIL); } - - - - - /************************************************************************/ /* */ /* */ @@ -429,28 +248,33 @@ LispPTR arrayblockmerger(LispPTR base, LispPTR nbase) /* */ /************************************************************************/ -LispPTR mergebackward(LispPTR base) -{ LispPTR pbase; - struct arrayblock *ptrailer; - - ptrailer = (struct arrayblock *)Addr68k_from_LADDR(base - - ARRAYBLOCKTRAILERWORDS); - if (base == NIL) - return(NIL); - else if ((*ArrayMerging_word == NIL) || ((base == *ArraySpace_word) || - ((base == *ArraySpace2_word) || (ptrailer->inuse == T)))) - return(linkblock(base)); - pbase = base - 2*ptrailer->arlen; - checkarrayblock(pbase, T,NIL); - deleteblock(pbase); - return(arrayblockmerger(pbase, base)); +LispPTR deleteblock(LispPTR base) { + struct arrayblock *bbase, *fbbase, *bbbase; + LispPTR fwd, bkwd, fbl, freeblocklsp; + LispPTR *freeblock; + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + if ((bbase->arlen >= MINARRAYBLOCKSIZE) && (bbase->fwd != NIL)) { + fwd = bbase->fwd; + fbbase = (struct arrayblock *)Addr68k_from_LADDR(fwd); + bkwd = bbase->bkwd; + bbbase = (struct arrayblock *)Addr68k_from_LADDR(bkwd); + fbl = FreeBlockChainN(bbase->arlen); + freeblock = (LispPTR *)Addr68k_from_LADDR(fbl); + freeblocklsp = POINTERMASK & *freeblock; + if (base == fwd) { + if (base == freeblocklsp) + *freeblock = NIL; + else + error("GC error:deleting last list # FREEBLOCKLIST\n"); + return (NIL); + } else if (base == freeblocklsp) + *freeblock = fwd; + fbbase->bkwd = bkwd; + bbbase->fwd = fwd; + } + return (NIL); } - - - - - /************************************************************************/ /* */ /* */ @@ -459,27 +283,142 @@ LispPTR mergebackward(LispPTR base) /* */ /************************************************************************/ -LispPTR mergeforward(LispPTR base) -{ LispPTR nbase, nbinuse; - struct arrayblock *bbase, *bnbase; +LispPTR linkblock(LispPTR base) { + struct arrayblock *bbase, *fbbase, *tmpbase; + LispPTR fbl, freeblocklsp; + LispPTR *freeblock; + if (*FreeBlockBuckets_word != NIL) { bbase = (struct arrayblock *)Addr68k_from_LADDR(base); - nbase = base + 2*(bbase->arlen); - bnbase = (struct arrayblock *)Addr68k_from_LADDR(nbase); - if ((*ArrayMerging_word == NIL) || ((base == NIL) - || (checkarrayblock(base, T, T) || ((nbase == *ArrayFrLst_word) || - ((nbase == *ArrayFrLst2_word) || - (checkarrayblock(nbase, (! (nbinuse = bnbase->inuse)),NIL) || - nbinuse)))))) - return(NIL); - deleteblock(nbase); - deleteblock(base); - return(arrayblockmerger(base, nbase)); + if (bbase->arlen < MINARRAYBLOCKSIZE) + checkarrayblock(base, T, NIL); + else { + fbl = FreeBlockChainN(bbase->arlen); + freeblock = (LispPTR *)Addr68k_from_LADDR(POINTERMASK & fbl); + freeblocklsp = POINTERMASK & (*freeblock); + if (freeblocklsp == NIL) { + bbase->fwd = base; + bbase->bkwd = base; + } else { + fbbase = (struct arrayblock *)Addr68k_from_LADDR(freeblocklsp); + bbase->fwd = freeblocklsp; + bbase->bkwd = fbbase->bkwd; + tmpbase = (struct arrayblock *)Addr68k_from_LADDR(fbbase->bkwd); + tmpbase->fwd = base; + fbbase->bkwd = base; + }; + *freeblock = base; + checkarrayblock(base, T, T); + }; + }; + return (base); } +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ +LispPTR makefreearrayblock(LispPTR block, DLword length) { + LispPTR trailer; + struct arrayblock *bbase; + struct abdum *dbase; + bbase = (struct arrayblock *)Addr68k_from_LADDR(block); + dbase = (struct abdum *)WORDPTR(bbase); + dbase->abflags = FREEARRAYFLAGWORD; + bbase->arlen = length; + trailer = Trailer(block, bbase); + bbase = (struct arrayblock *)Addr68k_from_LADDR(trailer); + dbase = (struct abdum *)WORDPTR(bbase); + dbase->abflags = FREEARRAYFLAGWORD; + bbase->arlen = length; + return (block); +} +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ +LispPTR arrayblockmerger(LispPTR base, LispPTR nbase) { + DLword arlens, narlens, secondbite, minblocksize, shaveback; + struct arrayblock *bbase, *bnbase; + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + bnbase = (struct arrayblock *)Addr68k_from_LADDR(nbase); + arlens = bbase->arlen; + narlens = bnbase->arlen; + secondbite = MAXARRAYBLOCKSIZE - arlens; + if (narlens > secondbite) { + arlens = MAXARRAYBLOCKSIZE; + narlens = narlens - secondbite; + minblocksize = + ((*Hunk_word == ATOM_T) ? (ARRAYBLOCKOVERHEADCELLS + MAXCELLSPERHUNK) : MINARRAYBLOCKSIZE); + if (narlens < minblocksize) { + shaveback = narlens - minblocksize; + narlens = minblocksize; + arlens += shaveback; + secondbite += shaveback; + }; + linkblock(makefreearrayblock(nbase + 2 * secondbite, narlens)); + narlens = 0; + }; + return (linkblock(makefreearrayblock(base, arlens + narlens))); +} +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR mergebackward(LispPTR base) { + LispPTR pbase; + struct arrayblock *ptrailer; + + ptrailer = (struct arrayblock *)Addr68k_from_LADDR(base - ARRAYBLOCKTRAILERWORDS); + if (base == NIL) + return (NIL); + else if ((*ArrayMerging_word == NIL) || + ((base == *ArraySpace_word) || ((base == *ArraySpace2_word) || (ptrailer->inuse == T)))) + return (linkblock(base)); + pbase = base - 2 * ptrailer->arlen; + checkarrayblock(pbase, T, NIL); + deleteblock(pbase); + return (arrayblockmerger(pbase, base)); +} + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR mergeforward(LispPTR base) { + LispPTR nbase, nbinuse; + struct arrayblock *bbase, *bnbase; + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + nbase = base + 2 * (bbase->arlen); + bnbase = (struct arrayblock *)Addr68k_from_LADDR(nbase); + if ((*ArrayMerging_word == NIL) || + ((base == NIL) || + (checkarrayblock(base, T, T) || + ((nbase == *ArrayFrLst_word) || + ((nbase == *ArrayFrLst2_word) || + (checkarrayblock(nbase, (!(nbinuse = bnbase->inuse)), NIL) || nbinuse)))))) + return (NIL); + deleteblock(nbase); + deleteblock(base); + return (arrayblockmerger(base, nbase)); +} /************************************************************************/ /* */ @@ -489,78 +428,66 @@ LispPTR mergeforward(LispPTR base) /* */ /************************************************************************/ -LispPTR reclaimarrayblock(LispPTR ptr) -{ LispPTR tmpptr, btrailer; - struct arrayblock *base; - LispPTR *tmpp; - int reclaim_p; +LispPTR reclaimarrayblock(LispPTR ptr) { + LispPTR tmpptr, btrailer; + struct arrayblock *base; + LispPTR *tmpp; + int reclaim_p; - reclaim_p = T; + reclaim_p = T; #ifdef ARRAYCHECK - checkarrayblock(ptr-ARRAYBLOCKHEADERWORDS, NIL, NIL); + checkarrayblock(ptr - ARRAYBLOCKHEADERWORDS, NIL, NIL); #endif /* ARRAYCHECK */ - base = (struct arrayblock *)Addr68k_from_LADDR(ptr-ARRAYBLOCKHEADERWORDS); + base = (struct arrayblock *)Addr68k_from_LADDR(ptr - ARRAYBLOCKHEADERWORDS); #ifdef ARRAYCHECK - if (HILOC(ptr) < FIRSTARRAYSEGMENT) - { - printarrayblock(ptr-ARRAYBLOCKHEADERWORDS); - error("Bad array block reclaimed [not in array space].\nContinue with 'q' but save state ASAP. \n"); - return(T); - } - else if (ARRAYBLOCKPASSWORD != base->password) - { - printarrayblock(ptr-ARRAYBLOCKHEADERWORDS); - error("Bad array block reclaimed [password wrong].\nContinue with 'q' but save state ASAP. \n"); - return(T); - } - else if (base->inuse == NIL) - { - printarrayblock(ptr-ARRAYBLOCKHEADERWORDS); - error("Bad array block reclaimed [block not in use].\nContinue with 'q' but save state ASAP. \n"); - return(T); - } -#else - /* Normal case, just tell the guy something's wrong: */ - if ((HILOC(ptr) < FIRSTARRAYSEGMENT) || - ((ARRAYBLOCKPASSWORD != base->password) || - (base->inuse == NIL))) - { - error("Bad array block reclaimed--continue with 'q' but save state ASAP. \n"); - return(T); - }; -#endif /* ARRAYCHECK */ - - - switch(base->gctype) - { - case PTRBLOCK_GCT: - {btrailer = (ptr-2)+2*(base->arlen - ARRAYBLOCKTRAILERCELLS); - tmpptr = ptr; - do - { - tmpp = (LispPTR *)Addr68k_from_LADDR(tmpptr); - /* GCLOOKUP(0x8000,DELREF, *tmpp);*/ /* added 8-Oct-87 TT */ - REC_GCLOOKUP(*tmpp, DELREF); - *tmpp = NIL; - tmpptr += 2; - } while (tmpptr != btrailer); - break; - }; - case CODEBLOCK_GCT: - reclaim_p = ((reclaimcodeblock(ptr) == NIL)?T:NIL); - - - /* default: No Action */ - }; - if (reclaim_p == T) - mergeforward(mergebackward(makefreearrayblock( - ptr-ARRAYBLOCKHEADERWORDS - ,base->arlen))); - return(T); + if (HILOC(ptr) < FIRSTARRAYSEGMENT) { + printarrayblock(ptr - ARRAYBLOCKHEADERWORDS); + error( + "Bad array block reclaimed [not in array space].\nContinue with 'q' but save state ASAP. " + "\n"); + return (T); + } else if (ARRAYBLOCKPASSWORD != base->password) { + printarrayblock(ptr - ARRAYBLOCKHEADERWORDS); + error("Bad array block reclaimed [password wrong].\nContinue with 'q' but save state ASAP. \n"); + return (T); + } else if (base->inuse == NIL) { + printarrayblock(ptr - ARRAYBLOCKHEADERWORDS); + error( + "Bad array block reclaimed [block not in use].\nContinue with 'q' but save state ASAP. \n"); + return (T); } +#else + /* Normal case, just tell the guy something's wrong: */ + if ((HILOC(ptr) < FIRSTARRAYSEGMENT) || + ((ARRAYBLOCKPASSWORD != base->password) || (base->inuse == NIL))) { + error("Bad array block reclaimed--continue with 'q' but save state ASAP. \n"); + return (T); + }; +#endif /* ARRAYCHECK */ + switch (base->gctype) { + case PTRBLOCK_GCT: { + btrailer = (ptr - 2) + 2 * (base->arlen - ARRAYBLOCKTRAILERCELLS); + tmpptr = ptr; + do { + tmpp = (LispPTR *)Addr68k_from_LADDR(tmpptr); + /* GCLOOKUP(0x8000,DELREF, *tmpp);*/ /* added 8-Oct-87 TT */ + REC_GCLOOKUP(*tmpp, DELREF); + *tmpp = NIL; + tmpptr += 2; + } while (tmpptr != btrailer); + break; + }; + case CODEBLOCK_GCT: + reclaim_p = ((reclaimcodeblock(ptr) == NIL) ? T : NIL); + /* default: No Action */ + }; + if (reclaim_p == T) + mergeforward(mergebackward(makefreearrayblock(ptr - ARRAYBLOCKHEADERWORDS, base->arlen))); + return (T); +} /************************************************************************/ /* */ @@ -570,18 +497,16 @@ LispPTR reclaimarrayblock(LispPTR ptr) /* */ /************************************************************************/ -LispPTR reclaimstackp (LispPTR ptr) /* This is the entry function */ - /* in stack reclaiming */ - { - register STACKP *stkp; - register FX *fxp; - stkp = (STACKP*)Addr68k_from_LADDR(ptr); - fxp = (FX*)Addr68k_from_StkOffset( stkp->edfxp ); - decusecount68k(fxp); /* decrement the use-count for the frame it uses */ - return(NIL); /* and let the normal reclaimer reclaim it */ - } - - +LispPTR reclaimstackp(LispPTR ptr) /* This is the entry function */ + /* in stack reclaiming */ +{ + register STACKP *stkp; + register FX *fxp; + stkp = (STACKP *)Addr68k_from_LADDR(ptr); + fxp = (FX *)Addr68k_from_StkOffset(stkp->edfxp); + decusecount68k(fxp); /* decrement the use-count for the frame it uses */ + return (NIL); /* and let the normal reclaimer reclaim it */ +} /************************************************************************/ /* */ @@ -591,40 +516,33 @@ LispPTR reclaimstackp (LispPTR ptr) /* This is the entry function */ /* */ /************************************************************************/ -void printarrayblock(LispPTR base) -{ - struct arrayblock *bbase, *btrailer, *ptrailer; - struct arrayblock *bfwd, *bbwd, *rbase; - LispPTR *addr, *tmprover; +void printarrayblock(LispPTR base) { + struct arrayblock *bbase, *btrailer, *ptrailer; + struct arrayblock *bfwd, *bbwd, *rbase; + LispPTR *addr, *tmprover; - LispPTR pbase, nbase; + LispPTR pbase, nbase; - bbase = (struct arrayblock *)Addr68k_from_LADDR(base); - btrailer=(struct arrayblock *)Addr68k_from_LADDR(Trailer(base,bbase)); - ptrailer=(struct arrayblock *)Addr68k_from_LADDR(base-ARRAYBLOCKTRAILERWORDS); - bfwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->fwd); - bbwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->bkwd); + bbase = (struct arrayblock *)Addr68k_from_LADDR(base); + btrailer = (struct arrayblock *)Addr68k_from_LADDR(Trailer(base, bbase)); + ptrailer = (struct arrayblock *)Addr68k_from_LADDR(base - ARRAYBLOCKTRAILERWORDS); + bfwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->fwd); + bbwd = (struct arrayblock *)Addr68k_from_LADDR(bbase->bkwd); - nbase = base + 2*bbase->arlen; - pbase = base - 2*ptrailer->arlen; + nbase = base + 2 * bbase->arlen; + pbase = base - 2 * ptrailer->arlen; - printf("This array block: 0x%x. Previous: 0x%x. Next: 0x%x.\n", - base, pbase, nbase); - printf(" Length: %d cells.\n\n", bbase->arlen); + printf("This array block: 0x%x. Previous: 0x%x. Next: 0x%x.\n", base, pbase, nbase); + printf(" Length: %d cells.\n\n", bbase->arlen); - addr = ((LispPTR *) bbase) - 20; - for (;addr<(LispPTR *)bbase; addr++) - printf("0x%x %8x\n", addr, *addr); - printf("0x%x %8x <- array header\n", addr, *addr++); - for (; addr < (LispPTR *) bbase + 20; addr++) - printf("0x%x %8x\n", addr, *addr); - printf(". . .\n"); + addr = ((LispPTR *)bbase) - 20; + for (; addr < (LispPTR *)bbase; addr++) printf("0x%x %8x\n", addr, *addr); + printf("0x%x %8x <- array header\n", addr, *addr++); + for (; addr < (LispPTR *)bbase + 20; addr++) printf("0x%x %8x\n", addr, *addr); + printf(". . .\n"); - addr = ((LispPTR *) btrailer) - 20; - for (;addr<(LispPTR *)btrailer; addr++) - printf("0x%x %8x\n", addr, *addr); - printf("0x%x %8x <- array trailer\n", addr, *addr++); - for (; addr < (LispPTR *) btrailer + 20; addr++) - printf("0x%x %8x\n", addr, *addr); - - } + addr = ((LispPTR *)btrailer) - 20; + for (; addr < (LispPTR *)btrailer; addr++) printf("0x%x %8x\n", addr, *addr); + printf("0x%x %8x <- array trailer\n", addr, *addr++); + for (; addr < (LispPTR *)btrailer + 20; addr++) printf("0x%x %8x\n", addr, *addr); +} diff --git a/src/gchtfind.c b/src/gchtfind.c old mode 100755 new mode 100644 index 36b8434..f8c2232 --- a/src/gchtfind.c +++ b/src/gchtfind.c @@ -1,10 +1,7 @@ -/* $Id: gchtfind.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gchtfind.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gchtfind.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,10 +14,8 @@ static char *id = "$Id: gchtfind.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copy /* */ /************************************************************************/ - #include "version.h" - #include "lispemul.h" #include "lsptypes.h" #include "address.h" @@ -30,192 +25,182 @@ static char *id = "$Id: gchtfind.c,v 1.3 1999/05/31 23:35:31 sybalsky Exp $ Copy #include "lispmap.h" #include "cell.h" - - -#define Evenp(num,prim) ((num % prim) == 0) +#define Evenp(num, prim) ((num % prim) == 0) #ifdef BIGVM - /* HTCOLLMAX should be in half-entries, not in words */ -#define HTCOLLMAX (HTCOLL_SIZE/DLWORDSPER_CELL)-16 +/* HTCOLLMAX should be in half-entries, not in words */ +#define HTCOLLMAX (HTCOLL_SIZE / DLWORDSPER_CELL) - 16 #else -#define HTCOLLMAX HTCOLL_SIZE-16 +#define HTCOLLMAX HTCOLL_SIZE - 16 #endif /* BIGVM */ /* GetLink gets a new entry from the GC collision table */ -#define GetLink(var) \ - { \ - \ - register GCENTRY linkoff; \ - linkoff = GETGC(HTcoll); \ - if (linkoff == 0) \ - { \ - if ((linkoff = GETGC((GCENTRY *)HTcoll + 1)) \ - >= HTCOLLMAX) \ - { \ - disablegc1(NIL); \ - return(NIL); \ - }; \ - GETGC((GCENTRY*)HTcoll + 1) = linkoff + 2; \ - var = (GCENTRY *)(HTcoll + linkoff); \ - } \ - else \ - { \ - GETGC(HTcoll) = GETGC((GCENTRY *)(HTcoll + linkoff+1)); \ - var = (GCENTRY *)(HTcoll + linkoff); \ - } \ -} +#define GetLink(var) \ + { \ + register GCENTRY linkoff; \ + linkoff = GETGC(HTcoll); \ + if (linkoff == 0) { \ + if ((linkoff = GETGC((GCENTRY *)HTcoll + 1)) >= HTCOLLMAX) { \ + disablegc1(NIL); \ + return (NIL); \ + }; \ + GETGC((GCENTRY *)HTcoll + 1) = linkoff + 2; \ + var = (GCENTRY *)(HTcoll + linkoff); \ + } else { \ + GETGC(HTcoll) = GETGC((GCENTRY *)(HTcoll + linkoff + 1)); \ + var = (GCENTRY *)(HTcoll + linkoff); \ + } \ + } #ifdef BIGVM -#define HTCNTSHIFT 17 /* amount to shift to get hash table count */ -#define HTCNTMASK 0xFFFE0000 /* mask which masks off hash table count */ +#define HTCNTSHIFT 17 /* amount to shift to get hash table count */ +#define HTCNTMASK 0xFFFE0000 /* mask which masks off hash table count */ #define HTCNTSTKMASK 0XFFFF0000 /* mask for hash table count + stack bit */ -#define HTSTKMASK 0x10000 /* mask for stack bit only */ -#define HTHIMASK 0x1FFE /* mask of bits which contain high part of - pointer in hash table FIXME change this - to 1FFE when pointers really go to - 28 bits. JDS */ -#define HTHISHIFT 1 /* high bits in hash table are shifted left 1 */ +#define HTSTKMASK 0x10000 /* mask for stack bit only */ +#define HTHIMASK \ + 0x1FFE /* mask of bits which contain high part of \ + pointer in hash table FIXME change this \ + to 1FFE when pointers really go to \ + 28 bits. JDS */ +#define HTHISHIFT 1 /* high bits in hash table are shifted left 1 */ #else -#define HTCNTSHIFT 10 /* amount to shift to get hash table count */ -#define HTCNTMASK 0xFC00 /* mask which masks off hash table count */ +#define HTCNTSHIFT 10 /* amount to shift to get hash table count */ +#define HTCNTMASK 0xFC00 /* mask which masks off hash table count */ #define HTCNTSTKMASK 0XFE00 /* mask for hash table count + stack bit */ -#define HTSTKMASK 0x0200 /* mask for stack bit only */ -#define HTHIMASK 0x1FE /* mask of bits which contain high part of pointer - in hash table */ -#define HTHISHIFT 1 /* high bits in hash table are shifted left 1 */ -#endif /* BIGVM */ - +#define HTSTKMASK 0x0200 /* mask for stack bit only */ +#define HTHIMASK \ + 0x1FE /* mask of bits which contain high part of pointer \ + in hash table */ +#define HTHISHIFT 1 /* high bits in hash table are shifted left 1 */ +#endif /* BIGVM */ /* NewEntry is a macro for adding a new gc hash table entry; - entry is pointer to hash table entry - hiptr is the high point of the ref-cnted entry, shifted - casep is one of ADDREF, DELREF, etc. + entry is pointer to hash table entry + hiptr is the high point of the ref-cnted entry, shifted + casep is one of ADDREF, DELREF, etc. */ /* * NewEntry is never called in the course of the reclaimation. * Thus STKREF case is not needed. */ -#define NewEntry(entry, hiptr, casep, ptr) { \ -switch (casep) { \ - case ADDREF: \ - GETGC(entry) = hiptr | (2 << HTCNTSHIFT); /* set count = 2 */ \ - IncAllocCnt(1);\ - return NIL; /* not new 0 entry */ \ - case DELREF: \ - GETGC(entry) = hiptr; /* set count = 0 */ \ - IncAllocCnt(1);\ - return ptr; /* new 0 entry */ \ - default: \ - error("GC error: new entry touches stack bit"); \ - }} +#define NewEntry(entry, hiptr, casep, ptr) \ + { \ + switch (casep) { \ + case ADDREF: \ + GETGC(entry) = hiptr | (2 << HTCNTSHIFT); /* set count = 2 */ \ + IncAllocCnt(1); \ + return NIL; /* not new 0 entry */ \ + case DELREF: \ + GETGC(entry) = hiptr; /* set count = 0 */ \ + IncAllocCnt(1); \ + return ptr; /* new 0 entry */ \ + default: error("GC error: new entry touches stack bit"); \ + } \ + } /* * RecNewEntry is called in the course of the reclaimation. * Does not maintain the allocation count. */ -#define RecNewEntry(entry, hiptr, casep, ptr) { \ -switch (casep) { \ - case ADDREF: \ - GETGC(entry) = hiptr | (2 << HTCNTSHIFT); /* set count = 2 */ \ - return NIL; /* not new 0 entry */ \ - case DELREF: \ - GETGC(entry) = hiptr; /* set count = 0 */ \ - return ptr; /* new 0 entry */ \ - case STKREF: /* set refcnt to 1, stack bit to 1 */ \ - GETGC(entry) = hiptr | (1<> HTCNTSHIFT) == 0) \ - error("attempt to decrement 0 reference count"); \ - contents -= (1 << HTCNTSHIFT); \ - if ((contents & HTCNTSTKMASK) == (1 << HTCNTSHIFT)) { \ - DecAllocCnt(1); \ - goto remove; \ - } \ - break;\ - default: error("GC error: mod entry touches stack bit"); \ - }\ - GETGC(entry) = contents;\ - return NIL;\ + It always return NIL, since cannot be creating a zero-count, + no-stack-bit entry */ +/* + * ModEntry is never called in the course of the reclamation. + * Thus STKREF and UNSTKREF cases are not needed. + */ +#define ModEntry(entry, contents, ptr, casep, remove) \ + { \ + if ((contents & HTCNTMASK) == HTCNTMASK) { /* overflow; return non-zero */ \ + modify_big_reference_count(entry, casep, ptr); \ + return NIL; \ + } \ + switch (casep) { \ + case ADDREF: \ + contents += (1 << HTCNTSHIFT); \ + if ((contents & HTCNTMASK) == HTCNTMASK) { /* overflow */ \ + GETGC(entry) = contents; \ + enter_big_reference_count(ptr); \ + return NIL; \ + } \ + if ((contents & HTCNTSTKMASK) == (1 << HTCNTSHIFT)) { \ + DecAllocCnt(1); \ + goto remove; \ + } \ + break; \ + case DELREF: \ + if ((contents >> HTCNTSHIFT) == 0) error("attempt to decrement 0 reference count"); \ + contents -= (1 << HTCNTSHIFT); \ + if ((contents & HTCNTSTKMASK) == (1 << HTCNTSHIFT)) { \ + DecAllocCnt(1); \ + goto remove; \ + } \ + break; \ + default: error("GC error: mod entry touches stack bit"); \ + } \ + GETGC(entry) = contents; \ + return NIL; \ } /* * RecModEntry is called in the course of the reclaimation. * Does not maintain the allocation count. */ -#define RecModEntry(entry, contents, ptr, casep, remove) { \ - if ((contents & HTCNTMASK) == HTCNTMASK) \ - { /* overflow; return non-zero */ \ - modify_big_reference_count(entry, casep, ptr);\ - return NIL;}\ - switch (casep) {\ - case ADDREF:\ - contents += (1 << HTCNTSHIFT);\ - if ((contents & HTCNTMASK) == HTCNTMASK) \ - {\ - /* overflow */\ - GETGC(entry) = contents; \ - enter_big_reference_count(ptr);\ - return NIL;\ - }\ - break; /* check for possibly deleting entry */\ - case DELREF:\ - if ( (contents >> HTCNTSHIFT) == 0) \ - error("attempt to decrement 0 reference count");\ - contents -= (1 << HTCNTSHIFT); \ - break;\ - case STKREF:\ - GETGC(entry) = contents | HTSTKMASK;\ - return NIL;\ -/*\ - case UNSTKREF:\ - contents = contents & ~ HTSTKMASK;\ - break;\ -*/\ - }\ - if ((contents & HTCNTSTKMASK) == (1 << HTCNTSHIFT)) goto remove;\ - GETGC(entry) = contents;\ - return NIL;\ -} +#define RecModEntry(entry, contents, ptr, casep, remove) \ + { \ + if ((contents & HTCNTMASK) == HTCNTMASK) { /* overflow; return non-zero */ \ + modify_big_reference_count(entry, casep, ptr); \ + return NIL; \ + } \ + switch (casep) { \ + case ADDREF: \ + contents += (1 << HTCNTSHIFT); \ + if ((contents & HTCNTMASK) == HTCNTMASK) { \ + /* overflow */ \ + GETGC(entry) = contents; \ + enter_big_reference_count(ptr); \ + return NIL; \ + } \ + break; /* check for possibly deleting entry */ \ + case DELREF: \ + if ((contents >> HTCNTSHIFT) == 0) error("attempt to decrement 0 reference count"); \ + contents -= (1 << HTCNTSHIFT); \ + break; \ + case STKREF: \ + GETGC(entry) = contents | HTSTKMASK; \ + return NIL; \ + /* \ + case UNSTKREF: \ + contents = contents & ~ HTSTKMASK; \ + break; \ + */ \ + } \ + if ((contents & HTCNTSTKMASK) == (1 << HTCNTSHIFT)) goto remove; \ + GETGC(entry) = contents; \ + return NIL; \ + } /************************************************************************/ /* */ @@ -226,46 +211,39 @@ switch (casep) { \ /* */ /************************************************************************/ -void enter_big_reference_count(LispPTR ptr) -{ - struct gc_ovfl *oventry; - register LispPTR tmp; +void enter_big_reference_count(LispPTR ptr) { + struct gc_ovfl *oventry; + register LispPTR tmp; - /* this kludge is apparently necessary. Odd pointers are - illegal, but apparently some are reference counted. If you - get an odd pointer, just ignore the low bit */ + /* this kludge is apparently necessary. Odd pointers are + illegal, but apparently some are reference counted. If you + get an odd pointer, just ignore the low bit */ - ptr &= 0xfffffffe; + ptr &= 0xfffffffe; - oventry = (struct gc_ovfl *)HTbigcount; - while(((tmp = oventry->ovfl_ptr) != ATOM_T) && (tmp != NIL)) - /* free area ? */ - { - if (tmp == ptr) - { - error("ERROR : PTR already in overflow table.\n"); - oventry->ovfl_cnt += 0x10000; /* "Assure it lives forever" */ - return; - } - else ++oventry; - }; + oventry = (struct gc_ovfl *)HTbigcount; + while (((tmp = oventry->ovfl_ptr) != ATOM_T) && (tmp != NIL)) + /* free area ? */ + { + if (tmp == ptr) { + error("ERROR : PTR already in overflow table.\n"); + oventry->ovfl_cnt += 0x10000; /* "Assure it lives forever" */ + return; + } else + ++oventry; + }; - if (tmp == NIL) - { - if (Evenp(LADDR_from_68k(oventry+1),DLWORDSPER_PAGE)) - { - if ((UNSIGNED)oventry+1 >= (UNSIGNED)HTcoll) - error("GC big reference count table overflow"); - newpage(LADDR_from_68k(oventry+1)); - } - } - - oventry->ovfl_cnt = MAX_GCCOUNT; - oventry->ovfl_ptr = ptr; - return; + if (tmp == NIL) { + if (Evenp(LADDR_from_68k(oventry + 1), DLWORDSPER_PAGE)) { + if ((UNSIGNED)oventry + 1 >= (UNSIGNED)HTcoll) error("GC big reference count table overflow"); + newpage(LADDR_from_68k(oventry + 1)); + } } - + oventry->ovfl_cnt = MAX_GCCOUNT; + oventry->ovfl_ptr = ptr; + return; +} /************************************************************************/ /* */ @@ -275,49 +253,41 @@ void enter_big_reference_count(LispPTR ptr) /* */ /************************************************************************/ -void modify_big_reference_count(LispPTR *entry, DLword casep, LispPTR ptr) -{ - struct gc_ovfl *oventry; - LispPTR tmp; - int tmpcnt; +void modify_big_reference_count(LispPTR *entry, DLword casep, LispPTR ptr) { + struct gc_ovfl *oventry; + LispPTR tmp; + int tmpcnt; - /* ditto comment in entry_big_reference_count */ - if (ptr & 1) ptr &= 0xfffffffe; - oventry = (struct gc_ovfl *) HTbigcount; - while ((tmp = oventry->ovfl_ptr) != ptr) - if (tmp == NIL) - { - error("refcnt previously overflowed, but not found in table.\n"); - return; - } - else ++oventry; /* increment by size of oventry structure */ + /* ditto comment in entry_big_reference_count */ + if (ptr & 1) ptr &= 0xfffffffe; + oventry = (struct gc_ovfl *)HTbigcount; + while ((tmp = oventry->ovfl_ptr) != ptr) + if (tmp == NIL) { + error("refcnt previously overflowed, but not found in table.\n"); + return; + } else + ++oventry; /* increment by size of oventry structure */ - switch (casep) - { - case ADDREF: - ++(oventry->ovfl_cnt); - return; - case DELREF: - if (--(oventry->ovfl_cnt) < MAX_GCCOUNT) - { - /* fallen below threshold */ - ((struct hashentry *) GCPTR(entry))->count = MAX_GCCOUNT - 1; - oventry->ovfl_ptr = ATOM_T; /* mark entry unused */ - } - return; - case STKREF: - ((struct hashentry *) WORDPTR(entry))->stackref = 1; - return; -/* - case UNSTKREF: - ((struct hashentry *) WORDPTR(entry))->stackref = 0; - return; -*/ - } + switch (casep) { + case ADDREF: ++(oventry->ovfl_cnt); return; + case DELREF: + if (--(oventry->ovfl_cnt) < MAX_GCCOUNT) { + /* fallen below threshold */ + ((struct hashentry *)GCPTR(entry))->count = MAX_GCCOUNT - 1; + oventry->ovfl_ptr = ATOM_T; /* mark entry unused */ + } + return; + case STKREF: + ((struct hashentry *)WORDPTR(entry))->stackref = 1; + return; + /* + case UNSTKREF: + ((struct hashentry *) WORDPTR(entry))->stackref = 0; + return; + */ + } } - - /************************************************************************/ /* */ /* h t f i n d */ @@ -338,120 +308,116 @@ void modify_big_reference_count(LispPTR *entry, DLword casep, LispPTR ptr) /* */ /************************************************************************/ -LispPTR htfind(LispPTR ptr, int casep) -{ - register GCENTRY *entry, *link, *prev; - register GCENTRY entry_contents, hiptr; - register struct htlinkptr *htlptr; +LispPTR htfind(LispPTR ptr, int casep) { + register GCENTRY *entry, *link, *prev; + register GCENTRY entry_contents, hiptr; + register struct htlinkptr *htlptr; - /* if the NOREF bit is on in the type table entry, do - not reference count this pointer. Used for non-reference - counted types like symbols, and also when the GC is - disabled. */ + /* if the NOREF bit is on in the type table entry, do + not reference count this pointer. Used for non-reference + counted types like symbols, and also when the GC is + disabled. */ - /* - * Following two tests were moved into GCLOOKUP macro - * for efficency. - */ -/* - if (GetTypeEntry(ptr) & TT_NOREF) return NIL; -*/ - /* if *GcDisabled_word is T then do nothing */ - /* FS: this test should not be needed (because type table should - be cleared). Also, this test seems to cause an infinite - ucode loop in remimplicitkeyhash on the 386i */ + /* + * Following two tests were moved into GCLOOKUP macro + * for efficency. + */ + /* + if (GetTypeEntry(ptr) & TT_NOREF) return NIL; + */ + /* if *GcDisabled_word is T then do nothing */ + /* FS: this test should not be needed (because type table should + be cleared). Also, this test seems to cause an infinite + ucode loop in remimplicitkeyhash on the 386i */ -/* if(*GcDisabled_word == ATOM_T) return(NIL); */ + /* if(*GcDisabled_word == ATOM_T) return(NIL); */ - /* GC hash table entries have the high 8 bits of the - pointer stored in the middle. Set up hiptr to have - the high bits of the pointer ready to store or test - against */ + /* GC hash table entries have the high 8 bits of the + pointer stored in the middle. Set up hiptr to have + the high bits of the pointer ready to store or test + against */ - hiptr = (((UNSIGNED)ptr) >> (16-HTHISHIFT) ) & HTHIMASK; + hiptr = (((UNSIGNED)ptr) >> (16 - HTHISHIFT)) & HTHIMASK; - /* entry points at the place in the main hash table - where this pointer is stored. The 'hash' isn't one really; - it just uses the low bits of the pointer. */ + /* entry points at the place in the main hash table + where this pointer is stored. The 'hash' isn't one really; + it just uses the low bits of the pointer. */ - entry = HTmain + (LOLOC(ptr) >> 1); + entry = HTmain + (LOLOC(ptr) >> 1); - entry_contents = GETGC(entry); + entry_contents = GETGC(entry); - if (entry_contents == 0) NewEntry(entry, hiptr, casep, ptr); - /* NewEntry returns */ + if (entry_contents == 0) NewEntry(entry, hiptr, casep, ptr); + /* NewEntry returns */ - if (entry_contents & 1) - { /* low bit means a collision entry */ - /* entry_contents-1 removes low bit */ - link = HTcoll + (entry_contents - 1); - prev = 0; - goto newlink; - } + if (entry_contents & 1) { /* low bit means a collision entry */ + /* entry_contents-1 removes low bit */ + link = HTcoll + (entry_contents - 1); + prev = 0; + goto newlink; + } - if (hiptr == (entry_contents & HTHIMASK)) - { - ModEntry(entry, entry_contents, ptr, casep, delentry); - /* ModEntry returns or will go to delentry */ - } + if (hiptr == (entry_contents & HTHIMASK)) { + ModEntry(entry, entry_contents, ptr, casep, delentry); + /* ModEntry returns or will go to delentry */ + } - /* new collision */ + /* new collision */ - GetLink(link); - GetLink(prev); - GETGC((GCENTRY *)prev + 1) = 0; - GETGC((GCENTRY *)prev) = entry_contents; - GETGC((GCENTRY *)link + 1) = prev - HTcoll; - GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + GetLink(link); + GetLink(prev); + GETGC((GCENTRY *)prev + 1) = 0; + GETGC((GCENTRY *)prev) = entry_contents; + GETGC((GCENTRY *)link + 1) = prev - HTcoll; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; - NewEntry(link, hiptr, casep, ptr); - /* NewEntry returns */ + NewEntry(link, hiptr, casep, ptr); +/* NewEntry returns */ - -delentry: GETGC(entry) = 0; - return NIL; +delentry: + GETGC(entry) = 0; + return NIL; /* start here when a collision is detected. link is a pointer to the entry in the collision table, prev is the previous collision entry or 0 if this is the first one. */ newlink: - entry_contents = GETGC(link); - if (hiptr == (entry_contents & HTHIMASK) ) - { - ModEntry(link, entry_contents, ptr, casep, dellink); - /* ModEntry returns or goes to dellink */ - } - - /* collision didn't match */ - entry_contents = GETGC((GCENTRY *)link + 1); - if (entry_contents == 0) goto nolink; - - /* try the next link in the collision table */ - prev = link; - link = HTcoll + entry_contents; - goto newlink; - -dellink: - if (prev) GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); - else GETGC((GCENTRY *)entry) = (GETGC((GCENTRY *)link + 1)) | 1; - FreeLink(link); - link = HTcoll + (GETGC((GCENTRY *)entry)) - 1; - if (GETGC(link + 1) == 0) - { - GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); - FreeLink(link); - } - return NIL; - -nolink: /* no match */ - - GetLink(link); - GETGC((GCENTRY *)link + 1) = GETGC((GCENTRY *)entry) - 1; - GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; - NewEntry(link, hiptr, casep, ptr); + entry_contents = GETGC(link); + if (hiptr == (entry_contents & HTHIMASK)) { + ModEntry(link, entry_contents, ptr, casep, dellink); + /* ModEntry returns or goes to dellink */ } + /* collision didn't match */ + entry_contents = GETGC((GCENTRY *)link + 1); + if (entry_contents == 0) goto nolink; + + /* try the next link in the collision table */ + prev = link; + link = HTcoll + entry_contents; + goto newlink; + +dellink: + if (prev) + GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); + else + GETGC((GCENTRY *)entry) = (GETGC((GCENTRY *)link + 1)) | 1; + FreeLink(link); + link = HTcoll + (GETGC((GCENTRY *)entry)) - 1; + if (GETGC(link + 1) == 0) { + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); + FreeLink(link); + } + return NIL; + +nolink: /* no match */ + + GetLink(link); + GETGC((GCENTRY *)link + 1) = GETGC((GCENTRY *)entry) - 1; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + NewEntry(link, hiptr, casep, ptr); +} /************************************************************************/ /* */ @@ -463,122 +429,111 @@ nolink: /* no match */ /* */ /************************************************************************/ -LispPTR rec_htfind(LispPTR ptr, int casep) -{ - register GCENTRY *entry, *link, *prev; - register GCENTRY entry_contents, hiptr; - register struct htlinkptr *htlptr; +LispPTR rec_htfind(LispPTR ptr, int casep) { + register GCENTRY *entry, *link, *prev; + register GCENTRY entry_contents, hiptr; + register struct htlinkptr *htlptr; - /* if the NOREF bit is on in the type table entry, do - not reference count this pointer. Used for non-reference - counted types like symbols, and also when the GC is - disabled. */ - /* - * Following two tests were moved into GCLOOKUP macro - * for efficency. - */ -/* - if (GetTypeEntry(ptr) & TT_NOREF) - return NIL; -*/ - /* if *GcDisabled_word is T then do nothing */ - /* FS: this test should not be needed (because type table should - be cleared). Also, this test seems to cause an infinite - ucode loop in remimplicitkeyhash on the 386i */ + /* if the NOREF bit is on in the type table entry, do + not reference count this pointer. Used for non-reference + counted types like symbols, and also when the GC is + disabled. */ + /* + * Following two tests were moved into GCLOOKUP macro + * for efficency. + */ + /* + if (GetTypeEntry(ptr) & TT_NOREF) + return NIL; + */ + /* if *GcDisabled_word is T then do nothing */ + /* FS: this test should not be needed (because type table should + be cleared). Also, this test seems to cause an infinite + ucode loop in remimplicitkeyhash on the 386i */ -/* if(*GcDisabled_word == ATOM_T) return(NIL); */ + /* if(*GcDisabled_word == ATOM_T) return(NIL); */ - /* GC hash table entries have the high 8 bits of the - pointer stored in the middle. Set up hiptr to have - the high bits of the pointer ready to store or test - against */ + /* GC hash table entries have the high 8 bits of the + pointer stored in the middle. Set up hiptr to have + the high bits of the pointer ready to store or test + against */ - hiptr = (((unsigned int)ptr) >> (16-HTHISHIFT) ) & HTHIMASK; + hiptr = (((unsigned int)ptr) >> (16 - HTHISHIFT)) & HTHIMASK; - /* entry points at the place in the main hash table - where this pointer is stored. The 'hash' isn't one really; - it just uses the low bits of the pointer. */ + /* entry points at the place in the main hash table + where this pointer is stored. The 'hash' isn't one really; + it just uses the low bits of the pointer. */ - entry = HTmain + (LOLOC(ptr) >> 1); + entry = HTmain + (LOLOC(ptr) >> 1); - entry_contents = GETGC(entry); + entry_contents = GETGC(entry); - if (entry_contents == 0) RecNewEntry(entry, hiptr, casep, ptr); - /* NewEntry returns */ + if (entry_contents == 0) RecNewEntry(entry, hiptr, casep, ptr); + /* NewEntry returns */ - if (entry_contents & 1) - { /* low bit means a collision entry */ - /* entry_contents-1 removes low bit */ - link = HTcoll + (entry_contents - 1); - prev = 0; - goto newlink; - } + if (entry_contents & 1) { /* low bit means a collision entry */ + /* entry_contents-1 removes low bit */ + link = HTcoll + (entry_contents - 1); + prev = 0; + goto newlink; + } - if (hiptr == (entry_contents & HTHIMASK)) - { - RecModEntry(entry, entry_contents, ptr, casep, delentry); - /* ModEntry returns or will go to delentry */ - } + if (hiptr == (entry_contents & HTHIMASK)) { + RecModEntry(entry, entry_contents, ptr, casep, delentry); + /* ModEntry returns or will go to delentry */ + } - /* new collision */ + /* new collision */ - GetLink(link); - GetLink(prev); - GETGC((GCENTRY *)prev + 1) = 0; - GETGC((GCENTRY *)prev) = entry_contents; - GETGC((GCENTRY *)link + 1) = prev - HTcoll; - GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; - - RecNewEntry(link, hiptr, casep, ptr); + GetLink(link); + GetLink(prev); + GETGC((GCENTRY *)prev + 1) = 0; + GETGC((GCENTRY *)prev) = entry_contents; + GETGC((GCENTRY *)link + 1) = prev - HTcoll; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + RecNewEntry(link, hiptr, casep, ptr); delentry: - GETGC(entry) = 0; - return NIL; + GETGC(entry) = 0; + return NIL; /* start here when a collision is detected. link is a pointer to the entry in the collision table, prev is the previous collision entry or 0 if this is the first one. */ newlink: - entry_contents = GETGC(link); - if (hiptr == (entry_contents & HTHIMASK) ) - { - RecModEntry(link, entry_contents, ptr, casep, dellink); - /* ModEntry returns or goes to dellink */ - } - /* collision didn't match */ - entry_contents = GETGC(link + 1); - if (entry_contents == 0) - { - goto nolink; - } - /* try the next link in the collision table */ - prev = link; - link = HTcoll + entry_contents; - goto newlink; + entry_contents = GETGC(link); + if (hiptr == (entry_contents & HTHIMASK)) { + RecModEntry(link, entry_contents, ptr, casep, dellink); + /* ModEntry returns or goes to dellink */ + } + /* collision didn't match */ + entry_contents = GETGC(link + 1); + if (entry_contents == 0) { goto nolink; } + /* try the next link in the collision table */ + prev = link; + link = HTcoll + entry_contents; + goto newlink; dellink: - if (prev) GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); - else GETGC((GCENTRY *)entry) = (GETGC((GCENTRY *)link + 1)) | 1; + if (prev) + GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); + else + GETGC((GCENTRY *)entry) = (GETGC((GCENTRY *)link + 1)) | 1; + FreeLink(link); + link = HTcoll + ((GETGC((GCENTRY *)entry)) - 1); + if (GETGC((GCENTRY *)link + 1) == 0) { + GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); FreeLink(link); - link = HTcoll + ((GETGC((GCENTRY *)entry)) - 1); - if (GETGC((GCENTRY *)link + 1) == 0) - { - GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); - FreeLink(link); - } - return NIL; - -nolink: /* no match */ - - GetLink(link); - GETGC((GCENTRY *)link + 1) = GETGC((GCENTRY *)entry) - 1; - GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; - RecNewEntry(link, hiptr, casep, ptr); + } + return NIL; +nolink: /* no match */ + GetLink(link); + GETGC((GCENTRY *)link + 1) = GETGC((GCENTRY *)entry) - 1; + GETGC((GCENTRY *)entry) = (link - HTcoll) + 1; + RecNewEntry(link, hiptr, casep, ptr); } - - diff --git a/src/gcmain3.c b/src/gcmain3.c old mode 100755 new mode 100644 index 57b51b5..ec6b932 --- a/src/gcmain3.c +++ b/src/gcmain3.c @@ -1,10 +1,7 @@ -/* $Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -17,10 +14,8 @@ static char *id = "$Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - /*************************************************************************/ /* */ /* File Name : gcmain3.c */ @@ -44,7 +39,7 @@ static char *id = "$Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ Copyr /* \Tomtom */ /*************************************************************************/ -#include /* for sprintf */ +#include /* for sprintf */ #include "lispemul.h" #include "lispmap.h" #include "lsptypes.h" @@ -61,62 +56,59 @@ static char *id = "$Id: gcmain3.c,v 1.4 1999/05/31 23:35:31 sybalsky Exp $ Copyr #include "inlnPS2.h" #endif - - -#define WORDSPERCELL 2 -#define MAXHTCNT 63 -#define PADDING 4 -#define FNOVERHEADWORDS 8 -#define ADD_OFFSET(ptr, dloffset) ((LispPTR *) ((DLword *) (ptr) + (dloffset))) +#define WORDSPERCELL 2 +#define MAXHTCNT 63 +#define PADDING 4 +#define FNOVERHEADWORDS 8 +#define ADD_OFFSET(ptr, dloffset) ((LispPTR *)((DLword *)(ptr) + (dloffset))) #ifdef BIGVM -#define BIND_BITS(value) ((unsigned int) (value) >> 28) -#define BF_FLAGS(value) ((unsigned int) (value) >> 29) -#define PTR_BITS(entry) ((unsigned int)(entry) & POINTERMASK) -#define GetSegnuminColl(entry1) (((entry1) & 0xFFFE) >> 1) -#define GetStkCnt(entry1) ((entry1) >> 16) -#define StkCntIsZero(entry1) (!((entry1) & 0xFFFF0000)) -#define StkrefP(entry1) ((entry1) & 0x10000) -#define SinglerefP(entry1) (((entry1) & 0xFFFE0000) == 0x20000) -#define Boundp(frame_field) ((frame_field) == 0) -#define Stkref(ptr) REC_GCLOOKUP(ptr, STKREF) -#define GcreclaimLp(ptr) while((ptr = gcreccell(ptr)) != NIL) \ - REC_GCLOOKUP(ptr, ADDREF) -#define HTLPTR ((struct htlinkptr *) (entry)) -#define HENTRY ((struct hashentry *) (entry)) +#define BIND_BITS(value) ((unsigned int)(value) >> 28) +#define BF_FLAGS(value) ((unsigned int)(value) >> 29) +#define PTR_BITS(entry) ((unsigned int)(entry)&POINTERMASK) +#define GetSegnuminColl(entry1) (((entry1)&0xFFFE) >> 1) +#define GetStkCnt(entry1) ((entry1) >> 16) +#define StkCntIsZero(entry1) (!((entry1)&0xFFFF0000)) +#define StkrefP(entry1) ((entry1)&0x10000) +#define SinglerefP(entry1) (((entry1)&0xFFFE0000) == 0x20000) +#define Boundp(frame_field) ((frame_field) == 0) +#define Stkref(ptr) REC_GCLOOKUP(ptr, STKREF) +#define GcreclaimLp(ptr) \ + while ((ptr = gcreccell(ptr)) != NIL) REC_GCLOOKUP(ptr, ADDREF) +#define HTLPTR ((struct htlinkptr *)(entry)) +#define HENTRY ((struct hashentry *)(entry)) #define HTMAIN_ENTRY_COUNT (HTMAIN_SIZE >> 1) -#define STKREFBIT 0x10000 /* the bit that says "I'm on the stack" */ +#define STKREFBIT 0x10000 /* the bit that says "I'm on the stack" */ #else -#define BIND_BITS(value) ((unsigned int) (value) >> 24) -#define BF_FLAGS(value) ((unsigned int) (value) >> 29) -#define PTR_BITS(entry) ((unsigned int)((unsigned int)((entry) << 8) >> 8)) -#define GetSegnuminColl(entry1) ((entry1 & 0x01fe) >> 1) -#define GetStkCnt(entry1) ((entry1 & 0x0fe00) >> 9) -#define StkCntIsZero(entry1) (!((entry1) & 0x0fe00)) -#define StkrefP(entry1) ((entry1) & 0x0200) -#define SinglerefP(entry1) (((entry1) & 0xFC00) == 0x0400) -#define Boundp(frame_field) ((frame_field) == 0) -#define Stkref(ptr) REC_GCLOOKUP(ptr, STKREF) -#define GcreclaimLp(ptr) while((ptr = gcreccell(ptr)) != NIL) \ - REC_GCLOOKUP(ptr, ADDREF) -#define HTLPTR ((struct htlinkptr *) WORDPTR(entry)) -#define HENTRY ((struct hashentry *) WORDPTR(entry)) +#define BIND_BITS(value) ((unsigned int)(value) >> 24) +#define BF_FLAGS(value) ((unsigned int)(value) >> 29) +#define PTR_BITS(entry) ((unsigned int)((unsigned int)((entry) << 8) >> 8)) +#define GetSegnuminColl(entry1) ((entry1 & 0x01fe) >> 1) +#define GetStkCnt(entry1) ((entry1 & 0x0fe00) >> 9) +#define StkCntIsZero(entry1) (!((entry1)&0x0fe00)) +#define StkrefP(entry1) ((entry1)&0x0200) +#define SinglerefP(entry1) (((entry1)&0xFC00) == 0x0400) +#define Boundp(frame_field) ((frame_field) == 0) +#define Stkref(ptr) REC_GCLOOKUP(ptr, STKREF) +#define GcreclaimLp(ptr) \ + while ((ptr = gcreccell(ptr)) != NIL) REC_GCLOOKUP(ptr, ADDREF) +#define HTLPTR ((struct htlinkptr *)WORDPTR(entry)) +#define HENTRY ((struct hashentry *)WORDPTR(entry)) #define HTMAIN_ENTRY_COUNT HTMAIN_SIZE #define STKREFBIT 0x200 #endif /* BIGVM */ - #ifdef GCC386 - /* byte-swapped, 386 assembler version */ -LispPTR gcmapscan() - { - volatile DLword probe; - volatile DLword *entry; - volatile DLword offset; - volatile LispPTR ptr; +/* byte-swapped, 386 assembler version */ +LispPTR gcmapscan() { + volatile DLword probe; + volatile DLword *entry; + volatile DLword offset; + volatile LispPTR ptr; - asm volatile(" \n\ + asm volatile( + " \n\ movl $32768,%%edi / probe = HTSIZE. \n\ .align 4 \n\ nextentry: / nextentry: \n\ @@ -296,335 +288,301 @@ gclp2: / GcreclaimLp \n\ jmp gclp2 \n\ .align 4 \n\ returNIL: \n\ - " : "=g" (entry), "=g" (offset), "=g" (ptr) : : "ax", "dx", "cx", "bx", "si", "di"); + " + : "=g"(entry), "=g"(offset), "=g"(ptr) + : + : "ax", "dx", "cx", "bx", "si", "di"); - return NIL; - } + return NIL; +} #else +LispPTR gcmapscan(void) { + register GCENTRY probe; + register GCENTRY *entry; + GCENTRY offset, dbgentry, dbgcontents; + register LispPTR ptr; -LispPTR gcmapscan(void) -{ - register GCENTRY probe; - register GCENTRY *entry; - GCENTRY offset, dbgentry, dbgcontents; - register LispPTR ptr; + probe = HTMAIN_ENTRY_COUNT; +nextentry: + while ((probe = gcscan1(probe)) != NIL) { + entry = (GCENTRY *)HTmain + probe; + dbgentry = GETGC(entry); + retry: + if (HENTRY->collision) { + register GCENTRY *prev; + register GCENTRY *link; + LispPTR content, dbgfree; - probe = HTMAIN_ENTRY_COUNT; - nextentry: - while ((probe = gcscan1(probe)) != NIL) - { - entry = (GCENTRY *)HTmain + probe; - dbgentry = GETGC(entry); - retry: - if (HENTRY->collision) - { - register GCENTRY *prev; - register GCENTRY *link; - LispPTR content, dbgfree; - - prev = (GCENTRY *)0; - link = (GCENTRY *)HTcoll + GetLinkptr((content = HTLPTR->contents)); - linkloop: - offset = ((struct htcoll *)link)->free_ptr; - dbgfree = ((struct htcoll *)link)->next_free; - if (StkCntIsZero(offset)) - { - /* Reclaimable object */ - ptr = VAG2(GetSegnuminColl(offset), (probe << 1)); - DelLink(link, prev, entry); - GcreclaimLp(ptr); - if (HTLPTR->contents == 0) - goto nextentry; - else - goto retry; - } - if ((offset = ((struct htcoll *)link)->next_free)) - { - prev = link; - link = (GCENTRY *)(HTcoll + offset); - goto linkloop; - } - goto nextentry; - } - if (StkCntIsZero(dbgcontents = HTLPTR->contents)) { - ptr = VAG2(HENTRY->segnum, (probe << 1)); - HTLPTR->contents = 0; - GcreclaimLp(ptr); - } + prev = (GCENTRY *)0; + link = (GCENTRY *)HTcoll + GetLinkptr((content = HTLPTR->contents)); + linkloop: + offset = ((struct htcoll *)link)->free_ptr; + dbgfree = ((struct htcoll *)link)->next_free; + if (StkCntIsZero(offset)) { + /* Reclaimable object */ + ptr = VAG2(GetSegnuminColl(offset), (probe << 1)); + DelLink(link, prev, entry); + GcreclaimLp(ptr); + if (HTLPTR->contents == 0) + goto nextentry; + else + goto retry; } - return(NIL); + if ((offset = ((struct htcoll *)link)->next_free)) { + prev = link; + link = (GCENTRY *)(HTcoll + offset); + goto linkloop; + } + goto nextentry; + } + if (StkCntIsZero(dbgcontents = HTLPTR->contents)) { + ptr = VAG2(HENTRY->segnum, (probe << 1)); + HTLPTR->contents = 0; + GcreclaimLp(ptr); + } } + return (NIL); +} #endif /* GCC386 */ +LispPTR gcmapunscan(void) { + register GCENTRY probe; + register GCENTRY *entry; + GCENTRY offset; + register LispPTR ptr; + probe = HTMAIN_ENTRY_COUNT; + while ((probe = gcscan2(probe)) != NIL) { + entry = (GCENTRY *)HTmain + probe; + retry: + if (HENTRY->collision) { + register GCENTRY *prev; + register GCENTRY *link; - -LispPTR gcmapunscan(void) -{ - register GCENTRY probe; - register GCENTRY *entry; - GCENTRY offset; - register LispPTR ptr; - - probe = HTMAIN_ENTRY_COUNT; - while ((probe = gcscan2(probe)) != NIL) { - entry = (GCENTRY *)HTmain + probe; - retry: - if (HENTRY->collision) { - register GCENTRY *prev; - register GCENTRY *link; - - prev = (GCENTRY *)0; - link = (GCENTRY *)(HTcoll + GetLinkptr(HTLPTR->contents)); - scnlp: - offset = ((struct htcoll *)link)->free_ptr; - if (StkrefP(offset)) { - if (SinglerefP(offset)) { - DelLink(link, prev, entry); - goto retry; - } else { - GETGC((GCENTRY *)link) = - offset & (~ STKREFBIT); - } - } - if ((offset = ((struct htcoll *)link)->next_free)) { - prev = link; - link = (GCENTRY *)(HTcoll + offset); - goto scnlp; - } - } else if (HENTRY->stackref) { - if (HENTRY->count == 1) - HTLPTR->contents = 0; - else - HENTRY->stackref = 0; - } - } - return(NIL); + prev = (GCENTRY *)0; + link = (GCENTRY *)(HTcoll + GetLinkptr(HTLPTR->contents)); + scnlp: + offset = ((struct htcoll *)link)->free_ptr; + if (StkrefP(offset)) { + if (SinglerefP(offset)) { + DelLink(link, prev, entry); + goto retry; + } else { + GETGC((GCENTRY *)link) = offset & (~STKREFBIT); + } + } + if ((offset = ((struct htcoll *)link)->next_free)) { + prev = link; + link = (GCENTRY *)(HTcoll + offset); + goto scnlp; + } + } else if (HENTRY->stackref) { + if (HENTRY->count == 1) + HTLPTR->contents = 0; + else + HENTRY->stackref = 0; + } + } + return (NIL); } +LispPTR gcscanstack(void) { + register Bframe *bascframe; + Bframe *obascframe; + LispPTR scanptr, scanend; + UNSIGNED scanend68K; + struct fnhead *nametable; + int ftyp; + int pvcount; - - -LispPTR gcscanstack(void) -{ - register Bframe *bascframe; - Bframe *obascframe; - LispPTR scanptr,scanend; - UNSIGNED scanend68K; - struct fnhead *nametable; - int ftyp; - int pvcount; - - scanptr = VAG2(STK_HI,InterfacePage->stackbase); - scanend = VAG2(STK_HI,InterfacePage->endofstack); - scanend68K = (UNSIGNED) Addr68k_from_LADDR(scanend); + scanptr = VAG2(STK_HI, InterfacePage->stackbase); + scanend = VAG2(STK_HI, InterfacePage->endofstack); + scanend68K = (UNSIGNED)Addr68k_from_LADDR(scanend); bascframe = (Bframe *)Addr68k_from_LADDR(scanptr); - if (0 != 3 & (UNSIGNED)bascframe) - { - char debugStr[100]; - sprintf(debugStr, "Frame ptr (0x%x) not to word bound " - "at start of gcscanstack.", bascframe); - error(debugStr); - } - - while (1) { + if (0 != 3 & (UNSIGNED)bascframe) { + char debugStr[100]; + sprintf(debugStr, + "Frame ptr (0x%x) not to word bound " + "at start of gcscanstack.", + bascframe); + error(debugStr); + } + while (1) { /*This is endless loop until encountering tail of stack */ ftyp = (int)bascframe->flags; - switch(ftyp) - { - case STK_FX: - { - { - register struct frameex1 *frameex; - register struct fnhead *fnheader; - frameex = (struct frameex1 *)bascframe; - scanptr = LADDR_from_68k(frameex); - { - register LispPTR fn_head; + switch (ftyp) { + case STK_FX: { + { + register struct frameex1 *frameex; + register struct fnhead *fnheader; + frameex = (struct frameex1 *)bascframe; + scanptr = LADDR_from_68k(frameex); + { + register LispPTR fn_head; #ifdef BIGVM - fn_head = (LispPTR) (frameex->fnheader); + fn_head = (LispPTR)(frameex->fnheader); #else - fn_head = (LispPTR) - VAG2(frameex->hi2fnheader, - frameex->lofnheader); + fn_head = (LispPTR)VAG2(frameex->hi2fnheader, frameex->lofnheader); #endif /* BIGVM */ - Stkref(fn_head); - fnheader = (struct fnhead *) - Addr68k_from_LADDR(fn_head); - }; - { - register int pcou; - register LispPTR *pvars; - pvars =(LispPTR *) - ((DLword *)bascframe + FRAMESIZE); - for (pcou = fnheader->nlocals;pcou-- != 0;) { - register LispPTR value; - value = *pvars; - if Boundp(BIND_BITS(value)) Stkref(value); - ++pvars; - }; /* for */ - }; /* register int pcou */ - - { - register UNSIGNED qtemp; - register UNSIGNED next; - register UNSIGNED ntend; - - next = qtemp = (UNSIGNED) - Addr68k_from_StkOffset(frameex->nextblock); - /* this is offset */ - ntend = 0; /* init flag */ - if (frameex->validnametable) { - register LispPTR nametable; + Stkref(fn_head); + fnheader = (struct fnhead *)Addr68k_from_LADDR(fn_head); + }; + { + register int pcou; + register LispPTR *pvars; + pvars = (LispPTR *)((DLword *)bascframe + FRAMESIZE); + for (pcou = fnheader->nlocals; pcou-- != 0;) { + register LispPTR value; + value = *pvars; + if + Boundp(BIND_BITS(value)) Stkref(value); + ++pvars; + }; /* for */ + }; /* register int pcou */ + + { + register UNSIGNED qtemp; + register UNSIGNED next; + register UNSIGNED ntend; + + next = qtemp = (UNSIGNED)Addr68k_from_StkOffset(frameex->nextblock); + /* this is offset */ + ntend = 0; /* init flag */ + if (frameex->validnametable) { + register LispPTR nametable; #ifdef BIGVM - nametable = frameex->nametable; -#define hi2nametable (nametable >> 16 ) + nametable = frameex->nametable; +#define hi2nametable (nametable >> 16) #else - register unsigned int hi2nametable; - register unsigned int lonametable; - lonametable = frameex->lonametable; - hi2nametable = frameex->hi2nametable; - nametable = VAG2(hi2nametable,lonametable); + register unsigned int hi2nametable; + register unsigned int lonametable; + lonametable = frameex->lonametable; + hi2nametable = frameex->hi2nametable; + nametable = VAG2(hi2nametable, lonametable); #endif /* BIGVM */ - if (STK_HI == hi2nametable) - { - Stkref(fnheader->framename); + if (STK_HI == hi2nametable) { + Stkref(fnheader->framename); #ifdef BIGVM - qtemp = (UNSIGNED) - Addr68k_from_StkOffset(nametable&0xFFFF); + qtemp = (UNSIGNED)Addr68k_from_StkOffset(nametable & 0xFFFF); #else - qtemp = (UNSIGNED) - Addr68k_from_StkOffset(lonametable); + qtemp = (UNSIGNED)Addr68k_from_StkOffset(lonametable); #endif - ntend = (UNSIGNED) ( - ((DLword *)qtemp) + - FNHEADSIZE + - (((struct fnhead *)qtemp)->ntsize)*2); - } else Stkref(nametable); - }; /* frameex->validnametable */ + ntend = (UNSIGNED)(((DLword *)qtemp) + FNHEADSIZE + + (((struct fnhead *)qtemp)->ntsize) * 2); + } else + Stkref(nametable); + }; /* frameex->validnametable */ - obascframe = bascframe; - bascframe = (Bframe *) - ADD_OFFSET(bascframe, FRAMESIZE+PADDING+ - (((fnheader->pv)+1)<<2)); + obascframe = bascframe; + bascframe = + (Bframe *)ADD_OFFSET(bascframe, FRAMESIZE + PADDING + (((fnheader->pv) + 1) << 2)); - if (0 != 3 & (UNSIGNED)bascframe) - { - char debugStr[100]; - sprintf(debugStr, "Frame ptr (0x%x) not to word bound " - "in gcscanstack() STK_FX case; old frame = 0x%x.", - bascframe, obascframe); - error(debugStr); - } + if (0 != 3 & (UNSIGNED)bascframe) { + char debugStr[100]; + sprintf(debugStr, + "Frame ptr (0x%x) not to word bound " + "in gcscanstack() STK_FX case; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } - scantemps: - while((UNSIGNED)bascframe < (UNSIGNED )qtemp) { - register LispPTR value; - value = *((LispPTR *) bascframe); - if Boundp(BIND_BITS(value)) Stkref(value); - bascframe++; - }; /* while */ - - if (ntend != 0) { - obascframe = bascframe; - bascframe = (Bframe *) - Addr68k_from_StkOffset(ntend); - if (0 != 3 & (UNSIGNED)bascframe) - { - char debugStr[100]; - sprintf(debugStr, "Frame ptr (0x%x) not to word bound " - "in gcscanstack() scantemps; old frame = 0x%x.", - bascframe, obascframe); - error(debugStr); - } + scantemps: + while ((UNSIGNED)bascframe < (UNSIGNED)qtemp) { + register LispPTR value; + value = *((LispPTR *)bascframe); + if + Boundp(BIND_BITS(value)) Stkref(value); + bascframe++; + }; /* while */ - qtemp = next; - ntend = 0; - goto scantemps; - }; + if (ntend != 0) { + obascframe = bascframe; + bascframe = (Bframe *)Addr68k_from_StkOffset(ntend); + if (0 != 3 & (UNSIGNED)bascframe) { + char debugStr[100]; + sprintf(debugStr, + "Frame ptr (0x%x) not to word bound " + "in gcscanstack() scantemps; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } - obascframe = bascframe; - bascframe = (Bframe *) next; + qtemp = next; + ntend = 0; + goto scantemps; + }; - if (0 != 3 & (UNSIGNED)bascframe) - { - char debugStr[100]; - sprintf(debugStr, "Frame ptr (0x%x) not to word bound " - "in gcscanstack(), end scantemps; old frame = 0x%x.", - bascframe, obascframe); - error(debugStr); - } + obascframe = bascframe; + bascframe = (Bframe *)next; - - }; /* LOCAL regs qtemp next */ - }; /* local regs fnheader frameex */ - break; - }; - case STK_GUARD:/* stack's tail ? */ { - if ((UNSIGNED) bascframe >= (UNSIGNED) scanend68K) - return(NIL); - else { - obascframe = bascframe; - bascframe = (Bframe *)((DLword *) - bascframe + bascframe->ivar); + if (0 != 3 & (UNSIGNED)bascframe) { + char debugStr[100]; + sprintf(debugStr, + "Frame ptr (0x%x) not to word bound " + "in gcscanstack(), end scantemps; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } - if (0 != 3 & (UNSIGNED)bascframe) - { - char debugStr[100]; - sprintf(debugStr, "Frame ptr (0x%x) not to word bound " - "in gcscanstack() STK_GUARD; old frame = 0x%x.", - bascframe, obascframe); - error(debugStr); - } - - }; - break; + }; /* LOCAL regs qtemp next */ + }; /* local regs fnheader frameex */ + break; }; - case STK_FSB: { - obascframe = bascframe; - bascframe = (Bframe *)((DLword *) - bascframe + bascframe->ivar); + case STK_GUARD: /* stack's tail ? */ { + if ((UNSIGNED)bascframe >= (UNSIGNED)scanend68K) + return (NIL); + else { + obascframe = bascframe; + bascframe = (Bframe *)((DLword *)bascframe + bascframe->ivar); - if (0 != 3 & (UNSIGNED)bascframe) - { - char debugStr[100]; - sprintf(debugStr, "Frame ptr (0x%x) not to word bound " - "in gcscanstack() STK_FSB; old frame = 0x%x.", - bascframe, obascframe); - error(debugStr); - } - - break; + if (0 != 3 & (UNSIGNED)bascframe) { + char debugStr[100]; + sprintf(debugStr, + "Frame ptr (0x%x) not to word bound " + "in gcscanstack() STK_GUARD; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } + }; + break; }; - default: /* must be basic frame !! */ - { - register LispPTR bf_word; - while(STK_BF != BF_FLAGS(bf_word = *((LispPTR *)bascframe))) - { Stkref(PTR_BITS(bf_word)); - bascframe++; - }; - bascframe++; - }; - - - /* **** NOTE THIS CODE DOES NOT COMPILE CORRECTLY ON THE SUN 4 - {register LispPTR bf_word; - while(STK_BF != BF_FLAGS( - bf_word = *((LispPTR *)bascframe++))) - { Stkref(PTR_BITS(bf_word)); - }; - }; - **** */ - }; /* switch */ - }; /* while(1) */ + case STK_FSB: { + obascframe = bascframe; + bascframe = (Bframe *)((DLword *)bascframe + bascframe->ivar); + + if (0 != 3 & (UNSIGNED)bascframe) { + char debugStr[100]; + sprintf(debugStr, + "Frame ptr (0x%x) not to word bound " + "in gcscanstack() STK_FSB; old frame = 0x%x.", + bascframe, obascframe); + error(debugStr); + } + + break; + }; + default: /* must be basic frame !! */ + { + register LispPTR bf_word; + while (STK_BF != BF_FLAGS(bf_word = *((LispPTR *)bascframe))) { + Stkref(PTR_BITS(bf_word)); + bascframe++; + }; + bascframe++; + }; + + /* **** NOTE THIS CODE DOES NOT COMPILE CORRECTLY ON THE SUN 4 + {register LispPTR bf_word; + while(STK_BF != BF_FLAGS( + bf_word = *((LispPTR *)bascframe++))) + { Stkref(PTR_BITS(bf_word)); + }; + }; + **** */ + }; /* switch */ + }; /* while(1) */ } - - - - - - diff --git a/src/gcoflow.c b/src/gcoflow.c old mode 100755 new mode 100644 index 2e5cc16..ced726a --- a/src/gcoflow.c +++ b/src/gcoflow.c @@ -1,8 +1,7 @@ -/* $Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -34,10 +33,8 @@ static char *id = "$Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyr /* \Tomtom */ /*************************************************************************/ - #include "version.h" - #include "lispemul.h" #include "lsptypes.h" #include "address.h" @@ -45,74 +42,67 @@ static char *id = "$Id: gcoflow.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyr #include "lspglob.h" #include "gc.h" +#define MAXSMALLP 65535 +#define HTBIGENTRYSIZE 4 +#define WORDSPERPAGE 256 +#define MAXTYPENUMBER INIT_TYPENUM +#define Oddp(num) (((num % 2) != 0) ? 1 : 0) +#define Evenp(num, prim) (((num % prim) == 0) ? 1 : 0) +#define Increment_Allocation_Count(n) \ + if (*Reclaim_cnt_word != NIL) \ + if (*Reclaim_cnt_word > n) \ + (*Reclaim_cnt_word) -= n; \ + else { \ + *Reclaim_cnt_word = NIL; \ + doreclaim(); \ + }; +DLword gc_handleoverflow(DLword arg) { + struct htoverflow *cell; + struct dtd *ptr; + LispPTR cellcnt; + LispPTR addr; + cell = (struct htoverflow *)HToverflow; + /* This proc. protected from interrupt */ + while ((addr = cell->ptr) != NIL) { + REC_GCLOOKUP(addr, cell->pcase); + cell->ptr = 0; + cell->pcase = 0; + ++cell; /* (\ADDBASE CELL WORDSPERCELL) */ + }; + ptr = (struct dtd *)GetDTD(TYPE_LISTP); + /* same as "extern struct dtd *ListpDTD" */ + if ((cellcnt = ptr->dtd_cnt0) > 1024) { + Increment_Allocation_Count(cellcnt); + ptr->dtd_oldcnt += cellcnt; + ptr->dtd_cnt0 = 0; + }; + return (arg); +} -#define MAXSMALLP 65535 -#define HTBIGENTRYSIZE 4 -#define WORDSPERPAGE 256 -#define MAXTYPENUMBER INIT_TYPENUM -#define Oddp(num) (((num % 2) != 0)?1:0) -#define Evenp(num,prim) (((num % prim) == 0)?1:0) -#define Increment_Allocation_Count(n) \ - if (*Reclaim_cnt_word != NIL) \ - if (*Reclaim_cnt_word > n) \ - (*Reclaim_cnt_word) -= n; \ - else { *Reclaim_cnt_word = NIL; \ - doreclaim(); \ - }; \ - - -DLword gc_handleoverflow(DLword arg) -{ struct htoverflow *cell; - struct dtd *ptr; - LispPTR cellcnt; - LispPTR addr; - cell = (struct htoverflow *)HToverflow; - /* This proc. protected from interrupt */ - while((addr = cell->ptr) != NIL) - { - REC_GCLOOKUP(addr, cell->pcase); - cell->ptr = 0; - cell->pcase = 0; - ++cell; /* (\ADDBASE CELL WORDSPERCELL) */ - }; - ptr = (struct dtd *)GetDTD(TYPE_LISTP); - /* same as "extern struct dtd *ListpDTD" */ - if ((cellcnt = ptr->dtd_cnt0) > 1024) - { Increment_Allocation_Count(cellcnt); - ptr->dtd_oldcnt += cellcnt; - ptr->dtd_cnt0 = 0; - }; - return(arg); - } - -DLword gcmaptable(DLword arg) -{ struct htoverflow *cell; - struct dtd *ptr; - LispPTR cellcnt; - int typnum; - LispPTR addr; - cell = (struct htoverflow *)HToverflow; - /* This proc. protected from interrupt */ - while((addr = cell->ptr) != NIL) - { - REC_GCLOOKUP(addr, cell->pcase); - cell->ptr = 0; - cell->pcase = 0; - ++cell; /* (\ADDBASE CELL WORDSPERCELL) */ - }; - for(typnum = 1; typnum <= *MaxTypeNumber_word; ++typnum) - /* applied alltype */ - { ptr = (struct dtd *)GetDTD(typnum); - if ((cellcnt = ptr->dtd_cnt0) != 0) - { ptr->dtd_oldcnt += cellcnt; - ptr->dtd_cnt0 = 0; - Increment_Allocation_Count(cellcnt); - }; - }; - return(arg); - } - - - - +DLword gcmaptable(DLword arg) { + struct htoverflow *cell; + struct dtd *ptr; + LispPTR cellcnt; + int typnum; + LispPTR addr; + cell = (struct htoverflow *)HToverflow; + /* This proc. protected from interrupt */ + while ((addr = cell->ptr) != NIL) { + REC_GCLOOKUP(addr, cell->pcase); + cell->ptr = 0; + cell->pcase = 0; + ++cell; /* (\ADDBASE CELL WORDSPERCELL) */ + }; + for (typnum = 1; typnum <= *MaxTypeNumber_word; ++typnum) + /* applied alltype */ + { + ptr = (struct dtd *)GetDTD(typnum); + if ((cellcnt = ptr->dtd_cnt0) != 0) { + ptr->dtd_oldcnt += cellcnt; + ptr->dtd_cnt0 = 0; + Increment_Allocation_Count(cellcnt); + }; + }; + return (arg); +} diff --git a/src/gcr.c b/src/gcr.c old mode 100755 new mode 100644 index 048fd9f..3afdd36 --- a/src/gcr.c +++ b/src/gcr.c @@ -1,8 +1,6 @@ /* $Id: gcr.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: gcr.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -58,10 +56,8 @@ static char *id = "$Id: gcr.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright /* \tomtom */ /*************************************************************************/ - #include "version.h" - #include "lispemul.h" #include "lispmap.h" #include "emlglob.h" @@ -72,52 +68,47 @@ static char *id = "$Id: gcr.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright #include "stack.h" #include "gc.h" - - -#define MAXSMALLP 65535 -#define HTBIGENTRYSIZE 4 -#define WORDSPERPAGE 256 -#define WORDSPERCELL 2 -#define MAXTYPENUMBER INIT_TYPENUM -#define STK_HI 1 +#define MAXSMALLP 65535 +#define HTBIGENTRYSIZE 4 +#define WORDSPERPAGE 256 +#define WORDSPERCELL 2 +#define MAXTYPENUMBER INIT_TYPENUM +#define STK_HI 1 #ifndef BYTESWAP - struct interruptstate - { unsigned nil1 :3; - unsigned gcdisabled :1; - unsigned vmemfull :1; - unsigned stackoverflow :1; - unsigned storagefull :1; - unsigned waitinginterrupt :1; - unsigned nil2 :8; - DLword intcharcode; - }; +struct interruptstate { + unsigned nil1 : 3; + unsigned gcdisabled : 1; + unsigned vmemfull : 1; + unsigned stackoverflow : 1; + unsigned storagefull : 1; + unsigned waitinginterrupt : 1; + unsigned nil2 : 8; + DLword intcharcode; +}; #else - struct interruptstate - { - DLword intcharcode; - unsigned nil2 :8; - unsigned waitinginterrupt :1; - unsigned storagefull :1; - unsigned stackoverflow :1; - unsigned vmemfull :1; - unsigned gcdisabled :1; - unsigned nil1 :3; - }; +struct interruptstate { + DLword intcharcode; + unsigned nil2 : 8; + unsigned waitinginterrupt : 1; + unsigned storagefull : 1; + unsigned stackoverflow : 1; + unsigned vmemfull : 1; + unsigned gcdisabled : 1; + unsigned nil1 : 3; +}; #endif /* BYTESWAP */ - -void gcarrangementstack(void) -{ LispPTR tmpnextblock; - PushCStack; - tmpnextblock = LADDR_from_68k(CurrentStackPTR+=WORDSPERCELL); - CURRENTFX->nextblock = LOLOC(tmpnextblock); -if ((UNSIGNED)EndSTKP == (UNSIGNED)CurrentStackPTR) error("creating 0-long stack block."); - GETWORD(CurrentStackPTR)=STK_FSB_WORD; - GETWORD(CurrentStackPTR+1)=(((UNSIGNED)EndSTKP-(UNSIGNED)CurrentStackPTR)>>1); +void gcarrangementstack(void) { + LispPTR tmpnextblock; + PushCStack; + tmpnextblock = LADDR_from_68k(CurrentStackPTR += WORDSPERCELL); + CURRENTFX->nextblock = LOLOC(tmpnextblock); + if ((UNSIGNED)EndSTKP == (UNSIGNED)CurrentStackPTR) error("creating 0-long stack block."); + GETWORD(CurrentStackPTR) = STK_FSB_WORD; + GETWORD(CurrentStackPTR + 1) = (((UNSIGNED)EndSTKP - (UNSIGNED)CurrentStackPTR) >> 1); } - /****************************************************************/ /* The following function is the caller that is the reclaimer. */ /* And, this function is same as \DOGC1 in Lisp because in the */ @@ -125,60 +116,49 @@ if ((UNSIGNED)EndSTKP == (UNSIGNED)CurrentStackPTR) error("creating 0-long stack /* remaining the system status. */ /****************************************************************/ -void dogc01(void) -{ - gcarrangementstack(); - gcscanstack(); - gcmapscan(); - gcmapunscan(); - PopCStack; - } +void dogc01(void) { + gcarrangementstack(); + gcscanstack(); + gcmapscan(); + gcmapunscan(); + PopCStack; +} /*!!!!!! should update clock in Miscstats */ -void doreclaim(void) -{ - int gctm1; - MISCSTATS gcmisc; +void doreclaim(void) { + int gctm1; + MISCSTATS gcmisc; - if (*GcDisabled_word == NIL) - { - update_miscstats(); - gcmisc = *((MISCSTATS *)MiscStats); - *Reclaim_cnt_word = NIL; - if (*GcMess_word != NIL) flip_cursor(); - dogc01(); - if (*GcMess_word != NIL) flip_cursor(); - *Reclaim_cnt_word = *ReclaimMin_word; - update_miscstats(); - MiscStats->gctime = MiscStats->gctime + - MiscStats->totaltime - gcmisc.totaltime + - MiscStats->swapwaittime - gcmisc.swapwaittime; - } - } - - - -void disablegc1(int noerror) -{ - struct interruptstate *gcinterruptstate; - int count, i; - DLword typeword; - gcinterruptstate = (struct interruptstate *) - Addr68k_from_LADDR(*INTERRUPTSTATE_word); - count = (128)*256; /* This is test value. 128 is *MdsTTsize(\MDSTTsize) */ - for(i = 0;i < count;i++) - { - typeword = GETWORD((DLword *)Addr68k_from_LADDR(LADDR_from_68k(MDStypetbl)+i)); - GETWORD((DLword *)Addr68k_from_LADDR(LADDR_from_68k(MDStypetbl)+i) ) - = (typeword | TT_NOREF); - } + if (*GcDisabled_word == NIL) { + update_miscstats(); + gcmisc = *((MISCSTATS *)MiscStats); *Reclaim_cnt_word = NIL; - *ReclaimMin_word = NIL; - if ((noerror == NIL) && (*GcDisabled_word == NIL)) - { - gcinterruptstate->gcdisabled = T; - *PENDINGINTERRUPT_word = ATOM_T; - }; - *GcDisabled_word = ATOM_T; + if (*GcMess_word != NIL) flip_cursor(); + dogc01(); + if (*GcMess_word != NIL) flip_cursor(); + *Reclaim_cnt_word = *ReclaimMin_word; + update_miscstats(); + MiscStats->gctime = MiscStats->gctime + MiscStats->totaltime - gcmisc.totaltime + + MiscStats->swapwaittime - gcmisc.swapwaittime; } +} + +void disablegc1(int noerror) { + struct interruptstate *gcinterruptstate; + int count, i; + DLword typeword; + gcinterruptstate = (struct interruptstate *)Addr68k_from_LADDR(*INTERRUPTSTATE_word); + count = (128) * 256; /* This is test value. 128 is *MdsTTsize(\MDSTTsize) */ + for (i = 0; i < count; i++) { + typeword = GETWORD((DLword *)Addr68k_from_LADDR(LADDR_from_68k(MDStypetbl) + i)); + GETWORD((DLword *)Addr68k_from_LADDR(LADDR_from_68k(MDStypetbl) + i)) = (typeword | TT_NOREF); + } + *Reclaim_cnt_word = NIL; + *ReclaimMin_word = NIL; + if ((noerror == NIL) && (*GcDisabled_word == NIL)) { + gcinterruptstate->gcdisabled = T; + *PENDINGINTERRUPT_word = ATOM_T; + }; + *GcDisabled_word = ATOM_T; +} diff --git a/src/gcrcell.c b/src/gcrcell.c old mode 100755 new mode 100644 index a641c5f..0225ae3 --- a/src/gcrcell.c +++ b/src/gcrcell.c @@ -1,10 +1,7 @@ -/* $Id: gcrcell.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gcrcell.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gcrcell.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,10 +14,8 @@ static char *id = "$Id: gcrcell.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - /*************************************************************************/ /* */ /* File Name : gcrcell.c */ @@ -88,23 +83,24 @@ static char *id = "$Id: gcrcell.c,v 1.3 1999/05/31 23:35:32 sybalsky Exp $ Copyr #ifdef NEWCDRCODING #undef CONSPAGE_LAST -#define CONSPAGE_LAST 0x0ffffffff +#define CONSPAGE_LAST 0x0ffffffff #else #undef CONSPAGE_LAST -#define CONSPAGE_LAST 0x0ffff +#define CONSPAGE_LAST 0x0ffff #endif /* NEWCDRCODING */ #define TODO_LIMIT 1000 -#define ADD_TO_DO(ptr,offset) \ - if (do_count < TODO_LIMIT) \ - { \ - if (ptr & 0xF0000000) error("illegal ptr in addtodo"); \ - to_do[do_count] = (ptr); \ - to_do_offset[do_count] = offset; \ - todo_uses++; \ - /*REC_GCLOOKUP((ptr), ADDREF);*/ \ - do_count++; \ - } else { /* error("GC missing some to-do's"); */ todo_misses++; } +#define ADD_TO_DO(ptr, offset) \ + if (do_count < TODO_LIMIT) { \ + if (ptr & 0xF0000000) error("illegal ptr in addtodo"); \ + to_do[do_count] = (ptr); \ + to_do_offset[do_count] = offset; \ + todo_uses++; \ + /*REC_GCLOOKUP((ptr), ADDREF);*/ \ + do_count++; \ + } else { /* error("GC missing some to-do's"); */ \ + todo_misses++; \ + } unsigned todo_uses = 0; unsigned todo_misses = 0; @@ -120,216 +116,201 @@ void freelistcell(LispPTR cell); /* */ /************************************************************************/ -LispPTR gcreccell(LispPTR cell) -{ - register ConsCell *ptr; - struct dtd *typdtd; - DLword typ; - register LispPTR tmpptr, donext, tmpcell, val; - LispPTR ptrfield, carfield; - int index, code; - LispPTR *field; - int freecnt; - LispPTR freeptr; +LispPTR gcreccell(LispPTR cell) { + register ConsCell *ptr; + struct dtd *typdtd; + DLword typ; + register LispPTR tmpptr, donext, tmpcell, val; + LispPTR ptrfield, carfield; + int index, code; + LispPTR *field; + int freecnt; + LispPTR freeptr; #ifdef NEWCDRCODING - LispPTR to_do[TODO_LIMIT]; /* table of pointers to follow, since Cdr coding lost */ - short to_do_offset[TODO_LIMIT]; /* offset in datatype */ - unsigned do_count = 0; /* counter of entries in to_do table */ -#endif /* NEWCDRCODING */ + LispPTR to_do[TODO_LIMIT]; /* table of pointers to follow, since Cdr coding lost */ + short to_do_offset[TODO_LIMIT]; /* offset in datatype */ + unsigned do_count = 0; /* counter of entries in to_do table */ +#endif /* NEWCDRCODING */ - val = NIL; - tmpptr = cell; - index = -1; - donext = NIL; - lp: - ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr&-2); + val = NIL; + tmpptr = cell; + index = -1; + donext = NIL; +lp: + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr & -2); /* # ifdef CHECK if (refcnt(tmpptr) != 1) error("reclaiming cell w/refcnt not 1"); # endif */ #ifdef DEBUG - if (tmpptr & 1) error("Reclaiming cell pointer with low bit 1."); + if (tmpptr & 1) error("Reclaiming cell pointer with low bit 1."); #else - tmpptr &= -2; /* turn off low bit of pointer, so we never reclaim odd'ns */ + tmpptr &= -2; /* turn off low bit of pointer, so we never reclaim odd'ns */ #endif - if ((tmpptr & 0x0FFF0000) == 0x60000) error("freeing an old atom??"); + if ((tmpptr & 0x0FFF0000) == 0x60000) error("freeing an old atom??"); - typ = GetTypeNumber(tmpptr); + typ = GetTypeNumber(tmpptr); #ifdef DEBUG - if (typ==6) printf("Reclaiming array ptr 0x%x.\n", tmpptr); + if (typ == 6) printf("Reclaiming array ptr 0x%x.\n", tmpptr); #endif - switch(typ) - { - case TYPE_LISTP: - { - if ((code = ptr->cdr_code) == CDR_INDIRECT) /* indirect */ - { tmpcell = ptr->car_field; /* Monitor */ - freelistcell(tmpptr); - ptr = (ConsCell *) Addr68k_from_LADDR(tmpcell); - tmpptr = tmpcell; - code = ptr->cdr_code; - }; - if (index != -1) /* car part */ - index = -1; - else - { - REC_GCLOOKUPV(car(tmpptr), DELREF, val); - if (val != NIL) - { - ptr->car_field = donext; - ptr->cdr_code = code; - donext = tmpptr; - goto doval; - }; - } - REC_GCLOOKUPV(cdr(tmpptr), DELREF, val); - if (code <= CDR_MAXINDIRECT) - { -#ifdef NEWCDRCODING - tmpcell = tmpptr + ((code - CDR_INDIRECT) << 1); -#else - tmpcell = POINTER_PAGEBASE(tmpptr) - + ((code - CDR_INDIRECT) << 1); -#endif /* NEWCDRCODING */ - freelistcell(tmpcell); - }; - freelistcell(tmpptr); - goto doval; - }; - case TYPE_ARRAYBLOCK: - if ((index == -1) && reclaimarrayblock(tmpptr)) - goto trynext; - else break; - case TYPE_STACKP: - if ((index == -1) && reclaimstackp(tmpptr)) goto trynext; - break; - case TYPE_VMEMPAGEP: - if ((index == -1) && releasingvmempage(tmpptr)) - { - goto trynext; - } - else break; - case TYPE_CODEHUNK1: - case TYPE_CODEHUNK2: - case TYPE_CODEHUNK3: - case TYPE_CODEHUNK4: - case TYPE_CODEHUNK5: - case TYPE_CODEHUNK6: - case TYPE_CODEHUNK7: - case TYPE_CODEHUNK8: - case TYPE_CODEHUNK9: - case TYPE_CODEHUNK10: - if ((index == -1) && reclaimcodeblock(tmpptr)) goto trynext; - else break; - default: ; - }; - normal: - typdtd = (struct dtd *)GetDTD(typ); - ptrfield = typdtd->dtd_ptrs; - if (index != -1) + switch (typ) { + case TYPE_LISTP: { + if ((code = ptr->cdr_code) == CDR_INDIRECT) /* indirect */ { - index = (index << 1); - ptrfield = cdr(ptrfield); - while ((car(ptrfield) & 0x0ffff) != index) ptrfield = cdr(ptrfield); - index = -1; - }; - while(ptrfield != NIL) - { - carfield = car(ptrfield); - ptrfield = cdr(ptrfield); - carfield &= 0x0ffff; - REC_GCLOOKUPV((POINTERMASK & - *(LispPTR *)Addr68k_from_LADDR(tmpptr+carfield)), - DELREF, val); -#ifndef NEWCDRCODING - if (val != NIL) - { - if (ptrfield != NIL) - { - ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); - ptr->car_field = donext; - ptr->cdr_code = ((car(ptrfield) & 0x0ffff) >> 1); - donext = tmpptr; - goto doval; - } - else goto addtofreelist; - }; -#else - if (val != NIL) - { - if (ptrfield != NIL) - { - if ((carfield = car(ptrfield) & 0x0ffff) >> 1 < 15) - { - ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); - ptr->car_field = donext; - ptr->cdr_code = ((car(ptrfield) & 0x0ffff) >> 1); - donext = tmpptr; - goto doval; - } - else - { ADD_TO_DO(tmpptr, (car(ptrfield) & 0xffff)>>1); goto doval; } - } - else goto addtofreelist; - }; -#endif /* NEWCDRCODING */ + tmpcell = ptr->car_field; /* Monitor */ + freelistcell(tmpptr); + ptr = (ConsCell *)Addr68k_from_LADDR(tmpcell); + tmpptr = tmpcell; + code = ptr->cdr_code; }; - addtofreelist: - field = (LispPTR *)Addr68k_from_LADDR(tmpptr); - *field = typdtd->dtd_free; - typdtd->dtd_free = tmpptr & POINTERMASK; -#ifdef DTDDEBUG - check_dtd_chain(GetTypeNumber(tmpptr & POINTERMASK)); -#endif - - /******************************/ - /* */ - /* Freeing one cell made another cell's refcnt = 0. */ - /* ADDREF the second cell (to remove it from the GC table) */ - /* and reclaim it. */ - /************************************************************/ - doval: - if (val != NIL) - { - tmpptr = val; - REC_GCLOOKUP(tmpptr, ADDREF); -/* GCLOOKUP(0x8000, ADDREF,tmpptr); */ - val = NIL; - goto lp; - }; - - /***************************************************************/ - /* */ - /* Finished freeing the main cell, but we may have saved other */ - /* cells whose refcnt's went to 0 along the way. This is */ - /* where we work down the list of saved items to free. */ - /* */ - /****************************************************************/ - trynext: - if (donext != NIL) - { - tmpptr = donext; - ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); - donext = (LispPTR)ptr->car_field; - index = ptr->cdr_code; - goto lp; - }; -#ifdef NEWCDRCODING - if (do_count) /* If there are other cells to collect */ - { - do_count--; - tmpptr = to_do[do_count]; - index = to_do_offset[do_count]; - todo_reads++; - /*REC_GCLOOKUP(tmpptr, ADDREF); */ - goto lp; + if (index != -1) /* car part */ + index = -1; + else { + REC_GCLOOKUPV(car(tmpptr), DELREF, val); + if (val != NIL) { + ptr->car_field = donext; + ptr->cdr_code = code; + donext = tmpptr; + goto doval; + }; } -#endif /*NEWCDRCODING */ - return(NIL); - } + REC_GCLOOKUPV(cdr(tmpptr), DELREF, val); + if (code <= CDR_MAXINDIRECT) { +#ifdef NEWCDRCODING + tmpcell = tmpptr + ((code - CDR_INDIRECT) << 1); +#else + tmpcell = POINTER_PAGEBASE(tmpptr) + ((code - CDR_INDIRECT) << 1); +#endif /* NEWCDRCODING */ + freelistcell(tmpcell); + }; + freelistcell(tmpptr); + goto doval; + }; + case TYPE_ARRAYBLOCK: + if ((index == -1) && reclaimarrayblock(tmpptr)) + goto trynext; + else + break; + case TYPE_STACKP: + if ((index == -1) && reclaimstackp(tmpptr)) goto trynext; + break; + case TYPE_VMEMPAGEP: + if ((index == -1) && releasingvmempage(tmpptr)) { + goto trynext; + } else + break; + case TYPE_CODEHUNK1: + case TYPE_CODEHUNK2: + case TYPE_CODEHUNK3: + case TYPE_CODEHUNK4: + case TYPE_CODEHUNK5: + case TYPE_CODEHUNK6: + case TYPE_CODEHUNK7: + case TYPE_CODEHUNK8: + case TYPE_CODEHUNK9: + case TYPE_CODEHUNK10: + if ((index == -1) && reclaimcodeblock(tmpptr)) + goto trynext; + else + break; + default:; + }; +normal: + typdtd = (struct dtd *)GetDTD(typ); + ptrfield = typdtd->dtd_ptrs; + if (index != -1) { + index = (index << 1); + ptrfield = cdr(ptrfield); + while ((car(ptrfield) & 0x0ffff) != index) ptrfield = cdr(ptrfield); + index = -1; + }; + while (ptrfield != NIL) { + carfield = car(ptrfield); + ptrfield = cdr(ptrfield); + carfield &= 0x0ffff; + REC_GCLOOKUPV((POINTERMASK & *(LispPTR *)Addr68k_from_LADDR(tmpptr + carfield)), DELREF, val); +#ifndef NEWCDRCODING + if (val != NIL) { + if (ptrfield != NIL) { + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); + ptr->car_field = donext; + ptr->cdr_code = ((car(ptrfield) & 0x0ffff) >> 1); + donext = tmpptr; + goto doval; + } else + goto addtofreelist; + }; +#else + if (val != NIL) { + if (ptrfield != NIL) { + if ((carfield = car(ptrfield) & 0x0ffff) >> 1 < 15) { + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); + ptr->car_field = donext; + ptr->cdr_code = ((car(ptrfield) & 0x0ffff) >> 1); + donext = tmpptr; + goto doval; + } else { + ADD_TO_DO(tmpptr, (car(ptrfield) & 0xffff) >> 1); + goto doval; + } + } else + goto addtofreelist; + }; +#endif /* NEWCDRCODING */ + }; +addtofreelist: + field = (LispPTR *)Addr68k_from_LADDR(tmpptr); + *field = typdtd->dtd_free; + typdtd->dtd_free = tmpptr & POINTERMASK; +#ifdef DTDDEBUG + check_dtd_chain(GetTypeNumber(tmpptr & POINTERMASK)); +#endif +/******************************/ +/* */ +/* Freeing one cell made another cell's refcnt = 0. */ +/* ADDREF the second cell (to remove it from the GC table) */ +/* and reclaim it. */ +/************************************************************/ +doval: + if (val != NIL) { + tmpptr = val; + REC_GCLOOKUP(tmpptr, ADDREF); + /* GCLOOKUP(0x8000, ADDREF,tmpptr); */ + val = NIL; + goto lp; + }; + +/***************************************************************/ +/* */ +/* Finished freeing the main cell, but we may have saved other */ +/* cells whose refcnt's went to 0 along the way. This is */ +/* where we work down the list of saved items to free. */ +/* */ +/****************************************************************/ +trynext: + if (donext != NIL) { + tmpptr = donext; + ptr = (ConsCell *)Addr68k_from_LADDR(tmpptr); + donext = (LispPTR)ptr->car_field; + index = ptr->cdr_code; + goto lp; + }; +#ifdef NEWCDRCODING + if (do_count) /* If there are other cells to collect */ + { + do_count--; + tmpptr = to_do[do_count]; + index = to_do_offset[do_count]; + todo_reads++; + /*REC_GCLOOKUP(tmpptr, ADDREF); */ + goto lp; + } +#endif /*NEWCDRCODING */ + return (NIL); +} /************************************************************************/ /* */ @@ -339,53 +320,47 @@ LispPTR gcreccell(LispPTR cell) /* */ /************************************************************************/ -void freelistcell(LispPTR cell) -{ - struct conspage *pbase; - register ConsCell *cell68k; - unsigned int offset, prior, celloffset; +void freelistcell(LispPTR cell) { + struct conspage *pbase; + register ConsCell *cell68k; + unsigned int offset, prior, celloffset; - cell68k = (ConsCell *)Addr68k_from_LADDR(cell); - pbase = (struct conspage *)Addr68k_from_LPAGE(POINTER_PAGE(cell)); - celloffset = (LispPTR)cell & 0xFF; + cell68k = (ConsCell *)Addr68k_from_LADDR(cell); + pbase = (struct conspage *)Addr68k_from_LPAGE(POINTER_PAGE(cell)); + celloffset = (LispPTR)cell & 0xFF; #ifdef NEWCDRCODING - if (celloffset < 8) - error("freeing CONS cell that's really freelist ptr"); + if (celloffset < 8) error("freeing CONS cell that's really freelist ptr"); #endif /* NEWCDRCODING */ - if (pbase->count) /* There are free cells on the page already */ - { + if (pbase->count) /* There are free cells on the page already */ + { prior = 0; - for (offset = pbase->next_cell; offset; - offset = FREECONS(pbase,offset) -> next_free) - { + for (offset = pbase->next_cell; offset; offset = FREECONS(pbase, offset)->next_free) { #ifdef NEWCDRCODING - if ((6^offset) < (6^celloffset)) + if ((6 ^ offset) < (6 ^ celloffset)) #else - if (offset < celloffset) + if (offset < celloffset) #endif /* NEWCDRCODING */ - { - break; - } - prior = offset; - } - - if (prior) FREECONS(pbase, prior)->next_free = celloffset; - else pbase->next_cell = celloffset; - ((freecons *)cell68k) -> next_free = offset; - } - else /* NO FREE CELLS. Just replace next_free. */ - { - pbase->next_cell = celloffset; - FREECONS(pbase,celloffset)->next_free = 0; /* And this is end of the chain */ - } - - if ((++pbase->count > 32) && (pbase->next_page == CONSPAGE_LAST)) { - pbase->next_page = ListpDTD->dtd_nextpage; - ListpDTD->dtd_nextpage = POINTER_PAGE(cell); - }; + break; + } + prior = offset; + } + if (prior) + FREECONS(pbase, prior)->next_free = celloffset; + else + pbase->next_cell = celloffset; + ((freecons *)cell68k)->next_free = offset; + } else /* NO FREE CELLS. Just replace next_free. */ + { + pbase->next_cell = celloffset; + FREECONS(pbase, celloffset)->next_free = 0; /* And this is end of the chain */ } + if ((++pbase->count > 32) && (pbase->next_page == CONSPAGE_LAST)) { + pbase->next_page = ListpDTD->dtd_nextpage; + ListpDTD->dtd_nextpage = POINTER_PAGE(cell); + }; +} diff --git a/src/gcscan.c b/src/gcscan.c old mode 100755 new mode 100644 index 2338a04..9756360 --- a/src/gcscan.c +++ b/src/gcscan.c @@ -1,8 +1,7 @@ -/* $Id: gcscan.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gcscan.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: gcscan.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: gcscan.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyri #include "version.h" - /*************************************************************************/ /* */ /* File Name : gcscan.c */ @@ -60,46 +58,41 @@ static char *id = "$Id: gcscan.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyri #include "lsptypes.h" #ifdef BIGVM -#define HTSTKBIT 0x10000 /* = 512 */ -#define HTENDS ((struct hashentry *) htlptr) -#define GetStkCnt(entry1) (entry1 >> 16) +#define HTSTKBIT 0x10000 /* = 512 */ +#define HTENDS ((struct hashentry *)htlptr) +#define GetStkCnt(entry1) (entry1 >> 16) #else -#define HTSTKBIT 0x200 /* = 512 */ -#define HTENDS ((struct hashentry *) htlptr) -#define GetStkCnt(entry1) (entry1 >> 9) +#define HTSTKBIT 0x200 /* = 512 */ +#define HTENDS ((struct hashentry *)htlptr) +#define GetStkCnt(entry1) (entry1 >> 9) #endif /* BIGVM */ - - - -DLword gcscan1 (register int probe) - /* probe is offset */ - { register struct htlinkptr *htlptr; /* overlay access method */ - register int contents; - while (--probe >= 0) /* End of HTmain Table ? */ - { - /* Start addr. of scanning */ - htlptr = (struct htlinkptr *)(HTmain+probe); - contents = ((struct htlinkptr *)GCPTR(htlptr))->contents; - if (contents && (((struct hashentry *)GCPTR(HTENDS))->collision - || (GetStkCnt(contents) == 0))) - return(probe); - } - return(NIL); - } - - - -DLword gcscan2 (register int probe) - /* probe is offset */ +DLword gcscan1(register int probe) +/* probe is offset */ +{ + register struct htlinkptr *htlptr; /* overlay access method */ + register int contents; + while (--probe >= 0) /* End of HTmain Table ? */ { - register struct htlinkptr *htlptr; /* overlay access method */ - while (--probe >= 0) /* End of HTmain Table ? */ - { - htlptr = (struct htlinkptr *)(HTmain+probe); - /* Start addr. of scanning */ - if (((HTSTKBIT | 1) & ((struct htlinkptr *)GCPTR(htlptr))->contents) != 0) - return(probe); /* stackref or collision ON */ - } - return(NIL); + /* Start addr. of scanning */ + htlptr = (struct htlinkptr *)(HTmain + probe); + contents = ((struct htlinkptr *)GCPTR(htlptr))->contents; + if (contents && (((struct hashentry *)GCPTR(HTENDS))->collision || (GetStkCnt(contents) == 0))) + return (probe); } + return (NIL); +} + +DLword gcscan2(register int probe) +/* probe is offset */ +{ + register struct htlinkptr *htlptr; /* overlay access method */ + while (--probe >= 0) /* End of HTmain Table ? */ + { + htlptr = (struct htlinkptr *)(HTmain + probe); + /* Start addr. of scanning */ + if (((HTSTKBIT | 1) & ((struct htlinkptr *)GCPTR(htlptr))->contents) != 0) + return (probe); /* stackref or collision ON */ + } + return (NIL); +} diff --git a/src/gvar2.c b/src/gvar2.c old mode 100755 new mode 100644 index 67b1a95..f413c72 --- a/src/gvar2.c +++ b/src/gvar2.c @@ -1,12 +1,6 @@ -/* $Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyright (C) Venue"; - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -21,9 +15,6 @@ static char *id = "$Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyrig #include "version.h" - - - #include #include "lispemul.h" #include "lsptypes.h" @@ -34,8 +25,6 @@ static char *id = "$Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyrig #include "cell.h" #include "dbprint.h" - - /************************************************************************/ /* */ /* N _ O P _ g v a r _ */ @@ -51,29 +40,25 @@ static char *id = "$Id: gvar2.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyrig /* * If Hash Table is overflow, call fn1ext. */ /* */ /************************************************************************/ - -LispPTR N_OP_gvar_(register LispPTR tos, unsigned int atom_index) -{ - register LispPTR *pslot; /* pointer to argued GVAR slot */ + +LispPTR N_OP_gvar_(register LispPTR tos, unsigned int atom_index) { + register LispPTR *pslot; /* pointer to argued GVAR slot */ #ifdef BIGATOMS - if (0 != (atom_index & SEGMASK)) - pslot = (LispPTR *) Addr68k_from_LADDR(atom_index + NEWATOM_VALUE_OFFSET); - else + if (0 != (atom_index & SEGMASK)) + pslot = (LispPTR *)Addr68k_from_LADDR(atom_index + NEWATOM_VALUE_OFFSET); + else #endif /* BIGATOMS */ #ifdef BIGVM - pslot = ((LispPTR *) AtomSpace) + (5 * atom_index) + NEWATOM_VALUE_PTROFF; + pslot = ((LispPTR *)AtomSpace) + (5 * atom_index) + NEWATOM_VALUE_PTROFF; #else - pslot = (LispPTR *) Valspace + atom_index; + pslot = (LispPTR *)Valspace + atom_index; #endif /* BIGVM */ - DEBUGGER(if (tos&0xF0000000) error("Setting GVAR with high bits on")); - FRPLPTR(((struct xpointer*)pslot)->addr, tos); - return(tos); - } - - - + DEBUGGER(if (tos & 0xF0000000) error("Setting GVAR with high bits on")); + FRPLPTR(((struct xpointer *)pslot)->addr, tos); + return (tos); +} /************************************************************************/ /* */ @@ -89,13 +74,10 @@ LispPTR N_OP_gvar_(register LispPTR tos, unsigned int atom_index) /* */ /************************************************************************/ -LispPTR N_OP_rplptr(register LispPTR tos_m_1, register LispPTR tos, unsigned int alpha) -{ - register DLword *pslot; /* pointer to argued slot (68 address) */ - - pslot = Addr68k_from_LADDR(tos_m_1 + alpha ); - FRPLPTR( ((struct xpointer*)pslot)->addr,tos); - return(tos_m_1); - } - +LispPTR N_OP_rplptr(register LispPTR tos_m_1, register LispPTR tos, unsigned int alpha) { + register DLword *pslot; /* pointer to argued slot (68 address) */ + pslot = Addr68k_from_LADDR(tos_m_1 + alpha); + FRPLPTR(((struct xpointer *)pslot)->addr, tos); + return (tos_m_1); +} diff --git a/src/hacks.c b/src/hacks.c old mode 100755 new mode 100644 index c759b34..c1bd30b --- a/src/hacks.c +++ b/src/hacks.c @@ -1,9 +1,6 @@ -/* $Id: hacks.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: hacks.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: hacks.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,27 +15,14 @@ static char *id = "$Id: hacks.c,v 1.3 1999/05/31 23:35:33 sybalsky Exp $ Copyrig #include "version.h" - /* These functions are created so that you can split a float into */ /* four integers. The general idea behind these functions is to */ - /* act as a caster between different entitys on the stack */ +/* act as a caster between different entitys on the stack */ -int pickapart1(int i1, int i2, int i3, int i4) -{ - return(i1); -} +int pickapart1(int i1, int i2, int i3, int i4) { return (i1); } -int pickapart2(int i1, int i2, int i3, int i4) -{ - return(i2); -} +int pickapart2(int i1, int i2, int i3, int i4) { return (i2); } -int pickapart3(int i1, int i2, int i3, int i4) -{ - return(i3); -} +int pickapart3(int i1, int i2, int i3, int i4) { return (i3); } -int pickapart4(int i1, int i2, int i3, int i4) -{ - return(i4); -} +int pickapart4(int i1, int i2, int i3, int i4) { return (i4); } diff --git a/src/hardrtn.c b/src/hardrtn.c old mode 100755 new mode 100644 index 5aadf1c..5eade81 --- a/src/hardrtn.c +++ b/src/hardrtn.c @@ -1,13 +1,7 @@ -/* $Id: hardrtn.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: hardrtn.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: hardrtn.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyright (C) Venue"; - - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -22,16 +16,15 @@ static char *id = "$Id: hardrtn.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyr #include "version.h" - /********************************************************************/ /* - File Name : hardrtn.c + File Name : hardrtn.c - Edited by Takeshi Shimizu - Date: 10-MAY-88 + Edited by Takeshi Shimizu + Date: 10-MAY-88 - RET VAL: If success: 0 - else (NO SPACE in STACK) 1 -> should cause HARDRESET + RET VAL: If success: 0 + else (NO SPACE in STACK) 1 -> should cause HARDRESET */ /********************************************************************/ @@ -46,289 +39,260 @@ static char *id = "$Id: hardrtn.c,v 1.4 2001/12/24 01:09:02 sybalsky Exp $ Copyr #include "stack.h" #include "return.h" -#define MAKE_FXCOPY(fx68k) { BEFORE_CONTEXTSW; \ - if((fx68k=(FX*)make_FXcopy(fx68k)) == 0){ \ - return(1); /* Whole space exhausted */} \ - AFTER_CONTEXTSW; \ - CHECK_FX(fx68k);} - void incusecount68k(FX *fx68k),decusecount68k(register FX *frame68k); +#define MAKE_FXCOPY(fx68k) \ + { \ + BEFORE_CONTEXTSW; \ + if ((fx68k = (FX *)make_FXcopy(fx68k)) == 0) { return (1); /* Whole space exhausted */ } \ + AFTER_CONTEXTSW; \ + CHECK_FX(fx68k); \ + } +void incusecount68k(FX *fx68k), decusecount68k(register FX *frame68k); /********************************************************************/ /* - Func Name : slowreturn() + Func Name : slowreturn() - Edited by Takeshi Shimizu - DATE: 10-MAY-88 + Edited by Takeshi Shimizu + DATE: 10-MAY-88 - RET VAL : If 0 success - If 1 NO STACK SPACE->uraid-> HARDRESET + RET VAL : If 0 success + If 1 NO STACK SPACE->uraid-> HARDRESET */ /********************************************************************/ -int slowreturn(void) -{ - register DLword *next68k; - register DLword *freeptr; - register Bframe *currentBF; - register FX *returnFX; - extern FX *make_FXcopy(register FX *fx68k); +int slowreturn(void) { + register DLword *next68k; + register DLword *freeptr; + register Bframe *currentBF; + register FX *returnFX; + extern FX *make_FXcopy(register FX * fx68k); - S_CHECK(SLOWP(CURRENTFX), "CURRENTFX not SLOWP"); + S_CHECK(SLOWP(CURRENTFX), "CURRENTFX not SLOWP"); -/* Get returnee's FX from CURRENTFX->alink , It's SLOWP case */ -returnFX= (FX*)Addr68k_from_StkOffset(CURRENTFX->alink-11); + /* Get returnee's FX from CURRENTFX->alink , It's SLOWP case */ + returnFX = (FX *)Addr68k_from_StkOffset(CURRENTFX->alink - 11); -if((CURRENTFX->alink & 0xFFFE) != CURRENTFX->clink) - { /* ALINK != CLINK */ + if ((CURRENTFX->alink & 0xFFFE) != CURRENTFX->clink) { /* ALINK != CLINK */ #ifdef STACKCHECK - printf("A!=C\n"); + printf("A!=C\n"); #endif - /* return to CLINK fx */ - SETALINK(CURRENTFX,CURRENTFX->clink); - decusecount68k(returnFX); - returnFX = (FX*)Addr68k_from_StkOffset(CURRENTFX->clink - FRAMESIZE); - } + /* return to CLINK fx */ + SETALINK(CURRENTFX, CURRENTFX->clink); + decusecount68k(returnFX); + returnFX = (FX *)Addr68k_from_StkOffset(CURRENTFX->clink - FRAMESIZE); + } -if(returnFX->usecount !=0) - { /* COPY returnee's FX */ + if (returnFX->usecount != 0) { /* COPY returnee's FX */ #ifdef STACKCHECK - printf("returnFX->usecount !=0\n"); + printf("returnFX->usecount !=0\n"); #endif - MAKE_FXCOPY(returnFX);/* smashes returnFX */ - } + MAKE_FXCOPY(returnFX); /* smashes returnFX */ + } -retry : /* this is retry entry after MAKE_FXCOPY etc */ +retry: /* this is retry entry after MAKE_FXCOPY etc */ - next68k = Addr68k_from_StkOffset(returnFX->nextblock) ; - currentBF = (Bframe *)Addr68k_from_StkOffset(CURRENTFX->blink); + next68k = Addr68k_from_StkOffset(returnFX->nextblock); + currentBF = (Bframe *)Addr68k_from_StkOffset(CURRENTFX->blink); -if(GETWORD(next68k) == STK_FSB_WORD) - { -another:freeptr = ((DLword *)CURRENTFX)-2 ; - if( BFRAMEPTR(freeptr)->residual) - { - if(BFRAMEPTR(currentBF)->usecnt == 0) - { - /* make FREEBLOCK for real BF */ - GETWORD(IVar) = STK_FSB_WORD; - GETWORD(IVar +1) =(((UNSIGNED)currentBF - (UNSIGNED)IVar)>>1 )+2 ; - if (0 == GETWORD(IVar+1)) error("creating 0-len block"); - } - else - BFRAMEPTR(currentBF)->usecnt --; - } - else - freeptr = IVar ; /* reset free ptr: not residual case */ + if (GETWORD(next68k) == STK_FSB_WORD) { + another: + freeptr = ((DLword *)CURRENTFX) - 2; + if (BFRAMEPTR(freeptr)->residual) { + if (BFRAMEPTR(currentBF)->usecnt == 0) { + /* make FREEBLOCK for real BF */ + GETWORD(IVar) = STK_FSB_WORD; + GETWORD(IVar + 1) = (((UNSIGNED)currentBF - (UNSIGNED)IVar) >> 1) + 2; + if (0 == GETWORD(IVar + 1)) error("creating 0-len block"); + } else + BFRAMEPTR(currentBF)->usecnt--; + } else + freeptr = IVar; /* reset free ptr: not residual case */ - /* free FX + BF(dummy or real) */ - GETWORD(freeptr) = STK_FSB_WORD; - GETWORD(freeptr +1)= ((UNSIGNED)EndSTKP - (UNSIGNED)freeptr)>>1 ; - if (0 == GETWORD(freeptr+1)) error("creating 0-len block"); - S_CHECK(EndSTKP >= freeptr, "EndSTKP < freeptr!"); - S_CHECK(FSB_size(freeptr) >= MINEXTRASTACKWORDS, - "free block < min size, after deciding it fits."); + /* free FX + BF(dummy or real) */ + GETWORD(freeptr) = STK_FSB_WORD; + GETWORD(freeptr + 1) = ((UNSIGNED)EndSTKP - (UNSIGNED)freeptr) >> 1; + if (0 == GETWORD(freeptr + 1)) error("creating 0-len block"); + S_CHECK(EndSTKP >= freeptr, "EndSTKP < freeptr!"); + S_CHECK(FSB_size(freeptr) >= MINEXTRASTACKWORDS, + "free block < min size, after deciding it fits."); - PVar=((DLword *)returnFX) + FRAMESIZE ; - /* Now right CURRENTFX(PVar) is set */ + PVar = ((DLword *)returnFX) + FRAMESIZE; + /* Now right CURRENTFX(PVar) is set */ - if (GETWORD(next68k) != STK_FSB_WORD) - error("OP_return: MP9316"); + if (GETWORD(next68k) != STK_FSB_WORD) error("OP_return: MP9316"); - freeptr = next68k ; - while(GETWORD(freeptr)==STK_FSB_WORD) - EndSTKP = freeptr = freeptr + GETWORD(freeptr+1); + freeptr = next68k; + while (GETWORD(freeptr) == STK_FSB_WORD) EndSTKP = freeptr = freeptr + GETWORD(freeptr + 1); - if(CURRENTFX->incall) - { /* this frame is Interrupted */ - error("Stack error: INCALL bit found in returnee frame"); - } - else - { - if (CURRENTFX->nopush) - { - CURRENTFX->nopush =NIL; - CurrentStackPTR = next68k-2 ; - TopOfStack = *((LispPTR *)CurrentStackPTR) ; - CurrentStackPTR-=2; + if (CURRENTFX->incall) { /* this frame is Interrupted */ + error("Stack error: INCALL bit found in returnee frame"); + } else { + if (CURRENTFX->nopush) { + CURRENTFX->nopush = NIL; + CurrentStackPTR = next68k - 2; + TopOfStack = *((LispPTR *)CurrentStackPTR); + CurrentStackPTR -= 2; - } - else - CurrentStackPTR = next68k-2 ; + } else + CurrentStackPTR = next68k - 2; - S_CHECK(EndSTKP >= freeptr, "EndSTKP < freeptr"); + S_CHECK(EndSTKP >= freeptr, "EndSTKP < freeptr"); - FastRetCALL; + FastRetCALL; #ifdef LISPTRACE - printf("TRACE: return from "); - print(fnobj->framename); - printf(" :<= "); - print(TopOfStack);printf("\n"); + printf("TRACE: return from "); + print(fnobj->framename); + printf(" :<= "); + print(TopOfStack); + printf("\n"); #endif - return(0); /* normal return */ - } + return (0); /* normal return */ + } -}/* FSB end */ -else if (next68k != IVar) - { + } /* FSB end */ + else if (next68k != IVar) { #ifdef STACKCHECK - printf("next68k != IVar and not FSB\n"); + printf("next68k != IVar and not FSB\n"); #endif - MAKE_FXCOPY(returnFX);/* smashes returnFX */ - goto retry; - } -else if (BFRAMEPTR(currentBF)->usecnt != 0) - { + MAKE_FXCOPY(returnFX); /* smashes returnFX */ + goto retry; + } else if (BFRAMEPTR(currentBF)->usecnt != 0) { #ifdef STACKCHECK - printf("currentBF->usecnt != 0"); + printf("currentBF->usecnt != 0"); #endif - MAKE_FXCOPY(returnFX);/* smashes returnFX */ - goto retry; - } -else { - if((next68k == IVar)|| (BFRAMEPTR(currentBF)->usecnt ==0)) - goto another; - else error("Shouldn't"); - } + MAKE_FXCOPY(returnFX); /* smashes returnFX */ + goto retry; + } else { + if ((next68k == IVar) || (BFRAMEPTR(currentBF)->usecnt == 0)) + goto another; + else + error("Shouldn't"); + } } /* slowreturn end */ - - - - -FX *make_FXcopy(register FX *fx68k) -{ - register int size; - int nametbl_on_stk=NIL; - register DLword *new68k; - register Bframe *retbf68k; - extern DLword *freestackblock(DLword n, StackWord *start68k, int align); +FX *make_FXcopy(register FX *fx68k) { + register int size; + int nametbl_on_stk = NIL; + register DLword *new68k; + register Bframe *retbf68k; + extern DLword *freestackblock(DLword n, StackWord * start68k, int align); #ifdef FLIPCURSOR - flip_cursorbar(5); + flip_cursorbar(5); #endif - CHECK_FX(fx68k); - size = FX_size(fx68k) + DLWORDSPER_CELL; + CHECK_FX(fx68k); + size = FX_size(fx68k) + DLWORDSPER_CELL; #ifdef BIGVM - if(fx68k->validnametable && ((fx68k->nametable >> 16)==STK_HI)) + if (fx68k->validnametable && ((fx68k->nametable >> 16) == STK_HI)) #else - if(fx68k->validnametable && (fx68k->hi2nametable==STK_HI)) + if (fx68k->validnametable && (fx68k->hi2nametable == STK_HI)) #endif /* BIGVM */ - { - /* frame contains a name table, so we care that the alignment - of the new block be same as old */ + { +/* frame contains a name table, so we care that the alignment + of the new block be same as old */ #ifdef STACKCHECK - { DLword n; + { + DLword n; #ifdef BIGVM - n = fx68k->nametable & 0xFFFF; + n = fx68k->nametable & 0xFFFF; #else - n=fx68k->lonametable; + n = fx68k->lonametable; #endif /* BIGVM */ - if((n <= StkOffset_from_68K(fx68k)) - && (n >= fx68k->nextblock)) - error("hardreturn:nametable check"); - } + if ((n <= StkOffset_from_68K(fx68k)) && (n >= fx68k->nextblock)) + error("hardreturn:nametable check"); + } #endif - nametbl_on_stk = T; - /* Find a free stack block */ - new68k=freestackblock(size,(StackWord *)CURRENTFX, - (StkOffset_from_68K(fx68k)-DLWORDSPER_CELL)% DLWORDSPER_QUAD); - } /*if end */ - else new68k=freestackblock(size,(StackWord *)CURRENTFX,-1); /* No align */ + nametbl_on_stk = T; + /* Find a free stack block */ + new68k = freestackblock(size, (StackWord *)CURRENTFX, + (StkOffset_from_68K(fx68k) - DLWORDSPER_CELL) % DLWORDSPER_QUAD); + } /*if end */ + else + new68k = freestackblock(size, (StackWord *)CURRENTFX, -1); /* No align */ - if(new68k == 0) return(0); /* No more space for STACK */ + if (new68k == 0) return (0); /* No more space for STACK */ - /* blt(dest,source,size) */ - blt(new68k,(((DLword*)fx68k) - DLWORDSPER_CELL),size); + /* blt(dest,source,size) */ + blt(new68k, (((DLword *)fx68k) - DLWORDSPER_CELL), size); - ((Bframe*)new68k)->residual =T; - new68k = new68k + DLWORDSPER_CELL; /* now NEW points to the FX */ - ((FX*)new68k)->nextblock=(StkOffset_from_68K(new68k) + size)-DLWORDSPER_CELL; - retbf68k=(Bframe*)Addr68k_from_StkOffset(GETBLINK(fx68k)); - /* Set true BFptr,not the residual */ - SETBLINK(new68k,GETBLINK(fx68k)); - ((FX*)new68k)->usecount=0; - CHECK_BF(retbf68k); + ((Bframe *)new68k)->residual = T; + new68k = new68k + DLWORDSPER_CELL; /* now NEW points to the FX */ + ((FX *)new68k)->nextblock = (StkOffset_from_68K(new68k) + size) - DLWORDSPER_CELL; + retbf68k = (Bframe *)Addr68k_from_StkOffset(GETBLINK(fx68k)); + /* Set true BFptr,not the residual */ + SETBLINK(new68k, GETBLINK(fx68k)); + ((FX *)new68k)->usecount = 0; + CHECK_BF(retbf68k); #ifdef BIGVM - if(nametbl_on_stk) - ((FX*)new68k)->nametable += (((UNSIGNED)new68k - (UNSIGNED)fx68k)>>1); + if (nametbl_on_stk) ((FX *)new68k)->nametable += (((UNSIGNED)new68k - (UNSIGNED)fx68k) >> 1); #else - if(nametbl_on_stk) - ((FX*)new68k)->lonametable += (((UNSIGNED)new68k - (UNSIGNED)fx68k)>>1); + if (nametbl_on_stk) ((FX *)new68k)->lonametable += (((UNSIGNED)new68k - (UNSIGNED)fx68k) >> 1); #endif - /* increment use count of basic frame of returnee because - we made another FX which points to it */ - retbf68k->usecnt ++; - SET_FASTP_NIL(fx68k); - /* increment use count of CLINK of returnee - because we made a copy of returnee */ - incusecount68k((FX *)Addr68k_from_StkOffset(GETCLINK(fx68k))); + /* increment use count of basic frame of returnee because + we made another FX which points to it */ + retbf68k->usecnt++; + SET_FASTP_NIL(fx68k); + /* increment use count of CLINK of returnee + because we made a copy of returnee */ + incusecount68k((FX *)Addr68k_from_StkOffset(GETCLINK(fx68k))); - if(GETCLINK(fx68k) != GETALINK(fx68k)) - { - incusecount68k((FX *)Addr68k_from_StkOffset(GETALINK(fx68k))); - } + if (GETCLINK(fx68k) != GETALINK(fx68k)) { + incusecount68k((FX *)Addr68k_from_StkOffset(GETALINK(fx68k))); + } - decusecount68k(fx68k);/* if usecon==0 -> FSB */ - SETACLINK(CURRENTFX,StkOffset_from_68K(new68k)); - CHECK_FX(new68k); - CHECK_FX(CURRENTFX); + decusecount68k(fx68k); /* if usecon==0 -> FSB */ + SETACLINK(CURRENTFX, StkOffset_from_68K(new68k)); + CHECK_FX(new68k); + CHECK_FX(CURRENTFX); #ifdef STACKCHECK - stack_check(0); + stack_check(0); #endif #ifdef FLIPCURSOR - flip_cursorbar(5); + flip_cursorbar(5); #endif - return((FX*)new68k); - } /* make_FXcopy end */ - - - + return ((FX *)new68k); +} /* make_FXcopy end */ #define MAXSAFEUSECOUNT 200 -void incusecount68k(FX *fx68k) -{ - StackWord *scanptr68k; +void incusecount68k(FX *fx68k) { + StackWord *scanptr68k; - if(FX_INVALIDP(fx68k)) return; + if (FX_INVALIDP(fx68k)) return; -CHECK_FX(fx68k); + CHECK_FX(fx68k); -if((++(fx68k->usecount)) > MAXSAFEUSECOUNT) - error("MP9324:Stack frame use count maximum exceeded"); + if ((++(fx68k->usecount)) > MAXSAFEUSECOUNT) + error("MP9324:Stack frame use count maximum exceeded"); -scanptr68k=(StackWord*)Addr68k_from_StkOffset(fx68k->nextblock); -switch(STKWORD(scanptr68k)->flags) - { - case STK_NOTFLG: - while(STKWORD(scanptr68k)->flags !=STK_BF) - scanptr68k = (StackWord *) - (((DLword *)scanptr68k) - + DLWORDSPER_CELL); - break; + scanptr68k = (StackWord *)Addr68k_from_StkOffset(fx68k->nextblock); + switch (STKWORD(scanptr68k)->flags) { + case STK_NOTFLG: + while (STKWORD(scanptr68k)->flags != STK_BF) + scanptr68k = (StackWord *)(((DLword *)scanptr68k) + DLWORDSPER_CELL); + break; - case STK_BF: break; + case STK_BF: break; - default : return; - /* break; */ - } /* switch end */ + default: + return; + /* break; */ + } /* switch end */ -/* DEBUG */ -S_CHECK((((Bframe*)scanptr68k)->residual==T) || - ( ((Bframe*)scanptr68k)->ivar== fx68k->nextblock) , - "BF not residual, and IVER /= nextblock of prior frame"); + /* DEBUG */ + S_CHECK( + (((Bframe *)scanptr68k)->residual == T) || (((Bframe *)scanptr68k)->ivar == fx68k->nextblock), + "BF not residual, and IVER /= nextblock of prior frame"); -scanptr68k = (StackWord *) (((DLword *)scanptr68k) + DLWORDSPER_CELL); + scanptr68k = (StackWord *)(((DLword *)scanptr68k) + DLWORDSPER_CELL); -if(STKWORD(scanptr68k)->flags == STK_FX) -{ - CHECK_FX(scanptr68k); - SET_FASTP_NIL(scanptr68k); -} + if (STKWORD(scanptr68k)->flags == STK_FX) { + CHECK_FX(scanptr68k); + SET_FASTP_NIL(scanptr68k); + } } /* incusecount68k end */ - diff --git a/src/imagefile.c b/src/imagefile.c old mode 100755 new mode 100644 index f37594f..0615aa6 --- a/src/imagefile.c +++ b/src/imagefile.c @@ -1,8 +1,7 @@ -/* $Id: imagefile.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: imagefile.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: imagefile.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,359 +16,304 @@ static char *id = "$Id: imagefile.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ Cop #include "version.h" - - #include #include -#define NOT_IMAGEFILE 0 -#define TYPE_SUNRASTER 1 -#define TYPE_PBM 2 -#define TYPE_PPM 3 +#define NOT_IMAGEFILE 0 +#define TYPE_SUNRASTER 1 +#define TYPE_PBM 2 +#define TYPE_PPM 3 struct image_info { - int depth; - int width; - int height; + int depth; + int width; + int height; }; struct rgb { - unsigned char r; - unsigned char g; - unsigned char b; + unsigned char r; + unsigned char g; + unsigned char b; }; -Pixrect *PPM_to_Pixrect() - , *PBM_to_Pixrect() - , *SunRaster_to_Pixrect(); +Pixrect *PPM_to_Pixrect(), *PBM_to_Pixrect(), *SunRaster_to_Pixrect(); -#define MAX_BUFF_SIZE 1024 -static char buff[ MAX_BUFF_SIZE ]; +#define MAX_BUFF_SIZE 1024 +static char buff[MAX_BUFF_SIZE]; -int -Pixrect_to_File( pix, name ) -Pixrect *pix; +int Pixrect_to_File(pix, name) Pixrect *pix; char *name; -{ - FILE *file; - int err = 0; +{ + FILE *file; + int err = 0; - switch( pix->pr_depth ) { - case 1: - file = fopen( name, "w" ); - err = Pixrect_to_PBM( file, pix ); - fclose( file ); - break; - case 32: - file = fopen( name, "w" ); - err = Pixrect_to_PPM( file, pix ); - fclose( file ); - break; - case 8: - break; - defaults: - break; - } /* end switch( pix->depth ) */ + switch (pix->pr_depth) { + case 1: + file = fopen(name, "w"); + err = Pixrect_to_PBM(file, pix); + fclose(file); + break; + case 32: + file = fopen(name, "w"); + err = Pixrect_to_PPM(file, pix); + fclose(file); + break; + case 8: + break; + defaults: + break; + } /* end switch( pix->depth ) */ - return( err ); + return (err); } /* end Pixrect_to_File */ -Pixrect -*File_to_Pixrect( name ) -char *name; +Pixrect *File_to_Pixrect(name) char *name; { - FILE *file; - Pixrect *pix; - int type; + FILE *file; + Pixrect *pix; + int type; - file = fopen( name, "r" ); + file = fopen(name, "r"); - type = image_file_type( file ); + type = image_file_type(file); - switch( type ) { - case TYPE_SUNRASTER: - pix = SunRaster_to_Pixrect( file ); - break; - case TYPE_PBM: - pix = PBM_to_Pixrect( file ); - break; - case TYPE_PPM: - pix = PPM_to_Pixrect( file ); - break; - defaults: - break; - } /* end switch */ + switch (type) { + case TYPE_SUNRASTER: pix = SunRaster_to_Pixrect(file); break; + case TYPE_PBM: pix = PBM_to_Pixrect(file); break; + case TYPE_PPM: + pix = PPM_to_Pixrect(file); + break; + defaults: + break; + } /* end switch */ - fclose( file ); + fclose(file); + + return (pix); - return( pix ); - } /* end File_to_Pixrect */ -#define magic_number_PBM "P4" -#define magic_number_PPM "P6" +#define magic_number_PBM "P4" +#define magic_number_PPM "P6" -Pixrect_to_PPM( file, pix ) -FILE *file; +Pixrect_to_PPM(file, pix) FILE *file; Pixrect *pix; { - struct image_info info; + struct image_info info; - info.width = pix->pr_width; - info.height = pix->pr_height; - info.depth = pix->pr_depth; - write_PPM_header( file, &info ); + info.width = pix->pr_width; + info.height = pix->pr_height; + info.depth = pix->pr_depth; + write_PPM_header(file, &info); - write_raw_PPM( file, mpr_d(pix)->md_image - , pix->pr_width, pix->pr_height ); + write_raw_PPM(file, mpr_d(pix)->md_image, pix->pr_width, pix->pr_height); } /* end Pixrect_to_PPM */ -Pixrect -*PPM_to_Pixrect( file ) -FILE *file; +Pixrect *PPM_to_Pixrect(file) FILE *file; { - Pixrect *pix; - struct image_info info; + Pixrect *pix; + struct image_info info; - read_PPM_header( file, &info ); - pix = mem_create( info.width, info.height, 32 ); - read_raw_PPM( file, mpr_d(pix)->md_image, info.width, info.height ); + read_PPM_header(file, &info); + pix = mem_create(info.width, info.height, 32); + read_raw_PPM(file, mpr_d(pix)->md_image, info.width, info.height); - return( pix ); + return (pix); } /* PPM_to_Pixrect */ -Pixrect_to_PBM( file, pix ) -FILE *file; +Pixrect_to_PBM(file, pix) FILE *file; Pixrect *pix; { - struct image_info info; + struct image_info info; - info.width = pix->pr_width; - info.height = pix->pr_height; - info.depth = pix->pr_depth; - write_PBM_header( file, &info ); + info.width = pix->pr_width; + info.height = pix->pr_height; + info.depth = pix->pr_depth; + write_PBM_header(file, &info); - write_raw_PBM( file, mpr_d(pix)->md_image - , pix->pr_width, pix->pr_height ); + write_raw_PBM(file, mpr_d(pix)->md_image, pix->pr_width, pix->pr_height); } /* end Pixrect_to_PBM */ -Pixrect -*PBM_to_Pixrect( file ) -FILE *file; +Pixrect *PBM_to_Pixrect(file) FILE *file; { - Pixrect *pix; - struct image_info info; + Pixrect *pix; + struct image_info info; - read_PPM_header( file, &info ); - pix = mem_create( info.width, info.height, 32 ); - read_raw_PPM( file, mpr_d(pix)->md_image, info.width, info.height ); + read_PPM_header(file, &info); + pix = mem_create(info.width, info.height, 32); + read_raw_PPM(file, mpr_d(pix)->md_image, info.width, info.height); + + return (pix); - return( pix ); - } /* end PBM_to_Pixrect */ -Pixrect -*SunRaster_to_Pixrect( file ) -FILE *file; +Pixrect *SunRaster_to_Pixrect(file) FILE *file; { - Pixrect *pix; - colormap_t cmap; + Pixrect *pix; + colormap_t cmap; - cmap.type = RMT_NONE; - - pix = pr_load( file, &cmap ); + cmap.type = RMT_NONE; - return( pix ); + pix = pr_load(file, &cmap); + + return (pix); } /* end SunRaster_to_Pixrect */ -write_raw_PBM( file, data, width, height ) -FILE *file; +write_raw_PBM(file, data, width, height) FILE *file; unsigned char *data; -int width - , height; +int width, height; { - int i - , n - , flg - , len; + int i, n, flg, len; - n = ( (width + 15) / 16 ) * 2; /* bytes per line */ - flg = ( width%16 ) / 8; /* PBM is byts alignment */ - for( i=0; ichannel.R; - color24.g = ((union fbunit *)data)->channel.G; - color24.b = ((union fbunit *)data)->channel.B; - len = fwrite( &color24, sizeof( color24 ), 1, file ); - } /* end for( j ) */ - } /* end for( i ) */ + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++, ((union fbunit *)data)++) { + color24.r = ((union fbunit *)data)->channel.R; + color24.g = ((union fbunit *)data)->channel.G; + color24.b = ((union fbunit *)data)->channel.B; + len = fwrite(&color24, sizeof(color24), 1, file); + } /* end for( j ) */ + } /* end for( i ) */ } /* end write_raw_PPM */ -read_raw_PPM( file, data, width, height ) -FILE *file; +read_raw_PPM(file, data, width, height) FILE *file; unsigned char *data; -int width - , height; +int width, height; { - struct rgb color24; - int i - , j - , len; + struct rgb color24; + int i, j, len; - for( i=0; ichannel.R = color24.r; - ((union fbunit *)data)->channel.G = color24.g; - ((union fbunit *)data)->channel.B = color24.b; - } /* end for( j ) */ - } /* end for( i ) */ + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++, ((union fbunit *)data)++) { + len = fread((char *)(&color24), sizeof(color24), 1, file); + ((union fbunit *)data)->channel.R = color24.r; + ((union fbunit *)data)->channel.G = color24.g; + ((union fbunit *)data)->channel.B = color24.b; + } /* end for( j ) */ + } /* end for( i ) */ } /* endi read_raw_PPM */ -int -image_file_type( file ) -FILE *file; +int image_file_type(file) FILE *file; { - int c - , file_type; + int c, file_type; - if( (c = getc( file )) == -1 ) return( NOT_IMAGEFILE ); + if ((c = getc(file)) == -1) return (NOT_IMAGEFILE); - switch( c ) { - case 'Y': /* may be Sun Raster format */ - file_type = TYPE_SUNRASTER; - break; - case 'P': { - if( (c = getc( file )) == -1 ) return( NOT_IMAGEFILE ); - if( c == '4' ) file_type = TYPE_PBM; - else if( c == '6' ) file_type = TYPE_PPM; - else file_type = NOT_IMAGEFILE; - } /* end case P */ - break; - defaults: - file_type = NOT_IMAGEFILE; - break; - } /* end switch( c ) */ + switch (c) { + case 'Y': /* may be Sun Raster format */ file_type = TYPE_SUNRASTER; break; + case 'P': { + if ((c = getc(file)) == -1) return (NOT_IMAGEFILE); + if (c == '4') + file_type = TYPE_PBM; + else if (c == '6') + file_type = TYPE_PPM; + else + file_type = NOT_IMAGEFILE; + } /* end case P */ + break; + defaults: + file_type = NOT_IMAGEFILE; + break; + } /* end switch( c ) */ - rewind( file ); + rewind(file); - return( file_type ); + return (file_type); } /* end image_file_type */ -read_PBM_header( file, info ) -FILE *file; +read_PBM_header(file, info) FILE *file; struct image_info *info; { - int err; + int err; - err = skip_line( file ); - if( err == 0 ) return( err ); + err = skip_line(file); + if (err == 0) return (err); - err = read_available_line( file, buff ); - if( err == 0 ) return( err ); - err = sscanf( buff, "%d %d", &(info->width), &(info->height) ); - if( err == 0 ) return( err ); + err = read_available_line(file, buff); + if (err == 0) return (err); + err = sscanf(buff, "%d %d", &(info->width), &(info->height)); + if (err == 0) return (err); + + return (err); - return( err ); - } /* end read_PBM_header */ -write_PBM_header( file, info ) -FILE *file; +write_PBM_header(file, info) FILE *file; struct image_info *info; { - fprintf( file, "P4\n" ); - fprintf( file, "%d %d\n", info->width, info->height ); + fprintf(file, "P4\n"); + fprintf(file, "%d %d\n", info->width, info->height); } /* write_PBM_header */ -read_PPM_header( file, info ) -FILE *file; +read_PPM_header(file, info) FILE *file; struct image_info *info; { - int err; + int err; - err = skip_line( file ); - if( err == 0 ) return( err ); + err = skip_line(file); + if (err == 0) return (err); - err = read_available_line( file, buff ); - if( err == 0 ) return( err ); - err = sscanf( buff, "%d %d", &(info->width), &(info->height) ); - if( err == 0 ) return( err ); + err = read_available_line(file, buff); + if (err == 0) return (err); + err = sscanf(buff, "%d %d", &(info->width), &(info->height)); + if (err == 0) return (err); - err = skip_line( file ); + err = skip_line(file); - return( err ); + return (err); } /* read_PPM_header */ -write_PPM_header( file, info ) -FILE *file; +write_PPM_header(file, info) FILE *file; struct image_info *info; { - fprintf( file, "P6\n" ); - fprintf( file, "%d %d\n", info->width, info->height ); - fprintf( file, "255\n" ); + fprintf(file, "P6\n"); + fprintf(file, "%d %d\n", info->width, info->height); + fprintf(file, "255\n"); } /* end write_PPM_header */ -int -skip_line( file ) -FILE *file; +int skip_line(file) FILE *file; { - char *err; - char buff[ MAX_BUFF_SIZE ]; + char *err; + char buff[MAX_BUFF_SIZE]; - err = fgets( buff, (int)MAX_BUFF_SIZE, file ); - return( (int)err ); + err = fgets(buff, (int)MAX_BUFF_SIZE, file); + return ((int)err); } /* end skip_line */ -int -read_available_line( file, buff ) -FILE *file; +int read_available_line(file, buff) FILE *file; char *buff; { - char *err; - err = fgets( buff, MAX_BUFF_SIZE, file ); - while( (err != 0) && (buff[0] == '#') ) { - err = fgets( buff, MAX_BUFF_SIZE, file ); - } /* end while */ - return( (int)err ); + char *err; + err = fgets(buff, MAX_BUFF_SIZE, file); + while ((err != 0) && (buff[0] == '#')) { err = fgets(buff, MAX_BUFF_SIZE, file); } /* end while */ + return ((int)err); } /* end read_available_line */ diff --git a/src/imagefile2.c b/src/imagefile2.c old mode 100755 new mode 100644 index c52050e..365cce7 --- a/src/imagefile2.c +++ b/src/imagefile2.c @@ -1,8 +1,7 @@ -/* $Id: imagefile2.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: imagefile2.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: imagefile2.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,164 +16,138 @@ static char *id = "$Id: imagefile2.c,v 1.2 1999/01/03 02:07:07 sybalsky Exp $ Co #include "version.h" - #include #include #define FALSE 0 -#define TRUE !FALSE +#define TRUE !FALSE typedef struct { - FILE *file; - struct rasterfile rh; - colormap_t colormap; + FILE *file; + struct rasterfile rh; + colormap_t colormap; } RASTERFILE_INFO; -unsigned int -open_rasterfile( filename ) -char *filename; +unsigned int open_rasterfile(filename) char *filename; { - FILE *file; - RASTERFILE_INFO *fileinfo; - int status; + FILE *file; + RASTERFILE_INFO *fileinfo; + int status; - if( (fileinfo = (RASTERFILE_INFO*)malloc( sizeof( RASTERFILE_INFO ) )) == 0 ) { - return( 0 ); - } /* end if( fileinfo ) */ + if ((fileinfo = (RASTERFILE_INFO *)malloc(sizeof(RASTERFILE_INFO))) == 0) { + return (0); + } /* end if( fileinfo ) */ - if( (fileinfo->file = fopen( filename, "r" )) != 0 ) { - if( (status = pr_load_header( fileinfo->file - , &(fileinfo->rh) )) == 0 ) { - if( fileinfo->rh.ras_magic == RAS_MAGIC ) { - /* RasterFile */ - pr_load_colormap( fileinfo->file - , &(fileinfo->rh) - , &(fileinfo->colormap) ); - /* normal case */ - return( (unsigned int)fileinfo ); - } /* end if( fileinfo->rh.ras_magic ) */ - fclose( fileinfo->file ); - } /* end if( status ) */ - } /* end if( file ) */ + if ((fileinfo->file = fopen(filename, "r")) != 0) { + if ((status = pr_load_header(fileinfo->file, &(fileinfo->rh))) == 0) { + if (fileinfo->rh.ras_magic == RAS_MAGIC) { + /* RasterFile */ + pr_load_colormap(fileinfo->file, &(fileinfo->rh), &(fileinfo->colormap)); + /* normal case */ + return ((unsigned int)fileinfo); + } /* end if( fileinfo->rh.ras_magic ) */ + fclose(fileinfo->file); + } /* end if( status ) */ + } /* end if( file ) */ - free( fileinfo ); - return( 0 ); /* error return */ + free(fileinfo); + return (0); /* error return */ } /* end open_rasterfile */ -unsigned int -create_rasterfile( filename ) -char *filename; +unsigned int create_rasterfile(filename) char *filename; { - RASTERFILE_INFO *fileinfo; + RASTERFILE_INFO *fileinfo; - if( !(fileinfo = (RASTERFILE_INFO*)malloc( sizeof( RASTERFILE_INFO ) )) ) { - return( 0 ); - } /* end if( fileinfo ) */ - fileinfo->file = fopen( filename, "w" ); + if (!(fileinfo = (RASTERFILE_INFO *)malloc(sizeof(RASTERFILE_INFO)))) { + return (0); + } /* end if( fileinfo ) */ + fileinfo->file = fopen(filename, "w"); - fileinfo->rh.ras_magic = 0; + fileinfo->rh.ras_magic = 0; + + return ((unsigned int)fileinfo); - return( (unsigned int)fileinfo ); - } /* end create_rasterfile */ -close_rasterfile( fileinfo ) -RASTERFILE_INFO *fileinfo; +close_rasterfile(fileinfo) RASTERFILE_INFO *fileinfo; { - fclose( fileinfo->file ); - free( (char*)fileinfo ); + fclose(fileinfo->file); + free((char *)fileinfo); } /* end close_rasterfile */ -unsigned int -read_rasterfile( fileinfo ) -RASTERFILE_INFO *fileinfo; +unsigned int read_rasterfile(fileinfo) RASTERFILE_INFO *fileinfo; { - Pixrect *pict; - pict = pr_load_std_image( fileinfo->file - , &(fileinfo->rh) - , &(fileinfo->colormap) ); - return( (unsigned int)pict ); + Pixrect *pict; + pict = pr_load_std_image(fileinfo->file, &(fileinfo->rh), &(fileinfo->colormap)); + return ((unsigned int)pict); } /* end read_rasterfile */ -int -write_rasterfile( fileinfo, pix ) -RASTERFILE_INFO *fileinfo; +int write_rasterfile(fileinfo, pix) RASTERFILE_INFO *fileinfo; Pixrect *pix; { - int status; + int status; - if( fileinfo->rh.ras_magic == RAS_MAGIC ) { - if( ( fileinfo->rh.ras_width != pix->pr_size.x ) - || ( fileinfo->rh.ras_height != pix->pr_size.y ) - || ( fileinfo->rh.ras_depth != pix->pr_depth ) ) { - return( FALSE ); - } /* end if( .. ) */ - } else { - if( !(status = init_rasterfile_header( fileinfo, pix )) ) { - return( FALSE ); - } /* end if( !status ) */ - } /* end if( fileinfo->rh.ras_magic ) */ + if (fileinfo->rh.ras_magic == RAS_MAGIC) { + if ((fileinfo->rh.ras_width != pix->pr_size.x) || (fileinfo->rh.ras_height != pix->pr_size.y) || + (fileinfo->rh.ras_depth != pix->pr_depth)) { + return (FALSE); + } /* end if( .. ) */ + } else { + if (!(status = init_rasterfile_header(fileinfo, pix))) { + return (FALSE); + } /* end if( !status ) */ + } /* end if( fileinfo->rh.ras_magic ) */ - if( (status = pr_dump_image( pix, fileinfo->file, &(fileinfo->rh) )) == NULL ) { - return( TRUE ); /* normal return */ - } - return( FALSE ); + if ((status = pr_dump_image(pix, fileinfo->file, &(fileinfo->rh))) == NULL) { + return (TRUE); /* normal return */ + } + return (FALSE); } /* end write_rasterfile */ -int -init_rasterfile_header( fileinfo, pix ) -RASTERFILE_INFO *fileinfo; +int init_rasterfile_header(fileinfo, pix) RASTERFILE_INFO *fileinfo; Pixrect *pix; { - Pixrect *ret_pix; - int status; + Pixrect *ret_pix; + int status; - switch( pix->pr_depth ) { - case 32: - if( !(ret_pix = pr_dump_init( pix, &(fileinfo->rh) - , NULL, 0 )) ) { - return( FALSE ); - } /* end if( ret_pix ) */ + switch (pix->pr_depth) { + case 32: + if (!(ret_pix = pr_dump_init(pix, &(fileinfo->rh), NULL, 0))) { + return (FALSE); + } /* end if( ret_pix ) */ - fileinfo->rh.ras_length = fileinfo->rh.ras_width * fileinfo->rh.ras_height * 4; - fileinfo->rh.ras_type = RT_STANDARD; + fileinfo->rh.ras_length = fileinfo->rh.ras_width * fileinfo->rh.ras_height * 4; + fileinfo->rh.ras_type = RT_STANDARD; - if( (status = pr_dump_header( fileinfo->file - , &(fileinfo->rh), NULL )) ) { - return( FALSE ); - } /* end if( status ) */ - break; - case 1: - case 8: - default: - return( FALSE ); - break; - } /* end switch( pix->pr_depth ) */ + if ((status = pr_dump_header(fileinfo->file, &(fileinfo->rh), NULL))) { + return (FALSE); + } /* end if( status ) */ + break; + case 1: + case 8: + default: return (FALSE); break; + } /* end switch( pix->pr_depth ) */ - return( TRUE ); + return (TRUE); } /* end init_rasterfile_header */ -int -position_rasterfile( fileinfo, n ) -RASTERFILE_INFO *fileinfo; +int position_rasterfile(fileinfo, n) RASTERFILE_INFO *fileinfo; int n; { - long position; - int status; + long position; + int status; - if( n > 0 ) { - position = sizeof( struct rasterfile ) - + (n - 1)*fileinfo->rh.ras_length; - if( (status = fseek( fileinfo->file - , position, (int)0 )) == 0 ) { - /* normal return */ - return( TRUE ); - } /* end if( status ) */ - } /* end if( n ) */ + if (n > 0) { + position = sizeof(struct rasterfile) + (n - 1) * fileinfo->rh.ras_length; + if ((status = fseek(fileinfo->file, position, (int)0)) == 0) { + /* normal return */ + return (TRUE); + } /* end if( status ) */ + } /* end if( n ) */ + + /* error return */ + return (FALSE); - /* error return */ - return( FALSE ); - } /* end position_rasterfile */ diff --git a/src/inet.c b/src/inet.c old mode 100755 new mode 100644 index 096a26d..e14dfef --- a/src/inet.c +++ b/src/inet.c @@ -1,8 +1,6 @@ /* $Id: inet.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: inet.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -15,11 +13,8 @@ static char *id = "$Id: inet.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copyrigh /* */ /************************************************************************/ - - #include "version.h" - #include #include #include /* for mem... fns */ @@ -63,12 +58,10 @@ static char *id = "$Id: inet.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copyrigh #define SIGIO SIGPOLL #endif /* ISC */ - #ifdef GCC386 #include "inlnPS2.h" #endif - #ifdef OS5 #define ToMem memmove #else @@ -77,405 +70,369 @@ static char *id = "$Id: inet.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copyrigh #define TCPhostlookup 0 #define TCPservicelookup 1 -#define TCPsocket 2 -#define TCPclose 3 -#define TCPconnect 4 -#define TCPsend 5 -#define TCPrecv 6 -#define TCPListen 7 -#define TCPAccept 8 +#define TCPsocket 2 +#define TCPclose 3 +#define TCPconnect 4 +#define TCPsend 5 +#define TCPrecv 6 +#define TCPListen 7 +#define TCPAccept 8 -#define INETpeername 64 /* (socket buf) => buf has name, returns len */ -#define INETpeeraddr 65 -#define INETgetname 66 /* Address to name translation */ - -#define UDPListen 128 -#define UDPConnect 129 -#define UDPSendto 130 -#define UDPRecvfrom 131 +#define INETpeername 64 /* (socket buf) => buf has name, returns len */ +#define INETpeeraddr 65 +#define INETgetname 66 /* Address to name translation */ +#define UDPListen 128 +#define UDPConnect 129 +#define UDPSendto 130 +#define UDPRecvfrom 131 extern u_int LispIOFds, LispReadFds; extern int *Lisp_errno; -LispPTR subr_TCP_ops (op, nameConn, proto, length, bufaddr, maxlen) - int op; - LispPTR nameConn, proto, length, bufaddr, maxlen; - { +LispPTR subr_TCP_ops(op, nameConn, proto, length, bufaddr, maxlen) int op; +LispPTR nameConn, proto, length, bufaddr, maxlen; +{ #ifndef DOS - int sock, len, buflen, res; - char namestring[100]; - char servstring[50]; - struct sockaddr_in addr; - struct hostent *host; - struct servent *service; - struct sockaddr_in farend; - int addr_class, protocol; - char *buffer; - int result; + int sock, len, buflen, res; + char namestring[100]; + char servstring[50]; + struct sockaddr_in addr; + struct hostent *host; + struct servent *service; + struct sockaddr_in farend; + int addr_class, protocol; + char *buffer; + int result; #ifdef RS6000 - static int one=1; /* Used in TCPconnect */ + static int one = 1; /* Used in TCPconnect */ #endif #ifdef HPUX - static int one=1; /* Used in TCPconnect */ + static int one = 1; /* Used in TCPconnect */ #endif - switch (op & 0xFFFF) - { - case TCPhostlookup: LispStringToCString(nameConn, namestring, 100); - host = gethostbyname(namestring); - if (!host) return(NIL); - N_ARITH_SWITCH(*(int *)host->h_addr); - break; + switch (op & 0xFFFF) { + case TCPhostlookup: + LispStringToCString(nameConn, namestring, 100); + host = gethostbyname(namestring); + if (!host) return (NIL); + N_ARITH_SWITCH(*(int *)host->h_addr); + break; - case TCPservicelookup: LispStringToCString(nameConn, namestring, 100); - LispStringToCString(proto, servstring, 50); - service = getservbyname(namestring, servstring); - if (!service) return(NIL); - return(GetSmallp(service->s_port)); - break; + case TCPservicelookup: + LispStringToCString(nameConn, namestring, 100); + LispStringToCString(proto, servstring, 50); + service = getservbyname(namestring, servstring); + if (!service) return (NIL); + return (GetSmallp(service->s_port)); + break; - case TCPsocket: addr_class = LispNumToCInt(nameConn); - protocol = LispNumToCInt(proto); - result = socket(addr_class, protocol, 0); + case TCPsocket: + addr_class = LispNumToCInt(nameConn); + protocol = LispNumToCInt(proto); + result = socket(addr_class, protocol, 0); #ifdef RS6000 - ioctl(result, FIONBIO, &one); - fcntl(result, F_SETOWN, getpid()); + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); #else #ifdef HPUX - ioctl(result, FIOSNBIO, &one); + ioctl(result, FIOSNBIO, &one); #else - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) - | FNDELAY | FASYNC); + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY | FASYNC); #ifndef ISC - fcntl(result, F_SETOWN, getpid()); + fcntl(result, F_SETOWN, getpid()); #endif /* ISC */ #endif /* HPUX */ #endif /* RS6000 */ - return(GetSmallp(result)); - break; + return (GetSmallp(result)); + break; - case TCPconnect: /* args: hostname, socket# */ - memset(&farend, 0, sizeof farend); - N_GETNUMBER(nameConn, res, string_host); - farend.sin_addr.s_addr = htons(res); - goto host_ok; - string_host: - LispStringToCString(nameConn, namestring, 100); - host = gethostbyname(namestring); - if (!host) return(NIL); - ToMem( (char *)&farend.sin_addr, - (char *)host->h_addr, - host->h_length); - host_ok: - sock = LispNumToCInt(proto); - result = socket(AF_INET, SOCK_STREAM, 0); - farend.sin_family = AF_INET; - ToMem( (char *)&farend.sin_addr, - (char *)host->h_addr, - host->h_length); - farend.sin_port = sock; - if (connect(result, (struct sockaddr *)&farend, - sizeof farend)<0) - { - perror("TCP connect"); - return(NIL); - } -#ifdef RS6000 - /* FNDELAY alone isn't enough on aix */ - /* (don't know if FIONBIO alone is enough) */ - ioctl(result, FIONBIO, &one); - fcntl(result, F_SETOWN, getpid()); -#else -#ifdef HPUX - ioctl(result, FIOSNBIO, &one); -#else - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) - | FNDELAY); -#ifndef ISC - fcntl(result, F_SETOWN, getpid()); -#endif /* ISC */ - -#endif /* HPUX */ - -#endif /* RS6000 */ - - return(GetSmallp(result)); - break; - - case TCPsend: /* args: conn, buffer, len */ - sock = LispNumToCInt(nameConn); - buffer = (char *)Addr68k_from_LADDR(proto); - len = LispNumToCInt(length); - DBPRINT(("sock: %d, len %d.\n", sock, len)); - -#ifdef BYTESWAP - word_swap_page(buffer, (len + 3) >> 2); -#endif /* BYTESWAP */ - - - result = send(sock, buffer, len, 0); - -#ifdef BYTESWAP - word_swap_page(buffer, (len + 3) >> 2); -#endif /* BYTESWAP */ - - - if (result < 0) - { - perror("TCP send"); return(NIL); - } - return(GetSmallp(result)); - break; - - case TCPrecv: /* args: conn, buffer, maxlen */ - sock = LispNumToCInt(nameConn); - buffer = (char *)Addr68k_from_LADDR(proto); - len = LispNumToCInt(length); - result = read(sock, buffer, len); - if (result < 0) - { - if (errno == EWOULDBLOCK) - return(ATOM_T); - perror("TCP read"); - *Lisp_errno = errno; - return(NIL); - } -#ifdef BYTESWAP - word_swap_page(buffer, (result + 3) >> 2); -#endif /* BYTESWAP */ - - return(GetSmallp(result)); - break; - - - case TCPclose: sock = LispNumToCInt(nameConn); - LispIOFds &= ~(1<h_name); - return(GetSmallp(strlen(host->h_name))); - break; - - case INETgetname: /* host addr, buffer for name string */ - sock = LispNumToCInt(nameConn); - buffer = (char *)Addr68k_from_LADDR(proto); - res = sizeof(addr); - addr.sin_addr.s_addr = sock; - host = gethostbyaddr((const char *)&addr, res, 0); - if (!host) return(GetSmallp(0)); - strcpy(buffer, host->h_name); - return(GetSmallp(strlen(host->h_name))); - break; - - case UDPListen: /* socket# to listen on */ - sock = LispNumToCInt(nameConn); - result = socket(AF_INET, SOCK_DGRAM, 0); - farend.sin_family = AF_INET; - farend.sin_port = sock; - farend.sin_addr.s_addr = INADDR_ANY; - if (bind(result, (struct sockaddr *)&farend, sizeof(farend))<0) - { - perror("UDP bind"); - close(result); - return(NIL); - } -#ifdef RS6000 - ioctl(result, FIONBIO, &one); - fcntl(result, F_SETOWN, getpid()); -#else -#ifdef HPUX - ioctl(result, FIOSNBIO, &one); -#else - fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) - | FNDELAY | FASYNC); -#ifndef ISC - fcntl(result, F_SETOWN, getpid()); -#endif /* ISC */ - -#endif /* HPUX */ - -#endif /* RS6000 */ - - LispIOFds |= (1 << result); /* so we get interrupts */ - LispReadFds |= LispIOFds; - DBPRINT(("LispIOFds = 0x%x.\n", LispIOFds)); - return(GetSmallp(result)); - break; - - case UDPSendto: /* fd-socket# addr remote-socket buffer len*/ - sock = LispNumToCInt(nameConn); - farend.sin_family = AF_INET; - farend.sin_port = LispNumToCInt(length); - farend.sin_addr.s_addr = LispNumToCInt(proto); - buffer = (char *) Addr68k_from_LADDR(bufaddr); - buflen = LispNumToCInt(maxlen); - - DBPRINT(("UDP send: socket = %d, remote-port = %d.\n", - sock, farend.sin_port)); - DBPRINT((" remote-addr = 0x%x, buflen = %d.\n", - farend.sin_addr.s_addr, buflen)); - - -#ifdef BYTESWAP - word_swap_page(buffer, (buflen + 3) >> 2); -#endif /* BYTESWAP */ - - - if (result = sendto(sock, buffer, buflen, 0, - (struct sockaddr *)&farend, sizeof farend) <0) - -#ifdef BYTESWAP - word_swap_page(buffer, (buflen + 3) >> 2); -#endif /* BYTESWAP */ - - - { - perror("UDP Send"); - printf(" fd = %d, addr = 0x%x.\n", sock, - farend.sin_addr.s_addr); - return(NIL); - } - return(GetSmallp(result)); - break; - - case UDPRecvfrom: /* fd-socket# buffer len addr-cell port-cell*/ - sock = LispNumToCInt(nameConn); - buffer = (char *)Addr68k_from_LADDR(proto); - buflen = LispNumToCInt(length); - res = sizeof farend; - if ((result = recvfrom(sock, buffer, buflen, 0, - (struct sockaddr *)&farend, &res)) <0) - { - perror("UDP Recv"); - return(NIL); - } - - DBPRINT(("UDP recv: socket = %d, len = %d.\n", - sock, result)); - DBPRINT((" remote-addr = 0x%x, remote-port = %d.\n", - farend.sin_addr.s_addr, farend.sin_port)); - DBPRINT((" bufsize = %d, addrcell = 0x%x, portcell = 0x%x.\n", - buflen, bufaddr, maxlen)); - - *((int *)Addr68k_from_LADDR(bufaddr)) = (int)farend.sin_addr.s_addr; - *((int *)Addr68k_from_LADDR(maxlen)) = (int)farend.sin_port; - -#ifdef BYTESWAP - word_swap_page(buffer, (result + 3) >> 2); -#endif /* BYTESWAP */ - - return(GetSmallp(result)); - break; - - - default: return(NIL); - break; + case TCPconnect: /* args: hostname, socket# */ + memset(&farend, 0, sizeof farend); + N_GETNUMBER(nameConn, res, string_host); + farend.sin_addr.s_addr = htons(res); + goto host_ok; + string_host: + LispStringToCString(nameConn, namestring, 100); + host = gethostbyname(namestring); + if (!host) return (NIL); + ToMem((char *)&farend.sin_addr, (char *)host->h_addr, host->h_length); + host_ok: + sock = LispNumToCInt(proto); + result = socket(AF_INET, SOCK_STREAM, 0); + farend.sin_family = AF_INET; + ToMem((char *)&farend.sin_addr, (char *)host->h_addr, host->h_length); + farend.sin_port = sock; + if (connect(result, (struct sockaddr *)&farend, sizeof farend) < 0) { + perror("TCP connect"); + return (NIL); } -#endif /* DOS */ - } +#ifdef RS6000 + /* FNDELAY alone isn't enough on aix */ + /* (don't know if FIONBIO alone is enough) */ + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(result, FIOSNBIO, &one); +#else + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY); +#ifndef ISC + fcntl(result, F_SETOWN, getpid()); +#endif /* ISC */ +#endif /* HPUX */ + +#endif /* RS6000 */ + + return (GetSmallp(result)); + break; + + case TCPsend: /* args: conn, buffer, len */ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + len = LispNumToCInt(length); + DBPRINT(("sock: %d, len %d.\n", sock, len)); + +#ifdef BYTESWAP + word_swap_page(buffer, (len + 3) >> 2); +#endif /* BYTESWAP */ + + result = send(sock, buffer, len, 0); + +#ifdef BYTESWAP + word_swap_page(buffer, (len + 3) >> 2); +#endif /* BYTESWAP */ + + if (result < 0) { + perror("TCP send"); + return (NIL); + } + return (GetSmallp(result)); + break; + + case TCPrecv: /* args: conn, buffer, maxlen */ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + len = LispNumToCInt(length); + result = read(sock, buffer, len); + if (result < 0) { + if (errno == EWOULDBLOCK) return (ATOM_T); + perror("TCP read"); + *Lisp_errno = errno; + return (NIL); + } +#ifdef BYTESWAP + word_swap_page(buffer, (result + 3) >> 2); +#endif /* BYTESWAP */ + + return (GetSmallp(result)); + break; + + case TCPclose: + sock = LispNumToCInt(nameConn); + LispIOFds &= ~(1 << sock); + LispReadFds &= ~(1 << sock); + shutdown(sock, 2); + close(sock); + return (ATOM_T); + + case TCPListen: /* socket# to listen on */ + sock = LispNumToCInt(nameConn); + result = socket(AF_INET, SOCK_STREAM, 0); + farend.sin_family = AF_INET; + farend.sin_port = sock; + farend.sin_addr.s_addr = INADDR_ANY; + if (bind(result, (struct sockaddr *)&farend, sizeof(farend)) < 0) { + perror("TCP bind"); + close(result); + return (NIL); + } + { /* Do this without taking IO interrupts */ +#ifdef SYSVSIGNALS + sighold(SIGIO); +#else + int oldmask = sigblock(sigmask(SIGIO)); +#endif /* SYSVSIGNALS */ + +#ifdef RS6000 + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(result, FIOSNBIO, &one); +#else + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY | FASYNC); +#ifndef ISC + fcntl(result, F_SETOWN, getpid()); +#endif /* ISC */ + +#endif /* HPUX */ + +#endif /* RS6000 */ + + if (listen(result, 5) == -1) { + perror("TCP Listen"); + close(result); +#ifdef SYSVSIGNALS + sigrelse(SIGIO); +#else + sigsetmask(oldmask); +#endif /* SYSVSIGNALS */ + + return (NIL); + } +#ifdef SYSVSIGNALS + sigrelse(SIGIO); +#else + sigsetmask(oldmask); +#endif /* SYSVSIGNALS */ + } + LispIOFds |= (1 << result); /* so we get interrupts */ + LispReadFds |= LispIOFds; + DBPRINT(("LispIOFds = 0x%x.\n", LispIOFds)); + return (GetSmallp(result)); + break; + + case TCPAccept: /* Socket we're listening on */ + sock = LispNumToCInt(nameConn); + result = accept(sock, NULL, 0); + if (result < 0) { + if (errno != EWOULDBLOCK) perror("TCP Accept"); + return (NIL); + } +#ifdef RS6000 + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(result, FIOSNBIO, &one); +#else + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY); +#ifndef ISC + fcntl(result, F_SETOWN, getpid()); +#endif /* ISC */ + +#endif /* HPUX */ + +#endif /* RS6000 */ + + return (GetSmallp(result)); + break; + + case INETpeername: /* socket#, buffer for name string */ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + res = sizeof(addr); + getpeername(sock, (struct sockaddr *)&addr, &res); + host = gethostbyaddr((const char *)&addr, res, AF_INET); + strcpy(buffer, host->h_name); + return (GetSmallp(strlen(host->h_name))); + break; + + case INETgetname: /* host addr, buffer for name string */ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + res = sizeof(addr); + addr.sin_addr.s_addr = sock; + host = gethostbyaddr((const char *)&addr, res, 0); + if (!host) return (GetSmallp(0)); + strcpy(buffer, host->h_name); + return (GetSmallp(strlen(host->h_name))); + break; + + case UDPListen: /* socket# to listen on */ + sock = LispNumToCInt(nameConn); + result = socket(AF_INET, SOCK_DGRAM, 0); + farend.sin_family = AF_INET; + farend.sin_port = sock; + farend.sin_addr.s_addr = INADDR_ANY; + if (bind(result, (struct sockaddr *)&farend, sizeof(farend)) < 0) { + perror("UDP bind"); + close(result); + return (NIL); + } +#ifdef RS6000 + ioctl(result, FIONBIO, &one); + fcntl(result, F_SETOWN, getpid()); +#else +#ifdef HPUX + ioctl(result, FIOSNBIO, &one); +#else + fcntl(result, F_SETFL, fcntl(result, F_GETFL, 0) | FNDELAY | FASYNC); +#ifndef ISC + fcntl(result, F_SETOWN, getpid()); +#endif /* ISC */ + +#endif /* HPUX */ + +#endif /* RS6000 */ + + LispIOFds |= (1 << result); /* so we get interrupts */ + LispReadFds |= LispIOFds; + DBPRINT(("LispIOFds = 0x%x.\n", LispIOFds)); + return (GetSmallp(result)); + break; + + case UDPSendto: /* fd-socket# addr remote-socket buffer len*/ + sock = LispNumToCInt(nameConn); + farend.sin_family = AF_INET; + farend.sin_port = LispNumToCInt(length); + farend.sin_addr.s_addr = LispNumToCInt(proto); + buffer = (char *)Addr68k_from_LADDR(bufaddr); + buflen = LispNumToCInt(maxlen); + + DBPRINT(("UDP send: socket = %d, remote-port = %d.\n", sock, farend.sin_port)); + DBPRINT((" remote-addr = 0x%x, buflen = %d.\n", farend.sin_addr.s_addr, buflen)); + +#ifdef BYTESWAP + word_swap_page(buffer, (buflen + 3) >> 2); +#endif /* BYTESWAP */ + + if (result = sendto(sock, buffer, buflen, 0, (struct sockaddr *)&farend, sizeof farend) < 0) + +#ifdef BYTESWAP + word_swap_page(buffer, (buflen + 3) >> 2); +#endif /* BYTESWAP */ + + { + perror("UDP Send"); + printf(" fd = %d, addr = 0x%x.\n", sock, farend.sin_addr.s_addr); + return (NIL); + } + return (GetSmallp(result)); + break; + + case UDPRecvfrom: /* fd-socket# buffer len addr-cell port-cell*/ + sock = LispNumToCInt(nameConn); + buffer = (char *)Addr68k_from_LADDR(proto); + buflen = LispNumToCInt(length); + res = sizeof farend; + if ((result = recvfrom(sock, buffer, buflen, 0, (struct sockaddr *)&farend, &res)) < 0) { + perror("UDP Recv"); + return (NIL); + } + + DBPRINT(("UDP recv: socket = %d, len = %d.\n", sock, result)); + DBPRINT((" remote-addr = 0x%x, remote-port = %d.\n", farend.sin_addr.s_addr, + farend.sin_port)); + DBPRINT((" bufsize = %d, addrcell = 0x%x, portcell = 0x%x.\n", buflen, bufaddr, + maxlen)); + + *((int *)Addr68k_from_LADDR(bufaddr)) = (int)farend.sin_addr.s_addr; + *((int *)Addr68k_from_LADDR(maxlen)) = (int)farend.sin_port; + +#ifdef BYTESWAP + word_swap_page(buffer, (result + 3) >> 2); +#endif /* BYTESWAP */ + + return (GetSmallp(result)); + break; + + default: return (NIL); break; + } +#endif /* DOS */ +} diff --git a/src/initdsp.c b/src/initdsp.c old mode 100755 new mode 100644 index 925e6ec..bb5e6c2 --- a/src/initdsp.c +++ b/src/initdsp.c @@ -1,10 +1,7 @@ -/* $Id: initdsp.c,v 1.2 1999/01/03 02:07:08 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: initdsp.c,v 1.2 1999/01/03 02:07:08 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: initdsp.c,v 1.2 1999/01/03 02:07:08 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,17 +14,13 @@ static char *id = "$Id: initdsp.c,v 1.2 1999/01/03 02:07:08 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - /* * file : initdsp.c * Author : Osamu Nakamura */ - - #include #ifndef NOPIXRECT @@ -95,10 +88,9 @@ int DisplayWidth8; extern DspInterfaceRec _curdsp, _coldsp; #endif /* DOS */ - /* from /usr/include/sun/fbio.h some machines don't have following def. */ #ifndef FBTYPE_SUNROP_COLOR -#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */ +#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */ #define FBTYPE_SUNFAST_COLOR 12 #endif @@ -107,12 +99,11 @@ struct screen LispScreen; struct pixrect *CursorBitMap, *InvisibleCursorBitMap; struct pixrect *SrcePixRect, *DestPixRect; #ifdef DISPLAYBUFFER - int black = 0, white = -1; - struct pixrect *ColorDisplayPixrect, - *DisplayRegionPixrect; -#define COPY_PIXRECT_TO_COLOR (PIX_SRC /*| PIX_DONTCLIP */) +int black = 0, white = -1; +struct pixrect *ColorDisplayPixrect, *DisplayRegionPixrect; +#define COPY_PIXRECT_TO_COLOR (PIX_SRC /*| PIX_DONTCLIP */) #ifdef DEBUG - int oldred[2], oldgreen[2], oldblue[2]; +int oldred[2], oldgreen[2], oldblue[2]; #endif /* DEBUG */ #endif /* DISPLAYBUFFER */ #endif /* NOPIXRECT */ @@ -120,9 +111,9 @@ struct pixrect *SrcePixRect, *DestPixRect; int LispWindowFd; int FrameBufferFd; -int displaywidth, displayheight, DisplayRasterWidth, DisplayType; -int DisplayByteSize; -DLword *DisplayRegion68k; /* 68k addr of #{}22,0 */ +int displaywidth, displayheight, DisplayRasterWidth, DisplayType; +int DisplayByteSize; +DLword *DisplayRegion68k; /* 68k addr of #{}22,0 */ #ifdef DISPLAYBUFFER /* both vars has same value. That is the end of Lisp DisplayRegion */ @@ -150,20 +141,18 @@ extern int MonoOrColor; #ifdef XWINDOW DLword *DisplayRegion68k_end_addr; -int LispDisplayWidth - , LispDisplayHeight; -extern int *Xdisplay; /* DAANGER -jarl nilsson 27-apr-92 */ -#endif /* XWINDOW */ +int LispDisplayWidth, LispDisplayHeight; +extern int *Xdisplay; /* DAANGER -jarl nilsson 27-apr-92 */ +#endif /* XWINDOW */ #ifdef SUNDISPLAY /* For SunOS4.1 Window Security Feature. */ int Win_security_p; #include -#define SV_ACQUIRE "/bin/sunview1/sv_acquire" -#define SV_RELEASE "/bin/sunview1/sv_release" +#define SV_ACQUIRE "/bin/sunview1/sv_acquire" +#define SV_RELEASE "/bin/sunview1/sv_release" #endif /* SUNDISPLAY */ - /************************************************************************/ /* */ /* */ @@ -172,37 +161,34 @@ int Win_security_p; /* */ /************************************************************************/ -void init_cursor() - { +void init_cursor() { +#ifndef NOPIXRECT + CursorBitMap = mem_create(CURSORWIDTH, CURSORHEIGHT, 1); + mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3; /* 2(byte) */ +#endif /* NOPIXRECT */ + +#ifdef SUNDISPLAY + CurrentCursor.cur_xhot = 0; + CurrentCursor.cur_yhot = 0; + CurrentCursor.cur_shape = CursorBitMap; + CurrentCursor.cur_function = PIX_SRC | PIX_DST; +#endif /* SUNDISPLAY */ + +/* Invisible Cursor */ #ifndef NOPIXRECT - CursorBitMap = mem_create( CURSORWIDTH, CURSORHEIGHT, 1 ); - mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3;/* 2(byte) */ + InvisibleCursorBitMap = mem_create(0, 0, 1); #endif /* NOPIXRECT */ #ifdef SUNDISPLAY - CurrentCursor.cur_xhot = 0; - CurrentCursor.cur_yhot = 0; - CurrentCursor.cur_shape = CursorBitMap; - CurrentCursor.cur_function = PIX_SRC | PIX_DST; + InvisibleCursor.cur_xhot = 0; + InvisibleCursor.cur_yhot = 0; + InvisibleCursor.cur_shape = InvisibleCursorBitMap; + InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST; + win_setcursor(LispWindowFd, &InvisibleCursor); + win_setmouseposition(LispWindowFd, 0, 0); #endif /* SUNDISPLAY */ - - /* Invisible Cursor */ - -#ifndef NOPIXRECT - InvisibleCursorBitMap = mem_create( 0, 0, 1 ); -#endif /* NOPIXRECT */ - -#ifdef SUNDISPLAY - InvisibleCursor.cur_xhot = 0; - InvisibleCursor.cur_yhot = 0; - InvisibleCursor.cur_shape = InvisibleCursorBitMap; - InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST; - win_setcursor( LispWindowFd, &InvisibleCursor); - win_setmouseposition(LispWindowFd, 0, 0); -#endif /* SUNDISPLAY */ - - } +} /************************************************************************/ /* */ @@ -211,33 +197,27 @@ void init_cursor() /* */ /* */ /************************************************************************/ -void set_cursor() - { +void set_cursor() { #ifdef SUNDISPLAY #ifdef OLD_CURSOR - (mpr_d(CursorBitMap))->md_image = - (short *)(IOPage->dlcursorbitmap); - /* BitmapBase of CurrentCursor - * is set to IOPage->dlcursorbitmap - */ - if( win_setcursor( LispWindowFd, &CurrentCursor )== -1) - perror("SET Cursor"); - if( win_setmouseposition(LispWindowFd, 0, 0)==-1) - perror("SET Mouse POS"); + (mpr_d(CursorBitMap))->md_image = (short *)(IOPage->dlcursorbitmap); + /* BitmapBase of CurrentCursor + * is set to IOPage->dlcursorbitmap + */ + if (win_setcursor(LispWindowFd, &CurrentCursor) == -1) perror("SET Cursor"); + if (win_setmouseposition(LispWindowFd, 0, 0) == -1) perror("SET Mouse POS"); #else - if( win_setcursor(LispWindowFd,&InvisibleCursor) ==-1) - perror("SET Cursor:"); + if (win_setcursor(LispWindowFd, &InvisibleCursor) == -1) perror("SET Cursor:"); #endif #endif /* SUNDISPLAY */ #ifdef XWINDOW - Init_XCursor(); + Init_XCursor(); #endif /* XWINDOW */ - DBPRINT(("After Set cursor\n")); + DBPRINT(("After Set cursor\n")); } - /************************************************************************/ /* */ /* */ @@ -247,398 +227,348 @@ void set_cursor() /************************************************************************/ #ifndef COLOR -void clear_display() - { +void clear_display() { #ifdef SUNDISPLAY #ifndef DISPLAYBUFFER - register short *word; - register int w, h; - word =(short*) DisplayRegion68k; - for (h = displayheight; (h--);) - { - for (w = DisplayRasterWidth; (w--);) {*word++ = 0;} - } + register short *word; + register int w, h; + word = (short *)DisplayRegion68k; + for (h = displayheight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *word++ = 0; } + } #else - pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, - PIX_CLR, - ColorDisplayPixrect, 0, 0); - /* Original images are still kept in SYSOUT(DisplayRegion) */ - /* clear_CG6; */ + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, PIX_CLR, ColorDisplayPixrect, 0, + 0); +/* Original images are still kept in SYSOUT(DisplayRegion) */ +/* clear_CG6; */ #endif /* DISPLAYBUFFER */ #endif /* SUNDISPLAY */ #ifdef DOS - TPRINT(("Enter Clear_display\n")); - (currentdsp->cleardisplay)(currentdsp); - TPRINT(("Exit Clear_display\n")); + TPRINT(("Enter Clear_display\n")); + (currentdsp->cleardisplay)(currentdsp); + TPRINT(("Exit Clear_display\n")); #endif /* DOS */ - - } +} #else /* COLOR */ -void clear_display() -{ - register short *word; - register int w, h; - if( MonoOrColor == MONO_SCREEN ) { +void clear_display() { + register short *word; + register int w, h; + if (MonoOrColor == MONO_SCREEN) { #ifndef DISPLAYBUFFER - word = DisplayRegion68k; - for( h=displayheight; (h--);) { - for( w=DisplayRasterWidth; (w--);) {*word++ = 0;} - } /* end for(h) */ -#else /* DISPLAYBUFFER */ - pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, - PIX_CLR,ColorDisplayPixrect, 0, 0); + word = DisplayRegion68k; + for (h = displayheight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *word++ = 0; } + } /* end for(h) */ +#else /* DISPLAYBUFFER */ + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, PIX_CLR, ColorDisplayPixrect, 0, + 0); #endif /* DISPLAYBUFFER */ - } else { /* MonoOrColo is COLOR_SCREEN */ - word = (short *)ColorDisplayRegion68k; - for( h=displayheight; (h--);) { - for( w=DisplayRasterWidth*8; (w--);) {*word++ = 0;} - } /* end for(h) */ - } /* end if(MonoOrColor) */ + } else { /* MonoOrColo is COLOR_SCREEN */ + word = (short *)ColorDisplayRegion68k; + for (h = displayheight; (h--);) { + for (w = DisplayRasterWidth * 8; (w--);) { *word++ = 0; } + } /* end for(h) */ + } /* end if(MonoOrColor) */ } #endif /* COLOR */ /* ================================================================ */ /* Now takes 68k address, function renamed for safety */ -void init_display2(display_addr, display_max) - INT display_addr, display_max; - { - int mmapstat; - int fbgattr_result; - char *texture_base; +void init_display2(display_addr, display_max) INT display_addr, display_max; +{ + int mmapstat; + int fbgattr_result; + char *texture_base; #ifdef SUNDISPLAY - struct fbtype my_screen; - char groups[PIXPG_OVERLAY+1]; - struct fbgattr FBattr; - struct pixrect *ColorFb; + struct fbtype my_screen; + char groups[PIXPG_OVERLAY + 1]; + struct fbgattr FBattr; + struct pixrect *ColorFb; #endif /* SUNDISPLAY */ #ifdef SUNDISPLAY - /* For SunOS4.1 Window Security Feature. */ + /* For SunOS4.1 Window Security Feature. */ - union wait status; + union wait status; - /* Window Security is available? */ - if (!access(SV_ACQUIRE, F_OK)) - Win_security_p = 1; - else - Win_security_p = 0; + /* Window Security is available? */ + if (!access(SV_ACQUIRE, F_OK)) + Win_security_p = 1; + else + Win_security_p = 0; - if (Win_security_p) { - switch (vfork()) { - case -1: /* Error */ - (void)fprintf(stderr, "init_display: Fork failed.\n"); - exit(1); + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ (void)fprintf(stderr, "init_display: Fork failed.\n"); exit(1); - case 0: /* Child */ - (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); - /* should not return */ - (void)fprintf(stderr, "init_display: exec for sv_acquire failed\n"); - exit(1); + case 0: /* Child */ + (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); + /* should not return */ + (void)fprintf(stderr, "init_display: exec for sv_acquire failed\n"); + exit(1); - default: /* Parent */ - /* do nothing */ - break; - } - (void)wait(&status); /* child dies after changing 6 */ - - if (status.w_retcode != 0) { - (void)fprintf(stderr, - "init_display: failed to set ownership of win devices\n"); - exit(1); - } + default: /* Parent */ + /* do nothing */ + break; } - + (void)wait(&status); /* child dies after changing 6 */ + + if (status.w_retcode != 0) { + (void)fprintf(stderr, "init_display: failed to set ownership of win devices\n"); + exit(1); + } + } + #endif /* SUNDISPLAY */ #ifdef SUNDISPLAY - if( (LispWindowFd = win_screennew( &LispScreen )) == -1) - { - perror("init_display: can't create LispWindow\n"); - exit( -1 ); - } - else - { + if ((LispWindowFd = win_screennew(&LispScreen)) == -1) { + perror("init_display: can't create LispWindow\n"); + exit(-1); + } else { #ifdef KBINT - /* int_io_open(LispWindowFd); JDS 4/27/94 move to initkbd, to try preventing the move-mouse-never-get-kbd bug */ +/* int_io_open(LispWindowFd); JDS 4/27/94 move to initkbd, to try preventing the + * move-mouse-never-get-kbd bug */ #endif - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); - } + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); + } #endif /* SUNDISPLAY */ - DisplayRegion68k = (DLword *) display_addr; + DisplayRegion68k = (DLword *)display_addr; #ifdef SUNDISPLAY - if( (FrameBufferFd = open( LispScreen.scr_fbname, 2 )) == -1) - { - perror("init_display: can't open FrameBuffer\n"); - exit( -1 ); - } + if ((FrameBufferFd = open(LispScreen.scr_fbname, 2)) == -1) { + perror("init_display: can't open FrameBuffer\n"); + exit(-1); + } - /* initialize Display parameters */ - if (ioctl(FrameBufferFd, FBIOGTYPE , &my_screen)== -1) - { - perror("init_display: can't find screen parameters\n"); - exit( -1 ); - } - displaywidth = my_screen.fb_width; - displayheight = my_screen.fb_height; + /* initialize Display parameters */ + if (ioctl(FrameBufferFd, FBIOGTYPE, &my_screen) == -1) { + perror("init_display: can't find screen parameters\n"); + exit(-1); + } + displaywidth = my_screen.fb_width; + displayheight = my_screen.fb_height; #endif /* SUNDISPLAY */ #if (defined(XWINDOW) || defined(DOS)) - (currentdsp->device.enter)(currentdsp); - displaywidth = currentdsp->Display.width; - displayheight = currentdsp->Display.height; + (currentdsp->device.enter)(currentdsp); + displaywidth = currentdsp->Display.width; + displayheight = currentdsp->Display.height; #endif /* XWINDOW */ - DisplayRasterWidth = displaywidth / BITSPER_DLWORD; - - if ((displaywidth * displayheight) > display_max) - { - displayheight = display_max / displaywidth; - } - DISP_MAX_Address = DisplayRegion68k + DisplayRasterWidth * displayheight; - DBPRINT(("FBIOGTYPE w x h = %d x %d\n", displaywidth, displayheight)); - + DisplayRasterWidth = displaywidth / BITSPER_DLWORD; + if ((displaywidth * displayheight) > display_max) { displayheight = display_max / displaywidth; } + DISP_MAX_Address = DisplayRegion68k + DisplayRasterWidth * displayheight; + DBPRINT(("FBIOGTYPE w x h = %d x %d\n", displaywidth, displayheight)); #ifdef DOS - DisplayWidth8 = displaywidth / 8; + DisplayWidth8 = displaywidth / 8; #endif /* DOS */ - DBPRINT(("FBIOGTYPE w x h = %d x %d\n", displaywidth, displayheight)); + DBPRINT(("FBIOGTYPE w x h = %d x %d\n", displaywidth, displayheight)); #if (!defined(XWINDOW) && !defined(DOS)) - DBPRINT((" (real) type = %d\n", my_screen.fb_type )); - DBPRINT((" (real) bpp = %d\n", my_screen.fb_depth )); + DBPRINT((" (real) type = %d\n", my_screen.fb_type)); + DBPRINT((" (real) bpp = %d\n", my_screen.fb_depth)); #endif /* XWINDOW */ #ifdef SUNDISPLAY -/** now attempt to use the FBIOGATTR call for more information **/ + /** now attempt to use the FBIOGATTR call for more information **/ - fbgattr_result = ioctl(FrameBufferFd, FBIOGATTR, &FBattr); - if( fbgattr_result >= 0 ) - { - DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type)); - DBPRINT((" (real) size = %d x %d\n", FBattr.fbtype.fb_width, - FBattr.fbtype.fb_height)); - DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type )); - DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth )); - DBPRINT((" emuls= %d %d %d %d\n", - FBattr.emu_types[0], FBattr.emu_types[1], - FBattr.emu_types[2], FBattr.emu_types[3])); - } - else - { /* fill in defaults */ - FBattr.real_type = my_screen.fb_type; - } - DBPRINT (("init_display: FBIOGATTR_result = %d\n", fbgattr_result)); + fbgattr_result = ioctl(FrameBufferFd, FBIOGATTR, &FBattr); + if (fbgattr_result >= 0) { + DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type)); + DBPRINT((" (real) size = %d x %d\n", FBattr.fbtype.fb_width, FBattr.fbtype.fb_height)); + DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type)); + DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth)); + DBPRINT((" emuls= %d %d %d %d\n", FBattr.emu_types[0], FBattr.emu_types[1], + FBattr.emu_types[2], FBattr.emu_types[3])); + } else { /* fill in defaults */ + FBattr.real_type = my_screen.fb_type; + } + DBPRINT(("init_display: FBIOGATTR_result = %d\n", fbgattr_result)); /* probe for DISPLAY type */ /********************************************************************** * FB-TYPE REAL-TYPE * BW2 2 x * CG2 3 3 * CG3 8 6 - * CG4 2 8 + * CG4 2 8 * CG6 8 12 * CG8 6 7 * CG9(GP1) 4 4 ;gpconfig -f -b - * CG9(GP1) 2 13 ;gpconfig gpone0 -f -b cgtwo0 + * CG9(GP1) 2 13 ;gpconfig gpone0 -f -b cgtwo0 * ;We assume This config for GXP model ***********************************************************************/ /* Medley supports real (or emulated) BW2, so check for that first */ #ifndef DISPLAYBUFFER - if ( (my_screen.fb_type == FBTYPE_SUN2BW ) /* real or emulated bwtwo */ - ||(my_screen.fb_type == FBTYPE_SUN3COLOR) ) /* Sun 3 color? */ - switch ( FBattr.real_type ) - { - case FBTYPE_SUN2BW : DisplayType = SUN2BW; - break; + if ((my_screen.fb_type == FBTYPE_SUN2BW) /* real or emulated bwtwo */ + || (my_screen.fb_type == FBTYPE_SUN3COLOR)) /* Sun 3 color? */ + switch (FBattr.real_type) { + case FBTYPE_SUN2BW: DisplayType = SUN2BW; break; - case FBTYPE_MEMCOLOR : /* memory 24-bit (CG8) */ - { - DisplayType = SUNMEMCOLOR; - ColorFb = pr_open("/dev/fb"); - pr_available_plane_groups( ColorFb, sizeof(groups), groups); - if(groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) - { - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, - PIX_SET, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY); - } - } - break; + case FBTYPE_MEMCOLOR: /* memory 24-bit (CG8) */ + { + DisplayType = SUNMEMCOLOR; + ColorFb = pr_open("/dev/fb"); + pr_available_plane_groups(ColorFb, sizeof(groups), groups); + if (groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } + } break; - case FBTYPE_SUN4COLOR : /* cg4 */ - case FBTYPE_SUNROP_COLOR : /* cg9(GXP) */ - { /* need to clear overlay plane */ - DisplayType = SUN4COLOR; - ColorFb = pr_open("/dev/fb"); - pr_available_plane_groups( ColorFb, sizeof(groups), groups); - if(groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) - { - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, - PIX_SET, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY); - } - break; - } - - default : - printf("initdisplay: Unsupported FBreal_type %d\n", - FBattr.real_type); - DisplayType = (my_screen.fb_type) << 3; - /* should be able to proceed, since its an emulated bwtwo */ - } - else - { /* not currently a SUN2BW, perhaps can emulate it? */ - if ( fbgattr_result >= 0 ) - { /* got gattrs, can try sattr */ -#ifdef DEBUG - error ( "fb bwtwo emulation not implemented, q to proceed\n" ); -#endif /* DEBUG */ - } - else - { - error ( "Not cgfour or bwtwo, q to attempt to proceed" ); - } - printf("initdisplay: Unsupported FBreal_type %d\n", FBattr.real_type); - DisplayType = (my_screen.fb_type) << 3; - /* try to muddle on */ + case FBTYPE_SUN4COLOR: /* cg4 */ + case FBTYPE_SUNROP_COLOR: /* cg9(GXP) */ + { /* need to clear overlay plane */ + DisplayType = SUN4COLOR; + ColorFb = pr_open("/dev/fb"); + pr_available_plane_groups(ColorFb, sizeof(groups), groups); + if (groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } + break; } + + default: + printf("initdisplay: Unsupported FBreal_type %d\n", FBattr.real_type); + DisplayType = (my_screen.fb_type) << 3; + /* should be able to proceed, since its an emulated bwtwo */ + } + else { /* not currently a SUN2BW, perhaps can emulate it? */ + if (fbgattr_result >= 0) { /* got gattrs, can try sattr */ +#ifdef DEBUG + error("fb bwtwo emulation not implemented, q to proceed\n"); +#endif /* DEBUG */ + } else { + error("Not cgfour or bwtwo, q to attempt to proceed"); + } + printf("initdisplay: Unsupported FBreal_type %d\n", FBattr.real_type); + DisplayType = (my_screen.fb_type) << 3; + /* try to muddle on */ + } #else /* DISPLAYBUFFER is defined, then: */ - DisplayRegion68k_end_addr = DisplayRegion68k - + DisplayRasterWidth * displayheight; -if ( my_screen.fb_type == FBTYPE_SUN2BW ) /* real or emulated bwtwo */ - switch ( FBattr.real_type ) - { - case FBTYPE_SUN4COLOR : - { /* need to clear overlay plane */ - DisplayType = SUN4COLOR; - ColorFb = pr_open("/dev/fb"); - pr_available_plane_groups( ColorFb, sizeof(groups), groups); - if(groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) - { - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, - PIX_CLR, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); - } - ColorDisplayPixrect = ColorFb; - break; - } + DisplayRegion68k_end_addr = DisplayRegion68k + DisplayRasterWidth * displayheight; + if (my_screen.fb_type == FBTYPE_SUN2BW) /* real or emulated bwtwo */ + switch (FBattr.real_type) { + case FBTYPE_SUN4COLOR: { /* need to clear overlay plane */ + DisplayType = SUN4COLOR; + ColorFb = pr_open("/dev/fb"); + pr_available_plane_groups(ColorFb, sizeof(groups), groups); + if (groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_CLR, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); + } + ColorDisplayPixrect = ColorFb; + break; + } - default : ColorDisplayPixrect = pr_open("/dev/fb"); - break; - } + default: ColorDisplayPixrect = pr_open("/dev/fb"); break; + } -else if( my_screen.fb_type == FBTYPE_SUN4COLOR ) { /* cg3 or cg6 */ - switch ( FBattr.real_type ) { - case FBTYPE_SUN3COLOR: /* cg3 */ - /* DisplayType = SUN3COLOR; */ - DisplayType = (FBattr.real_type) << 3; - break; - case FBTYPE_SUNFAST_COLOR: /* cg6 */ - /* DisplayType = SUNFASTCOLOR; */ - DisplayType = (FBattr.real_type) << 3; - break; - default: /* unknown display */ - DisplayType = (FBattr.real_type) << 3; - break; - } /* end switch */ - ColorDisplayPixrect = pr_open("/dev/fb"); -} /* end else if() */ + else if (my_screen.fb_type == FBTYPE_SUN4COLOR) { /* cg3 or cg6 */ + switch (FBattr.real_type) { + case FBTYPE_SUN3COLOR: /* cg3 */ + /* DisplayType = SUN3COLOR; */ + DisplayType = (FBattr.real_type) << 3; + break; + case FBTYPE_SUNFAST_COLOR: /* cg6 */ + /* DisplayType = SUNFASTCOLOR; */ + DisplayType = (FBattr.real_type) << 3; + break; + default: /* unknown display */ DisplayType = (FBattr.real_type) << 3; break; + } /* end switch */ + ColorDisplayPixrect = pr_open("/dev/fb"); + } /* end else if() */ - else ColorDisplayPixrect = pr_open("/dev/fb"); - DisplayRegionPixrect = mem_point(displaywidth, displayheight, - 1, display_addr); + else + ColorDisplayPixrect = pr_open("/dev/fb"); + DisplayRegionPixrect = mem_point(displaywidth, displayheight, 1, display_addr); #ifdef I386 - ((struct mpr_data *)DisplayRegionPixrect->pr_data)->md_flags |= MP_I386; - ((struct mpr_data *)ColorDisplayPixrect->pr_data)->md_flags |= MP_I386; + ((struct mpr_data *)DisplayRegionPixrect->pr_data)->md_flags |= MP_I386; + ((struct mpr_data *)ColorDisplayPixrect->pr_data)->md_flags |= MP_I386; #endif #ifdef DEBUG - pr_getcolormap(ColorDisplayPixrect, 0, 2, oldred, oldgreen, oldblue); + pr_getcolormap(ColorDisplayPixrect, 0, 2, oldred, oldgreen, oldblue); #endif /* DEBUG */ - DBPRINT(("Color map for color pixrect:\n 0: R: %d, G: %d, B: %d\n 1: R: %d, G: %d, B: %d\n", oldred[0], oldgreen[0], oldblue[0], oldred[1], oldgreen[1], oldblue[1])); - DBPRINT(("Color depth = %d.\n", ColorDisplayPixrect->pr_depth)); - pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); - pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); - pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); - pr_putcolormap(ColorDisplayPixrect, - (1<pr_depth)-1, 1, - &black, &black, &black); + DBPRINT(("Color map for color pixrect:\n 0: R: %d, G: %d, B: %d\n 1: R: %d, G: %d, B: %d\n", + oldred[0], oldgreen[0], oldblue[0], oldred[1], oldgreen[1], oldblue[1])); + DBPRINT(("Color depth = %d.\n", ColorDisplayPixrect->pr_depth)); + pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); + pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, (1 << ColorDisplayPixrect->pr_depth) - 1, 1, &black, &black, + &black); #endif - DisplayLockArea.wl_rect.r_width = displaywidth; - DisplayLockArea.wl_rect.r_height = displayheight; + DisplayLockArea.wl_rect.r_width = displaywidth; + DisplayLockArea.wl_rect.r_height = displayheight; #endif /* SUNDISPLAY */ #ifdef XWINDOW - DisplayType = SUN2BW; - DisplayRegion68k_end_addr = DisplayRegion68k - + DisplayRasterWidth * displayheight; + DisplayType = SUN2BW; + DisplayRegion68k_end_addr = DisplayRegion68k + DisplayRasterWidth * displayheight; #endif /* XWINDOW */ - init_cursor(); - DisplayByteSize= ((displaywidth * displayheight / 8 + (getpagesize()-1) ) - & -getpagesize()); + init_cursor(); + DisplayByteSize = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); - DBPRINT(("Display address: 0x%x\n",DisplayRegion68k)); - DBPRINT((" length : 0x%x\n",DisplayByteSize)); - DBPRINT((" pg size: 0x%x\n",getpagesize())); + DBPRINT(("Display address: 0x%x\n", DisplayRegion68k)); + DBPRINT((" length : 0x%x\n", DisplayByteSize)); + DBPRINT((" pg size: 0x%x\n", getpagesize())); #ifdef SUNDISPLAY #ifndef DISPLAYBUFFER - mmapstat = (int)mmap( DisplayRegion68k, - DisplayByteSize, - PROT_READ | PROT_WRITE, + mmapstat = (int)mmap(DisplayRegion68k, DisplayByteSize, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif - MAP_SHARED, - FrameBufferFd, 0 ); + MAP_SHARED, + FrameBufferFd, 0); - DBPRINT(("after mmap: 0x%x\n",mmapstat)); + DBPRINT(("after mmap: 0x%x\n", mmapstat)); - if(mmapstat == -1) - { - perror("init_display: ERROR at mmap system call\n"); - exit( 0 ); - } + if (mmapstat == -1) { + perror("init_display: ERROR at mmap system call\n"); + exit(0); + } #endif /* ifndef DISPLAYBUFFER */ - DBPRINT(("after mem_point\n")); + DBPRINT(("after mem_point\n")); #endif /* SUNDISPLAY */ #ifdef DOS - (currentdsp->cleardisplay)(currentdsp); -#else /* DOS */ - clear_display(); + (currentdsp->cleardisplay)(currentdsp); +#else /* DOS */ + clear_display(); #endif /* DOS */ - DBPRINT(("after clear_display()\n")); + DBPRINT(("after clear_display()\n")); #ifndef NOPIXRECT - /* initialize pixrect used in pilotbitblt */ - SrcePixRect = mem_point( 0, 0, 1, NULL ); - DestPixRect = mem_point( 0, 0, 1, NULL ); + /* initialize pixrect used in pilotbitblt */ + SrcePixRect = mem_point(0, 0, 1, NULL); + DestPixRect = mem_point(0, 0, 1, NULL); #endif /* NOPIXRECT */ - DBPRINT(("exiting init_display\n")); + DBPRINT(("exiting init_display\n")); } - - /************************************************************************/ /* */ /* */ @@ -646,59 +576,51 @@ else if( my_screen.fb_type == FBTYPE_SUN4COLOR ) { /* cg3 or cg6 */ /* */ /* */ /************************************************************************/ -void display_before_exit() - { +void display_before_exit() { #ifdef SUNDISPLAY - union wait status; + union wait status; #endif /* SUNDISPLAY */ #ifdef TRUECOLOR - truecolor_before_exit(); + truecolor_before_exit(); #endif /* TRUECOLOR */ - clear_display(); + clear_display(); #ifdef SUNDISPLAY /* win_remove( LispWindowFd ); */ - win_screendestroy( LispWindowFd ); + win_screendestroy(LispWindowFd); #ifdef KBINT - int_io_close(LispWindowFd); + int_io_close(LispWindowFd); #endif - close( LispWindowFd ); + close(LispWindowFd); - if (Win_security_p) { + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ (void)fprintf(stderr, "display_before_exit: Fork failed.\n"); exit(1); - switch (vfork()) { - case -1: /* Error */ - (void)fprintf(stderr, "display_before_exit: Fork failed.\n"); - exit(1); + case 0: /* Child */ + (void)execl(SV_RELEASE, "sv_release", 0); + /* should not return */ + (void)fprintf(stderr, "display_before_exit: exec for sv_release failed\n"); + exit(1); - case 0: /* Child */ - (void)execl(SV_RELEASE, "sv_release", 0); - /* should not return */ - (void)fprintf(stderr, - "display_before_exit: exec for sv_release failed\n"); - exit(1); - - default: /* Parent */ - /* do nothing */ - break; - } - (void)wait(&status); - if (status.w_retcode != 0) { - (void)fprintf(stderr, - "display_before_raid: failed to set ownership of win devices\n"); - exit(1); - } - } + default: /* Parent */ + /* do nothing */ + break; + } + (void)wait(&status); + if (status.w_retcode != 0) { + (void)fprintf(stderr, "display_before_raid: failed to set ownership of win devices\n"); + exit(1); + } + } #endif /* SUNDISPLAY */ #if defined(XWINDOW) || defined(DOS) - (currentdsp->device.exit)(currentdsp); + (currentdsp->device.exit)(currentdsp); #endif /* DOS */ - } - - +} #ifdef DISPLAYBUFFER @@ -720,18 +642,17 @@ void display_before_exit() /* */ /************************************************************************/ /* Change as MACRO by osamu '90/02/08 - * new macro definition is in display.h + * new macro definition is in display.h in_display_segment(baseaddr) register DLword *baseaddr; { if ((DisplayRegion68k <= baseaddr) && - (baseaddr <=DISP_MAX_Address)) return(T); + (baseaddr <=DISP_MAX_Address)) return(T); return(NIL); } ------------------ */ #endif /* DISPLAYBUFFER */ - /************************************************************************/ /* */ /* f l u s h _ d i s p l a y _ b u f f e r */ @@ -741,44 +662,33 @@ in_display_segment(baseaddr) /* */ /************************************************************************/ -void flush_display_buffer() - { +void flush_display_buffer() { #ifdef SUNDISPLAY #ifdef DISPLAYBUFFER #ifdef I386 - bit_reverse_region( DisplayRegion68k, displaywidth, - displayheight, DLWORD_PERLINE); + bit_reverse_region(DisplayRegion68k, displaywidth, displayheight, DLWORD_PERLINE); #endif - pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, - COPY_PIXRECT_TO_COLOR, - DisplayRegionPixrect, 0, 0); + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, COPY_PIXRECT_TO_COLOR, + DisplayRegionPixrect, 0, 0); #ifdef I386 - bit_reverse_region( DisplayRegion68k, displaywidth, - displayheight, DLWORD_PERLINE); + bit_reverse_region(DisplayRegion68k, displaywidth, displayheight, DLWORD_PERLINE); #endif #endif /* DISPLAYBUFFER */ #endif /* SUNDISPLAY */ #ifdef XWINDOW - (currentdsp->bitblt_to_screen)(currentdsp, - DisplayRegion68k, - currentdsp->Vissible.x, - currentdsp->Vissible.y, - currentdsp->Vissible.width, - currentdsp->Vissible.height ); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, currentdsp->Vissible.x, + currentdsp->Vissible.y, currentdsp->Vissible.width, + currentdsp->Vissible.height); #elif DOS - TPRINT(("Enter flush_display_buffer\n")); - (currentdsp->bitblt_to_screen)(currentdsp, - DisplayRegion68k, - 0, 0, - currentdsp->Display.width, - currentdsp->Display.height ); - TPRINT(("Exit flush_display_buffer\n")); + TPRINT(("Enter flush_display_buffer\n")); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, 0, 0, currentdsp->Display.width, + currentdsp->Display.height); + TPRINT(("Exit flush_display_buffer\n")); #endif /* DOS */ - } - +} /************************************************************************/ /* */ @@ -794,51 +704,43 @@ void flush_display_buffer() /* */ /************************************************************************/ #define BITEPER_DLBYTE 8 -#define DLBYTE_PERLINE (displaywidth/8) +#define DLBYTE_PERLINE (displaywidth / 8) -void flush_display_region(x, y, w, h) - int x, y, w, h; - { +void flush_display_region(x, y, w, h) int x, y, w, h; +{ #ifdef SUNDISPLAY #ifdef DISPLAYBUFFER - pr_rop(ColorDisplayPixrect, x, y, w, h, - COPY_PIXRECT_TO_COLOR, - DisplayRegionPixrect, x, y); + pr_rop(ColorDisplayPixrect, x, y, w, h, COPY_PIXRECT_TO_COLOR, DisplayRegionPixrect, x, y); #endif /* DISPLAYBUFFER */ #endif /* SUNDISPLAY */ - #if (defined(XWINDOW) || defined(DOS)) - TPRINT(("Enter flush_display_region x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); - (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); - TPRINT(("Exit flush_display_region\n")); + TPRINT(("Enter flush_display_region x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); + TPRINT(("Exit flush_display_region\n")); #endif /* DOS */ } #ifdef BYTESWAP -void byte_swapped_displayregion(x , y , w , h) - int x ,y,w,h; +void byte_swapped_displayregion(x, y, w, h) int x, y, w, h; { extern unsigned char reversedbits[]; - register unsigned int *longptr,*lineptr; - register int linecount,wordlimit; + register unsigned int *longptr, *lineptr; + register int linecount, wordlimit; - /* Get QUAD byte aligned pointer */ - longptr = (unsigned int *) - (((UNSIGNED)((DLword*)DisplayRegion68k + (DLWORD_PERLINE * y)) - + ((x +7)>>3)) & 0xfffffffc); + longptr = (unsigned int *)(((UNSIGNED)((DLword *)DisplayRegion68k + (DLWORD_PERLINE * y)) + + ((x + 7) >> 3)) & + 0xfffffffc); bit_reverse_region(longptr, w, h, DLWORD_PERLINE); return; - }/* byte_swapped_displayregion end */ +} /* byte_swapped_displayregion end */ #endif /* BYTESWAP */ - - /************************************************************************/ /* */ /* f l u s h _ d i s p l a y _ l i n e r e g i o n */ @@ -854,43 +756,36 @@ void byte_swapped_displayregion(x , y , w , h) /* */ /************************************************************************/ -void flush_display_lineregion(x, ybase, w, h) - UNSIGNED x, ybase, w, h; +void flush_display_lineregion(x, ybase, w, h) UNSIGNED x, ybase, w, h; #ifdef I386 - { /*flush_display_buffer(); */ - int y; - y = ((DLword *)ybase-DisplayRegion68k)/DLWORD_PERLINE; +{ /*flush_display_buffer(); */ + int y; + y = ((DLword *)ybase - DisplayRegion68k) / DLWORD_PERLINE; - bit_reverse_region(ybase, displaywidth, h,DLWORD_PERLINE); - pr_rop(ColorDisplayPixrect, x, y, displaywidth, h, - COPY_PIXRECT_TO_COLOR, - DisplayRegionPixrect, x, y); + bit_reverse_region(ybase, displaywidth, h, DLWORD_PERLINE); + pr_rop(ColorDisplayPixrect, x, y, displaywidth, h, COPY_PIXRECT_TO_COLOR, DisplayRegionPixrect, x, + y); - bit_reverse_region(ybase, displaywidth, h,DLWORD_PERLINE); - - } + bit_reverse_region(ybase, displaywidth, h, DLWORD_PERLINE); +} #else - { - int y; - y = ((DLword *)ybase-DisplayRegion68k)/DLWORD_PERLINE; +{ + int y; + y = ((DLword *)ybase - DisplayRegion68k) / DLWORD_PERLINE; #ifdef SUNDISPLAY #ifdef DISPLAYBUFFER - pr_rop(ColorDisplayPixrect, x, - y, w, h, - COPY_PIXRECT_TO_COLOR, - DisplayRegionPixrect, x, y); + pr_rop(ColorDisplayPixrect, x, y, w, h, COPY_PIXRECT_TO_COLOR, DisplayRegionPixrect, x, y); #endif /* DISPLAYBUFFER */ #endif /* SUNDISPLAY */ #if (defined(XWINDOW) || defined(DOS)) - TPRINT(("Enter flush_display_lineregion x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); - (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); - TPRINT(("Exit flush_display_lineregion\n")); + TPRINT(("Enter flush_display_lineregion x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); + (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); + TPRINT(("Exit flush_display_lineregion\n")); #endif /* DOS */ - - } +} #endif /* I386 */ /************************************************************************/ @@ -910,24 +805,22 @@ void flush_display_lineregion(x, ybase, w, h) #define BITSPERWORD 16 -void flush_display_ptrregion(ybase, bitoffset, w, h) - UNSIGNED bitoffset, ybase, w, h; +void flush_display_ptrregion(ybase, bitoffset, w, h) UNSIGNED bitoffset, ybase, w, h; #ifdef I386 - { flush_display_buffer(); } +{ flush_display_buffer(); } #else - { - int y, x, baseoffset, realw; - baseoffset = (((DLword *)ybase)-DisplayRegion68k); - y = baseoffset/DLWORD_PERLINE; - x = bitoffset + (BITSPERWORD*(baseoffset - (DLWORD_PERLINE * y))); +{ + int y, x, baseoffset, realw; + baseoffset = (((DLword *)ybase) - DisplayRegion68k); + y = baseoffset / DLWORD_PERLINE; + x = bitoffset + (BITSPERWORD * (baseoffset - (DLWORD_PERLINE * y))); #endif /* I386 */ #if (defined(SUNDISPLAY) && defined(DISPLAYBUFFER)) - pr_rop(ColorDisplayPixrect, x, y, w, h, COPY_PIXRECT_TO_COLOR, - DisplayRegionPixrect, x, y); +pr_rop(ColorDisplayPixrect, x, y, w, h, COPY_PIXRECT_TO_COLOR, DisplayRegionPixrect, x, y); #elif (defined(XWINDOW) || defined(DOS)) TPRINT(("Enter flush_display_ptrregion\n x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, x, y, w, h); TPRINT(("Exit flush_display_ptrregion\n")); #endif /* DOS */ - } +} diff --git a/src/initkbd.c b/src/initkbd.c old mode 100755 new mode 100644 index 1fcc7de..0482814 --- a/src/initkbd.c +++ b/src/initkbd.c @@ -1,8 +1,7 @@ -/* $Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ @@ -15,11 +14,8 @@ static char *id = "$Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - - #include #include #ifndef DOS @@ -31,9 +27,9 @@ static char *id = "$Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ Copyr #endif /* SUNDISPLAY */ #ifdef DOS -#include /* "#pragma interrupt" & '_chain_intr'*/ -#include /* defines REGS & other structs */ -#include /* define NULL */ +#include /* "#pragma interrupt" & '_chain_intr'*/ +#include /* defines REGS & other structs */ +#include /* define NULL */ #include #include #include @@ -51,40 +47,40 @@ static char *id = "$Id: initkbd.c,v 1.2 1999/01/03 02:07:09 sybalsky Exp $ Copyr #endif /* SUNDISPLAY */ #ifdef DOS -#define KBD_COMMAND_PORT 0x64 -#define KBD_ENABLE 0xAE -#define KBD_DISABLE 0xAD -#define KBD_RESET 0xF6 +#define KBD_COMMAND_PORT 0x64 +#define KBD_ENABLE 0xAE +#define KBD_DISABLE 0xAD +#define KBD_RESET 0xF6 -#define PORT_8042 0x60 -#define KBD_SCAN_CODE_PORT 0x60 +#define PORT_8042 0x60 +#define KBD_SCAN_CODE_PORT 0x60 -#define KBD_resend 0xFE -#define KBD_ack 0xFA -#define KBD_echo_responce 0xEE -#define KBD_failiure 0xFD -#define KBD_prefix 0xE0 -#define KBD_pause_prefix 0xE1 -#define KBD_overflow 0x00 +#define KBD_resend 0xFE +#define KBD_ack 0xFA +#define KBD_echo_responce 0xEE +#define KBD_failiure 0xFD +#define KBD_prefix 0xE0 +#define KBD_pause_prefix 0xE1 +#define KBD_overflow 0x00 -#define INTA00 0x20 /* The 8259 port */ -#define ENDOFINTERRUPT 0x20 +#define INTA00 0x20 /* The 8259 port */ +#define ENDOFINTERRUPT 0x20 -#define PRTSC_KEY 0x37 -#define HOME_KEY 0x47 -#define UPARROW_KEY 0x48 -#define PGUP_KEY 0x49 -#define LEFTARROW_KEY 0x4b -#define RIGHTARROW_KEY 0x4d -#define END_KEY 0x4f -#define DOWNARROW_KEY 0x50 -#define PGDOWN_KEY 0x51 -#define INS_KEY 0x52 -#define DEL_KEY 0x53 +#define PRTSC_KEY 0x37 +#define HOME_KEY 0x47 +#define UPARROW_KEY 0x48 +#define PGUP_KEY 0x49 +#define LEFTARROW_KEY 0x4b +#define RIGHTARROW_KEY 0x4d +#define END_KEY 0x4f +#define DOWNARROW_KEY 0x50 +#define PGDOWN_KEY 0x51 +#define INS_KEY 0x52 +#define DEL_KEY 0x53 -void (*prev_int_09)(); /* keeps address of previous 09 handlr*/ +void (*prev_int_09)(); /* keeps address of previous 09 handlr*/ #pragma interrupt(DOSkbd) -void DOSkbd(void); /* the flih-kbd handler INT 0x09 */ +void DOSkbd(void); /* the flih-kbd handler INT 0x09 */ unsigned char inchar = 0; extern int KBDEventFlg; @@ -99,12 +95,10 @@ extern int KBDEventFlg; #include "xdefs.h" #endif /* XWINDOW */ - #ifdef ISC #include #endif /* ISC */ - #include "lispemul.h" #include "lispmap.h" #include "lspglob.h" @@ -131,14 +125,13 @@ extern DspInterface currentdsp; extern struct screen LispScreen; #endif /* SUNDISPLAY */ - extern int LispWindowFd; int LispKbdFd; extern int errno; /* for debug */ -int DebugKBD = NIL; -FILE *KBlog; +int DebugKBD = NIL; +FILE *KBlog; u_int LispReadFds = 0; #ifdef SUNDISPLAY @@ -148,23 +141,22 @@ struct inputmask LispEventMask; struct inputmask LispEventMask; #endif /* XWINDOW */ +IOPAGE *IOPage68K; -IOPAGE *IOPage68K; - -DLword *EmMouseX68K; -DLword *EmMouseY68K; -DLword *EmCursorX68K; -DLword *EmCursorY68K; -DLword *EmRealUtilin68K; -DLword *EmUtilin68K; -DLword *EmKbdAd068K; -DLword *EmKbdAd168K; -DLword *EmKbdAd268K; -DLword *EmKbdAd368K; -DLword *EmKbdAd468K; -DLword *EmKbdAd568K; -DLword *EmDispInterrupt68K; -DLword *EmCursorBitMap68K; +DLword *EmMouseX68K; +DLword *EmMouseY68K; +DLword *EmCursorX68K; +DLword *EmCursorY68K; +DLword *EmRealUtilin68K; +DLword *EmUtilin68K; +DLword *EmKbdAd068K; +DLword *EmKbdAd168K; +DLword *EmKbdAd268K; +DLword *EmKbdAd368K; +DLword *EmKbdAd468K; +DLword *EmKbdAd568K; +DLword *EmDispInterrupt68K; +DLword *EmCursorBitMap68K; /*u_char SUNLispKeyMap[128];*/ u_char *SUNLispKeyMap; @@ -172,67 +164,67 @@ u_char *SUNLispKeyMap; /* keymap for type3 */ u_char SUNLispKeyMap_for3[128] = { -/* 0 */ -1, 61, -1, 91, -1, 97, 99, -1, -/* 8 */ 100, -1, 67, -1, 68, -1, 101, -1, -/* 16*/ 66, 104, 80, 47, -1, 73, 74, 75, -/* 24*/ -1, 92, 63, -1, -1, 33, 32, 17, -/* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, -/* 40*/ 10, 59, 45, 13, -1, 81, 82, 83, -/* 48*/ -1, 14, -1, 62, -1, 34, 19, 18, -/* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, -/* 64*/ 58, 29, 15, -1, 84, 85, 87, -1, -/* 72*/ 111, 89, -1, -1, 36, 21, 20, 5, -/* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, -/* 88*/ 105, 44, -1, 94, 69, 70, -1, 90, -/* 96*/ -1, 46, -1, 41, 40, 24, 37, 7, -/*104*/ 39, 54, 55, 27, 42, 12, 60, 71, -/*112*/ 98, 76, 72, -1, -1, -1, -1, 56, -/*120*/ 31, 57, 93, -1, -1, -1, -1, -1, - }; + /* 0 */ -1, 61, -1, 91, -1, 97, 99, -1, + /* 8 */ 100, -1, 67, -1, 68, -1, 101, -1, + /* 16*/ 66, 104, 80, 47, -1, 73, 74, 75, + /* 24*/ -1, 92, 63, -1, -1, 33, 32, 17, + /* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, + /* 40*/ 10, 59, 45, 13, -1, 81, 82, 83, + /* 48*/ -1, 14, -1, 62, -1, 34, 19, 18, + /* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, + /* 64*/ 58, 29, 15, -1, 84, 85, 87, -1, + /* 72*/ 111, 89, -1, -1, 36, 21, 20, 5, + /* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, + /* 88*/ 105, 44, -1, 94, 69, 70, -1, 90, + /* 96*/ -1, 46, -1, 41, 40, 24, 37, 7, + /*104*/ 39, 54, 55, 27, 42, 12, 60, 71, + /*112*/ 98, 76, 72, -1, -1, -1, -1, 56, + /*120*/ 31, 57, 93, -1, -1, -1, -1, -1, +}; /* for type4 */ u_char SUNLispKeyMap_for4[128] = { -/* 0 */ -1, 61, -1, 91, -1, 97, 99, 106, -/* 8 */ 100, 107, 67, 108, 68, 47, 101, 30, -/* 16*/ 66, 104, 80, 31, -1, 75, 110, 74, -/* 24*/ -1, 109, 63, -1, -1, 33, 32, 17, -/* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, -/* 40*/ 10, 59, 45, 15, -1, 64, 65, 95, -/* 48*/ -1, 14, 13, 89, -1, 34, 19, 18, -/* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, -/* 64*/ 58, 29, 13, 93, 81, 82, 83, 96, -/* 72*/ 111, 62, -1, -1, 36, 21, 20, 5, -/* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, -/* 88*/ 105, 44, 76, 84, 85, 87, 98, 90, -/* 96*/ -1, 46, 73, 41, 40, 24, 37, 7, -/*104*/ 39, 54, 55, 27, 42, 12, 60, 71, -/*112*/ 94, 69, 70, -1, -1, -1, 92, 56, -/*120*/ 86, 57, 88, -1, 103, 102, -1, -1, - }; + /* 0 */ -1, 61, -1, 91, -1, 97, 99, 106, + /* 8 */ 100, 107, 67, 108, 68, 47, 101, 30, + /* 16*/ 66, 104, 80, 31, -1, 75, 110, 74, + /* 24*/ -1, 109, 63, -1, -1, 33, 32, 17, + /* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, + /* 40*/ 10, 59, 45, 15, -1, 64, 65, 95, + /* 48*/ -1, 14, 13, 89, -1, 34, 19, 18, + /* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, + /* 64*/ 58, 29, 13, 93, 81, 82, 83, 96, + /* 72*/ 111, 62, -1, -1, 36, 21, 20, 5, + /* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, + /* 88*/ 105, 44, 76, 84, 85, 87, 98, 90, + /* 96*/ -1, 46, 73, 41, 40, 24, 37, 7, + /*104*/ 39, 54, 55, 27, 42, 12, 60, 71, + /*112*/ 94, 69, 70, -1, -1, -1, 92, 56, + /*120*/ 86, 57, 88, -1, 103, 102, -1, -1, +}; /* for jle */ u_char SUNLispKeyMap_jle[128] = { -/* 0 */ -1, 61, -1, 91, -1, 97, 99, 106, -/* 8 */ 100, 107, 67, 108, 68, 47, 101, 71, -/* 16*/ 66, 104, 80, 31, -1, 75, 110, 74, -/* 24*/ -1, 109, 63, -1, -1, 33, 32, 17, -/* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, -/* 40*/ 59, 45, 30, 15, -1, 64, 65, 95, -/* 48*/ -1, 14, 13, 89, -1, 34, 19, 18, -/* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, -/* 64*/ 58, 29, 13, 93, 81, 82, 83, 96, -/* 72*/ 111, 62, -1, -1, 36, 21, 20, 5, -/* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, -/* 88*/ 105, 44, 76, 84, 85, 87, 98, 90, -/* 96*/ -1, 46, 73, 41, 40, 24, 37, 7, -/*104*/ 39, 54, 55, 27, 42, 12, 60, 10, -/*112*/ 94, 69, 70, 72, 103, 109, 92, 56, -/*120*/ 86, 57, 88, -1, -1, 102, -1, -1, - }; + /* 0 */ -1, 61, -1, 91, -1, 97, 99, 106, + /* 8 */ 100, 107, 67, 108, 68, 47, 101, 71, + /* 16*/ 66, 104, 80, 31, -1, 75, 110, 74, + /* 24*/ -1, 109, 63, -1, -1, 33, 32, 17, + /* 32*/ 16, 1, 0, 2, 4, 53, 22, 8, + /* 40*/ 59, 45, 30, 15, -1, 64, 65, 95, + /* 48*/ -1, 14, 13, 89, -1, 34, 19, 18, + /* 56*/ 3, 48, 49, 51, 6, 23, 25, 11, + /* 64*/ 58, 29, 13, 93, 81, 82, 83, 96, + /* 72*/ 111, 62, -1, -1, 36, 21, 20, 5, + /* 80*/ 35, 50, 52, 38, 9, 26, 43, 28, + /* 88*/ 105, 44, 76, 84, 85, 87, 98, 90, + /* 96*/ -1, 46, 73, 41, 40, 24, 37, 7, + /*104*/ 39, 54, 55, 27, 42, 12, 60, 10, + /*112*/ 94, 69, 70, 72, 103, 109, 92, 56, + /*120*/ 86, 57, 88, -1, -1, 102, -1, -1, +}; /* [40] 10->59 */ /* [41] 59->45 */ /* [42] 45->30 */ @@ -241,288 +233,301 @@ u_char SUNLispKeyMap_jle[128] = { /* [116] -1 -> 103 Henkan */ /* [117] -1 -> 109 Nihongo On-Off */ - - /* For IBM Risc System 6000 */ u_char SUNLispKeyMap_RS6000[128] = { -/* 7 */ -1, -1, 45, 32, 17, 16, 1, 0, -/* 15*/ 2, 4, 53, 22, 8, 10, 59, -1, -/* 23*/ 15, 34, 19, 18, 3, 48, 49, 51, -/* 31*/ 6, 23, 25, 11, 58, 29, 105, 56, -/* 39*/ 21, 20, 5, 35, 50, 52, 38, 9, -/* 47*/ 26, 43, 28, -1, 44, 41, -1, 40, -/* 55*/ 24, 37, 7, 39, 54, 55, 27, 42, -/* 63*/ 12, -1, 60, 36, -1, 31, 57, 93, -/* 71*/ -1, 47, -1, -1, -1, -1, -1, -1, -/* 79*/ -1, -1, -1, -1, 89, 46, -1, -1, -/* 87*/ 129, 62, 90, -1, 130, 131, 63, 91, -/* 95*/ -1, -1, 132, 73, 81, 84, 94, -1, -/*103*/ 65, 82, 85, 69, 98, 95, 83, 87, -/*111*/ 70, 13, 96, 102, -1, 128, -1, 33, -/*119*/ -1, 97, 99, 100, 67, 68, 101, 66, -/*127*/ 104, 80, 106, 107, 92, 76, 14, 61, -/*136*/ - }; - - + /* 7 */ -1, -1, 45, 32, 17, 16, 1, 0, + /* 15*/ 2, 4, 53, 22, 8, 10, 59, -1, + /* 23*/ 15, 34, 19, 18, 3, 48, 49, 51, + /* 31*/ 6, 23, 25, 11, 58, 29, 105, 56, + /* 39*/ 21, 20, 5, 35, 50, 52, 38, 9, + /* 47*/ 26, 43, 28, -1, 44, 41, -1, 40, + /* 55*/ 24, 37, 7, 39, 54, 55, 27, 42, + /* 63*/ 12, -1, 60, 36, -1, 31, 57, 93, + /* 71*/ -1, 47, -1, -1, -1, -1, -1, -1, + /* 79*/ -1, -1, -1, -1, 89, 46, -1, -1, + /* 87*/ 129, 62, 90, -1, 130, 131, 63, 91, + /* 95*/ -1, -1, 132, 73, 81, 84, 94, -1, + /*103*/ 65, 82, 85, 69, 98, 95, 83, 87, + /*111*/ 70, 13, 96, 102, -1, 128, -1, 33, + /*119*/ -1, 97, 99, 100, 67, 68, 101, 66, + /*127*/ 104, 80, 106, 107, 92, 76, 14, 61, + /*136*/ +}; /* For DECStation 3100 */ u_char SUNLispKeyMap_DEC3100[256] = { -/* 7*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 15*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 23*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 31*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 39*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 47*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 55*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 63*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 71*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 79*/ -1, -1, -1, -1, -1, -1, -1, 97, -/* 87*/ 99, 100, 67, 68, -1, -1, -1, -1, -/* 95*/ -1, -1, -1, -1, -1, 101, 66, 104, -/*103*/ 80, 106, -1, -1, -1, -1, -1, -1, -/*111*/ -1, -1, 107, 108, -1, -1, -1, -1, -/*119*/ -1, -1, -1, -1, -1, 92, 76, -1, -/*127*/ -1, -1, -1, -1, -1, -1, -1, -1, -/*135*/ -1, -1, -1, 90, 91, 46, 93, 89, -/*143*/ 47, -1, -1, 98, -1, 13, 76, 94, -/*151*/ 69, 70, 84, 85, 87, 102, 81, 82, -/*159*/ 83, -1, -1, -1, -1, -1, -1, -1, -/*167*/ 129, 132, 131, 130, -1, -1, -1, 41, -/*175*/ 36, 56, 31, -1, -1, -1, -1, -1, -/*183*/ -1, -1, -1, -1, -1, 15, 44, 34, -/*191*/ 33, 32, 19, 21, 40, -1, 17, 18, -/*199*/ 20, 24, 45, -1, 16, 3, 5, 37, -/*207*/ -1, 1, 48, 35, 7, 57, -1, 0, -/*215*/ 49, 50, 39, -1, 2, 51, 52, 54, -/*223*/ -1, 4, 6, 38, 55, -1, 53, 23, -/*231*/ 9, 27, -1, 22, 25, 26, 42, -1, -/*239*/ 8, 11, -1, 43, 12, -1, 59, 29, -/*247*/ 105, -1, 10, 58, 28, -1, -1, -1 + /* 7*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 15*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 23*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 31*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 39*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 47*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 55*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 63*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 71*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /* 79*/ -1, -1, -1, -1, -1, + -1, -1, 97, + /* 87*/ 99, 100, 67, 68, -1, + -1, -1, -1, + /* 95*/ -1, -1, -1, -1, -1, + 101, 66, 104, + /*103*/ 80, 106, -1, -1, -1, + -1, -1, -1, + /*111*/ -1, -1, 107, 108, -1, + -1, -1, -1, + /*119*/ -1, -1, -1, -1, -1, + 92, 76, -1, + /*127*/ -1, -1, -1, -1, -1, + -1, -1, -1, + /*135*/ -1, -1, -1, 90, 91, + 46, 93, 89, + /*143*/ 47, -1, -1, 98, -1, + 13, 76, 94, + /*151*/ 69, 70, 84, 85, 87, + 102, 81, 82, + /*159*/ 83, -1, -1, -1, -1, + -1, -1, -1, + /*167*/ 129, 132, 131, 130, -1, + -1, -1, 41, + /*175*/ 36, 56, 31, -1, -1, + -1, -1, -1, + /*183*/ -1, -1, -1, -1, -1, + 15, 44, 34, + /*191*/ 33, 32, 19, 21, 40, + -1, 17, 18, + /*199*/ 20, 24, 45, -1, 16, + 3, 5, 37, + /*207*/ -1, 1, 48, 35, 7, + 57, -1, 0, + /*215*/ 49, 50, 39, -1, 2, + 51, 52, 54, + /*223*/ -1, 4, 6, 38, 55, + -1, 53, 23, + /*231*/ 9, 27, -1, 22, 25, + 26, 42, -1, + /*239*/ 8, 11, -1, 43, 12, + -1, 59, 29, + /*247*/ 105, -1, 10, 58, 28, + -1, -1, -1 - }; - - -u_char SUNLispKeyMap_HP9000[135] = - { -/* 7*/ -1, -1, -1, 93, 31, 60, 41, 36, -/* 15*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 23*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 31*/ -1, 39, 7, 37, 24, 40, -1, -1, -/* 39*/ -1, -1, -1, -1, -1, -1, -1, -1, -/* 47*/ -1, 52, 50, 35, 5, 20, 21, -1, -/* 55*/ 56, 6, 51, 49, 48, 3, 18, 19, -/* 63*/ 34, 4, 2, 0, 1, 16, 17, 32, -/* 71*/ 45, -1, -1, -1, -1, -1, -1, -1, -/* 79*/ -1, 68, 67,100, 99, 97, -1, -1, -/* 87*/ -1, 68,101, 66,104, 80, 13, -1, -/* 95*/ -1, 53, 22, 8, 10, 59, 15, -1, -/* 103*/ -1, 23, 25, 11, 58, 29,105, -1, -/* 111*/ -1, 38, 9, 26, 43, 28, 44, -1, -/* 119*/ -1, 55, 27, 42, 12, -1, -1, -1, -/* 127*/ 47, 54, 57, -1, -1, -1, -1, -1 }; -u_char *XGenericKeyMap; /* filled in with malloc if needed */ +u_char SUNLispKeyMap_HP9000[135] = { + /* 7*/ -1, -1, -1, 93, 31, 60, 41, 36, + /* 15*/ -1, -1, -1, -1, -1, -1, -1, -1, + /* 23*/ -1, -1, -1, -1, -1, -1, -1, -1, + /* 31*/ -1, 39, 7, 37, 24, 40, -1, -1, + /* 39*/ -1, -1, -1, -1, -1, -1, -1, -1, + /* 47*/ -1, 52, 50, 35, 5, 20, 21, -1, + /* 55*/ 56, 6, 51, 49, 48, 3, 18, 19, + /* 63*/ 34, 4, 2, 0, 1, 16, 17, 32, + /* 71*/ 45, -1, -1, -1, -1, -1, -1, -1, + /* 79*/ -1, 68, 67, 100, 99, 97, -1, -1, + /* 87*/ -1, 68, 101, 66, 104, 80, 13, -1, + /* 95*/ -1, 53, 22, 8, 10, 59, 15, -1, + /* 103*/ -1, 23, 25, 11, 58, 29, 105, -1, + /* 111*/ -1, 38, 9, 26, 43, 28, 44, -1, + /* 119*/ -1, 55, 27, 42, 12, -1, -1, -1, + /* 127*/ 47, 54, 57, -1, -1, -1, -1, -1}; +u_char *XGenericKeyMap; /* filled in with malloc if needed */ /* For the IBM-101 kbd FF marks exceptions */ #ifdef NEVER -u_char DOSLispKeyMap_101[0x80] = -{ -/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ +u_char DOSLispKeyMap_101[0x80] = { + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ -/* 0*/ 0xff, 33, 32, 17, 16, 1, 0, 2, 4, 53, 22, 8, 10, 59, 15, 34, -/* 1*/ 19, 18, 3, 48, 49, 51, 6, 23, 25, 11, 58, 29, 44, 36, 21, 20, -/* 2*/ 5, 35, 50, 52, 38, 9, 26, 43, 28, 45, 41, 105, 40, 24, 37, 7, -/* 3*/ 39, 54, 55, 27, 42, 12, 60, 95, 31, 57, 56, 97, 99, 100, 67, 68, -/* 4*/ 101, 66, 104, 80, 106, 73, 74, 81, 82, 83, 96, 84, 85, 87, 102, 94, -/* 5*/ 69, 70, 98, 13,0xff,0xff,0xff, 107, 108,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -/* 6*/ 89, 62, 63, 46, 90, 91, 130, 129, 131, 132, 92, 61,0xff,0xff,0xff,0xff, -/* 7*/ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff -}; + /* 0*/ 0xff, 33, 32, 17, 16, 1, 0, 2, + 4, 53, 22, 8, 10, 59, 15, 34, + /* 1*/ 19, 18, 3, 48, 49, 51, 6, 23, + 25, 11, 58, 29, 44, 36, 21, 20, + /* 2*/ 5, 35, 50, 52, 38, 9, 26, 43, + 28, 45, 41, 105, 40, 24, 37, 7, + /* 3*/ 39, 54, 55, 27, 42, 12, 60, 95, + 31, 57, 56, 97, 99, 100, 67, 68, + /* 4*/ 101, 66, 104, 80, 106, 73, 74, 81, + 82, 83, 96, 84, 85, 87, 102, 94, + /* 5*/ 69, 70, 98, 13, 0xff, 0xff, 0xff, 107, + 108, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + /* 6*/ 89, 62, 63, 46, 90, 91, 130, 129, + 131, 132, 92, 61, 0xff, 0xff, 0xff, 0xff, + /* 7*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; #endif /* NEVER */ /* For the IBM-101 kbd FF marks exceptions */ -u_char DOSLispKeyMap_101[0x80] = -{ -/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ +u_char DOSLispKeyMap_101[0x80] = { + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ -/* 0*/ 0xff, 33, 32, 17, 16, 1, 0, 2, 4, 53, 22, 8, 10, 59, 15, 34, -/* 1*/ 19, 18, 3, 48, 49, 51, 6, 23, 25, 11, 58, 29, 44, 36, 21, 20, -/* 2*/ 5, 35, 50, 52, 38, 9, 26, 43, 28, 45, 41, 105, 40, 24, 37, 7, -/* 3*/ 39, 54, 55, 27, 42, 12, 60, 95, 31, 57, 56, 97, 99, 100, 67, 68, -/* 4*/ 101, 66, 104, 80, 106, 73, 74, 62, 130, 63, 96, 129, 85, 132, 102, 90, -/* 5*/ 131, 91, 89, 46,0xff,0xff,0xff, 107, 108,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -/* 6*/ 89, 62, 63, 46, 90, 91, 130, 129, 131, 132, 92, 61,0xff,0xff,0xff,0xff, -/* 7*/ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff -}; + /* 0*/ 0xff, 33, 32, 17, 16, 1, 0, 2, + 4, 53, 22, 8, 10, 59, 15, 34, + /* 1*/ 19, 18, 3, 48, 49, 51, 6, 23, + 25, 11, 58, 29, 44, 36, 21, 20, + /* 2*/ 5, 35, 50, 52, 38, 9, 26, 43, + 28, 45, 41, 105, 40, 24, 37, 7, + /* 3*/ 39, 54, 55, 27, 42, 12, 60, 95, + 31, 57, 56, 97, 99, 100, 67, 68, + /* 4*/ 101, 66, 104, 80, 106, 73, 74, 62, + 130, 63, 96, 129, 85, 132, 102, 90, + /* 5*/ 131, 91, 89, 46, 0xff, 0xff, 0xff, 107, + 108, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + /* 6*/ 89, 62, 63, 46, 90, 91, 130, 129, + 131, 132, 92, 61, 0xff, 0xff, 0xff, 0xff, + /* 7*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; void set_kbd_iopointers(); void keyboardtype(int fd); -void init_keyboard(flg) - int flg ; /* if 0 init else re-init */ - { - int keytrans; +void init_keyboard(flg) int flg; /* if 0 init else re-init */ +{ + int keytrans; - set_kbd_iopointers(); + set_kbd_iopointers(); #ifdef SUNDISPLAY - if( (LispKbdFd = open( LispScreen.scr_kbdname , O_RDWR)) == -1) - { - fprintf( stderr, "can't open %s\n", LispScreen.scr_kbdname); - exit( -1 ); - } + if ((LispKbdFd = open(LispScreen.scr_kbdname, O_RDWR)) == -1) { + fprintf(stderr, "can't open %s\n", LispScreen.scr_kbdname); + exit(-1); + } #endif /* SUNDISPLAY */ - if(flg==0) - { - keyboardtype(LispKbdFd); - } + if (flg == 0) { keyboardtype(LispKbdFd); } #ifdef SUNDISPLAY - keytrans = TR_UNTRANS_EVENT; /* keyboard does not encode key */ - if(ioctl( LispKbdFd, KIOCTRANS, &keytrans)== -1) - { - fprintf( stderr, "Error at ioctl errnoo =%d\n", errno); - exit( -1 ); - } - close( LispKbdFd ); + keytrans = TR_UNTRANS_EVENT; /* keyboard does not encode key */ + if (ioctl(LispKbdFd, KIOCTRANS, &keytrans) == -1) { + fprintf(stderr, "Error at ioctl errnoo =%d\n", errno); + exit(-1); + } + close(LispKbdFd); #ifdef KBINT - int_io_open(LispWindowFd); /* from init_dsp, try to prevent mouse-move-no-kbd bug */ -#endif /* KBINT */ - seteventmask( &LispEventMask ); + int_io_open(LispWindowFd); /* from init_dsp, try to prevent mouse-move-no-kbd bug */ +#endif /* KBINT */ + seteventmask(&LispEventMask); #elif xXWINDOW - init_Xevent(); + init_Xevent(); - seteventmask( &LispEventMask ); + seteventmask(&LispEventMask); #elif XWINDOW - init_Xevent(currentdsp); + init_Xevent(currentdsp); #elif DOS - if (flg == 0) - { /* Install the handlers ONLY when we */ - /* init the kbd the init the kbd the */ - /* first time. */ + if (flg == 0) { /* Install the handlers ONLY when we */ + /* init the kbd the init the kbd the */ + /* first time. */ - /* turn on kbd */ - make_kbd_instance(currentkbd); - (currentkbd->device.enter)(currentkbd); + /* turn on kbd */ + make_kbd_instance(currentkbd); + (currentkbd->device.enter)(currentkbd); - /* turn on mouse */ - make_mouse_instance(currentmouse); - (currentmouse->device.enter)(currentmouse, currentdsp); - } - /* outp( KBD_COMMAND_PORT, KBD_RESET); Reset the kbd */ -#endif /* XWINDOW DOS */ + /* turn on mouse */ + make_mouse_instance(currentmouse); + (currentmouse->device.enter)(currentmouse, currentdsp); + } +/* outp( KBD_COMMAND_PORT, KBD_RESET); Reset the kbd */ +#endif /* XWINDOW DOS */ +} + +/* ----------------------------------------------------------------*/ + +void device_before_exit() { +#ifdef SUNDISPLAY + int keytrans; + + if ((LispKbdFd = open(LispScreen.scr_kbdname, O_RDWR)) == -1) { + fprintf(stderr, "can't open %s\n", LispScreen.scr_kbdname); + exit(-1); } - - - -/* ----------------------------------------------------------------*/ - -void device_before_exit() -{ -#ifdef SUNDISPLAY - int keytrans; - - if( (LispKbdFd = open( LispScreen.scr_kbdname , O_RDWR)) == -1){ - fprintf( stderr, "can't open %s\n", LispScreen.scr_kbdname); - exit( -1 ); - } - - keytrans = TR_EVENT; /* keyboard encodes key */ - if(ioctl( LispKbdFd, KIOCTRANS, &keytrans)== -1){ - fprintf( stderr, "Error at ioctl errnoo =%d\n", errno); - exit( -1 ); - } - close( LispKbdFd ); + keytrans = TR_EVENT; /* keyboard encodes key */ + if (ioctl(LispKbdFd, KIOCTRANS, &keytrans) == -1) { + fprintf(stderr, "Error at ioctl errnoo =%d\n", errno); + exit(-1); + } + close(LispKbdFd); #elif DOS - (currentmouse->device.exit)(currentmouse, currentdsp); - (currentkbd->device.exit)(currentkbd); -#endif /* SUNDISPLAY DOS*/ - display_before_exit(); + (currentmouse->device.exit)(currentmouse, currentdsp); + (currentkbd->device.exit)(currentkbd); +#endif /* SUNDISPLAY DOS*/ + display_before_exit(); } - - - /* ----------------------------------------------------------------*/ -void set_kbd_iopointers() -{ - IOPage68K = (IOPAGE *)IOPage; - EmMouseX68K = (DLword *) &(IOPage68K->dlmousex); - EmMouseY68K = (DLword *) &(IOPage68K->dlmousey); - EmCursorX68K = (DLword *) &(IOPage68K->dlcursorx); - EmCursorY68K = (DLword *) &(IOPage68K->dlcursory); - EmRealUtilin68K = (DLword *) &(IOPage68K->dlutilin); - /* EmUtilin68K is for KEYDOWNP1 macro or etc. */ - EmUtilin68K = (DLword *) &(InterfacePage->fakemousebits); - EmKbdAd068K = (DLword *) &(IOPage68K->dlkbdad0); - EmKbdAd168K = (DLword *) &(IOPage68K->dlkbdad1); - EmKbdAd268K = (DLword *) &(IOPage68K->dlkbdad2); - EmKbdAd368K = (DLword *) &(IOPage68K->dlkbdad3); - EmKbdAd468K = (DLword *) &(IOPage68K->dlkbdad4); - EmKbdAd568K = (DLword *) &(IOPage68K->dlkbdad5); - EmDispInterrupt68K = (DLword *) &(IOPage68K->dldispinterrupt); - EmCursorBitMap68K = (DLword *) (IOPage68K->dlcursorbitmap); - - *EmRealUtilin68K = KB_ALLUP; - *EmKbdAd068K = KB_ALLUP; - *EmKbdAd168K = KB_ALLUP; - *EmKbdAd268K = KB_ALLUP; - *EmKbdAd368K = KB_ALLUP; - *EmKbdAd468K = KB_ALLUP; - *EmKbdAd568K = KB_ALLUP; +void set_kbd_iopointers() { + IOPage68K = (IOPAGE *)IOPage; + EmMouseX68K = (DLword *)&(IOPage68K->dlmousex); + EmMouseY68K = (DLword *)&(IOPage68K->dlmousey); + EmCursorX68K = (DLword *)&(IOPage68K->dlcursorx); + EmCursorY68K = (DLword *)&(IOPage68K->dlcursory); + EmRealUtilin68K = (DLword *)&(IOPage68K->dlutilin); + /* EmUtilin68K is for KEYDOWNP1 macro or etc. */ + EmUtilin68K = (DLword *)&(InterfacePage->fakemousebits); + EmKbdAd068K = (DLword *)&(IOPage68K->dlkbdad0); + EmKbdAd168K = (DLword *)&(IOPage68K->dlkbdad1); + EmKbdAd268K = (DLword *)&(IOPage68K->dlkbdad2); + EmKbdAd368K = (DLword *)&(IOPage68K->dlkbdad3); + EmKbdAd468K = (DLword *)&(IOPage68K->dlkbdad4); + EmKbdAd568K = (DLword *)&(IOPage68K->dlkbdad5); + EmDispInterrupt68K = (DLword *)&(IOPage68K->dldispinterrupt); + EmCursorBitMap68K = (DLword *)(IOPage68K->dlcursorbitmap); + *EmRealUtilin68K = KB_ALLUP; + *EmKbdAd068K = KB_ALLUP; + *EmKbdAd168K = KB_ALLUP; + *EmKbdAd268K = KB_ALLUP; + *EmKbdAd368K = KB_ALLUP; + *EmKbdAd468K = KB_ALLUP; + *EmKbdAd568K = KB_ALLUP; } - - - /* ----------------------------------------------------------------*/ #ifdef SUNDISPLAY -void seteventmask( eventmask ) -struct inputmask *eventmask; +void seteventmask(eventmask) struct inputmask *eventmask; { - input_imnull( eventmask ); - eventmask->im_flags |= IM_ASCII | IM_NEGASCII | IM_NEGEVENT; + input_imnull(eventmask); + eventmask->im_flags |= IM_ASCII | IM_NEGASCII | IM_NEGEVENT; - win_setinputcodebit ( eventmask, MS_LEFT ); - win_setinputcodebit ( eventmask, MS_MIDDLE ); - win_setinputcodebit ( eventmask, MS_RIGHT ); - win_setinputcodebit ( eventmask, LOC_MOVE ); - win_unsetinputcodebit( eventmask, LOC_STILL ); - win_unsetinputcodebit( eventmask, LOC_MOVEWHILEBUTDOWN ); - win_unsetinputcodebit( eventmask, LOC_WINENTER ); - win_unsetinputcodebit( eventmask, LOC_WINEXIT ); + win_setinputcodebit(eventmask, MS_LEFT); + win_setinputcodebit(eventmask, MS_MIDDLE); + win_setinputcodebit(eventmask, MS_RIGHT); + win_setinputcodebit(eventmask, LOC_MOVE); + win_unsetinputcodebit(eventmask, LOC_STILL); + win_unsetinputcodebit(eventmask, LOC_MOVEWHILEBUTDOWN); + win_unsetinputcodebit(eventmask, LOC_WINENTER); + win_unsetinputcodebit(eventmask, LOC_WINEXIT); - win_setinputmask( LispWindowFd, eventmask, eventmask, WIN_NULLLINK); + win_setinputmask(LispWindowFd, eventmask, eventmask, WIN_NULLLINK); } #endif /* SUNDISPLAY */ - - -char* getenv(); /* ---- external entry points --------*/ +char *getenv(); /* ---- external entry points --------*/ #define MIN_KEYTYPE 3 #define KB_AS3000J (7 + MIN_KEYTYPE) -#define KB_RS6000 (8 + MIN_KEYTYPE) +#define KB_RS6000 (8 + MIN_KEYTYPE) #define KB_DEC3100 (9 + MIN_KEYTYPE) -#define KB_HP9000 (10+ MIN_KEYTYPE) -#define KB_X (11+ MIN_KEYTYPE) -#define KB_DOS (12+MIN_KEYTYPE) +#define KB_HP9000 (10 + MIN_KEYTYPE) +#define KB_X (11 + MIN_KEYTYPE) +#define KB_DOS (12 + MIN_KEYTYPE) /* KB_SUN4 not defined in older OS versions */ #ifndef KB_SUN4 @@ -530,17 +535,14 @@ char* getenv(); /* ---- external entry points --------*/ #endif #ifndef KB_SUN2 - /* These KB types nog defined outside Sun world,so define them here */ +/* These KB types nog defined outside Sun world,so define them here */ #define KB_SUN2 2 #define KB_SUN3 3 #endif /* KB_SUN2 */ - /* For the JLE keyboard */ #define KB_JLE 5 - - /************************************************************************/ /* */ /* m a k e _ X _ k e y m a p */ @@ -553,104 +555,88 @@ char* getenv(); /* ---- external entry points --------*/ /************************************************************************/ #ifdef XWINDOW -u_char * make_X_keymap() - { - u_char *table = (u_char *)malloc(256); /* the final result table */ - int lisp_codes_used[256]; /* Keep track of the Lisk key #s we've used */ - int last_KEYSYM = -1; - int sym_used = 0; - int *key_sym_pairs = generic_X_keymap; - int i = 0; - KeySym * mapping; - KeyCode first; - int codecount, symspercode, minkey, maxkey; +u_char *make_X_keymap() { + u_char *table = (u_char *)malloc(256); /* the final result table */ + int lisp_codes_used[256]; /* Keep track of the Lisk key #s we've used */ + int last_KEYSYM = -1; + int sym_used = 0; + int *key_sym_pairs = generic_X_keymap; + int i = 0; + KeySym *mapping; + KeyCode first; + int codecount, symspercode, minkey, maxkey; - for (; i<256; i++) - { /* clear the tables we just allocated */ - lisp_codes_used[i] = 0; - table[i]=255; /* The "no key assigned" code */ - } -XLOCK; + for (; i < 256; i++) { /* clear the tables we just allocated */ + lisp_codes_used[i] = 0; + table[i] = 255; /* The "no key assigned" code */ + } + XLOCK; #ifdef WHAT_THE_DICKENS_HAPPENED_HERE - XDisplayKeycodes(ConnectionNumber(currentdsp->display_id), &minkey, &maxkey); + XDisplayKeycodes(ConnectionNumber(currentdsp->display_id), &minkey, &maxkey); #else /* WHAT_THE_DICKENS_HAPPENED_HERE */ - XDisplayKeycodes(currentdsp->display_id, &minkey, &maxkey); + XDisplayKeycodes(currentdsp->display_id, &minkey, &maxkey); #endif /* WHAT_THE_DICKENS_HAPPENED_HERE */ - codecount = maxkey + 1 - minkey; + codecount = maxkey + 1 - minkey; #ifdef WHAT_THE_DICKENS_HAPPENED_HERE - mapping = XGetKeyboardMapping(ConnectionNumber(currentdsp->display_id), minkey, codecount, &symspercode); -#else /* WHAT_THE_DICKENS_HAPPENED_HERE */ - mapping = XGetKeyboardMapping(currentdsp->display_id, minkey, codecount, &symspercode); + mapping = XGetKeyboardMapping(ConnectionNumber(currentdsp->display_id), minkey, codecount, + &symspercode); +#else /* WHAT_THE_DICKENS_HAPPENED_HERE */ + mapping = XGetKeyboardMapping(currentdsp->display_id, minkey, codecount, &symspercode); #endif /* WHAT_THE_DICKENS_HAPPENED_HERE */ -XUNLOCK; + XUNLOCK; - for (; *key_sym_pairs != -1; ) - { - int reusable = *key_sym_pairs++, - code = *key_sym_pairs++, - sym = *key_sym_pairs++, - xcode; + for (; *key_sym_pairs != -1;) { + int reusable = *key_sym_pairs++, code = *key_sym_pairs++, sym = *key_sym_pairs++, xcode; - if (sym_used && (sym == last_KEYSYM)) continue; + if (sym_used && (sym == last_KEYSYM)) continue; - sym_used = 0; - last_KEYSYM = sym; + sym_used = 0; + last_KEYSYM = sym; + xcode = find_unused_key(mapping, minkey, codecount, symspercode, sym, table); - xcode = find_unused_key(mapping, minkey, codecount, - symspercode, sym, table); + if (xcode == 0) continue; + if ((!reusable) && (lisp_codes_used[code] != 0)) continue; - if (xcode==0) continue; - if ((!reusable) && (lisp_codes_used[code] != 0)) continue; - - sym_used = 1; - last_KEYSYM = sym; - lisp_codes_used[code] = 1; - table[xcode-7] = code; - - - } + sym_used = 1; + last_KEYSYM = sym; + lisp_codes_used[code] = 1; + table[xcode - 7] = code; + } #ifdef DEBUG - for (i=0; i < 256; i += 8) - { - printf("\n\n\tKeyboard mapping table\n\n"); - printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", - table[i], table[i+1], table[i+2], table[i+3], - table[i+4], table[i+5], table[i+6], table[i+7]); - } + for (i = 0; i < 256; i += 8) { + printf("\n\n\tKeyboard mapping table\n\n"); + printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", table[i], table[i + 1], table[i + 2], table[i + 3], + table[i + 4], table[i + 5], table[i + 6], table[i + 7]); + } #endif /* DEBUG */ + return (table); +} - return(table); - } - -int find_unused_key(map, minkey, len, syms, sym, table) - KeySym *map; - int minkey, len, syms, sym; - u_char *table; - { - int i; - - for (i=0; i<(len*syms); i++) - { - if (sym == map[i]) - { - int code = minkey + (i/syms); - if (table[code-7] != 255) continue; - return(code); - } - } - return(0); +int find_unused_key(map, minkey, len, syms, sym, table) KeySym *map; +int minkey, len, syms, sym; +u_char *table; +{ + int i; + + for (i = 0; i < (len * syms); i++) { + if (sym == map[i]) { + int code = minkey + (i / syms); + if (table[code - 7] != 255) continue; + return (code); + } } + return (0); +} #endif /* XWINDOW */ - /************************************************************************/ /* */ /* k e y b o a r d t y p e */ @@ -673,53 +659,53 @@ int find_unused_key(map, minkey, len, syms, sym, table) /* */ /************************************************************************/ -void keyboardtype(fd) - int fd; - { - int type; - int i; - char *key; +void keyboardtype(fd) int fd; +{ + int type; + int i; + char *key; - for(i=0;i<5000;i++){/* IDLE LOOP */} /* because of a SunOS bug */ + for (i = 0; i < 5000; i++) { /* IDLE LOOP */ + } /* because of a SunOS bug */ - /* clear the keyboard field in devconfig */ - InterfacePage->devconfig &= 0xfff8; + /* clear the keyboard field in devconfig */ + InterfacePage->devconfig &= 0xfff8; - /************************************************************ - Due to the problems of SunOS 4.0 & 4.0.1 - calling ioctl never return the correct keyboard type. - So,these 2 lines are commented out ...(Take)->AR11100 - *************************************************************/ + /************************************************************ + Due to the problems of SunOS 4.0 & 4.0.1 + calling ioctl never return the correct keyboard type. + So,these 2 lines are commented out ...(Take)->AR11100 + *************************************************************/ - /* Get keytype from LDEKBDTYPE */ - if ((key = getenv("LDEKBDTYPE")) == 0) { + /* Get keytype from LDEKBDTYPE */ + if ((key = getenv("LDEKBDTYPE")) == 0) { #ifdef FUJI - /* obnoxious behavior */ - mess_reset(); - printf("!!CAUTION: LDEKBDTYPE is not set.\n"); - printf("Please retry after setting LDEKBDTYPE correctly.\n"); - printf("Usage: setenv LDEKBDTYPE \n"); - printf(" (one of type2, type3, type4, jle, or as3000j)"); - exit(0); /* exit to shell */ + /* obnoxious behavior */ + mess_reset(); + printf("!!CAUTION: LDEKBDTYPE is not set.\n"); + printf("Please retry after setting LDEKBDTYPE correctly.\n"); + printf("Usage: setenv LDEKBDTYPE \n"); + printf(" (one of type2, type3, type4, jle, or as3000j)"); + exit(0); /* exit to shell */ #else #ifdef DECSTN - type = KB_DEC3100; + type = KB_DEC3100; #else #ifdef RS6000 - type = KB_RS6000; + type = KB_RS6000; #else #ifdef HP9000 - type = KB_HP9000; + type = KB_HP9000; #else #ifdef XWINDOW - type = KB_X; + type = KB_X; #elif DOS - type = KB_DOS; + type = KB_DOS; #else - if(ioctl(fd,KIOCTYPE,&type) !=0) { - error("keyboardtype:IOCTL(KIOCTYPE) fails (cont. w. type-3"); - type = KB_SUN3; - } /* otherwise, type is set */ + if (ioctl(fd, KIOCTYPE, &type) != 0) { + error("keyboardtype:IOCTL(KIOCTYPE) fails (cont. w. type-3"); + type = KB_SUN3; + } /* otherwise, type is set */ #endif /* XWINDOW */ #endif /* HP9000 */ @@ -733,80 +719,90 @@ void keyboardtype(fd) #undef FUJI #endif /* XWINDOW */ - }/* if end */ - else { - if (strcmp("as3000j", key)==0) type = KB_AS3000J; - else if (strcmp("type4", key)==0) type = KB_SUN4; - else if (strcmp("type2", key)==0) type = KB_SUN2; - else if (strcmp("jle", key)==0) type = KB_JLE; - else if (strcmp("rs6000", key)==0) type = KB_RS6000; - else if (strcmp("dec3100", key)==0) type = KB_DEC3100; - else if (strcmp("hp9000", key)==0) type = KB_HP9000; - else if (strcmp("X", key)==0) type = KB_X; - else if (strcmp("x", key)==0) type = KB_X; - else type = KB_SUN3; /* default */ - } + } /* if end */ + else { + if (strcmp("as3000j", key) == 0) + type = KB_AS3000J; + else if (strcmp("type4", key) == 0) + type = KB_SUN4; + else if (strcmp("type2", key) == 0) + type = KB_SUN2; + else if (strcmp("jle", key) == 0) + type = KB_JLE; + else if (strcmp("rs6000", key) == 0) + type = KB_RS6000; + else if (strcmp("dec3100", key) == 0) + type = KB_DEC3100; + else if (strcmp("hp9000", key) == 0) + type = KB_HP9000; + else if (strcmp("X", key) == 0) + type = KB_X; + else if (strcmp("x", key) == 0) + type = KB_X; + else + type = KB_SUN3; /* default */ + } - - switch(type) { - case KB_SUN2 : /* type2, we still use keymap for type3 */ - SUNLispKeyMap = SUNLispKeyMap_for3; - /* MIN_KEYTYPE is 3,so we can't set devconfig correctly */ - /* Therefore type2 may treat as type3 */ - InterfacePage->devconfig |= 0; - break; - case KB_SUN3 : /* type3 */ - SUNLispKeyMap = SUNLispKeyMap_for3; - InterfacePage->devconfig |= type-MIN_KEYTYPE; - break; - case KB_SUN4 : /* type4 */ - SUNLispKeyMap = SUNLispKeyMap_for4; - InterfacePage->devconfig |= type-MIN_KEYTYPE; - break; - case KB_JLE : /* JLE */ - /*printf("jle\n"); */ - SUNLispKeyMap=SUNLispKeyMap_jle; - InterfacePage->devconfig |= type-MIN_KEYTYPE; - /* InterfacePage->devconfig |= 4-MIN_KEYTYPE; */ - break; - case KB_AS3000J : /* for AS, use type4 map */ - SUNLispKeyMap = SUNLispKeyMap_for4; - InterfacePage->devconfig |= type-MIN_KEYTYPE;/* 7 */ - break; - case KB_RS6000: - SUNLispKeyMap = SUNLispKeyMap_RS6000; - InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 8 */ - break; - case KB_DEC3100: - SUNLispKeyMap = SUNLispKeyMap_DEC3100; - InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 9 */ - break; - case KB_HP9000: - SUNLispKeyMap = SUNLispKeyMap_HP9000; - InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ - break; + switch (type) { + case KB_SUN2: /* type2, we still use keymap for type3 */ + SUNLispKeyMap = SUNLispKeyMap_for3; + /* MIN_KEYTYPE is 3,so we can't set devconfig correctly */ + /* Therefore type2 may treat as type3 */ + InterfacePage->devconfig |= 0; + break; + case KB_SUN3: /* type3 */ + SUNLispKeyMap = SUNLispKeyMap_for3; + InterfacePage->devconfig |= type - MIN_KEYTYPE; + break; + case KB_SUN4: /* type4 */ + SUNLispKeyMap = SUNLispKeyMap_for4; + InterfacePage->devconfig |= type - MIN_KEYTYPE; + break; + case KB_JLE: /* JLE */ + /*printf("jle\n"); */ + SUNLispKeyMap = SUNLispKeyMap_jle; + InterfacePage->devconfig |= type - MIN_KEYTYPE; + /* InterfacePage->devconfig |= 4-MIN_KEYTYPE; */ + break; + case KB_AS3000J: /* for AS, use type4 map */ + SUNLispKeyMap = SUNLispKeyMap_for4; + InterfacePage->devconfig |= type - MIN_KEYTYPE; /* 7 */ + break; + case KB_RS6000: + SUNLispKeyMap = SUNLispKeyMap_RS6000; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 8 */ + break; + case KB_DEC3100: + SUNLispKeyMap = SUNLispKeyMap_DEC3100; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 9 */ + break; + case KB_HP9000: + SUNLispKeyMap = SUNLispKeyMap_HP9000; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ + break; #ifdef XWINDOW - case KB_X: - XGenericKeyMap = (u_char *)make_X_keymap(); - SUNLispKeyMap = XGenericKeyMap; - InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ - break; + case KB_X: + XGenericKeyMap = (u_char *)make_X_keymap(); + SUNLispKeyMap = XGenericKeyMap; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ + break; #endif /* XWINDOW */ #ifdef DOS - case KB_DOS: - SUNLispKeyMap = DOSLispKeyMap_101; - InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ - break; + case KB_DOS: + SUNLispKeyMap = DOSLispKeyMap_101; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; /* 10 */ + break; #endif /* DOS */ - default: { char errmsg [ 200 ]; - sprintf ( errmsg, "Unsupported keyboard type: %d", type); - printf ( "%s\n", errmsg); - printf ( "Configuring keyboard for type-3\n", errmsg); - SUNLispKeyMap = SUNLispKeyMap_for3; - InterfacePage->devconfig |= KB_SUN3-MIN_KEYTYPE; - break; - } - } + default: { + char errmsg[200]; + sprintf(errmsg, "Unsupported keyboard type: %d", type); + printf("%s\n", errmsg); + printf("Configuring keyboard for type-3\n", errmsg); + SUNLispKeyMap = SUNLispKeyMap_for3; + InterfacePage->devconfig |= KB_SUN3 - MIN_KEYTYPE; + break; + } + } -}/* end keyboardtype*/ +} /* end keyboardtype*/ diff --git a/src/initsout.c b/src/initsout.c old mode 100755 new mode 100644 index e19da8f..0f20b3d --- a/src/initsout.c +++ b/src/initsout.c @@ -1,7 +1,7 @@ -/* $Id: initsout.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: initsout.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: initsout.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -21,10 +21,8 @@ static char *id = "$Id: initsout.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copy /* */ /************************************************************************/ - #include "version.h" - #include #include #if defined(MACOSX) || defined(FREEBSD) @@ -49,20 +47,18 @@ static char *id = "$Id: initsout.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copy #include "devconf.h" #include "dbprint.h" #include "lldsp.h" -#include "gc.h" /* for ADDREF & GCLOOKUP */ +#include "gc.h" /* for ADDREF & GCLOOKUP */ /********** definitions for bitblt. add by osamu **********/ -DLword TEXTURE_atom; -DLword MERGE_atom; -DLword INPUT_atom; -DLword INVERT_atom; -DLword ERASE_atom; -DLword PAINT_atom; -DLword REPLACE_atom; +DLword TEXTURE_atom; +DLword MERGE_atom; +DLword INPUT_atom; +DLword INVERT_atom; +DLword ERASE_atom; +DLword PAINT_atom; +DLword REPLACE_atom; /************ end definitions for bitblt.*****************/ - - #ifdef BIGVM #define GCENTRY LispPTR #else @@ -83,29 +79,26 @@ void init_for_bitblt(void); /************************************************************************/ #ifdef BIGVM -LispPTR * fixp_value(LispPTR *ptr) -{ - LispPTR val = *ptr; +LispPTR *fixp_value(LispPTR *ptr) { + LispPTR val = *ptr; - if (val < (S_NEGATIVE | 0xFFFF)) - { - LispPTR newval = N_OP_createcell(S_POSITIVE | TYPE_FIXP); - LispPTR *newcell; newcell = (LispPTR *) Addr68k_from_LADDR(newval); - *newcell = val & 0xFFFF; /* it was smallp, so fill in */ - *ptr = newval; - GCLOOKUP(newval, ADDREF); /* so it has a refcount */ - return((LispPTR *)newcell); - } - return((LispPTR *)Addr68k_from_LADDR(val)); + if (val < (S_NEGATIVE | 0xFFFF)) { + LispPTR newval = N_OP_createcell(S_POSITIVE | TYPE_FIXP); + LispPTR *newcell; + newcell = (LispPTR *)Addr68k_from_LADDR(newval); + *newcell = val & 0xFFFF; /* it was smallp, so fill in */ + *ptr = newval; + GCLOOKUP(newval, ADDREF); /* so it has a refcount */ + return ((LispPTR *)newcell); } + return ((LispPTR *)Addr68k_from_LADDR(val)); +} #else - /* In old system, this is just a NO-OP */ +/* In old system, this is just a NO-OP */ #define fixp_value #endif /* BIGVM */ - - - + /************************************************************************/ /* */ /* i n i t _ i f p a g e */ @@ -119,84 +112,79 @@ LispPTR * fixp_value(LispPTR *ptr) #define PAGES_IN_MBYTE 2048 -void init_ifpage(int sysout_size) -{ - extern long MDate; - extern int DisplayType; +void init_ifpage(int sysout_size) { + extern long MDate; + extern int DisplayType; #ifdef NEW_STORAGE - extern int Storage_expanded; - int new_lastvmem ; + extern int Storage_expanded; + int new_lastvmem; #endif - /* - Initialize IFPAGE - */ - InterfacePage->machinetype = KATANA; /* 3 is katana */ + /* + Initialize IFPAGE + */ + InterfacePage->machinetype = KATANA; /* 3 is katana */ #ifdef NOETHER #else - init_ifpage_ether(); /* store ethernet ID in IF page */ + init_ifpage_ether(); /* store ethernet ID in IF page */ #endif /* NOETHER */ - /*InterfacePage->dl24bitaddressable = (sysout_size == 32? 0xffff : 0);*/ - InterfacePage->dl24bitaddressable = (sysout_size == 8? 0: 0xffff); + /*InterfacePage->dl24bitaddressable = (sysout_size == 32? 0xffff : 0);*/ + InterfacePage->dl24bitaddressable = (sysout_size == 8 ? 0 : 0xffff); #ifdef NEW_STORAGE - new_lastvmem = (sysout_size * PAGES_IN_MBYTE)-1; + new_lastvmem = (sysout_size * PAGES_IN_MBYTE) - 1; - if((!Storage_expanded) && (InterfacePage->dllastvmempage != new_lastvmem)) - { - fprintf(stderr,"You can't expand VMEM\n"); - exit(-1); - } - else - { /* Set value which will be set to \\LASTVMEMFILEPAGE in LISP */ - InterfacePage->dllastvmempage = new_lastvmem; - /* Also you can expand lisp space even if \\STOAGEFULL was T */ - *STORAGEFULL_word = NIL; - } - /* Set current process size */ - InterfacePage->process_size = sysout_size ; + if ((!Storage_expanded) && (InterfacePage->dllastvmempage != new_lastvmem)) { + fprintf(stderr, "You can't expand VMEM\n"); + exit(-1); + } else { /* Set value which will be set to \\LASTVMEMFILEPAGE in LISP */ + InterfacePage->dllastvmempage = new_lastvmem; + /* Also you can expand lisp space even if \\STOAGEFULL was T */ + *STORAGEFULL_word = NIL; + } + /* Set current process size */ + InterfacePage->process_size = sysout_size; #else - InterfacePage->dllastvmempage = LASTVMEMPAGE; + InterfacePage->dllastvmempage = LASTVMEMPAGE; #endif /* NEW_STORAGE */ - #ifdef BIGVM - /* For BIGVM system, save the value in \LASTVMEMFILEPAGE for lisp's use */ - if ((LispPTR)LASTVMEMFILEPAGE_word != 0xFFFFFFFF) *LASTVMEMFILEPAGE_word = InterfacePage->dllastvmempage; + /* For BIGVM system, save the value in \LASTVMEMFILEPAGE for lisp's use */ + if ((LispPTR)LASTVMEMFILEPAGE_word != 0xFFFFFFFF) + *LASTVMEMFILEPAGE_word = InterfacePage->dllastvmempage; #endif /* BIGVM */ - - /* unfortunately, Lisp only looks at a 16 bit serial number */ +/* unfortunately, Lisp only looks at a 16 bit serial number */ #ifdef HAS_GETHOSTID - InterfacePage->serialnumber = 0xffff & gethostid(); + InterfacePage->serialnumber = 0xffff & gethostid(); #endif /* HAS_GETHOSTID */ - /* get user name and stuff into vmem; this is the VMEM buffer; - This is a BCPL string -- it starts with a length count. C strings - are null terminated instead */ +/* get user name and stuff into vmem; this is the VMEM buffer; +This is a BCPL string -- it starts with a length count. C strings +are null terminated instead */ #ifndef DOS - {struct passwd *pwd; - char *s = (char*)Addr68k_from_LADDR(0155001); - /* try getpwuid first; use cuserid if it fails */ - if((pwd = getpwuid(getuid())) == NULL) + { + struct passwd *pwd; + char *s = (char *)Addr68k_from_LADDR(0155001); + /* try getpwuid first; use cuserid if it fails */ + if ((pwd = getpwuid(getuid())) == NULL) #if defined(MACOSX) || defined(FREEBSD) - ; + ; #else - cuserid(s+1); + cuserid(s + 1); #endif - else strcpy(s+1, pwd->pw_name); - *s = (char)strlen(s+1); - } + else + strcpy(s + 1, pwd->pw_name); + *s = (char)strlen(s + 1); + } #endif /* DOS */ - /* sec from Oct-13-87 12:00 It's My birthday(take) */ - /* MDate may be set by makefile(by mkvdate.c) */ - InterfacePage->rversion = (MDate - 561150000)/ (60*60*24); - - /* For DisplayType ,I couldn't insert this line into init_display */ - InterfacePage->devconfig &= 0xff87; - InterfacePage->devconfig |= DisplayType; - } - + /* sec from Oct-13-87 12:00 It's My birthday(take) */ + /* MDate may be set by makefile(by mkvdate.c) */ + InterfacePage->rversion = (MDate - 561150000) / (60 * 60 * 24); + /* For DisplayType ,I couldn't insert this line into init_display */ + InterfacePage->devconfig &= 0xff87; + InterfacePage->devconfig |= DisplayType; +} /************************************************************************/ /* */ @@ -206,23 +194,18 @@ void init_ifpage(int sysout_size) /* */ /************************************************************************/ -void init_iopage(void) -{ - - /* - * Initialize IOPAGE - */ - IOPage->dlkbdad0 = 65535; /* ALL UP */ - IOPage->dlkbdad1 = 65535; /* ALL UP */ - IOPage->dlkbdad2 = 65535; /* ALL UP */ - IOPage->dlkbdad3 = 65535; /* ALL UP */ - IOPage->dlkbdad4 = 65535; /* ALL UP */ - IOPage->dlkbdad5 = 65535; /* ALL UP */ - IOPage->dlutilin = 65535; /* ALL UP */ - - } - - +void init_iopage(void) { + /* + * Initialize IOPAGE + */ + IOPage->dlkbdad0 = 65535; /* ALL UP */ + IOPage->dlkbdad1 = 65535; /* ALL UP */ + IOPage->dlkbdad2 = 65535; /* ALL UP */ + IOPage->dlkbdad3 = 65535; /* ALL UP */ + IOPage->dlkbdad4 = 65535; /* ALL UP */ + IOPage->dlkbdad5 = 65535; /* ALL UP */ + IOPage->dlutilin = 65535; /* ALL UP */ +} /************************************************************************/ /* */ @@ -237,157 +220,142 @@ extern int for_makeinit; extern LispPTR *MakeAtom68k(char *string); -void build_lisp_map(void) -{ - DLword index; +void build_lisp_map(void) { + DLword index; - Stackspace = (DLword *) Addr68k_from_LADDR(STK_OFFSET); - Plistspace = (DLword *) Addr68k_from_LADDR(PLIS_OFFSET); - DTDspace = (DLword *) Addr68k_from_LADDR(DTD_OFFSET); - MDStypetbl = (DLword *) Addr68k_from_LADDR(MDS_OFFSET); - AtomHT = (DLword *) Addr68k_from_LADDR(ATMHT_OFFSET); - Pnamespace = (DLword *) Addr68k_from_LADDR(PNP_OFFSET); - AtomSpace = (DLword *) Addr68k_from_LADDR(ATOMS_OFFSET); - Defspace = (DLword *) Addr68k_from_LADDR(DEFS_OFFSET); - Valspace = (DLword *) Addr68k_from_LADDR(VALS_OFFSET); + Stackspace = (DLword *)Addr68k_from_LADDR(STK_OFFSET); + Plistspace = (DLword *)Addr68k_from_LADDR(PLIS_OFFSET); + DTDspace = (DLword *)Addr68k_from_LADDR(DTD_OFFSET); + MDStypetbl = (DLword *)Addr68k_from_LADDR(MDS_OFFSET); + AtomHT = (DLword *)Addr68k_from_LADDR(ATMHT_OFFSET); + Pnamespace = (DLword *)Addr68k_from_LADDR(PNP_OFFSET); + AtomSpace = (DLword *)Addr68k_from_LADDR(ATOMS_OFFSET); + Defspace = (DLword *)Addr68k_from_LADDR(DEFS_OFFSET); + Valspace = (DLword *)Addr68k_from_LADDR(VALS_OFFSET); - DBPRINT(("Stackspace = 0x%x.\n", Stackspace)); - DBPRINT(("AtomHT = 0x%x.\n", AtomHT)); + DBPRINT(("Stackspace = 0x%x.\n", Stackspace)); + DBPRINT(("AtomHT = 0x%x.\n", AtomHT)); - ListpDTD = (struct dtd *)GetDTD(TYPE_LISTP); + ListpDTD = (struct dtd *)GetDTD(TYPE_LISTP); #ifdef BIGVM - FPtoVP = (LispPTR *) Addr68k_from_LADDR(FPTOVP_OFFSET); + FPtoVP = (LispPTR *)Addr68k_from_LADDR(FPTOVP_OFFSET); #else - FPtoVP = (DLword *) Addr68k_from_LADDR(FPTOVP_OFFSET); + FPtoVP = (DLword *)Addr68k_from_LADDR(FPTOVP_OFFSET); #endif /* BIGVM */ - IOPage = (IOPAGE *) Addr68k_from_LADDR(IOPAGE_OFFSET); - InterfacePage = (IFPAGE *) Addr68k_from_LADDR(IFPAGE_OFFSET); - MiscStats = (MISCSTATS *) Addr68k_from_LADDR(MISCSTATS_OFFSET); + IOPage = (IOPAGE *)Addr68k_from_LADDR(IOPAGE_OFFSET); + InterfacePage = (IFPAGE *)Addr68k_from_LADDR(IFPAGE_OFFSET); + MiscStats = (MISCSTATS *)Addr68k_from_LADDR(MISCSTATS_OFFSET); - UFNTable = (DLword *) Addr68k_from_LADDR(UFNTBL_OFFSET); - DisplayRegion = (DLword *) Addr68k_from_LADDR(DISPLAY_OFFSET); + UFNTable = (DLword *)Addr68k_from_LADDR(UFNTBL_OFFSET); + DisplayRegion = (DLword *)Addr68k_from_LADDR(DISPLAY_OFFSET); - HTmain = (GCENTRY *) Addr68k_from_LADDR(HTMAIN_OFFSET); - HToverflow = (GCENTRY *) Addr68k_from_LADDR(HTOVERFLOW_OFFSET); - HTbigcount = (GCENTRY *) Addr68k_from_LADDR(HTBIG_OFFSET); - HTcoll = (GCENTRY *) Addr68k_from_LADDR(HTCOLL_OFFSET); + HTmain = (GCENTRY *)Addr68k_from_LADDR(HTMAIN_OFFSET); + HToverflow = (GCENTRY *)Addr68k_from_LADDR(HTOVERFLOW_OFFSET); + HTbigcount = (GCENTRY *)Addr68k_from_LADDR(HTBIG_OFFSET); + HTcoll = (GCENTRY *)Addr68k_from_LADDR(HTCOLL_OFFSET); + /**** cache values *****/ + Reclaim_cnt_word = MakeAtom68k("\\RECLAIM.COUNTDOWN"); -/**** cache values *****/ - Reclaim_cnt_word = MakeAtom68k("\\RECLAIM.COUNTDOWN"); + /*** cache values for gcreclaimer : added by T. Teruuchi 30-Sep-1987 ***/ - /*** cache values for gcreclaimer : added by T. Teruuchi 30-Sep-1987 ***/ + GcDisabled_word = MakeAtom68k("\\GCDISABLED"); - GcDisabled_word = MakeAtom68k("\\GCDISABLED"); + /*** following cache values are the solution for array reclaimer ***/ + FreeBlockBuckets_word = MakeAtom68k("\\FREEBLOCKBUCKETS"); + Array_Block_Checking_word = MakeAtom68k("ARRAYBLOCKCHECKING"); + ArrayMerging_word = MakeAtom68k("\\ARRAYMERGING"); + ArraySpace_word = MakeAtom68k("\\ARRAYSPACE"); + ArraySpace2_word = MakeAtom68k("\\ARRAYSPACE2"); + ArrayFrLst_word = MakeAtom68k("\\ArrayFrLst"); + ArrayFrLst2_word = MakeAtom68k("\\ArrayFrLst2"); + Hunk_word = MakeAtom68k("\\HUNKING?"); + System_Buffer_List_word = MakeAtom68k("SYSTEMBUFFERLIST"); + /*** The following cache values are for the top level reclaimer ***/ - /*** following cache values are the solution for array reclaimer ***/ + GcMess_word = MakeAtom68k("GCMESS"); + ReclaimMin_word = MakeAtom68k("\\RECLAIMMIN"); - FreeBlockBuckets_word = MakeAtom68k("\\FREEBLOCKBUCKETS"); - Array_Block_Checking_word = MakeAtom68k("ARRAYBLOCKCHECKING"); - ArrayMerging_word = MakeAtom68k("\\ARRAYMERGING"); - ArraySpace_word = MakeAtom68k("\\ARRAYSPACE"); - ArraySpace2_word = MakeAtom68k("\\ARRAYSPACE2"); - ArrayFrLst_word = MakeAtom68k("\\ArrayFrLst"); - ArrayFrLst2_word = MakeAtom68k("\\ArrayFrLst2"); - Hunk_word = MakeAtom68k("\\HUNKING?"); - System_Buffer_List_word = MakeAtom68k("SYSTEMBUFFERLIST"); + /*** The following caches are for Symbol lookup April-28,1988 Tomtom ***/ - /*** The following cache values are for the top level reclaimer ***/ + Package_from_Index_word = MakeAtom68k("*PACKAGE-FROM-INDEX*"); + Package_from_Name_word = MakeAtom68k("*PACKAGE-FROM-NAME*"); + Keyword_Package_word = MakeAtom68k("*KEYWORD-PACKAGE*"); + DBPRINT(("Package_from_Index_word = 0x%x.\n", Package_from_Index_word)); + DBPRINT(("Package_from_Name_word = 0x%x.\n", Package_from_Name_word)); - GcMess_word = MakeAtom68k("GCMESS"); - ReclaimMin_word = MakeAtom68k("\\RECLAIMMIN"); + /*** The following atom-index cache is for CL:VALUES opcode JDS 4/5/89 ***/ - /*** The following caches are for Symbol lookup April-28,1988 Tomtom ***/ + MVLIST_index = MAKEATOM("\\MVLIST"); - Package_from_Index_word = MakeAtom68k("*PACKAGE-FROM-INDEX*"); - Package_from_Name_word = MakeAtom68k("*PACKAGE-FROM-NAME*"); - Keyword_Package_word = MakeAtom68k("*KEYWORD-PACKAGE*"); - DBPRINT(("Package_from_Index_word = 0x%x.\n", Package_from_Index_word)); - DBPRINT(("Package_from_Name_word = 0x%x.\n", Package_from_Name_word)); + /* * * Atoms for closure-cache interface * * */ - /*** The following atom-index cache is for CL:VALUES opcode JDS 4/5/89 ***/ + if (for_makeinit) { + Closure_Cache_Enabled_word = (LispPTR *)malloc(4); + *Closure_Cache_Enabled_word = NIL; - MVLIST_index = MAKEATOM("\\MVLIST"); + Closure_Cache_word = (LispPTR *)malloc(4); + *Closure_Cache_word = NIL; - /* * * Atoms for closure-cache interface * * */ + Deleted_Implicit_Hash_Slot_word = (LispPTR *)malloc(4); + *Deleted_Implicit_Hash_Slot_word = NIL; + } else { + DBPRINT(("%d %d %d %d %d", Stackspace, Plistspace, DTDspace, MDStypetbl, AtomHT)); - if (for_makeinit) - { - Closure_Cache_Enabled_word = (LispPTR *)malloc(4); - *Closure_Cache_Enabled_word = NIL; + index = get_package_atom("*CLOSURE-CACHE-ENABLED*", 23, "SI", 2, NIL); + Closure_Cache_Enabled_word = GetVALCELL68k(index); - Closure_Cache_word = (LispPTR *)malloc(4); - *Closure_Cache_word = NIL; - - Deleted_Implicit_Hash_Slot_word = (LispPTR *)malloc(4); - *Deleted_Implicit_Hash_Slot_word = NIL; - } - else - { - DBPRINT(("%d %d %d %d %d", Stackspace, - Plistspace, DTDspace, MDStypetbl, AtomHT)); - - index = get_package_atom("*CLOSURE-CACHE-ENABLED*", 23, "SI", 2, NIL); - Closure_Cache_Enabled_word = GetVALCELL68k(index); - - index = get_package_atom("*CLOSURE-CACHE*", 15, "SI", 2, NIL); - Closure_Cache_word = GetVALCELL68k(index); - - index = get_package_atom("*DELETED-IMPLICIT-HASH-SLOT*", 28, "XCL", 3,NIL); - Deleted_Implicit_Hash_Slot_word = GetVALCELL68k(index); - - } - -/*** THE following CACHE values are added by Take. ***/ -/* The fixp_value calls make sure that those values are held - in FIXP cells (and the ..._word variable points to that cell) - so that the BIGVM code can go beyond 16 bits of page # */ - - - STORAGEFULLSTATE_index = MAKEATOM("\\STORAGEFULLSTATE"); - STORAGEFULLSTATE_word = MakeAtom68k("\\STORAGEFULLSTATE"); - STORAGEFULL_word = MakeAtom68k("\\STORAGEFULL"); - PENDINGINTERRUPT_word = MakeAtom68k("\\PENDINGINTERRUPT"); - LeastMDSPage_word = fixp_value(MakeAtom68k("\\LeastMDSPage")); - SecondMDSPage_word = fixp_value(MakeAtom68k("\\SecondMDSPage")); - SecondArrayPage_word = fixp_value(MakeAtom68k("\\SecondArrayPage")); - INTERRUPTSTATE_word = MakeAtom68k("\\INTERRUPTSTATE"); - SYSTEMCACHEVARS_word = MakeAtom68k("\\SYSTEMCACHEVARS"); - MACHINETYPE_word = MakeAtom68k("\\MACHINETYPE"); - LASTVMEMFILEPAGE_word = fixp_value(MakeAtom68k("\\LASTVMEMFILEPAGE")); - VMEM_FULL_STATE_word = MakeAtom68k("\\VMEM.FULL.STATE"); - Next_MDSpage_word = fixp_value(MakeAtom68k("\\NxtMDSPage")); - Next_Array_word = fixp_value(MakeAtom68k("\\NxtArrayPage")); - MDS_free_page_word = MakeAtom68k("\\MDSFREELISTPAGE"); - - - /*** The following are STK-OVER-FLOW stuff * Take **/ - STACKOVERFLOW_word = MakeAtom68k("\\STACKOVERFLOW"); - GuardStackAddr_word = MakeAtom68k("\\GuardStackAddr"); - LastStackAddr_word = MakeAtom68k("\\LastStackAddr"); - NeedHardreturnCleanup_word = MakeAtom68k("\\NEED.HARDRESET.CLEANUP"); - - /*** The addition of cache values for Bitblt by osamu April 13, 1988 ***/ - TEXTURE_atom = MAKEATOM("TEXTURE"); - MERGE_atom = MAKEATOM("MERGE"); - INPUT_atom = MAKEATOM("INPUT"); - INVERT_atom = MAKEATOM("INVERT"); - ERASE_atom = MAKEATOM("ERASE"); - PAINT_atom = MAKEATOM("PAINT"); - REPLACE_atom = MAKEATOM("REPLACE"); - - - /*** Do initialization for specific devices ***/ - init_for_keyhandle(); /* keyboard-interrupt handler */ - init_for_bltchar(); /* BLTCHAR speed-up */ - init_for_bitblt(); /* BITBLT-to-display speed-up */ + index = get_package_atom("*CLOSURE-CACHE*", 15, "SI", 2, NIL); + Closure_Cache_word = GetVALCELL68k(index); + index = get_package_atom("*DELETED-IMPLICIT-HASH-SLOT*", 28, "XCL", 3, NIL); + Deleted_Implicit_Hash_Slot_word = GetVALCELL68k(index); } + /*** THE following CACHE values are added by Take. ***/ + /* The fixp_value calls make sure that those values are held + in FIXP cells (and the ..._word variable points to that cell) + so that the BIGVM code can go beyond 16 bits of page # */ + STORAGEFULLSTATE_index = MAKEATOM("\\STORAGEFULLSTATE"); + STORAGEFULLSTATE_word = MakeAtom68k("\\STORAGEFULLSTATE"); + STORAGEFULL_word = MakeAtom68k("\\STORAGEFULL"); + PENDINGINTERRUPT_word = MakeAtom68k("\\PENDINGINTERRUPT"); + LeastMDSPage_word = fixp_value(MakeAtom68k("\\LeastMDSPage")); + SecondMDSPage_word = fixp_value(MakeAtom68k("\\SecondMDSPage")); + SecondArrayPage_word = fixp_value(MakeAtom68k("\\SecondArrayPage")); + INTERRUPTSTATE_word = MakeAtom68k("\\INTERRUPTSTATE"); + SYSTEMCACHEVARS_word = MakeAtom68k("\\SYSTEMCACHEVARS"); + MACHINETYPE_word = MakeAtom68k("\\MACHINETYPE"); + LASTVMEMFILEPAGE_word = fixp_value(MakeAtom68k("\\LASTVMEMFILEPAGE")); + VMEM_FULL_STATE_word = MakeAtom68k("\\VMEM.FULL.STATE"); + Next_MDSpage_word = fixp_value(MakeAtom68k("\\NxtMDSPage")); + Next_Array_word = fixp_value(MakeAtom68k("\\NxtArrayPage")); + MDS_free_page_word = MakeAtom68k("\\MDSFREELISTPAGE"); + + /*** The following are STK-OVER-FLOW stuff * Take **/ + STACKOVERFLOW_word = MakeAtom68k("\\STACKOVERFLOW"); + GuardStackAddr_word = MakeAtom68k("\\GuardStackAddr"); + LastStackAddr_word = MakeAtom68k("\\LastStackAddr"); + NeedHardreturnCleanup_word = MakeAtom68k("\\NEED.HARDRESET.CLEANUP"); + + /*** The addition of cache values for Bitblt by osamu April 13, 1988 ***/ + TEXTURE_atom = MAKEATOM("TEXTURE"); + MERGE_atom = MAKEATOM("MERGE"); + INPUT_atom = MAKEATOM("INPUT"); + INVERT_atom = MAKEATOM("INVERT"); + ERASE_atom = MAKEATOM("ERASE"); + PAINT_atom = MAKEATOM("PAINT"); + REPLACE_atom = MAKEATOM("REPLACE"); + + /*** Do initialization for specific devices ***/ + init_for_keyhandle(); /* keyboard-interrupt handler */ + init_for_bltchar(); /* BLTCHAR speed-up */ + init_for_bitblt(); /* BITBLT-to-display speed-up */ +} /************************************************************************/ /* */ @@ -397,128 +365,115 @@ void build_lisp_map(void) /* */ /************************************************************************/ -void init_for_keyhandle(void) -{ - DLword index; - extern DLword *CTopKeyevent; - extern LispPTR *KEYBOARDEVENTQUEUE68k; - extern LispPTR *KEYBUFFERING68k; - extern LispPTR DOBUFFEREDTRANSITION_index; - extern LispPTR INTERRUPTFRAME_index; - extern LispPTR *TIMER_INTERRUPT_PENDING68k; - extern LispPTR *PENDINGINTERRUPT68k; - extern LispPTR *MOUSECHORDTICKS68k; - extern LispPTR *LASTUSERACTION68k; - extern LispPTR ATOM_STARTED; - extern LispPTR *CLastUserActionCell68k; +void init_for_keyhandle(void) { + DLword index; + extern DLword *CTopKeyevent; + extern LispPTR *KEYBOARDEVENTQUEUE68k; + extern LispPTR *KEYBUFFERING68k; + extern LispPTR DOBUFFEREDTRANSITION_index; + extern LispPTR INTERRUPTFRAME_index; + extern LispPTR *TIMER_INTERRUPT_PENDING68k; + extern LispPTR *PENDINGINTERRUPT68k; + extern LispPTR *MOUSECHORDTICKS68k; + extern LispPTR *LASTUSERACTION68k; + extern LispPTR ATOM_STARTED; + extern LispPTR *CLastUserActionCell68k; - extern LispPTR *CURSORDESTHEIGHT68k; - extern LispPTR *CURSORDESTWIDTH68k; + extern LispPTR *CURSORDESTHEIGHT68k; + extern LispPTR *CURSORDESTWIDTH68k; - extern LispPTR *CURSORHOTSPOTX68k; - extern LispPTR *CURSORHOTSPOTY68k; - extern LispPTR *SOFTCURSORUPP68k; - extern LispPTR *SOFTCURSORWIDTH68k; - extern LispPTR *SOFTCURSORHEIGHT68k; - extern LispPTR *CURRENTCURSOR68k; + extern LispPTR *CURSORHOTSPOTX68k; + extern LispPTR *CURSORHOTSPOTY68k; + extern LispPTR *SOFTCURSORUPP68k; + extern LispPTR *SOFTCURSORWIDTH68k; + extern LispPTR *SOFTCURSORHEIGHT68k; + extern LispPTR *CURRENTCURSOR68k; + extern LispPTR *PERIODIC_INTERRUPT68k; + extern LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; + extern LispPTR PERIODIC_INTERRUPTFRAME_index; + extern LispPTR DORECLAIM_index; + extern LispPTR *IOINTERRUPTFLAGS_word; - extern LispPTR *PERIODIC_INTERRUPT68k; - extern LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; - extern LispPTR PERIODIC_INTERRUPTFRAME_index; - extern LispPTR DORECLAIM_index; - extern LispPTR *IOINTERRUPTFLAGS_word; + CURSORDESTHEIGHT68k = MakeAtom68k("\\CURSORDESTHEIGHT"); + CURSORDESTWIDTH68k = MakeAtom68k("\\CURSORDESTWIDTH"); + CURSORHOTSPOTX68k = MakeAtom68k("\\CURSORHOTSPOTX"); + CURSORHOTSPOTY68k = MakeAtom68k("\\CURSORHOTSPOTY"); - CURSORDESTHEIGHT68k = MakeAtom68k("\\CURSORDESTHEIGHT"); - CURSORDESTWIDTH68k = MakeAtom68k("\\CURSORDESTWIDTH"); - CURSORHOTSPOTX68k = MakeAtom68k("\\CURSORHOTSPOTX"); - CURSORHOTSPOTY68k = MakeAtom68k("\\CURSORHOTSPOTY"); + SOFTCURSORUPP68k = MakeAtom68k("\\SOFTCURSORUPP"); + SOFTCURSORWIDTH68k = MakeAtom68k("\\SOFTCURSORWIDTH"); + SOFTCURSORHEIGHT68k = MakeAtom68k("\\SOFTCURSORHEIGHT"); + CURRENTCURSOR68k = MakeAtom68k("\\CURRENTCURSOR"); - SOFTCURSORUPP68k = MakeAtom68k("\\SOFTCURSORUPP"); - SOFTCURSORWIDTH68k = MakeAtom68k("\\SOFTCURSORWIDTH"); - SOFTCURSORHEIGHT68k = MakeAtom68k("\\SOFTCURSORHEIGHT"); - CURRENTCURSOR68k = MakeAtom68k("\\CURRENTCURSOR"); + ATOM_STARTED = MAKEATOM("STARTED"); - ATOM_STARTED= MAKEATOM("STARTED"); + KEYBOARDEVENTQUEUE68k = MakeAtom68k("\\KEYBOARDEVENTQUEUE"); + KEYBUFFERING68k = MakeAtom68k("\\KEYBUFFERING"); - KEYBOARDEVENTQUEUE68k = MakeAtom68k("\\KEYBOARDEVENTQUEUE"); - KEYBUFFERING68k = MakeAtom68k("\\KEYBUFFERING"); + PENDINGINTERRUPT68k = MakeAtom68k("\\PENDINGINTERRUPT"); + MOUSECHORDTICKS68k = MakeAtom68k("\\MOUSECHORDTICKS"); + LASTUSERACTION68k = MakeAtom68k("\\LASTUSERACTION"); - PENDINGINTERRUPT68k = MakeAtom68k("\\PENDINGINTERRUPT"); - MOUSECHORDTICKS68k = MakeAtom68k("\\MOUSECHORDTICKS"); - LASTUSERACTION68k = MakeAtom68k("\\LASTUSERACTION"); + CLastUserActionCell68k = (LispPTR *)Addr68k_from_LADDR(*LASTUSERACTION68k & 0xffffff); - CLastUserActionCell68k= (LispPTR*) - Addr68k_from_LADDR(*LASTUSERACTION68k& 0xffffff); + DOBUFFEREDTRANSITION_index = MAKEATOM("\\DOBUFFEREDTRANSITIONS"); + INTERRUPTFRAME_index = MAKEATOM("\\INTERRUPTFRAME"); + CTopKeyevent = (DLword *)Addr68k_from_LADDR(*KEYBOARDEVENTQUEUE68k); - DOBUFFEREDTRANSITION_index = MAKEATOM("\\DOBUFFEREDTRANSITIONS"); - INTERRUPTFRAME_index = MAKEATOM("\\INTERRUPTFRAME"); + PERIODIC_INTERRUPT68k = MakeAtom68k("\\PERIODIC.INTERRUPT"); + PERIODIC_INTERRUPT_FREQUENCY68k = MakeAtom68k("\\PERIODIC.INTERRUPT.FREQUENCY"); - CTopKeyevent= (DLword*)Addr68k_from_LADDR(*KEYBOARDEVENTQUEUE68k); - - PERIODIC_INTERRUPT68k = MakeAtom68k("\\PERIODIC.INTERRUPT"); - PERIODIC_INTERRUPT_FREQUENCY68k - = MakeAtom68k("\\PERIODIC.INTERRUPT.FREQUENCY"); - - PERIODIC_INTERRUPTFRAME_index = MAKEATOM("\\PERIODIC.INTERRUPTFRAME"); - DORECLAIM_index = MAKEATOM("\\DORECLAIM"); + PERIODIC_INTERRUPTFRAME_index = MAKEATOM("\\PERIODIC.INTERRUPTFRAME"); + DORECLAIM_index = MAKEATOM("\\DORECLAIM"); #ifndef INIT - index = get_package_atom("\\MAIKO.IO-INTERRUPT-FLAGS", 25, "INTERLISP", 9, NIL); - IOINTERRUPTFLAGS_word = GetVALCELL68k(index); + index = get_package_atom("\\MAIKO.IO-INTERRUPT-FLAGS", 25, "INTERLISP", 9, NIL); + IOINTERRUPTFLAGS_word = GetVALCELL68k(index); #endif +} + +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +void init_for_bltchar(void) { + LispPTR index; + char *IL; + + extern LispPTR *TOPWDS68k; + extern LispPTR BLTCHAR_index; + extern LispPTR TEDIT_BLTCHAR_index; + +#ifdef COLOR + extern LispPTR *SCREENBITMAPS68k; + extern LispPTR SLOWBLTCHAR_index; + extern LispPTR *COLORSCREEN68k; /* \\COLORSCREEN */ + extern LispPTR COLORSCREEN_index; +#endif + IL = "INTERLISP"; + + if (!for_makeinit) { + BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR", 18, IL, 9, NIL); + TEDIT_BLTCHAR_index = get_package_atom("\\TEDIT.BLTCHAR", 14, IL, 9, NIL); + }; + TOPWDS68k = MakeAtom68k("\\TOPWDS"); + +#ifdef COLOR + if (!for_makeinit) { + SLOWBLTCHAR_index = get_package_atom("\\PUNT.SLOWBLTCHAR", 17, "INTERLISP", 9, NIL); + + index = MAKEATOM("\\SCREENBITMAPS"); + SCREENBITMAPS68k = GetVALCELL68k(index); + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); } - - -/************************************************************************/ -/* */ -/* */ -/* */ -/* */ -/* */ -/************************************************************************/ - -void init_for_bltchar(void) -{ LispPTR index; - char *IL; - - extern LispPTR *TOPWDS68k; - extern LispPTR BLTCHAR_index; - extern LispPTR TEDIT_BLTCHAR_index; - -#ifdef COLOR - extern LispPTR *SCREENBITMAPS68k; - extern LispPTR SLOWBLTCHAR_index; - extern LispPTR *COLORSCREEN68k; /* \\COLORSCREEN */ - extern LispPTR COLORSCREEN_index; -#endif - IL = "INTERLISP"; - - if(!for_makeinit) - { - BLTCHAR_index = get_package_atom("\\MAIKO.PUNTBLTCHAR", 18,IL,9,NIL); - TEDIT_BLTCHAR_index = get_package_atom("\\TEDIT.BLTCHAR", 14,IL,9,NIL); - }; - TOPWDS68k = MakeAtom68k("\\TOPWDS"); - -#ifdef COLOR - if(!for_makeinit) - { - SLOWBLTCHAR_index= get_package_atom("\\PUNT.SLOWBLTCHAR", - 17, "INTERLISP", 9, NIL); - - index = MAKEATOM("\\SCREENBITMAPS"); - SCREENBITMAPS68k = GetVALCELL68k(index); - COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); - COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); - } - #endif /* COLOR */ - - } - - +} /************************************************************************/ /* */ @@ -528,31 +483,24 @@ void init_for_bltchar(void) /* */ /************************************************************************/ -void init_for_bitblt(void) -{ - LispPTR index; - char *IL; +void init_for_bitblt(void) { + LispPTR index; + char *IL; - extern LispPTR BITBLTBITMAP_index; - extern LispPTR BLTSHADEBITMAP_index; + extern LispPTR BITBLTBITMAP_index; + extern LispPTR BLTSHADEBITMAP_index; #ifdef COLOR - extern LispPTR *COLORSCREEN68k; - extern LispPTR COLORSCREEN_index; + extern LispPTR *COLORSCREEN68k; + extern LispPTR COLORSCREEN_index; #endif /* COLOR */ - - if(!for_makeinit) - { - BITBLTBITMAP_index=get_package_atom("\\PUNT.BITBLT.BITMAP",19, - "INTERLISP",9, NIL); - BLTSHADEBITMAP_index=get_package_atom("\\PUNT.BLTSHADE.BITMAP",21, - "INTERLISP",9, NIL); + if (!for_makeinit) { + BITBLTBITMAP_index = get_package_atom("\\PUNT.BITBLT.BITMAP", 19, "INTERLISP", 9, NIL); + BLTSHADEBITMAP_index = get_package_atom("\\PUNT.BLTSHADE.BITMAP", 21, "INTERLISP", 9, NIL); #ifdef COLOR - COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); - COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); #endif /* COLOR */ - - } - } +} diff --git a/src/intcall.c b/src/intcall.c old mode 100755 new mode 100644 index 23f286c..03be3cd --- a/src/intcall.c +++ b/src/intcall.c @@ -1,10 +1,7 @@ -/* $Id: intcall.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: intcall.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: intcall.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,9 +16,6 @@ static char *id = "$Id: intcall.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copyr #include "version.h" - - - #include "lispemul.h" #include "address.h" #include "adr68k.h" @@ -35,98 +29,89 @@ static char *id = "$Id: intcall.c,v 1.3 1999/05/31 23:35:34 sybalsky Exp $ Copyr #include "cell.h" #include "tosfns.h" - - void cause_interruptcall(register unsigned int atom_index) - /* Atomindex for Function you want to invoke */ +/* Atomindex for Function you want to invoke */ { - register struct definition_cell *defcell68k ; /* Definition Cell PTR */ - register short pv_num ; /* scratch for pv */ + register struct definition_cell *defcell68k; /* Definition Cell PTR */ + register short pv_num; /* scratch for pv */ register struct fnhead *tmp_fn; - int rest ; /* use for arignments */ + int rest; /* use for arignments */ CURRENTFX->nopush = T; - CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR)+4; - PushCStack ; /* save TOS */ + CURRENTFX->nextblock = StkOffset_from_68K(CurrentStackPTR) + 4; + PushCStack; /* save TOS */ /* Setup IVar */ - IVar = Addr68k_from_StkOffset(CURRENTFX->nextblock) ; + IVar = Addr68k_from_StkOffset(CURRENTFX->nextblock); /* Set PC to the Next Instruction and save into pre-FX */ - CURRENTFX->pc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) ; - + CURRENTFX->pc = ((UNSIGNED)PC - (UNSIGNED)FuncObj); /* Get DEFCELL 68k address */ - defcell68k =(struct definition_cell *) GetDEFCELL68k(atom_index) ; + defcell68k = (struct definition_cell *)GetDEFCELL68k(atom_index); - /* Interrupt FN should be compiled code */ - tmp_fn = (struct fnhead *)Addr68k_from_LADDR( defcell68k->defpointer ) ; + /* Interrupt FN should be compiled code */ + tmp_fn = (struct fnhead *)Addr68k_from_LADDR(defcell68k->defpointer); -/* This used to be >=, but I think that was a change from earlier, - when it was originally >. I changed it back on 2/2/98 to see - if that fixes stack overflow toruble. --JDS */ -if((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin +STK_SAFE) > (UNSIGNED)EndSTKP ) - { - - /*printf("Intrrupt:$$ STKOVER when "); - print(atom_index); - printf(" was called *****\n");*/ - DOSTACKOVERFLOW(0,-1); - } - FuncObj = tmp_fn ; + /* This used to be >=, but I think that was a change from earlier, + when it was originally >. I changed it back on 2/2/98 to see + if that fixes stack overflow toruble. --JDS */ + if ((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin + STK_SAFE) > (UNSIGNED)EndSTKP) { + /*printf("Intrrupt:$$ STKOVER when "); + print(atom_index); + printf(" was called *****\n");*/ + DOSTACKOVERFLOW(0, -1); + } + FuncObj = tmp_fn; SWAPPED_FN_CHECK; /* Check for need to re-swap code stream */ - if( FuncObj->na >= 0 ) - { - /* This Function is Spread Type */ - /* Arguments on Stack Adjustment */ - rest = 0 - (FuncObj->na) ; - - while(rest <0) { - PushStack(NIL_PTR) ; - rest++; - } - CurrentStackPTR -= (rest<<1) ; + if (FuncObj->na >= 0) { + /* This Function is Spread Type */ + /* Arguments on Stack Adjustment */ + rest = 0 - (FuncObj->na); + + while (rest < 0) { + PushStack(NIL_PTR); + rest++; + } + CurrentStackPTR -= (rest << 1); } /* if end */ - /* Set up BF */ -CurrentStackPTR+=2; - GETWORD(CurrentStackPTR) = BF_MARK ; - GETWORD(CurrentStackPTR+1) = CURRENTFX->nextblock ; -CurrentStackPTR+=2; + /* Set up BF */ + CurrentStackPTR += 2; + GETWORD(CurrentStackPTR) = BF_MARK; + GETWORD(CurrentStackPTR + 1) = CURRENTFX->nextblock; + CurrentStackPTR += 2; - /* Set up FX */ - GETWORD(CurrentStackPTR) = FX_MARK; + /* Set up FX */ + GETWORD(CurrentStackPTR) = FX_MARK; - /* Now SET new FX */ - /* Make it SLOWP */ - ((FX*)CurrentStackPTR)->alink = StkOffset_from_68K(PVar) + 1; - ((FX*)CurrentStackPTR)->blink = StkOffset_from_68K(DUMMYBF(CurrentStackPTR)); - ((FX*)CurrentStackPTR)->clink = StkOffset_from_68K(PVar) ; - PVar = (DLword *)CurrentStackPTR + FRAMESIZE; + /* Now SET new FX */ + /* Make it SLOWP */ + ((FX *)CurrentStackPTR)->alink = StkOffset_from_68K(PVar) + 1; + ((FX *)CurrentStackPTR)->blink = StkOffset_from_68K(DUMMYBF(CurrentStackPTR)); + ((FX *)CurrentStackPTR)->clink = StkOffset_from_68K(PVar); + PVar = (DLword *)CurrentStackPTR + FRAMESIZE; #ifdef BIGVM - ((FX*)CurrentStackPTR)->fnheader = - (defcell68k->defpointer); + ((FX *)CurrentStackPTR)->fnheader = (defcell68k->defpointer); #else - ((FX*)CurrentStackPTR)->lofnheader = - (defcell68k->defpointer) & 0x0ffff ; - ((FX*)CurrentStackPTR)->hi2fnheader = - ((defcell68k->defpointer) & SEGMASK) >> 16 ; + ((FX *)CurrentStackPTR)->lofnheader = (defcell68k->defpointer) & 0x0ffff; + ((FX *)CurrentStackPTR)->hi2fnheader = ((defcell68k->defpointer) & SEGMASK) >> 16; #endif /* BIGVM */ - CurrentStackPTR = PVar ; + CurrentStackPTR = PVar; - /* Set up PVar area */ - pv_num = FuncObj->pv+1 ; - while(pv_num > 0) { - *((LispPTR *)CurrentStackPTR) = 0x0ffffffff ; - CurrentStackPTR += DLWORDSPER_CELL ; - *((LispPTR *)CurrentStackPTR) = 0x0ffffffff ; - CurrentStackPTR += DLWORDSPER_CELL ; - pv_num--; + /* Set up PVar area */ + pv_num = FuncObj->pv + 1; + while (pv_num > 0) { + *((LispPTR *)CurrentStackPTR) = 0x0ffffffff; + CurrentStackPTR += DLWORDSPER_CELL; + *((LispPTR *)CurrentStackPTR) = 0x0ffffffff; + CurrentStackPTR += DLWORDSPER_CELL; + pv_num--; } - /* Set PC points New Function's first OPCODE */ - PC = (ByteCode *)FuncObj + FuncObj->startpc ; - CURRENTFX->nextblock = StkOffset_from_68K(CurrentStackPTR); - MAKEFREEBLOCK(CurrentStackPTR , ((UNSIGNED)EndSTKP - (UNSIGNED)CurrentStackPTR) >> 1); + /* Set PC points New Function's first OPCODE */ + PC = (ByteCode *)FuncObj + FuncObj->startpc; + CURRENTFX->nextblock = StkOffset_from_68K(CurrentStackPTR); + MAKEFREEBLOCK(CurrentStackPTR, ((UNSIGNED)EndSTKP - (UNSIGNED)CurrentStackPTR) >> 1); } /* end */ diff --git a/src/kbdif.c b/src/kbdif.c old mode 100755 new mode 100644 index 8ffbea5..ef6177a --- a/src/kbdif.c +++ b/src/kbdif.c @@ -1,9 +1,6 @@ -/* $Id: kbdif.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: kbdif.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: kbdif.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -17,14 +14,10 @@ static char *id = "$Id: kbdif.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copyrig /* */ /************************************************************************/ - #include "version.h" - - /* * K Y E B O A R D I N T E R F A C E * */ - #include "lispemul.h" #include "dbprint.h" #include "devif.h" @@ -39,9 +32,7 @@ extern void ExitDosKbd(); extern unsigned long GenericReturnT(); #endif /* DOS */ - -make_kbd_instance(KbdInterface kbd) -{ +make_kbd_instance(KbdInterface kbd) { #ifdef DOS kbd->device_event = &Kbd_event; /* */ kbd->device.enter = &EnterDosKbd; diff --git a/src/kbdsubrs.c b/src/kbdsubrs.c old mode 100755 new mode 100644 index d1c432e..ea910bf --- a/src/kbdsubrs.c +++ b/src/kbdsubrs.c @@ -1,9 +1,7 @@ -/* $Id: kbdsubrs.c,v 1.2 1999/01/03 02:07:10 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: kbdsubrs.c,v 1.2 1999/01/03 02:07:10 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: kbdsubrs.c,v 1.2 1999/01/03 02:07:10 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,10 +16,9 @@ static char *id = "$Id: kbdsubrs.c,v 1.2 1999/01/03 02:07:10 sybalsky Exp $ Copy #include "version.h" - #include #ifdef DOS -#include +#include #include #else #include @@ -38,10 +35,10 @@ static char *id = "$Id: kbdsubrs.c,v 1.2 1999/01/03 02:07:10 sybalsky Exp $ Copy #include "lispemul.h" #ifdef DOS -#define PORT_A 0x60 -#define KBD_COMMAND_PORT 0x64 -#define KBD_ENABLE 0xAE -#define KBD_DISABLE 0xAD +#define PORT_A 0x60 +#define KBD_COMMAND_PORT 0x64 +#define KBD_ENABLE 0xAE +#define KBD_DISABLE 0xAD #include "devif.h" extern KbdInterface currentkbd; @@ -63,49 +60,44 @@ extern DspInterface currentdsp; extern struct screen LispScreen; #endif /* XWINDOW */ - #ifdef XWINDOW #include #endif /* XWINDOW */ -extern int LispWindowFd, - LispReadFds; +extern int LispWindowFd, LispReadFds; extern int errno; -void KB_enable( args ) -LispPTR *args; /* args[0] : ON/OFF flag - * T -- ON - * NIL -- OFF - */ +void KB_enable(args) LispPTR *args; /* args[0] : ON/OFF flag + * T -- ON + * NIL -- OFF + */ { - if( args[0] == ATOM_T ) + if (args[0] == ATOM_T) #ifdef SUNDISPLAY - LispReadFds |= 1<< LispWindowFd; + LispReadFds |= 1 << LispWindowFd; #elif XWINDOW - enable_Xkeyboard(currentdsp); + enable_Xkeyboard(currentdsp); #elif DOS - (currentkbd->device.enter)(currentkbd); - /* outp( KBD_COMMAND_PORT, KBD_ENABLE); */ + (currentkbd->device.enter)(currentkbd); +/* outp( KBD_COMMAND_PORT, KBD_ENABLE); */ #endif /* DOS */ - else if( args[0] == NIL ) + else if (args[0] == NIL) #ifdef SUNDISPLAY - LispReadFds &= ~(1 << LispWindowFd); + LispReadFds &= ~(1 << LispWindowFd); #elif XWINDOW - disable_Xkeyboard(currentdsp); + disable_Xkeyboard(currentdsp); #elif DOS - (currentkbd->device.exit)(currentkbd); - /* outp( KBD_COMMAND_PORT, KBD_DISABLE); */ + (currentkbd->device.exit)(currentkbd); +/* outp( KBD_COMMAND_PORT, KBD_DISABLE); */ #endif /* DOS */ - else{ - error("KB_enable: illegal arg \n"); - printf("KB_enable: arg = %d\n", args[0] ); - } + else { + error("KB_enable: illegal arg \n"); + printf("KB_enable: arg = %d\n", args[0]); + } } - - /**************************************************** * * KB_beep() entry of SUBRCALL 80 2 @@ -114,63 +106,58 @@ LispPTR *args; /* args[0] : ON/OFF flag ****************************************************/ /* struct timeval belltime ={ - 0,100 + 0,100 }; */ extern int LispKbdFd; #ifdef DOS - int bell_status_word; +int bell_status_word; #endif /* DOS */ -void KB_beep( args ) -LispPTR *args; /* args[0] : ON/OFF flag - * T -- ON - * NIL -- OFF - * args[1] : frequency - */ +void KB_beep(args) LispPTR *args; /* args[0] : ON/OFF flag + * T -- ON + * NIL -- OFF + * args[1] : frequency + */ { - int keycommand; + int keycommand; #ifdef SUNDISPLAY -/* belltime.tv_usec = args[1] & 0xffff; - win_bell(LispWindowFd, belltime, 0); -*/ - if( (LispKbdFd = open( LispScreen.scr_kbdname, O_RDWR)) == -1) - fprintf( stderr, "can't open %s, errno=%d\n", - LispScreen.scr_kbdname, errno); + /* belltime.tv_usec = args[1] & 0xffff; + win_bell(LispWindowFd, belltime, 0); + */ + if ((LispKbdFd = open(LispScreen.scr_kbdname, O_RDWR)) == -1) + fprintf(stderr, "can't open %s, errno=%d\n", LispScreen.scr_kbdname, errno); - if( args[0] == ATOM_T ){ - keycommand = KBD_CMD_BELL; /* Turn on the bell */ - if(ioctl( LispKbdFd, KIOCCMD, &keycommand)== -1) - fprintf( stderr, "Error at ioctl errno =%d\n", errno); - } - else{ - keycommand = KBD_CMD_NOBELL; /* Turn off the bell */ - if(ioctl( LispKbdFd, KIOCCMD, &keycommand)== -1) - fprintf( stderr, "Error at ioctl errno =%d\n", errno); - } + if (args[0] == ATOM_T) { + keycommand = KBD_CMD_BELL; /* Turn on the bell */ + if (ioctl(LispKbdFd, KIOCCMD, &keycommand) == -1) + fprintf(stderr, "Error at ioctl errno =%d\n", errno); + } else { + keycommand = KBD_CMD_NOBELL; /* Turn off the bell */ + if (ioctl(LispKbdFd, KIOCCMD, &keycommand) == -1) + fprintf(stderr, "Error at ioctl errno =%d\n", errno); + } - close( LispKbdFd ); + close(LispKbdFd); #elif XWINDOW - if( args[0] == ATOM_T ) - beep_Xkeyboard(currentdsp); + if (args[0] == ATOM_T) beep_Xkeyboard(currentdsp); #elif DOS - if( args[0] == ATOM_T ){ - bell_status_word = inp( 0x61 ); - outp( 0x61, bell_status_word | 0x3 ); /* Turn on the speaker */ + if (args[0] == ATOM_T) { + bell_status_word = inp(0x61); + outp(0x61, bell_status_word | 0x3); /* Turn on the speaker */ /* Prepare timer by sending 10111100 to port 43. */ - outp( 0x43, 0xb6 ); + outp(0x43, 0xb6); /* Divide input frequency by timer ticks per second and * write (byte by byte) to timer. */ - outp( 0x42, (char)(1193180L / (LispIntToCInt(args[1]))) ); - outp( 0x42, (char)(1193180L / (LispIntToCInt(args[1])) >> 8) ); + outp(0x42, (char)(1193180L / (LispIntToCInt(args[1])))); + outp(0x42, (char)(1193180L / (LispIntToCInt(args[1])) >> 8)); } else { - outp( 0x61, bell_status_word & ~0x3 ); /* Turn off the speaker (with */ + outp(0x61, bell_status_word & ~0x3); /* Turn off the speaker (with */ /* bits 0 and 1). */ - } #endif /* SUNDISPLAY, XWINDOW, DOS */ } @@ -182,12 +169,10 @@ LispPTR *args; /* args[0] : ON/OFF flag * ****************************************************/ -void KB_setmp( args ) -LispPTR *args; /* args[0] : MPCODE */ +void KB_setmp(args) LispPTR *args; /* args[0] : MPCODE */ { - -#ifdef DEBUG - printf("MP: %d\n", args[0] & 0xffff ); +#ifdef DEBUG + printf("MP: %d\n", args[0] & 0xffff); #endif } @@ -203,14 +188,11 @@ LispPTR *args; /* args[0] : MPCODE */ * ****************************************************/ -void KB_setled( args ) -LispPTR *args; +void KB_setled(args) LispPTR *args; { #ifdef DOS outp(PORT_A, (unsigned char)0xED); - outp(PORT_A, (unsigned char)(((args[0] != NIL) << 2) | - ((args[1] != NIL) << 1) | - (args[2] != NIL))); + outp(PORT_A, + (unsigned char)(((args[0] != NIL) << 2) | ((args[1] != NIL) << 1) | (args[2] != NIL))); #endif /* DOS */ } - diff --git a/src/keyevent.c b/src/keyevent.c old mode 100755 new mode 100644 index f373399..cfcbba7 --- a/src/keyevent.c +++ b/src/keyevent.c @@ -1,8 +1,7 @@ -/* $Id: keyevent.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: keyevent.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: keyevent.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -23,43 +22,41 @@ static char *id = "$Id: keyevent.c,v 1.3 2001/12/24 01:09:03 sybalsky Exp $ Copy * */ -#include -#include -#include +#include +#include +#include #ifndef DOS -#include -#include +#include +#include #include #else #include #endif /* DOS */ #ifdef DOS -#include /* Defines "#pragma interrupt" */ -#include /* Defines REGS & other structs */ -#include /* _XSTACK struct definition */ +#include /* Defines "#pragma interrupt" */ +#include /* Defines REGS & other structs */ +#include /* _XSTACK struct definition */ #pragma interrupt(Mouse_hndlr) -void Mouse_hndlr(void); /* Fields mouse events from driver */ - /* (during servicing of mouse interrupt) */ +void Mouse_hndlr(void); /* Fields mouse events from driver */ + /* (during servicing of mouse interrupt) */ #elif XWINDOW #else -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #endif /* DOS */ - #ifdef ISC #include #include #define SIGIO SIGPOLL #endif /* ISC */ - #include "lispemul.h" #include "lspglob.h" #include "adr68k.h" @@ -69,7 +66,6 @@ void Mouse_hndlr(void); /* Fields mouse events from driver */ #include "display.h" #include "lsptypes.h" - #include "iopage.h" #include "ifpage.h" @@ -85,183 +81,161 @@ extern IOPAGE *IOPage68K; #endif /* DOS */ #ifdef ISC - /*****************************************************/ - /* ISC Unix uses POLL, rather than SELECT, because */ - /* SELECT causes intermittent wild jumps. This is */ - /* the pollfd structure to drive it. */ - /*****************************************************/ +/*****************************************************/ +/* ISC Unix uses POLL, rather than SELECT, because */ +/* SELECT causes intermittent wild jumps. This is */ +/* the pollfd structure to drive it. */ +/*****************************************************/ #include -struct pollfd pollfds[33] = { {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0}, - {0, POLLIN|POLLOUT, 0} }; +struct pollfd pollfds[33] = { + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, + {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}, {0, POLLIN | POLLOUT, 0}}; #endif /* ISC */ - - /* for contextsw */ -#define AS_OPCODE 1 -#define AS_CPROG 0 +#define AS_OPCODE 1 +#define AS_CPROG 0 /* EmMouseX68K are already swapped, no need for GETWORD */ -#define MouseMove(x,y) {*((DLword *)EmMouseX68K) = x; \ - *((DLword *)EmMouseY68K) = y;} +#define MouseMove(x, y) \ + { \ + *((DLword *)EmMouseX68K) = x; \ + *((DLword *)EmMouseY68K) = y; \ + } #ifdef NEVER #ifndef BYTESWAP -#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ - if( bitvalue) \ - *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ - |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ - else \ - *((DLword*)(base68k) + (((u_short)(offset))>>4 )) \ - &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ - } +#define PUTBASEBIT68K(base68k, offset, bitvalue) \ + { \ + if (bitvalue) \ + *((DLword *)(base68k) + (((u_short)(offset)) >> 4)) |= \ + 1 << (15 - ((u_short)(offset)) % BITSPER_DLWORD); \ + else \ + *((DLword *)(base68k) + (((u_short)(offset)) >> 4)) &= \ + ~(1 << (15 - ((u_short)(offset)) % BITSPER_DLWORD)); \ + } #else /* convert to real 68 k address, then do arithmetic, and convert back to i386 address pointer */ -#define PUTBASEBIT68K(base68k, offset, bitvalue ) { \ - int real68kbase; \ - real68kbase = 2 ^ ((int)(base68k)); \ - if( bitvalue) \ - GETWORD((DLword*)(real68kbase) + (((u_short)(offset))>>4 )) \ - |= 1 << (15 - ((u_short)(offset))%BITSPER_DLWORD); \ - else \ - GETWORD((DLword*)(real68kbase) + (((u_short)(offset))>>4 )) \ - &= ~( 1 << (15 - ((u_short)(offset)) %BITSPER_DLWORD)); \ - } +#define PUTBASEBIT68K(base68k, offset, bitvalue) \ + { \ + int real68kbase; \ + real68kbase = 2 ^ ((int)(base68k)); \ + if (bitvalue) \ + GETWORD((DLword *)(real68kbase) + (((u_short)(offset)) >> 4)) |= \ + 1 << (15 - ((u_short)(offset)) % BITSPER_DLWORD); \ + else \ + GETWORD((DLword *)(real68kbase) + (((u_short)(offset)) >> 4)) &= \ + ~(1 << (15 - ((u_short)(offset)) % BITSPER_DLWORD)); \ + } #endif #endif /* NEVER */ -extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K,*EmUtilin68K; -extern DLword *EmKbdAd168K,*EmKbdAd268K,*EmKbdAd368K,*EmKbdAd468K,*EmKbdAd568K; +extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K, *EmUtilin68K; +extern DLword *EmKbdAd168K, *EmKbdAd268K, *EmKbdAd368K, *EmKbdAd468K, *EmKbdAd568K; extern u_char *SUNLispKeyMap; -extern u_int LispReadFds, LispWindowFd; -extern int RS232CReadFds, RS232C_remain_data, XLocked; -int XNeedSignal = 0; /* T if an X interrupt happened while XLOCK asserted */ +extern u_int LispReadFds, LispWindowFd; +extern int RS232CReadFds, RS232C_remain_data, XLocked; +int XNeedSignal = 0; /* T if an X interrupt happened while XLOCK asserted */ #ifdef NOETHER -extern u_int LogFileFd; +extern u_int LogFileFd; #else -extern int ether_fd; -extern u_int LogFileFd, EtherReadFds; +extern int ether_fd; +extern u_int LogFileFd, EtherReadFds; #endif /* NOETHER */ extern DLword *DisplayRegion68k; u_int LispIOFds = 0; #ifndef DOS -static struct timeval SelectTimeout = { - 0, 0 -}; +static struct timeval SelectTimeout = {0, 0}; #endif /* DOS */ - #ifdef XWINDOW -static int Xcount=1; +static int Xcount = 1; extern int Event_Req; #endif /* XWINDOW */ - - extern MISCSTATS *MiscStats; - LispPTR *LASTUSERACTION68k; - LispPTR *CLastUserActionCell68k; - LispPTR *CURSORDESTHEIGHT68k; - LispPTR *CURSORDESTWIDTH68k; +LispPTR *LASTUSERACTION68k; +LispPTR *CLastUserActionCell68k; +LispPTR *CURSORDESTHEIGHT68k; +LispPTR *CURSORDESTWIDTH68k; - LispPTR *CURSORHOTSPOTX68k; - LispPTR *CURSORHOTSPOTY68k; - LispPTR *SOFTCURSORUPP68k; - LispPTR *SOFTCURSORWIDTH68k; - LispPTR *SOFTCURSORHEIGHT68k; - LispPTR *CURRENTCURSOR68k; +LispPTR *CURSORHOTSPOTX68k; +LispPTR *CURSORHOTSPOTY68k; +LispPTR *SOFTCURSORUPP68k; +LispPTR *SOFTCURSORWIDTH68k; +LispPTR *SOFTCURSORHEIGHT68k; +LispPTR *CURRENTCURSOR68k; extern DLword *EmCursorX68K; extern DLword *EmCursorY68K; #ifndef BYTESWAP -typedef struct - { - unsigned nil : 8; - unsigned type: 8; - unsigned num : 16; - } SNum; +typedef struct { + unsigned nil : 8; + unsigned type : 8; + unsigned num : 16; +} SNum; #else -typedef struct - { - unsigned num : 16; - unsigned type: 8; - unsigned nil : 8; - } SNum; +typedef struct { + unsigned num : 16; + unsigned type : 8; + unsigned nil : 8; +} SNum; #endif /* BYTESWAP */ -#define IDiff(x68k,y68k) (((SNum*)(x68k))->num - ((SNum*)(y68k))->num) +#define IDiff(x68k, y68k) (((SNum *)(x68k))->num - ((SNum *)(y68k))->num) /* EmXXXX68K are already swapped, no need for GETWORD */ #ifdef OLD_CURSOR -#define TrackCursor(cx,cy) {*CLastUserActionCell68k = MiscStats->secondstmp;\ - *EmCursorX68K = cx; \ - *EmCursorY68K = cy;} +#define TrackCursor(cx, cy) \ + { \ + *CLastUserActionCell68k = MiscStats->secondstmp; \ + *EmCursorX68K = cx; \ + *EmCursorY68K = cy; \ + } #else -#define TrackCursor(cx,cy) {*CLastUserActionCell68k = MiscStats->secondstmp;\ - taking_mouse_down();\ - taking_mouse_up(cx,cy); \ - *EmCursorX68K= cx;\ - *EmCursorY68K= cy;} +#define TrackCursor(cx, cy) \ + { \ + *CLastUserActionCell68k = MiscStats->secondstmp; \ + taking_mouse_down(); \ + taking_mouse_up(cx, cy); \ + *EmCursorX68K = cx; \ + *EmCursorY68K = cy; \ + } #endif /* OLD_CURSOR */ - - /* function that checks to see if more input is waiting on a file; - if some is, it bumps FileIOFlag so it'll get seen next time around */ -/* commented out is some code that would also clobber - Irq_Stk_Check & Irq_Stk_End to force - a new interrupt as rapidly as possible; it causes odd behavior... - needs some study and thought */ + if some is, it bumps FileIOFlag so it'll get seen next time around */ +/* commented out is some code that would also clobber + Irq_Stk_Check & Irq_Stk_End to force + a new interrupt as rapidly as possible; it causes odd behavior... + needs some study and thought */ /* this is currently called EVERY time the timer expires. It checks for keyboard input */ - LispPTR *MOUSECHORDTICKS68k; /**NEW GLOBAL***-> will be moved***/ LispPTR *KEYBOARDEVENTQUEUE68k; LispPTR *KEYBUFFERING68k; -int KBDEventFlg=NIL; +int KBDEventFlg = NIL; DLword *CTopKeyevent; LispPTR DOBUFFEREDTRANSITION_index; @@ -276,14 +250,14 @@ LispPTR DORECLAIM_index; LispPTR *IOINTERRUPTFLAGS_word; -int URaid_req=NIL; -int ScreenLocked=NIL; +int URaid_req = NIL; +int ScreenLocked = NIL; DLword MonoCursor_savebitmap[CURSORHEIGHT]; /* for mono cursor save-image */ #define COLOR_DEPTH 8 #define COLORPIXELS_IN_LONGWORD 4 #define COLORPIXELS_IN_DLWORD 2 -DLword ColorCursor_savebitmap[CURSORWIDTH/COLORPIXELS_IN_DLWORD * CURSORHEIGHT]; +DLword ColorCursor_savebitmap[CURSORWIDTH / COLORPIXELS_IN_DLWORD * CURSORHEIGHT]; /************************************************************************/ /* */ @@ -326,126 +300,112 @@ DLword ColorCursor_savebitmap[CURSORWIDTH/COLORPIXELS_IN_DLWORD * CURSORHEIGHT]; /* */ /************************************************************************/ -void getsignaldata(sig, code, scp) - int sig, code; - struct sigcontext *scp; - { +void getsignaldata(sig, code, scp) int sig, code; +struct sigcontext *scp; +{ #ifndef DOS #ifndef XWINDOW - struct inputevent event; + struct inputevent event; #endif /* XWINDOW */ - static int rfds, wfds, efds, res; + static int rfds, wfds, efds, res; #ifdef ISC - int fdcount = 0; - int bit; + int fdcount = 0; + int bit; #endif #ifdef XWINDOW #if (defined(APOLLO) || defined(sun)) - if( Event_Req ) - { - if (!XLocked++) getXsignaldata(currentdsp); - else XNeedSignal = 1; - Event_Req = FALSE; - XLocked--; - } -#endif + if (Event_Req) { + if (!XLocked++) + getXsignaldata(currentdsp); + else + XNeedSignal = 1; + Event_Req = FALSE; + XLocked--; + } +#endif #endif /* XWINDOW */ - -/* #ifndef KBINT */ - rfds = LispReadFds; - efds = LispReadFds; - /* label and ifs not needed if only keyboard on SIGIO */ -getmore: + /* #ifndef KBINT */ + rfds = LispReadFds; + efds = LispReadFds; +/* label and ifs not needed if only keyboard on SIGIO */ +getmore: #ifdef ISC - for (res=0, bit=1; res<32; res++, bit <<= 1) - if (LispReadFds&bit) - { - pollfds[fdcount++].fd = res; - } - if ((res = poll(pollfds, fdcount, 0)) > 0) + for (res = 0, bit = 1; res < 32; res++, bit <<= 1) + if (LispReadFds & bit) { pollfds[fdcount++].fd = res; } + if ((res = poll(pollfds, fdcount, 0)) > 0) #else - if(select(32, (fd_set *)&rfds, NULL, (fd_set *)&efds, &SelectTimeout) >= 0 ) + if (select(32, (fd_set *)&rfds, NULL, (fd_set *)&efds, &SelectTimeout) >= 0) #endif - { - DBPRINT(("SIGIO: fd mask(r/e) = 0x%x/0x%x.\n", rfds, efds)); + { + DBPRINT(("SIGIO: fd mask(r/e) = 0x%x/0x%x.\n", rfds, efds)); #ifdef SUNDISPLAY - if( rfds & (1 << LispWindowFd) ) - { -/* #endif */ - while( input_readevent(LispWindowFd, &event) >= 0 ) - { - /*if(!kb_event( &event )) {goto getmore;};*/ - if((KBDEventFlg+=kb_event( &event ))>0) - { - /* immidiately request for IRQ check */ - Irq_Stk_End=Irq_Stk_Check=0; - } - } -/* #ifndef KBINT */ - } + if (rfds & (1 << LispWindowFd)) { + /* #endif */ + while (input_readevent(LispWindowFd, &event) >= 0) { + /*if(!kb_event( &event )) {goto getmore;};*/ + if ((KBDEventFlg += kb_event(&event)) > 0) { + /* immidiately request for IRQ check */ + Irq_Stk_End = Irq_Stk_Check = 0; + } + } + /* #ifndef KBINT */ + } #endif /* SUNDISPLAY */ #ifdef XWINDOW - if (rfds & (1 << ConnectionNumber(currentdsp->display_id))) - { - if (!XLocked) getXsignaldata(currentdsp); - else XNeedSignal = 1; - } + if (rfds & (1 << ConnectionNumber(currentdsp->display_id))) { + if (!XLocked) + getXsignaldata(currentdsp); + else + XNeedSignal = 1; + } #endif /* XWINDOW */ #ifdef NOETHER #else - if (rfds & EtherReadFds) - { /* Raw ethernet (NIT) I/O happened, so handle it. */ - DBPRINT(("Handling enet interrupt.\n\n")); - check_ether(); - } + if (rfds & EtherReadFds) { /* Raw ethernet (NIT) I/O happened, so handle it. */ + DBPRINT(("Handling enet interrupt.\n\n")); + check_ether(); + } #endif /* NOETHER */ - #ifdef RS232 - if (((rfds & RS232CReadFds) == RS232CReadFds) || - (RS232C_remain_data && rs232c_lisp_is_ready())) rs232c_read(); + if (((rfds & RS232CReadFds) == RS232CReadFds) || (RS232C_remain_data && rs232c_lisp_is_ready())) + rs232c_read(); #endif /* RS232 */ - #ifdef LOGINT - if (rfds & LogFileFd) - { /* There's info in the log file. Tell Lisp to print it. */ - flush_pty(); /* move the msg(s) to the log file */ - - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word)) - ->LogFileIO = 1; + if (rfds & LogFileFd) { /* There's info in the log file. Tell Lisp to print it. */ + flush_pty(); /* move the msg(s) to the log file */ - *PENDINGINTERRUPT68k = ATOM_T; - Irq_Stk_End=Irq_Stk_Check=0; - } + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->LogFileIO = 1; + + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End = Irq_Stk_Check = 0; + } #endif - if (rfds & LispIOFds) - { /* There's activity on a Lisp-opened FD. Tell Lisp. */ - u_int *flags; - flags = (u_int *)Addr68k_from_LADDR(*IOINTERRUPTFLAGS_word); - *flags = rfds & LispIOFds; - - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word)) - ->IOInterrupt = 1; + if (rfds & LispIOFds) { /* There's activity on a Lisp-opened FD. Tell Lisp. */ + u_int *flags; + flags = (u_int *)Addr68k_from_LADDR(*IOINTERRUPTFLAGS_word); + *flags = rfds & LispIOFds; - *PENDINGINTERRUPT68k = ATOM_T; - Irq_Stk_End=Irq_Stk_Check=0; - } + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->IOInterrupt = 1; - } + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End = Irq_Stk_Check = 0; + } + } /* #endif */ #endif /* DOS */ - } /* end getsignaldata */ +} /* end getsignaldata */ -void kb_trans( u_short keycode, u_short upflg ); +void kb_trans(u_short keycode, u_short upflg); /************************************************************************/ /* */ @@ -458,131 +418,122 @@ void kb_trans( u_short keycode, u_short upflg ); #if (!defined(XWINDOW) && !defined(DOS)) extern int for_makeinit; -int kb_event( event ) -register struct inputevent *event; - { - register u_int upflg; - int kn; - DLword w,r; - KBEVENT *kbevent; +int kb_event(event) register struct inputevent *event; +{ + register u_int upflg; + int kn; + DLword w, r; + KBEVENT *kbevent; #ifdef INIT -/* generate some code to check if we are running as an INIT. Don't - needlessly generate this code, and don't return if we aren't - running with the -INIT flag turned on. --was 2/7/89 */ + /* generate some code to check if we are running as an INIT. Don't + needlessly generate this code, and don't return if we aren't + running with the -INIT flag turned on. --was 2/7/89 */ - if (for_makeinit) - { - return(0); - }; + if (for_makeinit) { return (0); }; #endif - upflg = event_is_up( event ); + upflg = event_is_up(event); #ifdef SHOWKEYSTROKES - printf("Key # %d, upflg %d.\n", (unsigned short)event->ie_code, upflg); + printf("Key # %d, upflg %d.\n", (unsigned short)event->ie_code, upflg); #endif - switch( ((unsigned short)event->ie_code) ) - { - case LOC_MOVE: + switch (((unsigned short)event->ie_code)) { + case LOC_MOVE: #ifndef OLD_CURSOR - if(!ScreenLocked) + if (!ScreenLocked) #endif - { ScreenLocked=T; - MouseMove( event->ie_locx, event->ie_locy ); - TrackCursor(event->ie_locx,event->ie_locy ); - ScreenLocked=NIL; - } - return(0); - - case MS_LEFT: /*mouse_button( MOUSE_LEFT, upflg );*/ - PUTBASEBIT68K( EmRealUtilin68K, MOUSE_LEFT, upflg ); - break; - - case MS_MIDDLE: /*mouse_button( MOUSE_MIDDLE, upflg );*/ - PUTBASEBIT68K( EmRealUtilin68K, MOUSE_MIDDLE, upflg ); - break; - - case MS_RIGHT: /*mouse_button( MOUSE_RIGHT, upflg );*/ - PUTBASEBIT68K( EmRealUtilin68K, MOUSE_RIGHT, upflg ); - break; - - default: /* keystroke */ - if((kn=SUNLispKeyMap[((unsigned short)event->ie_code)]) > -1) - kb_trans( kn, upflg ); - else - printf("kb_event: unknown key number=%d\n", - event->ie_code ); - - break; - }; { - do_ring: - /* Emxxx do not use GETWORD */ - if(((*EmKbdAd268K) & 2113) == 0) - {/*Ctrl-shift-NEXT*/ - error("****** EMERGENCY Interrupt ******"); - (*EmKbdAd268K)=KB_ALLUP; /*reset*/ - ((RING*)CTopKeyevent)->read=0; /* reset queue */ - ((RING*)CTopKeyevent)->write=MINKEYEVENT; - /*return(0);*/ - } - else if(((*EmKbdAd268K) & 2114) == 0) - { /* Ctrl-Shift-DEL */ - (*EmKbdAd268K)=KB_ALLUP; /*reset*/ - URaid_req=T; - ((RING*)CTopKeyevent)->read=0; /* reset queue */ - ((RING*)CTopKeyevent)->write=MINKEYEVENT; + ScreenLocked = T; + MouseMove(event->ie_locx, event->ie_locy); + TrackCursor(event->ie_locx, event->ie_locy); + ScreenLocked = NIL; + } + return (0); - /*return(0);*/ - } + case MS_LEFT: /*mouse_button( MOUSE_LEFT, upflg );*/ + PUTBASEBIT68K(EmRealUtilin68K, MOUSE_LEFT, upflg); + break; + + case MS_MIDDLE: /*mouse_button( MOUSE_MIDDLE, upflg );*/ + PUTBASEBIT68K(EmRealUtilin68K, MOUSE_MIDDLE, upflg); + break; + + case MS_RIGHT: /*mouse_button( MOUSE_RIGHT, upflg );*/ + PUTBASEBIT68K(EmRealUtilin68K, MOUSE_RIGHT, upflg); + break; + + default: /* keystroke */ + if ((kn = SUNLispKeyMap[((unsigned short)event->ie_code)]) > -1) + kb_trans(kn, upflg); + else + printf("kb_event: unknown key number=%d\n", event->ie_code); + + break; + }; + { + do_ring: + /* Emxxx do not use GETWORD */ + if (((*EmKbdAd268K) & 2113) == 0) { /*Ctrl-shift-NEXT*/ + error("****** EMERGENCY Interrupt ******"); + (*EmKbdAd268K) = KB_ALLUP; /*reset*/ + ((RING *)CTopKeyevent)->read = 0; /* reset queue */ + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + /*return(0);*/ + } else if (((*EmKbdAd268K) & 2114) == 0) { /* Ctrl-Shift-DEL */ + (*EmKbdAd268K) = KB_ALLUP; /*reset*/ + URaid_req = T; + ((RING *)CTopKeyevent)->read = 0; /* reset queue */ + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + + /*return(0);*/ + } #ifdef OS4_TYPE4BUG - else if(((*EmKbdAd268K) & 2120) == 0) - { /* Ctrl-Shift-Return */ - error("****** EMERGENCY Interrupt ******"); - (*EmKbdAd268K)=KB_ALLUP; /*reset*/ - ((RING*)CTopKeyevent)->read=0; /* reset queue */ - ((RING*)CTopKeyevent)->write=MINKEYEVENT; - /*return(0);*/ - } + else if (((*EmKbdAd268K) & 2120) == 0) { /* Ctrl-Shift-Return */ + error("****** EMERGENCY Interrupt ******"); + (*EmKbdAd268K) = KB_ALLUP; /*reset*/ + ((RING *)CTopKeyevent)->read = 0; /* reset queue */ + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + /*return(0);*/ + } #endif - r=RING_READ(CTopKeyevent); - w=RING_WRITE(CTopKeyevent); + r = RING_READ(CTopKeyevent); + w = RING_WRITE(CTopKeyevent); - if(r==w) goto KBnext; /* event queue FULL */ + if (r == w) goto KBnext; /* event queue FULL */ - kbevent=(KBEVENT*)(CTopKeyevent+ w); + kbevent = (KBEVENT *)(CTopKeyevent + w); -/* RCLK(kbevent->time); */ + /* RCLK(kbevent->time); */ - kbevent->W0= (*EmKbdAd068K); /* Emxxxx do not use GETWORD */ - kbevent->W1= (*EmKbdAd168K); - kbevent->W2= (*EmKbdAd268K); - kbevent->W3= (*EmKbdAd368K); - kbevent->W4= (*EmKbdAd468K); - kbevent->W5= (*EmKbdAd568K); - kbevent->WU= (*EmRealUtilin68K); + kbevent->W0 = (*EmKbdAd068K); /* Emxxxx do not use GETWORD */ + kbevent->W1 = (*EmKbdAd168K); + kbevent->W2 = (*EmKbdAd268K); + kbevent->W3 = (*EmKbdAd368K); + kbevent->W4 = (*EmKbdAd468K); + kbevent->W5 = (*EmKbdAd568K); + kbevent->WU = (*EmRealUtilin68K); - if(r==0) /* Queue was empty */ ((RING*)CTopKeyevent)->read=w; - if(w >= MAXKEYEVENT) ((RING*)CTopKeyevent)->write = MINKEYEVENT; - else ((RING*)CTopKeyevent)->write = w + KEYEVENTSIZE; + if (r == 0) /* Queue was empty */ + ((RING *)CTopKeyevent)->read = w; + if (w >= MAXKEYEVENT) + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + else + ((RING *)CTopKeyevent)->write = w + KEYEVENTSIZE; - KBnext: - if(*KEYBUFFERING68k == NIL) *KEYBUFFERING68k=ATOM_T; + KBnext: + if (*KEYBUFFERING68k == NIL) *KEYBUFFERING68k = ATOM_T; - } /* if *EmRealUtilin68K end */ - return(1); - } + } /* if *EmRealUtilin68K end */ + return (1); +} #endif /* neither XWINDOW nor DOS*/ - - - /************************************************************************/ /* */ /* k b _ t r a n s */ @@ -591,288 +542,276 @@ register struct inputevent *event; /* */ /************************************************************************/ -void kb_trans( keycode, upflg ) - u_short keycode; - u_short upflg; +void kb_trans(keycode, upflg) u_short keycode; +u_short upflg; +{ + extern IFPAGE *InterfacePage; + if (keycode < 64) /* DLKBDAD0 ~ 3 */ { - extern IFPAGE *InterfacePage; - if( keycode < 64 ) /* DLKBDAD0 ~ 3 */ - { PUTBASEBIT68K( EmKbdAd068K, keycode, upflg );} - else if( keycode >= 80 )/* DLKBDAD4, 5 */ - { PUTBASEBIT68K( EmKbdAd068K, keycode - 16, upflg );} - else if( keycode >= 64 && keycode < 80 )/* DLUTILIN */ - { - PUTBASEBIT68K( EmRealUtilin68K, (keycode & 15), upflg ); - PUTBASEBIT68K( EmUtilin68K, (keycode & 15), upflg ); - } + PUTBASEBIT68K(EmKbdAd068K, keycode, upflg); + } else if (keycode >= 80) /* DLKBDAD4, 5 */ + { + PUTBASEBIT68K(EmKbdAd068K, keycode - 16, upflg); + } else if (keycode >= 64 && keycode < 80) /* DLUTILIN */ + { + PUTBASEBIT68K(EmRealUtilin68K, (keycode & 15), upflg); + PUTBASEBIT68K(EmUtilin68K, (keycode & 15), upflg); + } } - - - /**********************************************************/ -/* - MOUSE tracking +/* + MOUSE tracking */ /**********************************************************/ +typedef struct { + LispPTR CUIMAGE; + LispPTR CUMASK; + LispPTR CUHOTSPOTX; + LispPTR CUHOTSPOTY; + LispPTR CUDATA; +} CURSOR; -typedef struct - { - LispPTR CUIMAGE; - LispPTR CUMASK; - LispPTR CUHOTSPOTX; - LispPTR CUHOTSPOTY; - LispPTR CUDATA; - } CURSOR ; - -#define DLWORD_PERLINE (displaywidth/16) +#define DLWORD_PERLINE (displaywidth / 16) #define HARD_CURSORWIDTH 16 #define HARD_CURSORHEIGHT 16 #define COLOR_BITSPER_PIXEL 8 /* For MonoOrColor */ #define MONO_SCREEN 0 #define COLOR_SCREEN 1 -#define CursorClippingX(posx,width) { \ - if( displaywidth < (posx + HARD_CURSORWIDTH)) { \ - LastCursorClippingX=width=displaywidth-posx;} \ - else { LastCursorClippingX=width=HARD_CURSORWIDTH;}} +#define CursorClippingX(posx, width) \ + { \ + if (displaywidth < (posx + HARD_CURSORWIDTH)) { \ + LastCursorClippingX = width = displaywidth - posx; \ + } else { \ + LastCursorClippingX = width = HARD_CURSORWIDTH; \ + } \ + } -#define CursorClippingY(posy,height){ \ - if(displayheight < (posy + HARD_CURSORHEIGHT)) { \ - LastCursorClippingY = height = displayheight - posy;} \ - else { LastCursorClippingY = height = HARD_CURSORHEIGHT;}} +#define CursorClippingY(posy, height) \ + { \ + if (displayheight < (posy + HARD_CURSORHEIGHT)) { \ + LastCursorClippingY = height = displayheight - posy; \ + } else { \ + LastCursorClippingY = height = HARD_CURSORHEIGHT; \ + } \ + } extern int displaywidth, displayheight; -extern int DisplayInitialized ; +extern int DisplayInitialized; extern int MonoOrColor; /* MONO_SCREEN or COLOR_SCREEN */ -int LastCursorClippingX=HARD_CURSORWIDTH; +int LastCursorClippingX = HARD_CURSORWIDTH; int LastCursorClippingY = HARD_CURSORHEIGHT; -int LastCursorX=0; -int LastCursorY=0; +int LastCursorX = 0; +int LastCursorY = 0; void cursor_hidden_bitmap(int, int); #ifndef COLOR /* FOR MONO ONLY */ -void taking_mouse_down() - { - register DLword *srcbase, *dstbase; - static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; +void taking_mouse_down() { + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; #ifdef DOS - (currentdsp->mouse_invissible)(currentdsp, IOPage68K); + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); #else - if(!DisplayInitialized) return; + if (!DisplayInitialized) return; - /* restore saved image */ - srcbase=MonoCursor_savebitmap; - dstbase=DisplayRegion68k +( (LastCursorY) * DLWORD_PERLINE); /* old y */ - sx=0; - dx = LastCursorX; /* old x */ - w = LastCursorClippingX; /* Old clipping */ - h= LastCursorClippingY; - srcbpl =HARD_CURSORWIDTH; - dstbpl =displaywidth; - op=0; - new_bitblt_code; + /* restore saved image */ + srcbase = MonoCursor_savebitmap; + dstbase = DisplayRegion68k + ((LastCursorY)*DLWORD_PERLINE); /* old y */ + sx = 0; + dx = LastCursorX; /* old x */ + w = LastCursorClippingX; /* Old clipping */ + h = LastCursorClippingY; + srcbpl = HARD_CURSORWIDTH; + dstbpl = displaywidth; + op = 0; + new_bitblt_code; #ifdef DISPLAYBUFFER - flush_display_region(dx, (LastCursorY), w, h); + flush_display_region(dx, (LastCursorY), w, h); #endif /* DISPLAYBUFFER */ #endif /* DOS */ - } +} #else - /* For COLOR & MONO */ +/* For COLOR & MONO */ extern DLword *ColorDisplayRegion68k; - /* It assumes that MONO screen size and COLOR screen size are identical */ -void taking_mouse_down() - { - register DLword *srcbase, *dstbase; - static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; +/* It assumes that MONO screen size and COLOR screen size are identical */ +void taking_mouse_down() { + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; - if(!DisplayInitialized) return; - /* restore saved image */ - sx=0; + if (!DisplayInitialized) return; + /* restore saved image */ + sx = 0; - if(MonoOrColor == MONO_SCREEN) - { - dx = LastCursorX; /* old x */ - srcbase=MonoCursor_savebitmap; - dstbase=DisplayRegion68k +( (LastCursorY) * DLWORD_PERLINE); /* old y */ - w = LastCursorClippingX; /* Old clipping */ - h= LastCursorClippingY; - srcbpl =HARD_CURSORWIDTH; - dstbpl =displaywidth; - } - else - { - dx = LastCursorX * COLOR_BITSPER_PIXEL; /* old x */ - srcbase=ColorCursor_savebitmap; - dstbase= ColorDisplayRegion68k + - ((LastCursorY) * DLWORD_PERLINE * COLOR_BITSPER_PIXEL); /* old y */ - w = LastCursorClippingX * COLOR_BITSPER_PIXEL; /* Old clipping */ - h= LastCursorClippingY; - srcbpl =HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL; - dstbpl =displaywidth * COLOR_BITSPER_PIXEL ; - } - op=0; - new_bitblt_code; + if (MonoOrColor == MONO_SCREEN) { + dx = LastCursorX; /* old x */ + srcbase = MonoCursor_savebitmap; + dstbase = DisplayRegion68k + ((LastCursorY)*DLWORD_PERLINE); /* old y */ + w = LastCursorClippingX; /* Old clipping */ + h = LastCursorClippingY; + srcbpl = HARD_CURSORWIDTH; + dstbpl = displaywidth; + } else { + dx = LastCursorX * COLOR_BITSPER_PIXEL; /* old x */ + srcbase = ColorCursor_savebitmap; + dstbase = + ColorDisplayRegion68k + ((LastCursorY)*DLWORD_PERLINE * COLOR_BITSPER_PIXEL); /* old y */ + w = LastCursorClippingX * COLOR_BITSPER_PIXEL; /* Old clipping */ + h = LastCursorClippingY; + srcbpl = HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL; + dstbpl = displaywidth * COLOR_BITSPER_PIXEL; + } + op = 0; + new_bitblt_code; #ifdef DISPLAYBUFFER - if( MonoOrColor == MONO_SCREEN ) - flush_display_region(dx, LastCursorY, w, h); + if (MonoOrColor == MONO_SCREEN) flush_display_region(dx, LastCursorY, w, h); #endif } #endif /* COLOR */ - -/* LastCursorClippingX must be set brfore calling +/* LastCursorClippingX must be set brfore calling To avoid duplicate caluculation */ #ifndef COLOR /* FOR MONO ONLY */ -void copy_cursor(newx,newy) - int newx,newy; - { - register DLword *srcbase, *dstbase; - register int offsetx,offsety; - static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; - extern DLword *EmCursorBitMap68K; - /* copy cursor image */ - srcbase = EmCursorBitMap68K; - dstbase= DisplayRegion68k +(newy * DLWORD_PERLINE) ; - sx=0; - dx=newx; - w=LastCursorClippingX; - h=LastCursorClippingY;; - srcbpl=HARD_CURSORWIDTH; - dstbpl=displaywidth; - op=2; /* OR-in */ - new_bitblt_code; +void copy_cursor(newx, newy) int newx, newy; +{ + register DLword *srcbase, *dstbase; + register int offsetx, offsety; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; + extern DLword *EmCursorBitMap68K; + /* copy cursor image */ + srcbase = EmCursorBitMap68K; + dstbase = DisplayRegion68k + (newy * DLWORD_PERLINE); + sx = 0; + dx = newx; + w = LastCursorClippingX; + h = LastCursorClippingY; + ; + srcbpl = HARD_CURSORWIDTH; + dstbpl = displaywidth; + op = 2; /* OR-in */ + new_bitblt_code; #ifdef DISPLAYBUFFER - flush_display_region(dx, newy, w, h); + flush_display_region(dx, newy, w, h); #endif - } +} /* store bitmap image inside rect. which specified by x,y */ -void cursor_hidden_bitmap(x,y) - int x,y; - { - register DLword *srcbase, *dstbase; - static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; - /* save image */ - srcbase=DisplayRegion68k +( y* DLWORD_PERLINE) ; - dstbase=MonoCursor_savebitmap; - sx=x; - dx=0; - CursorClippingX(x,w); /* w and LastCursorClippingX rest */ - CursorClippingY(y,h); /* h and LastCursorClippingY reset */ - srcbpl =displaywidth; - dstbpl=HARD_CURSORWIDTH; - op= 0; /* replace */ - new_bitblt_code; - } +void cursor_hidden_bitmap(x, y) int x, y; +{ + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; + /* save image */ + srcbase = DisplayRegion68k + (y * DLWORD_PERLINE); + dstbase = MonoCursor_savebitmap; + sx = x; + dx = 0; + CursorClippingX(x, w); /* w and LastCursorClippingX rest */ + CursorClippingY(y, h); /* h and LastCursorClippingY reset */ + srcbpl = displaywidth; + dstbpl = HARD_CURSORWIDTH; + op = 0; /* replace */ + new_bitblt_code; +} #else /* For COLOR & MONO */ -#define IMIN(x,y) (((x) > (y)) ? (y) : (x)) -void copy_cursor(newx,newy) - int newx,newy; - { - register DLword *srcbase, *dstbase; - register int offsetx,offsety; - static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; - static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; - CURSOR *cursor68k; - BITMAP *bitmap68k; - extern DLword *EmCursorBitMap68K; - /* copy cursor image */ - if(MonoOrColor == MONO_SCREEN) - { - srcbase = EmCursorBitMap68K; - dstbase= DisplayRegion68k +(newy * DLWORD_PERLINE) ; - sx=0; - dx=newx; - w=LastCursorClippingX; - h=LastCursorClippingY;; - srcbpl=HARD_CURSORWIDTH; - dstbpl=displaywidth; - } - else - { - cursor68k = (CURSOR*)Addr68k_from_LADDR(*CURRENTCURSOR68k); - bitmap68k=(BITMAP*)Addr68k_from_LADDR(cursor68k->CUIMAGE); - srcbase =(DLword*) Addr68k_from_LADDR(bitmap68k->bmbase); - dstbase= ColorDisplayRegion68k +(newy * DLWORD_PERLINE * COLOR_BITSPER_PIXEL) ; - sx=0; - dx=newx * COLOR_BITSPER_PIXEL; - w=IMIN(LastCursorClippingX,LOLOC(bitmap68k->bmwidth)) * COLOR_BITSPER_PIXEL; - h=IMIN(LastCursorClippingY,LOLOC(bitmap68k->bmheight)); - /* srcbpl=HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL;*/ - srcbpl = bitmap68k->bmwidth * COLOR_BITSPER_PIXEL; - dstbpl=displaywidth * COLOR_BITSPER_PIXEL; - } - op=2; /* OR-in */ - new_bitblt_code; -#ifdef DISPLAYBUFFER - if( MonoOrColor == MONO_SCREEN ) - flush_display_region(dx, newy, w, h); -#endif +#define IMIN(x, y) (((x) > (y)) ? (y) : (x)) +void copy_cursor(newx, newy) int newx, newy; +{ + register DLword *srcbase, *dstbase; + register int offsetx, offsety; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; + CURSOR *cursor68k; + BITMAP *bitmap68k; + extern DLword *EmCursorBitMap68K; + /* copy cursor image */ + if (MonoOrColor == MONO_SCREEN) { + srcbase = EmCursorBitMap68K; + dstbase = DisplayRegion68k + (newy * DLWORD_PERLINE); + sx = 0; + dx = newx; + w = LastCursorClippingX; + h = LastCursorClippingY; + ; + srcbpl = HARD_CURSORWIDTH; + dstbpl = displaywidth; + } else { + cursor68k = (CURSOR *)Addr68k_from_LADDR(*CURRENTCURSOR68k); + bitmap68k = (BITMAP *)Addr68k_from_LADDR(cursor68k->CUIMAGE); + srcbase = (DLword *)Addr68k_from_LADDR(bitmap68k->bmbase); + dstbase = ColorDisplayRegion68k + (newy * DLWORD_PERLINE * COLOR_BITSPER_PIXEL); + sx = 0; + dx = newx * COLOR_BITSPER_PIXEL; + w = IMIN(LastCursorClippingX, LOLOC(bitmap68k->bmwidth)) * COLOR_BITSPER_PIXEL; + h = IMIN(LastCursorClippingY, LOLOC(bitmap68k->bmheight)); + /* srcbpl=HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL;*/ + srcbpl = bitmap68k->bmwidth * COLOR_BITSPER_PIXEL; + dstbpl = displaywidth * COLOR_BITSPER_PIXEL; } + op = 2; /* OR-in */ + new_bitblt_code; +#ifdef DISPLAYBUFFER + if (MonoOrColor == MONO_SCREEN) flush_display_region(dx, newy, w, h); +#endif +} /* I'll make it MACRO */ -void taking_mouse_up(newx,newy) - int newx,newy; - { +void taking_mouse_up(newx, newy) int newx, newy; +{ #ifdef DOS - (currentdsp->mouse_vissible)(newx, newy); + (currentdsp->mouse_vissible)(newx, newy); #else - if(!DisplayInitialized) return; - /* save hidden bitmap */ - cursor_hidden_bitmap(newx,newy); - /* Copy Cursor Image */ + if (!DisplayInitialized) return; + /* save hidden bitmap */ + cursor_hidden_bitmap(newx, newy); +/* Copy Cursor Image */ #ifndef INIT - copy_cursor(newx,newy); -#endif - LastCursorX=newx; - LastCursorY=newy; + copy_cursor(newx, newy); #endif - } + LastCursorX = newx; + LastCursorY = newy; +#endif +} /* store bitmap image inside rect. which specified by x,y */ -void cursor_hidden_bitmap(x,y) -int x,y; +void cursor_hidden_bitmap(x, y) int x, y; { -register DLword *srcbase, *dstbase; -static int sx, dx, w, h, srcbpl, dstbpl, backwardflg=0; -static int src_comp=0, op=0, gray=0, num_gray=0, curr_gray_line=0; -/* save image */ -if(MonoOrColor == MONO_SCREEN) { - srcbase=DisplayRegion68k +( y* DLWORD_PERLINE) ; - dstbase=MonoCursor_savebitmap; - sx=x; - dx=0; - CursorClippingX(x,w); /* w and LastCursorClippingX rest */ - CursorClippingY(y,h); /* h and LastCursorClippingY reset */ - srcbpl =displaywidth; - dstbpl=HARD_CURSORWIDTH; -} -else { - srcbase=ColorDisplayRegion68k +(y * DLWORD_PERLINE * COLOR_BITSPER_PIXEL); - dstbase= ColorCursor_savebitmap; - sx=x * COLOR_BITSPER_PIXEL ; - dx=0; - CursorClippingX(x,w); /* w and LastCursorClippingX rest */ - CursorClippingY(y,h); /* h and LastCursorClippingY reset */ - w = w * COLOR_BITSPER_PIXEL; - srcbpl =displaywidth * COLOR_BITSPER_PIXEL ; - dstbpl=HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL; -} -op= 0; /* replace */ -new_bitblt_code; + register DLword *srcbase, *dstbase; + static int sx, dx, w, h, srcbpl, dstbpl, backwardflg = 0; + static int src_comp = 0, op = 0, gray = 0, num_gray = 0, curr_gray_line = 0; + /* save image */ + if (MonoOrColor == MONO_SCREEN) { + srcbase = DisplayRegion68k + (y * DLWORD_PERLINE); + dstbase = MonoCursor_savebitmap; + sx = x; + dx = 0; + CursorClippingX(x, w); /* w and LastCursorClippingX rest */ + CursorClippingY(y, h); /* h and LastCursorClippingY reset */ + srcbpl = displaywidth; + dstbpl = HARD_CURSORWIDTH; + } else { + srcbase = ColorDisplayRegion68k + (y * DLWORD_PERLINE * COLOR_BITSPER_PIXEL); + dstbase = ColorCursor_savebitmap; + sx = x * COLOR_BITSPER_PIXEL; + dx = 0; + CursorClippingX(x, w); /* w and LastCursorClippingX rest */ + CursorClippingY(y, h); /* h and LastCursorClippingY reset */ + w = w * COLOR_BITSPER_PIXEL; + srcbpl = displaywidth * COLOR_BITSPER_PIXEL; + dstbpl = HARD_CURSORWIDTH * COLOR_BITSPER_PIXEL; + } + op = 0; /* replace */ + new_bitblt_code; } #endif /* COLOR */ - diff --git a/src/keylib.c b/src/keylib.c old mode 100755 new mode 100644 index 22cf5c9..d30175f --- a/src/keylib.c +++ b/src/keylib.c @@ -1,9 +1,7 @@ -/* $Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-1999 Venue. All Rights Reserved. */ @@ -18,234 +16,185 @@ static char *id = "$Id: keylib.c,v 1.4 2001/12/24 01:09:03 sybalsky Exp $ Copyri #include "version.h" - /* ============================================================================== - The functions defined in this file were called by KEYMAKER.C & KEYTESTER.C - - Creation Date: May, 1988 + The functions defined in this file were called by KEYMAKER.C & KEYTESTER.C + + Creation Date: May, 1988 ============================================================================== */ #include #include #include - -#define GOLDEN_RATIO_HACK -478700649 -#define ULONG_MAX 4294967295 +#define GOLDEN_RATIO_HACK -478700649 +#define ULONG_MAX 4294967295 /* meaning of symbolic constant used: - FAILURE2 invalid date */ + FAILURE2 invalid date */ -#define FAILURE2 -2 +#define FAILURE2 -2 unsigned long make_verification(long unsigned int x, long unsigned int y); unsigned long date_integer16(const char *date); unsigned long idate(const char *str); unsigned long modify(long unsigned int hostid); - /* =========================================================================== - MAKE_VERIFICATION forms a new 32-bit integer by messaging the two input - long integers x and y. The number was created from the lower bits toward - higher bits. + MAKE_VERIFICATION forms a new 32-bit integer by messaging the two input + long integers x and y. The number was created from the lower bits toward + higher bits. =============================================================================*/ -unsigned long make_verification (long unsigned int x, long unsigned int y) -{ - return (imod64bit(x , y , 4) | - (imod64bit(x , y , 6) << 3) | - (imod64bit(x , y , 13) << 6) | - (imod64bit(x , y , 25) << 10) | - (imod64bit(x , y , 30) << 15) | - (imod64bit(x , y , 63) << 20) | - (imod64bit(x , y , 5) << 26) | - (imod64bit(x , y , 7) << 29) ); - } - +unsigned long make_verification(long unsigned int x, long unsigned int y) { + return (imod64bit(x, y, 4) | (imod64bit(x, y, 6) << 3) | (imod64bit(x, y, 13) << 6) | + (imod64bit(x, y, 25) << 10) | (imod64bit(x, y, 30) << 15) | (imod64bit(x, y, 63) << 20) | + (imod64bit(x, y, 5) << 26) | (imod64bit(x, y, 7) << 29)); +} /* =========================================================================== - IMOD64BIT computs (IMOD X Y). - X is a 64-bit integer; x1 is the higher 32-bit while x0 is the lower 32-bit. - Y is less than 65535. - (((ULONG_MAX % y) + 1 ) % y) is equivalent to (expt 2 32) % y + IMOD64BIT computs (IMOD X Y). + X is a 64-bit integer; x1 is the higher 32-bit while x0 is the lower 32-bit. + Y is less than 65535. + (((ULONG_MAX % y) + 1 ) % y) is equivalent to (expt 2 32) % y =============================================================================*/ - -int imod64bit (long unsigned int x1, long unsigned int x0, long unsigned int y) -{ -/* JDS 990601 ansi return (((x0 % y) + ((x1 % y) * (((ULONG_MAX % y) + 1 ) % y) )) % y); */ - return (((x0 % y) + ((x1 % y) * ((y + 1 ) % y) )) % y); +int imod64bit(long unsigned int x1, long unsigned int x0, long unsigned int y) { + /* JDS 990601 ansi return (((x0 % y) + ((x1 % y) * (((ULONG_MAX % y) + 1 ) % y) )) % y); */ + return (((x0 % y) + ((x1 % y) * ((y + 1) % y))) % y); } /* ============================================================ - DATE_INTEGER16 takes a date string and return an intger + DATE_INTEGER16 takes a date string and return an intger =============================================================*/ -unsigned long date_integer16 (const char *date) -{ - unsigned long const1 , const2; +unsigned long date_integer16(const char *date) { + unsigned long const1, const2; - const1 = 17152 ; - const2 = 86400 ; - return ((idate(date) - const1 ) / const2); + const1 = 17152; + const2 = 86400; + return ((idate(date) - const1) / const2); } - /* =================================================================== - IDATE takes a date string (dd-mmm-yy or dd mmm yy) and return an - integer. - dd - date in decimal digits - mmm - month name in alphabetic form or decimal digits - yy - year in decimal digits ; can be 2 or 4 digits - If date1 is before date2 then (idate date1) < (idate date2). - If date string is not valid, FAILURE2 is returned. + IDATE takes a date string (dd-mmm-yy or dd mmm yy) and return an + integer. + dd - date in decimal digits + mmm - month name in alphabetic form or decimal digits + yy - year in decimal digits ; can be 2 or 4 digits + If date1 is before date2 then (idate date1) < (idate date2). + If date string is not valid, FAILURE2 is returned. =====================================================================*/ -unsigned long idate(const char *str) -{ - char ds[50]; - char *decdigits = {"0123456789"}; - char *tokendelimiters = {" -"}; - char *yptr, *mptr, *dptr, *ptr1; +unsigned long idate(const char *str) { + char ds[50]; + char *decdigits = {"0123456789"}; + char *tokendelimiters = {" -"}; + char *yptr, *mptr, *dptr, *ptr1; - int day, month, year, maxday; - int i, len ,s; - unsigned long days_since_day0, sec, hour; + int day, month, year, maxday; + int i, len, s; + unsigned long days_since_day0, sec, hour; - static char *month_name[13] = {"", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", - "SEP", "OCT", "NOV", "DEC"}; + static char *month_name[13] = {"", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", + "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; - static int days_each_month[13] = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - static int days_since_jan1st[12] = {0,31,59,90,120,151,181,212,243,273,304,334} ; + static int days_each_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + static int days_since_jan1st[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; - /* copy input string to a local one */ - ds[0] = '\0'; - strcpy(ds,str); + /* copy input string to a local one */ + ds[0] = '\0'; + strcpy(ds, str); - /* get day, month, and year string tokens */ - if ((dptr = strtok(ds, tokendelimiters)) == NULL) return FAILURE2; - if ((mptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2; - if ((yptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2; + /* get day, month, and year string tokens */ + if ((dptr = strtok(ds, tokendelimiters)) == NULL) return FAILURE2; + if ((mptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2; + if ((yptr = strtok(NULL, tokendelimiters)) == NULL) return FAILURE2; + /* validate year and convert it to numeric form 19xx */ + if (strspn(yptr, decdigits) != strlen(yptr)) return FAILURE2; + if ((year = atoi(yptr)) <= 100) year += 1900; + if (year < 1970 || year > 2050) return FAILURE2; - /* validate year and convert it to numeric form 19xx */ - if (strspn (yptr, decdigits) != strlen(yptr)) return FAILURE2; - if ((year = atoi(yptr)) <= 100) year += 1900; - if (year < 1970 || year > 2050) return FAILURE2; + /* validate month and convert it to numeric form if necessary */ + if (strspn(mptr, decdigits) == (len = (strlen(mptr)))) { + /* input month is in numeric form */ + if ((month = atoi(mptr)) < 1 || month > 12) return FAILURE2; + } else { + /* input month is in alphabetic form */ + /* we're only interested in the first 3 chars */ + if (len > 3) *(mptr + 3) = '\0'; - /* validate month and convert it to numeric form if necessary */ - if (strspn (mptr,decdigits) == (len = (strlen(mptr)))) - { - /* input month is in numeric form */ - if ((month = atoi(mptr)) < 1 || month > 12) return FAILURE2; - } - else - { - /* input month is in alphabetic form */ + ptr1 = mptr; - /* we're only interested in the first 3 chars */ - if (len > 3) *(mptr+3) = '\0'; + /* make sure month name is in upper case letters */ + for (i = 0; (s = *(ptr1 + i)) != '\0'; ++i) + if (islower(s)) *(ptr1 + i) = toupper(s); - ptr1 = mptr; + /* find out its corresponding numeric value */ + for (i = 1; i <= 12; ++i) + if (strcmp(*(month_name + i), mptr) == 0) { + month = i; + break; + }; + if (i == 13) return FAILURE2; + }; - - /* make sure month name is in upper case letters */ - for (i = 0 ; (s = *(ptr1+i)) != '\0' ; ++i) - if (islower(s)) *(ptr1+i) = toupper(s); + /* set up maxday to be the number of days of that month */ + maxday = days_each_month[month]; + /* watch out for leap year */ + if (month == 2 && (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) ++maxday; - /* find out its corresponding numeric value */ - for (i = 1 ; i <= 12 ; ++i) - if ( strcmp(*(month_name+i), mptr) == 0) - { month = i ; - break; - }; - if (i == 13) return FAILURE2; - }; + /* validate day */ + if (strspn(dptr, decdigits) != strlen(dptr) || (day = atoi(dptr)) < 1 || maxday < day) + return FAILURE2; - /* set up maxday to be the number of days of that month */ - maxday = days_each_month[month]; - - /* watch out for leap year */ - if (month == 2 && (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) ++maxday; + year -= 1901; + --month; + days_since_day0 = days_since_jan1st[month] + (day - 1) + (365 * year) + (year / 4); + if (month > 1 && year % 4 == 3 && year != -1) ++days_since_day0; - /* validate day */ - if ( strspn(dptr,decdigits) != strlen(dptr) || (day = atoi(dptr)) < 1 || maxday < day) - return FAILURE2; - - - year -= 1901; --month; - days_since_day0 = days_since_jan1st[month] + (day - 1) + (365 * year) + (year / 4); - - if (month > 1 && year % 4 == 3 && year != -1) ++days_since_day0; - - - hour = (24 * days_since_day0) + 7; -/* JDS 990601 ANSI cleanup sec = (60 * (60 * hour)) ^ -2147483648L ; */ - sec = (60 * (60 * hour)) ^ 0x80000000 ; - /* printf("\n days_since_day0: %ld hour: %ld sec: %ld\n", days_since_day0 , hour ,sec); */ - return sec; - } - - -/* ============================================================ - MODIFY turns on/off certain bits of the passed - in 32-bit hostid, depending on the value of (hostid % 16). - =============================================================*/ - -unsigned long modify (long unsigned int hostid) -{ - unsigned long dividor; - -#ifdef xBIGVM - hostid ^= 0xa3f5069e; -#endif /* xBIGVM */ - - dividor = 16; - switch (hostid % dividor) - { - case 0: hostid = hostid | 0x48004802; - break; - case 1: hostid = hostid ^ 0xfedc5793; - break; - case 2: hostid = hostid ^ 0x9981afe3; - break; - case 3: hostid = hostid & 0xffcb6ffd; - break; - case 4: hostid = hostid ^ 0x3489dfa8; - break; - case 5: hostid = hostid | 0x77012877; - break; - case 6: hostid = hostid & 0xefc9fffd; - break; - case 7: hostid = hostid | 0x22311300; - break; - case 8: hostid = hostid & 0xdadf8871; - break; - case 9: hostid = hostid ^ 0xe8c948ad; - break; - case 10: hostid = hostid | 0x12488412; - break; - case 11: hostid = hostid & 0xeffdea87; - break; - case 12: hostid = hostid ^ 0xad8ce639; - break; - case 13: hostid = hostid | 0x88221144; - break; - case 14: hostid = hostid & 0xfffb6edd; - break; - default: hostid = hostid ^ 0xfffddeee; - break; - }; - /* printf("\n ** new host id: result: %x ", hostid); */ - return hostid; + hour = (24 * days_since_day0) + 7; + /* JDS 990601 ANSI cleanup sec = (60 * (60 * hour)) ^ -2147483648L ; */ + sec = (60 * (60 * hour)) ^ 0x80000000; + /* printf("\n days_since_day0: %ld hour: %ld sec: %ld\n", days_since_day0 , hour ,sec); */ + return sec; } +/* ============================================================ + MODIFY turns on/off certain bits of the passed + in 32-bit hostid, depending on the value of (hostid % 16). + =============================================================*/ +unsigned long modify(long unsigned int hostid) { + unsigned long dividor; +#ifdef xBIGVM + hostid ^= 0xa3f5069e; +#endif /* xBIGVM */ - - + dividor = 16; + switch (hostid % dividor) { + case 0: hostid = hostid | 0x48004802; break; + case 1: hostid = hostid ^ 0xfedc5793; break; + case 2: hostid = hostid ^ 0x9981afe3; break; + case 3: hostid = hostid & 0xffcb6ffd; break; + case 4: hostid = hostid ^ 0x3489dfa8; break; + case 5: hostid = hostid | 0x77012877; break; + case 6: hostid = hostid & 0xefc9fffd; break; + case 7: hostid = hostid | 0x22311300; break; + case 8: hostid = hostid & 0xdadf8871; break; + case 9: hostid = hostid ^ 0xe8c948ad; break; + case 10: hostid = hostid | 0x12488412; break; + case 11: hostid = hostid & 0xeffdea87; break; + case 12: hostid = hostid ^ 0xad8ce639; break; + case 13: hostid = hostid | 0x88221144; break; + case 14: hostid = hostid & 0xfffb6edd; break; + default: hostid = hostid ^ 0xfffddeee; break; + }; + /* printf("\n ** new host id: result: %x ", hostid); */ + return hostid; +} diff --git a/src/keymaker.c b/src/keymaker.c old mode 100755 new mode 100644 index 0e047cb..11e6c72 --- a/src/keymaker.c +++ b/src/keymaker.c @@ -1,7 +1,7 @@ -/* $Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-98 Venue. All Rights Reserved. */ @@ -16,18 +16,14 @@ static char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copy #include "version.h" - - - - /* ===================================================================== - This function is used to generate copyright protection keys for - enue's Medley software. It prompts for a machine's host id and - the software's expiration date before generating a set of 3 keys. + This function is used to generate copyright protection keys for + enue's Medley software. It prompts for a machine's host id and + the software's expiration date before generating a set of 3 keys. - The external functions called were stored in file 'keylib.o'. + The external functions called were stored in file 'keylib.o'. - Creation Date: May, 1988 + Creation Date: May, 1988 ===================================================================== */ #include @@ -35,30 +31,27 @@ static char *id = "$Id: keymaker.c,v 1.3 1999/05/31 23:35:35 sybalsky Exp $ Copy #include #include -#define GOLDEN_RATIO_HACK -478700649 -#define floadbyte(number,pos) ((number >> pos) & 0xFFFF) -#define hash_unhash(number,hashkey) (number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey,16) + floadbyte(hashkey,0)) )) -#define KEYNUMBERS 3 - +#define GOLDEN_RATIO_HACK -478700649 +#define floadbyte(number, pos) ((number >> pos) & 0xFFFF) +#define hash_unhash(number, hashkey) \ + (number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey, 16) + floadbyte(hashkey, 0)))) +#define KEYNUMBERS 3 /* meaning of symbolic constants used: - FAILURE1 invalid hostid - FAILURE2 invalid date entered from terminal - FAILURE3 can't open logfile in the command line */ - -#define FAILURE1 -1 -#define FAILURE2 -2 -#define FAILURE3 -3 + FAILURE1 invalid hostid + FAILURE2 invalid date entered from terminal + FAILURE3 can't open logfile in the command line */ +#define FAILURE1 -1 +#define FAILURE2 -2 +#define FAILURE3 -3 unsigned long make_verification(long unsigned int x, long unsigned int y); unsigned long date_integer16(char *date); unsigned long idate(char *str); unsigned long modify(long unsigned int hostid); - - /************************************************************************/ /* */ /* w r i t e r e s u l t s */ @@ -67,14 +60,11 @@ unsigned long modify(long unsigned int hostid); /* */ /************************************************************************/ -void writeresults(FILE *fp, char *host, char *expdate, int key1, int key2, int key3, char *info) -{ - fprintf(fp, "Host ID: %-14s Expiration: %-9s",host, expdate); - fprintf(fp, " Key: %8x %8x %8x", key1, key2, key3); - fprintf(fp, " Doc: %s\n", info); - } - - +void writeresults(FILE *fp, char *host, char *expdate, int key1, int key2, int key3, char *info) { + fprintf(fp, "Host ID: %-14s Expiration: %-9s", host, expdate); + fprintf(fp, " Key: %8x %8x %8x", key1, key2, key3); + fprintf(fp, " Doc: %s\n", info); +} /************************************************************************/ /* */ @@ -84,170 +74,143 @@ void writeresults(FILE *fp, char *host, char *expdate, int key1, int key2, int k /* */ /************************************************************************/ -int main(int argc, char **argv) -{ - int logfile = 0; /* set to 1 if logfile on command line */ - FILE *fp; /* file pointer for the logfile */ - unsigned long hostid; - long keyarray[KEYNUMBERS]; - char *hexdigits = {"-0123456789abcdefABCDEF"}; - char s[50], hstr[50], expdate[30], saveexpdate[30], cc; - char infostring[500]; - char *sptr, *ptr, *digitstring; - char *hptr = {" "}; - char **hhptr = &hptr; - int base = 10; - int i,j,c; - int commandlineargs; +int main(int argc, char **argv) { + int logfile = 0; /* set to 1 if logfile on command line */ + FILE *fp; /* file pointer for the logfile */ + unsigned long hostid; + long keyarray[KEYNUMBERS]; + char *hexdigits = {"-0123456789abcdefABCDEF"}; + char s[50], hstr[50], expdate[30], saveexpdate[30], cc; + char infostring[500]; + char *sptr, *ptr, *digitstring; + char *hptr = {" "}; + char **hhptr = &hptr; + int base = 10; + int i, j, c; + int commandlineargs; - commandlineargs = (argc > 2); - /* If we have more than one argv we assume this is used as a filter */ + commandlineargs = (argc > 2); + /* If we have more than one argv we assume this is used as a filter */ - /* == check if user enters logfile name in the command line == */ + /* == check if user enters logfile name in the command line == */ - if ((argc > 1) & !commandlineargs) - { - if ((fp = fopen(*++argv,"a")) == NULL) - { - printf("\n Can't open %s \n", *argv); - exit(FAILURE3); - }; - logfile = 1; - }; + if ((argc > 1) & !commandlineargs) { + if ((fp = fopen(*++argv, "a")) == NULL) { + printf("\n Can't open %s \n", *argv); + exit(FAILURE3); + }; + logfile = 1; + }; - /* == prompt for machine's host id, verify, then do some modification == */ + /* == prompt for machine's host id, verify, then do some modification == */ - if (commandlineargs) - { - /* assume that the second argument is hex-hostid */ - sptr = *++argv; - hostid = strtol(sptr,hhptr,16); + if (commandlineargs) { + /* assume that the second argument is hex-hostid */ + sptr = *++argv; + hostid = strtol(sptr, hhptr, 16); - } - else - { - printf("\n\nEnter Host ID (starts with 0x if the number is hexidecimal): "); - gets(s); - sptr = strtok(s," "); + } else { + printf("\n\nEnter Host ID (starts with 0x if the number is hexidecimal): "); + gets(s); + sptr = strtok(s, " "); + + /* decide the base */ + if (((ptr = strchr(sptr, '0')) != NULL) && (*(ptr + 1) == 'x' || *(ptr + 1) == 'X')) base = 16; - /* decide the base */ - if (((ptr = strchr(sptr,'0')) != NULL) && - (*(ptr+1) == 'x' || *(ptr+1) == 'X')) base = 16; - #ifdef INDIGO - hostid = strtoul(sptr,hhptr,base); + hostid = strtoul(sptr, hhptr, base); #elif defined(OS5) - hostid = strtoul(sptr,hhptr,base); + hostid = strtoul(sptr, hhptr, base); #else - hostid = strtol(sptr,hhptr,base); + hostid = strtol(sptr, hhptr, base); #endif - - /* look for syntax error */ - if (**hhptr != '\0') - { - printf("\nInvalid Host ID \n"); - exit(FAILURE1); - }; - /* make sure Host ID is less than 32 bits */ - if (base == 16) - { sprintf(hstr, "%x", hostid); - for (i = 0 ; (cc = *(sptr+i)) != '\0' ; ++i) - if (isupper(cc)) *(sptr+i) = tolower(cc); - for (i = 0 ; (cc = *(hstr+i)) != '\0' ; ++i) - if (isupper(cc)) *(hstr+i) = tolower(cc); - digitstring = "123456789abcdef"; - } - else - { sprintf(hstr, "%u", hostid); - digitstring = "123456789"; - }; + /* look for syntax error */ + if (**hhptr != '\0') { + printf("\nInvalid Host ID \n"); + exit(FAILURE1); + }; - ptr = strpbrk(sptr,digitstring); - if ((ptr == NULL && *sptr != '0' && *hstr != '0') || - (ptr != NULL && strcmp(ptr,hstr) != 0)) - { - printf("\nInvalid Host ID \n"); - exit(FAILURE1); - } - }; - hostid = modify(hostid); + /* make sure Host ID is less than 32 bits */ + if (base == 16) { + sprintf(hstr, "%x", hostid); + for (i = 0; (cc = *(sptr + i)) != '\0'; ++i) + if (isupper(cc)) *(sptr + i) = tolower(cc); + for (i = 0; (cc = *(hstr + i)) != '\0'; ++i) + if (isupper(cc)) *(hstr + i) = tolower(cc); + digitstring = "123456789abcdef"; + } else { + sprintf(hstr, "%u", hostid); + digitstring = "123456789"; + }; - /* == prompt for the expiration date and validate it == */ + ptr = strpbrk(sptr, digitstring); + if ((ptr == NULL && *sptr != '0' && *hstr != '0') || (ptr != NULL && strcmp(ptr, hstr) != 0)) { + printf("\nInvalid Host ID \n"); + exit(FAILURE1); + } + }; + hostid = modify(hostid); - if (!commandlineargs) - { - /* assume that info is not needed when we use argc,argv */ - printf("\n\nEnter information string (one line only, below)\n:"); - gets(infostring); - } - /* == prompt for the expiration date and validate it == */ + /* == prompt for the expiration date and validate it == */ - if (commandlineargs) - { - - strcpy(expdate,*++argv); - - } else { - - printf("Enter Software Expiration Date (dd-mmm-yy or never): "); - gets(expdate); - - } - strcpy(saveexpdate,expdate); - /* check for 'never' entry */ - if ((expdate[0] == 'N') || (expdate[0] == 'n')) - { - for (i = 0 ; (c = expdate[i]) != '\0' ; ++i) - if (islower(c)) expdate[i] = toupper(c); - - if ( strcmp(expdate, "NEVER") == 0) - strcpy(expdate, "29-DEC-77"); - else { - printf("\nInvalid Software Expiration Date\n"); - exit(FAILURE2); - }; - }; - - /* validate the date */ - if ( idate(expdate) == FAILURE2) - { - printf("\nInvalid Software Expiration Date\n"); - exit(FAILURE2); - }; + if (!commandlineargs) { + /* assume that info is not needed when we use argc,argv */ + printf("\n\nEnter information string (one line only, below)\n:"); + gets(infostring); + } + /* == prompt for the expiration date and validate it == */ - /* == generate 3 keys == */ - keyarray[0] = hash_unhash(hostid, hostid); - keyarray[1] = hash_unhash( ((date_integer16(expdate) << 16) | 0), hostid); - keyarray[2] = make_verification(keyarray[0], keyarray[1]); + if (commandlineargs) { + strcpy(expdate, *++argv); + } else { + printf("Enter Software Expiration Date (dd-mmm-yy or never): "); + gets(expdate); + } + strcpy(saveexpdate, expdate); + /* check for 'never' entry */ + if ((expdate[0] == 'N') || (expdate[0] == 'n')) { + for (i = 0; (c = expdate[i]) != '\0'; ++i) + if (islower(c)) expdate[i] = toupper(c); + + if (strcmp(expdate, "NEVER") == 0) + strcpy(expdate, "29-DEC-77"); + else { + printf("\nInvalid Software Expiration Date\n"); + exit(FAILURE2); + }; + }; + + /* validate the date */ + if (idate(expdate) == FAILURE2) { + printf("\nInvalid Software Expiration Date\n"); + exit(FAILURE2); + }; + + /* == generate 3 keys == */ + keyarray[0] = hash_unhash(hostid, hostid); + keyarray[1] = hash_unhash(((date_integer16(expdate) << 16) | 0), hostid); + keyarray[2] = make_verification(keyarray[0], keyarray[1]); /* == report the results == */ - if (commandlineargs) - { - printf("%8x %8x %8x\n", *keyarray, *(keyarray+1), *(keyarray+2)); - exit(1); + if (commandlineargs) { + printf("%8x %8x %8x\n", *keyarray, *(keyarray + 1), *(keyarray + 2)); + exit(1); + } else { + /* if logfile is open, append the results to the end of the file */ + if (logfile == 1) { + if (argc > 2) { + fprintf(fp, "\n%s", *++argv); + printf("\n%s", *argv); } - else - { - /* if logfile is open, append the results to the end of the file */ - if (logfile == 1) - { - if (argc > 2) - { - fprintf(fp,"\n%s",*++argv); - printf("\n%s",*argv); - } - writeresults( fp, sptr, saveexpdate, - *keyarray, *(keyarray+1), *(keyarray+2), - infostring); - fclose(fp); - }; - writeresults( stdout, sptr, saveexpdate, - *keyarray, *(keyarray+1), *(keyarray+2), - infostring); - /* display the results on the terminal */ - }; - exit(0); + writeresults(fp, sptr, saveexpdate, *keyarray, *(keyarray + 1), *(keyarray + 2), infostring); + fclose(fp); + }; + writeresults(stdout, sptr, saveexpdate, *keyarray, *(keyarray + 1), *(keyarray + 2), + infostring); + /* display the results on the terminal */ + }; + exit(0); } diff --git a/src/keytst.c b/src/keytst.c old mode 100755 new mode 100644 index eee2892..76ce34f --- a/src/keytst.c +++ b/src/keytst.c @@ -1,9 +1,7 @@ -/* $Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,18 +16,15 @@ static char *id = "$Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copyri #include "version.h" - - - /* ========================================================================= - The functions defined in this file are used to validate the copyright - protection keys for NewCo's Maiko software. The main function is - 'keytester', which takes an input key string and returns a status - code after processing the keys. - - The external functions called were stored in file 'keylib.o'. + The functions defined in this file are used to validate the copyright + protection keys for NewCo's Maiko software. The main function is + 'keytester', which takes an input key string and returns a status + code after processing the keys. - Creation date: May, 1988 + The external functions called were stored in file 'keylib.o'. + + Creation date: May, 1988 ====================================================================== */ #include @@ -37,165 +32,154 @@ static char *id = "$Id: keytst.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copyri #include #ifdef HPUX - /* On HPUX, use the UNAME syscall to get hostid */ -#include +/* On HPUX, use the UNAME syscall to get hostid */ +#include #endif - -#define GOLDEN_RATIO_HACK -478700649 -#define floadbyte(number,pos) ((number >> pos) & 0xFFFF) -#define hash_unhash(number,hashkey) (number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey,16) + floadbyte(hashkey,0)) )) -#define KEYNUMBERS 3 -#define RC0 0 +#define GOLDEN_RATIO_HACK -478700649 +#define floadbyte(number, pos) ((number >> pos) & 0xFFFF) +#define hash_unhash(number, hashkey) \ + (number ^ (GOLDEN_RATIO_HACK * (floadbyte(hashkey, 16) + floadbyte(hashkey, 0)))) +#define KEYNUMBERS 3 +#define RC0 0 /* meaning of symbolic constants used: - - FAILURE2 invalid date - FAILURE3 invalid key - FAILURE4 key expired - FAILURE99 invalid date (this shouldn't happen unless string format returned by ctime got changed) */ - -#define FAILURE2 -2 -#define FAILURE3 -3 -#define FAILURE4 -4 -#define FAILURE99 -99 + FAILURE2 invalid date + FAILURE3 invalid key + FAILURE4 key expired + FAILURE99 invalid date (this shouldn't happen unless string format returned + by ctime got changed) */ +#define FAILURE2 -2 +#define FAILURE3 -3 +#define FAILURE4 -4 +#define FAILURE99 -99 unsigned long make_verification(long unsigned int x, long unsigned int y); unsigned long date_integer16(char *date); unsigned long idate(char *str); unsigned long modify(long unsigned int hostid); - /* ===================================================================== - KEYTESTER checks the input key string. + KEYTESTER checks the input key string. It returns 0 if the keys are valid, otherwise it returns non-0. ====================================================================== */ -int keytester(char *keystring) -{ unsigned long keyarray[KEYNUMBERS]; /* array which holds numeric keys */ - unsigned long hostid ; /* 32-bit unique identifier of the current host */ - unsigned long hashedword; - int rc; /* return code */ +int keytester(char *keystring) { + unsigned long keyarray[KEYNUMBERS]; /* array which holds numeric keys */ + unsigned long hostid; /* 32-bit unique identifier of the current host */ + unsigned long hashedword; + int rc; /* return code */ #ifdef HPUX - struct utsname unameinfo; + struct utsname unameinfo; #endif + /* check the keys and convert them from hexdecimal strings to numbers */ + if (keystring == NULL) return FAILURE3; + if (read_hex(keystring, keyarray) == FAILURE3) return FAILURE3; - /* check the keys and convert them from hexdecimal strings to numbers */ - if (keystring == NULL) return FAILURE3; - if ( read_hex(keystring , keyarray) == FAILURE3) return FAILURE3 ; - - - /* get machines host id */ +/* get machines host id */ #ifdef HPUX - uname(&unameinfo); - hostid = atol(unameinfo.idnumber); + uname(&unameinfo); + hostid = atol(unameinfo.idnumber); #else - hostid = gethostid(); - printf("hostid = 0x%x\n", hostid); + hostid = gethostid(); + printf("hostid = 0x%x\n", hostid); #endif - hostid = modify(hostid); + hostid = modify(hostid); - /* generate hashword */ - hashedword = hash_unhash(keyarray[1] , hostid); - - /* validate keys */ - if (keyarray[0] != hash_unhash(hostid , hostid)) return FAILURE3; - if ((rc = ok_date(floadbyte(hashedword , 16))) != RC0) return rc; - if (keyarray[2] != make_verification(keyarray[0] , keyarray[1])) - return FAILURE3; - - return 0; - } + /* generate hashword */ + hashedword = hash_unhash(keyarray[1], hostid); + + /* validate keys */ + if (keyarray[0] != hash_unhash(hostid, hostid)) return FAILURE3; + if ((rc = ok_date(floadbyte(hashedword, 16))) != RC0) return rc; + if (keyarray[2] != make_verification(keyarray[0], keyarray[1])) return FAILURE3; + + return 0; +} /* ===================================================================== - READ_HEX reads in keys from the input string , validates them, then + READ_HEX reads in keys from the input string , validates them, then stores them in the input array. ====================================================================== */ -int read_hex(char *s1, long unsigned int *array) -{ - char *s2 = {" "}; - char *ptr; - char *hexdigits = {"0123456789abcdefABCDEF"}; - int i ; - - for (i = 0 ; (i < KEYNUMBERS) && ((ptr = strtok(s1 , s2)) != NULL) ; ++i) - { +int read_hex(char *s1, long unsigned int *array) { + char *s2 = {" "}; + char *ptr; + char *hexdigits = {"0123456789abcdefABCDEF"}; + int i; - /* make sure the key contains only hexadecimal characters */ - if ( (strspn (ptr,hexdigits)) != strlen(ptr)) return FAILURE3; + for (i = 0; (i < KEYNUMBERS) && ((ptr = strtok(s1, s2)) != NULL); ++i) { + /* make sure the key contains only hexadecimal characters */ + if ((strspn(ptr, hexdigits)) != strlen(ptr)) return FAILURE3; - /* convert key to numeric format*/ +/* convert key to numeric format*/ #ifdef HPUX - *(array + i) = strtoul(ptr,NULL,16); /* On HP, must convert to unsigned */ + *(array + i) = strtoul(ptr, NULL, 16); /* On HP, must convert to unsigned */ #elif defined(APOLLO) - *(array + i) = strtoul(ptr,NULL,16); /* On APOLLO, must convert to unsigned */ + *(array + i) = strtoul(ptr, NULL, 16); /* On APOLLO, must convert to unsigned */ #elif defined(INDIGO) - *(array + i) = strtoul(ptr,NULL,16); /* On Indigo, must convert to unsigned */ + *(array + i) = strtoul(ptr, NULL, 16); /* On Indigo, must convert to unsigned */ #elif defined(RS6000) - *(array + i) = strtoul(ptr,NULL,16); /* On RS/6000, must convert to unsigned */ + *(array + i) = strtoul(ptr, NULL, 16); /* On RS/6000, must convert to unsigned */ #elif defined(OSF1) - *(array + i) = strtoul(ptr,NULL,16); /* On Alpha, must convert to unsigned */ + *(array + i) = strtoul(ptr, NULL, 16); /* On Alpha, must convert to unsigned */ #else - *(array + i) = strtol(ptr,NULL,16); /* On suns, this works OK */ + *(array + i) = strtol(ptr, NULL, 16); /* On suns, this works OK */ #endif -printf("0x%x ", *(array+i)); fflush(stdout); - /* continue search the next one */ - s1 = NULL; - }; + printf("0x%x ", *(array + i)); + fflush(stdout); + /* continue search the next one */ + s1 = NULL; + }; - if (i == KEYNUMBERS) return RC0; - else return FAILURE3; - } + if (i == KEYNUMBERS) + return RC0; + else + return FAILURE3; +} /* ============================================ - OK_DATE checks the expiration of the key + OK_DATE checks the expiration of the key ============================================ */ -int ok_date (long unsigned int date) -{ - char current_date[30]; - char *mptr, *dptr, *yptr, *str; - long realtime , *clock; +int ok_date(long unsigned int date) { + char current_date[30]; + char *mptr, *dptr, *yptr, *str; + long realtime, *clock; - /* first check if the expiration date is set to indefinite */ + /* first check if the expiration date is set to indefinite */ - printf("\narg date: %ld %x\n", date, date); - printf("\narg date ?????: %ld %x\n", date_integer16("29-DEC-77"), date_integer16("29-DEC-77")); + printf("\narg date: %ld %x\n", date, date); + printf("\narg date ?????: %ld %x\n", date_integer16("29-DEC-77"), date_integer16("29-DEC-77")); - if (date == date_integer16("29-DEC-77")) return RC0; + if (date == date_integer16("29-DEC-77")) return RC0; + /* next check if current date is less than or equal to the expiration date */ + /* get the current date string */ + realtime = time(0); + clock = &realtime; + str = (char *)ctime(clock); - /* next check if current date is less than or equal to the expiration date */ - /* get the current date string */ - realtime = time(0); - clock = &realtime; - str = (char *) ctime(clock); - - /* delete day and time info and rearrange the string format to be dd-mmm-yy */ - mptr = strtok(str," "); - mptr = strtok(NULL," "); - dptr = strtok(NULL," "); - yptr = strtok(NULL," "); - yptr = strtok(NULL," \n"); /* watch out for newline char */ - current_date[0] = '\0'; - strcat(current_date , dptr); - strcat(current_date , "-"); - strcat(current_date , mptr); - strcat(current_date , "-"); - strcat(current_date , yptr); - - /* check the date */ - if (idate(current_date) == FAILURE2) return FAILURE99; - - - printf("*current date*: %ld %x\n", date_integer16(current_date), date_integer16(current_date)); - - return (date_integer16(current_date) <= date ) ? RC0 : FAILURE4; - } + /* delete day and time info and rearrange the string format to be dd-mmm-yy */ + mptr = strtok(str, " "); + mptr = strtok(NULL, " "); + dptr = strtok(NULL, " "); + yptr = strtok(NULL, " "); + yptr = strtok(NULL, " \n"); /* watch out for newline char */ + current_date[0] = '\0'; + strcat(current_date, dptr); + strcat(current_date, "-"); + strcat(current_date, mptr); + strcat(current_date, "-"); + strcat(current_date, yptr); + /* check the date */ + if (idate(current_date) == FAILURE2) return FAILURE99; + printf("*current date*: %ld %x\n", date_integer16(current_date), date_integer16(current_date)); + return (date_integer16(current_date) <= date) ? RC0 : FAILURE4; +} diff --git a/src/keytstno.c b/src/keytstno.c old mode 100755 new mode 100644 index 3533c80..313fb15 --- a/src/keytstno.c +++ b/src/keytstno.c @@ -1,10 +1,9 @@ -/* $Id: keytstno.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: keytstno.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: keytstno.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copyright (C) Venue"; /* Loaded instead of keytst.c, with unlocked definition of keytester */ - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,8 +18,4 @@ static char *id = "$Id: keytstno.c,v 1.3 1999/05/31 23:35:36 sybalsky Exp $ Copy #include "version.h" - -int keytester (void) -{ - return 0; - } +int keytester(void) { return 0; } diff --git a/src/kprint.c b/src/kprint.c old mode 100755 new mode 100644 index 0113e89..42d5646 --- a/src/kprint.c +++ b/src/kprint.c @@ -1,8 +1,7 @@ -/* $Id: kprint.c,v 1.2 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: kprint.c,v 1.2 1999/05/31 23:35:36 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: kprint.c,v 1.2 1999/05/31 23:35:36 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ @@ -17,23 +16,22 @@ static char *id = "$Id: kprint.c,v 1.2 1999/05/31 23:35:36 sybalsky Exp $ Copyri #include "version.h" -#include -#include "print.h" -#include "address.h" -#include "lispemul.h" -#include "lsptypes.h" -#include "lspglob.h" -#include "initatms.h" -#include "cell.h" -#include "emlglob.h" -#include "lispmap.h" -#include "adr68k.h" +#include +#include "print.h" +#include "address.h" +#include "lispemul.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "initatms.h" +#include "cell.h" +#include "emlglob.h" +#include "lispmap.h" +#include "adr68k.h" - -int PrintMaxLevel= 3; -int Printdepth=0; +int PrintMaxLevel = 3; +int Printdepth = 0; int PrintMaxLen = 10; -int PrintLen[20] ; +int PrintLen[20]; /* forward references */ void print_string(LispPTR x); @@ -47,94 +45,90 @@ void print_floatp(LispPTR x); /* */ /************************************************************************/ -void prindatum(LispPTR x) -{ - NEWSTRINGP *newstring ; - struct dtd *dtd_base; - int typen; - LispPTR typename; +void prindatum(LispPTR x) { + NEWSTRINGP *newstring; + struct dtd *dtd_base; + int typen; + LispPTR typename; + + if (Printdepth >= PrintMaxLevel) { + if (Printdepth = PrintMaxLevel) { + if (GetTypeNumber(x) == TYPE_LISTP) { + printf("(-)"); + } else + printf("*"); + } + return; + } - if(Printdepth >= PrintMaxLevel) - { - if (Printdepth = PrintMaxLevel){ if(GetTypeNumber(x)==TYPE_LISTP) - { - printf("(-)"); - } - else printf("*");} - return; - } - x = x & POINTERMASK; - switch (typen = GetTypeNumber(x)) - { - case TYPE_LITATOM: + switch (typen = GetTypeNumber(x)) { + case TYPE_LITATOM: #ifdef BIGATOMS - case TYPE_NEWATOM: + case TYPE_NEWATOM: #endif /* BIGATOMS */ - print_atomname(x); - break; - case TYPE_LISTP: - Printdepth++; - PrintLen[Printdepth] = 0; - printf("%c" , LEFT_PAREN); /* print "(" */ - lp: if (PrintLen[Printdepth] ++ > PrintMaxLen) {printf("%c", RIGHT_PAREN); Printdepth--; break;} - prindatum(car(x)); - if (Listp (cdr(x)) == 0) - { /* print dotted pair */ - if ((x = cdr(x)) != NIL) - { - printf(" . "); - prindatum(x); - } - } - else - { - printf("%c" , SPACE); - x = cdr(x); - goto lp; - } - printf("%c" , RIGHT_PAREN); /* print ")" */ - Printdepth--; - break; - - case TYPE_SMALLP: - if ((x & SEGMASK) == S_POSITIVE) - printf("%d" , LOLOC(x)); /* print positive smallp */ - else - printf("%d" , (LOLOC(x) | 0xffff0000)); /* print negative smallp */ - break; - case TYPE_FIXP: - print_fixp(x); /* print fixp */ - break; - case TYPE_FLOATP: - print_floatp(x); - break; - case TYPE_STRINGP: - print_string(x); /* print string */ - break; - case TYPE_ONED_ARRAY : - case TYPE_GENERAL_ARRAY : - newstring=(NEWSTRINGP *)Addr68k_from_LADDR(x); - if(newstring->stringp){ - print_NEWstring(x); - break; } + print_atomname(x); + break; + case TYPE_LISTP: + Printdepth++; + PrintLen[Printdepth] = 0; + printf("%c", LEFT_PAREN); /* print "(" */ + lp: + if (PrintLen[Printdepth]++ > PrintMaxLen) { + printf("%c", RIGHT_PAREN); + Printdepth--; + break; + } + prindatum(car(x)); + if (Listp(cdr(x)) == 0) { /* print dotted pair */ + if ((x = cdr(x)) != NIL) { + printf(" . "); + prindatum(x); + } + } else { + printf("%c", SPACE); + x = cdr(x); + goto lp; + } + printf("%c", RIGHT_PAREN); /* print ")" */ + Printdepth--; + break; - default: - dtd_base = (struct dtd *)GetDTD(typen); - printf("{"); -#ifdef BIGVM - if((typename = dtd_base->dtd_name) != 0) + case TYPE_SMALLP: + if ((x & SEGMASK) == S_POSITIVE) + printf("%d", LOLOC(x)); /* print positive smallp */ + else + printf("%d", (LOLOC(x) | 0xffff0000)); /* print negative smallp */ + break; + case TYPE_FIXP: + print_fixp(x); /* print fixp */ + break; + case TYPE_FLOATP: print_floatp(x); break; + case TYPE_STRINGP: + print_string(x); /* print string */ + break; + case TYPE_ONED_ARRAY: + case TYPE_GENERAL_ARRAY: + newstring = (NEWSTRINGP *)Addr68k_from_LADDR(x); + if (newstring->stringp) { + print_NEWstring(x); + break; + } + + default: dtd_base = (struct dtd *)GetDTD(typen); printf("{"); +#ifdef BIGVM + if ((typename = dtd_base->dtd_name) != 0) #else - if((typename = dtd_base->dtd_namelo+(dtd_base->dtd_namehi<<16)) != 0) + if ((typename = dtd_base->dtd_namelo + (dtd_base->dtd_namehi << 16)) != 0) #endif - print_atomname(typename); - else printf("unknown"); - printf("}0x"); - printf("%x" , x); /* print lisp address in hex */ - } + print_atomname(typename); + else + printf("unknown"); + printf("}0x"); + printf("%x", x); /* print lisp address in hex */ + } } - /************************************************************************/ /* */ /* P R I N T */ @@ -143,15 +137,12 @@ void prindatum(LispPTR x) /* */ /************************************************************************/ -LispPTR print(LispPTR x) -{ - Printdepth=0; - prindatum(x&POINTERMASK); - /* printf("\n"); */ /* print CR */ - return (x); - } - - +LispPTR print(LispPTR x) { + Printdepth = 0; + prindatum(x & POINTERMASK); + /* printf("\n"); */ /* print CR */ + return (x); +} /************************************************************************/ /* */ @@ -161,31 +152,26 @@ LispPTR print(LispPTR x) /* */ /************************************************************************/ -void print_string(LispPTR x) -{ - struct stringp *string_point; - DLword st_length; - DLbyte *string_base; +void print_string(LispPTR x) { + struct stringp *string_point; + DLword st_length; + DLbyte *string_base; - int i; + int i; + string_point = (struct stringp *)Addr68k_from_LADDR(x); + st_length = string_point->length; + string_base = (DLbyte *)Addr68k_from_LADDR(string_point->base); - string_point = (struct stringp *)Addr68k_from_LADDR(x); - st_length = string_point->length; - string_base = (DLbyte *)Addr68k_from_LADDR(string_point->base); + printf("%c", DOUBLEQUOTE); /* print %" */ - printf("%c" , DOUBLEQUOTE); /* print %" */ - - for (i = 1 ; i <= st_length ; i++) - { - printf("%c" , GETBYTE(string_base)); - string_base++; - } - - printf("%c" , DOUBLEQUOTE); /* print %" */ + for (i = 1; i <= st_length; i++) { + printf("%c", GETBYTE(string_base)); + string_base++; } - + printf("%c", DOUBLEQUOTE); /* print %" */ +} /************************************************************************/ /* */ @@ -196,31 +182,27 @@ void print_string(LispPTR x) /* */ /************************************************************************/ -void print_NEWstring(LispPTR x) -{ - NEWSTRINGP *string_point; - DLword st_length; - DLbyte *string_base; +void print_NEWstring(LispPTR x) { + NEWSTRINGP *string_point; + DLword st_length; + DLbyte *string_base; - int i; + int i; - string_point = (NEWSTRINGP *)Addr68k_from_LADDR(x); - st_length = string_point->fillpointer; - string_base = (DLbyte *)Addr68k_from_LADDR(string_point->base); - string_base += string_point->offset ; + string_point = (NEWSTRINGP *)Addr68k_from_LADDR(x); + st_length = string_point->fillpointer; + string_base = (DLbyte *)Addr68k_from_LADDR(string_point->base); + string_base += string_point->offset; - printf("%c" , DOUBLEQUOTE); /* print %" */ - - for (i = 0 ; i < st_length ; i++) - { - printf("%c" , GETBYTE(string_base)); - string_base++; - } + printf("%c", DOUBLEQUOTE); /* print %" */ - printf("%c" , DOUBLEQUOTE); /* print %" */ + for (i = 0; i < st_length; i++) { + printf("%c", GETBYTE(string_base)); + string_base++; } - + printf("%c", DOUBLEQUOTE); /* print %" */ +} /************************************************************************/ /* */ @@ -230,15 +212,12 @@ void print_NEWstring(LispPTR x) /* */ /************************************************************************/ -void print_fixp(LispPTR x) -{ - int *addr_fixp; - - addr_fixp = (int *)Addr68k_from_LADDR(x); - printf("%d" , *addr_fixp); - } - +void print_fixp(LispPTR x) { + int *addr_fixp; + addr_fixp = (int *)Addr68k_from_LADDR(x); + printf("%d", *addr_fixp); +} /************************************************************************/ /* */ @@ -248,12 +227,9 @@ void print_fixp(LispPTR x) /* */ /************************************************************************/ -void print_floatp(LispPTR x) -{ - float *addr_floatp; +void print_floatp(LispPTR x) { + float *addr_floatp; - addr_floatp = (float *)Addr68k_from_LADDR(x); - printf("%f" , *addr_floatp); - } - - + addr_floatp = (float *)Addr68k_from_LADDR(x); + printf("%f", *addr_floatp); +} diff --git a/src/ldeboot.c b/src/ldeboot.c old mode 100755 new mode 100644 index 786e2d0..149cd03 --- a/src/ldeboot.c +++ b/src/ldeboot.c @@ -1,11 +1,7 @@ -/* $Id: ldeboot.c,v 1.3 1999/01/03 02:07:13 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: ldeboot.c,v 1.3 1999/01/03 02:07:13 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: ldeboot.c,v 1.3 1999/01/03 02:07:13 sybalsky Exp $ Copyright (C) Venue"; - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-98 Venue. All Rights Reserved. */ @@ -20,9 +16,7 @@ static char *id = "$Id: ldeboot.c,v 1.3 1999/01/03 02:07:13 sybalsky Exp $ Copyr #include "version.h" - - -#if defined(sun) && !defined(OS5) +#if defined(sun) && !defined(OS5) #define USESUNSCREEN #else #undef USESUNSCREEN @@ -57,7 +51,6 @@ static char *id = "$Id: ldeboot.c,v 1.3 1999/01/03 02:07:13 sybalsky Exp $ Copyr extern char *getenv(); #endif /* XWINDOW */ - #define LDEMONO "ldesingle" #define LDECOLOR "ldemulti" #define LDETRUECOLOR "ldetruecolor" @@ -66,8 +59,6 @@ extern char *getenv(); char filetorun[30]; - - /************************************************************************/ /* */ /* m a i n */ @@ -76,215 +67,169 @@ char filetorun[30]; /* */ /************************************************************************/ -main(argc, argv) - int argc; char **argv; - { - char Earg[30], Ename[30], **newargv; - int i; +main(argc, argv) int argc; +char **argv; +{ + char Earg[30], Ename[30], **newargv; + int i; #ifdef USESUNSCREEN - struct fbtype my_screen; + struct fbtype my_screen; #endif /* USESUNSCREEN */ - - int FrameBufferFd; + int FrameBufferFd; #ifdef USESUNSCREEN - struct fbinfo FB_info; - struct fbgattr FBattr; + struct fbinfo FB_info; + struct fbgattr FBattr; #endif /* USESUNSCREEN */ +/* Kickstart program for the Lisp Development Environment (LDE). + Display Device emulator + CG3, CG6 lde.multi + BW2, CG2, CG4, CG9 lde.single - - /* Kickstart program for the Lisp Development Environment (LDE). - Display Device emulator - CG3, CG6 lde.multi - BW2, CG2, CG4, CG9 lde.single - - FB-TYPE REAL-TYPE - BW2 2 x - CG2 3 3 - CG3 8 6 - CG4 2 8 - CG6 8 12 - CG8 6 7 - CG9(GP1) 4 4 ;gpconfig -f -b - CG9(GP1) 2 13 ;gpconfig gpone0 -f -b cgtwo0 - ;We assume This config for GXP model - */ + FB-TYPE REAL-TYPE + BW2 2 x + CG2 3 3 + CG3 8 6 + CG4 2 8 + CG6 8 12 + CG8 6 7 + CG9(GP1) 4 4 ;gpconfig -f -b + CG9(GP1) 2 13 ;gpconfig gpone0 -f -b cgtwo0 + ;We assume This config for GXP model + */ #ifdef XWINDOW - /* If X-Server exists on the host specified in -display option - or environment variable DISPLAY, ldex is started. Othewise - ldesingle or ldemulti. - */ - { - char *Display_Name = (char *)NULL ; - Display *Xdisplay = (Display *)NULL; - int i , option; - char *pos; - - for( i=1; i= 0) - { - if( FBattr.real_type == FBTYPE_SUN3COLOR || /* cg3 */ - FBattr.real_type == FBTYPE_SUNFAST_COLOR ) /* cg6 */ - { - strcpy(filetorun, LDECOLOR); - } - } - else - { /* if( ioctl... */ - perror("lde: This Display Model does not supported\n"); - exit( -1 ); - } + if (my_screen.fb_type == FBTYPE_SUN4COLOR) { /* cg3 or cg6 */ + if (ioctl(FrameBufferFd, FBIOGATTR, &FBattr) >= 0) { + if (FBattr.real_type == FBTYPE_SUN3COLOR || /* cg3 */ + FBattr.real_type == FBTYPE_SUNFAST_COLOR) /* cg6 */ + { + strcpy(filetorun, LDECOLOR); } - else if( my_screen.fb_type == FBTYPE_SUN2BW ) - { /* bw2, cg4 or cg9 */ - strcpy(filetorun, LDEMONO); + } else { /* if( ioctl... */ + perror("lde: This Display Model does not supported\n"); + exit(-1); + } + } else if (my_screen.fb_type == FBTYPE_SUN2BW) { /* bw2, cg4 or cg9 */ + strcpy(filetorun, LDEMONO); + } else if (my_screen.fb_type == FBTYPE_SUN3COLOR) { + if (ioctl(FrameBufferFd, FBIOGATTR, &FBattr) >= 0) { + if (FBattr.real_type == FBTYPE_MEMCOLOR) /* cg8 */ + { + strcpy(filetorun, LDETRUECOLOR); } - else if( my_screen.fb_type == FBTYPE_SUN3COLOR ) - { - if(ioctl(FrameBufferFd,FBIOGATTR,&FBattr) >= 0) - { - if( FBattr.real_type == FBTYPE_MEMCOLOR ) /* cg8 */ - { - strcpy(filetorun, LDETRUECOLOR); - } - } - else - { /* if( ioctl... */ - perror("lde: This Display Model does not supported\n"); - exit( -1 ); - } - - } - else if( my_screen.fb_type == FBTYPE_SUN2COLOR ) - { /* cg2 */ - strcpy(filetorun, LDEMONO); - } - else - { - perror("lde: This Display Model does not supported\n"); - exit (-1); - }; /* endif( my_screen... */ + } else { /* if( ioctl... */ + perror("lde: This Display Model does not supported\n"); + exit(-1); + } - close(FrameBufferFd); + } else if (my_screen.fb_type == FBTYPE_SUN2COLOR) { /* cg2 */ + strcpy(filetorun, LDEMONO); + } else { + perror("lde: This Display Model does not supported\n"); + exit(-1); + }; /* endif( my_screen... */ + + close(FrameBufferFd); #endif /* USESUNSCREEN */ - - - #ifdef FORKCOMM -/* JRB - call fork_Unix here, while we're REALLY small, unless -NF is - specified, of course... */ - for(i=0; i @@ -40,23 +30,15 @@ int main (int argc, char *argv[]) #include #if defined(SVR4) && !defined(SUNOS5) -char *devices[] = { - "emd0", "emd1", "emd2", "emd3", "emd4", - 0 -}; +char *devices[] = {"emd0", "emd1", "emd2", "emd3", "emd4", 0}; #endif #ifdef SUNOS5 #include -char *devices[] = { - "le0", "le1", "le2", "le3", "le4", - "ie0", "ie1", "ie2", "ie3", "ie4", - "qe0", "qe1", "qe2", "qe3", "qe4", "qe5", "qe6", "qe7", - "fddi0", "fddi1", "fddi2", "fddi3", "fddi4", - "bf0", "bf1", - 0 -}; +char *devices[] = {"le0", "le1", "le2", "le3", "le4", "ie0", "ie1", "ie2", "ie3", + "ie4", "qe0", "qe1", "qe2", "qe3", "qe4", "qe5", "qe6", "qe7", + "fddi0", "fddi1", "fddi2", "fddi3", "fddi4", "bf0", "bf1", 0}; #endif #endif /* USE_DLPI */ @@ -89,203 +71,192 @@ char *devices[] = { #endif /* NOETHER */ - - -int ether_fd = -1; /* file descriptor for ether socket */ -int ether_intf_type = 0; /* IF type? from DLPI */ -unsigned char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address */ +int ether_fd = -1; /* file descriptor for ether socket */ +int ether_intf_type = 0; /* IF type? from DLPI */ +unsigned char ether_host[6] = {0, 0, 0, 0, 0, 0}; /* 48 bit address */ char filetorun[30] = "lde"; - - -int main(int argc, char *argv[]) -{ - char Earg[30], Ename[30], **newargv; - int i; - int flags; +int main(int argc, char *argv[]) { + char Earg[30], Ename[30], **newargv; + int i; + int flags; #ifdef USE_DLPI - static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; - struct strioctl si; + static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; + struct strioctl si; #endif /* USE_DLPI */ - #ifndef NOETHER - /* Only do the ether kick=-start if we've got to. */ + /* Only do the ether kick=-start if we've got to. */ -/* Kickstart program for the Lisp Development Environment (LDE). - Run this as setuid root to open the LDE ether socket. - Passes all arguments through to LDE plus -E - to communicate open ether socket. + /* Kickstart program for the Lisp Development Environment (LDE). + Run this as setuid root to open the LDE ether socket. + Passes all arguments through to LDE plus -E + to communicate open ether socket. - looks like this: - ::::::: + looks like this: + ::::::: - where is the number of the open - socket (decimal), and - are hex of the socket's - 48-bit Ethernet address, and is the name of the - Ethernet device as found by SIOCGIFCONF. -*/ - -if (!geteuid()){ -#ifdef USE_DLPI - /* Use DLPI to connect to the ethernet. This code is stolen - from NFSWATCH4.3 + where is the number of the open + socket (decimal), and - are hex of the socket's + 48-bit Ethernet address, and is the name of the + Ethernet device as found by SIOCGIFCONF. */ - if ( ether_fd = setup_dlpi_dev(NULL)) { /* Open an ether interface */ - ether_intf_type = dlpi_devtype(ether_fd); -printf("opened ldeether fd %d.\n", ether_fd); - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + if (!geteuid()) { +#ifdef USE_DLPI + /* Use DLPI to connect to the ethernet. This code is stolen + from NFSWATCH4.3 + */ - if(ioctl(ether_fd, I_PUSH, "pfmod") < 0) { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } - - si.ic_cmd = PFIOCSETF; - si.ic_timout = -1; - si.ic_len = sizeof(pf); - si.ic_dp = (char *)&pf; + if (ether_fd = setup_dlpi_dev(NULL)) { /* Open an ether interface */ + ether_intf_type = dlpi_devtype(ether_fd); + printf("opened ldeether fd %d.\n", ether_fd); + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if (ioctl(ether_fd, I_STR, &si) < 0) { - perror("ioctl: I_STR PFIOCSETF"); - return(-1); - } + if (ioctl(ether_fd, I_PUSH, "pfmod") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } - flags = fcntl(ether_fd, F_GETFL, 0); - flags = fcntl(ether_fd, F_SETFL, flags | O_NDELAY ); + si.ic_cmd = PFIOCSETF; + si.ic_timout = -1; + si.ic_len = sizeof(pf); + si.ic_dp = (char *)&pf; + + if (ioctl(ether_fd, I_STR, &si) < 0) { + perror("ioctl: I_STR PFIOCSETF"); + return (-1); + } + + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | O_NDELAY); #else - /* N O T D L P I C O D E */ - +/* N O T D L P I C O D E */ #ifndef OS4 - if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { -#else /* OS4 */ + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { +#else /* OS4 */ - if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { + if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { #endif /* OS4 */ - /* it's open, now query it and find out its name and address */ - /* JRB - must document that LDE uses the first net board as found - by SIOCGIFCONF (see if(4)). Maybe we need an option to specify - which net board (suspect more than one net board on an LDE machine - will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as found + by SIOCGIFCONF (see if(4)). Maybe we need an option to specify + which net board (suspect more than one net board on an LDE machine + will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; #ifdef OS4 - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if(ioctl(ether_fd, I_PUSH, "pf") < 0) { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } + if (ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } #endif /* OS4 */ - if_data.ifc_len = sizeof(ifbuf); - if_data.ifc_req = ifbuf; + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; #ifndef OS4 - if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { - perror("Couldn't GIFCONF socket; Net is off"); -#else /* OS4 */ + if (ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ - bzero(ifbuf, sizeof(ifbuf)); - { - /* we have to get the interface name from another socket, since - /dev/nit doesn't know anything until it gets bound, and we - can't bind it without knowing the interface name... */ - int s; + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("No socket for interface name"); - close(s); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { - perror("Couldn't get interface name from socket"); - close(s); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - (void) close(s); - } - if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { - perror("Couldn't NIOCBIND socket: Net is off"); + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + (void)close(s); + } + if (ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); #endif /* OS4 */ - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - /* now for the address */ - if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { - perror("Couldn't GIFADDR socket: Net is off"); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); - strcpy(Ename, if_data.ifc_req[0].ifr_name); - - flags = fcntl(ether_fd, F_GETFL, 0); - flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if (ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + strcpy(Ename, if_data.ifc_req[0].ifr_name); + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); #endif /* USE_DLPI */ -#ifdef DEBUG - printf("init_ether: **** Ethernet starts ****\n"); +#ifdef DEBUG + printf("init_ether: **** Ethernet starts ****\n"); #endif - } else { -I_Give_Up: - perror("init_ether: can't open NIT socket\n"); - ether_fd = -1; - /* exit(); */ - } - seteuid(getuid()); - } + } else { + I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + /* exit(); */ + } + seteuid(getuid()); + } #endif /* NOETHER */ -/* OK, right here do other stuff like scan args */ -/* finally crank up LDE; first copy the original args */ + /* OK, right here do other stuff like scan args */ + /* finally crank up LDE; first copy the original args */ -newargv = (char **) malloc((argc + 1 + (ether_fd > 0)*2) * sizeof (char **)); -newargv[0] = filetorun; /* or whatever... */ -for(i=1; i 0) * 2) * sizeof(char **)); + newargv[0] = filetorun; /* or whatever... */ + for (i = 1; i < argc; i++) newargv[i] = argv[i]; -/* then if the net is active, spit out the ether info */ -if(ether_fd > 0) { - newargv[i++] = "-E"; + /* then if the net is active, spit out the ether info */ + if (ether_fd > 0) { + newargv[i++] = "-E"; #ifdef USE_DLPI - sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x", ether_fd, - ether_host[0], ether_host[1], ether_host[2], - ether_host[3], ether_host[4], ether_host[5]); + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x", ether_fd, ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5]); #else - sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, - ether_host[0], ether_host[1], ether_host[2], - ether_host[3], ether_host[4], ether_host[5], Ename); + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); #endif /* USE_DLPI */ - newargv[i++] = Earg; - printf("ether = %d:%x:%x:%x:%x:%x:%x:%s", ether_fd, - ether_host[0], ether_host[1], ether_host[2], - ether_host[3], ether_host[4], ether_host[5], Ename); -} -newargv[i] = 0; + newargv[i++] = Earg; + printf("ether = %d:%x:%x:%x:%x:%x:%x:%s", ether_fd, ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); + } + newargv[i] = 0; -/* then execve the LDE executable */ -execvp(filetorun, newargv); -perror(filetorun); -return(1); + /* then execve the LDE executable */ + execvp(filetorun, newargv); + perror(filetorun); + return (1); } #endif /* NOETHER */ diff --git a/src/ldsout.c b/src/ldsout.c old mode 100755 new mode 100644 index f7abd59..60fd1b1 --- a/src/ldsout.c +++ b/src/ldsout.c @@ -1,8 +1,7 @@ -/* $Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1998 Venue. */ @@ -16,13 +15,8 @@ static char *id = "$Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ Copyri /* */ /************************************************************************/ - - #include "version.h" - - - #include #include #include @@ -40,7 +34,6 @@ static char *id = "$Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ Copyri #include #endif /* DOS */ - #include "adr68k.h" #include "lispemul.h" #include "lsptypes.h" @@ -53,19 +46,18 @@ static char *id = "$Id: ldsout.c,v 1.4 2001/12/26 22:17:02 sybalsky Exp $ Copyri #include "inlnPS2.h" #endif /* GCC386 */ -#define IFPAGE_ADDRESS 512 -#define DEFAULT_MAX_SYSOUTSIZE 64 /* in Mbyte */ -#define DEFAULT_PRIME_SYSOUTSIZE 8 -#define MAX_EXPLICIT_SYSOUTSIZE 256 /* Max possible sysout size is 64Mb */ -#define MBYTE 0x100000 /* 1 Mbyte */ -extern int errno; +#define IFPAGE_ADDRESS 512 +#define DEFAULT_MAX_SYSOUTSIZE 64 /* in Mbyte */ +#define DEFAULT_PRIME_SYSOUTSIZE 8 +#define MAX_EXPLICIT_SYSOUTSIZE 256 /* Max possible sysout size is 64Mb */ +#define MBYTE 0x100000 /* 1 Mbyte */ +extern int errno; -/* Flag for indication whether process space +/* Flag for indication whether process space is going to expand or not */ -int Storage_expanded; /* T or NIL */ +int Storage_expanded; /* T or NIL */ - - /* RISCOS, OSF1 and MACOSX don't have valloc, and malloc works OK there. */ +/* RISCOS, OSF1 and MACOSX don't have valloc, and malloc works OK there. */ #if defined(SYSVONLY) || defined(OSF1) || defined(MACOSX) #define valloc malloc #else @@ -79,324 +71,293 @@ char *valloc(); /* Load the sysout file into memory. */ /* */ /************************************************************************/ -#if defined(DOS) || defined (XWINDOW) +#if defined(DOS) || defined(XWINDOW) #include "devif.h" static char *metersyms = "-\\|/"; extern DspInterface currentdsp; #endif /* DOS || XWINDOW */ -int sysout_loader(sysout_file_name, sys_size) - char *sysout_file_name; - int sys_size; /* sysout size in megabytes */ +int sysout_loader(sysout_file_name, sys_size) char *sysout_file_name; +int sys_size; /* sysout size in megabytes */ { - int sysout; /* SysoutFile descriptor */ + int sysout; /* SysoutFile descriptor */ - IFPAGE ifpage; /* IFPAGE */ + IFPAGE ifpage; /* IFPAGE */ - char *fptovp_scratch; /* scratch area for FPTOVP */ + char *fptovp_scratch; /* scratch area for FPTOVP */ #ifdef BIGVM - unsigned int fptovp[0x40000]; /* FPTOVP */ + unsigned int fptovp[0x40000]; /* FPTOVP */ #else - DLword fptovp[0x10000]; /* FPTOVP */ -#endif /* BIGVM */ - long fptovp_offset; /* FPTOVP start offset */ + DLword fptovp[0x10000]; /* FPTOVP */ +#endif /* BIGVM */ + long fptovp_offset; /* FPTOVP start offset */ - char *lispworld_scratch; /* scratch area for lispworld */ - long lispworld_offset; /* lispworld offset */ + char *lispworld_scratch; /* scratch area for lispworld */ + long lispworld_offset; /* lispworld offset */ - unsigned sysout_size;/* sysout size in page */ - struct stat stat_buf; /* file stat buf */ - int i, vp; + unsigned sysout_size; /* sysout size in page */ + struct stat stat_buf; /* file stat buf */ + int i, vp; - int machinetype; - char errmsg [ 255 ]; + int machinetype; + char errmsg[255]; - int j = 0; + int j = 0; - machinetype = 0; + machinetype = 0; - /* Checks for specifying the process size (phase I) */ - /* If sys_size == 0 figure out the proper size later */ - if((sys_size != 0) && (sys_size < DEFAULT_PRIME_SYSOUTSIZE)) - { - perror("You have to specify more than 8MB for process size"); - exit(-1); - } - else if ( sys_size > MAX_EXPLICIT_SYSOUTSIZE) - { - perror("256Mb is the maximum legal sysout size."); - exit(-1); - } + /* Checks for specifying the process size (phase I) */ + /* If sys_size == 0 figure out the proper size later */ + if ((sys_size != 0) && (sys_size < DEFAULT_PRIME_SYSOUTSIZE)) { + perror("You have to specify more than 8MB for process size"); + exit(-1); + } else if (sys_size > MAX_EXPLICIT_SYSOUTSIZE) { + perror("256Mb is the maximum legal sysout size."); + exit(-1); + } - /* - * first read the IFPAGE(InterfacePage) - */ + /* + * first read the IFPAGE(InterfacePage) + */ - /* open SysoutFile */ - sysout = open(sysout_file_name, O_RDONLY, NULL); - if (sysout == -1) - { - sprintf( errmsg, - "sysout_loader: can't open sysout file: %s", - sysout_file_name); - perror( errmsg ); - exit(-1); - } + /* open SysoutFile */ + sysout = open(sysout_file_name, O_RDONLY, NULL); + if (sysout == -1) { + sprintf(errmsg, "sysout_loader: can't open sysout file: %s", sysout_file_name); + perror(errmsg); + exit(-1); + } - /* seek to IFPAGE */ - if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) - { - perror("sysout_loader: can't seek to IFPAGE"); - exit(-1); - } + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } - /* reads IFPAGE into scratch_page */ - if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) - { - perror("sysout_loader: can't read IFPAGE"); - exit(-1); - } + /* reads IFPAGE into scratch_page */ + if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) { + perror("sysout_loader: can't read IFPAGE"); + exit(-1); + } #ifdef BYTESWAP - word_swap_page((unsigned int *)&ifpage, - (3+sizeof(IFPAGE))/4); + word_swap_page((unsigned int *)&ifpage, (3 + sizeof(IFPAGE)) / 4); #endif - /* Check the sysout and emulator for compatibility: - The sysout's ifpage.lversion must be >= LVERSION, and - the sysout's ifpage.minbversion must be <= MINBVERSION - */ +/* Check the sysout and emulator for compatibility: + The sysout's ifpage.lversion must be >= LVERSION, and + the sysout's ifpage.minbversion must be <= MINBVERSION +*/ #ifndef NOVERSION - if (ifpage.lversion < LVERSION) - { - fprintf(stderr, "Lisp VM is too old for this emulator.\n"); - fprintf(stderr, "(version is %d, must be at least %d.)\n", - ifpage.lversion, LVERSION); - exit(-1); - } + if (ifpage.lversion < LVERSION) { + fprintf(stderr, "Lisp VM is too old for this emulator.\n"); + fprintf(stderr, "(version is %d, must be at least %d.)\n", ifpage.lversion, LVERSION); + exit(-1); + } - if (ifpage.minbversion > MINBVERSION) - { - fprintf(stderr, "Emulator is too old for this Lisp VM.\n"); - fprintf(stderr, "(version is %d, must be at least %d.)\n", - MINBVERSION, ifpage.minbversion); - exit(-1); - } + if (ifpage.minbversion > MINBVERSION) { + fprintf(stderr, "Emulator is too old for this Lisp VM.\n"); + fprintf(stderr, "(version is %d, must be at least %d.)\n", MINBVERSION, ifpage.minbversion); + exit(-1); + } #endif /* NOVERSION */ #ifdef NEW_STORAGE - if(sys_size == 0) /* use default or the previous one */ - { - if(ifpage.process_size == 0) /* Pure LISP.SYSOUT */ - sys_size = DEFAULT_MAX_SYSOUTSIZE; /* default for pure SYSOUT */ - else - sys_size = ifpage.process_size; /* use previous one */ - } - - /* Checks for specifying the process size (phase II) */ - if((ifpage.storagefullstate == SFS_ARRAYSWITCHED) || - (ifpage.storagefullstate == SFS_FULLYSWITCHED)) - { - /* Storage may be allocated from Secondary space */ - /* Therefore you can not change \\DefaultSecondMDSPage */ - if(ifpage.process_size != sys_size) - { - char tmp[200]; - sprintf(tmp, "\nsysout loader: Error, secondary space in use. You can't specify size.\nProcess size = %d\nSys size = %d\n", ifpage.process_size, sys_size); -#ifdef DOS - /* Note that we have an initialized display by now. */ - /* Hence we have to observe the display protocol. */ - VESA_errorexit( tmp ); -#else - fprintf(stderr,"sysout_loader: You can't specify the process size.\n"); - fprintf(stderr,"Because, secondary space is already used.\n"); - fprintf(stderr,"(size is %d, you specified %d.)\n", ifpage.process_size, sys_size); - exit(-1); -#endif /* DOS */ - } - /*Can use this sys_size as the process size */ - /* The sys_size should be same as the previous one */ - Storage_expanded=NIL; - } + if (sys_size == 0) /* use default or the previous one */ + { + if (ifpage.process_size == 0) /* Pure LISP.SYSOUT */ + sys_size = DEFAULT_MAX_SYSOUTSIZE; /* default for pure SYSOUT */ else - { /* assumes that we can expand the process space */ - Storage_expanded=T; - /* You can use secondary space , though it was STORAGEFULL - So, STORAGEFULL may be set to NIL later */ - } + sys_size = ifpage.process_size; /* use previous one */ + } + + /* Checks for specifying the process size (phase II) */ + if ((ifpage.storagefullstate == SFS_ARRAYSWITCHED) || + (ifpage.storagefullstate == SFS_FULLYSWITCHED)) { + /* Storage may be allocated from Secondary space */ + /* Therefore you can not change \\DefaultSecondMDSPage */ + if (ifpage.process_size != sys_size) { + char tmp[200]; + sprintf(tmp, + "\nsysout loader: Error, secondary space in use. You can't specify size.\nProcess " + "size = %d\nSys size = %d\n", + ifpage.process_size, sys_size); +#ifdef DOS + /* Note that we have an initialized display by now. */ + /* Hence we have to observe the display protocol. */ + VESA_errorexit(tmp); #else - if(sys_size == 0) sys_size = DEFAULT_MAX_SYSOUTSIZE; + fprintf(stderr, "sysout_loader: You can't specify the process size.\n"); + fprintf(stderr, "Because, secondary space is already used.\n"); + fprintf(stderr, "(size is %d, you specified %d.)\n", ifpage.process_size, sys_size); + exit(-1); +#endif /* DOS */ + } + /*Can use this sys_size as the process size */ + /* The sys_size should be same as the previous one */ + Storage_expanded = NIL; + } else { /* assumes that we can expand the process space */ + Storage_expanded = T; + /* You can use secondary space , though it was STORAGEFULL + So, STORAGEFULL may be set to NIL later */ + } +#else + if (sys_size == 0) sys_size = DEFAULT_MAX_SYSOUTSIZE; #endif /* NEW_STORAGE */ + /* allocate Virtual Memory Space */ + lispworld_scratch = valloc(sys_size * MBYTE); - /* allocate Virtual Memory Space */ + if (lispworld_scratch == NULL) { + fprintf(stderr, "sysout_loader: can't allocate Lisp %dMBytes VM \n", sys_size); + exit(-1); + } - lispworld_scratch = valloc(sys_size * MBYTE); + /* now you can access lispworld */ + Lisp_world = (DLword *)lispworld_scratch; - if (lispworld_scratch == NULL) - { - fprintf(stderr,"sysout_loader: can't allocate Lisp %dMBytes VM \n", - sys_size); - exit(-1); - } + DBPRINT(("VM allocated = 0x%x at 0x%x\n", sys_size * MBYTE, Lisp_world)); + DBPRINT(("Native Load Address = 0x%x\n", native_load_address)); - /* now you can access lispworld */ - Lisp_world = (DLword *) lispworld_scratch; + /* + * get FPTOVP location and SysoutFile size + */ - DBPRINT(("VM allocated = 0x%x at 0x%x\n", sys_size * MBYTE, Lisp_world)); - DBPRINT(("Native Load Address = 0x%x\n", native_load_address)); + /* get FPTOVP location from IFPAGE */ + fptovp_offset = ifpage.fptovpstart; + DBPRINT(("FPTOVP Location %d \n", fptovp_offset)); - /* - * get FPTOVP location and SysoutFile size - */ + /* get sysout file size in halfpage(256) */ + if (fstat(sysout, &stat_buf) == -1) { + perror("sysout_loader: can't get sysout file size"); + exit(-1); + } + sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2; - /* get FPTOVP location from IFPAGE */ - fptovp_offset = ifpage.fptovpstart; + DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2)); + DBPRINT(("vmem size = 0x%x\n", ifpage.nactivepages)); - DBPRINT(("FPTOVP Location %d \n", fptovp_offset)); + /* do some simple checks to see if this is really a sysout */ + if (ifpage.key != IFPAGE_KEYVAL) { + printf("sysout_loader: %s isn't a sysout:\nkey is %x, should be %x\n", sysout_file_name, + ifpage.key, IFPAGE_KEYVAL); + exit(1); + } - /* get sysout file size in halfpage(256) */ - if (fstat(sysout, &stat_buf) == -1) - { - perror("sysout_loader: can't get sysout file size"); - exit(-1); - } - sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2; + machinetype = ifpage.machinetype; - DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2)); - DBPRINT(("vmem size = 0x%x\n", ifpage.nactivepages)); + if ((stat_buf.st_size & 0x1ff) != 0) + printf("CAUTION::sysout & 0x1ff = 0x%x\n", stat_buf.st_size & BYTESPER_PAGE); - /* do some simple checks to see if this is really a sysout */ - if(ifpage.key != IFPAGE_KEYVAL) - { - printf("sysout_loader: %s isn't a sysout:\nkey is %x, should be %x\n", - sysout_file_name, ifpage.key, IFPAGE_KEYVAL); - exit(1); - } + if (ifpage.nactivepages != (sysout_size / 2)) { + printf("sysout_loader:IFPAGE says sysout size is %d\n", ifpage.nactivepages); + printf("But, sysout size from UNIX is %d\n", sysout_size / 2); + exit(-1); + } - machinetype = ifpage.machinetype; +/* + * Now get FPTOVP + */ - if(( stat_buf.st_size & 0x1ff) != 0) - printf("CAUTION::sysout & 0x1ff = 0x%x\n", - stat_buf.st_size & BYTESPER_PAGE); - - if(ifpage.nactivepages != ( sysout_size /2) ) - { - printf("sysout_loader:IFPAGE says sysout size is %d\n", - ifpage.nactivepages); - printf("But, sysout size from UNIX is %d\n",sysout_size /2); - exit(-1); - } - - /* - * Now get FPTOVP - */ - - /* seek to FPTOVP */ +/* seek to FPTOVP */ #ifdef BIGVM - fptovp_offset = (fptovp_offset - 1) * BYTESPER_PAGE + 4; + fptovp_offset = (fptovp_offset - 1) * BYTESPER_PAGE + 4; #else - fptovp_offset = (fptovp_offset - 1) * BYTESPER_PAGE + 2; + fptovp_offset = (fptovp_offset - 1) * BYTESPER_PAGE + 2; #endif - if (lseek(sysout, fptovp_offset, 0) == -1) - { - perror("sysout_loader: can't seek to FPTOVP"); - exit(-1); - } + if (lseek(sysout, fptovp_offset, 0) == -1) { + perror("sysout_loader: can't seek to FPTOVP"); + exit(-1); + } - /* read FPTOVP */ +/* read FPTOVP */ #ifdef BIGVM - /* fptovp is now in cells, not words */ - if (read(sysout, fptovp, sysout_size*2) == -1) - { - perror("sysout_loader: can't read FPTOVP"); - exit(-1); - } + /* fptovp is now in cells, not words */ + if (read(sysout, fptovp, sysout_size * 2) == -1) { + perror("sysout_loader: can't read FPTOVP"); + exit(-1); + } #ifdef BYTESWAP - word_swap_page(fptovp, (sysout_size/2)+1); /* So space to swap is twice as big, too. */ -#endif /* BYTESWAP */ + word_swap_page(fptovp, (sysout_size / 2) + 1); /* So space to swap is twice as big, too. */ +#endif /* BYTESWAP */ #else - if (read(sysout, fptovp, sysout_size) == -1) - { - perror("sysout_loader: can't read FPTOVP"); - exit(-1); - } + if (read(sysout, fptovp, sysout_size) == -1) { + perror("sysout_loader: can't read FPTOVP"); + exit(-1); + } #ifdef BYTESWAP - word_swap_page(fptovp, (sysout_size/4)+1); + word_swap_page(fptovp, (sysout_size / 4) + 1); #endif /* BYTESWAP */ #endif /* BIGVM */ - /* - * Initialize the display (note now passing 68k address!!!) - */ - init_display2(Addr68k_from_LADDR(DISPLAY_OFFSET), 65536 * 16 * 2); + /* + * Initialize the display (note now passing 68k address!!!) + */ + init_display2(Addr68k_from_LADDR(DISPLAY_OFFSET), 65536 * 16 * 2); - /* read sysout file to lispworld */ + /* read sysout file to lispworld */ - for (i = 0; i < (sysout_size / 2); i++) - { + for (i = 0; i < (sysout_size / 2); i++) { #ifdef DOS - /* Dial that floats from left to right on the top line of the */ - /* displaty. Dial shows % of sysout loaded by digits and */ - /* position. */ - int columns; - switch (currentdsp->graphicsmode){ - case 0x104: columns = 120; /* 131 - 10 */ - break; - case 0x102: columns = 69; /* 79 - 10 */ - break; - default: columns = 69; /* 79 - 10 */ - break; - } - _settextposition((short)0, (short)0); - if ((i & 0xf) == 0){ - for (j = 0; j < (columns * i) / (sysout_size >> 1); j++) putchar(' '); - printf("-=(%2d%%)=-\n", (100 * i) / (sysout_size >> 1)); - } + /* Dial that floats from left to right on the top line of the */ + /* displaty. Dial shows % of sysout loaded by digits and */ + /* position. */ + int columns; + switch (currentdsp->graphicsmode) { + case 0x104: + columns = 120; /* 131 - 10 */ + break; + case 0x102: + columns = 69; /* 79 - 10 */ + break; + default: + columns = 69; /* 79 - 10 */ + break; + } + _settextposition((short)0, (short)0); + if ((i & 0xf) == 0) { + for (j = 0; j < (columns * i) / (sysout_size >> 1); j++) putchar(' '); + printf("-=(%2d%%)=-\n", (100 * i) / (sysout_size >> 1)); + } #endif /* DOS */ - if (GETPAGEOK(fptovp,i) != 0177777) - { - if (lseek(sysout, i * BYTESPER_PAGE, 0) == -1) - { - perror("sysout_loader: can't seek sysout file"); - exit(-1); - }; - lispworld_offset = GETFPTOVP(fptovp,i) * BYTESPER_PAGE; - if (read(sysout, lispworld_scratch + - lispworld_offset , BYTESPER_PAGE) == -1) - { - printf("sysout_loader: can't read sysout file at %d\n", i); - printf(" offset was 0x%x (0x%x pages).\n", - lispworld_offset, GETFPTOVP(fptovp,i)); - perror("read() error was"); - { int j; - for (j = 0; j < 10; j++) printf(" %d: 0x%x ", j, GETFPTOVP(fptovp,j)); - } - exit(-1); - }; + if (GETPAGEOK(fptovp, i) != 0177777) { + if (lseek(sysout, i * BYTESPER_PAGE, 0) == -1) { + perror("sysout_loader: can't seek sysout file"); + exit(-1); + }; + lispworld_offset = GETFPTOVP(fptovp, i) * BYTESPER_PAGE; + if (read(sysout, lispworld_scratch + lispworld_offset, BYTESPER_PAGE) == -1) { + printf("sysout_loader: can't read sysout file at %d\n", i); + printf(" offset was 0x%x (0x%x pages).\n", lispworld_offset, + GETFPTOVP(fptovp, i)); + perror("read() error was"); + { + int j; + for (j = 0; j < 10; j++) printf(" %d: 0x%x ", j, GETFPTOVP(fptovp, j)); + } + exit(-1); + }; #ifdef BYTESWAP - word_swap_page(lispworld_scratch+lispworld_offset, 128); + word_swap_page(lispworld_scratch + lispworld_offset, 128); #endif + }; + } - }; - } - - DBPRINT(("sysout file is read completely.\n")); - + DBPRINT(("sysout file is read completely.\n")); #if (defined(DISPLAYBUFFER) || defined(XWINDOW) || defined(DOS)) - TPRINT(("Flushing display buffer...\n")) - flush_display_buffer(); - TPRINT(("After Flushing display buffer\n")) + TPRINT(("Flushing display buffer...\n")) + flush_display_buffer(); + TPRINT(("After Flushing display buffer\n")) #endif /* DISPLAYBUFFER || XWINDOW || DOS */ - close(sysout); - return(sys_size); - } + close(sysout); + return (sys_size); +} diff --git a/src/lineblt8.c b/src/lineblt8.c old mode 100755 new mode 100644 index 57830ee..30bc2a1 --- a/src/lineblt8.c +++ b/src/lineblt8.c @@ -1,12 +1,7 @@ -/* $Id: lineblt8.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lineblt8.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lineblt8.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copyright (C) Venue"; - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -21,8 +16,6 @@ static char *id = "$Id: lineblt8.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copy #include "version.h" - - #include #include "lispemul.h" @@ -30,120 +23,108 @@ static char *id = "$Id: lineblt8.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copy #include #endif /* ISC */ - -#define COLOR8ARRAYSIZE 16 -#define BITSPERNIBBLE 4 +#define COLOR8ARRAYSIZE 16 +#define BITSPERNIBBLE 4 #define BITSPERDLWORD 16 -DLword BitMaskArray[]={32768,16384,8192,4096,2048,1024, - 512,256,128,64,32,16,8,4,2,1}; -unsigned int ConvBM_tbl[] = { - 0 , 0xff , 0xff00 , 0xffff , - 0xff0000 , 0xff00ff , 0xffff00 , 0xffffff , - 0xff000000 , 0xff0000ff , 0xff00ff00 , 0xff00ffff , - 0xffff0000 , 0xffff00ff , 0xffffff00 , 0xffffffff }; -unsigned int BMask_tbl[] = { 0xf , 7 , 3 , 1 }; +DLword BitMaskArray[] = {32768, 16384, 8192, 4096, 2048, 1024, 512, 256, + 128, 64, 32, 16, 8, 4, 2, 1}; +unsigned int ConvBM_tbl[] = {0, 0xff, 0xff00, 0xffff, 0xff0000, 0xff00ff, + 0xffff00, 0xffffff, 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, + 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff}; +unsigned int BMask_tbl[] = {0xf, 7, 3, 1}; #define noop 1 -/*************************************************************** - Macro:WriteLongW +/*************************************************************** + Macro:WriteLongW **************************************************************/ -#define WriteLongW(srcpattern,destptr,op1,op2) {\ - register cnt;\ - register u_char *des,*src;\ - for(cnt=0,des=(u_char*)destptr,src=(u_char*)(&(srcpattern));\ - cnt <4 ; cnt++,des++,src++)\ - (*des) op1 (*src);} +#define WriteLongW(srcpattern, destptr, op1, op2) \ + { \ + register cnt; \ + register u_char *des, *src; \ + for (cnt = 0, des = (u_char *)destptr, src = (u_char *)(&(srcpattern)); cnt < 4; \ + cnt++, des++, src++) \ + (*des) op1(*src); \ + } - -/*************************************************************** - Macro:LineBLT8 - srcWptr : DLword ptr - offset : Bits offset - width : Bits width to copy - dstLptr : Destination's LispPTR ptr - op1,op2 : operations in C(=,|=,^=,&=,^) - ERASE only uses op2 +/*************************************************************** + Macro:LineBLT8 + srcWptr : DLword ptr + offset : Bits offset + width : Bits width to copy + dstLptr : Destination's LispPTR ptr + op1,op2 : operations in C(=,|=,^=,&=,^) + ERASE only uses op2 **************************************************************/ - /* srcw points DLword which contains the nibble processed now */ - /* offset indicates MSB in the nibble */ - /* width:before copy,make sure the nibble is inside source bitmap */ - /* width:after copy,decremented by BITSPERNIBBLE. - therefore,width indictes the rest bits in source bitmap */ - -#define LineBLT8(srcWptr,offset,width,dstLptr,op1,op2){ \ - register DLword *srcw; \ - register u_int temp1; \ - for(srcw= (srcWptr) + (offset)/BITSPERDLWORD ; \ - ((width) -BITSPERNIBBLE)>= 0; \ - (width) -=BITSPERNIBBLE, \ - (dstLptr) = (u_char *) ((u_int *)(dstLptr) + 1), \ - (offset)+=BITSPERNIBBLE) \ - {\ - switch((offset) % 16) {\ - case 0 : WriteLongW(color_array[(*srcw )>> 12],dstLptr,op1,op2);\ - break;\ - case 1 : WriteLongW(color_array[(*srcw & 0x7800) >> 11],dstLptr,op1,op2); \ - break;\ - case 2 : WriteLongW(color_array[(*srcw & 0x3c00) >> 10],dstLptr,op1,op2); \ - break;\ - case 3 : WriteLongW(color_array[(*srcw & 0x1e00) >> 9],dstLptr,op1,op2);\ - break;\ - case 4 : WriteLongW(color_array[(*srcw & 0x0f00) >> 8],dstLptr,op1,op2);\ - break;\ - case 5 : WriteLongW(color_array[(*srcw & 0x0780) >> 7],dstLptr,op1,op2);\ - break;\ - case 6 : WriteLongW(color_array[(*srcw & 0x03c0) >> 6],dstLptr,op1,op2);\ - break;\ - case 7 : WriteLongW(color_array[(*srcw & 0x01e0) >> 5],dstLptr,op1,op2);\ - break;\ - case 8 : WriteLongW(color_array[(*srcw & 0x00f0) >> 4],dstLptr,op1,op2);\ - break;\ - case 9 : WriteLongW(color_array[(*srcw & 0x0078) >> 3],dstLptr,op1,op2);\ - break;\ - case 10 : WriteLongW(color_array[(*srcw & 0x003c) >> 2],dstLptr,op1,op2);\ - break;\ - case 11 : WriteLongW(color_array[(*srcw & 0x001e) >> 1],dstLptr,op1,op2);\ - break;\ - case 12 : WriteLongW(color_array[*srcw & 0xf],dstLptr,op1,op2);\ - srcw++; /* move srcw pointer */\ - break;\ - case 13 : temp1= (*srcw & 7) << 1 ;\ - temp1 |= ((*(++srcw)) & 0x8000)>> 15 ;/** Compiler's BUG?*/\ - WriteLongW(color_array[temp1],dstLptr,op1,op2);\ - break;\ - case 14 : temp1= ((*srcw & 3) << 2) ;\ - temp1 |= ((*(++srcw) & 0xc000)>> 14) ;\ - WriteLongW(color_array[temp1],dstLptr,op1,op2);\ - break;\ - case 15 : temp1= ((*srcw & 1) << 3);\ - temp1 |= ((*(++srcw) & 0xe000)>> 13) ;\ - WriteLongW(color_array[temp1],dstLptr,op1,op2);\ - break;\ - } /* switch end */\ - } /* for end */\ -/* process for the rest bits (0~3)*/\ -switch(width)\ -{ register u_char *destc;\ - register int mod;\ - case 0: /* already finished */\ - break;\ - case 1: \ - case 2:\ - case 3: destc=(u_char *)dstLptr;\ - while(width--){\ - if(BitMaskArray[mod =(offset %16)] & *srcw) \ - (*destc++) op1 (color1);\ - else (*destc++) op1 (color0);\ - if(mod == 15) srcw++;\ - offset++;\ - } /* WHILE END */\ - break;\ - default: ;/* error */\ -}/* switch end */\ -} /* MACRO END */ +/* srcw points DLword which contains the nibble processed now */ +/* offset indicates MSB in the nibble */ +/* width:before copy,make sure the nibble is inside source bitmap */ +/* width:after copy,decremented by BITSPERNIBBLE. + therefore,width indictes the rest bits in source bitmap */ +#define LineBLT8(srcWptr, offset, width, dstLptr, op1, op2) \ + { \ + register DLword *srcw; \ + register u_int temp1; \ + for (srcw = (srcWptr) + (offset) / BITSPERDLWORD; ((width)-BITSPERNIBBLE) >= 0; \ + (width) -= BITSPERNIBBLE, (dstLptr) = (u_char *)((u_int *)(dstLptr) + 1), \ + (offset) += BITSPERNIBBLE) { \ + switch ((offset) % 16) { \ + case 0: WriteLongW(color_array[(*srcw) >> 12], dstLptr, op1, op2); break; \ + case 1: WriteLongW(color_array[(*srcw & 0x7800) >> 11], dstLptr, op1, op2); break; \ + case 2: WriteLongW(color_array[(*srcw & 0x3c00) >> 10], dstLptr, op1, op2); break; \ + case 3: WriteLongW(color_array[(*srcw & 0x1e00) >> 9], dstLptr, op1, op2); break; \ + case 4: WriteLongW(color_array[(*srcw & 0x0f00) >> 8], dstLptr, op1, op2); break; \ + case 5: WriteLongW(color_array[(*srcw & 0x0780) >> 7], dstLptr, op1, op2); break; \ + case 6: WriteLongW(color_array[(*srcw & 0x03c0) >> 6], dstLptr, op1, op2); break; \ + case 7: WriteLongW(color_array[(*srcw & 0x01e0) >> 5], dstLptr, op1, op2); break; \ + case 8: WriteLongW(color_array[(*srcw & 0x00f0) >> 4], dstLptr, op1, op2); break; \ + case 9: WriteLongW(color_array[(*srcw & 0x0078) >> 3], dstLptr, op1, op2); break; \ + case 10: WriteLongW(color_array[(*srcw & 0x003c) >> 2], dstLptr, op1, op2); break; \ + case 11: WriteLongW(color_array[(*srcw & 0x001e) >> 1], dstLptr, op1, op2); break; \ + case 12: \ + WriteLongW(color_array[*srcw & 0xf], dstLptr, op1, op2); \ + srcw++; /* move srcw pointer */ \ + break; \ + case 13: \ + temp1 = (*srcw & 7) << 1; \ + temp1 |= ((*(++srcw)) & 0x8000) >> 15; /** Compiler's BUG?*/ \ + WriteLongW(color_array[temp1], dstLptr, op1, op2); \ + break; \ + case 14: \ + temp1 = ((*srcw & 3) << 2); \ + temp1 |= ((*(++srcw) & 0xc000) >> 14); \ + WriteLongW(color_array[temp1], dstLptr, op1, op2); \ + break; \ + case 15: \ + temp1 = ((*srcw & 1) << 3); \ + temp1 |= ((*(++srcw) & 0xe000) >> 13); \ + WriteLongW(color_array[temp1], dstLptr, op1, op2); \ + break; \ + } /* switch end */ \ + } /* for end */ \ + /* process for the rest bits (0~3)*/ \ + switch (width) { \ + register u_char *destc; \ + register int mod; \ + case 0: /* already finished */ break; \ + case 1: \ + case 2: \ + case 3: \ + destc = (u_char *)dstLptr; \ + while (width--) { \ + if (BitMaskArray[mod = (offset % 16)] & *srcw) \ + (*destc++) op1(color1); \ + else \ + (*destc++) op1(color0); \ + if (mod == 15) srcw++; \ + offset++; \ + } /* WHILE END */ \ + break; \ + default:; /* error */ \ + } /* switch end */ \ + } /* MACRO END */ /************************************************************************/ /* */ @@ -157,76 +138,61 @@ switch(width)\ /* I don't care sourcetype & operation NOW */ -void lineBlt8(DLword *srcbase, register int offset, register u_char *destl, register int width, u_char color0, u_char color1, LispPTR sourcetype, LispPTR operation) - - - /* register u_int *destl;*/ - /* for SPARC */ - - /* Background color */ - /* foreground color */ - - /*operation type PAINT,REPLACE or INVERT */ +void lineBlt8(DLword *srcbase, register int offset, register u_char *destl, register int width, + u_char color0, u_char color1, LispPTR sourcetype, LispPTR operation) - { - static unsigned char beforecolor0=0; - static unsigned char beforecolor1=0; - static color_array[COLOR8ARRAYSIZE]; +/* register u_int *destl;*/ +/* for SPARC */ - extern DLword REPLACE_atom; - extern DLword INPUT_atom; - extern DLword INVERT_atom; - extern DLword PAINT_atom; - extern DLword ERASE_atom; +/* Background color */ +/* foreground color */ +/*operation type PAINT,REPLACE or INVERT */ +{ + static unsigned char beforecolor0 = 0; + static unsigned char beforecolor1 = 0; + static color_array[COLOR8ARRAYSIZE]; - DLword *baseword; /* Assume dest word always quad aligned */ + extern DLword REPLACE_atom; + extern DLword INPUT_atom; + extern DLword INVERT_atom; + extern DLword PAINT_atom; + extern DLword ERASE_atom; + DLword *baseword; /* Assume dest word always quad aligned */ - if(sourcetype == INVERT_atom) - { - register tempcol; - tempcol = color0; - color0 = color1; - color1 = tempcol; - } - if((beforecolor0 != color0) || (beforecolor1 != color1)) - { - /* making color-mapped array */ - register i; - register u_int longcol0,longcol1; - - beforecolor0 = color0; - beforecolor1 = color1; - longcol0 = (color0 << 24) | (color0 << 16) | (color0 << 8) | color0; - longcol1 = (color1 << 24) | (color1 << 16) | (color1 << 8) | color1; - - for(i=0;i < COLOR8ARRAYSIZE;i++) - { - color_array[i] = ConvBM_tbl[i] & longcol1; - color_array[i] |= (~(ConvBM_tbl[i])) & longcol0; - } - } /* otherwise previous colors are same as current one. use cached one */ - - if(operation == REPLACE_atom) - { - LineBLT8(srcbase,offset,width,destl,=,noop); - } - else if (operation == INVERT_atom) - { - LineBLT8(srcbase,offset,width,destl,^=,noop); - } - else if (operation == PAINT_atom) - { - LineBLT8(srcbase,offset,width,destl,|=,noop); - } - else if (operation == ERASE_atom) - { /*erase */ - LineBLT8(srcbase,offset,width,destl,&=~,noop); - } - else error("lineBlt8:Illegal operation specified"); - + if (sourcetype == INVERT_atom) { + register tempcol; + tempcol = color0; + color0 = color1; + color1 = tempcol; } -/* lineBlt8 end */ + if ((beforecolor0 != color0) || (beforecolor1 != color1)) { + /* making color-mapped array */ + register i; + register u_int longcol0, longcol1; + beforecolor0 = color0; + beforecolor1 = color1; + longcol0 = (color0 << 24) | (color0 << 16) | (color0 << 8) | color0; + longcol1 = (color1 << 24) | (color1 << 16) | (color1 << 8) | color1; + + for (i = 0; i < COLOR8ARRAYSIZE; i++) { + color_array[i] = ConvBM_tbl[i] & longcol1; + color_array[i] |= (~(ConvBM_tbl[i])) & longcol0; + } + } /* otherwise previous colors are same as current one. use cached one */ + + if (operation == REPLACE_atom) { + LineBLT8(srcbase, offset, width, destl, =, noop); + } else if (operation == INVERT_atom) { + LineBLT8(srcbase, offset, width, destl, ^=, noop); + } else if (operation == PAINT_atom) { + LineBLT8(srcbase, offset, width, destl, |=, noop); + } else if (operation == ERASE_atom) { /*erase */ + LineBLT8(srcbase, offset, width, destl, &= ~, noop); + } else + error("lineBlt8:Illegal operation specified"); +} +/* lineBlt8 end */ diff --git a/src/lisp2c.c b/src/lisp2c.c old mode 100755 new mode 100644 index 50b779b..81bcb58 --- a/src/lisp2c.c +++ b/src/lisp2c.c @@ -1,10 +1,9 @@ -/* $Id: lisp2c.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lisp2c.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lisp2c.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copyright (C) Venue"; /* File containing the conversion functions between lisp and C */ /* -jarl */ - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -30,111 +29,82 @@ static char *id = "$Id: lisp2c.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copyri #include "medleyfp.h" #include "arith.h" - - - -int LispStringP(LispPTR object) -{ +int LispStringP(LispPTR object) { int type; type = ((OneDArray *)Addr68k_from_LADDR(object))->typenumber; - return((type == THIN_CHAR_TYPENUMBER) || (type == FAT_CHAR_TYPENUMBER)); + return ((type == THIN_CHAR_TYPENUMBER) || (type == FAT_CHAR_TYPENUMBER)); } - - -int LispStringLength (LispPTR lispstring) -{ - OneDArray *arrayp; +int LispStringLength(LispPTR lispstring) { + OneDArray *arrayp; arrayp = (OneDArray *)(Addr68k_from_LADDR(lispstring)); - return(arrayp->fillpointer); + return (arrayp->fillpointer); } - - -void LispStringToCStr (LispPTR lispstring, char *cstring) -{ +void LispStringToCStr(LispPTR lispstring, char *cstring) { OneDArray *arrayp; - char *base; - short *sbase; - int i, Len; + char *base; + short *sbase; + int i, Len; arrayp = (OneDArray *)(Addr68k_from_LADDR((UNSIGNED)lispstring)); Len = arrayp->fillpointer; - switch(arrayp->typenumber) - { + switch (arrayp->typenumber) { case THIN_CHAR_TYPENUMBER: - base = ((char *) - (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) - + ((int)(arrayp->offset)); - for(i=0;ibase))) + ((int)(arrayp->offset)); + for (i = 0; i < Len; i++) cstring[i] = base[i]; cstring[Len] = '\0'; break; case FAT_CHAR_TYPENUMBER: - sbase = ((short *) - (Addr68k_from_LADDR((UNSIGNED)arrayp->base))) - + ((int)(arrayp->offset)); + sbase = ((short *)(Addr68k_from_LADDR((UNSIGNED)arrayp->base))) + ((int)(arrayp->offset)); base = (char *)sbase; - for(i=0;i 0xFFFF) { /* its a fixp! */ +LispPTR CIntToLispInt(int cint) { + if (abs(cint) > 0xFFFF) { /* its a fixp! */ register LispPTR *wordp; - wordp = (LispPTR *) createcell68k(TYPE_FIXP); + wordp = (LispPTR *)createcell68k(TYPE_FIXP); *((int *)wordp) = cint; - return(LADDR_from_68k(wordp)); - } else if (cint >= 0) { /* its a positive smallp! */ - return(S_POSITIVE | cint); - } else { /* its a negative smallp! */ - return(S_NEGATIVE | (0xFFFF & cint)); + return (LADDR_from_68k(wordp)); + } else if (cint >= 0) { /* its a positive smallp! */ + return (S_POSITIVE | cint); + } else { /* its a negative smallp! */ + return (S_NEGATIVE | (0xFFFF & cint)); } } -DLword CIntToSmallp(int cint) -{ - if (abs(cint) > 0xFFFF) { /* its a fixp! */ +DLword CIntToSmallp(int cint) { + if (abs(cint) > 0xFFFF) { /* its a fixp! */ error("Arg not a Smallp.\n"); - } else if (cint >= 0) { /* its a positive smallp! */ - return(S_POSITIVE | cint); - } else { /* its a negative smallp! */ - return(S_NEGATIVE | (0xFFFF & cint)); + } else if (cint >= 0) { /* its a positive smallp! */ + return (S_POSITIVE | cint); + } else { /* its a negative smallp! */ + return (S_NEGATIVE | (0xFFFF & cint)); } } diff --git a/src/llcolor.c b/src/llcolor.c old mode 100755 new mode 100644 index 6db4ff2..cc3c1f8 --- a/src/llcolor.c +++ b/src/llcolor.c @@ -1,10 +1,7 @@ -/* $Id: llcolor.c,v 1.2 1999/01/03 02:07:15 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: llcolor.c,v 1.2 1999/01/03 02:07:15 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: llcolor.c,v 1.2 1999/01/03 02:07:15 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,7 +16,6 @@ static char *id = "$Id: llcolor.c,v 1.2 1999/01/03 02:07:15 sybalsky Exp $ Copyr #include "version.h" - #include #ifndef NOPIXRECT @@ -50,201 +46,182 @@ static char *id = "$Id: llcolor.c,v 1.2 1999/01/03 02:07:15 sybalsky Exp $ Copyr #include "bb.h" #include "bitblt.h" -#include "pilotbbt.h" +#include "pilotbbt.h" #include "dbprint.h" -int MonoOrColor=MONO_SCREEN; +int MonoOrColor = MONO_SCREEN; DLword *ColorDisplayRegion68k; int Dispcolorsize; int Inited_Color = NIL; extern struct pixrect *ColorDisplayPixrect; -extern int displaywidth - , displayheight - , FrameBufferFd; +extern int displaywidth, displayheight, FrameBufferFd; /*******************************************************************/ /* Func name : cgfour_init_color_display(args) - Arg(s) : COLOR BITMAP ADDRESS(LISPPTR) - Desc : Assign to SUBR 0210 - mmap LispPTR to Color Display FB. - By Takeshi + Arg(s) : COLOR BITMAP ADDRESS(LISPPTR) + Desc : Assign to SUBR 0210 + mmap LispPTR to Color Display FB. + By Takeshi */ /*******************************************************************/ #ifdef COLOR cgfour_init_color_display(color_bitmapbase) /* SUBR 0210 */ - LispPTR color_bitmapbase; /* COLOR BITMAP ADDRESS */ - { - struct pixrect *ColorFb; - struct pixrect *color_source; - int mmapstat; + LispPTR color_bitmapbase; /* COLOR BITMAP ADDRESS */ +{ + struct pixrect *ColorFb; + struct pixrect *color_source; + int mmapstat; - if(MonoOrColor == COLOR_SCREEN) { - printf("You can not initialize the color screen from inside color screen. \n"); + if (MonoOrColor == COLOR_SCREEN) { + printf("You can not initialize the color screen from inside color screen. \n"); } - ColorDisplayRegion68k = Addr68k_from_LADDR(color_bitmapbase ); - - Dispcolorsize = ((displaywidth * displayheight + (getpagesize()-1) ) - & -getpagesize()); /* 8 bit depth */ + ColorDisplayRegion68k = Addr68k_from_LADDR(color_bitmapbase); + + Dispcolorsize = + ((displaywidth * displayheight + (getpagesize() - 1)) & -getpagesize()); /* 8 bit depth */ #ifndef DISPLAYBUFFER - ColorFb = pr_open("/dev/fb"); -#else - ColorFb = ColorDisplayPixrect; + ColorFb = pr_open("/dev/fb"); +#else + ColorFb = ColorDisplayPixrect; #endif /* DISPLAYBUFFER */ - #ifndef DISPLAYBUFFER - color_source = mem_point(displaywidth,displayheight,8, - ColorDisplayRegion68k); - - pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); - pr_rop(ColorFb,0,0,displaywidth,displayheight,PIX_SRC, - color_source,0,0); + color_source = mem_point(displaywidth, displayheight, 8, ColorDisplayRegion68k); - mmapstat = (int)mmap(ColorDisplayRegion68k , - Dispcolorsize, - PROT_READ | PROT_WRITE, + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); + pr_rop(ColorFb, 0, 0, displaywidth, displayheight, PIX_SRC, color_source, 0, 0); + + mmapstat = (int)mmap(ColorDisplayRegion68k, Dispcolorsize, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif - MAP_SHARED, - FrameBufferFd, 0x40000 ); - if(mmapstat == -1){ - perror("cgfour_init_color_display: ERROR at mmap system call\n"); - error ("cgfour_init_color_display: ERROR at mmap system call\n You may be able to continue by typing 'q'"); - } + MAP_SHARED, + FrameBufferFd, 0x40000); + if (mmapstat == -1) { + perror("cgfour_init_color_display: ERROR at mmap system call\n"); + error( + "cgfour_init_color_display: ERROR at mmap system call\n You may be able to continue by " + "typing 'q'"); + } #endif /* DISPLAYBUFFER */ + printf("COLOR-INIT OK BMBASE=0x%x\nNATIVE:= 0x%x)\n", color_bitmapbase, ColorDisplayRegion68k); - printf("COLOR-INIT OK BMBASE=0x%x\nNATIVE:= 0x%x)\n", - color_bitmapbase,ColorDisplayRegion68k); + Inited_Color = T; /* Color display is active. */ - Inited_Color = T; /* Color display is active. */ + return (color_bitmapbase); +} /* end cgfour_init_color_display */ - return(color_bitmapbase); - } /* end cgfour_init_color_display */ - -#else /* COLOR */ +#else /* COLOR */ LispPTR cgfour_init_color_display(color_bitmapbase) /* SUBR 0210 */ - LispPTR color_bitmapbase; /* COLOR BITMAP ADDRESS */ + LispPTR color_bitmapbase; /* COLOR BITMAP ADDRESS */ { - printf( "Color is not supported.\n" ); - return (NIL); + printf("Color is not supported.\n"); + return (NIL); } #endif /* COLOR */ /*******************************************************************/ /* Func name : cgfour_change_screen_mode(which_screen) - Arg(s) : MONO_SCREEN OR COLOR_SCREEN - Desc : Assign to SUBR 0211 - Change screen Mono to Color,vice versa. - By Takeshi + Arg(s) : MONO_SCREEN OR COLOR_SCREEN + Desc : Assign to SUBR 0211 + Change screen Mono to Color,vice versa. + By Takeshi */ /*******************************************************************/ #ifdef COLOR -LispPTR cgfour_change_screen_mode(which_screen) - LispPTR which_screen; - { /* subr 0211 */ - struct pixrect *ColorFb; - extern ScreenLocked; - extern DLword *EmCursorX68K,*EmCursorY68K; +LispPTR cgfour_change_screen_mode(which_screen) LispPTR which_screen; +{ /* subr 0211 */ + struct pixrect *ColorFb; + extern ScreenLocked; + extern DLword *EmCursorX68K, *EmCursorY68K; - int mmapstat; + int mmapstat; #ifndef DISPLAYBUFFER - ColorFb = pr_open("/dev/fb"); -#else - ColorFb = ColorDisplayPixrect; + ColorFb = pr_open("/dev/fb"); +#else + ColorFb = ColorDisplayPixrect; #endif /* DISPLAYBUFFER */ - ScreenLocked=T; - taking_mouse_down(); + ScreenLocked = T; + taking_mouse_down(); - switch (which_screen & 0xf) { - case MONO_SCREEN : { /* resume mono screen */ + switch (which_screen & 0xf) { + case MONO_SCREEN: { /* resume mono screen */ #ifdef DISPLAYBUFFER - mmapstat = (int)munmap( ColorDisplayRegion68k, Dispcolorsize ); - if( mmapstat == -1){ - perror("cg_four_change_screen: ERROR at munmap system call\n"); - exit( 0 ); - } /* end if(mmapstat) */ - save_color_screen(); + mmapstat = (int)munmap(ColorDisplayRegion68k, Dispcolorsize); + if (mmapstat == -1) { + perror("cg_four_change_screen: ERROR at munmap system call\n"); + exit(0); + } /* end if(mmapstat) */ + save_color_screen(); #endif /* DISPLAYBUFFER */ - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb,0,0, - ColorFb->pr_width, - ColorFb->pr_height, PIX_SET, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); #ifdef DISPLAYBUFFER - flush_display_buffer(); + flush_display_buffer(); #endif /* DISPLAYBUFFER */ - MonoOrColor = MONO_SCREEN; - break; - } - case COLOR_SCREEN : { -#ifndef DISPLAYBUFFER - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb,0,0, - ColorFb->pr_width, - ColorFb->pr_height, PIX_CLR, 0, 0, 0); -#endif /* DISPLAYBUFFER */ - - pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); -#ifdef DISPLAYBUFFER - restore_color_screen(); - mmapstat = (int)mmap(ColorDisplayRegion68k , - Dispcolorsize, - PROT_READ | PROT_WRITE, -#ifdef OS4 - MAP_FIXED | -#endif - MAP_SHARED, - FrameBufferFd, 0x40000 ); - if(mmapstat == -1){ - perror("cg_four_change_screen: ERROR at mmap system call\n"); - exit(0); - } -#endif /* DISPLAYBUFFER */ - - MonoOrColor = COLOR_SCREEN; - break; - } - default : { - error("cgfour_change_screen_mode:Unknown mode:"); - } - }; - -#ifndef DISPLAYBUFFER - pr_close(ColorFb); -#endif /* DISPLAYBUFFER */ - - - taking_mouse_up(*EmCursorX68K,*EmCursorY68K); - ScreenLocked=NIL; - return(which_screen); + MonoOrColor = MONO_SCREEN; + break; } -#else /* COLOR */ + case COLOR_SCREEN: { +#ifndef DISPLAYBUFFER + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_CLR, 0, 0, 0); +#endif /* DISPLAYBUFFER */ -LispPTR cgfour_change_screen_mode(which_screen) - LispPTR which_screen; + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); +#ifdef DISPLAYBUFFER + restore_color_screen(); + mmapstat = (int)mmap(ColorDisplayRegion68k, Dispcolorsize, PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x40000); + if (mmapstat == -1) { + perror("cg_four_change_screen: ERROR at mmap system call\n"); + exit(0); + } +#endif /* DISPLAYBUFFER */ + + MonoOrColor = COLOR_SCREEN; + break; + } + default: { error("cgfour_change_screen_mode:Unknown mode:"); } + }; + +#ifndef DISPLAYBUFFER + pr_close(ColorFb); +#endif /* DISPLAYBUFFER */ + + taking_mouse_up(*EmCursorX68K, *EmCursorY68K); + ScreenLocked = NIL; + return (which_screen); +} +#else /* COLOR */ + +LispPTR cgfour_change_screen_mode(which_screen) LispPTR which_screen; { - printf( "Color is not supported.\n" ); - return (NIL); + printf("Color is not supported.\n"); + return (NIL); } #endif /* COLOR */ - /*******************************************************************/ /* Func name : cgfour_set_colormap(args) - Arg(s) : Passed by args - index: colormap index(0~255) - red,green,blue:(0~255) - Desc : Assign to SUBR 0212 - Set Colormap entry - By Takeshi + Arg(s) : Passed by args + index: colormap index(0~255) + red,green,blue:(0~255) + Desc : Assign to SUBR 0212 + Set Colormap entry + By Takeshi */ /*******************************************************************/ unsigned char RED_colormap; @@ -252,111 +229,80 @@ unsigned char GRN_colormap; unsigned char BLU_colormap; #ifdef COLOR -LispPTR cgfour_set_colormap(args) - LispPTR args[]; - { - int index; - struct pixrect *ColorFb; - - index=args[0] & 0xff; - - RED_colormap = (unsigned char) (args[1] & 0xff); - GRN_colormap = (unsigned char) (args[2] & 0xff); - BLU_colormap = (unsigned char) (args[3] & 0xff); - - ColorFb = pr_open("/dev/fb"); - - if (pr_putcolormap(ColorFb,index,1, - &RED_colormap, - &GRN_colormap, - &BLU_colormap)==-1) - perror("putcolormap:"); - pr_close(ColorFb); - return(T); - } -#else /* COLOR */ - -LispPTR cgfour_set_colormap(args) - LispPTR args[]; +LispPTR cgfour_set_colormap(args) LispPTR args[]; { - printf( "Color is not supported.\n" ); - return (NIL); + int index; + struct pixrect *ColorFb; + + index = args[0] & 0xff; + + RED_colormap = (unsigned char)(args[1] & 0xff); + GRN_colormap = (unsigned char)(args[2] & 0xff); + BLU_colormap = (unsigned char)(args[3] & 0xff); + + ColorFb = pr_open("/dev/fb"); + + if (pr_putcolormap(ColorFb, index, 1, &RED_colormap, &GRN_colormap, &BLU_colormap) == -1) + perror("putcolormap:"); + pr_close(ColorFb); + return (T); +} +#else /* COLOR */ + +LispPTR cgfour_set_colormap(args) LispPTR args[]; +{ + printf("Color is not supported.\n"); + return (NIL); } #endif /* COLOR */ - #ifdef COLOR #ifdef DISPLAYBUFFER static struct pixrect *saved_screen; static int Screen_Saved = T; -void save_color_screen() -{ - if( !Screen_Saved ) { - saved_screen = mem_point( displaywidth - , displayheight - , 8 - , ColorDisplayRegion68k ); - pr_rop( saved_screen - , 0, 0, displaywidth, displayheight - , PIX_SRC, ColorDisplayPixrect, 0, 0 ); - Screen_Saved = T; - } /* end if(!Screen_Saved) */ +void save_color_screen() { + if (!Screen_Saved) { + saved_screen = mem_point(displaywidth, displayheight, 8, ColorDisplayRegion68k); + pr_rop(saved_screen, 0, 0, displaywidth, displayheight, PIX_SRC, ColorDisplayPixrect, 0, 0); + Screen_Saved = T; + } /* end if(!Screen_Saved) */ } /* end save_color_screen() */ -void restore_color_screen() -{ - if( Screen_Saved ) { - saved_screen = mem_point( displaywidth - , displayheight - , 8 - , ColorDisplayRegion68k ); - pr_rop( ColorDisplayPixrect - , 0, 0, displaywidth, displayheight - , PIX_SRC, saved_screen, 0, 0 ); - Screen_Saved = NIL; - } /* end if(Screen_Saved) */ +void restore_color_screen() { + if (Screen_Saved) { + saved_screen = mem_point(displaywidth, displayheight, 8, ColorDisplayRegion68k); + pr_rop(ColorDisplayPixrect, 0, 0, displaywidth, displayheight, PIX_SRC, saved_screen, 0, 0); + Screen_Saved = NIL; + } /* end if(Screen_Saved) */ } /* end restore_color_screen() */ #endif /* DISPLAYBUFFER */ - -static unsigned char red_colormap[256] - , green_colormap[256] - , blue_colormap[256]; +static unsigned char red_colormap[256], green_colormap[256], blue_colormap[256]; static int Saved_Colormap = NIL; -void save_colormap() -{ - struct pixrect *Color_Fb; +void save_colormap() { + struct pixrect *Color_Fb; - if( !Saved_Colormap ) { - Color_Fb = pr_open( "/dev/fb" ); - if( (pr_getcolormap( Color_Fb, 0 , 256 - , red_colormap - , green_colormap - , blue_colormap )) == -1 ) - perror("save_color_map:"); - else - Saved_Colormap = T; + if (!Saved_Colormap) { + Color_Fb = pr_open("/dev/fb"); + if ((pr_getcolormap(Color_Fb, 0, 256, red_colormap, green_colormap, blue_colormap)) == -1) + perror("save_color_map:"); + else + Saved_Colormap = T; - pr_close( Color_Fb ); - } /* end if( !Saved_Colormap ) */ + pr_close(Color_Fb); + } /* end if( !Saved_Colormap ) */ } /* end save_colormap() */ -void restore_colormap() -{ - struct pixrect *Color_Fb; +void restore_colormap() { + struct pixrect *Color_Fb; - if( Saved_Colormap ) { - Color_Fb = pr_open( "/dev/fb" ); - if( (pr_putcolormap( Color_Fb, 0 , 256 - , red_colormap - , green_colormap - , blue_colormap )) == -1 ) - perror("restore_color_map:"); - pr_close( Color_Fb ); - Saved_Colormap = NIL; - } /* end if( Saved_Colormap ) */ + if (Saved_Colormap) { + Color_Fb = pr_open("/dev/fb"); + if ((pr_putcolormap(Color_Fb, 0, 256, red_colormap, green_colormap, blue_colormap)) == -1) + perror("restore_color_map:"); + pr_close(Color_Fb); + Saved_Colormap = NIL; + } /* end if( Saved_Colormap ) */ } /* end restore_colormap() */ #endif /* COLOR */ - - diff --git a/src/llstk.c b/src/llstk.c old mode 100755 new mode 100644 index 0d41587..54846ae --- a/src/llstk.c +++ b/src/llstk.c @@ -1,10 +1,6 @@ -/* $Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,8 +15,6 @@ static char *id = "$Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyrig #include "version.h" - - /******************************************************************/ /* File Name : llstk.c @@ -31,7 +25,7 @@ static char *id = "$Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyrig */ /******************************************************************/ -#include /* for printf */ +#include /* for printf */ #include "lispemul.h" #include "lispmap.h" #include "adr68k.h" @@ -46,7 +40,6 @@ static char *id = "$Id: llstk.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyrig extern int extended_frame; - void blt(register DLword *dest68k, register DLword *source68k, int nw); /******************************************************************/ @@ -56,235 +49,198 @@ void blt(register DLword *dest68k, register DLword *source68k, int nw); Edited by : Take(March 14, 1988) */ /******************************************************************/ -LispPTR moveframe(register FX *oldfx68k) -{ - register int size; - register DLword *next68k; - register DLword *new68k; - DLword *freestackblock(DLword n, StackWord *start68k, int align); - DLword *extendstack(void); - int nametbl_on_stk =NIL; - int at_eos = NIL; +LispPTR moveframe(register FX *oldfx68k) { + register int size; + register DLword *next68k; + register DLword *new68k; + DLword *freestackblock(DLword n, StackWord * start68k, int align); + DLword *extendstack(void); + int nametbl_on_stk = NIL; + int at_eos = NIL; - PreMoveFrameCheck(oldfx68k); + PreMoveFrameCheck(oldfx68k); #ifdef FLIPCURSOR - flip_cursorbar(10); + flip_cursorbar(10); #endif - size = FX_size(oldfx68k) + DLWORDSPER_CELL; - S_CHECK(size > 0, "size of stack block < 0"); - next68k=Addr68k_from_StkOffset(oldfx68k->nextblock); + size = FX_size(oldfx68k) + DLWORDSPER_CELL; + S_CHECK(size > 0, "size of stack block < 0"); + next68k = Addr68k_from_StkOffset(oldfx68k->nextblock); tryfsb: - if(FSBP(next68k)) - { - /* merge free blocks */ - new68k = next68k + FSB_size(next68k); - if(FSBP(new68k)) - { - for(;FSBP(new68k); new68k = new68k + FSB_size(new68k)) - FSB_size(next68k) += FSB_size(new68k); - new68k=(DLword *)oldfx68k; - goto out; - } - else if(StkOffset_from_68K(new68k) == InterfacePage->endofstack) - { - if((StkOffset_from_68K(new68k) > LOLOC(*GuardStackAddr_word)) && - ((*STACKOVERFLOW_word)== NIL) ) - at_eos = T; /* search FSB in earler STACK area by freestackblock */ - else if(extendstack() != NIL) - { - new68k=(DLword *)oldfx68k; - goto out; - } - else - { - /* These lines are different from Original Code */ - return(0xFFFF); /* No space */ - } - }/* else if end */ - + if (FSBP(next68k)) { + /* merge free blocks */ + new68k = next68k + FSB_size(next68k); + if (FSBP(new68k)) { + for (; FSBP(new68k); new68k = new68k + FSB_size(new68k)) + FSB_size(next68k) += FSB_size(new68k); + new68k = (DLword *)oldfx68k; + goto out; + } else if (StkOffset_from_68K(new68k) == InterfacePage->endofstack) { + if ((StkOffset_from_68K(new68k) > LOLOC(*GuardStackAddr_word)) && + ((*STACKOVERFLOW_word) == NIL)) + at_eos = T; /* search FSB in earler STACK area by freestackblock */ + else if (extendstack() != NIL) { + new68k = (DLword *)oldfx68k; + goto out; + } else { + /* These lines are different from Original Code */ + return (0xFFFF); /* No space */ } + } /* else if end */ + } - CHECK_FX(oldfx68k); + CHECK_FX(oldfx68k); - S_CHECK(oldfx68k->usecount == 0, "use count > 0"); - /* we don't check \INTERRUPTABLE */ + S_CHECK(oldfx68k->usecount == 0, "use count > 0"); +/* we don't check \INTERRUPTABLE */ #ifdef BIGVM - if(oldfx68k->validnametable && ((oldfx68k->nametable>>16)==STK_HI)) + if (oldfx68k->validnametable && ((oldfx68k->nametable >> 16) == STK_HI)) #else - if(oldfx68k->validnametable && (oldfx68k->hi2nametable==STK_HI)) + if (oldfx68k->validnametable && (oldfx68k->hi2nametable == STK_HI)) #endif /* BIGVM */ - { - /* frame contains a name table, so we care that the alignment - of the new block be same as old */ + { +/* frame contains a name table, so we care that the alignment + of the new block be same as old */ #ifdef STACKCHECK - { DLword n; + { + DLword n; #ifdef BIGVM - n = oldfx68k->nametable & 0xFFFF; + n = oldfx68k->nametable & 0xFFFF; #else - n=oldfx68k->lonametable; + n = oldfx68k->lonametable; #endif /* BIGVM */ - if((n <= StkOffset_from_68K(oldfx68k)) - && (n >= oldfx68k->nextblock)) - { WARN("moveframe:check!!", sff(LADDR_from_68k(oldfx68k)));} - } + if ((n <= StkOffset_from_68K(oldfx68k)) && (n >= oldfx68k->nextblock)) { + WARN("moveframe:check!!", sff(LADDR_from_68k(oldfx68k))); + } + } #endif - nametbl_on_stk = T; - /* Find a free stack block */ - new68k=freestackblock(size,(StackWord *)oldfx68k, - (LADDR_from_68k(oldfx68k)-DLWORDSPER_CELL)% DLWORDSPER_QUAD); - } - else - new68k=freestackblock(size,(StackWord *)oldfx68k,-1);/* Not needed to align */ + nametbl_on_stk = T; + /* Find a free stack block */ + new68k = freestackblock(size, (StackWord *)oldfx68k, + (LADDR_from_68k(oldfx68k) - DLWORDSPER_CELL) % DLWORDSPER_QUAD); + } else + new68k = freestackblock(size, (StackWord *)oldfx68k, -1); /* Not needed to align */ + if (new68k == 0) return (0xFFFF); /* exhausted */ + if (new68k < Stackspace) error("freestackblock returned gunk."); - if(new68k==0) return(0xFFFF); /* exhausted */ -if (new68k < Stackspace) error("freestackblock returned gunk."); + if (at_eos && ((UNSIGNED)new68k > (UNSIGNED)oldfx68k)) { + /* extendstack already done in freestackblock */ + ((STKBLK *)new68k)->flagword = STK_FSB_WORD; + if (((STKBLK *)new68k)->size == 0) error("0-long stack freeblock."); + goto tryfsb; + } - if( at_eos && ((UNSIGNED)new68k > (UNSIGNED)oldfx68k)) - { - /* extendstack already done in freestackblock */ - ((STKBLK*)new68k)->flagword = STK_FSB_WORD; -if (((STKBLK *)new68k)->size == 0) error("0-long stack freeblock."); - goto tryfsb; - } + /* copy frame and dummy bf pointer too */ + blt(new68k, (((DLword *)oldfx68k) - DLWORDSPER_CELL), size); - /* copy frame and dummy bf pointer too */ - blt(new68k,(((DLword*)oldfx68k) - DLWORDSPER_CELL),size); + ((Bframe *)new68k)->residual = T; + new68k = new68k + DLWORDSPER_CELL; /* now NEW points to the FX */ + ((FX *)new68k)->nextblock = (StkOffset_from_68K(new68k) + size) - DLWORDSPER_CELL; + /* (CHECK (fetch (BF CHECKED) of (fetch (FX BLINK) of OLDFRAME)))*/ + CHECK_BF(Addr68k_from_StkOffset(GETBLINK(oldfx68k))); - ((Bframe*)new68k)->residual =T; - new68k = new68k + DLWORDSPER_CELL; /* now NEW points to the FX */ - ((FX*)new68k)->nextblock = (StkOffset_from_68K(new68k) + size) - -DLWORDSPER_CELL; - /* (CHECK (fetch (BF CHECKED) of (fetch (FX BLINK) of OLDFRAME)))*/ - CHECK_BF(Addr68k_from_StkOffset(GETBLINK(oldfx68k))); + /* Set true BFptr,not residual */ + SETBLINK(new68k, GETBLINK(oldfx68k)); - /* Set true BFptr,not residual */ - SETBLINK(new68k,GETBLINK(oldfx68k)); - - if(nametbl_on_stk) - { - S_CHECK(( (((UNSIGNED)new68k - (UNSIGNED)oldfx68k)>>1) % DLWORDSPER_QUAD) == 0, - "Misalignment of stack blocks, with nametable on stack"); + if (nametbl_on_stk) { + S_CHECK(((((UNSIGNED)new68k - (UNSIGNED)oldfx68k) >> 1) % DLWORDSPER_QUAD) == 0, + "Misalignment of stack blocks, with nametable on stack"); #ifdef BIGVM - ((FX*)new68k)->nametable += (((UNSIGNED)new68k - (UNSIGNED)oldfx68k)>>1); + ((FX *)new68k)->nametable += (((UNSIGNED)new68k - (UNSIGNED)oldfx68k) >> 1); #else - ((FX*)new68k)->lonametable += (((UNSIGNED)new68k - (UNSIGNED)oldfx68k)>>1); + ((FX *)new68k)->lonametable += (((UNSIGNED)new68k - (UNSIGNED)oldfx68k) >> 1); #endif - } - if( ((Bframe*)DUMMYBF(oldfx68k))->residual ) - { - MAKEFREEBLOCK(((DLword*)oldfx68k)-DLWORDSPER_CELL , size); - } - else - { - MAKEFREEBLOCK(oldfx68k,size - DLWORDSPER_CELL); - } + } + if (((Bframe *)DUMMYBF(oldfx68k))->residual) { + MAKEFREEBLOCK(((DLword *)oldfx68k) - DLWORDSPER_CELL, size); + } else { + MAKEFREEBLOCK(oldfx68k, size - DLWORDSPER_CELL); + } out: #ifdef FLIPCURSOR - flip_cursorbar(10); + flip_cursorbar(10); #endif - return(S_POSITIVE|StkOffset_from_68K(new68k)); - } /* moveframe end */ - + return (S_POSITIVE | StkOffset_from_68K(new68k)); +} /* moveframe end */ /******************************************************************/ /* Func Name : do_stackoverflow(incallp) - retval: If There is no space for stack then return 1 - else return 0 - incallp: - If Calling during function call,incallp=T - else NIL + retval: If There is no space for stack then return 1 + else return 0 + incallp: + If Calling during function call,incallp=T + else NIL Edited by : Take(March 28, 1988) */ /******************************************************************/ -int do_stackoverflow(int incallp) -{ - register DLword *next68k; - DLword newfx; - DLword savenext; - DLword *oldPVar; - int movedistance; - LispPTR moveframe(register FX *oldfx68k); +int do_stackoverflow(int incallp) { + register DLword *next68k; + DLword newfx; + DLword savenext; + DLword *oldPVar; + int movedistance; + LispPTR moveframe(register FX * oldfx68k); #ifdef STACKCHECK - LispPTR stackcontents; - LispPTR TopIVAR; + LispPTR stackcontents; + LispPTR TopIVAR; - stackcontents= *((LispPTR*)CurrentStackPTR); - TopIVAR= *((LispPTR*)IVar); + stackcontents = *((LispPTR *)CurrentStackPTR); + TopIVAR = *((LispPTR *)IVar); #endif - /* Don't care PC,FuncObj, */ - /*if incall flag ON ,Don't care IVar - ,became resudual and it is pointed by copied FX's BLINK*/ - oldPVar=PVar; + /* Don't care PC,FuncObj, */ + /*if incall flag ON ,Don't care IVar + ,became resudual and it is pointed by copied FX's BLINK*/ + oldPVar = PVar; - if(*NeedHardreturnCleanup_word) - { - warn("HardreturnCleanup in do_stackoverflow"); - } - if(incallp) - { - savenext=CURRENTFX->nextblock; /* save old nextblock */ - } + if (*NeedHardreturnCleanup_word) { warn("HardreturnCleanup in do_stackoverflow"); } + if (incallp) { savenext = CURRENTFX->nextblock; /* save old nextblock */ } - BEFORE_CONTEXTSW; /* Don't Use MIDPUNT and Don't care IFPAGE */ + BEFORE_CONTEXTSW; /* Don't Use MIDPUNT and Don't care IFPAGE */ + /* Call MOVEFRAME directly */ + if ((newfx = (DLword)moveframe(CURRENTFX)) == 0xFFFF) { + /* To make immidiately call HARDRESET */ + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + return (1); /* Whole space exausted */ + } - /* Call MOVEFRAME directly */ - if((newfx=(DLword)moveframe(CURRENTFX)) == 0xFFFF) - { - /* To make immidiately call HARDRESET */ - Irq_Stk_Check = 0; - Irq_Stk_End=0; - return(1); /* Whole space exausted */ - } + /* Return from MOVEFRAME directly */ + PVar = (DLword *)Addr68k_from_StkOffset(newfx + FRAMESIZE); + movedistance = ((UNSIGNED)PVar - (UNSIGNED)oldPVar) >> 1; + AFTER_CONTEXTSW; - /* Return from MOVEFRAME directly */ + if (incallp) { + /* set next(it pointed to old IVar) with offset */ + CURRENTFX->nextblock = savenext + movedistance; - PVar=(DLword*)Addr68k_from_StkOffset(newfx+FRAMESIZE); - movedistance= ((UNSIGNED)PVar-(UNSIGNED)oldPVar) >>1; - AFTER_CONTEXTSW; - - if(incallp) - { - /* set next(it pointed to old IVar) with offset */ - CURRENTFX->nextblock= savenext + movedistance; - - /* including Last Arg(kept in TOS */ +/* including Last Arg(kept in TOS */ #ifdef BIGVM - S_CHECK(FuncObj == (struct fnhead *) - Addr68k_from_LADDR(CURRENTFX->fnheader), - "in call, but stack frame doesn't match FN being executed." ); + S_CHECK(FuncObj == (struct fnhead *)Addr68k_from_LADDR(CURRENTFX->fnheader), + "in call, but stack frame doesn't match FN being executed."); #else - S_CHECK(FuncObj == (struct fnhead *) - Addr68k_from_LADDR( - (CURRENTFX->hi2fnheader << 16) | - CURRENTFX->lofnheader), - "in call, but stack frame doesn't match FN being executed." ); + S_CHECK(FuncObj == (struct fnhead *)Addr68k_from_LADDR((CURRENTFX->hi2fnheader << 16) | + CURRENTFX->lofnheader), + "in call, but stack frame doesn't match FN being executed."); #endif /* BIGVM */ - CHECK_FX(CURRENTFX); - - /* We should re-Set up IVAR,CURRENTFX->nextblock */ - IVar += movedistance; - } /* incallp */ - - return(0); /* Normal return */ - /* If incallp ,we CAN continue executing FN or APPLY by just returning */ - /* new PVar will set in funcall */ - }/* end do_stackoverflow */ - - - - + CHECK_FX(CURRENTFX); + /* We should re-Set up IVAR,CURRENTFX->nextblock */ + IVar += movedistance; + } /* incallp */ + return (0); /* Normal return */ + /* If incallp ,we CAN continue executing FN or APPLY by just returning */ + /* new PVar will set in funcall */ +} /* end do_stackoverflow */ /******************************************************************/ /* @@ -296,44 +252,36 @@ int do_stackoverflow(int incallp) */ /******************************************************************/ -DLword *extendstack(void) -{ - register LispPTR easp; - register LispPTR scanptr; - - easp = InterfacePage->endofstack; - - if (easp < LOLOC(*LastStackAddr_word)) - { - if((easp > LOLOC(*GuardStackAddr_word)) && - ((*STACKOVERFLOW_word)== NIL) ) - { extended_frame = 1; - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->stackoverflow = 1; - *STACKOVERFLOW_word = *PENDINGINTERRUPT_word=ATOM_T; - } - newpage(STK_OFFSET|(scanptr=easp+2)); - /* I don't concern about DOLOCKPAGES */ - - MAKEFREEBLOCK(Addr68k_from_StkOffset(scanptr),DLWORDSPER_PAGE-2); - InterfacePage->endofstack = scanptr=easp+DLWORDSPER_PAGE; - SETUPGUARDBLOCK( - Addr68k_from_StkOffset(InterfacePage->endofstack), 2); - MAKEFREEBLOCK(Addr68k_from_StkOffset(easp) , 2); - return((DLword*)Addr68k_from_StkOffset(scanptr)); - } - else return(NIL); - } /* end extendstack */ - +DLword *extendstack(void) { + register LispPTR easp; + register LispPTR scanptr; + easp = InterfacePage->endofstack; + if (easp < LOLOC(*LastStackAddr_word)) { + if ((easp > LOLOC(*GuardStackAddr_word)) && ((*STACKOVERFLOW_word) == NIL)) { + extended_frame = 1; + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->stackoverflow = 1; + *STACKOVERFLOW_word = *PENDINGINTERRUPT_word = ATOM_T; + } + newpage(STK_OFFSET | (scanptr = easp + 2)); + /* I don't concern about DOLOCKPAGES */ + MAKEFREEBLOCK(Addr68k_from_StkOffset(scanptr), DLWORDSPER_PAGE - 2); + InterfacePage->endofstack = scanptr = easp + DLWORDSPER_PAGE; + SETUPGUARDBLOCK(Addr68k_from_StkOffset(InterfacePage->endofstack), 2); + MAKEFREEBLOCK(Addr68k_from_StkOffset(easp), 2); + return ((DLword *)Addr68k_from_StkOffset(scanptr)); + } else + return (NIL); +} /* end extendstack */ /******************************************************************/ /* Func Name : freestackblock(n,sart,align) Desc. : Search the FSB has specified size n or more Return useful area's ptr. - If there is no space for STACK,return 0 + If there is no space for STACK,return 0 Edited by : take(15-Jul-87) take(11-Apr-88) @@ -341,153 +289,132 @@ DLword *extendstack(void) /******************************************************************/ DLword *freestackblock(DLword n, StackWord *start68k, int align) - /* size you want(in DLword) */ - /* searching will start68k at here */ - /* if Negative,it needn't align */ - { - register int wantedsize; - register StackWord *scanptr68k; -StackWord *ooscan, *oscan; - register StackWord *orig68k; - register STKBLK *freeptr68k; - register StackWord *easp68k; - register DLword freesize; +/* size you want(in DLword) */ +/* searching will start68k at here */ +/* if Negative,it needn't align */ +{ + register int wantedsize; + register StackWord *scanptr68k; + StackWord *ooscan, *oscan; + register StackWord *orig68k; + register STKBLK *freeptr68k; + register StackWord *easp68k; + register DLword freesize; - DLword *extendstack(void); + DLword *extendstack(void); - if (n%2) error("asking for odd-length stack block"); + if (n % 2) error("asking for odd-length stack block"); - /* compute actually size you needed */ - wantedsize = n + STACKAREA_SIZE + MINEXTRASTACKWORDS; + /* compute actually size you needed */ + wantedsize = n + STACKAREA_SIZE + MINEXTRASTACKWORDS; - easp68k =(StackWord*) (Addr68k_from_StkOffset(InterfacePage->endofstack)); + easp68k = (StackWord *)(Addr68k_from_StkOffset(InterfacePage->endofstack)); + /*** DEBUG ***/ + S_CHECK(n > 2, "asking for block < 2 words long"); + S_CHECK(start68k != 0, "start68k = 0"); + S_CHECK(start68k >= (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase), + "start68k before stack base"); - /*** DEBUG ***/ - S_CHECK(n>2, "asking for block < 2 words long"); - S_CHECK(start68k != 0, "start68k = 0"); - S_CHECK(start68k >= - (StackWord*)Addr68k_from_StkOffset(InterfacePage->stackbase), - "start68k before stack base"); +STARTOVER: + if (start68k) + scanptr68k = start68k; + else + scanptr68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); -STARTOVER : - if(start68k) scanptr68k = start68k; - else scanptr68k = - (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); +SCAN: + switch ((unsigned)(STKWORD(scanptr68k)->flags)) { + case STK_FSB: goto FREESCAN; break; + case STK_GUARD: + if ((UNSIGNED)scanptr68k < (UNSIGNED)easp68k) goto FREESCAN; + if (start68k) { + scanptr68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + goto SCAN; + } else + goto NEWPAGE; + break; + case STK_FX: + scanptr68k = (StackWord *)Addr68k_from_StkOffset(((FX *)scanptr68k)->nextblock); + break; + default: + orig68k = scanptr68k; -SCAN : switch((unsigned)(STKWORD(scanptr68k)->flags)) - { - case STK_FSB : goto FREESCAN; - break; - case STK_GUARD: if((UNSIGNED)scanptr68k < (UNSIGNED)easp68k) - goto FREESCAN; - if (start68k) - { - scanptr68k =(StackWord *)Addr68k_from_StkOffset - (InterfacePage->stackbase); - goto SCAN; - } - else goto NEWPAGE; - break; - case STK_FX : scanptr68k =(StackWord *)Addr68k_from_StkOffset( - ((FX*)scanptr68k)->nextblock); - break; - default : orig68k = scanptr68k; - - while(STKWORD(scanptr68k)->flags != STK_BF) - { - S_WARN(STKWORD(scanptr68k)->flags==STK_NOTFLG, - "NOTFLG not on", scanptr68k); - scanptr68k = (StackWord *) - (((DLword *)scanptr68k) - + DLWORDSPER_CELL); - }; + while (STKWORD(scanptr68k)->flags != STK_BF) { + S_WARN(STKWORD(scanptr68k)->flags == STK_NOTFLG, "NOTFLG not on", scanptr68k); + scanptr68k = (StackWord *)(((DLword *)scanptr68k) + DLWORDSPER_CELL); + }; #ifdef STACKCHECK - if(((Bframe*)scanptr68k)->residual) - { if(scanptr68k != orig68k) - { - WARN("freestackblock:scanptr68k !=org", - printf(":0x%x\n", - LADDR_from_68k(scanptr68k))); - } - } - else - { - if(((Bframe*)scanptr68k)->ivar - != StkOffset_from_68K(orig68k)) - { - WARN("BF doesn't point TopIVAR", - printf(":0x%x\n", - LADDR_from_68k(scanptr68k))); - } - } + if (((Bframe *)scanptr68k)->residual) { + if (scanptr68k != orig68k) { + WARN("freestackblock:scanptr68k !=org", printf(":0x%x\n", LADDR_from_68k(scanptr68k))); + } + } else { + if (((Bframe *)scanptr68k)->ivar != StkOffset_from_68K(orig68k)) { + WARN("BF doesn't point TopIVAR", printf(":0x%x\n", LADDR_from_68k(scanptr68k))); + } + } #endif - /* Used to be a +=, but SunOS4/Sparc compiles it wrong */ - scanptr68k = (StackWord *) - ((DLword *)scanptr68k - + DLWORDSPER_CELL); - break; + /* Used to be a +=, but SunOS4/Sparc compiles it wrong */ + scanptr68k = (StackWord *)((DLword *)scanptr68k + DLWORDSPER_CELL); + break; - } /* end switch(scanptr68k */ + } /* end switch(scanptr68k */ -NEXT: if(scanptr68k != start68k) - { - S_CHECK((UNSIGNED)scanptr68k <=(UNSIGNED)easp68k, "scan ptr past end of stack"); - goto SCAN; - } -NEWPAGE : easp68k =(StackWord*)extendstack(); - if(easp68k) goto STARTOVER; - else - { - warn("freestackblock:StackFull MP9319"); - return(0); - } +NEXT: + if (scanptr68k != start68k) { + S_CHECK((UNSIGNED)scanptr68k <= (UNSIGNED)easp68k, "scan ptr past end of stack"); + goto SCAN; + } +NEWPAGE: + easp68k = (StackWord *)extendstack(); + if (easp68k) + goto STARTOVER; + else { + warn("freestackblock:StackFull MP9319"); + return (0); + } -FREESCAN : freeptr68k=(STKBLK *)scanptr68k; - freesize=FSB_size(freeptr68k); +FREESCAN: + freeptr68k = (STKBLK *)scanptr68k; + freesize = FSB_size(freeptr68k); FREE: - ooscan = oscan; oscan = scanptr68k; - scanptr68k = (StackWord *)(((DLword *)freeptr68k) + freesize); - if (freesize == 0) error("FREESIZE = 0"); + ooscan = oscan; + oscan = scanptr68k; + scanptr68k = (StackWord *)(((DLword *)freeptr68k) + freesize); + if (freesize == 0) error("FREESIZE = 0"); - switch((unsigned)(STKWORD(scanptr68k)->flags)) - { - case STK_FSB: freesize = freesize + FSB_size(scanptr68k); - goto FREE; - - case STK_GUARD: if((UNSIGNED)scanptr68k<(UNSIGNED)easp68k) - { - freesize = freesize + FSB_size(scanptr68k); - goto FREE; - } - break; + switch ((unsigned)(STKWORD(scanptr68k)->flags)) { + case STK_FSB: freesize = freesize + FSB_size(scanptr68k); goto FREE; - default : break; - - } /* end switch(scanp.. */ - - if(freesize >= wantedsize) - { - if((align<0) || - (align==(StkOffset_from_68K(freeptr68k) % DLWORDSPER_QUAD))) - wantedsize= MINEXTRASTACKWORDS; - else wantedsize= MINEXTRASTACKWORDS+DLWORDSPER_CELL; - - scanptr68k =(StackWord*) (((DLword *)freeptr68k) + wantedsize); - - SETUPGUARDBLOCK(scanptr68k, n); - MAKEFREEBLOCK(freeptr68k,wantedsize); - MAKEFREEBLOCK(((DLword*)scanptr68k) + n, freesize - wantedsize -n); - return((DLword*)scanptr68k); + case STK_GUARD: + if ((UNSIGNED)scanptr68k < (UNSIGNED)easp68k) { + freesize = freesize + FSB_size(scanptr68k); + goto FREE; } - else MAKEFREEBLOCK( freeptr68k, freesize); + break; - goto NEXT; - } /* freestackblock end */ + default: break; + } /* end switch(scanp.. */ + if (freesize >= wantedsize) { + if ((align < 0) || (align == (StkOffset_from_68K(freeptr68k) % DLWORDSPER_QUAD))) + wantedsize = MINEXTRASTACKWORDS; + else + wantedsize = MINEXTRASTACKWORDS + DLWORDSPER_CELL; + scanptr68k = (StackWord *)(((DLword *)freeptr68k) + wantedsize); + + SETUPGUARDBLOCK(scanptr68k, n); + MAKEFREEBLOCK(freeptr68k, wantedsize); + MAKEFREEBLOCK(((DLword *)scanptr68k) + n, freesize - wantedsize - n); + return ((DLword *)scanptr68k); + } else + MAKEFREEBLOCK(freeptr68k, freesize); + + goto NEXT; +} /* freestackblock end */ /******************************************************************/ /* @@ -498,70 +425,53 @@ FREE: Edited by : take(March 14, 1988) */ /******************************************************************/ -#define BF_size(ptr68k) ((StkOffset_from_68K(ptr68k)) - ((Bframe*)(ptr68k))->ivar + 2) +#define BF_size(ptr68k) ((StkOffset_from_68K(ptr68k)) - ((Bframe *)(ptr68k))->ivar + 2) -void decusecount68k(register FX *frame68k) -{ - DLword *alink68k; - register Bframe *blink68k; - DLword *clink68k; - register DLword *ivar68k; - register int size; +void decusecount68k(register FX *frame68k) { + DLword *alink68k; + register Bframe *blink68k; + DLword *clink68k; + register DLword *ivar68k; + register int size; -if(FX_INVALIDP(frame68k)) return; -CHECK_FX(frame68k); -/* I don't check if \INTERRUPTABLE is NIL */ - while(StkOffset_from_68K(frame68k)) - { - if(frame68k->usecount != 0) - { - frame68k->usecount--; - return; - } - else - { - alink68k = Addr68k_from_StkOffset(GETALINK(frame68k)); - blink68k =(Bframe*) Addr68k_from_StkOffset(GETBLINK(frame68k)); - clink68k = Addr68k_from_StkOffset(GETCLINK(frame68k)); + if (FX_INVALIDP(frame68k)) return; + CHECK_FX(frame68k); + /* I don't check if \INTERRUPTABLE is NIL */ + while (StkOffset_from_68K(frame68k)) { + if (frame68k->usecount != 0) { + frame68k->usecount--; + return; + } else { + alink68k = Addr68k_from_StkOffset(GETALINK(frame68k)); + blink68k = (Bframe *)Addr68k_from_StkOffset(GETBLINK(frame68k)); + clink68k = Addr68k_from_StkOffset(GETCLINK(frame68k)); - size = FX_size(frame68k); + size = FX_size(frame68k); - if(((Bframe*)DUMMYBF(frame68k))->residual) - { /* this frame has dummy BF */ - MAKEFREEBLOCK(((DLword*)frame68k) -DLWORDSPER_CELL,size+DLWORDSPER_CELL); - } - else - { - MAKEFREEBLOCK(frame68k,size); - } + if (((Bframe *)DUMMYBF(frame68k))->residual) { /* this frame has dummy BF */ + MAKEFREEBLOCK(((DLword *)frame68k) - DLWORDSPER_CELL, size + DLWORDSPER_CELL); + } else { + MAKEFREEBLOCK(frame68k, size); + } - if(blink68k->usecnt !=0) - { - blink68k->usecnt--; - } - else - { - /*** ivar68k=Addr68k_from_StkOffset(blink68k->ivar); - GETWORD(ivar68k)=STK_FSB_WORD; - GETWORD(ivar68k+1)=ivar68k -(DLword *)blink68k +2; **/ + if (blink68k->usecnt != 0) { + blink68k->usecnt--; + } else { + /*** ivar68k=Addr68k_from_StkOffset(blink68k->ivar); + GETWORD(ivar68k)=STK_FSB_WORD; + GETWORD(ivar68k+1)=ivar68k -(DLword *)blink68k +2; **/ - MAKEFREEBLOCK(Addr68k_from_StkOffset(blink68k->ivar), - BF_size(blink68k)); - } - if(alink68k!= clink68k) - decusecount68k((FX *)alink68k); + MAKEFREEBLOCK(Addr68k_from_StkOffset(blink68k->ivar), BF_size(blink68k)); + } + if (alink68k != clink68k) decusecount68k((FX *)alink68k); - frame68k = (FX*)clink68k; + frame68k = (FX *)clink68k; - } /* else end */ + } /* else end */ - }/*while end */ + } /*while end */ } /* decusecount68k end */ - - - - #ifdef ORG_FILPCORSORBAR extern DLword *EmCursorBitMap68K; extern int LispWindowFd; @@ -570,226 +480,185 @@ extern int LispWindowFd; extern int Current_Hot_X, Current_Hot_Y; #endif /* XWINDOW */ - extern struct cursor CurrentCursor; -void flip_cursorbar(n) - int n; - { - GETWORD(EmCursorBitMap68K +n) = ~(GETWORD(EmCursorBitMap68K +n)); +void flip_cursorbar(n) int n; +{ + GETWORD(EmCursorBitMap68K + n) = ~(GETWORD(EmCursorBitMap68K + n)); #ifdef SUNDISPLAY - win_setcursor(LispWindowFd,&CurrentCursor); + win_setcursor(LispWindowFd, &CurrentCursor); #endif /* SUNDISPLAY */ #ifdef XWINDOW - /* JDS 011213 When using current_hot_y, remember fn does 15-it! */ - Set_XCursor( Current_Hot_X, 15-Current_Hot_Y ); + /* JDS 011213 When using current_hot_y, remember fn does 15-it! */ + Set_XCursor(Current_Hot_X, 15 - Current_Hot_Y); #endif /* XWINDOW */ - } #else extern short *DisplayRegion68k; extern int DisplayRasterWidth; -void flip_cursorbar(int n) - { - register short *word; - word = DisplayRegion68k + (n * DisplayRasterWidth); - GETWORD(word) ^= 0xFFFF; - } +void flip_cursorbar(int n) { + register short *word; + word = DisplayRegion68k + (n * DisplayRasterWidth); + GETWORD(word) ^= 0xFFFF; +} #endif - - - - /**************************************************************/ /* blt(dest,source,size) */ /**************************************************************/ -void blt(register DLword *dest68k, register DLword *source68k, int nw) -{ -/******* OLD def , - Due to C compiler's bug, we can't use pre-decriment for register val - source68k += nw; - dest68k += nw; - while(nw) - { - GETWORD(--dest68k)= GETWORD(--source68k); - nw--; - } -**** OLD def ****/ - source68k = source68k + nw-1; - dest68k = dest68k + nw-1; - while(nw--) - { - GETWORD(dest68k--) = GETWORD(source68k--); - } +void blt(register DLword *dest68k, register DLword *source68k, int nw) { + /******* OLD def , + Due to C compiler's bug, we can't use pre-decriment for register val + source68k += nw; + dest68k += nw; + while(nw) + { + GETWORD(--dest68k)= GETWORD(--source68k); + nw--; + } + **** OLD def ****/ + source68k = source68k + nw - 1; + dest68k = dest68k + nw - 1; + while (nw--) { GETWORD(dest68k--) = GETWORD(source68k--); } } - - /**************************************************************/ /* - stack_check(start68k) - for DEBUG + stack_check(start68k) + for DEBUG */ /**************************************************************/ -void stack_check(StackWord *start68k) -{ - StackWord *scanptr68k; - StackWord *endstack68k; - DLword *top_ivar; - DLword save_nextblock; - DLword savestack1,savestack2; - DLword setflg=NIL; - DLword freesize; +void stack_check(StackWord *start68k) { + StackWord *scanptr68k; + StackWord *endstack68k; + DLword *top_ivar; + DLword save_nextblock; + DLword savestack1, savestack2; + DLword setflg = NIL; + DLword freesize; #ifdef FSBCHECK - struct big_fsbs { DLword offset; DLword size;} bigFSB[100]; - int bigFSBindex=0; + struct big_fsbs { + DLword offset; + DLword size; + } bigFSB[100]; + int bigFSBindex = 0; - memset((char*)bigFSB, 0, 100 * 2 * 2); + memset((char *)bigFSB, 0, 100 * 2 * 2); #endif - if((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) - ||(!FSBP(CurrentStackPTR))) - { - if((DLword*)CURRENTFX >= CurrentStackPTR) - { - WARN("CURRENTFX >= CurrentStackPTR??\n", - printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", - LADDR_from_68k(CURRENTFX),LADDR_from_68k(CurrentStackPTR))); - } - setflg=T; - printf("set CURRENTFX->nextblock in debugger. But it will be reset after this check \n"); - save_nextblock=CURRENTFX->nextblock; - savestack1= GETWORD(CurrentStackPTR+2); - savestack2= GETWORD(CurrentStackPTR+3); - CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR+2); - GETWORD(CurrentStackPTR+2)=STK_FSB_WORD; - GETWORD(CurrentStackPTR+3)= (((UNSIGNED)EndSTKP-(UNSIGNED)(CurrentStackPTR+2))>>1); - } - - - if(start68k) scanptr68k =start68k; - else scanptr68k = - (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); - endstack68k=(StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); - - if(STKWORD(endstack68k)->flags !=STK_GUARD) - printf("?? endstack is not GUARD BLK\n"); - - while(scanptr68k flags)) - { - case STK_FSB : freesize= FSB_size(scanptr68k); - if (freesize == 0) - { - warn("FSB freesize = 0!"); - } -#ifdef FSBCHECK - if(freesize > STACKAREA_SIZE+MINEXTRASTACKWORDS) - { - if(bigFSBindex < 100) - { - bigFSB[bigFSBindex].offset = StkOffset_from_68K(scanptr68k); - bigFSB[bigFSBindex].size = freesize; - bigFSBindex++; - } - } -#endif - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + freesize); - putchar('F'); - break; - - case STK_GUARD: freesize = FSB_size(scanptr68k); - if (freesize == 0) - { - warn("Guard block freesize = 0!"); - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + freesize); - putchar('G'); - break; - - case STK_FX : CHECK_FX(scanptr68k); - scanptr68k =(StackWord *)Addr68k_from_StkOffset( - ((FX*)scanptr68k)->nextblock); - putchar('X'); - break; - - default: top_ivar=(DLword*)scanptr68k; - while(STKWORD(scanptr68k)->flags != STK_BF) - { - if (STKWORD(scanptr68k)->flags!=STK_NOTFLG) - { - WARN("StackCheck:!=STK_NOTFLG", - printf("content:0x%x\n",GETWORD(scanptr68k))); - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + DLWORDSPER_CELL); - }/* while end */; - CHECK_BF(scanptr68k); - if(((Bframe*)scanptr68k)->residual) - { - if((DLword*)scanptr68k != top_ivar) - printf("Residual has real IVAR:0x%x\n", - LADDR_from_68k(scanptr68k)); - } - else - { - if(((Bframe*)scanptr68k)->ivar - != StkOffset_from_68K(top_ivar)) - printf("BF doesn't point TopIVAR:0x%x\n", - LADDR_from_68k(scanptr68k)); - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k - + DLWORDSPER_CELL); - putchar('B'); - break; - - }/*switch end */ - - if(scanptr68k != start68k) - { - if(scanptr68k >endstack68k) - { - WARN("scanptr exceeded end stack", - printf("scanptr68k=0x%x endstack68k=0x%x",scanptr68k,endstack68k)); - } + if ((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) || (!FSBP(CurrentStackPTR))) { + if ((DLword *)CURRENTFX >= CurrentStackPTR) { + WARN("CURRENTFX >= CurrentStackPTR??\n", + printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", LADDR_from_68k(CURRENTFX), + LADDR_from_68k(CurrentStackPTR))); } - }/* while end */ + setflg = T; + printf("set CURRENTFX->nextblock in debugger. But it will be reset after this check \n"); + save_nextblock = CURRENTFX->nextblock; + savestack1 = GETWORD(CurrentStackPTR + 2); + savestack2 = GETWORD(CurrentStackPTR + 3); + CURRENTFX->nextblock = StkOffset_from_68K(CurrentStackPTR + 2); + GETWORD(CurrentStackPTR + 2) = STK_FSB_WORD; + GETWORD(CurrentStackPTR + 3) = (((UNSIGNED)EndSTKP - (UNSIGNED)(CurrentStackPTR + 2)) >> 1); + } + + if (start68k) + scanptr68k = start68k; + else + scanptr68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + endstack68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); + + if (STKWORD(endstack68k)->flags != STK_GUARD) printf("?? endstack is not GUARD BLK\n"); + + while (scanptr68k < endstack68k) { + switch ((unsigned)(STKWORD(scanptr68k)->flags)) { + case STK_FSB: + freesize = FSB_size(scanptr68k); + if (freesize == 0) { warn("FSB freesize = 0!"); } +#ifdef FSBCHECK + if (freesize > STACKAREA_SIZE + MINEXTRASTACKWORDS) { + if (bigFSBindex < 100) { + bigFSB[bigFSBindex].offset = StkOffset_from_68K(scanptr68k); + bigFSB[bigFSBindex].size = freesize; + bigFSBindex++; + } + } +#endif + scanptr68k = (StackWord *)((DLword *)scanptr68k + freesize); + putchar('F'); + break; + + case STK_GUARD: + freesize = FSB_size(scanptr68k); + if (freesize == 0) { warn("Guard block freesize = 0!"); } + scanptr68k = (StackWord *)((DLword *)scanptr68k + freesize); + putchar('G'); + break; + + case STK_FX: + CHECK_FX(scanptr68k); + scanptr68k = (StackWord *)Addr68k_from_StkOffset(((FX *)scanptr68k)->nextblock); + putchar('X'); + break; + + default: + top_ivar = (DLword *)scanptr68k; + while (STKWORD(scanptr68k)->flags != STK_BF) { + if (STKWORD(scanptr68k)->flags != STK_NOTFLG) { + WARN("StackCheck:!=STK_NOTFLG", printf("content:0x%x\n", GETWORD(scanptr68k))); + } + scanptr68k = (StackWord *)((DLword *)scanptr68k + DLWORDSPER_CELL); + } /* while end */; + CHECK_BF(scanptr68k); + if (((Bframe *)scanptr68k)->residual) { + if ((DLword *)scanptr68k != top_ivar) + printf("Residual has real IVAR:0x%x\n", LADDR_from_68k(scanptr68k)); + } else { + if (((Bframe *)scanptr68k)->ivar != StkOffset_from_68K(top_ivar)) + printf("BF doesn't point TopIVAR:0x%x\n", LADDR_from_68k(scanptr68k)); + } + scanptr68k = (StackWord *)((DLword *)scanptr68k + DLWORDSPER_CELL); + putchar('B'); + break; + + } /*switch end */ + + if (scanptr68k != start68k) { + if (scanptr68k > endstack68k) { + WARN("scanptr exceeded end stack", + printf("scanptr68k=0x%x endstack68k=0x%x", scanptr68k, endstack68k)); + } + } + } /* while end */ #ifdef FSBCHECK -if(bigFSBindex!=0){ - int i; + if (bigFSBindex != 0) { + int i; - printf("\nBIG FSB(s):\n"); + printf("\nBIG FSB(s):\n"); - for(i=0;inextblock=save_nextblock; - GETWORD(CurrentStackPTR+2)=savestack1; - GETWORD(CurrentStackPTR+3)=savestack2; - } - -}/*stack_check end */ + printf("\nStack Check done\n"); + if (setflg) { + CURRENTFX->nextblock = save_nextblock; + GETWORD(CurrentStackPTR + 2) = savestack1; + GETWORD(CurrentStackPTR + 3) = savestack2; + } +} /*stack_check end */ /**************************************************************/ /* - walk_stack(start68k) - for DEBUG + walk_stack(start68k) + for DEBUG Walk the stack, printing information about what we see as we go. Unlike stack_check, this prints frame @@ -797,353 +666,291 @@ printf("\nStack Check done\n"); */ /**************************************************************/ -void walk_stack(StackWord *start68k) -{ - StackWord *scanptr68k; - StackWord *endstack68k; - DLword *top_ivar; - DLword save_nextblock; - DLword savestack1,savestack2; - DLword setflg=NIL; - DLword freesize; +void walk_stack(StackWord *start68k) { + StackWord *scanptr68k; + StackWord *endstack68k; + DLword *top_ivar; + DLword save_nextblock; + DLword savestack1, savestack2; + DLword setflg = NIL; + DLword freesize; - - if((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) - ||(!FSBP(CurrentStackPTR))) - { - if((DLword*)CURRENTFX >= CurrentStackPTR) - { - WARN("CURRENTFX >= CurrentStackPTR??\n", - printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", - LADDR_from_68k(CURRENTFX),LADDR_from_68k(CurrentStackPTR))); - } - setflg=T; - printf("set CURRENTFX->nextblock in debugger. But it will be reset after this check \n"); - save_nextblock=CURRENTFX->nextblock; - savestack1= GETWORD(CurrentStackPTR+2); - savestack2= GETWORD(CurrentStackPTR+3); - CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR+2); - GETWORD(CurrentStackPTR+2)=STK_FSB_WORD; - GETWORD(CurrentStackPTR+3)= (((UNSIGNED)EndSTKP-(UNSIGNED)(CurrentStackPTR+2))>>1); - } - - /* Start from where caller specifies, (as real address!); if addr=0 */ - /* start from stackbase. */ - - if(start68k) - { - scanptr68k =(StackWord *) ((unsigned long)start68k & -2 ); - printf("Starting at 0x%x.", (DLword*)scanptr68k-Stackspace); - } - else - { - scanptr68k = - (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); - printf("Stack base = 0x%x.", (DLword*)scanptr68k-Stackspace); - } - - endstack68k=(StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); - - printf(" End of stack = 0x%x.\n\n", (DLword*)endstack68k-Stackspace); - - if(STKWORD(endstack68k)->flags !=STK_GUARD) - printf("?? endstack is not GUARD BLK\nendstack = 0x%x, flags = %d\n\n", - endstack68k, STKWORD(endstack68k)->flags); - - while(scanptr68k < endstack68k) - { - switch((unsigned)(STKWORD(scanptr68k)->flags)) - { - /* Free stack block */ - case STK_FSB : freesize= FSB_size(scanptr68k); - printf("%04x: Free block (len %d/0x%x)\n", - (DLword*)scanptr68k-Stackspace, freesize, - freesize); - - if (freesize == 0) - { - freesize = 2; - } - - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + freesize); - - break; - - case STK_GUARD: freesize = FSB_size(scanptr68k); - printf("%04x: Guard block (len %d/0x%x)\n", - (DLword*)scanptr68k-Stackspace, freesize, - freesize); - if (freesize == 0) - { - freesize = 2; - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + freesize); - - break; - - case STK_FX : CHECK_FX(scanptr68k); - - printf("%04x: ", - (DLword*)scanptr68k-Stackspace); - - { - FX *fx = (FX *)scanptr68k; - struct fnhead *fnobj; -#ifdef BIGVM - fnobj = (struct fnhead *) - Addr68k_from_LADDR(fx->fnheader); -#else - fnobj = (struct fnhead *) - Addr68k_from_LADDR( - ((int)fx->hi2fnheader << 16) - | fx->lofnheader); -#endif /* BIGVM */ - print(fnobj->framename); - printf("\talink: 0x%04x, clink: 0x%04x, next: 0x%04x\n", - fx->alink, fx->clink, fx->nextblock); - } - - { - Bframe *dummybf,*mtmp; - int mblink; - - /* Now make sure the FX is connected to */ - /* a Basic Frame. */ - - dummybf=(Bframe*)DUMMYBF(scanptr68k); - - /* Check for connection via BLINK field: */ - if(StkOffset_from_68K(dummybf) - != GETBLINK(scanptr68k)) - { - mblink=GETBLINK(scanptr68k); - mtmp=(Bframe*) - Addr68k_from_StkOffset(mblink); - if( ( dummybf->residual == NIL ) || - ( dummybf->ivar != mtmp->ivar ) ) - printf(" [Bad residual]\n"); - } - } - - scanptr68k =(StackWord *)Addr68k_from_StkOffset( - ((FX*)scanptr68k)->nextblock); - break; - - default: top_ivar=(DLword*)scanptr68k; - while(STKWORD(scanptr68k)->flags != STK_BF) - { - if (STKWORD(scanptr68k)->flags!=STK_NOTFLG) - { - printf("%04x: Bad BF IVAR 0x%x\n", - (DLword*)scanptr68k-Stackspace, - GETWORD(scanptr68k)); - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + DLWORDSPER_CELL); - }/* while end */; - /* CHECK_BF(scanptr68k); */ - { - Bframe *bf = (Bframe *)scanptr68k; - printf("%04x: BF usecnt %d, resid %d, padding %d, ivar 0x%04x\n", - (DLword*)scanptr68k-Stackspace, - bf->usecnt, bf->residual, bf->padding, - bf->ivar); - - if(((Bframe*)scanptr68k)->ivar - != StkOffset_from_68K(top_ivar)) - printf(" [but top_ivar = 0x%04x]\n", - top_ivar - Stackspace); - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k - + DLWORDSPER_CELL); - break; - - }/*switch end */ - - if(scanptr68k != start68k) - { - if(scanptr68k >endstack68k) - { - WARN("scanptr exceeded end stack", - printf("scanptr68k=0x%x endstack68k=0x%x",scanptr68k,endstack68k)); - } + if ((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) || (!FSBP(CurrentStackPTR))) { + if ((DLword *)CURRENTFX >= CurrentStackPTR) { + WARN("CURRENTFX >= CurrentStackPTR??\n", + printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", LADDR_from_68k(CURRENTFX), + LADDR_from_68k(CurrentStackPTR))); } - }/* while end */ + setflg = T; + printf("set CURRENTFX->nextblock in debugger. But it will be reset after this check \n"); + save_nextblock = CURRENTFX->nextblock; + savestack1 = GETWORD(CurrentStackPTR + 2); + savestack2 = GETWORD(CurrentStackPTR + 3); + CURRENTFX->nextblock = StkOffset_from_68K(CurrentStackPTR + 2); + GETWORD(CurrentStackPTR + 2) = STK_FSB_WORD; + GETWORD(CurrentStackPTR + 3) = (((UNSIGNED)EndSTKP - (UNSIGNED)(CurrentStackPTR + 2)) >> 1); + } + + /* Start from where caller specifies, (as real address!); if addr=0 */ + /* start from stackbase. */ + + if (start68k) { + scanptr68k = (StackWord *)((unsigned long)start68k & -2); + printf("Starting at 0x%x.", (DLword *)scanptr68k - Stackspace); + } else { + scanptr68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + printf("Stack base = 0x%x.", (DLword *)scanptr68k - Stackspace); + } + + endstack68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); + + printf(" End of stack = 0x%x.\n\n", (DLword *)endstack68k - Stackspace); + + if (STKWORD(endstack68k)->flags != STK_GUARD) + printf("?? endstack is not GUARD BLK\nendstack = 0x%x, flags = %d\n\n", endstack68k, + STKWORD(endstack68k)->flags); + + while (scanptr68k < endstack68k) { + switch ((unsigned)(STKWORD(scanptr68k)->flags)) { + /* Free stack block */ + case STK_FSB: + freesize = FSB_size(scanptr68k); + printf("%04x: Free block (len %d/0x%x)\n", (DLword *)scanptr68k - Stackspace, freesize, + freesize); + + if (freesize == 0) { freesize = 2; } + + scanptr68k = (StackWord *)((DLword *)scanptr68k + freesize); + + break; + + case STK_GUARD: + freesize = FSB_size(scanptr68k); + printf("%04x: Guard block (len %d/0x%x)\n", (DLword *)scanptr68k - Stackspace, freesize, + freesize); + if (freesize == 0) { freesize = 2; } + scanptr68k = (StackWord *)((DLword *)scanptr68k + freesize); + + break; + + case STK_FX: + CHECK_FX(scanptr68k); + + printf("%04x: ", (DLword *)scanptr68k - Stackspace); + + { + FX *fx = (FX *)scanptr68k; + struct fnhead *fnobj; +#ifdef BIGVM + fnobj = (struct fnhead *)Addr68k_from_LADDR(fx->fnheader); +#else + fnobj = + (struct fnhead *)Addr68k_from_LADDR(((int)fx->hi2fnheader << 16) | fx->lofnheader); +#endif /* BIGVM */ + print(fnobj->framename); + printf("\talink: 0x%04x, clink: 0x%04x, next: 0x%04x\n", fx->alink, fx->clink, + fx->nextblock); + } + + { + Bframe *dummybf, *mtmp; + int mblink; + + /* Now make sure the FX is connected to */ + /* a Basic Frame. */ + + dummybf = (Bframe *)DUMMYBF(scanptr68k); + + /* Check for connection via BLINK field: */ + if (StkOffset_from_68K(dummybf) != GETBLINK(scanptr68k)) { + mblink = GETBLINK(scanptr68k); + mtmp = (Bframe *)Addr68k_from_StkOffset(mblink); + if ((dummybf->residual == NIL) || (dummybf->ivar != mtmp->ivar)) + printf(" [Bad residual]\n"); + } + } + + scanptr68k = (StackWord *)Addr68k_from_StkOffset(((FX *)scanptr68k)->nextblock); + break; + + default: + top_ivar = (DLword *)scanptr68k; + while (STKWORD(scanptr68k)->flags != STK_BF) { + if (STKWORD(scanptr68k)->flags != STK_NOTFLG) { + printf("%04x: Bad BF IVAR 0x%x\n", (DLword *)scanptr68k - Stackspace, + GETWORD(scanptr68k)); + } + scanptr68k = (StackWord *)((DLword *)scanptr68k + DLWORDSPER_CELL); + } /* while end */; + /* CHECK_BF(scanptr68k); */ + { + Bframe *bf = (Bframe *)scanptr68k; + printf("%04x: BF usecnt %d, resid %d, padding %d, ivar 0x%04x\n", + (DLword *)scanptr68k - Stackspace, bf->usecnt, bf->residual, bf->padding, + bf->ivar); + + if (((Bframe *)scanptr68k)->ivar != StkOffset_from_68K(top_ivar)) + printf(" [but top_ivar = 0x%04x]\n", top_ivar - Stackspace); + } + scanptr68k = (StackWord *)((DLword *)scanptr68k + DLWORDSPER_CELL); + break; + + } /*switch end */ + + if (scanptr68k != start68k) { + if (scanptr68k > endstack68k) { + WARN("scanptr exceeded end stack", + printf("scanptr68k=0x%x endstack68k=0x%x", scanptr68k, endstack68k)); + } + } + } /* while end */ #ifdef FSBCHECK -if(bigFSBindex!=0){ - int i; + if (bigFSBindex != 0) { + int i; - printf("\nBIG FSB(s):\n"); + printf("\nBIG FSB(s):\n"); - for(i=0;inextblock=save_nextblock; - GETWORD(CurrentStackPTR+2)=savestack1; - GETWORD(CurrentStackPTR+3)=savestack2; - } - - } /* walk_stack end */ + printf("\nStack Check done\n"); + if (setflg) { + CURRENTFX->nextblock = save_nextblock; + GETWORD(CurrentStackPTR + 2) = savestack1; + GETWORD(CurrentStackPTR + 3) = savestack2; + } +} /* walk_stack end */ /**************************************************************/ /* - quick_stack_check() - for DEBUGING using FNSTKCHECK + quick_stack_check() + for DEBUGING using FNSTKCHECK */ /**************************************************************/ -void quick_stack_check(void) -{ - StackWord *start68k; - StackWord *scanptr68k; - StackWord *endstack68k; - DLword *top_ivar; - DLword save_nextblock; - DLword savestack1,savestack2; - DLword setflg=NIL; - DLword freesize; +void quick_stack_check(void) { + StackWord *start68k; + StackWord *scanptr68k; + StackWord *endstack68k; + DLword *top_ivar; + DLword save_nextblock; + DLword savestack1, savestack2; + DLword setflg = NIL; + DLword freesize; #ifdef FSBCHECK - struct big_fsbs { DLword offset; DLword size;} bigFSB[100]; - int bigFSBindex=0; + struct big_fsbs { + DLword offset; + DLword size; + } bigFSB[100]; + int bigFSBindex = 0; - memset((char*)bigFSB, 0, 100 * 2 * 2); + memset((char *)bigFSB, 0, 100 * 2 * 2); #endif - if((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) - ||(!FSBP(CurrentStackPTR))) - { - if((DLword*)CURRENTFX >= CurrentStackPTR) - { - WARN("CURRENTFX >= CurrentStackPTR??\n", - printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", - LADDR_from_68k(CURRENTFX),LADDR_from_68k(CurrentStackPTR))); - return; - } - setflg=T; - save_nextblock=CURRENTFX->nextblock; - savestack1= GETWORD(CurrentStackPTR+2); - savestack2= GETWORD(CurrentStackPTR+3); - CURRENTFX->nextblock=StkOffset_from_68K(CurrentStackPTR+2); - GETWORD(CurrentStackPTR+2)=STK_FSB_WORD; - GETWORD(CurrentStackPTR+3)= (((UNSIGNED)EndSTKP-(UNSIGNED)(CurrentStackPTR+2))>>1); - } - - - scanptr68k = start68k = - (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); - endstack68k=(StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); - - if(STKWORD(endstack68k)->flags !=STK_GUARD) - printf("?? endstack is not GUARD BLK\n"); - - while(scanptr68k flags)) - { - case STK_FSB : freesize= FSB_size(scanptr68k); - if (freesize == 0) - { - warn("FSB freesize = 0!"); - return; - } -#ifdef FSBCHECK - if(freesize > STACKAREA_SIZE+MINEXTRASTACKWORDS){ - if(bigFSBindex < 100){ - bigFSB[bigFSBindex].offset = StkOffset_from_68K(scanptr68k); - bigFSB[bigFSBindex].size = freesize; - bigFSBindex++; - } - } -#endif - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + freesize); - break; - case STK_GUARD: freesize = FSB_size(scanptr68k); - if (freesize == 0) - { - warn("Guard block freesize = 0!"); - return; - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + freesize); - break; - case STK_FX : CHECK_FX(scanptr68k); - scanptr68k =(StackWord *)Addr68k_from_StkOffset( - ((FX*)scanptr68k)->nextblock); - break; - default: top_ivar=(DLword*)scanptr68k; - while(STKWORD(scanptr68k)->flags != STK_BF) { - if (STKWORD(scanptr68k)->flags!=STK_NOTFLG) - { - warn("StackCheck:!=STK_NOTFLG"); - printf("content:0x%x\n",GETWORD(scanptr68k)); - return; - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k + DLWORDSPER_CELL); - }/* while end */; - CHECK_BF(scanptr68k); - if(((Bframe*)scanptr68k)->residual) - { - if((DLword*)scanptr68k != top_ivar) - printf("Residual has real IVAR:0x%x\n",LADDR_from_68k(scanptr68k)); - } - else - { - if(((Bframe*)scanptr68k)->ivar - != StkOffset_from_68K(top_ivar)) - printf("BF doesn't point TopIVAR:0x%x\n",LADDR_from_68k(scanptr68k)); - } - scanptr68k = (StackWord *) - ((DLword *)scanptr68k - + DLWORDSPER_CELL); - break; - }/*switch end */ - if(scanptr68k != start68k) - { - if(scanptr68k >endstack68k) - { - WARN("scanptr exceeded end stack",printf("scanptr68k=0x%x endstack68k=0x%x",scanptr68k,endstack68k)); - } + if ((CURRENTFX->nextblock != StkOffset_from_68K(CurrentStackPTR)) || (!FSBP(CurrentStackPTR))) { + if ((DLword *)CURRENTFX >= CurrentStackPTR) { + WARN("CURRENTFX >= CurrentStackPTR??\n", + printf("CURRENTFX=0x%x,CurrentStackPTR=0x%x\n", LADDR_from_68k(CURRENTFX), + LADDR_from_68k(CurrentStackPTR))); + return; + } + setflg = T; + save_nextblock = CURRENTFX->nextblock; + savestack1 = GETWORD(CurrentStackPTR + 2); + savestack2 = GETWORD(CurrentStackPTR + 3); + CURRENTFX->nextblock = StkOffset_from_68K(CurrentStackPTR + 2); + GETWORD(CurrentStackPTR + 2) = STK_FSB_WORD; + GETWORD(CurrentStackPTR + 3) = (((UNSIGNED)EndSTKP - (UNSIGNED)(CurrentStackPTR + 2)) >> 1); } -}/* while end */ + + scanptr68k = start68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->stackbase); + endstack68k = (StackWord *)Addr68k_from_StkOffset(InterfacePage->endofstack); + + if (STKWORD(endstack68k)->flags != STK_GUARD) printf("?? endstack is not GUARD BLK\n"); + + while (scanptr68k < endstack68k) { + switch ((unsigned)(STKWORD(scanptr68k)->flags)) { + case STK_FSB: + freesize = FSB_size(scanptr68k); + if (freesize == 0) { + warn("FSB freesize = 0!"); + return; + } #ifdef FSBCHECK -if(bigFSBindex!=0){ - int i; + if (freesize > STACKAREA_SIZE + MINEXTRASTACKWORDS) { + if (bigFSBindex < 100) { + bigFSB[bigFSBindex].offset = StkOffset_from_68K(scanptr68k); + bigFSB[bigFSBindex].size = freesize; + bigFSBindex++; + } + } +#endif + scanptr68k = (StackWord *)((DLword *)scanptr68k + freesize); + break; + case STK_GUARD: + freesize = FSB_size(scanptr68k); + if (freesize == 0) { + warn("Guard block freesize = 0!"); + return; + } + scanptr68k = (StackWord *)((DLword *)scanptr68k + freesize); + break; + case STK_FX: + CHECK_FX(scanptr68k); + scanptr68k = (StackWord *)Addr68k_from_StkOffset(((FX *)scanptr68k)->nextblock); + break; + default: + top_ivar = (DLword *)scanptr68k; + while (STKWORD(scanptr68k)->flags != STK_BF) { + if (STKWORD(scanptr68k)->flags != STK_NOTFLG) { + warn("StackCheck:!=STK_NOTFLG"); + printf("content:0x%x\n", GETWORD(scanptr68k)); + return; + } + scanptr68k = (StackWord *)((DLword *)scanptr68k + DLWORDSPER_CELL); + } /* while end */; + CHECK_BF(scanptr68k); + if (((Bframe *)scanptr68k)->residual) { + if ((DLword *)scanptr68k != top_ivar) + printf("Residual has real IVAR:0x%x\n", LADDR_from_68k(scanptr68k)); + } else { + if (((Bframe *)scanptr68k)->ivar != StkOffset_from_68K(top_ivar)) + printf("BF doesn't point TopIVAR:0x%x\n", LADDR_from_68k(scanptr68k)); + } + scanptr68k = (StackWord *)((DLword *)scanptr68k + DLWORDSPER_CELL); + break; + } /*switch end */ + if (scanptr68k != start68k) { + if (scanptr68k > endstack68k) { + WARN("scanptr exceeded end stack", + printf("scanptr68k=0x%x endstack68k=0x%x", scanptr68k, endstack68k)); + } + } + } /* while end */ +#ifdef FSBCHECK + if (bigFSBindex != 0) { + int i; - printf("\nBIG FSB(s):\n"); + printf("\nBIG FSB(s):\n"); - for(i=0;inextblock=save_nextblock; - GETWORD(CurrentStackPTR+2)=savestack1; - GETWORD(CurrentStackPTR+3)=savestack2; - } - return; - -}/* quick_stack_check end */ - - - - - + if (setflg) { + CURRENTFX->nextblock = save_nextblock; + GETWORD(CurrentStackPTR + 2) = savestack1; + GETWORD(CurrentStackPTR + 3) = savestack2; + } + return; +} /* quick_stack_check end */ /************************************************************************/ /* */ @@ -1157,47 +964,39 @@ if(bigFSBindex!=0){ /* */ /************************************************************************/ -void check_FX(FX *fx68k) -{ - Bframe *dummybf,*mtmp; - int mblink; +void check_FX(FX *fx68k) { + Bframe *dummybf, *mtmp; + int mblink; - /* The FX better really be an FX */ + /* The FX better really be an FX */ - if(((FX*)(fx68k))->flags != STK_FX) - error("CheckFX:NOT FX"); + if (((FX *)(fx68k))->flags != STK_FX) error("CheckFX:NOT FX"); - /* Make sure the NEXTBLOCK field of the FX */ - /* Points BEYOND the start of the FX; some */ - /* stack blocks have been corrupted this */ - /* way. --JDS 2/3/98 */ + /* Make sure the NEXTBLOCK field of the FX */ + /* Points BEYOND the start of the FX; some */ + /* stack blocks have been corrupted this */ + /* way. --JDS 2/3/98 */ - if (fx68k->nextblock < StkOffset_from_68K(fx68k)/*+FRAMESIZE*/) - { - error("FX's nextblock field < the FFX."); - } + if (fx68k->nextblock < StkOffset_from_68K(fx68k) /*+FRAMESIZE*/) { + error("FX's nextblock field < the FFX."); + } - /* Now make sure the FX is connected to */ - /* a Basic Frame. */ - - dummybf=(Bframe*)DUMMYBF(fx68k); - - /* Check for connection via BLINK field: */ - if(StkOffset_from_68K(dummybf) == GETBLINK(fx68k)) return; - - mblink=GETBLINK(fx68k); - mtmp=(Bframe*)Addr68k_from_StkOffset(mblink); - if( ( dummybf->residual != NIL ) && - ( dummybf->ivar == mtmp->ivar ) ) - return; - else error("CheckFX:bad residual case"); - - - } /* END check_FX */ + /* Now make sure the FX is connected to */ + /* a Basic Frame. */ + dummybf = (Bframe *)DUMMYBF(fx68k); + /* Check for connection via BLINK field: */ + if (StkOffset_from_68K(dummybf) == GETBLINK(fx68k)) return; + mblink = GETBLINK(fx68k); + mtmp = (Bframe *)Addr68k_from_StkOffset(mblink); + if ((dummybf->residual != NIL) && (dummybf->ivar == mtmp->ivar)) + return; + else + error("CheckFX:bad residual case"); +} /* END check_FX */ /************************************************************************/ /* */ @@ -1208,33 +1007,29 @@ void check_FX(FX *fx68k) /* */ /************************************************************************/ -void check_BF(Bframe *bf68k) -{ - Bframe *iptr68k; +void check_BF(Bframe *bf68k) { + Bframe *iptr68k; - /* For starterd, it must BE a BF */ - if(bf68k->flags != STK_BF) error("checkBF:not BF1"); + /* For starterd, it must BE a BF */ + if (bf68k->flags != STK_BF) error("checkBF:not BF1"); - /* If the frame is residual (whatever that means), it's OK */ - if(bf68k->residual == T) return; + /* If the frame is residual (whatever that means), it's OK */ + if (bf68k->residual == T) + return; + else { + if (bf68k->ivar & 1) + error("IVAR is ODD in a BF"); else + for (iptr68k = (Bframe *)Addr68k_from_StkOffset(bf68k->ivar); + iptr68k <= (Bframe *)(((DLword *)bf68k) - 2); iptr68k++) /* inc 2DLword */ { - if (bf68k->ivar & 1) error("IVAR is ODD in a BF"); - else for (iptr68k=(Bframe*)Addr68k_from_StkOffset(bf68k->ivar); - iptr68k <=(Bframe*)(((DLword*)bf68k)-2); - iptr68k++ ) /* inc 2DLword */ - { - /* Make sure none of the "ivar" slots have stack-type */ - /* bits set. */ - if(iptr68k->flags!=STK_NOTFLG) - warn("CheckBF:Stack-bits set in IVAR"); - } + /* Make sure none of the "ivar" slots have stack-type */ + /* bits set. */ + if (iptr68k->flags != STK_NOTFLG) warn("CheckBF:Stack-bits set in IVAR"); } + } - } /* end check_BF */ - - - +} /* end check_BF */ /************************************************************************/ /* */ @@ -1244,17 +1039,15 @@ void check_BF(Bframe *bf68k) /* */ /************************************************************************/ -int check_stack_rooms(FX *fx68k) -{ - int size; - DLword *freeptr68k,*endstk68k; +int check_stack_rooms(FX *fx68k) { + int size; + DLword *freeptr68k, *endstk68k; - CHECK_FX(fx68k); - freeptr68k=Addr68k_from_StkOffset(fx68k->nextblock); - if(!FSBP(freeptr68k)) - error("check_stack_rooms: nextblock doesn't point to an FSB"); - /*endstk68k=freeptr68k + FSB_size(freeptr68k); - size=((UNSIGNED)endstk68k - (UNSIGNED)CurrentStackPTR) >> 1;*/ - return(FSB_size(freeptr68k)); + CHECK_FX(fx68k); + freeptr68k = Addr68k_from_StkOffset(fx68k->nextblock); + if (!FSBP(freeptr68k)) error("check_stack_rooms: nextblock doesn't point to an FSB"); + /*endstk68k=freeptr68k + FSB_size(freeptr68k); + size=((UNSIGNED)endstk68k - (UNSIGNED)CurrentStackPTR) >> 1;*/ + return (FSB_size(freeptr68k)); - } /* end check_stack_rooms */ +} /* end check_stack_rooms */ diff --git a/src/loader.c b/src/loader.c old mode 100755 new mode 100644 index 408b36a..56091a9 --- a/src/loader.c +++ b/src/loader.c @@ -1,7 +1,7 @@ -/* $Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,7 +16,6 @@ static char *id = "$Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ Copyri #include "version.h" - #include "sys/exec.h" /* choose one you like */ #include #include "lispemul.h" @@ -28,194 +27,195 @@ static char *id = "$Id: loader.c,v 1.2 1999/01/03 02:07:16 sybalsky Exp $ Copyri char *sbrk(); unsigned getpagesize(), getpid(); -char * malloc(); +char *malloc(); -#define roundup( a, b) ((((unsigned)(a)+(b)-1)/(b))*(b)) +#define roundup(a, b) ((((unsigned)(a) + (b)-1) / (b)) * (b)) /* A macro to convert a Lisp String to a C string */ -#define LispStringToCString(Lisp, C){ \ - LispPTR *naddress; \ - char *base; \ - int length; \ - int offset; \ - naddress = (LispPTR *)(Addr68k_from_LADDR(Lisp)); \ - base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); \ - offset = (int)(((OneDArray *)naddress)->offset); \ - length = ((OneDArray *)naddress)->totalsize; \ - strncpy(C, base + offset, length); \ - C[length] = '\0'; \ - } +#define LispStringToCString(Lisp, C) \ + { \ + LispPTR *naddress; \ + char *base; \ + int length; \ + int offset; \ + naddress = (LispPTR *)(Addr68k_from_LADDR(Lisp)); \ + base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); \ + offset = (int)(((OneDArray *)naddress)->offset); \ + length = ((OneDArray *)naddress)->totalsize; \ + strncpy(C, base + offset, length); \ + C[length] = '\0'; \ + } - -int dynamic_load_code(args) - LispPTR *args; +int dynamic_load_code(args) LispPTR *args; /* args[0]: LispPTR to file name. - args[1]: native addr of where to load the code + args[1]: native addr of where to load the code - returns: List(load_addr, entry_point, length) + returns: List(load_addr, entry_point, length) */ { -char file_name[512]; -int load_address; -int entry_point; + char file_name[512]; + int load_address; + int entry_point; - LispStringToCString(args[0], file_name); - N_GETNUMBER(args[1], load_address, return_error); - return(load_native_object(load_address, file_name)); + LispStringToCString(args[0], file_name); + N_GETNUMBER(args[1], load_address, return_error); + return (load_native_object(load_address, file_name)); return_error: - printf("error in dynamic load: 0x%x\n",args[1]); - return(NIL_PTR); + printf("error in dynamic load: 0x%x\n", args[1]); + return (NIL_PTR); } -load_native_object(load_address, dynamic_file) - unsigned load_address; - char *dynamic_file; +load_native_object(load_address, dynamic_file) unsigned load_address; +char *dynamic_file; { - int load_length, entry_point; - typedef char *charstrptr; - typedef charstrptr charstrlist[2]; - charstrlist p; - int fd, asize, i; - struct exec hdr; + int load_length, entry_point; + typedef char *charstrptr; + typedef charstrptr charstrlist[2]; + charstrlist p; + int fd, asize, i; + struct exec hdr; - fd = open( dynamic_file, 0 ); - if (fd == -1) return(0); - if (read( fd, &hdr, sizeof hdr ) == -1) return(0); - - load_length = hdr.a_text+hdr.a_data; + fd = open(dynamic_file, 0); + if (fd == -1) return (0); + if (read(fd, &hdr, sizeof hdr) == -1) return (0); -#ifdef DEBUG - printf("Load Size: %x, Header Rec Size %x\n",load_length,sizeof hdr); - printf("Data Size: %x, Text Size %x\n",hdr.a_data, hdr.a_text); + load_length = hdr.a_text + hdr.a_data; + +#ifdef DEBUG + printf("Load Size: %x, Header Rec Size %x\n", load_length, sizeof hdr); + printf("Data Size: %x, Text Size %x\n", hdr.a_data, hdr.a_text); #endif - if (read( fd, load_address, load_length ) == -1) return(0); - entry_point = (int) ( (CFuncPTR)asmcall(load_address) ); - {register int r0, r1, r2; - ARITH_SWITCH((int) load_address, r0); - ARITH_SWITCH((int) entry_point, r1); - ARITH_SWITCH(load_length, r2); - return(N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2, NIL_PTR)))); - } + if (read(fd, load_address, load_length) == -1) return (0); + entry_point = (int)((CFuncPTR)asmcall(load_address)); + { + register int r0, r1, r2; + ARITH_SWITCH((int)load_address, r0); + ARITH_SWITCH((int)entry_point, r1); + ARITH_SWITCH(load_length, r2); + return (N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2, NIL_PTR)))); + } } /* **** system call subr, living in sb_OLD_COMPILE_LOAD_NATIVE slot *** */ -int do_system_call(arg) - LispPTR arg; +int do_system_call(arg) LispPTR arg; { -char cmd_str[512]; -register int result; -register int lisp_result; + char cmd_str[512]; + register int result; + register int lisp_result; - LispStringToCString(arg, cmd_str); -#ifdef DEBUG - printf(":: %s \n",cmd_str); + LispStringToCString(arg, cmd_str); +#ifdef DEBUG + printf(":: %s \n", cmd_str); #endif - int_timer_off(); - result = system(cmd_str); - int_timer_on(); - ARITH_SWITCH(result, lisp_result); - return(lisp_result); + int_timer_off(); + result = system(cmd_str); + int_timer_on(); + ARITH_SWITCH(result, lisp_result); + return (lisp_result); } - /* ****** stuff below is old & should be removed when the subr is *** */ -int dynamic_load (host_file, dynamic_file, load_address, needs_compile, needs_link, do_load) - char *host_file, *dynamic_file; - unsigned load_address, needs_compile, needs_link, do_load; +int dynamic_load(host_file, dynamic_file, load_address, needs_compile, needs_link, + do_load) char *host_file, + *dynamic_file; +unsigned load_address, needs_compile, needs_link, do_load; { - int result = 0; - char fnamec[80], fnameo[80], fnameil[80], cc_str[255], ld_str[255]; - unsigned pagsiz = getpagesize(); - - host_file = "lisp"; /* TEMPORARY ********** */ + int result = 0; + char fnamec[80], fnameo[80], fnameil[80], cc_str[255], ld_str[255]; + unsigned pagsiz = getpagesize(); - printf("loading: %s into %s \n",dynamic_file,host_file); - if (load_address == 0) load_address = roundup(sbrk(0),pagsiz); - sprintf(fnamec, "%s.c", dynamic_file); - sprintf(fnameo, "%s.o", dynamic_file); - sprintf(fnameil, "%s.il", dynamic_file); - sprintf(cc_str,"/bin/cc -pipe -c %s -o %s %s -O -I/users/krivacic/maiko/inc /users/krivacic/maiko/src/disp68K.il",fnamec,fnameo,fnameil); - sprintf(ld_str,"/bin/ld -N -s -Ttext %x -A /users/krivacic/maiko/bin/%s -o %s %s -lc", - load_address,host_file,dynamic_file,fnameo); + host_file = "lisp"; /* TEMPORARY ********** */ + printf("loading: %s into %s \n", dynamic_file, host_file); + if (load_address == 0) load_address = roundup(sbrk(0), pagsiz); + sprintf(fnamec, "%s.c", dynamic_file); + sprintf(fnameo, "%s.o", dynamic_file); + sprintf(fnameil, "%s.il", dynamic_file); + sprintf(cc_str, + "/bin/cc -pipe -c %s -o %s %s -O -I/users/krivacic/maiko/inc " + "/users/krivacic/maiko/src/disp68K.il", + fnamec, fnameo, fnameil); + sprintf(ld_str, "/bin/ld -N -s -Ttext %x -A /users/krivacic/maiko/bin/%s -o %s %s -lc", + load_address, host_file, dynamic_file, fnameo); - if (needs_compile) - {result = exec_command(cc_str); - if (result) return(0); - } - if (needs_link) - {result = exec_command(ld_str); - if (result) return(0); - } - if (do_load) {char rm_str[200]; - result = load_object(load_address, dynamic_file); - sprintf(rm_str,"/bin/rm %s %s %s %s",fnamec, fnameil, fnameo, dynamic_file); -/* *** exec_command(rm_str); *** */ - } - TopOfStack = result; - return(result); + if (needs_compile) { + result = exec_command(cc_str); + if (result) return (0); + } + if (needs_link) { + result = exec_command(ld_str); + if (result) return (0); + } + if (do_load) { + char rm_str[200]; + result = load_object(load_address, dynamic_file); + sprintf(rm_str, "/bin/rm %s %s %s %s", fnamec, fnameil, fnameo, dynamic_file); + /* *** exec_command(rm_str); *** */ + } + TopOfStack = result; + return (result); -} /*dynamic_load */ +} /*dynamic_load */ -exec_command(cmd_str) - char *cmd_str; -{ typedef char *charstrptr; - typedef charstrptr charstrlist[21]; - charstrlist p; - char ws[21][80]; - int i, ii, cmd_length; +exec_command(cmd_str) char *cmd_str; +{ + typedef char *charstrptr; + typedef charstrptr charstrlist[21]; + charstrlist p; + char ws[21][80]; + int i, ii, cmd_length; - int_timer_off(); - i = system(cmd_str); - int_timer_on(); - return(i); + int_timer_off(); + i = system(cmd_str); + int_timer_on(); + return (i); } /*exec_command */ -load_object(load_address, dynamic_file) - unsigned load_address; - char *dynamic_file; +load_object(load_address, dynamic_file) unsigned load_address; +char *dynamic_file; { - int load_length, entry_point; - typedef char *charstrptr; - typedef charstrptr charstrlist[2]; - charstrlist p; - int fd, asize, i; - struct exec hdr; - char *addr2; - unsigned pagsiz = getpagesize(); + int load_length, entry_point; + typedef char *charstrptr; + typedef charstrptr charstrlist[2]; + charstrlist p; + int fd, asize, i; + struct exec hdr; + char *addr2; + unsigned pagsiz = getpagesize(); - fd = open( dynamic_file, 0 ); - if (fd == -1) return(0); - if (read( fd, &hdr, sizeof hdr ) == -1) return(0); - - asize = roundup(hdr.a_text+hdr.a_data+hdr.a_bss, pagsiz)+pagsiz; -#ifdef DEBUG - printf("Load Size: %x, Header Rec Size %x\n",asize,sizeof hdr); - printf("Data Size: %x, Text Size %x\n",hdr.a_data, hdr.a_text); -#endif - addr2 = sbrk(asize); - addr2 = (char *)roundup(addr2,pagsiz); + fd = open(dynamic_file, 0); + if (fd == -1) return (0); + if (read(fd, &hdr, sizeof hdr) == -1) return (0); - if ( load_address != (unsigned)addr2 ){ return(NIL_PTR); } + asize = roundup(hdr.a_text + hdr.a_data + hdr.a_bss, pagsiz) + pagsiz; +#ifdef DEBUG + printf("Load Size: %x, Header Rec Size %x\n", asize, sizeof hdr); + printf("Data Size: %x, Text Size %x\n", hdr.a_data, hdr.a_text); +#endif + addr2 = sbrk(asize); + addr2 = (char *)roundup(addr2, pagsiz); - load_length = hdr.a_text+hdr.a_data; - read( fd, addr2, load_length ); - entry_point = (int) ( (CFuncPTR)asmcall(addr2) ); - {register int r0, r1, r2; -#ifdef DEBUG - printf("Values 0x%x & 0x%x\n",entry_point,load_length); + if (load_address != (unsigned)addr2) { return (NIL_PTR); } + + load_length = hdr.a_text + hdr.a_data; + read(fd, addr2, load_length); + entry_point = (int)((CFuncPTR)asmcall(addr2)); + { + register int r0, r1, r2; +#ifdef DEBUG + printf("Values 0x%x & 0x%x\n", entry_point, load_length); #endif - ARITH_SWITCH((int) addr2, r0); - ARITH_SWITCH((int) entry_point, r1); - ARITH_SWITCH(load_length, r2); -#ifdef DEBUG - printf("Returning 0x%x & 0x%x\n",r1,r2); + ARITH_SWITCH((int)addr2, r0); + ARITH_SWITCH((int)entry_point, r1); + ARITH_SWITCH(load_length, r2); +#ifdef DEBUG + printf("Returning 0x%x & 0x%x\n", r1, r2); #endif - return(N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2)))); - } + return (N_OP_cons(r0, N_OP_cons(r1, N_OP_cons(r2)))); + } } diff --git a/src/loopsops.c b/src/loopsops.c old mode 100755 new mode 100644 index b8b73db..2d4facd --- a/src/loopsops.c +++ b/src/loopsops.c @@ -1,7 +1,7 @@ -/* $Id: loopsops.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: loopsops.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: loopsops.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,16 +16,13 @@ static char *id = "$Id: loopsops.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copy #include "version.h" - - - /* LOOPS opcodes: - FetchMethodOrHelp(object, selector) -> MethodFn - LookupIV(object, iv) -> Index into iDescrs - GetValue(object, iv) - PutValue(object, iv, val) + FetchMethodOrHelp(object, selector) -> MethodFn + LookupIV(object, iv) -> Index into iDescrs + GetValue(object, iv) + PutValue(object, iv, val) */ #include "lispemul.h" @@ -38,111 +35,100 @@ static char *id = "$Id: loopsops.c,v 1.3 1999/05/31 23:35:37 sybalsky Exp $ Copy #include "gc.h" LispPTR lcfuncall(register unsigned int atom_index, register int argnum, register int bytenum); -LispPTR get_package_atom(char *char_base, DLword charlen, char *packname, DLword packlen, int externalp); -static char il_string[]="INTERLISP"; -#define GET_IL_ATOM(string) get_package_atom((string),(sizeof(string)-1), \ - il_string,9,NIL) +LispPTR get_package_atom(char *char_base, DLword charlen, char *packname, DLword packlen, + int externalp); +static char il_string[] = "INTERLISP"; +#define GET_IL_ATOM(string) get_package_atom((string), (sizeof(string) - 1), il_string, 9, NIL) -#define AtomValPtr(index) Addr68k_from_LADDR(*(GetVALCELL68k(index))) +#define AtomValPtr(index) Addr68k_from_LADDR(*(GetVALCELL68k(index))) #ifdef BIGVM -#define DTD_FROM_LADDR(x) \ - (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_name) +#define DTD_FROM_LADDR(x) (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_name) #else -#define DTD_FROM_LADDR(x) \ - (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_namelo + \ - (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_namehi<<16)) +#define DTD_FROM_LADDR(x) \ + (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_namelo + \ + (((struct dtd *)GetDTD(GetTypeNumber((x))))->dtd_namehi << 16)) #endif /* BIGVM */ /* These assume 0 <= POSINT <= 65535 */ -#define SMALLP_FROM_POSINT(x) ((x) | S_POSITIVE) -#define POSINT_FROM_SMALLP(x) ((x) & 0xffff) - -#define RETCALL(fn,argnum) return lcfuncall(fn,argnum,3) +#define SMALLP_FROM_POSINT(x) ((x) | S_POSITIVE) +#define POSINT_FROM_SMALLP(x) ((x)&0xffff) + +#define RETCALL(fn, argnum) return lcfuncall(fn, argnum, 3) /* #define PUNT (-1)*/ -#define METH_CACHE_INDEX(CLASS,SELECTOR) (1023 & ((CLASS) ^ (SELECTOR))) -#define IV_CACHE_INDEX(VARLIST,IV) (1023 & ((VARLIST) ^ (IV))) +#define METH_CACHE_INDEX(CLASS, SELECTOR) (1023 & ((CLASS) ^ (SELECTOR))) +#define IV_CACHE_INDEX(VARLIST, IV) (1023 & ((VARLIST) ^ (IV))) -#define LC_TYPEP(obj,typeATOM) (DTD_FROM_LADDR((obj)) == typeATOM) +#define LC_TYPEP(obj, typeATOM) (DTD_FROM_LADDR((obj)) == typeATOM) -#define INSTANCEP(obj) (LC_TYPEP((obj),atom_instance)) -#define CLASSP(obj) (LC_TYPEP((obj),atom_class)) +#define INSTANCEP(obj) (LC_TYPEP((obj), atom_instance)) +#define CLASSP(obj) (LC_TYPEP((obj), atom_class)) -#define INSTANCE_OR_PUNT(obj,fn,argnum) \ - { if (!LC_TYPEP((obj),atom_instance)) \ - RETCALL(fn,argnum); \ - } +#define INSTANCE_OR_PUNT(obj, fn, argnum) \ + { \ + if (!LC_TYPEP((obj), atom_instance)) RETCALL(fn, argnum); \ + } -#define INSTANCE_CLASS_OR_PUNT(obj,fn,argnum) \ - { register LispPTR tmp = DTD_FROM_LADDR(obj); \ - if (tmp != atom_instance && tmp != atom_class) \ - RETCALL(fn,argnum); \ - } +#define INSTANCE_CLASS_OR_PUNT(obj, fn, argnum) \ + { \ + register LispPTR tmp = DTD_FROM_LADDR(obj); \ + if (tmp != atom_instance && tmp != atom_class) RETCALL(fn, argnum); \ + } -#define LC_INIT if (atom_instance == 0) LCinit() +#define LC_INIT \ + if (atom_instance == 0) LCinit() - -#define GET_IV_INDEX(objptr,iv,dest,otherwise) \ -{ \ - register struct LCIVCacheEntry *ce; \ - register LispPTR iNames=objptr->iNames; \ - \ - ce = &(LCIVCache[IV_CACHE_INDEX(iNames, iv)]); \ - if (ce->iNames == iNames && ce->iv == iv){ \ - (dest) = POSINT_FROM_SMALLP(ce->index); \ - }else{ \ - if (! Listp(iNames)) { \ - otherwise; \ - }else{ \ - register int i=0; \ - while (1) { \ - if ( car(iNames) == iv) { \ - ce->iNames = objptr->iNames; \ - ce->iv = iv; \ - ce->index = SMALLP_FROM_POSINT(i); \ - (dest) = i; \ - break; \ - }else{ \ - i++; \ - if ((iNames = cdr(iNames)) == NIL_PTR) { \ - otherwise; \ - } \ - } \ - } \ - } \ - } \ -} +#define GET_IV_INDEX(objptr, iv, dest, otherwise) \ + { \ + register struct LCIVCacheEntry *ce; \ + register LispPTR iNames = objptr->iNames; \ + \ + ce = &(LCIVCache[IV_CACHE_INDEX(iNames, iv)]); \ + if (ce->iNames == iNames && ce->iv == iv) { \ + (dest) = POSINT_FROM_SMALLP(ce->index); \ + } else { \ + if (!Listp(iNames)) { \ + otherwise; \ + } else { \ + register int i = 0; \ + while (1) { \ + if (car(iNames) == iv) { \ + ce->iNames = objptr->iNames; \ + ce->iv = iv; \ + ce->index = SMALLP_FROM_POSINT(i); \ + (dest) = i; \ + break; \ + } else { \ + i++; \ + if ((iNames = cdr(iNames)) == NIL_PTR) { otherwise; } \ + } \ + } \ + } \ + } \ + } - -struct LCClass { /* class datatype */ - LispPTR metaClass, ivNames, ivDescrs, - classUnitRec, localIVs, cvNames, - cvDescrs, className, supers, subClasses, - otherClassDescription, selectors, methods, localSupers; +struct LCClass { /* class datatype */ + LispPTR metaClass, ivNames, ivDescrs, classUnitRec, localIVs, cvNames, cvDescrs, className, + supers, subClasses, otherClassDescription, selectors, methods, localSupers; }; -struct LCInstance { /* instance datatype */ +struct LCInstance { /* instance datatype */ LispPTR class, iNames, iDescrs, instMiscField; }; struct LCMethodCacheEntry { LispPTR class, selector, method_fn, junk; -} *LCMethodCache; +} * LCMethodCache; struct LCIVCacheEntry { LispPTR iNames, iv, index, junk; -} *LCIVCache; +} * LCIVCache; -LispPTR atom_instance = 0, /* various atom indices */ - atom_class, - atom_annotatedValue, - atom_FetchMethodOrHelp_LCUFN, - atom_FetchMethod_LCUFN, - atom_FindVarIndex_LCUFN, - atom_GetIVValue_LCUFN, - atom_PutIVValue_LCUFN; +LispPTR atom_instance = 0, /* various atom indices */ + atom_class, atom_annotatedValue, atom_FetchMethodOrHelp_LCUFN, atom_FetchMethod_LCUFN, + atom_FindVarIndex_LCUFN, atom_GetIVValue_LCUFN, atom_PutIVValue_LCUFN; /* Called once to initialize the "constants" above */ @@ -155,11 +141,9 @@ LispPTR LCinit(void) { atom_FindVarIndex_LCUFN = GET_IL_ATOM("\\FindVarIndex-LCUFN"); atom_GetIVValue_LCUFN = GET_IL_ATOM("\\GetIVValue-LCUFN"); atom_PutIVValue_LCUFN = GET_IL_ATOM("\\PutIVValue-LCUFN"); - LCMethodCache = (struct LCMethodCacheEntry *) - AtomValPtr(GET_IL_ATOM("*Global-Method-Cache*")); - LCIVCache = (struct LCIVCacheEntry *) - AtomValPtr(GET_IL_ATOM("*Global-IV-Cache-Block*")); - return NIL_PTR; /* in case called from lisp */ + LCMethodCache = (struct LCMethodCacheEntry *)AtomValPtr(GET_IL_ATOM("*Global-Method-Cache*")); + LCIVCache = (struct LCIVCacheEntry *)AtomValPtr(GET_IL_ATOM("*Global-IV-Cache-Block*")); + return NIL_PTR; /* in case called from lisp */ } /* Type check fn */ @@ -167,126 +151,116 @@ LispPTR LCinit(void) { so the loop is unnecessary. */ /* * * NOT USED * * */ #ifdef NEVER -int LCTypeOf(thing, typename) -register LispPTR thing,typename; +int LCTypeOf(thing, typename) register LispPTR thing, typename; { register struct dtd *dtd68k; #ifdef BIGVM - for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(thing)); - typename != (dtd68k->dtd_name); - dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype) ) { - if( dtd68k->dtd_supertype == 0) return 0; + for (dtd68k = (struct dtd *)GetDTD(GetTypeNumber(thing)); typename != (dtd68k->dtd_name); + dtd68k = (struct dtd *)GetDTD(dtd68k->dtd_supertype)) { + if (dtd68k->dtd_supertype == 0) return 0; } #else - for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(thing)); - typename != dtd68k->dtd_namelo+(dtgd68k->dtd_namehi<<16) ; - dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype) ) { - if( dtd68k->dtd_supertype == 0) return 0; + for (dtd68k = (struct dtd *)GetDTD(GetTypeNumber(thing)); + typename != dtd68k->dtd_namelo + (dtgd68k->dtd_namehi << 16); + dtd68k = (struct dtd *)GetDTD(dtd68k->dtd_supertype)) { + if (dtd68k->dtd_supertype == 0) return 0; } #endif /* BIGVM */ - return 1; + return 1; } #endif /* NEVER */ - /* Method lookup using global cache */ -LispPTR LCFetchMethodOrHelp(register LispPTR object, register LispPTR selector) -{ +LispPTR LCFetchMethodOrHelp(register LispPTR object, register LispPTR selector) { register struct LCInstance *objptr; register struct LCMethodCacheEntry *ce; register LispPTR cur_class; - + LC_INIT; - INSTANCE_CLASS_OR_PUNT(object,atom_FetchMethodOrHelp_LCUFN,2); + INSTANCE_CLASS_OR_PUNT(object, atom_FetchMethodOrHelp_LCUFN, 2); - objptr = (struct LCInstance *) Addr68k_from_LADDR(object); + objptr = (struct LCInstance *)Addr68k_from_LADDR(object); ce = &(LCMethodCache[METH_CACHE_INDEX((cur_class = objptr->class), selector)]); - if(ce->class == cur_class && ce->selector == selector) - return ce->method_fn; - + if (ce->class == cur_class && ce->selector == selector) return ce->method_fn; + /* not in cache, search class then supers */ { LispPTR supers = ((struct LCClass *)Addr68k_from_LADDR(cur_class))->supers; - + for (;;) { - register i=0; + register i = 0; register LispPTR val; register LispPTR *selectorptr; register struct LCClass *classptr; - + classptr = (struct LCClass *)Addr68k_from_LADDR(cur_class); if (classptr->selectors == NIL_PTR) { - goto next_class; - }else{ - selectorptr = (LispPTR *)Addr68k_from_LADDR(classptr->selectors); + goto next_class; + } else { + selectorptr = (LispPTR *)Addr68k_from_LADDR(classptr->selectors); } - + while ((val = selectorptr[i++]) != NIL_PTR) { - if (val == selector) { - ce->class = objptr->class; - ce->selector = selector; - return (ce->method_fn = - ((LispPTR *)Addr68k_from_LADDR(classptr->methods))[i-1]) ; - } + if (val == selector) { + ce->class = objptr->class; + ce->selector = selector; + return (ce->method_fn = ((LispPTR *)Addr68k_from_LADDR(classptr->methods))[i - 1]); + } }; - -next_class: - if( (cur_class = car(supers) ) == NIL_PTR) - break; + + next_class: + if ((cur_class = car(supers)) == NIL_PTR) break; supers = cdr(supers); } } /* we didn't find it at all; punt */ - RETCALL(atom_FetchMethodOrHelp_LCUFN,2); + RETCALL(atom_FetchMethodOrHelp_LCUFN, 2); -/* return lcfuncall(atom_FetchMethodOrHelp_LCUFN,2,3); */ -/* return PUNT;*/ + /* return lcfuncall(atom_FetchMethodOrHelp_LCUFN,2,3); */ + /* return PUNT;*/ } - -LispPTR LCFetchMethod(register LispPTR class, register LispPTR selector) -{ +LispPTR LCFetchMethod(register LispPTR class, register LispPTR selector) { register struct LCMethodCacheEntry *ce; - + LC_INIT; /* Check cache before doing type check */ ce = &(LCMethodCache[METH_CACHE_INDEX(class, selector)]); - if(ce->class == class && ce->selector == selector) - return ce->method_fn; - + if (ce->class == class && ce->selector == selector) return ce->method_fn; + /* it wasn't there, go search class then supers */ - - if (!LC_TYPEP(class, atom_class)) RETCALL(atom_FetchMethod_LCUFN,2); + + if (!LC_TYPEP(class, atom_class)) RETCALL(atom_FetchMethod_LCUFN, 2); { register LispPTR cur_class = class; LispPTR supers = ((struct LCClass *)Addr68k_from_LADDR(cur_class))->supers; - + for (;;) { - register i=0; + register i = 0; register LispPTR val; register struct LCClass *classptr; register LispPTR *selectorptr; - + classptr = (struct LCClass *)Addr68k_from_LADDR(cur_class); - if (classptr->selectors == NIL_PTR) goto next_class; - else selectorptr = (LispPTR *)Addr68k_from_LADDR(classptr->selectors); - + if (classptr->selectors == NIL_PTR) + goto next_class; + else + selectorptr = (LispPTR *)Addr68k_from_LADDR(classptr->selectors); + while ((val = selectorptr[i++]) != NIL_PTR) { - if (val == selector) { - ce->class = class; - ce->selector = selector; - return (ce->method_fn = - ((LispPTR *)Addr68k_from_LADDR(classptr->methods))[i-1]); - } + if (val == selector) { + ce->class = class; + ce->selector = selector; + return (ce->method_fn = ((LispPTR *)Addr68k_from_LADDR(classptr->methods))[i - 1]); + } }; - -next_class: - if( (cur_class = car(supers) ) == NIL_PTR) - break; + + next_class: + if ((cur_class = car(supers)) == NIL_PTR) break; supers = cdr(supers); } } @@ -295,106 +269,97 @@ next_class: return NIL_PTR; } -LispPTR LCFindVarIndex(register LispPTR iv, register LispPTR object) -{ +LispPTR LCFindVarIndex(register LispPTR iv, register LispPTR object) { register struct LCInstance *objptr; register struct LCIVCacheEntry *ce; register LispPTR iNames; LC_INIT; - INSTANCE_CLASS_OR_PUNT(object,atom_FindVarIndex_LCUFN,2); + INSTANCE_CLASS_OR_PUNT(object, atom_FindVarIndex_LCUFN, 2); - objptr = (struct LCInstance *) Addr68k_from_LADDR(object); + objptr = (struct LCInstance *)Addr68k_from_LADDR(object); ce = &(LCIVCache[IV_CACHE_INDEX((iNames = objptr->iNames), iv)]); - if (ce->iNames == iNames && ce->iv == iv) - return ce->index; + if (ce->iNames == iNames && ce->iv == iv) return ce->index; - if (! Listp(iNames)) return NIL_PTR; /* FastFindIndex lisp macro (& others?) */ - /* needs this check too ! */ + if (!Listp(iNames)) return NIL_PTR; /* FastFindIndex lisp macro (& others?) */ + /* needs this check too ! */ { register int i; - for (i=0; i++; (iNames = cdr(iNames)) != NIL_PTR) { - if ( car(iNames) == iv) { - ce->iNames = objptr->iNames; - ce->iv = iv; - return (ce->index = SMALLP_FROM_POSINT(i)); + for (i = 0; i++; (iNames = cdr(iNames)) != NIL_PTR) { + if (car(iNames) == iv) { + ce->iNames = objptr->iNames; + ce->iv = iv; + return (ce->index = SMALLP_FROM_POSINT(i)); } } return NIL_PTR; } } - #if 01 -LispPTR -LCGetIVValue(register LispPTR object, register LispPTR iv) -{ +LispPTR LCGetIVValue(register LispPTR object, register LispPTR iv) { register struct LCInstance *objptr; register LispPTR val; register int index; LC_INIT; - INSTANCE_OR_PUNT(object,atom_GetIVValue_LCUFN,2); + INSTANCE_OR_PUNT(object, atom_GetIVValue_LCUFN, 2); - objptr = (struct LCInstance *) Addr68k_from_LADDR(object); - GET_IV_INDEX(objptr,iv,index,goto pnut); - val = ((LispPTR *) Addr68k_from_LADDR(objptr->iDescrs))[index]; + objptr = (struct LCInstance *)Addr68k_from_LADDR(object); + GET_IV_INDEX(objptr, iv, index, goto pnut); + val = ((LispPTR *)Addr68k_from_LADDR(objptr->iDescrs))[index]; if (!LC_TYPEP(val, atom_annotatedValue)) return val; - pnut: - RETCALL(atom_GetIVValue_LCUFN,2); -/* - return LCGetActiveValue(object,val); -*/ +pnut: + RETCALL(atom_GetIVValue_LCUFN, 2); + /* + return LCGetActiveValue(object,val); + */ } -LispPTR LCPutIVValue(register LispPTR object, register LispPTR iv, register LispPTR val) -{ +LispPTR LCPutIVValue(register LispPTR object, register LispPTR iv, register LispPTR val) { register struct LCInstance *objptr; register LispPTR *valptr; register int index; LC_INIT; - INSTANCE_OR_PUNT(object,atom_PutIVValue_LCUFN,3); + INSTANCE_OR_PUNT(object, atom_PutIVValue_LCUFN, 3); - objptr = (struct LCInstance *) Addr68k_from_LADDR(object); - GET_IV_INDEX(objptr,iv,index,goto pnut); - valptr = &(((LispPTR *) Addr68k_from_LADDR(objptr->iDescrs))[index]); + objptr = (struct LCInstance *)Addr68k_from_LADDR(object); + GET_IV_INDEX(objptr, iv, index, goto pnut); + valptr = &(((LispPTR *)Addr68k_from_LADDR(objptr->iDescrs))[index]); if (!LC_TYPEP(*valptr, atom_annotatedValue)) { FRPLPTR((*valptr), val); return val; } - pnut: - RETCALL(atom_PutIVValue_LCUFN,3); -/* - return LCPutActiveValue(object,*valptr,val); -*/ +pnut: + RETCALL(atom_PutIVValue_LCUFN, 3); + /* + return LCPutActiveValue(object,*valptr,val); + */ } #endif - - LispPTR lcfuncall(register unsigned int atom_index, register int argnum, register int bytenum) - /* Atomindex for Function to invoke */ - /* Number of ARGS on TOS and STK */ - /* Number of bytes of Caller's - OPCODE(including multi-byte) */ +/* Atomindex for Function to invoke */ +/* Number of ARGS on TOS and STK */ +/* Number of bytes of Caller's + OPCODE(including multi-byte) */ { register struct definition_cell *defcell68k; /* Definition Cell PTR */ - register short pv_num; /* scratch for pv */ + register short pv_num; /* scratch for pv */ register struct fnhead *tmp_fn; - int rest; /* use for arignments */ - int closurep=NIL; + int rest; /* use for arignments */ + int closurep = NIL; register CClosure *closure68k; if (atom_index == 0xffffffff) error("Loops punt to nonexistant fn"); /* Get Next Block offset from argnum */ - CURRENTFX->nextblock = (LADDR_from_68k(CurrentStackPTR) & 0x0ffff) - - (argnum<<1)+4 /* +3 */; + CURRENTFX->nextblock = (LADDR_from_68k(CurrentStackPTR) & 0x0ffff) - (argnum << 1) + 4 /* +3 */; /* Setup IVar */ IVar = Addr68k_from_LADDR((((LispPTR)(CURRENTFX->nextblock)) | STK_OFFSET)); @@ -402,41 +367,38 @@ LispPTR lcfuncall(register unsigned int atom_index, register int argnum, registe /* Set PC to the Next Instruction and save into FX */ CURRENTFX->pc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) + bytenum; - PushCStack; /* save TOS */ + PushCStack; /* save TOS */ /* Get DEFCELL 68k address */ - defcell68k =(struct definition_cell *) GetDEFCELL68k(atom_index); + defcell68k = (struct definition_cell *)GetDEFCELL68k(atom_index); - tmp_fn = (struct fnhead *)Addr68k_from_LADDR( defcell68k->defpointer ); + tmp_fn = (struct fnhead *)Addr68k_from_LADDR(defcell68k->defpointer); - if((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin +STK_SAFE) - >= (UNSIGNED)EndSTKP ) - { - LispPTR test; - test= *((LispPTR*)CurrentStackPTR); - /* DOSTACKOVERFLOW(argnum,bytenum-1); XXX until we figure out what should be happening */ - S_CHECK(test==*((LispPTR*)CurrentStackPTR), "overflow in ccfuncall"); - } + if ((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin + STK_SAFE) >= (UNSIGNED)EndSTKP) { + LispPTR test; + test = *((LispPTR *)CurrentStackPTR); + /* DOSTACKOVERFLOW(argnum,bytenum-1); XXX until we figure out what should be happening */ + S_CHECK(test == *((LispPTR *)CurrentStackPTR), "overflow in ccfuncall"); + } FuncObj = tmp_fn; - if( FuncObj->na >= 0 ) - { - /* This Function is Spread Type */ - /* Arguments on Stack Adjustment */ - rest = argnum - FuncObj->na; + if (FuncObj->na >= 0) { + /* This Function is Spread Type */ + /* Arguments on Stack Adjustment */ + rest = argnum - FuncObj->na; - while(rest <0) { - PushStack(NIL_PTR); - rest++; - } - CurrentStackPTR -= (rest<<1); - } /* if end */ + while (rest < 0) { + PushStack(NIL_PTR); + rest++; + } + CurrentStackPTR -= (rest << 1); + } /* if end */ /* Set up BF */ - CurrentStackPTR+=2; + CurrentStackPTR += 2; GETWORD(CurrentStackPTR) = BF_MARK; - GETWORD(CurrentStackPTR+1) = CURRENTFX->nextblock; - CurrentStackPTR+=2; + GETWORD(CurrentStackPTR + 1) = CURRENTFX->nextblock; + CurrentStackPTR += 2; /* Set up FX */ GETWORD(CurrentStackPTR) = FX_MARK; @@ -445,22 +407,19 @@ LispPTR lcfuncall(register unsigned int atom_index, register int argnum, registe ((struct frameex1 *)CurrentStackPTR)->alink = LADDR_from_68k(PVar); PVar = (DLword *)CurrentStackPTR + FRAMESIZE; #ifdef BIGVM - ((struct frameex1 *)CurrentStackPTR)->fnheader = - (defcell68k->defpointer); + ((struct frameex1 *)CurrentStackPTR)->fnheader = (defcell68k->defpointer); #else - ((struct frameex1 *)CurrentStackPTR)->lofnheader = - (defcell68k->defpointer) & 0x0ffff; - ((struct frameex1 *)CurrentStackPTR)->hi2fnheader = - ((defcell68k->defpointer) & SEGMASK) >> 16; + ((struct frameex1 *)CurrentStackPTR)->lofnheader = (defcell68k->defpointer) & 0x0ffff; + ((struct frameex1 *)CurrentStackPTR)->hi2fnheader = ((defcell68k->defpointer) & SEGMASK) >> 16; ((struct frameex1 *)CurrentStackPTR)->hi1fnheader = 0; #endif /* BIGVM */ CurrentStackPTR = PVar; /* Set up PVar area */ - pv_num = FuncObj->pv+1; /* Changed Apr.27 */ + pv_num = FuncObj->pv + 1; /* Changed Apr.27 */ - while(pv_num > 0) { + while (pv_num > 0) { *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; CurrentStackPTR += DLWORDSPER_CELL; *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; @@ -471,6 +430,5 @@ LispPTR lcfuncall(register unsigned int atom_index, register int argnum, registe /* Set PC points New Function's first OPCODE */ PC = (ByteCode *)FuncObj + FuncObj->startpc; - return -2; /* signal to OP_miscn to leave stack & pc alone */ + return -2; /* signal to OP_miscn to leave stack & pc alone */ } /* end lcfuncall */ - diff --git a/src/lowlev1.c b/src/lowlev1.c old mode 100755 new mode 100644 index e5e030e..5dfecef --- a/src/lowlev1.c +++ b/src/lowlev1.c @@ -1,9 +1,7 @@ -/* $Id: lowlev1.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lowlev1.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lowlev1.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,8 +16,6 @@ static char *id = "$Id: lowlev1.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyr #include "version.h" - - #include #include "lispemul.h" #include "lspglob.h" @@ -28,136 +24,125 @@ static char *id = "$Id: lowlev1.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyr #include "lsptypes.h" #include "emlglob.h" -int mask_array[16] = { 1, 3, 7, 0xf, - 0x1f, 0x3f, 0x7f, 0xff, - 0x1ff, 0x3ff, 0x7ff, 0xfff, - 0x1fff, 0x3fff, 0x7fff, 0xffff}; - +int mask_array[16] = {1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, + 0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff}; /************************************************************ N_OP_putbitsnfd - entry PUTBITS.N.FD OPCODE[0317] + entry PUTBITS.N.FD OPCODE[0317] - 1. <> - TopOfStack: NewValue - *((int *)(CurrentStackPTR)): base address. - alpha: word offset. - beta: High nibble -- number of the first bit of the field - Low nibble -- (number of the size of the fiel) - 1 - 2. Data is @[TopOfStack + alpha] - 3. Shift and mask the data. - 4. Set the data at [TopOfStack + alpha]. - 5. <> - return: ?? + 1. <> + TopOfStack: NewValue + *((int *)(CurrentStackPTR)): base address. + alpha: word offset. + beta: High nibble -- number of the first bit of the field + Low nibble -- (number of the size of the fiel) - 1 + 2. Data is @[TopOfStack + alpha] + 3. Shift and mask the data. + 4. Set the data at [TopOfStack + alpha]. + 5. <> + return: ?? ***********************************************************/ -LispPTR N_OP_putbitsnfd(register LispPTR base, register LispPTR data, int word_offset, register int beta) -{ -register DLword *pword; -register int shift_size, field_size, fmask; +LispPTR N_OP_putbitsnfd(register LispPTR base, register LispPTR data, int word_offset, + register int beta) { + register DLword *pword; + register int shift_size, field_size, fmask; #ifdef CHECK - if (base > POINTERMASK) {error("getbits: base out of range");} - if (beta > 0xFF) {error("bad beta argument to PUTBITS");} + if (base > POINTERMASK) { error("getbits: base out of range"); } + if (beta > 0xFF) { error("bad beta argument to PUTBITS"); } #endif - if( (SEGMASK & data ) != S_POSITIVE ) { ERROR_EXIT(data); }; + if ((SEGMASK & data) != S_POSITIVE) { ERROR_EXIT(data); }; - pword = Addr68k_from_LADDR( base + word_offset ); - field_size = 0xF & beta; - shift_size = 15 - (beta >> 4) - field_size; - fmask = mask_array[field_size] << shift_size; - GETWORD(pword) = ( (data << shift_size) & fmask) | (GETWORD(pword) & (~fmask)); + pword = Addr68k_from_LADDR(base + word_offset); + field_size = 0xF & beta; + shift_size = 15 - (beta >> 4) - field_size; + fmask = mask_array[field_size] << shift_size; + GETWORD(pword) = ((data << shift_size) & fmask) | (GETWORD(pword) & (~fmask)); - return(base); + return (base); } /************************************************************ N_OP_getbitsnfd - entry GETBITS.N.FD OPCODE[0312] + entry GETBITS.N.FD OPCODE[0312] - 1. <> - TopOfStack: base address. - alpha: word offset. - beta: High nibble -- number of the first bit of the field - Low nibble -- (number of the size of the fiel) - 1 - 2. Data is @[TopOfStack + alpha] - 3. Shift and mask the data. - 4. <> - return: hi - S_POSITIVE - lo - mask & shifted data + 1. <> + TopOfStack: base address. + alpha: word offset. + beta: High nibble -- number of the first bit of the field + Low nibble -- (number of the size of the fiel) - 1 + 2. Data is @[TopOfStack + alpha] + 3. Shift and mask the data. + 4. <> + return: hi - S_POSITIVE + lo - mask & shifted data ***********************************************************/ -LispPTR N_OP_getbitsnfd(int base_addr, register int word_offset, int beta) -{ -register DLword *pword; -register short first; -register short size; +LispPTR N_OP_getbitsnfd(int base_addr, register int word_offset, int beta) { + register DLword *pword; + register short first; + register short size; - - pword = Addr68k_from_LADDR( base_addr + word_offset ); - size = 0xF & beta; - first = beta >> 4; + pword = Addr68k_from_LADDR(base_addr + word_offset); + size = 0xF & beta; + first = beta >> 4; #ifdef CHECK - if (base_addr > POINTERMASK) {error("getbits: base out of range");} - if (first+size > 15) {error("getbits beta too big");} + if (base_addr > POINTERMASK) { error("getbits: base out of range"); } + if (first + size > 15) { error("getbits beta too big"); } #endif - return(S_POSITIVE | - ( ( GETWORD(pword) >> (16 - (first + size + 1)) ) - & mask_array[size] ) ) ; + return (S_POSITIVE | ((GETWORD(pword) >> (16 - (first + size + 1))) & mask_array[size])); } - /************************************************************ N_OP_putbasen - entry PUTBASE.N OPCODE[0315] + entry PUTBASE.N OPCODE[0315] - 1. <> - TopOfStack: Low Word - replace data - *(CurrentStackPTR): base address. - alpha: offset. - 2. if high word of TopOFStack is not SMALLPL, - then call ufn2incS, - else replace (base address + offset) with data. - 3. increment PC by 2. - 4. <> - return: base address. - (Called only by Native code) + 1. <> + TopOfStack: Low Word - replace data + *(CurrentStackPTR): base address. + alpha: offset. + 2. if high word of TopOFStack is not SMALLPL, + then call ufn2incS, + else replace (base address + offset) with data. + 3. increment PC by 2. + 4. <> + return: base address. + (Called only by Native code) ***********************************************************/ -LispPTR N_OP_putbasen(register LispPTR base, register LispPTR tos, int n) -{ - base = POINTERMASK & base; - if( (SEGMASK & tos ) != S_POSITIVE ) {ERROR_EXIT(tos);} - else{ - GETWORD((DLword *) Addr68k_from_LADDR( base + n )) = GetLoWord(tos); - return(base); - } +LispPTR N_OP_putbasen(register LispPTR base, register LispPTR tos, int n) { + base = POINTERMASK & base; + if ((SEGMASK & tos) != S_POSITIVE) { + ERROR_EXIT(tos); + } else { + GETWORD((DLword *)Addr68k_from_LADDR(base + n)) = GetLoWord(tos); + return (base); + } } /************************************************************ N_OP_putbaseptrn - entry PUTBASEPTR.N OPCODE[0316] + entry PUTBASEPTR.N OPCODE[0316] - 1. <> - TopOfStack: replace data (2 words) - *(CurrentStackPTR): base address. - alpha: offset. - 2. replace (base address + offset) with data. - 3. save base address to TopOfStack - 3. increment PC by 2. - 4. <> - return: base address. - (Called only by Native code) + 1. <> + TopOfStack: replace data (2 words) + *(CurrentStackPTR): base address. + alpha: offset. + 2. replace (base address + offset) with data. + 3. save base address to TopOfStack + 3. increment PC by 2. + 4. <> + return: base address. + (Called only by Native code) ***********************************************************/ -LispPTR N_OP_putbaseptrn(register LispPTR base, register LispPTR tos, int n) -{ - base = POINTERMASK & base; - *((LispPTR *) Addr68k_from_LADDR( base + n )) = tos & POINTERMASK; - return(base); - +LispPTR N_OP_putbaseptrn(register LispPTR base, register LispPTR tos, int n) { + base = POINTERMASK & base; + *((LispPTR *)Addr68k_from_LADDR(base + n)) = tos & POINTERMASK; + return (base); } - diff --git a/src/lowlev2.c b/src/lowlev2.c old mode 100755 new mode 100644 index 49eefa6..b69cf96 --- a/src/lowlev2.c +++ b/src/lowlev2.c @@ -1,9 +1,7 @@ -/* $Id: lowlev2.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lowlev2.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lowlev2.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,9 +16,6 @@ static char *id = "$Id: lowlev2.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyr #include "version.h" - - - #include #include "lispemul.h" #include "lspglob.h" @@ -33,105 +28,86 @@ static char *id = "$Id: lowlev2.c,v 1.3 1999/05/31 23:35:38 sybalsky Exp $ Copyr /************************************************************ N_OP_addbase - entry ADDBASE OPCODE[0320] + entry ADDBASE OPCODE[0320] - 1. <> - TopOfStack: offset - *(CurrentStackPTR): base address - 2. if High word of TopOfStack is SMALLPL or SMALLNEG, - then add base address and offset and set result to TopOfStack. - else call ufn2incs. - 4. <> - return: new address + 1. <> + TopOfStack: offset + *(CurrentStackPTR): base address + 2. if High word of TopOfStack is SMALLPL or SMALLNEG, + then add base address and offset and set result to TopOfStack. + else call ufn2incs. + 4. <> + return: new address ***********************************************************/ -LispPTR N_OP_addbase(register int base, register int offset) -{ - base = POINTERMASK & base; - switch( (SEGMASK & offset) ){ - case S_POSITIVE: - return(base + (offset & 0x0000FFFF)); - case S_NEGATIVE: - return(base + (offset | 0xFFFF0000)); - default: - switch( (GetTypeNumber(offset)) ){ - case TYPE_FIXP: - /* overflow or underflow isn't check */ - return(base + *(int *)Addr68k_from_LADDR(offset)); - default: /* floatp also */ - ERROR_EXIT(offset); - }/* end switch */ - }/* end switch */ +LispPTR N_OP_addbase(register int base, register int offset) { + base = POINTERMASK & base; + switch ((SEGMASK & offset)) { + case S_POSITIVE: return (base + (offset & 0x0000FFFF)); + case S_NEGATIVE: return (base + (offset | 0xFFFF0000)); + default: + switch ((GetTypeNumber(offset))) { + case TYPE_FIXP: + /* overflow or underflow isn't check */ + return (base + *(int *)Addr68k_from_LADDR(offset)); + default: /* floatp also */ ERROR_EXIT(offset); + } /* end switch */ + } /* end switch */ } /************************************************************ N_OP_getbasebyte - entry GETBASEBYTE OPCODE[0302] + entry GETBASEBYTE OPCODE[0302] - 1. <> - *(--CurrentStackPTR): base address. - TopOfStack: Low word - byte offset. - 2. if high word of TopOfStack is not SMALLPL, - then call ufn2incS. - else fetch 8 bits word at (base address + byte offset). - 4. <> - return: Least Low Byte - fetched data + 1. <> + *(--CurrentStackPTR): base address. + TopOfStack: Low word - byte offset. + 2. if high word of TopOfStack is not SMALLPL, + then call ufn2incS. + else fetch 8 bits word at (base address + byte offset). + 4. <> + return: Least Low Byte - fetched data ***********************************************************/ -LispPTR N_OP_getbasebyte(register LispPTR base_addr, register int byteoffset) -{ - switch( (SEGMASK & byteoffset) ){ - case S_POSITIVE: - byteoffset = byteoffset & 0x0000FFFF; - break; - case S_NEGATIVE: - byteoffset = byteoffset | 0xFFFF0000; - break; - default: - switch( (GetTypeNumber(byteoffset)) ){ - case TYPE_FIXP: - byteoffset = *((int *)Addr68k_from_LADDR(byteoffset)); - break; - default: /* floatp also fall thru */ - ERROR_EXIT(byteoffset); - }/* end switch */ - break; - }/* end switch */ - return((0xFF & (GETBYTE((char*)Addr68k_from_LADDR((POINTERMASK & base_addr)) + byteoffset))) | S_POSITIVE); +LispPTR N_OP_getbasebyte(register LispPTR base_addr, register int byteoffset) { + switch ((SEGMASK & byteoffset)) { + case S_POSITIVE: byteoffset = byteoffset & 0x0000FFFF; break; + case S_NEGATIVE: byteoffset = byteoffset | 0xFFFF0000; break; + default: + switch ((GetTypeNumber(byteoffset))) { + case TYPE_FIXP: byteoffset = *((int *)Addr68k_from_LADDR(byteoffset)); break; + default: /* floatp also fall thru */ ERROR_EXIT(byteoffset); + } /* end switch */ + break; + } /* end switch */ + return ((0xFF & (GETBYTE((char *)Addr68k_from_LADDR((POINTERMASK & base_addr)) + byteoffset))) | + S_POSITIVE); } /************************************************************ N_OP_putbasebyte - entry PUTBASEBYTE OPCODE[0307] + entry PUTBASEBYTE OPCODE[0307] - 1. <> - TopOfStack: Least Low Byte - replace data. - *((int *)(CurrentStackPTR-1)): byte offset. - *((int *)(CurrentStackPTR-2)): base address. - 4. <> - return: Least Low Byte - replace data ? + 1. <> + TopOfStack: Least Low Byte - replace data. + *((int *)(CurrentStackPTR-1)): byte offset. + *((int *)(CurrentStackPTR-2)): base address. + 4. <> + return: Least Low Byte - replace data ? ***********************************************************/ -LispPTR N_OP_putbasebyte(register LispPTR base_addr, register int byteoffset, register int tos) -{ - if(((SEGMASK & tos ) != S_POSITIVE) || ((unsigned short)tos >= 256)) - ERROR_EXIT(tos); - switch( (SEGMASK & byteoffset) ){ - case S_POSITIVE: - byteoffset &= 0x0000FFFF; - break; - case S_NEGATIVE: - byteoffset |= 0xFFFF0000; - break; - default: - /* ucode and ufn don't handle displacement not smallp */ - ERROR_EXIT(tos); - }/* end switch */ - GETBYTE(((char*)Addr68k_from_LADDR(POINTERMASK & base_addr)) + byteoffset) = 0xFF & tos; - return ( tos ); +LispPTR N_OP_putbasebyte(register LispPTR base_addr, register int byteoffset, register int tos) { + if (((SEGMASK & tos) != S_POSITIVE) || ((unsigned short)tos >= 256)) ERROR_EXIT(tos); + switch ((SEGMASK & byteoffset)) { + case S_POSITIVE: byteoffset &= 0x0000FFFF; break; + case S_NEGATIVE: byteoffset |= 0xFFFF0000; break; + default: + /* ucode and ufn don't handle displacement not smallp */ + ERROR_EXIT(tos); + } /* end switch */ + GETBYTE(((char *)Addr68k_from_LADDR(POINTERMASK & base_addr)) + byteoffset) = 0xFF & tos; + return (tos); } - - diff --git a/src/lpdual.c b/src/lpdual.c old mode 100755 new mode 100644 index 966ac5e..27efce4 --- a/src/lpdual.c +++ b/src/lpdual.c @@ -1,7 +1,7 @@ -/* $Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,141 +16,116 @@ static char *id = "$Id: lpdual.c,v 1.2 1999/01/03 02:07:17 sybalsky Exp $ Copyri #include "version.h" - #include "lpdefs.h" #include "lpglobl.h" #ifdef alliant -#pragma global safe (Eta_rownr, Eta_value) +#pragma global safe(Eta_rownr, Eta_value) #pragma global assoc #endif #ifdef OS4 -rowdual(rownr) -int *rownr; +rowdual(rownr) int *rownr; #else -void rowdual(int *rownr) +void rowdual(int *rownr) #endif { - int i; + int i; double f, g, minrhs; - short artifs; + short artifs; #ifdef alliant -#pragma safe (Rhs, Upbo, Bas) +#pragma safe(Rhs, Upbo, Bas) #endif - - if (Verbose) - printf("rowdual\n"); + + if (Verbose) printf("rowdual\n"); (*rownr) = 0; minrhs = -EPSB; i = 0; artifs = FALSE; - while (i < Rows && !artifs) - { - i++; - f = Upbo[Bas[i]]; - if (f == 0 && Rhs[i] != 0) - { - artifs = TRUE; - (*rownr) = i; - } + while (i < Rows && !artifs) { + i++; + f = Upbo[Bas[i]]; + if (f == 0 && Rhs[i] != 0) { + artifs = TRUE; + (*rownr) = i; + } else { + if (Rhs[i] < f - Rhs[i]) + g = Rhs[i]; else - { - if (Rhs[i] < f - Rhs[i]) - g = Rhs[i]; - else - g = f - Rhs[i]; - if (g < minrhs) - { - minrhs = g; - (*rownr) = i; - } - } + g = f - Rhs[i]; + if (g < minrhs) { + minrhs = g; + (*rownr) = i; + } } + } } /* rowdual */ #ifdef OS4 -short coldual(numeta, rownr, colnr, minit, prow, drow) - int *numeta, *rownr, *colnr; - short *minit; - double *prow, *drow; +short coldual(numeta, rownr, colnr, minit, prow, drow) int *numeta, *rownr, *colnr; +short *minit; +double *prow, *drow; #else -short coldual(int *numeta, - int *rownr, - int *colnr, - short *minit, - double *prow, - double *drow) +short coldual(int *numeta, int *rownr, int *colnr, short *minit, double *prow, double *drow) #endif { - int i, j, r, varnr; + int i, j, r, varnr; double theta, quot, pivot, d, f, g; - + #ifdef alliant -#pragma safe (Rhs, Upbo, Bas, Cend, Endetacol, prow, drow, Basis, Lower) +#pragma safe(Rhs, Upbo, Bas, Cend, Endetacol, prow, drow, Basis, Lower) #endif - if (Verbose) - printf("coldual\n"); - if (!(*minit)) - { - for (i = 0; i <= Rows; i++) - { - prow[i] = 0; - drow[i] = 0; - } - drow[0] = 1; - prow[(*rownr)] = 1; - for (i = (*numeta); i >= 1; i--) - { - d = 0; - f = 0; - r = Eta_rownr[Endetacol[i] - 1]; - for (j = Endetacol[i - 1]; j < Endetacol[i]; j++) - { - /* this is where the program consumes most cpu time */ - f = f + prow[Eta_rownr[j]] * Eta_value[j]; - d = d + drow[Eta_rownr[j]] * Eta_value[j]; - } - if (abs(f) < EPSEL) - prow[r] = 0; - else - prow[r] = f; - if (abs(d) < EPSEL) - drow[r] = 0; - else - drow[r] = d; - } - for (i = 1; i <= Columns; i++) - { - varnr = Rows + i; - if (!Basis[varnr]) - { - d = -Extrad * drow[0]; - f = 0; - for (j = Cend[i - 1]; j < Cend[i]; j++) - { - d += drow[Mat[j].rownr] * Mat[j].value; - f += prow[Mat[j].rownr] * Mat[j].value; - } - drow[varnr] = d; - prow[varnr] = f; - } - } + if (Verbose) printf("coldual\n"); + if (!(*minit)) { + for (i = 0; i <= Rows; i++) { + prow[i] = 0; + drow[i] = 0; + } + drow[0] = 1; + prow[(*rownr)] = 1; + for (i = (*numeta); i >= 1; i--) { + d = 0; + f = 0; + r = Eta_rownr[Endetacol[i] - 1]; + for (j = Endetacol[i - 1]; j < Endetacol[i]; j++) { + /* this is where the program consumes most cpu time */ + f = f + prow[Eta_rownr[j]] * Eta_value[j]; + d = d + drow[Eta_rownr[j]] * Eta_value[j]; + } + if (abs(f) < EPSEL) + prow[r] = 0; + else + prow[r] = f; + if (abs(d) < EPSEL) + drow[r] = 0; + else + drow[r] = d; + } + for (i = 1; i <= Columns; i++) { + varnr = Rows + i; + if (!Basis[varnr]) { + d = -Extrad * drow[0]; + f = 0; + for (j = Cend[i - 1]; j < Cend[i]; j++) { + d += drow[Mat[j].rownr] * Mat[j].value; + f += prow[Mat[j].rownr] * Mat[j].value; + } + drow[varnr] = d; + prow[varnr] = f; + } + } #ifdef alliant #pragma loop novector #endif - - for (i = 0; i <= Sum; i++) - { - if (abs(prow[i]) < EPSEL) - prow[i] = 0; - if (abs(drow[i]) < EPSD) - drow[i] = 0; - } + + for (i = 0; i <= Sum; i++) { + if (abs(prow[i]) < EPSEL) prow[i] = 0; + if (abs(drow[i]) < EPSD) drow[i] = 0; } + } if (Rhs[(*rownr)] > Upbo[Bas[(*rownr)]]) g = -1; else @@ -158,34 +133,28 @@ short coldual(int *numeta, pivot = 0; (*colnr) = 0; theta = INFINITE; - for (i = 1; i <= Sum; i++) - { - if (Lower[i]) - d = prow[i] * g; - else - d = -prow[i] * g; - if (d < 0) - if (!Basis[i]) - if (Upbo[i] > 0) - { - if (Lower[i]) - quot = -drow[i] / (double) d; - else - quot = drow[i] / (double) d; - if (quot < theta) - { - theta = quot; - pivot = d; - (*colnr) = i; - } - else - if (quot == theta) - if (abs(d) > abs(pivot)) - { - pivot = d; - (*colnr) = i; - } - } - } + for (i = 1; i <= Sum; i++) { + if (Lower[i]) + d = prow[i] * g; + else + d = -prow[i] * g; + if (d < 0) + if (!Basis[i]) + if (Upbo[i] > 0) { + if (Lower[i]) + quot = -drow[i] / (double)d; + else + quot = drow[i] / (double)d; + if (quot < theta) { + theta = quot; + pivot = d; + (*colnr) = i; + } else if (quot == theta) + if (abs(d) > abs(pivot)) { + pivot = d; + (*colnr) = i; + } + } + } return ((*colnr) > 0); } /* coldual */ diff --git a/src/lpkit.c b/src/lpkit.c old mode 100755 new mode 100644 index 61655a8..181d524 --- a/src/lpkit.c +++ b/src/lpkit.c @@ -1,23 +1,20 @@ -/* $Id: lpkit.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ -static char *id = "$Id: lpkit.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ Copyright (C) Venue"; - - - -/************************************************************************/ -/* */ -/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/* The contents of this file are proprietary information */ -/* belonging to Venue, and are provided to you under license. */ -/* They may not be further distributed or disclosed to third */ -/* parties without the specific permission of Venue. */ -/* */ -/************************************************************************/ - -#include "version.h" - - +/* $Id: lpkit.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +static char *id = "$Id: lpkit.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-99 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + #include "lpkit.h" #include "lpglob.h" #include @@ -25,52 +22,51 @@ static char *id = "$Id: lpkit.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ Copyrig #include /* Globals */ -lprec *Lp=NULL; /* pointer to active problem */ -int Rows; -int Columns; -int Sum; -int Non_zeros; -int Level; -matrec *Mat; -int *Col_no; -int *Col_end; -int *Row_end; -REAL *Orig_rh; -REAL *Rh; -REAL *Rhs; -short *Must_be_int; -REAL *Orig_upbo; -REAL *Orig_lowbo; -REAL *Upbo; -REAL *Lowbo; -int *Bas; -short *Basis; -short *Lower; -int Eta_alloc; -int Eta_size; -REAL *Eta_value; -int *Eta_row_nr; -int *Eta_col_end; -int Num_inv; -REAL *Solution; -REAL *Best_solution; -REAL Infinite; -REAL Epsilon; -REAL Epsb; -REAL Epsd; -REAL Epsel; +lprec *Lp = NULL; /* pointer to active problem */ +int Rows; +int Columns; +int Sum; +int Non_zeros; +int Level; +matrec *Mat; +int *Col_no; +int *Col_end; +int *Row_end; +REAL *Orig_rh; +REAL *Rh; +REAL *Rhs; +short *Must_be_int; +REAL *Orig_upbo; +REAL *Orig_lowbo; +REAL *Upbo; +REAL *Lowbo; +int *Bas; +short *Basis; +short *Lower; +int Eta_alloc; +int Eta_size; +REAL *Eta_value; +int *Eta_row_nr; +int *Eta_col_end; +int Num_inv; +REAL *Solution; +REAL *Best_solution; +REAL Infinite; +REAL Epsilon; +REAL Epsb; +REAL Epsd; +REAL Epsel; -REAL TREJ; -REAL TINV; +REAL TREJ; +REAL TINV; -short Maximise; -short Floor_first; -REAL Extrad; +short Maximise; +short Floor_first; +REAL Extrad; -int Warn_count; /* used in CHECK version of rounding macro */ +int Warn_count; /* used in CHECK version of rounding macro */ #ifdef NEVER -void error(char *format, ...) -{ +void error(char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); @@ -80,91 +76,84 @@ void error(char *format, ...) } #endif -lprec *make_lp(int rows, int columns) -{ +lprec *make_lp(int rows, int columns) { lprec *newlp; - int i, sum; - sstate *st; /* to save state in MILP runs */ + int i, sum; + sstate *st; /* to save state in MILP runs */ - sum=rows+columns; - if(rows < 0 || columns < 0) - error("rows < 0 or columns < 0"); + sum = rows + columns; + if (rows < 0 || columns < 0) error("rows < 0 or columns < 0"); CALLOC(newlp, 1, lprec); strcpy(newlp->lp_name, "unnamed"); - newlp->active=FALSE; - newlp->verbose=FALSE; - newlp->print_duals=FALSE; - newlp->print_sol=FALSE; - newlp->debug=FALSE; - newlp->print_at_invert=FALSE; - newlp->trace=FALSE; + newlp->active = FALSE; + newlp->verbose = FALSE; + newlp->print_duals = FALSE; + newlp->print_sol = FALSE; + newlp->debug = FALSE; + newlp->print_at_invert = FALSE; + newlp->trace = FALSE; - newlp->rows=rows; - newlp->columns=columns; - newlp->sum=sum; - newlp->rows_alloc=rows; - newlp->columns_alloc=columns; - newlp->sum_alloc=sum; - newlp->names_used=FALSE; + newlp->rows = rows; + newlp->columns = columns; + newlp->sum = sum; + newlp->rows_alloc = rows; + newlp->columns_alloc = columns; + newlp->sum_alloc = sum; + newlp->names_used = FALSE; - newlp->obj_bound=DEF_INFINITE; - newlp->infinite=DEF_INFINITE; - newlp->epsilon=DEF_EPSILON; - newlp->epsb=DEF_EPSB; - newlp->epsd=DEF_EPSD; - newlp->epsel=DEF_EPSEL; - newlp->non_zeros=0; - newlp->mat_alloc=1; + newlp->obj_bound = DEF_INFINITE; + newlp->infinite = DEF_INFINITE; + newlp->epsilon = DEF_EPSILON; + newlp->epsb = DEF_EPSB; + newlp->epsd = DEF_EPSD; + newlp->epsel = DEF_EPSEL; + newlp->non_zeros = 0; + newlp->mat_alloc = 1; CALLOC(newlp->mat, newlp->mat_alloc, matrec); CALLOC(newlp->col_no, newlp->mat_alloc, int); CALLOC(newlp->col_end, columns + 1, int); CALLOC(newlp->row_end, rows + 1, int); - newlp->row_end_valid=FALSE; + newlp->row_end_valid = FALSE; CALLOC(newlp->orig_rh, rows + 1, REAL); CALLOC(newlp->rh, rows + 1, REAL); CALLOC(newlp->rhs, rows + 1, REAL); CALLOC(newlp->must_be_int, sum + 1, short); - for(i = 0; i <= sum; i++) - newlp->must_be_int[i]=FALSE; + for (i = 0; i <= sum; i++) newlp->must_be_int[i] = FALSE; CALLOC(newlp->orig_upbo, sum + 1, REAL); - for(i = 0; i <= sum; i++) - newlp->orig_upbo[i]=newlp->infinite; + for (i = 0; i <= sum; i++) newlp->orig_upbo[i] = newlp->infinite; CALLOC(newlp->upbo, sum + 1, REAL); CALLOC(newlp->orig_lowbo, sum + 1, REAL); CALLOC(newlp->lowbo, sum + 1, REAL); - newlp->basis_valid=TRUE; - CALLOC(newlp->bas, rows+1, int); + newlp->basis_valid = TRUE; + CALLOC(newlp->bas, rows + 1, int); CALLOC(newlp->basis, sum + 1, short); CALLOC(newlp->lower, sum + 1, short); - for(i = 0; i <= rows; i++) - { - newlp->bas[i]=i; - newlp->basis[i]=TRUE; - } - for(i = rows + 1; i <= sum; i++) - newlp->basis[i]=FALSE; - for(i = 0 ; i <= sum; i++) - newlp->lower[i]=TRUE; - - newlp->eta_valid=TRUE; - newlp->eta_size=0; - newlp->eta_alloc=10000; - newlp->max_num_inv=DEFNUMINV; + for (i = 0; i <= rows; i++) { + newlp->bas[i] = i; + newlp->basis[i] = TRUE; + } + for (i = rows + 1; i <= sum; i++) newlp->basis[i] = FALSE; + for (i = 0; i <= sum; i++) newlp->lower[i] = TRUE; - newlp->nr_lagrange=0; + newlp->eta_valid = TRUE; + newlp->eta_size = 0; + newlp->eta_alloc = 10000; + newlp->max_num_inv = DEFNUMINV; + + newlp->nr_lagrange = 0; CALLOC(newlp->eta_value, newlp->eta_alloc, REAL); CALLOC(newlp->eta_row_nr, newlp->eta_alloc, int); CALLOC(newlp->eta_col_end, newlp->rows_alloc + newlp->max_num_inv, int); - newlp->bb_rule=FIRST_NI; - newlp->break_at_int=FALSE; - newlp->break_value=0; + newlp->bb_rule = FIRST_NI; + newlp->break_at_int = FALSE; + newlp->break_value = 0; - newlp->iter=0; - newlp->total_iter=0; + newlp->iter = 0; + newlp->total_iter = 0; CALLOC(newlp->solution, sum + 1, REAL); CALLOC(newlp->best_solution, sum + 1, REAL); CALLOC(newlp->duals, rows + 1, REAL); @@ -177,46 +166,39 @@ lprec *make_lp(int rows, int columns) CALLOC(newlp->ch_sign, rows + 1, short); - for(i = 0; i <= rows; i++) - newlp->ch_sign[i] = FALSE; + for (i = 0; i <= rows; i++) newlp->ch_sign[i] = FALSE; st = newlp->solve_states = NULL; - for (i=0; i < Sum + 2; i++) - { - if (st) /* There's an old state-saver to use; re-use it. */ - { - st->saved = 0; /* clear the in-use field */ - st->notint = 0; /* And the not-integer field */ - st = st->next; - } - else - { - st = (sstate *) malloc(sizeof(sstate)); - if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */ - st->next = newlp->solve_states; - st->saved = 0; - st->notint = 0; /* And the not-integer field */ - newlp->solve_states = st; - st = (sstate *)NULL; - } + for (i = 0; i < Sum + 2; i++) { + if (st) /* There's an old state-saver to use; re-use it. */ + { + st->saved = 0; /* clear the in-use field */ + st->notint = 0; /* And the not-integer field */ + st = st->next; + } else { + st = (sstate *)malloc(sizeof(sstate)); + if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */ + st->next = newlp->solve_states; + st->saved = 0; + st->notint = 0; /* And the not-integer field */ + newlp->solve_states = st; + st = (sstate *)NULL; } + } - newlp->valid = FALSE; + newlp->valid = FALSE; - return(newlp); + return (newlp); } -void delete_lp(lprec *lp) -{ - int i; +void delete_lp(lprec *lp) { + int i; - if(lp->active) - Lp=NULL; - if(lp->names_used) - { - free(lp->row_name); - free(lp->col_name); - } + if (lp->active) Lp = NULL; + if (lp->names_used) { + free(lp->row_name); + free(lp->col_name); + } free(lp->mat); free(lp->col_no); free(lp->col_end); @@ -239,40 +221,35 @@ void delete_lp(lprec *lp) free(lp->best_solution); free(lp->duals); free(lp->ch_sign); - if(lp->scaling_used) - free(lp->scale); - if(lp->nr_lagrange>0) - { - free(lp->lag_rhs); - free(lp->lambda); - free(lp->lag_con_type); - for(i=0; i < lp->nr_lagrange; i++) - free(lp->lag_row[i]); - free(lp->lag_row); - } + if (lp->scaling_used) free(lp->scale); + if (lp->nr_lagrange > 0) { + free(lp->lag_rhs); + free(lp->lambda); + free(lp->lag_con_type); + for (i = 0; i < lp->nr_lagrange; i++) free(lp->lag_row[i]); + free(lp->lag_row); + } free(lp); - lp=NULL; -} + lp = NULL; +} -lprec *copy_lp(lprec *lp) -{ +lprec *copy_lp(lprec *lp) { lprec *newlp; int i, rowsplus, colsplus, sumplus; - - rowsplus=lp->rows_alloc+1; - colsplus=lp->columns_alloc+1; - sumplus=lp->sum_alloc+1; + + rowsplus = lp->rows_alloc + 1; + colsplus = lp->columns_alloc + 1; + sumplus = lp->sum_alloc + 1; MALLOCCPY(newlp, lp, 1, lprec); /* copy all non pointers */ - newlp->active=FALSE; + newlp->active = FALSE; - if(newlp->names_used) - { - MALLOCCPY(newlp->col_name, lp->col_name, colsplus, nstring); - MALLOCCPY(newlp->row_name, lp->row_name, rowsplus, nstring); - } + if (newlp->names_used) { + MALLOCCPY(newlp->col_name, lp->col_name, colsplus, nstring); + MALLOCCPY(newlp->row_name, lp->row_name, rowsplus, nstring); + } MALLOCCPY(newlp->mat, lp->mat, newlp->mat_alloc, matrec); MALLOCCPY(newlp->col_end, lp->col_end, colsplus, int); @@ -291,226 +268,180 @@ lprec *copy_lp(lprec *lp) MALLOCCPY(newlp->lower, lp->lower, sumplus, short); MALLOCCPY(newlp->eta_value, lp->eta_value, lp->eta_alloc, REAL); MALLOCCPY(newlp->eta_row_nr, lp->eta_row_nr, lp->eta_alloc, int); - MALLOCCPY(newlp->eta_col_end, lp->eta_col_end, - lp->rows_alloc + lp->max_num_inv, int); + MALLOCCPY(newlp->eta_col_end, lp->eta_col_end, lp->rows_alloc + lp->max_num_inv, int); MALLOCCPY(newlp->solution, lp->solution, sumplus, REAL); MALLOCCPY(newlp->best_solution, lp->best_solution, sumplus, REAL); MALLOCCPY(newlp->duals, lp->duals, rowsplus, REAL); MALLOCCPY(newlp->ch_sign, lp->ch_sign, rowsplus, short); - if(newlp->scaling_used) - MALLOCCPY(newlp->scale, lp->scale, sumplus, REAL); + if (newlp->scaling_used) MALLOCCPY(newlp->scale, lp->scale, sumplus, REAL); - if(newlp->nr_lagrange > 0) - { - MALLOCCPY(newlp->lag_rhs, lp->lag_rhs, newlp->nr_lagrange, REAL); - MALLOCCPY(newlp->lambda, lp->lambda, newlp->nr_lagrange, REAL); - MALLOCCPY(newlp->lag_con_type, lp->lag_con_type, newlp->nr_lagrange, - short); - MALLOC(newlp->lag_row, newlp->nr_lagrange, REAL*); - for(i = 0; i < newlp->nr_lagrange; i++) - MALLOCCPY(newlp->lag_row[i], lp->lag_row[i], colsplus, REAL); + if (newlp->nr_lagrange > 0) { + MALLOCCPY(newlp->lag_rhs, lp->lag_rhs, newlp->nr_lagrange, REAL); + MALLOCCPY(newlp->lambda, lp->lambda, newlp->nr_lagrange, REAL); + MALLOCCPY(newlp->lag_con_type, lp->lag_con_type, newlp->nr_lagrange, short); + MALLOC(newlp->lag_row, newlp->nr_lagrange, REAL *); + for (i = 0; i < newlp->nr_lagrange; i++) + MALLOCCPY(newlp->lag_row[i], lp->lag_row[i], colsplus, REAL); + } + return (newlp); +} + +void inc_mat_space(lprec *lp, int maxextra) { + if (lp->non_zeros + maxextra >= lp->mat_alloc) { + lp->mat_alloc = lp->non_zeros + maxextra; + REALLOC(lp->mat, lp->mat_alloc, matrec); + REALLOC(lp->col_no, lp->mat_alloc, int); + if (lp->active) { + Mat = lp->mat; + Col_no = lp->col_no; } - return(newlp); + } } -void inc_mat_space(lprec *lp, int maxextra) -{ - if(lp->non_zeros + maxextra >= lp->mat_alloc) - { - lp->mat_alloc = lp->non_zeros + maxextra; - REALLOC(lp->mat, lp->mat_alloc, matrec); - REALLOC(lp->col_no, lp->mat_alloc, int); - if (lp->active) - { - Mat=lp->mat; - Col_no=lp->col_no; - } - } -} - -void inc_row_space(lprec *lp) -{ - if(lp->rows > lp->rows_alloc) - { - lp->rows_alloc=lp->rows+10; - lp->sum_alloc=lp->rows_alloc+lp->columns_alloc; - REALLOC(lp->orig_rh, lp->rows_alloc + 1, REAL); - REALLOC(lp->rh, lp->rows_alloc + 1, REAL); - REALLOC(lp->rhs, lp->rows_alloc + 1, REAL); - REALLOC(lp->orig_upbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->upbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->orig_lowbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->lowbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->solution, lp->sum_alloc + 1, REAL); - REALLOC(lp->best_solution, lp->sum_alloc + 1, REAL); - REALLOC(lp->row_end, lp->rows_alloc + 1, int); - REALLOC(lp->basis, lp->sum_alloc + 1, short); - REALLOC(lp->lower, lp->sum_alloc + 1, short); - REALLOC(lp->must_be_int, lp->sum_alloc + 1, short); - REALLOC(lp->bas, lp->rows_alloc + 1, int); - REALLOC(lp->duals, lp->rows_alloc + 1, REAL); - REALLOC(lp->ch_sign, lp->rows_alloc + 1, short); - REALLOC(lp->eta_col_end, lp->rows_alloc + lp->max_num_inv, int); - if(lp->names_used) - REALLOC(lp->row_name, lp->rows_alloc + 1, nstring); - if(lp->scaling_used) - REALLOC(lp->scale, lp->sum_alloc + 1, REAL); - if(lp->active) - set_globals(lp); - } +void inc_row_space(lprec *lp) { + if (lp->rows > lp->rows_alloc) { + lp->rows_alloc = lp->rows + 10; + lp->sum_alloc = lp->rows_alloc + lp->columns_alloc; + REALLOC(lp->orig_rh, lp->rows_alloc + 1, REAL); + REALLOC(lp->rh, lp->rows_alloc + 1, REAL); + REALLOC(lp->rhs, lp->rows_alloc + 1, REAL); + REALLOC(lp->orig_upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->orig_lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->best_solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->row_end, lp->rows_alloc + 1, int); + REALLOC(lp->basis, lp->sum_alloc + 1, short); + REALLOC(lp->lower, lp->sum_alloc + 1, short); + REALLOC(lp->must_be_int, lp->sum_alloc + 1, short); + REALLOC(lp->bas, lp->rows_alloc + 1, int); + REALLOC(lp->duals, lp->rows_alloc + 1, REAL); + REALLOC(lp->ch_sign, lp->rows_alloc + 1, short); + REALLOC(lp->eta_col_end, lp->rows_alloc + lp->max_num_inv, int); + if (lp->names_used) REALLOC(lp->row_name, lp->rows_alloc + 1, nstring); + if (lp->scaling_used) REALLOC(lp->scale, lp->sum_alloc + 1, REAL); + if (lp->active) set_globals(lp); + } } -void inc_col_space(lprec *lp) -{ - if(lp->columns >= lp->columns_alloc) - { - lp->columns_alloc=lp->columns+10; - lp->sum_alloc=lp->rows_alloc+lp->columns_alloc; - REALLOC(lp->must_be_int, lp->sum_alloc + 1, short); - REALLOC(lp->orig_upbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->upbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->orig_lowbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->lowbo, lp->sum_alloc + 1, REAL); - REALLOC(lp->solution, lp->sum_alloc + 1, REAL); - REALLOC(lp->best_solution, lp->sum_alloc + 1, REAL); - REALLOC(lp->basis, lp->sum_alloc + 1, short); - REALLOC(lp->lower, lp->sum_alloc + 1, short); - if(lp->names_used) - REALLOC(lp->col_name, lp->columns_alloc + 1, nstring); - if(lp->scaling_used) - REALLOC(lp->scale, lp->sum_alloc + 1, REAL); - REALLOC(lp->col_end, lp->columns_alloc + 1, int); - if(lp->active) - set_globals(lp); - } +void inc_col_space(lprec *lp) { + if (lp->columns >= lp->columns_alloc) { + lp->columns_alloc = lp->columns + 10; + lp->sum_alloc = lp->rows_alloc + lp->columns_alloc; + REALLOC(lp->must_be_int, lp->sum_alloc + 1, short); + REALLOC(lp->orig_upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->upbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->orig_lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->lowbo, lp->sum_alloc + 1, REAL); + REALLOC(lp->solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->best_solution, lp->sum_alloc + 1, REAL); + REALLOC(lp->basis, lp->sum_alloc + 1, short); + REALLOC(lp->lower, lp->sum_alloc + 1, short); + if (lp->names_used) REALLOC(lp->col_name, lp->columns_alloc + 1, nstring); + if (lp->scaling_used) REALLOC(lp->scale, lp->sum_alloc + 1, REAL); + REALLOC(lp->col_end, lp->columns_alloc + 1, int); + if (lp->active) set_globals(lp); + } } -void set_mat(lprec *lp, int Row, int Column, REAL Value) -{ +void set_mat(lprec *lp, int Row, int Column, REAL Value) { int elmnr, lastelm, i; - if(Row > lp->rows || Row < 0) - error("Row out of range"); - if(Column > lp->columns || Column < 1) - error("Column out of range"); - if(lp->scaling_used) - Value *= lp->scale[Row] * lp->scale[lp->rows + Column]; - - if(TRUE /*abs(Value) > lp->epsilon*/) - { - if (lp->basis[Column] == TRUE && Row > 0) - lp->basis_valid = FALSE; - lp->eta_valid = FALSE; - elmnr = lp->col_end[Column-1]; - while((elmnr < lp->col_end[Column]) ? - (lp->mat[elmnr].row_nr != Row) : FALSE) - elmnr++; + if (Row > lp->rows || Row < 0) error("Row out of range"); + if (Column > lp->columns || Column < 1) error("Column out of range"); + if (lp->scaling_used) Value *= lp->scale[Row] * lp->scale[lp->rows + Column]; - if((elmnr != lp->col_end[Column]) ? - (lp->mat[elmnr].row_nr == Row) : FALSE ) - if (lp->scaling_used) - { - if(lp->ch_sign[Row]) - lp->mat[elmnr].value = - -Value * lp->scale[Row] * lp->scale[Column]; - else - lp->mat[elmnr].value = - Value * lp->scale[Row] * lp->scale[Column]; - } - else - { - if(lp->ch_sign[Row]) - lp->mat[elmnr].value = -Value; - else - lp->mat[elmnr].value = Value; - } - else - { - /* check if more space is needed for matrix */ - inc_mat_space(lp,1); + if (TRUE /*abs(Value) > lp->epsilon*/) { + if (lp->basis[Column] == TRUE && Row > 0) lp->basis_valid = FALSE; + lp->eta_valid = FALSE; + elmnr = lp->col_end[Column - 1]; + while ((elmnr < lp->col_end[Column]) ? (lp->mat[elmnr].row_nr != Row) : FALSE) elmnr++; - /* Shift the matrix */ - lastelm=lp->non_zeros; - for(i = lastelm; i > elmnr ; i--) - lp->mat[i]=lp->mat[i-1]; - for(i = Column; i <= lp->columns; i++) - lp->col_end[i]++; + if ((elmnr != lp->col_end[Column]) ? (lp->mat[elmnr].row_nr == Row) : FALSE) + if (lp->scaling_used) { + if (lp->ch_sign[Row]) + lp->mat[elmnr].value = -Value * lp->scale[Row] * lp->scale[Column]; + else + lp->mat[elmnr].value = Value * lp->scale[Row] * lp->scale[Column]; + } else { + if (lp->ch_sign[Row]) + lp->mat[elmnr].value = -Value; + else + lp->mat[elmnr].value = Value; + } + else { + /* check if more space is needed for matrix */ + inc_mat_space(lp, 1); - /* Set new element */ - lp->mat[elmnr].row_nr=Row; + /* Shift the matrix */ + lastelm = lp->non_zeros; + for (i = lastelm; i > elmnr; i--) lp->mat[i] = lp->mat[i - 1]; + for (i = Column; i <= lp->columns; i++) lp->col_end[i]++; - if (lp->scaling_used) - { - if(lp->ch_sign[Row]) - lp->mat[elmnr].value=-Value*lp->scale[Row]*lp->scale[Column]; - else - lp->mat[elmnr].value=Value*lp->scale[Row]*lp->scale[Column]; - } - else - { - if(lp->ch_sign[Row]) - lp->mat[elmnr].value=-Value; - else - lp->mat[elmnr].value=Value; - } + /* Set new element */ + lp->mat[elmnr].row_nr = Row; - lp->row_end_valid=FALSE; - - lp->non_zeros++; - if (lp->active) - Non_zeros=lp->non_zeros; - } + if (lp->scaling_used) { + if (lp->ch_sign[Row]) + lp->mat[elmnr].value = -Value * lp->scale[Row] * lp->scale[Column]; + else + lp->mat[elmnr].value = Value * lp->scale[Row] * lp->scale[Column]; + } else { + if (lp->ch_sign[Row]) + lp->mat[elmnr].value = -Value; + else + lp->mat[elmnr].value = Value; + } + + lp->row_end_valid = FALSE; + + lp->non_zeros++; + if (lp->active) Non_zeros = lp->non_zeros; } + } } -void set_obj_fn(lprec *lp, REAL *row) -{ +void set_obj_fn(lprec *lp, REAL *row) { int i; - for(i = 1; i <= lp->columns; i++) - set_mat(lp, 0, i, row[i]); + for (i = 1; i <= lp->columns; i++) set_mat(lp, 0, i, row[i]); } -void str_set_obj_fn(lprec *lp, char *row) -{ - int i; +void str_set_obj_fn(lprec *lp, char *row) { + int i; REAL *arow; char *p, *newp; CALLOC(arow, lp->columns + 1, REAL); p = row; - for(i = 1; i <= lp->columns; i++) - { - arow[i] = (REAL) strtod(p, &newp); - if(p==newp) - error("Bad string in str_set_obj_fn"); - else - p=newp; - } + for (i = 1; i <= lp->columns; i++) { + arow[i] = (REAL)strtod(p, &newp); + if (p == newp) + error("Bad string in str_set_obj_fn"); + else + p = newp; + } set_obj_fn(lp, arow); free(arow); } - -void add_constraint(lprec *lp, REAL *row, short constr_type, REAL rh) -{ +void add_constraint(lprec *lp, REAL *row, short constr_type, REAL rh) { matrec *newmat; - int i, j; - int elmnr; - int stcol; - int *addtoo; - int *num,*rownum, row_nr; + int i, j; + int elmnr; + int stcol; + int *addtoo; + int *num, *rownum, row_nr; REAL theta; - MALLOC(addtoo, lp->columns + 1, int) + MALLOC(addtoo, lp->columns + 1, int) - for(i = 1; i <= lp->columns; i++) - if(row[i]!=0) - { - addtoo[i]=TRUE; - lp->non_zeros++; - } - else - addtoo[i]=FALSE; + for (i = 1; i <= lp->columns; i++) + if (row[i] != 0) { + addtoo[i] = TRUE; + lp->non_zeros++; + } else + addtoo[i] = FALSE; MALLOC(newmat, lp->non_zeros, matrec); inc_mat_space(lp, 0); @@ -518,1339 +449,1065 @@ void add_constraint(lprec *lp, REAL *row, short constr_type, REAL rh) lp->sum++; inc_row_space(lp); - if(lp->scaling_used) - { - /* shift scale */ - for(i=lp->sum; i > lp->rows; i--) - lp->scale[i]=lp->scale[i-1]; - lp->scale[lp->rows]=1; - } + if (lp->scaling_used) { + /* shift scale */ + for (i = lp->sum; i > lp->rows; i--) lp->scale[i] = lp->scale[i - 1]; + lp->scale[lp->rows] = 1; + } - if(lp->names_used) - sprintf(lp->row_name[lp->rows], "r_%d", lp->rows); + if (lp->names_used) sprintf(lp->row_name[lp->rows], "r_%d", lp->rows); - if(lp->scaling_used && lp->columns_scaled) - for(i = 1; i <= lp->columns; i++) - row[i] *= lp->scale[lp->rows+i]; - - if(constr_type==GE) + if (lp->scaling_used && lp->columns_scaled) + for (i = 1; i <= lp->columns; i++) row[i] *= lp->scale[lp->rows + i]; + + if (constr_type == GE) lp->ch_sign[lp->rows] = TRUE; else lp->ch_sign[lp->rows] = FALSE; elmnr = 0; stcol = 0; - for(i = 1; i <= lp->columns; i++) - { - for(j = stcol; j < lp->col_end[i]; j++) - { - newmat[elmnr].row_nr=lp->mat[j].row_nr; - newmat[elmnr].value=lp->mat[j].value; - elmnr++; - } - if(addtoo[i]) - { - if(lp->ch_sign[lp->rows]) - newmat[elmnr].value = -row[i]; - else - newmat[elmnr].value = row[i]; - newmat[elmnr].row_nr = lp->rows; - elmnr++; - } - stcol=lp->col_end[i]; - lp->col_end[i]=elmnr; - } - - memcpy(lp->mat, newmat, lp->non_zeros*sizeof(matrec)); - + for (i = 1; i <= lp->columns; i++) { + for (j = stcol; j < lp->col_end[i]; j++) { + newmat[elmnr].row_nr = lp->mat[j].row_nr; + newmat[elmnr].value = lp->mat[j].value; + elmnr++; + } + if (addtoo[i]) { + if (lp->ch_sign[lp->rows]) + newmat[elmnr].value = -row[i]; + else + newmat[elmnr].value = row[i]; + newmat[elmnr].row_nr = lp->rows; + elmnr++; + } + stcol = lp->col_end[i]; + lp->col_end[i] = elmnr; + } + + memcpy(lp->mat, newmat, lp->non_zeros * sizeof(matrec)); + free(newmat); free(addtoo); - for(i=lp->sum ; i > lp->rows; i--) - { - lp->orig_upbo[i]=lp->orig_upbo[i-1]; - lp->orig_lowbo[i]=lp->orig_lowbo[i-1]; - lp->basis[i]=lp->basis[i-1]; - lp->lower[i]=lp->lower[i-1]; - lp->must_be_int[i]=lp->must_be_int[i-1]; - } + for (i = lp->sum; i > lp->rows; i--) { + lp->orig_upbo[i] = lp->orig_upbo[i - 1]; + lp->orig_lowbo[i] = lp->orig_lowbo[i - 1]; + lp->basis[i] = lp->basis[i - 1]; + lp->lower[i] = lp->lower[i - 1]; + lp->must_be_int[i] = lp->must_be_int[i - 1]; + } - for(i= 1 ; i <= lp->rows; i++) - if(lp->bas[i] >= lp->rows) - lp->bas[i]++; + for (i = 1; i <= lp->rows; i++) + if (lp->bas[i] >= lp->rows) lp->bas[i]++; - if(constr_type==LE || constr_type==GE) - { - lp->orig_upbo[lp->rows]=lp->infinite; - } - else if(constr_type==EQ) - { - lp->orig_upbo[lp->rows]=0; - } + if (constr_type == LE || constr_type == GE) { + lp->orig_upbo[lp->rows] = lp->infinite; + } else if (constr_type == EQ) { + lp->orig_upbo[lp->rows] = 0; + } else { + fprintf(stderr, "Wrong constraint type\n"); + exit(FAIL); + } + + lp->orig_lowbo[lp->rows] = 0; + + if (constr_type == GE && rh != 0) + lp->orig_rh[lp->rows] = -rh; else - { - fprintf(stderr, "Wrong constraint type\n"); - exit(FAIL); - } + lp->orig_rh[lp->rows] = rh; - lp->orig_lowbo[lp->rows]=0; + lp->row_end_valid = FALSE; - if(constr_type==GE && rh != 0) - lp->orig_rh[lp->rows]=-rh; - else - lp->orig_rh[lp->rows]=rh; + lp->bas[lp->rows] = lp->rows; + lp->basis[lp->rows] = TRUE; + lp->lower[lp->rows] = TRUE; - lp->row_end_valid=FALSE; - - lp->bas[lp->rows]=lp->rows; - lp->basis[lp->rows]=TRUE; - lp->lower[lp->rows]=TRUE; - - if(lp->active) - set_globals(lp); - lp->eta_valid=FALSE; + if (lp->active) set_globals(lp); + lp->eta_valid = FALSE; } -void str_add_constraint(lprec *lp, - char *row_string, - short constr_type, - REAL rh) -{ - int i; +void str_add_constraint(lprec *lp, char *row_string, short constr_type, REAL rh) { + int i; REAL *aRow; char *p, *newp; CALLOC(aRow, lp->columns + 1, REAL); p = row_string; - - for(i = 1; i <= lp->columns; i++) - { - aRow[i] = (REAL) strtod(p, &newp); - if(p==newp) - error("Bad string in str_add_constr"); - else - p=newp; - } + + for (i = 1; i <= lp->columns; i++) { + aRow[i] = (REAL)strtod(p, &newp); + if (p == newp) + error("Bad string in str_add_constr"); + else + p = newp; + } add_constraint(lp, aRow, constr_type, rh); free(aRow); } -void del_constraint(lprec *lp, int del_row) -{ +void del_constraint(lprec *lp, int del_row) { int i, j; unsigned elmnr; int startcol; int row_nr; - if(del_row<1 || del_row>lp->rows) - { - fprintf(stderr, "There is no constraint nr. %d\n", del_row); - exit(FAIL); - } + if (del_row < 1 || del_row > lp->rows) { + fprintf(stderr, "There is no constraint nr. %d\n", del_row); + exit(FAIL); + } - elmnr=0; - startcol=0; + elmnr = 0; + startcol = 0; - for(i = 1; i <= lp->columns; i++) - { - for(j=startcol; j < lp->col_end[i]; j++) - { - if(lp->mat[j].row_nr!=del_row) - { - lp->mat[elmnr]=lp->mat[j]; - if(lp->mat[elmnr].row_nr > del_row) - lp->mat[elmnr].row_nr--; - elmnr++; - } - else - lp->non_zeros--; - } - startcol=lp->col_end[i]; - lp->col_end[i]=elmnr; + for (i = 1; i <= lp->columns; i++) { + for (j = startcol; j < lp->col_end[i]; j++) { + if (lp->mat[j].row_nr != del_row) { + lp->mat[elmnr] = lp->mat[j]; + if (lp->mat[elmnr].row_nr > del_row) lp->mat[elmnr].row_nr--; + elmnr++; + } else + lp->non_zeros--; } - for(i = del_row; i < lp->rows; i++) - { - lp->orig_rh[i] = lp->orig_rh[i+1]; - lp->ch_sign[i] = lp->ch_sign[i+1]; - lp->bas[i] = lp->bas[i+1]; - if(lp->names_used) - strcpy(lp->row_name[i], lp->row_name[i+1]); - } - for(i = 1; i < lp->rows; i++) - if(lp->bas[i] > del_row) - lp->bas[i]--; + startcol = lp->col_end[i]; + lp->col_end[i] = elmnr; + } + for (i = del_row; i < lp->rows; i++) { + lp->orig_rh[i] = lp->orig_rh[i + 1]; + lp->ch_sign[i] = lp->ch_sign[i + 1]; + lp->bas[i] = lp->bas[i + 1]; + if (lp->names_used) strcpy(lp->row_name[i], lp->row_name[i + 1]); + } + for (i = 1; i < lp->rows; i++) + if (lp->bas[i] > del_row) lp->bas[i]--; - for(i=del_row; i < lp->sum; i++) - { - lp->lower[i]=lp->lower[i+1]; - lp->basis[i]=lp->basis[i+1]; - lp->orig_upbo[i]=lp->orig_upbo[i+1]; - lp->orig_lowbo[i]=lp->orig_lowbo[i+1]; - lp->must_be_int[i]=lp->must_be_int[i+1]; - if(lp->scaling_used) - lp->scale[i]=lp->scale[i+1]; - } + for (i = del_row; i < lp->sum; i++) { + lp->lower[i] = lp->lower[i + 1]; + lp->basis[i] = lp->basis[i + 1]; + lp->orig_upbo[i] = lp->orig_upbo[i + 1]; + lp->orig_lowbo[i] = lp->orig_lowbo[i + 1]; + lp->must_be_int[i] = lp->must_be_int[i + 1]; + if (lp->scaling_used) lp->scale[i] = lp->scale[i + 1]; + } lp->rows--; lp->sum--; - lp->row_end_valid=FALSE; - - if(lp->active) - set_globals(lp); - lp->eta_valid=FALSE; - lp->basis_valid=FALSE; + lp->row_end_valid = FALSE; + + if (lp->active) set_globals(lp); + lp->eta_valid = FALSE; + lp->basis_valid = FALSE; } -void add_lag_con(lprec *lp, REAL *row, short con_type, REAL rhs) -{ +void add_lag_con(lprec *lp, REAL *row, short con_type, REAL rhs) { int i; REAL sign; - if(con_type == LE || con_type == EQ) - sign=1; - else if(con_type == GE) - sign=-1; + if (con_type == LE || con_type == EQ) + sign = 1; + else if (con_type == GE) + sign = -1; else error("con_type not implemented\n"); lp->nr_lagrange++; - if(lp->nr_lagrange==1) - { - CALLOC(lp->lag_row, lp->nr_lagrange, REAL*); - CALLOC(lp->lag_rhs, lp->nr_lagrange, REAL); - CALLOC(lp->lambda, lp->nr_lagrange, REAL); - CALLOC(lp->lag_con_type, lp->nr_lagrange, short); - } - else - { - REALLOC(lp->lag_row, lp->nr_lagrange, REAL*); - REALLOC(lp->lag_rhs, lp->nr_lagrange, REAL); - REALLOC(lp->lambda, lp->nr_lagrange, REAL); - REALLOC(lp->lag_con_type, lp->nr_lagrange, short); - } - CALLOC(lp->lag_row[lp->nr_lagrange-1], lp->columns+1, REAL); - lp->lag_rhs[lp->nr_lagrange-1]=rhs * sign; - for( i=1; i <= lp->columns; i++) - lp->lag_row[lp->nr_lagrange-1][i]=row[i] * sign; - lp->lambda[lp->nr_lagrange-1]=0; - lp->lag_con_type[lp->nr_lagrange-1]=(con_type == EQ); + if (lp->nr_lagrange == 1) { + CALLOC(lp->lag_row, lp->nr_lagrange, REAL *); + CALLOC(lp->lag_rhs, lp->nr_lagrange, REAL); + CALLOC(lp->lambda, lp->nr_lagrange, REAL); + CALLOC(lp->lag_con_type, lp->nr_lagrange, short); + } else { + REALLOC(lp->lag_row, lp->nr_lagrange, REAL *); + REALLOC(lp->lag_rhs, lp->nr_lagrange, REAL); + REALLOC(lp->lambda, lp->nr_lagrange, REAL); + REALLOC(lp->lag_con_type, lp->nr_lagrange, short); + } + CALLOC(lp->lag_row[lp->nr_lagrange - 1], lp->columns + 1, REAL); + lp->lag_rhs[lp->nr_lagrange - 1] = rhs * sign; + for (i = 1; i <= lp->columns; i++) lp->lag_row[lp->nr_lagrange - 1][i] = row[i] * sign; + lp->lambda[lp->nr_lagrange - 1] = 0; + lp->lag_con_type[lp->nr_lagrange - 1] = (con_type == EQ); } -void str_add_lag_con(lprec *lp, char *row, short con_type, REAL rhs) -{ - int i; +void str_add_lag_con(lprec *lp, char *row, short con_type, REAL rhs) { + int i; REAL *a_row; char *p, *new_p; CALLOC(a_row, lp->columns + 1, REAL); p = row; - - for(i = 1; i <= lp->columns; i++) - { - a_row[i] = (REAL) strtod(p, &new_p); - if(p==new_p) - error("Bad string in str_add_lag_con"); - else - p=new_p; - } + + for (i = 1; i <= lp->columns; i++) { + a_row[i] = (REAL)strtod(p, &new_p); + if (p == new_p) + error("Bad string in str_add_lag_con"); + else + p = new_p; + } add_lag_con(lp, a_row, con_type, rhs); free(a_row); } - -void add_column(lprec *lp, REAL *column) -{ +void add_column(lprec *lp, REAL *column) { int i, j, elmnr, row_nr, *num, *rownum; lp->columns++; lp->sum++; inc_col_space(lp); - inc_mat_space(lp, lp->rows+1); + inc_mat_space(lp, lp->rows + 1); - if(lp->scaling_used) - { - for(i = 0; i <= lp->rows; i++) - column[i]*=lp->scale[i]; - lp->scale[lp->sum]=1; + if (lp->scaling_used) { + for (i = 0; i <= lp->rows; i++) column[i] *= lp->scale[i]; + lp->scale[lp->sum] = 1; + } + + elmnr = lp->col_end[lp->columns - 1]; + for (i = 0; i <= lp->rows; i++) + if (column[i] != 0) { + lp->mat[elmnr].row_nr = i; + if (lp->ch_sign[i]) + lp->mat[elmnr].value = -column[i]; + else + lp->mat[elmnr].value = column[i]; + lp->non_zeros++; + elmnr++; } + lp->col_end[lp->columns] = elmnr; + lp->orig_lowbo[lp->sum] = 0; + lp->orig_upbo[lp->sum] = lp->infinite; + lp->lower[lp->sum] = TRUE; + lp->basis[lp->sum] = FALSE; + lp->must_be_int[lp->sum] = FALSE; + if (lp->names_used) sprintf(lp->col_name[lp->columns], "var_%d", lp->columns); - elmnr=lp->col_end[lp->columns-1]; - for(i = 0 ; i <= lp->rows ; i++) - if(column[i] != 0) - { - lp->mat[elmnr].row_nr=i; - if(lp->ch_sign[i]) - lp->mat[elmnr].value=-column[i]; - else - lp->mat[elmnr].value=column[i]; - lp->non_zeros++; - elmnr++; - } - lp->col_end[lp->columns]=elmnr; - lp->orig_lowbo[lp->sum]=0; - lp->orig_upbo[lp->sum]=lp->infinite; - lp->lower[lp->sum]=TRUE; - lp->basis[lp->sum]=FALSE; - lp->must_be_int[lp->sum]=FALSE; - if(lp->names_used) - sprintf(lp->col_name[lp->columns], "var_%d", lp->columns); + lp->row_end_valid = FALSE; - - lp->row_end_valid=FALSE; - - if(lp->active) - { - Sum=lp->sum; - Columns=lp->columns; - Non_zeros=lp->non_zeros; - } + if (lp->active) { + Sum = lp->sum; + Columns = lp->columns; + Non_zeros = lp->non_zeros; + } } -void str_add_column(lprec *lp, char *col_string) -{ - int i; +void str_add_column(lprec *lp, char *col_string) { + int i; REAL *aCol; char *p, *newp; CALLOC(aCol, lp->rows + 1, REAL); p = col_string; - - for(i = 0; i <= lp->rows; i++) - { - aCol[i] = (REAL) strtod(p, &newp); - if(p==newp) - error("Bad string in str_add_column"); - else - p=newp; - } + + for (i = 0; i <= lp->rows; i++) { + aCol[i] = (REAL)strtod(p, &newp); + if (p == newp) + error("Bad string in str_add_column"); + else + p = newp; + } add_column(lp, aCol); free(aCol); } -void del_column(lprec *lp, int column) -{ +void del_column(lprec *lp, int column) { int i, j, from_elm, to_elm, elm_in_col; - if(column > lp->columns || column < 1) - error("Column out of range in del_column"); - for(i = 1; i <= lp->rows; i++) - { - if(lp->bas[i]==lp->rows+column) - lp->basis_valid=FALSE; - else if(lp->bas[i] > lp->rows+column) - lp->bas[i]--; - } - for(i = lp->rows+column; i < lp->sum; i++) - { - if(lp->names_used) - strcpy(lp->col_name[i-lp->rows], lp->col_name[i-lp->rows+1]); - lp->must_be_int[i]=lp->must_be_int[i+1]; - lp->orig_upbo[i]=lp->orig_upbo[i+1]; - lp->orig_lowbo[i]=lp->orig_lowbo[i+1]; - lp->upbo[i]=lp->upbo[i+1]; - lp->lowbo[i]=lp->lowbo[i+1]; - lp->basis[i]=lp->basis[i+1]; - lp->lower[i]=lp->lower[i+1]; - if(lp->scaling_used) - lp->scale[i]=lp->scale[i+1]; - } - for(i = 0; i < lp->nr_lagrange; i++) - for(j = column; j <= lp->columns; j++) - lp->lag_row[i][j]=lp->lag_row[i][j+1]; - to_elm=lp->col_end[column-1]; - from_elm=lp->col_end[column]; - elm_in_col=from_elm-to_elm; - for(i = from_elm; i < lp->non_zeros; i++) - { - lp->mat[to_elm]=lp->mat[i]; - to_elm++; - } - for(i = column; i < lp->columns; i++) - lp->col_end[i]=lp->col_end[i+1]-elm_in_col; + if (column > lp->columns || column < 1) error("Column out of range in del_column"); + for (i = 1; i <= lp->rows; i++) { + if (lp->bas[i] == lp->rows + column) + lp->basis_valid = FALSE; + else if (lp->bas[i] > lp->rows + column) + lp->bas[i]--; + } + for (i = lp->rows + column; i < lp->sum; i++) { + if (lp->names_used) strcpy(lp->col_name[i - lp->rows], lp->col_name[i - lp->rows + 1]); + lp->must_be_int[i] = lp->must_be_int[i + 1]; + lp->orig_upbo[i] = lp->orig_upbo[i + 1]; + lp->orig_lowbo[i] = lp->orig_lowbo[i + 1]; + lp->upbo[i] = lp->upbo[i + 1]; + lp->lowbo[i] = lp->lowbo[i + 1]; + lp->basis[i] = lp->basis[i + 1]; + lp->lower[i] = lp->lower[i + 1]; + if (lp->scaling_used) lp->scale[i] = lp->scale[i + 1]; + } + for (i = 0; i < lp->nr_lagrange; i++) + for (j = column; j <= lp->columns; j++) lp->lag_row[i][j] = lp->lag_row[i][j + 1]; + to_elm = lp->col_end[column - 1]; + from_elm = lp->col_end[column]; + elm_in_col = from_elm - to_elm; + for (i = from_elm; i < lp->non_zeros; i++) { + lp->mat[to_elm] = lp->mat[i]; + to_elm++; + } + for (i = column; i < lp->columns; i++) lp->col_end[i] = lp->col_end[i + 1] - elm_in_col; lp->non_zeros -= elm_in_col; - lp->row_end_valid=FALSE; - lp->eta_valid=FALSE; + lp->row_end_valid = FALSE; + lp->eta_valid = FALSE; lp->sum--; lp->columns--; - if(lp->active) - set_globals(lp); + if (lp->active) set_globals(lp); } -void set_upbo(lprec *lp, int column, REAL value) -{ - if(column > lp->columns || column < 1) - error("Column out of range"); - if(lp->scaling_used) - value /= lp->scale[lp->rows + column]; - if(value < lp->orig_lowbo[lp->rows + column]) - error("Upperbound must be >= lowerbound"); +void set_upbo(lprec *lp, int column, REAL value) { + if (column > lp->columns || column < 1) error("Column out of range"); + if (lp->scaling_used) value /= lp->scale[lp->rows + column]; + if (value < lp->orig_lowbo[lp->rows + column]) error("Upperbound must be >= lowerbound"); lp->eta_valid = FALSE; - lp->orig_upbo[lp->rows+column] = value; + lp->orig_upbo[lp->rows + column] = value; } -void set_lowbo(lprec *lp, int column, REAL value) -{ - if(column > lp->columns || column < 1) - error("Column out of range"); - if(lp->scaling_used) - value /= lp->scale[lp->rows + column]; - if(value > lp->orig_upbo[lp->rows + column]) - error("Upperbound must be >= lowerbound"); +void set_lowbo(lprec *lp, int column, REAL value) { + if (column > lp->columns || column < 1) error("Column out of range"); + if (lp->scaling_used) value /= lp->scale[lp->rows + column]; + if (value > lp->orig_upbo[lp->rows + column]) error("Upperbound must be >= lowerbound"); lp->eta_valid = FALSE; - lp->orig_lowbo[lp->rows+column] = value; + lp->orig_lowbo[lp->rows + column] = value; } -void set_int(lprec *lp, int column, short must_be_int) -{ - if(column > lp->columns || column < 1) - error("Column out of range"); - lp->must_be_int[lp->rows+column]=must_be_int; - if(must_be_int==TRUE) - if(lp->columns_scaled) - unscale_columns(lp); +void set_int(lprec *lp, int column, short must_be_int) { + if (column > lp->columns || column < 1) error("Column out of range"); + lp->must_be_int[lp->rows + column] = must_be_int; + if (must_be_int == TRUE) + if (lp->columns_scaled) unscale_columns(lp); } -void set_rh(lprec *lp, int row, REAL value) -{ - if(row > lp->rows || row < 0) - error("Row out of Range"); - if(row == 0) /* setting of RHS of OF not meaningful */ - { - fprintf(stderr, - "Warning: attempt to set RHS of objective function, ignored\n"); - return; - } - if(lp->scaling_used) - if(lp->ch_sign[row]) +void set_rh(lprec *lp, int row, REAL value) { + if (row > lp->rows || row < 0) error("Row out of Range"); + if (row == 0) /* setting of RHS of OF not meaningful */ + { + fprintf(stderr, "Warning: attempt to set RHS of objective function, ignored\n"); + return; + } + if (lp->scaling_used) + if (lp->ch_sign[row]) lp->orig_rh[row] = -value * lp->scale[row]; else lp->orig_rh[row] = value * lp->scale[row]; + else if (lp->ch_sign[row]) + lp->orig_rh[row] = -value; else - if(lp->ch_sign[row]) - lp->orig_rh[row] = -value; - else - lp->orig_rh[row] = value; + lp->orig_rh[row] = value; lp->eta_valid = FALSE; -} - -void set_rh_vec(lprec *lp, REAL *rh) -{ - int i; - if(lp->scaling_used) - for(i = 1; i <= lp->rows; i++) - if(lp->ch_sign[i]) - lp->orig_rh[i]=-rh[i]*lp->scale[i]; - else - lp->orig_rh[i]=rh[i]*lp->scale[i]; - else - for(i=1; i <= lp->rows; i++) - if(lp->ch_sign[i]) - lp->orig_rh[i]=-rh[i]; - else - lp->orig_rh[i]=rh[i]; - lp->eta_valid=FALSE; } -void str_set_rh_vec(lprec *lp, char *rh_string) -{ - int i; +void set_rh_vec(lprec *lp, REAL *rh) { + int i; + if (lp->scaling_used) + for (i = 1; i <= lp->rows; i++) + if (lp->ch_sign[i]) + lp->orig_rh[i] = -rh[i] * lp->scale[i]; + else + lp->orig_rh[i] = rh[i] * lp->scale[i]; + else + for (i = 1; i <= lp->rows; i++) + if (lp->ch_sign[i]) + lp->orig_rh[i] = -rh[i]; + else + lp->orig_rh[i] = rh[i]; + lp->eta_valid = FALSE; +} + +void str_set_rh_vec(lprec *lp, char *rh_string) { + int i; REAL *newrh; char *p, *newp; CALLOC(newrh, lp->rows + 1, REAL); p = rh_string; - - for(i = 1; i <= lp->rows; i++) - { - newrh[i] = (REAL) strtod(p, &newp); - if(p==newp) - error("Bad string in str_set_rh_vec"); - else - p=newp; - } + + for (i = 1; i <= lp->rows; i++) { + newrh[i] = (REAL)strtod(p, &newp); + if (p == newp) + error("Bad string in str_set_rh_vec"); + else + p = newp; + } set_rh_vec(lp, newrh); free(newrh); } - -void set_maxim(lprec *lp) -{ +void set_maxim(lprec *lp) { int i; - if(lp->maximise==FALSE) - { - for(i = 0; i < lp->non_zeros; i++) - if(lp->mat[i].row_nr==0) - lp->mat[i].value*=-1; - lp->eta_valid=FALSE; - } - lp->maximise=TRUE; - lp->ch_sign[0]=TRUE; - if(lp->active) - Maximise=TRUE; + if (lp->maximise == FALSE) { + for (i = 0; i < lp->non_zeros; i++) + if (lp->mat[i].row_nr == 0) lp->mat[i].value *= -1; + lp->eta_valid = FALSE; + } + lp->maximise = TRUE; + lp->ch_sign[0] = TRUE; + if (lp->active) Maximise = TRUE; } -void set_minim(lprec *lp) -{ +void set_minim(lprec *lp) { int i; - if(lp->maximise==TRUE) - { - for(i = 0; i < lp->non_zeros; i++) - if(lp->mat[i].row_nr==0) - lp->mat[i].value = -lp->mat[i].value; - lp->eta_valid=FALSE; - } - lp->maximise=FALSE; - lp->ch_sign[0]=FALSE; - if(lp->active) - Maximise=FALSE; + if (lp->maximise == TRUE) { + for (i = 0; i < lp->non_zeros; i++) + if (lp->mat[i].row_nr == 0) lp->mat[i].value = -lp->mat[i].value; + lp->eta_valid = FALSE; + } + lp->maximise = FALSE; + lp->ch_sign[0] = FALSE; + if (lp->active) Maximise = FALSE; } -void set_constr_type(lprec *lp, int row, short con_type) -{ +void set_constr_type(lprec *lp, int row, short con_type) { int i; - if(row > lp->rows || row < 1) - error("Row out of Range"); - if(con_type==EQ) - { - lp->orig_upbo[row]=0; - lp->basis_valid=FALSE; - if(lp->ch_sign[row]) - { - for(i = 0; i < lp->non_zeros; i++) - if(lp->mat[i].row_nr==row) - lp->mat[i].value*=-1; - lp->eta_valid=FALSE; - lp->ch_sign[row]=FALSE; - if(lp->orig_rh[row]!=0) - lp->orig_rh[row]*=-1; - } + if (row > lp->rows || row < 1) error("Row out of Range"); + if (con_type == EQ) { + lp->orig_upbo[row] = 0; + lp->basis_valid = FALSE; + if (lp->ch_sign[row]) { + for (i = 0; i < lp->non_zeros; i++) + if (lp->mat[i].row_nr == row) lp->mat[i].value *= -1; + lp->eta_valid = FALSE; + lp->ch_sign[row] = FALSE; + if (lp->orig_rh[row] != 0) lp->orig_rh[row] *= -1; } - else if(con_type==LE) - { - lp->orig_upbo[row]=lp->infinite; - lp->basis_valid=FALSE; - if(lp->ch_sign[row]) - { - for(i = 0; i < lp->non_zeros; i++) - if(lp->mat[i].row_nr==row) - lp->mat[i].value*=-1; - lp->eta_valid=FALSE; - lp->ch_sign[row]=FALSE; - if(lp->orig_rh[row]!=0) - lp->orig_rh[row]*=-1; - } + } else if (con_type == LE) { + lp->orig_upbo[row] = lp->infinite; + lp->basis_valid = FALSE; + if (lp->ch_sign[row]) { + for (i = 0; i < lp->non_zeros; i++) + if (lp->mat[i].row_nr == row) lp->mat[i].value *= -1; + lp->eta_valid = FALSE; + lp->ch_sign[row] = FALSE; + if (lp->orig_rh[row] != 0) lp->orig_rh[row] *= -1; } - else if(con_type==GE) - { - lp->orig_upbo[row]=lp->infinite; - lp->basis_valid=FALSE; - if(!lp->ch_sign[row]) - { - for(i = 0; i < lp->non_zeros; i++) - if(lp->mat[i].row_nr==row) - lp->mat[i].value*=-1; - lp->eta_valid=FALSE; - lp->ch_sign[row]=TRUE; - if(lp->orig_rh[row]!=0) - lp->orig_rh[row]*=-1; - } - } - else + } else if (con_type == GE) { + lp->orig_upbo[row] = lp->infinite; + lp->basis_valid = FALSE; + if (!lp->ch_sign[row]) { + for (i = 0; i < lp->non_zeros; i++) + if (lp->mat[i].row_nr == row) lp->mat[i].value *= -1; + lp->eta_valid = FALSE; + lp->ch_sign[row] = TRUE; + if (lp->orig_rh[row] != 0) lp->orig_rh[row] *= -1; + } + } else error("Constraint type not (yet) implemented"); } -REAL mat_elm(lprec *lp, int row, int column) -{ +REAL mat_elm(lprec *lp, int row, int column) { REAL value; int elmnr; - if(row < 0 || row > lp->rows) - error("Row out of range in mat_elm"); - if(column < 1 || column > lp->columns) - error("Column out of range in mat_elm"); - value=0; - elmnr=lp->col_end[column-1]; - while(lp->mat[elmnr].row_nr != row && elmnr < lp->col_end[column]) - elmnr++; - if(elmnr != lp->col_end[column]) - { - value = lp->mat[elmnr].value; - if(lp->ch_sign[row]) - value = -value; - if(lp->scaling_used) - value /= lp->scale[row] * lp->scale[lp->rows + column]; - } - return(value); + if (row < 0 || row > lp->rows) error("Row out of range in mat_elm"); + if (column < 1 || column > lp->columns) error("Column out of range in mat_elm"); + value = 0; + elmnr = lp->col_end[column - 1]; + while (lp->mat[elmnr].row_nr != row && elmnr < lp->col_end[column]) elmnr++; + if (elmnr != lp->col_end[column]) { + value = lp->mat[elmnr].value; + if (lp->ch_sign[row]) value = -value; + if (lp->scaling_used) value /= lp->scale[row] * lp->scale[lp->rows + column]; + } + return (value); } - -void get_row(lprec *lp, int row_nr, REAL *row) -{ +void get_row(lprec *lp, int row_nr, REAL *row) { int i, j; REAL RowMult; - if(row_nr <0 || row_nr > lp->rows) - error("Row nr. out of range in get_row"); - for(i = 1; i <= lp->columns; i++) - { - row[i]=0; - for(j=lp->col_end[i-1]; j < lp->col_end[i]; j++) - if(lp->mat[j].row_nr==row_nr) - row[i]=lp->mat[j].value; - if(lp->scaling_used) - row[i] /= lp->scale[lp->rows+i] * lp->scale[row_nr]; - } - if(lp->ch_sign[row_nr]) - for(i=0; i <= lp->columns; i++) - if(row[i]!=0) - row[i] = -row[i]; + if (row_nr < 0 || row_nr > lp->rows) error("Row nr. out of range in get_row"); + for (i = 1; i <= lp->columns; i++) { + row[i] = 0; + for (j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) + if (lp->mat[j].row_nr == row_nr) row[i] = lp->mat[j].value; + if (lp->scaling_used) row[i] /= lp->scale[lp->rows + i] * lp->scale[row_nr]; + } + if (lp->ch_sign[row_nr]) + for (i = 0; i <= lp->columns; i++) + if (row[i] != 0) row[i] = -row[i]; } -void get_column(lprec *lp, int col_nr, REAL *column) -{ +void get_column(lprec *lp, int col_nr, REAL *column) { int i; - if(col_nr < 1 || col_nr > lp->columns) - error("Col. nr. out of range in get_column"); - for(i = 0; i <= lp->rows; i++) - column[i]=0; - for(i = lp->col_end[col_nr-1]; i < lp->col_end[col_nr]; i++) - column[lp->mat[i].row_nr]=lp->mat[i].value; - for(i = 0; i <= lp->rows; i++) - if(column[i] !=0) - { - if(lp->ch_sign[i]) - column[i]*=-1; - if(lp->scaling_used) - column[i]/=(lp->scale[i] * lp->scale[lp->rows+col_nr]); - } + if (col_nr < 1 || col_nr > lp->columns) error("Col. nr. out of range in get_column"); + for (i = 0; i <= lp->rows; i++) column[i] = 0; + for (i = lp->col_end[col_nr - 1]; i < lp->col_end[col_nr]; i++) + column[lp->mat[i].row_nr] = lp->mat[i].value; + for (i = 0; i <= lp->rows; i++) + if (column[i] != 0) { + if (lp->ch_sign[i]) column[i] *= -1; + if (lp->scaling_used) column[i] /= (lp->scale[i] * lp->scale[lp->rows + col_nr]); + } } -void get_reduced_costs(lprec *lp, REAL *rc) -{ +void get_reduced_costs(lprec *lp, REAL *rc) { int varnr, i, j; REAL f; - if(!lp->basis_valid) - error("Not a valid basis in get_reduced_costs"); + if (!lp->basis_valid) error("Not a valid basis in get_reduced_costs"); set_globals(lp); - if(!lp->eta_valid) - invert(); - for(i = 1; i <= lp->sum; i++) - rc[i] = 0; + if (!lp->eta_valid) invert(); + for (i = 1; i <= lp->sum; i++) rc[i] = 0; rc[0] = 1; btran(rc); - for(i = 1; i <= lp->columns; i++) - { - varnr = lp->rows + i; - if(!Basis[varnr]) - if(Upbo[varnr] > 0) - { - f = 0; - for(j = Col_end[i - 1]; j < Col_end[i]; j++) - f += rc[Mat[j].row_nr] * Mat[j].value; - rc[varnr] = f; - } - } - for(i = 1; i <= Sum; i++) - my_round(rc[i], Epsd); -} + for (i = 1; i <= lp->columns; i++) { + varnr = lp->rows + i; + if (!Basis[varnr]) + if (Upbo[varnr] > 0) { + f = 0; + for (j = Col_end[i - 1]; j < Col_end[i]; j++) f += rc[Mat[j].row_nr] * Mat[j].value; + rc[varnr] = f; + } + } + for (i = 1; i <= Sum; i++) my_round(rc[i], Epsd); +} -short is_feasible(lprec *lp, REAL *values) -{ +short is_feasible(lprec *lp, REAL *values) { int i, elmnr; REAL *this_rhs; REAL dist; - if(lp->scaling_used) - { - for(i = lp->rows+1; i <= lp->sum; i++) - if( values[i - lp->rows] < lp->orig_lowbo[i]*lp->scale[i] - || values[i - lp->rows] > lp->orig_upbo[i]*lp->scale[i]) - return(FALSE); + if (lp->scaling_used) { + for (i = lp->rows + 1; i <= lp->sum; i++) + if (values[i - lp->rows] < lp->orig_lowbo[i] * lp->scale[i] || + values[i - lp->rows] > lp->orig_upbo[i] * lp->scale[i]) + return (FALSE); + } else { + for (i = lp->rows + 1; i <= lp->sum; i++) + if (values[i - lp->rows] < lp->orig_lowbo[i] || values[i - lp->rows] > lp->orig_upbo[i]) + return (FALSE); + } + CALLOC(this_rhs, lp->rows + 1, REAL) + for (i = 1; i <= lp->columns; i++) + for (elmnr = lp->col_end[i - 1]; elmnr < lp->col_end[i]; elmnr++) + this_rhs[lp->mat[elmnr].row_nr] += lp->mat[elmnr].value * values[i]; + for (i = 1; i <= lp->rows; i++) { + dist = lp->orig_rh[i] - this_rhs[i]; + my_round(dist, 0.001) if ((lp->orig_upbo[i] == 0 && dist != 0) || dist < 0) { + free(this_rhs); + return (FALSE); } - else - { - for(i = lp->rows+1; i <= lp->sum; i++) - if( values[i - lp->rows] < lp->orig_lowbo[i] - || values[i - lp->rows] > lp->orig_upbo[i]) - return(FALSE); - } - CALLOC(this_rhs, lp->rows+1, REAL) - for(i = 1; i <= lp->columns; i++) - for(elmnr = lp->col_end[i - 1]; elmnr < lp->col_end[i]; elmnr++) - this_rhs[lp->mat[elmnr].row_nr] += lp->mat[elmnr].value * values[i]; - for(i = 1; i <= lp->rows; i++) - { - dist = lp->orig_rh[i] - this_rhs[i]; - my_round(dist, 0.001) - if((lp->orig_upbo[i] == 0 && dist != 0) || dist < 0) - { - free(this_rhs); - return(FALSE); - } - } + } free(this_rhs); - return(TRUE); + return (TRUE); } -short column_in_lp(lprec *lp, REAL *testcolumn) -{ +short column_in_lp(lprec *lp, REAL *testcolumn) { int i, j; short ident; REAL value; - if(lp->scaling_used) - for(i = 1; i <= lp->columns; i++) - { - ident = TRUE; - j = lp->col_end[i-1]; - while(ident && (j < lp->col_end[i])) - { - value = lp->mat[j].value; - if(lp->ch_sign[lp->mat[j].row_nr]) - value = -value; - value /= lp->scale[lp->rows+i]; - value /= lp->scale[lp->mat[j].row_nr]; - value -= testcolumn[lp->mat[j].row_nr]; - if(my_abs(value) > 0.001) /* should be some epsilon? MB */ - ident=FALSE; - j++; - } - if(ident) - return(TRUE); + if (lp->scaling_used) + for (i = 1; i <= lp->columns; i++) { + ident = TRUE; + j = lp->col_end[i - 1]; + while (ident && (j < lp->col_end[i])) { + value = lp->mat[j].value; + if (lp->ch_sign[lp->mat[j].row_nr]) value = -value; + value /= lp->scale[lp->rows + i]; + value /= lp->scale[lp->mat[j].row_nr]; + value -= testcolumn[lp->mat[j].row_nr]; + if (my_abs(value) > 0.001) /* should be some epsilon? MB */ + ident = FALSE; + j++; } + if (ident) return (TRUE); + } else - for(i = 1; i <= lp->columns; i++) - { - ident = TRUE; - j = lp->col_end[i-1]; - while(ident && j < lp->col_end[i]) - { - value = lp->mat[j].value; - if(lp->ch_sign[lp->mat[j].row_nr]) - value *= -1; - value -= testcolumn[lp->mat[j].row_nr]; - if( my_abs(value) > 0.001 ) - ident=FALSE; - j++; - } - if(ident) - return(TRUE); + for (i = 1; i <= lp->columns; i++) { + ident = TRUE; + j = lp->col_end[i - 1]; + while (ident && j < lp->col_end[i]) { + value = lp->mat[j].value; + if (lp->ch_sign[lp->mat[j].row_nr]) value *= -1; + value -= testcolumn[lp->mat[j].row_nr]; + if (my_abs(value) > 0.001) ident = FALSE; + j++; } - return(FALSE); + if (ident) return (TRUE); + } + return (FALSE); } - -void print_lp(lprec *lp) -{ +void print_lp(lprec *lp) { int i, j; REAL *fatmat; CALLOC(fatmat, (lp->rows + 1) * lp->columns, REAL); - for(i = 1; i <= lp->columns; i++) - for(j = lp->col_end[i-1]; j < lp->col_end[i]; j++) - fatmat[(i - 1) * (lp->rows + 1) + lp->mat[j].row_nr]=lp->mat[j].value; + for (i = 1; i <= lp->columns; i++) + for (j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) + fatmat[(i - 1) * (lp->rows + 1) + lp->mat[j].row_nr] = lp->mat[j].value; printf("problem name: %s\n", lp->lp_name); printf(" "); - for(j = 1; j <= lp->columns; j++) - if(lp->names_used) + for (j = 1; j <= lp->columns; j++) + if (lp->names_used) printf("%8s ", lp->col_name[j]); else printf("Var[%3d] ", j); - if(lp->maximise) - { - printf("\nMaximise "); - for(j = 0; j < lp->columns; j++) - printf("% 8.2f ",-fatmat[j*(lp->rows+1)]); - } - else - { - printf("\nMinimize "); - for(j = 0; j < lp->columns; j++) - printf("% 8.2f ", fatmat[j*(lp->rows+1)]); - } + if (lp->maximise) { + printf("\nMaximise "); + for (j = 0; j < lp->columns; j++) printf("% 8.2f ", -fatmat[j * (lp->rows + 1)]); + } else { + printf("\nMinimize "); + for (j = 0; j < lp->columns; j++) printf("% 8.2f ", fatmat[j * (lp->rows + 1)]); + } printf("\n"); - for(i = 1; i <= lp->rows; i++) - { - if(lp->names_used) - printf("%9s ", lp->row_name[i]); + for (i = 1; i <= lp->rows; i++) { + if (lp->names_used) + printf("%9s ", lp->row_name[i]); + else + printf("Row[%3d] ", i); + for (j = 0; j < lp->columns; j++) + if (lp->ch_sign[i] && fatmat[j * (lp->rows + 1) + i] != 0) + printf("% 8.2f ", -fatmat[j * (lp->rows + 1) + i]); else - printf("Row[%3d] ", i); - for(j = 0; j < lp->columns; j++) - if(lp->ch_sign[i] && fatmat[j*(lp->rows+1)+i] != 0) - printf("% 8.2f ",-fatmat[j*(lp->rows+1)+i]); - else - printf("% 8.2f ", fatmat[j*(lp->rows+1)+i]); - if(lp->orig_upbo[i]==lp->infinite) - if(lp->ch_sign[i]) - printf(">= "); - else - printf("<= "); + printf("% 8.2f ", fatmat[j * (lp->rows + 1) + i]); + if (lp->orig_upbo[i] == lp->infinite) + if (lp->ch_sign[i]) + printf(">= "); else - printf(" = "); - if(lp->ch_sign[i]) - printf("% 8.2f\n",-lp->orig_rh[i]); - else - printf("% 8.2f\n", lp->orig_rh[i]); - } + printf("<= "); + else + printf(" = "); + if (lp->ch_sign[i]) + printf("% 8.2f\n", -lp->orig_rh[i]); + else + printf("% 8.2f\n", lp->orig_rh[i]); + } printf("Type "); - for(i = 1; i <= lp->columns; i++) - if(lp->must_be_int[lp->rows+i]==TRUE) + for (i = 1; i <= lp->columns; i++) + if (lp->must_be_int[lp->rows + i] == TRUE) printf(" Int "); else printf(" Real "); printf("\nupbo "); - for(i = 1; i <= lp->columns; i++) - if(lp->orig_upbo[lp->rows+i]==lp->infinite) + for (i = 1; i <= lp->columns; i++) + if (lp->orig_upbo[lp->rows + i] == lp->infinite) printf(" Inf "); else - printf("% 8.2f ", lp->orig_upbo[lp->rows+i]); + printf("% 8.2f ", lp->orig_upbo[lp->rows + i]); printf("\nlowbo "); - for(i = 1; i <= lp->columns; i++) - printf("% 8.2f ", lp->orig_lowbo[lp->rows+i]); + for (i = 1; i <= lp->columns; i++) printf("% 8.2f ", lp->orig_lowbo[lp->rows + i]); printf("\n"); - for(i = 0; i < lp->nr_lagrange; i++) - { - printf("lag[%3d] ", i); - for(j = 1; j <= lp->columns; j++) - printf("% 8.2f ", lp->lag_row[i][j]); - if(lp->orig_upbo[i]==lp->infinite) - if(lp->lag_con_type[i] == GE) - printf(">= "); - else if(lp->lag_con_type[i] == LE) - printf("<= "); - else if(lp->lag_con_type[i] == EQ) - printf(" = "); - printf("% 8.2f\n", lp->lag_rhs[i]); - } + for (i = 0; i < lp->nr_lagrange; i++) { + printf("lag[%3d] ", i); + for (j = 1; j <= lp->columns; j++) printf("% 8.2f ", lp->lag_row[i][j]); + if (lp->orig_upbo[i] == lp->infinite) + if (lp->lag_con_type[i] == GE) + printf(">= "); + else if (lp->lag_con_type[i] == LE) + printf("<= "); + else if (lp->lag_con_type[i] == EQ) + printf(" = "); + printf("% 8.2f\n", lp->lag_rhs[i]); + } free(fatmat); -} +} -void set_row_name(lprec *lp, int row, nstring new_name) -{ +void set_row_name(lprec *lp, int row, nstring new_name) { int i; - if(!lp->names_used) - { - CALLOC(lp->row_name, lp->rows_alloc + 1, nstring); - CALLOC(lp->col_name, lp->columns_alloc + 1, nstring); - lp->names_used=TRUE; - for(i = 0; i <= lp->rows; i++) - sprintf(lp->row_name[i], "r_%d", i); - for(i = 1; i <= lp->columns; i++) - sprintf(lp->col_name[i], "var_%d", i); - } + if (!lp->names_used) { + CALLOC(lp->row_name, lp->rows_alloc + 1, nstring); + CALLOC(lp->col_name, lp->columns_alloc + 1, nstring); + lp->names_used = TRUE; + for (i = 0; i <= lp->rows; i++) sprintf(lp->row_name[i], "r_%d", i); + for (i = 1; i <= lp->columns; i++) sprintf(lp->col_name[i], "var_%d", i); + } strcpy(lp->row_name[row], new_name); } -void set_col_name(lprec *lp, int column, nstring new_name) -{ +void set_col_name(lprec *lp, int column, nstring new_name) { int i; - - if(!lp->names_used) - { - CALLOC(lp->row_name, lp->rows_alloc + 1, nstring); - CALLOC(lp->col_name, lp->columns_alloc + 1, nstring); - lp->names_used=TRUE; - for(i = 0; i <= lp->rows; i++) - sprintf(lp->row_name[i], "r_%d", i); - for(i = 1; i <= lp->columns; i++) - sprintf(lp->col_name[i], "var_%d", i); - } + + if (!lp->names_used) { + CALLOC(lp->row_name, lp->rows_alloc + 1, nstring); + CALLOC(lp->col_name, lp->columns_alloc + 1, nstring); + lp->names_used = TRUE; + for (i = 0; i <= lp->rows; i++) sprintf(lp->row_name[i], "r_%d", i); + for (i = 1; i <= lp->columns; i++) sprintf(lp->col_name[i], "var_%d", i); + } strcpy(lp->col_name[column], new_name); } -static REAL minmax_to_scale(REAL min, REAL max) -{ +static REAL minmax_to_scale(REAL min, REAL max) { REAL scale; /* should do something sensible when min or max is 0, MB */ - if((min == 0) || (max == 0)) - return((REAL)1); + if ((min == 0) || (max == 0)) return ((REAL)1); scale = 1 / pow(10, (log10(min) + log10(max)) / 2); - return(scale); + return (scale); } -void unscale_columns(lprec *lp) -{ +void unscale_columns(lprec *lp) { int i, j; /* unscale mat */ - for(j = 1; j <= lp->columns; j++) - for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + for (j = 1; j <= lp->columns; j++) + for (i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) lp->mat[i].value /= lp->scale[lp->rows + j]; /* unscale bounds as well */ - for(i = lp->rows + 1; i < lp->sum; i++) - { - if(lp->orig_lowbo[i] != 0) - lp->orig_lowbo[i] *= lp->scale[i]; - if(lp->orig_upbo[i] != lp->infinite) - lp->orig_upbo[i] *= lp->scale[i]; - } - - for(i=lp->rows+1; i<= lp->sum; i++) - lp->scale[i]=1; - lp->columns_scaled=FALSE; - lp->eta_valid=FALSE; + for (i = lp->rows + 1; i < lp->sum; i++) { + if (lp->orig_lowbo[i] != 0) lp->orig_lowbo[i] *= lp->scale[i]; + if (lp->orig_upbo[i] != lp->infinite) lp->orig_upbo[i] *= lp->scale[i]; + } + + for (i = lp->rows + 1; i <= lp->sum; i++) lp->scale[i] = 1; + lp->columns_scaled = FALSE; + lp->eta_valid = FALSE; } -void unscale(lprec *lp) -{ +void unscale(lprec *lp) { int i, j; - - if(lp->scaling_used) - { - /* unscale mat */ - for(j = 1; j <= lp->columns; j++) - for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) - lp->mat[i].value /= lp->scale[lp->rows + j]; + if (lp->scaling_used) { + /* unscale mat */ + for (j = 1; j <= lp->columns; j++) + for (i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + lp->mat[i].value /= lp->scale[lp->rows + j]; - /* unscale bounds */ - for(i = lp->rows + 1; i < lp->sum; i++) - { - if(lp->orig_lowbo[i] != 0) - lp->orig_lowbo[i] *= lp->scale[i]; - if(lp->orig_upbo[i] != lp->infinite) - lp->orig_upbo[i] *= lp->scale[i]; - } - - /* unscale the matrix */ - for(j = 1; j <= lp->columns; j++) - for(i = lp->col_end[j-1]; i < lp->col_end[j]; i++) - lp->mat[i].value /= lp->scale[lp->mat[i].row_nr]; - - /* unscale the rhs! */ - for(i = 0; i <= lp->rows; i++) - lp->orig_rh[i] /= lp->scale[i]; - - free(lp->scale); - lp->scaling_used=FALSE; - lp->eta_valid=FALSE; + /* unscale bounds */ + for (i = lp->rows + 1; i < lp->sum; i++) { + if (lp->orig_lowbo[i] != 0) lp->orig_lowbo[i] *= lp->scale[i]; + if (lp->orig_upbo[i] != lp->infinite) lp->orig_upbo[i] *= lp->scale[i]; } + + /* unscale the matrix */ + for (j = 1; j <= lp->columns; j++) + for (i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + lp->mat[i].value /= lp->scale[lp->mat[i].row_nr]; + + /* unscale the rhs! */ + for (i = 0; i <= lp->rows; i++) lp->orig_rh[i] /= lp->scale[i]; + + free(lp->scale); + lp->scaling_used = FALSE; + lp->eta_valid = FALSE; + } } - -void auto_scale(lprec *lp) -{ +void auto_scale(lprec *lp) { int i, j, row_nr, IntUsed; REAL *row_max, *row_min, *scalechange, absval; REAL col_max, col_min, col_scale; - if(!lp->scaling_used) - { - MALLOC(lp->scale, lp->sum_alloc + 1, REAL); - for(i=0; i <= lp->sum; i++) - lp->scale[i]=1; - } + if (!lp->scaling_used) { + MALLOC(lp->scale, lp->sum_alloc + 1, REAL); + for (i = 0; i <= lp->sum; i++) lp->scale[i] = 1; + } MALLOC(row_max, lp->rows + 1, REAL); MALLOC(row_min, lp->rows + 1, REAL); MALLOC(scalechange, lp->sum + 1, REAL); /* initialise min and max values */ - for(i = 0; i <= lp->rows; i++) - { - row_max[i]=0; - row_min[i]=lp->infinite; - } + for (i = 0; i <= lp->rows; i++) { + row_max[i] = 0; + row_min[i] = lp->infinite; + } /* calculate min and max absolute values of rows */ - for(j = 1; j <= lp->columns; j++) - { - - for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) - { - row_nr = lp->mat[i].row_nr; - absval = my_abs(lp->mat[i].value); - if(absval!=0) - { - row_max[row_nr] = my_max(row_max[row_nr], absval); - row_min[row_nr] = my_min(row_min[row_nr], absval); - } - } + for (j = 1; j <= lp->columns; j++) { + for (i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) { + row_nr = lp->mat[i].row_nr; + absval = my_abs(lp->mat[i].value); + if (absval != 0) { + row_max[row_nr] = my_max(row_max[row_nr], absval); + row_min[row_nr] = my_min(row_min[row_nr], absval); + } + } } /* calculate scale factors for rows */ - for(i = 0; i <= lp->rows; i++) - { - scalechange[i] = minmax_to_scale(row_min[i], row_max[i]); - lp->scale[i] *= scalechange[i]; - } + for (i = 0; i <= lp->rows; i++) { + scalechange[i] = minmax_to_scale(row_min[i], row_max[i]); + lp->scale[i] *= scalechange[i]; + } /* now actually scale the matrix */ - for(j = 1; j <= lp->columns; j++) - for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + for (j = 1; j <= lp->columns; j++) + for (i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) lp->mat[i].value *= scalechange[lp->mat[i].row_nr]; /* and scale the rhs! */ - for(i = 0; i <= lp->rows; i++) - lp->orig_rh[i] *= scalechange[i]; + for (i = 0; i <= lp->rows; i++) lp->orig_rh[i] *= scalechange[i]; free(row_max); printf("after free r_max. "); free(row_min); printf("after free rmin. "); - - IntUsed=FALSE; - i=lp->rows+1; - while(!IntUsed && i <= lp->sum) - { - IntUsed=lp->must_be_int[i]; - i++; + + IntUsed = FALSE; + i = lp->rows + 1; + while (!IntUsed && i <= lp->sum) { + IntUsed = lp->must_be_int[i]; + i++; + } + if (!IntUsed) { + REAL col_max, col_min, col_scale; + + /* calculate scales */ + for (j = 1; j <= lp->columns; j++) { + col_max = 0; + col_min = lp->infinite; + for (i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) { + if (lp->mat[i].value != 0) { + col_max = my_max(col_max, my_abs(lp->mat[i].value)); + col_min = my_min(col_min, my_abs(lp->mat[i].value)); + } + } + scalechange[lp->rows + j] = minmax_to_scale(col_min, col_max); + lp->scale[lp->rows + j] *= scalechange[lp->rows + j]; } - if(!IntUsed) - { - REAL col_max, col_min, col_scale; - /* calculate scales */ - for(j = 1; j <= lp->columns; j++) - { - col_max = 0; - col_min = lp->infinite; - for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) - { - if(lp->mat[i].value!=0) - { - col_max = my_max(col_max, my_abs(lp->mat[i].value)); - col_min = my_min(col_min, my_abs(lp->mat[i].value)); - } - } - scalechange[lp->rows + j] = minmax_to_scale(col_min, col_max); - lp->scale[lp->rows + j] *= scalechange[lp->rows + j]; - } + /* scale mat */ + for (j = 1; j <= lp->columns; j++) + for (i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) + lp->mat[i].value *= scalechange[lp->rows + j]; - /* scale mat */ - for(j = 1; j <= lp->columns; j++) - for(i = lp->col_end[j - 1]; i < lp->col_end[j]; i++) - lp->mat[i].value *= scalechange[lp->rows + j]; - - /* scale bounds as well */ - for(i = lp->rows + 1; i < lp->sum; i++) - { - if(lp->orig_lowbo[i] != 0) - lp->orig_lowbo[i] /= scalechange[i]; - if(lp->orig_upbo[i] != lp->infinite) - lp->orig_upbo[i] /= scalechange[i]; - } - lp->columns_scaled=TRUE; + /* scale bounds as well */ + for (i = lp->rows + 1; i < lp->sum; i++) { + if (lp->orig_lowbo[i] != 0) lp->orig_lowbo[i] /= scalechange[i]; + if (lp->orig_upbo[i] != lp->infinite) lp->orig_upbo[i] /= scalechange[i]; } + lp->columns_scaled = TRUE; + } printf("b4 free scch. "); free(scalechange); printf("after free scch. "); - lp->scaling_used=TRUE; - lp->eta_valid=FALSE; + lp->scaling_used = TRUE; + lp->eta_valid = FALSE; } -void reset_basis(lprec *lp) -{ - lp->basis_valid=FALSE; -} +void reset_basis(lprec *lp) { lp->basis_valid = FALSE; } -void print_solution(lprec *lp) -{ +void print_solution(lprec *lp) { int i; - fprintf(stdout, "Value of objective function: %16.10g\n", - (double)lp->best_solution[0]); + fprintf(stdout, "Value of objective function: %16.10g\n", (double)lp->best_solution[0]); /* print normal variables */ - for(i = 1; i <= lp->columns; i++) - if(lp->names_used) - fprintf(stdout, "%-10s%16.5g\n", lp->col_name[i], - (double)lp->best_solution[lp->rows+i]); + for (i = 1; i <= lp->columns; i++) + if (lp->names_used) + fprintf(stdout, "%-10s%16.5g\n", lp->col_name[i], (double)lp->best_solution[lp->rows + i]); else - fprintf(stdout, "Var [%4d] %16.5g\n", i, - (double)lp->best_solution[lp->rows+i]); + fprintf(stdout, "Var [%4d] %16.5g\n", i, (double)lp->best_solution[lp->rows + i]); /* print achieved constraint values */ - if(lp->verbose) - { - fprintf(stdout, "\nActual values of the constraints:\n"); - for(i = 1; i <= lp->rows; i++) - if(lp->names_used) - fprintf(stdout, "%-10s%16.5g\n", lp->row_name[i], - (double)lp->best_solution[i]); - else - fprintf(stdout, "%Row [%4d] %16.5g\n", i, - (double)lp->best_solution[i]); - } - - if((lp->verbose || lp->print_duals)) - { - if(lp->max_level != 1) - fprintf(stdout, - "These are the duals from the node that gave the optimal solution.\n"); + if (lp->verbose) { + fprintf(stdout, "\nActual values of the constraints:\n"); + for (i = 1; i <= lp->rows; i++) + if (lp->names_used) + fprintf(stdout, "%-10s%16.5g\n", lp->row_name[i], (double)lp->best_solution[i]); else - fprintf(stdout, "\nDual values:\n"); - for(i = 1; i <= lp->rows; i++) - if(lp->names_used) - fprintf(stdout, "%-10s%16.5g\n", lp->row_name[i], - (double)lp->duals[i]); - else - fprintf(stdout, "Row [%4d] %16.5g\n", i, (double)lp->duals[i]); - } + fprintf(stdout, "%Row [%4d] %16.5g\n", i, (double)lp->best_solution[i]); + } + + if ((lp->verbose || lp->print_duals)) { + if (lp->max_level != 1) + fprintf(stdout, "These are the duals from the node that gave the optimal solution.\n"); + else + fprintf(stdout, "\nDual values:\n"); + for (i = 1; i <= lp->rows; i++) + if (lp->names_used) + fprintf(stdout, "%-10s%16.5g\n", lp->row_name[i], (double)lp->duals[i]); + else + fprintf(stdout, "Row [%4d] %16.5g\n", i, (double)lp->duals[i]); + } } /* Printsolution */ -void write_LP(lprec *lp, FILE *output) -{ +void write_LP(lprec *lp, FILE *output) { int i, j; REAL *row; nstring var_name; - - MALLOC(row, lp->columns+1, REAL); - if(lp->maximise) + + MALLOC(row, lp->columns + 1, REAL); + if (lp->maximise) fprintf(output, "max:"); else fprintf(output, "min:"); get_row(lp, 0, row); - for(i = 1; i <= lp->columns; i++) - if(row[i] != 0) - { - if(row[i] == -1) - fprintf(output, " -"); - else if(row[i] == 1) - fprintf(output, " +"); - else - fprintf(output, " %+g ", row[i]); - if(lp->names_used) - fprintf(output, "%s", lp->col_name[i]); - else - fprintf(output, "x%d", i); - } + for (i = 1; i <= lp->columns; i++) + if (row[i] != 0) { + if (row[i] == -1) + fprintf(output, " -"); + else if (row[i] == 1) + fprintf(output, " +"); + else + fprintf(output, " %+g ", row[i]); + if (lp->names_used) + fprintf(output, "%s", lp->col_name[i]); + else + fprintf(output, "x%d", i); + } fprintf(output, ";\n"); - for(j = 1; j <= lp->rows; j++) - { - if(lp->names_used) - fprintf(output, "%s:", lp->row_name[j]); - get_row(lp, j, row); - for(i = 1; i <= lp->columns; i++) - if(row[i] != 0) - { - if(row[i] == -1) - fprintf(output, " -"); - else if(row[i] == 1) - fprintf(output, " +"); - else - fprintf(output, " %+g ", row[i]); - if(lp->names_used) - fprintf(output, "%s", lp->col_name[i]); - else - fprintf(output, "x%d", i); - } - if(lp->orig_upbo[j] == 0) - fprintf(output, " ="); - else if(lp->ch_sign[j]) - fprintf(output, " >"); + for (j = 1; j <= lp->rows; j++) { + if (lp->names_used) fprintf(output, "%s:", lp->row_name[j]); + get_row(lp, j, row); + for (i = 1; i <= lp->columns; i++) + if (row[i] != 0) { + if (row[i] == -1) + fprintf(output, " -"); + else if (row[i] == 1) + fprintf(output, " +"); + else + fprintf(output, " %+g ", row[i]); + if (lp->names_used) + fprintf(output, "%s", lp->col_name[i]); + else + fprintf(output, "x%d", i); + } + if (lp->orig_upbo[j] == 0) + fprintf(output, " ="); + else if (lp->ch_sign[j]) + fprintf(output, " >"); + else + fprintf(output, " <"); + if (lp->ch_sign[j]) + fprintf(output, " %g;\n", -lp->orig_rh[j]); + else + fprintf(output, " %g;\n", lp->orig_rh[j]); + } + for (i = lp->rows + 1; i <= lp->sum; i++) { + if (lp->orig_lowbo[i] != 0) { + if (lp->names_used) + fprintf(output, "%s > %g;\n", lp->col_name[i - lp->rows], lp->orig_lowbo[i]); else - fprintf(output, " <"); - if(lp->ch_sign[j]) - fprintf(output, " %g;\n",-lp->orig_rh[j]); + fprintf(output, "x%d > %g;\n", i - lp->rows, lp->orig_lowbo[i]); + } + if (lp->orig_upbo[i] != lp->infinite) { + if (lp->names_used) + fprintf(output, "%s < %g;\n", lp->col_name[i - lp->rows], lp->orig_upbo[i]); else - fprintf(output, " %g;\n", lp->orig_rh[j]); - } - for(i = lp->rows+1; i <= lp->sum; i++) - { - if(lp->orig_lowbo[i] != 0) - { - if(lp->names_used) - fprintf(output, "%s > %g;\n", lp->col_name[i - lp->rows], - lp->orig_lowbo[i]); - else - fprintf(output, "x%d > %g;\n", i - lp->rows, - lp->orig_lowbo[i]); - } - if(lp->orig_upbo[i] != lp->infinite) - { - if(lp->names_used) - fprintf(output, "%s < %g;\n", lp->col_name[i - lp->rows], - lp->orig_upbo[i]); - else - fprintf(output, "x%d < %g;\n", i - lp->rows, lp->orig_upbo[i]); - } + fprintf(output, "x%d < %g;\n", i - lp->rows, lp->orig_upbo[i]); } + } - - i=1; - while(!lp->must_be_int[lp->rows+i] && i <= lp->columns) + i = 1; + while (!lp->must_be_int[lp->rows + i] && i <= lp->columns) i++; + if (i <= lp->columns) { + if (lp->names_used) + fprintf(output, "\nint %s", lp->col_name[i]); + else + fprintf(output, "\nint x%d", i); i++; - if(i <= lp->columns) - { - if(lp->names_used) - fprintf(output, "\nint %s", lp->col_name[i]); - else - fprintf(output, "\nint x%d", i); - i++; - for(; i <= lp->columns; i++) - if(lp->must_be_int[lp->rows+i]) - if(lp->names_used) - fprintf(output, ",%s", lp->col_name[i]); - else - fprintf(output, ", x%d", i); - fprintf(output, ";\n"); - } + for (; i <= lp->columns; i++) + if (lp->must_be_int[lp->rows + i]) + if (lp->names_used) + fprintf(output, ",%s", lp->col_name[i]); + else + fprintf(output, ", x%d", i); + fprintf(output, ";\n"); + } free(row); } - - - -void write_MPS(lprec *lp, FILE *output) -{ +void write_MPS(lprec *lp, FILE *output) { int i, j, marker; REAL *column; - - MALLOC(column, lp->rows+1, REAL); - marker=0; + MALLOC(column, lp->rows + 1, REAL); + marker = 0; fprintf(output, "NAME %s\n", lp->lp_name); fprintf(output, "ROWS\n"); - for(i = 0; i <= lp->rows; i++) - { - if(i==0) - fprintf(output, " N "); + for (i = 0; i <= lp->rows; i++) { + if (i == 0) + fprintf(output, " N "); + else if (lp->orig_upbo[i] == lp->infinite) + if (lp->ch_sign[i]) + fprintf(output, " G "); else - if(lp->orig_upbo[i]==lp->infinite) - if(lp->ch_sign[i]) - fprintf(output, " G "); - else - fprintf(output, " L "); - else - fprintf(output, " E "); - if(lp->names_used) - fprintf(output, "%s\n", lp->row_name[i]); - else - fprintf(output, "r_%d\n", i); - } - + fprintf(output, " L "); + else + fprintf(output, " E "); + if (lp->names_used) + fprintf(output, "%s\n", lp->row_name[i]); + else + fprintf(output, "r_%d\n", i); + } + fprintf(output, "COLUMNS\n"); j = 0; - for(i = 1; i <= lp->columns; i++) - { - if((lp->must_be_int[i+lp->rows]) && (marker % 2)==0) - { - fprintf(output, - " MARK%04d 'MARKER' 'INTORG'\n", - marker); - marker++; - } - if((!lp->must_be_int[i+lp->rows]) && (marker % 2)==1) - { - fprintf(output, - " MARK%04d 'MARKER' 'INTEND'\n", - marker); - marker++; - } - get_column(lp, i, column); - j=0; - if(lp->maximise) - { - if(column[j] != 0) - { - if(lp->names_used) - fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], - lp->row_name[j], -column[j]); - else - fprintf(output, " var_%-4d r_%-6d %g\n", i, j, - -column[j]); - } - } - else - { - if(column[j] != 0) - { - if(lp->names_used) - fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], - lp->row_name[j], column[j]); - else - fprintf(output, " var_%-4d r_%-6d %g\n", i, j, - column[j]); - } - } - for(j=1; j <= lp->rows; j++) - if(column[j] != 0) - { - if(lp->names_used) - fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], - lp->row_name[j], column[j]); - else - fprintf(output, " var_%-4d r_%-6d %g\n", i, j, - column[j]); - } - } - if((marker % 2) ==1) - { - fprintf(output, " MARK%04d 'MARKER' 'INTEND'\n", - marker); + for (i = 1; i <= lp->columns; i++) { + if ((lp->must_be_int[i + lp->rows]) && (marker % 2) == 0) { + fprintf(output, " MARK%04d 'MARKER' 'INTORG'\n", marker); marker++; } + if ((!lp->must_be_int[i + lp->rows]) && (marker % 2) == 1) { + fprintf(output, " MARK%04d 'MARKER' 'INTEND'\n", marker); + marker++; + } + get_column(lp, i, column); + j = 0; + if (lp->maximise) { + if (column[j] != 0) { + if (lp->names_used) + fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], lp->row_name[j], -column[j]); + else + fprintf(output, " var_%-4d r_%-6d %g\n", i, j, -column[j]); + } + } else { + if (column[j] != 0) { + if (lp->names_used) + fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], lp->row_name[j], column[j]); + else + fprintf(output, " var_%-4d r_%-6d %g\n", i, j, column[j]); + } + } + for (j = 1; j <= lp->rows; j++) + if (column[j] != 0) { + if (lp->names_used) + fprintf(output, " %-8s %-8s %g\n", lp->col_name[i], lp->row_name[j], column[j]); + else + fprintf(output, " var_%-4d r_%-6d %g\n", i, j, column[j]); + } + } + if ((marker % 2) == 1) { + fprintf(output, " MARK%04d 'MARKER' 'INTEND'\n", marker); + marker++; + } fprintf(output, "RHS\n"); - for(i = 1; i <= lp->rows; i++) - { - if(lp->ch_sign[i]) - { - if(lp->names_used) - fprintf(output, " RHS %-8s %g\n", lp->row_name[i], - (double)-lp->orig_rh[i]); - else - fprintf(output, " RHS r_%-6d %g\n", i, - (double)-lp->orig_rh[i]); - } + for (i = 1; i <= lp->rows; i++) { + if (lp->ch_sign[i]) { + if (lp->names_used) + fprintf(output, " RHS %-8s %g\n", lp->row_name[i], (double)-lp->orig_rh[i]); else - { - if(lp->names_used) - fprintf(output, " RHS %-8s %g\n", lp->row_name[i], - (double)lp->orig_rh[i]); - else - fprintf(output, " RHS r_%-6d %g\n", i, - (double)lp->orig_rh[i]); - } + fprintf(output, " RHS r_%-6d %g\n", i, (double)-lp->orig_rh[i]); + } else { + if (lp->names_used) + fprintf(output, " RHS %-8s %g\n", lp->row_name[i], (double)lp->orig_rh[i]); + else + fprintf(output, " RHS r_%-6d %g\n", i, (double)lp->orig_rh[i]); } - + } + fprintf(output, "BOUNDS\n"); - if(lp->names_used) - for(i = lp->rows + 1; i <= lp->sum; i++) - { - if(lp->orig_upbo[i] < lp->infinite) - fprintf(output, " UP BND %-8s %g\n", - lp->col_name[i- lp->rows], (double)lp->orig_upbo[i]); - if(lp->orig_lowbo[i] != 0) - fprintf(output, " LO BND %-8s %g\n", - lp->col_name[i- lp->rows], (double)lp->orig_lowbo[i]); - } + if (lp->names_used) + for (i = lp->rows + 1; i <= lp->sum; i++) { + if (lp->orig_upbo[i] < lp->infinite) + fprintf(output, " UP BND %-8s %g\n", lp->col_name[i - lp->rows], + (double)lp->orig_upbo[i]); + if (lp->orig_lowbo[i] != 0) + fprintf(output, " LO BND %-8s %g\n", lp->col_name[i - lp->rows], + (double)lp->orig_lowbo[i]); + } else - for(i = lp->rows + 1; i <= lp->sum; i++) - { - if(lp->orig_upbo[i] < lp->infinite) - fprintf(output, " UP BND var_%-4d %g\n", - i - lp->rows, (double)lp->orig_upbo[i]); - if(lp->orig_lowbo[i] != 0) - fprintf(output, " LO BND var_%-4d %g\n", i - lp->rows, - (double)lp->orig_lowbo[i]); - } + for (i = lp->rows + 1; i <= lp->sum; i++) { + if (lp->orig_upbo[i] < lp->infinite) + fprintf(output, " UP BND var_%-4d %g\n", i - lp->rows, (double)lp->orig_upbo[i]); + if (lp->orig_lowbo[i] != 0) + fprintf(output, " LO BND var_%-4d %g\n", i - lp->rows, (double)lp->orig_lowbo[i]); + } fprintf(output, "ENDATA\n"); free(column); } -void print_duals(lprec *lp) -{ +void print_duals(lprec *lp) { int i; - for(i = 1; i <= lp->rows; i++) - if(lp->names_used) - fprintf(stdout, "%10s [%3d] % 10.4f\n", lp->row_name[i], i, - lp->duals[i]); + for (i = 1; i <= lp->rows; i++) + if (lp->names_used) + fprintf(stdout, "%10s [%3d] % 10.4f\n", lp->row_name[i], i, lp->duals[i]); else fprintf(stdout, "Dual [%3d] % 10.4f\n", i, lp->duals[i]); } -void print_scales(lprec *lp) -{ +void print_scales(lprec *lp) { int i; - if(lp->scaling_used) - { - for(i = 0; i <= lp->rows; i++) - fprintf(stdout, "Row[%3d] scaled at % 10.6f\n", i, lp->scale[i]); - for(i = 1; i <= lp->columns; i++) - fprintf(stdout, "Column[%3d] scaled at % 10.6f\n", i, - lp->scale[lp->rows + i]); - } + if (lp->scaling_used) { + for (i = 0; i <= lp->rows; i++) + fprintf(stdout, "Row[%3d] scaled at % 10.6f\n", i, lp->scale[i]); + for (i = 1; i <= lp->columns; i++) + fprintf(stdout, "Column[%3d] scaled at % 10.6f\n", i, lp->scale[lp->rows + i]); + } } diff --git a/src/lplexyy.c b/src/lplexyy.c old mode 100755 new mode 100644 index 6230625..5d0d094 --- a/src/lplexyy.c +++ b/src/lplexyy.c @@ -1,48 +1,62 @@ -/* $Id: lplexyy.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ -static char *id = "$Id: lplexyy.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ Copyright (C) Venue"; - - -/************************************************************************/ -/* */ -/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/* The contents of this file are proprietary information */ -/* belonging to Venue, and are provided to you under license. */ -/* They may not be further distributed or disclosed to third */ -/* parties without the specific permission of Venue. */ -/* */ -/************************************************************************/ - -#include "version.h" - - -#ifndef BIGATOMS -# include "stdio.h" -# define U(x) x -# define NLSTATE yyprevious=YYNEWLINE -# define BEGIN yybgin = yysvec + 1 + -# define INITIAL 0 -# define YYLERR yysvec -# define YYSTATE (yyestate-yysvec-1) -# define YYOPTIM 1 -# define YYLMAX 200 -# define output(c) putc(c,yyout) -# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) -# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} -# define yymore() (yymorfg=1) -# define ECHO fprintf(yyout, "%s",yytext) -# define REJECT { nstr = yyreject(); goto yyfussy;} -int yyleng; extern char yytext[]; +/* $Id: lplexyy.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ +static char *id = "$Id: lplexyy.c,v 1.2 1999/01/03 02:07:18 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + +#ifndef BIGATOMS +#include "stdio.h" +#define U(x) x +#define NLSTATE yyprevious = YYNEWLINE +#define BEGIN yybgin = yysvec + 1 + +#define INITIAL 0 +#define YYLERR yysvec +#define YYSTATE (yyestate - yysvec - 1) +#define YYOPTIM 1 +#define YYLMAX 200 +#define output(c) putc(c, yyout) +#define input() \ + (((yytchar = yysptr > yysbuf ? U(*--yysptr) : getc(yyin)) == 10 ? (yylineno++, yytchar) \ + : yytchar) == EOF \ + ? 0 \ + : yytchar) +#define unput(c) \ + { \ + yytchar = (c); \ + if (yytchar == '\n') yylineno--; \ + *yysptr++ = yytchar; \ + } +#define yymore() (yymorfg = 1) +#define ECHO fprintf(yyout, "%s", yytext) +#define REJECT \ + { \ + nstr = yyreject(); \ + goto yyfussy; \ + } +int yyleng; +extern char yytext[]; int yymorfg; extern char *yysptr, yysbuf[]; int yytchar; FILE *yyin = {stdin}, *yyout = {stdout}; extern int yylineno; -struct yysvf { - struct yywork *yystoff; - struct yysvf *yyother; - int *yystops;}; +struct yysvf { + struct yywork *yystoff; + struct yysvf *yyother; + int *yystops; +}; struct yysvf *yyestate; extern struct yysvf yysvec[], *yybgin; extern int yylook(); @@ -57,822 +71,589 @@ extern int yyless(int); #ifdef __cplusplus } #endif -# define COMMENT 2 -# define YYNEWLINE 10 -yylex(){ -int nstr; extern int yyprevious; -while((nstr = yylook()) >= 0) -yyfussy: switch(nstr){ -case 0: -if(yywrap()) return(0); break; -case 1: -{ - BEGIN COMMENT; +#define COMMENT 2 +#define YYNEWLINE 10 +yylex() { + int nstr; + extern int yyprevious; + while ((nstr = yylook()) >= 0) + yyfussy: + switch (nstr) { + case 0: + if (yywrap()) return (0); + break; + case 1: { + BEGIN COMMENT; + } break; + case 2: { + BEGIN INITIAL; + } break; + case 3: { + } break; + case 4: { + } break; + case 5: { + } break; + case 6: { + return (COMMA); + } break; + case 7: { + return (MINIMISE); + } break; + case 8: { + return (MAXIMISE); + } break; + case 9: { + sscanf((char *)yytext, "%lf", &f); + return (CONS); + } break; + case 10: { + Sign = 0; + for (x = 0; x < yyleng; x++) + if (yytext[x] == '-' || yytext[x] == '+') Sign = (Sign == (yytext[x] == '+')); + return (SIGN); + /* Sign is TRUE if the sign-string + represents a '-'. Otherwise Sign + is FALSE */ + } break; + case 11: { + strcpy(Last_var, (char *)yytext); + return (VAR); + } break; + case 12: { + return (COLON); + } break; + case 13: { + return (AR_M_OP); + } break; + case 14: { + return (RE_OP); + } break; + case 15: { + return (END_C); + } break; + case 16: { + fprintf(stderr, "LEX ERROR : %s lineno %d \n", yytext, yylineno); + } break; + case -1: break; + default: fprintf(yyout, "bad switch yylook %d", nstr); + } + return (0); } -break; -case 2: -{ - BEGIN INITIAL; -} -break; -case 3: -{ -} -break; -case 4: -{ -} -break; -case 5: -{ -} -break; -case 6: -{ - return(COMMA); -} -break; -case 7: -{ - return(MINIMISE); -} -break; -case 8: -{ - return(MAXIMISE); -} -break; -case 9: -{ - sscanf((char *)yytext,"%lf",&f); - return(CONS); -} -break; -case 10: -{ - Sign=0; - for(x=0;xyystoff; - if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ - yyz = yystate->yyother; - if(yyz == 0)break; - if(yyz->yystoff == yycrank)break; - } - *yylastch++ = yych = input(); - yyfirst=0; - tryagain: -# ifdef LEXDEBUG - if(debug){ - fprintf(yyout,"char "); - allprint(yych); - putchar('\n'); - } -# endif - yyr = yyt; - if ( (int)yyt > (int)yycrank){ - yyt = yyr + yych; - if (yyt <= yytop && yyt->verify+yysvec == yystate){ - if(yyt->advance+yysvec == YYLERR) /* error transitions */ - {unput(*--yylastch);break;} - *lsp++ = yystate = yyt->advance+yysvec; - goto contin; - } - } -# ifdef YYOPTIM - else if((int)yyt < (int)yycrank) { /* r < yycrank */ - yyt = yyr = yycrank+(yycrank-yyt); -# ifdef LEXDEBUG - if(debug)fprintf(yyout,"compressed state\n"); -# endif - yyt = yyt + yych; - if(yyt <= yytop && yyt->verify+yysvec == yystate){ - if(yyt->advance+yysvec == YYLERR) /* error transitions */ - {unput(*--yylastch);break;} - *lsp++ = yystate = yyt->advance+yysvec; - goto contin; - } - yyt = yyr + YYU(yymatch[yych]); -# ifdef LEXDEBUG - if(debug){ - fprintf(yyout,"try fall back character "); - allprint(YYU(yymatch[yych])); - putchar('\n'); - } -# endif - if(yyt <= yytop && yyt->verify+yysvec == yystate){ - if(yyt->advance+yysvec == YYLERR) /* error transition */ - {unput(*--yylastch);break;} - *lsp++ = yystate = yyt->advance+yysvec; - goto contin; - } - } - if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ -# ifdef LEXDEBUG - if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); -# endif - goto tryagain; - } -# endif - else - {unput(*--yylastch);break;} - contin: -# ifdef LEXDEBUG - if(debug){ - fprintf(yyout,"state %d char ",yystate-yysvec-1); - allprint(yych); - putchar('\n'); - } -# endif - ; - } -# ifdef LEXDEBUG - if(debug){ - fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); - allprint(yych); - putchar('\n'); - } -# endif - while (lsp-- > yylstate){ - *yylastch-- = 0; - if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ - yyolsp = lsp; - if(yyextra[*yyfnd]){ /* must backup */ - while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ - lsp--; - unput(*yylastch--); - } - } - yyprevious = YYU(*yylastch); - yylsp = lsp; - yyleng = yylastch-yytext+1; - yytext[yyleng] = 0; -# ifdef LEXDEBUG - if(debug){ - fprintf(yyout,"\nmatch "); - sprint(yytext); - fprintf(yyout," action %d\n",*yyfnd); - } -# endif - return(*yyfnd++); - } - unput(*yylastch); - } - if (yytext[0] == 0 /* && feof(yyin) */) - { - yysptr=yysbuf; - return(0); - } - yyprevious = yytext[0] = input(); - if (yyprevious>0) - output(yyprevious); - yylastch=yytext; -# ifdef LEXDEBUG - if(debug)putchar('\n'); -# endif - } - } +int yylook() { + register struct yysvf *yystate, **lsp; + register struct yywork *yyt; + struct yysvf *yyz; + int yych, yyfirst; + struct yywork *yyr; +#ifdef LEXDEBUG + int debug; +#endif + char *yylastch; +/* start off machines */ +#ifdef LEXDEBUG + debug = 0; +#endif + yyfirst = 1; + if (!yymorfg) + yylastch = yytext; + else { + yymorfg = 0; + yylastch = yytext + yyleng; + } + for (;;) { + lsp = yylstate; + yyestate = yystate = yybgin; + if (yyprevious == YYNEWLINE) yystate++; + for (;;) { +#ifdef LEXDEBUG + if (debug) fprintf(yyout, "state %d\n", yystate - yysvec - 1); +#endif + yyt = yystate->yystoff; + if (yyt == yycrank && !yyfirst) { /* may not be any transitions */ + yyz = yystate->yyother; + if (yyz == 0) break; + if (yyz->yystoff == yycrank) break; + } + *yylastch++ = yych = input(); + yyfirst = 0; + tryagain: +#ifdef LEXDEBUG + if (debug) { + fprintf(yyout, "char "); + allprint(yych); + putchar('\n'); + } +#endif + yyr = yyt; + if ((int)yyt > (int)yycrank) { + yyt = yyr + yych; + if (yyt <= yytop && yyt->verify + yysvec == yystate) { + if (yyt->advance + yysvec == YYLERR) /* error transitions */ + { + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance + yysvec; + goto contin; + } + } +#ifdef YYOPTIM + else if ((int)yyt < (int)yycrank) { /* r < yycrank */ + yyt = yyr = yycrank + (yycrank - yyt); +#ifdef LEXDEBUG + if (debug) fprintf(yyout, "compressed state\n"); +#endif + yyt = yyt + yych; + if (yyt <= yytop && yyt->verify + yysvec == yystate) { + if (yyt->advance + yysvec == YYLERR) /* error transitions */ + { + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance + yysvec; + goto contin; + } + yyt = yyr + YYU(yymatch[yych]); +#ifdef LEXDEBUG + if (debug) { + fprintf(yyout, "try fall back character "); + allprint(YYU(yymatch[yych])); + putchar('\n'); + } +#endif + if (yyt <= yytop && yyt->verify + yysvec == yystate) { + if (yyt->advance + yysvec == YYLERR) /* error transition */ + { + unput(*--yylastch); + break; + } + *lsp++ = yystate = yyt->advance + yysvec; + goto contin; + } + } + if ((yystate = yystate->yyother) && (yyt = yystate->yystoff) != yycrank) { +#ifdef LEXDEBUG + if (debug) fprintf(yyout, "fall back to state %d\n", yystate - yysvec - 1); +#endif + goto tryagain; + } +#endif + else { + unput(*--yylastch); + break; + } + contin: +#ifdef LEXDEBUG + if (debug) { + fprintf(yyout, "state %d char ", yystate - yysvec - 1); + allprint(yych); + putchar('\n'); + } +#endif + ; + } +#ifdef LEXDEBUG + if (debug) { + fprintf(yyout, "stopped at %d with ", *(lsp - 1) - yysvec - 1); + allprint(yych); + putchar('\n'); + } +#endif + while (lsp-- > yylstate) { + *yylastch-- = 0; + if (*lsp != 0 && (yyfnd = (*lsp)->yystops) && *yyfnd > 0) { + yyolsp = lsp; + if (yyextra[*yyfnd]) { /* must backup */ + while (yyback((*lsp)->yystops, -*yyfnd) != 1 && lsp > yylstate) { + lsp--; + unput(*yylastch--); + } + } + yyprevious = YYU(*yylastch); + yylsp = lsp; + yyleng = yylastch - yytext + 1; + yytext[yyleng] = 0; +#ifdef LEXDEBUG + if (debug) { + fprintf(yyout, "\nmatch "); + sprint(yytext); + fprintf(yyout, " action %d\n", *yyfnd); + } +#endif + return (*yyfnd++); + } + unput(*yylastch); + } + if (yytext[0] == 0 /* && feof(yyin) */) { + yysptr = yysbuf; + return (0); + } + yyprevious = yytext[0] = input(); + if (yyprevious > 0) output(yyprevious); + yylastch = yytext; +#ifdef LEXDEBUG + if (debug) putchar('\n'); +#endif + } +} #endif - diff --git a/src/lpmain.c b/src/lpmain.c old mode 100755 new mode 100644 index b0cb665..87d1ba1 --- a/src/lpmain.c +++ b/src/lpmain.c @@ -1,9 +1,7 @@ -/* $Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -19,8 +17,6 @@ static char *id = "$Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyri #include "version.h" - - #include #include "lpkit.h" #include "lpglob.h" @@ -38,19 +34,21 @@ static char *id = "$Id: lpmain.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyri #include "adr68k.h" #include "arith.h" +#define CFREE(x) \ + if (x) { \ + free(x); \ + (x) = (void *)0; \ + } -#define CFREE(x) if (x) { free(x); (x) = (void *)0; } - -lprec *Medley_lp = NULL; /* The lp description for us */ -int SolveCount = 0; /* Counter for interrupting periodically */ +lprec *Medley_lp = NULL; /* The lp description for us */ +int SolveCount = 0; /* Counter for interrupting periodically */ jmp_buf LP_jmpbuf; -static lprec *initmilp(lprec *lp) -{ - int i,j, rownr; +static lprec *initmilp(lprec *lp) { + int i, j, rownr; int *num, *rownum; - sstate *st; /* for saving state at timeouts */ - + sstate *st; /* for saving state at timeouts */ + if (!lp) CALLOC(lp, 1, lprec); /* Done already in lisp. Rows--; */ @@ -123,15 +121,14 @@ static lprec *initmilp(lprec *lp) CFREE(lp->lowbo); CALLOC(lp->lowbo, Sum + 1, REAL); - for(i = 0; i <= Sum; i++) - { - lp->orig_upbo[i] = lp->infinite; - lp->orig_lowbo[i] = 0; - } + for (i = 0; i <= Sum; i++) { + lp->orig_upbo[i] = lp->infinite; + lp->orig_lowbo[i] = 0; + } lp->basis_valid = TRUE; CFREE(lp->bas); - CALLOC(lp->bas, Rows+1, int); + CALLOC(lp->bas, Rows + 1, int); CFREE(lp->basis); CALLOC(lp->basis, Sum + 1, short); @@ -139,20 +136,17 @@ static lprec *initmilp(lprec *lp) CFREE(lp->lower); CALLOC(lp->lower, Sum + 1, short); - for(i = 0; i <= Rows; i++) - { - lp->bas[i] = i; - lp->basis[i] = TRUE; - } - for(i = Rows + 1; i <= Sum; i++) - lp->basis[i] = FALSE; - for(i = 0 ; i <= Sum; i++) - lp->lower[i] = TRUE; - + for (i = 0; i <= Rows; i++) { + lp->bas[i] = i; + lp->basis[i] = TRUE; + } + for (i = Rows + 1; i <= Sum; i++) lp->basis[i] = FALSE; + for (i = 0; i <= Sum; i++) lp->lower[i] = TRUE; + lp->eta_valid = TRUE; lp->eta_size = 0; lp->eta_alloc = 10000; - lp->max_num_inv=DEFNUMINV; + lp->max_num_inv = DEFNUMINV; CFREE(lp->eta_value); CALLOC(lp->eta_value, 10000, REAL); @@ -182,48 +176,40 @@ static lprec *initmilp(lprec *lp) CALLOC(lp->ch_sign, Rows + 1, short); - for(i = 0; i <= Rows; i++) - lp->ch_sign[i] = FALSE; - + for (i = 0; i <= Rows; i++) lp->ch_sign[i] = FALSE; st = lp->solve_states = NULL; - for (i=0; i < Sum + 2; i++) - { - if (st) /* There's an old state-saver to use; re-use it. */ - { - st->saved = 0; /* clear the in-use field */ - st->notint = 0; /* And the not-integer field */ - st = st->next; - } - else - { - st = (sstate *) malloc(sizeof(sstate)); - if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */ - st->next = lp->solve_states; - st->saved = 0; - st->notint = 0; /* And the not-integer field */ - lp->solve_states = st; - st = (sstate *)NULL; - } + for (i = 0; i < Sum + 2; i++) { + if (st) /* There's an old state-saver to use; re-use it. */ + { + st->saved = 0; /* clear the in-use field */ + st->notint = 0; /* And the not-integer field */ + st = st->next; + } else { + st = (sstate *)malloc(sizeof(sstate)); + if (!st) ERROR(ERR_NOMEM); /* Tell the guy there's no memory */ + st->next = lp->solve_states; + st->saved = 0; + st->notint = 0; /* And the not-integer field */ + lp->solve_states = st; + st = (sstate *)NULL; } + } - lp->valid = FALSE; + lp->valid = FALSE; - return(lp); + return (lp); } - - -int lpmain (LispPTR lispresults) -{ - int i, failure; - float* results = (float *)Addr68k_from_LADDR(lispresults); +int lpmain(LispPTR lispresults) { + int i, failure; + float *results = (float *)Addr68k_from_LADDR(lispresults); /* solve it */ - SolveCount = 0; /* reset the "timer", to limit length of a run */ + SolveCount = 0; /* reset the "timer", to limit length of a run */ - if(failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure); + if (failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure); /* solve it */ @@ -231,101 +217,73 @@ int lpmain (LispPTR lispresults) failure = milpsolve(Medley_lp->solve_states, Orig_upbo, Orig_lowbo, Basis, Lower, Bas); - Medley_lp->eta_size = Eta_size; - Medley_lp->eta_alloc = Eta_alloc; - Medley_lp->num_inv = Num_inv; + Medley_lp->eta_size = Eta_size; + Medley_lp->eta_alloc = Eta_alloc; + Medley_lp->num_inv = Num_inv; if ((failure == INT_SOLN) || (failure == OPTIMAL)) - for (i=0; i < Sum+1; i++) results[i] = Best_solution[i]; + for (i = 0; i < Sum + 1; i++) results[i] = Best_solution[i]; - return(S_POSITIVE | failure); /* Tell him what happened so far. */ + return (S_POSITIVE | failure); /* Tell him what happened so far. */ } /* main */ - - - - #ifdef OS4 -int lpsetup(rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound) - int rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound; +int lpsetup(rows, cols, nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound) int rows, cols, + nonnuls, rhs, relns, cend, mat, ints, lowbo, upbo, objbound; #else -int lpsetup (int rows, int cols, int nonnuls, - int rhs, int relns, int cend, int mat, int ints, - int lowbo, int upbo, int objbound) +int lpsetup(int rows, int cols, int nonnuls, int rhs, int relns, int cend, int mat, int ints, + int lowbo, int upbo, int objbound) #endif /* OS4 */ { double obj_bound = -Infinite; int failure, i, autoscale; - - if(failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure); + + if (failure = setjmp(LP_jmpbuf)) return (S_POSITIVE | failure); /* mallopt(M_DEBUG, 1);*/ /*debugging!!!!*/ - Rows = rows&0xFFFF; - Columns = cols&0xFFFF; - Non_zeros = nonnuls&0xFFFF; + Rows = rows & 0xFFFF; + Columns = cols & 0xFFFF; + Non_zeros = nonnuls & 0xFFFF; printf("Rows = %d. Cols = %d. Non-zeros = %d.\n", Rows, Columns, Non_zeros); Medley_lp = initmilp(Medley_lp); - readlispinput(Medley_lp, - Addr68k_from_LADDR(rhs), - Addr68k_from_LADDR(relns), - Addr68k_from_LADDR(cend), - Addr68k_from_LADDR(mat), - Addr68k_from_LADDR(ints), - Addr68k_from_LADDR(lowbo), - Addr68k_from_LADDR(upbo)); + readlispinput(Medley_lp, Addr68k_from_LADDR(rhs), Addr68k_from_LADDR(relns), + Addr68k_from_LADDR(cend), Addr68k_from_LADDR(mat), Addr68k_from_LADDR(ints), + Addr68k_from_LADDR(lowbo), Addr68k_from_LADDR(upbo)); + auto_scale(Medley_lp); /* Scale values */ - auto_scale(Medley_lp); /* Scale values */ - - Medley_lp->total_iter = 0; - Medley_lp->max_level = 1; + Medley_lp->total_iter = 0; + Medley_lp->max_level = 1; Medley_lp->total_nodes = 0; - set_globals(Medley_lp); /* Set global vars for the run */ - if(Isvalid(Medley_lp)) - { - if (objbound) - { - Medley_lp->obj_bound = Best_solution[0] = *((float *) Addr68k_from_LADDR(objbound)); - } - else if(Maximise && Medley_lp->obj_bound == Infinite) - Best_solution[0]=-Infinite; - else if(!Maximise && Medley_lp->obj_bound==-Infinite) - Best_solution[0] = Infinite; - else - Best_solution[0] = Medley_lp->obj_bound; + set_globals(Medley_lp); /* Set global vars for the run */ + if (Isvalid(Medley_lp)) { + if (objbound) { + Medley_lp->obj_bound = Best_solution[0] = *((float *)Addr68k_from_LADDR(objbound)); + } else if (Maximise && Medley_lp->obj_bound == Infinite) + Best_solution[0] = -Infinite; + else if (!Maximise && Medley_lp->obj_bound == -Infinite) + Best_solution[0] = Infinite; + else + Best_solution[0] = Medley_lp->obj_bound; - Level = 0; + Level = 0; - if(!Medley_lp->basis_valid) - { - for(i = 0; i <= Medley_lp->rows; i++) - { - Medley_lp->basis[i] = TRUE; - Medley_lp->bas[i] = i; - } - for(i = Medley_lp->rows+1; i <= Medley_lp->sum; i++) - Medley_lp->basis[i] = FALSE; - for(i = 0; i <= Medley_lp->sum; i++) - Medley_lp->lower[i] = TRUE; - Medley_lp->basis_valid = TRUE; - } - - Medley_lp->eta_valid = FALSE; + if (!Medley_lp->basis_valid) { + for (i = 0; i <= Medley_lp->rows; i++) { + Medley_lp->basis[i] = TRUE; + Medley_lp->bas[i] = i; + } + for (i = Medley_lp->rows + 1; i <= Medley_lp->sum; i++) Medley_lp->basis[i] = FALSE; + for (i = 0; i <= Medley_lp->sum; i++) Medley_lp->lower[i] = TRUE; + Medley_lp->basis_valid = TRUE; } + + Medley_lp->eta_valid = FALSE; + } return (0); } /* lpsetup */ - - - - - - - - - - diff --git a/src/lpread.c b/src/lpread.c old mode 100755 new mode 100644 index e17a23e..612cf5c --- a/src/lpread.c +++ b/src/lpread.c @@ -1,9 +1,7 @@ -/* $Id: lpread.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lpread.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lpread.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1994, 1995 Venue. */ @@ -19,8 +17,6 @@ static char *id = "$Id: lpread.c,v 1.2 1999/01/03 02:07:19 sybalsky Exp $ Copyri #include "version.h" - - /* ============================================================================ NAME : read.c @@ -60,9 +56,7 @@ extern REAL Infinite; */ #ifdef OS4 -readlispinput(lp, lisprhs, lisprelns, - lispcend, lispmat, lispints, lisplowbo, lispupbo) -lprec *lp; +readlispinput(lp, lisprhs, lisprelns, lispcend, lispmat, lispints, lisplowbo, lispupbo) lprec *lp; float *lisprhs; short *lisprelns; int *lispcend; @@ -71,67 +65,47 @@ short *lispints; float *lisplowbo; float *lispupbo; #else -void readlispinput(lprec *lp, - float *lisprhs, - short *lisprelns, - int *lispcend, - lispmr *lispmat, - short *lispints, - float *lisplowbo, - float *lispupbo) +void readlispinput(lprec *lp, float *lisprhs, short *lisprelns, int *lispcend, lispmr *lispmat, + short *lispints, float *lisplowbo, float *lispupbo) #endif /* OS4 */ { - int i, j, k, index, nn_ind; - int x; - + int i, j, k, index, nn_ind; + int x; + /* initialize lower and upper bound arrays */ - for (i = 0; i <= Sum; i++) - { - lp->orig_lowbo[i] = lisplowbo[i]; + for (i = 0; i <= Sum; i++) { + lp->orig_lowbo[i] = lisplowbo[i]; - if(lispupbo[i] > 1.0e20) lp->orig_upbo[i] = Infinite; - else lp->orig_upbo[i] = lispupbo[i]; - } + if (lispupbo[i] > 1.0e20) + lp->orig_upbo[i] = Infinite; + else + lp->orig_upbo[i] = lispupbo[i]; + } - for (i = Rows;i >= 0;i--) - { - lp->orig_rh[i] = lisprhs[i]; - } - + for (i = Rows; i >= 0; i--) { lp->orig_rh[i] = lisprhs[i]; } - - - memcpy(lp->col_end, lispcend, (Columns+1)*sizeof(int)); + memcpy(lp->col_end, lispcend, (Columns + 1) * sizeof(int)); #ifdef BYTESWAP - for (i=0; imust_be_int[i] = lispints[i^1]; + for (i = 0; i < Sum + 1; i++) lp->must_be_int[i] = lispints[i ^ 1]; #else - memcpy(lp->must_be_int, lispints, (Sum+1)*sizeof(short)); + memcpy(lp->must_be_int, lispints, (Sum + 1) * sizeof(short)); #endif /* BYTESWAP */ + for (i = 0; i < Non_zeros; i++) { + lp->mat[i].row_nr = lispmat[i].rownr; + lp->mat[i].value = lispmat[i].value; + } - for (i=0; i< Non_zeros; i++) - { - lp->mat[i].row_nr = lispmat[i].rownr; - lp->mat[i].value = lispmat[i].value; - } + set_maxim(lp); /* We always maximize. */ - set_maxim(lp); /* We always maximize. */ - - for (i = Rows;i > 0;i--) - { + for (i = Rows; i > 0; i--) { #ifdef BYTESWAP - set_constr_type(lp, i, lisprelns[i^1]); + set_constr_type(lp, i, lisprelns[i ^ 1]); #else - set_constr_type(lp, i, lisprelns[i]); + set_constr_type(lp, i, lisprelns[i]); #endif /* BYTESWAP */ - } + } } /* readlispinput */ - /* ===================== END OF read.c ===================================== */ - - - - - diff --git a/src/lpsolve.c b/src/lpsolve.c old mode 100755 new mode 100644 index 158862e..0c83c3c --- a/src/lpsolve.c +++ b/src/lpsolve.c @@ -1,10 +1,7 @@ -/* $Id: lpsolve.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lpsolve.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lpsolve.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,8 +16,6 @@ static char *id = "$Id: lpsolve.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyr #include "version.h" - - #include #include "lpkit.h" #include "lpglob.h" @@ -44,13 +39,11 @@ short Doiter; short DoInvert; short Break_bb; -void set_globals(lprec *lp) -{ +void set_globals(lprec *lp) { sstate *st; int i; - if(Lp != NULL) - Lp->active = FALSE; + if (Lp != NULL) Lp->active = FALSE; Lp = lp; Rows = lp->rows; Columns = lp->columns; @@ -92,107 +85,85 @@ void set_globals(lprec *lp) Maximise = lp->maximise; Floor_first = lp->floor_first; lp->active = TRUE; - } -void ftran(int start, - int end, - REAL *pcol) -{ - int i, j, k, r; +void ftran(int start, int end, REAL *pcol) { + int i, j, k, r; REAL theta; - for(i = start; i <= end; i++) - { - k = Eta_col_end[i] - 1; - r = Eta_row_nr[k]; - theta = pcol[r]; - if(theta != 0) - for(j = Eta_col_end[i - 1]; j < k; j++) - pcol[Eta_row_nr[j]] += theta * Eta_value[j]; /* cpu expensive line */ - pcol[r] *= Eta_value[k]; - } + for (i = start; i <= end; i++) { + k = Eta_col_end[i] - 1; + r = Eta_row_nr[k]; + theta = pcol[r]; + if (theta != 0) + for (j = Eta_col_end[i - 1]; j < k; j++) + pcol[Eta_row_nr[j]] += theta * Eta_value[j]; /* cpu expensive line */ + pcol[r] *= Eta_value[k]; + } /* round small values to zero */ - for(i = 0; i <= Rows; i++) - my_round(pcol[i], Epsel); + for (i = 0; i <= Rows; i++) my_round(pcol[i], Epsel); } /* ftran */ -void btran(REAL *row) -{ - int i, j, k; +void btran(REAL *row) { + int i, j, k; REAL f; - for(i = Eta_size; i >= 1; i--) - { - f = 0; - k = Eta_col_end[i] - 1; - for(j = Eta_col_end[i - 1]; j <= k; j++) - f += row[Eta_row_nr[j]] * Eta_value[j]; - my_round(f, Epsel); - row[Eta_row_nr[k]] = f; - } + for (i = Eta_size; i >= 1; i--) { + f = 0; + k = Eta_col_end[i] - 1; + for (j = Eta_col_end[i - 1]; j <= k; j++) f += row[Eta_row_nr[j]] * Eta_value[j]; + my_round(f, Epsel); + row[Eta_row_nr[k]] = f; + } } /* btran */ - -short Isvalid(lprec *lp) -{ +short Isvalid(lprec *lp) { int i, j, *rownum, *colnum; int *num, row_nr; - if(!lp->row_end_valid) - { - MALLOC(num, lp->rows + 1, int); - MALLOC(rownum, lp->rows + 1, int); - for(i = 0; i <= lp->rows; i++) - { - num[i] = 0; - rownum[i] = 0; - } - for(i = 0; i < lp->non_zeros; i++) - rownum[lp->mat[i].row_nr]++; - lp->row_end[0] = 0; - for(i = 1; i <= lp->rows; i++) - lp->row_end[i] = lp->row_end[i - 1] + rownum[i]; - for(i = 1; i <= lp->columns; i++) - for(j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) - { - row_nr = lp->mat[j].row_nr; - if(row_nr != 0) - { - num[row_nr]++; - lp->col_no[lp->row_end[row_nr - 1] + num[row_nr]] = i; - } - } - free(num); - free(rownum); - lp->row_end_valid = TRUE; + if (!lp->row_end_valid) { + MALLOC(num, lp->rows + 1, int); + MALLOC(rownum, lp->rows + 1, int); + for (i = 0; i <= lp->rows; i++) { + num[i] = 0; + rownum[i] = 0; } - if(lp->valid) - return(TRUE); + for (i = 0; i < lp->non_zeros; i++) rownum[lp->mat[i].row_nr]++; + lp->row_end[0] = 0; + for (i = 1; i <= lp->rows; i++) lp->row_end[i] = lp->row_end[i - 1] + rownum[i]; + for (i = 1; i <= lp->columns; i++) + for (j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) { + row_nr = lp->mat[j].row_nr; + if (row_nr != 0) { + num[row_nr]++; + lp->col_no[lp->row_end[row_nr - 1] + num[row_nr]] = i; + } + } + free(num); + free(rownum); + lp->row_end_valid = TRUE; + } + if (lp->valid) return (TRUE); CALLOC(rownum, lp->rows + 1, int); CALLOC(colnum, lp->columns + 1, int); - for(i = 1 ; i <= lp->columns; i++) - for(j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) - { - colnum[i]++; - rownum[lp->mat[j].row_nr]++; - } - for(i = 1; i <= lp->columns; i++) - if(colnum[i] == 0) - if(lp->names_used) - fprintf(stderr, "Warning: Variable %s not used in any constraints\n", - lp->col_name[i]); + for (i = 1; i <= lp->columns; i++) + for (j = lp->col_end[i - 1]; j < lp->col_end[i]; j++) { + colnum[i]++; + rownum[lp->mat[j].row_nr]++; + } + for (i = 1; i <= lp->columns; i++) + if (colnum[i] == 0) + if (lp->names_used) + fprintf(stderr, "Warning: Variable %s not used in any constraints\n", lp->col_name[i]); else - fprintf(stderr, "Warning: Variable %d not used in any constaints\n", - i); + fprintf(stderr, "Warning: Variable %d not used in any constaints\n", i); free(rownum); free(colnum); lp->valid = TRUE; - return(TRUE); -} + return (TRUE); +} -static void resize_eta(void) -{ +static void resize_eta(void) { Eta_alloc *= 2; REALLOC(Eta_value, Eta_alloc, REAL); Lp->eta_value = Eta_value; @@ -200,143 +171,113 @@ static void resize_eta(void) Lp->eta_row_nr = Eta_row_nr; } /* resize_eta */ - -static void condensecol(int row_nr, - REAL *pcol) -{ +static void condensecol(int row_nr, REAL *pcol) { int i, elnr; - + elnr = Eta_col_end[Eta_size]; - if(elnr + Rows + 2 > Eta_alloc) /* maximum local growth of Eta */ + if (elnr + Rows + 2 > Eta_alloc) /* maximum local growth of Eta */ resize_eta(); - for(i = 0; i <= Rows; i++) - if(i != row_nr && pcol[i] != 0) - { - Eta_row_nr[elnr] = i; - Eta_value[elnr] = pcol[i]; - elnr++; - } + for (i = 0; i <= Rows; i++) + if (i != row_nr && pcol[i] != 0) { + Eta_row_nr[elnr] = i; + Eta_value[elnr] = pcol[i]; + elnr++; + } Eta_row_nr[elnr] = row_nr; Eta_value[elnr] = pcol[row_nr]; elnr++; Eta_col_end[Eta_size + 1] = elnr; } /* condensecol */ - -static void addetacol(void) -{ - int i, j, k; +static void addetacol(void) { + int i, j, k; REAL theta; - + j = Eta_col_end[Eta_size]; Eta_size++; k = Eta_col_end[Eta_size]; - theta = 1 / (REAL) Eta_value[k - 1]; + theta = 1 / (REAL)Eta_value[k - 1]; Eta_value[k - 1] = theta; - for(i = j; i < k - 1; i++) - Eta_value[i] *= -theta; + for (i = j; i < k - 1; i++) Eta_value[i] *= -theta; JustInverted = FALSE; } /* addetacol */ -static void setpivcol(short lower, - int varin, - REAL *pcol) -{ - int i, colnr; +static void setpivcol(short lower, int varin, REAL *pcol) { + int i, colnr; REAL f; - - if(lower) + + if (lower) f = 1; else f = -1; - for(i = 0; i <= Rows; i++) - pcol[i] = 0; - if(varin > Rows) - { - colnr = varin - Rows; - for(i = Col_end[colnr - 1]; i < Col_end[colnr]; i++) - pcol[Mat[i].row_nr] = Mat[i].value * f; - pcol[0] -= Extrad * f; - } + for (i = 0; i <= Rows; i++) pcol[i] = 0; + if (varin > Rows) { + colnr = varin - Rows; + for (i = Col_end[colnr - 1]; i < Col_end[colnr]; i++) pcol[Mat[i].row_nr] = Mat[i].value * f; + pcol[0] -= Extrad * f; + } else if (lower) + pcol[varin] = 1; else - if(lower) - pcol[varin] = 1; - else - pcol[varin] = -1; + pcol[varin] = -1; ftran(1, Eta_size, pcol); } /* setpivcol */ - -static void minoriteration(int colnr, - int row_nr) -{ - int i, j, k, wk, varin, varout, elnr; +static void minoriteration(int colnr, int row_nr) { + int i, j, k, wk, varin, varout, elnr; REAL piv, theta; - + varin = colnr + Rows; elnr = Eta_col_end[Eta_size]; wk = elnr; Eta_size++; - if(Extrad != 0) - { - Eta_row_nr[elnr] = 0; - Eta_value[elnr] = -Extrad; + if (Extrad != 0) { + Eta_row_nr[elnr] = 0; + Eta_value[elnr] = -Extrad; + elnr++; + } + for (j = Col_end[colnr - 1]; j < Col_end[colnr]; j++) { + k = Mat[j].row_nr; + if (k == 0 && Extrad != 0) + Eta_value[Eta_col_end[Eta_size - 1]] += Mat[j].value; + else if (k != row_nr) { + Eta_row_nr[elnr] = k; + Eta_value[elnr] = Mat[j].value; elnr++; - } - for(j = Col_end[colnr - 1] ; j < Col_end[colnr]; j++) - { - k = Mat[j].row_nr; - if(k == 0 && Extrad != 0) - Eta_value[Eta_col_end[Eta_size -1]] += Mat[j].value; - else if(k != row_nr) - { - Eta_row_nr[elnr] = k; - Eta_value[elnr] = Mat[j].value; - elnr++; - } - else - piv = Mat[j].value; - } + } else + piv = Mat[j].value; + } Eta_row_nr[elnr] = row_nr; - Eta_value[elnr] = 1 / (REAL) piv; + Eta_value[elnr] = 1 / (REAL)piv; elnr++; - theta = Rhs[row_nr] / (REAL) piv; + theta = Rhs[row_nr] / (REAL)piv; Rhs[row_nr] = theta; - for(i = wk; i < elnr - 1; i++) - Rhs[Eta_row_nr[i]] -= theta * Eta_value[i]; + for (i = wk; i < elnr - 1; i++) Rhs[Eta_row_nr[i]] -= theta * Eta_value[i]; varout = Bas[row_nr]; Bas[row_nr] = varin; Basis[varout] = FALSE; Basis[varin] = TRUE; - for(i = wk; i < elnr - 1; i++) - Eta_value[i] /= - (REAL) piv; + for (i = wk; i < elnr - 1; i++) Eta_value[i] /= -(REAL)piv; Eta_col_end[Eta_size] = elnr; } /* minoriteration */ -static void rhsmincol(REAL theta, - int row_nr, - int varin) -{ - int i, j, k, varout; +static void rhsmincol(REAL theta, int row_nr, int varin) { + int i, j, k, varout; REAL f; - - if(row_nr > Rows + 1) - { - fprintf(stderr, "Error: rhsmincol called with row_nr: %d, rows: %d\n", - row_nr, Rows); - fprintf(stderr, "This indicates numerical instability\n"); - /* exit(1); */ ERROR(ERR_NUM); - } + + if (row_nr > Rows + 1) { + fprintf(stderr, "Error: rhsmincol called with row_nr: %d, rows: %d\n", row_nr, Rows); + fprintf(stderr, "This indicates numerical instability\n"); + /* exit(1); */ ERROR(ERR_NUM); + } j = Eta_col_end[Eta_size]; k = Eta_col_end[Eta_size + 1]; - for(i = j; i < k; i++) - { - f = Rhs[Eta_row_nr[i]] - theta * Eta_value[i]; - my_round(f, Epsb); - Rhs[Eta_row_nr[i]] = f; - } + for (i = j; i < k; i++) { + f = Rhs[Eta_row_nr[i]] - theta * Eta_value[i]; + my_round(f, Epsb); + Rhs[Eta_row_nr[i]] = f; + } Rhs[row_nr] = theta; varout = Bas[row_nr]; Bas[row_nr] = varin; @@ -344,21 +285,19 @@ static void rhsmincol(REAL theta, Basis[varin] = TRUE; } /* rhsmincol */ +void invert(void) { + int i, j, v, wk, numit, varnr, row_nr, colnr, varin; + REAL f, theta; + REAL *pcol; + short *frow; + short *fcol; + int *rownum, *col, *row; + int *colnum; -void invert(void) -{ - int i, j, v, wk, numit, varnr, row_nr, colnr, varin; - REAL f, theta; - REAL *pcol; - short *frow; - short *fcol; - int *rownum, *col, *row; - int *colnum; + if (Lp->print_at_invert) + fprintf(stderr, "Start Invert iter %7d eta_size %4d rhs[0] %16.4f \n", Lp->iter, Eta_size, + -Rhs[0]); - if(Lp->print_at_invert) - fprintf(stderr, "Start Invert iter %7d eta_size %4d rhs[0] %16.4f \n", - Lp->iter, Eta_size,-Rhs[0]); - CALLOC(rownum, Rows + 1, int); CALLOC(col, Rows + 1, int); CALLOC(row, Rows + 1, int); @@ -366,152 +305,123 @@ void invert(void) CALLOC(frow, Rows + 1, short); CALLOC(fcol, Columns + 1, short); CALLOC(colnum, Columns + 1, int); - - for(i = 0; i <= Rows; i++) - frow[i] = TRUE; - for(i = 0; i < Columns; i++) - fcol[i] = FALSE; + for (i = 0; i <= Rows; i++) frow[i] = TRUE; - for(i = 0; i < Rows; i++) - rownum[i] = 0; + for (i = 0; i < Columns; i++) fcol[i] = FALSE; - for(i = 0; i <= Columns; i++) - colnum[i] = 0; + for (i = 0; i < Rows; i++) rownum[i] = 0; - for(i = 0; i <= Rows; i++) - if(Bas[i] > Rows) + for (i = 0; i <= Columns; i++) colnum[i] = 0; + + for (i = 0; i <= Rows; i++) + if (Bas[i] > Rows) fcol[Bas[i] - Rows - 1] = TRUE; else frow[Bas[i]] = FALSE; - for(i = 1; i <= Rows; i++) - if(frow[i]) - for(j = Row_end[i - 1] + 1; j <= Row_end[i]; j++) - { - wk = Col_no[j]; - if(fcol[wk - 1]) - { - colnum[wk]++; - rownum[i - 1]++; - } - } - for(i = 1; i <= Rows; i++) - Bas[i] = i; - for(i = 1; i <= Rows; i++) - Basis[i] = TRUE; - for(i = 1; i <= Columns; i++) - Basis[i + Rows] = FALSE; + for (i = 1; i <= Rows; i++) + if (frow[i]) + for (j = Row_end[i - 1] + 1; j <= Row_end[i]; j++) { + wk = Col_no[j]; + if (fcol[wk - 1]) { + colnum[wk]++; + rownum[i - 1]++; + } + } + for (i = 1; i <= Rows; i++) Bas[i] = i; + for (i = 1; i <= Rows; i++) Basis[i] = TRUE; + for (i = 1; i <= Columns; i++) Basis[i + Rows] = FALSE; - for(i = 0; i <= Rows; i++) - Rhs[i] = Rh[i]; + for (i = 0; i <= Rows; i++) Rhs[i] = Rh[i]; - for(i = 1; i <= Columns; i++) - { - varnr = Rows + i; - if(!Lower[varnr]) - { - theta = Upbo[varnr]; - for(j = Col_end[i - 1]; j < Col_end[i]; j++) - Rhs[Mat[j].row_nr] -= theta * Mat[j].value; - } + for (i = 1; i <= Columns; i++) { + varnr = Rows + i; + if (!Lower[varnr]) { + theta = Upbo[varnr]; + for (j = Col_end[i - 1]; j < Col_end[i]; j++) Rhs[Mat[j].row_nr] -= theta * Mat[j].value; } - for(i = 1; i <= Rows; i++) - if(!Lower[i]) - Rhs[i] -= Upbo[i]; + } + for (i = 1; i <= Rows; i++) + if (!Lower[i]) Rhs[i] -= Upbo[i]; Eta_size = 0; v = 0; row_nr = 0; Num_inv = 0; numit = 0; - while(v < Rows) - { - row_nr++; - if(row_nr > Rows) - row_nr = 1; - v++; - if(rownum[row_nr - 1] == 1) - if(frow[row_nr]) - { - v = 0; - j = Row_end[row_nr - 1] + 1; - while(!(fcol[Col_no[j] - 1])) - j++; - colnr = Col_no[j]; - fcol[colnr - 1] = FALSE; - colnum[colnr] = 0; - for(j = Col_end[colnr - 1]; j < Col_end[colnr]; j++) - if(frow[Mat[j].row_nr]) - rownum[Mat[j].row_nr - 1]--; - frow[row_nr] = FALSE; - minoriteration(colnr, row_nr); - } - } + while (v < Rows) { + row_nr++; + if (row_nr > Rows) row_nr = 1; + v++; + if (rownum[row_nr - 1] == 1) + if (frow[row_nr]) { + v = 0; + j = Row_end[row_nr - 1] + 1; + while (!(fcol[Col_no[j] - 1])) j++; + colnr = Col_no[j]; + fcol[colnr - 1] = FALSE; + colnum[colnr] = 0; + for (j = Col_end[colnr - 1]; j < Col_end[colnr]; j++) + if (frow[Mat[j].row_nr]) rownum[Mat[j].row_nr - 1]--; + frow[row_nr] = FALSE; + minoriteration(colnr, row_nr); + } + } v = 0; colnr = 0; - while(v Columns) - colnr = 1; - v++; - if(colnum[colnr] == 1) - if(fcol[colnr - 1]) - { - v = 0; - j = Col_end[colnr - 1] + 1; - while(!(frow[Mat[j - 1].row_nr])) - j++; - row_nr = Mat[j - 1].row_nr; - frow[row_nr] = FALSE; - rownum[row_nr - 1] = 0; - for(j = Row_end[row_nr - 1] + 1; j <= Row_end[row_nr]; j++) - if(fcol[Col_no[j] - 1]) - colnum[Col_no[j]]--; - fcol[colnr - 1] = FALSE; - numit++; - col[numit - 1] = colnr; - row[numit - 1] = row_nr; - } - } - for(j = 1; j <= Columns; j++) - if(fcol[j - 1]) - { - fcol[j - 1] = FALSE; - setpivcol(Lower[Rows + j], j + Rows, pcol); - row_nr = 1; - while((!(frow[row_nr] && pcol[row_nr])) && row_nr <= Rows) - row_nr++; /* this sometimes sets row_nr to Rows + 1 and makes - rhsmincol crash. Solved in 2.0? MB */ - if(row_nr == Rows + 1) - { printf("Inverting failed"); ERROR(ERR_NUM); } - frow[row_nr] = FALSE; - condensecol(row_nr, pcol); - theta = Rhs[row_nr] / (REAL) pcol[row_nr]; - rhsmincol(theta, row_nr, Rows + j); - addetacol(); + while (v < Columns) { + colnr++; + if (colnr > Columns) colnr = 1; + v++; + if (colnum[colnr] == 1) + if (fcol[colnr - 1]) { + v = 0; + j = Col_end[colnr - 1] + 1; + while (!(frow[Mat[j - 1].row_nr])) j++; + row_nr = Mat[j - 1].row_nr; + frow[row_nr] = FALSE; + rownum[row_nr - 1] = 0; + for (j = Row_end[row_nr - 1] + 1; j <= Row_end[row_nr]; j++) + if (fcol[Col_no[j] - 1]) colnum[Col_no[j]]--; + fcol[colnr - 1] = FALSE; + numit++; + col[numit - 1] = colnr; + row[numit - 1] = row_nr; } - for(i = numit - 1; i >= 0; i--) - { - colnr = col[i]; - row_nr = row[i]; - varin = colnr + Rows; - for(j = 0; j <= Rows; j++) - pcol[j] = 0; - for(j = Col_end[colnr - 1]; j < Col_end[colnr]; j++) - pcol[Mat[j].row_nr] = Mat[j].value; - pcol[0] -= Extrad; + } + for (j = 1; j <= Columns; j++) + if (fcol[j - 1]) { + fcol[j - 1] = FALSE; + setpivcol(Lower[Rows + j], j + Rows, pcol); + row_nr = 1; + while ((!(frow[row_nr] && pcol[row_nr])) && row_nr <= Rows) + row_nr++; /* this sometimes sets row_nr to Rows + 1 and makes + rhsmincol crash. Solved in 2.0? MB */ + if (row_nr == Rows + 1) { + printf("Inverting failed"); + ERROR(ERR_NUM); + } + frow[row_nr] = FALSE; condensecol(row_nr, pcol); - theta = Rhs[row_nr] / (REAL) pcol[row_nr]; - rhsmincol(theta, row_nr, varin); + theta = Rhs[row_nr] / (REAL)pcol[row_nr]; + rhsmincol(theta, row_nr, Rows + j); addetacol(); } - for(i = 1; i <= Rows; i++) - my_round(Rhs[i], Epsb); - if(Lp->print_at_invert) - fprintf(stderr, - "End Invert eta_size %4d rhs[0] %16.4f\n", - Eta_size,-Rhs[0]); + for (i = numit - 1; i >= 0; i--) { + colnr = col[i]; + row_nr = row[i]; + varin = colnr + Rows; + for (j = 0; j <= Rows; j++) pcol[j] = 0; + for (j = Col_end[colnr - 1]; j < Col_end[colnr]; j++) pcol[Mat[j].row_nr] = Mat[j].value; + pcol[0] -= Extrad; + condensecol(row_nr, pcol); + theta = Rhs[row_nr] / (REAL)pcol[row_nr]; + rhsmincol(theta, row_nr, varin); + addetacol(); + } + for (i = 1; i <= Rows; i++) my_round(Rhs[i], Epsb); + if (Lp->print_at_invert) + fprintf(stderr, "End Invert eta_size %4d rhs[0] %16.4f\n", Eta_size, -Rhs[0]); JustInverted = TRUE; DoInvert = FALSE; @@ -524,409 +434,315 @@ void invert(void) free(colnum); } /* invert */ -static short colprim(int *colnr, - short minit, - REAL *drow) -{ - int varnr, i, j; +static short colprim(int *colnr, short minit, REAL *drow) { + int varnr, i, j; REAL f, dpiv; - + dpiv = -Epsd; (*colnr) = 0; - if(!minit) - { - for(i = 1; i <= Sum; i++) - drow[i] = 0; - drow[0] = 1; - btran(drow); - for(i = 1; i <= Columns; i++) - { - varnr = Rows + i; - if(!Basis[varnr]) - if(Upbo[varnr] > 0) - { - f = 0; - for(j = Col_end[i - 1]; j < Col_end[i]; j++) - f += drow[Mat[j].row_nr] * Mat[j].value; - drow[varnr] = f; - } - } - for(i = 1; i <= Sum; i++) - my_round(drow[i], Epsd); + if (!minit) { + for (i = 1; i <= Sum; i++) drow[i] = 0; + drow[0] = 1; + btran(drow); + for (i = 1; i <= Columns; i++) { + varnr = Rows + i; + if (!Basis[varnr]) + if (Upbo[varnr] > 0) { + f = 0; + for (j = Col_end[i - 1]; j < Col_end[i]; j++) f += drow[Mat[j].row_nr] * Mat[j].value; + drow[varnr] = f; + } } - for(i = 1; i <= Sum; i++) - if(!Basis[i]) - if(Upbo[i] > 0) - { - if(Lower[i]) - f = drow[i]; - else - f = -drow[i]; - if(f < dpiv) - { - dpiv = f; - (*colnr) = i; - } - } - if(Lp->trace) - if((*colnr)>0) - fprintf(stderr, "col_prim:%7d, reduced cost: % 18.10f\n", - (*colnr), dpiv); + for (i = 1; i <= Sum; i++) my_round(drow[i], Epsd); + } + for (i = 1; i <= Sum; i++) + if (!Basis[i]) + if (Upbo[i] > 0) { + if (Lower[i]) + f = drow[i]; + else + f = -drow[i]; + if (f < dpiv) { + dpiv = f; + (*colnr) = i; + } + } + if (Lp->trace) + if ((*colnr) > 0) + fprintf(stderr, "col_prim:%7d, reduced cost: % 18.10f\n", (*colnr), dpiv); else - fprintf(stderr, - "col_prim: no negative reduced costs found, optimality!\n"); - if(*colnr == 0) - { - Doiter = FALSE; - DoInvert = FALSE; - Status = OPTIMAL; - } - return((*colnr) > 0); + fprintf(stderr, "col_prim: no negative reduced costs found, optimality!\n"); + if (*colnr == 0) { + Doiter = FALSE; + DoInvert = FALSE; + Status = OPTIMAL; + } + return ((*colnr) > 0); } /* colprim */ -static short rowprim(int colnr, - int *row_nr, - REAL *theta, - REAL *pcol) -{ - int i; - REAL f, quot; +static short rowprim(int colnr, int *row_nr, REAL *theta, REAL *pcol) { + int i; + REAL f, quot; (*row_nr) = 0; (*theta) = Infinite; - for(i = 1; i <= Rows; i++) - { - f = pcol[i]; - if(my_abs(f) < TREJ) - f = 0; - if(f != 0) - { - quot = 2 * Infinite; - if(f > 0) - quot = Rhs[i] / (REAL) f; - else - if(Upbo[Bas[i]] < Infinite) - quot = (Rhs[i] - Upbo[Bas[i]]) / (REAL) f; - my_round(quot, Epsel); - if(quot < (*theta)) - { - (*theta) = quot; - (*row_nr) = i; - } - } - } - if((*row_nr) == 0) - for(i = 1; i <= Rows; i++) - { - f = pcol[i]; - if(f != 0) - { - quot = 2 * Infinite; - if(f > 0) - quot = Rhs[i] / (REAL) f; - else - if(Upbo[Bas[i]] < Infinite) - quot = (Rhs[i] - Upbo[Bas[i]]) / (REAL) f; - my_round(quot, Epsel); - if(quot < (*theta)) - { - (*theta) = quot; - (*row_nr) = i; - } - } + for (i = 1; i <= Rows; i++) { + f = pcol[i]; + if (my_abs(f) < TREJ) f = 0; + if (f != 0) { + quot = 2 * Infinite; + if (f > 0) + quot = Rhs[i] / (REAL)f; + else if (Upbo[Bas[i]] < Infinite) + quot = (Rhs[i] - Upbo[Bas[i]]) / (REAL)f; + my_round(quot, Epsel); + if (quot < (*theta)) { + (*theta) = quot; + (*row_nr) = i; } - - if((*theta) < 0) - { - fprintf(stderr, "Warning: Numerical instability, qout = %f\n", (*theta)); - fprintf(stderr, "pcol[%d] = % 18.10f, rhs[%d] = % 18.8f , upbo = % f\n", - (*row_nr), f, (*row_nr), Rhs[(*row_nr)], Upbo[Bas[(*row_nr)]]); } - if((*row_nr) == 0) - { - if(Upbo[colnr] == Infinite) - { - Doiter = FALSE; - DoInvert = FALSE; - Status = UNBOUNDED; - } - else - { - i = 1; - while(pcol[i] >= 0 && i <= Rows) - i++; - if(i > Rows) /* empty column with upperbound! */ - { - Lower[colnr] = FALSE; - Rhs[0] += Upbo[colnr]*pcol[0]; - Doiter = FALSE; - DoInvert = FALSE; - } - else if(pcol[i]<0) - { - (*row_nr) = i; - } + } + if ((*row_nr) == 0) + for (i = 1; i <= Rows; i++) { + f = pcol[i]; + if (f != 0) { + quot = 2 * Infinite; + if (f > 0) + quot = Rhs[i] / (REAL)f; + else if (Upbo[Bas[i]] < Infinite) + quot = (Rhs[i] - Upbo[Bas[i]]) / (REAL)f; + my_round(quot, Epsel); + if (quot < (*theta)) { + (*theta) = quot; + (*row_nr) = i; } + } } - if((*row_nr) > 0) - Doiter = TRUE; - if(Lp->trace) - fprintf(stderr, "row_prim:%7d, pivot element:% 18.10f\n", (*row_nr), - pcol[(*row_nr)]); - return((*row_nr) > 0); + if ((*theta) < 0) { + fprintf(stderr, "Warning: Numerical instability, qout = %f\n", (*theta)); + fprintf(stderr, "pcol[%d] = % 18.10f, rhs[%d] = % 18.8f , upbo = % f\n", (*row_nr), f, + (*row_nr), Rhs[(*row_nr)], Upbo[Bas[(*row_nr)]]); + } + if ((*row_nr) == 0) { + if (Upbo[colnr] == Infinite) { + Doiter = FALSE; + DoInvert = FALSE; + Status = UNBOUNDED; + } else { + i = 1; + while (pcol[i] >= 0 && i <= Rows) i++; + if (i > Rows) /* empty column with upperbound! */ + { + Lower[colnr] = FALSE; + Rhs[0] += Upbo[colnr] * pcol[0]; + Doiter = FALSE; + DoInvert = FALSE; + } else if (pcol[i] < 0) { + (*row_nr) = i; + } + } + } + if ((*row_nr) > 0) Doiter = TRUE; + if (Lp->trace) + fprintf(stderr, "row_prim:%7d, pivot element:% 18.10f\n", (*row_nr), pcol[(*row_nr)]); + + return ((*row_nr) > 0); } /* rowprim */ -static short rowdual(int *row_nr) -{ - int i; - REAL f, g, minrhs; +static short rowdual(int *row_nr) { + int i; + REAL f, g, minrhs; short artifs; (*row_nr) = 0; minrhs = -Epsb; i = 0; artifs = FALSE; - while(i < Rows && !artifs) - { - i++; - f = Upbo[Bas[i]]; - if(f == 0 && (Rhs[i] != 0)) - { - artifs = TRUE; - (*row_nr) = i; - } + while (i < Rows && !artifs) { + i++; + f = Upbo[Bas[i]]; + if (f == 0 && (Rhs[i] != 0)) { + artifs = TRUE; + (*row_nr) = i; + } else { + if (Rhs[i] < f - Rhs[i]) + g = Rhs[i]; else - { - if(Rhs[i] < f - Rhs[i]) - g = Rhs[i]; - else - g = f - Rhs[i]; - if(g < minrhs) - { - minrhs = g; - (*row_nr) = i; - } - } + g = f - Rhs[i]; + if (g < minrhs) { + minrhs = g; + (*row_nr) = i; + } } + } - if(Lp->trace) - { - if((*row_nr)>0) - { - fprintf(stderr, - "row_dual:%7d, rhs of selected row: % 18.10f\n", - (*row_nr), Rhs[(*row_nr)]); - if(Upbo[Bas[(*row_nr)]] < Infinite) - fprintf(stderr, - " upper bound of basis variable: % 18.10f\n", - Upbo[Bas[(*row_nr)]]); - } - else - fprintf(stderr, "row_dual: no infeasibilities found\n"); - } - - return((*row_nr)>0); + if (Lp->trace) { + if ((*row_nr) > 0) { + fprintf(stderr, "row_dual:%7d, rhs of selected row: % 18.10f\n", (*row_nr), + Rhs[(*row_nr)]); + if (Upbo[Bas[(*row_nr)]] < Infinite) + fprintf(stderr, " upper bound of basis variable: % 18.10f\n", + Upbo[Bas[(*row_nr)]]); + } else + fprintf(stderr, "row_dual: no infeasibilities found\n"); + } + + return ((*row_nr) > 0); } /* rowdual */ -static short coldual(int row_nr, - int *colnr, - short minit, - REAL *prow, - REAL *drow) -{ - int i, j, r, varnr; +static short coldual(int row_nr, int *colnr, short minit, REAL *prow, REAL *drow) { + int i, j, r, varnr; REAL theta, quot, pivot, d, f, g; - + Doiter = FALSE; - if(!minit) - { - for(i = 0; i <= Rows; i++) - { - prow[i] = 0; - drow[i] = 0; - } - drow[0] = 1; - prow[row_nr] = 1; - for(i = Eta_size; i >= 1; i--) - { - d = 0; - f = 0; - r = Eta_row_nr[Eta_col_end[i] - 1]; - for(j = Eta_col_end[i - 1]; j < Eta_col_end[i]; j++) - { - /* this is where the program consumes most cpu time */ - f += prow[Eta_row_nr[j]] * Eta_value[j]; - d += drow[Eta_row_nr[j]] * Eta_value[j]; - } - my_round(f, Epsel); - prow[r] = f; - my_round(d, Epsel); - drow[r] = d; - } - for(i = 1; i <= Columns; i++) - { - varnr = Rows + i; - if(!Basis[varnr]) - { - d = - Extrad * drow[0]; - f = 0; - for(j = Col_end[i - 1]; j < Col_end[i]; j++) - { - d = d + drow[Mat[j].row_nr] * Mat[j].value; - f = f + prow[Mat[j].row_nr] * Mat[j].value; - } - drow[varnr] = d; - prow[varnr] = f; - } - } - for(i = 0; i <= Sum; i++) - { - my_round(prow[i], Epsel); - my_round(drow[i], Epsd); - } + if (!minit) { + for (i = 0; i <= Rows; i++) { + prow[i] = 0; + drow[i] = 0; } - if(Rhs[row_nr] > Upbo[Bas[row_nr]]) + drow[0] = 1; + prow[row_nr] = 1; + for (i = Eta_size; i >= 1; i--) { + d = 0; + f = 0; + r = Eta_row_nr[Eta_col_end[i] - 1]; + for (j = Eta_col_end[i - 1]; j < Eta_col_end[i]; j++) { + /* this is where the program consumes most cpu time */ + f += prow[Eta_row_nr[j]] * Eta_value[j]; + d += drow[Eta_row_nr[j]] * Eta_value[j]; + } + my_round(f, Epsel); + prow[r] = f; + my_round(d, Epsel); + drow[r] = d; + } + for (i = 1; i <= Columns; i++) { + varnr = Rows + i; + if (!Basis[varnr]) { + d = -Extrad * drow[0]; + f = 0; + for (j = Col_end[i - 1]; j < Col_end[i]; j++) { + d = d + drow[Mat[j].row_nr] * Mat[j].value; + f = f + prow[Mat[j].row_nr] * Mat[j].value; + } + drow[varnr] = d; + prow[varnr] = f; + } + } + for (i = 0; i <= Sum; i++) { + my_round(prow[i], Epsel); + my_round(drow[i], Epsd); + } + } + if (Rhs[row_nr] > Upbo[Bas[row_nr]]) g = -1; else g = 1; pivot = 0; (*colnr) = 0; theta = Infinite; - for(i = 1; i <= Sum; i++) - { - if(Lower[i]) - d = prow[i] * g; + for (i = 1; i <= Sum; i++) { + if (Lower[i]) + d = prow[i] * g; + else + d = -prow[i] * g; + if ((d < 0) && (!Basis[i]) && (Upbo[i] > 0)) { + if (Lower[i]) + quot = -drow[i] / (REAL)d; else - d = -prow[i] * g; - if((d < 0) && (!Basis[i]) && (Upbo[i] > 0)) - { - if(Lower[i]) - quot = -drow[i] / (REAL) d; - else - quot = drow[i] / (REAL) d; - if(quot < theta) - { - theta = quot; - pivot = d; - (*colnr) = i; - } - else if((quot == theta) && (my_abs(d) > my_abs(pivot))) - { - pivot = d; - (*colnr) = i; - } - } + quot = drow[i] / (REAL)d; + if (quot < theta) { + theta = quot; + pivot = d; + (*colnr) = i; + } else if ((quot == theta) && (my_abs(d) > my_abs(pivot))) { + pivot = d; + (*colnr) = i; + } } - if(Lp->trace) - fprintf(stderr, "col_dual:%7d, pivot element: % 18.10f\n", (*colnr), - prow[(*colnr)]); + } + if (Lp->trace) + fprintf(stderr, "col_dual:%7d, pivot element: % 18.10f\n", (*colnr), prow[(*colnr)]); - if((*colnr)>0) - Doiter = TRUE; + if ((*colnr) > 0) Doiter = TRUE; - return((*colnr) > 0); + return ((*colnr) > 0); } /* coldual */ -static void iteration(int row_nr, - int varin, - REAL *theta, - REAL up, - short *minit, - short *low, - short primal, - REAL *pcol) -{ - int i, k, varout; +static void iteration(int row_nr, int varin, REAL *theta, REAL up, short *minit, short *low, + short primal, REAL *pcol) { + int i, k, varout; REAL f; REAL pivot; - + Lp->iter++; (*minit) = (*theta) > (up + Epsb); - if((*minit)) - { - (*theta) = up; - (*low) = !(*low); - } + if ((*minit)) { + (*theta) = up; + (*low) = !(*low); + } k = Eta_col_end[Eta_size + 1]; pivot = Eta_value[k - 1]; - for(i = Eta_col_end[Eta_size]; i < k; i++) - { - f = Rhs[Eta_row_nr[i]] - (*theta) * Eta_value[i]; - my_round(f, Epsb); - Rhs[Eta_row_nr[i]] = f; + for (i = Eta_col_end[Eta_size]; i < k; i++) { + f = Rhs[Eta_row_nr[i]] - (*theta) * Eta_value[i]; + my_round(f, Epsb); + Rhs[Eta_row_nr[i]] = f; + } + if (!(*minit)) { + Rhs[row_nr] = (*theta); + varout = Bas[row_nr]; + Bas[row_nr] = varin; + Basis[varout] = FALSE; + Basis[varin] = TRUE; + if (primal && pivot < 0) Lower[varout] = FALSE; + if (!(*low) && up < Infinite) { + (*low) = TRUE; + Rhs[row_nr] = up - Rhs[row_nr]; + for (i = Eta_col_end[Eta_size]; i < k; i++) Eta_value[i] = -Eta_value[i]; } - if(!(*minit)) - { - Rhs[row_nr] = (*theta); - varout = Bas[row_nr]; - Bas[row_nr] = varin; - Basis[varout] = FALSE; - Basis[varin] = TRUE; - if(primal && pivot < 0) - Lower[varout] = FALSE; - if(!(*low) && up < Infinite) - { - (*low) = TRUE; - Rhs[row_nr] = up - Rhs[row_nr]; - for(i = Eta_col_end[Eta_size]; i < k; i++) - Eta_value[i] = -Eta_value[i]; - } - addetacol(); - Num_inv++; - } - if(Lp->trace) - { - fprintf(stderr, "Theta = %16.4g ", (*theta)); - if((*minit)) - { - if(!Lower[varin]) - fprintf(stderr, - "Iteration:%6d, variable%5d changed from 0 to its upper bound of %12f\n", - Lp->iter, varin, Upbo[varin]); - else - fprintf(stderr, - "Iteration:%6d, variable%5d changed its upper bound of %12f to 0\n", - Lp->iter, varin, Upbo[varin]); - } + addetacol(); + Num_inv++; + } + if (Lp->trace) { + fprintf(stderr, "Theta = %16.4g ", (*theta)); + if ((*minit)) { + if (!Lower[varin]) + fprintf(stderr, "Iteration:%6d, variable%5d changed from 0 to its upper bound of %12f\n", + Lp->iter, varin, Upbo[varin]); else - fprintf(stderr, - "Iteration:%6d, variable%5d entered basis at:% 18.10f\n", - Lp->iter, varin, Rhs[row_nr]); - if(!primal) - { - f = 0; - for(i = 1; i <= Rows; i++) - if(Rhs[i] < 0) - f -= Rhs[i]; - else - if(Rhs[i] > Upbo[Bas[i]]) - f += Rhs[i] - Upbo[Bas[i]]; - fprintf(stderr, "feasibility gap of this basis:% 18.10f\n", - (double)f); - } - else - fprintf(stderr, - "objective function value of this feasible basis: % 18.10f\n", - (double)Rhs[0]); - } + fprintf(stderr, "Iteration:%6d, variable%5d changed its upper bound of %12f to 0\n", + Lp->iter, varin, Upbo[varin]); + } else + fprintf(stderr, "Iteration:%6d, variable%5d entered basis at:% 18.10f\n", Lp->iter, varin, + Rhs[row_nr]); + if (!primal) { + f = 0; + for (i = 1; i <= Rows; i++) + if (Rhs[i] < 0) + f -= Rhs[i]; + else if (Rhs[i] > Upbo[Bas[i]]) + f += Rhs[i] - Upbo[Bas[i]]; + fprintf(stderr, "feasibility gap of this basis:% 18.10f\n", (double)f); + } else + fprintf(stderr, "objective function value of this feasible basis: % 18.10f\n", + (double)Rhs[0]); + } } /* iteration */ - -static int solvelp(void) -{ - int i, j, iter, varnr; - REAL f, theta; - short primal; - REAL *drow, *prow, *Pcol; - short minit; - int colnr, row_nr; - short *test; +static int solvelp(void) { + int i, j, iter, varnr; + REAL f, theta; + short primal; + REAL *drow, *prow, *Pcol; + short minit; + int colnr, row_nr; + short *test; CALLOC(drow, Sum + 1, REAL); CALLOC(prow, Sum + 1, REAL); CALLOC(Pcol, Rows + 1, REAL); - CALLOC(test, Sum +1, short); + CALLOC(test, Sum + 1, short); Lp->iter = 0; minit = FALSE; @@ -935,630 +751,503 @@ static int solvelp(void) Doiter = FALSE; i = 0; primal = TRUE; - while(i != Rows && primal) - { - i++; - primal = Rhs[i] >= 0 && Rhs[i] <= Upbo[Bas[i]]; - } - if(Lp->trace) - { - if(primal) - fprintf(stderr, "Start at feasible basis\n"); - else - fprintf(stderr, "Start at infeasible basis\n"); - } - if(!primal) - { - drow[0] = 1; - for(i = 1; i <= Rows; i++) - drow[i] = 0; - Extrad = 0; - for(i = 1; i <= Columns; i++) - { - varnr = Rows + i; - drow[varnr] = 0; - for(j = Col_end[i - 1]; j < Col_end[i]; j++) - if(drow[Mat[j].row_nr] != 0) - drow[varnr] += drow[Mat[j].row_nr] * Mat[j].value; - if(drow[varnr] < Extrad) - Extrad = drow[varnr]; - } - } - else + while (i != Rows && primal) { + i++; + primal = Rhs[i] >= 0 && Rhs[i] <= Upbo[Bas[i]]; + } + if (Lp->trace) { + if (primal) + fprintf(stderr, "Start at feasible basis\n"); + else + fprintf(stderr, "Start at infeasible basis\n"); + } + if (!primal) { + drow[0] = 1; + for (i = 1; i <= Rows; i++) drow[i] = 0; Extrad = 0; - if(Lp->trace) - fprintf(stderr, "Extrad = %f\n", Extrad); + for (i = 1; i <= Columns; i++) { + varnr = Rows + i; + drow[varnr] = 0; + for (j = Col_end[i - 1]; j < Col_end[i]; j++) + if (drow[Mat[j].row_nr] != 0) drow[varnr] += drow[Mat[j].row_nr] * Mat[j].value; + if (drow[varnr] < Extrad) Extrad = drow[varnr]; + } + } else + Extrad = 0; + if (Lp->trace) fprintf(stderr, "Extrad = %f\n", Extrad); minit = FALSE; - while(Status == RUNNING) - { - Doiter = FALSE; - DoInvert = FALSE; + while (Status == RUNNING) { + Doiter = FALSE; + DoInvert = FALSE; - if(primal) - { - if(colprim(&colnr, minit, drow)) - { - setpivcol(Lower[colnr], colnr, Pcol); - if(rowprim(colnr, &row_nr, &theta, Pcol)) - condensecol(row_nr, Pcol); - - } - } - else /* not primal */ - { - if(!minit) - rowdual(&row_nr); - if(row_nr > 0 ) - { - if(coldual(row_nr, &colnr, minit, prow, drow)) - { - setpivcol(Lower[colnr], colnr, Pcol); - /* getting div by zero here ... MB */ - if(Pcol[row_nr] == 0) - { - fprintf(stderr, - "An attempt was made to divide by zero (Pcol[%d])\n", - row_nr); - fprintf(stderr, - "This indicates numerical instability\n"); - Doiter = FALSE; - if(!JustInverted) - { - fprintf(stderr, "Reinverting Eta\n"); - DoInvert = TRUE; - } - else - { - fprintf(stderr, "Can't reinvert, failure\n"); - Status = FAILURE; - } - } - else - { - condensecol(row_nr, Pcol); - f = Rhs[row_nr] - Upbo[Bas[row_nr]]; - if(f > 0) - { - theta = f / (REAL) Pcol[row_nr]; - if(theta <= Upbo[colnr]) - Lower[Bas[row_nr]] = !Lower[Bas[row_nr]]; - } - else /* f <= 0 */ - theta = Rhs[row_nr] / (REAL) Pcol[row_nr]; - } - } - else - Status = INFEASIBLE; - } - else - { - primal = TRUE; - Doiter = FALSE; - Extrad = 0; + if (primal) { + if (colprim(&colnr, minit, drow)) { + setpivcol(Lower[colnr], colnr, Pcol); + if (rowprim(colnr, &row_nr, &theta, Pcol)) condensecol(row_nr, Pcol); + } + } else /* not primal */ + { + if (!minit) rowdual(&row_nr); + if (row_nr > 0) { + if (coldual(row_nr, &colnr, minit, prow, drow)) { + setpivcol(Lower[colnr], colnr, Pcol); + /* getting div by zero here ... MB */ + if (Pcol[row_nr] == 0) { + fprintf(stderr, "An attempt was made to divide by zero (Pcol[%d])\n", row_nr); + fprintf(stderr, "This indicates numerical instability\n"); + Doiter = FALSE; + if (!JustInverted) { + fprintf(stderr, "Reinverting Eta\n"); DoInvert = TRUE; - } - } - if(Doiter) - iteration(row_nr, colnr, &theta, Upbo[colnr], &minit, &Lower[colnr], - primal, Pcol); - if(Num_inv >= Lp->max_num_inv) + } else { + fprintf(stderr, "Can't reinvert, failure\n"); + Status = FAILURE; + } + } else { + condensecol(row_nr, Pcol); + f = Rhs[row_nr] - Upbo[Bas[row_nr]]; + if (f > 0) { + theta = f / (REAL)Pcol[row_nr]; + if (theta <= Upbo[colnr]) Lower[Bas[row_nr]] = !Lower[Bas[row_nr]]; + } else /* f <= 0 */ + theta = Rhs[row_nr] / (REAL)Pcol[row_nr]; + } + } else + Status = INFEASIBLE; + } else { + primal = TRUE; + Doiter = FALSE; + Extrad = 0; DoInvert = TRUE; - if(DoInvert) - { - if(Lp->print_at_invert) - fprintf(stderr, "Inverting: Primal = %d\n", primal); - invert(); - } - } + } + } + if (Doiter) iteration(row_nr, colnr, &theta, Upbo[colnr], &minit, &Lower[colnr], primal, Pcol); + if (Num_inv >= Lp->max_num_inv) DoInvert = TRUE; + if (DoInvert) { + if (Lp->print_at_invert) fprintf(stderr, "Inverting: Primal = %d\n", primal); + invert(); + } + } Lp->total_iter += Lp->iter; - + free(drow); free(prow); free(Pcol); free(test); - return(Status); + return (Status); } /* solvelp */ - -static short is_int(REAL value) -{ - REAL tmp; +static short is_int(REAL value) { + REAL tmp; tmp = value - (REAL)floor((double)value); - if(tmp < Epsilon) - return(TRUE); - if(tmp > (1 - Epsilon)) - return(TRUE); - return(FALSE); + if (tmp < Epsilon) return (TRUE); + if (tmp > (1 - Epsilon)) return (TRUE); + return (FALSE); } /* is_int */ -static void construct_solution(REAL *sol) -{ - int i, j, basi; - REAL f; +static void construct_solution(REAL *sol) { + int i, j, basi; + REAL f; /* zero all results of rows */ memset(sol, '\0', (Rows + 1) * sizeof(REAL)); - if(Lp->scaling_used) - { - for(i = Rows + 1; i <= Sum; i++) - sol[i] = Lowbo[i] * Lp->scale[i]; - for(i = 1; i <= Rows; i++) - { - basi = Bas[i]; - if(basi > Rows) - sol[basi] += Rhs[i] * Lp->scale[basi]; - } - for(i = Rows + 1; i <= Sum; i++) - if(!Basis[i] && !Lower[i]) - sol[i] += Upbo[i] * Lp->scale[i]; + if (Lp->scaling_used) { + for (i = Rows + 1; i <= Sum; i++) sol[i] = Lowbo[i] * Lp->scale[i]; + for (i = 1; i <= Rows; i++) { + basi = Bas[i]; + if (basi > Rows) sol[basi] += Rhs[i] * Lp->scale[basi]; + } + for (i = Rows + 1; i <= Sum; i++) + if (!Basis[i] && !Lower[i]) sol[i] += Upbo[i] * Lp->scale[i]; - for(j = 1; j <= Columns; j++) - { - f = sol[Rows + j]; - if(f != 0) - for(i = Col_end[j - 1]; i < Col_end[j]; i++) - sol[Mat[i].row_nr] += (f / Lp->scale[Rows+j]) - * (Mat[i].value / Lp->scale[Mat[i].row_nr]); - } - - for(i = 0; i <= Rows; i++) - { - if(my_abs(sol[i]) < Epsb) - sol[i] = 0; - else - if(Lp->ch_sign[i]) - sol[i] = -sol[i]; - } + for (j = 1; j <= Columns; j++) { + f = sol[Rows + j]; + if (f != 0) + for (i = Col_end[j - 1]; i < Col_end[j]; i++) + sol[Mat[i].row_nr] += + (f / Lp->scale[Rows + j]) * (Mat[i].value / Lp->scale[Mat[i].row_nr]); } - else - { - for(i = Rows + 1; i <= Sum; i++) - sol[i] = Lowbo[i]; - for(i = 1; i <= Rows; i++) - { - basi = Bas[i]; - if(basi > Rows) - sol[basi] += Rhs[i]; - } - for(i = Rows + 1; i <= Sum; i++) - if(!Basis[i] && !Lower[i]) - sol[i] += Upbo[i]; - for(j = 1; j <= Columns; j++) - { - f = sol[Rows + j]; - if(f != 0) - for(i = Col_end[j - 1]; i < Col_end[j]; i++) - sol[Mat[i].row_nr] += f * Mat[i].value; - } - - for(i = 0; i <= Rows; i++) - { - if(my_abs(sol[i]) < Epsb) - sol[i] = 0; - else - if(Lp->ch_sign[i]) - sol[i] = -sol[i]; - } + + for (i = 0; i <= Rows; i++) { + if (my_abs(sol[i]) < Epsb) + sol[i] = 0; + else if (Lp->ch_sign[i]) + sol[i] = -sol[i]; } + } else { + for (i = Rows + 1; i <= Sum; i++) sol[i] = Lowbo[i]; + for (i = 1; i <= Rows; i++) { + basi = Bas[i]; + if (basi > Rows) sol[basi] += Rhs[i]; + } + for (i = Rows + 1; i <= Sum; i++) + if (!Basis[i] && !Lower[i]) sol[i] += Upbo[i]; + for (j = 1; j <= Columns; j++) { + f = sol[Rows + j]; + if (f != 0) + for (i = Col_end[j - 1]; i < Col_end[j]; i++) sol[Mat[i].row_nr] += f * Mat[i].value; + } + + for (i = 0; i <= Rows; i++) { + if (my_abs(sol[i]) < Epsb) + sol[i] = 0; + else if (Lp->ch_sign[i]) + sol[i] = -sol[i]; + } + } } /* construct_solution */ -static void calculate_duals(void) -{ +static void calculate_duals(void) { int i; /* initialise */ - for(i = 1; i <= Rows; i++) - Lp->duals[i] = 0; + for (i = 1; i <= Rows; i++) Lp->duals[i] = 0; Lp->duals[0] = 1; btran(Lp->duals); - if(Lp->scaling_used) - for(i = 1; i <= Rows; i++) - Lp->duals[i] *= Lp->scale[i]/Lp->scale[0]; + if (Lp->scaling_used) + for (i = 1; i <= Rows; i++) Lp->duals[i] *= Lp->scale[i] / Lp->scale[0]; /* the dual values are the reduced costs of the slacks */ /* When the slack is at its upper bound, change the sign. Can this happen? */ - for(i = 1; i <= Rows; i++) - { - if(Lp->basis[i]) - Lp->duals[i] = 0; - else if( Lp->ch_sign[0] == Lp->ch_sign[i]) - Lp->duals[i] = -Lp->duals[i]; - } + for (i = 1; i <= Rows; i++) { + if (Lp->basis[i]) + Lp->duals[i] = 0; + else if (Lp->ch_sign[0] == Lp->ch_sign[i]) + Lp->duals[i] = -Lp->duals[i]; + } } -int milpsolve(sstate *st, - REAL *upbo, - REAL *lowbo, - short *sbasis, - short *slower, - int *sbas) -{ +int milpsolve(sstate *st, REAL *upbo, REAL *lowbo, short *sbasis, short *slower, int *sbas) { int i, j, failure, notint, is_worse; REAL theta, tmpreal; - /* First, check for "time-out", time to give control back to lisp */ - if(st->next) st = st->next; + if (st->next) + st = st->next; else - for (i=0; i< 20; i++) - { /* Need more state-saving space, so create 20 more. */ - sstate * newst; - newst = (sstate *)malloc(sizeof(sstate)); - if (!st) ERROR(ERR_ST); - newst->next = st->next; - st->next = newst; - newst->saved = newst->notint = 0; - } + for (i = 0; i < 20; i++) { /* Need more state-saving space, so create 20 more. */ + sstate *newst; + newst = (sstate *)malloc(sizeof(sstate)); + if (!st) ERROR(ERR_ST); + newst->next = st->next; + st->next = newst; + newst->saved = newst->notint = 0; + } - if (st->saved) - { if (st->saved == ST_SOLN) { st->saved = 0; return(OPTIMAL); } } - else if (SolveCount++ > 100) return(TIMEOUT); /* Time out every 100 LP solves */ - else if ((KBDEventFlg>0) && *KEYBUFFERING68k == ATOM_T) - return(TIMEOUT); /* Time out on key/mouse clicks */ + if (st->saved) { + if (st->saved == ST_SOLN) { + st->saved = 0; + return (OPTIMAL); + } + } else if (SolveCount++ > 100) + return (TIMEOUT); /* Time out every 100 LP solves */ + else if ((KBDEventFlg > 0) && *KEYBUFFERING68k == ATOM_T) + return (TIMEOUT); /* Time out on key/mouse clicks */ #ifdef DOS - else if (currentmouse->Cursor.Moved) return(TIMEOUT); /* Time out if mouse moves in DOS */ -#endif /* DOS */ + else if (currentmouse->Cursor.Moved) + return (TIMEOUT); /* Time out if mouse moves in DOS */ +#endif /* DOS */ - if(Break_bb) - return(BREAK_BB); + if (Break_bb) return (BREAK_BB); Level++; Lp->total_nodes++; - if(Level > Lp->max_level) - Lp->max_level = Level; + if (Level > Lp->max_level) Lp->max_level = Level; - if (! st->saved) - { /* We're coming into this fresh, rather than returnin from a TIMEOUT. */ - /* make fresh copies of upbo, lowbo, rh as solving changes them */ - memcpy(Upbo, upbo, (Sum + 1) * sizeof(REAL)); - memcpy(Lowbo, lowbo, (Sum + 1) * sizeof(REAL)); - memcpy(Basis, sbasis, (Sum + 1) * sizeof(short)); - memcpy(Lower, slower, (Sum + 1) * sizeof(short)); - memcpy(Bas, sbas, (Rows + 1) * sizeof(int)); - memcpy(Rh, Orig_rh, (Rows + 1) * sizeof(REAL)); + if (!st->saved) { /* We're coming into this fresh, rather than returnin from a TIMEOUT. */ + /* make fresh copies of upbo, lowbo, rh as solving changes them */ + memcpy(Upbo, upbo, (Sum + 1) * sizeof(REAL)); + memcpy(Lowbo, lowbo, (Sum + 1) * sizeof(REAL)); + memcpy(Basis, sbasis, (Sum + 1) * sizeof(short)); + memcpy(Lower, slower, (Sum + 1) * sizeof(short)); + memcpy(Bas, sbas, (Rows + 1) * sizeof(int)); + memcpy(Rh, Orig_rh, (Rows + 1) * sizeof(REAL)); - if(Lp->anti_degen) - { - for(i = 1; i <= Columns; i++) - { - tmpreal = (REAL) (rand() % 100 * 0.00001); - if(tmpreal > Epsb) - Lowbo[i + Rows] -= tmpreal; - tmpreal = (REAL) (rand() % 100 * 0.00001); - if(tmpreal > Epsb) - Upbo[i + Rows] += tmpreal; - } + if (Lp->anti_degen) { + for (i = 1; i <= Columns; i++) { + tmpreal = (REAL)(rand() % 100 * 0.00001); + if (tmpreal > Epsb) Lowbo[i + Rows] -= tmpreal; + tmpreal = (REAL)(rand() % 100 * 0.00001); + if (tmpreal > Epsb) Upbo[i + Rows] += tmpreal; + } Lp->eta_valid = FALSE; } - if(!Lp->eta_valid) - { - for(i = 1; i <= Columns; i++) - if(Lowbo[Rows + i] != 0) - { - theta = Lowbo[ Rows + i]; - if(Upbo[Rows + i]eta_valid) { + for (i = 1; i <= Columns; i++) + if (Lowbo[Rows + i] != 0) { + theta = Lowbo[Rows + i]; + if (Upbo[Rows + i] < Infinite) Upbo[Rows + i] -= theta; + for (j = Col_end[i - 1]; j < Col_end[i]; j++) Rh[Mat[j].row_nr] -= theta * Mat[j].value; + } invert(); Lp->eta_valid = TRUE; } - failure = solvelp(); + failure = solvelp(); - if(Lp->anti_degen) - { - memcpy(Upbo, upbo, (Sum + 1) * sizeof(REAL)); - memcpy(Lowbo, lowbo, (Sum + 1) * sizeof(REAL)); - memcpy(Rh, Orig_rh, (Rows + 1) * sizeof(REAL)); + if (Lp->anti_degen) { + memcpy(Upbo, upbo, (Sum + 1) * sizeof(REAL)); + memcpy(Lowbo, lowbo, (Sum + 1) * sizeof(REAL)); + memcpy(Rh, Orig_rh, (Rows + 1) * sizeof(REAL)); - for(i = 1; i <= Columns; i++) - if(Lowbo[Rows + i] != 0) - { - theta = Lowbo[ Rows + i]; - if(Upbo[Rows + i]eta_valid = TRUE; failure = solvelp(); } - if(failure == INFEASIBLE && Lp->verbose) - fprintf(stderr, "level%4d INF\n", Level); - } - else failure = OPTIMAL; /* Coming back thru after a timeout; we got OPTIMAL last time, so do it again. */ + if (failure == INFEASIBLE && Lp->verbose) fprintf(stderr, "level%4d INF\n", Level); + } else + failure = + OPTIMAL; /* Coming back thru after a timeout; we got OPTIMAL last time, so do it again. */ - - if(failure == OPTIMAL) /* there is a solution */ - { - if (!st->saved) - { + if (failure == OPTIMAL) /* there is a solution */ + { + if (!st->saved) { construct_solution(Solution); - /* if this solution is worse than the best sofar, this branch must die */ - if(Maximise) - is_worse = Solution[0] <= Best_solution[0]; - else /* minimising! */ - is_worse = Solution[0] >= Best_solution[0]; + if (Maximise) + is_worse = Solution[0] <= Best_solution[0]; + else /* minimising! */ + is_worse = Solution[0] >= Best_solution[0]; - if(is_worse) - { - if(Lp->verbose) - fprintf(stderr, "level%4d OPT NOB value %f bound %f\n", - Level, Solution[0], Best_solution[0]); - Level--; - return(MILP_FAIL); - } + if (is_worse) { + if (Lp->verbose) + fprintf(stderr, "level%4d OPT NOB value %f bound %f\n", Level, Solution[0], + Best_solution[0]); + Level--; + return (MILP_FAIL); + } /* check if solution contains enough ints */ st->notint = notint = 0; - if(Lp->bb_rule == FIRST_NI) - { + if (Lp->bb_rule == FIRST_NI) { + notint = 0; + i = Rows + 1; + while (i <= Sum && notint == 0) { + if (Must_be_int[i] && !is_int(Solution[i])) + if (lowbo[i] == upbo[i]) /* this var is already fixed */ + { + fprintf( + stderr, + "Warning: integer var %d is already fixed at %d, but has non-integer value %g\n", + i - Rows, (int)lowbo[i], Solution[i]); + fprintf(stderr, "Perhaps the -e option should be used\n"); + } else + st->notint = notint = i; + i++; + } + } + if (Lp->bb_rule == RAND_NI) { + int nr_not_int, select_not_int; + nr_not_int = 0; + for (i = Rows + 1; i <= Sum; i++) + if (Must_be_int[i] && !is_int(Solution[i])) nr_not_int++; + if (nr_not_int == 0) notint = 0; + else { + select_not_int = (rand() % nr_not_int) + 1; i = Rows + 1; - while(i <= Sum && notint == 0) - { - if(Must_be_int[i] && !is_int(Solution[i])) - if(lowbo[i] == upbo[i]) /* this var is already fixed */ - { - fprintf(stderr, - "Warning: integer var %d is already fixed at %d, but has non-integer value %g\n", - i - Rows, (int)lowbo[i], Solution[i]); - fprintf(stderr, "Perhaps the -e option should be used\n"); - } - else - st->notint = notint = i; - i++; - } + while (select_not_int > 0) { + if (Must_be_int[i] && !is_int(Solution[i])) select_not_int--; + i++; + } + st->notint = notint = i - 1; } - if(Lp->bb_rule == RAND_NI) - { - int nr_not_int, select_not_int; - nr_not_int = 0; - for(i = Rows + 1; i <= Sum; i++) - if(Must_be_int[i] && !is_int(Solution[i])) - nr_not_int++; - if(nr_not_int == 0) - notint = 0; - else - { - select_not_int=(rand() % nr_not_int) + 1; - i = Rows + 1; - while(select_not_int > 0) - { - if(Must_be_int[i] && !is_int(Solution[i])) - select_not_int--; - i++; - } - st->notint = notint = i - 1; - } - } - } - else notint = st->notint; /* Coming back in, use old value. */ + } + } else + notint = st->notint; /* Coming back in, use old value. */ - if(Lp->verbose == TRUE) - if(notint) - fprintf(stderr, "level %3d OPT value %f\n", Level, Solution[0]); + if (Lp->verbose == TRUE) + if (notint) + fprintf(stderr, "level %3d OPT value %f\n", Level, Solution[0]); + else + fprintf(stderr, "level %3d OPT INT value %f\n", Level, Solution[0]); + + if (notint) /* there is at least one value not yet int */ + { + /* set up two new problems */ + REAL *new_upbo, *new_lowbo; + REAL new_bound; + short *new_lower, *new_basis; + int *new_bas; + int resone, restwo; + + /* allocate room for them */ + MALLOC(new_upbo, Sum + 1, REAL); + MALLOC(new_lowbo, Sum + 1, REAL); + MALLOC(new_lower, Sum + 1, short); + MALLOC(new_basis, Sum + 1, short); + MALLOC(new_bas, Rows + 1, int); + memcpy(new_upbo, upbo, (Sum + 1) * sizeof(REAL)); + memcpy(new_lowbo, lowbo, (Sum + 1) * sizeof(REAL)); + memcpy(new_lower, Lower, (Sum + 1) * sizeof(short)); + memcpy(new_basis, Basis, (Sum + 1) * sizeof(short)); + memcpy(new_bas, Bas, (Rows + 1) * sizeof(int)); + + if (Floor_first) { + if (st->saved) + new_bound = st->bound; else - fprintf(stderr, "level %3d OPT INT value %f\n", Level, Solution[0]); + st->bound = new_bound = ceil(Solution[notint]) - 1; + /* this bound might conflict */ + if (st->saved >= ST_HI) + resone = st->res1; /* We got the upper bound earlier; skip lower */ + else if (new_bound < lowbo[notint]) { + resone = MILP_FAIL; + } else /* bound feasible */ + { + new_upbo[notint] = new_bound; + Lp->eta_valid = FALSE; + st->saved = ST_LO; + resone = milpsolve(st, new_upbo, lowbo, new_basis, new_lower, new_bas); + Lp->eta_valid = FALSE; + st->res1 = resone; + if ((resone == INT_SOLN) || (resone == TIMEOUT)) { + Level--; + free(new_upbo); + free(new_lowbo); + free(new_lower); + free(new_basis); + free(new_bas); + return resone; + } + } + new_bound += 1; + if (new_bound > upbo[notint]) { + restwo = MILP_FAIL; + } else /* bound feasible */ + { + new_lowbo[notint] = new_bound; + st->saved = ST_HI; + Lp->eta_valid = FALSE; + restwo = milpsolve(st, upbo, new_lowbo, new_basis, new_lower, new_bas); + Lp->eta_valid = FALSE; + st->res2 = restwo; + if ((restwo == INT_SOLN) || (restwo == TIMEOUT)) { + Level--; + free(new_upbo); + free(new_lowbo); + free(new_lower); + free(new_basis); + free(new_bas); + return restwo; + } + } + } else /* take ceiling first */ + { + new_bound = ceil(Solution[notint]); + /* this bound might conflict */ + if (new_bound > upbo[notint]) { + resone = MILP_FAIL; + } else /* bound feasible */ + { + new_lowbo[notint] = new_bound; + Lp->eta_valid = FALSE; + resone = milpsolve(st, upbo, new_lowbo, new_basis, new_lower, new_bas); + Lp->eta_valid = FALSE; + } + new_bound -= 1; + if (new_bound < lowbo[notint]) { + restwo = MILP_FAIL; + } else /* bound feasible */ + { + new_upbo[notint] = new_bound; + Lp->eta_valid = FALSE; + restwo = milpsolve(st, new_upbo, lowbo, new_basis, new_lower, new_bas); + Lp->eta_valid = FALSE; + } + } + if (resone && restwo) /* both failed and must have been infeasible */ + failure = INFEASIBLE; + else + failure = OPTIMAL; - if(notint) /* there is at least one value not yet int */ - { - /* set up two new problems */ - REAL *new_upbo, *new_lowbo; - REAL new_bound; - short *new_lower,*new_basis; - int *new_bas; - int resone, restwo; + free(new_upbo); + free(new_lowbo); + free(new_basis); + free(new_lower); + free(new_bas); + } else /* all required values are int */ + { + if (Maximise) + is_worse = Solution[0] < Best_solution[0]; + else + is_worse = Solution[0] > Best_solution[0]; - /* allocate room for them */ - MALLOC(new_upbo, Sum + 1, REAL); - MALLOC(new_lowbo, Sum + 1, REAL); - MALLOC(new_lower, Sum + 1, short); - MALLOC(new_basis, Sum + 1, short); - MALLOC(new_bas, Rows + 1, int); - memcpy(new_upbo, upbo, (Sum + 1) * sizeof(REAL)); - memcpy(new_lowbo, lowbo, (Sum + 1) * sizeof(REAL)); - memcpy(new_lower, Lower, (Sum + 1) * sizeof(short)); - memcpy(new_basis, Basis, (Sum + 1) * sizeof(short)); - memcpy(new_bas, Bas, (Rows +1) * sizeof(int)); - - - if(Floor_first) - { - if (st->saved) new_bound = st->bound; - else st->bound = new_bound = ceil(Solution[notint]) - 1; - /* this bound might conflict */ - if (st->saved >= ST_HI) resone = st->res1; /* We got the upper bound earlier; skip lower */ - else if(new_bound < lowbo[notint]) - { - resone = MILP_FAIL; - } - else /* bound feasible */ - { - new_upbo[notint] = new_bound; - Lp->eta_valid = FALSE; - st->saved = ST_LO; - resone = milpsolve(st, new_upbo, lowbo, new_basis, new_lower, - new_bas); - Lp->eta_valid = FALSE; - st->res1 = resone; - if ((resone == INT_SOLN) || (resone == TIMEOUT)) - { - Level--; - free(new_upbo); - free(new_lowbo); - free(new_lower); - free(new_basis); - free(new_bas); - return resone; - } - - } - new_bound += 1; - if(new_bound > upbo[notint]) - { - restwo = MILP_FAIL; - } - else /* bound feasible */ - { - new_lowbo[notint] = new_bound; - st->saved = ST_HI; - Lp->eta_valid = FALSE; - restwo = milpsolve(st, upbo, new_lowbo, new_basis, new_lower, - new_bas); - Lp->eta_valid = FALSE; - st->res2 = restwo; - if ((restwo == INT_SOLN) || (restwo == TIMEOUT)) - { - Level--; - free(new_upbo); - free(new_lowbo); - free(new_lower); - free(new_basis); - free(new_bas); - return restwo; - } - - } - } - else /* take ceiling first */ - { - new_bound = ceil(Solution[notint]); - /* this bound might conflict */ - if(new_bound > upbo[notint]) - { - resone = MILP_FAIL; - } - else /* bound feasible */ - { - new_lowbo[notint] = new_bound; - Lp->eta_valid = FALSE; - resone = milpsolve(st, upbo, new_lowbo, new_basis, new_lower, - new_bas); - Lp->eta_valid = FALSE; - } - new_bound -= 1; - if(new_bound < lowbo[notint]) - { - restwo = MILP_FAIL; - } - else /* bound feasible */ - { - new_upbo[notint] = new_bound; - Lp->eta_valid = FALSE; - restwo = milpsolve(st, new_upbo, lowbo, new_basis, new_lower, - new_bas); - Lp->eta_valid = FALSE; - } - } - if(resone && restwo) /* both failed and must have been infeasible */ - failure = INFEASIBLE; - else - failure = OPTIMAL; - - free(new_upbo); - free(new_lowbo); - free(new_basis); - free(new_lower); - free(new_bas); - } - else /* all required values are int */ - { - - if(Maximise) - is_worse = Solution[0] < Best_solution[0]; - else - is_worse = Solution[0] > Best_solution[0]; - - if(!is_worse) /* Current solution better */ - { - if(Lp->debug || (Lp->verbose && !Lp->print_sol)) - fprintf(stderr, - "*** new best solution: old: %g, new: %g ***\n", - (double)Best_solution[0], (double)Solution[0]); - memcpy(Best_solution, Solution, (Sum + 1) * sizeof(REAL)); - calculate_duals(); - if(Lp->print_sol) - print_solution(Lp); - if(Lp->break_at_int) - { - if(Maximise && (Best_solution[0] > Lp->break_value)) - Break_bb = TRUE; - if(!Maximise && (Best_solution[0] < Lp->break_value)) - Break_bb = TRUE; - } - st->saved = INT_SOLN; /* Tell caller we found -a- solution */ - failure = INT_SOLN; /* & remember that fact for next time. */ - } - } + if (!is_worse) /* Current solution better */ + { + if (Lp->debug || (Lp->verbose && !Lp->print_sol)) + fprintf(stderr, "*** new best solution: old: %g, new: %g ***\n", (double)Best_solution[0], + (double)Solution[0]); + memcpy(Best_solution, Solution, (Sum + 1) * sizeof(REAL)); + calculate_duals(); + if (Lp->print_sol) print_solution(Lp); + if (Lp->break_at_int) { + if (Maximise && (Best_solution[0] > Lp->break_value)) Break_bb = TRUE; + if (!Maximise && (Best_solution[0] < Lp->break_value)) Break_bb = TRUE; + } + st->saved = INT_SOLN; /* Tell caller we found -a- solution */ + failure = INT_SOLN; /* & remember that fact for next time. */ + } } + } /* failure can have the values OPTIMAL, UNBOUNDED and INFEASIBLE. */ /* INT_SOLN, TIMEOUT, or MILP_FAIL */ Level--; st->saved = 0; /* We're done at this level, so mark the ST empty. */ - return(failure); + return (failure); } /* milpsolve */ - - -int solve(lprec *lp) -{ +int solve(lprec *lp) { int result, i; - if(!lp->active) - set_globals(lp); + if (!lp->active) set_globals(lp); - lp->total_iter = 0; - lp->max_level = 1; + lp->total_iter = 0; + lp->max_level = 1; lp->total_nodes = 0; - if(Isvalid(lp)) - { - if(Maximise && lp->obj_bound == Infinite) - Best_solution[0]=-Infinite; - else if(!Maximise && lp->obj_bound==-Infinite) - Best_solution[0] = Infinite; - else - Best_solution[0] = lp->obj_bound; + if (Isvalid(lp)) { + if (Maximise && lp->obj_bound == Infinite) + Best_solution[0] = -Infinite; + else if (!Maximise && lp->obj_bound == -Infinite) + Best_solution[0] = Infinite; + else + Best_solution[0] = lp->obj_bound; - Level = 0; + Level = 0; - if(!lp->basis_valid) - { - for(i = 0; i <= lp->rows; i++) - { - lp->basis[i] = TRUE; - lp->bas[i] = i; - } - for(i = lp->rows+1; i <= lp->sum; i++) - lp->basis[i] = FALSE; - for(i = 0; i <= lp->sum; i++) - lp->lower[i] = TRUE; - lp->basis_valid = TRUE; - } - - lp->eta_valid = FALSE; - Break_bb = FALSE; - result = milpsolve(lp->solve_states, Orig_upbo, Orig_lowbo, Basis, Lower, Bas); - lp->eta_size = Eta_size; - lp->eta_alloc = Eta_alloc; - lp->num_inv = Num_inv; + if (!lp->basis_valid) { + for (i = 0; i <= lp->rows; i++) { + lp->basis[i] = TRUE; + lp->bas[i] = i; + } + for (i = lp->rows + 1; i <= lp->sum; i++) lp->basis[i] = FALSE; + for (i = 0; i <= lp->sum; i++) lp->lower[i] = TRUE; + lp->basis_valid = TRUE; } - return(result); + + lp->eta_valid = FALSE; + Break_bb = FALSE; + result = milpsolve(lp->solve_states, Orig_upbo, Orig_lowbo, Basis, Lower, Bas); + lp->eta_size = Eta_size; + lp->eta_alloc = Eta_alloc; + lp->num_inv = Num_inv; + } + return (result); } /* * * * lag_solve used to be here * * * * */ - - diff --git a/src/lptran.c b/src/lptran.c old mode 100755 new mode 100644 index 4b03993..26c21a7 --- a/src/lptran.c +++ b/src/lptran.c @@ -1,7 +1,7 @@ -/* $Id: lptran.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lptran.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lptran.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,83 +16,71 @@ static char *id = "$Id: lptran.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyri #include "version.h" - #include "lpdefs.h" #include "lpglobl.h" #ifdef alliant -#pragma global safe (Eta_rownr, Eta_value) +#pragma global safe(Eta_rownr, Eta_value) #pragma global assoc #endif - #ifdef OS4 -ftran(start, end, pcol) -int start, end; double *pcol; +ftran(start, end, pcol) int start, end; +double *pcol; #else -void ftran(int start, - int end, - double *pcol) +void ftran(int start, int end, double *pcol) #endif { - int i, j; - int k, r; + int i, j; + int k, r; double theta; - + #ifdef alliant -#pragma safe (pcol, Endetacol) -#pragma routine permutation (Eta_rownr) +#pragma safe(pcol, Endetacol) +#pragma routine permutation(Eta_rownr) #endif - if (Verbose) - printf("ftran\n"); - for (i = start; i <= end; i++) - { - k = Endetacol[i] - 1; - r = Eta_rownr[k]; - theta = pcol[r]; - if (theta != 0) - for (j = Endetacol[i - 1]; j < k; j++) - pcol[Eta_rownr[j]] += theta * Eta_value[j]; /* cpu expensive line */ - pcol[r] *= Eta_value[k]; - } + if (Verbose) printf("ftran\n"); + for (i = start; i <= end; i++) { + k = Endetacol[i] - 1; + r = Eta_rownr[k]; + theta = pcol[r]; + if (theta != 0) + for (j = Endetacol[i - 1]; j < k; j++) + pcol[Eta_rownr[j]] += theta * Eta_value[j]; /* cpu expensive line */ + pcol[r] *= Eta_value[k]; + } #ifdef alliant #pragma loop novector #endif for (i = 0; i <= Rows; i++) - if (abs(pcol[i]) < EPSEL) - pcol[i] = 0; + if (abs(pcol[i]) < EPSEL) pcol[i] = 0; } /* ftran */ - #ifdef OS4 -btran(numc, row) -int numc; double *row; +btran(numc, row) int numc; +double *row; #else -void btran(int numc, - double *row) +void btran(int numc, double *row) #endif { - int i, j, k; + int i, j, k; double f; - + #ifdef alliant -#pragma safe (row, Endetacol) +#pragma safe(row, Endetacol) #endif - if (Verbose) - printf("btran\n"); - for (i = numc; i >= 1; i--) - { - f = 0; - k = Endetacol[i]; - for (j = Endetacol[i - 1]; j < k; j++) - f += row[Eta_rownr[j]] * Eta_value[j]; - if (abs(f) < EPSEL) - row[Eta_rownr[k - 1]] = 0; - else - row[Eta_rownr[k - 1]] = f; - } + if (Verbose) printf("btran\n"); + for (i = numc; i >= 1; i--) { + f = 0; + k = Endetacol[i]; + for (j = Endetacol[i - 1]; j < k; j++) f += row[Eta_rownr[j]] * Eta_value[j]; + if (abs(f) < EPSEL) + row[Eta_rownr[k - 1]] = 0; + else + row[Eta_rownr[k - 1]] = f; + } } /* btran */ diff --git a/src/lpwrite.c b/src/lpwrite.c old mode 100755 new mode 100644 index e4bbf8f..d107e3b --- a/src/lpwrite.c +++ b/src/lpwrite.c @@ -1,7 +1,7 @@ -/* $Id: lpwrite.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lpwrite.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lpwrite.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,7 +16,6 @@ static char *id = "$Id: lpwrite.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyr #include "version.h" - #include "lpdefs.h" #include "lpglobl.h" #ifdef OS4 @@ -29,8 +28,8 @@ static char *id = "$Id: lpwrite.c,v 1.2 1999/01/03 02:07:20 sybalsky Exp $ Copyr /* this is the ansi version ... */ #ifdef OS4 -print_solution(stream, sol) -FILE *stream; double *sol; +print_solution(stream, sol) FILE *stream; +double *sol; #else void print_solution(FILE *stream, double *sol) #endif @@ -44,15 +43,13 @@ void print_solution(FILE *stream, double *sol) if (0 != sol[i]) fprintf(stream, "%-10s%16.5g\n", Names[i], sol[i]); /* print dual variables */ - if(Verbose || Print_duals) - { - fprintf(stream, "\nValues of the dual variables:\n"); - for (i = 1; i <= Rows; i++) - if (0 != sol[i]) fprintf(stream, "%-10s%16.5g\n", Names[i], sol[i]); - } + if (Verbose || Print_duals) { + fprintf(stream, "\nValues of the dual variables:\n"); + for (i = 1; i <= Rows; i++) + if (0 != sol[i]) fprintf(stream, "%-10s%16.5g\n", Names[i], sol[i]); + } } /* print_solution */ - #ifdef OS4 print_indent() #else @@ -62,73 +59,60 @@ void print_indent(void) int i; fprintf(stderr, "%2d", Level); - for(i = Level; i > 0; i--) - fprintf(stderr, "--"); + for (i = Level; i > 0; i--) fprintf(stderr, "--"); fprintf(stderr, "> "); } /* print_indent */ - #ifdef OS4 -debug_print_solution(sol) -double *sol; +debug_print_solution(sol) double *sol; #else void debug_print_solution(double *sol) #endif { int i; - if(Debug) - for (i = 0; i <= Sum; i++) - { - print_indent(); - if (sol[i] != 0) fprintf(stderr, "%-10s%16.5g\n", Names[i], sol[i]); - } + if (Debug) + for (i = 0; i <= Sum; i++) { + print_indent(); + if (sol[i] != 0) fprintf(stderr, "%-10s%16.5g\n", Names[i], sol[i]); + } } /* debug_print_solution */ - #ifdef OS4 -debug_print_bounds(upbo, lowbo) -double *upbo, *lowbo; +debug_print_bounds(upbo, lowbo) double *upbo, *lowbo; #else void debug_print_bounds(double *upbo, double *lowbo) #endif { int i; - if(Debug) - for(i = Rows + 1; i <= Sum; i++) - { - if(lowbo[i] != 0) - { - print_indent(); - fprintf(stderr, "%s > %10.3g\n", Names[i], lowbo[i]); - } - if(upbo[i] != INFINITE) - { - print_indent(); - fprintf(stderr, "%s < %10.3g\n", Names[i], upbo[i]); - } + if (Debug) + for (i = Rows + 1; i <= Sum; i++) { + if (lowbo[i] != 0) { + print_indent(); + fprintf(stderr, "%s > %10.3g\n", Names[i], lowbo[i]); } + if (upbo[i] != INFINITE) { + print_indent(); + fprintf(stderr, "%s < %10.3g\n", Names[i], upbo[i]); + } + } } /* debug_print_bounds */ - #ifdef OS4 -debug_print(format) -char *format; +debug_print(format) char *format; { return 0; } #else -void debug_print(char *format, ...) -{ +void debug_print(char *format, ...) { va_list ap; - if(Debug) - { - va_start(ap, format); - print_indent(); - vfprintf(stderr, format, ap); - fputc('\n', stderr); - va_end(ap); - } + if (Debug) { + va_start(ap, format); + print_indent(); + vfprintf(stderr, format, ap); + fputc('\n', stderr); + va_end(ap); + } } /* debug_print */ #endif diff --git a/src/lpytab.c b/src/lpytab.c old mode 100755 new mode 100644 index 997eb43..4b710f5 --- a/src/lpytab.c +++ b/src/lpytab.c @@ -1,37 +1,36 @@ -/* $Id: lpytab.c,v 1.2 1999/01/03 02:07:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ -static char *id = "$Id: lpytab.c,v 1.2 1999/01/03 02:07:21 sybalsky Exp $ Copyright (C) Venue"; - - -/************************************************************************/ -/* */ -/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/* The contents of this file are proprietary information */ -/* belonging to Venue, and are provided to you under license. */ -/* They may not be further distributed or disclosed to third */ -/* parties without the specific permission of Venue. */ -/* */ -/************************************************************************/ - -#include "version.h" - - -#ifndef BIGATOMS - -# define VAR 257 -# define CONS 258 -# define SIGN 259 -# define AR_M_OP 260 -# define RE_OP 261 -# define END_C 262 -# define COMMA 263 -# define COLON 264 -# define MINIMISE 265 -# define MAXIMISE 266 +/* $Id: lpytab.c,v 1.2 1999/01/03 02:07:21 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ +static char *id = "$Id: lpytab.c,v 1.2 1999/01/03 02:07:21 sybalsky Exp $ Copyright (C) Venue"; -# line 10 "lp.y" -#include "lpdefines.h" +/************************************************************************/ +/* */ +/* (C) Copyright 1989-95 Venue. All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +#include "version.h" + +#ifndef BIGATOMS + +#define VAR 257 +#define CONS 258 +#define SIGN 259 +#define AR_M_OP 260 +#define RE_OP 261 +#define END_C 262 +#define COMMA 263 +#define COLON 264 +#define MINIMISE 265 +#define MAXIMISE 266 + +#line 10 "lp.y" +#include "lpdefines.h" #include "lpglobals.h" /* globals */ @@ -41,10 +40,10 @@ int Lin_term_count; double f; int x; int Sign; -int isign; /* internal_sign variable to make sure nothing goes wrong */ - /* with lookahead */ -int make_neg; /* is true after the relational operator is seen in order */ - /* to remember if lin_term stands before or after re_op */ +int isign; /* internal_sign variable to make sure nothing goes wrong */ +/* with lookahead */ +int make_neg; /* is true after the relational operator is seen in order */ +/* to remember if lin_term stands before or after re_op */ #define yyclearin yychar = -1 #define yyerrok yyerrflag = 0 extern int yychar; @@ -57,142 +56,112 @@ extern int yyerrflag; #endif YYSTYPE yylval, yyval; typedef int yytabelem; -# define YYERRCODE 256 +#define YYERRCODE 256 -# line 193 "lp.y" +#line 193 "lp.y" -# include "lexyy.c" -yytabelem yyexca[] ={ --1, 1, - 0, -1, - -2, 0, --1, 31, - 257, 15, - -2, 31, - }; -# define YYNPROD 38 -# define YYLAST 87 -yytabelem yyact[]={ +#include "lexyy.c" +yytabelem yyexca[] = { + -1, 1, 0, -1, -2, 0, -1, 31, 257, 15, -2, 31, +}; +#define YYNPROD 38 +#define YYLAST 87 +yytabelem yyact[] = { - 10, 11, 9, 34, 36, 51, 56, 57, 5, 4, - 50, 52, 23, 44, 36, 24, 35, 10, 20, 18, - 26, 10, 20, 27, 31, 20, 18, 10, 11, 9, - 15, 20, 18, 10, 11, 42, 40, 17, 14, 16, - 19, 32, 13, 8, 6, 8, 8, 38, 25, 21, - 22, 7, 47, 37, 43, 29, 33, 30, 46, 45, - 28, 12, 3, 2, 1, 0, 39, 0, 0, 0, - 0, 0, 41, 0, 0, 48, 0, 0, 0, 49, - 0, 0, 0, 0, 53, 55, 54 }; -yytabelem yypact[]={ + 10, 11, 9, 34, 36, 51, 56, 57, 5, 4, 50, 52, 23, 44, 36, 24, 35, 10, 20, 18, 26, 10, + 20, 27, 31, 20, 18, 10, 11, 9, 15, 20, 18, 10, 11, 42, 40, 17, 14, 16, 19, 32, 13, 8, + 6, 8, 8, 38, 25, 21, 22, 7, 47, 37, 43, 29, 33, 30, 46, 45, 28, 12, 3, 2, 1, 0, + 39, 0, 0, 0, 0, 0, 41, 0, 0, 48, 0, 0, 0, 49, 0, 0, 0, 0, 53, 55, 54}; +yytabelem yypact[] = { - -1000, -1000, -257, -227, -230, -230, -1000, -247, -1000, -1000, - -1000, -237, -233, -1000, -1000, -261, -245, -1000, -1000, -1000, - -237, -1000, -1000, -1000, -1000, -224, -1000, -221, -1000, -1000, - -222, -261, -1000, -244, -1000, -1000, -1000, -236, -224, -1000, - -1000, -1000, -1000, -252, -1000, -240, -240, -236, -1000, -1000, - -1000, -1000, -251, -1000, -255, -1000, -1000, -1000 }; -yytabelem yypgo[]={ + -1000, -1000, -257, -227, -230, -230, -1000, -247, -1000, -1000, -1000, -237, + -233, -1000, -1000, -261, -245, -1000, -1000, -1000, -237, -1000, -1000, -1000, + -1000, -224, -1000, -221, -1000, -1000, -222, -261, -1000, -244, -1000, -1000, + -1000, -236, -224, -1000, -1000, -1000, -1000, -252, -1000, -240, -240, -236, + -1000, -1000, -1000, -1000, -251, -1000, -255, -1000, -1000, -1000}; +yytabelem yypgo[] = { - 0, 64, 63, 62, 61, 60, 42, 38, 59, 39, - 58, 57, 41, 56, 54, 37, 53, 52, 40, 51, - 48, 47, 44 }; -yytabelem yyr1[]={ + 0, 64, 63, 62, 61, 60, 42, 38, 59, 39, 58, 57, 41, 56, 54, 37, 53, 52, 40, 51, 48, 47, 44}; +yytabelem yyr1[] = { - 0, 2, 1, 4, 4, 6, 8, 6, 10, 7, - 5, 5, 11, 11, 12, 13, 14, 14, 14, 9, - 16, 9, 17, 9, 15, 15, 19, 20, 19, 21, - 19, 18, 18, 18, 3, 3, 3, 22 }; -yytabelem yyr2[]={ + 0, 2, 1, 4, 4, 6, 8, 6, 10, 7, 5, 5, 11, 11, 12, 13, 14, 14, 14, + 9, 16, 9, 17, 9, 15, 15, 19, 20, 19, 21, 19, 18, 18, 18, 3, 3, 3, 22}; +yytabelem yyr2[] = { - 0, 1, 8, 2, 4, 2, 1, 8, 1, 11, - 0, 2, 2, 4, 7, 3, 3, 5, 7, 2, - 1, 6, 1, 8, 2, 3, 2, 1, 6, 1, - 8, 3, 5, 7, 5, 5, 2, 5 }; -yytabelem yychk[]={ + 0, 1, 8, 2, 4, 2, 1, 8, 1, 11, 0, 2, 2, 4, 7, 3, 3, 5, 7, + 2, 1, 6, 1, 8, 2, 3, 2, 1, 6, 1, 8, 3, 5, 7, 5, 5, 2, 5}; +yytabelem yychk[] = { - -1000, -1, -2, -3, 266, 265, -22, -19, -18, 259, - 257, 258, -4, -6, -7, 257, -9, -15, 259, -18, - 258, -22, -22, 259, 262, -20, 257, 260, -5, -6, - -11, 257, -12, -13, 264, 261, 259, -16, -21, -18, - 257, -12, 257, -14, 257, -8, -10, -17, -15, -18, - 262, 257, 263, -7, -9, -15, 257, 262 }; -yytabelem yydef[]={ + -1000, -1, -2, -3, 266, 265, -22, -19, -18, 259, 257, 258, -4, -6, -7, + 257, -9, -15, 259, -18, 258, -22, -22, 259, 262, -20, 257, 260, -5, -6, + -11, 257, -12, -13, 264, 261, 259, -16, -21, -18, 257, -12, 257, -14, 257, + -8, -10, -17, -15, -18, 262, 257, 263, -7, -9, -15, 257, 262}; +yytabelem yydef[] = { - 1, -2, 0, 0, 0, 0, 36, 0, 26, 27, - 31, 0, 10, 3, 5, 31, 0, 19, 20, 24, - 25, 34, 35, 29, 37, 0, 32, 0, 2, 4, - 11, -2, 12, 0, 6, 8, 22, 0, 0, 28, - 33, 13, 15, 0, 16, 0, 0, 0, 21, 30, - 14, 17, 0, 7, 0, 23, 18, 9 }; -typedef struct { char *t_name; int t_val; } yytoktype; + 1, -2, 0, 0, 0, 0, 36, 0, 26, 27, 31, 0, 10, 3, 5, 31, 0, 19, 20, 24, + 25, 34, 35, 29, 37, 0, 32, 0, 2, 4, 11, -2, 12, 0, 6, 8, 22, 0, 0, 28, + 33, 13, 15, 0, 16, 0, 0, 0, 21, 30, 14, 17, 0, 7, 0, 23, 18, 9}; +typedef struct { + char *t_name; + int t_val; +} yytoktype; #ifndef YYDEBUG -# define YYDEBUG 0 /* don't allow debugging */ +#define YYDEBUG 0 /* don't allow debugging */ #endif #if YYDEBUG -yytoktype yytoks[] = -{ - "VAR", 257, - "CONS", 258, - "SIGN", 259, - "AR_M_OP", 260, - "RE_OP", 261, - "END_C", 262, - "COMMA", 263, - "COLON", 264, - "MINIMISE", 265, - "MAXIMISE", 266, - "-unknown-", -1 /* ends search */ +yytoktype yytoks[] = { + "VAR", 257, "CONS", 258, "SIGN", 259, "AR_M_OP", 260, "RE_OP", 261, "END_C", 262, + "COMMA", 263, "COLON", 264, "MINIMISE", 265, "MAXIMISE", 266, "-unknown-", -1 /* ends search */ }; -char * yyreds[] = -{ - "-no such reduction-", - "inputfile : /* empty */", - "inputfile : objective_function constraints int_declarations", - "constraints : constraint", - "constraints : constraints constraint", - "constraint : real_constraint", - "constraint : VAR COLON", - "constraint : VAR COLON real_constraint", - "real_constraint : x_lineair_sum RE_OP", - "real_constraint : x_lineair_sum RE_OP x_lineair_sum END_C", - "int_declarations : /* empty */", - "int_declarations : real_int_decls", - "real_int_decls : int_declaration", - "real_int_decls : real_int_decls int_declaration", - "int_declaration : int_declarator vars END_C", - "int_declarator : VAR", - "vars : VAR", - "vars : vars VAR", - "vars : vars COMMA VAR", - "x_lineair_sum : x_lineair_term", - "x_lineair_sum : SIGN", - "x_lineair_sum : SIGN x_lineair_term", - "x_lineair_sum : x_lineair_sum SIGN", - "x_lineair_sum : x_lineair_sum SIGN x_lineair_term", - "x_lineair_term : lineair_term", - "x_lineair_term : CONS", - "lineair_sum : lineair_term", - "lineair_sum : SIGN", - "lineair_sum : SIGN lineair_term", - "lineair_sum : lineair_sum SIGN", - "lineair_sum : lineair_sum SIGN lineair_term", - "lineair_term : VAR", - "lineair_term : CONS VAR", - "lineair_term : CONS AR_M_OP VAR", - "objective_function : MAXIMISE real_of", - "objective_function : MINIMISE real_of", - "objective_function : real_of", - "real_of : lineair_sum END_C", +char *yyreds[] = { + "-no such reduction-", + "inputfile : /* empty */", + "inputfile : objective_function constraints int_declarations", + "constraints : constraint", + "constraints : constraints constraint", + "constraint : real_constraint", + "constraint : VAR COLON", + "constraint : VAR COLON real_constraint", + "real_constraint : x_lineair_sum RE_OP", + "real_constraint : x_lineair_sum RE_OP x_lineair_sum END_C", + "int_declarations : /* empty */", + "int_declarations : real_int_decls", + "real_int_decls : int_declaration", + "real_int_decls : real_int_decls int_declaration", + "int_declaration : int_declarator vars END_C", + "int_declarator : VAR", + "vars : VAR", + "vars : vars VAR", + "vars : vars COMMA VAR", + "x_lineair_sum : x_lineair_term", + "x_lineair_sum : SIGN", + "x_lineair_sum : SIGN x_lineair_term", + "x_lineair_sum : x_lineair_sum SIGN", + "x_lineair_sum : x_lineair_sum SIGN x_lineair_term", + "x_lineair_term : lineair_term", + "x_lineair_term : CONS", + "lineair_sum : lineair_term", + "lineair_sum : SIGN", + "lineair_sum : SIGN lineair_term", + "lineair_sum : lineair_sum SIGN", + "lineair_sum : lineair_sum SIGN lineair_term", + "lineair_term : VAR", + "lineair_term : CONS VAR", + "lineair_term : CONS AR_M_OP VAR", + "objective_function : MAXIMISE real_of", + "objective_function : MINIMISE real_of", + "objective_function : real_of", + "real_of : lineair_sum END_C", }; #endif /* YYDEBUG */ -/* +/* * Copyright 1987 Silicon Graphics, Inc. - All Rights Reserved */ -#ident "$Revision: 1.2 $" +#ident "$Revision: 1.2 $" /* ** Skeleton parser driver for yacc output @@ -201,540 +170,480 @@ char * yyreds[] = /* ** yacc user known macros and defines */ -#define YYERROR goto yyerrlab -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYBACKUP( newtoken, newvalue )\ -{\ - if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ - {\ - yyerror( "syntax error - cannot backup" );\ - goto yyerrlab;\ - }\ - yychar = newtoken;\ - yystate = *yyps;\ - yylval = newvalue;\ - goto yynewstate;\ +#define YYERROR goto yyerrlab +#define YYACCEPT return (0) +#define YYABORT return (1) +#define YYBACKUP(newtoken, newvalue) \ + \ +{ \ + if (yychar >= 0 || (yyr2[yytmp] >> 1) != 1) { \ + yyerror("syntax error - cannot backup"); \ + goto yyerrlab; \ + } \ + yychar = newtoken; \ + yystate = *yyps; \ + yylval = newvalue; \ + goto yynewstate; \ + \ } -#define YYRECOVERING() (!!yyerrflag) +#define YYRECOVERING() (!!yyerrflag) #ifndef YYDEBUG -# define YYDEBUG 1 /* make debugging available */ +#define YYDEBUG 1 /* make debugging available */ #endif /* ** user known globals */ -int yydebug; /* set to 1 to get debugging */ +int yydebug; /* set to 1 to get debugging */ /* ** driver internal defines */ -#define YYFLAG (-1000) +#define YYFLAG (-1000) /* ** global variables used by the parser */ -YYSTYPE yyv[ YYMAXDEPTH ]; /* value stack */ -int yys[ YYMAXDEPTH ]; /* state stack */ +YYSTYPE yyv[YYMAXDEPTH]; /* value stack */ +int yys[YYMAXDEPTH]; /* state stack */ -YYSTYPE *yypv; /* top of value stack */ -int *yyps; /* top of state stack */ - -int yystate; /* current state */ -int yytmp; /* extra var (lasts between blocks) */ - -int yynerrs; /* number of errors */ -int yyerrflag; /* error recovery flag */ -int yychar; /* current input token number */ +YYSTYPE *yypv; /* top of value stack */ +int *yyps; /* top of state stack */ +int yystate; /* current state */ +int yytmp; /* extra var (lasts between blocks) */ +int yynerrs; /* number of errors */ +int yyerrflag; /* error recovery flag */ +int yychar; /* current input token number */ /* ** yyparse - return 0 if worked, 1 if syntax error not recovered from */ -int -yyparse() -{ - register YYSTYPE *yypvt; /* top of value stack for $vars */ +int yyparse() { + register YYSTYPE *yypvt; /* top of value stack for $vars */ - /* - ** Initialize externals - yyparse may be called more than once - */ - yypv = &yyv[-1]; - yyps = &yys[-1]; - yystate = 0; - yytmp = 0; - yynerrs = 0; - yyerrflag = 0; - yychar = -1; + /* + ** Initialize externals - yyparse may be called more than once + */ + yypv = &yyv[-1]; + yyps = &yys[-1]; + yystate = 0; + yytmp = 0; + yynerrs = 0; + yyerrflag = 0; + yychar = -1; - goto yystack; - { - register YYSTYPE *yy_pv; /* top of value stack */ - register int *yy_ps; /* top of state stack */ - register int yy_state; /* current state */ - register int yy_n; /* internal state number info */ + goto yystack; + { + register YYSTYPE *yy_pv; /* top of value stack */ + register int *yy_ps; /* top of state stack */ + register int yy_state; /* current state */ + register int yy_n; /* internal state number info */ - /* - ** get globals into registers. - ** branch to here only if YYBACKUP was called. - */ - yynewstate: - yy_pv = yypv; - yy_ps = yyps; - yy_state = yystate; - goto yy_newstate; + /* + ** get globals into registers. + ** branch to here only if YYBACKUP was called. + */ + yynewstate: + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + goto yy_newstate; - /* - ** get globals into registers. - ** either we just started, or we just finished a reduction - */ - yystack: - yy_pv = yypv; - yy_ps = yyps; - yy_state = yystate; + /* + ** get globals into registers. + ** either we just started, or we just finished a reduction + */ + yystack: + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; - /* - ** top of for (;;) loop while no reductions done - */ - yy_stack: - /* - ** put a state and value onto the stacks - */ + /* + ** top of for (;;) loop while no reductions done + */ + yy_stack: +/* +** put a state and value onto the stacks +*/ #if YYDEBUG - /* - ** if debugging, look up token value in list of value vs. - ** name pairs. 0 and negative (-1) are special values. - ** Note: linear search is used since time is not a real - ** consideration while debugging. - */ - if ( yydebug ) - { - register int yy_i; + /* + ** if debugging, look up token value in list of value vs. + ** name pairs. 0 and negative (-1) are special values. + ** Note: linear search is used since time is not a real + ** consideration while debugging. + */ + if (yydebug) { + register int yy_i; - printf( "State %d, token ", yy_state ); - if ( yychar == 0 ) - printf( "end-of-file\n" ); - else if ( yychar < 0 ) - printf( "-none-\n" ); - else - { - for ( yy_i = 0; yytoks[yy_i].t_val >= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val == yychar ) - break; - } - printf( "%s\n", yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( ++yy_ps >= &yys[ YYMAXDEPTH ] ) /* room on stack? */ - { - yyerror( "yacc stack overflow" ); - YYABORT; - } - *yy_ps = yy_state; - *++yy_pv = yyval; - - /* - ** we have a new state - find out what to do - */ - yy_newstate: - if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) - goto yydefault; /* simple state */ -#if YYDEBUG - /* - ** if debugging, need to mark whether new token grabbed - */ - yytmp = yychar < 0; -#endif - if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) - yychar = 0; /* reached EOF */ -#if YYDEBUG - if ( yydebug && yytmp ) - { - register int yy_i; - - printf( "Received token " ); - if ( yychar == 0 ) - printf( "end-of-file\n" ); - else if ( yychar < 0 ) - printf( "-none-\n" ); - else - { - for ( yy_i = 0; yytoks[yy_i].t_val >= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val == yychar ) - break; - } - printf( "%s\n", yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) - goto yydefault; - if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ - { - yychar = -1; - yyval = yylval; - yy_state = yy_n; - if ( yyerrflag > 0 ) - yyerrflag--; - goto yy_stack; - } - - yydefault: - if ( ( yy_n = yydef[ yy_state ] ) == -2 ) - { -#if YYDEBUG - yytmp = yychar < 0; -#endif - if ( ( yychar < 0 ) && ( ( yychar = yylex() ) < 0 ) ) - yychar = 0; /* reached EOF */ -#if YYDEBUG - if ( yydebug && yytmp ) - { - register int yy_i; - - printf( "Received token " ); - if ( yychar == 0 ) - printf( "end-of-file\n" ); - else if ( yychar < 0 ) - printf( "-none-\n" ); - else - { - for ( yy_i = 0; - yytoks[yy_i].t_val >= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val - == yychar ) - { - break; - } - } - printf( "%s\n", yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - /* - ** look through exception table - */ - { - register int *yyxi = yyexca; - - while ( ( *yyxi != -1 ) || - ( yyxi[1] != yy_state ) ) - { - yyxi += 2; - } - while ( ( *(yyxi += 2) >= 0 ) && - ( *yyxi != yychar ) ) - ; - if ( ( yy_n = yyxi[1] ) < 0 ) - YYACCEPT; - } - } - - /* - ** check for syntax error - */ - if ( yy_n == 0 ) /* have an error */ - { - /* no worry about speed here! */ - switch ( yyerrflag ) - { - case 0: /* new error */ - yyerror( "syntax error" ); - goto skip_init; - yyerrlab: - /* - ** get globals into registers. - ** we have a user generated syntax type error - */ - yy_pv = yypv; - yy_ps = yyps; - yy_state = yystate; - yynerrs++; - skip_init: - case 1: - case 2: /* incompletely recovered error */ - /* try again... */ - yyerrflag = 3; - /* - ** find state where "error" is a legal - ** shift action - */ - while ( yy_ps >= yys ) - { - yy_n = yypact[ *yy_ps ] + YYERRCODE; - if ( yy_n >= 0 && yy_n < YYLAST && - yychk[yyact[yy_n]] == YYERRCODE) { - /* - ** simulate shift of "error" - */ - yy_state = yyact[ yy_n ]; - goto yy_stack; - } - /* - ** current state has no shift on - ** "error", pop stack - */ -#if YYDEBUG -# define _POP_ "Error recovery pops state %d, uncovers state %d\n" - if ( yydebug ) - printf( _POP_, *yy_ps, - yy_ps[-1] ); -# undef _POP_ -#endif - yy_ps--; - yy_pv--; - } - /* - ** there is no state on stack with "error" as - ** a valid shift. give up. - */ - YYABORT; - case 3: /* no shift yet; eat a token */ -#if YYDEBUG - /* - ** if debugging, look up token in list of - ** pairs. 0 and negative shouldn't occur, - ** but since timing doesn't matter when - ** debugging, it doesn't hurt to leave the - ** tests here. - */ - if ( yydebug ) - { - register int yy_i; - - printf( "Error recovery discards " ); - if ( yychar == 0 ) - printf( "token end-of-file\n" ); - else if ( yychar < 0 ) - printf( "token -none-\n" ); - else - { - for ( yy_i = 0; - yytoks[yy_i].t_val >= 0; - yy_i++ ) - { - if ( yytoks[yy_i].t_val - == yychar ) - { - break; - } - } - printf( "token %s\n", - yytoks[yy_i].t_name ); - } - } -#endif /* YYDEBUG */ - if ( yychar == 0 ) /* reached EOF. quit */ - YYABORT; - yychar = -1; - goto yy_newstate; - } - }/* end if ( yy_n == 0 ) */ - /* - ** reduction by production yy_n - ** put stack tops, etc. so things right after switch - */ -#if YYDEBUG - /* - ** if debugging, print the string that is the user's - ** specification of the reduction which is just about - ** to be done. - */ - if ( yydebug ) - printf( "Reduce by (%d) \"%s\"\n", - yy_n, yyreds[ yy_n ] ); -#endif - yytmp = yy_n; /* value to switch over */ - yypvt = yy_pv; /* $vars top of value stack */ - /* - ** Look in goto table for next state - ** Sorry about using yy_state here as temporary - ** register variable, but why not, if it works... - ** If yyr2[ yy_n ] doesn't have the low order bit - ** set, then there is no action to be done for - ** this reduction. So, no saving & unsaving of - ** registers done. The only difference between the - ** code just after the if and the body of the if is - ** the goto yy_stack in the body. This way the test - ** can be made before the choice of what to do is needed. - */ - { - /* length of production doubled with extra bit */ - register int yy_len = yyr2[ yy_n ]; - - if ( !( yy_len & 01 ) ) - { - yy_len >>= 1; - yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ - yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + - *( yy_ps -= yy_len ) + 1; - if ( yy_state >= YYLAST || - yychk[ yy_state = - yyact[ yy_state ] ] != -yy_n ) - { - yy_state = yyact[ yypgo[ yy_n ] ]; - } - goto yy_stack; - } - yy_len >>= 1; - yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ - yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + - *( yy_ps -= yy_len ) + 1; - if ( yy_state >= YYLAST || - yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) - { - yy_state = yyact[ yypgo[ yy_n ] ]; - } - } - /* save until reenter driver code */ - yystate = yy_state; - yyps = yy_ps; - yypv = yy_pv; - } - /* - ** code supplied by user is placed in this switch - */ - switch( yytmp ) - { - -case 1: -# line 32 "lp.y" -{ - init_read(); - isign = 0; - make_neg = 0; -} break; -case 6: -# line 49 "lp.y" -{ - add_constraint_name(Last_var, Rows); -} break; -case 8: -# line 58 "lp.y" -{ - store_re_op(); - make_neg = 1; -} break; -case 9: -# line 64 "lp.y" -{ - if(Lin_term_count == 0) + printf("State %d, token ", yy_state); + if (yychar == 0) + printf("end-of-file\n"); + else if (yychar < 0) + printf("-none-\n"); + else { + for (yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++) { + if (yytoks[yy_i].t_val == yychar) break; + } + printf("%s\n", yytoks[yy_i].t_name); + } + } +#endif /* YYDEBUG */ + if (++yy_ps >= &yys[YYMAXDEPTH]) /* room on stack? */ { - fprintf(stderr, "WARNING line %d: constraint contains no variables\n", - yylineno); - null_tmp_store(); + yyerror("yacc stack overflow"); + YYABORT; + } + *yy_ps = yy_state; + *++yy_pv = yyval; + + /* + ** we have a new state - find out what to do + */ + yy_newstate: + if ((yy_n = yypact[yy_state]) <= YYFLAG) goto yydefault; /* simple state */ +#if YYDEBUG + /* + ** if debugging, need to mark whether new token grabbed + */ + yytmp = yychar < 0; +#endif + if ((yychar < 0) && ((yychar = yylex()) < 0)) yychar = 0; /* reached EOF */ +#if YYDEBUG + if (yydebug && yytmp) { + register int yy_i; + + printf("Received token "); + if (yychar == 0) + printf("end-of-file\n"); + else if (yychar < 0) + printf("-none-\n"); + else { + for (yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++) { + if (yytoks[yy_i].t_val == yychar) break; + } + printf("%s\n", yytoks[yy_i].t_name); + } + } +#endif /* YYDEBUG */ + if (((yy_n += yychar) < 0) || (yy_n >= YYLAST)) goto yydefault; + if (yychk[yy_n = yyact[yy_n]] == yychar) /*valid shift*/ + { + yychar = -1; + yyval = yylval; + yy_state = yy_n; + if (yyerrflag > 0) yyerrflag--; + goto yy_stack; } - if(Lin_term_count > 1) - Rows++; + yydefault: + if ((yy_n = yydef[yy_state]) == -2) { +#if YYDEBUG + yytmp = yychar < 0; +#endif + if ((yychar < 0) && ((yychar = yylex()) < 0)) yychar = 0; /* reached EOF */ +#if YYDEBUG + if (yydebug && yytmp) { + register int yy_i; - if(Lin_term_count == 1) - store_bounds(); + printf("Received token "); + if (yychar == 0) + printf("end-of-file\n"); + else if (yychar < 0) + printf("-none-\n"); + else { + for (yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++) { + if (yytoks[yy_i].t_val == yychar) { break; } + } + printf("%s\n", yytoks[yy_i].t_name); + } + } +#endif /* YYDEBUG */ + /* + ** look through exception table + */ + { + register int *yyxi = yyexca; - Lin_term_count = 0; - isign = 0 ; - make_neg = 0; - Constraint_name[0] = '\0'; -} break; -case 14: -# line 93 "lp.y" -{Having_ints = 1;} break; -case 15: -# line 96 "lp.y" -{/* check_decl(yytext);*/} break; -case 16: -# line 99 "lp.y" -{add_int_var((char *)yytext);} break; -case 17: -# line 100 "lp.y" -{add_int_var((char *)yytext);} break; -case 18: -# line 101 "lp.y" -{add_int_var((char *)yytext);} break; -case 20: -# line 106 "lp.y" -{ - isign = Sign; -} break; -case 22: -# line 112 "lp.y" -{ - isign = Sign; -} break; -case 25: -# line 120 "lp.y" -{ - if ( (isign || !make_neg) - && !(isign && !make_neg)) /* but not both! */ - f = -f; - rhs_store(f); - isign = 0; -} break; -case 27: -# line 131 "lp.y" -{ - isign = Sign; -} break; -case 29: -# line 137 "lp.y" -{ - isign = Sign; -} break; -case 31: -# line 144 "lp.y" -{ - if ( (isign || make_neg) - && !(isign && make_neg)) /* but not both! */ - var_store(Last_var, Rows, (double)-1); - else - var_store(Last_var, Rows, (double)1); - isign = 0; -} break; -case 32: -# line 154 "lp.y" -{ - if ( (isign || make_neg) - && !(isign && make_neg)) /* but not both! */ - f = -f; - var_store(Last_var, Rows, f); - isign = 0; -} break; -case 33: -# line 164 "lp.y" -{ - if ( (isign || make_neg) - && !(isign && make_neg)) /* but not both! */ - f = -f; - var_store(Last_var, Rows, f); - isign = 0; -} break; -case 34: -# line 174 "lp.y" -{ - Maximise = TRUE; -} break; -case 35: -# line 178 "lp.y" -{ - Maximise = FALSE; -} break; -case 37: -# line 186 "lp.y" -{ - Rows++; - Lin_term_count = 0; - isign = 0; - make_neg = 0; -} break; - } - goto yystack; /* reset registers in driver code */ + while ((*yyxi != -1) || (yyxi[1] != yy_state)) { yyxi += 2; } + while ((*(yyxi += 2) >= 0) && (*yyxi != yychar)) + ; + if ((yy_n = yyxi[1]) < 0) YYACCEPT; + } + } + + /* + ** check for syntax error + */ + if (yy_n == 0) /* have an error */ + { + /* no worry about speed here! */ + switch (yyerrflag) { + case 0: /* new error */ + yyerror("syntax error"); + goto skip_init; + yyerrlab: + /* + ** get globals into registers. + ** we have a user generated syntax type error + */ + yy_pv = yypv; + yy_ps = yyps; + yy_state = yystate; + yynerrs++; + skip_init: + case 1: + case 2: /* incompletely recovered error */ + /* try again... */ + yyerrflag = 3; + /* + ** find state where "error" is a legal + ** shift action + */ + while (yy_ps >= yys) { + yy_n = yypact[*yy_ps] + YYERRCODE; + if (yy_n >= 0 && yy_n < YYLAST && yychk[yyact[yy_n]] == YYERRCODE) { + /* + ** simulate shift of "error" + */ + yy_state = yyact[yy_n]; + goto yy_stack; + } +/* +** current state has no shift on +** "error", pop stack +*/ +#if YYDEBUG +#define _POP_ "Error recovery pops state %d, uncovers state %d\n" + if (yydebug) printf(_POP_, *yy_ps, yy_ps[-1]); +#undef _POP_ +#endif + yy_ps--; + yy_pv--; + } + /* + ** there is no state on stack with "error" as + ** a valid shift. give up. + */ + YYABORT; + case 3: /* no shift yet; eat a token */ +#if YYDEBUG + /* + ** if debugging, look up token in list of + ** pairs. 0 and negative shouldn't occur, + ** but since timing doesn't matter when + ** debugging, it doesn't hurt to leave the + ** tests here. + */ + if (yydebug) { + register int yy_i; + + printf("Error recovery discards "); + if (yychar == 0) + printf("token end-of-file\n"); + else if (yychar < 0) + printf("token -none-\n"); + else { + for (yy_i = 0; yytoks[yy_i].t_val >= 0; yy_i++) { + if (yytoks[yy_i].t_val == yychar) { break; } + } + printf("token %s\n", yytoks[yy_i].t_name); + } + } +#endif /* YYDEBUG */ + if (yychar == 0) /* reached EOF. quit */ + YYABORT; + yychar = -1; + goto yy_newstate; + } + } /* end if ( yy_n == 0 ) */ +/* +** reduction by production yy_n +** put stack tops, etc. so things right after switch +*/ +#if YYDEBUG + /* + ** if debugging, print the string that is the user's + ** specification of the reduction which is just about + ** to be done. + */ + if (yydebug) printf("Reduce by (%d) \"%s\"\n", yy_n, yyreds[yy_n]); +#endif + yytmp = yy_n; /* value to switch over */ + yypvt = yy_pv; /* $vars top of value stack */ + /* + ** Look in goto table for next state + ** Sorry about using yy_state here as temporary + ** register variable, but why not, if it works... + ** If yyr2[ yy_n ] doesn't have the low order bit + ** set, then there is no action to be done for + ** this reduction. So, no saving & unsaving of + ** registers done. The only difference between the + ** code just after the if and the body of the if is + ** the goto yy_stack in the body. This way the test + ** can be made before the choice of what to do is needed. + */ + { + /* length of production doubled with extra bit */ + register int yy_len = yyr2[yy_n]; + + if (!(yy_len & 01)) { + yy_len >>= 1; + yyval = (yy_pv -= yy_len)[1]; /* $$ = $1 */ + yy_state = yypgo[yy_n = yyr1[yy_n]] + *(yy_ps -= yy_len) + 1; + if (yy_state >= YYLAST || yychk[yy_state = yyact[yy_state]] != -yy_n) { + yy_state = yyact[yypgo[yy_n]]; + } + goto yy_stack; + } + yy_len >>= 1; + yyval = (yy_pv -= yy_len)[1]; /* $$ = $1 */ + yy_state = yypgo[yy_n = yyr1[yy_n]] + *(yy_ps -= yy_len) + 1; + if (yy_state >= YYLAST || yychk[yy_state = yyact[yy_state]] != -yy_n) { + yy_state = yyact[yypgo[yy_n]]; + } + } + /* save until reenter driver code */ + yystate = yy_state; + yyps = yy_ps; + yypv = yy_pv; + } + /* + ** code supplied by user is placed in this switch + */ + switch (yytmp) { + case 1: +#line 32 "lp.y" + { + init_read(); + isign = 0; + make_neg = 0; + } break; + case 6: +#line 49 "lp.y" + { + add_constraint_name(Last_var, Rows); + } break; + case 8: +#line 58 "lp.y" + { + store_re_op(); + make_neg = 1; + } break; + case 9: +#line 64 "lp.y" + { + if (Lin_term_count == 0) { + fprintf(stderr, "WARNING line %d: constraint contains no variables\n", yylineno); + null_tmp_store(); + } + + if (Lin_term_count > 1) Rows++; + + if (Lin_term_count == 1) store_bounds(); + + Lin_term_count = 0; + isign = 0; + make_neg = 0; + Constraint_name[0] = '\0'; + } break; + case 14: +#line 93 "lp.y" + { + Having_ints = 1; + } break; + case 15: +#line 96 "lp.y" + { /* check_decl(yytext);*/ + } break; + case 16: +#line 99 "lp.y" + { + add_int_var((char *)yytext); + } break; + case 17: +#line 100 "lp.y" + { + add_int_var((char *)yytext); + } break; + case 18: +#line 101 "lp.y" + { + add_int_var((char *)yytext); + } break; + case 20: +#line 106 "lp.y" + { + isign = Sign; + } break; + case 22: +#line 112 "lp.y" + { + isign = Sign; + } break; + case 25: +#line 120 "lp.y" + { + if ((isign || !make_neg) && !(isign && !make_neg)) /* but not both! */ + f = -f; + rhs_store(f); + isign = 0; + } break; + case 27: +#line 131 "lp.y" + { + isign = Sign; + } break; + case 29: +#line 137 "lp.y" + { + isign = Sign; + } break; + case 31: +#line 144 "lp.y" + { + if ((isign || make_neg) && !(isign && make_neg)) /* but not both! */ + var_store(Last_var, Rows, (double)-1); + else + var_store(Last_var, Rows, (double)1); + isign = 0; + } break; + case 32: +#line 154 "lp.y" + { + if ((isign || make_neg) && !(isign && make_neg)) /* but not both! */ + f = -f; + var_store(Last_var, Rows, f); + isign = 0; + } break; + case 33: +#line 164 "lp.y" + { + if ((isign || make_neg) && !(isign && make_neg)) /* but not both! */ + f = -f; + var_store(Last_var, Rows, f); + isign = 0; + } break; + case 34: +#line 174 "lp.y" + { + Maximise = TRUE; + } break; + case 35: +#line 178 "lp.y" + { + Maximise = FALSE; + } break; + case 37: +#line 186 "lp.y" + { + Rows++; + Lin_term_count = 0; + isign = 0; + make_neg = 0; + } break; + } + goto yystack; /* reset registers in driver code */ } -#endif +#endif diff --git a/src/lsthandl.c b/src/lsthandl.c old mode 100755 new mode 100644 index b118913..daf37a3 --- a/src/lsthandl.c +++ b/src/lsthandl.c @@ -1,7 +1,7 @@ -/* $Id: lsthandl.c,v 1.4 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: lsthandl.c,v 1.4 1999/05/31 23:35:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: lsthandl.c,v 1.4 1999/05/31 23:35:38 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -14,11 +14,10 @@ static char *id = "$Id: lsthandl.c,v 1.4 1999/05/31 23:35:38 sybalsky Exp $ Copy /* */ /************************************************************************/ - /************************************************************************/ /* - Including : OP_fmemb - OP_listget + Including : OP_fmemb + OP_listget */ /**********************************************************************/ @@ -33,113 +32,97 @@ static char *id = "$Id: lsthandl.c,v 1.4 1999/05/31 23:35:38 sybalsky Exp $ Copy #include "adr68k.h" #include "cell.h" - /***********************************************************************/ /* N_OP_fmemb */ /**********************************************************************/ -LispPTR -N_OP_fmemb(register LispPTR item, register LispPTR tos) -{ /* OP 34Q */ - - while(Listp(tos)) { - if ( item == car(tos) ) return tos; +LispPTR N_OP_fmemb(register LispPTR item, register LispPTR tos) { /* OP 34Q */ + + while (Listp(tos)) { + if (item == car(tos)) return tos; tos = cdr(tos); /* if we get an interrupt, punt so we can handle it safely */ - if (!Irq_Stk_End) { - TIMER_EXIT(tos); - } + if (!Irq_Stk_End) { TIMER_EXIT(tos); } } - if(tos) ERROR_EXIT(tos); + if (tos) ERROR_EXIT(tos); return tos; } /* N_OP_fmemb end */ - - /***********************************************************************/ -/* - Func Name : fmemb(item,list) - >>For User programming<< - NOTE: You should not handle long list, because it doesn't care - about interrupt. +/* + Func Name : fmemb(item,list) + >>For User programming<< + NOTE: You should not handle long list, because it doesn't care + about interrupt. */ /**********************************************************************/ -LispPTR -fmemb(register LispPTR item, register LispPTR list) -{ - - while(Listp(list)) { - if(item == car(list)) - return (list); +LispPTR fmemb(register LispPTR item, register LispPTR list) { + while (Listp(list)) { + if (item == car(list)) return (list); list = cdr(list); } - if(list) return(list); + if (list) return (list); return (list); - + } /* fmemb end */ - - /***********************************************************************/ /* - Func Name : N_OP_listget - Opcode : 47Q + Func Name : N_OP_listget + Opcode : 47Q */ /**********************************************************************/ -extern struct cadr_cell cadr(LispPTR cell_adr); /** declaration only **/ +extern struct cadr_cell cadr(LispPTR cell_adr); /** declaration only **/ -#define SAVE_ERROR_EXIT2(topcstk,tos) {Scratch_CSTK=topcstk; ERROR_EXIT(tos);} +#define SAVE_ERROR_EXIT2(topcstk, tos) \ + { \ + Scratch_CSTK = topcstk; \ + ERROR_EXIT(tos); \ + } -#define S_N_CHECKANDCADR2(sour,dest,tos,tcstk) \ -{register LispPTR parm = sour; \ - if(GetTypeNumber(parm) != TYPE_LISTP){ \ - SAVE_ERROR_EXIT2(tcstk,tos); \ - } else \ - dest = cadr(parm); \ -} +#define S_N_CHECKANDCADR2(sour, dest, tos, tcstk) \ + { \ + register LispPTR parm = sour; \ + if (GetTypeNumber(parm) != TYPE_LISTP) { \ + SAVE_ERROR_EXIT2(tcstk, tos); \ + } else \ + dest = cadr(parm); \ + } - - -LispPTR -N_OP_listget(register LispPTR plist, register LispPTR tos) -{ +LispPTR N_OP_listget(register LispPTR plist, register LispPTR tos) { REGISTER struct cadr_cell cadrobj; - - while ( plist != NIL_PTR ) { + + while (plist != NIL_PTR) { S_N_CHECKANDCADR2(plist, cadrobj, tos, plist); - - if ( cadrobj.car_cell == tos ) { - if(cadrobj.cdr_cell == NIL_PTR) return NIL_PTR; + if (cadrobj.car_cell == tos) { + if (cadrobj.cdr_cell == NIL_PTR) return NIL_PTR; - if(Listp(cadrobj.cdr_cell)) - return(car(cadrobj.cdr_cell)); - else /* must punt in case car/cdrerr */ - SAVE_ERROR_EXIT2(plist,tos); + if (Listp(cadrobj.cdr_cell)) + return (car(cadrobj.cdr_cell)); + else /* must punt in case car/cdrerr */ + SAVE_ERROR_EXIT2(plist, tos); } - - if( ! Listp(cadrobj.cdr_cell) ) - { /* this list ended before we found prop */ - return ( NIL_PTR ); - } - + + if (!Listp(cadrobj.cdr_cell)) { /* this list ended before we found prop */ + return (NIL_PTR); + } + S_N_CHECKANDCADR2(cadrobj.cdr_cell, cadrobj, tos, plist); plist = cadrobj.cdr_cell; - + if (!Irq_Stk_End) { /* for continuation, it becomes plist on next time */ Scratch_CSTK = plist; TIMER_EXIT(tos); } } - - return(NIL_PTR); - -}/* N_OP_listget end */ + return (NIL_PTR); +} /* N_OP_listget end */ diff --git a/src/main.c b/src/main.c old mode 100755 new mode 100644 index b611fff..abec01a --- a/src/main.c +++ b/src/main.c @@ -1,9 +1,6 @@ /* $Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,8 +15,6 @@ static char *id = "$Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ Copyrigh #include "version.h" - - /* * main.c * This file includes main() @@ -27,10 +22,10 @@ static char *id = "$Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ Copyrigh #include "lispemul.h" #include "dbprint.h" -#include +#include #ifndef DOS -#include -#include +#include +#include #else /* DOS */ #define MAXPATHLEN 128 #define R_OK 04 @@ -38,38 +33,37 @@ static char *id = "$Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ Copyrigh #define rindex strrchr #include #include -#include +#include #endif /* DOS */ #ifndef NOETHER #ifndef USE_DLPI -#include /* needed for Ethernet stuff below */ -#endif /* USE_DLPI */ -#endif /* NOETHER */ -#include +#include /* needed for Ethernet stuff below */ +#endif /* USE_DLPI */ +#endif /* NOETHER */ +#include #ifndef SYSVONLY #ifndef DOS -#include +#include #endif /* DOS */ -#else /* SYSVONLY -IS- ON */ +#else /* SYSVONLY -IS- ON */ #include #include #endif /* SYSVONLY */ #ifndef DOS -#include +#include #endif /* DOS */ -#include +#include #ifndef DOS -#include +#include #endif /* DOS */ #ifdef RISCOS #include #endif /* RISCOS */ - #ifdef ISC #include #include @@ -79,7 +73,7 @@ static char *id = "$Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ Copyrigh #include #endif -#include +#include #include "emlglob.h" #include "address.h" @@ -98,66 +92,65 @@ static char *id = "$Id: main.c,v 1.4 2001/12/26 22:17:03 sybalsky Exp $ Copyrigh #include "timeout.h" -DLword *Lisp_world; /* lispworld */ +DLword *Lisp_world; /* lispworld */ /********** 68k address for Lisp Space **********/ -DLword *Atomspace; -DLword *Stackspace; -DLword *Plistspace; -DLword *DTDspace; -DLword *MDStypetbl; -DLword *AtomHT; -DLword *Pnamespace; -DLword *AtomSpace; -DLword *Defspace; -DLword *Valspace; -DLword *Spospspace; -DLword *Snegspace; +DLword *Atomspace; +DLword *Stackspace; +DLword *Plistspace; +DLword *DTDspace; +DLword *MDStypetbl; +DLword *AtomHT; +DLword *Pnamespace; +DLword *AtomSpace; +DLword *Defspace; +DLword *Valspace; +DLword *Spospspace; +DLword *Snegspace; /********** For Virtual Memory Management **********/ #ifdef BIGVM LispPTR *FPtoVP; #else -DLword *FPtoVP; +DLword *FPtoVP; #endif /* BIGVM */ -DLword *PAGEMap; -DLword *PageMapTBL; -DLword *LockedPageTable; +DLword *PAGEMap; +DLword *PageMapTBL; +DLword *LockedPageTable; /********** For Interface to LispMicro/Device **********/ -DLword *IOCBPage; -IOPAGE *IOPage; -IFPAGE *InterfacePage; -MISCSTATS *MiscStats; +DLword *IOCBPage; +IOPAGE *IOPage; +IFPAGE *InterfacePage; +MISCSTATS *MiscStats; /********** UFN Table **********/ -DLword *UFNTable; +DLword *UFNTable; /********** Tables for GC **********/ #ifdef BIGVM -LispPTR *HTmain; -LispPTR *HToverflow; -LispPTR *HTbigcount; -LispPTR *HTcoll; +LispPTR *HTmain; +LispPTR *HToverflow; +LispPTR *HTbigcount; +LispPTR *HTcoll; #else -DLword *HTmain; -DLword *HToverflow; -DLword *HTbigcount; -DLword *HTcoll; +DLword *HTmain; +DLword *HToverflow; +DLword *HTbigcount; +DLword *HTcoll; #endif /* BIGVM */ /********** Display **********/ -DLword *DisplayRegion; +DLword *DisplayRegion; int DisplayInitialized = NIL; -DLword *Arrayspace; -DLword *MDS_space_bottom; -DLword *PnCharspace; -struct dtd *ListpDTD; - +DLword *Arrayspace; +DLword *MDS_space_bottom; +DLword *PnCharspace; +struct dtd *ListpDTD; /********** For Lisp Emulator **********/ -struct state MachineState; +struct state MachineState; /**********************************/ /*** Share val with LISP code ******/ @@ -172,7 +165,7 @@ LispPTR *Next_MDSpage_word; LispPTR *Next_Array_word; LispPTR *MDS_free_page_word; -LispPTR *Reclaim_cnt_word ; +LispPTR *Reclaim_cnt_word; /*** Cache Values for reclaimer by Tomtom 30-Sep-1987 ***/ LispPTR *GcDisabled_word; @@ -189,7 +182,6 @@ LispPTR *System_Buffer_List_word; /*** The end of the addition of cache values on reclaimer ***/ - /*** cache values for the top level reclaimer's implementation ***/ LispPTR *GcMess_word; @@ -199,7 +191,7 @@ LispPTR *GcTime2_word; LispPTR *MaxTypeNumber_word; /*** The end of the addition of cache values for top reclaimer by Tomtom - 15-Oct-1987 ***/ + 15-Oct-1987 ***/ /* Pointers for closure caching */ @@ -226,7 +218,7 @@ LispPTR *MACHINETYPE_word; LispPTR STORAGEFULLSTATE_index; LispPTR *LASTVMEMFILEPAGE_word; -LispPTR *VMEM_FULL_STATE_word ; +LispPTR *VMEM_FULL_STATE_word; /** Array for N-tran **/ @@ -256,46 +248,47 @@ extern struct sockaddr_nit snit; #ifdef INIT int for_makeinit = 1; #else -int for_makeinit = 0; +int for_makeinit = 0; #endif /* INIT */ -int kbd_for_makeinit = 0; -int save_argc; -char **save_argv; -int display_max = 65536*16*2; +int kbd_for_makeinit = 0; +int save_argc; +char **save_argv; +int display_max = 65536 * 16 * 2; /* diagnostic flag for sysout dumping */ extern int maxpages; /** For call makepathname inside main() **/ -extern int *Lisp_errno; -extern int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ +extern int *Lisp_errno; +extern int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ char keystring[128]; #define FALSE 0 -#define TRUE !FALSE +#define TRUE !FALSE char *getenv(); int Lisp_Xinitialized = FALSE; -char sysout_name[1024]; /* Set by read_Xoption, in the X version. */ -int sysout_size = 0; /* ditto */ +char sysout_name[1024]; /* Set by read_Xoption, in the X version. */ +int sysout_size = 0; /* ditto */ -#if defined(DOS) || defined (XWINDOW) +#if defined(DOS) || defined(XWINDOW) #include "devif.h" extern DspInterface currentdsp; #endif /* DOS || XWINDOW */ extern long MDate; -extern int nokbdflag; -extern int nomouseflag; +extern int nokbdflag; +extern int nomouseflag; #ifdef DOS extern void dispatch(); int dosdisplaymode = 0; int twobuttonflag = FALSE; -int eurokbd = TRUE; /* Assume eurokbd by default. */ -char *helpstring = "\n\ +int eurokbd = TRUE; /* Assume eurokbd by default. */ +char *helpstring = + "\n\ medley [sysout-name] [] ...\n\ Where are:\n\ sysout-name The filename of your sysout.(see manual.)\n\ @@ -312,7 +305,8 @@ Where are:\n\ -info Print general info about the system\n\ -help Print this message\n"; #elif XWINDOW -char *helpstring = "\n\ +char *helpstring = + "\n\ either setenv LDESRCESYSOUT or do:\n\ medley [] []\n\ -info Print general info about the system\n\ @@ -322,8 +316,9 @@ char *helpstring = "\n\ -bw The Medley screen borderwidth\n\ -g[eometry] ] The Medley screen geometry\n\ -sc[reen] x] The Medley screen geometry\n"; -#else /* not DOS, not XWINDOW */ -char *helpstring = "\n\ +#else /* not DOS, not XWINDOW */ +char *helpstring = + "\n\ either setenv LDESRCESYSOUT or do:\n\ lde[ether] [sysout-name] [-k access-key] []\n\ -info Print general info about the system\n\ @@ -340,348 +335,299 @@ void print_info_lines(); /* */ /************************************************************************/ -int main(argc, argv) - int argc ; - char **argv ; - { - int i; - char *envname; - extern int TIMER_INTERVAL; - char keytyped [ 255 ]; +int main(argc, argv) int argc; +char **argv; +{ + int i; + char *envname; + extern int TIMER_INTERVAL; + char keytyped[255]; #ifndef NOFORN - if (dld_find_executable (argv[0]) == 0) { - perror("Name of executable not found."); - } else if (dld_init (dld_find_executable (argv[0])) != 0) { - dld_perror( "Can't init DLD." ); - }; + if (dld_find_executable(argv[0]) == 0) { + perror("Name of executable not found."); + } else if (dld_init(dld_find_executable(argv[0])) != 0) { + dld_perror("Can't init DLD."); + }; #endif /* NOFORN */ #ifdef XWINDOW - read_Xoption( &argc, argv ); + read_Xoption(&argc, argv); #endif /* XWINDOW */ - - save_argc = argc; - save_argv = argv; + save_argc = argc; + save_argv = argv; #ifdef PROFILE - moncontrol(0); /* initially stop sampling */ -#endif /* PROFILE */ - + moncontrol(0); /* initially stop sampling */ +#endif /* PROFILE */ /* Sysout is found as follows: - If the first argument doesn't begin with '-', assume it's the sysout - Look at the environment variable LDESRCESYSOUT if that fails - Look for ~/lisp.virtualmem if that fails - Barf and print the command line if tha fails + If the first argument doesn't begin with '-', assume it's the sysout + Look at the environment variable LDESRCESYSOUT if that fails + Look for ~/lisp.virtualmem if that fails + Barf and print the command line if tha fails */ -#ifdef FSERROR - /* For call makepathname */ - Lisp_errno = &Dummy_errno; +#ifdef FSERROR + /* For call makepathname */ + Lisp_errno = &Dummy_errno; #endif - i=1; + i = 1; - if (argv[i] && ((strcmp(argv[i], "-info") == 0) || - (strcmp(argv[i], "-INFO") == 0))) { - print_info_lines(); - exit(0); - } + if (argv[i] && ((strcmp(argv[i], "-info") == 0) || (strcmp(argv[i], "-INFO") == 0))) { + print_info_lines(); + exit(0); + } - if (argv[i] && - ((strcmp(argv[i], "-help") == 0) || - (strcmp(argv[i], "-HELP") == 0))) - { - fprintf(stderr, helpstring ); - exit(0); - } + if (argv[i] && ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "-HELP") == 0))) { + fprintf(stderr, helpstring); + exit(0); + } - if(argc > 1 && argv[1][0] != '-') - { - strcpy(sysout_name, argv[1]); - i++; - } - else if ((envname = getenv("LDESRCESYSOUT")) != NULL) - { - strcpy(sysout_name, envname); - } - else if ((envname = getenv("LDESOURCESYSOUT")) != NULL) - strcpy(sysout_name, envname); + if (argc > 1 && argv[1][0] != '-') { + strcpy(sysout_name, argv[1]); + i++; + } else if ((envname = getenv("LDESRCESYSOUT")) != NULL) { + strcpy(sysout_name, envname); + } else if ((envname = getenv("LDESOURCESYSOUT")) != NULL) + strcpy(sysout_name, envname); #ifdef DOS - else if( !makepathname("lisp.vm", sysout_name) + else if (!makepathname("lisp.vm", sysout_name) #else - else if( !makepathname("~/lisp.virtualmem", sysout_name) + else if (!makepathname("~/lisp.virtualmem", sysout_name) #endif /* DOS */ - || access(sysout_name, R_OK)) - { - fprintf(stderr, "Couldn't find a sysout to run;\n"); - fprintf(stderr, helpstring ); - exit(1); + || access(sysout_name, R_OK)) { + fprintf(stderr, "Couldn't find a sysout to run;\n"); + fprintf(stderr, helpstring); + exit(1); + } + /* OK, sysout name is now in sysout_name, and i is moved past a supplied name */ + + for (; i < argc; i += 1) { /* step by 1 in case of typo */ + + /* -t and -m are undocumented and somewhat dangerous... */ + + if (!strcmp(argv[i], "-t")) { /**** timer interval ****/ + if (argc > ++i) + TIMER_INTERVAL = atoi(argv[i]); + else { + fprintf(stderr, "Missing argument after -t\n"); + exit(1); } -/* OK, sysout name is now in sysout_name, and i is moved past a supplied name */ + } - for ( ; i < argc; i += 1 ) - { /* step by 1 in case of typo */ - - /* -t and -m are undocumented and somewhat dangerous... */ + else if (!strcmp(argv[i], "-m")) { /**** sysout size ****/ + if (argc > ++i) + sysout_size = atoi(argv[i]); + else { + fprintf(stderr, "Missing argument after -m\n"); + exit(1); + } + } - if (! strcmp(argv[i], "-t")) - { /**** timer interval ****/ - if(argc > ++i) TIMER_INTERVAL = atoi(argv[i]); - else - { - fprintf(stderr, "Missing argument after -t\n"); - exit(1); - } - } + else if (!strcmp(argv[i], "-NF")) { /**** Don't fork (for dbxing) ****/ + please_fork = 0; + } - else if (! strcmp(argv[i], "-m")) - { /**** sysout size ****/ - if(argc > ++i) sysout_size = atoi(argv[i]); - else - { - fprintf(stderr, "Missing argument after -m\n"); - exit(1); - } - } - - else if (! strcmp(argv[i], "-NF")) - { /**** Don't fork (for dbxing) ****/ - please_fork = 0; - } - - else if ( ! strcmp(argv[i], "-INIT")) - { /*** init sysout, no packaged */ - for_makeinit = 1; - } - else if (! strcmp(argv[i], "-k")) - { /**** security key ****/ - - if(argc > ++i) { (void)strcpy(keystring, argv[i]); } - else - { - fprintf(stderr, "Missing argument after -k\n"); - exit(1); - } - } + else if (!strcmp(argv[i], "-INIT")) { /*** init sysout, no packaged */ + for_makeinit = 1; + } else if (!strcmp(argv[i], "-k")) { /**** security key ****/ + if (argc > ++i) { + (void)strcpy(keystring, argv[i]); + } else { + fprintf(stderr, "Missing argument after -k\n"); + exit(1); + } + } #ifdef DOS - else if ((strcmp(argv[i], "-vga") == 0) || - (strcmp(argv[i], "-VGA") == 0)) - { - dosdisplaymode = 1; - } - else if ((strcmp(argv[i], "-vesa102") == 0) || - (strcmp(argv[i], "-VESA102") == 0)) - { - dosdisplaymode = 0x102; - } - else if ((strcmp(argv[i], "-vesa104") == 0) || - (strcmp(argv[i], "-VESA104") == 0)) - { - dosdisplaymode = 0x104; - } - else if ((strcmp(argv[i], "-2button") == 0) || - (strcmp(argv[i], "-2BUTTON") == 0)) { - twobuttonflag = TRUE; - } - else if ((strcmp(argv[i], "-3button") == 0) || - (strcmp(argv[i], "-3BUTTON") == 0)) { - twobuttonflag = FALSE; - } - else if ((strcmp(argv[i], "-noeurokbd") == 0) || - (strcmp(argv[i], "-NOEUROKBD") == 0)) { - eurokbd = FALSE; - } - else if ((strcmp(argv[i], "-eurokbd") == 0) || - (strcmp(argv[i], "-EUROKBD") == 0)) { - eurokbd = TRUE; - } - else if ((strcmp(argv[i], "-nokbd") == 0) || - (strcmp(argv[i], "-NOKBD") == 0)) { - nokbdflag = TRUE; - } - else if ((strcmp(argv[i], "-nomouse") == 0) || - (strcmp(argv[i], "-NOMOUSE") == 0)) { - nomouseflag = TRUE; - } + else if ((strcmp(argv[i], "-vga") == 0) || (strcmp(argv[i], "-VGA") == 0)) { + dosdisplaymode = 1; + } else if ((strcmp(argv[i], "-vesa102") == 0) || (strcmp(argv[i], "-VESA102") == 0)) { + dosdisplaymode = 0x102; + } else if ((strcmp(argv[i], "-vesa104") == 0) || (strcmp(argv[i], "-VESA104") == 0)) { + dosdisplaymode = 0x104; + } else if ((strcmp(argv[i], "-2button") == 0) || (strcmp(argv[i], "-2BUTTON") == 0)) { + twobuttonflag = TRUE; + } else if ((strcmp(argv[i], "-3button") == 0) || (strcmp(argv[i], "-3BUTTON") == 0)) { + twobuttonflag = FALSE; + } else if ((strcmp(argv[i], "-noeurokbd") == 0) || (strcmp(argv[i], "-NOEUROKBD") == 0)) { + eurokbd = FALSE; + } else if ((strcmp(argv[i], "-eurokbd") == 0) || (strcmp(argv[i], "-EUROKBD") == 0)) { + eurokbd = TRUE; + } else if ((strcmp(argv[i], "-nokbd") == 0) || (strcmp(argv[i], "-NOKBD") == 0)) { + nokbdflag = TRUE; + } else if ((strcmp(argv[i], "-nomouse") == 0) || (strcmp(argv[i], "-NOMOUSE") == 0)) { + nomouseflag = TRUE; + } #endif /* DOS */ - - /* Can only do this under SUNOs, for now */ - else if (! strcmp(argv[i], "-E")) - { /**** ethernet info ****/ + + /* Can only do this under SUNOs, for now */ + else if (!strcmp(argv[i], "-E")) { /**** ethernet info ****/ #ifdef NOETHER #else - int b0, b1, b2, b3, b4, b5; + int b0, b1, b2, b3, b4, b5; #ifdef USE_DLPI - if(argc > ++i && sscanf(argv[i],"%d:%x:%x:%x:%x:%x:%x",ðer_fd, - &b0, &b1, &b2, &b3, &b4, &b5) == 7) + if (argc > ++i && + sscanf(argv[i], "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5) == 7) #else - if(argc > ++i && sscanf(argv[i],"%d:%x:%x:%x:%x:%x:%x:%s",ðer_fd, - &b0, &b1, &b2, &b3, &b4, &b5, snit.snit_ifname) == 8) + if (argc > ++i && + sscanf(argv[i], "%d:%x:%x:%x:%x:%x:%x:%s", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5, + snit.snit_ifname) == 8) #endif /* USE_FDLPI */ - { - ether_host[0] = b0; ether_host[1] = b1; - ether_host[2] = b2; ether_host[3] = b3; - ether_host[4] = b4; ether_host[5] = b5; - } - else - { - fprintf(stderr, "Missing or bogus -E argument\n"); - ether_fd = -1; - exit(1); - } + { + ether_host[0] = b0; + ether_host[1] = b1; + ether_host[2] = b2; + ether_host[3] = b3; + ether_host[4] = b4; + ether_host[5] = b5; + } else { + fprintf(stderr, "Missing or bogus -E argument\n"); + ether_fd = -1; + exit(1); + } #endif /* NOETHER */ - } - /* diagnostic flag for big vmem write() calls */ - else if (! strcmp(argv[i], "-xpages")) - { - if(argc > ++i) maxpages = atoi(argv[i]); - else - { - fprintf(stderr, "Missing argument after -xpages\n"); - exit(1); - } - } + } + /* diagnostic flag for big vmem write() calls */ + else if (!strcmp(argv[i], "-xpages")) { + if (argc > ++i) + maxpages = atoi(argv[i]); + else { + fprintf(stderr, "Missing argument after -xpages\n"); + exit(1); } + } + } - /* Sanity checks. */ +/* Sanity checks. */ #ifdef DOS - probemouse(); /* See if the mouse is connected. */ + probemouse(); /* See if the mouse is connected. */ #else - if ( getuid() != geteuid() ) { - fprintf(stderr, "Effective user is not real user. Setting euid to uid.\n"); - seteuid(getuid()); - } + if (getuid() != geteuid()) { + fprintf(stderr, "Effective user is not real user. Setting euid to uid.\n"); + seteuid(getuid()); + } #endif /* DOS */ - if ( keystring ) /* key given, so safe to copy */ - strcpy ( keytyped, keystring ); + if (keystring) /* key given, so safe to copy */ + strcpy(keytyped, keystring); - if ( keytester(keystring) ) { /* keytester destroys keystring */ - fprintf (stderr, "Sorry, invalid or expired access key.\n" ); - fprintf (stderr, "Key tried: %s\n", keytyped ); - exit(-1); - } + if (keytester(keystring)) { /* keytester destroys keystring */ + fprintf(stderr, "Sorry, invalid or expired access key.\n"); + fprintf(stderr, "Key tried: %s\n", keytyped); + exit(-1); + } #ifndef NOETHER - init_ether(); /* modified by kiuchi Nov. 4 */ -#endif /* NOETHER */ - + init_ether(); /* modified by kiuchi Nov. 4 */ +#endif /* NOETHER */ #ifdef FORKCOMM - /* Fork Unix was called in kickstarter; if we forked, look up the */ - /* pipe handles to the subprocess and set them up. */ + /* Fork Unix was called in kickstarter; if we forked, look up the */ + /* pipe handles to the subprocess and set them up. */ - if(FindUnixPipes()) /* must call the routine to allocate storage, */ - { /* in case we're re-starting a savevm w/open ptys */ - if(please_fork) - fprintf(stderr, - "Failed to find UNIXCOMM file handles; no processes\n"); - } + if (FindUnixPipes()) /* must call the routine to allocate storage, */ + { /* in case we're re-starting a savevm w/open ptys */ + if (please_fork) fprintf(stderr, "Failed to find UNIXCOMM file handles; no processes\n"); + } #else - /* Fork Unix Interface subprocess before we create anything big; */ - /* interrupts need to be blocked here so subprocess won't see them */ - /* This should actually live in the kickstarter... */ +/* Fork Unix Interface subprocess before we create anything big; */ +/* interrupts need to be blocked here so subprocess won't see them */ +/* This should actually live in the kickstarter... */ #ifdef DOS - init_host_filesystem(); + init_host_filesystem(); #else - if(please_fork){int_block(); fork_Unix();} + if (please_fork) { + int_block(); + fork_Unix(); + } #endif /* DOS */ #endif /* FORKCOMM */ -#if defined(DOS) || defined (XWINDOW) - make_dsp_instance(currentdsp, 0, 0, 0, 1 ); /* All defaults the first time */ -#endif /* DOS || XWINDOW */ +#if defined(DOS) || defined(XWINDOW) + make_dsp_instance(currentdsp, 0, 0, 0, 1); /* All defaults the first time */ +#endif /* DOS || XWINDOW */ - /* Load sysout to VM space and returns real sysout_size(not 0) */ - sysout_size= sysout_loader(sysout_name, sysout_size); + /* Load sysout to VM space and returns real sysout_size(not 0) */ + sysout_size = sysout_loader(sysout_name, sysout_size); - build_lisp_map(); /* built up map */ + build_lisp_map(); /* built up map */ - init_ifpage(sysout_size); /* init interface page */ - init_iopage(); - init_miscstats(); + init_ifpage(sysout_size); /* init interface page */ + init_iopage(); + init_miscstats(); #ifdef NEW_STORAGE - init_storage(); + init_storage(); #endif /* NEW_STORAGE */ - set_cursor(); + set_cursor(); - /* file system directory enumeration stuff */ - if (!init_finfo()) - { - fprintf(stderr, "Cannot allocate internal data.\n"); - exit(1); - } + /* file system directory enumeration stuff */ + if (!init_finfo()) { + fprintf(stderr, "Cannot allocate internal data.\n"); + exit(1); + } #ifdef RS232 - rs232c_init(); + rs232c_init(); #endif - /* Get OS message to ~/lisp.log and print the message to prompt window */ - if(!for_makeinit) - { + /* Get OS message to ~/lisp.log and print the message to prompt window */ + if (!for_makeinit) { #ifdef SUNDISPLAY - mess_init(); + mess_init(); #endif /* SUNDISPLAY */ - init_keyboard(0); /* can't turn on the keyboard yet or you will die - in makeinit. Pilotbitblt will turn it on if - you used the proper switches when building LDE. - JDS -- 1/18/90 also BITBLTSUB does it now. */ - } + init_keyboard(0); /* can't turn on the keyboard yet or you will die + in makeinit. Pilotbitblt will turn it on if + you used the proper switches when building LDE. + JDS -- 1/18/90 also BITBLTSUB does it now. */ + } #ifdef I386 -/* 80387 initialization */ - asm(".data"); - asm(".align 4"); - asm("__FP_trunc:"); - asm(" .globl __FP_trunc"); - asm(".byte 0x3f"); - asm(".byte 0x0c"); - asm("__FP_round:"); - asm(" .globl __FP_round"); - asm(".byte 0x3f"); - asm(".byte 0x00"); - asm(".text"); - asm("fldcw __FP_round"); + /* 80387 initialization */ + asm(".data"); + asm(".align 4"); + asm("__FP_trunc:"); + asm(" .globl __FP_trunc"); + asm(".byte 0x3f"); + asm(".byte 0x0c"); + asm("__FP_round:"); + asm(" .globl __FP_round"); + asm(".byte 0x3f"); + asm(".byte 0x00"); + asm(".text"); + asm("fldcw __FP_round"); #elif DOS - _setrealmode(0x3f); /* Don't interrupt on FP overflows */ - _getrealerror(); + _setrealmode(0x3f); /* Don't interrupt on FP overflows */ + _getrealerror(); #endif /* I386 */ - - - #ifdef RS6000 - /****************************************************/ - /* For the IBM RS/6000, we have to initialize its */ - /* notion of the time zone, so gettimeofday works */ - /****************************************************/ + /****************************************************/ + /* For the IBM RS/6000, we have to initialize its */ + /* notion of the time zone, so gettimeofday works */ + /****************************************************/ - tzset(); + tzset(); #endif /* RS6000 */ #if defined(ISC) || defined(DOS) - tzset(); + tzset(); #endif #ifdef OS5 - tzset(); + tzset(); #endif /* OS5 */ - - /* now start up lisp */ - start_lisp(); - return (0); - } - - - + /* now start up lisp */ + start_lisp(); + return (0); +} /************************************************************************/ /* */ @@ -692,56 +638,48 @@ int main(argc, argv) /* */ /************************************************************************/ -void start_lisp() - { - DLword *freeptr,*next68k; +void start_lisp() { + DLword *freeptr, *next68k; - /*******************************/ - /* First, turn off any pending interrupts from during VMEMSAVE. */ - /* This keeps US from trying to handle OLD interrupts. */ - /*******************************/ +/*******************************/ +/* First, turn off any pending interrupts from during VMEMSAVE. */ +/* This keeps US from trying to handle OLD interrupts. */ +/*******************************/ #ifndef INIT - { INTSTAT * intstate = - ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); - intstate->ETHERInterrupt = 0; - intstate->LogFileIO = 0; - intstate->IOInterrupt = 0; - intstate->waitinginterrupt = 0; - intstate->intcharcode = 0; - } + { + INTSTAT *intstate = ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + intstate->ETHERInterrupt = 0; + intstate->LogFileIO = 0; + intstate->IOInterrupt = 0; + intstate->waitinginterrupt = 0; + intstate->intcharcode = 0; + } #endif /* INIT */ - TopOfStack=0; - Error_Exit = 0; + TopOfStack = 0; + Error_Exit = 0; - MState->pvar = (DLword *) Addr68k_from_LADDR( STK_OFFSET - | InterfacePage->currentfxp) - + FRAMESIZE; + MState->pvar = (DLword *)Addr68k_from_LADDR(STK_OFFSET | InterfacePage->currentfxp) + FRAMESIZE; - freeptr = next68k = Addr68k_from_LADDR(STK_OFFSET | CURRENTFX->nextblock); - - if (GETWORD(next68k) != STK_FSB_WORD) - error("Starting Lisp: Next stack block isn't free!"); + freeptr = next68k = Addr68k_from_LADDR(STK_OFFSET | CURRENTFX->nextblock); - while(GETWORD(freeptr)==STK_FSB_WORD) - EndSTKP = freeptr = freeptr + GETWORD(freeptr+1); + if (GETWORD(next68k) != STK_FSB_WORD) error("Starting Lisp: Next stack block isn't free!"); - CurrentStackPTR =next68k -2; + while (GETWORD(freeptr) == STK_FSB_WORD) EndSTKP = freeptr = freeptr + GETWORD(freeptr + 1); - FastRetCALL; + CurrentStackPTR = next68k - 2; - /* JRB - The interrupt intitialization must be done right before */ - /* entering the bytecode dispatch loop; interrupts get */ - /* unblocked here */ - int_init(); + FastRetCALL; + + /* JRB - The interrupt intitialization must be done right before */ + /* entering the bytecode dispatch loop; interrupts get */ + /* unblocked here */ + int_init(); #ifdef DOS - _dpmi_lockregion((void *)&dispatch, 32768); + _dpmi_lockregion((void *)&dispatch, 32768); #endif /* DOS */ - dispatch(); - } - - - + dispatch(); +} /************************************************************************/ /* */ @@ -751,151 +689,135 @@ void start_lisp() /* */ /************************************************************************/ -int makepathname(src, dst) - register char *src; - register char *dst; - { - register int len; - register char *base, *cp; - register struct passwd *pwd; - char name[MAXPATHLEN]; +int makepathname(src, dst) register char *src; +register char *dst; +{ + register int len; + register char *base, *cp; + register struct passwd *pwd; + char name[MAXPATHLEN]; - base = src; - switch ( *base ) - { - case '.': + base = src; + switch (*base) { + case '.': #ifdef DOS - if(getcwd(dst, MAXPATHLEN) == 0) + if (getcwd(dst, MAXPATHLEN) == 0) #else - if(getwd(dst) == 0) -#endif /* DOS */ - { /* set working directory */ + if (getwd(dst) == 0) +#endif /* DOS */ + { /* set working directory */ #ifdef FSERROR - *Lisp_errno = errno; + *Lisp_errno = errno; #endif - return(0); - } - switch ( *(base+1) ) - { - case '.': - if(*(base+2) == '/') - { /* Now, base == "../xxxx" */ - cp = (char *)strrchr(dst, '/'); - if(cp == 0) return(0); - *cp = '\0'; - strcat(dst, base+2); - return(1); - } - else return(0); - case '/': - /* Now, base == "./xxx" */ - strcat(dst, base+1); - return(1); - default: - return(0); - } - case '~': -#ifdef FSERROR - ERRSETJMP(0); -#else - SETJMP(0); -#endif - if( *(base+1) == '/') - { - /* path is "~/foo" */ -#ifdef DOS - pwd = 0; -#else - TIMEOUT( pwd = getpwuid( getuid()) ); -#endif /* DOS */ - if(pwd == NULL) - { -#ifdef FSERROR - *Lisp_errno = errno; -#endif - return(0); - } -#ifndef DOS - sprintf(dst, "%s%s", pwd->pw_dir, base+1); -#endif - return(1); - } - else - { - /* path is "~foo/" */ - if((cp=(char *)strchr(base+1, '/')) == 0) return(0); - else - { - len = (UNSIGNED)cp - (UNSIGNED)base -1; - strncpy(name, base+1, len); - name[len] = '\0'; -#ifndef DOS - TIMEOUT( pwd = getpwnam(name) ); -#endif /* DOS */ - if(pwd == NULL) - { -#ifdef FSERROR - *Lisp_errno = errno; -#endif - return(0); - } -#ifndef DOS - sprintf(dst, "%s%s", pwd->pw_dir, cp); -#endif /* DOS */ - return(1); - } - } - default: - strcpy(dst, src); - return(1); + return (0); } + switch (*(base + 1)) { + case '.': + if (*(base + 2) == '/') { /* Now, base == "../xxxx" */ + cp = (char *)strrchr(dst, '/'); + if (cp == 0) return (0); + *cp = '\0'; + strcat(dst, base + 2); + return (1); + } else + return (0); + case '/': + /* Now, base == "./xxx" */ + strcat(dst, base + 1); + return (1); + default: return (0); + } + case '~': +#ifdef FSERROR + ERRSETJMP(0); +#else + SETJMP(0); +#endif + if (*(base + 1) == '/') { +/* path is "~/foo" */ +#ifdef DOS + pwd = 0; +#else + TIMEOUT(pwd = getpwuid(getuid())); +#endif /* DOS */ + if (pwd == NULL) { +#ifdef FSERROR + *Lisp_errno = errno; +#endif + return (0); + } +#ifndef DOS + sprintf(dst, "%s%s", pwd->pw_dir, base + 1); +#endif + return (1); + } else { + /* path is "~foo/" */ + if ((cp = (char *)strchr(base + 1, '/')) == 0) + return (0); + else { + len = (UNSIGNED)cp - (UNSIGNED)base - 1; + strncpy(name, base + 1, len); + name[len] = '\0'; +#ifndef DOS + TIMEOUT(pwd = getpwnam(name)); +#endif /* DOS */ + if (pwd == NULL) { +#ifdef FSERROR + *Lisp_errno = errno; +#endif + return (0); + } +#ifndef DOS + sprintf(dst, "%s%s", pwd->pw_dir, cp); +#endif /* DOS */ + return (1); + } + } + default: strcpy(dst, src); return (1); } +} - - -void print_info_lines () - { +void print_info_lines() { #if (RELEASE == 200) - printf("Emulator for Medley release 2.0\n"); + printf("Emulator for Medley release 2.0\n"); #elif (RELEASE == 201) - printf("Emulator for Medley release 2.01\n"); + printf("Emulator for Medley release 2.01\n"); #elif (RELEASE == 210) - printf("Emulator for Medley release 2.1\n"); + printf("Emulator for Medley release 2.1\n"); #elif (RELEASE == 300) - printf("Emulator for Medley release 3.0\n"); + printf("Emulator for Medley release 3.0\n"); #elif (RELEASE == 350) - printf("Emulator for Medley release 3.5\n"); + printf("Emulator for Medley release 3.5\n"); #elif (RELEASE == 351) - printf("Emulator for Medley release 3.51\n"); + printf("Emulator for Medley release 3.51\n"); #endif /* RELEASE */ #if defined(MACOSX) || defined(FREEBSD) - printf("Creation date: %s", ctime((const time_t *)&MDate)); + printf("Creation date: %s", ctime((const time_t *)&MDate)); #else - printf("Creation date: %s", ctime(&MDate)); + printf("Creation date: %s", ctime(&MDate)); #endif #ifdef DEMO - printf("Demonstration emulator, not for commercial use\n"); + printf("Demonstration emulator, not for commercial use\n"); #endif /* DEMO */ #ifdef LPSOLVE - printf("Contains lp_solve LP solver.\n"); + printf("Contains lp_solve LP solver.\n"); #endif /* LPSOLVE */ #ifdef BIGBIGVM - printf("Supports 256Mb virtual memory.\n"); + printf("Supports 256Mb virtual memory.\n"); #elif BIGVM - printf("Supports 64Mb virtual memory.\n"); + printf("Supports 64Mb virtual memory.\n"); #else - printf("Supports 32Mb virtual memory.\n"); + printf("Supports 32Mb virtual memory.\n"); #endif /* BIGVM */ #ifdef NOVERSION - printf("Does not enforce SYSOUT version matching.\n"); + printf("Does not enforce SYSOUT version matching.\n"); #endif /* NOVERSION */ #ifdef NOFORN - printf("Has no foreign-function-call interface.\n"); -#endif /* NOFORN */ + printf("Has no foreign-function-call interface.\n"); +#endif /* NOFORN */ #ifdef NOEUROKBD - printf("No support for European keyboards.\n"); + printf("No support for European keyboards.\n"); #else - printf("Supports Sun European Type-4/5 keyboards.\n"); + printf("Supports Sun European Type-4/5 keyboards.\n"); #endif /* NOEUROKBD */ - - } +} diff --git a/src/misc7.c b/src/misc7.c old mode 100755 new mode 100644 index 74469bb..8ab8a64 --- a/src/misc7.c +++ b/src/misc7.c @@ -1,7 +1,6 @@ -/* $Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,7 +15,6 @@ static char *id = "$Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ Copyrig #include "version.h" - /* misc7.c */ #include @@ -36,7 +34,7 @@ static char *id = "$Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ Copyrig #include "dbprint.h" /* osamu '90/02/08 * add display.h, because in_display_secment() is changed as - * macro. difinition is in display.h + * macro. difinition is in display.h */ #include "display.h" @@ -50,84 +48,75 @@ static char *id = "$Id: misc7.c,v 1.2 1999/01/03 02:07:22 sybalsky Exp $ Copyrig #include #endif +/*************************************************/ +/* Possible operation fields for FBITMAPBIT */ +/*************************************************/ - - /*************************************************/ - /* Possible operation fields for FBITMAPBIT */ - /*************************************************/ - -#define OP_INVERT 0 /* Invert the bit at the given location */ -#define OP_ERASE 1 /* Turn the given bit off. */ -#define OP_READ 2 /* Just read the bit that's there. */ -#define OP_PAINT 3 /* Turn the bit on. */ - +#define OP_INVERT 0 /* Invert the bit at the given location */ +#define OP_ERASE 1 /* Turn the given bit off. */ +#define OP_READ 2 /* Just read the bit that's there. */ +#define OP_PAINT 3 /* Turn the bit on. */ extern int LispWindowFd; extern int ScreenLocked; - /*** N_OP_misc7 -- pseudocolor or fbitmapbit ***/ -LispPTR N_OP_misc7(arg1, arg2, arg3, arg4, arg5, arg6, arg7, alpha) - int alpha; - register LispPTR arg1, arg2, arg3, arg4, arg5, arg6, arg7; - { - DLword *base; - int x, y, operation, heightminus1, rasterwidth, oldbit; - int displayflg; +LispPTR N_OP_misc7(arg1, arg2, arg3, arg4, arg5, arg6, arg7, alpha) int alpha; +register LispPTR arg1, arg2, arg3, arg4, arg5, arg6, arg7; +{ + DLword *base; + int x, y, operation, heightminus1, rasterwidth, oldbit; + int displayflg; - DBPRINT(("MISC7 op with alpha byte %d.\n", alpha)); + DBPRINT(("MISC7 op with alpha byte %d.\n", alpha)); - if (alpha != 1) ERROR_EXIT(arg7); + if (alpha != 1) ERROR_EXIT(arg7); - base = Addr68k_from_LADDR(arg1); - N_GETNUMBER(arg2, x, doufn); - N_GETNUMBER(arg3, y, doufn); - N_GETNUMBER(arg4, operation, doufn); - N_GETNUMBER(arg5, heightminus1, doufn); - N_GETNUMBER(arg6, rasterwidth, doufn); + base = Addr68k_from_LADDR(arg1); + N_GETNUMBER(arg2, x, doufn); + N_GETNUMBER(arg3, y, doufn); + N_GETNUMBER(arg4, operation, doufn); + N_GETNUMBER(arg5, heightminus1, doufn); + N_GETNUMBER(arg6, rasterwidth, doufn); - DBPRINT(("MISC7 args OK.\n")); + DBPRINT(("MISC7 args OK.\n")); - displayflg = n_new_cursorin(base, x, (heightminus1 - y), 1, 1); + displayflg = n_new_cursorin(base, x, (heightminus1 - y), 1, 1); - base = base + (rasterwidth * (heightminus1 - y)) + (0xFFFF & (x>>4)); - x = 32768 >> (x & 0xF); + base = base + (rasterwidth * (heightminus1 - y)) + (0xFFFF & (x >> 4)); + x = 32768 >> (x & 0xF); - oldbit = x & *base; + oldbit = x & *base; - ScreenLocked = T; + ScreenLocked = T; #ifdef SUNDISPLAY - if (displayflg) HideCursor; + if (displayflg) HideCursor; #endif /* SUNDISPLAY */ - - switch (operation) - { - case OP_INVERT: *base ^= x; break; - case OP_ERASE: *base &= ~x; break; - case OP_READ: break; - default: *base |= x; - }; + switch (operation) { + case OP_INVERT: *base ^= x; break; + case OP_ERASE: *base &= ~x; break; + case OP_READ: break; + default: *base |= x; + }; #ifdef SUNDISPLAY #ifdef DISPLAYBUFFER - if (in_display_segment(base)) flush_display_ptrregion(base, 0, 16, 1); + if (in_display_segment(base)) flush_display_ptrregion(base, 0, 16, 1); #endif - if (displayflg) ShowCursor; + if (displayflg) ShowCursor; #endif /* SUNDISPLAY */ - #ifdef XWINDOW - if (in_display_segment(base)) flush_display_ptrregion(base, 0, 16, 1); + if (in_display_segment(base)) flush_display_ptrregion(base, 0, 16, 1); #endif /* XWINDOW */ + ScreenLocked = NIL; + DBPRINT(("FBITMAPBIT old bit = 0x%x.\n", oldbit)); + return (S_POSITIVE | (oldbit ? 1 : 0)); - ScreenLocked = NIL; - DBPRINT(("FBITMAPBIT old bit = 0x%x.\n", oldbit)); - return(S_POSITIVE | (oldbit ? 1 : 0)); - -doufn: ERROR_EXIT(arg7); +doufn: + ERROR_EXIT(arg7); } /* end N_OP_misc7() */ - diff --git a/src/miscn.c b/src/miscn.c old mode 100755 new mode 100644 index 64776c4..9beddee --- a/src/miscn.c +++ b/src/miscn.c @@ -1,10 +1,6 @@ -/* $Id: miscn.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: miscn.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: miscn.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,11 +15,10 @@ static char *id = "$Id: miscn.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyrig #include "version.h" - /***********************************************************/ /* - File Name: miscn.c - Including: OP_miscn + File Name: miscn.c + Including: OP_miscn */ /***********************************************************/ @@ -40,178 +35,153 @@ static char *id = "$Id: miscn.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyrig /***********************************************************/ /* - Func Name : OP_miscn + Func Name : OP_miscn - Interface: Global Machine State - Returns: (must UFN) - 0 = continue, C code succeeded. - 1 = must UFN, C code failed. + Interface: Global Machine State + Returns: (must UFN) + 0 = continue, C code succeeded. + 1 = must UFN, C code failed. */ /***********************************************************/ -int OP_miscn(int misc_index, int arg_count) -{ +int OP_miscn(int misc_index, int arg_count) { register LispPTR *stk; register int result; static LispPTR args[255]; -/* Put the Args into a Vector */ + /* Put the Args into a Vector */ - args[0] = NIL_PTR; - stk = ((LispPTR *) CurrentStackPTR) + 1; + args[0] = NIL_PTR; + stk = ((LispPTR *)CurrentStackPTR) + 1; - {register int arg_num = arg_count; - if (arg_num > 0) { - *stk++ = (LispPTR) TopOfStack; - while(arg_num > 0) args[--arg_num] = *--stk; - } - } - -/* Select the Misc Number */ - -switch(misc_index) { - case miscn_USER_SUBR: - {register LispPTR user_subr, user_args; - N_GETNUMBER(args[0], user_subr, do_ufn); - if ((result = UserSubr(user_subr, arg_count-1, &args[1])) < 0) - goto do_ufn; - } - break; - case miscn_SXHASH: result = SX_hash(args); - break; + register int arg_num = arg_count; + if (arg_num > 0) { + *stk++ = (LispPTR)TopOfStack; + while (arg_num > 0) args[--arg_num] = *--stk; + } + } - case miscn_STRING_EQUAL_HASHBITS: - result = STRING_EQUAL_HASHBITS(args); - break; + /* Select the Misc Number */ - case miscn_STRINGHASHBITS: - result = STRING_HASHBITS(args); - break; + switch (misc_index) { + case miscn_USER_SUBR: { + register LispPTR user_subr, user_args; + N_GETNUMBER(args[0], user_subr, do_ufn); + if ((result = UserSubr(user_subr, arg_count - 1, &args[1])) < 0) goto do_ufn; + } break; + case miscn_SXHASH: result = SX_hash(args); break; - case miscn_VALUES: - if ( arg_count > 255 ) { - error ( "miscn: arg_count too big! continue punts" ); - goto do_ufn; - break; - } - result = values(arg_count, args); - break; + case miscn_STRING_EQUAL_HASHBITS: result = STRING_EQUAL_HASHBITS(args); break; - case miscn_VALUES_LIST: - /*** debugging: should be impossible, but ADB found this once -FS *****/ - if ( arg_count > 255 ) { - error ( "miscn: arg_count too big! continue punts" ); - goto do_ufn; - break; - } - result = values_list(arg_count, args); - break; + case miscn_STRINGHASHBITS: result = STRING_HASHBITS(args); break; - case miscn_LCFetchMethod: - result = LCFetchMethod(args[0],args[1]); - if (result < 0) goto lc_ufn; - break; + case miscn_VALUES: + if (arg_count > 255) { + error("miscn: arg_count too big! continue punts"); + goto do_ufn; + break; + } + result = values(arg_count, args); + break; - case miscn_LCFetchMethodOrHelp: - result = LCFetchMethodOrHelp(args[0],args[1]); - if (result < 0) goto lc_ufn; - break; + case miscn_VALUES_LIST: + /*** debugging: should be impossible, but ADB found this once -FS *****/ + if (arg_count > 255) { + error("miscn: arg_count too big! continue punts"); + goto do_ufn; + break; + } + result = values_list(arg_count, args); + break; - case miscn_LCFindVarIndex: - result = LCFindVarIndex(args[0],args[1]); - if (result < 0) goto lc_ufn; - break; + case miscn_LCFetchMethod: + result = LCFetchMethod(args[0], args[1]); + if (result < 0) goto lc_ufn; + break; - case miscn_LCGetIVValue: - result = LCGetIVValue(args[0],args[1]); - if (result < 0) goto lc_ufn; - break; + case miscn_LCFetchMethodOrHelp: + result = LCFetchMethodOrHelp(args[0], args[1]); + if (result < 0) goto lc_ufn; + break; - case miscn_LCPutIVValue: - result = LCPutIVValue(args[0],args[1],args[2]); - if (result < 0) goto lc_ufn; - break; + case miscn_LCFindVarIndex: + result = LCFindVarIndex(args[0], args[1]); + if (result < 0) goto lc_ufn; + break; + + case miscn_LCGetIVValue: + result = LCGetIVValue(args[0], args[1]); + if (result < 0) goto lc_ufn; + break; + + case miscn_LCPutIVValue: + result = LCPutIVValue(args[0], args[1], args[2]); + if (result < 0) goto lc_ufn; + break; #ifdef RS232 - case miscn_RAW_RS232C_OPEN: - if((result = raw_rs232c_open(args[0]))==NIL) - goto do_ufn; + case miscn_RAW_RS232C_OPEN: + if ((result = raw_rs232c_open(args[0])) == NIL) goto do_ufn; - break; + break; - case miscn_RAW_RS232C_CLOSE: - if((result = raw_rs232c_close(args[0]))==NIL) - goto do_ufn; + case miscn_RAW_RS232C_CLOSE: + if ((result = raw_rs232c_close(args[0])) == NIL) goto do_ufn; - break; + break; - - case miscn_RAW_RS232C_SETPARAM: - if((result = raw_rs232c_setparams(args[0],args[1])) - == NIL) goto do_ufn; - break; - case miscn_RAW_RS232C_GETPARAM: - /******/ break; - case miscn_RAW_RS232C_READ: - if((result = raw_rs232c_read(args[0],args[1],args[2])) - == NIL) goto do_ufn; - break; - case miscn_RAW_RS232C_WRITE: - if((result = raw_rs232c_write(args[0],args[1],args[2])) - == NIL) goto do_ufn; - break; - case miscn_RAW_RS232C_SETINT: - if((result = raw_rs232c_setint(args[0],args[1])) - ==NIL) goto do_ufn; - break; - case miscn_CHATTER: - result = chatter(args); - break; + case miscn_RAW_RS232C_SETPARAM: + if ((result = raw_rs232c_setparams(args[0], args[1])) == NIL) goto do_ufn; + break; + case miscn_RAW_RS232C_GETPARAM: + /******/ break; + case miscn_RAW_RS232C_READ: + if ((result = raw_rs232c_read(args[0], args[1], args[2])) == NIL) goto do_ufn; + break; + case miscn_RAW_RS232C_WRITE: + if ((result = raw_rs232c_write(args[0], args[1], args[2])) == NIL) goto do_ufn; + break; + case miscn_RAW_RS232C_SETINT: + if ((result = raw_rs232c_setint(args[0], args[1])) == NIL) goto do_ufn; + break; + case miscn_CHATTER: result = chatter(args); break; #endif /* RS232 */ #ifdef JLISP - case miscn_EJLISP: + case miscn_EJLISP: #ifndef NOWNN - result = ejlisp(args); + result = ejlisp(args); #endif - break; + break; #endif /* JLISP */ #ifdef CDROM - case miscn_CDAUDIO: - result = cdaudio(args); - break; - case miscn_CDROM: - result = cdrom(args); - break; + case miscn_CDAUDIO: result = cdaudio(args); break; + case miscn_CDROM: result = cdrom(args); break; #endif /* CDROM */ - case /* miscn_CALL_C*/ 014:/* result = call_c_fn(args); */ - break; + case /* miscn_CALL_C*/ 014: /* result = call_c_fn(args); */ break; - default : - goto do_ufn; - break; + default: goto do_ufn; break; - }/* switch end */ + } /* switch end */ -/* Setup Global Machine State for a Normal Return */ + /* Setup Global Machine State for a Normal Return */ - PC += 3; - CurrentStackPTR = (DLword *) (stk - 1); - TopOfStack = (LispPTR) result; - return(0); + PC += 3; + CurrentStackPTR = (DLword *)(stk - 1); + TopOfStack = (LispPTR)result; + return (0); /* A UFN request, so return 1 & don't change the Machine State */ do_ufn: - return(1); + return (1); lc_ufn: - if (result == -2) { - return(0); /* have built new stack frame */ - }else{ - goto do_ufn; - } + if (result == -2) { + return (0); /* have built new stack frame */ + } else { + goto do_ufn; + } - -}/* OP_miscn */ +} /* OP_miscn */ diff --git a/src/mkatom.c b/src/mkatom.c old mode 100755 new mode 100644 index b649b0e..bf0a41e --- a/src/mkatom.c +++ b/src/mkatom.c @@ -1,12 +1,7 @@ -/* $Id: mkatom.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: mkatom.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: mkatom.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ Copyright (C) Venue"; - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -21,29 +16,27 @@ static char *id = "$Id: mkatom.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ Copyri #include "version.h" - /**********************************************************************/ /* - File Name : makeatom.c + File Name : makeatom.c - Desc. : Create atom + Desc. : Create atom - Date : January 29, 1987 - Edited by : Takeshi Shimizu - Change : create_symbol - take,30-Jun - 1 May 1987 take - 28 Aug. 1987 take + Date : January 29, 1987 + Edited by : Takeshi Shimizu + Change : create_symbol + take,30-Jun + 1 May 1987 take + 28 Aug. 1987 take - Including : make_atom - compute_hash - create_symbol - compare_chars - parse_number + Including : make_atom + compute_hash + create_symbol + compare_chars + parse_number */ /**********************************************************************/ - #include "lispemul.h" #include "adr68k.h" #include "lsptypes.h" @@ -51,44 +44,41 @@ static char *id = "$Id: mkatom.c,v 1.4 2001/12/24 01:09:05 sybalsky Exp $ Copyri #include "cell.h" #include "dbprint.h" -#define ATOMoffset 2 /* NIL NOBIND */ -#define MAX_ATOMINDEX 0xffff /* max number of atoms */ +#define ATOMoffset 2 /* NIL NOBIND */ +#define MAX_ATOMINDEX 0xffff /* max number of atoms */ -#define Atom_reprobe( hash , char ) ((((char) ^ (hash))| 1) & 63 ) +#define Atom_reprobe(hash, char) ((((char)^(hash)) | 1) & 63) -extern DLword *Lisp_world ; +extern DLword *Lisp_world; /**********************************************************************/ /* - Func name : compute_hash + Func name : compute_hash - Compute hash value from chars. - THIS ONLY WORKS CORRECTLY ON EMULATOR STRINGS. - Don't use it with strings in lisp-space. + Compute hash value from chars. + THIS ONLY WORKS CORRECTLY ON EMULATOR STRINGS. + Don't use it with strings in lisp-space. - Date : January 29, 1987 - Chan. Aug. 27 87 take - Edited by : Takeshi Shimizu + Date : January 29, 1987 + Chan. Aug. 27 87 take + Edited by : Takeshi Shimizu */ /**********************************************************************/ +DLword compute_hash(char *char_base, DLword offset, DLword length) { + DLword hash; + DLword number; + DLword temp1, temp2; + DLword *word_base; + char_base += offset; + hash = (int)(*(char_base)) << 8; /* get first byte */ + char_base++; /* skip length area */ -DLword compute_hash (char *char_base, DLword offset, DLword length) -{ - DLword hash; - DLword number; - DLword temp1,temp2; - DLword *word_base; - char_base +=offset; - hash = (int)(*(char_base)) << 8 ; /* get first byte */ - char_base++ ; /* skip length area */ - - for (number= 1; number <= length -1; char_base++, number++) - { - hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; - temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; - hash = (int)(temp1 + (*(char_base))) & 0x0ffff ; - } + for (number = 1; number <= length - 1; char_base++, number++) { + hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; + temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; + hash = (int)(temp1 + (*(char_base))) & 0x0ffff; + } return (hash); @@ -96,358 +86,314 @@ DLword compute_hash (char *char_base, DLword offset, DLword length) /**********************************************************************/ /* - Func name : compute_lisp_hash + Func name : compute_lisp_hash - Compute hash value from chars. WORKS ONLY ON LISP CHARS. + Compute hash value from chars. WORKS ONLY ON LISP CHARS. - Date : January 29, 1987 - Chan. Aug. 27 87 take - Edited by : Takeshi Shimizu + Date : January 29, 1987 + Chan. Aug. 27 87 take + Edited by : Takeshi Shimizu */ /**********************************************************************/ +DLword compute_lisp_hash(char *char_base, DLword offset, DLword length, DLword fatp) { + DLword hash; + DLword number; + DLword temp1, temp2; + DLword *word_base; -DLword compute_lisp_hash (char *char_base, DLword offset, DLword length, DLword fatp) -{ - DLword hash; - DLword number; - DLword temp1,temp2; - DLword *word_base; + if (length == 0) return (0); - if (length == 0) return(0); + if (fatp) { /* fat characters in the string to be searched. */ + word_base = (DLword *)char_base; + word_base += offset; + hash = (DLword)(0xFF & GETWORD(word_base)) << 8; /* get first byte */ + word_base++; /* skip length area */ - if (fatp) - { /* fat characters in the string to be searched. */ - word_base = (DLword *)char_base; - word_base +=offset; - hash = (DLword)(0xFF & GETWORD(word_base)) << 8 ; /* get first byte */ - word_base++ ; /* skip length area */ + for (number = 1; number <= length - 1; word_base++, number++) { + hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; + temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; + hash = (int)(temp1 + (0xFF & GETWORD(word_base))) & 0x0ffff; + } + } else { + char_base += offset; + hash = (int)(0xFF & GETBYTE(char_base)) << 8; /* get first byte */ + char_base++; /* skip length area */ - for (number= 1; number <= length -1; word_base++, number++) - { - hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; - temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; - hash = (int)(temp1 + (0xFF & GETWORD(word_base))) & 0x0ffff ; - } - } - else - { - char_base +=offset; - hash = (int)(0xFF & GETBYTE(char_base)) << 8 ; /* get first byte */ - char_base++ ; /* skip length area */ - - for (number= 1; number <= length -1; char_base++, number++) - { - hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; - temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; - hash = (int)(temp1 + (0xFF & GETBYTE(char_base))) & 0x0ffff ; - } - } + for (number = 1; number <= length - 1; char_base++, number++) { + hash = (hash + ((hash & 4095) << 2)) & 0x0ffff; + temp1 = (hash + ((hash & 255) << 8)) & 0x0ffff; + hash = (int)(temp1 + (0xFF & GETBYTE(char_base))) & 0x0ffff; + } + } return (hash); } /* end compute_lisp_hash */ /**********************************************************************/ /* - Func name : compare_chars + Func name : compare_chars - Compare two strings, char1, char2 - char1 -- in the LISP address space (& potentially - byte swapped!) - char2 -- in emulator space, and obeying the "natural" - ordering of bytes in a string. + Compare two strings, char1, char2 + char1 -- in the LISP address space (& potentially + byte swapped!) + char2 -- in emulator space, and obeying the "natural" + ordering of bytes in a string. - Date : January 29, 1987 - Edited by : Takeshi Shimizu - (why not call strncmp directly??) - Because we need to account for byte ordering!! --JDS - AND we need to compare NS chars (which have 0s in the string) correctly! + Date : January 29, 1987 + Edited by : Takeshi Shimizu + (why not call strncmp directly??) + Because we need to account for byte ordering!! --JDS + AND we need to compare NS chars (which have 0s in the string) correctly! */ /**********************************************************************/ -LispPTR compare_chars(register char *char1, register char *char2, register DLword length) -{ +LispPTR compare_chars(register char *char1, register char *char2, register DLword length) { #ifndef BYTESWAP - if (memcmp ( char1, char2, length ) == 0) + if (memcmp(char1, char2, length) == 0) #else - if (bytecmp ( char1, char2, length )) + if (bytecmp(char1, char2, length)) #endif /* BYTESWAP */ - { - return(T); - } - else - { - return(NIL); - } - - } /* end compare_chars */ -#ifdef BYTESWAP -int bytecmp (char1, char2, len) - char *char1; - char *char2; - int len; { - int index; - for (index=0; index 57 ) /* greater than '9 */ - return((LispPTR)(ATOMoffset + (first_char -10)) ); - else if (first_char > 47) /* between '0 to '9 */ - return((LispPTR)(S_POSITIVE + (first_char - 48)) ); - /* fixed S_... mar-27-87 take */ - else /* other one char. atoms */ - return ((LispPTR)(ATOMoffset +first_char)); - } /* if(length==1.. end */ - else if ((non_numericp ==NIL) &&(first_char <= '9')) - /* more than 10 arithmetic aon + - mixed atom process */ - { - if((hash_entry = parse_number(char_base+offset,length))!=0) - return((LispPTR)hash_entry); /* if NIL that means THE ATOM is +- mixed litatom */ - /* 15 may 87 take */ - } + first_char = (*(char_base + offset)) & 0xff; + if (length != 0) { + if (length == 1) /* one char. atoms */ + { + if (first_char > 57) /* greater than '9 */ + return ((LispPTR)(ATOMoffset + (first_char - 10))); + else if (first_char > 47) /* between '0 to '9 */ + return ((LispPTR)(S_POSITIVE + (first_char - 48))); + /* fixed S_... mar-27-87 take */ + else /* other one char. atoms */ + return ((LispPTR)(ATOMoffset + first_char)); + } /* if(length==1.. end */ + else if ((non_numericp == NIL) && (first_char <= '9')) + /* more than 10 arithmetic aon + - mixed atom process */ + { + if ((hash_entry = parse_number(char_base + offset, length)) != 0) + return ((LispPTR)hash_entry); /* if NIL that means THE ATOM is +- mixed litatom */ + /* 15 may 87 take */ + } - hash = compute_hash(char_base, offset,length) ; + hash = compute_hash(char_base, offset, length); - } /* if(lengt.. end */ - else - { - hash = 0; - first_char = 255 ; + } /* if(lengt.. end */ + else { + hash = 0; + first_char = 255; } -/* This point corresponds with LP in Lisp source */ + /* This point corresponds with LP in Lisp source */ -/* following for loop never exits until it finds new hash enty or same atom */ - for ( reprobe=Atom_reprobe(hash ,first_char) ; - (hash_entry= GETWORD(AtomHT+hash)) != 0 ; - hash = ((hash + reprobe) & 0xffff) ) - { - atom_index = hash_entry -1 ; - /* get pname pointer */ - pnptr = (PNCell *)GetPnameCell( atom_index); - pname_base= (char *)Addr68k_from_LADDR(POINTERMASK & pnptr->pnamebase) ; + /* following for loop never exits until it finds new hash enty or same atom */ + for (reprobe = Atom_reprobe(hash, first_char); (hash_entry = GETWORD(AtomHT + hash)) != 0; + hash = ((hash + reprobe) & 0xffff)) { + atom_index = hash_entry - 1; + /* get pname pointer */ + pnptr = (PNCell *)GetPnameCell(atom_index); + pname_base = (char *)Addr68k_from_LADDR(POINTERMASK & pnptr->pnamebase); - if ((length == GETBYTE(pname_base) ) && - (compare_chars(++pname_base,char_base+offset,length) ==T)) - { - DBPRINT(("FOUND the atom. \n")); - return ( atom_index ); /* find already existed atom */ - } - DBPRINT(("HASH doesn't hit. reprobe!\n")); + if ((length == GETBYTE(pname_base)) && + (compare_chars(++pname_base, char_base + offset, length) == T)) { + DBPRINT(("FOUND the atom. \n")); + return (atom_index); /* find already existed atom */ + } + DBPRINT(("HASH doesn't hit. reprobe!\n")); - } /* for end */ + } /* for end */ -/* we can't find that atom, then we should make new atom */ - DBPRINT(("HASH NEVER HIT. Returning -1.\n")); - return(0xffffffff); -/** Don't create newatom now **/ + /* we can't find that atom, then we should make new atom */ + DBPRINT(("HASH NEVER HIT. Returning -1.\n")); + return (0xffffffff); + /** Don't create newatom now **/ } /* make_atom end */ - - - - - /*********************************************************************/ /* - Func name : parse_number + Func name : parse_number - Desc : It can treat -65534 to 65535 integer - Returns SMALLP PTR - Date : 1,May 1987 Take - 15 May 87 take + Desc : It can treat -65534 to 65535 integer + Returns SMALLP PTR + Date : 1,May 1987 Take + 15 May 87 take */ /*********************************************************************/ /* Assume this func. should be called with C string in "char_base" */ -LispPTR parse_number(char *char_base, short int length) -{ - register LispPTR sign_mask ; - register LispPTR val ; - register int radix ; - register int *cell68k; - +LispPTR parse_number(char *char_base, short int length) { + register LispPTR sign_mask; + register LispPTR val; + register int radix; + register int *cell68k; #ifdef TRACE2 - printf("TRACE: parse_number()\n"); + printf("TRACE: parse_number()\n"); #endif - /* Check for Radix 8(Q) postfixed ?? */ - if( (*(char_base +(length -1))) == 'Q') - { - radix= 8; - length--; - } - else radix = 10 ; + /* Check for Radix 8(Q) postfixed ?? */ + if ((*(char_base + (length - 1))) == 'Q') { + radix = 8; + length--; + } else + radix = 10; - /* Check for Sign */ - sign_mask =S_POSITIVE ; + /* Check for Sign */ + sign_mask = S_POSITIVE; - if((*(char_base) == '+') || (*(char_base) == '-')) - { - sign_mask = ((*char_base++) =='+') ? S_POSITIVE : S_NEGATIVE ; - length--; - } - - for(val=0;length>0;length--) - { - if ( (((*char_base)) < '0' ) || ( '9' < ((*char_base))) ) - return(NIL); - val = radix * val + (*char_base++) - '0' ; - } - - if(val > 0xffffffff) - error("parse_number : Overflow ...exceeded range of FIXP"); - - if((sign_mask == S_POSITIVE)&&(val > 0xffff)) - { - cell68k = (int *)createcell68k(TYPE_FIXP); - *cell68k = val ; - return(LADDR_from_68k(cell68k)); - } - else if((sign_mask == S_NEGATIVE) && (val > 0xffff)) - { - cell68k =(int *) createcell68k(TYPE_FIXP); - *cell68k = ~val +1 ; - return(LADDR_from_68k(cell68k)); - } - - else if(sign_mask == S_NEGATIVE) - return(sign_mask | (~((DLword)val) + 1)); - else - { - return(sign_mask | val); - } + if ((*(char_base) == '+') || (*(char_base) == '-')) { + sign_mask = ((*char_base++) == '+') ? S_POSITIVE : S_NEGATIVE; + length--; } - /* end parse_number */ + + for (val = 0; length > 0; length--) { + if ((((*char_base)) < '0') || ('9' < ((*char_base)))) return (NIL); + val = radix * val + (*char_base++) - '0'; + } + + if (val > 0xffffffff) error("parse_number : Overflow ...exceeded range of FIXP"); + + if ((sign_mask == S_POSITIVE) && (val > 0xffff)) { + cell68k = (int *)createcell68k(TYPE_FIXP); + *cell68k = val; + return (LADDR_from_68k(cell68k)); + } else if ((sign_mask == S_NEGATIVE) && (val > 0xffff)) { + cell68k = (int *)createcell68k(TYPE_FIXP); + *cell68k = ~val + 1; + return (LADDR_from_68k(cell68k)); + } + + else if (sign_mask == S_NEGATIVE) + return (sign_mask | (~((DLword)val) + 1)); + else { + return (sign_mask | val); + } +} +/* end parse_number */ diff --git a/src/mkcell.c b/src/mkcell.c old mode 100755 new mode 100644 index c75de94..d18fe39 --- a/src/mkcell.c +++ b/src/mkcell.c @@ -1,9 +1,7 @@ -/* $Id: mkcell.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: mkcell.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: mkcell.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,21 +16,20 @@ static char *id = "$Id: mkcell.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyri #include "version.h" - /***********************************************************************/ /* - File Name : mkcell.c + File Name : mkcell.c + + Desc : + + Date : Jun. 4, 1987 + Edited by : Takeshi Shimizu + Changed : 9 Jun 1987 take + 26 Oct. 1987 take(add mask) + + Including : OP_createcell + - Desc : - - Date : Jun. 4, 1987 - Edited by : Takeshi Shimizu - Changed : 9 Jun 1987 take - 26 Oct. 1987 take(add mask) - - Including : OP_createcell - - */ /**********************************************************************/ @@ -43,203 +40,166 @@ static char *id = "$Id: mkcell.c,v 1.3 1999/05/31 23:35:39 sybalsky Exp $ Copyri #include "lsptypes.h" #include "address.h" #include "adr68k.h" -#include "cell.h" -#include "gc.h" +#include "cell.h" +#include "gc.h" static LispPTR oldoldfree; static LispPTR oldfree; - + LispPTR *alloc_mdspage(register short int type); LispPTR initmdspage(register LispPTR *base, register DLword size, register LispPTR prev); -LispPTR N_OP_createcell(register LispPTR tos) -{ +LispPTR N_OP_createcell(register LispPTR tos) { register struct dtd *dtd68k; - register DLword *ptr,*lastptr; - register LispPTR newcell ; - register unsigned int type ; + register DLword *ptr, *lastptr; + register LispPTR newcell; + register unsigned int type; - if((tos & SEGMASK) != S_POSITIVE) ERROR_EXIT(tos); - type = tos & 0xffff ; + if ((tos & SEGMASK) != S_POSITIVE) ERROR_EXIT(tos); + type = tos & 0xffff; #ifdef DTDDEBUG - if(type==TYPE_LISTP) - error("N_OP_createcell : Can't create Listp cell with CREATECELL"); - check_dtd_chain(type); + if (type == TYPE_LISTP) error("N_OP_createcell : Can't create Listp cell with CREATECELL"); + check_dtd_chain(type); #endif - dtd68k = (struct dtd *)GetDTD(type); oldoldfree = oldfree; oldfree = dtd68k->dtd_free; - if(dtd68k->dtd_size == 0) ERROR_EXIT(tos); - /* error("OP_createcell : Attempt to create a cell not declared yet"); */ + if (dtd68k->dtd_size == 0) ERROR_EXIT(tos); +/* error("OP_createcell : Attempt to create a cell not declared yet"); */ -retry : - if((tos=newcell=((dtd68k->dtd_free)&POINTERMASK)) != NIL) - { - ptr = (DLword *)Addr68k_from_LADDR(newcell); -if (917505 == *(LispPTR *)ptr) error("N_OP_createcell E0001 error"); - /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ - dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK; - if (dtd68k->dtd_free & 0x8000001) error("bad entry on free chain."); +retry: + if ((tos = newcell = ((dtd68k->dtd_free) & POINTERMASK)) != NIL) { + ptr = (DLword *)Addr68k_from_LADDR(newcell); + if (917505 == *(LispPTR *)ptr) error("N_OP_createcell E0001 error"); + /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ + dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK; + if (dtd68k->dtd_free & 0x8000001) error("bad entry on free chain."); - dtd68k->dtd_oldcnt++; + dtd68k->dtd_oldcnt++; - /* clear 0 */ - for(lastptr=ptr + dtd68k->dtd_size ; - ptr != lastptr ; ptr++) - { GETWORD(ptr) = 0 ; } + /* clear 0 */ + for (lastptr = ptr + dtd68k->dtd_size; ptr != lastptr; ptr++) { GETWORD(ptr) = 0; } -/* IncAllocCnt(1); */ - GCLOOKUP(tos, DELREF); - return(tos); - } - else - { - dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry) , - dtd68k->dtd_size ,NIL); - if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); - goto retry ; + /* IncAllocCnt(1); */ + GCLOOKUP(tos, DELREF); + return (tos); + } else { + dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry), dtd68k->dtd_size, NIL); + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + goto retry; } } /* N_OP_createcell end */ - - - - -DLword *createcell68k(unsigned int type) -{ +DLword *createcell68k(unsigned int type) { register struct dtd *dtd68k; - register DLword *ptr,*lastptr; + register DLword *ptr, *lastptr; register ConsCell *newcell68k; - register LispPTR newcell ; + register LispPTR newcell; #ifdef DTDDEBUG - if(type==TYPE_LISTP) - error("createcell : Can't create Listp cell with CREATECELL"); - if(type==TYPE_STREAM) stab(); + if (type == TYPE_LISTP) error("createcell : Can't create Listp cell with CREATECELL"); + if (type == TYPE_STREAM) stab(); - check_dtd_chain(type); + check_dtd_chain(type); #endif - + dtd68k = (struct dtd *)GetDTD(type); - if(dtd68k->dtd_size == 0) - error("createcell : Attempt to create a cell not declared yet"); + if (dtd68k->dtd_size == 0) error("createcell : Attempt to create a cell not declared yet"); -retry : - if((newcell=(dtd68k->dtd_free & POINTERMASK)) != NIL) - { +retry: + if ((newcell = (dtd68k->dtd_free & POINTERMASK)) != NIL) { #ifdef DTDDEBUG - if(type != GetTypeNumber(newcell)) - error("createcell : BAD cell in dtdfree"); - if(newcell > POINTERMASK) - error("createcell : BAD Lisp address"); + if (type != GetTypeNumber(newcell)) error("createcell : BAD cell in dtdfree"); + if (newcell > POINTERMASK) error("createcell : BAD Lisp address"); #endif - ptr = Addr68k_from_LADDR(newcell) ; + ptr = Addr68k_from_LADDR(newcell); -if (917505 == *(LispPTR *)ptr) error("N_OP_createcell E0001 error"); + if (917505 == *(LispPTR *)ptr) error("N_OP_createcell E0001 error"); - /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ - dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK ; - if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ + dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK; + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); #ifdef DTDDEBUG - if((dtd68k->dtd_free!=0)&&(type != GetTypeNumber(dtd68k->dtd_free)) ) - error("createcell : BAD cell in next dtdfree"); - check_dtd_chain(type); + if ((dtd68k->dtd_free != 0) && (type != GetTypeNumber(dtd68k->dtd_free))) + error("createcell : BAD cell in next dtdfree"); + check_dtd_chain(type); #endif - dtd68k->dtd_oldcnt++; + dtd68k->dtd_oldcnt++; - /* clear 0 */ - for(lastptr=ptr + dtd68k->dtd_size ; - ptr != lastptr ; ptr++) - { GETWORD(ptr) = 0 ; } + /* clear 0 */ + for (lastptr = ptr + dtd68k->dtd_size; ptr != lastptr; ptr++) { GETWORD(ptr) = 0; } -/* IncAllocCnt(1); */ - GCLOOKUP(newcell, DELREF); + /* IncAllocCnt(1); */ + GCLOOKUP(newcell, DELREF); #ifdef DTDDEBUG - check_dtd_chain(type); + check_dtd_chain(type); #endif + return (Addr68k_from_LADDR(newcell)); - return(Addr68k_from_LADDR(newcell)); - + } else { + dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry), dtd68k->dtd_size, NIL); + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + +#ifdef DTDDEBUG + check_dtd_chain(type); +#endif + + goto retry; } - else - { - dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry) , - dtd68k->dtd_size ,NIL); - if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); - -#ifdef DTDDEBUG - check_dtd_chain(type); -#endif - - goto retry ; - } - } /* createcell68k end */ - /**********************************************************/ /* Create a Cell of Specified Type & Set to given Value */ /* Works with 32 bit typed values only. */ /* (Initially used only by native code) */ /**********************************************************/ -LispPTR Create_n_Set_Cell(unsigned int type, LispPTR value) -{ +LispPTR Create_n_Set_Cell(unsigned int type, LispPTR value) { register struct dtd *dtd68k; - register DLword *ptr,*lastptr; + register DLword *ptr, *lastptr; register ConsCell *newcell68k; - register LispPTR newcell ; - + register LispPTR newcell; + dtd68k = (struct dtd *)GetDTD(type); - if(dtd68k->dtd_size == 0) - error("createcell : Attempt to create a cell not declared yet"); + if (dtd68k->dtd_size == 0) error("createcell : Attempt to create a cell not declared yet"); -retry : - if((newcell=(dtd68k->dtd_free & POINTERMASK)) != NIL) - { - ptr = Addr68k_from_LADDR(newcell) ; +retry: + if ((newcell = (dtd68k->dtd_free & POINTERMASK)) != NIL) { + ptr = Addr68k_from_LADDR(newcell); - /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ + /* replace dtd_free with newcell's top DLword (it may keep next chain)*/ - dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK ; - dtd68k->dtd_oldcnt++; - if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + dtd68k->dtd_free = (*((LispPTR *)ptr)) & POINTERMASK; + dtd68k->dtd_oldcnt++; + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); - /* clear 0 */ - for(lastptr=ptr + dtd68k->dtd_size ; - ptr != lastptr ; ptr++) - { GETWORD(ptr) = 0 ; } + /* clear 0 */ + for (lastptr = ptr + dtd68k->dtd_size; ptr != lastptr; ptr++) { GETWORD(ptr) = 0; } -/* IncAllocCnt(1); */ - GCLOOKUP(newcell, DELREF); - (* ((LispPTR *) Addr68k_from_LADDR(newcell))) = value; - return(newcell); - + /* IncAllocCnt(1); */ + GCLOOKUP(newcell, DELREF); + (*((LispPTR *)Addr68k_from_LADDR(newcell))) = value; + return (newcell); + + } else { + dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry), dtd68k->dtd_size, NIL); + if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); + + goto retry; } - else - { - dtd68k->dtd_free = initmdspage(alloc_mdspage(dtd68k->dtd_typeentry) , - dtd68k->dtd_size ,NIL); - if (dtd68k->dtd_free & 0x8000000) error("bad entry on free chain."); - - goto retry ; - } - } /* createcell68k end */ - diff --git a/src/mkkey.c b/src/mkkey.c old mode 100755 new mode 100644 index 4ee6594..0b9df1e --- a/src/mkkey.c +++ b/src/mkkey.c @@ -1,7 +1,6 @@ -/* $Id: mkkey.c,v 1.2 1999/01/03 02:07:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: mkkey.c,v 1.2 1999/01/03 02:07:24 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: mkkey.c,v 1.2 1999/01/03 02:07:24 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -15,5 +14,3 @@ static char *id = "$Id: mkkey.c,v 1.2 1999/01/03 02:07:24 sybalsky Exp $ Copyrig /************************************************************************/ #include "version.h" - - diff --git a/src/mkvdate.c b/src/mkvdate.c old mode 100755 new mode 100644 index bee8a7f..d636afe --- a/src/mkvdate.c +++ b/src/mkvdate.c @@ -1,9 +1,7 @@ -/* $Id: mkvdate.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: mkvdate.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: mkvdate.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,8 +16,6 @@ static char *id = "$Id: mkvdate.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyr #include "version.h" - - /************************************************************************/ /* */ /* m a k e v d a t e . c */ @@ -37,44 +33,39 @@ static char *id = "$Id: mkvdate.c,v 1.5 2001/12/26 22:17:03 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #ifdef OSF1 #include "time.h" #endif -#include +#include #ifdef USETIMEFN -#include +#include #elif DOS -#include +#include #else -#include +#include #endif /* USETIMEFN */ - #ifdef USETIMEFN - /* RISCOS doesn't have the BSD time functions */ -int main(void) - { - long dtime; - time(&dtime); - fprintf(stderr, "Mdate :%d\n", dtime); - printf("long MDate= %d;\n", dtime); - return (0); - } +/* RISCOS doesn't have the BSD time functions */ +int main(void) { + long dtime; + time(&dtime); + fprintf(stderr, "Mdate :%d\n", dtime); + printf("long MDate= %d;\n", dtime); + return (0); +} #else - /* Version for every other Unix */ -int main(void) -{ - struct timeval time; +/* Version for every other Unix */ +int main(void) { + struct timeval time; - gettimeofday(&time, NULL); - fprintf(stderr, "Mdate :%d\n", time.tv_sec); - fprintf(stderr, "Version: %s\n", ctime(&time.tv_sec)); + gettimeofday(&time, NULL); + fprintf(stderr, "Mdate :%d\n", time.tv_sec); + fprintf(stderr, "Version: %s\n", ctime(&time.tv_sec)); - printf("long MDate= %d;\n", time.tv_sec); - return (0); - } + printf("long MDate= %d;\n", time.tv_sec); + return (0); +} #endif /* SYSVONLY */ - diff --git a/src/mnwevent.c b/src/mnwevent.c old mode 100755 new mode 100644 index b7b9322..956f4e7 --- a/src/mnwevent.c +++ b/src/mnwevent.c @@ -1,10 +1,7 @@ -/* $Id: mnwevent.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: mnwevent.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: mnwevent.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -20,8 +17,6 @@ static char *id = "$Id: mnwevent.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ Copy #include "version.h" - - #include #include @@ -40,15 +35,15 @@ static char *id = "$Id: mnwevent.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ Copy #ifndef FALSE #define FALSE 0 -#define TRUE !FALSE +#define TRUE !FALSE #endif /* FALSE */ extern XEvent report; extern DLword *CTopMNWEvent; -int MNWEventFlg=0; /* Count of MNW events needing service */ +int MNWEventFlg = 0; /* Count of MNW events needing service */ -DspInterfaceRec *FD_to_dspif[32]; /* Map from FD # to a display */ +DspInterfaceRec *FD_to_dspif[32]; /* Map from FD # to a display */ int MNWReadFds = 0; DLword *CTopMNWEvent; @@ -57,12 +52,8 @@ LispPTR *MNWEVENTQUEUE68k; extern LispPTR *MakeAtom68k(); -extern DLword *EmCursorX68K - , *EmCursorY68K; -extern DLword *EmMouseX68K - , *EmMouseY68K - , *EmKbdAd068K - , *EmRealUtilin68K; +extern DLword *EmCursorX68K, *EmCursorY68K; +extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K; extern LispPTR *CLastUserActionCell68k; extern MISCSTATS *MiscStats; @@ -78,26 +69,25 @@ LispPTR *MNWBUFFERING68k = 0; /* at the head of the chain. (This is bubblesort) */ /* */ /************************************************************************/ -WindowInterface Find_window(dspif, Xwindow) - DspInterface dspif; - Window Xwindow; +WindowInterface Find_window(dspif, Xwindow) DspInterface dspif; +Window Xwindow; { WindowInterface curr, prev; - if(dspif->CreatedWifs == (WindowInterface)NULL) return(NIL); - if(dspif->CreatedWifs->blackframe == Xwindow) return(dspif->CreatedWifs); + if (dspif->CreatedWifs == (WindowInterface)NULL) return (NIL); + if (dspif->CreatedWifs->blackframe == Xwindow) return (dspif->CreatedWifs); /* Find the wif we are interested in. */ - for(prev = dspif->CreatedWifs, curr = prev->next; - ((curr != (WindowInterface)NULL) && (curr->blackframe != Xwindow)); - curr = curr->next, prev = prev->next){} - if(curr == (WindowInterface)NULL) return(NIL); /* wif not found */ + for (prev = dspif->CreatedWifs, curr = prev->next; + ((curr != (WindowInterface)NULL) && (curr->blackframe != Xwindow)); + curr = curr->next, prev = prev->next) {} + if (curr == (WindowInterface)NULL) return (NIL); /* wif not found */ /* Bubble curr to the head of the list */ prev->next = curr->next; curr->next = dspif->CreatedWifs; dspif->CreatedWifs = curr; - return(curr); + return (curr); } /************************************************************************/ @@ -111,55 +101,52 @@ WindowInterface Find_window(dspif, Xwindow) /* Get a pointer to the next event in line in the Lisp eventqueue. */ /* Return NULL if fail. This is the head of DoRing. */ /************************************************************************/ -MNWEvent *NewEvent() -{ - if (! CTopMNWEvent ) - { - LispPTR index; - index = get_package_atom("\\MNWEVENTQUEUE", 14, "INTERLISP", 9, NIL); - if (index != 0xFFFFFFFF) - { - MNWEVENTQUEUE68k = GetVALCELL68k(index); - DOMNWEVENT_index = get_package_atom("\\DOMNWEVENT", 11, "INTERLISP", 9, NIL); - CTopMNWEvent= (DLword*)Addr68k_from_LADDR(*MNWEVENTQUEUE68k); - } +MNWEvent *NewEvent() { + if (!CTopMNWEvent) { + LispPTR index; + index = get_package_atom("\\MNWEVENTQUEUE", 14, "INTERLISP", 9, NIL); + if (index != 0xFFFFFFFF) { + MNWEVENTQUEUE68k = GetVALCELL68k(index); + DOMNWEVENT_index = get_package_atom("\\DOMNWEVENT", 11, "INTERLISP", 9, NIL); + CTopMNWEvent = (DLword *)Addr68k_from_LADDR(*MNWEVENTQUEUE68k); } - if (CTopMNWEvent) - { DLword w, r; - r=RING_READ(CTopMNWEvent); - w=RING_WRITE(CTopMNWEvent); + } + if (CTopMNWEvent) { + DLword w, r; + r = RING_READ(CTopMNWEvent); + w = RING_WRITE(CTopMNWEvent); - if (r != w) return((MNWEvent*)(CTopMNWEvent+ w)); - } - return(NULL); + if (r != w) return ((MNWEvent *)(CTopMNWEvent + w)); + } + return (NULL); } /************************************************************************/ /* SignalMNWEvent */ /* Tell Lisp that an event happened. This is the tail part of DoRing */ /* */ /************************************************************************/ -SignalMNWEvent() -{ +SignalMNWEvent() { DLword w, r; if (CTopMNWEvent) { - r=RING_READ(CTopMNWEvent); - w=RING_WRITE(CTopMNWEvent); + r = RING_READ(CTopMNWEvent); + w = RING_WRITE(CTopMNWEvent); - if(r==0) /* Queue was empty */ - ((RING*)CTopMNWEvent)->read=w; - if(w >= MAXMNWEVENT) ((RING*)CTopMNWEvent)->write = MINMNWEVENT; - else ((RING*)CTopMNWEvent)->write = w + MNWEVENTSIZE; + if (r == 0) /* Queue was empty */ + ((RING *)CTopMNWEvent)->read = w; + if (w >= MAXMNWEVENT) + ((RING *)CTopMNWEvent)->write = MINMNWEVENT; + else + ((RING *)CTopMNWEvent)->write = w + MNWEVENTSIZE; - if (*MNWBUFFERING68k == NIL) *MNWBUFFERING68k = ATOM_T; + if (*MNWBUFFERING68k == NIL) *MNWBUFFERING68k = ATOM_T; if (MNWEventFlg++ > 0) Irq_Stk_End = Irq_Stk_Check = 0; /* Ask for interrupt */ } } -void HandleMotion(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XMotionEvent *xevent; - Boolean *continue_to_dispatch; +void HandleMotion(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XMotionEvent *xevent; +Boolean *continue_to_dispatch; { MNWPointerMotionEvent *mevent; @@ -167,42 +154,34 @@ void HandleMotion(widget, wif, xevent, continue_to_dispatch) *CLastUserActionCell68k = MiscStats->secondstmp; (*((DLword *)EmMouseX68K)) = *EmCursorX68K = xevent->x_root; (*((DLword *)EmMouseY68K)) = *EmCursorY68K = xevent->y_root; - /* printf("mouse x %d, y %d\n", xevent->x_root, xevent->y_root); */ + /* printf("mouse x %d, y %d\n", xevent->x_root, xevent->y_root); */ DoRing(); - if(( KBDEventFlg ) > 0) - { - /* immidiately request for IRQ check */ - Irq_Stk_End=Irq_Stk_Check=0; - } + if ((KBDEventFlg) > 0) { + /* immidiately request for IRQ check */ + Irq_Stk_End = Irq_Stk_Check = 0; + } } } - -void HandleButton(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XButtonEvent *xevent; - Boolean *continue_to_dispatch; +void HandleButton(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XButtonEvent *xevent; +Boolean *continue_to_dispatch; { MNWButtonEvent *mevent; lisp_Xbutton(xevent, 0); - } - - -void HandleKey(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XKeyEvent *xevent; - Boolean *continue_to_dispatch; +void HandleKey(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XKeyEvent *xevent; +Boolean *continue_to_dispatch; { - lisp_Xkeyboard(xevent, 0); #ifdef NEVER - if((mevent = NewEvent()) != NULL){ + if ((mevent = NewEvent()) != NULL) { mevent->screen = wif->MedleyScreen; mevent->window = wif->MedleyWindow; mevent->event = MNWButton; @@ -216,230 +195,198 @@ void HandleKey(widget, wif, xevent, continue_to_dispatch) #endif /* NEVER */ } - - - -void HandleCrossing(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XCrossingEvent *xevent; - Boolean *continue_to_dispatch; +void HandleCrossing(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XCrossingEvent *xevent; +Boolean *continue_to_dispatch; { - switch (xevent->type) - { - case EnterNotify: DoMNWRing(MNWMouseIn, wif->MedleyScreen, wif->MedleyWindow, 0, 0, 0, 0); - break; + switch (xevent->type) { + case EnterNotify: + DoMNWRing(MNWMouseIn, wif->MedleyScreen, wif->MedleyWindow, 0, 0, 0, 0); + break; - case LeaveNotify: if (NotifyInferior != xevent->detail) - DoMNWRing(MNWMouseOut, wif->MedleyScreen, wif->MedleyWindow, 0, 0, 0, 0); - break; - } + case LeaveNotify: + if (NotifyInferior != xevent->detail) + DoMNWRing(MNWMouseOut, wif->MedleyScreen, wif->MedleyWindow, 0, 0, 0, 0); + break; } +} - - -void HandleBackgroundCrossing(widget, dspif, xevent, continue_to_dispatch) - Widget widget; - DspInterface dspif; - XCrossingEvent *xevent; - Boolean *continue_to_dispatch; +void HandleBackgroundCrossing(widget, dspif, xevent, continue_to_dispatch) Widget widget; +DspInterface dspif; +XCrossingEvent *xevent; +Boolean *continue_to_dispatch; { - switch (xevent->type) - { - case EnterNotify: DoMNWRing(MNWMouseIn, dspif->screen, 0, 0, 0, 0, 0); - break; + switch (xevent->type) { + case EnterNotify: DoMNWRing(MNWMouseIn, dspif->screen, 0, 0, 0, 0, 0); break; - case LeaveNotify: if (NotifyInferior != xevent->detail) - DoMNWRing(MNWMouseOut, dspif->screen, 0, 0, 0, 0, 0); - break; - } + case LeaveNotify: + if (NotifyInferior != xevent->detail) DoMNWRing(MNWMouseOut, dspif->screen, 0, 0, 0, 0, 0); + break; } +} - - -void HandleFocus(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XFocusChangeEvent *xevent; - Boolean *continue_to_dispatch; +void HandleFocus(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XFocusChangeEvent *xevent; +Boolean *continue_to_dispatch; { MNWFocusEvent *mevent; -/* - if((mevent = (MNWFocusEvent *)NewEvent()) != NULL){ - mevent->screen = wif->MedleyScreen; - mevent->window = wif->MedleyWindow; - if(xevent->type == FocusIn) mevent->event = MNWFocusIn; - else mevent->event = MNWFocusOut; - SignalMNWEvent(); - } -*/ + /* + if((mevent = (MNWFocusEvent *)NewEvent()) != NULL){ + mevent->screen = wif->MedleyScreen; + mevent->window = wif->MedleyWindow; + if(xevent->type == FocusIn) mevent->event = MNWFocusIn; + else mevent->event = MNWFocusOut; + SignalMNWEvent(); + } + */ } -void HandleStructure(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XAnyEvent *xevent; - Boolean *continue_to_dispatch; +void HandleStructure(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XAnyEvent *xevent; +Boolean *continue_to_dispatch; { - LispPTR screen, MWindow; - Window window; - Display *display; - DspInterfaceRec *dspif; + LispPTR screen, MWindow; + Window window; + Display *display; + DspInterfaceRec *dspif; - screen = wif->MedleyScreen; - MWindow = wif->MedleyWindow; - window = xevent->window; - dspif = wif->dspif; - display = dspif->handle; + screen = wif->MedleyScreen; + MWindow = wif->MedleyWindow; + window = xevent->window; + dspif = wif->dspif; + display = dspif->handle; - switch (xevent->type) - { - case UnmapNotify: DoMNWRing(MNWClose, screen, MWindow, 0, 0, 0, 0); - break; + switch (xevent->type) { + case UnmapNotify: DoMNWRing(MNWClose, screen, MWindow, 0, 0, 0, 0); break; - case MapNotify: break; + case MapNotify: break; - case ConfigureNotify: if (!wif) break; /* don't change inner windows */ - /* if (wif->moving || wif->reshaping) - { - wif->moving = wif->reshaping = 0; - break; - } - else */ - { - int l, b, b2, w, h; - XConfigureEvent *ev = (XConfigureEvent *) xevent; - /* printf("M/S event send %d, x %d, y %d, w %d, h %d\n", - xevent->send_event, ev->x, ev->y, - ev->width, ev->height); */ + case ConfigureNotify: + if (!wif) break; /* don't change inner windows */ + /* if (wif->moving || wif->reshaping) + { + wif->moving = wif->reshaping = 0; + break; + } + else */ + { + int l, b, b2, w, h; + XConfigureEvent *ev = (XConfigureEvent *)xevent; + /* printf("M/S event send %d, x %d, y %d, w %d, h %d\n", + xevent->send_event, ev->x, ev->y, + ev->width, ev->height); */ - l = ev->x; - b = ev->y; + l = ev->x; + b = ev->y; #ifdef INDIGO - /* apparent bug in SGI's x server */ - if ((!xevent->send_event) && (l==0) && (b == 0)) + /* apparent bug in SGI's x server */ + if ((!xevent->send_event) && (l == 0) && (b == 0)) #else - if ((!xevent->send_event)) + if ((!xevent->send_event)) #endif /* INDIGO */ - { - Window parent, root, *children; - int nch; + { + Window parent, root, *children; + int nch; - XQueryTree(display, window, &root, &parent, &children, &nch); - XFree(children); - if (parent != root) XTranslateCoordinates(display, parent, - dspif->root, - ev->x, ev->y, - &l, &b, &window); - /* printf("[translated x %d, y %d]\n", l, b); */ - } + XQueryTree(display, window, &root, &parent, &children, &nch); + XFree(children); + if (parent != root) + XTranslateCoordinates(display, parent, dspif->root, ev->x, ev->y, &l, &b, &window); + /* printf("[translated x %d, y %d]\n", l, b); */ + } - b2 = HeightOfScreen(wif->screen) - b - ev->height; - - if ((wif->topregion.width == ev->width) && - (wif->topregion.height == ev->height)) - { - if ((wif->topregion.x != l) || (wif->topregion.y != b)) - { - /* printf("movew to %d, %d.\n", l+wif->outerregion.x, b2+wif->outerregion.y); */ - DoMNWRing(MNWMove, screen, MWindow, l+wif->outerregion.x, b2+wif->outerregion.y, - ev->width-(wif->topregion.width - wif->outerregion.width), ev->height-(wif->topregion.height - wif->outerregion.height)); + b2 = HeightOfScreen(wif->screen) - b - ev->height; + + if ((wif->topregion.width == ev->width) && (wif->topregion.height == ev->height)) { + if ((wif->topregion.x != l) || (wif->topregion.y != b)) { + /* printf("movew to %d, %d.\n", l+wif->outerregion.x, b2+wif->outerregion.y); */ + DoMNWRing(MNWMove, screen, MWindow, l + wif->outerregion.x, b2 + wif->outerregion.y, + ev->width - (wif->topregion.width - wif->outerregion.width), + ev->height - (wif->topregion.height - wif->outerregion.height)); } + } else /* if ((ev->x != wif->outerregion.x) || (ev->y != wif->outerregion.y)) */ + { + /* printf("shapew to %d, %d, %d, %d.\n", l+wif->outerregion.x, b2+wif->outerregion.y, + ev->width-(wif->topregion.width - wif->outerregion.width), + ev->height-(wif->topregion.height - wif->outerregion.height)); */ + DoMNWRing(MNWShapeReq, screen, MWindow, l + wif->outerregion.x, b2 + wif->outerregion.y, + ev->width - (wif->topregion.width - wif->outerregion.width), + ev->height - (wif->topregion.height - wif->outerregion.height)); + } } - else /* if ((ev->x != wif->outerregion.x) || (ev->y != wif->outerregion.y)) */ - { - /* printf("shapew to %d, %d, %d, %d.\n", l+wif->outerregion.x, b2+wif->outerregion.y, - ev->width-(wif->topregion.width - wif->outerregion.width), ev->height-(wif->topregion.height - wif->outerregion.height)); */ - DoMNWRing(MNWShapeReq, screen, MWindow, l+wif->outerregion.x, b2+wif->outerregion.y, - ev->width-(wif->topregion.width - wif->outerregion.width), ev->height-(wif->topregion.height - wif->outerregion.height)); - } - } - break; + break; - case ReparentNotify: if (wif) wif->parent = ((XReparentEvent *)xevent)->parent; - break; - - - } + case ReparentNotify: + if (wif) wif->parent = ((XReparentEvent *)xevent)->parent; + break; + } } - - -void HandleBackgroundButton(widget, wif, xevent, continue_to_dispatch) - Widget widget; - LispPTR wif; - XButtonEvent *xevent; - Boolean *continue_to_dispatch; +void HandleBackgroundButton(widget, wif, xevent, continue_to_dispatch) Widget widget; +LispPTR wif; +XButtonEvent *xevent; +Boolean *continue_to_dispatch; { MNWButtonEvent *mevent; - { /* Copied from HandleMotion -- tell Lisp of mouse move */ *CLastUserActionCell68k = MiscStats->secondstmp; (*((DLword *)EmMouseX68K)) = *EmCursorX68K = xevent->x_root; (*((DLword *)EmMouseY68K)) = *EmCursorY68K = xevent->y_root; DoRing(); - if(( KBDEventFlg ) > 0) - { - /* immediately request for IRQ check */ - Irq_Stk_End=Irq_Stk_Check=0; - } + if ((KBDEventFlg) > 0) { + /* immediately request for IRQ check */ + Irq_Stk_End = Irq_Stk_Check = 0; + } } lisp_Xbutton(xevent, 0); #ifdef NEVER - if((xevent->type == ButtonPress) && - ((mevent = (MNWButtonEvent *)NewEvent()) != NULL)) - { - mevent->screen = wif/*->MedleyScreen*/; - mevent->window = 0; - mevent->event = MNWButton; - mevent->pos.x = xevent->x_root; - mevent->pos.y = xevent->y_root; - mevent->button.left = xevent->state | Button1Mask; - mevent->button.middle = xevent->state | Button2Mask; - mevent->button.right = xevent->state | Button3Mask; - SignalMNWEvent(); - } + if ((xevent->type == ButtonPress) && ((mevent = (MNWButtonEvent *)NewEvent()) != NULL)) { + mevent->screen = wif /*->MedleyScreen*/; + mevent->window = 0; + mevent->event = MNWButton; + mevent->pos.x = xevent->x_root; + mevent->pos.y = xevent->y_root; + mevent->button.left = xevent->state | Button1Mask; + mevent->button.middle = xevent->state | Button2Mask; + mevent->button.right = xevent->state | Button3Mask; + SignalMNWEvent(); + } #endif } - /* Handle expose events on the frame widget -- print the title */ -void HandleTitle(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XExposeEvent *xevent; - Boolean *continue_to_dispatch; +void HandleTitle(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XExposeEvent *xevent; +Boolean *continue_to_dispatch; { - if (xevent->y <= 12) showtitle(wif->MedleyWindow, - ((MedleyWindow)Cptr(wif->MedleyWindow))->WTITLE); + if (xevent->y <= 12) + showtitle(wif->MedleyWindow, ((MedleyWindow)Cptr(wif->MedleyWindow))->WTITLE); } - /* Handle expose events on the frame widget -- print the title */ -void HandleExpose(widget, wif, xevent, continue_to_dispatch) - Widget widget; - WindowInterface wif; - XExposeEvent *xevent; - Boolean *continue_to_dispatch; - { - XCopyPlane(wif->dspif->handle, wif->backing, XtWindow(wif->windowwidget), - wif->ReplaceGC, - xevent->x, xevent->y, xevent->width, xevent->height, - xevent->x, xevent->y, 1); - } +void HandleExpose(widget, wif, xevent, continue_to_dispatch) Widget widget; +WindowInterface wif; +XExposeEvent *xevent; +Boolean *continue_to_dispatch; +{ + XCopyPlane(wif->dspif->handle, wif->backing, XtWindow(wif->windowwidget), wif->ReplaceGC, + xevent->x, xevent->y, xevent->width, xevent->height, xevent->x, xevent->y, 1); +} - -void SignalVJmpScroll(widget, wif, percent_ptr) - Widget widget; - WindowInterface wif; - XtPointer percent_ptr; /* This is a *float */ +void SignalVJmpScroll(widget, wif, percent_ptr) Widget widget; +WindowInterface wif; +XtPointer percent_ptr; /* This is a *float */ { MNWJumpScrollReqEvent *event; - - if((event = (MNWJumpScrollReqEvent *)NewEvent()) != NULL){ + + if ((event = (MNWJumpScrollReqEvent *)NewEvent()) != NULL) { event->screen = wif->MedleyScreen; event->window = wif->MedleyWindow; event->event = MNWScrollJmpReq; @@ -449,14 +396,13 @@ void SignalVJmpScroll(widget, wif, percent_ptr) } } -void SignalHJmpScroll(widget, wif, percent_ptr) - Widget widget; - WindowInterface wif; - XtPointer percent_ptr; /* This is a *float */ +void SignalHJmpScroll(widget, wif, percent_ptr) Widget widget; +WindowInterface wif; +XtPointer percent_ptr; /* This is a *float */ { MNWJumpScrollReqEvent *event; - - if((event = (MNWJumpScrollReqEvent *)NewEvent()) != NULL){ + + if ((event = (MNWJumpScrollReqEvent *)NewEvent()) != NULL) { event->screen = wif->MedleyScreen; event->window = wif->MedleyWindow; event->event = MNWScrollJmpReq; @@ -466,14 +412,13 @@ void SignalHJmpScroll(widget, wif, percent_ptr) } } -void SignalVScroll(widget, wif, position) - Widget widget; - WindowInterface wif; - int position; +void SignalVScroll(widget, wif, position) Widget widget; +WindowInterface wif; +int position; { MNWScrollReqEvent *event; - - if((event = (MNWScrollReqEvent *)NewEvent()) != NULL){ + + if ((event = (MNWScrollReqEvent *)NewEvent()) != NULL) { event->screen = wif->MedleyScreen; event->window = wif->MedleyWindow; event->event = MNWScrollReq; @@ -483,26 +428,22 @@ void SignalVScroll(widget, wif, position) } } -void SignalHScroll(widget, wif, position) - Widget widget; - WindowInterface wif; - int position; +void SignalHScroll(widget, wif, position) Widget widget; +WindowInterface wif; +int position; { MNWScrollReqEvent *event; - - if((event = (MNWScrollReqEvent *)NewEvent()) != NULL){ + + if ((event = (MNWScrollReqEvent *)NewEvent()) != NULL) { event->screen = wif->MedleyScreen; event->window = wif->MedleyWindow; event->event = MNWScrollReq; event->dy = 0; - event->dx = - position; + event->dx = -position; SignalMNWEvent(); } } - - - /************************************************************************/ /* */ /* */ @@ -510,8 +451,7 @@ void SignalHScroll(widget, wif, position) /* */ /* */ /************************************************************************/ -getMNWsignaldata(fd) - int fd; +getMNWsignaldata(fd) int fd; { Display *display; DspInterfaceRec *dspif; @@ -522,113 +462,101 @@ getMNWsignaldata(fd) LispPTR screen; display = (dspif = FD_to_dspif[fd])->handle; - screen = dspif->screen; - TPRINT(( "TRACE: getXsignaldata()\n" )); + screen = dspif->screen; + TPRINT(("TRACE: getXsignaldata()\n")); - while(XtAppPending(dspif->xtcontext)) - { - XtAppNextEvent(dspif->xtcontext, &report); - XtDispatchEvent(&report); - } + while (XtAppPending(dspif->xtcontext)) { + XtAppNextEvent(dspif->xtcontext, &report); + XtDispatchEvent(&report); + } #ifdef NEVER - while(XPending(display)) - { - /* XtAppNextEvent(dspif->xtcontext, &report); */ - XNextEvent( display, &report ); - window = report.xany.window; + while (XPending(display)) { + /* XtAppNextEvent(dspif->xtcontext, &report); */ + XNextEvent(display, &report); + window = report.xany.window; - wif = Find_window(dspif, window); + wif = Find_window(dspif, window); - if (wif) { - switch (report.type) { - case KeyPress: - case KeyRelease: lisp_Xkeyboard(&report, 0); - break; + if (wif) { + switch (report.type) { + case KeyPress: + case KeyRelease: lisp_Xkeyboard(&report, 0); break; - case ButtonPress: - case ButtonRelease: lisp_Xbutton(&report, 0); - break; + case ButtonPress: + case ButtonRelease: lisp_Xbutton(&report, 0); break; - case MotionNotify: { - *CLastUserActionCell68k = MiscStats->secondstmp; - (*((DLword *)EmMouseX68K)) = *EmCursorX68K = report.xmotion.x_root; - (*((DLword *)EmMouseY68K)) = *EmCursorY68K = report.xmotion.y_root; - DoRing(); - if(( KBDEventFlg ) > 0) - { - /* immidiately request for IRQ check */ - Irq_Stk_End=Irq_Stk_Check=0; - } - } - break; + case MotionNotify: { + *CLastUserActionCell68k = MiscStats->secondstmp; + (*((DLword *)EmMouseX68K)) = *EmCursorX68K = report.xmotion.x_root; + (*((DLword *)EmMouseY68K)) = *EmCursorY68K = report.xmotion.y_root; + DoRing(); + if ((KBDEventFlg) > 0) { + /* immidiately request for IRQ check */ + Irq_Stk_End = Irq_Stk_Check = 0; + } + } break; - case EnterNotify: if (MWindow) DoMNWRing(MNWMouseIn, screen, MWindow, 0, 0, 0, 0); - break; + case EnterNotify: + if (MWindow) DoMNWRing(MNWMouseIn, screen, MWindow, 0, 0, 0, 0); + break; - case LeaveNotify: if (NotifyInferior != report.xcrossing.detail) - DoMNWRing(MNWMouseOut, screen, MWindow, 0, 0, 0, 0); - break; + case LeaveNotify: + if (NotifyInferior != report.xcrossing.detail) + DoMNWRing(MNWMouseOut, screen, MWindow, 0, 0, 0, 0); + break; - case FocusIn: DoMNWRing(MNWFocusIn, screen, MWindow, 0, 0, 0, 0); - break; + case FocusIn: DoMNWRing(MNWFocusIn, screen, MWindow, 0, 0, 0, 0); break; - case FocusOut: DoMNWRing(MNWFocusOut, screen, MWindow, 0, 0, 0, 0); - break; + case FocusOut: DoMNWRing(MNWFocusOut, screen, MWindow, 0, 0, 0, 0); break; - case Expose: if (wif->not_exposed) - { - char *tmpstring; - BITMAP *bitmap; - - - showtitle(MWindow, ((MedleyWindow)Cptr(MWindow))->WTITLE); - bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(MWindow))->SAVE); - - MBMToDrawable(bitmap, dspif, wif, 0, 0, - wif->innerregion.x, wif->innerregion.y, - wif->innerregion.width, wif->innerregion.height); - XFlush(display); - wif->not_exposed = 0; /* don't expose it again */ - } + case Expose: + if (wif->not_exposed) { + char *tmpstring; + BITMAP *bitmap; - break; + showtitle(MWindow, ((MedleyWindow)Cptr(MWindow))->WTITLE); + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(MWindow))->SAVE); - case NoExpose: + MBMToDrawable(bitmap, dspif, wif, 0, 0, wif->innerregion.x, wif->innerregion.y, + wif->innerregion.width, wif->innerregion.height); + XFlush(display); + wif->not_exposed = 0; /* don't expose it again */ + } - case CreateNotify: break; + break; - case DestroyNotify: + case NoExpose: - case CirculateNotify: - if (PlaceOnBottom == report.xcirculate.place) - { - DspInterface dspif; - BITMAP *bitmap; + case CreateNotify: break; - dspif = DspIfFromMscr(screen); - bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(MWindow))->SAVE); + case DestroyNotify: - /* Copy the whole black frame to the bitmap. */ - DrawableToMBM(bitmap, dspif, wif->blackframe, wif->screen, 0, 0, 0, 0, - wif->outerregion.width, wif->outerregion.height); - DrawableToMBM(bitmap, dspif, wif->handle, wif->screen, 0, 0, - wif->innerregion.x, wif->innerregion.y, - wif->innerregion.width, wif->innerregion.height); + case CirculateNotify: + if (PlaceOnBottom == report.xcirculate.place) { + DspInterface dspif; + BITMAP *bitmap; - } - break; + dspif = DspIfFromMscr(screen); + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(MWindow))->SAVE); - default: break; - } + /* Copy the whole black frame to the bitmap. */ + DrawableToMBM(bitmap, dspif, wif->blackframe, wif->screen, 0, 0, 0, 0, + wif->outerregion.width, wif->outerregion.height); + DrawableToMBM(bitmap, dspif, wif->handle, wif->screen, 0, 0, wif->innerregion.x, + wif->innerregion.y, wif->innerregion.width, wif->innerregion.height); + } + break; + + default: break; } -/* else {*/ /* No wif found. Assume it is a widget window. */ - /* XtDispatchEvent(&report); */ -/* } */ } + /* else {*/ /* No wif found. Assume it is a widget window. */ + /* XtDispatchEvent(&report); */ + /* } */ + } #endif /* NEVER */ -} /* end getMNWsignaldata() */ - +} /* end getMNWsignaldata() */ /************************************************************************/ /* */ @@ -639,50 +567,48 @@ getMNWsignaldata(fd) /* */ /************************************************************************/ -DoMNWRing(type, screen, window, l, b, wid, h) - int type; - LispPTR screen, window; - int l, b, wid, h; +DoMNWRing(type, screen, window, l, b, wid, h) int type; +LispPTR screen, window; +int l, b, wid, h; { DLword w, r; MNWEvent *event; - int foo = MNWEVENTSIZE; /* so we can examine the value */ + int foo = MNWEVENTSIZE; /* so we can examine the value */ - if (! CTopMNWEvent ) - { - LispPTR index; - index = get_package_atom("\\MNWEVENTQUEUE", 14, "INTERLISP", 9, NIL); - if (index != 0xFFFFFFFF) - { - MNWEVENTQUEUE68k = GetVALCELL68k(index); - DOMNWEVENT_index = get_package_atom("\\DOMNWEVENT", 11, "INTERLISP", 9, NIL); - CTopMNWEvent= (DLword*)Addr68k_from_LADDR(*MNWEVENTQUEUE68k); - } + if (!CTopMNWEvent) { + LispPTR index; + index = get_package_atom("\\MNWEVENTQUEUE", 14, "INTERLISP", 9, NIL); + if (index != 0xFFFFFFFF) { + MNWEVENTQUEUE68k = GetVALCELL68k(index); + DOMNWEVENT_index = get_package_atom("\\DOMNWEVENT", 11, "INTERLISP", 9, NIL); + CTopMNWEvent = (DLword *)Addr68k_from_LADDR(*MNWEVENTQUEUE68k); } - do_ring: + } +do_ring: - if (CTopMNWEvent) - { - r=RING_READ(CTopMNWEvent); - w=RING_WRITE(CTopMNWEvent); + if (CTopMNWEvent) { + r = RING_READ(CTopMNWEvent); + w = RING_WRITE(CTopMNWEvent); - if (r == w) return; + if (r == w) return; - event=(MNWEvent*)(CTopMNWEvent+ w); + event = (MNWEvent *)(CTopMNWEvent + w); - event->Any.event = type; - event->Any.screen = screen; - event->Any.window = window; - event->Any.pad[0] = l; - event->Any.pad[1] = b; - event->Any.pad[2] = wid; - event->Any.pad[3] = h; - if(r==0) /* Queue was empty */ - ((RING*)CTopMNWEvent)->read=w; - if(w >= MAXMNWEVENT) ((RING*)CTopMNWEvent)->write = MINMNWEVENT; - else ((RING*)CTopMNWEvent)->write = w + MNWEVENTSIZE; + event->Any.event = type; + event->Any.screen = screen; + event->Any.window = window; + event->Any.pad[0] = l; + event->Any.pad[1] = b; + event->Any.pad[2] = wid; + event->Any.pad[3] = h; + if (r == 0) /* Queue was empty */ + ((RING *)CTopMNWEvent)->read = w; + if (w >= MAXMNWEVENT) + ((RING *)CTopMNWEvent)->write = MINMNWEVENT; + else + ((RING *)CTopMNWEvent)->write = w + MNWEVENTSIZE; - if (*MNWBUFFERING68k == NIL) *MNWBUFFERING68k = ATOM_T; - if (MNWEventFlg++ > 0) Irq_Stk_End = Irq_Stk_Check = 0; /* Ask for interrupt */ - } + if (*MNWBUFFERING68k == NIL) *MNWBUFFERING68k = ATOM_T; + if (MNWEventFlg++ > 0) Irq_Stk_End = Irq_Stk_Check = 0; /* Ask for interrupt */ + } } diff --git a/src/mnxmeth.c b/src/mnxmeth.c old mode 100755 new mode 100644 index 26c68a6..1eb0be2 --- a/src/mnxmeth.c +++ b/src/mnxmeth.c @@ -1,8 +1,7 @@ -/* $Id: mnxmeth.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: mnxmeth.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: mnxmeth.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -16,10 +15,8 @@ static char *id = "$Id: mnxmeth.c,v 1.2 1999/01/03 02:07:25 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - #include #include #include @@ -68,34 +65,30 @@ extern char *sysout_name; extern int save_argc; extern char **save_argv; -extern DLword INVERT_atom; -extern DLword ERASE_atom; -extern DLword PAINT_atom; -extern DLword REPLACE_atom; +extern DLword INVERT_atom; +extern DLword ERASE_atom; +extern DLword PAINT_atom; +extern DLword REPLACE_atom; /**************************************************************/ /* Xerrhandler. */ /* Utility function to make URaid the error handler for X. */ /**************************************************************/ -int Xerrhandler( display, event ) - Display *display; - XErrorEvent *event; +int Xerrhandler(display, event) Display *display; +XErrorEvent *event; { char msg[80]; - + XGetErrorText(display, event->error_code, msg, 80); error(msg); } -intersectregions(reg1, reg2, result) - MRegion *reg1, *reg2, *result; +intersectregions(reg1, reg2, result) MRegion *reg1, *reg2, *result; { result->x = max(reg1->x, reg2->x); result->y = max(reg1->y, reg2->y); - result->width = result->x - min(reg1->x + reg1->width, - reg2->x + reg2->width); - result->height = result->y - min(reg1->y + reg1->height, - reg2->y + reg2->height); + result->width = result->x - min(reg1->x + reg1->width, reg2->x + reg2->width); + result->height = result->y - min(reg1->y + reg1->height, reg2->y + reg2->height); } /**************************************************************/ @@ -103,21 +96,21 @@ intersectregions(reg1, reg2, result) /* Utility function to calculate the white border of a window.*/ /* Takes a medley window as its argument. */ /**************************************************************/ -int getwhiteborder( medleywindow ) - LispPTR medleywindow; +int getwhiteborder(medleywindow) LispPTR medleywindow; { int border; - if(((MedleyWindow)Cptr(medleywindow))->WBORDER) + if (((MedleyWindow)Cptr(medleywindow))->WBORDER) border = LispIntToCInt(((MedleyWindow)Cptr(medleywindow))->WBORDER); else border = 0; - if(border <= 1) - return(0); - else if(border <= 3) - return(1); - else return(2); + if (border <= 1) + return (0); + else if (border <= 3) + return (1); + else + return (2); } /**************************************************************/ @@ -125,23 +118,23 @@ int getwhiteborder( medleywindow ) /* Utility function to calculate the black border of a window.*/ /* Takes a medley window as its argument. */ /**************************************************************/ -int getblackborder( medleywindow ) - LispPTR medleywindow; +int getblackborder(medleywindow) LispPTR medleywindow; { int border; - if(((MedleyWindow)Cptr(medleywindow))->WBORDER) + if (((MedleyWindow)Cptr(medleywindow))->WBORDER) border = LispIntToCInt(((MedleyWindow)Cptr(medleywindow))->WBORDER); else border = 0; - if(border <= 0) - return(0); - else if(border <= 2) - return(1); - else if(border <= 3) - return(2); - else return(border - 2); + if (border <= 0) + return (0); + else if (border <= 2) + return (1); + else if (border <= 3) + return (2); + else + return (border - 2); } /**************************************************************/ @@ -150,20 +143,19 @@ int getblackborder( medleywindow ) /* Takes a medley window as its argument. Returns a pointer to*/ /* a malloc'd c string or NULL if no string is present. */ /**************************************************************/ -char *gettitlestring( medleywin ) - LispPTR medleywin; +char *gettitlestring(medleywin) LispPTR medleywin; { char *titlestring; int strlen; - if(((MedleyWindow)Cptr(medleywin))->WTITLE == NIL) + if (((MedleyWindow)Cptr(medleywin))->WTITLE == NIL) titlestring = NULL; else { strlen = LispStringLength(((MedleyWindow)Cptr(medleywin))->WTITLE); titlestring = (char *)malloc(strlen + 1); LispStringToCStr(((MedleyWindow)Cptr(medleywin))->WTITLE, titlestring); } - return(titlestring); + return (titlestring); } /**************************************************************/ @@ -171,94 +163,74 @@ char *gettitlestring( medleywin ) /* Return the height of the title bar for this window. */ /* Pick the value from the TITLEDS of the screen. */ /**************************************************************/ -int gettitleheight( medleywin ) - LispPTR medleywin; +int gettitleheight(medleywin) LispPTR medleywin; { - if(((MedleyWindow)Cptr(medleywin))->WTITLE == NIL) - return(0); + if (((MedleyWindow)Cptr(medleywin))->WTITLE == NIL) + return (0); else { DISPLAYDATA *dd; dd = TitleDDFromMw(medleywin); - return(abs(LispIntToCInt(dd->ddlinefeed))); + return (abs(LispIntToCInt(dd->ddlinefeed))); } } - - - /**************************************************************/ /* setlineattributes */ /* This function attempts to syncronize the line data in lisp */ /* and X. */ /**************************************************************/ -void setlineattributes( display, dspif, wif, dd, mwidth, mdash ) - Display *display; - DspInterface dspif; - WindowInterface wif; - DISPLAYDATA *dd; - LispPTR mwidth, mdash; +void setlineattributes(display, dspif, wif, dd, mwidth, mdash) Display *display; +DspInterface dspif; +WindowInterface wif; +DISPLAYDATA *dd; +LispPTR mwidth, mdash; { int l, lw, ls; unsigned char *dash_list; - lw = ( mwidth == NIL )?0:LispIntToCInt(mwidth); - ls = ( mdash == NIL )?LineSolid:LineOnOffDash; + lw = (mwidth == NIL) ? 0 : LispIntToCInt(mwidth); + ls = (mdash == NIL) ? LineSolid : LineOnOffDash; - if( dd->ddoperation == INVERT_atom ) - { - XSetLineAttributes( display, wif->InvertGC, lw, ls, CapRound, JoinBevel); - XSetLineAttributes( display, dspif->PixIGC, lw, ls, CapRound, JoinBevel); - } - else if( dd->ddoperation == ERASE_atom ) - { - XSetLineAttributes( display, wif->EraseGC1, lw, ls, CapRound, JoinBevel); - XSetLineAttributes( display, wif->EraseGC2, lw, ls, CapRound, JoinBevel); - XSetLineAttributes( display, dspif->PixEGC, lw, ls, CapRound, JoinBevel); - } - else if( dd->ddoperation == PAINT_atom ) - { - XSetLineAttributes( display, wif->PaintGC1, lw, ls, CapRound, JoinBevel); - XSetLineAttributes( display, wif->PaintGC2, lw, ls, CapRound, JoinBevel); - XSetLineAttributes( display, dspif->PixPGC, lw, ls, CapRound, JoinBevel); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XSetLineAttributes( display, wif->ReplaceGC, lw, ls, CapRound, JoinBevel); - XSetLineAttributes( display, dspif->PixRGC, lw, ls, CapRound, JoinBevel); - } - - if( mdash != NIL ) { - l = LispStringLength( mdash ); - dash_list = (unsigned char *)malloc(l + 1); - LispStringToCStr( mdash , dash_list); - - if( dd->ddoperation == INVERT_atom ) - { - XSetDashes(display, wif->InvertGC, 0, dash_list, l); - XSetDashes(display, dspif->PixIGC, 0, dash_list, l); - } - else if( dd->ddoperation == ERASE_atom ) - { - XSetDashes(display, wif->EraseGC1, 0, dash_list, l); - XSetDashes(display, wif->EraseGC2, 0, dash_list, l); - XSetDashes(display, dspif->PixEGC, 0, dash_list, l); - } - else if( dd->ddoperation == PAINT_atom ) - { - XSetDashes(display, wif->PaintGC1, 0, dash_list, l); - XSetDashes(display, wif->PaintGC2, 0, dash_list, l); - XSetDashes(display, dspif->PixPGC, 0, dash_list, l); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XSetDashes(display, wif->ReplaceGC, 0, dash_list, l); - XSetDashes(display, dspif->PixRGC, 0, dash_list, l); - } + if (dd->ddoperation == INVERT_atom) { + XSetLineAttributes(display, wif->InvertGC, lw, ls, CapRound, JoinBevel); + XSetLineAttributes(display, dspif->PixIGC, lw, ls, CapRound, JoinBevel); + } else if (dd->ddoperation == ERASE_atom) { + XSetLineAttributes(display, wif->EraseGC1, lw, ls, CapRound, JoinBevel); + XSetLineAttributes(display, wif->EraseGC2, lw, ls, CapRound, JoinBevel); + XSetLineAttributes(display, dspif->PixEGC, lw, ls, CapRound, JoinBevel); + } else if (dd->ddoperation == PAINT_atom) { + XSetLineAttributes(display, wif->PaintGC1, lw, ls, CapRound, JoinBevel); + XSetLineAttributes(display, wif->PaintGC2, lw, ls, CapRound, JoinBevel); + XSetLineAttributes(display, dspif->PixPGC, lw, ls, CapRound, JoinBevel); + } else if (dd->ddoperation == REPLACE_atom) { + XSetLineAttributes(display, wif->ReplaceGC, lw, ls, CapRound, JoinBevel); + XSetLineAttributes(display, dspif->PixRGC, lw, ls, CapRound, JoinBevel); } -} -settileorigin(medleywin, x, y) - LispPTR medleywin, x, y; + if (mdash != NIL) { + l = LispStringLength(mdash); + dash_list = (unsigned char *)malloc(l + 1); + LispStringToCStr(mdash, dash_list); + + if (dd->ddoperation == INVERT_atom) { + XSetDashes(display, wif->InvertGC, 0, dash_list, l); + XSetDashes(display, dspif->PixIGC, 0, dash_list, l); + } else if (dd->ddoperation == ERASE_atom) { + XSetDashes(display, wif->EraseGC1, 0, dash_list, l); + XSetDashes(display, wif->EraseGC2, 0, dash_list, l); + XSetDashes(display, dspif->PixEGC, 0, dash_list, l); + } else if (dd->ddoperation == PAINT_atom) { + XSetDashes(display, wif->PaintGC1, 0, dash_list, l); + XSetDashes(display, wif->PaintGC2, 0, dash_list, l); + XSetDashes(display, dspif->PixPGC, 0, dash_list, l); + } else if (dd->ddoperation == REPLACE_atom) { + XSetDashes(display, wif->ReplaceGC, 0, dash_list, l); + XSetDashes(display, dspif->PixRGC, 0, dash_list, l); + } + } +} + +settileorigin(medleywin, x, y) LispPTR medleywin, x, y; { WindowInterface wif; Display *display; @@ -278,38 +250,32 @@ settileorigin(medleywin, x, y) XSetTSOrigin(display, wif->dspif->PixRGC, x, y); } - - /**************************************************************/ /**************************************************************/ -calculateshape( wif, x, y, width, height, topwidoffset, tophgtoffset) - WindowInterface wif; - LispPTR x, y, width, height; - int topwidoffset, tophgtoffset; +calculateshape(wif, x, y, width, height, topwidoffset, tophgtoffset) WindowInterface wif; +LispPTR x, y, width, height; +int topwidoffset, tophgtoffset; { - - wif->windowreg.width = LispIntToCInt( width ); - wif->windowreg.height = LispIntToCInt( height ); - wif->windowreg.x = LispIntToCInt( x ); - wif->windowreg.y = LispIntToCInt( y ); + wif->windowreg.width = LispIntToCInt(width); + wif->windowreg.height = LispIntToCInt(height); + wif->windowreg.x = LispIntToCInt(x); + wif->windowreg.y = LispIntToCInt(y); calcwif(wif, topwidoffset, tophgtoffset); } - /**************************************************************/ /* calcwif */ /* layout the regions. All calculations based on the outer */ /* region. The rest of the widget moves around this region. */ /**************************************************************/ -calcwif(wif, xoff, yoff) - WindowInterface wif; - int xoff, yoff; +calcwif(wif, xoff, yoff) WindowInterface wif; +int xoff, yoff; { int whiteborder, blackborder, blackborder2, titleheight, border; - blackborder = getblackborder( wif->MedleyWindow ); + blackborder = getblackborder(wif->MedleyWindow); blackborder2 = blackborder + blackborder; - whiteborder = getwhiteborder( wif->MedleyWindow ); + whiteborder = getwhiteborder(wif->MedleyWindow); /* Calculate the top & outer region */ wif->outerregion.y = 0; @@ -317,20 +283,18 @@ calcwif(wif, xoff, yoff) wif->outerregion.width = wif->windowreg.width; wif->topregion.width = wif->outerregion.width + /* wif->outerregion.x; */ - xoff; + xoff; wif->outerregion.height = wif->windowreg.height; wif->topregion.height = wif->outerregion.height + yoff; wif->topregion.x = wif->windowreg.x - wif->outerregion.x; - wif->topregion.y = (HeightOfScreen( wif->screen ) - - wif->windowreg.y - - wif->windowreg.height); + wif->topregion.y = (HeightOfScreen(wif->screen) - wif->windowreg.y - wif->windowreg.height); - titleheight = gettitleheight( wif->MedleyWindow ); + titleheight = gettitleheight(wif->MedleyWindow); /* Calculate the inner region. */ - border = 2*(blackborder + whiteborder); + border = 2 * (blackborder + whiteborder); wif->innerregion.x = blackborder; wif->innerregion.y = blackborder + titleheight; wif->innerregion.width = wif->windowreg.width - border; @@ -339,58 +303,37 @@ calcwif(wif, xoff, yoff) wif->whiteborder = whiteborder; wif->blackborder2 = blackborder2; - sprintf(wif->gstring, "%dx%d+%d+%d", - wif->topregion.width, - wif->topregion.height, - wif->topregion.x, - wif->topregion.y); + sprintf(wif->gstring, "%dx%d+%d+%d", wif->topregion.width, wif->topregion.height, + wif->topregion.x, wif->topregion.y); } - - /**************************************************************/ /**************************************************************/ -refreshwindow( medleywin ) - LispPTR medleywin; +refreshwindow(medleywin) LispPTR medleywin; { WindowInterface wif; DISPLAYDATA *dd; float top, shown; - wif = WIfFromMw( medleywin ); + wif = WIfFromMw(medleywin); dd = ImDataFromMw(medleywin); - calcwif(wif, wif->topregion.width-wif->outerregion.width, - wif->topregion.height - wif->outerregion.height); - XtVaSetValues(wif->formwidget, - XtNclippX, dd->ddclippingleft, - XtNclippY, dd->ddclippingbottom, - XtNclippWidth, dd->ddclippingright - dd->ddclippingleft, - XtNclippHeight, dd->ddclippingtop - dd->ddclippingbottom, - NULL); - if(XtIsRealized(wif->topwidget)){ - XtConfigureWidget(wif->topwidget, - wif->topregion.x, - wif->topregion.y, - wif->topregion.width, - wif->topregion.height, 0); + calcwif(wif, wif->topregion.width - wif->outerregion.width, + wif->topregion.height - wif->outerregion.height); + XtVaSetValues(wif->formwidget, XtNclippX, dd->ddclippingleft, XtNclippY, dd->ddclippingbottom, + XtNclippWidth, dd->ddclippingright - dd->ddclippingleft, XtNclippHeight, + dd->ddclippingtop - dd->ddclippingbottom, NULL); + if (XtIsRealized(wif->topwidget)) { + XtConfigureWidget(wif->topwidget, wif->topregion.x, wif->topregion.y, wif->topregion.width, + wif->topregion.height, 0); - XtConfigureWidget(wif->framewidget, - wif->outerregion.x, - wif->outerregion.y, - wif->outerregion.width, - wif->outerregion.height, 0); + XtConfigureWidget(wif->framewidget, wif->outerregion.x, wif->outerregion.y, + wif->outerregion.width, wif->outerregion.height, 0); - XtConfigureWidget(wif->windowwidget, - wif->innerregion.x, - wif->innerregion.y, - wif->innerregion.width, - wif->innerregion.height, - wif->whiteborder); + XtConfigureWidget(wif->windowwidget, wif->innerregion.x, wif->innerregion.y, + wif->innerregion.width, wif->innerregion.height, wif->whiteborder); } } - - /************************************************************************/ /* */ /* Translate X & Y window coords, allowing for offsets. */ @@ -399,28 +342,13 @@ refreshwindow( medleywin ) /* */ /************************************************************************/ -int translate_x(wif, xval) - int xval; - WindowInterface wif; - { - return (xval + (wif->xoffset - wif->windowreg.x - - (wif->blackborder2>>1) - wif->whiteborder )); - } - - - -int translate_y(wif, yval) - int yval; - WindowInterface wif; - { - return (yval + wif->yoffset - - (wif->windowreg.y + (wif->blackborder2>>1) + wif->whiteborder)); - } - - - - +int translate_x(wif, xval) int xval; +WindowInterface wif; +{ return (xval + (wif->xoffset - wif->windowreg.x - (wif->blackborder2 >> 1) - wif->whiteborder)); } +int translate_y(wif, yval) int yval; +WindowInterface wif; +{ return (yval + wif->yoffset - (wif->windowreg.y + (wif->blackborder2 >> 1) + wif->whiteborder)); } extern void SignalVJmpScroll(); extern void SignalVScroll(); @@ -437,68 +365,55 @@ extern void HandleStructure(); extern void HandleTitle(); extern void HandleExpose(); - /**************************************************************/ /* InitScratchDepth */ /* Init the scratch image to fit the description of a bitmap */ /**************************************************************/ -InitScratchDepth(image, MBM, scdepth) - XImage *image; - BITMAP *MBM; - int scdepth; +InitScratchDepth(image, MBM, scdepth) XImage *image; +BITMAP *MBM; +int scdepth; { /* Set up the scratch image for this operation */ image->width = MBM->bmwidth; image->height = MBM->bmheight; /* depth 1 implies that X should colorize */ - if((MBM->bmbitperpixel & 0xFFFF) == 1) - { - image->depth = MBM->bmbitperpixel & 0xFFFF; - image->bits_per_pixel = 1; - image->bytes_per_line = - (((image->width+(BITSPER_DLWORD-1)) - / BITSPER_DLWORD) - * (BITSPER_DLWORD/8)); - if (image->format != XYBitmap) - { - image->format = XYBitmap; - _XInitImageFuncPtrs(image); - } - } - else/* if(image->format != ZPixmap) */ - { - image->depth = MBM->bmbitperpixel & 0xFFFF; - image->format = ZPixmap; - image->red_mask = (scdepth / 3); - image->green_mask = ((scdepth - image->red_mask) / 2); - image->blue_mask = (scdepth - image->red_mask - image->green_mask); - image->bits_per_pixel = image->depth; + if ((MBM->bmbitperpixel & 0xFFFF) == 1) { + image->depth = MBM->bmbitperpixel & 0xFFFF; + image->bits_per_pixel = 1; + image->bytes_per_line = + (((image->width + (BITSPER_DLWORD - 1)) / BITSPER_DLWORD) * (BITSPER_DLWORD / 8)); + if (image->format != XYBitmap) { + image->format = XYBitmap; _XInitImageFuncPtrs(image); - image->bytes_per_line = - ((((image->width * image->depth)+(BITSPER_DLWORD-1)) - / BITSPER_DLWORD) - * (BITSPER_DLWORD/8)); } + } else /* if(image->format != ZPixmap) */ + { + image->depth = MBM->bmbitperpixel & 0xFFFF; + image->format = ZPixmap; + image->red_mask = (scdepth / 3); + image->green_mask = ((scdepth - image->red_mask) / 2); + image->blue_mask = (scdepth - image->red_mask - image->green_mask); + image->bits_per_pixel = image->depth; + _XInitImageFuncPtrs(image); + image->bytes_per_line = + ((((image->width * image->depth) + (BITSPER_DLWORD - 1)) / BITSPER_DLWORD) * + (BITSPER_DLWORD / 8)); + } } - /**************************************************************/ /* MakeScratchImageFromBM */ /* Convert a Lisp BITMAP to fit in the scratch image in the */ /* dspif. Use the scratch image in subsequent computations. */ /**************************************************************/ -MakeScratchImageFromBM(dspif, bitmap) - DspInterface dspif; - BITMAP *bitmap; +MakeScratchImageFromBM(dspif, bitmap) DspInterface dspif; +BITMAP *bitmap; { - InitScratchDepth(&dspif->image, bitmap, - DefaultDepthOfScreen(dspif->xscreen)); + InitScratchDepth(&dspif->image, bitmap, DefaultDepthOfScreen(dspif->xscreen)); dspif->image.data = (char *)Cptr((LispPTR)bitmap->bmbase); } - - /**************************************************************/ /* MakeScratchImageFromInt */ /* Convert a Lisp integer to be a bitmap in the scratch image */ @@ -509,12 +424,11 @@ MakeScratchImageFromBM(dspif, bitmap) /* is allocated. */ /**************************************************************/ int revbits[16] = {15, 7, 11, 3, 13, 5, 9, 1, 14, 6, 10, 2, 12, 4, 8, 0}; -MakeScratchImageFromInt(dspif, Texture) - DspInterface dspif; - int Texture; +MakeScratchImageFromInt(dspif, Texture) DspInterface dspif; +int Texture; { int width, height, pixpos, x, y; - unsigned char *bits = (unsigned char *) dspif->image.data; + unsigned char *bits = (unsigned char *)dspif->image.data; unsigned int tbits; width = height = 4; pixpos = 0; @@ -523,22 +437,18 @@ MakeScratchImageFromInt(dspif, Texture) dspif->image.depth = 1; dspif->image.format = XYBitmap; dspif->image.bytes_per_line = - ((width+(BITSPER_DLWORD-1)) /BITSPER_DLWORD) * (BITSPER_DLWORD/8); - - - tbits= revbits[Texture >> 12]; - bits[0] = (tbits<<4) | tbits; - tbits= revbits[15 & (Texture >> 8)]; - bits[1] = (tbits<<4) | tbits; - tbits= revbits[15 & (Texture >> 4)]; - bits[2] = (tbits<<4) | tbits; - tbits= revbits[15 & (Texture)]; - bits[3] = (tbits<<4) | tbits; + ((width + (BITSPER_DLWORD - 1)) / BITSPER_DLWORD) * (BITSPER_DLWORD / 8); + tbits = revbits[Texture >> 12]; + bits[0] = (tbits << 4) | tbits; + tbits = revbits[15 & (Texture >> 8)]; + bits[1] = (tbits << 4) | tbits; + tbits = revbits[15 & (Texture >> 4)]; + bits[2] = (tbits << 4) | tbits; + tbits = revbits[15 & (Texture)]; + bits[3] = (tbits << 4) | tbits; } - - /**************************************************************/ /* settexture */ /* Argument is a Medleywindow. This function scans the texture*/ @@ -548,8 +458,7 @@ MakeScratchImageFromInt(dspif, Texture) /* the background from the upper left corner. This is not */ /* accounted for. */ /**************************************************************/ -settexture(medleywin) - LispPTR medleywin; +settexture(medleywin) LispPTR medleywin; { DspInterface dspif; WindowInterface wif; @@ -562,177 +471,151 @@ settexture(medleywin) dd = ImDataFromMw(medleywin); display = dspif->handle; - if(dd->ddtexture != NIL){ - if(GetTypeNumber(dd->ddtexture) == TYPE_SMALLP) - if(LispIntToCInt(MScrFromMw(medleywin)->SCDEPTH) == 1){ - char id[64]; - dspif->image.data = id; /* Danger zone! read comment for function in next call */ - MakeScratchImageFromInt(dspif, LispIntToCInt(dd->ddtexture)); - } - else { - unsigned long pixval; + if (dd->ddtexture != NIL) { + if (GetTypeNumber(dd->ddtexture) == TYPE_SMALLP) + if (LispIntToCInt(MScrFromMw(medleywin)->SCDEPTH) == 1) { + char id[64]; + dspif->image.data = id; /* Danger zone! read comment for function in next call */ + MakeScratchImageFromInt(dspif, LispIntToCInt(dd->ddtexture)); + } else { + unsigned long pixval; - pixval = ~(unsigned long)LispIntToCInt(dd->ddtexture); - /* Set the background for pixel ops in this window */ - XSetBackground(display, wif->InvertGC, pixval); - XSetBackground(display, wif->EraseGC1, pixval); - XSetBackground(display, wif->EraseGC2, pixval); - XSetBackground(display, wif->PaintGC1, pixval); - XSetBackground(display, wif->PaintGC2, pixval); - XSetBackground(display, wif->ReplaceGC, pixval); - XSetBackground(display, dspif->PixIGC, pixval); - XSetBackground(display, dspif->PixEGC, pixval); - XSetBackground(display, dspif->PixPGC, pixval); - XSetBackground(display, dspif->PixRGC, pixval); - XtVaSetValues(wif->windowwidget, XtNbackground, pixval, NULL); - return(NIL); + pixval = ~(unsigned long)LispIntToCInt(dd->ddtexture); + /* Set the background for pixel ops in this window */ + XSetBackground(display, wif->InvertGC, pixval); + XSetBackground(display, wif->EraseGC1, pixval); + XSetBackground(display, wif->EraseGC2, pixval); + XSetBackground(display, wif->PaintGC1, pixval); + XSetBackground(display, wif->PaintGC2, pixval); + XSetBackground(display, wif->ReplaceGC, pixval); + XSetBackground(display, dspif->PixIGC, pixval); + XSetBackground(display, dspif->PixEGC, pixval); + XSetBackground(display, dspif->PixPGC, pixval); + XSetBackground(display, dspif->PixRGC, pixval); + XtVaSetValues(wif->windowwidget, XtNbackground, pixval, NULL); + return (NIL); } - else { /* Its a bitmap */ + else { /* Its a bitmap */ MakeScratchImageFromBM(dspif, (BITMAP *)Cptr(dd->ddtexture)); } - } - else { /* ddtexture is NIL */ + } else { /* ddtexture is NIL */ char id[64]; - dspif->image.data = id; /* Danger zone! read comment for function in next call */ + dspif->image.data = id; /* Danger zone! read comment for function in next call */ MakeScratchImageFromInt(dspif, 0); } - if(wif->bgpixmap){ + if (wif->bgpixmap) { /* If we have an fgpixmap, junk it */ XFreePixmap(display, wif->bgpixmap); wif->bgpixmap = 0; } - bgpixmap = XCreatePixmapFromBitmapData - (display, - dspif->root, - dspif->image.data, - dspif->image.width, - dspif->image.height, - WhitePixelOfScreen(wif->screen), - BlackPixelOfScreen(wif->screen), - DefaultDepthOfScreen(wif->screen)); + bgpixmap = XCreatePixmapFromBitmapData( + display, dspif->root, dspif->image.data, dspif->image.width, dspif->image.height, + WhitePixelOfScreen(wif->screen), BlackPixelOfScreen(wif->screen), + DefaultDepthOfScreen(wif->screen)); XSetTile(display, wif->InvertGC, bgpixmap); XSetTile(display, wif->EraseGC1, bgpixmap); XSetTile(display, wif->EraseGC2, bgpixmap); XSetTile(display, wif->PaintGC1, bgpixmap); XSetTile(display, wif->PaintGC2, bgpixmap); XSetTile(display, wif->ReplaceGC, bgpixmap); -/* XSetTile(display, dspif->PixIGC, bgpixmap); - XSetTile(display, dspif->PixEGC, bgpixmap); - XSetTile(display, dspif->PixPGC, bgpixmap); - XSetTile(display, dspif->PixRGC, bgpixmap); */ + /* XSetTile(display, dspif->PixIGC, bgpixmap); + XSetTile(display, dspif->PixEGC, bgpixmap); + XSetTile(display, dspif->PixPGC, bgpixmap); + XSetTile(display, dspif->PixRGC, bgpixmap); */ XtVaSetValues(wif->windowwidget, XtNbackgroundPixmap, bgpixmap, NULL); wif->bgpixmap = bgpixmap; - return(NIL); + return (NIL); } - - - -MBMToDrawable(MBM, dspif, wif, srcx, srcy, dstx, dsty, width, height, operation) - BITMAP *MBM; - WindowInterface wif; - DspInterface dspif; - int srcx, srcy, dstx, dsty, width, height, operation; +MBMToDrawable(MBM, dspif, wif, srcx, srcy, dstx, dsty, width, height, operation) BITMAP *MBM; +WindowInterface wif; +DspInterface dspif; +int srcx, srcy, dstx, dsty, width, height, operation; { Window window; window = XtWindow(wif->windowwidget); - if((MBM->bmbitperpixel == 1) || - (MBM->bmbitperpixel == DefaultDepthOfScreen(wif->screen))) - { - InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(wif->screen)); - dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); - switch(operation) - { - case REPLACE: if (window) XPutImage(dspif->handle, window, wif->ReplaceGC, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - XPutImage(dspif->handle, wif->backing, dspif->PixRGC, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - break; + if ((MBM->bmbitperpixel == 1) || (MBM->bmbitperpixel == DefaultDepthOfScreen(wif->screen))) { + InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(wif->screen)); + dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); + switch (operation) { + case REPLACE: + if (window) + XPutImage(dspif->handle, window, wif->ReplaceGC, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixRGC, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; - case INVERT: if (window) XPutImage(dspif->handle, - window, wif->InvertGC, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - XPutImage(dspif->handle, wif->backing, dspif->PixIGC, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - break; + case INVERT: + if (window) + XPutImage(dspif->handle, window, wif->InvertGC, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixIGC, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; - case PAINT: if (window) XPutImage(dspif->handle, window, wif->PaintGC1, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - if (window) XPutImage(dspif->handle, window, wif->PaintGC2, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - XPutImage(dspif->handle, wif->backing, dspif->PixPGC, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - break; + case PAINT: + if (window) + XPutImage(dspif->handle, window, wif->PaintGC1, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + if (window) + XPutImage(dspif->handle, window, wif->PaintGC2, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixPGC, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; - case ERASE: if (window) XPutImage(dspif->handle, window, wif->EraseGC1, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - if (window) XPutImage(dspif->handle, window, wif->EraseGC2, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - XPutImage(dspif->handle, wif->backing, dspif->PixEGC, - &dspif->image, srcx, srcy, dstx, dsty, - width, height); - break; - } + case ERASE: + if (window) + XPutImage(dspif->handle, window, wif->EraseGC1, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + if (window) + XPutImage(dspif->handle, window, wif->EraseGC2, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + XPutImage(dspif->handle, wif->backing, dspif->PixEGC, &dspif->image, srcx, srcy, dstx, dsty, + width, height); + break; } - else { - /* JDS 2/22/94: I'm not sure this part is right; haven't thought about it. */ + } else { + /* JDS 2/22/94: I'm not sure this part is right; haven't thought about it. */ int x, y; InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(wif->screen)); dspif->image.depth = DefaultDepthOfScreen(wif->screen); - dspif->image.data = (char *)malloc(dspif->image.bytes_per_line - * dspif->image.width - * dspif->image.depth); + dspif->image.data = + (char *)malloc(dspif->image.bytes_per_line * dspif->image.width * dspif->image.depth); InitScratchDepth(&dspif->tmpimage, MBM, DefaultDepthOfScreen(wif->screen)); dspif->tmpimage.data = (char *)Cptr((LispPTR)MBM->bmbase); - for(x = 0; x < MBM->bmwidth; x++) - for(y = 0; y < MBM->bmheight; y++) - XPutPixel(&dspif->image, x, y, XGetPixel(&dspif->tmpimage, x, y)); - if( operation == INVERT_atom ) - { - XPutImage(dspif->handle, window, wif->InvertGC, - &dspif->image, srcx,srcy,dstx,dsty,width,height); - } - else if( operation == ERASE_atom ) - { - XPutImage(dspif->handle, window, wif->EraseGC1, - &dspif->image, srcx,srcy,dstx,dsty,width,height); - XPutImage(dspif->handle, window, wif->EraseGC2, - &dspif->image, srcx,srcy,dstx,dsty,width,height); - } - else if( operation == PAINT_atom ) - { - XPutImage(dspif->handle, window, wif->PaintGC1, - &dspif->image, srcx,srcy,dstx,dsty,width,height); - XPutImage(dspif->handle, window, wif->PaintGC2, - &dspif->image, srcx,srcy,dstx,dsty,width,height); - } - else if( operation == REPLACE_atom ) - { - XPutImage(dspif->handle, window, wif->ReplaceGC, - &dspif->image, srcx,srcy,dstx,dsty,width,height); - } + for (x = 0; x < MBM->bmwidth; x++) + for (y = 0; y < MBM->bmheight; y++) + XPutPixel(&dspif->image, x, y, XGetPixel(&dspif->tmpimage, x, y)); + if (operation == INVERT_atom) { + XPutImage(dspif->handle, window, wif->InvertGC, &dspif->image, srcx, srcy, dstx, dsty, width, + height); + } else if (operation == ERASE_atom) { + XPutImage(dspif->handle, window, wif->EraseGC1, &dspif->image, srcx, srcy, dstx, dsty, width, + height); + XPutImage(dspif->handle, window, wif->EraseGC2, &dspif->image, srcx, srcy, dstx, dsty, width, + height); + } else if (operation == PAINT_atom) { + XPutImage(dspif->handle, window, wif->PaintGC1, &dspif->image, srcx, srcy, dstx, dsty, width, + height); + XPutImage(dspif->handle, window, wif->PaintGC2, &dspif->image, srcx, srcy, dstx, dsty, width, + height); + } else if (operation == REPLACE_atom) { + XPutImage(dspif->handle, window, wif->ReplaceGC, &dspif->image, srcx, srcy, dstx, dsty, width, + height); + } free(dspif->image.data); } } - - /************************************************************************/ /* DrawableToMBM */ /* Copy a drawable to a Medley bitmap. All coordinates are in X style. */ @@ -743,85 +626,61 @@ MBMToDrawable(MBM, dspif, wif, srcx, srcy, dstx, dsty, width, height, operation) /* This offcause means that anything outside the screen will have to be */ /* ignored. (This has to be fixed. This sucks.). */ /************************************************************************/ -DrawableToMBM(MBM, dspif, wif, xdrawable, xscreen, srcx, srcy, dstx, dsty, width, height, op) - BITMAP *MBM; - WindowInterface wif; - Screen *xscreen; - Drawable xdrawable; - DspInterface dspif; - int srcx, srcy, dstx, dsty, width, height, op; +DrawableToMBM(MBM, dspif, wif, xdrawable, xscreen, srcx, srcy, dstx, dsty, width, height, + op) BITMAP *MBM; +WindowInterface wif; +Screen *xscreen; +Drawable xdrawable; +DspInterface dspif; +int srcx, srcy, dstx, dsty, width, height, op; { #ifdef NEVER - if(MBM->bmbitperpixel == DefaultDepthOfScreen(xscreen)) - { - InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(xscreen)); - dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); - XGetSubImage(dspif->handle, - xdrawable, - srcx, srcy, - width, height, - AllPlanes, - ZPixmap, - &dspif->image, dstx, dsty); - } - else - { + if (MBM->bmbitperpixel == DefaultDepthOfScreen(xscreen)) { + InitScratchDepth(&dspif->image, MBM, DefaultDepthOfScreen(xscreen)); + dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); + XGetSubImage(dspif->handle, xdrawable, srcx, srcy, width, height, AllPlanes, ZPixmap, + &dspif->image, dstx, dsty); + } else { int x, y, scdepth; BITMAP tmp; - scdepth = DefaultDepthOfScreen(xscreen); tmp.bmwidth = MBM->bmwidth; tmp.bmheight = MBM->bmheight; tmp.bmbitperpixel = scdepth; - InitScratchDepth(&dspif->tmpimage, &tmp, scdepth); + InitScratchDepth(&dspif->tmpimage, &tmp, scdepth); dspif->tmpimage.depth = scdepth; - dspif->tmpimage.data = (char *)malloc(dspif->tmpimage.bytes_per_line - * dspif->tmpimage.width - * dspif->tmpimage.depth); - XGetSubImage(dspif->handle, - xdrawable, - srcx, srcy, - width, height, - AllPlanes, - ZPixmap, - &dspif->tmpimage, dstx, dsty); + dspif->tmpimage.data = (char *)malloc(dspif->tmpimage.bytes_per_line * dspif->tmpimage.width * + dspif->tmpimage.depth); + XGetSubImage(dspif->handle, xdrawable, srcx, srcy, width, height, AllPlanes, ZPixmap, + &dspif->tmpimage, dstx, dsty); InitScratchDepth(&dspif->image, MBM, MBM->bmbitperpixel); dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); - for(x = 0; x < MBM->bmwidth; x++) - for(y = 0; y < MBM->bmheight; y++) - XPutPixel(&dspif->image, x, y, !XGetPixel(&dspif->tmpimage, x, y)); + for (x = 0; x < MBM->bmwidth; x++) + for (y = 0; y < MBM->bmheight; y++) + XPutPixel(&dspif->image, x, y, !XGetPixel(&dspif->tmpimage, x, y)); free(dspif->tmpimage.data); } -#else /* NEVER */ - InitScratchDepth(&dspif->image, MBM, 1); - dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); - XGetSubImage(dspif->handle, - xdrawable, - srcx, srcy, - width, height, - AllPlanes, - ZPixmap, - &dspif->image, dstx, dsty); +#else /* NEVER */ + InitScratchDepth(&dspif->image, MBM, 1); + dspif->image.data = (char *)Cptr((LispPTR)MBM->bmbase); + XGetSubImage(dspif->handle, xdrawable, srcx, srcy, width, height, AllPlanes, ZPixmap, + &dspif->image, dstx, dsty); #endif /* Never */ - } - - -MNXBBTToXWindow( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = LispPTR to src BITMAP */ - /* args[2] = scr_x */ - /* args[3] = scr_y */ - /* args[4] = dst WINDOW */ - /* args[5] = dst_x */ - /* args[6] = dst_y */ - /* args[7] = width */ - /* args[8] = height */ - /* args[9] = operation */ +MNXBBTToXWindow(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to src BITMAP */ + /* args[2] = scr_x */ + /* args[3] = scr_y */ + /* args[4] = dst WINDOW */ + /* args[5] = dst_x */ + /* args[6] = dst_y */ + /* args[7] = width */ + /* args[8] = height */ + /* args[9] = operation */ { WindowInterface wif; DspInterface dspif; @@ -834,36 +693,30 @@ MNXBBTToXWindow( args ) display = XDisplayFromMw(args[0]); bitmap = (BITMAP *)Cptr(args[1]); - if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + if (!wif->open) return (NIL); /* If window not open, don't do anything. */ /* Transform the coordinates */ width = LispIntToCInt(args[7]); height = LispIntToCInt(args[8]); dsty = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[6])) - height; srcy = (bitmap->bmheight & 0xFFFF) - LispIntToCInt(args[3]) - height; - MBMToDrawable(bitmap, dspif, wif, - LispIntToCInt(args[2]), /* src x */ - srcy, - translate_x(wif, LispIntToCInt(args[5])), /* dst x */ - dsty, width, height, args[9]&0xF); + MBMToDrawable(bitmap, dspif, wif, LispIntToCInt(args[2]), /* src x */ + srcy, translate_x(wif, LispIntToCInt(args[5])), /* dst x */ + dsty, width, height, args[9] & 0xF); XFlush(display); } - - - -MNXBBTFromXWindow( args ) - LispArgs args; /* args[0] = LispPTR to src WINDOW */ - /* args[1] = scr_x */ - /* args[2] = scr_y */ - /* args[3] = LispPTR to dst BITMAP */ - /* args[4] = dst_x */ - /* args[5] = dst_y */ - /* args[6] = width */ - /* args[7] = height */ - /* args[8] = operation */ - /* Things to remember: This function does not handle integer-textures */ - /* The handling of the OPERATION argument is done in lisp */ +MNXBBTFromXWindow(args) LispArgs args; /* args[0] = LispPTR to src WINDOW */ + /* args[1] = scr_x */ + /* args[2] = scr_y */ + /* args[3] = LispPTR to dst BITMAP */ + /* args[4] = dst_x */ + /* args[5] = dst_y */ + /* args[6] = width */ + /* args[7] = height */ + /* args[8] = operation */ +/* Things to remember: This function does not handle integer-textures */ +/* The handling of the OPERATION argument is done in lisp */ { WindowInterface wif; DspInterface dspif; @@ -876,35 +729,36 @@ MNXBBTFromXWindow( args ) display = XDisplayFromMw(args[0]); bitmap = (BITMAP *)Cptr(args[3]); - if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + if (!wif->open) return (NIL); /* If window not open, don't do anything. */ /* Transform the coordinates */ srcx = max(0, translate_x(wif, LispIntToCInt(args[1]))); dstx = LispIntToCInt(args[4]); - width = min(LispIntToCInt(args[6]), wif->innerregion.width - max(0, srcx));; - height = min(LispIntToCInt(args[7]), wif->innerregion.height - LispIntToCInt(args[2]));; + width = min(LispIntToCInt(args[6]), wif->innerregion.width - max(0, srcx)); + ; + height = min(LispIntToCInt(args[7]), wif->innerregion.height - LispIntToCInt(args[2])); + ; srcy = max(0, wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - height); dsty = (bitmap->bmheight & 0xFFFF) - LispIntToCInt(args[5]) - height; - DrawableToMBM(bitmap, dspif, wif, wif->backing, wif->screen, srcx, srcy, dstx, dsty, width, height, args[8]&0xF); + DrawableToMBM(bitmap, dspif, wif, wif->backing, wif->screen, srcx, srcy, dstx, dsty, width, + height, args[8] & 0xF); XFlush(display); - return(ATOM_T); + return (ATOM_T); } - -MNXBBTWinWin( args ) - LispArgs args; /* args[0] = LispPTR to src WINDOW */ - /* args[1] = scr_x */ - /* args[2] = scr_y */ - /* args[3] = LispPTR to dst WINDOW */ - /* args[4] = dst_x */ - /* args[5] = dst_y */ - /* args[6] = width */ - /* args[7] = height */ - /* args[8] = operation */ - /* Things to remember: This function does not handle integer-textures */ +MNXBBTWinWin(args) LispArgs args; /* args[0] = LispPTR to src WINDOW */ + /* args[1] = scr_x */ + /* args[2] = scr_y */ + /* args[3] = LispPTR to dst WINDOW */ + /* args[4] = dst_x */ + /* args[5] = dst_y */ + /* args[6] = width */ + /* args[7] = height */ + /* args[8] = operation */ +/* Things to remember: This function does not handle integer-textures */ { WindowInterface srcwif, dstwif; DspInterface dspif; @@ -917,15 +771,13 @@ MNXBBTWinWin( args ) srcwif = WIfFromMw(args[0]); dstwif = WIfFromMw(args[3]); dspif = DspIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); display = XtDisplay(srcwif->windowwidget); swin = XtWindow(srcwif->windowwidget); dwin = XtWindow(dstwif->windowwidget); - - if (!srcwif->open) return(NIL); /* If window not open, don't do anything. */ - if (!dstwif->open) return(NIL); /* If window not open, don't do anything. */ - + if (!srcwif->open) return (NIL); /* If window not open, don't do anything. */ + if (!dstwif->open) return (NIL); /* If window not open, don't do anything. */ /* Transform the coordinates */ width = LispIntToCInt(args[6]); @@ -935,47 +787,38 @@ MNXBBTWinWin( args ) srcx = translate_x(srcwif, LispIntToCInt(args[1])); dstx = translate_x(dstwif, LispIntToCInt(args[4])); - switch (args[8] & 0xF) - { - case INVERT: XCopyArea( display, swin, dwin, srcwif->InvertGC, - srcx, srcy, width, height, dstx, dsty); - XCopyArea(display, srcwif->backing, dstwif->backing, - dspif->PixIGC, srcx, srcy, width, height, - dstx, dsty); - break; + switch (args[8] & 0xF) { + case INVERT: + XCopyArea(display, swin, dwin, srcwif->InvertGC, srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, dspif->PixIGC, srcx, srcy, width, height, + dstx, dsty); + break; - case ERASE: XCopyArea(display, swin, dwin, srcwif->EraseGC1, - srcx, srcy, width, height, dstx, dsty); - XCopyArea(display, swin, dwin, srcwif->EraseGC2, - srcx, srcy, width, height, dstx, dsty); - XCopyArea(display, srcwif->backing, dstwif->backing, - dspif->PixEGC, srcx, srcy, width, height, - dstx, dsty); - break; + case ERASE: + XCopyArea(display, swin, dwin, srcwif->EraseGC1, srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, swin, dwin, srcwif->EraseGC2, srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, dspif->PixEGC, srcx, srcy, width, height, + dstx, dsty); + break; - case PAINT: XCopyArea(display, swin, dwin, srcwif->PaintGC1, - srcx, srcy, width, height, dstx, dsty); - XCopyArea(display, swin, dwin, srcwif->PaintGC2, - srcx, srcy, width, height, dstx, dsty); - XCopyArea(display, srcwif->backing, dstwif->backing, - dspif->PixPGC, srcx, srcy, width, height, - dstx, dsty); - break; + case PAINT: + XCopyArea(display, swin, dwin, srcwif->PaintGC1, srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, swin, dwin, srcwif->PaintGC2, srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, dspif->PixPGC, srcx, srcy, width, height, + dstx, dsty); + break; - case REPLACE: XCopyArea(display, swin, dwin, srcwif->ReplaceGC, - srcx, srcy, width, height, dstx, dsty); - XCopyArea(display, srcwif->backing, dstwif->backing, - dspif->PixRGC, srcx, srcy, width, height, - dstx, dsty); - break; - } + case REPLACE: + XCopyArea(display, swin, dwin, srcwif->ReplaceGC, srcx, srcy, width, height, dstx, dsty); + XCopyArea(display, srcwif->backing, dstwif->backing, dspif->PixRGC, srcx, srcy, width, height, + dstx, dsty); + break; + } XFlush(display); - return(ATOM_T); + return (ATOM_T); } - - /************************************************************************/ /* MNXcloseW */ /* Close a window and save the inner region of the window. */ @@ -983,8 +826,7 @@ MNXBBTWinWin( args ) /* contrary to Medleys own window system. If you do tricks with the */ /* SAVE field of the window, reconsider your evil ways. */ /************************************************************************/ -MNXcloseW ( args ) - LispArgs args; +MNXcloseW(args) LispArgs args; { Display *display; WindowInterface wif; @@ -995,61 +837,43 @@ MNXcloseW ( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif->open) return(NIL); /* If window not open, don't close it. */ + if (!wif->open) return (NIL); /* If window not open, don't close it. */ wif->open = 0; /* If it is, tell others it's closed. */ bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); DrawableToMBM(bitmap, dspif, wif, wif->backing, wif->screen, 0, 0, - /* wif->innerregion.x, wif->innerregion.y, */ 0, 0, - wif->innerregion.width, wif->innerregion.height, REPLACE); + /* wif->innerregion.x, wif->innerregion.y, */ 0, 0, wif->innerregion.width, + wif->innerregion.height, REPLACE); XtUnrealizeWidget(wif->topwidget); - XtRemoveEventHandler(wif->framewidget, - ButtonPressMask | ButtonReleaseMask, - False, HandleButton, wif); - XtRemoveEventHandler(wif->framewidget, - PointerMotionMask, - False, HandleMotion, wif); - XtRemoveEventHandler(wif->framewidget, - KeyPressMask | KeyReleaseMask, - False, HandleKey, wif); - XtRemoveEventHandler(wif->framewidget, - EnterWindowMask | LeaveWindowMask, - False, HandleCrossing, wif); - XtRemoveEventHandler(wif->framewidget, - FocusChangeMask, - False, HandleFocus, wif); - XtRemoveEventHandler(wif->framewidget, - ExposureMask, - False, HandleTitle, wif); - XtRemoveEventHandler(wif->windowwidget, - ExposureMask, - False, HandleExpose, wif); - XtRemoveEventHandler(wif->topwidget, - StructureNotifyMask, - False, HandleStructure, wif); - wif->not_exposed = 1; /* next time we open this, display it */ + XtRemoveEventHandler(wif->framewidget, ButtonPressMask | ButtonReleaseMask, False, HandleButton, + wif); + XtRemoveEventHandler(wif->framewidget, PointerMotionMask, False, HandleMotion, wif); + XtRemoveEventHandler(wif->framewidget, KeyPressMask | KeyReleaseMask, False, HandleKey, wif); + XtRemoveEventHandler(wif->framewidget, EnterWindowMask | LeaveWindowMask, False, HandleCrossing, + wif); + XtRemoveEventHandler(wif->framewidget, FocusChangeMask, False, HandleFocus, wif); + XtRemoveEventHandler(wif->framewidget, ExposureMask, False, HandleTitle, wif); + XtRemoveEventHandler(wif->windowwidget, ExposureMask, False, HandleExpose, wif); + XtRemoveEventHandler(wif->topwidget, StructureNotifyMask, False, HandleStructure, wif); + wif->not_exposed = 1; /* next time we open this, display it */ XFlush(display); - return(ATOM_T); + return (ATOM_T); } - - -WindowInterface removewif(chain, wif) - WindowInterface chain, wif; +WindowInterface removewif(chain, wif) WindowInterface chain, wif; { /* Recursive unlink off the wif from chain */ - if(chain == (WindowInterface)NULL) - return(NULL); - else if(chain == wif) return(chain->next); + if (chain == (WindowInterface)NULL) + return (NULL); + else if (chain == wif) + return (chain->next); else { chain->next = removewif(chain->next, wif); - return(chain); + return (chain); } } - - /************************************************************************/ /* bubblewif */ /* Make shure that the wif is the first wif in the chain of wifs on the */ @@ -1057,50 +881,46 @@ WindowInterface removewif(chain, wif) /* Return wif if we find wif. Return NIL if we don't find wif. */ /* */ /************************************************************************/ -WindowInterface bubblewif(dspif, wif) - DspInterface dspif; - WindowInterface wif; +WindowInterface bubblewif(dspif, wif) DspInterface dspif; +WindowInterface wif; { WindowInterface curr, prev; - if(dspif->CreatedWifs == (WindowInterface)NULL) return(NIL); - if(dspif->CreatedWifs == wif) return(wif); + if (dspif->CreatedWifs == (WindowInterface)NULL) return (NIL); + if (dspif->CreatedWifs == wif) return (wif); /* Find the wif we are interested in. */ - for(prev = dspif->CreatedWifs, curr = prev->next; - ((curr != (WindowInterface)NULL) && (curr != wif)); - curr = curr->next, prev = prev->next); - if(curr == (WindowInterface)NULL) return(NIL); /* wif not found */ + for (prev = dspif->CreatedWifs, curr = prev->next; + ((curr != (WindowInterface)NULL) && (curr != wif)); curr = curr->next, prev = prev->next) + ; + if (curr == (WindowInterface)NULL) return (NIL); /* wif not found */ /* Bubble curr to the head of the list */ prev->next = curr->next; curr->next = dspif->CreatedWifs; dspif->CreatedWifs = curr; - return(wif); + return (wif); } - - /************************************************************************/ /* destroyw/Xdestroyw */ /* Destroy a window by freeing all structures associated with it. */ /* */ /************************************************************************/ -destroyw(dspif, wif, medleyw) - WindowInterface wif; - DspInterface dspif; - MedleyWindow medleyw; +destroyw(dspif, wif, medleyw) WindowInterface wif; +DspInterface dspif; +MedleyWindow medleyw; -{ /* Tell X to destroy its part. */ +{ /* Tell X to destroy its part. */ + + if (wif->topwidget) XtDestroyWidget(wif->topwidget); + if (wif->InvertGC) XFreeGC(dspif->handle, wif->InvertGC); + if (wif->EraseGC1) XFreeGC(dspif->handle, wif->EraseGC1); + if (wif->EraseGC2) XFreeGC(dspif->handle, wif->EraseGC2); + if (wif->PaintGC1) XFreeGC(dspif->handle, wif->PaintGC1); + if (wif->PaintGC2) XFreeGC(dspif->handle, wif->PaintGC2); + if (wif->ReplaceGC) XFreeGC(dspif->handle, wif->ReplaceGC); - if(wif->topwidget) XtDestroyWidget(wif->topwidget); - if(wif->InvertGC) XFreeGC(dspif->handle, wif->InvertGC); - if(wif->EraseGC1) XFreeGC(dspif->handle, wif->EraseGC1); - if(wif->EraseGC2) XFreeGC(dspif->handle, wif->EraseGC2); - if(wif->PaintGC1) XFreeGC(dspif->handle, wif->PaintGC1); - if(wif->PaintGC2) XFreeGC(dspif->handle, wif->PaintGC2); - if(wif->ReplaceGC) XFreeGC(dspif->handle, wif->ReplaceGC); - XFreePixmap(dspif->handle, wif->backing); dspif->CreatedWifs = removewif(dspif->CreatedWifs, wif); @@ -1110,19 +930,13 @@ destroyw(dspif, wif, medleyw) medleyw->NativeIf = 0; } - - -MNXdestroyW( args ) - LispArgs args; +MNXdestroyW(args) LispArgs args; { -/* Medley interface to destroyw */ - destroyw( DspIfFromMw(args[0]), WIfFromMw(args[0]),Cptr(args[0])); - return(ATOM_T); + /* Medley interface to destroyw */ + destroyw(DspIfFromMw(args[0]), WIfFromMw(args[0]), Cptr(args[0])); + return (ATOM_T); } - - - /************************************************************************/ /* MNXdestroyDisplay */ /* Closeing down the screen means that we have to invalidate all window */ @@ -1131,8 +945,7 @@ MNXdestroyW( args ) /* */ /************************************************************************/ -MNXdestroyDisplay( args ) - LispArgs args; /* args[0] = LispPTR to MedleyScreen */ +MNXdestroyDisplay(args) LispArgs args; /* args[0] = LispPTR to MedleyScreen */ { DspInterface dspif; WindowInterface i; @@ -1151,25 +964,20 @@ MNXdestroyDisplay( args ) dspif->cursor = 0; /* Smash the handles of all the created wifs. */ - if(dspif != NULL) - { - for(i = dspif->CreatedWifs; i != NULL; i = dspif->CreatedWifs) - destroyw(dspif, i, (MedleyWindow)Cptr(i->MedleyWindow)); + if (dspif != NULL) { + for (i = dspif->CreatedWifs; i != NULL; i = dspif->CreatedWifs) + destroyw(dspif, i, (MedleyWindow)Cptr(i->MedleyWindow)); - if (dspif->legatewidget) XtDestroyWidget(dspif->legatewidget); - XtCloseDisplay(dspif->handle); - (void)free(dspif); - } + if (dspif->legatewidget) XtDestroyWidget(dspif->legatewidget); + XtCloseDisplay(dspif->handle); + (void)free(dspif); + } } - - - -MNXmoveW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = left */ - /* args[2] = bottom */ - /* args[3] = non-NIL => skip actually moving it */ +MNXmoveW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = non-NIL => skip actually moving it */ { Display *dsp; WindowInterface wif; @@ -1177,84 +985,65 @@ MNXmoveW( args ) dsp = XDisplayFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif) return(NIL); /* no real window, no action. */ - wif->moving = 1; /* tell event handler to expect an event */ + if (!wif) return (NIL); /* no real window, no action. */ + wif->moving = 1; /* tell event handler to expect an event */ wif->windowreg.x = LispIntToCInt(args[1]); wif->windowreg.y = LispIntToCInt(args[2]); - calcwif(wif, wif->topregion.width-wif->outerregion.width, - wif->topregion.height-wif->outerregion.height); - /* stolen from calculateshape */ + calcwif(wif, wif->topregion.width - wif->outerregion.width, + wif->topregion.height - wif->outerregion.height); + /* stolen from calculateshape */ - /* printf("MOVEW to %d, %d.\n", wif->windowreg.x, wif->windowreg.y); */ - if (!args[3]) - { - if (wif->open) - XtMoveWidget( wif->topwidget - , wif->topregion.x - , wif->topregion.y - , 0); - else - { - wif->move_pend = 1; /* Save the move for when we open it. */ - } - XFlush(dsp); - } - return(ATOM_T); + /* printf("MOVEW to %d, %d.\n", wif->windowreg.x, wif->windowreg.y); */ + if (!args[3]) { + if (wif->open) + XtMoveWidget(wif->topwidget, wif->topregion.x, wif->topregion.y, 0); + else { + wif->move_pend = 1; /* Save the move for when we open it. */ + } + XFlush(dsp); + } + return (ATOM_T); } - - -MNXshapeW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = left */ - /* args[2] = bottom */ - /* args[3] = width */ - /* args[4] = height */ +MNXshapeW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = width */ + /* args[4] = height */ { Display *dsp; WindowInterface wif; XtWidgetGeometry geom; wif = WIfFromMw(args[0]); - if (!wif) return(NIL); /* no real window, no action. */ - wif->reshaping = 1; /* tell event handler to expect an event */ + if (!wif) return (NIL); /* no real window, no action. */ + wif->reshaping = 1; /* tell event handler to expect an event */ dsp = XDisplayFromMw(args[0]); - calculateshape( wif, args[1], args[2], args[3], args[4], - wif->topregion.width - wif->outerregion.width, - wif->topregion.height - wif->outerregion.height); - /* printf("SHAPEW to %d, %d, %d, %d.\n", args[1]&0xFFFF, args[2]&0xFFFF, - args[3]&0xFFFF, args[4]&0xFFFF); */ - if (wif->open) - { - refreshwindow( args[0] ); - XtVaSetValues(wif->formwidget, XtNextentX, 0, XtNextentY, 0, - XtNextentWidth, args[3] & 0xFFFF, - XtNextentHeight, args[4] & 0xFFFF, - NULL); - XtMoveWidget(wif->topwidget, args[1] & 0xFFFF, - HeightOfScreen(wif->screen) - - (args[2] & 0xFFFF) - wif->topregion.height); - } - else - { - wif->shape_pend = 1; - } + calculateshape(wif, args[1], args[2], args[3], args[4], + wif->topregion.width - wif->outerregion.width, + wif->topregion.height - wif->outerregion.height); + /* printf("SHAPEW to %d, %d, %d, %d.\n", args[1]&0xFFFF, args[2]&0xFFFF, + args[3]&0xFFFF, args[4]&0xFFFF); */ + if (wif->open) { + refreshwindow(args[0]); + XtVaSetValues(wif->formwidget, XtNextentX, 0, XtNextentY, 0, XtNextentWidth, args[3] & 0xFFFF, + XtNextentHeight, args[4] & 0xFFFF, NULL); + XtMoveWidget(wif->topwidget, args[1] & 0xFFFF, + HeightOfScreen(wif->screen) - (args[2] & 0xFFFF) - wif->topregion.height); + } else { + wif->shape_pend = 1; + } XFreePixmap(wif->dspif->handle, wif->backing); - wif->backing = XCreatePixmap(dsp, wif->dspif->root, - args[3] & 0xFFFF, args[4] & 0xFFFF, 1); + wif->backing = XCreatePixmap(dsp, wif->dspif->root, args[3] & 0xFFFF, args[4] & 0xFFFF, 1); XFlush(dsp); - return(ATOM_T); + return (ATOM_T); } - - - -MNXtotopW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +MNXtotopW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ { Display *dsp; WindowInterface wif; @@ -1262,17 +1051,13 @@ MNXtotopW( args ) dsp = XDisplayFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif->open) return(NIL); /* If window not open, don't do anything. */ - XRaiseWindow( dsp, XtWindow(wif->topwidget)); + if (!wif->open) return (NIL); /* If window not open, don't do anything. */ + XRaiseWindow(dsp, XtWindow(wif->topwidget)); XFlush(dsp); - return(ATOM_T); + return (ATOM_T); } - - - -MNXburyW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +MNXburyW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ { Display *dsp; WindowInterface wif; @@ -1280,27 +1065,24 @@ MNXburyW( args ) dsp = XDisplayFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif->open) return(NIL); /* If window not open, don't do anything. */ - XLowerWindow( dsp, XtWindow(wif->topwidget)); + if (!wif->open) return (NIL); /* If window not open, don't do anything. */ + XLowerWindow(dsp, XtWindow(wif->topwidget)); XFlush(dsp); - return(ATOM_T); + return (ATOM_T); } - - -MNXshrinkW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = LispPTR to icon MedleyWindow. */ - /* args[2] = Iconwindow x */ - /* args[3] = Iconwindow y */ - /* args[4] = Iconwindow width */ - /* args[5] = Iconwindow height */ +MNXshrinkW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to icon MedleyWindow. */ + /* args[2] = Iconwindow x */ + /* args[3] = Iconwindow y */ + /* args[4] = Iconwindow width */ + /* args[5] = Iconwindow height */ { - Screen *screen; - Display *display; - XImage Xbm; + Screen *screen; + Display *display; + XImage Xbm; XWMHints Lisp_WMhints; - BITMAP *bitmap; + BITMAP *bitmap; WindowInterface wif, iconwif; DspInterface dspif; int depth; @@ -1311,24 +1093,19 @@ MNXshrinkW( args ) bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); wif = WIfFromMw(args[0]); - if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + if (!wif->open) return (NIL); /* If window not open, don't do anything. */ iconwif = WIfFromMw(args[1]); XtVaSetValues(wif->topwidget, XtNiconWindow, iconwif->blackframe, NULL); DrawableToMBM(bitmap, dspif, wif, wif->backing, XtScreen(wif->topwidget), 0, 0, 0, 0, - wif->innerregion.width, wif->innerregion.height, REPLACE); - XIconifyWindow( XtDisplay(wif->topwidget) - , XtWindow(wif->topwidget) - , DefaultScreen(display)); + wif->innerregion.width, wif->innerregion.height, REPLACE); + XIconifyWindow(XtDisplay(wif->topwidget), XtWindow(wif->topwidget), DefaultScreen(display)); XFlush(display); - return(ATOM_T); + return (ATOM_T); } - - -MNXexpandW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +MNXexpandW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ { DspInterface dspif; WindowInterface wif; @@ -1337,28 +1114,24 @@ MNXexpandW( args ) wif = WIfFromMw(args[0]); dspif = DspIfFromMw(args[0]); - if (! args[0]) return(NIL); - if (!wif->open) return(NIL); /* If window not open, don't do anything. */ + if (!args[0]) return (NIL); + if (!wif->open) return (NIL); /* If window not open, don't do anything. */ XMapWindow(XtDisplay(wif->topwidget), XtWindow(wif->topwidget)); showtitle(args[0]); bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); - MBMToDrawable(bitmap, dspif, wif, 0, 0, 0, 0, - wif->innerregion.width, wif->innerregion.height, - REPLACE); + MBMToDrawable(bitmap, dspif, wif, 0, 0, 0, 0, wif->innerregion.width, wif->innerregion.height, + REPLACE); XFlush(XtDisplay(wif->topwidget)); - return(ATOM_T); + return (ATOM_T); } - - -MNXcreateW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = left */ - /* args[2] = bottom */ - /* args[3] = width */ - /* args[4] = height */ +MNXcreateW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = width */ + /* args[4] = height */ { - XGCValues gcv; + XGCValues gcv; XVisualInfo vinfo, *vinfo2; XSizeHints sizehints; @@ -1386,17 +1159,17 @@ MNXcreateW( args ) display = XDisplayFromMw(args[0]); scrno = DefaultScreen(display); - wif->screen = ScreenOfDisplay( display, scrno); + wif->screen = ScreenOfDisplay(display, scrno); wif->Dispatch = &(dspif->ImageOp); - wif->MedleyWindow = args[0]; /* so we know what WINDOW this corresponds to */ - /* Cache the MScreen for the benefit of the signals. */ + wif->MedleyWindow = args[0]; /* so we know what WINDOW this corresponds to */ + /* Cache the MScreen for the benefit of the signals. */ wif->MedleyScreen = ((MedleyWindow)Cptr(args[0]))->SCREEN; wif->dspif = dspif; - wif->fgpixmap = 0; /* Cache for the foreground pixmap. */ - wif->bgpixmap = 0; /* Cache for the foreground pixmap. */ - whiteborder = getwhiteborder( args[0] ); - blackborder = getblackborder( args[0] ); - tmpstring = gettitlestring( args[0] ); + wif->fgpixmap = 0; /* Cache for the foreground pixmap. */ + wif->bgpixmap = 0; /* Cache for the foreground pixmap. */ + whiteborder = getwhiteborder(args[0]); + blackborder = getblackborder(args[0]); + tmpstring = gettitlestring(args[0]); dd = ImDataFromMw(args[0]); wif->xoffset = LispIntToCInt(dd->ddxoffset); @@ -1404,120 +1177,79 @@ MNXcreateW( args ) /* Special case for Icons and windows with no content and only a titlebar */ if (wif->innerregion.height == 0) whiteborder = 0; - calculateshape( wif, args[1], args[2], args[3], args[4], 0, 0); + calculateshape(wif, args[1], args[2], args[3], args[4], 0, 0); /********************************/ /* Create the X window instance */ /********************************/ - wif->topwidget = XtVaAppCreateShell - (tmpstring, tmpstring, - applicationShellWidgetClass, display, - XtNgeometry, wif->gstring, - XtNargc, save_argc, - XtNargv, save_argv, - XtNborderWidth, 0, - NULL); + wif->topwidget = XtVaAppCreateShell(tmpstring, tmpstring, applicationShellWidgetClass, display, + XtNgeometry, wif->gstring, XtNargc, save_argc, XtNargv, + save_argv, XtNborderWidth, 0, NULL); - wif->formwidget = XtCreateManagedWidget - ("scrollBox", scrollBoxWidgetClass, wif->topwidget, - NULL, 0); + wif->formwidget = + XtCreateManagedWidget("scrollBox", scrollBoxWidgetClass, wif->topwidget, NULL, 0); - wif->framewidget = XtVaCreateManagedWidget - ("frame", boxWidgetClass, wif->formwidget, - XtNheight, wif->outerregion.height, - XtNwidth, wif->outerregion.width, - XtNborderWidth, blackborder, - XtNbackground, BlackPixelOfScreen( wif->screen ), - XtNvSpace, 0, - XtNdefaultDistance, 0, - XtNhorizDistance, 0, - XtNvertDistance, 0, - NULL); + wif->framewidget = XtVaCreateManagedWidget( + "frame", boxWidgetClass, wif->formwidget, XtNheight, wif->outerregion.height, XtNwidth, + wif->outerregion.width, XtNborderWidth, blackborder, XtNbackground, + BlackPixelOfScreen(wif->screen), XtNvSpace, 0, XtNdefaultDistance, 0, XtNhorizDistance, 0, + XtNvertDistance, 0, NULL); boxClassRec.core_class.compress_motion = False; - wif->windowwidget = XtVaCreateManagedWidget - ("window", boxWidgetClass, wif->framewidget, - XtNheight, wif->innerregion.height, - XtNwidth, wif->innerregion.width, - XtNx, wif->innerregion.x, - XtNy, wif->innerregion.y, - XtNborderColor, WhitePixelOfScreen(wif->screen), - XtNborderWidth, whiteborder, - XtNvSpace, 0, - XtNdefaultDistance, 0, - XtNhorizDistance, 0, - XtNvertDistance, 0, - XtNbottom, XtChainBottom, - XtNleft, XtChainLeft, - NULL); + wif->windowwidget = XtVaCreateManagedWidget( + "window", boxWidgetClass, wif->framewidget, XtNheight, wif->innerregion.height, XtNwidth, + wif->innerregion.width, XtNx, wif->innerregion.x, XtNy, wif->innerregion.y, XtNborderColor, + WhitePixelOfScreen(wif->screen), XtNborderWidth, whiteborder, XtNvSpace, 0, + XtNdefaultDistance, 0, XtNhorizDistance, 0, XtNvertDistance, 0, XtNbottom, XtChainBottom, + XtNleft, XtChainLeft, NULL); - gcv.function = GXcopy; + gcv.function = GXcopy; gcv.foreground = dspif->black; gcv.background = dspif->white; - wif->ReplaceGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + wif->ReplaceGC = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXxor; + gcv.function = GXxor; gcv.foreground = (dspif->black) ^ (dspif->white); gcv.background = 0; - wif->InvertGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + wif->InvertGC = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXor; - gcv.foreground = dspif->black & (~ dspif->white); - gcv.background = 0; - wif->PaintGC1 = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); - - gcv.function = GXandInverted; - gcv.foreground = dspif->white & (~dspif->black); - gcv.background = 0; - wif->PaintGC2 = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); - - gcv.function = GXor; - gcv.foreground = dspif->white & (~dspif->black); - gcv.background = 0; - wif->EraseGC1 = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); - - gcv.function = GXandInverted; + gcv.function = GXor; gcv.foreground = dspif->black & (~dspif->white); gcv.background = 0; - wif->EraseGC2 = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + wif->PaintGC1 = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXandInverted; + gcv.function = GXandInverted; + gcv.foreground = dspif->white & (~dspif->black); + gcv.background = 0; + wif->PaintGC2 = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); + + gcv.function = GXor; + gcv.foreground = dspif->white & (~dspif->black); + gcv.background = 0; + wif->EraseGC1 = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); + + gcv.function = GXandInverted; gcv.foreground = dspif->black & (~dspif->white); gcv.background = 0; - wif->gc = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + wif->EraseGC2 = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); + + gcv.function = GXandInverted; + gcv.foreground = dspif->black & (~dspif->white); + gcv.background = 0; + wif->gc = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); /* Push this wif onto the list of created wifs. */ wif->next = dspif->CreatedWifs; dspif->CreatedWifs = wif; - wif->backing = XCreatePixmap(display, dspif->root, - args[3] & 0xFFFF, args[4] & 0xFFFF, 1); + wif->backing = XCreatePixmap(display, dspif->root, args[3] & 0xFFFF, args[4] & 0xFFFF, 1); bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); - MBMToDrawable(bitmap, dspif, wif, 0, 0, - wif->innerregion.x, wif->innerregion.y, - wif->innerregion.width, wif->innerregion.height, - REPLACE); + MBMToDrawable(bitmap, dspif, wif, 0, 0, wif->innerregion.x, wif->innerregion.y, + wif->innerregion.width, wif->innerregion.height, REPLACE); - free( tmpstring ); - return(ATOM_T); + free(tmpstring); + return (ATOM_T); } - - - /**************************************************************/ /* showtitle */ /* Update the title frame of the window. It is assumed that */ @@ -1525,8 +1257,7 @@ MNXcreateW( args ) /* the displaydata of the screen. */ /**************************************************************/ -showtitle(win) - LispPTR win; +showtitle(win) LispPTR win; { BITMAP *bitmap; DISPLAYDATA *dd; @@ -1539,9 +1270,9 @@ showtitle(win) dspif = DspIfFromMw(win); dd = TitleDDFromMw(win); - tmpstring = gettitlestring( win ); - titleheight = gettitleheight( win ); - if(tmpstring == NULL) return(ATOM_T); + tmpstring = gettitlestring(win); + titleheight = gettitleheight(win); + if (tmpstring == NULL) return (ATOM_T); stringlen = strlen(tmpstring); bitmap = (BITMAP *)Cptr(dd->ddpilotbbt); @@ -1551,7 +1282,7 @@ showtitle(win) XClearWindow(dspif->handle, wif->blackframe); /* Start text flush to the border */ - xpos = LispIntToCInt(((MedleyWindow)Cptr(win))->WBORDER); + xpos = LispIntToCInt(((MedleyWindow)Cptr(win))->WBORDER); dsty = titleheight - bitmap->bmheight + 2; /* The +2 is ad hoc */ /* Set the name property in the server */ @@ -1559,21 +1290,16 @@ showtitle(win) /* Add character set switching code... */ - if((bitmap->bmbitperpixel == 1) || - (bitmap->bmbitperpixel == DefaultDepthOfScreen(wif->screen))) + if ((bitmap->bmbitperpixel == 1) || (bitmap->bmbitperpixel == DefaultDepthOfScreen(wif->screen))) for (i = 0; i < stringlen; i++) { - width = GETWORD((DLword*)Cptr(dd->ddwidthscache + tmpstring[i])); - XPutImage(dspif->handle, - wif->blackframe, - dspif->TitleGC, - &dspif->image, - GETWORD(Cptr(dd->ddoffsetscache + tmpstring[i])), /* src x */ - 0, /* src y */ - xpos, /* dst x */ - dsty, /* ??? dst y */ - width, - bitmap->bmheight /* height */ - ); + width = GETWORD((DLword *)Cptr(dd->ddwidthscache + tmpstring[i])); + XPutImage(dspif->handle, wif->blackframe, dspif->TitleGC, &dspif->image, + GETWORD(Cptr(dd->ddoffsetscache + tmpstring[i])), /* src x */ + 0, /* src y */ + xpos, /* dst x */ + dsty, /* ??? dst y */ + width, bitmap->bmheight /* height */ + ); xpos += width; } else { @@ -1584,53 +1310,44 @@ showtitle(win) dspif->image.width = bitmap->bmwidth; dspif->image.height = bitmap->bmheight; dspif->image.bytes_per_line = - ((bitmap->bmwidth+(BITSPER_DLWORD-1)) /BITSPER_DLWORD) * (BITSPER_DLWORD/8); + ((bitmap->bmwidth + (BITSPER_DLWORD - 1)) / BITSPER_DLWORD) * (BITSPER_DLWORD / 8); dspif->image.depth = DefaultDepthOfScreen(wif->screen); - dspif->image.data = (char *)malloc(dspif->image.bytes_per_line - * dspif->image.width - * dspif->image.depth); + dspif->image.data = + (char *)malloc(dspif->image.bytes_per_line * dspif->image.width * dspif->image.depth); dspif->tmpimage.width = bitmap->bmwidth; dspif->tmpimage.height = bitmap->bmheight; dspif->tmpimage.depth = bitmap->bmbitperpixel & 0xFFFF; dspif->tmpimage.data = (char *)Cptr((LispPTR)bitmap->bmbase); dspif->tmpimage.bytes_per_line = - ((bitmap->bmwidth+(BITSPER_DLWORD-1)) /BITSPER_DLWORD) * (BITSPER_DLWORD/8); - for(x = 0; x < bitmap->bmwidth; x++) - for(y = 0; y < bitmap->bmheight; y++) - XPutPixel(&dspif->image, x, y, XGetPixel(&dspif->tmpimage, x, y)); + ((bitmap->bmwidth + (BITSPER_DLWORD - 1)) / BITSPER_DLWORD) * (BITSPER_DLWORD / 8); + for (x = 0; x < bitmap->bmwidth; x++) + for (y = 0; y < bitmap->bmheight; y++) + XPutPixel(&dspif->image, x, y, XGetPixel(&dspif->tmpimage, x, y)); for (i = 0; i < stringlen; i++) { - width = GETWORD((DLword*)Cptr(dd->ddwidthscache + tmpstring[i])); - XPutImage(dspif->handle, - wif->blackframe, - dspif->TitleGC, - &dspif->image, - GETWORD(Cptr(dd->ddoffsetscache + tmpstring[i])), /* src x */ - 0, /* src y */ - xpos, /* dst x */ - dsty, /* ??? dst y */ - width, - bitmap->bmheight /* height */ - ); + width = GETWORD((DLword *)Cptr(dd->ddwidthscache + tmpstring[i])); + XPutImage(dspif->handle, wif->blackframe, dspif->TitleGC, &dspif->image, + GETWORD(Cptr(dd->ddoffsetscache + tmpstring[i])), /* src x */ + 0, /* src y */ + xpos, /* dst x */ + dsty, /* ??? dst y */ + width, bitmap->bmheight /* height */ + ); xpos += width; } free(dspif->image.data); } free(tmpstring); - return(ATOM_T); + return (ATOM_T); } - - - /************************************************************************/ /* MNXopenW */ /* Open a window and get the inner region of the window from the SAVE */ /* slot on the MedWindow */ /* NOTE! we don't get whiteframe, blackframe or the title. See MNXcloseW. */ /************************************************************************/ -MNXopenW( args ) - LispArgs args; +MNXopenW(args) LispArgs args; { Display *display; WindowInterface wif; @@ -1645,51 +1362,31 @@ MNXopenW( args ) dspif = DspIfFromMw(args[0]); display = dspif->handle; - XtAddEventHandler(wif->framewidget, - ButtonPressMask | ButtonReleaseMask, - False, HandleButton, wif); - XtAddEventHandler(wif->framewidget, - PointerMotionMask, - False, HandleMotion, wif); - XtAddEventHandler(wif->framewidget, - KeyPressMask | KeyReleaseMask, - False, HandleKey, wif); - XtAddEventHandler(wif->framewidget, - EnterWindowMask | LeaveWindowMask, - False, HandleCrossing, wif); - XtAddEventHandler(wif->framewidget, - FocusChangeMask, - False, HandleFocus, wif); - XtAddEventHandler(wif->framewidget, - ExposureMask, - False, HandleTitle, wif); - XtAddEventHandler(wif->windowwidget, - ExposureMask, - False, HandleExpose, wif); - XtAddEventHandler(wif->topwidget, - StructureNotifyMask, - False, HandleStructure, wif); + XtAddEventHandler(wif->framewidget, ButtonPressMask | ButtonReleaseMask, False, HandleButton, + wif); + XtAddEventHandler(wif->framewidget, PointerMotionMask, False, HandleMotion, wif); + XtAddEventHandler(wif->framewidget, KeyPressMask | KeyReleaseMask, False, HandleKey, wif); + XtAddEventHandler(wif->framewidget, EnterWindowMask | LeaveWindowMask, False, HandleCrossing, + wif); + XtAddEventHandler(wif->framewidget, FocusChangeMask, False, HandleFocus, wif); + XtAddEventHandler(wif->framewidget, ExposureMask, False, HandleTitle, wif); + XtAddEventHandler(wif->windowwidget, ExposureMask, False, HandleExpose, wif); + XtAddEventHandler(wif->topwidget, StructureNotifyMask, False, HandleStructure, wif); XtRealizeWidget(wif->topwidget); #ifdef NEVER - if (wif->shape_pend) /* We reshaped while closed; do it for real here */ - { - refreshwindow( args[0] ); - XtVaSetValues(wif->formwidget, XtNextentX, 0, XtNextentY, 0, - XtNextentWidth, wif->windowreg.width, - XtNextentHeight, wif->windowreg.height, - NULL); - XtMoveWidget(wif->topwidget, wif->topregion.x, wif->topregion.y); - wif->move_pend = wif->shape_pend = 0; - } - else if (wif->move_pend) /* We moved while closed; do the move here. */ - { - wif->move_pend = 0; - XtMoveWidget( wif->topwidget - , wif->topregion.x - , wif->topregion.y - , 0); - } + if (wif->shape_pend) /* We reshaped while closed; do it for real here */ + { + refreshwindow(args[0]); + XtVaSetValues(wif->formwidget, XtNextentX, 0, XtNextentY, 0, XtNextentWidth, + wif->windowreg.width, XtNextentHeight, wif->windowreg.height, NULL); + XtMoveWidget(wif->topwidget, wif->topregion.x, wif->topregion.y); + wif->move_pend = wif->shape_pend = 0; + } else if (wif->move_pend) /* We moved while closed; do the move here. */ + { + wif->move_pend = 0; + XtMoveWidget(wif->topwidget, wif->topregion.x, wif->topregion.y, 0); + } #endif wif->blackframe = XtWindow(wif->framewidget); wif->handle = window = XtWindow(wif->windowwidget); @@ -1699,38 +1396,31 @@ MNXopenW( args ) wif->parent = parent; XFree(children); - refreshwindow( args[0] ); - settileorigin( args[0], 0, wif->innerregion.height ); + refreshwindow(args[0]); + settileorigin(args[0], 0, wif->innerregion.height); settexture(args[0]); - showtitle( args[0] ); + showtitle(args[0]); XtSetSensitive(wif->framewidget, True); XtSetSensitive(wif->windowwidget, True); - if (!wif->backing) - { - wif->backing = XCreatePixmap(display, window, wif->outerregion.width, - wif->outerregion.height, 1); - } + if (!wif->backing) { + wif->backing = + XCreatePixmap(display, window, wif->outerregion.width, wif->outerregion.height, 1); + } - - bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); - MBMToDrawable(bitmap, dspif, wif, 0, 0, - /* wif->innerregion.x, wif->innerregion.y, */ 0, 0, - wif->innerregion.width, wif->innerregion.height, - REPLACE); + bitmap = (BITMAP *)Cptr(((MedleyWindow)Cptr(args[0]))->SAVE); + MBMToDrawable(bitmap, dspif, wif, 0, 0, + /* wif->innerregion.x, wif->innerregion.y, */ 0, 0, wif->innerregion.width, + wif->innerregion.height, REPLACE); XRaiseWindow(display, XtWindow(wif->topwidget)); XFlush(display); - wif->open = 1; /* mark the window open. */ - return(ATOM_T); + wif->open = 1; /* mark the window open. */ + return (ATOM_T); } - - - -MNXresetW( args ) - LispArgs args; +MNXresetW(args) LispArgs args; { Display *display; WindowInterface wif; @@ -1738,52 +1428,43 @@ MNXresetW( args ) display = XDisplayFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) return(NIL); /* if the window is closed, do nothing */ - if(XtIsRealized(wif->topwidget)) - { + if (!wif->open) return (NIL); /* if the window is closed, do nothing */ + if (XtIsRealized(wif->topwidget)) { #ifdef NEVER - showtitle( args[0] ); - settexture(args[0]); - XClearWindow(display, XtWindow(wif->windowwidget)); + showtitle(args[0]); + settexture(args[0]); + XClearWindow(display, XtWindow(wif->windowwidget)); #else - bltshade_internal(display, 0, dd->ddtexture, 0, 0, wif->innerregion.width, - wif->innerregion.height, wif, wif->dspif); + bltshade_internal(display, 0, dd->ddtexture, 0, 0, wif->innerregion.width, + wif->innerregion.height, wif, wif->dspif); #endif /* NEVER */ - } + } XFlush(display); - return(ATOM_T); + return (ATOM_T); } +MNXSetOffsets(args) LispArgs args; /* args[0] = window XOFFSET/YOFFSET changed in */ + /* args[1] = new XOFFSET */ + /* args[2] = new YOFFSET */ +{ + Display *display; + WindowInterface wif; - -MNXSetOffsets(args) - LispArgs args; /* args[0] = window XOFFSET/YOFFSET changed in */ - /* args[1] = new XOFFSET */ - /* args[2] = new YOFFSET */ - { - Display *display; - WindowInterface wif; - - wif = WIfFromMw(args[0]); - wif->xoffset = LispIntToCInt(args[1]); - wif->yoffset = LispIntToCInt(args[2]); - - } - + wif = WIfFromMw(args[0]); + wif->xoffset = LispIntToCInt(args[1]); + wif->yoffset = LispIntToCInt(args[2]); +} /*********************/ /* Imageop Methods. */ /*********************/ - - -MNXdrawpoint( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = x */ - /* args[2] = y */ - /* args[3] = brush */ +MNXdrawpoint(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = x */ + /* args[2] = y */ + /* args[3] = brush */ { Display *display; Window window; @@ -1795,13 +1476,13 @@ MNXdrawpoint( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); display = dspif->handle; window = XtWindow(wif->windowwidget); - if( args[3] == NIL ) + if (args[3] == NIL) width = 0; else width = LispIntToCInt(args[3]); @@ -1810,35 +1491,26 @@ MNXdrawpoint( args ) y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])); /** Handle the four operation cases **/ - if( dd->ddoperation == INVERT_atom ) - { - XDrawPoint(display, window, wif->InvertGC, x, y); - XDrawPoint(display, wif->backing, dspif->PixIGC, x, y); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawPoint(display, window, wif->EraseGC1, x, y); - XDrawPoint(display, window, wif->EraseGC2, x, y); - XDrawPoint(display, wif->backing, dspif->PixEGC, x, y); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawPoint(display, window, wif->PaintGC1, x, y); - XDrawPoint(display, window, wif->PaintGC2, x, y); - XDrawPoint(display, wif->backing, dspif->PixPGC, x, y); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawPoint(display, window, wif->ReplaceGC, x, y); - XDrawPoint(display, wif->backing, dspif->PixRGC, x, y); - } + if (dd->ddoperation == INVERT_atom) { + XDrawPoint(display, window, wif->InvertGC, x, y); + XDrawPoint(display, wif->backing, dspif->PixIGC, x, y); + } else if (dd->ddoperation == ERASE_atom) { + XDrawPoint(display, window, wif->EraseGC1, x, y); + XDrawPoint(display, window, wif->EraseGC2, x, y); + XDrawPoint(display, wif->backing, dspif->PixEGC, x, y); + } else if (dd->ddoperation == PAINT_atom) { + XDrawPoint(display, window, wif->PaintGC1, x, y); + XDrawPoint(display, window, wif->PaintGC2, x, y); + XDrawPoint(display, wif->backing, dspif->PixPGC, x, y); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawPoint(display, window, wif->ReplaceGC, x, y); + XDrawPoint(display, wif->backing, dspif->PixRGC, x, y); + } XFlush(display); - return(NIL); + return (NIL); } - - /**************************************************************/ /* MNXdrawline */ /* color not yet implemented */ @@ -1848,14 +1520,13 @@ MNXdrawpoint( args ) /* Remember that this method has an OPERATION arument in Lisp */ /* so we have to fix that there. */ /**************************************************************/ -MNXdrawline( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = x1 */ - /* args[2] = y1 */ - /* args[3] = x2 */ - /* args[4] = y2 */ - /* args[5] = width */ - /* Args[6] = dashing */ +MNXdrawline(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = x1 */ + /* args[2] = y1 */ + /* args[3] = x2 */ + /* args[4] = y2 */ + /* args[5] = width */ + /* Args[6] = dashing */ { WindowInterface wif; Display *display; @@ -1866,8 +1537,8 @@ MNXdrawline( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ - dd = ImDataFromMw( args[0] ); + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + dd = ImDataFromMw(args[0]); display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -1879,48 +1550,38 @@ MNXdrawline( args ) setlineattributes(display, dspif, wif, dd, args[5], args[6]); - if( dd->ddoperation == INVERT_atom ) - { - XDrawLine( display,window, wif->InvertGC, x1, y1, x2, y2); - XDrawLine( display, wif->backing, dspif->PixIGC, x1, y1, x2, y2); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawLine( display,window, wif->EraseGC1, x1, y1, x2, y2); - XDrawLine( display,window, wif->EraseGC2, x1, y1, x2, y2); - XDrawLine( display, wif->backing, dspif->PixEGC, x1, y1, x2, y2); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawLine( display,window, wif->PaintGC1, x1, y1, x2, y2); - XDrawLine( display,window, wif->PaintGC2, x1, y1, x2, y2); - XDrawLine( display, wif->backing, dspif->PixPGC, x1, y1, x2, y2); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawLine( display,window, wif->ReplaceGC, x1, y1, x2, y2); - XDrawLine( display, wif->backing, dspif->PixRGC, x1, y1, x2, y2); - } + if (dd->ddoperation == INVERT_atom) { + XDrawLine(display, window, wif->InvertGC, x1, y1, x2, y2); + XDrawLine(display, wif->backing, dspif->PixIGC, x1, y1, x2, y2); + } else if (dd->ddoperation == ERASE_atom) { + XDrawLine(display, window, wif->EraseGC1, x1, y1, x2, y2); + XDrawLine(display, window, wif->EraseGC2, x1, y1, x2, y2); + XDrawLine(display, wif->backing, dspif->PixEGC, x1, y1, x2, y2); + } else if (dd->ddoperation == PAINT_atom) { + XDrawLine(display, window, wif->PaintGC1, x1, y1, x2, y2); + XDrawLine(display, window, wif->PaintGC2, x1, y1, x2, y2); + XDrawLine(display, wif->backing, dspif->PixPGC, x1, y1, x2, y2); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawLine(display, window, wif->ReplaceGC, x1, y1, x2, y2); + XDrawLine(display, wif->backing, dspif->PixRGC, x1, y1, x2, y2); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } - - /**************************************************************/ /* MNXdrawcircle */ /* Note: 23040 is 360 * 64 sixtyfourth degrees */ /* It is assumed that the BRUSH argument is a fixp that */ /* represents a ROUND brush. */ /**************************************************************/ -MNXdrawcircle( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = centerX */ - /* args[2] = centerY */ - /* args[3] = radius */ - /* args[4] = brush */ - /* args[5] = dashing */ +MNXdrawcircle(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = radius */ + /* args[4] = brush */ + /* args[5] = dashing */ { int radius, d, x, y; WindowInterface wif; @@ -1931,9 +1592,9 @@ MNXdrawcircle( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -1945,49 +1606,39 @@ MNXdrawcircle( args ) setlineattributes(display, dspif, wif, dd, args[4], args[5]); - if( dd->ddoperation == INVERT_atom ) - { - XDrawArc( display, window, wif->InvertGC, x, y, d, d, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixIGC, x, y, d, d, 0, 23040); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawArc( display, window, wif->EraseGC1, x, y, d, d, 0, 23040); - XDrawArc( display, window, wif->EraseGC2, x, y, d, d, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixEGC, x, y, d, d, 0, 23040); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawArc( display, window, wif->PaintGC1, x, y, d, d, 0, 23040); - XDrawArc( display, window, wif->PaintGC2, x, y, d, d, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixPGC, x, y, d, d, 0, 23040); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawArc( display, window, wif->ReplaceGC, x, y, d, d, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixRGC, x, y, d, d, 0, 23040); - } + if (dd->ddoperation == INVERT_atom) { + XDrawArc(display, window, wif->InvertGC, x, y, d, d, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixIGC, x, y, d, d, 0, 23040); + } else if (dd->ddoperation == ERASE_atom) { + XDrawArc(display, window, wif->EraseGC1, x, y, d, d, 0, 23040); + XDrawArc(display, window, wif->EraseGC2, x, y, d, d, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixEGC, x, y, d, d, 0, 23040); + } else if (dd->ddoperation == PAINT_atom) { + XDrawArc(display, window, wif->PaintGC1, x, y, d, d, 0, 23040); + XDrawArc(display, window, wif->PaintGC2, x, y, d, d, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixPGC, x, y, d, d, 0, 23040); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawArc(display, window, wif->ReplaceGC, x, y, d, d, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixRGC, x, y, d, d, 0, 23040); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } - - /**************************************************************/ /* MNXdrawarc */ /* It is assumed that the BRUSH argument is a fixp that */ /* represents a ROUND brush. */ /**************************************************************/ -MNXdrawarc( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = centerX */ - /* args[2] = centerY */ - /* args[3] = radius */ - /* args[4] = startangle in 64'ths degrees */ - /* args[5] = ndegrees in 64'ths degrees */ - /* args[6] = brush */ - /* args[7] = dashing */ - /* Brush and dashing args are ignored for the moment. */ +MNXdrawarc(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = radius */ + /* args[4] = startangle in 64'ths degrees */ + /* args[5] = ndegrees in 64'ths degrees */ + /* args[6] = brush */ + /* args[7] = dashing */ + /* Brush and dashing args are ignored for the moment. */ { int radius, d, x, y, start, ndeg; WindowInterface wif; @@ -1998,9 +1649,9 @@ MNXdrawarc( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -2010,35 +1661,28 @@ MNXdrawarc( args ) x = translate_x(wif, LispIntToCInt(args[1])) - radius; y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - radius; start = LispIntToCInt(args[4]); - ndeg = LispIntToCInt(args[5]); + ndeg = LispIntToCInt(args[5]); - setlineattributes(display, dspif, wif,dd, args[6], args[7]); + setlineattributes(display, dspif, wif, dd, args[6], args[7]); - if( dd->ddoperation == INVERT_atom ) - { - XDrawArc( display, window, wif->InvertGC, x, y, d, d, start, ndeg); - XDrawArc( display, wif->backing, dspif->PixIGC, x, y, d, d, start, ndeg); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawArc( display, window, wif->EraseGC1, x, y, d, d, start, ndeg); - XDrawArc( display, window, wif->EraseGC2, x, y, d, d, start, ndeg); - XDrawArc( display, wif->backing, dspif->PixEGC, x, y, d, d, start, ndeg); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawArc( display, window, wif->PaintGC1, x, y, d, d, start, ndeg); - XDrawArc( display, window, wif->PaintGC2, x, y, d, d, start, ndeg); - XDrawArc( display, wif->backing, dspif->PixPGC, x, y, d, d, start, ndeg); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawArc( display, window, wif->ReplaceGC, x, y, d, d, start, ndeg); - XDrawArc( display, wif->backing, dspif->PixRGC, x, y, d, d, start, ndeg); - } + if (dd->ddoperation == INVERT_atom) { + XDrawArc(display, window, wif->InvertGC, x, y, d, d, start, ndeg); + XDrawArc(display, wif->backing, dspif->PixIGC, x, y, d, d, start, ndeg); + } else if (dd->ddoperation == ERASE_atom) { + XDrawArc(display, window, wif->EraseGC1, x, y, d, d, start, ndeg); + XDrawArc(display, window, wif->EraseGC2, x, y, d, d, start, ndeg); + XDrawArc(display, wif->backing, dspif->PixEGC, x, y, d, d, start, ndeg); + } else if (dd->ddoperation == PAINT_atom) { + XDrawArc(display, window, wif->PaintGC1, x, y, d, d, start, ndeg); + XDrawArc(display, window, wif->PaintGC2, x, y, d, d, start, ndeg); + XDrawArc(display, wif->backing, dspif->PixPGC, x, y, d, d, start, ndeg); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawArc(display, window, wif->ReplaceGC, x, y, d, d, start, ndeg); + XDrawArc(display, wif->backing, dspif->PixRGC, x, y, d, d, start, ndeg); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } /**************************************************************/ @@ -2047,16 +1691,15 @@ MNXdrawarc( args ) /* It is assumed that the BRUSH argument is a fixp that */ /* represents a ROUND brush. */ /**************************************************************/ -MNXdrawelipse( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = centerX */ - /* args[2] = centerY */ - /* args[3] = semiminorradius */ - /* args[4] = semimajorradius */ - /* args[5] = orientation */ - /* args[6] = brush */ - /* args[7] = dashing */ - +MNXdrawelipse(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = semiminorradius */ + /* args[4] = semimajorradius */ + /* args[5] = orientation */ + /* args[6] = brush */ + /* args[7] = dashing */ + { int radius, d1, d2, x, y; WindowInterface wif; @@ -2067,9 +1710,9 @@ MNXdrawelipse( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -2081,43 +1724,35 @@ MNXdrawelipse( args ) setlineattributes(display, dspif, wif, dd, args[6], args[7]); - if( dd->ddoperation == INVERT_atom ) - { - XDrawArc( display, window, wif->InvertGC, x, y, d1, d2, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixIGC, x, y, d1, d2, 0, 23040); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawArc( display, window, wif->EraseGC1, x, y, d1, d2, 0, 23040); - XDrawArc( display, window, wif->EraseGC2, x, y, d1, d2, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixEGC, x, y, d1, d2, 0, 23040); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawArc( display, window, wif->PaintGC1, x, y, d1, d2, 0, 23040); - XDrawArc( display, window, wif->PaintGC2, x, y, d1, d2, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixPGC, x, y, d1, d2, 0, 23040); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawArc( display, window, wif->ReplaceGC, x, y, d1, d2, 0, 23040); - XDrawArc( display, wif->backing, dspif->PixRGC, x, y, d1, d2, 0, 23040); - } + if (dd->ddoperation == INVERT_atom) { + XDrawArc(display, window, wif->InvertGC, x, y, d1, d2, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixIGC, x, y, d1, d2, 0, 23040); + } else if (dd->ddoperation == ERASE_atom) { + XDrawArc(display, window, wif->EraseGC1, x, y, d1, d2, 0, 23040); + XDrawArc(display, window, wif->EraseGC2, x, y, d1, d2, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixEGC, x, y, d1, d2, 0, 23040); + } else if (dd->ddoperation == PAINT_atom) { + XDrawArc(display, window, wif->PaintGC1, x, y, d1, d2, 0, 23040); + XDrawArc(display, window, wif->PaintGC2, x, y, d1, d2, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixPGC, x, y, d1, d2, 0, 23040); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawArc(display, window, wif->ReplaceGC, x, y, d1, d2, 0, 23040); + XDrawArc(display, wif->backing, dspif->PixRGC, x, y, d1, d2, 0, 23040); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } /**************************************************************/ /* MNXfillcircle */ /* Note: 23040 is 360 * 64 sixtyfourth degrees */ /**************************************************************/ -MNXfillcircle( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = centerX */ - /* args[2] = centerY */ - /* args[3] = radius */ - /* Brush and dashing args are ignored for the moment. */ +MNXfillcircle(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = centerX */ + /* args[2] = centerY */ + /* args[3] = radius */ + /* Brush and dashing args are ignored for the moment. */ { int radius, d, x, y; WindowInterface wif; @@ -2128,9 +1763,9 @@ MNXfillcircle( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -2140,40 +1775,32 @@ MNXfillcircle( args ) x = translate_x(wif, LispIntToCInt(args[1])) - radius; y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - radius; - if( dd->ddoperation == INVERT_atom ) - { - XFillArc( display, window, wif->InvertGC, x, y, d, d, 0, 23040); - XFillArc( display, wif->backing, dspif->PixIGC, x, y, d, d, 0, 23040); - } - else if( dd->ddoperation == ERASE_atom ) - { - XFillArc( display, window, wif->EraseGC1, x, y, d, d, 0, 23040); - XFillArc( display, window, wif->EraseGC2, x, y, d, d, 0, 23040); - XFillArc( display, wif->backing, dspif->PixEGC, x, y, d, d, 0, 23040); - } - else if( dd->ddoperation == PAINT_atom ) - { - XFillArc( display, window, wif->PaintGC1, x, y, d, d, 0, 23040); - XFillArc( display, window, wif->PaintGC2, x, y, d, d, 0, 23040); - XFillArc( display, wif->backing, dspif->PixPGC, x, y, d, d, 0, 23040); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XFillArc( display, window, wif->ReplaceGC, x, y, d, d, 0, 23040); - XFillArc( display, wif->backing, dspif->PixRGC, x, y, d, d, 0, 23040); - } + if (dd->ddoperation == INVERT_atom) { + XFillArc(display, window, wif->InvertGC, x, y, d, d, 0, 23040); + XFillArc(display, wif->backing, dspif->PixIGC, x, y, d, d, 0, 23040); + } else if (dd->ddoperation == ERASE_atom) { + XFillArc(display, window, wif->EraseGC1, x, y, d, d, 0, 23040); + XFillArc(display, window, wif->EraseGC2, x, y, d, d, 0, 23040); + XFillArc(display, wif->backing, dspif->PixEGC, x, y, d, d, 0, 23040); + } else if (dd->ddoperation == PAINT_atom) { + XFillArc(display, window, wif->PaintGC1, x, y, d, d, 0, 23040); + XFillArc(display, window, wif->PaintGC2, x, y, d, d, 0, 23040); + XFillArc(display, wif->backing, dspif->PixPGC, x, y, d, d, 0, 23040); + } else if (dd->ddoperation == REPLACE_atom) { + XFillArc(display, window, wif->ReplaceGC, x, y, d, d, 0, 23040); + XFillArc(display, wif->backing, dspif->PixRGC, x, y, d, d, 0, 23040); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } /**************************************************************/ /* MNXwritepixel */ /**************************************************************/ -MNXwritepixel( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = x */ - /* args[2] = y */ +MNXwritepixel(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = x */ + /* args[2] = y */ { int x, y; WindowInterface wif; @@ -2184,9 +1811,9 @@ MNXwritepixel( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -2194,31 +1821,24 @@ MNXwritepixel( args ) x = translate_x(wif, LispIntToCInt(args[1])); y = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])); - if( dd->ddoperation == INVERT_atom ) - { - XDrawPoint( display, window, wif->InvertGC, x, y); - XDrawPoint( display, wif->backing, dspif->PixIGC, x, y); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawPoint( display, window, wif->EraseGC1, x, y); - XDrawPoint( display, window, wif->EraseGC2, x, y); - XDrawPoint( display, wif->backing, dspif->PixEGC, x, y); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawPoint( display, window, wif->PaintGC1, x, y); - XDrawPoint( display, window, wif->PaintGC2, x, y); - XDrawPoint( display, wif->backing, dspif->PixPGC, x, y); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawPoint( display, window, wif->ReplaceGC, x, y); - XDrawPoint( display, wif->backing, dspif->PixRGC, x, y); - } + if (dd->ddoperation == INVERT_atom) { + XDrawPoint(display, window, wif->InvertGC, x, y); + XDrawPoint(display, wif->backing, dspif->PixIGC, x, y); + } else if (dd->ddoperation == ERASE_atom) { + XDrawPoint(display, window, wif->EraseGC1, x, y); + XDrawPoint(display, window, wif->EraseGC2, x, y); + XDrawPoint(display, wif->backing, dspif->PixEGC, x, y); + } else if (dd->ddoperation == PAINT_atom) { + XDrawPoint(display, window, wif->PaintGC1, x, y); + XDrawPoint(display, window, wif->PaintGC2, x, y); + XDrawPoint(display, wif->backing, dspif->PixPGC, x, y); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawPoint(display, window, wif->ReplaceGC, x, y); + XDrawPoint(display, wif->backing, dspif->PixRGC, x, y); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } /**************************************************************/ @@ -2227,10 +1847,9 @@ MNXwritepixel( args ) /* is organized as [x1,y1,x2,y2,...] MNXdrawpolygon smashes this*/ /* vector with the integer values converted to C integers. */ /**************************************************************/ -MNXdrawpolygon( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = LispPTR to Pointvector */ - /* args[2] = Closedp */ +MNXdrawpolygon(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to Pointvector */ + /* args[2] = Closedp */ { WindowInterface wif; Window window; @@ -2244,9 +1863,9 @@ MNXdrawpolygon( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -2261,48 +1880,39 @@ MNXdrawpolygon( args ) /* Transmogrify the y coordinates */ y = (short)wif->innerregion.height; - for (i = 1; i < pv->length; i += 2) - { - xpt[i] = y - translate_y(wif, xpt[i]); - xpt[i-1] = translate_x(wif, xpt[i-1]); - } + for (i = 1; i < pv->length; i += 2) { + xpt[i] = y - translate_y(wif, xpt[i]); + xpt[i - 1] = translate_x(wif, xpt[i - 1]); + } /* If CLOSED then set last point are eq to the first. */ if (args[2] != NIL) { xpt[pv->length++] = xpt[0]; xpt[pv->length++] = xpt[1]; } - if( dd->ddoperation == INVERT_atom ) - { - XDrawLines( display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawLines( display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawLines( display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawLines( display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); - } + if (dd->ddoperation == INVERT_atom) { + XDrawLines(display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == ERASE_atom) { + XDrawLines(display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == PAINT_atom) { + XDrawLines(display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawLines(display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } -MNXfillpolygon( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = LispPTR to Pointvector */ - /* args[2] = Closedp */ +MNXfillpolygon(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to Pointvector */ + /* args[2] = Closedp */ { WindowInterface wif; Window window; @@ -2316,9 +1926,9 @@ MNXfillpolygon( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -2333,11 +1943,10 @@ MNXfillpolygon( args ) /* Transmogrify the y coordinates */ y = (short)wif->innerregion.height; - for (i = 1; i < pv->length; i += 2) - { - xpt[i] = y - translate_y(wif, xpt[i]); - xpt[i-1] = translate_x(wif, xpt[i-1]); - } + for (i = 1; i < pv->length; i += 2) { + xpt[i] = y - translate_y(wif, xpt[i]); + xpt[i - 1] = translate_x(wif, xpt[i - 1]); + } /* If CLOSED then set last point are eq to the first. */ if (args[2] != NIL) { @@ -2345,31 +1954,24 @@ MNXfillpolygon( args ) xpt[pv->length++] = xpt[1]; } - if( dd->ddoperation == INVERT_atom ) - { - XFillPolygon( display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); - XFillPolygon( display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == ERASE_atom ) - { - XFillPolygon( display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); - XFillPolygon( display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); - XFillPolygon( display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == PAINT_atom ) - { - XFillPolygon( display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); - XFillPolygon( display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); - XFillPolygon( display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XFillPolygon( display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); - XFillPolygon( display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); - } + if (dd->ddoperation == INVERT_atom) { + XFillPolygon(display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon(display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == ERASE_atom) { + XFillPolygon(display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon(display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon(display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == PAINT_atom) { + XFillPolygon(display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon(display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon(display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == REPLACE_atom) { + XFillPolygon(display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); + XFillPolygon(display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } /**************************************************************/ @@ -2379,10 +1981,9 @@ MNXfillpolygon( args ) /* is organized as [x1,y1,x2,y2,...] MNXdrawpolygon smashes this*/ /* vector with the integer values converted to C integers. */ /**************************************************************/ -MNXdrawcurve( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = LispPTR to Pointvector */ - /* args[2] = Closedp */ +MNXdrawcurve(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to Pointvector */ + /* args[2] = Closedp */ { WindowInterface wif; Window window; @@ -2396,9 +1997,9 @@ MNXdrawcurve( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); @@ -2413,11 +2014,10 @@ MNXdrawcurve( args ) /* Transmogrify the y coordinates */ y = (short)wif->innerregion.height; - for (i = 1; i < pv->length; i += 2) - { - xpt[i] = y - translate_y(wif, xpt[i]); - xpt[i-1] = translate_x(wif, xpt[i-1]); - } + for (i = 1; i < pv->length; i += 2) { + xpt[i] = y - translate_y(wif, xpt[i]); + xpt[i - 1] = translate_x(wif, xpt[i - 1]); + } /* If CLOSED then set last point are eq to the first. */ if (args[2] != NIL) { @@ -2425,43 +2025,34 @@ MNXdrawcurve( args ) xpt[pv->length++] = xpt[1]; } - if( dd->ddoperation == INVERT_atom ) - { - XDrawLines( display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == ERASE_atom ) - { - XDrawLines( display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == PAINT_atom ) - { - XDrawLines( display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XDrawLines( display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); - XDrawLines( display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); - } + if (dd->ddoperation == INVERT_atom) { + XDrawLines(display, window, wif->InvertGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixIGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == ERASE_atom) { + XDrawLines(display, window, wif->EraseGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, window, wif->EraseGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixEGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == PAINT_atom) { + XDrawLines(display, window, wif->PaintGC1, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, window, wif->PaintGC2, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixPGC, xpt, (pv->length >> 1), CoordModeOrigin); + } else if (dd->ddoperation == REPLACE_atom) { + XDrawLines(display, window, wif->ReplaceGC, xpt, (pv->length >> 1), CoordModeOrigin); + XDrawLines(display, wif->backing, dspif->PixRGC, xpt, (pv->length >> 1), CoordModeOrigin); + } XFlush(display); - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } - /************************************************************/ /* MNXclippingregion */ /************************************************************/ -MNXclippingregion( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = left */ - /* args[2] = bottom */ - /* args[3] = width */ - /* args[4] = height */ +MNXclippingregion(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = left */ + /* args[2] = bottom */ + /* args[3] = width */ + /* args[4] = height */ { WindowInterface wif; @@ -2473,7 +2064,7 @@ MNXclippingregion( args ) /* This is a noop. We read the region straight from the displaydata slots. */ - return(ATOM_T); + return (ATOM_T); } /**************************************************************/ @@ -2484,9 +2075,8 @@ MNXclippingregion( args ) /* Thus have to call this function explicitly twice. Once to */ /* set the new state and once to put the old state back. */ /**************************************************************/ -MNXoperation( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = Smallp for function. */ +MNXoperation(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = Smallp for function. */ { WindowInterface wif; Window window; @@ -2498,16 +2088,20 @@ MNXoperation( args ) window = XWindowFromMw(args[0]); dspif = DspIfFromMw(args[0]); display = XDisplayFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); /* This is a noop. We manipulate the GC from the displaydata slots. */ - if (dd->ddoperation == REPLACE_atom) wif->op = 0; - else if (dd->ddoperation == PAINT_atom) wif->op = 1; - else if (dd->ddoperation == INVERT_atom) wif->op = 2; - else if (dd->ddoperation == ERASE_atom) wif->op = 3; + if (dd->ddoperation == REPLACE_atom) + wif->op = 0; + else if (dd->ddoperation == PAINT_atom) + wif->op = 1; + else if (dd->ddoperation == INVERT_atom) + wif->op = 2; + else if (dd->ddoperation == ERASE_atom) + wif->op = 3; - return(NIL); + return (NIL); } /**************************************************************/ @@ -2517,9 +2111,8 @@ MNXoperation( args ) /* */ /* */ /**************************************************************/ -MNXdspcolor( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = LispPTR to FIXP or BITMAPP */ +MNXdspcolor(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to FIXP or BITMAPP */ { WindowInterface wif; DspInterface dspif; @@ -2531,21 +2124,20 @@ MNXdspcolor( args ) wif = WIfFromMw(args[0]); dspif = DspIfFromMw(args[0]); display = XDisplayFromMw(args[0]); - dd = ImDataFromMw( args[0] ); + dd = ImDataFromMw(args[0]); - if(wif->fgpixmap){ + if (wif->fgpixmap) { /* If we have an fgpixmap, junk it */ XFreePixmap(display, wif->fgpixmap); wif->fgpixmap = 0; } - if(TYPE_SMALLP == GetTypeNumber(args[1])) - if(LispIntToCInt(MScrFromMw(args[0])->SCDEPTH) == 1) { + if (TYPE_SMALLP == GetTypeNumber(args[1])) + if (LispIntToCInt(MScrFromMw(args[0])->SCDEPTH) == 1) { /* A fixp on a BW screen: make a texture of this */ dspif->image.data = id; MakeScratchImageFromInt(dspif, LispIntToCInt(args[1])); - } - else { /* A fixp on a color screen: color the foreground */ + } else { /* A fixp on a color screen: color the foreground */ fgcol = ~LispIntToCInt(args[1]); XSetForeground(display, wif->InvertGC, fgcol); XSetForeground(display, wif->EraseGC1, fgcol); @@ -2553,40 +2145,30 @@ MNXdspcolor( args ) XSetForeground(display, wif->PaintGC1, fgcol); XSetForeground(display, wif->PaintGC2, fgcol); XSetForeground(display, wif->ReplaceGC, fgcol); - return(NIL); + return (NIL); } else { BITMAP *bitmap; - + bitmap = (BITMAP *)Cptr(args[1]); MakeScratchImageFromBM(dspif, bitmap); } - if(dspif->image.depth == 1) { - wif->fgpixmap = XCreatePixmapFromBitmapData(dspif->handle, - XtWindow(wif->windowwidget), - dspif->image.data, - dspif->image.width, - dspif->image.height, - 0, - 1, - dspif->image.depth); + if (dspif->image.depth == 1) { + wif->fgpixmap = XCreatePixmapFromBitmapData(dspif->handle, XtWindow(wif->windowwidget), + dspif->image.data, dspif->image.width, + dspif->image.height, 0, 1, dspif->image.depth); XSetStipple(display, wif->InvertGC, wif->fgpixmap); XSetStipple(display, wif->EraseGC1, wif->fgpixmap); XSetStipple(display, wif->EraseGC2, wif->fgpixmap); XSetStipple(display, wif->PaintGC1, wif->fgpixmap); XSetStipple(display, wif->PaintGC2, wif->fgpixmap); XSetStipple(display, wif->ReplaceGC, wif->fgpixmap); - } - else { - wif->fgpixmap = XCreatePixmapFromBitmapData(dspif->handle, - XtWindow(wif->windowwidget), - dspif->image.data, - dspif->image.width, - dspif->image.height, - BlackPixelOfScreen(wif->screen), - WhitePixelOfScreen(wif->screen), - dspif->image.depth); + } else { + wif->fgpixmap = XCreatePixmapFromBitmapData( + dspif->handle, XtWindow(wif->windowwidget), dspif->image.data, dspif->image.width, + dspif->image.height, BlackPixelOfScreen(wif->screen), WhitePixelOfScreen(wif->screen), + dspif->image.depth); XSetTile(display, wif->InvertGC, wif->fgpixmap); XSetTile(display, wif->EraseGC1, wif->fgpixmap); XSetTile(display, wif->EraseGC2, wif->fgpixmap); @@ -2594,7 +2176,7 @@ MNXdspcolor( args ) XSetTile(display, wif->PaintGC2, wif->fgpixmap); XSetTile(display, wif->ReplaceGC, wif->fgpixmap); } - return(NIL); /* Report that all is ok. */ + return (NIL); /* Report that all is ok. */ } /**************************************************************/ @@ -2604,37 +2186,25 @@ MNXdspcolor( args ) /* */ /* */ /**************************************************************/ -MNXdspbackcolor ( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = background type 0=fixp for color 1=bitmap for stiple. */ - /* args[2] = background, fixp or bitmap */ -{ - settexture( args[0] ); -} - - - +MNXdspbackcolor(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +/* args[1] = background type 0=fixp for color 1=bitmap for stiple. */ +/* args[2] = background, fixp or bitmap */ +{ settexture(args[0]); } /************************************************************/ /* MNXBitblt - can only copy from bitmap to window. we need */ /* to make it do WINDOW -> BITMAP and WINDOW -> WINDOW */ /************************************************************/ -MNXBitBltBW( ) -{ - error("Call to MNXBitBltBW. This function is not in use anymore."); -} +MNXBitBltBW() { error("Call to MNXBitBltBW. This function is not in use anymore."); } - - -MNXbltshadeBW( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = LispPTR to TEXTURE */ - /* args[2] = dst_x */ - /* args[3] = dst_y */ - /* args[4] = width */ - /* args[5] = height */ - /* args[6] = operation */ - /* args[7] = background, fixp or bitmap */ +MNXbltshadeBW(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = LispPTR to TEXTURE */ + /* args[2] = dst_x */ + /* args[3] = dst_y */ + /* args[4] = width */ + /* args[5] = height */ + /* args[6] = operation */ + /* args[7] = background, fixp or bitmap */ { WindowInterface wif; DspInterface dspif; @@ -2647,110 +2217,79 @@ MNXbltshadeBW( args ) wif = WIfFromMw(args[0]); dspif = DspIfFromMw(args[0]); display = XDisplayFromMw(args[0]); - - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ regheight = LispIntToCInt(args[5]); width = LispIntToCInt(args[4]); - + dstx = translate_x(wif, LispIntToCInt(args[2])); - dsty = wif->innerregion.height - - translate_y(wif, LispIntToCInt(args[3])) - regheight; + dsty = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[3])) - regheight; bltshade_internal(display, op, args[1], dstx, dsty, width, regheight, wif, dspif); - } - - -bltshade_internal(display, op, texture, dstx, dsty, width, regheight, wif, dspif) - Display *display; - LispPTR texture; - int op, dstx, dsty, width, regheight; - WindowInterface wif; - DspInterface dspif; +bltshade_internal(display, op, texture, dstx, dsty, width, regheight, wif, dspif) Display *display; +LispPTR texture; +int op, dstx, dsty, width, regheight; +WindowInterface wif; +DspInterface dspif; { Pixmap bgpixmap; char id[64]; - if(TYPE_SMALLP == GetTypeNumber(texture)) - { + if (TYPE_SMALLP == GetTypeNumber(texture)) { #ifdef NEVER - if(dspif->depth == 1) - { + if (dspif->depth == 1) { #endif /* NEVER */ - dspif->image.data = id; - MakeScratchImageFromInt(dspif, texture & 0xFFFF); + dspif->image.data = id; + MakeScratchImageFromInt(dspif, texture & 0xFFFF); #ifdef NEVER - } - else - { /* Medley sez' color the foreground */ - XSetForeground(display, wif->gc, ~LispIntToCInt(texture)); - XFillRectangle(display, XtWindow(wif->windowwidget), wif->gc, - dstx, - dsty, - width, - regheight); - XFlush(display); - return(ATOM_T); - } -#endif /* NEVER */ + } else { /* Medley sez' color the foreground */ + XSetForeground(display, wif->gc, ~LispIntToCInt(texture)); + XFillRectangle(display, XtWindow(wif->windowwidget), wif->gc, dstx, dsty, width, regheight); + XFlush(display); + return (ATOM_T); } - else { /* Its a bitmap. Medley sez' make a texture of this */ +#endif /* NEVER */ + } else { /* Its a bitmap. Medley sez' make a texture of this */ BITMAP *bitmap; - + bitmap = (BITMAP *)Cptr(texture); MakeScratchImageFromBM(dspif, bitmap); } #ifdef NEVER - if(dspif->image.depth == 1) - { + if (dspif->image.depth == 1) { #endif /* NEVER */ - bgpixmap = XCreatePixmapFromBitmapData(dspif->handle, - XtWindow(wif->windowwidget), - dspif->image.data, - dspif->image.width, - dspif->image.height, - 0, - 1, - dspif->image.depth); - XSetStipple(display, wif->gc, bgpixmap); + bgpixmap = XCreatePixmapFromBitmapData(dspif->handle, XtWindow(wif->windowwidget), + dspif->image.data, dspif->image.width, + dspif->image.height, 0, 1, dspif->image.depth); + XSetStipple(display, wif->gc, bgpixmap); #ifdef NEVER - } - else - { - bgpixmap = XCreatePixmapFromBitmapData(dspif->handle, - XtWindow(wif->windowwidget), - dspif->image.data, - dspif->image.width, - dspif->image.height, - BlackPixelOfScreen(wif->screen), - WhitePixelOfScreen(wif->screen), - dspif->image.depth); - XSetTile(display, wif->gc, bgpixmap); - } + } else { + bgpixmap = XCreatePixmapFromBitmapData(dspif->handle, XtWindow(wif->windowwidget), + dspif->image.data, dspif->image.width, + dspif->image.height, BlackPixelOfScreen(wif->screen), + WhitePixelOfScreen(wif->screen), dspif->image.depth); + XSetTile(display, wif->gc, bgpixmap); + } #endif /* NEVER */ - - - XSetFunction(display, wif->gc, bltshade_function[op % 4]); - switch(op) - { + XSetFunction(display, wif->gc, bltshade_function[op % 4]); + switch (op) { case 0: /* XSetFillStyle(display, wif->gc, FillOpaqueStippled); */ XSetFillStyle(display, dspif->PixRGC, FillOpaqueStippled); XSetStipple(display, dspif->PixRGC, bgpixmap); XSetTSOrigin(display, dspif->PixRGC, dstx, dsty); - XFillRectangle(display, wif->backing, dspif->PixRGC, - dstx, dsty, width, regheight); + XFillRectangle(display, wif->backing, dspif->PixRGC, dstx, dsty, width, regheight); break; case 1: XSetFillStyle(display, wif->gc, FillStippled); XSetFillStyle(display, dspif->PixRGC, FillStippled); XSetStipple(display, dspif->PixRGC, bgpixmap); XSetTSOrigin(display, dspif->PixRGC, dstx, dsty); - XFillRectangle(display, wif->backing, dspif->PixRGC, - dstx, dsty, width, regheight); + XFillRectangle(display, wif->backing, dspif->PixRGC, dstx, dsty, width, regheight); break; case 2: XSetForeground(display, wif->gc, dspif->white ^ dspif->black); @@ -2758,8 +2297,7 @@ bltshade_internal(display, op, texture, dstx, dsty, width, regheight, wif, dspif XSetFillStyle(display, dspif->PixIGC, FillStippled); XSetStipple(display, dspif->PixIGC, bgpixmap); XSetTSOrigin(display, dspif->PixIGC, dstx, dsty); - XFillRectangle(display, wif->backing, dspif->PixIGC, - dstx, dsty, width, regheight); + XFillRectangle(display, wif->backing, dspif->PixIGC, dstx, dsty, width, regheight); break; case 3: XSetForeground(display, wif->gc, dspif->white); @@ -2767,40 +2305,36 @@ bltshade_internal(display, op, texture, dstx, dsty, width, regheight, wif, dspif XSetFillStyle(display, dspif->PixEGC, FillStippled); XSetStipple(display, dspif->PixEGC, bgpixmap); XSetTSOrigin(display, dspif->PixEGC, dstx, dsty); - XFillRectangle(display, wif->backing, dspif->PixEGC, - dstx, dsty, width, regheight); + XFillRectangle(display, wif->backing, dspif->PixEGC, dstx, dsty, width, regheight); break; - } + } -/* XSetTSOrigin(display, wif->gc, dstx, dsty); - XFillRectangle(display, XtWindow(wif->windowwidget), wif->gc, - dstx, dsty, width, regheight); */ + /* XSetTSOrigin(display, wif->gc, dstx, dsty); + XFillRectangle(display, XtWindow(wif->windowwidget), wif->gc, + dstx, dsty, width, regheight); */ - XCopyPlane(display, wif->backing, XtWindow(wif->windowwidget), wif->ReplaceGC, - dstx, dsty, width, regheight, dstx, dsty, 1); + XCopyPlane(display, wif->backing, XtWindow(wif->windowwidget), wif->ReplaceGC, dstx, dsty, width, + regheight, dstx, dsty, 1); XFreePixmap(display, bgpixmap); - switch(op) /* undo the changing of foreground color above */ - { - case 0: - case 1: XSetFillStyle(display, dspif->PixRGC, FillSolid); - break; - case 2: XSetForeground(display, wif->gc, dspif->black); - XSetFillStyle(display, dspif->PixIGC, FillSolid); - break; - case 3: XSetForeground(display, wif->gc, dspif->black); - XSetFillStyle(display, dspif->PixEGC, FillSolid); - break; - } + switch (op) /* undo the changing of foreground color above */ + { + case 0: + case 1: XSetFillStyle(display, dspif->PixRGC, FillSolid); break; + case 2: + XSetForeground(display, wif->gc, dspif->black); + XSetFillStyle(display, dspif->PixIGC, FillSolid); + break; + case 3: + XSetForeground(display, wif->gc, dspif->black); + XSetFillStyle(display, dspif->PixEGC, FillSolid); + break; + } /* XSetFunction(display, wif->gc, gcfunction[wif->op % 4]); */ XFlush(display); } - - - -XClearToEOL ( args ) - LispArgs args; /* args[0] = MedleyWindow */ +XClearToEOL(args) LispArgs args; /* args[0] = MedleyWindow */ { Display *display; Window window; @@ -2812,25 +2346,19 @@ XClearToEOL ( args ) display = XDisplayFromMw(args[0]); window = XWindowFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ height = abs(dd->ddlinefeed); dstx = translate_x(wif, LispIntToCInt(args[1])); dsty = wif->innerregion.height - translate_y(wif, LispIntToCInt(args[2])) - height; - XClearArea( display, window, - dstx, - dsty, - 0, /* Out to the end */ - height, /* The height */ - False /* Don't generate exposure events */ - ); + XClearArea(display, window, dstx, dsty, 0, /* Out to the end */ + height, /* The height */ + False /* Don't generate exposure events */ + ); XFlush(display); } - - -MNXNewPage ( args ) - LispArgs args; /* args[0] = MedleyWindow */ +MNXNewPage(args) LispArgs args; /* args[0] = MedleyWindow */ { Display *display; Window window; @@ -2841,20 +2369,16 @@ MNXNewPage ( args ) XFlush(display); } - - - /************************************************************/ /* MNXOutchar */ /* NOTE this function returns NIL if we succeed and T if we */ /* bump into the right margin. */ /************************************************************/ -MNXOutchar ( args ) - LispArgs args; /* args[0] = MedleyWindow */ - /* args[1] = Charcode */ - /* args[2] = Stream */ - /* args[3] = DD */ - /* DSPXOFFSET and DSPYOFFSET are ignored here. */ +MNXOutchar(args) LispArgs args; /* args[0] = MedleyWindow */ + /* args[1] = Charcode */ + /* args[2] = Stream */ + /* args[3] = DD */ + /* DSPXOFFSET and DSPYOFFSET are ignored here. */ { /* Doesn't switch charsets. */ Display *display; @@ -2870,13 +2394,12 @@ MNXOutchar ( args ) dspif = DspIfFromMw(args[0]); wif = WIfFromMw(args[0]); - if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ + if (!wif->open) MNXopenW(args); /* if window is closed, open it. */ display = dspif->handle; window = XtWindow(wif->windowwidget); - if (!window) return(NIL); /* No window, pretend we succeeded. */ - + if (!window) return (NIL); /* No window, pretend we succeeded. */ s = ((Stream *)Cptr(args[2])); dd = ((DISPLAYDATA *)Cptr(args[3])); @@ -2886,20 +2409,19 @@ MNXOutchar ( args ) cx = translate_x(wif, LispIntToCInt(dd->ddxposition)); rmargin = LispIntToCInt(dd->ddrightmargin); lmargin = LispIntToCInt(dd->ddleftmargin); - w = GETWORD((DLword*)Cptr(dd->ddcharimagewidths + char8code)); + w = GETWORD((DLword *)Cptr(dd->ddcharimagewidths + char8code)); right = cx + w; - if((right> rmargin )&&(cx >lmargin)) /* a linebreak. Punt. */ - return(ATOM_T); + if ((right > rmargin) && (cx > lmargin)) /* a linebreak. Punt. */ + return (ATOM_T); - newpos = cx + GETWORD((DLword*)Cptr(dd->ddwidthscache + char8code )); + newpos = cx + GETWORD((DLword *)Cptr(dd->ddwidthscache + char8code)); dd->ddxposition = CIntToLispInt(newpos); /* Y transform. Ypos is the baseline, it is adjusted by ascent */ cy = translate_y(wif, LispIntToCInt(dd->ddyposition)); - cy = wif->innerregion.height - cy - - dd->ddcharsetascent; + cy = wif->innerregion.height - cy - dd->ddcharsetascent; /* This bitmap should be cached on the server! */ /* Do this in the CHANGECHARSET code. */ @@ -2909,57 +2431,48 @@ MNXOutchar ( args ) sx = GETWORD(Cptr(dd->ddoffsetscache + char8code)); sy = 0; - if( dd->ddoperation == INVERT_atom ) - { - XPutImage( display, window, wif->InvertGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - XPutImage( display, wif->backing, dspif->PixIGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - } - else if( dd->ddoperation == ERASE_atom ) - { - XPutImage( display, window, wif->EraseGC1, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - XPutImage( display, window, wif->EraseGC2, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - XPutImage( display, wif->backing, dspif->PixEGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - } - else if( dd->ddoperation == PAINT_atom ) - { - XPutImage( display, window, wif->PaintGC1, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - XPutImage( display, window, wif->PaintGC2, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - XPutImage( display, wif->backing, dspif->PixPGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - } - else if( dd->ddoperation == REPLACE_atom ) - { - XPutImage( display, window, wif->ReplaceGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - XPutImage( display, wif->backing, dspif->PixRGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight ); - } + if (dd->ddoperation == INVERT_atom) { + XPutImage(display, window, wif->InvertGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight); + XPutImage(display, wif->backing, dspif->PixIGC, &dspif->image, sx, sy, cx, cy, w, + bitmap->bmheight); + } else if (dd->ddoperation == ERASE_atom) { + XPutImage(display, window, wif->EraseGC1, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight); + XPutImage(display, window, wif->EraseGC2, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight); + XPutImage(display, wif->backing, dspif->PixEGC, &dspif->image, sx, sy, cx, cy, w, + bitmap->bmheight); + } else if (dd->ddoperation == PAINT_atom) { + XPutImage(display, window, wif->PaintGC1, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight); + XPutImage(display, window, wif->PaintGC2, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight); + XPutImage(display, wif->backing, dspif->PixPGC, &dspif->image, sx, sy, cx, cy, w, + bitmap->bmheight); + } else if (dd->ddoperation == REPLACE_atom) { + XPutImage(display, window, wif->ReplaceGC, &dspif->image, sx, sy, cx, cy, w, bitmap->bmheight); + XPutImage(display, wif->backing, dspif->PixRGC, &dspif->image, sx, sy, cx, cy, w, + bitmap->bmheight); + } /* Increment the CHARPOSITION of the stream with 1 */ s->CHARPOSITION++; XFlush(display); - return(NIL); + return (NIL); } - - - /************************************************************/ /* The WINDOWPROP interface */ /************************************************************/ -MNXgetwindowprop( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ -{ -} +MNXgetwindowprop(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +{} -MNXputwindowprop( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ - /* args[1] = Lispint to despatch on. */ - /* args[n] = args for the method. */ +MNXputwindowprop(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ + /* args[1] = Lispint to despatch on. */ + /* args[n] = args for the method. */ { int method; Window window; XWindowAttributes attr; WindowInterface wif; - method = LispIntToCInt( args[1] ); + method = LispIntToCInt(args[1]); wif = WIfFromMw(args[0]); /* Discard the dispatching lispint and */ @@ -2967,68 +2480,44 @@ MNXputwindowprop( args ) /* ... */ args[1] = args[0]; args++; - - switch( method ){ - case MNWTitle: - showtitle( args[0] ); - break; - case MNWScrollFn: - XtVaSetValues(WIfFromMw(args[0])->formwidget, - XtNbarOnOff, (args[1] != NIL), - XtNmedleyWindow, wif, - XtNhScroll, &SignalHScroll, - XtNhJmpScroll, &SignalHJmpScroll, - XtNvScroll, &SignalVScroll, - XtNvJmpScroll, &SignalVJmpScroll, - NULL); - if (XtWindow(wif->topwidget)) - { - XGetWindowAttributes(wif->dspif->handle, XtWindow(wif->topwidget), &attr); - wif->topregion.width = attr.width; - wif->topregion.height = attr.height; - } - break; - case MNWNoScrollbars: - XtVaSetValues(WIfFromMw(args[0])->formwidget, - XtNbarOnOff, (args[1] == NIL), - NULL); - if (XtWindow(wif->topwidget)) - { - XGetWindowAttributes(wif->dspif->handle, XtWindow(wif->topwidget), &attr); - wif->topregion.width = attr.width; - wif->topregion.height = attr.height; - } - break; - case MNWScrollExtent: - XtVaSetValues(WIfFromMw(args[0])->formwidget, - XtNextentX, LispIntToCInt( args[1] ), - XtNextentY, LispIntToCInt( args[2] ), - XtNextentWidth, LispIntToCInt( args[3] ), - XtNextentHeight, LispIntToCInt( args[4] ), - NULL); - break; - case MNWScrollExtentUse: - break; - case MNWBorder: - refreshwindow( args[0] ); - break; - default: - break; + + switch (method) { + case MNWTitle: showtitle(args[0]); break; + case MNWScrollFn: + XtVaSetValues(WIfFromMw(args[0])->formwidget, XtNbarOnOff, (args[1] != NIL), XtNmedleyWindow, + wif, XtNhScroll, &SignalHScroll, XtNhJmpScroll, &SignalHJmpScroll, XtNvScroll, + &SignalVScroll, XtNvJmpScroll, &SignalVJmpScroll, NULL); + if (XtWindow(wif->topwidget)) { + XGetWindowAttributes(wif->dspif->handle, XtWindow(wif->topwidget), &attr); + wif->topregion.width = attr.width; + wif->topregion.height = attr.height; + } + break; + case MNWNoScrollbars: + XtVaSetValues(WIfFromMw(args[0])->formwidget, XtNbarOnOff, (args[1] == NIL), NULL); + if (XtWindow(wif->topwidget)) { + XGetWindowAttributes(wif->dspif->handle, XtWindow(wif->topwidget), &attr); + wif->topregion.width = attr.width; + wif->topregion.height = attr.height; + } + break; + case MNWScrollExtent: + XtVaSetValues(WIfFromMw(args[0])->formwidget, XtNextentX, LispIntToCInt(args[1]), XtNextentY, + LispIntToCInt(args[2]), XtNextentWidth, LispIntToCInt(args[3]), XtNextentHeight, + LispIntToCInt(args[4]), NULL); + break; + case MNWScrollExtentUse: break; + case MNWBorder: refreshwindow(args[0]); break; + default: break; } } - - - /************************************************************/ /* Mouse position and friends. Have to be vectored through */ /* the screen. */ /************************************************************/ - - - -static Cursor grab_cursor = 0; /* Cursor in effect while pointer is grabbed */ +static Cursor grab_cursor = 0; /* Cursor in effect while pointer is grabbed */ /************************************************************************/ /* */ @@ -3041,70 +2530,60 @@ static Cursor grab_cursor = 0; /* Cursor in effect while pointer is grabbed */ /* */ /************************************************************************/ -MNXGrabPointer(args) - LispArgs args; - /* args[0] = medley screen */ - /* args[1] = cursor to use, or NIL */ - { +MNXGrabPointer(args) LispArgs args; +/* args[0] = medley screen */ +/* args[1] = cursor to use, or NIL */ +{ Display *display; WindowInterface wif; DspInterface dspif; char *tmpstring; BITMAP *bitmap; - XGCValues gcv; + XGCValues gcv; MedleyScreen MScreen; Pixmap bits; Window promptw; int res, i; extern unsigned char reversedbits[]; unsigned char *src; - unsigned char srcbits[32]; /* holds the reversed bits for cursor */ + unsigned char srcbits[32]; /* holds the reversed bits for cursor */ MScreen = (MedleyScreen)Cptr(args[0]); dspif = MScreen->NativeIf; display = dspif->handle; - wif = dspif -> promptw; /* handle on the prompt window */ + wif = dspif->promptw; /* handle on the prompt window */ promptw = XtWindow(wif->framewidget); - if (args[1]) - { - - src = (unsigned char *) Cptr(args[1]); - for (i=0; i<32; i++) srcbits[i] = reversedbits[src[i]]; - - bits = XCreatePixmapFromBitmapData(display, dspif->root, srcbits, - 16, 16, 1, 0, 1); - grab_cursor = XCreatePixmapCursor(display, bits, bits, &dspif->black, &dspif->white, - args[2]&0xFFFF, 16-(args[3]&0xFFFF)); - } - else - { - grab_cursor = None; - } - - res = XGrabPointer(display, promptw, False, PointerMotionMask|ButtonPressMask|ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, - None, grab_cursor, CurrentTime); - - - if (grab_cursor != None) { XFreePixmap(display, bits); } - if (res == GrabSuccess) return (ATOM_T); - else return(NIL); + if (args[1]) { + src = (unsigned char *)Cptr(args[1]); + for (i = 0; i < 32; i++) srcbits[i] = reversedbits[src[i]]; + bits = XCreatePixmapFromBitmapData(display, dspif->root, srcbits, 16, 16, 1, 0, 1); + grab_cursor = XCreatePixmapCursor(display, bits, bits, &dspif->black, &dspif->white, + args[2] & 0xFFFF, 16 - (args[3] & 0xFFFF)); + } else { + grab_cursor = None; } + res = + XGrabPointer(display, promptw, False, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, grab_cursor, CurrentTime); + if (grab_cursor != None) { XFreePixmap(display, bits); } + if (res == GrabSuccess) + return (ATOM_T); + else + return (NIL); +} - -MNXUngrabPointer(args) - LispArgs args; - { +MNXUngrabPointer(args) LispArgs args; +{ Display *display; WindowInterface wif; DspInterface dspif; char *tmpstring; BITMAP *bitmap; - XGCValues gcv; + XGCValues gcv; MedleyScreen MScreen; int res; @@ -3121,132 +2600,100 @@ MNXUngrabPointer(args) grab_cursor = None; return (ATOM_T); +} - } +static int box_drawn = 0; /* T if there's a box on already */ +MNXDrawBox(args) LispArgs args; /* args[0] = Medley SCREEN to draw box on */ + /* args[1] = Left of box */ + /* args[2] = bottom of box */ + /* args[3] = width of box */ + /* args[4] = height of box */ + /* args[5] = T to force turning box off iff it's on */ +{ + Display *display; + WindowInterface wif; + DspInterface dspif; + MedleyScreen MScreen; + int res, l, b, w, h; + GC gc; + Window root; + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = MScreen->NativeIf; + display = dspif->handle; + gc = dspif->BoxingGC; + root = dspif->root; + l = LispIntToCInt(args[1]); + b = LispIntToCInt(args[2]); + w = LispIntToCInt(args[3]); + h = LispIntToCInt(args[4]); -static int box_drawn = 0; /* T if there's a box on already */ - -MNXDrawBox(args) - LispArgs args; /* args[0] = Medley SCREEN to draw box on */ - /* args[1] = Left of box */ - /* args[2] = bottom of box */ - /* args[3] = width of box */ - /* args[4] = height of box */ - /* args[5] = T to force turning box off iff it's on */ + if (w < 0) /* Negative width, change X coord and make it positive */ { - - Display *display; - WindowInterface wif; - DspInterface dspif; - MedleyScreen MScreen; - int res, l, b, w, h; - GC gc; - Window root; - - MScreen = (MedleyScreen)Cptr(args[0]); - dspif = MScreen->NativeIf; - display = dspif->handle; - gc = dspif->BoxingGC; - root = dspif->root; - - l = LispIntToCInt(args[1]); - b = LispIntToCInt(args[2]); - w = LispIntToCInt(args[3]); - h = LispIntToCInt(args[4]); - - if (w < 0) /* Negative width, change X coord and make it positive */ - { - l += w; - w = -w; - } - - if (h < 0) /* Negative height, change Y coord and make it positive */ - { - b += h; - h = -h; - } - - b = HeightOfScreen(dspif->xscreen) - b - h; /* convert to X's Y-coord */ - - if (args[5]) - { - if (box_drawn) XDrawRectangle(display, root, gc, l, b, w, h); - box_drawn = 0; - } - else - { - XDrawRectangle(display, root, gc, l, b, w, h); - box_drawn = !box_drawn; - } + l += w; + w = -w; } + if (h < 0) /* Negative height, change Y coord and make it positive */ + { + b += h; + h = -h; + } + b = HeightOfScreen(dspif->xscreen) - b - h; /* convert to X's Y-coord */ - - -MNXMovePointer( args ) - LispArgs args; /* args[0] = LispPTR to SCREEN */ - /* args[1] = new pointer X */ - /* args[2] = new pointer Y */ -{ - Display *display; - WindowInterface wif; - DspInterface dspif; - MedleyScreen MScreen; - int res, l, b, w, h; - GC gc; - Window root; - - MScreen = (MedleyScreen)Cptr(args[0]); - dspif = MScreen->NativeIf; - display = dspif->handle; - gc = dspif->BoxingGC; - root = dspif->root; - - XWarpPointer(display, None, root, 0, 0, 0, 0, - args[1] & 0xFFFF, - args[2] & 0xFFFF); - return(ATOM_T); + if (args[5]) { + if (box_drawn) XDrawRectangle(display, root, gc, l, b, w, h); + box_drawn = 0; + } else { + XDrawRectangle(display, root, gc, l, b, w, h); + box_drawn = !box_drawn; + } } - - - -MNXmouseconfirm( args ) - LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +MNXMovePointer(args) LispArgs args; /* args[0] = LispPTR to SCREEN */ + /* args[1] = new pointer X */ + /* args[2] = new pointer Y */ { - /* Use a DIALOG WIDGET here. */ + Display *display; + WindowInterface wif; + DspInterface dspif; + MedleyScreen MScreen; + int res, l, b, w, h; + GC gc; + Window root; + + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = MScreen->NativeIf; + display = dspif->handle; + gc = dspif->BoxingGC; + root = dspif->root; + + XWarpPointer(display, None, root, 0, 0, 0, 0, args[1] & 0xFFFF, args[2] & 0xFFFF); + return (ATOM_T); } +MNXmouseconfirm(args) LispArgs args; /* args[0] = LispPTR to MedleyWindow */ +{ /* Use a DIALOG WIDGET here. */ } - - -MNXgarb( args ) - LispArgs args; /* args[0] = LispPTR to MedleyScreen */ - /* args[1] = NIL for GC off, non-NIL for GC on */ +MNXgarb(args) LispArgs args; /* args[0] = LispPTR to MedleyScreen */ + /* args[1] = NIL for GC off, non-NIL for GC on */ { DspInterface dspif; dspif = DspIfFromMscr(args[0]); - if(dspif->gcindicator) - if(XtIsRealized(dspif->gcindicator)) - if(args[1] == NIL) - XClearWindow(XtDisplay(dspif->gcindicator), XtWindow(dspif->gcindicator)); + if (dspif->gcindicator) + if (XtIsRealized(dspif->gcindicator)) + if (args[1] == NIL) + XClearWindow(XtDisplay(dspif->gcindicator), XtWindow(dspif->gcindicator)); else - XFillRectangle(XtDisplay(dspif->gcindicator), XtWindow(dspif->gcindicator), - DefaultGCOfScreen(XtScreen(dspif->gcindicator)), 0, 0, - 8, - 8); + XFillRectangle(XtDisplay(dspif->gcindicator), XtWindow(dspif->gcindicator), + DefaultGCOfScreen(XtScreen(dspif->gcindicator)), 0, 0, 8, 8); } - - - -MNXMakePromptWindow( args ) - LispArgs args; /* args[0] = Lisp window, the prompt window */ +MNXMakePromptWindow(args) LispArgs args; /* args[0] = Lisp window, the prompt window */ { Widget form, menu; DspInterface dspif; @@ -3255,49 +2702,31 @@ MNXMakePromptWindow( args ) wif = WIfFromMw(args[0]); dspif = wif->dspif; - dspif->promptw = wif; /* Save prompt window, for grabbing pointer events */ + dspif->promptw = wif; /* Save prompt window, for grabbing pointer events */ - dspif->legatewidget = XtVaAppCreateShell - ("Medley Status", "Medley Status", - applicationShellWidgetClass, XDisplayFromMw(args[0]), - XtNargc, save_argc, - XtNargv, save_argv, - XtNborderWidth, 0, - NULL); + dspif->legatewidget = XtVaAppCreateShell( + "Medley Status", "Medley Status", applicationShellWidgetClass, XDisplayFromMw(args[0]), + XtNargc, save_argc, XtNargv, save_argv, XtNborderWidth, 0, NULL); - form = XtVaCreateManagedWidget("bar", boxWidgetClass, dspif->legatewidget, NULL); + form = XtVaCreateManagedWidget("bar", boxWidgetClass, dspif->legatewidget, NULL); - dspif->gcindicator = XtVaCreateManagedWidget - ("gcindicator", boxWidgetClass, form, - XtNwidth, 8, - XtNheight, 8, - NULL); + dspif->gcindicator = + XtVaCreateManagedWidget("gcindicator", boxWidgetClass, form, XtNwidth, 8, XtNheight, 8, NULL); menu = XtVaCreateManagedWidget("Background", commandWidgetClass, form, NULL); - XtAddEventHandler(menu, - ButtonPressMask | ButtonReleaseMask, - False, - HandleBackgroundButton, - dspif->screen); - XtAddEventHandler(dspif->legatewidget, - PointerMotionMask, - False, HandleMotion, 0); - XtAddEventHandler(dspif->legatewidget, - EnterWindowMask | LeaveWindowMask, - False, HandleBackgroundCrossing, dspif); - XtAddEventHandler(dspif->legatewidget, - KeyPressMask | KeyReleaseMask, - False, HandleKey, dspif); + XtAddEventHandler(menu, ButtonPressMask | ButtonReleaseMask, False, HandleBackgroundButton, + dspif->screen); + XtAddEventHandler(dspif->legatewidget, PointerMotionMask, False, HandleMotion, 0); + XtAddEventHandler(dspif->legatewidget, EnterWindowMask | LeaveWindowMask, False, + HandleBackgroundCrossing, dspif); + XtAddEventHandler(dspif->legatewidget, KeyPressMask | KeyReleaseMask, False, HandleKey, dspif); XtRealizeWidget(dspif->legatewidget); XtSetSensitive(dspif->legatewidget, True); XtSetSensitive(form, True); - return(ATOM_T); + return (ATOM_T); } - - - /************************************************************/ /* */ /* M N X S e t C u r s o r */ @@ -3306,57 +2735,49 @@ MNXMakePromptWindow( args ) /* */ /************************************************************/ +static Cursor MNX_cursor = NULL; /* Cursor in active use */ -static Cursor MNX_cursor = NULL; /* Cursor in active use */ +MNXSetCursor(args) LispArgs args; /* args[0] = Medley screen */ + /* args[1] = bits for new cursor */ + /* args[2] = hot-spot x */ + /* args[3] = hot-spot y */ +{ + Display *display; + WindowInterface wif; + DspInterface dspif; + char *tmpstring; + BITMAP *bitmap; + XGCValues gcv; + MedleyScreen MScreen; + Pixmap bits; + Cursor new_cursor; + Window win; + unsigned char srcbits[32]; /* hold the reversed-bits for cursor */ + extern unsigned char reversedbits[]; + unsigned char *src; + int i; -MNXSetCursor(args) - LispArgs args; /* args[0] = Medley screen */ - /* args[1] = bits for new cursor */ - /* args[2] = hot-spot x */ - /* args[3] = hot-spot y */ - { - Display *display; - WindowInterface wif; - DspInterface dspif; - char *tmpstring; - BITMAP *bitmap; - XGCValues gcv; - MedleyScreen MScreen; - Pixmap bits; - Cursor new_cursor; - Window win; - unsigned char srcbits[32]; /* hold the reversed-bits for cursor */ - extern unsigned char reversedbits[]; - unsigned char *src; - int i; + MScreen = (MedleyScreen)Cptr(args[0]); + dspif = DspIfFromMscr(args[0]); + display = dspif->handle; - MScreen = (MedleyScreen)Cptr(args[0]); - dspif = DspIfFromMscr(args[0]); - display = dspif->handle; + src = (unsigned char *)Cptr(args[1]); + for (i = 0; i < 32; i++) srcbits[i] = reversedbits[src[i]]; - src = (unsigned char *) Cptr(args[1]); - for (i=0; i<32; i++) srcbits[i] = reversedbits[src[i]]; + bits = XCreatePixmapFromBitmapData(display, dspif->root, srcbits, 16, 16, 1, 0, 1); + new_cursor = XCreatePixmapCursor(display, bits, bits, &dspif->black, &dspif->white, + args[2] & 0xFFFF, args[3] & 0xFFFF); - bits = XCreatePixmapFromBitmapData(display, dspif->root, srcbits, - 16, 16, 1, 0, 1); - new_cursor = XCreatePixmapCursor(display, bits, bits, &dspif->black, - &dspif->white, args[2]&0xFFFF, args[3]&0xFFFF); - - for (wif = dspif->CreatedWifs; wif; wif = wif->next) - if (win=XtWindow(wif->windowwidget)) - XDefineCursor(display, win, new_cursor); - - XFreePixmap(display, bits); - - if (dspif->cursor) { XFreeCursor(display, dspif->cursor); } - dspif->cursor = new_cursor; - - - return(NIL); - } + for (wif = dspif->CreatedWifs; wif; wif = wif->next) + if (win = XtWindow(wif->windowwidget)) XDefineCursor(display, win, new_cursor); + XFreePixmap(display, bits); + if (dspif->cursor) { XFreeCursor(display, dspif->cursor); } + dspif->cursor = new_cursor; + return (NIL); +} /************************************************************/ /* I n i t D s p */ @@ -3364,8 +2785,7 @@ MNXSetCursor(args) /* The slots for identifier, object type and window system */ /* has to be filled in. */ /************************************************************/ -InitDsp( args ) - LispArgs args; /* arg[0] = LispPTR to MedleyScreen */ +InitDsp(args) LispArgs args; /* arg[0] = LispPTR to MedleyScreen */ { DspInterface dspif; MedleyScreen SCREEN; @@ -3374,17 +2794,16 @@ InitDsp( args ) Display *display; Screen *screen; XGCValues gcv; - int black, white; /* Pixel values for this display */ - int mask, diff, inverted; /* For finding a plane where they differ */ - Pixmap tpx; /* temp pixmap of depth 1 for creating GCs */ + int black, white; /* Pixel values for this display */ + int mask, diff, inverted; /* For finding a plane where they differ */ + Pixmap tpx; /* temp pixmap of depth 1 for creating GCs */ int Xfd; - SCREEN = (MedleyScreen)Cptr(args[0]); dspif = (DspInterface)malloc(sizeof(DspInterfaceRec)); SCREEN->NativeIf = dspif; - if (!xtinitialized){ + if (!xtinitialized) { XtToolkitInitialize(); xtinitialized = True; } @@ -3392,36 +2811,23 @@ InitDsp( args ) /* if NATIVE_INFO has a string use it for the hostname */ /* else use the environment var DISPLAY or "unix:0.0" */ - if(LispStringP (SCREEN->NATIVE_INFO)) - { - strlen = LispStringLength(SCREEN->NATIVE_INFO); - tmpstring = (char *)alloca(strlen + 1); - LispStringToCStr(SCREEN->NATIVE_INFO, tmpstring); - dspif->handle = XtOpenDisplay( dspif->xtcontext, - tmpstring, - NULL, - "window", - NULL, - 0, - &save_argc, - save_argv); - } - else dspif->handle = XtOpenDisplay( dspif->xtcontext, - NULL, - NULL, - "window", - NULL, - 0, - &save_argc, - save_argv); + if (LispStringP(SCREEN->NATIVE_INFO)) { + strlen = LispStringLength(SCREEN->NATIVE_INFO); + tmpstring = (char *)alloca(strlen + 1); + LispStringToCStr(SCREEN->NATIVE_INFO, tmpstring); + dspif->handle = + XtOpenDisplay(dspif->xtcontext, tmpstring, NULL, "window", NULL, 0, &save_argc, save_argv); + } else + dspif->handle = + XtOpenDisplay(dspif->xtcontext, NULL, NULL, "window", NULL, 0, &save_argc, save_argv); /* Set up the native structure here */ - if (dspif->handle == NULL) return(CIntToLispInt(2)); + if (dspif->handle == NULL) return (CIntToLispInt(2)); XSetErrorHandler(Xerrhandler); display = dspif->handle; - dspif->xscreen = screen = DefaultScreenOfDisplay( display ); + dspif->xscreen = screen = DefaultScreenOfDisplay(display); Xfd = ConnectionNumber(display); FD_to_dspif[Xfd] = dspif; @@ -3433,49 +2839,38 @@ InitDsp( args ) #endif /* HPUX */ #endif /* ISC */ - dspif->screen = args[0]; /* So we know which SCREEN this display is */ + dspif->screen = args[0]; /* So we know which SCREEN this display is */ dspif->root = RootWindowOfScreen(screen); /* And the root window for the screen */ dspif->gcindicator = 0; dspif->legatewidget = 0; dspif->cursor = 0; - gcv.function = GXcopy; - gcv.foreground = dspif->white = WhitePixelOfScreen( screen ); - gcv.background = dspif->black = BlackPixelOfScreen( screen ); - dspif->TitleGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + gcv.function = GXcopy; + gcv.foreground = dspif->white = WhitePixelOfScreen(screen); + gcv.background = dspif->black = BlackPixelOfScreen(screen); + dspif->TitleGC = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); tpx = XCreatePixmap(display, dspif->root, 10, 10, 1); - gcv.function = GXcopy; + gcv.function = GXcopy; gcv.foreground = 1; gcv.background = 0; - dspif->PixRGC = XCreateGC( display, tpx - , GCForeground | GCBackground | GCFunction - , &gcv ); + dspif->PixRGC = XCreateGC(display, tpx, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXor; + gcv.function = GXor; gcv.foreground = 1; gcv.background = 0; - dspif->PixPGC = XCreateGC( display, tpx - , GCForeground | GCBackground | GCFunction - , &gcv ); + dspif->PixPGC = XCreateGC(display, tpx, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXxor; + gcv.function = GXxor; gcv.foreground = 1; gcv.background = 0; - dspif->PixIGC = XCreateGC( display, tpx - , GCForeground | GCBackground | GCFunction - , &gcv ); + dspif->PixIGC = XCreateGC(display, tpx, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXandInverted; + gcv.function = GXandInverted; gcv.foreground = 1; gcv.background = 0; - dspif->PixEGC = XCreateGC( display, tpx - , GCForeground | GCBackground | GCFunction - , &gcv ); - + dspif->PixEGC = XCreateGC(display, tpx, GCForeground | GCBackground | GCFunction, &gcv); XFreePixmap(display, tpx); @@ -3483,10 +2878,10 @@ InitDsp( args ) dspif->image.xoffset = 0; #if (defined(BYTESWAP)) dspif->image.byte_order = LSBFirst; -#else /* BYTESWAP */ +#else /* BYTESWAP */ dspif->image.byte_order = MSBFirst; -#endif /* BYTESWAP */ - dspif->image.bitmap_unit = 16 /*BitmapUnit( dspif->handle )*/; +#endif /* BYTESWAP */ + dspif->image.bitmap_unit = 16 /*BitmapUnit( dspif->handle )*/; dspif->image.bitmap_bit_order = MSBFirst; dspif->image.bitmap_pad = 16 /* 32 */; _XInitImageFuncPtrs(&dspif->image); @@ -3495,27 +2890,24 @@ InitDsp( args ) dspif->tmpimage.xoffset = 0; #if (defined(BYTESWAP)) dspif->tmpimage.byte_order = LSBFirst; -#else /* BYTESWAP */ +#else /* BYTESWAP */ dspif->tmpimage.byte_order = MSBFirst; -#endif /* BYTESWAP */ - dspif->tmpimage.bitmap_unit = 16 /*BitmapUnit( dspif->handle )*/; +#endif /* BYTESWAP */ + dspif->tmpimage.bitmap_unit = 16 /*BitmapUnit( dspif->handle )*/; dspif->tmpimage.bitmap_bit_order = MSBFirst; dspif->tmpimage.bitmap_pad = 16 /* 32 */; _XInitImageFuncPtrs(&dspif->tmpimage); - dspif->CreatedWifs = NULL; /* List of created wif. */ + dspif->CreatedWifs = NULL; /* List of created wif. */ /* Fill in the screen dimensions too! */ - SCREEN->SCWIDTH = - CIntToLispInt(WidthOfScreen(screen)); - SCREEN->SCHEIGHT = - CIntToLispInt(HeightOfScreen(screen)); + SCREEN->SCWIDTH = CIntToLispInt(WidthOfScreen(screen)); + SCREEN->SCHEIGHT = CIntToLispInt(HeightOfScreen(screen)); #ifndef NEVER - SCREEN->SCDEPTH = - CIntToLispInt(PlanesOfScreen(screen)); + SCREEN->SCDEPTH = CIntToLispInt(PlanesOfScreen(screen)); #endif /* Methods for the display */ - dspif->Dispatch.Method.InitW = MNXcreateW; + dspif->Dispatch.Method.InitW = MNXcreateW; dspif->Dispatch.Method.Openw = MNXopenW; dspif->Dispatch.Method.Closew = MNXcloseW; dspif->Dispatch.Method.MoveW = MNXmoveW; @@ -3565,81 +2957,66 @@ InitDsp( args ) XSynchronize(display, True); + /**************************************************/ + /* Create GCs for BITBLTs from window to bitmap */ + /**************************************************/ + diff = black & (~white); + inverted = 0; - /**************************************************/ - /* Create GCs for BITBLTs from window to bitmap */ - /**************************************************/ - - diff = black & (~white); - inverted = 0; - - if (diff) - for (mask = 1; mask; mask<<= 1) { if (mask & diff) break;} - else - { - mask = 1; inverted = 1; - for (diff = white&(~black); mask; mask<<=1) - { if (mask & diff) break;} - } + if (diff) + for (mask = 1; mask; mask <<= 1) { + if (mask & diff) break; + } + else { + mask = 1; + inverted = 1; + for (diff = white & (~black); mask; mask <<= 1) { + if (mask & diff) break; + } + } #ifdef NEVER - gcv.function = GXcopy; - gcv.foreground = !inverted; - gcv.background = inverted; - dspif->GetRGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + gcv.function = GXcopy; + gcv.foreground = !inverted; + gcv.background = inverted; + dspif->GetRGC = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXxor; - dspif->GetIGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + gcv.function = GXxor; + dspif->GetIGC = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXor; - dspif->GetPGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); + gcv.function = GXor; + dspif->GetPGC = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); - gcv.function = GXandInverted; - dspif->GetEGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction - , &gcv ); - dspif->bw_plane = mask; - dspif->bw_inverted = inverted; + gcv.function = GXandInverted; + dspif->GetEGC = XCreateGC(display, dspif->root, GCForeground | GCBackground | GCFunction, &gcv); + dspif->bw_plane = mask; + dspif->bw_inverted = inverted; #endif /* NEVER */ - gcv.function = GXxor; - gcv.line_style = LineSolid; - gcv.line_width = 0; - gcv.foreground = 255; - gcv.background = 0; - dspif->BoxingGC = XCreateGC( display, dspif->root - , GCForeground | GCBackground | GCFunction | - GCLineWidth | GCLineStyle - , &gcv ); - XSetSubwindowMode( display, dspif->BoxingGC, IncludeInferiors); + gcv.function = GXxor; + gcv.line_style = LineSolid; + gcv.line_width = 0; + gcv.foreground = 255; + gcv.background = 0; + dspif->BoxingGC = + XCreateGC(display, dspif->root, + GCForeground | GCBackground | GCFunction | GCLineWidth | GCLineStyle, &gcv); + XSetSubwindowMode(display, dspif->BoxingGC, IncludeInferiors); + /* Check the requested depth against possibilities */ - /* Check the requested depth against possibilities */ + if (SCREEN->SCDEPTH) { + int i; + int *dlist; + int dcount; - if (SCREEN->SCDEPTH) - { int i; - int *dlist; - int dcount; - - dlist = XListDepths(display, - XScreenNumberOfScreen(screen), - &dcount); - for (i=0; iSCDEPTH & 0xFFFF)) - return(NIL); - return(CIntToLispInt(1)); /* Can't find depth */ + dlist = XListDepths(display, XScreenNumberOfScreen(screen), &dcount); + for (i = 0; i < dcount; i++) + if (dlist[i] == (SCREEN->SCDEPTH & 0xFFFF)) return (NIL); + return (CIntToLispInt(1)); /* Can't find depth */ + } else { + SCREEN->SCDEPTH = CIntToLispInt(PlanesOfScreen(screen)); } - else - { - SCREEN->SCDEPTH = - CIntToLispInt(PlanesOfScreen(screen)); - } - return(NIL); + return (NIL); } /************************************************************/ @@ -3648,8 +3025,7 @@ InitDsp( args ) /* */ /* */ /************************************************************/ -init_mnw_instance( args ) - LispPTR *args; +init_mnw_instance(args) LispPTR *args; { int type; @@ -3660,9 +3036,11 @@ init_mnw_instance( args ) type = GetTypeNumber(args[0]); - if(type == MedleyScreenType) { return(InitDsp(args)); } - else error("Bogus type\n"); - return(ATOM_T); + if (type == MedleyScreenType) { + return (InitDsp(args)); + } else + error("Bogus type\n"); + return (ATOM_T); } /**************************************************************/ @@ -3677,51 +3055,46 @@ init_mnw_instance( args ) /* object and dispatches the method. The method is called */ /* with the methodindex removed. */ /**************************************************************/ -dispatch_mnw_method( args ) - LispPTR *args; +dispatch_mnw_method(args) LispPTR *args; { int type; int index; index = LispIntToCInt(args[0]); type = GetTypeNumber(args[1]); - - if(args[1] == NULL) - error("No object to dispatch from\n"); - if(type == MedleyWindowType) { + if (args[1] == NULL) error("No object to dispatch from\n"); + + if (type == MedleyWindowType) { WindowInterface wif; wif = WIfFromMw(args[1]); - if(wif == NULL){ - /* error("Attempt to dispatch on a non-native window.\n"); */ - return(NIL); + if (wif == NULL) { + /* error("Attempt to dispatch on a non-native window.\n"); */ + return (NIL); } - if((wif->Dispatch->vector[index]) == NULL){ + if ((wif->Dispatch->vector[index]) == NULL) { error("Display method not defined.\n"); - return(NIL); + return (NIL); } /* Now, dispatch with the selector (first) arg shave off */ - return((wif->Dispatch->vector[index])(&args[1])); - } - else if(type == MedleyScreenType) { + return ((wif->Dispatch->vector[index])(&args[1])); + } else if (type == MedleyScreenType) { DspInterface dspif; dspif = DspIfFromMscr(args[1]); - if(dspif == NULL){ + if (dspif == NULL) { error("Attempt to dispatch on a non-native screen.\n"); - return(NIL); + return (NIL); } - if((dspif->Dispatch.vector[index]) == NULL){ + if ((dspif->Dispatch.vector[index]) == NULL) { error("Display method not defined.\n"); - return(NIL); + return (NIL); } /* Dispatch with selector and screen popped off */ - return((dspif->Dispatch.vector[index])(&args[2])); - } - else { + return ((dspif->Dispatch.vector[index])(&args[2])); + } else { error("Bogus type\n"); - return(NIL); + return (NIL); } } - diff --git a/src/mouseif.c b/src/mouseif.c old mode 100755 new mode 100644 index 85f1f5c..1f44d95 --- a/src/mouseif.c +++ b/src/mouseif.c @@ -1,29 +1,24 @@ -/* $Id: mouseif.c,v 1.2 1999/01/03 02:07:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ -static char *id = "$Id: mouseif.c,v 1.2 1999/01/03 02:07:26 sybalsky Exp $ Copyright (C) Venue"; - - - - -/************************************************************************/ -/* */ -/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ -/* All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ -/* The contents of this file are proprietary information */ -/* belonging to Venue, and are provided to you under license. */ -/* They may not be further distributed or disclosed to third */ -/* parties without the specific permission of Venue. */ -/* */ -/************************************************************************/ - -/* * * * D O S M O U S E I N T E R F A C E * * * */ - - -#include "version.h" - - - +/* $Id: mouseif.c,v 1.2 1999/01/03 02:07:26 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ +static char *id = "$Id: mouseif.c,v 1.2 1999/01/03 02:07:26 sybalsky Exp $ Copyright (C) Venue"; + +/************************************************************************/ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ +/* The contents of this file are proprietary information */ +/* belonging to Venue, and are provided to you under license. */ +/* They may not be further distributed or disclosed to third */ +/* parties without the specific permission of Venue. */ +/* */ +/************************************************************************/ + +/* * * * D O S M O U S E I N T E R F A C E * * * */ + +#include "version.h" + #include "lispemul.h" #include "dbprint.h" #include "devif.h" @@ -53,28 +48,25 @@ extern void TwoButtonHandler(); /* */ /* Probe for mouse and return the number of buttons available. */ /*****************************************************************/ -int probemouse() -{ +int probemouse() { union REGS regs; char c; /*************************************************************************** * Reset mouse driver, exit if no mouse driver present ***************************************************************************/ /* int 33h, case 0000, ax = drive installed, bx = # of buttons. */ - if (nomouseflag) { - return(666); /* return something, why not 666? */ - } - else { - regs.w.eax = 0; /* Func 0 = Reset mouse, ret. button info */ + if (nomouseflag) { + return (666); /* return something, why not 666? */ + } else { + regs.w.eax = 0; /* Func 0 = Reset mouse, ret. button info */ int86(0x33, ®s, ®s); - - if(regs.x.ax == 0x0000) VESA_errorexit("No mouse driver found.", -1); - return(regs.x.bx); + + if (regs.x.ax == 0x0000) VESA_errorexit("No mouse driver found.", -1); + return (regs.x.bx); } } -make_mouse_instance( mouse ) -MouseInterface mouse; +make_mouse_instance(mouse) MouseInterface mouse; { #ifdef DOS @@ -86,8 +78,7 @@ MouseInterface mouse; mouse->device.after_raid = &GenericReturnT; mouse->device.active = FALSE; NumberOfButtons = 3; - } - else { + } else { mouse->device.enter = &EnterDosMouse; mouse->device.exit = &ExitDosMouse; mouse->device.before_raid = &DosMouseBeforeRaid; @@ -100,38 +91,35 @@ MouseInterface mouse; mouse->Cursor.Last.width = 16; mouse->Cursor.Last.height = 16; - - if (nomouseflag == FALSE) { - if(twobuttonflag) { /* We force two button handling. */ + if (twobuttonflag) { /* We force two button handling. */ mouse->Handler = &TwoButtonHandler; mouse->Button.TwoButtonP = TRUE; - } - else /* Determine how many buttons we have. */ - switch(NumberOfButtons) { - case 0x0000: /* Other than 2 buttons, assume three */ - mouse->Button.TwoButtonP = FALSE; - mouse->Handler = &ThreeButtonHandler; - break; - case 0x0002: /* Two buttons. */ - mouse->Button.TwoButtonP = TRUE; - mouse->Handler = &TwoButtonHandler; - break; - case 0x0003: /* Three buttons. */ - mouse->Button.TwoButtonP = FALSE; - mouse->Handler = &ThreeButtonHandler; - break; - case 0xffff: /* Two buttons. */ - mouse->Button.TwoButtonP = TRUE; - mouse->Handler = &TwoButtonHandler; - break; - default: /* Strange case, assume three. */ - mouse->Button.TwoButtonP = FALSE; - mouse->Handler = &ThreeButtonHandler; - break; + } else /* Determine how many buttons we have. */ + switch (NumberOfButtons) { + case 0x0000: /* Other than 2 buttons, assume three */ + mouse->Button.TwoButtonP = FALSE; + mouse->Handler = &ThreeButtonHandler; + break; + case 0x0002: /* Two buttons. */ + mouse->Button.TwoButtonP = TRUE; + mouse->Handler = &TwoButtonHandler; + break; + case 0x0003: /* Three buttons. */ + mouse->Button.TwoButtonP = FALSE; + mouse->Handler = &ThreeButtonHandler; + break; + case 0xffff: /* Two buttons. */ + mouse->Button.TwoButtonP = TRUE; + mouse->Handler = &TwoButtonHandler; + break; + default: /* Strange case, assume three. */ + mouse->Button.TwoButtonP = FALSE; + mouse->Handler = &ThreeButtonHandler; + break; } } - /* mouse->timestamp = ((*LASTUSERACTION68k& 0xffffff) + Lisp_world); */ +/* mouse->timestamp = ((*LASTUSERACTION68k& 0xffffff) + Lisp_world); */ #elif XWINDOW -#endif /* DOS or XWINDOW */ +#endif /* DOS or XWINDOW */ } diff --git a/src/mvs.c b/src/mvs.c old mode 100755 new mode 100644 index 0a64739..4d09764 --- a/src/mvs.c +++ b/src/mvs.c @@ -1,11 +1,6 @@ /* $Id: mvs.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: mvs.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyright (C) Venue"; - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -20,8 +15,6 @@ static char *id = "$Id: mvs.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyright #include "version.h" - - /************************************************************************/ /* */ /* M U L T I P L E - V A L U E S U P P O R T */ @@ -33,7 +26,6 @@ static char *id = "$Id: mvs.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyright #include - #include "lispemul.h" #include "lispmap.h" #include "lspglob.h" @@ -47,15 +39,13 @@ static char *id = "$Id: mvs.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyright #include "inlnPS2.h" #endif /* AIXPS2 */ - /* to optionally swap the fnhead field of a frame */ +/* to optionally swap the fnhead field of a frame */ #ifdef BIGVM #define SWA_FNHEAD #else #define SWA_FNHEAD swapx #endif /* BIGVM */ - - LispPTR MVLIST_index; LispPTR make_value_list(int argcount, LispPTR *argarray); @@ -69,111 +59,102 @@ void simulate_unbind(FX2 *frame, int unbind_count, FX2 *returner); /* */ /****************************************************************/ -LispPTR values (int arg_count, register LispPTR *args) -{ - FX2 *caller, *prevcaller=0, *immediate_caller=0; - ByteCode *pc; - int unbind_count=0; - struct fnhead *fnhead; - int byteswapped; /* T if on 386 & reswapped code block */ - short opcode; +LispPTR values(int arg_count, register LispPTR *args) { + FX2 *caller, *prevcaller = 0, *immediate_caller = 0; + ByteCode *pc; + int unbind_count = 0; + struct fnhead *fnhead; + int byteswapped; /* T if on 386 & reswapped code block */ + short opcode; - caller = (FX2 *) CURRENTFX; - immediate_caller = caller; + caller = (FX2 *)CURRENTFX; + immediate_caller = caller; newframe: - if (caller == immediate_caller) - { - fnhead = (struct fnhead *) FuncObj; - pc = (ByteCode *) PC+3; /* to skip the miscn opcode we're in now */ - } - else - { - fnhead = (struct fnhead *) - Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader)); - pc = (ByteCode *)fnhead+(caller->pc); - } + if (caller == immediate_caller) { + fnhead = (struct fnhead *)FuncObj; + pc = (ByteCode *)PC + 3; /* to skip the miscn opcode we're in now */ + } else { + fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader)); + pc = (ByteCode *)fnhead + (caller->pc); + } #ifdef ISC - if(!fnhead->byteswapped) - { - byte_swap_code_block(fnhead); - fnhead->byteswapped=1; - } + if (!fnhead->byteswapped) { + byte_swap_code_block(fnhead); + fnhead->byteswapped = 1; + } #endif /* ISC */ - - - newpc: #ifdef ISC - opcode = (short)((unsigned char) *((char *)pc)); + opcode = (short)((unsigned char)*((char *)pc)); #else - opcode = (short)((unsigned char)GETBYTE((char *)pc)); + opcode = (short)((unsigned char)GETBYTE((char *)pc)); #endif - switch (opcode) - { - case opc_RETURN: - case opc_SLRETURN: prevcaller = caller; - caller = (FX2 *) (Stackspace+(unsigned)(GETCLINK(caller))); - goto newframe; + switch (opcode) { + case opc_RETURN: + case opc_SLRETURN: + prevcaller = caller; + caller = (FX2 *)(Stackspace + (unsigned)(GETCLINK(caller))); + goto newframe; - case opc_FN1: if (MVLIST_index == Get_code_AtomNo(pc+1)) - { - if (unbind_count > 0) - simulate_unbind(caller, unbind_count, prevcaller); + case opc_FN1: + if (MVLIST_index == Get_code_AtomNo(pc + 1)) { + if (unbind_count > 0) simulate_unbind(caller, unbind_count, prevcaller); #ifndef BIGATOMS - /* would add 3 to PC, but miscn return code does.*/ - if (caller == immediate_caller) PC = pc; + /* would add 3 to PC, but miscn return code does.*/ + if (caller == immediate_caller) PC = pc; #else - /* BUT 3's not enough for big atoms, so add diff between FN op size & MISCN op size */ - if (caller == immediate_caller) PC = pc + (FN_OPCODE_SIZE-3); + /* BUT 3's not enough for big atoms, so add diff between FN op size & MISCN op size */ + if (caller == immediate_caller) PC = pc + (FN_OPCODE_SIZE - 3); #endif /* BIGATOMS */ - else caller->pc = (UNSIGNED)pc+ FN_OPCODE_SIZE-(UNSIGNED)fnhead; - return(make_value_list(arg_count, args)); - } - break; - - case opc_UNBIND: pc += 1; - unbind_count += 1; - goto newpc; - - case opc_JUMPX: { - register short displacement; -#ifdef ISC - displacement = (short) (*((char *)pc+1)); -#else - displacement = (short) (GETBYTE((char *)pc+1)); -#endif - if (displacement >= 128) displacement -= 256; - pc += displacement; - goto newpc; - } - - case opc_JUMPXX: { - register int displacement; - displacement = (int) Get_code_DLword(pc+1); - if (displacement >= 32768) displacement -= 65536; - pc += displacement; - goto newpc; - } - default: if ((opcode >= opc_JUMP) && (opcode < opc_FJUMP)) - { - pc += 2 + opcode - opc_JUMP; - goto newpc; - } + else + caller->pc = (UNSIGNED)pc + FN_OPCODE_SIZE - (UNSIGNED)fnhead; + return (make_value_list(arg_count, args)); } + break; - /*****************************************/ - /* Default case: Return a single value. */ - /*****************************************/ + case opc_UNBIND: + pc += 1; + unbind_count += 1; + goto newpc; - if (arg_count>0) return(args[0]); - else return(NIL_PTR); + case opc_JUMPX: { + register short displacement; +#ifdef ISC + displacement = (short)(*((char *)pc + 1)); +#else + displacement = (short)(GETBYTE((char *)pc + 1)); +#endif + if (displacement >= 128) displacement -= 256; + pc += displacement; + goto newpc; + } + + case opc_JUMPXX: { + register int displacement; + displacement = (int)Get_code_DLword(pc + 1); + if (displacement >= 32768) displacement -= 65536; + pc += displacement; + goto newpc; + } + default: + if ((opcode >= opc_JUMP) && (opcode < opc_FJUMP)) { + pc += 2 + opcode - opc_JUMP; + goto newpc; + } } + /*****************************************/ + /* Default case: Return a single value. */ + /*****************************************/ - + if (arg_count > 0) + return (args[0]); + else + return (NIL_PTR); +} /****************************************************************/ /* */ @@ -183,110 +164,102 @@ newpc: /* */ /****************************************************************/ -LispPTR values_list (int arg_count, register LispPTR *args) -{ - FX2 *caller, *prevcaller=0, *immediate_caller=0; - ByteCode *pc; - int unbind_count=0; - struct fnhead *fnhead; - short opcode; +LispPTR values_list(int arg_count, register LispPTR *args) { + FX2 *caller, *prevcaller = 0, *immediate_caller = 0; + ByteCode *pc; + int unbind_count = 0; + struct fnhead *fnhead; + short opcode; - caller = (FX2 *) CURRENTFX; - immediate_caller = caller; + caller = (FX2 *)CURRENTFX; + immediate_caller = caller; newframe: - if (caller == immediate_caller) - { - fnhead = (struct fnhead *) FuncObj; - pc = (ByteCode *) PC+3; /* Skip over the miscn opcode we're in now */ - } - else - { - fnhead = (struct fnhead *) - Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader)); - pc = (ByteCode *)fnhead+(caller->pc); - } - - -#ifdef ISC - if(!fnhead->byteswapped) - { - byte_swap_code_block(fnhead); - fnhead->byteswapped=1; - } -#endif /* ISC */ - - - - -newpc: -#ifdef ISC - opcode = (short)((unsigned char) *((char *)pc)); -#else - opcode = (short)((unsigned char)GETBYTE((char *)pc)); -#endif - switch (opcode) - { - case opc_RETURN: - case opc_SLRETURN: prevcaller = caller; - caller = (FX2 *) (Stackspace+(int)(GETCLINK(caller))); - goto newframe; - - case opc_FN1: if (MVLIST_index == Get_code_AtomNo(pc+1)) - { - if (unbind_count > 0) - simulate_unbind(caller, unbind_count, prevcaller); - /* would add 3 to PC, but miscn ret code does. */ -#ifndef BIGATOMS - if (caller == immediate_caller) PC = pc; -#else - /* BUT 3's not enough for big atoms, so add 1 */ - if (caller == immediate_caller) PC = pc + (FN_OPCODE_SIZE-3); -#endif /* BIGATOMS */ - - else caller->pc = (UNSIGNED)pc+ FN_OPCODE_SIZE-(UNSIGNED)fnhead; - return(args[0]); - } - break; - - case opc_UNBIND: pc += 1; - unbind_count += 1; - goto newpc; - - case opc_JUMPX: { - register short displacement; -#ifdef ISC - displacement = (short) (*((char *)pc+1)); -#else - displacement = (short) (GETBYTE((char *)pc+1)); -#endif - if (displacement >= 128) displacement -= 256; - pc += displacement; - goto newpc; - } - - case opc_JUMPXX: { - register int displacement; - displacement = (int) Get_code_DLword(pc+1); - if (displacement >= 32768) displacement -= 65536; - pc += displacement; - goto newpc; - } - default: if ((opcode >= opc_JUMP) && (opcode < opc_FJUMP)) - { - pc += 2 + opcode - opc_JUMP; - goto newpc; - } - } - - /*****************************************/ - /* Default case: Return a single value. */ - /*****************************************/ - - if (Listp(args[0])) return(car(args[0])); - else return(args[0]); + if (caller == immediate_caller) { + fnhead = (struct fnhead *)FuncObj; + pc = (ByteCode *)PC + 3; /* Skip over the miscn opcode we're in now */ + } else { + fnhead = (struct fnhead *)Addr68k_from_LADDR(POINTERMASK & SWA_FNHEAD((int)caller->fnheader)); + pc = (ByteCode *)fnhead + (caller->pc); } +#ifdef ISC + if (!fnhead->byteswapped) { + byte_swap_code_block(fnhead); + fnhead->byteswapped = 1; + } +#endif /* ISC */ + +newpc: +#ifdef ISC + opcode = (short)((unsigned char)*((char *)pc)); +#else + opcode = (short)((unsigned char)GETBYTE((char *)pc)); +#endif + switch (opcode) { + case opc_RETURN: + case opc_SLRETURN: + prevcaller = caller; + caller = (FX2 *)(Stackspace + (int)(GETCLINK(caller))); + goto newframe; + + case opc_FN1: + if (MVLIST_index == Get_code_AtomNo(pc + 1)) { + if (unbind_count > 0) simulate_unbind(caller, unbind_count, prevcaller); +/* would add 3 to PC, but miscn ret code does. */ +#ifndef BIGATOMS + if (caller == immediate_caller) PC = pc; +#else + /* BUT 3's not enough for big atoms, so add 1 */ + if (caller == immediate_caller) PC = pc + (FN_OPCODE_SIZE - 3); +#endif /* BIGATOMS */ + + else + caller->pc = (UNSIGNED)pc + FN_OPCODE_SIZE - (UNSIGNED)fnhead; + return (args[0]); + } + break; + + case opc_UNBIND: + pc += 1; + unbind_count += 1; + goto newpc; + + case opc_JUMPX: { + register short displacement; +#ifdef ISC + displacement = (short)(*((char *)pc + 1)); +#else + displacement = (short)(GETBYTE((char *)pc + 1)); +#endif + if (displacement >= 128) displacement -= 256; + pc += displacement; + goto newpc; + } + + case opc_JUMPXX: { + register int displacement; + displacement = (int)Get_code_DLword(pc + 1); + if (displacement >= 32768) displacement -= 65536; + pc += displacement; + goto newpc; + } + default: + if ((opcode >= opc_JUMP) && (opcode < opc_FJUMP)) { + pc += 2 + opcode - opc_JUMP; + goto newpc; + } + } + + /*****************************************/ + /* Default case: Return a single value. */ + /*****************************************/ + + if (Listp(args[0])) + return (car(args[0])); + else + return (args[0]); +} /************************************************************************/ /* */ @@ -299,19 +272,13 @@ newpc: /* */ /************************************************************************/ -LispPTR make_value_list(int argcount, LispPTR *argarray) -{ - register LispPTR result = NIL_PTR; - register int i; - if (argcount == 0) return(NIL_PTR); - for (i = argcount-1; i>=0; i--) - { - result = cons(argarray[i], result); - } - return(result); - } - - +LispPTR make_value_list(int argcount, LispPTR *argarray) { + register LispPTR result = NIL_PTR; + register int i; + if (argcount == 0) return (NIL_PTR); + for (i = argcount - 1; i >= 0; i--) { result = cons(argarray[i], result); } + return (result); +} /************************************************************************/ /* */ @@ -324,32 +291,31 @@ LispPTR make_value_list(int argcount, LispPTR *argarray) /* */ /************************************************************************/ -void simulate_unbind(FX2 *frame, int unbind_count, FX2 *returner) -{ - int unbind; - LispPTR *stackptr; - DLword *nextblock; - stackptr = (LispPTR *) (Stackspace+frame->nextblock); - nextblock = (DLword *) stackptr; - for (unbind = 0; unbind=0);); /* find the binding mark */ - value = (int)*stackptr; - lastpvar = (LispPTR *) ((DLword *)frame + FRAMESIZE + 2 + GetLoWord(value));; - bindnvalues = (~value)>>16; - for(value=bindnvalues; --value >= 0;){*--lastpvar = 0xffffffff;} - /* This line caused \NSMAIL.READ.HEADING to smash memory, */ - /* so I removed it 21 Jul 91 --JDS. This was the only */ - /* difference between this function and the UNWIND code */ - /* in inlineC.h */ -/* MAKEFREEBLOCK(stackptr, (DLword *)stackptr-nextblock); */ - } - if (returner) returner->fast = 0; /* since we've destroyed congituity - /* in the stack, but that only - matters if there's a return. */ +void simulate_unbind(FX2 *frame, int unbind_count, FX2 *returner) { + int unbind; + LispPTR *stackptr; + DLword *nextblock; + stackptr = (LispPTR *)(Stackspace + frame->nextblock); + nextblock = (DLword *)stackptr; + for (unbind = 0; unbind < unbind_count; unbind++) { + register int value; + register LispPTR *lastpvar; + int bindnvalues; + for (; ((int)*--stackptr >= 0);) + ; /* find the binding mark */ + value = (int)*stackptr; + lastpvar = (LispPTR *)((DLword *)frame + FRAMESIZE + 2 + GetLoWord(value)); + ; + bindnvalues = (~value) >> 16; + for (value = bindnvalues; --value >= 0;) { *--lastpvar = 0xffffffff; } + /* This line caused \NSMAIL.READ.HEADING to smash memory, */ + /* so I removed it 21 Jul 91 --JDS. This was the only */ + /* difference between this function and the UNWIND code */ + /* in inlineC.h */ + /* MAKEFREEBLOCK(stackptr, (DLword *)stackptr-nextblock); */ } - - + if (returner) + returner->fast = 0; /* since we've destroyed congituity + /* in the stack, but that only + matters if there's a return. */ +} diff --git a/src/ocr.c b/src/ocr.c old mode 100755 new mode 100644 index 9d196a8..1b3bf65 --- a/src/ocr.c +++ b/src/ocr.c @@ -1,8 +1,6 @@ /* $Id: ocr.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: ocr.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +15,6 @@ static char *id = "$Id: ocr.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyright #include "version.h" - #ifdef OCR #include @@ -45,14 +42,14 @@ static char *id = "$Id: ocr.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyright * Socket descriptor to communicate with the OCR process */ -int OCR_sock = -1; -u_int shifted_OCR_sock; +int OCR_sock = -1; +u_int shifted_OCR_sock; /* * OCR process ID */ -int OCR_procID = -1; +int OCR_procID = -1; /* * Lisp I/F to indicate wait status. @@ -65,7 +62,7 @@ LispPTR *OCR_state_word = NULL; * Other Lisp I/F area */ -struct ocr_image_info *OCR_iminfo_block = NULL; +struct ocr_image_info *OCR_iminfo_block = NULL; /* * Image size cache @@ -77,38 +74,41 @@ static u_int OCR_image_size = 0; * Local Definitions for clarify code */ -#ifndef MIN -#define MIN(a,b) (((a)<(b))?(a):(b)) +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef MAX -#define MAX(a,b) (((a)>(b))?(a):(b)) +#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 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 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 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 +#define FD_BLOCK 1 +#define FD_NON_BLOCK 0 /* * Local Functions @@ -123,7 +123,6 @@ 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: * @@ -136,411 +135,359 @@ static LispPTR ocr_get_read_result(); * unwind protected contour to reset OCR. */ -int -ocr_comm(args) -LispPTR *args; +int ocr_comm(args) LispPTR *args; { - int com; - LispPTR val; + 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; + 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 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 -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; - case 0: - default: - val = NIL; - } - } - 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 DO_IMG_INFO: + if (OCR_sock < 0) { + val = NIL; + } else { + OCR_iminfo_block = (struct ocr_image_info *)Addr68k_from_LADDR(args[2]); - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; + switch (ocr_iminfo((struct ocr_up_para *)Addr68k_from_LADDR(args[1]))) { + case 1: val = ATOM_T; break; - case 0: - default: - val = NIL; - } - } - break; + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; - case DO_IMG_UPLD: - { - BITMAP *bmp; - int len; + case 0: + default: val = NIL; + } + } + break; - bmp = (BITMAP *)Addr68k_from_LADDR(args[1]); + case DO_IMG_UPLD: { + BITMAP *bmp; + int len; - len = ocr_bulk_read(OCR_sock, - (char *)Addr68k_from_LADDR(bmp->bmbase), - 10); - val = (len < 0) ? NIL : ATOM_T; - } - break; + bmp = (BITMAP *)Addr68k_from_LADDR(args[1]); - case DO_SET_RPARA: - { - int cnt; - u_char *pp; + len = ocr_bulk_read(OCR_sock, (char *)Addr68k_from_LADDR(bmp->bmbase), 10); + val = (len < 0) ? NIL : ATOM_T; + } break; - pp = (u_char *)Addr68k_from_LADDR(args[1]); - N_GETNUMBER(args[2], cnt, INVAL); + case DO_SET_RPARA: { + int cnt; + u_char *pp; - switch (ocr_set_rpara(pp, cnt)) { - case 1: - val = ATOM_T; - break; + pp = (u_char *)Addr68k_from_LADDR(args[1]); + N_GETNUMBER(args[2], cnt, INVAL); - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; + switch (ocr_set_rpara(pp, cnt)) { + case 1: val = ATOM_T; break; - case 0: - default: - val = NIL; - } - } - break; + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; - case DO_CLR_RPARA: - { - switch(ocr_clr_rpara()) { - case 1: - val = ATOM_T; - break; + case 0: + default: val = NIL; + } + } break; - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; + case DO_CLR_RPARA: { + switch (ocr_clr_rpara()) { + case 1: val = ATOM_T; break; - case 0: - default: - val = NIL; - } - } - break; + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; - case DO_READ: - { - switch(ocr_read()) { - case 1: - val = ATOM_T; - break; + case 0: + default: val = NIL; + } + } break; - case -1: - val = NIL; - SET_WAIT_FLG(OCR_ST_PROC_DEAD); - ocr_irq(); - break; + case DO_READ: { + switch (ocr_read()) { + case 1: val = ATOM_T; break; - case 0: - default: - val = NIL; - } - } - break; + case -1: + val = NIL; + SET_WAIT_FLG(OCR_ST_PROC_DEAD); + ocr_irq(); + break; - case DO_GET_RESULT: - if (OCR_sock < 0) { - val = NIL; - } else { - val = ocr_get_read_result(OCR_sock); - } - break; + case 0: + default: val = NIL; + } + } break; - case DO_CLOSE: - if (OCR_sock < 0) { - val = NIL; - } else { - ocr_close(); - val = ATOM_T; - } - break; + case DO_GET_RESULT: + if (OCR_sock < 0) { + val = NIL; + } else { + val = ocr_get_read_result(OCR_sock); + } + 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_CLOSE: + if (OCR_sock < 0) { + val = NIL; + } else { + ocr_close(); + val = ATOM_T; + } + break; - case DO_TEST: - { - extern DLword *createcell68k(); - u_char *np, *np2; - LispPTR lp; + 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; - 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; + case DO_TEST: { + extern DLword *createcell68k(); + u_char *np, *np2; + LispPTR lp; - default: - error("ocr_comm: Invalid Comm byte"); - } - return(val); - INVAL: - return(NIL); + 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 isssue 'O' command to open OCR device. */ -static int -ocr_open() -{ - int cnt; - u_char pkt[PKTLEN]; +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; - } + 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); + 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; - } - } + 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; +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; - } + 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); + 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; - } + 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; - } + 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); + 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; - } + 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; +static int ocr_block_mode(fd, doblock) int fd; +int doblock; { - int flags; - - if (fd < 0) return 0; + int flags; - flags = fcntl(fd, F_GETFL, 0); - if (flags < 0) return 0; + if (fd < 0) return 0; - if (doblock) { - flags &= ~FNDELAY; - } else { - flags |= FNDELAY; - } + flags = fcntl(fd, F_GETFL, 0); + if (flags < 0) return 0; - if (fcntl(fd, F_SETFL, flags) < 0) return 0; + if (doblock) { + flags &= ~FNDELAY; + } else { + flags |= FNDELAY; + } + + if (fcntl(fd, F_SETFL, flags) < 0) return 0; + + return 1; +} - 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)); +static void ocr_device_reset() { + if (OCR_sock >= 0) { + u_char pkt[PKTLEN]; - sleep(1); - } - return; + 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; +static int ocr_wait() { + u_char pkt[4]; + int status; - if (OCR_procID > 0) { + if (OCR_procID > 0) { + pkt[0] = 'w'; + pkt[1] = OCR_procID >> 8 & 0xFF; + pkt[2] = OCR_procID & 0xFF; - pkt[0] = 'w'; - pkt[1] = OCR_procID >> 8 & 0xFF; - pkt[2] = OCR_procID & 0xFF; - - write(UnixPipeOut, pkt, sizeof(pkt)); - read(UnixPipeIn, pkt, sizeof(pkt)); + write(UnixPipeOut, pkt, sizeof(pkt)); + read(UnixPipeIn, pkt, sizeof(pkt)); - status = pkt[0] << 24 | pkt[1] << 16 | pkt[2] << 8 | pkt[3]; + 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; + 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(); +static void ocr_close() { + int status, pid; - 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; + 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 * @@ -548,44 +495,38 @@ ocr_close() * without waiting device to finish scanning. */ -static int -ocr_scan(sp) -struct ocr_scan_para *sp; +static int ocr_scan(sp) struct ocr_scan_para *sp; { - int cnt; - u_char pkt[PKTLEN]; + int cnt; + u_char pkt[PKTLEN]; + pkt[0] = 'S'; + pkt[1] = 0; + pkt[2] = sizeof(struct ocr_scan_para); - 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 (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; + }); - 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); - 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; - } + 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 * @@ -594,130 +535,115 @@ struct ocr_scan_para *sp; * finish its work. */ -static int -ocr_iminfo(up) -struct ocr_up_para *up; +static int ocr_iminfo(up) struct ocr_up_para *up; { - int i, cnt; - u_char pkt[PKTLEN]; + int i, cnt; + u_char pkt[PKTLEN]; + pkt[0] = 'I'; + pkt[1] = 0; + pkt[2] = sizeof(struct ocr_up_para); - 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 (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; - }); + 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); - 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; - } + 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; +static int ocr_set_rpara(pp, num) register u_char *pp; +register int num; { - register int cnt; - u_char pkt[PKTLEN]; + 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); + pkt[0] = 'P'; + num = num * sizeof(struct ocr_read_para); + pkt[1] = num >> 8 & 0xFF; + pkt[2] = num & 0xFF; - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); + 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); - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); - if (cnt == sizeof(pkt) && pkt[0] == 1) { - return 1; - } else { - 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]; +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; - } + pkt[0] = 'C'; + pkt[1] = pkt[2] = 0; - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); + if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { return 0; } - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); - if (cnt == sizeof(pkt) && pkt[0] == 1) { - return 1; - } else { - 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 * @@ -726,37 +652,33 @@ ocr_clr_rpara() * finish its work. */ -static int -ocr_read() -{ - register int cnt; - u_char pkt[PKTLEN]; +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; - } + pkt[0] = 'R'; + pkt[1] = pkt[2] = 0; - IF_TIMEOUT({ - int i; - for (i = 0; i < 10; i++) { - if (ocr_wait()) return -1; - } - return 0; - }); + if (write(OCR_sock, pkt, sizeof(pkt)) != sizeof(pkt)) { return 0; } - S_TOUT_TIME(cnt = read(OCR_sock, pkt, sizeof(pkt)), 15); + IF_TIMEOUT({ + int i; + for (i = 0; i < 10; i++) { + if (ocr_wait()) return -1; + } + return 0; + }); - if (cnt == sizeof(pkt) && pkt[0] == 1) { - SET_WAIT_FLG(OCR_ST_READING) - return 1; - } else { - 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. * @@ -764,850 +686,774 @@ ocr_read() * Accoding 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; +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; + if (OCR_sock < 0) return; - case OCR_ST_UPLDING: - ocr_img_upld_finish(); - break; + switch (WAITING_REASON) { + case OCR_ST_SCANNING: ocr_scan_finish(); break; - case OCR_ST_READING: - ocr_read_finish(); - break; + case OCR_ST_UPLDING: ocr_img_upld_finish(); break; - default: - SET_WAIT_FLG(OCR_ST_FAIL); - - } - ocr_irq(); - return; + 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; +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; + 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(); +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; + 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]; +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; - }); + 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); - 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; +} - 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; - }); +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); + 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; + 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]; +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; - }); + 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); - 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; +} - 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 requst. */ -static void -ocr_irq() -{ - u_int *flagp; - extern LispPTR *IOINTERRUPTFLAGS_word; - extern LispPTR *IOINTERRUPTSTATE_word; - extern LispPTR *PENDINGINTERRUPT68k; +static void ocr_irq() { + u_int *flagp; + extern LispPTR *IOINTERRUPTFLAGS_word; + extern LispPTR *IOINTERRUPTSTATE_word; + extern LispPTR *PENDINGINTERRUPT68k; - if (OCR_sock < 0) return; + if (OCR_sock < 0) return; - flagp = (u_int *)Addr68k_from_LADDR(*IOINTERRUPTFLAGS_word); - *flagp = shifted_OCR_sock; + flagp = (u_int *)Addr68k_from_LADDR(*IOINTERRUPTFLAGS_word); + *flagp = shifted_OCR_sock; - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word)) - ->IOInterrupt = 1; + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->IOInterrupt = 1; - *PENDINGINTERRUPT68k = ATOM_T; - Irq_Stk_End=Irq_Stk_Check=0; + *PENDINGINTERRUPT68k = ATOM_T; + Irq_Stk_End = Irq_Stk_Check = 0; - return; + return; } - + /* * Bulk data transfer */ -static int -ocr_bulk_read(fd, buf, tout) -int fd, tout; -register char *buf; +static int ocr_bulk_read(fd, buf, tout) int fd, tout; +register char *buf; { - register u_int cnt, len = 0; - struct bd_header hd; + register u_int cnt, len = 0; + struct bd_header hd; - SETJMP(-1); + 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; - } + 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; +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; + register u_int cnt, len, buflen; + struct bd_header hd; + u_char *buf, *ptr; + LispPTR val; - SETJMP(NIL); + SETJMP(NIL); - S_TOUT_TIME(cnt = read(fd, &hd, sizeof(struct bd_header)), 1); - val = 0; - ptr = buf = NULL; - buflen = 0; + 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); + 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, +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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 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, + 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, + 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, + 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, + 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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 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, + 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, + 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, + 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, + 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, + 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, + 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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 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, 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, + 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, + 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, + 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, + 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, 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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, + 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, + 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, + 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, + 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, + 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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 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, + 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, + 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, + 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, + 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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 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, 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, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 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, 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, 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, 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, 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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 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, 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, + 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, + 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, + 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, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 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, 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, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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, +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, 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, + 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, + 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, + 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, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, + 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, 0x2223, - 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;\ - }\ +#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--; + } } -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 old mode 100755 new mode 100644 index 3490dc9..0ce4e85 --- a/src/ocrproc.c +++ b/src/ocrproc.c @@ -1,8 +1,7 @@ -/* $Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyr #include "version.h" - #ifdef OCR #include @@ -32,8 +30,8 @@ static char *id = "$Id: ocrproc.c,v 1.2 1999/01/03 02:07:27 sybalsky Exp $ Copyr * 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; +static struct ocr_scan_para OCR_scan_para; +static struct ocr_up_para OCR_up_para; /* * Image size cache @@ -51,23 +49,23 @@ static int OCR_read_regions = 0; * Socket fd to communicate the primary emulator process */ -int OCR_sv = -1; +int OCR_sv = -1; /* * Fd for the OCR device file */ -int OCR_fd = -1; +int OCR_fd = -1; /* * Local definitions for clarify code */ -#ifndef MIN -#define MIN(a,b) (((a)<(b))?(a):(b)) +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef MAX -#define MAX(a,b) (((a)>(b))?(a):(b)) +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif /* @@ -80,7 +78,7 @@ 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 * @@ -100,791 +98,579 @@ static void ocr_proc_post_read(); * notify the completion of the initial request. */ -void -ocr_proc(ppid) -pid_t ppid; +void ocr_proc(ppid) pid_t ppid; { - int len, postponed = 0; - u_char pkt[PKTLEN]; - static u_char epkt[EPKTLEN]; /* Maximum size of extra packet */ + 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(); + 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; + 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); - } - } - } - } - } + 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); +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(pkt, epkt, reasonp) -u_char pkt[], epkt[]; -int *reasonp; +static int ocr_handle_comm(pkt, epkt, reasonp) u_char pkt[], 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; + int len; - 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; + *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 'P': /* Set read params */ - { - int len; + 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; - 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 '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 '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 'P': /* Set read params */ + { + int len; - case 'A': - if (OCR_fd > 0) ioctl(OCR_fd, OCR_ABORT); - exit(1); + 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; +} - 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(reason, ppid) -int reason; -pid_t ppid; +static void ocr_do_postponed_work(reason, ppid) int reason; +pid_t ppid; { - u_char pkt[PKTLEN]; + 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; + 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_UPLDING: { + struct ocr_image_info iminfo; - 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; + 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; - default: - pkt[0] = 0; - write(OCR_sv, pkt, sizeof(pkt)); - notify_ready(ppid); - break; - } - return; + 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(ppid) -pid_t ppid; -{ - kill(ppid, SIGUSR1); -} - +static void notify_ready(ppid) pid_t ppid; +{ kill(ppid, SIGUSR1); } + /* * Put the socket descriptor into blocking mode, and extend * the buffer size. */ -static int -ocr_init_sv() -{ +static int ocr_init_sv() { + int flags; - int flags; - - if (OCR_sv < 0) return 0; + if (OCR_sv < 0) return 0; + + flags = fcntl(OCR_sv, F_GETFL, 0); + if (flags < 0) { + perror("ocr_init_sv: fcntl"); + return 0; + } + flags &= ~FNDELAY; + if (fcntl(OCR_sv, F_SETFL, flags) < 0) { + perror("ocr_init_sv: fcntl 2"); + return 0; + } + return 1; +} - flags = fcntl(OCR_sv, F_GETFL, 0); - if (flags < 0) { - perror("ocr_init_sv: fcntl"); - return 0; - } - flags &= ~FNDELAY; - 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; +static void ocr_init_signal() { + struct sigvec sv; - sv.sv_flags = sv.sv_mask = 0; - sv.sv_handler = ocr_proc_exit; + 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; + 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(spp) -struct ocr_scan_para *spp; +static int ocr_proc_scan(spp) struct ocr_scan_para *spp; { - struct scan_params sp; + 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; - } + 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(upp, infop) -struct ocr_up_para *upp; -struct ocr_image_info *infop; +static int ocr_proc_iminfo(upp, infop) 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; */ + struct img_params upara; + struct ocr_stat st; - 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; + 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; - return 1; - + 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(rpp, len) -register struct ocr_read_para *rpp; -int len; +static int ocr_proc_set_rpara(rpp, len) 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; + register int cnt = len; + struct read_params rpara; - if (ioctl(OCR_fd, OCR_READ_PARA, &rpara) < 0) { - return 0; - } - } - OCR_read_regions += len; - return 1; - } + 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; - } +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; - } +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(iminfop, ppid) -struct ocr_image_info *iminfop; -pid_t ppid; +static void ocr_proc_img_upload(iminfop, ppid) 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; + register int len, resid, firsttime = 1; + int cnt; + char rbuf[65536], pkt[PKTLEN]; + register char *ptr; + struct bd_header hd; - resid = OCR_image_size; + 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; + 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, @@ -892,122 +678,114 @@ pid_t ppid; * compatible with ocr_bulk_read in 'ocr.c'. */ -static void -ocr_proc_post_read(ppid) -pid_t ppid; +static void ocr_proc_post_read(ppid) 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; + 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 (OCR_fd < 0) goto fail; - if (ioctl(OCR_fd, OCR_STAT, &st) < 0 || - st.state != STATE_RDING) 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); + 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; + 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]; + 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; - } + 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; + 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; + 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; - } +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(sp, dp, len) -register u_char *sp, *dp; -register int len; +static int ocr_conv_read_data(sp, dp, len) register u_char *sp, *dp; +register int len; { - bcopy(sp, dp, len); - return(len); + bcopy(sp, dp, len); + return (len); } - + /**************************************************** **************************************************** - + #define INC_SP(pos) {\ - if (--len == 0) {\ - statep->jmp = (pos);\ - return(amt);\ - } else {\ - sp++;\ - }\ + if (--len == 0) {\ + statep->jmp = (pos);\ + return(amt);\ + } else {\ + sp++;\ + }\ } #define CONV_CODE_BLOCK { - static int pos, hi, lo; + 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 - 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(sp, dp, len, statep) @@ -1015,128 +793,127 @@ register u_char *sp, *dp; register int len; struct parse_state *statep; { - /+ - * for now... - +/ + /+ + * for now... + +/ - bcopy(sp, dp, len); - return(len); + bcopy(sp, dp, len); + return(len); - switch (statep->jmp) { - case POS1: goto pos1; - } + 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) - } + 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 +/ - } - } + 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/oether.c b/src/oether.c old mode 100755 new mode 100644 index 975680d..42212a5 --- a/src/oether.c +++ b/src/oether.c @@ -1,9 +1,7 @@ -/* $Id: oether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: oether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: oether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,7 +16,6 @@ static char *id = "$Id: oether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ Copyri #include "version.h" - #include #include #ifndef DOS @@ -58,61 +55,77 @@ static char *id = "$Id: oether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ Copyri #include "ether.h" #include "dbprint.h" -u_int EtherReadFds; +u_int EtherReadFds; -int ether_fd = -1; /* file descriptor for ether socket */ -u_char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address of this node */ +int ether_fd = -1; /* file descriptor for ether socket */ +u_char ether_host[6] = {0, 0, 0, 0, 0, 0}; /* 48 bit address of this node */ u_char broadcast[6] = {255, 255, 255, 255, 255, 255}; -int ether_bsize = 0; /* if nonzero then a receive is pending */ -u_char *ether_buf; /* address of receive buffer */ -u_char nit_buf[3000]; /* the current chunk read from NIT (one packet) */ +int ether_bsize = 0; /* if nonzero then a receive is pending */ +u_char *ether_buf; /* address of receive buffer */ +u_char nit_buf[3000]; /* the current chunk read from NIT (one packet) */ extern LispPTR *PENDINGINTERRUPT68k; -extern u_int LispReadFds; +extern u_int LispReadFds; int ETHEREventCount = 0; -#define PacketTypeIP 0x0800 -#define PacketTypeARP 0x0806 -#define PacketTypeRARP 0x8035 -#define PacketTypeXNS 0x0600 -#define PacketTypePUP 0x0200 -#define PacketType3TO10 0x0201 +#define PacketTypeIP 0x0800 +#define PacketTypeARP 0x0806 +#define PacketTypeRARP 0x8035 +#define PacketTypeXNS 0x0600 +#define PacketTypePUP 0x0200 +#define PacketType3TO10 0x0201 #ifndef NOETHER #ifdef OS4 /* the receiving packetfilter structure */ /* if this is changed, be sure to get the references to it in init_ether - and check the length (the second entry in the structure) */ -struct packetfilt goodpf = {0, 29,{ -ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeIP, /* punt if PacketTypeIP */ -ENF_PUSHWORD+6, ENF_PUSHLIT+ENF_CNOR, PacketTypeARP, /* or PacketTypeARP */ -ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 8, /* check our addr */ -ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 11, /* which is filled in */ -ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 14, /* in init_ether */ -ENF_AND, ENF_AND, -ENF_PUSHWORD, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* check broadcast */ -ENF_PUSHWORD+1, ENF_PUSHLIT+ENF_EQ, 0xFFFF, /* which is all ones */ -ENF_PUSHWORD+2, ENF_PUSHLIT+ENF_EQ, 0xFFFF, -ENF_AND, ENF_AND, -ENF_OR}}; + and check the length (the second entry in the structure) */ +struct packetfilt goodpf = {0, + 29, + {ENF_PUSHWORD + 6, + ENF_PUSHLIT + ENF_CNOR, + PacketTypeIP, /* punt if PacketTypeIP */ + ENF_PUSHWORD + 6, + ENF_PUSHLIT + ENF_CNOR, + PacketTypeARP, /* or PacketTypeARP */ + ENF_PUSHWORD, + ENF_PUSHLIT + ENF_EQ, + 8, /* check our addr */ + ENF_PUSHWORD + 1, + ENF_PUSHLIT + ENF_EQ, + 11, /* which is filled in */ + ENF_PUSHWORD + 2, + ENF_PUSHLIT + ENF_EQ, + 14, /* in init_ether */ + ENF_AND, + ENF_AND, + ENF_PUSHWORD, + ENF_PUSHLIT + ENF_EQ, + 0xFFFF, /* check broadcast */ + ENF_PUSHWORD + 1, + ENF_PUSHLIT + ENF_EQ, + 0xFFFF, /* which is all ones */ + ENF_PUSHWORD + 2, + ENF_PUSHLIT + ENF_EQ, + 0xFFFF, + ENF_AND, + ENF_AND, + ENF_OR}}; /* a filter that rejects all packets to be used by ether_suspend and the - initial routine to flush out ether_fd */ + initial routine to flush out ether_fd */ struct packetfilt nopf = {0, 1, {ENF_PUSHZERO}}; #endif /* OS4 */ -int ether_in = 0; /* number of packets received */ -int ether_out = 0; /* number of packets sent */ +int ether_in = 0; /* number of packets received */ +int ether_out = 0; /* number of packets sent */ #ifndef OS4 static struct nit_ioc nioc; #endif /* OS4 */ #endif /* NOETHER */ - - - /************************************************************************/ /* */ /* e t h e r _ s u s p e n d */ @@ -122,38 +135,32 @@ static struct nit_ioc nioc; /* */ /************************************************************************/ -ether_suspend(args) - LispPTR args[]; - { +ether_suspend(args) LispPTR args[]; +{ #ifndef NOETHER #ifdef OS4 - static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; + static struct packetfilt pf = {0, 1, {ENF_PUSHZERO}}; #endif /* OS4 */ - if (ether_fd == -1) return(NIL); + if (ether_fd == -1) return (NIL); #ifndef OS4 - nioc.nioc_typetomatch = NT_NOTYPES; - if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) - { - printf("ether_suspend: ioctl failed\n"); -#else /* OS4 */ + nioc.nioc_typetomatch = NT_NOTYPES; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("ether_suspend: ioctl failed\n"); +#else /* OS4 */ - /* The trick here is to install a packet filter */ - /* that rejects all packets, I think... */ - if ( ioctl(ether_fd, NIOCSETF, &nopf) != 0) - { - perror("ether_suspend: NIOCSETF failed\n"); + /* The trick here is to install a packet filter */ + /* that rejects all packets, I think... */ + if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { + perror("ether_suspend: NIOCSETF failed\n"); #endif /* OS4 */ - return(NIL); - } + return (NIL); + } #endif /* NOETHER */ - return(ATOM_T); - } /* ether_suspend */ - - - + return (ATOM_T); +} /* ether_suspend */ /************************************************************************/ /* */ @@ -163,32 +170,27 @@ ether_suspend(args) /* */ /************************************************************************/ -ether_resume(args) - LispPTR args[]; - { - if (ether_fd == -1) return(NIL); +ether_resume(args) LispPTR args[]; +{ + if (ether_fd == -1) return (NIL); #ifndef NOETHER #ifndef OS4 - nioc.nioc_typetomatch = NT_ALLTYPES; - if ( ioctl(ether_fd, SIOCSNIT, &nioc) != 0) - { - printf("ether_resume: ioctl failed\n"); -#else /* OS4 */ + nioc.nioc_typetomatch = NT_ALLTYPES; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("ether_resume: ioctl failed\n"); +#else /* OS4 */ -/* Install a packet filter that accepts all packets we want */ - if ( ioctl(ether_fd, NIOCSETF, &goodpf) != 0) - { - perror("ether_resume: NIOCSETF failed\n"); + /* Install a packet filter that accepts all packets we want */ + if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { + perror("ether_resume: NIOCSETF failed\n"); #endif /* OS4 */ - return(NIL); - } + return (NIL); + } #endif /* NOETHER */ - return(ATOM_T); - } /* ether_resume */ - - + return (ATOM_T); +} /* ether_resume */ /************************************************************************/ /* */ @@ -198,33 +200,27 @@ ether_resume(args) /* */ /************************************************************************/ -ether_ctrlr(args) - LispPTR args[]; - { - if (ether_fd < 0) return(NIL); - return(ATOM_T); - } - - +ether_ctrlr(args) LispPTR args[]; +{ + if (ether_fd < 0) return (NIL); + return (ATOM_T); +} /********************************************************************** * ether_reset(args) 175/73/0 * reset ether controller and disable receipt of packets **********************************************************************/ -ether_reset(args) - LispPTR args[]; - { - int i; - char hostnumber[6]; - - if (ether_fd < 0) {return(NIL);} - /* JRB - host number check removed here; if ether_fd is open here, - net is on... */ - ether_bsize = 0; /* deactivate receiver */ - return(ATOM_T); - } /* ether_reset */ - +ether_reset(args) LispPTR args[]; +{ + int i; + char hostnumber[6]; + if (ether_fd < 0) { return (NIL); } + /* JRB - host number check removed here; if ether_fd is open here, + net is on... */ + ether_bsize = 0; /* deactivate receiver */ + return (ATOM_T); +} /* ether_reset */ /************************************************************************/ /* */ @@ -245,34 +241,29 @@ ether_reset(args) /* */ /************************************************************************/ -ether_get(args) - LispPTR args[]; - { - LispPTR MaxByteCount; - LispPTR result = NIL; - int interrupt_mask; +ether_get(args) LispPTR args[]; +{ + LispPTR MaxByteCount; + LispPTR result = NIL; + int interrupt_mask; #ifndef NOETHER - MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ - DBPRINT(("Ether Get. ")); - - interrupt_mask = sigblock(sigmask(SIGIO)); /* turn off ENET interrupts */ - if (ether_fd >= 0 && (MaxByteCount > 0)) - { - ether_buf = (u_char *)Addr68k_from_LADDR(args[1]); - ether_bsize = MaxByteCount; /* do this LAST; it enables reads */ - result = get_packet(); -/* check_ether(); for old behavior, move comment to above line */ - } - sigsetmask(interrupt_mask); /* interrupts back on */ -#endif /* NOETHER */ - - - return (result); - } /* ether_get */ + DBPRINT(("Ether Get. ")); + interrupt_mask = sigblock(sigmask(SIGIO)); /* turn off ENET interrupts */ + if (ether_fd >= 0 && (MaxByteCount > 0)) { + ether_buf = (u_char *)Addr68k_from_LADDR(args[1]); + ether_bsize = MaxByteCount; /* do this LAST; it enables reads */ + result = get_packet(); + /* check_ether(); for old behavior, move comment to above line */ + } + sigsetmask(interrupt_mask); /* interrupts back on */ +#endif /* NOETHER */ + return (result); +} /* ether_get */ /********************************************************************** * ether_send(args) 175/75/2 max_words,buffer_addr @@ -280,75 +271,64 @@ ether_get(args) **********************************************************************/ #define OFFSET sizeof(sa.sa_data) -ether_send(args) -LispPTR args[]; +ether_send(args) LispPTR args[]; { #ifndef NOETHER - /* - * Send a packet. - */ - struct sockaddr sa; + /* + * Send a packet. + */ + struct sockaddr sa; - LispPTR MaxByteCount; - char *BufferAddr; /* buffer address pointer(in native address) */ + LispPTR MaxByteCount; + char *BufferAddr; /* buffer address pointer(in native address) */ - MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ - BufferAddr = (char *)Addr68k_from_LADDR(args[1]); + MaxByteCount = 2 * (0xFFFF & args[0]); /* words to bytes */ + BufferAddr = (char *)Addr68k_from_LADDR(args[1]); - if (ether_fd >= 0) { + if (ether_fd >= 0) { #ifdef OS4 - struct strbuf ctl,data; + struct strbuf ctl, data; #endif /* OS4 */ - sa.sa_family = AF_UNSPEC; /* required for the NIT protocol */ - bcopy(BufferAddr, sa.sa_data, OFFSET); + sa.sa_family = AF_UNSPEC; /* required for the NIT protocol */ + bcopy(BufferAddr, sa.sa_data, OFFSET); #ifndef OS4 - if ( sendto(ether_fd, BufferAddr+OFFSET, MaxByteCount-OFFSET, 0, - &sa, sizeof(sa)) == (MaxByteCount-OFFSET) ); - else perror("Lisp Ether: sendto"); - ether_out++; -#else /* OS4 */ + if (sendto(ether_fd, BufferAddr + OFFSET, MaxByteCount - OFFSET, 0, &sa, sizeof(sa)) == + (MaxByteCount - OFFSET)) + ; + else + perror("Lisp Ether: sendto"); + ether_out++; +#else /* OS4 */ - ctl.maxlen = ctl.len = sizeof(sa); - ctl.buf = (char *)&sa; - data.maxlen = data.len = MaxByteCount - OFFSET; - data.buf = BufferAddr + OFFSET; - if(putmsg(ether_fd, &ctl, &data, 0)<0) { - perror("Ether_send lost"); - return(NIL); - } - else { - ether_out++; - /* flush the buffers to make sure the packet leaves */ - /* maybe we'll use the buffering module some day... */ - ioctl(ether_fd, I_FLUSH, FLUSHW); - } + ctl.maxlen = ctl.len = sizeof(sa); + ctl.buf = (char *)&sa; + data.maxlen = data.len = MaxByteCount - OFFSET; + data.buf = BufferAddr + OFFSET; + if (putmsg(ether_fd, &ctl, &data, 0) < 0) { + perror("Ether_send lost"); + return (NIL); + } else { + ether_out++; + /* flush the buffers to make sure the packet leaves */ + /* maybe we'll use the buffering module some day... */ + ioctl(ether_fd, I_FLUSH, FLUSHW); + } #endif /* OS4 */ - - } + } #endif /* NOETHER */ - - return(ATOM_T); + return (ATOM_T); } /* ether_send */ - - - /********************************************************************** * ether_setfilter(args) 175/75/1 filterbits * check whether a packet has come. if does, notify iocb **********************************************************************/ -ether_setfilter(args) - LispPTR args[]; - { - return(NIL); - } /* ether_setfilter */ - - - +ether_setfilter(args) LispPTR args[]; +{ return (NIL); } /* ether_setfilter */ /********************************************************************** * ether_debug() @@ -357,157 +337,135 @@ ether_setfilter(args) int estat[3]; -int *ether_debug() - { +int *ether_debug() { #ifndef NOETHER - estat[0] = 0; - if (ether_fd < 0) return(NIL); - printf("fd %d bsize %d buf %X icb %X in %d out %d\n ", - ether_fd, ether_bsize, (int)ether_buf, - IOPage->dlethernet[3],ether_in,ether_out); + estat[0] = 0; + if (ether_fd < 0) return (NIL); + printf("fd %d bsize %d buf %X icb %X in %d out %d\n ", ether_fd, ether_bsize, (int)ether_buf, + IOPage->dlethernet[3], ether_in, ether_out); #endif /* NOETHER */ - return(estat); - } /* end ether_debug */ + return (estat); +} /* end ether_debug */ #ifndef NOETHER -static struct timeval EtherTimeout = { - 0, 0 -}; +static struct timeval EtherTimeout = {0, 0}; #endif /* NOETHER */ - /********************************************************************** * check_ether() * checks an incoming packet **********************************************************************/ #ifndef OS4 -static int nitpos=0, nitlen=0; /* for NIT read buffer in OS3 */ +static int nitpos = 0, nitlen = 0; /* for NIT read buffer in OS3 */ #endif -check_ether() - { - /* - * If receiver active then check if any packets are - * available from the ethernet. If so, read the packet - * and signal the icb and return T. - */ +check_ether() { +/* + * If receiver active then check if any packets are + * available from the ethernet. If so, read the packet + * and signal the icb and return T. + */ #ifndef NOETHER #ifndef OS4 - static int rfds; - int result, fromlen; - struct nit_hdr header; - int posi, i; -#else /* OS4 */ + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* OS4 */ - static int rfds; - int result; - int i; - u_long plen; - struct strbuf ctl, data; - char ctlbuf[2000]; + static int rfds; + int result; + int i; + u_long plen; + struct strbuf ctl, data; + char ctlbuf[2000]; #endif /* OS4 */ - - rfds = EtherReadFds; + rfds = EtherReadFds; #ifndef OS4 - i = 2; - if(/* select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 ) */ (1)) - { - if( (ether_fd >= 0) && (ether_bsize > 0) ) - { - while ( (select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0) - && (i-- > 0) ) - { - if (nitpos>=nitlen) - { /* Used up last NIT buffer full; read another. */ - nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); - nitpos = 0; - } - /* enumerate the NIT headers until the packet is found */ - while (nitpos < nitlen) - { - bcopy(&nit_buf[nitpos], &header, sizeof(header)); - nitpos += sizeof(header); - switch (header.nh_state) - { - case NIT_CATCH: - fromlen = header.nh_datalen; - if (check_filter(&nit_buf[nitpos])) - { - bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); - ether_bsize = 0; /* deactivate receiver */ - ether_in++; - IOPage->dlethernet[3] = fromlen; - DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); - nitpos += fromlen; - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; - ETHEREventCount++; - Irq_Stk_Check = Irq_Stk_End=0; - *PENDINGINTERRUPT68k = ATOM_T; - /* return(NIL); */ - return(ATOM_T); - } - nitpos += fromlen; - break; + i = 2; + if (/* select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 ) */ (1)) { + if ((ether_fd >= 0) && (ether_bsize > 0)) { + while ((select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0) && (i-- > 0)) { + if (nitpos >= nitlen) { /* Used up last NIT buffer full; read another. */ + nitlen = read(ether_fd, nit_buf, sizeof(nit_buf)); + nitpos = 0; + } + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT( + ("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); + nitpos += fromlen; + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End = 0; + *PENDINGINTERRUPT68k = ATOM_T; + /* return(NIL); */ + return (ATOM_T); + } + nitpos += fromlen; + break; - /* ignore all the other header types */ - case NIT_QUIET: break; - case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; - case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; - case NIT_NOSPACE: DBPRINT(("No Space\n")); break; - case NIT_SEQNO: break; - } - } - } - } + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; + } + } } -#else /* OS4 */ + } + } +#else /* OS4 */ - if(ether_fd >= 0 && ether_bsize > 0 -/* && select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 - * -- [on '90/02/14: getsignsldata() chech this] */ - && (rfds & (1 << ether_fd))) - { - data.maxlen = sizeof(nit_buf); - data.len = 0; - data.buf = (char *)nit_buf; - ctl.maxlen = sizeof(ctlbuf); - ctl.len = 0; - ctl.buf = ctlbuf; - plen = 0; - result = getmsg(ether_fd, &ctl, &data, &plen); - if(result >= 0 ) - { - if(data.len <= ether_bsize - && data.len > 0) - { - bcopy(nit_buf, ðer_buf[0], data.len); - ether_bsize = 0; - ether_in++; - IOPage->dlethernet[3] = data.len; - ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; - ETHEREventCount++; - Irq_Stk_Check = Irq_Stk_End=0; - *PENDINGINTERRUPT68k = ATOM_T; - return(NIL); /* return(ATOM_T); */ - } - } - else if (errno != EWOULDBLOCK) - { - perror("Check_ether read error:\n"); - } + if (ether_fd >= 0 && ether_bsize > 0 + /* && select(32, &rfds, NULL, NULL, &EtherTimeout) >= 0 + * -- [on '90/02/14: getsignsldata() chech this] */ + && (rfds & (1 << ether_fd))) { + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if (result >= 0) { + if (data.len <= ether_bsize && data.len > 0) { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 1; + ETHEREventCount++; + Irq_Stk_Check = Irq_Stk_End = 0; + *PENDINGINTERRUPT68k = ATOM_T; + return (NIL); /* return(ATOM_T); */ } + } else if (errno != EWOULDBLOCK) { + perror("Check_ether read error:\n"); + } + } #endif /* OS4 */ #endif /* NOETHER */ - - return(NIL); - } /* end check_ether */ - + return (NIL); +} /* end check_ether */ /************************************************************************/ /* */ @@ -518,101 +476,86 @@ check_ether() /* */ /************************************************************************/ -get_packet() - { +get_packet() { #ifndef NOETHER #ifndef OS4 - static int rfds; - int result, fromlen; - struct nit_hdr header; - int posi, i; -#else /* OS4 */ + static int rfds; + int result, fromlen; + struct nit_hdr header; + int posi, i; +#else /* OS4 */ - static int rfds; - int result; - int i; - u_long plen; - struct strbuf ctl, data; - char ctlbuf[2000]; + static int rfds; + int result; + int i; + u_long plen; + struct strbuf ctl, data; + char ctlbuf[2000]; #endif /* OS4 */ - #ifndef OS4 - while (1) - { - if (nitpos>=nitlen) - { /* Used up last NIT buffer full; read another. */ - nitlen = read (ether_fd, nit_buf, sizeof(nit_buf)); - if (nitlen < 0) return(NIL); /* No more packets to try. */ - nitpos = 0; - } + while (1) { + if (nitpos >= nitlen) { /* Used up last NIT buffer full; read another. */ + nitlen = read(ether_fd, nit_buf, sizeof(nit_buf)); + if (nitlen < 0) return (NIL); /* No more packets to try. */ + nitpos = 0; + } - /* enumerate the NIT headers until the packet is found */ - while (nitpos < nitlen) - { - bcopy(&nit_buf[nitpos], &header, sizeof(header)); - nitpos += sizeof(header); - switch (header.nh_state) - { - case NIT_CATCH: - fromlen = header.nh_datalen; - if (check_filter(&nit_buf[nitpos])) - { - bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); - ether_bsize = 0; /* deactivate receiver */ - ether_in++; - IOPage->dlethernet[3] = fromlen; - DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", - fromlen, nitpos, nitlen)); - nitpos += fromlen; - return(ATOM_T); - } - nitpos += fromlen; - break; + /* enumerate the NIT headers until the packet is found */ + while (nitpos < nitlen) { + bcopy(&nit_buf[nitpos], &header, sizeof(header)); + nitpos += sizeof(header); + switch (header.nh_state) { + case NIT_CATCH: + fromlen = header.nh_datalen; + if (check_filter(&nit_buf[nitpos])) { + bcopy(&nit_buf[nitpos], ðer_buf[0], fromlen); + ether_bsize = 0; /* deactivate receiver */ + ether_in++; + IOPage->dlethernet[3] = fromlen; + DBPRINT(("Found packet len %d, at pos %d in buflen %d.\n", fromlen, nitpos, nitlen)); + nitpos += fromlen; + return (ATOM_T); + } + nitpos += fromlen; + break; - /* ignore all the other header types */ - case NIT_QUIET: break; - case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; - case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; - case NIT_NOSPACE: DBPRINT(("No Space\n")); break; - case NIT_SEQNO: break; - } - } + /* ignore all the other header types */ + case NIT_QUIET: break; + case NIT_NOMBUF: DBPRINT(("No MBUFs\n")); break; + case NIT_NOCLUSTER: DBPRINT(("No Clusters\n")); break; + case NIT_NOSPACE: DBPRINT(("No Space\n")); break; + case NIT_SEQNO: break; } + } + } -#else /* OS4 */ +#else /* OS4 */ - data.maxlen = sizeof(nit_buf); - data.len = 0; - data.buf = (char *)nit_buf; - ctl.maxlen = sizeof(ctlbuf); - ctl.len = 0; - ctl.buf = ctlbuf; - plen = 0; - result = getmsg(ether_fd, &ctl, &data, &plen); - if(result >= 0 ) - { - if(data.len <= ether_bsize && data.len > 0) - { - bcopy(nit_buf, ðer_buf[0], data.len); - ether_bsize = 0; - ether_in++; - IOPage->dlethernet[3] = data.len; - return(ATOM_T); - } - } - else if (errno != EWOULDBLOCK) perror("Check_ether read error:\n"); + data.maxlen = sizeof(nit_buf); + data.len = 0; + data.buf = (char *)nit_buf; + ctl.maxlen = sizeof(ctlbuf); + ctl.len = 0; + ctl.buf = ctlbuf; + plen = 0; + result = getmsg(ether_fd, &ctl, &data, &plen); + if (result >= 0) { + if (data.len <= ether_bsize && data.len > 0) { + bcopy(nit_buf, ðer_buf[0], data.len); + ether_bsize = 0; + ether_in++; + IOPage->dlethernet[3] = data.len; + return (ATOM_T); + } + } else if (errno != EWOULDBLOCK) + perror("Check_ether read error:\n"); #endif /* OS4 */ #endif /* NOETHER */ - - return(NIL); - } /* end get_packet */ - - - - + return (NIL); +} /* end get_packet */ /********************************************************************** * check_filter(buffer) @@ -620,29 +563,22 @@ get_packet() * This is believed obsolete with packet filtering enabled **********************************************************************/ -check_filter(buffer) - u_char* buffer; - { - /* broadcast packets */ - if (ether_addr_equal(buffer, broadcast)) - switch(((short*)buffer)[6]) - { - case PacketTypeIP: return(0); - case PacketTypeARP: return(0); - default: return(1); - }; - /* my address */ - if (ether_addr_equal(buffer, ether_host)) - switch(((short*)buffer)[6]) - { - case PacketTypeIP: return(0); - case PacketTypeARP: return(0); - default: return(1); - }; - return(0); - } - - +check_filter(buffer) u_char *buffer; +{ + /* broadcast packets */ + if (ether_addr_equal(buffer, broadcast)) switch (((short *)buffer)[6]) { + case PacketTypeIP: return (0); + case PacketTypeARP: return (0); + default: return (1); + }; + /* my address */ + if (ether_addr_equal(buffer, ether_host)) switch (((short *)buffer)[6]) { + case PacketTypeIP: return (0); + case PacketTypeARP: return (0); + default: return (1); + }; + return (0); +} /********************************************************************** * ether_addr_equal(add1, add2) @@ -652,29 +588,26 @@ check_filter(buffer) ether_addr_equal(add1, add2) -u_char add1[], add2[]; - { - register int i; - for(i=0; i<6; i++) if (add1[i] != add2[i]) return(0); - return(1); - } - - + u_char add1[], + add2[]; +{ + register int i; + for (i = 0; i < 6; i++) + if (add1[i] != add2[i]) return (0); + return (1); +} /********************************************************************** * init_uid() * sets effective user-id to real user-id **********************************************************************/ -init_uid() - { +init_uid() { #ifndef NOETHER - int rid; - rid = getuid(); - seteuid(rid); + int rid; + rid = getuid(); + seteuid(rid); #endif /* NOETHER */ - } - - +} /************************************************************************/ /* i n i t _ i f p a g e _ e t h e r */ @@ -684,292 +617,256 @@ init_uid() /* */ /************************************************************************/ -init_ifpage_ether() - { - InterfacePage->nshost0 = (DLword)((ether_host[0] << 8) + ether_host[1]); - InterfacePage->nshost1 = (DLword)((ether_host[2] << 8) + ether_host[3]); - InterfacePage->nshost2 = (DLword)((ether_host[4] << 8) + ether_host[5]); - } - +init_ifpage_ether() { + InterfacePage->nshost0 = (DLword)((ether_host[0] << 8) + ether_host[1]); + InterfacePage->nshost1 = (DLword)((ether_host[2] << 8) + ether_host[3]); + InterfacePage->nshost2 = (DLword)((ether_host[4] << 8) + ether_host[5]); +} #ifndef NOETHER - /* this needs to be a global so the name can be set by main() in Ctest */ - /* But NOETHER doesn't support NIT, so dyke it out for NOETHER */ +/* this needs to be a global so the name can be set by main() in Ctest */ +/* But NOETHER doesn't support NIT, so dyke it out for NOETHER */ struct sockaddr_nit snit; #endif /* NOETHER */ - - - - /************************************************************************/ /* i n i t _ e t h e r */ /* */ /* open nit socket, called from main before starting BCE. */ /* */ /************************************************************************/ -init_ether() - { - +init_ether() { #ifndef NOETHER - /* JRB - This code will have to be a bit different for SUN 4.0; the probable differences are in commented-out code below - (not ifdefed because they're untested...) - */ - int flags; + /* JRB - This code will have to be a bit different for SUN 4.0; the probable + differences are in commented-out code below + (not ifdefed because they're untested...) + */ + int flags; - /* ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 0; - ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->handledmask = 0; + /* ((INTSTAT*)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->ETHERInterrupt = 0; + ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->handledmask = 0; + */ + if (ether_fd < 0) { +/* it's not open yet, try and open it; + if it's already open here, it was opened by ldeether and + all the appropriate stuff was done to it there. */ - if (ether_fd < 0) - { - /* it's not open yet, try and open it; - if it's already open here, it was opened by ldeether and - all the appropriate stuff was done to it there. - */ #ifndef OS4 - if (getuid() != geteuid()) - { - if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) - { - /* 4.0: socket -> open("/dev/nit", O_BOTH) */ - /* it's open, now query it and find out its name and address */ - /* JRB - must document that Maiko uses the first net board as - found by SIOCGIFCONF (see if(4)). Maybe we need an option to - specify which net board (suspect more than one net board on a - Maiko machine will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + if (getuid() != geteuid()) { + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { + /* 4.0: socket -> open("/dev/nit", O_BOTH) */ + /* it's open, now query it and find out its name and address */ + /* JRB - must document that Maiko uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option to + specify which net board (suspect more than one net board on a + Maiko machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; - if_data.ifc_len = sizeof(ifbuf); - if_data.ifc_req = ifbuf; - /* 4.0 - before the SIOCGIFCONF, do: - bzero(ifbuf, sizeof(ifbuf)) - */ - if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) - { - perror("Couldn't GIFCONF socket; Net is off"); -#else /* OS4 */ + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + /* 4.0 - before the SIOCGIFCONF, do: + bzero(ifbuf, sizeof(ifbuf)) + */ + if (ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ - if (getuid() != geteuid()) - { - if ((ether_fd = open("/dev/nit", O_RDWR|FASYNC)) >= 0) - { - /* it's open, now query it and find out its name and address */ - /* JRB - must document that LDE uses the first net board as - found by SIOCGIFCONF (see if(4)). Maybe we need an option - to specify which net board (suspect more than one net - board on an LDE machine will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + if (getuid() != geteuid()) { + if ((ether_fd = open("/dev/nit", O_RDWR | FASYNC)) >= 0) { + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as + found by SIOCGIFCONF (see if(4)). Maybe we need an option + to specify which net board (suspect more than one net + board on an LDE machine will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if(ioctl(ether_fd, I_PUSH, "pf") < 0) - { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } - if_data.ifc_len = sizeof(ifbuf); - if_data.ifc_req = ifbuf; - bzero(ifbuf, sizeof(ifbuf)); - { - /* we have to get the interface name from another socket, since - /dev/nit doesn't know anything until it gets bound, and we - can't bind it without knowing the interface name... */ - int s; + if (ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - { - perror("No socket for interface name"); - close(s); + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); #endif /* OS4 */ - close(ether_fd); - ether_fd = -1; + close(ether_fd); + ether_fd = -1; #ifndef OS4 - return(NIL); -#else /* OS4 */ + return (NIL); +#else /* OS4 */ - goto I_Give_Up; + goto I_Give_Up; +#endif /* OS4 */ + } +#ifndef OS4 + /* got its name, copy it into snit */ + strcpy(snit.snit_ifname, if_data.ifc_req[0].ifr_name); + /* 4.0, before the SIOCGIFADDR, do: + ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) + */ + /* now for the address */ + if (ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); +#else /* OS4 */ + + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); #endif /* OS4 */ - } + close(ether_fd); + ether_fd = -1; #ifndef OS4 - /* got its name, copy it into snit */ - strcpy(snit.snit_ifname, if_data.ifc_req[0].ifr_name); - /* 4.0, before the SIOCGIFADDR, do: - ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) - */ - /* now for the address */ - if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) - { - perror("Couldn't GIFADDR socket: Net is off"); -#else /* OS4 */ + return (NIL); +#else /* OS4 */ - if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) - { - perror("Couldn't get interface name from socket"); - close(s); + goto I_Give_Up; #endif /* OS4 */ - - close(ether_fd); - ether_fd = -1; + } #ifndef OS4 - return(NIL); -#else /* OS4 */ + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + init_uid(); + } +#else /* OS4 */ - goto I_Give_Up; + (void)close(s); #endif /* OS4 */ - - } -#ifndef OS4 - bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); - init_uid(); - } -#else /* OS4 */ - - (void) close(s); -#endif /* OS4 */ - - } + } #ifdef OS4 - if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) - { - perror("Couldn't NIOCBIND socket: Net is off"); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - /* now for the address */ - if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) - { - perror("Couldn't GIFADDR socket: Net is off"); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); - DBPRINT(("init_ether: **** Ethernet starts ****\n")); - } - else - { -I_Give_Up: - perror("init_ether: can't open NIT socket\n"); - ether_fd = -1; - exit(); - } - seteuid(getuid()); + if (ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if (ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + DBPRINT(("init_ether: **** Ethernet starts ****\n")); + } else { + I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + exit(); } + seteuid(getuid()); +} #endif /* OS4 */ - } if (ether_fd >= 0) { #ifndef OS4 - /* bind the socket to an interface */ - snit.snit_family = AF_NIT; - bind(ether_fd, &snit, sizeof(snit)); -#else /* OS4 */ + /* bind the socket to an interface */ + snit.snit_family = AF_NIT; + bind(ether_fd, &snit, sizeof(snit)); +#else /* OS4 */ -/* I think all you really have to do here is set the SNAP length, flags, - and configure the buffering module */ - unsigned long snaplen = 0; - struct timeval zerotime; + /* I think all you really have to do here is set the SNAP length, flags, + and configure the buffering module */ + unsigned long snaplen = 0; + struct timeval zerotime; #endif /* OS4 */ - #ifndef OS4 - /* establish the operating modes */ - bzero(&nioc, sizeof(nioc)); - nioc.nioc_bufspace = 20000; - nioc.nioc_chunksize = 50; /* small chunks so each packet read */ - nioc.nioc_typetomatch = NT_ALLTYPES; - nioc.nioc_snaplen = 32767; - nioc.nioc_flags = 0; - if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { - printf("init_ether: ioctl failed\n"); -#else /* OS4 */ + /* establish the operating modes */ + bzero(&nioc, sizeof(nioc)); + nioc.nioc_bufspace = 20000; + nioc.nioc_chunksize = 50; /* small chunks so each packet read */ + nioc.nioc_typetomatch = NT_ALLTYPES; + nioc.nioc_snaplen = 32767; + nioc.nioc_flags = 0; + if (ioctl(ether_fd, SIOCSNIT, &nioc) != 0) { + printf("init_ether: ioctl failed\n"); +#else /* OS4 */ - EtherReadFds |= (1 << ether_fd); + EtherReadFds |= (1 << ether_fd); -/* first and foremost, flush out ether_fd's buffers and filter it */ -/* install packetfilter that rejects everything */ - if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { - perror("init_ether: nopf NIOCSETF failed:\n"); + /* first and foremost, flush out ether_fd's buffers and filter it */ + /* install packetfilter that rejects everything */ + if (ioctl(ether_fd, NIOCSETF, &nopf) != 0) { + perror("init_ether: nopf NIOCSETF failed:\n"); #endif /* OS4 */ - close(ether_fd); - ether_fd = -1; - return(NIL); - } -#ifndef OS4 - EtherReadFds |= (1 << ether_fd); - if (fcntl(ether_fd, F_SETFL, - fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY)<0) - perror("Ether setup SETFLAGS fcntl"); - if( fcntl(ether_fd, F_SETOWN, getpid()) < 0) - perror("Ether setup SETOWN"); -#else /* OS4 */ - -/* then throw away everything that's currently buffered there; - this descriptor may have been open since ldeether ran, with - no filtering; a busy net will have stuffed it full */ - {int rfds = EtherReadFds; - while(select(32, &rfds, NULL, NULL, &EtherTimeout) > 0) - read(ether_fd, nit_buf, sizeof(nit_buf)); - } - - -/* put the address into the packetfilter structure */ -/* DANGER! Vulnerable to byte ordering! DANGER! */ - goodpf.Pf_Filter[8]= *((short *)ðer_host[0]); - goodpf.Pf_Filter[11]= *((short *)ðer_host[2]); - goodpf.Pf_Filter[14]= *((short *)ðer_host[4]); -/* and set up the packetfilter */ - if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { - perror("init_ether: NIOCSETF failed:\n"); - close(ether_fd); - ether_fd = -1; - return(NIL); - } -/* clobber the flags */ - if(ioctl(ether_fd, NIOCSFLAGS, &snaplen) != 0) - { - perror("init_ether: NIOCSFLAGS failed:\n"); - close(ether_fd); - ether_fd = -1; - return(NIL); - } - DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); - if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) - { - perror("init_ether: I_SETSIG failed:\n"); - close(ether_fd); - ether_fd = -1; - return(NIL); - } -#endif /* OS4 */ - - if (EtherReadFds == 0) - error("EtherReadFds is zero, but enet opened??"); - LispReadFds |= EtherReadFds; - - DBPRINT(("init_ether: **** Ethernet starts ****\n")); - } -#endif /* NOETHER */ - + close(ether_fd); + ether_fd = -1; + return (NIL); } +#ifndef OS4 + EtherReadFds |= (1 << ether_fd); + if (fcntl(ether_fd, F_SETFL, fcntl(ether_fd, F_GETFL, 0) | FASYNC | FNDELAY) < 0) + perror("Ether setup SETFLAGS fcntl"); + if (fcntl(ether_fd, F_SETOWN, getpid()) < 0) perror("Ether setup SETOWN"); +#else /* OS4 */ + /* then throw away everything that's currently buffered there; + this descriptor may have been open since ldeether ran, with + no filtering; a busy net will have stuffed it full */ + { + int rfds = EtherReadFds; + while (select(32, &rfds, NULL, NULL, &EtherTimeout) > 0) + read(ether_fd, nit_buf, sizeof(nit_buf)); + } + /* put the address into the packetfilter structure */ + /* DANGER! Vulnerable to byte ordering! DANGER! */ + goodpf.Pf_Filter[8] = *((short *)ðer_host[0]); + goodpf.Pf_Filter[11] = *((short *)ðer_host[2]); + goodpf.Pf_Filter[14] = *((short *)ðer_host[4]); + /* and set up the packetfilter */ + if (ioctl(ether_fd, NIOCSETF, &goodpf) != 0) { + perror("init_ether: NIOCSETF failed:\n"); + close(ether_fd); + ether_fd = -1; + return (NIL); + } + /* clobber the flags */ + if (ioctl(ether_fd, NIOCSFLAGS, &snaplen) != 0) { + perror("init_ether: NIOCSFLAGS failed:\n"); + close(ether_fd); + ether_fd = -1; + return (NIL); + } + DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); + if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) { + perror("init_ether: I_SETSIG failed:\n"); + close(ether_fd); + ether_fd = -1; + return (NIL); + } +#endif /* OS4 */ + if (EtherReadFds == 0) error("EtherReadFds is zero, but enet opened??"); + LispReadFds |= EtherReadFds; -#define MASKWORD1 0xffff + DBPRINT(("init_ether: **** Ethernet starts ****\n")); +} +#endif /* NOETHER */ +} +#define MASKWORD1 0xffff /************************************************************************/ /* */ @@ -985,31 +882,33 @@ if (ether_fd >= 0) { /* */ /************************************************************************/ -check_sum(args) - register LispPTR *args; - { - register LispPTR checksum; - register DLword *address; - register int nwords; +check_sum(args) register LispPTR *args; +{ + register LispPTR checksum; + register DLword *address; + register int nwords; - address=(DLword*)Addr68k_from_LADDR(*args++); - nwords = *args ++; + address = (DLword *)Addr68k_from_LADDR(*args++); + nwords = *args++; - if( *args != NIL) checksum = (*args) & MASKWORD1; - else checksum = 0; + if (*args != NIL) + checksum = (*args) & MASKWORD1; + else + checksum = 0; - for(;nwords > (S_POSITIVE); address++,nwords--) - { - checksum= checksum + GETWORD(address); - if(checksum > 0xffff) - checksum = (checksum & 0xffff) +1; /* add carry */ + for (; nwords > (S_POSITIVE); address++, nwords--) { + checksum = checksum + GETWORD(address); + if (checksum > 0xffff) checksum = (checksum & 0xffff) + 1; /* add carry */ - if(checksum >0x7fff) /* ROTATE LEFT 1 */ - checksum= ((checksum & 0x7fff)<<1) | 1 ; - else checksum = checksum << 1; - } + if (checksum > 0x7fff) /* ROTATE LEFT 1 */ + checksum = ((checksum & 0x7fff) << 1) | 1; + else + checksum = checksum << 1; + } - if(checksum == MASKWORD1) return(S_POSITIVE);/* ret 0 */ - else return(S_POSITIVE|checksum); + if (checksum == MASKWORD1) + return (S_POSITIVE); /* ret 0 */ + else + return (S_POSITIVE | checksum); - } /*check_sum */ +} /*check_sum */ diff --git a/src/oldeether.c b/src/oldeether.c old mode 100755 new mode 100644 index f9f12e7..7f3f80d --- a/src/oldeether.c +++ b/src/oldeether.c @@ -1,12 +1,7 @@ -/* $Id: oldeether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: oldeether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: oldeether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ Copyright (C) Venue"; - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -21,11 +16,10 @@ static char *id = "$Id: oldeether.c,v 1.2 1999/01/03 02:07:28 sybalsky Exp $ Cop #include "version.h" - #ifdef NOETHER -main (argc, argv, argp) int argc; char **argv, **argp; -{ -} +main(argc, argv, argp) int argc; +char **argv, **argp; +{} #else #include @@ -53,143 +47,141 @@ main (argc, argv, argp) int argc; char **argv, **argp; #include #include -int ether_fd = -1; /* file descriptor for ether socket */ -unsigned char ether_host[6] = {0,0,0,0,0,0}; /* 48 bit address */ +int ether_fd = -1; /* file descriptor for ether socket */ +unsigned char ether_host[6] = {0, 0, 0, 0, 0, 0}; /* 48 bit address */ char filetorun[30] = "lde"; -main(argc, argv, envp) int argc; char **argv, **envp; +main(argc, argv, envp) int argc; +char **argv, **envp; { - char Earg[30], Ename[30], **newargv; - int i; - int flags; -/* Kickstart program for the Lisp Development Environment (LDE). - Run this as setuid root to open the LDE ether socket. - Passes all arguments through to LDE plus -E - to communicate open ether socket. + char Earg[30], Ename[30], **newargv; + int i; + int flags; + /* Kickstart program for the Lisp Development Environment (LDE). + Run this as setuid root to open the LDE ether socket. + Passes all arguments through to LDE plus -E + to communicate open ether socket. - looks like this: - ::::::: + looks like this: + ::::::: - where is the number of the open - socket (decimal), and - are hex of the socket's - 48-bit Ethernet address, and is the name of the - Ethernet device as found by SIOCGIFCONF. -*/ + where is the number of the open + socket (decimal), and - are hex of the socket's + 48-bit Ethernet address, and is the name of the + Ethernet device as found by SIOCGIFCONF. + */ -if (!geteuid()){ + if (!geteuid()) { #ifndef OS4 - if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { -#else /* OS4 */ + if ((ether_fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW)) >= 0) { +#else /* OS4 */ - if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { + if ((ether_fd = open("/dev/nit", O_RDWR)) >= 0) { #endif /* OS4 */ - /* it's open, now query it and find out its name and address */ - /* JRB - must document that LDE uses the first net board as found - by SIOCGIFCONF (see if(4)). Maybe we need an option to specify - which net board (suspect more than one net board on an LDE machine - will be rare, but...). - */ - struct ifconf if_data; - struct ifreq ifbuf[20]; + /* it's open, now query it and find out its name and address */ + /* JRB - must document that LDE uses the first net board as found + by SIOCGIFCONF (see if(4)). Maybe we need an option to specify + which net board (suspect more than one net board on an LDE machine + will be rare, but...). + */ + struct ifconf if_data; + struct ifreq ifbuf[20]; #ifdef OS4 - /* first and foremost, get the packet filter module attached - (used for ether_suspend and ether_resume) */ + /* first and foremost, get the packet filter module attached + (used for ether_suspend and ether_resume) */ - if(ioctl(ether_fd, I_PUSH, "pf") < 0) { - perror("IOCTL push of pf lost"); - close(ether_fd); - goto I_Give_Up; - } + if (ioctl(ether_fd, I_PUSH, "pf") < 0) { + perror("IOCTL push of pf lost"); + close(ether_fd); + goto I_Give_Up; + } #endif /* OS4 */ - if_data.ifc_len = sizeof(ifbuf); - if_data.ifc_req = ifbuf; + if_data.ifc_len = sizeof(ifbuf); + if_data.ifc_req = ifbuf; #ifndef OS4 - if(ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { - perror("Couldn't GIFCONF socket; Net is off"); -#else /* OS4 */ + if (ioctl(ether_fd, SIOCGIFCONF, &if_data) < 0) { + perror("Couldn't GIFCONF socket; Net is off"); +#else /* OS4 */ - bzero(ifbuf, sizeof(ifbuf)); - { - /* we have to get the interface name from another socket, since - /dev/nit doesn't know anything until it gets bound, and we - can't bind it without knowing the interface name... */ - int s; + bzero(ifbuf, sizeof(ifbuf)); + { + /* we have to get the interface name from another socket, since + /dev/nit doesn't know anything until it gets bound, and we + can't bind it without knowing the interface name... */ + int s; - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - perror("No socket for interface name"); - close(s); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { - perror("Couldn't get interface name from socket"); - close(s); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - (void) close(s); - } - if(ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { - perror("Couldn't NIOCBIND socket: Net is off"); + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("No socket for interface name"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + if (ioctl(s, SIOCGIFCONF, (char *)&if_data) < 0) { + perror("Couldn't get interface name from socket"); + close(s); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + (void)close(s); + } + if (ioctl(ether_fd, NIOCBIND, &if_data.ifc_req[0]) < 0) { + perror("Couldn't NIOCBIND socket: Net is off"); #endif /* OS4 */ - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - /* now for the address */ - if(ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { - perror("Couldn't GIFADDR socket: Net is off"); - close(ether_fd); - ether_fd = -1; - goto I_Give_Up; - } - bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); - strcpy(Ename, if_data.ifc_req[0].ifr_name); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + /* now for the address */ + if (ioctl(ether_fd, SIOCGIFADDR, &if_data.ifc_req[0]) < 0) { + perror("Couldn't GIFADDR socket: Net is off"); + close(ether_fd); + ether_fd = -1; + goto I_Give_Up; + } + bcopy(if_data.ifc_req[0].ifr_addr.sa_data, ether_host, 6); + strcpy(Ename, if_data.ifc_req[0].ifr_name); - flags = fcntl(ether_fd, F_GETFL, 0); - flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); + flags = fcntl(ether_fd, F_GETFL, 0); + flags = fcntl(ether_fd, F_SETFL, flags | FASYNC | FNDELAY); - -#ifdef DEBUG - printf("init_ether: **** Ethernet starts ****\n"); +#ifdef DEBUG + printf("init_ether: **** Ethernet starts ****\n"); #endif - } else { -I_Give_Up: - perror("init_ether: can't open NIT socket\n"); - ether_fd = -1; - /* exit(); */ - } - seteuid(getuid()); - } + } else { + I_Give_Up: + perror("init_ether: can't open NIT socket\n"); + ether_fd = -1; + /* exit(); */ + } + seteuid(getuid()); + } -/* OK, right here do other stuff like scan args */ -/* finally crank up LDE; first copy the original args */ + /* OK, right here do other stuff like scan args */ + /* finally crank up LDE; first copy the original args */ -newargv = (char **) malloc((argc + 1 + (ether_fd > 0)*2) * sizeof (char **)); -newargv[0] = filetorun; /* or whatever... */ -for(i=1; i 0) * 2) * sizeof(char **)); + newargv[0] = filetorun; /* or whatever... */ + for (i = 1; i < argc; i++) newargv[i] = argv[i]; -/* then if the net is active, spit out the ether info */ -if(ether_fd > 0) { - newargv[i++] = "-E"; - sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, - ether_host[0], ether_host[1], ether_host[2], - ether_host[3], ether_host[4], ether_host[5], Ename); - newargv[i++] = Earg; -} -newargv[i] = 0; + /* then if the net is active, spit out the ether info */ + if (ether_fd > 0) { + newargv[i++] = "-E"; + sprintf(Earg, "%d:%x:%x:%x:%x:%x:%x:%s", ether_fd, ether_host[0], ether_host[1], ether_host[2], + ether_host[3], ether_host[4], ether_host[5], Ename); + newargv[i++] = Earg; + } + newargv[i] = 0; -/* then execve the LDE executable */ -execvp(filetorun, newargv); -perror(filetorun); -exit(1); + /* then execve the LDE executable */ + execvp(filetorun, newargv); + perror(filetorun); + exit(1); } #endif /* NOETHER */ - diff --git a/src/optck.c b/src/optck.c old mode 100755 new mode 100644 index 629a9a9..274a8c4 --- a/src/optck.c +++ b/src/optck.c @@ -1,17 +1,15 @@ -/* $Id: optck.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: optck.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: optck.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyright (C) Venue"; /* optck.c * * This example is almost same as one shown in * SunOS 4.1 Release Manual: 4.2. Known Problems With SunOS Release 4.1 Products. - * + * * Compiling this file with -O or -O2 level and executing, if assembler optimizes * incorrectly, "wrong" message is printed out to stdout. - * + * */ - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -26,32 +24,26 @@ static char *id = "$Id: optck.c,v 1.3 1999/05/31 23:35:40 sybalsky Exp $ Copyrig #include "version.h" +int boothowto = 1; -int boothowto = 1; +int main(void) { + int unit; -int -main(void) -{ - int unit; - - if (boothowto & 1) { - retry: - unit = -1; - while (unit == -1) { - if (unit != -1) { - printf("wrong"); - exit(1); - } - unit = 0; - foo(&unit); - } - } else { - unit = 0; - goto retry; - } -} - -foo(int *unitp) -{ + if (boothowto & 1) { + retry: + unit = -1; + while (unit == -1) { + if (unit != -1) { + printf("wrong"); + exit(1); + } + unit = 0; + foo(&unit); + } + } else { + unit = 0; + goto retry; + } } +foo(int *unitp) {} diff --git a/src/osmsg.c b/src/osmsg.c old mode 100755 new mode 100644 index 8f021c1..9da2a46 --- a/src/osmsg.c +++ b/src/osmsg.c @@ -1,4 +1,4 @@ -/* $Id: osmsg.c,v 1.2 1999/01/03 02:07:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: osmsg.c,v 1.2 1999/01/03 02:07:29 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: osmsg.c,v 1.2 1999/01/03 02:07:29 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ @@ -25,67 +25,63 @@ static char *id = "$Id: osmsg.c,v 1.2 1999/01/03 02:07:29 sybalsky Exp $ Copyrig #include "version.h" - #ifndef DOS -#include +#include -#include +#include #ifdef ISC -#include +#include #endif /* ISC */ -#include -#include +#include +#include #ifndef AIX -#include +#include #endif /* AIX */ -#include +#include #ifndef AIX #ifndef APOLLO #ifndef MACOSX #ifndef FREEBSD -#include +#include #endif /* FREEBSD */ #endif /* MACOSX */ #endif /* APOLLO */ #endif /* AIX */ #ifndef SYSVONLY -#include +#include #endif /* SYSVONLY */ #endif /* DOS */ - -#include -#include -#include -#include "lispemul.h" -#include "lispmap.h" -#include "adr68k.h" -#include "lsptypes.h" -#include "arith.h" -#include "stream.h" -#include "lspglob.h" -#include "timeout.h" -#include "locfile.h" -#include "osmsg.h" +#include +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "stream.h" +#include "lspglob.h" +#include "timeout.h" +#include "locfile.h" +#include "osmsg.h" #include "dbprint.h" #ifdef OS4 #include #endif -#define MESSAGE_BUFFER_SIZE 1024 -int cons_tty; -int cons_pty; +#define MESSAGE_BUFFER_SIZE 1024 +int cons_tty; +int cons_pty; -char logfile[100]; -int log_id; -int previous_size; -int logChanged; /* T if log file has changed since last READ */ - /* Set by flush_pty, to avoid the stat call */ +char logfile[100]; +int log_id; +int previous_size; +int logChanged; /* T if log file has changed since last READ */ + /* Set by flush_pty, to avoid the stat call */ u_int LogFileFd; extern u_int LispReadFds; - - /************************************************************************/ /* */ /* m e s s _ i n i t */ @@ -98,102 +94,92 @@ extern u_int LispReadFds; /* */ /************************************************************************/ -void mess_init() - { +void mess_init() { #ifndef XWINDOW #ifndef DOS - int id; - struct passwd *pwd; - int ttyfd; - int ptyfd, ptynum; - char *ptyname, *ttyname; - int temp, flags; - int on = 1; + int id; + struct passwd *pwd; + int ttyfd; + int ptyfd, ptynum; + char *ptyname, *ttyname; + int temp, flags; + int on = 1; - ptyname = "/dev/ptypx"; - ttyname = "/dev/ttypx"; + ptyname = "/dev/ptypx"; + ttyname = "/dev/ttypx"; -/* Get pty and tty */ - ptynum = 0; + /* Get pty and tty */ + ptynum = 0; needpty: - while( ptynum<16 ) - { - ptyname[9] = "0123456789abcdef"[ptynum]; - if( (ptyfd=open(ptyname, 2)) >= 0 ) goto gotpty; - ptynum++; - } - return; + while (ptynum < 16) { + ptyname[9] = "0123456789abcdef"[ptynum]; + if ((ptyfd = open(ptyname, 2)) >= 0) goto gotpty; + ptynum++; + } + return; gotpty: - ttyname[9] = ptyname[9]; - if( (ttyfd=open(ttyname, 2)) < 0) - { - ptynum++; - close(ptyfd); - goto needpty; - } - - /* Set tty parameters same as stderr */ - - ioctl( 2, TIOCGETD, &temp); /* Line discipline */ - ioctl(ttyfd, TIOCSETD, &temp); - - ioctl( 2, TIOCGETP, &temp); /* TTY parameters */ - ioctl(ttyfd, TIOCSETP, &temp); - - ioctl( 2, TIOCLGET, &temp); - ioctl(ttyfd, TIOCLSET, &temp); - - ioctl( 2, TIOCGETC, &temp); /* Terminal characters */ - ioctl(ttyfd, TIOCSETC, &temp); - - ioctl( 2, TIOCGLTC, &temp); /* Local special characters */ - ioctl(ttyfd, TIOCSLTC, &temp); - -/* Get console IO */ - ioctl(ptyfd, FIOCLEX, 0); -#ifndef AIX - if( (ioctl(ttyfd, TIOCCONS, 0)) == -1) - { - OSMESSAGE_PRINT( printf("TIOCCONS error\n") ); - exit(-1); - } -#endif /* AIX */ - - cons_pty = ptyfd; - cons_tty = ttyfd; - -/* Initialize log file */ - pwd = getpwuid(getuid()); - sprintf(logfile,"/tmp/%s-lisp.log", pwd->pw_name); - if( unlink(logfile) == -1) - { /* delete old log file */ - if(errno != ENOENT) return; - } - - if( (log_id = open(logfile, (O_RDWR | O_CREAT), 0666)) < 0 ) - return; -#ifdef LOGINT - LogFileFd = 1 << cons_pty; - flags = fcntl(cons_pty, F_GETFL, 0); - flags = fcntl(cons_pty, F_SETFL, (flags | FASYNC | FNDELAY)); - if(fcntl(cons_pty, F_SETOWN, getpid()) == -1 ) - { -#ifdef DEBUG - perror("fcntl F_SETOWN of log PTY"); -#endif - }; - LispReadFds |= LogFileFd; - flush_pty(); -#endif - previous_size = 0; - DBPRINT(("Console logging started.\n")); -#endif /* DOS */ -#endif /* XWINDOW */ - + ttyname[9] = ptyname[9]; + if ((ttyfd = open(ttyname, 2)) < 0) { + ptynum++; + close(ptyfd); + goto needpty; } + /* Set tty parameters same as stderr */ + ioctl(2, TIOCGETD, &temp); /* Line discipline */ + ioctl(ttyfd, TIOCSETD, &temp); + + ioctl(2, TIOCGETP, &temp); /* TTY parameters */ + ioctl(ttyfd, TIOCSETP, &temp); + + ioctl(2, TIOCLGET, &temp); + ioctl(ttyfd, TIOCLSET, &temp); + + ioctl(2, TIOCGETC, &temp); /* Terminal characters */ + ioctl(ttyfd, TIOCSETC, &temp); + + ioctl(2, TIOCGLTC, &temp); /* Local special characters */ + ioctl(ttyfd, TIOCSLTC, &temp); + + /* Get console IO */ + ioctl(ptyfd, FIOCLEX, 0); +#ifndef AIX + if ((ioctl(ttyfd, TIOCCONS, 0)) == -1) { + OSMESSAGE_PRINT(printf("TIOCCONS error\n")); + exit(-1); + } +#endif /* AIX */ + + cons_pty = ptyfd; + cons_tty = ttyfd; + + /* Initialize log file */ + pwd = getpwuid(getuid()); + sprintf(logfile, "/tmp/%s-lisp.log", pwd->pw_name); + if (unlink(logfile) == -1) { /* delete old log file */ + if (errno != ENOENT) return; + } + + if ((log_id = open(logfile, (O_RDWR | O_CREAT), 0666)) < 0) return; +#ifdef LOGINT + LogFileFd = 1 << cons_pty; + flags = fcntl(cons_pty, F_GETFL, 0); + flags = fcntl(cons_pty, F_SETFL, (flags | FASYNC | FNDELAY)); + if (fcntl(cons_pty, F_SETOWN, getpid()) == -1) { +#ifdef DEBUG + perror("fcntl F_SETOWN of log PTY"); +#endif + }; + LispReadFds |= LogFileFd; + flush_pty(); +#endif + previous_size = 0; + DBPRINT(("Console logging started.\n")); +#endif /* DOS */ +#endif /* XWINDOW */ +} /************************************************************************/ /* */ @@ -205,28 +191,24 @@ gotpty: /* */ /************************************************************************/ -void mess_reset() - { +void mess_reset() { #ifndef DOS #ifndef XWINDOW - int console_fd; - close(log_id); - close(cons_tty); - close(cons_pty); - /* Try to make /dev/console be the real console again */ + int console_fd; + close(log_id); + close(cons_tty); + close(cons_pty); +/* Try to make /dev/console be the real console again */ /*** This sequence sometimes cause SunOs panic on SunOS4.0(and 4.0.1). TIOCCONS probelm ??? if ((console_fd = open("/dev/console", 0)) >= 0) { - ioctl(console_fd, TIOCCONS, 0); - close(console_fd); - } + ioctl(console_fd, TIOCCONS, 0); + close(console_fd); + } ***/ #endif /* XWINDOW */ #endif /* DOS */ - - } - - +} /************************************************************************/ /* */ @@ -238,41 +220,38 @@ void mess_reset() /* */ /************************************************************************/ #ifndef DOS -static struct timeval selecttimeout = {0, 0}; +static struct timeval selecttimeout = {0, 0}; #endif -LispPTR mess_readp() - { +LispPTR mess_readp() { #ifndef DOS #ifndef XWINDOW - int id; - struct stat sbuf; - int size; - int rval; - struct statfs fsbuf; + int id; + struct stat sbuf; + int size; + int rval; + struct statfs fsbuf; - /* polling pty nd flush os message to log file */ - flush_pty(); + /* polling pty nd flush os message to log file */ + flush_pty(); -/* * * * * * * * * * * * COMMENTED OUT * * * * * * * * * - SETJMP(NIL); - TIMEOUT( rval=stat(logfile, &sbuf) ); + /* * * * * * * * * * * * COMMENTED OUT * * * * * * * * * + SETJMP(NIL); + TIMEOUT( rval=stat(logfile, &sbuf) ); - if(rval != 0) - { - error("osmessage error: can not find a log file under /tmp"); - return(NIL); - } - if( previous_size < (int)(sbuf.st_size) ) return(ATOM_T); -* * * * * * * * * * * * * */ + if(rval != 0) + { + error("osmessage error: can not find a log file under /tmp"); + return(NIL); + } + if( previous_size < (int)(sbuf.st_size) ) return(ATOM_T); + * * * * * * * * * * * * * */ - if (logChanged) return(ATOM_T); + if (logChanged) return (ATOM_T); #endif /* XWINDOW */ #endif /* DOS */ - return(NIL); + return (NIL); } - - /************************************************************************/ /* */ /* m e s s _ r e a d */ @@ -285,78 +264,71 @@ LispPTR mess_readp() /* */ /************************************************************************/ -LispPTR mess_read(args) - LispPTR *args; - /* args[0] buffer */ - { +LispPTR mess_read(args) LispPTR *args; +/* args[0] buffer */ +{ #if defined(DOS) || defined(XWINDOW) - return (NIL); + return (NIL); #else - int id; - struct stat sbuf; - int size, save_size; - char *base; - LispPTR *naddress; - int i; - static char temp_buf[MESSAGE_BUFFER_SIZE]; + int id; + struct stat sbuf; + int size, save_size; + char *base; + LispPTR *naddress; + int i; + static char temp_buf[MESSAGE_BUFFER_SIZE]; - SETJMP(NIL); + SETJMP(NIL); - /* Get buff address from LISP */ - naddress = (LispPTR *)(Addr68k_from_LADDR(args[0])); - base = (char *)(Addr68k_from_LADDR(((OneDArray *)naddress)->base)); - - close(log_id); - TIMEOUT(log_id=open(logfile, O_RDONLY)); - if(log_id == -1)return(NIL); - TIMEOUT(i=fstat(log_id, &sbuf)); - if(i != 0) - { - OSMESSAGE_PRINT( printf("stat err\n") ); - return(NIL); - } - save_size = (int)(sbuf.st_size); - size = save_size - previous_size; - if(size > MESSAGE_BUFFER_SIZE) size = MESSAGE_BUFFER_SIZE; - else logChanged = 0; /* only reset msg-pending flg if we cleaned it out! */ - TIMEOUT(i=lseek(log_id, previous_size, L_SET)); - if(i == -1) - { - OSMESSAGE_PRINT( printf("seek err\n") ); - return(NIL); - } - - /* Now, read "console output" */ - TIMEOUT(size=read(log_id, temp_buf, size)); - if(size == -1) - { - OSMESSAGE_PRINT( printf("read err\n") ); - return(NIL); - } - TIMEOUT(i=lseek(log_id, save_size, L_SET)); - if(i == -1) - { - OSMESSAGE_PRINT( printf("seek err\n") ); - return(NIL); - } -/* - TIMEOUT( close(id) ); -*/ - previous_size += size; - - for(i=0;ibase)); + close(log_id); + TIMEOUT(log_id = open(logfile, O_RDONLY)); + if (log_id == -1) return (NIL); + TIMEOUT(i = fstat(log_id, &sbuf)); + if (i != 0) { + OSMESSAGE_PRINT(printf("stat err\n")); + return (NIL); + } + save_size = (int)(sbuf.st_size); + size = save_size - previous_size; + if (size > MESSAGE_BUFFER_SIZE) + size = MESSAGE_BUFFER_SIZE; + else + logChanged = 0; /* only reset msg-pending flg if we cleaned it out! */ + TIMEOUT(i = lseek(log_id, previous_size, L_SET)); + if (i == -1) { + OSMESSAGE_PRINT(printf("seek err\n")); + return (NIL); } + /* Now, read "console output" */ + TIMEOUT(size = read(log_id, temp_buf, size)); + if (size == -1) { + OSMESSAGE_PRINT(printf("read err\n")); + return (NIL); + } + TIMEOUT(i = lseek(log_id, save_size, L_SET)); + if (i == -1) { + OSMESSAGE_PRINT(printf("seek err\n")); + return (NIL); + } + /* + TIMEOUT( close(id) ); + */ + previous_size += size; + for (i = 0; i < size; ++i) { + if (temp_buf[i] == '\n') temp_buf[i] = '\000'; + } + /* COPY actual Lisp Buffer(for BYTESWAP magic) */ + StrNCpyFromCToLisp(base, temp_buf, size); + + return (GetSmallp(size)); +#endif /* DOS | XWINDOW*/ +} /************************************************************************/ /* */ @@ -369,79 +341,69 @@ LispPTR mess_read(args) /* */ /************************************************************************/ -LispPTR flush_pty() - { +LispPTR flush_pty() { #if defined(DOS) || defined(XWINDOW) - return (NIL); + return (NIL); #else - int id; - struct stat sbuf; - char buf[MESSAGE_BUFFER_SIZE]; /* Buffer between pty and log file */ - int size; - static int rfds; - int rval; - struct statfs fsbuf; + int id; + struct stat sbuf; + char buf[MESSAGE_BUFFER_SIZE]; /* Buffer between pty and log file */ + int size; + static int rfds; + int rval; + struct statfs fsbuf; - SETJMP(NIL); - DBPRINT(("flush_pty() called.\n")); + SETJMP(NIL); + DBPRINT(("flush_pty() called.\n")); /* polling pty nd flush os message to log file */ #ifndef LOGINT - rfds = (1 << cons_pty); - if(select(32, &rfds, NULL, NULL, &selecttimeout) < 0 ) return(NIL); + rfds = (1 << cons_pty); + if (select(32, &rfds, NULL, NULL, &selecttimeout) < 0) return (NIL); - if( (cons_pty >= 0) && (rfds & (1 << cons_pty)) ) + if ((cons_pty >= 0) && (rfds & (1 << cons_pty))) #else /* LOGINT */ - if ((cons_pty >= 0) && - ((size = read(cons_pty, buf, MESSAGE_BUFFER_SIZE-1)) > 0)) + if ((cons_pty >= 0) && ((size = read(cons_pty, buf, MESSAGE_BUFFER_SIZE - 1)) > 0)) #endif - { /* There are messages to log in the file. */ - DBPRINT(("Log msgs being printed...\n")); - close(log_id); - TIMEOUT( log_id=open(logfile, O_WRONLY | O_APPEND, 0666) ); - if( log_id == -1)return(NIL); + { /* There are messages to log in the file. */ + DBPRINT(("Log msgs being printed...\n")); + close(log_id); + TIMEOUT(log_id = open(logfile, O_WRONLY | O_APPEND, 0666)); + if (log_id == -1) return (NIL); #ifndef LOGINT - size = read(cons_pty, buf, MESSAGE_BUFFER_SIZE-1); + size = read(cons_pty, buf, MESSAGE_BUFFER_SIZE - 1); #endif - if(size == -1) return(NIL); + if (size == -1) return (NIL); - /* Check free space to avoid print System Error Mesage - to /dev/console */ - TIMEOUT( rval=statfs("/tmp", &fsbuf) ); - if( rval != 0) return(NIL); + /* Check free space to avoid print System Error Mesage + to /dev/console */ + TIMEOUT(rval = statfs("/tmp", &fsbuf)); + if (rval != 0) return (NIL); - if(fsbuf.f_bavail <= (long)0) - { - /* No Free Space */ - error("osmessage error: No free space on file system (/tmp)."); - return(NIL); - } - logChanged = 1; /* Note the change, for READP */ - TIMEOUT( rval=write(log_id, buf, size) ); - if( rval == -1) - { - if(errno == ENOSPC) /* == 28 on Sun, ibm */ - { - /* No free space, but it's too late to avoid - print system Error Message. */ - error("osmessage error: No free space on file system (/tmp)."); - return(NIL); - } - else - { - error("osmessage error: cannot write to log file (/tmp)"); - return(NIL); - } - } - else - { -/** - close(id); -**/ - return(ATOM_T); - } + if (fsbuf.f_bavail <= (long)0) { + /* No Free Space */ + error("osmessage error: No free space on file system (/tmp)."); + return (NIL); + } + logChanged = 1; /* Note the change, for READP */ + TIMEOUT(rval = write(log_id, buf, size)); + if (rval == -1) { + if (errno == ENOSPC) /* == 28 on Sun, ibm */ + { + /* No free space, but it's too late to avoid + print system Error Message. */ + error("osmessage error: No free space on file system (/tmp)."); + return (NIL); + } else { + error("osmessage error: cannot write to log file (/tmp)"); + return (NIL); } -#endif /* XWINDOW | DOS */ + } else { + /** + close(id); + **/ + return (ATOM_T); + } } - - +#endif /* XWINDOW | DOS */ +} diff --git a/src/perrno.c b/src/perrno.c old mode 100755 new mode 100644 index 0a68b3a..05d39e1 --- a/src/perrno.c +++ b/src/perrno.c @@ -1,12 +1,7 @@ -/* $Id: perrno.c,v 1.4 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: perrno.c,v 1.4 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: perrno.c,v 1.4 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue"; - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -21,13 +16,9 @@ static char *id = "$Id: perrno.c,v 1.4 2001/12/26 22:17:04 sybalsky Exp $ Copyri #include "version.h" - - -#include -#include -#include "osmsg.h" - - +#include +#include +#include "osmsg.h" /************************************************************************/ /* */ @@ -39,7 +30,7 @@ static char *id = "$Id: perrno.c,v 1.4 2001/12/26 22:17:04 sybalsky Exp $ Copyri extern int errno; #if defined(MACOSX) || defined(FREEBSD) -extern const char * const sys_errlist[]; +extern const char *const sys_errlist[]; extern const int sys_nerr; #else int sys_nerr; @@ -48,11 +39,8 @@ extern char *sys_errlist[]; #endif /* LINUX */ #endif -void perrorn(char *s, int n) -{ - if ( s != NULL && *s != '\0' ) { - fprintf(stderr, "%s: ",s); - } +void perrorn(char *s, int n) { + if (s != NULL && *s != '\0') { fprintf(stderr, "%s: ", s); } if (n > 0 && n < sys_nerr) { fprintf(stderr, "%s\n", sys_errlist[n]); } else { @@ -60,8 +48,6 @@ void perrorn(char *s, int n) } } - - /************************************************************************/ /* */ /* e r r _ m e s s */ @@ -71,15 +57,13 @@ void perrorn(char *s, int n) /* */ /************************************************************************/ -void err_mess(char *from, int no) -{ - int save_errno=errno; /* Save errno around OSMESSAGE_PRINT */ +void err_mess(char *from, int no) { + int save_errno = errno; /* Save errno around OSMESSAGE_PRINT */ + OSMESSAGE_PRINT({ + fprintf(stderr, "System call error: %s errno=%d ", from, no); + perror(""); + }); - OSMESSAGE_PRINT({fprintf(stderr, - "System call error: %s errno=%d ", - from, no); perror("");}); - - errno=save_errno; - - } + errno = save_errno; +} diff --git a/src/picture.c b/src/picture.c old mode 100755 new mode 100644 index ab8e074..ff8f35d --- a/src/picture.c +++ b/src/picture.c @@ -1,8 +1,7 @@ -/* $Id: picture.c,v 1.2 1999/01/03 02:07:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: picture.c,v 1.2 1999/01/03 02:07:30 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: picture.c,v 1.2 1999/01/03 02:07:30 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: picture.c,v 1.2 1999/01/03 02:07:30 sybalsky Exp $ Copyr #include "version.h" - #include #include @@ -29,678 +27,548 @@ static char *id = "$Id: picture.c,v 1.2 1999/01/03 02:07:30 sybalsky Exp $ Copyr #include "lspglob.h" #define FALSE 0 -#define TRUE !FALSE +#define TRUE !FALSE #include "picture.h" -#define min(x,y) (((x) > (y)) ? (y) : (x)) -#define max(x,y) (((x) > (y)) ? (x) : (y)) +#define min(x, y) (((x) > (y)) ? (y) : (x)) +#define max(x, y) (((x) > (y)) ? (x) : (y)) - -#define LStringToCString(Lisp, C, MaxLen ,Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int i; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ - Len = min(MaxLen, arrayp->totalsize); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(i=0;ibase))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(i=0;itotalsize); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = \ + ((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + for (i = 0; i < Len; i++) C[i] = base[i]; \ + C[Len] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = \ + ((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (i = 0; i < Len * 2; i++) C[i] = base[i]; \ + C[Len * 2] = '\0'; \ + break; \ + \ + default: error("LStringToCString can not handle\n"); \ + } \ } -#define CStringToLString(C, Lisp, Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int id; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(id=0;idfillpointer = Len; \ - break; \ - \ - case FAT_CHAR_TYPENUMBER: \ - sbase = ((short *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(id=0;idfillpointer = Len; \ - break; \ - \ - default: \ - error("CStringToLString can not handle\n"); \ - } \ +#define CStringToLString(C, Lisp, Len) \ + { \ + OneDArray *arrayp; \ + char *base; \ + short *sbase; \ + int id; \ + \ + arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = \ + ((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + for (id = 0; id < Len; id++) base[id] = C[id]; \ + arrayp->fillpointer = Len; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = \ + ((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (id = 0; id < Len * 2; id++) base[id] = C[id]; \ + arrayp->fillpointer = Len; \ + break; \ + \ + default: error("CStringToLString can not handle\n"); \ + } \ } -#define IntToFixp(C, Lisp) \ - { \ - int *base; \ - \ - base = (int *) Addr68k_from_LADDR((unsigned int)Lisp); \ - *base = C; \ +#define IntToFixp(C, Lisp) \ + { \ + int *base; \ + \ + base = (int *)Addr68k_from_LADDR((unsigned int)Lisp); \ + *base = C; \ } -#define PICT_CREATE 0 -#define PICT_FREE 1 -#define PICT_GETVALUE 2 -#define PICT_SETVALUE 3 -#define PICT_GET 4 -#define PICT_PUT 5 -#define PICT_BITBLT 6 -#define PICT_BLTSHADE 7 +#define PICT_CREATE 0 +#define PICT_FREE 1 +#define PICT_GETVALUE 2 +#define PICT_SETVALUE 3 +#define PICT_GET 4 +#define PICT_PUT 5 +#define PICT_BITBLT 6 +#define PICT_BLTSHADE 7 -#define VIDEOFILE_OPEN 64 -#define VIDEOFILE_CLOSE 65 -#define VIDEOFILE_READ 66 -#define VIDEOFILE_WRITE 67 -#define VIDEOFILE_POSITION 68 +#define VIDEOFILE_OPEN 64 +#define VIDEOFILE_CLOSE 65 +#define VIDEOFILE_READ 66 +#define VIDEOFILE_WRITE 67 +#define VIDEOFILE_POSITION 68 -extern DLword REPLACE_atom - , INVERT_atom - , PAINT_atom - , ERASE_atom; +extern DLword REPLACE_atom, INVERT_atom, PAINT_atom, ERASE_atom; #ifdef VIDEO extern int Video_OnOff_Flg; #endif /* VIDEO */ - -LispPTR -Picture_Op( args ) -LispPTR *args; +LispPTR Picture_Op(args) LispPTR *args; { - int op; - LispPTR ret_value; - - op = (DLword)args[0]; + int op; + LispPTR ret_value; - switch( op ) { - case PICT_CREATE: - ret_value = (LispPTR) Picture_Create( args ); - break; - case PICT_FREE: - ret_value = Picture_Free( args ); - break; - case PICT_GETVALUE: - ret_value = Picture_GetValue( args ); - break; - case PICT_SETVALUE: - ret_value = Picture_SetValue( args ); - break; - case PICT_GET: - ret_value = Picture_Get( args ); - break; - case PICT_PUT: - ret_value = Picture_Put( args ); - break; - case PICT_BITBLT: - ret_value = Picture_Bitblt( args ); - break; - case PICT_BLTSHADE: - ret_value = Picture_Bltshade( args ); - break; - case VIDEOFILE_OPEN: - ret_value = VideoFile_Open( args ); - break; - case VIDEOFILE_CLOSE: - ret_value = VideoFile_Close( args ); - break; - case VIDEOFILE_READ: - ret_value = VideoFile_Read( args ); - break; - case VIDEOFILE_WRITE: - ret_value = VideoFile_Write( args ); - break; - case VIDEOFILE_POSITION: - ret_value = VideoFile_Position( args ); - break; - defaults: - ret_value = NIL; - break; - } /* end switch( op ) */ + op = (DLword)args[0]; - return( ret_value ); + switch (op) { + case PICT_CREATE: ret_value = (LispPTR)Picture_Create(args); break; + case PICT_FREE: ret_value = Picture_Free(args); break; + case PICT_GETVALUE: ret_value = Picture_GetValue(args); break; + case PICT_SETVALUE: ret_value = Picture_SetValue(args); break; + case PICT_GET: ret_value = Picture_Get(args); break; + case PICT_PUT: ret_value = Picture_Put(args); break; + case PICT_BITBLT: ret_value = Picture_Bitblt(args); break; + case PICT_BLTSHADE: ret_value = Picture_Bltshade(args); break; + case VIDEOFILE_OPEN: ret_value = VideoFile_Open(args); break; + case VIDEOFILE_CLOSE: ret_value = VideoFile_Close(args); break; + case VIDEOFILE_READ: ret_value = VideoFile_Read(args); break; + case VIDEOFILE_WRITE: ret_value = VideoFile_Write(args); break; + case VIDEOFILE_POSITION: + ret_value = VideoFile_Position(args); + break; + defaults: + ret_value = NIL; + break; + } /* end switch( op ) */ + + return (ret_value); } -int -Picture_Create( args ) -LispPTR *args; +int Picture_Create(args) LispPTR *args; { - int width - , height - , bitsperpixel; - Pixrect *storage; - unsigned int *cell; + int width, height, bitsperpixel; + Pixrect *storage; + unsigned int *cell; - width = (DLword) args[1]; - height = (DLword) args[2]; - bitsperpixel = (DLword) args[3]; + width = (DLword)args[1]; + height = (DLword)args[2]; + bitsperpixel = (DLword)args[3]; - if( (bitsperpixel != 1) - && (bitsperpixel != 8) - && (bitsperpixel != 24) ) { - return( NULL ); - } /* end if( bitsperpixel ) */ + if ((bitsperpixel != 1) && (bitsperpixel != 8) && (bitsperpixel != 24)) { + return (NULL); + } /* end if( bitsperpixel ) */ - if( bitsperpixel == 24 ) bitsperpixel = 32; + if (bitsperpixel == 24) bitsperpixel = 32; - storage = mem_create( width, height, bitsperpixel ); - /* if storage is NULL, memory pixrect could not allocated. */ - /* Checking error must be done in Lisp. */ + storage = mem_create(width, height, bitsperpixel); + /* if storage is NULL, memory pixrect could not allocated. */ + /* Checking error must be done in Lisp. */ - /* Initial picture data is set. (may be white) */ - if( (bitsperpixel == 8) || (bitsperpixel == 24) ) { - pr_rop( storage, 0, 0, storage->pr_width, storage->pr_height - , PIX_SET, 0, 0, 0 ); - } /* end if( bitsprepixel ) */ + /* Initial picture data is set. (may be white) */ + if ((bitsperpixel == 8) || (bitsperpixel == 24)) { + pr_rop(storage, 0, 0, storage->pr_width, storage->pr_height, PIX_SET, 0, 0, 0); + } /* end if( bitsprepixel ) */ - cell = (unsigned int*)createcell68k( TYPE_FIXP ); - *cell = (unsigned int) storage; - return( LADDR_from_68k( cell ) ); + cell = (unsigned int *)createcell68k(TYPE_FIXP); + *cell = (unsigned int)storage; + return (LADDR_from_68k(cell)); } /* end Picture_Create */ extern Pixrect *TrueColorFb; -int -Picture_Free( args ) -LispPTR *args; +int Picture_Free(args) LispPTR *args; { - LispPicture *n_picture; - Pixrect *pict; + LispPicture *n_picture; + Pixrect *pict; - n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); - pict = (Pixrect*)n_picture->storage; + n_picture = (LispPicture *)Addr68k_from_LADDR(args[1]); + pict = (Pixrect *)n_picture->storage; - /* TrueColorFb should not be destory. */ - if( pict != TrueColorFb ) { - pr_destroy( pict ); - n_picture->storage = NULL; - } /* end if( pict ) */ - - return( T ); + /* TrueColorFb should not be destory. */ + if (pict != TrueColorFb) { + pr_destroy(pict); + n_picture->storage = NULL; + } /* end if( pict ) */ + + return (T); } /* end Picture_Free */ -int -Picture_GetValue( args ) -LispPTR *args; +int Picture_GetValue(args) LispPTR *args; { - LispPTR picture; - int x - , y - , value; - LispPicture *n_picture; - Pixrect *pict; - unsigned int *cell; + LispPTR picture; + int x, y, value; + LispPicture *n_picture; + Pixrect *pict; + unsigned int *cell; - n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); - x = (DLword) args[2]; - y = (DLword) args[3]; + n_picture = (LispPicture *)Addr68k_from_LADDR(args[1]); + x = (DLword)args[2]; + y = (DLword)args[3]; - pict = (Pixrect*)n_picture->storage; - value = pr_get( pict, x, y ); + pict = (Pixrect *)n_picture->storage; + value = pr_get(pict, x, y); - cell = (unsigned int*)createcell68k( TYPE_FIXP ); - *cell = (unsigned int) value; - return( LADDR_from_68k( cell ) ); + cell = (unsigned int *)createcell68k(TYPE_FIXP); + *cell = (unsigned int)value; + return (LADDR_from_68k(cell)); } /* end Picture_GetValue */ -int -Picture_SetValue( args ) -LispPTR *args; +int Picture_SetValue(args) LispPTR *args; { - int x - , y - , value; - LispPicture *n_picture; - struct pixrect *pict; + int x, y, value; + LispPicture *n_picture; + struct pixrect *pict; - n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); - x = (DLword) args[2]; - y = (DLword) args[3]; - N_GETNUMBER( args[4], value, bad_arg ); + n_picture = (LispPicture *)Addr68k_from_LADDR(args[1]); + x = (DLword)args[2]; + y = (DLword)args[3]; + N_GETNUMBER(args[4], value, bad_arg); - pict = (Pixrect*)n_picture->storage; - pr_put( pict, x, y, value ); - return( T ); + pict = (Pixrect *)n_picture->storage; + pr_put(pict, x, y, value); + return (T); -bad_arg: return( NIL ); +bad_arg: + return (NIL); } /* end Picture_SetValue */ -#define MAX_NAME_LEN 512 -static char file_name[ MAX_NAME_LEN ]; +#define MAX_NAME_LEN 512 +static char file_name[MAX_NAME_LEN]; -int -Picture_Get( args ) -LispPTR *args; +int Picture_Get(args) LispPTR *args; { - LispPicture *n_picture; - int length; + LispPicture *n_picture; + int length; - n_picture = (LispPicture *)Addr68k_from_LADDR( args[1] ); - LStringToCString( args[2], file_name, MAX_NAME_LEN, length ); + n_picture = (LispPicture *)Addr68k_from_LADDR(args[1]); + LStringToCString(args[2], file_name, MAX_NAME_LEN, length); - if( (n_picture->storage = (unsigned int)File_to_Pixrect( file_name )) != NULL ) { - n_picture->width = (DLword)(((Pixrect*)n_picture->storage)->pr_width); - n_picture->height = (DLword)(((Pixrect*)n_picture->storage)->pr_height); - n_picture->bitsperpixel = (DLword)(((Pixrect*)n_picture->storage)->pr_depth); - if( n_picture->bitsperpixel == 32 ) - n_picture->bitsperpixel = 24; - return( T ); - } else { - return( NIL ); - } /* end if */ + if ((n_picture->storage = (unsigned int)File_to_Pixrect(file_name)) != NULL) { + n_picture->width = (DLword)(((Pixrect *)n_picture->storage)->pr_width); + n_picture->height = (DLword)(((Pixrect *)n_picture->storage)->pr_height); + n_picture->bitsperpixel = (DLword)(((Pixrect *)n_picture->storage)->pr_depth); + if (n_picture->bitsperpixel == 32) n_picture->bitsperpixel = 24; + return (T); + } else { + return (NIL); + } /* end if */ } /* end Picture_Get */ -int -Picture_Put( args ) -LispPTR *args; +int Picture_Put(args) LispPTR *args; { - LispPicture *n_picture; - char *name; - int length; + LispPicture *n_picture; + char *name; + int length; - n_picture = (LispPicture*)Addr68k_from_LADDR( args[1] ); - LStringToCString( args[2], file_name, MAX_NAME_LEN, length ); + n_picture = (LispPicture *)Addr68k_from_LADDR(args[1]); + LStringToCString(args[2], file_name, MAX_NAME_LEN, length); - Pixrect_to_File( (Pixrect*)n_picture->storage, file_name ); + Pixrect_to_File((Pixrect *)n_picture->storage, file_name); - return( T ); + return (T); } /*end Picture_Put */ -Picture_Bitblt( args ) -LispPTR *args; +Picture_Bitblt(args) LispPTR *args; { - LispPicture *src - , *dst; - int src_left - , src_bottom - , dst_left - , dst_bottom - , top - , bottom - , left - , right - , width - , height - , stodx - , stody - , src_top - , dst_top; - int dty - , dlx - , sty - , slx; - int cl_src_left - , cl_src_bottom; - int video_flg; - LispPTR operation - , cl_region; + LispPicture *src, *dst; + int src_left, src_bottom, dst_left, dst_bottom, top, bottom, left, right, width, height, stodx, + stody, src_top, dst_top; + int dty, dlx, sty, slx; + int cl_src_left, cl_src_bottom; + int video_flg; + LispPTR operation, cl_region; - src = (LispPicture*)Addr68k_from_LADDR( args[1] ); - dst = (LispPicture*)Addr68k_from_LADDR( args[4] ); - N_GETNUMBER( args[2], src_left, bad_arg ); - N_GETNUMBER( args[3], src_bottom, bad_arg ); - N_GETNUMBER( args[5], dst_left, bad_arg ); - N_GETNUMBER( args[6], dst_bottom, bad_arg ); + src = (LispPicture *)Addr68k_from_LADDR(args[1]); + dst = (LispPicture *)Addr68k_from_LADDR(args[4]); + N_GETNUMBER(args[2], src_left, bad_arg); + N_GETNUMBER(args[3], src_bottom, bad_arg); + N_GETNUMBER(args[5], dst_left, bad_arg); + N_GETNUMBER(args[6], dst_bottom, bad_arg); - if( args[9] == PAINT_atom ) - operation = PIX_SRC | PIX_DST; - else if( args[9] == ERASE_atom ) - operation = PIX_NOT(PIX_SRC) & PIX_DST; - else if( args[9] == INVERT_atom ) - operation = PIX_SRC ^ PIX_DST; - else - operation = PIX_SRC; + if (args[9] == PAINT_atom) + operation = PIX_SRC | PIX_DST; + else if (args[9] == ERASE_atom) + operation = PIX_NOT(PIX_SRC) & PIX_DST; + else if (args[9] == INVERT_atom) + operation = PIX_SRC ^ PIX_DST; + else + operation = PIX_SRC; - cl_region = args[10]; + cl_region = args[10]; - N_GETNUMBER( args[11], cl_src_left, bad_arg ); - N_GETNUMBER( args[12], cl_src_bottom, bad_arg ); + N_GETNUMBER(args[11], cl_src_left, bad_arg); + N_GETNUMBER(args[12], cl_src_bottom, bad_arg); - top = dst->height; - left = bottom = 0; - right = dst->width; + top = dst->height; + left = bottom = 0; + right = dst->width; - if( cl_region != NIL_PTR ) { - LispPTR cl_value; - int tmp - , cl_left - , cl_bottom; + if (cl_region != NIL_PTR) { + LispPTR cl_value; + int tmp, cl_left, cl_bottom; - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, cl_left, bad_arg ); - left = max( left, cl_left ); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, cl_left, bad_arg); + left = max(left, cl_left); - cl_region = cdr( cl_region ); - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, cl_bottom, bad_arg ); - bottom = max( bottom, cl_bottom ); + cl_region = cdr(cl_region); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, cl_bottom, bad_arg); + bottom = max(bottom, cl_bottom); - cl_region = cdr( cl_region ); - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, tmp, bad_arg ); - right = min( right, cl_left+tmp ); + cl_region = cdr(cl_region); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, tmp, bad_arg); + right = min(right, cl_left + tmp); - cl_region = cdr( cl_region ); - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, tmp, bad_arg ); - top = min( top, cl_bottom+tmp); - } /* end if( cl_region ) */ + cl_region = cdr(cl_region); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, tmp, bad_arg); + top = min(top, cl_bottom + tmp); + } /* end if( cl_region ) */ - left = max( left, dst_left ); - bottom = max( bottom, dst_bottom ); + left = max(left, dst_left); + bottom = max(bottom, dst_bottom); - if( args[6] != NIL_PTR ) { - N_GETNUMBER( args[7], width, bad_arg ); - right = min( right, dst_left+width ); - } /* end if( args[6] ) */ + if (args[6] != NIL_PTR) { + N_GETNUMBER(args[7], width, bad_arg); + right = min(right, dst_left + width); + } /* end if( args[6] ) */ - if( args[7] != NIL_PTR ) { - N_GETNUMBER( args[8], height, bad_arg ); - top = min( top, dst_bottom+height ); - } /* end if( args[7] ) */ + if (args[7] != NIL_PTR) { + N_GETNUMBER(args[8], height, bad_arg); + top = min(top, dst_bottom + height); + } /* end if( args[7] ) */ - stodx = dst_left - src_left; - stody = dst_bottom - src_bottom; + stodx = dst_left - src_left; + stody = dst_bottom - src_bottom; - { - int tmp; + { + int tmp; - left = max( cl_src_left, max( 0, left-stodx ) ); - bottom = max( cl_src_bottom, max( 0, bottom-stody ) ); - tmp = src->width; - right = min( cl_src_left+tmp, min( right-stodx, src_left+width )); - tmp = src->height; - top = min( cl_src_bottom+tmp, min( top-stody, src_bottom+height )); - } + left = max(cl_src_left, max(0, left - stodx)); + bottom = max(cl_src_bottom, max(0, bottom - stody)); + tmp = src->width; + right = min(cl_src_left + tmp, min(right - stodx, src_left + width)); + tmp = src->height; + top = min(cl_src_bottom + tmp, min(top - stody, src_bottom + height)); + } - if( (right <= left) || (top <= bottom) ) return( NIL ); + if ((right <= left) || (top <= bottom)) return (NIL); - height = top - bottom; - width = right - left; + height = top - bottom; + width = right - left; - dty = dst->height - ( top+stody ); - dlx = left + stodx; - sty = src->height - top; - slx = left; + dty = dst->height - (top + stody); + dlx = left + stodx; + sty = src->height - top; + slx = left; #ifdef VIDEO - if( (video_flg = Video_OnOff_Flg) ) Video_OnOff( FALSE ); + if ((video_flg = Video_OnOff_Flg)) Video_OnOff(FALSE); #endif /* VIDEO */ - - pr_rop( (Pixrect*)dst->storage, dlx, dty, width, height - , operation, (Pixrect*)src->storage, slx, sty ); + pr_rop((Pixrect *)dst->storage, dlx, dty, width, height, operation, (Pixrect *)src->storage, slx, + sty); #ifdef VIDEO - if( video_flg ) Video_OnOff( TRUE ); + if (video_flg) Video_OnOff(TRUE); #endif /* VIDEO */ - bad_arg: - return( NIL ); + return (NIL); } /* end Picture_Bitblt */ -Picture_Bltshade( args ) -LispPTR *args; +Picture_Bltshade(args) LispPTR *args; { - LispPicture *dst; - unsigned int texture; - LispPTR cl_region; - int dst_left - , dst_bottom - , left - , right - , bottom - , top - , width - , height - , operation - , video_flg; + LispPicture *dst; + unsigned int texture; + LispPTR cl_region; + int dst_left, dst_bottom, left, right, bottom, top, width, height, operation, video_flg; - dst = (LispPicture*)Addr68k_from_LADDR( args[2] ); - N_GETNUMBER( args[1], texture, bad_arg ); - N_GETNUMBER( args[3], dst_left, bad_arg ); - N_GETNUMBER( args[4], dst_bottom, bad_arg ); + dst = (LispPicture *)Addr68k_from_LADDR(args[2]); + N_GETNUMBER(args[1], texture, bad_arg); + N_GETNUMBER(args[3], dst_left, bad_arg); + N_GETNUMBER(args[4], dst_bottom, bad_arg); - if( args[7] == PAINT_atom ) - operation = PIX_SRC | PIX_DST; - else if( args[7] == ERASE_atom ) - operation = PIX_NOT(PIX_SRC) & PIX_DST; - else if( args[7] == INVERT_atom ) - operation = PIX_SRC ^ PIX_DST; - else - operation = PIX_SRC; + if (args[7] == PAINT_atom) + operation = PIX_SRC | PIX_DST; + else if (args[7] == ERASE_atom) + operation = PIX_NOT(PIX_SRC) & PIX_DST; + else if (args[7] == INVERT_atom) + operation = PIX_SRC ^ PIX_DST; + else + operation = PIX_SRC; - cl_region = args[8]; + cl_region = args[8]; - switch( dst->bitsperpixel ) { - case 1: - texture &= 1; - break; - case 8: - texture &= 0xff; - break; - case 24: - texture &= POINTERMASK; - break; - defaulsts: - texture &= POINTERMASK; - break; - } /* end switch */ + switch (dst->bitsperpixel) { + case 1: texture &= 1; break; + case 8: texture &= 0xff; break; + case 24: + texture &= POINTERMASK; + break; + defaulsts: + texture &= POINTERMASK; + break; + } /* end switch */ - left = bottom = 0; - top = (int)(dst->height); - right = (int)(dst->width); + left = bottom = 0; + top = (int)(dst->height); + right = (int)(dst->width); - if( cl_region != NIL_PTR ) { - LispPTR cl_value; - int tmp - , cl_left - , cl_bottom; + if (cl_region != NIL_PTR) { + LispPTR cl_value; + int tmp, cl_left, cl_bottom; - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, cl_left, bad_arg ); - left = max( left, cl_left ); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, cl_left, bad_arg); + left = max(left, cl_left); - cl_region = cdr( cl_region ); - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, cl_bottom, bad_arg ); - bottom = max( bottom, cl_bottom ); + cl_region = cdr(cl_region); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, cl_bottom, bad_arg); + bottom = max(bottom, cl_bottom); - cl_region = cdr( cl_region ); - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, tmp, bad_arg ); - right = min( right, cl_left+tmp ); + cl_region = cdr(cl_region); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, tmp, bad_arg); + right = min(right, cl_left + tmp); - cl_region = cdr( cl_region ); - cl_value = car( cl_region ); - N_GETNUMBER( cl_value, tmp, bad_arg ); - top = min( top, cl_bottom+tmp); - } /* end if( cl_region ) */ + cl_region = cdr(cl_region); + cl_value = car(cl_region); + N_GETNUMBER(cl_value, tmp, bad_arg); + top = min(top, cl_bottom + tmp); + } /* end if( cl_region ) */ - left = max( left, dst_left ); - bottom = max( bottom, dst_bottom ); + left = max(left, dst_left); + bottom = max(bottom, dst_bottom); - if( args[5] != NIL_PTR ) { - N_GETNUMBER( args[5], width, bad_arg ); - right = min( right, dst_left+width ); - } /* end if( args[5] ) */ + if (args[5] != NIL_PTR) { + N_GETNUMBER(args[5], width, bad_arg); + right = min(right, dst_left + width); + } /* end if( args[5] ) */ - if( args[6] != NIL_PTR ) { - N_GETNUMBER( args[6], height, bad_arg ); - top = min( top, dst_bottom+height ); - } /* end if( args[6] ) */ + if (args[6] != NIL_PTR) { + N_GETNUMBER(args[6], height, bad_arg); + top = min(top, dst_bottom + height); + } /* end if( args[6] ) */ - if( (right <= left) || (top <= bottom) ) return( NIL ); - - height = top - bottom; - width = right - left; + if ((right <= left) || (top <= bottom)) return (NIL); + + height = top - bottom; + width = right - left; #ifdef VIDEO - if( (video_flg = Video_OnOff_Flg) ) Video_OnOff( FALSE ); + if ((video_flg = Video_OnOff_Flg)) Video_OnOff(FALSE); #endif /* VIDEO */ - - pr_rop( (Pixrect*)dst->storage, left, (int)(dst->height) - top - , width, height - , operation | PIX_COLOR( texture ), 0, 0, 0 ); + pr_rop((Pixrect *)dst->storage, left, (int)(dst->height) - top, width, height, + operation | PIX_COLOR(texture), 0, 0, 0); #ifdef VIDEO - if( video_flg ) Video_OnOff( TRUE ); + if (video_flg) Video_OnOff(TRUE); #endif /* VIDEO */ - bad_arg: - return( NIL ); - + return (NIL); + } /* end Picture_Bltshade */ -#define OPEN_FOR_READ 0 -#define OPEN_FOR_WRITE 1 +#define OPEN_FOR_READ 0 +#define OPEN_FOR_WRITE 1 -VideoFile_Open( args ) -LispPTR *args; +VideoFile_Open(args) LispPTR *args; { - unsigned int *cell - , videofile; - int length - , access; + unsigned int *cell, videofile; + int length, access; - LStringToCString( args[1], file_name, MAX_NAME_LEN, length ); - access = (DLword)args[2]; + LStringToCString(args[1], file_name, MAX_NAME_LEN, length); + access = (DLword)args[2]; - switch( access ) { - case OPEN_FOR_READ: - videofile = open_rasterfile( file_name ); - break; - case OPEN_FOR_WRITE: - videofile = create_rasterfile( file_name ); - break; - default: - videofile = 0; - break; - } /* end switch( access ) */ + switch (access) { + case OPEN_FOR_READ: videofile = open_rasterfile(file_name); break; + case OPEN_FOR_WRITE: videofile = create_rasterfile(file_name); break; + default: videofile = 0; break; + } /* end switch( access ) */ - cell = (unsigned int*)createcell68k( TYPE_FIXP ); - *cell = videofile; - return( LADDR_from_68k( cell ) ); + cell = (unsigned int *)createcell68k(TYPE_FIXP); + *cell = videofile; + return (LADDR_from_68k(cell)); } /* end VideoFile_Open */ -int -VideoFile_Close( args ) -LispPTR *args; +int VideoFile_Close(args) LispPTR *args; { - unsigned int videofile; - - N_GETNUMBER( args[1], videofile, bad_arg ); + unsigned int videofile; - close_rasterfile( videofile ); - return( T ); + N_GETNUMBER(args[1], videofile, bad_arg); + + close_rasterfile(videofile); + return (T); bad_arg: - return( NIL ); + return (NIL); } /* end VideoFile_Close */ -int -VideoFile_Read( args ) -LispPTR *args; +int VideoFile_Read(args) LispPTR *args; { - LispPicture *n_picture; - unsigned int *cell - , pix - , videofile; + LispPicture *n_picture; + unsigned int *cell, pix, videofile; - N_GETNUMBER( args[1], (unsigned int)videofile, bad_arg ); - n_picture = (LispPicture *)Addr68k_from_LADDR( args[2] ); + N_GETNUMBER(args[1], (unsigned int)videofile, bad_arg); + n_picture = (LispPicture *)Addr68k_from_LADDR(args[2]); - if( (n_picture->storage = (unsigned int)read_rasterfile( videofile )) != NULL ) { - n_picture->width = (DLword)(((Pixrect*)n_picture->storage)->pr_width); - n_picture->height = (DLword)(((Pixrect*)n_picture->storage)->pr_height); - n_picture->bitsperpixel = (DLword)(((Pixrect*)n_picture->storage)->pr_depth); - if( n_picture->bitsperpixel == 32 ) - n_picture->bitsperpixel = 24; + if ((n_picture->storage = (unsigned int)read_rasterfile(videofile)) != NULL) { + n_picture->width = (DLword)(((Pixrect *)n_picture->storage)->pr_width); + n_picture->height = (DLword)(((Pixrect *)n_picture->storage)->pr_height); + n_picture->bitsperpixel = (DLword)(((Pixrect *)n_picture->storage)->pr_depth); + if (n_picture->bitsperpixel == 32) n_picture->bitsperpixel = 24; - return( T ); /* normal return */ - } /* end if */ + return (T); /* normal return */ + } /* end if */ bad_arg: - return( NIL ); + return (NIL); } /* end VideoFile_Read */ -int -VideoFile_Write( args ) -LispPTR *args; +int VideoFile_Write(args) LispPTR *args; { - unsigned int videofile; - LispPicture *n_pict; - int status; + unsigned int videofile; + LispPicture *n_pict; + int status; - N_GETNUMBER( args[1], videofile, bad_arg ); - n_pict = (LispPicture *)Addr68k_from_LADDR( args[2] ); + N_GETNUMBER(args[1], videofile, bad_arg); + n_pict = (LispPicture *)Addr68k_from_LADDR(args[2]); - if( (status = write_rasterfile( videofile, (Pixrect*)n_pict->storage )) ) { - return( T ); - } /* end if( status ) */ + if ((status = write_rasterfile(videofile, (Pixrect *)n_pict->storage))) { + return (T); + } /* end if( status ) */ bad_arg: - return( NIL ); + return (NIL); } /* end VideoFile_Write */ -int -VideoFile_Position( args ) -LispPTR *args; +int VideoFile_Position(args) LispPTR *args; { - unsigned int videofile; - int n - , status; + unsigned int videofile; + int n, status; - N_GETNUMBER( args[1], videofile, bad_arg ); - n = (DLword) args[2]; + N_GETNUMBER(args[1], videofile, bad_arg); + n = (DLword)args[2]; - if( (status = position_rasterfile( videofile, n )) ) { - return( T ); - } /* end if( status ) */ + if ((status = position_rasterfile(videofile, n))) { return (T); } /* end if( status ) */ bad_arg: - return( NIL ); - -} /* end VideoFile_Position */ + return (NIL); +} /* end VideoFile_Position */ diff --git a/src/rawcolor.c b/src/rawcolor.c old mode 100755 new mode 100644 index accf1b7..2706389 --- a/src/rawcolor.c +++ b/src/rawcolor.c @@ -1,7 +1,7 @@ -/* $Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* C O L O R B I T B L T / G R A P H I C S S U P P O R T */ @@ -10,12 +10,6 @@ static char *id = "$Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ Copy /* */ /************************************************************************/ - - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -30,8 +24,6 @@ static char *id = "$Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ Copy #include "version.h" - - #include #include "lispemul.h" #include "lspglob.h" @@ -48,78 +40,85 @@ static char *id = "$Id: rawcolor.c,v 1.3 2001/12/26 22:17:04 sybalsky Exp $ Copy #include "bitblt.h" #include "lldsp.h" -#define IMIN(x,y) (((x) > (y)) ? (y) : (x)) -#define IMAX(x,y) (((x) > (y)) ? (x) : (y)) +#define IMIN(x, y) (((x) > (y)) ? (y) : (x)) +#define IMAX(x, y) (((x) > (y)) ? (x) : (y)) - /*******************************/ - /* A LISP Big-bitmap structure */ - /*******************************/ -typedef struct - { - LispPTR bigbmwidth; - LispPTR bigbmheight; - LispPTR bigbmlist; - } BIGBM; +/*******************************/ +/* A LISP Big-bitmap structure */ +/*******************************/ +typedef struct { + LispPTR bigbmwidth; + LispPTR bigbmheight; + LispPTR bigbmlist; +} BIGBM; - - -#define GetNewFragment(list,frag,type) \ - frag = (type)Addr68k_from_LADDR( car(list) ); \ - list = cdr( list ); +#define GetNewFragment(list, frag, type) \ + frag = (type)Addr68k_from_LADDR(car(list)); \ + list = cdr(list); LispPTR SLOWBLTCHAR_index; #define SLOWBLTCHAR_argnum 2 -#define PUNT_TO_SLOWBLTCHAR {\ - if(SLOWBLTCHAR_index==0xffffffff)\ - SLOWBLTCHAR_index= get_package_atom("\\PUNT.SLOWBLTCHAR", \ - 17, "INTERLISP", 9, NIL);\ - if(SLOWBLTCHAR_index==0xffffffff)\ - {error("SLOWBLTCHAR install fail"); return;} \ - CurrentStackPTR +=(SLOWBLTCHAR_argnum-1)*DLWORDSPER_CELL; \ - ccfuncall(SLOWBLTCHAR_index,SLOWBLTCHAR_argnum,3);return;} +#define PUNT_TO_SLOWBLTCHAR \ + { \ + if (SLOWBLTCHAR_index == 0xffffffff) \ + SLOWBLTCHAR_index = get_package_atom("\\PUNT.SLOWBLTCHAR", 17, "INTERLISP", 9, NIL); \ + if (SLOWBLTCHAR_index == 0xffffffff) { \ + error("SLOWBLTCHAR install fail"); \ + return; \ + } \ + CurrentStackPTR += (SLOWBLTCHAR_argnum - 1) * DLWORDSPER_CELL; \ + ccfuncall(SLOWBLTCHAR_index, SLOWBLTCHAR_argnum, 3); \ + return; \ + } /***********************************************************/ /* - C_slowbltchar + C_slowbltchar - by Takeshi - June 6, 1989 + by Takeshi + June 6, 1989 */ /***********************************************************/ /* I'll merge this macro with FGetNum later */ -#define SFGetNum(ptr, place) { \ - if(((ptr) & SEGMASK)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ - else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ - else {PUNT_TO_SLOWBLTCHAR;}} +#define SFGetNum(ptr, place) \ + { \ + if (((ptr)&SEGMASK) == S_POSITIVE) { \ + (place) = ((ptr)&0xffff); \ + } else if (((ptr)&SEGMASK) == S_NEGATIVE) { \ + (place) = (int)((ptr) | 0xffff0000); \ + } else { \ + PUNT_TO_SLOWBLTCHAR; \ + } \ + } - -/* place: native pointer +/* place: native pointer val: native value(should be smallp) puntcase: punt descriptions */ -#define FReplaceSmallp(place,val,puntcase) {\ - if ((0 <= (val)) && ((val) <= MAX_SMALL)) \ - (LispPTR)(place) = (LispPTR)(S_POSITIVE | (val));\ - else if(MIN_SMALL <= val)\ - (LispPTR)(place) = (LispPTR)(S_NEGATIVE | (0xffff & (val)));\ - else {puntcase;}} +#define FReplaceSmallp(place, val, puntcase) \ + { \ + if ((0 <= (val)) && ((val) <= MAX_SMALL)) \ + (LispPTR)(place) = (LispPTR)(S_POSITIVE | (val)); \ + else if (MIN_SMALL <= val) \ + (LispPTR)(place) = (LispPTR)(S_NEGATIVE | (0xffff & (val))); \ + else { \ + puntcase; \ + } \ + } /* charcode should be pos. smallp */ -#define charcode (args[0] & 0xffff) -#define displaystream args[1] -#define Char8Code(x) ((u_char)((x) & 0xff)) -#define CharSet(x) ((x) >> 8) +#define charcode (args[0] & 0xffff) +#define displaystream args[1] +#define Char8Code(x) ((u_char)((x)&0xff)) +#define CharSet(x) ((x) >> 8) #define PSEUDO_BLACK 255 #define PSEUDO_WHITE 0 LispPTR *SCREENBITMAPS68k; /* Initialized in initsout.c */ -LispPTR *COLORSCREEN68k; /* Initialized in initsout.c */ +LispPTR *COLORSCREEN68k; /* Initialized in initsout.c */ LispPTR COLORSCREEN_index; /* if it's 0xffffffff, not yet initialized */ - - - /************************************************************************/ /* */ /* C _ s l o w b l t c h a r */ @@ -130,190 +129,158 @@ LispPTR COLORSCREEN_index; /* if it's 0xffffffff, not yet initialized */ /* */ /************************************************************************/ -C_slowbltchar(args) - register LispPTR *args; - { - Stream *n_dstream; - DISPLAYDATA *n_dd; - FONTDESC *n_fontd; - CHARSETINFO *n_csinfo; - BITMAP *n_destbitmap; - int dest_bpp; - LispPTR csinfo; - int curx,cury,newx,rmargin,lmargin,xoff,yoff; - DLword cl_left, cl_right, cl_bottom, cl_top; - DLword src_w, src_h, src_x, src_y, dst_x, dst_y, w, h; +C_slowbltchar(args) register LispPTR *args; +{ + Stream *n_dstream; + DISPLAYDATA *n_dd; + FONTDESC *n_fontd; + CHARSETINFO *n_csinfo; + BITMAP *n_destbitmap; + int dest_bpp; + LispPTR csinfo; + int curx, cury, newx, rmargin, lmargin, xoff, yoff; + DLword cl_left, cl_right, cl_bottom, cl_top; + DLword src_w, src_h, src_x, src_y, dst_x, dst_y, w, h; + u_char forecolor, backcolor; + register int displayflg; - u_char forecolor,backcolor; - register int displayflg; + extern LispPTR *TOPWDS68k; + n_dstream = (Stream *)Addr68k_from_LADDR(displaystream); + n_dd = (DISPLAYDATA *)Addr68k_from_LADDR(n_dstream->IMAGEDATA); + n_fontd = (FONTDESC *)Addr68k_from_LADDR(n_dd->ddfont); + n_destbitmap = (BITMAP *)Addr68k_from_LADDR(n_dd->dddestination); - extern LispPTR *TOPWDS68k; + if ((n_fontd->ROTATION & 0xffff) == 0) { + if ((csinfo = *(((LispPTR *)Addr68k_from_LADDR(n_fontd->FONTCHARSETVECTOR)) + + CharSet(charcode))) == NIL) + PUNT_TO_SLOWBLTCHAR; /* CSINFO is not cached */ - n_dstream=(Stream*)Addr68k_from_LADDR(displaystream); - n_dd=(DISPLAYDATA*)Addr68k_from_LADDR(n_dstream->IMAGEDATA); - n_fontd=(FONTDESC*)Addr68k_from_LADDR(n_dd->ddfont); - n_destbitmap=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); + n_csinfo = (CHARSETINFO *)Addr68k_from_LADDR(csinfo); - if((n_fontd->ROTATION & 0xffff) == 0) - { + SFGetNum(n_dd->ddxposition, curx); + SFGetNum(n_dd->ddyposition, cury); + SFGetNum(n_dd->ddrightmargin, rmargin); + SFGetNum(n_dd->ddleftmargin, lmargin); + SFGetNum(n_dd->ddxoffset, xoff); + SFGetNum(n_dd->ddyoffset, yoff); + cl_left = n_dd->ddclippingleft; + cl_right = n_dd->ddclippingright; + cl_bottom = n_dd->ddclippingbottom; + cl_top = n_dd->ddclippingtop; - if((csinfo= - *(((LispPTR*)Addr68k_from_LADDR(n_fontd->FONTCHARSETVECTOR)) - + CharSet(charcode) )) == NIL ) - PUNT_TO_SLOWBLTCHAR; /* CSINFO is not cached */ + newx = curx + *(DLword *)Addr68k_from_LADDR(n_dd->ddwidthscache + Char8Code(charcode)); - n_csinfo =(CHARSETINFO*)Addr68k_from_LADDR(csinfo); - - SFGetNum(n_dd->ddxposition, curx); - SFGetNum(n_dd->ddyposition, cury); - SFGetNum(n_dd->ddrightmargin, rmargin); - SFGetNum(n_dd->ddleftmargin, lmargin); - SFGetNum(n_dd->ddxoffset, xoff); - SFGetNum(n_dd->ddyoffset, yoff); - cl_left = n_dd->ddclippingleft; - cl_right = n_dd->ddclippingright; - cl_bottom = n_dd->ddclippingbottom; - cl_top = n_dd->ddclippingtop; + if (newx > rmargin) PUNT_TO_SLOWBLTCHAR; /* do \DSPPRINTCR/LF */ - newx = curx + *(DLword*)Addr68k_from_LADDR(n_dd->ddwidthscache - + Char8Code(charcode)); - - if(newx > rmargin) - PUNT_TO_SLOWBLTCHAR; /* do \DSPPRINTCR/LF */ - - /* If we care about TOPW then it's too slow to create Menu etc. - But,if we don't,it causes some error **/ - { - WINDOW *window; - SCREEN *ColorScreenData; - if(COLORSCREEN_index==0xffffffff) - { /* Make sure COLOR lives? */ - COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); - COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); - } - ColorScreenData=(SCREEN*)Addr68k_from_LADDR(*COLORSCREEN68k); - window = (WINDOW*)Addr68k_from_LADDR(ColorScreenData->SCTOPW); - if((displaystream != ColorScreenData->SCTOPW) && - (displaystream != window->DSP) && - (displaystream != *TOPWDS68k) && - ((fmemb(n_dd->dddestination,*SCREENBITMAPS68k)) != NIL)) - PUNT_TO_SLOWBLTCHAR; - } - - FReplaceSmallp( n_dd->ddxposition, newx, PUNT_TO_SLOWBLTCHAR); - - /* make curx abs coord */ - curx += xoff; - cury += yoff; - - { register PILOTBBT *pbt; - register BITMAP *n_destBM,*n_srcBM; - register BIGBM *n_destBIGBM; - register int destYOffset; - register int width,sourceBitOffset; - extern int ScreenLocked; - extern int displayheight; - - n_srcBM=(BITMAP*)Addr68k_from_LADDR(n_csinfo->CHARSETBITMAP); - src_h = n_srcBM->bmheight; - src_w = n_srcBM->bmwidth; - - src_x = *((DLword*)Addr68k_from_LADDR( n_dd->ddoffsetscache - + Char8Code(charcode))); - src_y = 0; - w = *(DLword*)Addr68k_from_LADDR(n_dd->ddcharimagewidths - + Char8Code(charcode)); - h = src_h; - - (short)dst_x = (short)curx; - (short)dst_y = (short)cury - (short)n_csinfo->CHARSETDESCENT; - - { /* clipping */ - short left,right,bottom,top; - short stodx,stody; - - left = (short)IMAX( (short)dst_x, (short)cl_left ); - right = (short)IMIN( (short)dst_x+w, (short)cl_right ); - bottom = (short)IMAX( (short)dst_y, (short)cl_bottom ); - top = (short)IMIN( (short)dst_y+h, (short)cl_top ); - stodx = (short)dst_x - (short)src_x; - stody = (short)dst_y - (short)src_y; - left = IMAX( (short)src_x, IMAX( left-stodx, 0 ) ); - bottom = IMAX( (short)src_y, IMAX( bottom-stody , 0 ) ); - right = IMIN( (short)src_w, IMIN( (short)(src_x+w), right-stodx ) ); - top = IMIN( (short)src_h, IMIN( (short)(src_y+h), top-stody ) ); - if ( (right<=left) || (top<=bottom) ) return; - w = (DLword)(right - left); - h = (DLword)(top - bottom); - dst_x = (DLword)(left + stodx); - dst_y = (DLword)(bottom + stody); - src_x = (DLword)left; - src_y = (DLword)bottom; - } - - /* forground and bacground color */ - - if(n_dd->ddcolor ==NIL_PTR) - { - forecolor = PSEUDO_BLACK; - backcolor = PSEUDO_WHITE; - } - else - { - backcolor = 0xff & cdr(n_dd->ddcolor); - forecolor = 0xff & car(n_dd->ddcolor); - } - - if(GetTypeNumber( n_dd->dddestination ) == TYPE_BITMAP) - { /* Bitap */ - n_destBM=(BITMAP*)Addr68k_from_LADDR(n_dd->dddestination); - ScreenLocked=T; - /* xposition is shifted 3 Kludge for cursorin - in color(8bpp) ** x's meaning is different from - bitbltsub's. For now,I use this func with Kludge */ - displayflg=n_new_cursorin( - Addr68k_from_LADDR(n_destBM->bmbase),dst_x<<3, - /* Kludge:YCoordination upside down*/ - displayheight-cury,w,h); - if(displayflg) HideCursor; - - ColorizeFont8(n_srcBM, src_x, src_y - , n_destBM, dst_x, dst_y - , w, h - , backcolor,forecolor - , n_dd->ddsourcetype,n_dd->ddoperation); - - - if(displayflg) ShowCursor; - ScreenLocked=NIL; - - } - else - { /* BIGBM */ - ScreenLocked=T; - n_destBIGBM = (BIGBM*)n_destbitmap; - ColorizeFont8_BIGBM(n_srcBM, src_x, src_y - , n_destBIGBM, dst_x, dst_y - , w, h - , backcolor,forecolor - , n_dd->ddsourcetype,n_dd->ddoperation); - ScreenLocked=NIL; - } /* end if( TYPE_BITMAP ) */ - - - } + /* If we care about TOPW then it's too slow to create Menu etc. + But,if we don't,it causes some error **/ + { + WINDOW *window; + SCREEN *ColorScreenData; + if (COLORSCREEN_index == 0xffffffff) { /* Make sure COLOR lives? */ + COLORSCREEN_index = MAKEATOM("\\COLORSCREEN"); + COLORSCREEN68k = GetVALCELL68k(COLORSCREEN_index); } - else - { - /* ROTATE case ,do-PUNT */ - PUNT_TO_SLOWBLTCHAR; + ColorScreenData = (SCREEN *)Addr68k_from_LADDR(*COLORSCREEN68k); + window = (WINDOW *)Addr68k_from_LADDR(ColorScreenData->SCTOPW); + if ((displaystream != ColorScreenData->SCTOPW) && (displaystream != window->DSP) && + (displaystream != *TOPWDS68k) && ((fmemb(n_dd->dddestination, *SCREENBITMAPS68k)) != NIL)) + PUNT_TO_SLOWBLTCHAR; + } + + FReplaceSmallp(n_dd->ddxposition, newx, PUNT_TO_SLOWBLTCHAR); + + /* make curx abs coord */ + curx += xoff; + cury += yoff; + + { + register PILOTBBT *pbt; + register BITMAP *n_destBM, *n_srcBM; + register BIGBM *n_destBIGBM; + register int destYOffset; + register int width, sourceBitOffset; + extern int ScreenLocked; + extern int displayheight; + + n_srcBM = (BITMAP *)Addr68k_from_LADDR(n_csinfo->CHARSETBITMAP); + src_h = n_srcBM->bmheight; + src_w = n_srcBM->bmwidth; + + src_x = *((DLword *)Addr68k_from_LADDR(n_dd->ddoffsetscache + Char8Code(charcode))); + src_y = 0; + w = *(DLword *)Addr68k_from_LADDR(n_dd->ddcharimagewidths + Char8Code(charcode)); + h = src_h; + + (short)dst_x = (short)curx; + (short)dst_y = (short)cury - (short)n_csinfo->CHARSETDESCENT; + + { /* clipping */ + short left, right, bottom, top; + short stodx, stody; + + left = (short)IMAX((short)dst_x, (short)cl_left); + right = (short)IMIN((short)dst_x + w, (short)cl_right); + bottom = (short)IMAX((short)dst_y, (short)cl_bottom); + top = (short)IMIN((short)dst_y + h, (short)cl_top); + stodx = (short)dst_x - (short)src_x; + stody = (short)dst_y - (short)src_y; + left = IMAX((short)src_x, IMAX(left - stodx, 0)); + bottom = IMAX((short)src_y, IMAX(bottom - stody, 0)); + right = IMIN((short)src_w, IMIN((short)(src_x + w), right - stodx)); + top = IMIN((short)src_h, IMIN((short)(src_y + h), top - stody)); + if ((right <= left) || (top <= bottom)) return; + w = (DLword)(right - left); + h = (DLword)(top - bottom); + dst_x = (DLword)(left + stodx); + dst_y = (DLword)(bottom + stody); + src_x = (DLword)left; + src_y = (DLword)bottom; } - - } /* end C_slowbltchar */ + /* forground and bacground color */ + if (n_dd->ddcolor == NIL_PTR) { + forecolor = PSEUDO_BLACK; + backcolor = PSEUDO_WHITE; + } else { + backcolor = 0xff & cdr(n_dd->ddcolor); + forecolor = 0xff & car(n_dd->ddcolor); + } + + if (GetTypeNumber(n_dd->dddestination) == TYPE_BITMAP) { /* Bitap */ + n_destBM = (BITMAP *)Addr68k_from_LADDR(n_dd->dddestination); + ScreenLocked = T; + /* xposition is shifted 3 Kludge for cursorin + in color(8bpp) ** x's meaning is different from + bitbltsub's. For now,I use this func with Kludge */ + displayflg = n_new_cursorin(Addr68k_from_LADDR(n_destBM->bmbase), dst_x << 3, + /* Kludge:YCoordination upside down*/ + displayheight - cury, w, h); + if (displayflg) HideCursor; + + ColorizeFont8(n_srcBM, src_x, src_y, n_destBM, dst_x, dst_y, w, h, backcolor, forecolor, + n_dd->ddsourcetype, n_dd->ddoperation); + + if (displayflg) ShowCursor; + ScreenLocked = NIL; + + } else { /* BIGBM */ + ScreenLocked = T; + n_destBIGBM = (BIGBM *)n_destbitmap; + ColorizeFont8_BIGBM(n_srcBM, src_x, src_y, n_destBIGBM, dst_x, dst_y, w, h, backcolor, + forecolor, n_dd->ddsourcetype, n_dd->ddoperation); + ScreenLocked = NIL; + } /* end if( TYPE_BITMAP ) */ + } + } else { + /* ROTATE case ,do-PUNT */ + PUNT_TO_SLOWBLTCHAR; + } + +} /* end C_slowbltchar */ /************************************************************************/ /* */ @@ -327,50 +294,39 @@ C_slowbltchar(args) /************************************************************************/ #define MAXFONTHEIGHT 48 -#define MAXFONTWIDTH 48 -#define BITSPERNIBBLE 4 +#define MAXFONTWIDTH 48 +#define BITSPERNIBBLE 4 #define BITSPERDLWORD 16 -#define BPP 8 +#define BPP 8 -u_int ColorizedFont8CACHE[MAXFONTHEIGHT/BITSPERNIBBLE * - MAXFONTWIDTH/BITSPERNIBBLE]; +u_int ColorizedFont8CACHE[MAXFONTHEIGHT / BITSPERNIBBLE * MAXFONTWIDTH / BITSPERNIBBLE]; - -ColorizeFont8(sBM,sXOffset,sYOffset,dBM,dXOffset, - dYOffset,width,height,col0,col1,sourcetype,operation) - register BITMAP *sBM; - register DLword sXOffset,sYOffset, width, height; - register BITMAP *dBM; - DLword dYOffset,dXOffset; - u_char col0,col1; - LispPTR sourcetype; - LispPTR operation; +ColorizeFont8(sBM, sXOffset, sYOffset, dBM, dXOffset, dYOffset, width, height, col0, col1, + sourcetype, operation) register BITMAP *sBM; +register DLword sXOffset, sYOffset, width, height; +register BITMAP *dBM; +DLword dYOffset, dXOffset; +u_char col0, col1; +LispPTR sourcetype; +LispPTR operation; { register DLword *nbase; register u_char *dbase; register int i; - sYOffset = sBM->bmheight - (sYOffset+height); - dYOffset = dBM->bmheight - (dYOffset+height); + sYOffset = sBM->bmheight - (sYOffset + height); + dYOffset = dBM->bmheight - (dYOffset + height); - nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) - + (sBM->bmrasterwidth * sYOffset); - (DLword*)dbase= (DLword*)Addr68k_from_LADDR(dBM->bmbase) - + (dBM->bmrasterwidth * dYOffset); - for(i=0, dbase += dXOffset;/* 8bpp */ - i < height; - i++,nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dBM->bmrasterwidth) - { - lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); - } /* for end */ + nbase = (DLword *)Addr68k_from_LADDR(sBM->bmbase) + (sBM->bmrasterwidth * sYOffset); + (DLword *)dbase = (DLword *)Addr68k_from_LADDR(dBM->bmbase) + (dBM->bmrasterwidth * dYOffset); + for (i = 0, dbase += dXOffset; /* 8bpp */ + i < height; i++, nbase += sBM->bmrasterwidth, ((DLword *)dbase) += dBM->bmrasterwidth) { + lineBlt8(nbase, (int)sXOffset, dbase, (int)width, col0, col1, sourcetype, operation); + } /* for end */ } /* ColorizeFont8 end */ - - - - /************************************************************************/ /* */ /* C o l o r i z e d F o n t 8 _ B I G B M */ @@ -382,93 +338,82 @@ ColorizeFont8(sBM,sXOffset,sYOffset,dBM,dXOffset, /* */ /************************************************************************/ -ColorizeFont8_BIGBM(sBM,sXOffset,sYOffset,dBM,dXOffset,dYOffset,width,height,col0,col1,sourcetype,operation) -register BITMAP *sBM; -register DLword sXOffset,sYOffset,width,height; +ColorizeFont8_BIGBM(sBM, sXOffset, sYOffset, dBM, dXOffset, dYOffset, width, height, col0, col1, + sourcetype, operation) register BITMAP *sBM; +register DLword sXOffset, sYOffset, width, height; register BIGBM *dBM; DLword dXOffset, dYOffset; -u_char col0,col1; +u_char col0, col1; LispPTR sourcetype; LispPTR operation; - { register DLword *nbase; register u_char *dbase; register int i; - int dest_bottom - , dest_bigbmheight - , dest_fragtop - , dest_fragbottom - , dest_yoffset - , dest_h; + int dest_bottom, dest_bigbmheight, dest_fragtop, dest_fragbottom, dest_yoffset, dest_h; LispPTR dest_bmlist; BITMAP *dest_frag; - SFGetNum( dBM->bigbmheight, dest_bigbmheight ); + SFGetNum(dBM->bigbmheight, dest_bigbmheight); - sYOffset = sBM->bmheight - ( sYOffset+height ); - dYOffset = dest_bigbmheight - ( dYOffset+height ); + sYOffset = sBM->bmheight - (sYOffset + height); + dYOffset = dest_bigbmheight - (dYOffset + height); - dest_bottom = dYOffset + height; - dest_bmlist = (LispPTR)dBM->bigbmlist; - GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); - dest_fragtop = 0; - dest_fragbottom = dest_frag->bmheight; + dest_bottom = dYOffset + height; + dest_bmlist = (LispPTR)dBM->bigbmlist; + GetNewFragment(dest_bmlist, dest_frag, BITMAP *); + dest_fragtop = 0; + dest_fragbottom = dest_frag->bmheight; -/* search fragment of bitmaps including the desitnation top. */ - while( dest_fragbottom <= dYOffset ) { - GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); - if( dest_frag == (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) return; - dest_fragtop = dest_fragbottom; - dest_fragbottom += dest_frag->bmheight; - } /* end while */ - -/* y offset form bitmap top. */ - dest_yoffset = dYOffset - dest_fragtop; + /* search fragment of bitmaps including the desitnation top. */ + while (dest_fragbottom <= dYOffset) { + GetNewFragment(dest_bmlist, dest_frag, BITMAP *); + if (dest_frag == (BITMAP *)Addr68k_from_LADDR(NIL_PTR)) return; + dest_fragtop = dest_fragbottom; + dest_fragbottom += dest_frag->bmheight; + } /* end while */ + + /* y offset form bitmap top. */ + dest_yoffset = dYOffset - dest_fragtop; loop: -/* height of lineBlt8 */ - if( dest_fragbottom > dest_bottom ) { - /* this fragment inludes dest bottom. */ - dest_h = dest_bottom - (dest_fragtop + dest_yoffset); - } else { - /* remaining fragments include dest bottom. */ - dest_h = dest_fragbottom - (dest_fragtop + dest_yoffset); - } /* end if */ + /* height of lineBlt8 */ + if (dest_fragbottom > dest_bottom) { + /* this fragment inludes dest bottom. */ + dest_h = dest_bottom - (dest_fragtop + dest_yoffset); + } else { + /* remaining fragments include dest bottom. */ + dest_h = dest_fragbottom - (dest_fragtop + dest_yoffset); + } /* end if */ - dbase= (DLword*)Addr68k_from_LADDR(dest_frag->bmbase) - + (dest_frag->bmrasterwidth * dest_yoffset); - nbase=(DLword*)Addr68k_from_LADDR(sBM->bmbase) - + (sBM->bmrasterwidth * sYOffset); + dbase = + (DLword *)Addr68k_from_LADDR(dest_frag->bmbase) + (dest_frag->bmrasterwidth * dest_yoffset); + nbase = (DLword *)Addr68k_from_LADDR(sBM->bmbase) + (sBM->bmrasterwidth * sYOffset); - sYOffset += (DLword)dest_h; /* next src yoffset */ + sYOffset += (DLword)dest_h; /* next src yoffset */ - for(i=0, dbase += dXOffset; - i < dest_h; - i++, nbase += sBM->bmrasterwidth , ((DLword*)dbase) += dest_frag->bmrasterwidth) - { - lineBlt8(nbase,(int)sXOffset,dbase,(int)width,col0,col1,sourcetype,operation); - } - -/* remaining height */ - height -= dest_h; - if( height > 0 ) { - GetNewFragment( dest_bmlist, dest_frag, BITMAP* ); - if( dest_frag != (BITMAP*)Addr68k_from_LADDR(NIL_PTR) ) { - dest_fragtop = dest_fragbottom; - dest_fragbottom = dest_fragtop + dest_frag->bmheight; - dest_yoffset = 0; /* y offset must be zero. */ - nbase += sBM->bmrasterwidth; - goto loop; - } /* end if(dest_frag) */ - } /* end if(height) */ + for (i = 0, dbase += dXOffset; i < dest_h; + i++, nbase += sBM->bmrasterwidth, ((DLword *)dbase) += dest_frag->bmrasterwidth) { + lineBlt8(nbase, (int)sXOffset, dbase, (int)width, col0, col1, sourcetype, operation); + } + + /* remaining height */ + height -= dest_h; + if (height > 0) { + GetNewFragment(dest_bmlist, dest_frag, BITMAP *); + if (dest_frag != (BITMAP *)Addr68k_from_LADDR(NIL_PTR)) { + dest_fragtop = dest_fragbottom; + dest_fragbottom = dest_fragtop + dest_frag->bmheight; + dest_yoffset = 0; /* y offset must be zero. */ + nbase += sBM->bmrasterwidth; + goto loop; + } /* end if(dest_frag) */ + } /* end if(height) */ } /* end ColorizeFont8_BIGBM() */ - - /************************************************************************/ /* */ /* n e w C o l o r i z e F o n t 8 */ @@ -477,32 +422,23 @@ loop: /* */ /************************************************************************/ -newColorizeFont8(pbt,backcolor,forecolor,srctype,ope) - PILOTBBT *pbt; - u_char backcolor,forecolor; - LispPTR srctype,ope; +newColorizeFont8(pbt, backcolor, forecolor, srctype, ope) PILOTBBT *pbt; +u_char backcolor, forecolor; +LispPTR srctype, ope; { - register DLword *nbase; - register u_char *dbase; - register int i; - - nbase=(DLword*)Addr68k_from_LADDR - ((pbt->pbtsourcehi << 16 ) | (pbt->pbtsourcelo)) ; - (DLword*)dbase= (DLword*)Addr68k_from_LADDR( - (pbt->pbtdesthi << 16 ) | (pbt->pbtdestlo)) ; - dbase += pbt->pbtdestbit; - for(i=0; i < pbt->pbtheight; - i++,nbase += pbt->pbtsourcebpl/16 - , dbase += pbt->pbtdestbpl/8) - { - lineBlt8(nbase,pbt->pbtsourcebit,dbase,pbt->pbtwidth,backcolor,forecolor,srctype,ope); - } /* for end */ - + register DLword *nbase; + register u_char *dbase; + register int i; + nbase = (DLword *)Addr68k_from_LADDR((pbt->pbtsourcehi << 16) | (pbt->pbtsourcelo)); + (DLword *)dbase = (DLword *)Addr68k_from_LADDR((pbt->pbtdesthi << 16) | (pbt->pbtdestlo)); + dbase += pbt->pbtdestbit; + for (i = 0; i < pbt->pbtheight; + i++, nbase += pbt->pbtsourcebpl / 16, dbase += pbt->pbtdestbpl / 8) { + lineBlt8(nbase, pbt->pbtsourcebit, dbase, pbt->pbtwidth, backcolor, forecolor, srctype, ope); + } /* for end */ } - - /************************************************************************/ /* */ /* U n c o l o r i z e _ B i t m a p */ @@ -511,83 +447,74 @@ newColorizeFont8(pbt,backcolor,forecolor,srctype,ope) /* */ /************************************************************************/ -Uncolorize_Bitmap( args ) -LispPTR args[]; +Uncolorize_Bitmap(args) LispPTR args[]; { - BITMAP *s_bitmap - , *d_bitmap; - register DLword* OnOff; + BITMAP *s_bitmap, *d_bitmap; + register DLword *OnOff; - register u_char *s_base; - register DLword *d_base; - register int y; - int s_height - , s_width - , s_bitsperpixel - , s_rasterwidth - , d_rasterwidth; + register u_char *s_base; + register DLword *d_base; + register int y; + int s_height, s_width, s_bitsperpixel, s_rasterwidth, d_rasterwidth; - s_bitmap = (BITMAP*)Addr68k_from_LADDR( args[0] ); - d_bitmap = (BITMAP*)Addr68k_from_LADDR( args[1] ); - OnOff = (DLword*)Addr68k_from_LADDR( args[2] ); + s_bitmap = (BITMAP *)Addr68k_from_LADDR(args[0]); + d_bitmap = (BITMAP *)Addr68k_from_LADDR(args[1]); + OnOff = (DLword *)Addr68k_from_LADDR(args[2]); - s_height = s_bitmap->bmheight; - s_width = s_bitmap->bmwidth; - s_bitsperpixel = s_bitmap->bmbitperpixel; + s_height = s_bitmap->bmheight; + s_width = s_bitmap->bmwidth; + s_bitsperpixel = s_bitmap->bmbitperpixel; - if( s_bitsperpixel != 8 ) return; + if (s_bitsperpixel != 8) return; - s_base = (u_char*)Addr68k_from_LADDR(s_bitmap->bmbase); - d_base = (DLword*)Addr68k_from_LADDR(d_bitmap->bmbase); - s_rasterwidth = s_bitmap->bmrasterwidth; - d_rasterwidth = d_bitmap->bmrasterwidth; + s_base = (u_char *)Addr68k_from_LADDR(s_bitmap->bmbase); + d_base = (DLword *)Addr68k_from_LADDR(d_bitmap->bmbase); + s_rasterwidth = s_bitmap->bmrasterwidth; + d_rasterwidth = d_bitmap->bmrasterwidth; - for( y=0; ybmbase ) - + s_bitmap->bmrasterwidth * (s_bitmap->bmheight - (s_bottom + height)); - (DLword*)d_base = (DLword*)Addr68k_from_LADDR( d_bitmap->bmbase ) - + d_bitmap->bmrasterwidth * (d_bitmap->bmheight - (d_bottom + height)); + s_base = (DLword *)Addr68k_from_LADDR(s_bitmap->bmbase) + + s_bitmap->bmrasterwidth * (s_bitmap->bmheight - (s_bottom + height)); + (DLword *)d_base = (DLword *)Addr68k_from_LADDR(d_bitmap->bmbase) + + d_bitmap->bmrasterwidth * (d_bitmap->bmheight - (d_bottom + height)); - for( i=0, d_base += d_left; ibmrasterwidth - , (DLword*)d_base += d_bitmap->bmrasterwidth ) { + for (i = 0, d_base += d_left; i < height; + i++, s_base += s_bitmap->bmrasterwidth, (DLword *)d_base += d_bitmap->bmrasterwidth) { + lineBlt8(s_base, s_left, d_base, width, (u_char)color0, (u_char)color1, INPUT_atom, + REPLACE_atom); - lineBlt8( s_base, s_left, d_base, width - , (u_char)color0, (u_char)color1 - , INPUT_atom, REPLACE_atom ); + } /* end for(i) */ - } /* end for(i) */ - - bad_arg: return( NIL ); +bad_arg: + return (NIL); } /* end Colorize_Bitmap() */ - - /************************************************************************/ /* */ /* D r a w _ 8 B p p C o l o r L i n e */ @@ -662,127 +573,106 @@ LispPTR args[]; /************************************************************************/ #define op_replace = -#define op_erase &= -#define op_invert ^= -#define op_paint |= +#define op_erase &= +#define op_invert ^= +#define op_paint |= -#define draw8bpplinex(op) \ - while( (x0 <= xlimit) && ( y0 <= ylimit ) ) { \ - *(base++) op color; ++x0; cdl += dy; \ - if( dx <= cdl ) { \ - cdl -= dx; \ - base += yinc; ++y0; \ - } \ - } - -#define draw8bppliney(op) \ - while( (x0 <= xlimit) && (y0 <= ylimit ) ) { \ - *base op color; base += yinc; ++y0; cdl += dx; \ - if( dy <= cdl ) { \ - cdl -= dy; \ - ++ base; ++x0; \ - } \ - } +#define draw8bpplinex(op) \ + while ((x0 <= xlimit) && (y0 <= ylimit)) { \ + *(base++)op color; \ + ++x0; \ + cdl += dy; \ + if (dx <= cdl) { \ + cdl -= dx; \ + base += yinc; \ + ++y0; \ + } \ + } -Draw_8BppColorLine( args ) - register LispPTR *args; - { - extern DLword REPLACE_atom - , INVERT_atom - , PAINT_atom - , ERASE_atom; - extern int ScreenLocked; +#define draw8bppliney(op) \ + while ((x0 <= xlimit) && (y0 <= ylimit)) { \ + *base op color; \ + base += yinc; \ + ++y0; \ + cdl += dx; \ + if (dy <= cdl) { \ + cdl -= dy; \ + ++base; \ + ++x0; \ + } \ + } - register u_char color; - register u_char *base; - register short x0 - , y0 - , xlimit - , ylimit - , dx - , dy - , cdl - , yinc - , raster_width; - int mode - , displayflg; - u_char *n_bmbase; +Draw_8BppColorLine(args) register LispPTR *args; +{ + extern DLword REPLACE_atom, INVERT_atom, PAINT_atom, ERASE_atom; + extern int ScreenLocked; - x0 = (short)( args[0] &0xffff ); - y0 = (short)( args[1] &0xffff ); - xlimit = (short)( args[2] &0xffff ); - ylimit = (short)( args[3] &0xffff ); - dx = (short)( args[4] &0xffff ); - dy = (short)( args[5] &0xffff ); - cdl = (short)( args[6] &0xffff ); - yinc = (short)( args[7] &0xffff ); yinc *= 2; /* for byte addressing */ + register u_char color; + register u_char *base; + register short x0, y0, xlimit, ylimit, dx, dy, cdl, yinc, raster_width; + int mode, displayflg; + u_char *n_bmbase; - if ( args[8] == PAINT_atom ) mode = 3; - else if( args[8] == INVERT_atom ) mode = 2; - else if( args[8] == ERASE_atom ) mode = 1; - else mode = 0; /* REPLACE_atom */ + x0 = (short)(args[0] & 0xffff); + y0 = (short)(args[1] & 0xffff); + xlimit = (short)(args[2] & 0xffff); + ylimit = (short)(args[3] & 0xffff); + dx = (short)(args[4] & 0xffff); + dy = (short)(args[5] & 0xffff); + cdl = (short)(args[6] & 0xffff); + yinc = (short)(args[7] & 0xffff); + yinc *= 2; /* for byte addressing */ - n_bmbase = (u_char*)Addr68k_from_LADDR( args[9] ); - raster_width = (short) ( args[10] &0xffff ); - color = (u_char)( args[11] & 0xff ); + if (args[8] == PAINT_atom) + mode = 3; + else if (args[8] == INVERT_atom) + mode = 2; + else if (args[8] == ERASE_atom) + mode = 1; + else + mode = 0; /* REPLACE_atom */ - if( yinc >= 0 ) - { - displayflg = n_new_cursorin( (DLword*)n_bmbase - , (int)(x0<<3), (int)y0, (int)(xlimit<<3), (int)ylimit ); - } - else - { - displayflg = - n_new_cursorin( (DLword*)n_bmbase, - (int)(x0<<3), (int)(y0-ylimit), - (int)(xlimit<<3), (int)ylimit ); - } + n_bmbase = (u_char *)Addr68k_from_LADDR(args[9]); + raster_width = (short)(args[10] & 0xffff); + color = (u_char)(args[11] & 0xff); - base = n_bmbase + y0 * (raster_width << 1) + x0; - x0 = y0 = 0; + if (yinc >= 0) { + displayflg = n_new_cursorin((DLword *)n_bmbase, (int)(x0 << 3), (int)y0, (int)(xlimit << 3), + (int)ylimit); + } else { + displayflg = n_new_cursorin((DLword *)n_bmbase, (int)(x0 << 3), (int)(y0 - ylimit), + (int)(xlimit << 3), (int)ylimit); + } - if( displayflg ) - { - ScreenLocked = T; - HideCursor; - } + base = n_bmbase + y0 * (raster_width << 1) + x0; + x0 = y0 = 0; - if( dx >= dy ) - { /* .draw8bpplinex */ - switch( mode ) - { - case 0: draw8bpplinex( op_replace ); - break; - case 1: draw8bpplinex( op_erase ); - break; - case 2: draw8bpplinex( op_invert ); - break; - case 3: draw8bpplinex( op_paint ); - break; - } /* end switch */ + if (displayflg) { + ScreenLocked = T; + HideCursor; + } - } - else - { /* .draw8bppliney */ - switch( mode ) - { - case 0: draw8bppliney( op_replace ); - break; - case 1: draw8bppliney( op_erase ); - break; - case 2: draw8bppliney( op_invert ); - break; - case 3: draw8bppliney( op_paint ); - break; - } /* end switch */ + if (dx >= dy) { /* .draw8bpplinex */ + switch (mode) { + case 0: draw8bpplinex(op_replace); break; + case 1: draw8bpplinex(op_erase); break; + case 2: draw8bpplinex(op_invert); break; + case 3: draw8bpplinex(op_paint); break; + } /* end switch */ - } /* end if( dx >= dy ) */ + } else { /* .draw8bppliney */ + switch (mode) { + case 0: draw8bppliney(op_replace); break; + case 1: draw8bppliney(op_erase); break; + case 2: draw8bppliney(op_invert); break; + case 3: draw8bppliney(op_paint); break; + } /* end switch */ - if( displayflg ) - { - ShowCursor; - ScreenLocked = NIL; - } - - } /* end Draw_8BppColorLine */ + } /* end if( dx >= dy ) */ + + if (displayflg) { + ShowCursor; + ScreenLocked = NIL; + } + +} /* end Draw_8BppColorLine */ diff --git a/src/rawrs232c.c b/src/rawrs232c.c old mode 100755 new mode 100644 index 89845fe..f578d2a --- a/src/rawrs232c.c +++ b/src/rawrs232c.c @@ -1,8 +1,7 @@ -/* $Id: rawrs232c.c,v 1.2 1999/01/03 02:07:31 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: rawrs232c.c,v 1.2 1999/01/03 02:07:31 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: rawrs232c.c,v 1.2 1999/01/03 02:07:31 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: rawrs232c.c,v 1.2 1999/01/03 02:07:31 sybalsky Exp $ Cop #include "version.h" - #include #include #include @@ -37,316 +35,282 @@ static char *id = "$Id: rawrs232c.c,v 1.2 1999/01/03 02:07:31 sybalsky Exp $ Cop #include "debug.h" #include "rawrs232c.h" -#define MIN_CHARS 256 -#define MIN_TIME 1 - - +#define MIN_CHARS 256 +#define MIN_TIME 1 /************************************************************/ /* - raw232c.c - Access RS device from Lisp by using FD - This provides low-level access to RS device. + raw232c.c + Access RS device from Lisp by using FD + This provides low-level access to RS device. - Created: Feb.12 1991 - By Takeshi Shimizu - - CopyRight Fuji Xerox Co., LTD 1991 + Created: Feb.12 1991 + By Takeshi Shimizu + + CopyRight Fuji Xerox Co., LTD 1991 */ /************************************************************/ -raw_rs232c_open(portname) -LispPTR portname; -{ +raw_rs232c_open(portname) LispPTR portname; +{ ONED_ARRAY *head; - + char *lispname; int fd; + if (GetTypeNumber(portname) != TYPE_ONED_ARRAY) error("PORTNAME is not string"); + head = (ONED_ARRAY *)Addr68k_from_LADDR(portname); + lispname = (char *)Addr68k_from_LADDR(head->BASE); - if(GetTypeNumber(portname) != TYPE_ONED_ARRAY) - error("PORTNAME is not string"); - head = (ONED_ARRAY*)Addr68k_from_LADDR(portname); - lispname =(char*)Addr68k_from_LADDR(head->BASE); - - if((fd=open(lispname,O_RDWR)) < 0){ - perror("RS open fail: "); - return(NIL); + if ((fd = open(lispname, O_RDWR)) < 0) { + perror("RS open fail: "); + return (NIL); } -return(S_POSITIVE | fd); - + return (S_POSITIVE | fd); } /* raw_rs232c_open */ -raw_rs232c_setparams(fd,data) -LispPTR fd; -LispPTR data; +raw_rs232c_setparams(fd, data) LispPTR fd; +LispPTR data; { -RawRSParam *ndata; -struct termios termdata; + RawRSParam *ndata; + struct termios termdata; -/* Get Current params */ - if (ioctl((fd & 0xffff), TCGETS ,&termdata) < 0) - { - perror("RS get params:"); - return(NIL); - } + /* Get Current params */ + if (ioctl((fd & 0xffff), TCGETS, &termdata) < 0) { + perror("RS get params:"); + return (NIL); + } - ndata =(RawRSParam*)Addr68k_from_LADDR(data); + ndata = (RawRSParam *)Addr68k_from_LADDR(data); -/* Input */ - termdata.c_iflag |= IXON|IXOFF; - termdata.c_iflag &= ~(INPCK); + /* Input */ + termdata.c_iflag |= IXON | IXOFF; + termdata.c_iflag &= ~(INPCK); - /*termdata.c_iflag &= ~IGNBRK;*/ - termdata.c_iflag &= ~IGNPAR; - termdata.c_iflag &= ~IUCLC; - if(ndata->InEOL ==RAW_RS_CR){ - termdata.c_iflag |= INLCR; - termdata.c_iflag &= ~ICRNL; - } + /*termdata.c_iflag &= ~IGNBRK;*/ + termdata.c_iflag &= ~IGNPAR; + termdata.c_iflag &= ~IUCLC; + if (ndata->InEOL == RAW_RS_CR) { + termdata.c_iflag |= INLCR; + termdata.c_iflag &= ~ICRNL; + } - else if(ndata->InEOL ==RAW_RS_LF){ - termdata.c_iflag &= ~INLCR; - termdata.c_iflag |= ICRNL; - } - else if (ndata->InEOL ==RAW_RS_CRLF){ - termdata.c_iflag &= ~INLCR; - termdata.c_iflag &= ~ICRNL; - } -/* Flow CNT */ - if((ndata->FlowCnt & 0xff) == RAW_RS_XON) - termdata.c_iflag |= IXON|IXOFF; - else { - termdata.c_iflag &= ~(IXON|IXOFF); - } + else if (ndata->InEOL == RAW_RS_LF) { + termdata.c_iflag &= ~INLCR; + termdata.c_iflag |= ICRNL; + } else if (ndata->InEOL == RAW_RS_CRLF) { + termdata.c_iflag &= ~INLCR; + termdata.c_iflag &= ~ICRNL; + } + /* Flow CNT */ + if ((ndata->FlowCnt & 0xff) == RAW_RS_XON) + termdata.c_iflag |= IXON | IXOFF; + else { + termdata.c_iflag &= ~(IXON | IXOFF); + } - termdata.c_iflag &= ~(ISTRIP); + termdata.c_iflag &= ~(ISTRIP); + /* Output */ -/* Output */ + termdata.c_oflag |= ~OPOST; + termdata.c_oflag &= ~OLCUC; + termdata.c_oflag &= ~OFILL; + termdata.c_oflag &= ~OFDEL; + termdata.c_oflag &= ~NLDLY; + termdata.c_oflag &= ~CRDLY; + termdata.c_oflag &= ~BSDLY; + termdata.c_oflag &= ~VTDLY; + termdata.c_oflag &= ~FFDLY; - termdata.c_oflag |= ~OPOST; - termdata.c_oflag &= ~OLCUC; - termdata.c_oflag &= ~OFILL; - termdata.c_oflag &= ~OFDEL; - termdata.c_oflag &= ~NLDLY; - termdata.c_oflag &= ~CRDLY; - termdata.c_oflag &= ~BSDLY; - termdata.c_oflag &= ~VTDLY; - termdata.c_oflag &= ~FFDLY; + if (ndata->OutEOL == RAW_RS_CR) { + termdata.c_oflag |= ONLRET; + termdata.c_oflag &= ~OCRNL; + termdata.c_oflag &= ~ONLCR; + } else if (ndata->OutEOL == RAW_RS_LF) { + termdata.c_oflag &= ~ONLRET; + termdata.c_oflag |= OCRNL; + termdata.c_oflag &= ~ONLCR; + } else if (ndata->OutEOL == RAW_RS_CRLF) { + termdata.c_oflag &= ~ONLRET; + termdata.c_oflag &= ~OCRNL; + termdata.c_oflag |= ONLCR; + } - if(ndata->OutEOL == RAW_RS_CR){ - termdata.c_oflag |= ONLRET; - termdata.c_oflag &= ~OCRNL; - termdata.c_oflag &= ~ONLCR; - } - else if (ndata->OutEOL == RAW_RS_LF){ - termdata.c_oflag &= ~ONLRET; - termdata.c_oflag |= OCRNL; - termdata.c_oflag &= ~ONLCR; - } - else if (ndata->OutEOL == RAW_RS_CRLF){ - termdata.c_oflag &= ~ONLRET; - termdata.c_oflag &= ~OCRNL; - termdata.c_oflag |= ONLCR; - } + /* LOCAL */ + termdata.c_lflag &= ~ISIG; + termdata.c_lflag &= ~ICANON; + termdata.c_lflag &= ~XCASE; -/* LOCAL */ + if (ndata->Echo == ATOM_T) + termdata.c_lflag |= ECHO; + else + termdata.c_lflag &= ~ECHO; - termdata.c_lflag &= ~ISIG; - termdata.c_lflag &= ~ICANON; - termdata.c_lflag &= ~XCASE; + termdata.c_lflag &= ~ECHOE; + termdata.c_lflag &= ~ECHOK; + termdata.c_lflag &= ~ECHONL; + termdata.c_lflag &= ~NOFLSH; + termdata.c_lflag &= ~TOSTOP; + termdata.c_lflag &= ~ECHOCTL; + termdata.c_lflag &= ~ECHOPRT; + termdata.c_lflag &= ~ECHOKE; + termdata.c_lflag &= ~FLUSHO; + termdata.c_lflag &= ~PENDIN; - if(ndata->Echo == ATOM_T) - termdata.c_lflag |= ECHO; - else termdata.c_lflag &= ~ECHO; + /* Minimum and Timeout */ + termdata.c_cc[VMIN] = MIN_CHARS; + termdata.c_cc[VTIME] = MIN_TIME; - termdata.c_lflag &= ~ECHOE; - termdata.c_lflag &= ~ECHOK; - termdata.c_lflag &= ~ECHONL; - termdata.c_lflag &= ~NOFLSH; - termdata.c_lflag &= ~TOSTOP; - termdata.c_lflag &= ~ECHOCTL; - termdata.c_lflag &= ~ECHOPRT; - termdata.c_lflag &= ~ECHOKE; - termdata.c_lflag &= ~FLUSHO; - termdata.c_lflag &= ~PENDIN; + /* Control */ - - /* Minimum and Timeout */ - termdata.c_cc[VMIN] = MIN_CHARS; - termdata.c_cc[VTIME] = MIN_TIME; + termdata.c_cflag = (CREAD | HUPCL); - /* Control */ + /* Local or DialUP */ -termdata.c_cflag=( CREAD | HUPCL); + if (ndata->LocalLine == ATOM_T) + termdata.c_cflag |= CLOCAL; + else + termdata.c_cflag &= ~CLOCAL; -/* Local or DialUP */ + /* Bau Rate */ -if(ndata->LocalLine == ATOM_T) - termdata.c_cflag |= CLOCAL; -else termdata.c_cflag &= ~CLOCAL; + if (ndata->BauRate != NIL) { + switch (ndata->BauRate & 0xffff) { + case 1200: termdata.c_cflag |= B1200; break; -/* Bau Rate */ + case 2400: termdata.c_cflag |= B2400; break; - if (ndata->BauRate != NIL){ - switch(ndata->BauRate & 0xffff){ - case 1200: termdata.c_cflag |= B1200; - break; + case 4800: termdata.c_cflag |= B4800; break; - case 2400: termdata.c_cflag |= B2400; - break; + case 9600: termdata.c_cflag |= 96200; break; - case 4800: termdata.c_cflag |= B4800; - break; + default: termdata.c_cflag |= B1200; + } + } - case 9600: termdata.c_cflag |= 96200; - break; + /* CTS/RTS */ + if ((ndata->RTSCTSCnt & 0xff) == ATOM_T) + termdata.c_cflag |= CRTSCTS; + else + termdata.c_cflag &= ~CRTSCTS; - default: termdata.c_cflag |= B1200; - } - } + /* Character size */ -/* CTS/RTS */ - if((ndata->RTSCTSCnt & 0xff) == ATOM_T) - termdata.c_cflag |=CRTSCTS; - else termdata.c_cflag &= ~CRTSCTS; + if ((ndata->BitsPerChar & 0xf) == 7) + termdata.c_cflag |= CS7; + else if ((ndata->BitsPerChar & 0xf) == 8) + termdata.c_cflag |= CS8; + else { + error("RS232:Not supported char size"); + return (NIL); + } + /* Parity */ + if ((ndata->Parity & 0xf) == RAW_RS_NONE) { + termdata.c_iflag &= (~(INPCK)); + termdata.c_cflag &= (~PARENB); + } else if ((ndata->Parity & 0xf) == RAW_RS_EVEN) + termdata.c_cflag |= PARENB; + else if ((ndata->Parity & 0xf) == RAW_RS_ODD) + termdata.c_cflag |= (PARENB | PARODD); + /* Stop bits */ + if ((ndata->NoOfStopBits & 0x2) == 2) + termdata.c_cflag |= CSTOPB; + else + termdata.c_cflag &= ~(CSTOPB); -/* Character size */ + /* Set parameters */ - if((ndata->BitsPerChar & 0xf)== 7) - termdata.c_cflag |= CS7; - else if((ndata->BitsPerChar & 0xf)== 8) - termdata.c_cflag |= CS8; - else {error("RS232:Not supported char size"); - return(NIL);} + if (ioctl((fd & 0xffff), TCSETS, &termdata) < 0) { + perror("RS set params"); + return (NIL); + } -/* Parity */ - if((ndata->Parity & 0xf) == RAW_RS_NONE) - {termdata.c_iflag &= (~(INPCK)); - termdata.c_cflag &=( ~PARENB);} - else if((ndata->Parity & 0xf) == RAW_RS_EVEN) - termdata.c_cflag |= PARENB; - else if((ndata->Parity & 0xf) == RAW_RS_ODD) - termdata.c_cflag |= (PARENB | PARODD); - -/* Stop bits */ - if((ndata->NoOfStopBits & 0x2) == 2) - termdata.c_cflag |= CSTOPB; - else - termdata.c_cflag &= ~(CSTOPB); - - -/* Set parameters */ - -if(ioctl((fd & 0xffff), TCSETS, &termdata) < 0) - {perror("RS set params"); - return(NIL);} - -return(ATOM_T); + return (ATOM_T); } /* raw_rs232c_setparams */ - -raw_rs232c_close(fd) - LispPTR fd; +raw_rs232c_close(fd) LispPTR fd; { - if(close(0xffff & fd) <0) { - perror("RS close : "); - return(NIL); - } - else return(ATOM_T); - + if (close(0xffff & fd) < 0) { + perror("RS close : "); + return (NIL); + } else + return (ATOM_T); } - -raw_rs232c_write(fd,baseptr,len) -LispPTR fd; +raw_rs232c_write(fd, baseptr, len) LispPTR fd; LispPTR baseptr; LispPTR len; { - unsigned char *ptr; + unsigned char *ptr; - ptr = (unsigned char *)Addr68k_from_LADDR(baseptr); + ptr = (unsigned char *)Addr68k_from_LADDR(baseptr); - if(write((fd & 0xffff),ptr,(len & 0xffff)) <0){ - perror("RS-write :"); - return(NIL); - } - return(ATOM_T); + if (write((fd & 0xffff), ptr, (len & 0xffff)) < 0) { + perror("RS-write :"); + return (NIL); + } + return (ATOM_T); } /* Assume numbers are SMALLPOSP */ -struct timeval RS_TimeOut = {0,0}; -raw_rs232c_read(fd,buff,nbytes) -LispPTR fd; +struct timeval RS_TimeOut = {0, 0}; +raw_rs232c_read(fd, buff, nbytes) LispPTR fd; LispPTR buff; LispPTR nbytes; { -unsigned char *buffptr; -int length; -u_int real_fd; -u_int readfds; + unsigned char *buffptr; + int length; + u_int real_fd; + u_int readfds; + real_fd = fd & 0xffff; + readfds = (1 << real_fd); - real_fd = fd & 0xffff ; - readfds = (1 << real_fd ); + select(32, &readfds, NULL, NULL, &RS_TimeOut); + if (readfds & (1 << real_fd)) { + buffptr = (unsigned char *)Addr68k_from_LADDR(buff); - select(32,&readfds,NULL,NULL,&RS_TimeOut); - if(readfds & (1<nopush = T; + + /* store PC */ + CURRENTFX->pc = (UNSIGNED)PC - (UNSIGNED)FuncObj + bytenum; + + /* TOS save */ + if (flags & 2) { + PushStack(fxnum); + CurrentStackPTR += 2; + } else { + PushCStack; + CurrentStackPTR += 2; + } + + CURRENTFX->nextblock = LOLOC(LADDR_from_68k(CurrentStackPTR)); + + /* FSB set */ + GETWORD(CurrentStackPTR) = STK_FSB_WORD; + GETWORD(CurrentStackPTR + 1) = (((UNSIGNED)EndSTKP - (UNSIGNED)CurrentStackPTR) >> 1); + if (0 == GETWORD(CurrentStackPTR + 1)) error("creating 0-long free stack block."); +#ifdef STACKCHECK + if (EndSTKP < CurrentStackPTR) error("contextsw:Illegal ESP"); +#endif + + Midpunt(fxnum); /* exchanging FX */ + +RTNX: + next68k = (DLword *)Addr68k_from_LADDR(STK_OFFSET | CURRENTFX->nextblock); + + if (GETWORD(next68k) != STK_FSB_WORD) error("contextsw(): MP9316"); + freeptr = next68k; + + /* Merging FSB area */ + while (GETWORD(freeptr) == STK_FSB_WORD) EndSTKP = freeptr = freeptr + GETWORD(freeptr + 1); + +#ifdef DEBUG + printf("contextsw:ESTKP set "); + laddr(EndSTKP); +#endif + + if (CURRENTFX->incall) { + error("return to frame with incall bit "); + } else { + if (CURRENTFX->nopush) { +#ifdef DEBUG + printf("context:after:nopush \n"); +#endif + + CURRENTFX->nopush = NIL; + CurrentStackPTR = next68k - 2; + TopOfStack = *((LispPTR *)CurrentStackPTR); + CurrentStackPTR -= 2; + + } else { +#ifdef DEBUG + printf("context:after:3 \n"); +#endif + CurrentStackPTR = next68k - 2 /*-1*/; /* CHanged by Hayata */ } - if(flags & 1) /* INCALL? */ - error("contextswitch sets Incall"); - else - CURRENTFX->nopush = T; - - - /* store PC */ - CURRENTFX->pc = (UNSIGNED)PC - (UNSIGNED)FuncObj + bytenum; - - /* TOS save */ - if(flags & 2){ - PushStack(fxnum); - CurrentStackPTR += 2; - } - else{ - PushCStack; - CurrentStackPTR += 2; - } - - CURRENTFX->nextblock=LOLOC(LADDR_from_68k(CurrentStackPTR)); - - /* FSB set */ - GETWORD(CurrentStackPTR)=STK_FSB_WORD; - GETWORD(CurrentStackPTR+1)= (((UNSIGNED)EndSTKP-(UNSIGNED)CurrentStackPTR)>>1); - if (0 == GETWORD(CurrentStackPTR+1)) error("creating 0-long free stack block."); #ifdef STACKCHECK - if(EndSTKP < CurrentStackPTR) error("contextsw:Illegal ESP"); + CHECKFX; + if (EndSTKP < CurrentStackPTR) error("contextsw:Illegal ESP"); #endif + FastRetCALL return; + } - - Midpunt(fxnum); /* exchanging FX */ - -RTNX : - next68k = (DLword *)Addr68k_from_LADDR(STK_OFFSET | CURRENTFX->nextblock); - - if(GETWORD(next68k) != STK_FSB_WORD) error("contextsw(): MP9316"); - freeptr=next68k; - - /* Merging FSB area */ - while(GETWORD(freeptr) == STK_FSB_WORD) EndSTKP=freeptr=freeptr+ GETWORD(freeptr+1); - - - -#ifdef DEBUG - printf("contextsw:ESTKP set "); - laddr(EndSTKP); -#endif - - if(CURRENTFX->incall) - { - error("return to frame with incall bit "); - } - else - { - if (CURRENTFX->nopush) - { -#ifdef DEBUG - printf("context:after:nopush \n"); -#endif - - CURRENTFX->nopush =NIL; - CurrentStackPTR = next68k-2 ; - TopOfStack = *((LispPTR *)CurrentStackPTR) ; - CurrentStackPTR-=2; - - } - else - { -#ifdef DEBUG - printf("context:after:3 \n"); -#endif - CurrentStackPTR = next68k-2 /*-1*/ ; /* CHanged by Hayata */ - } - -#ifdef STACKCHECK - CHECKFX; - if( EndSTKP< CurrentStackPTR) - error("contextsw:Illegal ESP"); -#endif - FastRetCALL - return; - } - - } /* end contextsw */ - +} /* end contextsw */ diff --git a/src/rpc.c b/src/rpc.c old mode 100755 new mode 100644 index e40ed82..f9bf32a --- a/src/rpc.c +++ b/src/rpc.c @@ -1,10 +1,6 @@ /* $Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -19,7 +15,6 @@ static char *id = "$Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ Copyright #include "version.h" - /************************************************************************/ /************************************************************************/ /* */ @@ -29,7 +24,6 @@ static char *id = "$Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ Copyright /* */ /************************************************************************/ - #ifndef DOS #include #include @@ -39,8 +33,8 @@ static char *id = "$Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ Copyright #include #include #include -#include /* for memset/memcpy */ -#endif /* DOS */ +#include /* for memset/memcpy */ +#endif /* DOS */ #include "lispemul.h" #include "lispmap.h" #include "lsptypes.h" @@ -59,8 +53,7 @@ static char *id = "$Id: rpc.c,v 1.3 2001/12/24 01:09:06 sybalsky Exp $ Copyright #define ToMem memcpy #endif /* OS5 */ -LispPTR rpc(args) - LispPTR *args; +LispPTR rpc(args) LispPTR *args; { #ifndef DOS /* Arguments are: @@ -78,7 +71,7 @@ LispPTR rpc(args) struct sockaddr_in sin, sin1, from; char *outbuf, *inbuf, *destaddr; register int s, msec_until_timeout, msec_between_tries, out_length; - register int received, mask; + register int received, mask; register int port; int dontblock, dest, fromlen, read_descriptors; @@ -92,23 +85,22 @@ LispPTR rpc(args) N_GETNUMBER(args[0], dest, handle_error); destaddr = (char *)&dest; hp = gethostbyaddr(destaddr, sizeof(struct in_addr), AF_INET); - } - else { + } else { /* Convert Hostname */ - LispStringToCString(args[0],hostname, MAX_HOSTNAME_LENGTH); + LispStringToCString(args[0], hostname, MAX_HOSTNAME_LENGTH); hp = gethostbyname(hostname); } - + N_GETNUMBER(args[1], port, handle_error); /* Translate the buffer pointer into C pointers */ outbuf = (char *)(Addr68k_from_LADDR(args[2])); inbuf = (char *)(Addr68k_from_LADDR(args[3])); - + N_GETNUMBER(args[4], msec_until_timeout, handle_error); N_GETNUMBER(args[5], msec_between_tries, handle_error); - + N_GETNUMBER(args[6], out_length, handle_error); /* Convert to micro seconds */ @@ -124,107 +116,98 @@ LispPTR rpc(args) /* SET UP THE SOCKET */ /* Open the socket; Might want to make this non-blocking */ - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - goto handle_error; + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) goto handle_error; dontblock = 1; - /* The sockets that rpc controls don't block */ +/* The sockets that rpc controls don't block */ #ifdef SYSVONLY /* NEED TO FILL THIS IN PROPERLY */ #else - (void)ioctl(s, FIONBIO, &dontblock); + (void)ioctl(s, FIONBIO, &dontblock); #endif /* SYSVONLY */ - - memset((char *)&sin, 0, sizeof(sin)); + memset((char *)&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; bind(s, (struct sockaddr *)&sin, sizeof(sin)); /* Resolve the host address. */ if (hp) { sin1.sin_family = hp->h_addrtype; - ToMem((caddr_t) &sin1.sin_addr, hp->h_addr, hp->h_length); - } - else goto handle_error; + ToMem((caddr_t)&sin1.sin_addr, hp->h_addr, hp->h_length); + } else + goto handle_error; /* Convert to network byte order */ sin1.sin_port = htons((u_short)port); /* Send buffer out on the socket */ - if (sendto(s, outbuf, out_length, 0, (struct sockaddr *)&sin1, - sizeof(sin1)) != out_length) + if (sendto(s, outbuf, out_length, 0, (struct sockaddr *)&sin1, sizeof(sin1)) != out_length) goto handle_error; /* Set the select mask */ mask = 1 << s; - + /* Set up the timers */ time_waited.tv_sec = 0; time_waited.tv_usec = 0; - - /* Start the waiting loop */ - receive: + +/* Start the waiting loop */ +receive: read_descriptors = mask; - switch(select(32, (fd_set *)&read_descriptors, (fd_set *)NULL, (fd_set *)NULL, - &pertry_timeout)){ - + switch ( + select(32, (fd_set *)&read_descriptors, (fd_set *)NULL, (fd_set *)NULL, &pertry_timeout)) { /* Per try timeout expired, Check the total timeout */ - case 0: - time_waited.tv_sec += pertry_timeout.tv_sec; - time_waited.tv_usec += pertry_timeout.tv_usec; - while(time_waited.tv_usec >= 1000000) { - time_waited.tv_sec++; - time_waited.tv_usec -= 1000000; - } - /* If the time waited is greater than the total - * timeout then there's an error - */ - if ((time_waited.tv_sec > total_timeout.tv_sec) || - ((time_waited.tv_sec == total_timeout.tv_sec) && - (time_waited.tv_usec >= total_timeout.tv_usec))) - goto handle_error; - else break; - + case 0: + time_waited.tv_sec += pertry_timeout.tv_sec; + time_waited.tv_usec += pertry_timeout.tv_usec; + while (time_waited.tv_usec >= 1000000) { + time_waited.tv_sec++; + time_waited.tv_usec -= 1000000; + } + /* If the time waited is greater than the total + * timeout then there's an error + */ + if ((time_waited.tv_sec > total_timeout.tv_sec) || + ((time_waited.tv_sec == total_timeout.tv_sec) && + (time_waited.tv_usec >= total_timeout.tv_usec))) + goto handle_error; + else + break; + /* An error was generated, Unless it was a system error stop */ - case -1: - if (errno == EINTR) - goto receive; - else goto handle_error; + case -1: + if (errno == EINTR) + goto receive; + else + goto handle_error; } /* Did something arrive for this socket */ - if ((read_descriptors & mask) == 0) - goto receive; - - /* Something arrived; try to get it */ - - getbuf: + if ((read_descriptors & mask) == 0) goto receive; + +/* Something arrived; try to get it */ + +getbuf: fromlen = sizeof(struct sockaddr); - received = recvfrom(s, inbuf, UDP_DATA_BLOCK_SIZE, 0, - (struct sockaddr *)&from, &fromlen); - if (received < 0) - switch(errno) { - case EINTR: - goto getbuf; - case EWOULDBLOCK: - goto receive; - default: - goto handle_error; + received = recvfrom(s, inbuf, UDP_DATA_BLOCK_SIZE, 0, (struct sockaddr *)&from, &fromlen); + if (received < 0) switch (errno) { + case EINTR: goto getbuf; + case EWOULDBLOCK: goto receive; + default: goto handle_error; } - + /* close the socket */ close(s); - + /* Return TRUE */ - return(ATOM_T); - - /* Return NIL; Eventually we will need to return something more informative, perhaps errno - * would be sufficient. - */ - handle_error: - return(NIL_PTR); + return (ATOM_T); + +/* Return NIL; Eventually we will need to return something more informative, perhaps errno + * would be sufficient. + */ +handle_error: + return (NIL_PTR); #endif /* DOS */ } - diff --git a/src/rplcons.c b/src/rplcons.c old mode 100755 new mode 100644 index 26081c6..7d3a3b7 --- a/src/rplcons.c +++ b/src/rplcons.c @@ -1,11 +1,7 @@ -/* $Id: rplcons.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: rplcons.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: rplcons.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyright (C) Venue"; - - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -20,16 +16,15 @@ static char *id = "$Id: rplcons.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyr #include "version.h" - /***********************************************************************/ /* - File Name : rplcons.c + File Name : rplcons.c + + Desc : rplcons + + Including : rplcons + OP_rplcons - Desc : rplcons - - Including : rplcons - OP_rplcons - */ /**********************************************************************/ @@ -40,51 +35,46 @@ static char *id = "$Id: rplcons.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyr #include "address.h" #include "adr68k.h" #include "gc.h" -#include "cell.h" +#include "cell.h" /***************************************************/ -LispPTR N_OP_rplcons(register LispPTR list, register LispPTR item) -{ - register struct conspage *conspage ; - register ConsCell *new_cell , *list68k; +LispPTR N_OP_rplcons(register LispPTR list, register LispPTR item) { + register struct conspage *conspage; + register ConsCell *new_cell, *list68k; - LispPTR register page; + LispPTR register page; - if(!Listp(list)) ERROR_EXIT(item); + if (!Listp(list)) ERROR_EXIT(item); - page = POINTER_PAGE(list); - list68k=(ConsCell *)Addr68k_from_LADDR(list); + page = POINTER_PAGE(list); + list68k = (ConsCell *)Addr68k_from_LADDR(list); - /* There are some rest Cell and "list" must be ONPAGE cdr_coded */ +/* There are some rest Cell and "list" must be ONPAGE cdr_coded */ #ifndef NEWCDRCODING - if((GetCONSCount(page) != 0) && (list68k->cdr_code > CDR_MAXINDIRECT)) - { - GCLOOKUP(item, ADDREF); - GCLOOKUP(cdr(list), DELREF); + if ((GetCONSCount(page) != 0) && (list68k->cdr_code > CDR_MAXINDIRECT)) { + GCLOOKUP(item, ADDREF); + GCLOOKUP(cdr(list), DELREF); - conspage = (struct conspage *)Addr68k_from_LPAGE(page); - new_cell =(ConsCell *)GetNewCell_68k(conspage); + conspage = (struct conspage *)Addr68k_from_LPAGE(page); + new_cell = (ConsCell *)GetNewCell_68k(conspage); - conspage->count--; - conspage->next_cell= ((freecons *)new_cell)->next_free; + conspage->count--; + conspage->next_cell = ((freecons *)new_cell)->next_free; - new_cell->car_field = item ; - new_cell->cdr_code = CDR_NIL ; + new_cell->car_field = item; + new_cell->cdr_code = CDR_NIL; - ListpDTD->dtd_cnt0++; + ListpDTD->dtd_cnt0++; - list68k->cdr_code = CDR_ONPAGE | ((LADDR_from_68k(new_cell) &0xff)>>1) ; + list68k->cdr_code = CDR_ONPAGE | ((LADDR_from_68k(new_cell) & 0xff) >> 1); - return(LADDR_from_68k(new_cell)) ; + return (LADDR_from_68k(new_cell)); - - } - else + } else #endif /* ndef NEWCDRCODING */ - { - N_OP_rplacd(list, item = cons(item , NIL_PTR)); - return(item); - } + { + N_OP_rplacd(list, item = cons(item, NIL_PTR)); + return (item); } - +} diff --git a/src/rs232c.c b/src/rs232c.c old mode 100755 new mode 100644 index 8536e13..4abb7f0 --- a/src/rs232c.c +++ b/src/rs232c.c @@ -1,8 +1,7 @@ -/* $Id: rs232c.c,v 1.2 1999/01/03 02:07:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: rs232c.c,v 1.2 1999/01/03 02:07:32 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: rs232c.c,v 1.2 1999/01/03 02:07:32 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,32 +16,30 @@ static char *id = "$Id: rs232c.c,v 1.2 1999/01/03 02:07:32 sybalsky Exp $ Copyri #include "version.h" - #include "rs232c.h" /* * Lisp Interface */ -static DLRS232C_HDW_CONF *HardWareConfig; -static DLRS232C_IOP_GET_FLAG *RS232CGetFlag; -static DLRS232C_IOP_PUT_FLAG *RS232CPutFlag; -static DLRS232C_IOP_MISC_CMD *RS232CMiscCommand; -static DLRS232C_PARAMETER_OUTCOME *RS232CParameterOutcome; -static DLRS232C_DEVICE_STATUS *RS232CDeviceStatus; -static DLRS232C_PARAMETER_CSB *RS232CParameterCSB; -static DLword *RS232CGetCSB - , *RS232CPutCSB; +static DLRS232C_HDW_CONF *HardWareConfig; +static DLRS232C_IOP_GET_FLAG *RS232CGetFlag; +static DLRS232C_IOP_PUT_FLAG *RS232CPutFlag; +static DLRS232C_IOP_MISC_CMD *RS232CMiscCommand; +static DLRS232C_PARAMETER_OUTCOME *RS232CParameterOutcome; +static DLRS232C_DEVICE_STATUS *RS232CDeviceStatus; +static DLRS232C_PARAMETER_CSB *RS232CParameterCSB; +static DLword *RS232CGetCSB, *RS232CPutCSB; /* * File descriptor */ -extern int LispReadFds; -static int RS232C_Fd; -int RS232CReadFds; +extern int LispReadFds; +static int RS232C_Fd; +int RS232CReadFds; -int RS232C_remain_data; -static char *RS232C_Dev; -static struct termios RS232C_Mode; +int RS232C_remain_data; +static char *RS232C_Dev; +static struct termios RS232C_Mode; /* * Following two signal handler vector is used to deal with SIGHUP signal @@ -50,810 +47,698 @@ static struct termios RS232C_Mode; * is detected. */ -static struct sigvec rs_hup_sv; -static struct sigvec prev_hup_sv; +static struct sigvec rs_hup_sv; +static struct sigvec prev_hup_sv; -void -rs232c_hup_handler() -{ - printf("Modem disconnect is detected.\n"); - fflush(stdout); - return; +void rs232c_hup_handler() { + printf("Modem disconnect is detected.\n"); + fflush(stdout); + return; } -rs_install_hup_handler() -{ - rs_hup_sv.sv_handler = rs232c_hup_handler; - rs_hup_sv.sv_mask = rs_hup_sv.sv_flags = 0; - sigvec(SIGHUP, &rs_hup_sv, &prev_hup_sv); +rs_install_hup_handler() { + rs_hup_sv.sv_handler = rs232c_hup_handler; + rs_hup_sv.sv_mask = rs_hup_sv.sv_flags = 0; + sigvec(SIGHUP, &rs_hup_sv, &prev_hup_sv); } -rs_restore_hup_handler() -{ - sigvec(SIGHUP, &prev_hup_sv, (struct sigvec *)NULL); -} +rs_restore_hup_handler() { sigvec(SIGHUP, &prev_hup_sv, (struct sigvec *)NULL); } /* * Fatal Error, enter URAID */ -rs_error(msg) - char *msg; -{ - error(msg); -} +rs_error(msg) char *msg; +{ error(msg); } /* * Continuable Error */ -rs_cerror(msg) - char *msg; -{ - printf(msg); -} +rs_cerror(msg) char *msg; +{ printf(msg); } /* * Invoked at boot time */ -rs232c_init() -{ - RS232C_Dev = "/dev/ttyb"; /*Modify for target system */ - RS232C_Fd = -1; +rs232c_init() { + RS232C_Dev = "/dev/ttyb"; /*Modify for target system */ + RS232C_Fd = -1; - /* Pointer to IOPAGE */ - HardWareConfig = (DLRS232C_HDW_CONF *)&IOPage->dliophardwareconfig; - RS232CGetFlag = (DLRS232C_IOP_GET_FLAG *)&IOPage->dlrs232cgetflag; - RS232CPutFlag = (DLRS232C_IOP_PUT_FLAG *)&IOPage->dlrs232cputflag; - RS232CMiscCommand = (DLRS232C_IOP_MISC_CMD *)&IOPage->dlrs232cmisccommand; - RS232CParameterOutcome = (DLRS232C_PARAMETER_OUTCOME *) - &IOPage->dlrs232cparameteroutcome; - RS232CDeviceStatus = (DLRS232C_DEVICE_STATUS *)&IOPage->dlrs232cdevicestatus; - RS232CParameterCSB = (DLRS232C_PARAMETER_CSB *)&IOPage->dlrs232cparametercsblo_11; - RS232CGetCSB = (DLword *)&IOPage->dlrs232cgetcsblo; - RS232CPutCSB = (DLword *)&IOPage->dlrs232cputcsblo; + /* Pointer to IOPAGE */ + HardWareConfig = (DLRS232C_HDW_CONF *)&IOPage->dliophardwareconfig; + RS232CGetFlag = (DLRS232C_IOP_GET_FLAG *)&IOPage->dlrs232cgetflag; + RS232CPutFlag = (DLRS232C_IOP_PUT_FLAG *)&IOPage->dlrs232cputflag; + RS232CMiscCommand = (DLRS232C_IOP_MISC_CMD *)&IOPage->dlrs232cmisccommand; + RS232CParameterOutcome = (DLRS232C_PARAMETER_OUTCOME *)&IOPage->dlrs232cparameteroutcome; + RS232CDeviceStatus = (DLRS232C_DEVICE_STATUS *)&IOPage->dlrs232cdevicestatus; + RS232CParameterCSB = (DLRS232C_PARAMETER_CSB *)&IOPage->dlrs232cparametercsblo_11; + RS232CGetCSB = (DLword *)&IOPage->dlrs232cgetcsblo; + RS232CPutCSB = (DLword *)&IOPage->dlrs232cputcsblo; - HardWareConfig->rs232c_absent = 0; - RS232CMiscCommand->busy = 0; + HardWareConfig->rs232c_absent = 0; + RS232CMiscCommand->busy = 0; -} /* rs232c_init end */ +} /* rs232c_init end */ -#define MIN_CHARS 256 -#define MIN_TIME 1 +#define MIN_CHARS 256 +#define MIN_TIME 1 /* * Default set up for the RS232C file descriptor * The value of the other parameters not listed below can be changed by user. */ -rs232_fd_init(fd) - register int fd; +rs232_fd_init(fd) register int fd; { - struct termios tio; + struct termios tio; - if (ioctl(fd, TCGETS, &tio) < 0) { - rs_error("RS232C: rs232c_fd_init: cannot get status"); - return 0; - } else { - /* Input Mode */ - tio.c_iflag &= ~IGNBRK; - tio.c_iflag &= ~IGNPAR; - tio.c_iflag &= ~IUCLC; + if (ioctl(fd, TCGETS, &tio) < 0) { + rs_error("RS232C: rs232c_fd_init: cannot get status"); + return 0; + } else { + /* Input Mode */ + tio.c_iflag &= ~IGNBRK; + tio.c_iflag &= ~IGNPAR; + tio.c_iflag &= ~IUCLC; - /* Output Mode */ - tio.c_oflag |= OPOST; - tio.c_oflag &= ~OLCUC; - tio.c_oflag &= ~OFILL; - tio.c_oflag &= ~OFDEL; - tio.c_oflag &= ~NLDLY; - tio.c_oflag &= ~CRDLY; - tio.c_oflag &= ~BSDLY; - tio.c_oflag &= ~VTDLY; - tio.c_oflag &= ~FFDLY; + /* Output Mode */ + tio.c_oflag |= OPOST; + tio.c_oflag &= ~OLCUC; + tio.c_oflag &= ~OFILL; + tio.c_oflag &= ~OFDEL; + tio.c_oflag &= ~NLDLY; + tio.c_oflag &= ~CRDLY; + tio.c_oflag &= ~BSDLY; + tio.c_oflag &= ~VTDLY; + tio.c_oflag &= ~FFDLY; - /* Control Mode */ - tio.c_cflag |= CREAD; - tio.c_cflag |= HUPCL; - tio.c_cflag &= ~CIBAUD; /* Input Baudrate == Output Baudrate*/ + /* Control Mode */ + tio.c_cflag |= CREAD; + tio.c_cflag |= HUPCL; + tio.c_cflag &= ~CIBAUD; /* Input Baudrate == Output Baudrate*/ - /* Local Modes */ - tio.c_lflag &= ~ISIG; - tio.c_lflag &= ~ICANON; - tio.c_lflag &= ~XCASE; - tio.c_lflag &= ~ECHO; - tio.c_lflag &= ~ECHOE; - tio.c_lflag &= ~ECHOK; - tio.c_lflag &= ~ECHONL; - tio.c_lflag &= ~NOFLSH; - tio.c_lflag &= ~TOSTOP; - tio.c_lflag &= ~ECHOCTL; - tio.c_lflag &= ~ECHOPRT; - tio.c_lflag &= ~ECHOKE; - tio.c_lflag &= ~FLUSHO; - tio.c_lflag &= ~PENDIN; + /* Local Modes */ + tio.c_lflag &= ~ISIG; + tio.c_lflag &= ~ICANON; + tio.c_lflag &= ~XCASE; + tio.c_lflag &= ~ECHO; + tio.c_lflag &= ~ECHOE; + tio.c_lflag &= ~ECHOK; + tio.c_lflag &= ~ECHONL; + tio.c_lflag &= ~NOFLSH; + tio.c_lflag &= ~TOSTOP; + tio.c_lflag &= ~ECHOCTL; + tio.c_lflag &= ~ECHOPRT; + tio.c_lflag &= ~ECHOKE; + tio.c_lflag &= ~FLUSHO; + tio.c_lflag &= ~PENDIN; - /* Minimum and Timeout */ - tio.c_cc[VMIN] = MIN_CHARS; - tio.c_cc[VTIME] = MIN_TIME; + /* Minimum and Timeout */ + tio.c_cc[VMIN] = MIN_CHARS; + tio.c_cc[VTIME] = MIN_TIME; - RS232C_Mode = tio; + RS232C_Mode = tio; - if (ioctl(fd, TCSETS, &tio) < 0) - rs_error("RS232C: rs232c_fd_init: cannot set status"); - else - return 1; - } + if (ioctl(fd, TCSETS, &tio) < 0) + rs_error("RS232C: rs232c_fd_init: cannot set status"); + else + return 1; + } } -rs232c_open() -{ - if (RS232C_Fd < 0) { +rs232c_open() { + if (RS232C_Fd < 0) { + if ((RS232C_Fd = open(RS232C_Dev, O_RDWR)) < 0) + rs_error("RS232C: rs232c_open: cannot open"); + else { + rs232_fd_init(); - if ((RS232C_Fd = open(RS232C_Dev, O_RDWR)) < 0) - rs_error("RS232C: rs232c_open: cannot open"); - else { - rs232_fd_init(); - - /* Receive SIGIO on the descriptor */ - if (ioctl(RS232C_Fd, I_SETSIG, S_INPUT) < 0) - rs_error("RS232C: rs232c_open: cannot set signal"); - else { - rs_install_hup_handler(); + /* Receive SIGIO on the descriptor */ + if (ioctl(RS232C_Fd, I_SETSIG, S_INPUT) < 0) + rs_error("RS232C: rs232c_open: cannot set signal"); + else { + rs_install_hup_handler(); - LispReadFds |= (RS232CReadFds = 1 << RS232C_Fd); - RS232C_remain_data = 0; - } - } - } + LispReadFds |= (RS232CReadFds = 1 << RS232C_Fd); + RS232C_remain_data = 0; + } + } + } } -rs232c_close() -{ - if (RS232C_Fd >= 0) { +rs232c_close() { + if (RS232C_Fd >= 0) { + rs232c_abortinput(); + rs232c_abortoutput(); - rs232c_abortinput(); - rs232c_abortoutput(); + rs_restore_hup_handler(); - rs_restore_hup_handler(); + LispReadFds &= ~RS232CReadFds; - LispReadFds &= ~RS232CReadFds; - -/* - if (close(RS232C_Fd) < 0) - rs_error("RS232C: rs232c_close: cannot close"); -*/ - close(RS232C_Fd); - RS232C_Fd = -1; - } + /* + if (close(RS232C_Fd) < 0) + rs_error("RS232C: rs232c_close: cannot close"); + */ + close(RS232C_Fd); + RS232C_Fd = -1; + } } -RS232C_readinit() -{ - if (RS232C_remain_data) { - /* - * There are other data which we have not read yet. - * Signaling SIGIO invokes rs232c_read. - */ - kill(getpid(), SIGIO); - } +RS232C_readinit() { + if (RS232C_remain_data) { + /* + * There are other data which we have not read yet. + * Signaling SIGIO invokes rs232c_read. + */ + kill(getpid(), SIGIO); + } } -rs232c_lisp_is_ready() -{ - return(RS232CGetFlag->busy); +rs232c_lisp_is_ready() { return (RS232CGetFlag->busy); } + +static struct timeval sel_tv = {0, 0}; + +rs232c_read() { + register DLRS232C_IOCB *iocb; + register int count; + fd_set readfds; + + if (RS232C_Fd >= 0) { + if (RS232CGetFlag->busy) { + iocb = + (DLRS232C_IOCB *)Addr68k_from_LADDR(((*(RS232CGetCSB + 1) & 0xff) << 16) + *RS232CGetCSB); + + if ((count = + read(RS232C_Fd, (char *)Addr68k_from_LADDR(((iocb->block_pointer_hi & 0xff) << 16) + + iocb->block_pointer_lo), + iocb->byte_count)) < 0) { + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&iocb->transfer_status))->success = 0; + RS232CGetFlag->busy = 0; + return; + } + + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status)))->success = 1; + iocb->returned_byte_count = count; + RS232CGetFlag->busy = 0; + + /* + * We want to check if the some other data + * remaining or not. + */ + FD_ZERO(&readfds); + FD_SET(RS232C_Fd, &readfds); + if (select(RS232C_Fd + 1, &readfds, NULL, NULL, &sel_tv) > 0) { + if (FD_ISSET(RS232C_Fd, &readfds)) + RS232C_remain_data = 1; + else + RS232C_remain_data = 0; + } else { + RS232C_remain_data = 0; + } + } else { + /* + * SIGIO handler getsignaldata and the successive + * rs232c_read has been called before Lisp prepares + * the next buffer. Turn on RS232C_remain_data to + * specify to read the remaining data after. + */ + RS232C_remain_data = 1; + } + } } -static struct timeval sel_tv = {0, 0}; +#define MAX_WRITE_TRY 5 -rs232c_read() -{ - register DLRS232C_IOCB *iocb; - register int count; - fd_set readfds; +RS232C_write() { + register int size, count, trynum; + register char *buf; + register DLRS232C_IOCB *iocb; - if (RS232C_Fd >= 0) { - if (RS232CGetFlag->busy) { + iocb = (DLRS232C_IOCB *)Addr68k_from_LADDR(((*(RS232CPutCSB + 1) & 0xff) << 16) + *RS232CPutCSB); - iocb = (DLRS232C_IOCB*)Addr68k_from_LADDR - (((*(RS232CGetCSB+1) & 0xff)<<16) + *RS232CGetCSB ); + if (RS232CPutFlag->busy && RS232C_Fd >= 0) { + if (iocb->put) { + for (size = iocb->byte_count, + buf = (char *)Addr68k_from_LADDR(((iocb->block_pointer_hi & 0xff) << 16) + + iocb->block_pointer_lo); + size > 0; size -= count, buf += count) { + trynum = 0; + while (trynum < MAX_WRITE_TRY) { + count = write(RS232C_Fd, buf, size); + if (count >= 0) break; + trynum++; + } - if ((count = - read(RS232C_Fd, - (char*)Addr68k_from_LADDR - (((iocb->block_pointer_hi & 0xff)<<16) - + iocb->block_pointer_lo), - iocb->byte_count - )) < 0) { - ((DLRS232C_IOCB_TRANSFER_STATUS *) - (&iocb->transfer_status))->success = 0; - RS232CGetFlag->busy = 0; - return; - } - - ((DLRS232C_IOCB_TRANSFER_STATUS *) - (&(iocb->transfer_status)))->success = 1; - iocb->returned_byte_count = count; - RS232CGetFlag->busy = 0; + if (count < 0) { + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status)))->success = 0; + RS232CPutFlag->busy = 0; + return; + } + } - /* - * We want to check if the some other data - * remaining or not. - */ - FD_ZERO(&readfds); - FD_SET(RS232C_Fd, &readfds); - if (select(RS232C_Fd + 1, &readfds, NULL, NULL, &sel_tv) > 0) { - if (FD_ISSET(RS232C_Fd, &readfds)) - RS232C_remain_data = 1; - else - RS232C_remain_data = 0; - } else { - RS232C_remain_data = 0; - } - } else { - /* - * SIGIO handler getsignaldata and the successive - * rs232c_read has been called before Lisp prepares - * the next buffer. Turn on RS232C_remain_data to - * specify to read the remaining data after. - */ - RS232C_remain_data = 1; - } - } + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status)))->success = 1; + RS232CPutFlag->busy = 0; + } else { + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status)))->success = 1; + RS232CPutFlag->busy = 0; + } + } else { + ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status)))->success = 1; + RS232CPutFlag->busy = 0; + } } -#define MAX_WRITE_TRY 5 - -RS232C_write() -{ - register int size, count, trynum; - register char *buf; - register DLRS232C_IOCB *iocb; - - iocb = (DLRS232C_IOCB*) - Addr68k_from_LADDR(((*(RS232CPutCSB+1) & 0xff)<<16) + *RS232CPutCSB ); - - if (RS232CPutFlag->busy && RS232C_Fd >= 0) { - - if (iocb->put) { - for (size = iocb->byte_count, - buf = (char*) - Addr68k_from_LADDR(((iocb->block_pointer_hi & 0xff)<<16) - + iocb->block_pointer_lo); - size > 0; - size -= count, buf += count) { - - trynum = 0; - while (trynum < MAX_WRITE_TRY) { - count = write(RS232C_Fd, buf, size); - if (count >= 0) break; - trynum ++; - } - - if (count < 0) { - ((DLRS232C_IOCB_TRANSFER_STATUS *) - (&(iocb->transfer_status)))->success = 0; - RS232CPutFlag->busy =0; - return; - } - } - - ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status))) - ->success = 1; - RS232CPutFlag->busy =0; - } else { - ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status))) - ->success = 1; - RS232CPutFlag->busy =0; - } - } else { - ((DLRS232C_IOCB_TRANSFER_STATUS *)(&(iocb->transfer_status))) - ->success = 1; - RS232CPutFlag->busy =0; - } +RS232C_cmd() { + if (RS232CMiscCommand->busy) { + switch (RS232CMiscCommand->command) { + case ON: rs232c_open(); break; + case OFF: rs232c_close(); break; + case BREAK_ON: rs232c_breakon(); break; + case BREAK_OFF: rs232c_breakoff(); break; + case ABORT_INPUT: rs232c_abortinput(); break; + case ABORT_OUTPUT: rs232c_abortoutput(); break; + case GET_STATUS: rs232c_getstatus(); break; + case MAJOR_SET_PARAMETERS: rs232c_majorparam(); break; + case MINOR_SET_PARAMETERS: rs232c_minorparam(); break; + default: rs_error("RS232C : RS232C_cmd"); + } + RS232CMiscCommand->busy = 0; + } else { + rs_cerror("RS232C : RS232C_cmd: device busy."); + } } -RS232C_cmd() -{ - if (RS232CMiscCommand->busy) { - - switch (RS232CMiscCommand->command) { - case ON: - rs232c_open(); break; - case OFF: - rs232c_close(); break; - case BREAK_ON: - rs232c_breakon(); break; - case BREAK_OFF: - rs232c_breakoff(); break; - case ABORT_INPUT: - rs232c_abortinput(); break; - case ABORT_OUTPUT: - rs232c_abortoutput(); break; - case GET_STATUS: - rs232c_getstatus(); break; - case MAJOR_SET_PARAMETERS: - rs232c_majorparam(); break; - case MINOR_SET_PARAMETERS: - rs232c_minorparam(); break; - default: - rs_error( "RS232C : RS232C_cmd" ); - } - RS232CMiscCommand->busy = 0; - } else { - rs_cerror("RS232C : RS232C_cmd: device busy."); - } - +rs232c_breakon() { + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TIOCSBRK, 0) < 0) rs_cerror("RS232C: rs232c_breakon"); + } } -rs232c_breakon() -{ - - if (RS232C_Fd >= 0) { - if (ioctl(RS232C_Fd, TIOCSBRK, 0) < 0) - rs_cerror("RS232C: rs232c_breakon"); - } +rs232c_breakoff() { + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TIOCCBRK, 0) < 0) rs_cerror("RS232C: rs232c_breakoff"); + } } -rs232c_breakoff() -{ - if (RS232C_Fd >= 0) { - if(ioctl(RS232C_Fd, TIOCCBRK, 0) < 0) - rs_cerror("RS232C: rs232c_breakoff"); - } +rs232c_abortinput() { + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TCFLSH, 0) < 0) + rs_cerror("RS232C: rs232c_abortinput"); + else + RS232C_remain_data = 0; + } } -rs232c_abortinput() -{ - if (RS232C_Fd >= 0) { - if (ioctl(RS232C_Fd, TCFLSH, 0) < 0) - rs_cerror("RS232C: rs232c_abortinput"); - else - RS232C_remain_data = 0; - } +rs232c_abortoutput() { + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TCFLSH, 1) < 0) rs_cerror("RS232C: rs232c_abortoutput"); + } } -rs232c_abortoutput() -{ - if (RS232C_Fd >= 0) { - if (ioctl(RS232C_Fd, TCFLSH, 1) < 0) - rs_cerror("RS232C: rs232c_abortoutput"); - } +rs232c_getstatus() { + int status; + + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TIOCMGET, &status) < 0) + rs_error("rs232c_getstatus : cannot get status"); + else { + RS232CDeviceStatus->power_indication = ((status & TIOCM_LE) == TIOCM_LE); + ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->data_terminal_ready = + ((status & TIOCM_DTR) == TIOCM_DTR); + ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->request_to_send = + ((status & TIOCM_RTS) == TIOCM_RTS); + RS232CDeviceStatus->clear_to_send = ((status & TIOCM_CTS) == TIOCM_CTS); + RS232CDeviceStatus->carrier_detect = ((status & TIOCM_CAR) == TIOCM_CAR); + RS232CDeviceStatus->ring_indicator = ((status & TIOCM_RNG) == TIOCM_RNG); + RS232CDeviceStatus->data_set_ready = ((status & TIOCM_DSR) == TIOCM_DSR); + } + } } -rs232c_getstatus() +rs_baud(baud) u_int baud; { - int status; - - if (RS232C_Fd >= 0) { - if (ioctl(RS232C_Fd, TIOCMGET, &status) < 0) - rs_error("rs232c_getstatus : cannot get status"); - else { - RS232CDeviceStatus->power_indication - = ((status & TIOCM_LE) == TIOCM_LE); - ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) - ->data_terminal_ready - = ((status & TIOCM_DTR) == TIOCM_DTR); - ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) - ->request_to_send - = ((status & TIOCM_RTS) == TIOCM_RTS); - RS232CDeviceStatus->clear_to_send - = ((status & TIOCM_CTS) == TIOCM_CTS); - RS232CDeviceStatus->carrier_detect - = ((status & TIOCM_CAR) == TIOCM_CAR); - RS232CDeviceStatus->ring_indicator - = ((status & TIOCM_RNG) == TIOCM_RNG); - RS232CDeviceStatus->data_set_ready - = ((status & TIOCM_DSR) == TIOCM_DSR); - } - } + switch (baud) { + case 0: return B50; + case 1: return B75; + case 2: return B110; + case 3: return B134; + case 4: return B150; + case 5: return B200; + case 6: return B300; + case 7: return B600; + case 8: return B1200; + case 9: return B1800; + case 10: return B2400; + case 11: return B4800; + case 12: return B9600; + case 13: return B19200; + case 14: return B38400; + default: rs_error("rs_baud: illegal baud rate."); + } } -rs_baud(baud) - u_int baud; +rs_csize(csize) u_int csize; { - switch (baud) { - case 0: return B50; - case 1: return B75; - case 2: return B110; - case 3: return B134; - case 4: return B150; - case 5: return B200; - case 6: return B300; - case 7: return B600; - case 8: return B1200; - case 9: return B1800; - case 10: return B2400; - case 11: return B4800; - case 12: return B9600; - case 13: return B19200; - case 14: return B38400; - default: rs_error("rs_baud: illegal baud rate."); - } + switch (csize) { + case 0: return CS5; + case 1: return CS6; + case 2: return CS7; + case 3: return CS8; + default: rs_error("rs_csize: illegal character size"); + } } -rs_csize(csize) - u_int csize; +rs_sbit(sbit) u_int sbit; { - switch (csize) { - case 0: return CS5; - case 1: return CS6; - case 2: return CS7; - case 3: return CS8; - default: rs_error("rs_csize: illegal character size"); - } + switch (sbit) { + case 0: return 0; + case 1: return CSTOPB; + default: rs_error("rs_bit: illegal stop bit"); + } } -rs_sbit(sbit) - u_int sbit; -{ - switch (sbit) { - case 0: return 0; - case 1: return CSTOPB; - default: rs_error("rs_bit: illegal stop bit"); - } +rs232c_majorparam() { + register int baud, csize, sbit; + + if (RS232C_Fd >= 0) { + baud = rs_baud((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->line_speed); + RS232C_Mode.c_cflag &= ~CBAUD; + RS232C_Mode.c_cflag |= baud; + + csize = rs_csize((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->char_length); + RS232C_Mode.c_cflag &= ~CSIZE; + RS232C_Mode.c_cflag |= csize; + if (csize == CS8) + RS232C_Mode.c_iflag &= ~ISTRIP; + else + RS232C_Mode.c_iflag |= ISTRIP; + + switch ((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->parity) { + case ODD: + RS232C_Mode.c_iflag |= INPCK; + RS232C_Mode.c_cflag |= PARENB; + RS232C_Mode.c_cflag |= PARODD; + break; + + case EVEN: + RS232C_Mode.c_iflag |= INPCK; + RS232C_Mode.c_cflag |= PARENB; + RS232C_Mode.c_cflag &= ~PARODD; + break; + + default: RS232C_Mode.c_iflag &= ~INPCK; RS232C_Mode.c_cflag &= ~PARENB; + } + + sbit = rs_sbit((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->stop_bits); + RS232C_Mode.c_cflag &= ~CSTOPB; + RS232C_Mode.c_cflag |= sbit; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->flowcontrol_on) { + RS232C_Mode.c_iflag |= IXON; + RS232C_Mode.c_iflag |= IXOFF; + RS232C_Mode.c_cc[VSTART] = + (char)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->flowcontrol_xon_char; + RS232C_Mode.c_cc[VSTOP] = + (char)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->flowcontrol_xoff_char; + } else { + RS232C_Mode.c_iflag &= ~IXON; + RS232C_Mode.c_iflag &= ~IXOFF; + } + + switch ((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->in_eol) { + case CR: + RS232C_Mode.c_iflag &= ~INLCR; + RS232C_Mode.c_iflag &= ~IGNCR; + RS232C_Mode.c_iflag &= ~ICRNL; + break; + + case LF: + RS232C_Mode.c_iflag |= INLCR; + RS232C_Mode.c_iflag &= ~IGNCR; + RS232C_Mode.c_iflag &= ~ICRNL; + break; + + case CRLF: + default: RS232C_Mode.c_iflag |= INLCR; RS232C_Mode.c_iflag |= IGNCR; + } + + switch ((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->out_eol) { + case LF: + RS232C_Mode.c_oflag &= ~ONLCR; + RS232C_Mode.c_oflag &= ~OCRNL; + RS232C_Mode.c_oflag &= ~ONOCR; + RS232C_Mode.c_oflag &= ~ONLRET; + break; + + case CRLF: + RS232C_Mode.c_oflag |= ONLCR; + RS232C_Mode.c_oflag &= ~OCRNL; + RS232C_Mode.c_oflag &= ~ONOCR; + RS232C_Mode.c_oflag &= ~ONLRET; + break; + + case CR: + default: + RS232C_Mode.c_oflag &= ~ONLCR; + RS232C_Mode.c_oflag &= ~OCRNL; + RS232C_Mode.c_oflag &= ~ONOCR; + RS232C_Mode.c_oflag |= ONLRET; + } + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->input_max_bell) + RS232C_Mode.c_iflag |= IMAXBEL; + else + RS232C_Mode.c_iflag &= ~IMAXBEL; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->tab_expand) + RS232C_Mode.c_oflag |= XTABS; + else + RS232C_Mode.c_oflag &= ~XTABS; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->modem_status_line) + RS232C_Mode.c_cflag &= ~CLOCAL; + else + RS232C_Mode.c_cflag |= CLOCAL; + + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->rts_cts_control) + RS232C_Mode.c_cflag |= CRTSCTS; + else + RS232C_Mode.c_cflag &= ~CRTSCTS; + + if (ioctl(RS232C_Fd, TCSETS, &RS232C_Mode) < 0) + rs_error("rs232c_majorparam: cannot set params"); + else + RS232CParameterOutcome->success = 1; + } } -rs232c_majorparam() -{ +rs232c_minorparam() { + int status; - register int baud, csize, sbit; + if (RS232C_Fd >= 0) { + if (ioctl(RS232C_Fd, TIOCMGET, &status) < 0) + rs_error("rs_minorparam: cannot get status"); + else { + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->data_terminal_ready) + status |= TIOCM_DTR; + else + status &= ~TIOCM_DTR; - if (RS232C_Fd >= 0) { + if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->request_to_send) + status |= TIOCM_RTS; + else + status &= ~TIOCM_RTS; - baud = rs_baud((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->line_speed); - RS232C_Mode.c_cflag &= ~CBAUD; - RS232C_Mode.c_cflag |= baud; - - csize = rs_csize((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->char_length); - RS232C_Mode.c_cflag &= ~CSIZE; - RS232C_Mode.c_cflag |= csize; - if (csize == CS8) - RS232C_Mode.c_iflag &= ~ISTRIP; - else - RS232C_Mode.c_iflag |= ISTRIP; - - switch ((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->parity) { - case ODD: - RS232C_Mode.c_iflag |= INPCK; - RS232C_Mode.c_cflag |= PARENB; - RS232C_Mode.c_cflag |= PARODD; - break; - - case EVEN: - RS232C_Mode.c_iflag |= INPCK; - RS232C_Mode.c_cflag |= PARENB; - RS232C_Mode.c_cflag &= ~PARODD; - break; - - default: - RS232C_Mode.c_iflag &= ~INPCK; - RS232C_Mode.c_cflag &= ~PARENB; - } - - sbit = rs_sbit((u_int)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->stop_bits); - RS232C_Mode.c_cflag &= ~CSTOPB; - RS232C_Mode.c_cflag |= sbit; - - if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->flowcontrol_on) { - RS232C_Mode.c_iflag |= IXON; - RS232C_Mode.c_iflag |= IXOFF; - RS232C_Mode.c_cc[VSTART] = (char)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) - ->flowcontrol_xon_char; - RS232C_Mode.c_cc[VSTOP] = (char)((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) - ->flowcontrol_xoff_char; - } else { - RS232C_Mode.c_iflag &= ~IXON; - RS232C_Mode.c_iflag &= ~IXOFF; - } - - switch ((u_int) - ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->in_eol) { - case CR: - RS232C_Mode.c_iflag &= ~INLCR; - RS232C_Mode.c_iflag &= ~IGNCR; - RS232C_Mode.c_iflag &= ~ICRNL; - break; - - case LF: - RS232C_Mode.c_iflag |= INLCR; - RS232C_Mode.c_iflag &= ~IGNCR; - RS232C_Mode.c_iflag &= ~ICRNL; - break; - - case CRLF: - default: - RS232C_Mode.c_iflag |= INLCR; - RS232C_Mode.c_iflag |= IGNCR; - } - - switch ((u_int) - ((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->out_eol) { - case LF: - RS232C_Mode.c_oflag &= ~ONLCR; - RS232C_Mode.c_oflag &= ~OCRNL; - RS232C_Mode.c_oflag &= ~ONOCR; - RS232C_Mode.c_oflag &= ~ONLRET; - break; - - case CRLF: - RS232C_Mode.c_oflag |= ONLCR; - RS232C_Mode.c_oflag &= ~OCRNL; - RS232C_Mode.c_oflag &= ~ONOCR; - RS232C_Mode.c_oflag &= ~ONLRET; - break; - - case CR: - default: - RS232C_Mode.c_oflag &= ~ONLCR; - RS232C_Mode.c_oflag &= ~OCRNL; - RS232C_Mode.c_oflag &= ~ONOCR; - RS232C_Mode.c_oflag |= ONLRET; - } - - if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->input_max_bell) - RS232C_Mode.c_iflag |= IMAXBEL; - else - RS232C_Mode.c_iflag &= ~IMAXBEL; - - if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->tab_expand) - RS232C_Mode.c_oflag |= XTABS; - else - RS232C_Mode.c_oflag &= ~XTABS; - - if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->modem_status_line) - RS232C_Mode.c_cflag &= ~CLOCAL; - else - RS232C_Mode.c_cflag |= CLOCAL; - - if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB)->rts_cts_control) - RS232C_Mode.c_cflag |= CRTSCTS; - else - RS232C_Mode.c_cflag &= ~CRTSCTS; - - if (ioctl(RS232C_Fd, TCSETS, &RS232C_Mode) < 0) - rs_error("rs232c_majorparam: cannot set params"); - else - RS232CParameterOutcome->success = 1; - } -} - -rs232c_minorparam() -{ - - int status; - - if (RS232C_Fd >= 0) { - if (ioctl(RS232C_Fd, TIOCMGET, &status) < 0) - rs_error("rs_minorparam: cannot get status"); - else { - if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) - ->data_terminal_ready) - status |= TIOCM_DTR; - else - status &= ~TIOCM_DTR; - - if (((DLRS232C_PARAMETER_CSB *)RS232CParameterCSB) - ->request_to_send) - status |= TIOCM_RTS; - else - status &= ~TIOCM_RTS; - - if (ioctl(RS232C_Fd, TIOCMSET, &status) < 0) - rs_error("rs_minorparam: cannot set status"); - else - RS232CParameterOutcome->success = 1; - } - } + if (ioctl(RS232C_Fd, TIOCMSET, &status) < 0) + rs_error("rs_minorparam: cannot set status"); + else + RS232CParameterOutcome->success = 1; + } + } } /* * Following functions named as check_XXX are used for debug. */ -check_params(fd) - int fd; +check_params(fd) int fd; { - struct termios tos; + struct termios tos; - if (ioctl(fd, TCGETS, &tos) < 0) { - perror("IOCTL"); - exit(1); - } + if (ioctl(fd, TCGETS, &tos) < 0) { + perror("IOCTL"); + exit(1); + } - check_brate(tos.c_cflag); - check_csize(tos.c_cflag); - check_sbit(tos.c_cflag); - check_parity(tos.c_cflag); - check_oflag(tos.c_oflag); + check_brate(tos.c_cflag); + check_csize(tos.c_cflag); + check_sbit(tos.c_cflag); + check_parity(tos.c_cflag); + check_oflag(tos.c_oflag); - check_cannon(&tos); + check_cannon(&tos); } -check_brate(cf) - u_long cf; +check_brate(cf) u_long cf; { - int b; - printf("Baud rate : "); - switch (cf & CBAUD) { - case B0: b = 0; break; - case B50: b = 50; break; - case B75: b = 75; break; - case B110: b = 110; break; - case B134: b = 134; break; - case B200: b = 200; break; - case B300: b = 300; break; - case B600: b = 600; break; - case B1200: b = 1200; break; - case B1800: b = 1800; break; - case B2400: b = 2400; break; - case B4800: b = 4800; break; - case B9600: b = 9600; break; - case B19200: b = 19200; break; - case B38400: b = 384000; break; - default: printf("Illeagal.\n"); - } - printf("%d bps.\n", b); + int b; + printf("Baud rate : "); + switch (cf & CBAUD) { + case B0: b = 0; break; + case B50: b = 50; break; + case B75: b = 75; break; + case B110: b = 110; break; + case B134: b = 134; break; + case B200: b = 200; break; + case B300: b = 300; break; + case B600: b = 600; break; + case B1200: b = 1200; break; + case B1800: b = 1800; break; + case B2400: b = 2400; break; + case B4800: b = 4800; break; + case B9600: b = 9600; break; + case B19200: b = 19200; break; + case B38400: b = 384000; break; + default: printf("Illeagal.\n"); + } + printf("%d bps.\n", b); } - -check_csize(cf) - u_long cf; +check_csize(cf) u_long cf; { - int s; - printf("Char size : "); - switch(cf & CSIZE) { - case CS5: s = 5; break; - case CS6: s = 6; break; - case CS7: s = 7; break; - case CS8: s = 8; break; - default: printf("Illeagal.\n"); - } - printf("%d chars.\n", s); + int s; + printf("Char size : "); + switch (cf & CSIZE) { + case CS5: s = 5; break; + case CS6: s = 6; break; + case CS7: s = 7; break; + case CS8: s = 8; break; + default: printf("Illeagal.\n"); + } + printf("%d chars.\n", s); } -check_sbit(cf) - u_long cf; +check_sbit(cf) u_long cf; { - int s; - printf("Stop bit : "); - if (cf & CSTOPB) - printf("2 bits.\n"); - else - printf("1 bit.\n"); + int s; + printf("Stop bit : "); + if (cf & CSTOPB) + printf("2 bits.\n"); + else + printf("1 bit.\n"); } -check_parity(cf) - u_long cf; +check_parity(cf) u_long cf; { - if (cf & PARENB) { - printf("Parity Enabled : "); - if (cf &PARODD) - printf("Odd.\n"); - else - printf("Even.\n"); - } else { - printf("Parity Disabled.\n"); - } + if (cf & PARENB) { + printf("Parity Enabled : "); + if (cf & PARODD) + printf("Odd.\n"); + else + printf("Even.\n"); + } else { + printf("Parity Disabled.\n"); + } } -check_cannon(tos) - struct termios *tos; +check_cannon(tos) struct termios *tos; { - u_long lf; + u_long lf; - lf = tos->c_lflag; + lf = tos->c_lflag; - if (lf & ICANON) { - printf("Cannonical.\n"); - } else { - printf("Non-Cannonical.\n"); - printf("MIN : %d , TIME : %d\n", - (tos->c_cc)[VMIN], (tos->c_cc)[VTIME]); - } + if (lf & ICANON) { + printf("Cannonical.\n"); + } else { + printf("Non-Cannonical.\n"); + printf("MIN : %d , TIME : %d\n", (tos->c_cc)[VMIN], (tos->c_cc)[VTIME]); + } } -check_oflag(of) - u_long of; +check_oflag(of) u_long of; { - if ((OPOST & of) == OPOST) { - printf("OPOST : O\n"); - } else { - printf("OPOST : X\n"); - } + if ((OPOST & of) == OPOST) { + printf("OPOST : O\n"); + } else { + printf("OPOST : X\n"); + } - if ((ONLCR & of) == ONLCR) { - printf("ONLCR : O\n"); - } else { - printf("ONLCR : X\n"); - } - if ((OCRNL & of) == OCRNL) { - printf("OCRNL : O\n"); - } else { - printf("OCRNL : X\n"); - } + if ((ONLCR & of) == ONLCR) { + printf("ONLCR : O\n"); + } else { + printf("ONLCR : X\n"); + } + if ((OCRNL & of) == OCRNL) { + printf("OCRNL : O\n"); + } else { + printf("OCRNL : X\n"); + } - if ((ONOCR & of) == ONOCR) { - printf("ONOCR : O\n"); - } else { - printf("ONOCR : X\n"); - } - if ((ONLRET & of) == ONLRET) { - printf("ONLRET : O\n"); - } else { - printf("ONLRET : X\n"); - } - if ((OFILL & of) == OFILL) { - printf("OFILL : O\n"); - } else { - printf("OFILL : X\n"); - } - if ((OFDEL & of) == OFDEL) { - printf("OFDEL : O\n"); - } else { - printf("OFDEL : X\n"); - } - switch (NLDLY & of) { - case NL0: - printf("NL0 \n"); break; - case NL1: - printf("NL1\n"); break; - } - switch (CRDLY & of) { - case CR0: - printf("NL0 \n"); break; - case CR1: - printf("CR1\n"); break; - case CR2: - printf("CR2\n"); break; - case CR3: - printf("CR3\n"); break; - } - switch (TABDLY & of) { - case TAB0: - printf("NL0 \n"); break; - case TAB1: - printf("TAB1\n"); break; - case TAB2: - printf("TAB2\n"); break; - case XTABS: - printf("XTABS\n"); break; - } - switch (BSDLY & of) { - case BS0: - printf("NL0 \n"); break; - case BS1: - printf("BS1\n"); break; - } - switch (VTDLY & of) { - case VT0: - printf("NL0 \n"); break; - case VT1: - printf("VT1\n"); break; - } - switch (FFDLY & of) { - case FF0: - printf("NL0 \n"); break; - case FF1: - printf("FF1\n"); break; - } + if ((ONOCR & of) == ONOCR) { + printf("ONOCR : O\n"); + } else { + printf("ONOCR : X\n"); + } + if ((ONLRET & of) == ONLRET) { + printf("ONLRET : O\n"); + } else { + printf("ONLRET : X\n"); + } + if ((OFILL & of) == OFILL) { + printf("OFILL : O\n"); + } else { + printf("OFILL : X\n"); + } + if ((OFDEL & of) == OFDEL) { + printf("OFDEL : O\n"); + } else { + printf("OFDEL : X\n"); + } + switch (NLDLY & of) { + case NL0: printf("NL0 \n"); break; + case NL1: printf("NL1\n"); break; + } + switch (CRDLY & of) { + case CR0: printf("NL0 \n"); break; + case CR1: printf("CR1\n"); break; + case CR2: printf("CR2\n"); break; + case CR3: printf("CR3\n"); break; + } + switch (TABDLY & of) { + case TAB0: printf("NL0 \n"); break; + case TAB1: printf("TAB1\n"); break; + case TAB2: printf("TAB2\n"); break; + case XTABS: printf("XTABS\n"); break; + } + switch (BSDLY & of) { + case BS0: printf("NL0 \n"); break; + case BS1: printf("BS1\n"); break; + } + switch (VTDLY & of) { + case VT0: printf("NL0 \n"); break; + case VT1: printf("VT1\n"); break; + } + switch (FFDLY & of) { + case FF0: printf("NL0 \n"); break; + case FF1: printf("FF1\n"); break; + } } - + /* * In dbx, "call rsc()". */ -rsc() -{ - if (RS232C_Fd >= 0) - check_params(RS232C_Fd); +rsc() { + if (RS232C_Fd >= 0) check_params(RS232C_Fd); } /* Old debug function: not updated. rs232c_debug( name, sw ) char *name; - int sw; + int sw; { struct sgttyb mode; - if ( sw == 1 ) { + if ( sw == 1 ) { printf("DEBUG: %s\n",name); @@ -871,22 +756,29 @@ rs232c_debug( name, sw ) } /+ if(RS232C_Fd) end +/ - } /+ if(sw) end +/ + } /+ if(sw) end +/ - if ( sw == 2 ) { + if ( sw == 2 ) { printf("DEBUG: %s\n",name); - printf("DEBUG:\n"); - printf("DEBUG: \t\tSymbol Address Contents\n"); - printf("DEBUG: \t\tIOPAGE %#x\n",Addr68k_from_LADDR(IOPAGE_OFFSET)); - printf("DEBUG: \t\tHardWareConfig %#x %#x\n", HardWareConfig, *(DLword*) HardWareConfig); - printf("DEBUG: \t\tRS232CGetFlag %#x %#x\n", RS232CGetFlag, *(DLword*) RS232CGetFlag); - printf("DEBUG: \t\tRS232CPutFlag %#x %#x\n", RS232CPutFlag, *(DLword*) RS232CPutFlag); - printf("DEBUG: \t\tRS232CMiscCommand %#x %#x\n", RS232CMiscCommand, *(DLword*) RS232CMiscCommand); - printf("DEBUG: \t\tRS232CGetCSB %#x %#x\n", RS232CGetCSB, (LispPTR) (((*(RS232CGetCSB+1) & 0xff)<<16) + *RS232CGetCSB )); - printf("DEBUG: \t\tRS232CPutCSB %#x %#x\n", RS232CPutCSB, (LispPTR) (((*(RS232CPutCSB+1) & 0xff)<<16) + *RS232CPutCSB )); - printf("DEBUG: \t\tRS232CParameterCSB %#x %#x\n", RS232CParameterCSB, *(DLword*) RS232CParameterCSB); + printf("DEBUG:\n"); + printf("DEBUG: \t\tSymbol Address Contents\n"); + printf("DEBUG: \t\tIOPAGE %#x\n",Addr68k_from_LADDR(IOPAGE_OFFSET)); + printf("DEBUG: \t\tHardWareConfig %#x %#x\n", HardWareConfig, *(DLword*) +HardWareConfig); + printf("DEBUG: \t\tRS232CGetFlag %#x %#x\n", RS232CGetFlag, *(DLword*) +RS232CGetFlag); + printf("DEBUG: \t\tRS232CPutFlag %#x %#x\n", RS232CPutFlag, *(DLword*) +RS232CPutFlag); + printf("DEBUG: \t\tRS232CMiscCommand %#x %#x\n", RS232CMiscCommand, *(DLword*) +RS232CMiscCommand); + printf("DEBUG: \t\tRS232CGetCSB %#x %#x\n", RS232CGetCSB, (LispPTR) +(((*(RS232CGetCSB+1) & 0xff)<<16) + *RS232CGetCSB )); + printf("DEBUG: \t\tRS232CPutCSB %#x %#x\n", RS232CPutCSB, (LispPTR) +(((*(RS232CPutCSB+1) & 0xff)<<16) + *RS232CPutCSB )); + printf("DEBUG: \t\tRS232CParameterCSB %#x %#x\n", RS232CParameterCSB, *(DLword*) +RS232CParameterCSB); printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+1)); printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+2)); printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+3)); @@ -894,19 +786,21 @@ rs232c_debug( name, sw ) printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+5)); printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+6)); printf("DEBUG: \t\t %#x\n", *(DLword*) (RS232CParameterCSB+7)); - if( RS232C_WrIOCB != NULL ) - printf("DEBUG: \t\tRS232C_WrIOCB %#x %#x\n", RS232C_WrIOCB, *((LispPTR*)RS232C_WrIOCB)); - if( RS232C_RdIOCB != NULL ) - printf("DEBUG: \t\tRS232C_RdIOCB %#x %#x\n", RS232C_RdIOCB, *((LispPTR*)RS232C_RdIOCB)); + if( RS232C_WrIOCB != NULL ) + printf("DEBUG: \t\tRS232C_WrIOCB %#x %#x\n", RS232C_WrIOCB, +*((LispPTR*)RS232C_WrIOCB)); + if( RS232C_RdIOCB != NULL ) + printf("DEBUG: \t\tRS232C_RdIOCB %#x %#x\n", RS232C_RdIOCB, +*((LispPTR*)RS232C_RdIOCB)); - /+ - if( RS232C_WrBufAddr != NULL ) + /+ + if( RS232C_WrBufAddr != NULL ) printf("DEBUG: \t\tRS232C_WrBufAddr %s\n" , RS232C_WrBufAddr); - if( RS232C_WrBufAddr != NULL ) + if( RS232C_WrBufAddr != NULL ) printf("DEBUG: \t\tRS232C_RdBufAddr %s\n" , RS232C_RdBufAddr); - +/ + +/ - } /+ if(sw) end +/ + } /+ if(sw) end +/ } /+ rs232c_debug end +/ diff --git a/src/setsout.c b/src/setsout.c old mode 100755 new mode 100644 index fd3c6bb..8b47c52 --- a/src/setsout.c +++ b/src/setsout.c @@ -1,7 +1,7 @@ -/* $Id: setsout.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: setsout.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: setsout.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,7 +16,6 @@ static char *id = "$Id: setsout.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyr #include "version.h" - /* * setsout.c */ @@ -42,77 +41,71 @@ static char *id = "$Id: setsout.c,v 1.3 1999/05/31 23:35:41 sybalsky Exp $ Copyr #include "ifpage.h" #include "dbprint.h" -#define IFPAGE_ADDRESS 512 -#define MBYTE 0x100000 /* 1 Mbyte */ -extern int errno; +#define IFPAGE_ADDRESS 512 +#define MBYTE 0x100000 /* 1 Mbyte */ +extern int errno; /* JDS protoize char *valloc(size_t); */ -void set_sysout(int version, char *sysout_file_name) -{ - int sysout; /* SysoutFile descriptor */ - IFPAGE ifpage; /* IFPAGE */ - char errmsg [ 255 ]; +void set_sysout(int version, char *sysout_file_name) { + int sysout; /* SysoutFile descriptor */ + IFPAGE ifpage; /* IFPAGE */ + char errmsg[255]; - /* - * first read the IFPAGE(InterfacePage) - */ + /* + * first read the IFPAGE(InterfacePage) + */ - /* open SysoutFile */ - sysout = open(sysout_file_name, O_RDWR, NULL); - if (sysout == -1) { - sprintf( errmsg, - "sysout_loader: can't open sysout file: %s", - sysout_file_name); - perror( errmsg ); - exit(-1); - } - /* seek to IFPAGE */ - if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { - perror("sysout_loader: can't seek to IFPAGE"); - exit(-1); - } - /* reads IFPAGE into scratch_page */ - if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) { - perror("sysout_loader: can't read IFPAGE"); - exit(-1); - } + /* open SysoutFile */ + sysout = open(sysout_file_name, O_RDWR, NULL); + if (sysout == -1) { + sprintf(errmsg, "sysout_loader: can't open sysout file: %s", sysout_file_name); + perror(errmsg); + exit(-1); + } + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } + /* reads IFPAGE into scratch_page */ + if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) { + perror("sysout_loader: can't read IFPAGE"); + exit(-1); + } #ifdef BYTESWAP - word_swap_page(&ifpage, (3+sizeof(IFPAGE))/4); + word_swap_page(&ifpage, (3 + sizeof(IFPAGE)) / 4); #endif - ifpage.lversion = version; - ifpage.minbversion = version; + ifpage.lversion = version; + ifpage.minbversion = version; - /* seek to IFPAGE */ - if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { - perror("sysout_loader: can't seek to IFPAGE"); - exit(-1); - } - /* reads IFPAGE into scratch_page */ - if (write(sysout, &ifpage, sizeof(IFPAGE)) == -1) { - perror("Can't write IFPAGE"); - exit(-1); - } + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } + /* reads IFPAGE into scratch_page */ + if (write(sysout, &ifpage, sizeof(IFPAGE)) == -1) { + perror("Can't write IFPAGE"); + exit(-1); + } - close(sysout); - printf("%d", ifpage.minbversion); + close(sysout); + printf("%d", ifpage.minbversion); } -int main(int argc, char **argv) -{ - int version, res; - if (argc < 3) - { - printf("setsysout version sysout-name\n"); - return(-1); - } - if ((version = atoi(argv[1])) == 0) - { - printf("version must be an integer > 0.\n"); - return(-1); - } - set_sysout(version, argv[2]); - exit(0); +int main(int argc, char **argv) { + int version, res; + if (argc < 3) { + printf("setsysout version sysout-name\n"); + return (-1); } + if ((version = atoi(argv[1])) == 0) { + printf("version must be an integer > 0.\n"); + return (-1); + } + set_sysout(version, argv[2]); + exit(0); +} diff --git a/src/shift.c b/src/shift.c old mode 100755 new mode 100644 index f735f39..37b1dd1 --- a/src/shift.c +++ b/src/shift.c @@ -1,8 +1,6 @@ -/* $Id: shift.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: shift.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: shift.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +15,6 @@ static char *id = "$Id: shift.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyrig #include "version.h" - #include #include "lispemul.h" #include "lspglob.h" @@ -27,9 +24,9 @@ static char *id = "$Id: shift.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyrig #include "lsptypes.h" #include "arith.h" -#define LSH 0347 +#define LSH 0347 -DLword *createcell68k(unsigned int type); +DLword *createcell68k(unsigned int type); /* * XXX: it feels as though something is not clean here, looks like the @@ -39,78 +36,61 @@ DLword *createcell68k(unsigned int type); /************************************************************ N_OP_llsh1 - entry LLSH1 OPCODE[0340] - return(a << 1) + entry LLSH1 OPCODE[0340] + return(a << 1) ************************************************************/ -LispPTR N_OP_llsh1(int a) -{ - N_ARITH_BODY_1_UNSIGNED(a, 1, <<); -} +LispPTR N_OP_llsh1(int a) { N_ARITH_BODY_1_UNSIGNED(a, 1, <<); } /************************************************************ N_OP_llsh8 - entry LLSH8 OPCODE[0341] - return(a << 8) + entry LLSH8 OPCODE[0341] + return(a << 8) ************************************************************/ -LispPTR N_OP_llsh8(int a) -{ - N_ARITH_BODY_1_UNSIGNED(a, 8, <<); -} +LispPTR N_OP_llsh8(int a) { N_ARITH_BODY_1_UNSIGNED(a, 8, <<); } /************************************************************ N_OP_lrsh1 - entry LRSH1 OPCODE[0342] - return(a >> 1) + entry LRSH1 OPCODE[0342] + return(a >> 1) ************************************************************/ -LispPTR N_OP_lrsh1(int a) -{ - N_ARITH_BODY_1_UNSIGNED(a, 1, >>); -} +LispPTR N_OP_lrsh1(int a) { N_ARITH_BODY_1_UNSIGNED(a, 1, >>); } /************************************************************ N_OP_lrsh8 - entry LRSH8 OPCODE[0343] - return(a >> 8) + entry LRSH8 OPCODE[0343] + return(a >> 8) ************************************************************/ -LispPTR N_OP_lrsh8(int a) -{ - N_ARITH_BODY_1_UNSIGNED(a, 8, >>); -} +LispPTR N_OP_lrsh8(int a) { N_ARITH_BODY_1_UNSIGNED(a, 8, >>); } /************************************************************ N_OP_lsh - entry LSH OPCODE[0347] - return(a b) + entry LSH OPCODE[0347] + return(a b) ************************************************************/ -LispPTR N_OP_lsh(int a, int b) -{ -register int arg,arg2; -register int size; -/*DLword *wordp;*/ +LispPTR N_OP_lsh(int a, int b) { + register int arg, arg2; + register int size; + /*DLword *wordp;*/ - N_GETNUMBER(b, size, do_ufn); - N_GETNUMBER(a, arg2, do_ufn); + N_GETNUMBER(b, size, do_ufn); + N_GETNUMBER(a, arg2, do_ufn); + if (size > 0) { + if (size > 31) goto do_ufn; + arg = arg2 << size; + if ((arg >> size) != arg2) goto do_ufn; + } else if (size < 0) { + if (size < -31) goto do_ufn; + arg = arg2 >> -size; + /*** Commented out JDS 1/27/89: This punts if you shifted ***/ + /*** ANY 1 bits off the right edge. You CAN'T overflow ***/ + /*** in this direction!! ***/ + /* if ((arg << -size) != arg2) goto do_ufn; */ + } else + return (a); - if (size > 0) { - if (size > 31) goto do_ufn; - arg = arg2 << size; - if ((arg >> size) != arg2) goto do_ufn; - } else - if (size < 0) { - if (size < -31) goto do_ufn; - arg = arg2 >> -size; -/*** Commented out JDS 1/27/89: This punts if you shifted ***/ -/*** ANY 1 bits off the right edge. You CAN'T overflow ***/ -/*** in this direction!! ***/ -/* if ((arg << -size) != arg2) goto do_ufn; */ - } else return(a); + N_ARITH_SWITCH(arg); - - - N_ARITH_SWITCH(arg); - -do_ufn: ERROR_EXIT(b); +do_ufn: + ERROR_EXIT(b); } - - diff --git a/src/socdvr.c b/src/socdvr.c old mode 100755 new mode 100644 index d7b6cbc..0c03e4e --- a/src/socdvr.c +++ b/src/socdvr.c @@ -1,8 +1,7 @@ -/* $Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,8 +16,6 @@ static char *id = "$Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ Copyri #include "version.h" - - #include #include #include @@ -31,67 +28,63 @@ static char *id = "$Id: socdvr.c,v 1.2 1999/01/03 02:07:33 sybalsky Exp $ Copyri #include "lsptypes.h" #include "lispmap.h" -#define min(x,y) (((x) > (y)) ? (y) : (x)) +#define min(x, y) (((x) > (y)) ? (y) : (x)) +/***********************************************************/ +/* L S t r i n g T o C S t r i n g */ +/* */ +/* Convert a lisp string to a C string up to MaxLen long. */ +/***********************************************************/ - - /***********************************************************/ - /* L S t r i n g T o C S t r i n g */ - /* */ - /* Convert a lisp string to a C string up to MaxLen long. */ - /***********************************************************/ - -#define LStringToCString(Lisp, C, MaxLen ,Len) \ - { \ - OneDArray *arrayp; \ - char *base; \ - short *sbase; \ - int i; \ - \ - arrayp = (OneDArray *)(Addr68k_from_LADDR((unsigned int)Lisp)); \ - Len = min(MaxLen, arrayp->fillpointer); \ - \ - switch(arrayp->typenumber) \ - { \ - case THIN_CHAR_TYPENUMBER: \ - base = ((char *) \ - (Addr68k_from_LADDR((unsigned int)arrayp->base))) \ - + ((int)(arrayp->offset)); \ - for(i=0;ibase))) \ - + ((int)(arrayp->offset)); \ - base = (char *)sbase; \ - for(i=0;ifillpointer); \ + \ + switch (arrayp->typenumber) { \ + case THIN_CHAR_TYPENUMBER: \ + base = \ + ((char *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + for (i = 0; i < Len; i++) C[i] = base[i]; \ + C[Len] = '\0'; \ + break; \ + \ + case FAT_CHAR_TYPENUMBER: \ + sbase = \ + ((short *)(Addr68k_from_LADDR((unsigned int)arrayp->base))) + ((int)(arrayp->offset)); \ + base = (char *)sbase; \ + for (i = 0; i < Len * 2; i++) C[i] = base[i]; \ + C[Len * 2] = '\0'; \ + break; \ + \ + default: error("LStringToCString can not handle\n"); \ + } \ } -#define FGetNum(ptr, place) { \ - if(((ptr) & SEGMASK)== S_POSITIVE) {(place) = ((ptr) & 0xffff);}\ - else if(((ptr) & SEGMASK)== S_NEGATIVE) {(place) = (int)((ptr)| 0xffff0000);}\ - else {return(NIL);}} +#define FGetNum(ptr, place) \ + { \ + if (((ptr)&SEGMASK) == S_POSITIVE) { \ + (place) = ((ptr)&0xffff); \ + } else if (((ptr)&SEGMASK) == S_NEGATIVE) { \ + (place) = (int)((ptr) | 0xffff0000); \ + } else { \ + return (NIL); \ + } \ + } #define MAX_NAME_LEN 256 -static char XServer_Name[MAX_NAME_LEN]; /* Name of host with X server */ -static int XPort_Number = 0; /* Display # to ask for on it */ +static char XServer_Name[MAX_NAME_LEN]; /* Name of host with X server */ +static int XPort_Number = 0; /* Display # to ask for on it */ -int XServer_Fd = -1; /* The socket for the X server */ +int XServer_Fd = -1; /* The socket for the X server */ extern DLword *Lisp_world; - - /************************************************************************/ /* */ /* O p e n _ S o c k e t */ @@ -106,43 +99,38 @@ extern DLword *Lisp_world; /* */ /************************************************************************/ -Open_Socket( args ) - LispPTR *args; - { +Open_Socket(args) LispPTR *args; +{ #ifdef TRACE - printf( "TRACE: Open_Socket()\n" ); + printf("TRACE: Open_Socket()\n"); #endif - int length; + int length; - LStringToCString( args[0], XServer_Name, MAX_NAME_LEN, length ); - FGetNum( args[1], XPort_Number ); - XPort_Number -= X_TCP_PORT; + LStringToCString(args[0], XServer_Name, MAX_NAME_LEN, length); + FGetNum(args[1], XPort_Number); + XPort_Number -= X_TCP_PORT; - if( XServer_Fd == -1 ) - { - XServer_Fd = connect_to_server( XServer_Name, XPort_Number ); + if (XServer_Fd == -1) { + XServer_Fd = connect_to_server(XServer_Name, XPort_Number); - if (XServer_Fd < 0) /* error in connect. */ - { - perror("connecting to X server"); - return(NIL); - } + if (XServer_Fd < 0) /* error in connect. */ + { + perror("connecting to X server"); + return (NIL); + } - { /* Make it non-blocking I/O */ - int res; - res = fcntl( XServer_Fd, F_GETFL ); - res |= FNDELAY; - res = fcntl( XServer_Fd, F_SETFL, res ); - } - } /* end if(XServer_Fd) */ - - return( ATOM_T ); + { /* Make it non-blocking I/O */ + int res; + res = fcntl(XServer_Fd, F_GETFL); + res |= FNDELAY; + res = fcntl(XServer_Fd, F_SETFL, res); + } + } /* end if(XServer_Fd) */ + return (ATOM_T); } - - /************************************************************************/ /* */ /* C l o s e _ S o c k e t */ @@ -151,30 +139,24 @@ Open_Socket( args ) /* */ /************************************************************************/ -Close_Socket() - { - int stat; +Close_Socket() { + int stat; -#ifdef TRACE - printf( "TRACE: Close_Socket()\n" ); +#ifdef TRACE + printf("TRACE: Close_Socket()\n"); #endif - if( (stat = close( XServer_Fd )) == -1 ) - { /* close failed; return NIL, but squash the old fd anyhow */ - XServer_Fd = -1; - perror("Close_socket"); - return( NIL ); - } - else - { /* close succeeded; return T. */ - XServer_Fd = -1; - return( ATOM_T ); - } + if ((stat = close(XServer_Fd)) == + -1) { /* close failed; return NIL, but squash the old fd anyhow */ + XServer_Fd = -1; + perror("Close_socket"); + return (NIL); + } else { /* close succeeded; return T. */ + XServer_Fd = -1; + return (ATOM_T); + } } /* end Close_Socket */ - - - /************************************************************************/ /* */ /* R e a d _ S o c k e t */ @@ -183,60 +165,48 @@ Close_Socket() /* */ /************************************************************************/ -typedef struct - { /* Format for an X-server packet */ - DLword nil[22]; /* Packet header */ - DLword length; /* Request byte length */ - char data[592]; /* Data body */ - } PACKET; - +typedef struct { /* Format for an X-server packet */ + DLword nil[22]; /* Packet header */ + DLword length; /* Request byte length */ + char data[592]; /* Data body */ +} PACKET; #define PACKET_DEFOFFSET 46 -#define PACKET_MAXSIZE 638 +#define PACKET_MAXSIZE 638 -Read_Socket( args ) - LispPTR *args; - { - PACKET *packet; - char *buffer; - int length - , actlen; +Read_Socket(args) LispPTR *args; +{ + PACKET *packet; + char *buffer; + int length, actlen; #ifdef TRACE - printf( "TRACE: Read_Socket()\n" ); + printf("TRACE: Read_Socket()\n"); #endif - if( XServer_Fd >= 0 ) + if (XServer_Fd >= 0) { + packet = (PACKET *)Addr68k_from_LADDR(args[0]); + + if ((length = (int)(packet->length) - PACKET_DEFOFFSET) > 0) { + buffer = &(packet->data[0]); + + if ((actlen = read(XServer_Fd, buffer, length)) > 0) { + packet->length = (DLword)(actlen + PACKET_DEFOFFSET); + return (ATOM_T); + } /* end if(actlen) */ + if (actlen < 0) /* error !*/ { + if ((errno != EWOULDBLOCK) & (errno != EINTR)) perror("reading X connection"); + return (NIL); + } - packet = (PACKET *) Addr68k_from_LADDR( args[0] ); + } /* end if(length) */ - if( (length = (int)(packet->length)-PACKET_DEFOFFSET) > 0 ) - { - buffer = &(packet->data[0]); - - if( (actlen = read( XServer_Fd, buffer, length )) > 0 ) - { - packet->length = (DLword)(actlen + PACKET_DEFOFFSET); - return(ATOM_T); - } /* end if(actlen) */ - if(actlen < 0) /* error !*/ - { - if ((errno != EWOULDBLOCK) & (errno != EINTR)) - perror("reading X connection"); - return(NIL); - } - - } /* end if(length) */ - - } /* end if( fd ) */ - - - return( NIL ); - - } /* end Read_Socket */ + } /* end if( fd ) */ + return (NIL); +} /* end Read_Socket */ /************************************************************************/ /* */ @@ -246,51 +216,41 @@ Read_Socket( args ) /* */ /************************************************************************/ -Write_Socket( args ) - LispPTR *args; - { - PACKET *packet; - char *buffer; - int length - , actlen; +Write_Socket(args) LispPTR *args; +{ + PACKET *packet; + char *buffer; + int length, actlen; #ifdef TRACE - printf( "TRACE: Write_Socket()\n" ); + printf("TRACE: Write_Socket()\n"); #endif - if( XServer_Fd >= 0 ) + if (XServer_Fd >= 0) { + packet = (PACKET *)Addr68k_from_LADDR(args[0]); + + if ((length = (int)(packet->length) - PACKET_DEFOFFSET) > 0) { + buffer = &(packet->data[0]); + + if ((actlen = write(XServer_Fd, buffer, length)) > 0) { + packet->length = (DLword)(actlen + PACKET_DEFOFFSET); + return (ATOM_T); + + } /* end if( actlen ) */ + if (actlen < 0) /* error !*/ { + if (errno != EINTR) perror("writing X connection"); + return (NIL); + } - packet = (PACKET *) Addr68k_from_LADDR( args[0] ); - - if( (length = (int)(packet->length)-PACKET_DEFOFFSET) > 0 ) - { - buffer = &(packet->data[0]); - - if( (actlen = write( XServer_Fd, buffer, length )) > 0 ) - { - packet->length = (DLword)(actlen + PACKET_DEFOFFSET); - return(ATOM_T); - - } /* end if( actlen ) */ - if(actlen < 0) /* error !*/ - { - if (errno != EINTR) perror("writing X connection"); - return(NIL); - } - - - } /* end if(length) */ - - } /* end if( fd ) */ - - packet->length = 0; - return(NIL); - - } /* end Write_Socket */ + } /* end if(length) */ + } /* end if( fd ) */ + packet->length = 0; + return (NIL); +} /* end Write_Socket */ /************************************************************************/ /* */ @@ -304,19 +264,20 @@ Write_Socket( args ) /************************************************************************/ extern int KBDEventFlg; -Kbd_Transition( args ) - LispPTR *args; - /* args[0] is key-number */ - /* args[1] is up-flg */ - { - DLword key_number; - - key_number = (DLword)(args[0] & 0xffff); - if( args[1] ) kb_trans( key_number, 1 ); - else kb_trans( key_number, 0 ); +Kbd_Transition(args) LispPTR *args; +/* args[0] is key-number */ +/* args[1] is up-flg */ +{ + DLword key_number; - DoRing(); - /* If there's something for lisp to do, ask for an interrupt: */ - if( (KBDEventFlg += 1) > 0 ) Irq_Stk_End = Irq_Stk_Check = 0; + key_number = (DLword)(args[0] & 0xffff); + if (args[1]) + kb_trans(key_number, 1); + else + kb_trans(key_number, 0); - } /* end Kbd_Transition */ + DoRing(); + /* If there's something for lisp to do, ask for an interrupt: */ + if ((KBDEventFlg += 1) > 0) Irq_Stk_End = Irq_Stk_Check = 0; + +} /* end Kbd_Transition */ diff --git a/src/socket.c b/src/socket.c old mode 100755 new mode 100644 index e59c04c..038a953 --- a/src/socket.c +++ b/src/socket.c @@ -1,4 +1,5 @@ -/* $Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ Copyright (C) Venue"; /* Copyright Massachusetts Institute of Technology 1988 */ /* @@ -6,7 +7,7 @@ static char *id = "$Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ Copyri * systems. VMS and System V should plan to have their own version. * * This code was cribbed from lib/X/XConnDis.c. - * Compile using + * Compile using * % cc -c socket.c -DUNIXCONN */ @@ -18,14 +19,14 @@ static char *id = "$Id: socket.c,v 1.2 1999/01/03 02:07:34 sybalsky Exp $ Copyri #include #include #include -#include +#include #include #ifndef hpux #include #endif -extern int errno; /* Certain (broken) OS's don't have this */ - /* decl in errno.h */ +extern int errno; /* Certain (broken) OS's don't have this */ + /* decl in errno.h */ #ifdef UNIXCONN #include @@ -35,83 +36,75 @@ extern int errno; /* Certain (broken) OS's don't have this */ #endif /* UNIXCONN */ void bcopy(); -/* - * Attempts to connect to server, given host and display. Returns file +/* + * Attempts to connect to server, given host and display. Returns file * descriptor (network socket) or 0 if connection fails. */ -int connect_to_server (host, display) - char *host; - int display; +int connect_to_server(host, display) char *host; +int display; { - struct sockaddr_in inaddr; /* INET socket address. */ - struct sockaddr *addr; /* address to connect to */ + struct sockaddr_in inaddr; /* INET socket address. */ + struct sockaddr *addr; /* address to connect to */ struct hostent *host_ptr; - int addrlen; /* length of address */ + int addrlen; /* length of address */ #ifdef UNIXCONN - struct sockaddr_un unaddr; /* UNIX socket address. */ + struct sockaddr_un unaddr; /* UNIX socket address. */ #endif extern char *getenv(); extern struct hostent *gethostbyname(); - int fd; /* Network socket */ + int fd; /* Network socket */ { #ifdef UNIXCONN - if ((host[0] == '\0') || - (strcmp("unix", host) == 0)) { - /* Connect locally using Unix domain. */ - unaddr.sun_family = AF_UNIX; - (void) strcpy(unaddr.sun_path, X_UNIX_PATH); - sprintf(&unaddr.sun_path[strlen(unaddr.sun_path)], "%d", display); - addr = (struct sockaddr *) &unaddr; - addrlen = strlen(unaddr.sun_path) + 2; - /* - * Open the network connection. - */ - if ((fd = socket((int) addr->sa_family, SOCK_STREAM, 0)) < 0) - return(-1); /* errno set by system call. */ + if ((host[0] == '\0') || (strcmp("unix", host) == 0)) { + /* Connect locally using Unix domain. */ + unaddr.sun_family = AF_UNIX; + (void)strcpy(unaddr.sun_path, X_UNIX_PATH); + sprintf(&unaddr.sun_path[strlen(unaddr.sun_path)], "%d", display); + addr = (struct sockaddr *)&unaddr; + addrlen = strlen(unaddr.sun_path) + 2; + /* + * Open the network connection. + */ + if ((fd = socket((int)addr->sa_family, SOCK_STREAM, 0)) < 0) + return (-1); /* errno set by system call. */ } else #endif { /* Get the statistics on the specified host. */ - if ((inaddr.sin_addr.s_addr = inet_addr(host)) == -1) - { - if ((host_ptr = gethostbyname(host)) == NULL) - { - /* No such host! */ - errno = EINVAL; - return(-1); - } - /* Check the address type for an internet host. */ - if (host_ptr->h_addrtype != AF_INET) - { - /* Not an Internet host! */ - errno = EPROTOTYPE; - return(-1); - } - /* Set up the socket data. */ - inaddr.sin_family = host_ptr->h_addrtype; - bcopy((char *)host_ptr->h_addr, - (char *)&inaddr.sin_addr, - sizeof(inaddr.sin_addr)); - } - else - { - inaddr.sin_family = AF_INET; - } - addr = (struct sockaddr *) &inaddr; - addrlen = sizeof (struct sockaddr_in); + if ((inaddr.sin_addr.s_addr = inet_addr(host)) == -1) { + if ((host_ptr = gethostbyname(host)) == NULL) { + /* No such host! */ + errno = EINVAL; + return (-1); + } + /* Check the address type for an internet host. */ + if (host_ptr->h_addrtype != AF_INET) { + /* Not an Internet host! */ + errno = EPROTOTYPE; + return (-1); + } + /* Set up the socket data. */ + inaddr.sin_family = host_ptr->h_addrtype; + bcopy((char *)host_ptr->h_addr, (char *)&inaddr.sin_addr, sizeof(inaddr.sin_addr)); + } else { + inaddr.sin_family = AF_INET; + } + addr = (struct sockaddr *)&inaddr; + addrlen = sizeof(struct sockaddr_in); inaddr.sin_port = display + X_TCP_PORT; inaddr.sin_port = htons(inaddr.sin_port); /* * Open the network connection. */ - if ((fd = socket((int) addr->sa_family, SOCK_STREAM, 0)) < 0){ - return(-1); /* errno set by system call. */} - /* make sure to turn off TCP coalescence */ + if ((fd = socket((int)addr->sa_family, SOCK_STREAM, 0)) < 0) { + return (-1); /* errno set by system call. */ + } +/* make sure to turn off TCP coalescence */ #ifdef TCP_NODELAY { - int mi = 1; - setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (int)); + int mi = 1; + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof(int)); } #endif } @@ -122,14 +115,14 @@ int connect_to_server (host, display) * since the timer results in a SIGALRM. -- jdi */ while (connect(fd, addr, addrlen) == -1) { - if (errno != EINTR) { - (void) close (fd); - return(-1); /* errno set by system call. */ - } + if (errno != EINTR) { + (void)close(fd); + return (-1); /* errno set by system call. */ } + } } /* * Return the id if the connection succeeded. */ - return(fd); + return (fd); } diff --git a/src/storage.c b/src/storage.c old mode 100755 new mode 100644 index 6031bea..5fdec62 --- a/src/storage.c +++ b/src/storage.c @@ -1,7 +1,7 @@ -/* $Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ -static const char *id = "$Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue"; - - +/* $Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ +static const char *id = + "$Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ Copyright (C) Venue"; /************************************************************************/ /* */ @@ -15,18 +15,15 @@ static const char *id = "$Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ /* */ /************************************************************************/ - #include "version.h" - - /*****************************************************************/ /* - File Name : storage.c + File Name : storage.c */ /*****************************************************************/ -#include /* for printf */ +#include /* for printf */ #include "hdw_conf.h" #include "lispemul.h" #include "address.h" @@ -39,420 +36,361 @@ static const char *id = "$Id: storage.c,v 1.5 2001/12/26 22:17:04 sybalsky Exp $ #include "ifpage.h" #include "gc.h" - -#define MINARRAYBLOCKSIZE 4 -#define GUARDVMEMFULL 500 -#define IFPVALID_KEY 5603 - +#define MINARRAYBLOCKSIZE 4 +#define GUARDVMEMFULL 500 +#define IFPVALID_KEY 5603 void advance_array_seg(register unsigned int nxtpage); void set_storage_state(void); - /*****************************************************************/ /* - Func Name : checkfor_storagefull(npages) + Func Name : checkfor_storagefull(npages) - Created : Oct. 7, 1987 Takeshi Shimizu - Changed : Oct. 12,1987 take + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : Oct. 12,1987 take - Used to be LispPTR T/NIL return, but result never used + Used to be LispPTR T/NIL return, but result never used */ /*****************************************************************/ - -void checkfor_storagefull(register unsigned int npages) -{ - register int pagesleft; - register INTSTAT *int_state; - void advance_storagestate(DLword flg); +void checkfor_storagefull(register unsigned int npages) { + register int pagesleft; + register INTSTAT *int_state; + void advance_storagestate(DLword flg); #ifdef BIGVM - pagesleft = (*Next_MDSpage_word ) - - (*Next_Array_word) - PAGESPER_MDSUNIT ; + pagesleft = (*Next_MDSpage_word) - (*Next_Array_word) - PAGESPER_MDSUNIT; #else - pagesleft = (*Next_MDSpage_word & 0xffff) - - (*Next_Array_word & 0xffff) - PAGESPER_MDSUNIT ; + pagesleft = (*Next_MDSpage_word & 0xffff) - (*Next_Array_word & 0xffff) - PAGESPER_MDSUNIT; #endif - if((pagesleft < GUARDSTORAGEFULL) || (npages !=0)) - { - if (*STORAGEFULLSTATE_word == NIL) set_storage_state(); + if ((pagesleft < GUARDSTORAGEFULL) || (npages != 0)) { + if (*STORAGEFULLSTATE_word == NIL) set_storage_state(); - switch(*STORAGEFULLSTATE_word & 0xffff) - { - case SFS_NOTSWITCHABLE : - case SFS_FULLYSWITCHED : - if(pagesleft <0) - { - while(T) - { - error("MP9320:Storage completly full"); - } - } - else if ((pagesleft<=GUARD1STORAGEFULL) - && (*STORAGEFULL_word !=NIL)) - { - *STORAGEFULL_word = S_POSITIVE; - error("MP9325:Space getting VERY full.\ + switch (*STORAGEFULLSTATE_word & 0xffff) { + case SFS_NOTSWITCHABLE: + case SFS_FULLYSWITCHED: + if (pagesleft < 0) { + while (T) { error("MP9320:Storage completly full"); } + } else if ((pagesleft <= GUARD1STORAGEFULL) && (*STORAGEFULL_word != NIL)) { + *STORAGEFULL_word = S_POSITIVE; + error( + "MP9325:Space getting VERY full.\ Please save and reload a.s.a.p."); - } - else if (*STORAGEFULL_word == NIL) - { - *STORAGEFULL_word=ATOM_T; - int_state=(INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word); - int_state->storagefull=T; - *PENDINGINTERRUPT_word =ATOM_T; - } -#ifdef DEBUG - printf("\n checkfor_storagefull:DORECLAIM.....\n"); + } else if (*STORAGEFULL_word == NIL) { + *STORAGEFULL_word = ATOM_T; + int_state = (INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word); + int_state->storagefull = T; + *PENDINGINTERRUPT_word = ATOM_T; + } +#ifdef DEBUG + printf("\n checkfor_storagefull:DORECLAIM.....\n"); #endif - return; /*(NIL); */ + return; /*(NIL); */ - break; + break; - case SFS_SWITCHABLE : - if(npages==NIL) - { - if(pagesleft <= 0) - { - *LeastMDSPage_word= *Next_Array_word; - *Next_MDSpage_word= *SecondMDSPage_word; - advance_storagestate(SFS_FULLYSWITCHED); - advance_array_seg(*SecondArrayPage_word); - return; - } - } - else if (npages > pagesleft) - { - /* Have to switch array space over, - but leave MDS to fill the rest of the low pages */ - *LeastMDSPage_word= *Next_Array_word; - advance_storagestate(SFS_ARRAYSWITCHED); - advance_array_seg(*SecondArrayPage_word); - return; - } - break ; + case SFS_SWITCHABLE: + if (npages == NIL) { + if (pagesleft <= 0) { + *LeastMDSPage_word = *Next_Array_word; + *Next_MDSpage_word = *SecondMDSPage_word; + advance_storagestate(SFS_FULLYSWITCHED); + advance_array_seg(*SecondArrayPage_word); + return; + } + } else if (npages > pagesleft) { + /* Have to switch array space over, + but leave MDS to fill the rest of the low pages */ + *LeastMDSPage_word = *Next_Array_word; + advance_storagestate(SFS_ARRAYSWITCHED); + advance_array_seg(*SecondArrayPage_word); + return; + } + break; #ifdef BIGVM - case SFS_ARRAYSWITCHED : if((*Next_MDSpage_word) < - (*LeastMDSPage_word)) + case SFS_ARRAYSWITCHED: + if ((*Next_MDSpage_word) < (*LeastMDSPage_word)) #else - case SFS_ARRAYSWITCHED : if((*Next_MDSpage_word & 0xffff) < - (*LeastMDSPage_word & 0xffff)) + case SFS_ARRAYSWITCHED: + if ((*Next_MDSpage_word & 0xffff) < (*LeastMDSPage_word & 0xffff)) #endif - { - *Next_MDSpage_word= *SecondMDSPage_word; - advance_storagestate - (SFS_FULLYSWITCHED); - return; - } - else if (npages != NIL) - if((npages + GUARDSTORAGEFULL) >= + { + *Next_MDSpage_word = *SecondMDSPage_word; + advance_storagestate(SFS_FULLYSWITCHED); + return; + } else if (npages != NIL) + if ((npages + GUARDSTORAGEFULL) >= #ifdef BIGVM - ((*SecondMDSPage_word)- - (*Next_Array_word))) + ((*SecondMDSPage_word) - (*Next_Array_word))) #else - ((*SecondMDSPage_word & 0xffff)- - (*Next_Array_word & 0xffff))) + ((*SecondMDSPage_word & 0xffff) - (*Next_Array_word & 0xffff))) #endif - return; /* (NIL); */ - return; /* (T); */ - /* break; */ + return; /* (NIL); */ + return; /* (T); */ + /* break; */ - default : error("checkfor_storagefull: Shouldn't"); /* (*STORAGEFULLSTATE_word) & 0xffff) */ - break; - - } - } - else - return; /*(NIL); */ -}/* checkfor_storagefull end */ + default: + error("checkfor_storagefull: Shouldn't"); /* (*STORAGEFULLSTATE_word) & 0xffff) */ + break; + } + } else + return; /*(NIL); */ +} /* checkfor_storagefull end */ /*****************************************************************/ /* - Func Name : advance_array_seg(nxtpage) + Func Name : advance_array_seg(nxtpage) - Created : Oct. 7, 1987 Takeshi Shimizu - Changed : + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : */ /*****************************************************************/ void advance_array_seg(register unsigned int nxtpage) - /* rare page num */ +/* rare page num */ { + unsigned int ncellsleft; + LispPTR mergebackward(LispPTR base); + LispPTR makefreearrayblock(LispPTR block, DLword length); - unsigned int ncellsleft; - LispPTR mergebackward(LispPTR base); - LispPTR makefreearrayblock(LispPTR block, DLword length); - - /* Called when 8Mb are exhausted,and we want to switch array space - into the extended area(Secondary space),starting with nextpage. - We MUST clean up old area first. */ +/* Called when 8Mb are exhausted,and we want to switch array space + into the extended area(Secondary space),starting with nextpage. + We MUST clean up old area first. */ #ifdef BIGVM - nxtpage &= 0xFFFFF; /* new VM, limit is 20 bits of page */ + nxtpage &= 0xFFFFF; /* new VM, limit is 20 bits of page */ #else - nxtpage &= 0xFFFF; /* for old VM size, limit is 16 bits of page */ + nxtpage &= 0xFFFF; /* for old VM size, limit is 16 bits of page */ #endif - ncellsleft = - (*Next_Array_word - POINTER_PAGE(*ArrayFrLst_word) -1)* CELLSPER_PAGE - + (CELLSPER_PAGE - (((*ArrayFrLst_word) & 0xff) >> 1) ); + ncellsleft = (*Next_Array_word - POINTER_PAGE(*ArrayFrLst_word) - 1) * CELLSPER_PAGE + + (CELLSPER_PAGE - (((*ArrayFrLst_word) & 0xff) >> 1)); - if(ncellsleft >= MINARRAYBLOCKSIZE) - { - mergebackward(makefreearrayblock(*ArrayFrLst_word , ncellsleft)); + if (ncellsleft >= MINARRAYBLOCKSIZE) { + mergebackward(makefreearrayblock(*ArrayFrLst_word, ncellsleft)); #ifdef BIGVM - *ArrayFrLst2_word = (((*LeastMDSPage_word) ) << 8); + *ArrayFrLst2_word = (((*LeastMDSPage_word)) << 8); #else - *ArrayFrLst2_word = (((*LeastMDSPage_word) & 0xffff) << 8); + *ArrayFrLst2_word = (((*LeastMDSPage_word) & 0xffff) << 8); #endif - } -else - { - *ArrayFrLst2_word = *ArrayFrLst_word; + } else { + *ArrayFrLst2_word = *ArrayFrLst_word; } #ifdef BIGVM - *Next_Array_word = nxtpage ; + *Next_Array_word = nxtpage; #else - *Next_Array_word = S_POSITIVE | nxtpage ; + *Next_Array_word = S_POSITIVE | nxtpage; #endif - *ArrayFrLst_word = nxtpage << 8 ; - *ArraySpace2_word = *ArrayFrLst_word; + *ArrayFrLst_word = nxtpage << 8; + *ArraySpace2_word = *ArrayFrLst_word; - /* return(S_POSITIVE); making function void as result never used */ + /* return(S_POSITIVE); making function void as result never used */ } /* advance_array_seg end */ /*****************************************************************/ /* - Func Name : advance_storagestate(flg) + Func Name : advance_storagestate(flg) - Created : Oct. 7, 1987 Takeshi Shimizu - Changed : + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : */ /*****************************************************************/ /* DLword */ -void advance_storagestate(DLword flg) -{ - LispPTR dremove(LispPTR x, LispPTR l); +void advance_storagestate(DLword flg) { + LispPTR dremove(LispPTR x, LispPTR l); #ifdef DEBUG - printf("STORAGEFULLSTATE is now set to %d \n",flg); + printf("STORAGEFULLSTATE is now set to %d \n", flg); #endif - *STORAGEFULLSTATE_word = (S_POSITIVE | flg ); - InterfacePage->fullspaceused = 65535 ; - *SYSTEMCACHEVARS_word = dremove(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word); + *STORAGEFULLSTATE_word = (S_POSITIVE | flg); + InterfacePage->fullspaceused = 65535; + *SYSTEMCACHEVARS_word = dremove(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word); } /*****************************************************************/ /* - Func Name : set_storage_state() + Func Name : set_storage_state() - Created : Oct. 7, 1987 Takeshi Shimizu - Changed : + Created : Oct. 7, 1987 Takeshi Shimizu + Changed : */ /*****************************************************************/ -void set_storage_state(void) -{ - LispPTR cons(LispPTR cons_car, LispPTR cons_cdr); +void set_storage_state(void) { + LispPTR cons(LispPTR cons_car, LispPTR cons_cdr); - if((*MACHINETYPE_word & 0xffff)== KATANA) - { - if(InterfacePage->dl24bitaddressable !=0) - *STORAGEFULLSTATE_word = S_POSITIVE | SFS_SWITCHABLE ; + if ((*MACHINETYPE_word & 0xffff) == KATANA) { + if (InterfacePage->dl24bitaddressable != 0) + *STORAGEFULLSTATE_word = S_POSITIVE | SFS_SWITCHABLE; else - *STORAGEFULLSTATE_word = S_POSITIVE | SFS_NOTSWITCHABLE ; + *STORAGEFULLSTATE_word = S_POSITIVE | SFS_NOTSWITCHABLE; - *SYSTEMCACHEVARS_word = - cons(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word); + *SYSTEMCACHEVARS_word = cons(STORAGEFULLSTATE_index, *SYSTEMCACHEVARS_word); - GCLOOKUP(*SYSTEMCACHEVARS_word, ADDREF); + GCLOOKUP(*SYSTEMCACHEVARS_word, ADDREF); #ifdef DEBUG - printf("SETSTATE: set to %d \n",(*STORAGEFULLSTATE_word)& 0xffff); + printf("SETSTATE: set to %d \n", (*STORAGEFULLSTATE_word) & 0xffff); #endif - } - else - { - error("set_storage_state: Sorry! We can work on only KATANA"); + } else { + error("set_storage_state: Sorry! We can work on only KATANA"); } } /* set_storage_state() end */ +LispPTR dremove(LispPTR x, LispPTR l) { + LispPTR z; - - - -LispPTR dremove(LispPTR x, LispPTR l) -{ - LispPTR z; - - if( Listp(l)==NIL) return(NIL); - else if (x == car(l)) - { - if(cdr(l)!=NIL) - { - rplaca(l,car(cdr(l))); - rplacd(l,cdr(cdr(l))); - return(dremove(x,l)); - } - } - else - { - z=l; - lp: if(Listp(cdr(l)) ==NIL) - return(z); - else if(x==car(cdr(l))) - rplacd(l , cdr(cdr(l))); - else - l=cdr(l); - goto lp; - } + if (Listp(l) == NIL) + return (NIL); + else if (x == car(l)) { + if (cdr(l) != NIL) { + rplaca(l, car(cdr(l))); + rplacd(l, cdr(cdr(l))); + return (dremove(x, l)); + } + } else { + z = l; + lp: + if (Listp(cdr(l)) == NIL) + return (z); + else if (x == car(cdr(l))) + rplacd(l, cdr(cdr(l))); + else + l = cdr(l); + goto lp; + } } - /*****************************************************************/ /* - Func Name : newpage(addr) + Func Name : newpage(addr) - Created : Oct. 12, 1987 Takeshi Shimizu - Changed : Oct. 13, 1987 take - OCt. 20, 1987 take + Created : Oct. 12, 1987 Takeshi Shimizu + Changed : Oct. 13, 1987 take + OCt. 20, 1987 take */ /*****************************************************************/ -LispPTR newpage(LispPTR base) -{ +LispPTR newpage(LispPTR base) { #ifdef BIGVM - register unsigned int vp; /* Virtual Page we're creating */ + register unsigned int vp; /* Virtual Page we're creating */ #else - register DLword vp; /* (built from base) */ + register DLword vp; /* (built from base) */ #endif /* BIGVM */ - register INTSTAT *int_state; + register INTSTAT *int_state; - extern LispPTR *LASTVMEMFILEPAGE_word; - extern LispPTR *VMEM_FULL_STATE_word; - unsigned int nactive; + extern LispPTR *LASTVMEMFILEPAGE_word; + extern LispPTR *VMEM_FULL_STATE_word; + unsigned int nactive; - vp=base >>8; /* Compute virtual-page # from Lisp address of the page */ + vp = base >> 8; /* Compute virtual-page # from Lisp address of the page */ #ifdef DEBUG - /************************/ - if(vp == 0) error ("newpage: vp=0"); - printf("***newpage modify vmemsize %d ",InterfacePage->nactivepages); - /*************************/ + /************************/ + if (vp == 0) error("newpage: vp=0"); + printf("***newpage modify vmemsize %d ", InterfacePage->nactivepages); +/*************************/ #endif + nactive = ++(InterfacePage->nactivepages); + +/* if nactive is a multiple of the # of FPTOVP entries */ +/* on a page, we need to create a new FPTOVP page. */ +#ifdef BIGVM + if ((nactive & 127) == 0) /* in BIGVM, they're cells */ +#else + if ((nactive & 0xff) == 0) /* in old way, they're words */ +#endif /* BIGVM */ + { /* need to add virtual page for fptovp first */ + unsigned int vp_of_fp, fp_of_fptovp; + + /* compute virtual page of new FPtoVP table page */ + /* i.e., the vp that holds the next FPtoVP entry */ + vp_of_fp = (LADDR_from_68k(FPtoVP + nactive) >> 8); + + /* compute file page where this entry has to be to ensure + that FPtoVP is contiguous on the file */ + + fp_of_fptovp = InterfacePage->fptovpstart + (vp_of_fp - (LADDR_from_68k(FPtoVP) >> 8)); + + /* debugging check: make sure FPtoVP is contiguous */ + + if (GETFPTOVP(FPtoVP, fp_of_fptovp - 1) != vp_of_fp - 1) { + printf("FPtoVP not contiguous\n"); + printf("vp_of_fp = 0x%x, fp = 0x%x\n", vp_of_fp, fp_of_fptovp); + printf("FPTOVP(fp-1) = 0x%x.\n", GETFPTOVP(FPtoVP, fp_of_fptovp - 1)); + } + + /* move the file page for the previous VMEM page */ + GETFPTOVP(FPtoVP, nactive) = GETFPTOVP(FPtoVP, fp_of_fptovp); + + /* now, store virtual page of FPtoVP in FPtoVP table */ + + GETFPTOVP(FPtoVP, fp_of_fptovp) = (vp_of_fp); + + /* now we can make room for the new page we're adding */ nactive = ++(InterfacePage->nactivepages); - - /* if nactive is a multiple of the # of FPTOVP entries */ - /* on a page, we need to create a new FPTOVP page. */ -#ifdef BIGVM - if ((nactive & 127) == 0) /* in BIGVM, they're cells */ -#else - if ((nactive & 0xff) == 0) /* in old way, they're words */ -#endif /* BIGVM */ - { /* need to add virtual page for fptovp first */ - unsigned int vp_of_fp, fp_of_fptovp; - - /* compute virtual page of new FPtoVP table page */ - /* i.e., the vp that holds the next FPtoVP entry */ - vp_of_fp = (LADDR_from_68k(FPtoVP+nactive) >> 8); - - /* compute file page where this entry has to be to ensure - that FPtoVP is contiguous on the file */ - - fp_of_fptovp = InterfacePage->fptovpstart + - (vp_of_fp - (LADDR_from_68k(FPtoVP) >> 8)); - - /* debugging check: make sure FPtoVP is contiguous */ - - if (GETFPTOVP(FPtoVP, fp_of_fptovp - 1) != vp_of_fp -1 ) - { - printf ("FPtoVP not contiguous\n"); - printf("vp_of_fp = 0x%x, fp = 0x%x\n", vp_of_fp, fp_of_fptovp); - printf("FPTOVP(fp-1) = 0x%x.\n", GETFPTOVP(FPtoVP,fp_of_fptovp-1)); - } - - /* move the file page for the previous VMEM page */ - GETFPTOVP(FPtoVP, nactive) = GETFPTOVP(FPtoVP, fp_of_fptovp); - - /* now, store virtual page of FPtoVP in FPtoVP table */ - - GETFPTOVP(FPtoVP, fp_of_fptovp) = (vp_of_fp); - - /* now we can make room for the new page we're adding */ - nactive = ++(InterfacePage->nactivepages); - } - GETFPTOVP(FPtoVP, nactive) = vp ; + } + GETFPTOVP(FPtoVP, nactive) = vp; #ifdef DEBUG - /*************************/ - printf("to %d with VP:%d \n",InterfacePage->nactivepages,vp); - /************************/ + /*************************/ + printf("to %d with VP:%d \n", InterfacePage->nactivepages, vp); +/************************/ #endif - if(InterfacePage->nactivepages > + if (InterfacePage->nactivepages > #ifdef BIGVM - ( ((*LASTVMEMFILEPAGE_word)) - GUARDVMEMFULL ) ) + (((*LASTVMEMFILEPAGE_word)) - GUARDVMEMFULL)) #else - ( ((*LASTVMEMFILEPAGE_word) & 0xffff) - GUARDVMEMFULL ) ) + (((*LASTVMEMFILEPAGE_word) & 0xffff) - GUARDVMEMFULL)) #endif - { - /* set vmemfull state */ - if(*VMEM_FULL_STATE_word ==NIL) - { - int_state=(INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word); - int_state->vmemfull=T; - *PENDINGINTERRUPT_word =ATOM_T; - } + { + /* set vmemfull state */ + if (*VMEM_FULL_STATE_word == NIL) { + int_state = (INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word); + int_state->vmemfull = T; + *PENDINGINTERRUPT_word = ATOM_T; + } #ifdef BIGVM - if(InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word) )) + if (InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word))) #else - if(InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word) & 0xffff)) + if (InterfacePage->nactivepages < ((*LASTVMEMFILEPAGE_word) & 0xffff)) #endif - { - *VMEM_FULL_STATE_word =S_POSITIVE ; /* set 0 */ - } - else if(InterfacePage->key == IFPVALID_KEY) - { - *VMEM_FULL_STATE_word = ATOM_T; - } - else *VMEM_FULL_STATE_word = make_atom("DIRTY",0,5,0); - } - - return(base); - - } /* newpage */ - + { + *VMEM_FULL_STATE_word = S_POSITIVE; /* set 0 */ + } else if (InterfacePage->key == IFPVALID_KEY) { + *VMEM_FULL_STATE_word = ATOM_T; + } else + *VMEM_FULL_STATE_word = make_atom("DIRTY", 0, 5, 0); + } + return (base); +} /* newpage */ /*****************************************************************/ /* - Func Name : init_storage() - Description: - Set values which are referenced by - Lisp Storage handling funcs + Func Name : init_storage() + Description: + Set values which are referenced by + Lisp Storage handling funcs - Created : Apr-23 1990 Takeshi Shimizu - Changed : + Created : Apr-23 1990 Takeshi Shimizu + Changed : */ /*****************************************************************/ -void init_storage(void) -{ - +void init_storage(void) { #ifdef BIGVM - *SecondMDSPage_word = ( InterfacePage->dllastvmempage - - PAGESPER_MDSUNIT -1); + *SecondMDSPage_word = (InterfacePage->dllastvmempage - PAGESPER_MDSUNIT - 1); #else - *SecondMDSPage_word = S_POSITIVE |( InterfacePage->dllastvmempage - - PAGESPER_MDSUNIT -1); + *SecondMDSPage_word = S_POSITIVE | (InterfacePage->dllastvmempage - PAGESPER_MDSUNIT - 1); #endif - } /* init_storage */ - +} /* init_storage */ diff --git a/src/subr.c b/src/subr.c old mode 100755 new mode 100644 index 6d7fc0f..2441f63 --- a/src/subr.c +++ b/src/subr.c @@ -1,8 +1,6 @@ /* $Id: subr.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: subr.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,29 +15,25 @@ static char *id = "$Id: subr.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyrigh #include "version.h" - - - - /***********************************************************/ /* - File Name : subr.c - Including : OP_subrcall + File Name : subr.c + Including : OP_subrcall - Created : May 12, 1987 Takeshi Shimizu - Changed : May 15 87 take - Changed : Jun 2 87 NMitani - Jun. 5 87 take - Jun. 29 87 NMitani - Oct. 13 87 Hayata - Oct. 16 87 take - Nov. 18 87 Matsuda - Dec. 17 1987 Tomtom - 2/17/89 Sybalsky (Add SXHASH) + Created : May 12, 1987 Takeshi Shimizu + Changed : May 15 87 take + Changed : Jun 2 87 NMitani + Jun. 5 87 take + Jun. 29 87 NMitani + Oct. 13 87 Hayata + Oct. 16 87 take + Nov. 18 87 Matsuda + Dec. 17 1987 Tomtom + 2/17/89 Sybalsky (Add SXHASH) */ /***********************************************************/ - + #include #include "lispemul.h" #include "address.h" @@ -56,13 +50,12 @@ static char *id = "$Id: subr.c,v 1.3 1999/05/31 23:35:42 sybalsky Exp $ Copyrigh extern LispPTR *PENDINGINTERRUPT68k; - /***********************************************************/ /* - Func Name : OP_subrcall + Func Name : OP_subrcall - Last Modify : 13-Oct 1987 take + Last Modify : 13-Oct 1987 take */ /***********************************************************/ @@ -71,716 +64,767 @@ extern LispPTR *PENDINGINTERRUPT68k; extern int *c_ret_to_dispatch; extern int *ret_to_dispatch; #endif -extern LispPTR Uraid_mess; +extern LispPTR Uraid_mess; LispPTR subr_lisperror(); /* 0377 */ -char *atom_to_str(LispPTR atom_index) -{ PNCell *pnptr; - char *pname_base; +char *atom_to_str(LispPTR atom_index) { + PNCell *pnptr; + char *pname_base; - pnptr = (PNCell *) GetPnameCell(atom_index); - pname_base = (char *) Addr68k_from_LADDR(pnptr->pnamebase); - return(pname_base+1); + pnptr = (PNCell *)GetPnameCell(atom_index); + pname_base = (char *)Addr68k_from_LADDR(pnptr->pnamebase); + return (pname_base + 1); } /*atom_to_str*/ -#define POP_SUBR_ARGS \ -{ args[0] = NIL_PTR; \ - if (( arg_num = (argnum/* = (Get_BYTE(PC+2))*/)) > 0) { \ - while(arg_num >0) \ - PopStackTo(args[--arg_num]); \ - } \ -} +#define POP_SUBR_ARGS \ + { \ + args[0] = NIL_PTR; \ + if ((arg_num = (argnum /* = (Get_BYTE(PC+2))*/)) > 0) { \ + while (arg_num > 0) PopStackTo(args[--arg_num]); \ + } \ + } -void OP_subrcall(int subr_no, int argnum) -{ +void OP_subrcall(int subr_no, int argnum) { static LispPTR args[30]; - int arg_num; + int arg_num; int i; -PushCStack; /* save TOS in memory */ + PushCStack; /* save TOS in memory */ -DBPRINT(("Subr call to subr 0%o.\n", subr_no)); + DBPRINT(("Subr call to subr 0%o.\n", subr_no)); -switch(subr_no) - { - case sb_SHOWDISPLAY :POP_SUBR_ARGS; - DSP_showdisplay(args); - break;/* showdisplay */ - case sb_DSPBOUT : POP_SUBR_ARGS; - DSP_dspbout( args ); - break; /*dspbout */ - case sb_RAID : POP_SUBR_ARGS; - Uraid_mess= args[0]; - PC+= 3; /* for the case of hardreset */ - error("URAID Called:"); - Uraid_mess=NIL; - TopOfStack =NIL; - return; /* Direct return;avoid to increment PC */ - /* break; */ - /*************************/ - /* for Local File System */ - /*************************/ - case sb_COM_OPENFILE : POP_SUBR_ARGS; - TopOfStack = COM_openfile(args); - break; - case sb_COM_CLOSEFILE : POP_SUBR_ARGS; - TopOfStack = COM_closefile(args); - break; - case sb_UFS_GETFILENAME : POP_SUBR_ARGS; - TopOfStack = UFS_getfilename(args); - break; - case sb_UFS_DELETEFILE : POP_SUBR_ARGS; - TopOfStack = UFS_deletefile(args); - break; - case sb_UFS_RENAMEFILE : POP_SUBR_ARGS; - TopOfStack = UFS_renamefile(args); - break; - case sb_COM_READPAGES : POP_SUBR_ARGS; - TopOfStack = COM_readpage(args); - break; - case sb_COM_WRITEPAGES : POP_SUBR_ARGS; - TopOfStack = COM_writepage(args); - break; - case sb_COM_TRUNCATEFILE : POP_SUBR_ARGS; - TopOfStack = COM_truncatefile(args); - break; - case sb_COM_NEXT_FILE : POP_SUBR_ARGS; - TopOfStack = COM_next_file(args); - break; - case sb_COM_FINISH_FINFO : POP_SUBR_ARGS; - TopOfStack = COM_finish_finfo(args); - break; - case sb_COM_GEN_FILES : POP_SUBR_ARGS; - TopOfStack = COM_gen_files(args); - break; - case sb_UFS_DIRECTORYNAMEP : POP_SUBR_ARGS; - TopOfStack = UFS_directorynamep(args); - break; - case sb_COM_GETFILEINFO : POP_SUBR_ARGS; - TopOfStack = COM_getfileinfo(args); - break; - case sb_COM_CHANGEDIR : POP_SUBR_ARGS; - TopOfStack = COM_changedir(args); - break; - case sb_COM_GETFREEBLOCK: POP_SUBR_ARGS; - TopOfStack = COM_getfreeblock(args); - break; - case sb_COM_SETFILEINFO: POP_SUBR_ARGS; - TopOfStack = COM_setfileinfo(args); - break; + switch (subr_no) { + case sb_SHOWDISPLAY: + POP_SUBR_ARGS; + DSP_showdisplay(args); + break; /* showdisplay */ + case sb_DSPBOUT: + POP_SUBR_ARGS; + DSP_dspbout(args); + break; /*dspbout */ + case sb_RAID: + POP_SUBR_ARGS; + Uraid_mess = args[0]; + PC += 3; /* for the case of hardreset */ + error("URAID Called:"); + Uraid_mess = NIL; + TopOfStack = NIL; + return; /* Direct return;avoid to increment PC */ + /* break; */ + /*************************/ + /* for Local File System */ + /*************************/ + case sb_COM_OPENFILE: + POP_SUBR_ARGS; + TopOfStack = COM_openfile(args); + break; + case sb_COM_CLOSEFILE: + POP_SUBR_ARGS; + TopOfStack = COM_closefile(args); + break; + case sb_UFS_GETFILENAME: + POP_SUBR_ARGS; + TopOfStack = UFS_getfilename(args); + break; + case sb_UFS_DELETEFILE: + POP_SUBR_ARGS; + TopOfStack = UFS_deletefile(args); + break; + case sb_UFS_RENAMEFILE: + POP_SUBR_ARGS; + TopOfStack = UFS_renamefile(args); + break; + case sb_COM_READPAGES: + POP_SUBR_ARGS; + TopOfStack = COM_readpage(args); + break; + case sb_COM_WRITEPAGES: + POP_SUBR_ARGS; + TopOfStack = COM_writepage(args); + break; + case sb_COM_TRUNCATEFILE: + POP_SUBR_ARGS; + TopOfStack = COM_truncatefile(args); + break; + case sb_COM_NEXT_FILE: + POP_SUBR_ARGS; + TopOfStack = COM_next_file(args); + break; + case sb_COM_FINISH_FINFO: + POP_SUBR_ARGS; + TopOfStack = COM_finish_finfo(args); + break; + case sb_COM_GEN_FILES: + POP_SUBR_ARGS; + TopOfStack = COM_gen_files(args); + break; + case sb_UFS_DIRECTORYNAMEP: + POP_SUBR_ARGS; + TopOfStack = UFS_directorynamep(args); + break; + case sb_COM_GETFILEINFO: + POP_SUBR_ARGS; + TopOfStack = COM_getfileinfo(args); + break; + case sb_COM_CHANGEDIR: + POP_SUBR_ARGS; + TopOfStack = COM_changedir(args); + break; + case sb_COM_GETFREEBLOCK: + POP_SUBR_ARGS; + TopOfStack = COM_getfreeblock(args); + break; + case sb_COM_SETFILEINFO: + POP_SUBR_ARGS; + TopOfStack = COM_setfileinfo(args); + break; - /*************/ - /* for Timer */ - /*************/ - case sb_SETUNIXTIME : POP_SUBR_ARGS; - TopOfStack = subr_settime(args); - break; - case sb_GETUNIXTIME : POP_SUBR_ARGS; - TopOfStack = subr_gettime(args); - break; - case sb_COPYTIMESTATS : POP_SUBR_ARGS; - TopOfStack = subr_copytimestats(args); - break; + /*************/ + /* for Timer */ + /*************/ + case sb_SETUNIXTIME: + POP_SUBR_ARGS; + TopOfStack = subr_settime(args); + break; + case sb_GETUNIXTIME: + POP_SUBR_ARGS; + TopOfStack = subr_gettime(args); + break; + case sb_COPYTIMESTATS: + POP_SUBR_ARGS; + TopOfStack = subr_copytimestats(args); + break; - /*************/ - /* for Ether */ - /*************/ - case sb_CHECK_SUM :POP_SUBR_ARGS; - TopOfStack = check_sum(args); - break; + /*************/ + /* for Ether */ + /*************/ + case sb_CHECK_SUM: + POP_SUBR_ARGS; + TopOfStack = check_sum(args); + break; - case sb_ETHER_SUSPEND : POP_SUBR_ARGS; - TopOfStack = ether_suspend(args); - break; - case sb_ETHER_RESUME : POP_SUBR_ARGS; - TopOfStack = ether_resume(args); - break; - case sb_ETHER_AVAILABLE : POP_SUBR_ARGS; - TopOfStack = ether_ctrlr(args); - break; - case sb_ETHER_RESET : POP_SUBR_ARGS; - TopOfStack = ether_reset(args); - break; - case sb_ETHER_GET : POP_SUBR_ARGS; - TopOfStack = ether_get(args); - break; - case sb_ETHER_SEND : POP_SUBR_ARGS; - TopOfStack = ether_send(args); - break; - case sb_ETHER_SETFILTER : POP_SUBR_ARGS; - TopOfStack = ether_setfilter(args); - break; - case sb_ETHER_CHECK: POP_SUBR_ARGS; - TopOfStack = check_ether(); - break; + case sb_ETHER_SUSPEND: + POP_SUBR_ARGS; + TopOfStack = ether_suspend(args); + break; + case sb_ETHER_RESUME: + POP_SUBR_ARGS; + TopOfStack = ether_resume(args); + break; + case sb_ETHER_AVAILABLE: + POP_SUBR_ARGS; + TopOfStack = ether_ctrlr(args); + break; + case sb_ETHER_RESET: + POP_SUBR_ARGS; + TopOfStack = ether_reset(args); + break; + case sb_ETHER_GET: + POP_SUBR_ARGS; + TopOfStack = ether_get(args); + break; + case sb_ETHER_SEND: + POP_SUBR_ARGS; + TopOfStack = ether_send(args); + break; + case sb_ETHER_SETFILTER: + POP_SUBR_ARGS; + TopOfStack = ether_setfilter(args); + break; + case sb_ETHER_CHECK: + POP_SUBR_ARGS; + TopOfStack = check_ether(); + break; - /***************/ - /* for Display */ - /***************/ - case sb_DSPCURSOR : POP_SUBR_ARGS; - DSP_Cursor(args, argnum); - break; - case sb_SETMOUSEXY : POP_SUBR_ARGS; - DSP_SetMousePos(args); - break; - case sb_DSP_VIDEOCOLOR : POP_SUBR_ARGS; - TopOfStack = DSP_VideoColor(args); - break; - case sb_DSP_SCREENWIDTH : POP_SUBR_ARGS; - TopOfStack = DSP_ScreenWidth(args); - break; - case sb_DSP_SCREENHEIGHT : POP_SUBR_ARGS; - TopOfStack = DSP_ScreenHight(args); - break; + /***************/ + /* for Display */ + /***************/ + case sb_DSPCURSOR: + POP_SUBR_ARGS; + DSP_Cursor(args, argnum); + break; + case sb_SETMOUSEXY: + POP_SUBR_ARGS; + DSP_SetMousePos(args); + break; + case sb_DSP_VIDEOCOLOR: + POP_SUBR_ARGS; + TopOfStack = DSP_VideoColor(args); + break; + case sb_DSP_SCREENWIDTH: + POP_SUBR_ARGS; + TopOfStack = DSP_ScreenWidth(args); + break; + case sb_DSP_SCREENHEIGHT: + POP_SUBR_ARGS; + TopOfStack = DSP_ScreenHight(args); + break; - /*************************/ - /* for color experiments */ - /*************************/ +/*************************/ +/* for color experiments */ +/*************************/ #ifdef COLOR - case sb_COLOR_INIT : POP_SUBR_ARGS; - TopOfStack=cgfour_init_color_display(args[0]); - break; - case sb_COLOR_SCREENMODE : POP_SUBR_ARGS; - TopOfStack=cgfour_change_screen_mode(args[0]); - break; - case sb_COLOR_MAP : POP_SUBR_ARGS; - TopOfStack=cgfour_set_colormap(args); - break; - case sb_COLOR_BASE : POP_SUBR_ARGS; - /* retun DLword offsetbetween LISPBASE and Lisp_world */ - TopOfStack=S_POSITIVE |(((int)Lisp_world >> 1) & 0xffff); - break; + case sb_COLOR_INIT: + POP_SUBR_ARGS; + TopOfStack = cgfour_init_color_display(args[0]); + break; + case sb_COLOR_SCREENMODE: + POP_SUBR_ARGS; + TopOfStack = cgfour_change_screen_mode(args[0]); + break; + case sb_COLOR_MAP: + POP_SUBR_ARGS; + TopOfStack = cgfour_set_colormap(args); + break; + case sb_COLOR_BASE: + POP_SUBR_ARGS; + /* retun DLword offsetbetween LISPBASE and Lisp_world */ + TopOfStack = S_POSITIVE | (((int)Lisp_world >> 1) & 0xffff); + break; - case sb_C_SlowBltChar : POP_SUBR_ARGS; - /* \\SLOWBLTCHAR for 8BITCOLOR */ - C_slowbltchar(args); - break; - case 0215 : POP_SUBR_ARGS; - Uncolorize_Bitmap(args); - break; - case 0216 : POP_SUBR_ARGS; - Colorize_Bitmap(args); - break; - case 0217 : POP_SUBR_ARGS; - Draw_8BppColorLine(args); - break; + case sb_C_SlowBltChar: + POP_SUBR_ARGS; + /* \\SLOWBLTCHAR for 8BITCOLOR */ + C_slowbltchar(args); + break; + case 0215: + POP_SUBR_ARGS; + Uncolorize_Bitmap(args); + break; + case 0216: + POP_SUBR_ARGS; + Colorize_Bitmap(args); + break; + case 0217: + POP_SUBR_ARGS; + Draw_8BppColorLine(args); + break; #endif /* COLOR */ + /***************************/ + /*** bitbltsub, bltchar ***/ + /***************************/ + case sb_BITBLTSUB: + POP_SUBR_ARGS; + bitbltsub(args); + break; + case sb_BLTCHAR: + POP_SUBR_ARGS; /* argnum * DLwordsperCell*/ + bltchar(args); + break; + case sb_NEW_BLTCHAR: + POP_SUBR_ARGS; + newbltchar(args); + break; + case sb_TEDIT_BLTCHAR: + POP_SUBR_ARGS; + tedit_bltchar(args); + break; + /* case 209: JDS 4 may 91 - this is code for CHAR-FILLBUFFER?? */ + case sb_BITBLT_BITMAP: + POP_SUBR_ARGS; /* BITBLT to a bitmap */ + { + TopOfStack = bitblt_bitmap(args); + break; + } + break; + case 0111 /*sb_BITSHADE_BITMAP*/: + POP_SUBR_ARGS; /* BITSHADE to a bitmap */ + { + TopOfStack = bitshade_bitmap(args); + break; + } + break; - /***************************/ - /*** bitbltsub, bltchar ***/ - /***************************/ - case sb_BITBLTSUB : POP_SUBR_ARGS; - bitbltsub(args); - break; - case sb_BLTCHAR : POP_SUBR_ARGS; /* argnum * DLwordsperCell*/ - bltchar(args); - break; - case sb_NEW_BLTCHAR : POP_SUBR_ARGS; - newbltchar(args); - break; - case sb_TEDIT_BLTCHAR : POP_SUBR_ARGS; - tedit_bltchar(args); - break; -/* case 209: JDS 4 may 91 - this is code for CHAR-FILLBUFFER?? */ - case sb_BITBLT_BITMAP: POP_SUBR_ARGS; /* BITBLT to a bitmap */ - { - TopOfStack = bitblt_bitmap(args); - break; - } - break; - case 0111/*sb_BITSHADE_BITMAP*/: POP_SUBR_ARGS; /* BITSHADE to a bitmap */ - { - TopOfStack = bitshade_bitmap(args); - break; - } - break; - - - /**************/ - /* For RS232C */ - /**************/ +/**************/ +/* For RS232C */ +/**************/ #ifdef RS232 - case sb_RS232C_CMD: RS232C_cmd(); break; - case sb_RS232C_READ_INIT: RS232C_readinit(); break; - case sb_RS232C_WRITE: RS232C_write(); break; + case sb_RS232C_CMD: RS232C_cmd(); break; + case sb_RS232C_READ_INIT: RS232C_readinit(); break; + case sb_RS232C_WRITE: RS232C_write(); break; #endif /* RS232 */ + /***********/ + /* for K/B */ + /***********/ + case sb_KEYBOARDBEEP: + POP_SUBR_ARGS; + KB_beep(args); + break; + case sb_KEYBOARDMAP: + POP_SUBR_ARGS; + KB_setmp(args); + break; + case sb_KEYBOARDSTATE: + POP_SUBR_ARGS; + KB_enable(args); + break; - /***********/ - /* for K/B */ - /***********/ - case sb_KEYBOARDBEEP : POP_SUBR_ARGS; - KB_beep(args); - break; - case sb_KEYBOARDMAP : POP_SUBR_ARGS; - KB_setmp(args); - break; - case sb_KEYBOARDSTATE : POP_SUBR_ARGS; - KB_enable(args); - break; + case sb_VMEMSAVE: + POP_SUBR_ARGS; + TopOfStack = vmem_save0(args); + break; + case sb_LISPFINISH: + case sb_LISP_FINISH: + POP_SUBR_ARGS; + if ((argnum > 0) && (args[0] == S_POSITIVE)) + /* 8/03/88 This branch impossible to take, subr has no args */ + { + TopOfStack = suspend_lisp(args); + } else + lisp_finish(); + break; + case sb_NEWPAGE: + POP_SUBR_ARGS; + TopOfStack = newpage(args[0]); + break; + case sb_DORECLAIM: + POP_SUBR_ARGS; + doreclaim(); /* top-level GC function */ + TopOfStack = NIL_PTR; + break; - case sb_VMEMSAVE: POP_SUBR_ARGS; - TopOfStack = vmem_save0(args); - break; - case sb_LISPFINISH: - case sb_LISP_FINISH : POP_SUBR_ARGS; - if((argnum>0)&&(args[0]==S_POSITIVE)) - /* 8/03/88 This branch impossible to take, subr has no args */ - {TopOfStack=suspend_lisp(args);} - else lisp_finish(); - break; - case sb_NEWPAGE : POP_SUBR_ARGS; - TopOfStack = newpage(args[0]); - break; - case sb_DORECLAIM : POP_SUBR_ARGS; - doreclaim(); /* top-level GC function */ - TopOfStack = NIL_PTR; - break; + /* read & write a abs memory address */ - /* read & write a abs memory address */ + case sb_NATIVE_MEMORY_REFERENCE: + POP_SUBR_ARGS; - case sb_NATIVE_MEMORY_REFERENCE : POP_SUBR_ARGS; - - switch (args[0] & 0xffff) { - case 00: - {register UNSIGNED iarg; - if (argnum != 2) goto ret_nil; - N_GETNUMBER(args[1], iarg, ret_nil); - ARITH_SWITCH(*((LispPTR *) iarg), TopOfStack); - break; - } - - case 01: - {register UNSIGNED iarg,iarg2; - if (argnum != 3) goto ret_nil; - N_GETNUMBER(args[1], iarg, ret_nil); - N_GETNUMBER(args[2], iarg2, ret_nil); - *((LispPTR *) iarg) = iarg2; - break; - } + switch (args[0] & 0xffff) { + case 00: { + register UNSIGNED iarg; + if (argnum != 2) goto ret_nil; + N_GETNUMBER(args[1], iarg, ret_nil); + ARITH_SWITCH(*((LispPTR *)iarg), TopOfStack); + break; + } + + case 01: { + register UNSIGNED iarg, iarg2; + if (argnum != 3) goto ret_nil; + N_GETNUMBER(args[1], iarg, ret_nil); + N_GETNUMBER(args[2], iarg2, ret_nil); + *((LispPTR *)iarg) = iarg2; + break; + } #ifdef NATIVETRAN - case 02: /* get an emulator address */ - {register UNSIGNED iarg; - if (argnum != 2) goto ret_nil; - switch (args[1] & 0xffff) { - case 00: iarg = (UNSIGNED) &c_ret_to_dispatch; - break; - case 01: iarg = (UNSIGNED) &ret_to_dispatch; - break; - } - ARITH_SWITCH(iarg, TopOfStack); - break; - } + case 02: /* get an emulator address */ + { + register UNSIGNED iarg; + if (argnum != 2) goto ret_nil; + switch (args[1] & 0xffff) { + case 00: iarg = (UNSIGNED)&c_ret_to_dispatch; break; + case 01: iarg = (UNSIGNED)&ret_to_dispatch; break; + } + ARITH_SWITCH(iarg, TopOfStack); + break; + } #endif - } - break; - - ret_nil: TopOfStack = NIL_PTR; - break; + } + break; + ret_nil: + TopOfStack = NIL_PTR; + break; #ifdef NATIVETRAN - /* old load native (should be superceeded) */ - case sb_OLD_COMPILE_LOAD_NATIVE : POP_SUBR_ARGS; - { - - TopOfStack = do_system_call(args[0]); - break; - }; + /* old load native (should be superceeded) */ + case sb_OLD_COMPILE_LOAD_NATIVE: + POP_SUBR_ARGS; + { + TopOfStack = do_system_call(args[0]); + break; + }; #endif - case sb_DISABLEGC : POP_SUBR_ARGS; - disablegc1(NIL); - TopOfStack = NIL_PTR; - break; + case sb_DISABLEGC: + POP_SUBR_ARGS; + disablegc1(NIL); + TopOfStack = NIL_PTR; + break; - case sb_GET_NATIVE_ADDR_FROM_LISP_PTR: POP_SUBR_ARGS; - - {ARITH_SWITCH(Addr68k_from_LADDR(args[0]), TopOfStack); - break; - } + case sb_GET_NATIVE_ADDR_FROM_LISP_PTR: + POP_SUBR_ARGS; - case sb_GET_LISP_PTR_FROM_NATIVE_ADDR: POP_SUBR_ARGS; - - {register UNSIGNED iarg; - N_GETNUMBER(args[0], iarg, ret_nil); - ARITH_SWITCH(LADDR_from_68k(iarg), TopOfStack); - break; - }; + { + ARITH_SWITCH(Addr68k_from_LADDR(args[0]), TopOfStack); + break; + } + + case sb_GET_LISP_PTR_FROM_NATIVE_ADDR: + POP_SUBR_ARGS; + + { + register UNSIGNED iarg; + N_GETNUMBER(args[0], iarg, ret_nil); + ARITH_SWITCH(LADDR_from_68k(iarg), TopOfStack); + break; + }; #ifdef NATIVETRAN - case sb_LOAD_NATIVE_FILE: POP_SUBR_ARGS; - /* to become OBSOLETE */ - {TopOfStack = dynamic_load_code(args); - break; - } + case sb_LOAD_NATIVE_FILE: + POP_SUBR_ARGS; + /* to become OBSOLETE */ + { + TopOfStack = dynamic_load_code(args); + break; + } #endif - case sb_DSK_GETFILENAME : POP_SUBR_ARGS; - TopOfStack = DSK_getfilename(args); - break; - case sb_DSK_DELETEFILE : POP_SUBR_ARGS; - TopOfStack = DSK_deletefile(args); - break; - case sb_DSK_RENAMEFILE : POP_SUBR_ARGS; - TopOfStack = DSK_renamefile(args); - break; - case sb_DSK_DIRECTORYNAMEP : POP_SUBR_ARGS; - TopOfStack = DSK_directorynamep(args); - break; + case sb_DSK_GETFILENAME: + POP_SUBR_ARGS; + TopOfStack = DSK_getfilename(args); + break; + case sb_DSK_DELETEFILE: + POP_SUBR_ARGS; + TopOfStack = DSK_deletefile(args); + break; + case sb_DSK_RENAMEFILE: + POP_SUBR_ARGS; + TopOfStack = DSK_renamefile(args); + break; + case sb_DSK_DIRECTORYNAMEP: + POP_SUBR_ARGS; + TopOfStack = DSK_directorynamep(args); + break; -/* Communications with Unix Subprocess */ + /* Communications with Unix Subprocess */ - case sb_UNIX_HANDLECOMM: POP_SUBR_ARGS; + case sb_UNIX_HANDLECOMM: POP_SUBR_ARGS; #ifndef DOS - TopOfStack = Unix_handlecomm(args); + TopOfStack = Unix_handlecomm(args); #endif /* DOS */ - break; + break; #ifdef OCR - case sb_OCR_COMM: POP_SUBR_ARGS; - TopOfStack = ocr_comm(args); - break; + 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!!"); - {register int temp; - N_GETNUMBER(TopOfStack, temp, badarg); - temp = (UNSIGNED) Addr68k_from_LADDR(temp); - ARITH_SWITCH(temp, TopOfStack); - break; - badarg: TopOfStack = NIL; - break; - } -*/ -/* OS message print routines */ - - case sb_MESSAGE_READP: POP_SUBR_ARGS; - TopOfStack = mess_readp(); - break; - case sb_MESSAGE_READ: POP_SUBR_ARGS; - TopOfStack = mess_read(args); - break; - - -/* RPC routines */ + /* + case 0166: POP_SUBR_ARGS; + error("called SUBR 0166, not defined!!"); + {register int temp; + N_GETNUMBER(TopOfStack, temp, badarg); + temp = (UNSIGNED) Addr68k_from_LADDR(temp); + ARITH_SWITCH(temp, TopOfStack); + break; + badarg: TopOfStack = NIL; + break; + } + */ + /* OS message print routines */ - case sb_RPC_CALL: POP_SUBR_ARGS; - TopOfStack = rpc(args); - break; + case sb_MESSAGE_READP: + POP_SUBR_ARGS; + TopOfStack = mess_readp(); + break; + case sb_MESSAGE_READ: + POP_SUBR_ARGS; + TopOfStack = mess_read(args); + break; + /* RPC routines */ -/* Unix username/password utilities */ + case sb_RPC_CALL: + POP_SUBR_ARGS; + TopOfStack = rpc(args); + break; - case sb_CHECKBCPLPASSWORD: POP_SUBR_ARGS; - /* Check Unix username/password */ - TopOfStack = check_unix_password(args); - break; + /* Unix username/password utilities */ - case sb_UNIX_USERNAME: POP_SUBR_ARGS; - /* Get Unix username */ - TopOfStack = unix_username(args); - break; + case sb_CHECKBCPLPASSWORD: + POP_SUBR_ARGS; + /* Check Unix username/password */ + TopOfStack = check_unix_password(args); + break; - case sb_UNIX_FULLNAME: POP_SUBR_ARGS; - /* Get Unix person-name (GECOS field) */ - TopOfStack = unix_fullname(args); - break; + case sb_UNIX_USERNAME: + POP_SUBR_ARGS; + /* Get Unix username */ + TopOfStack = unix_username(args); + break; - case sb_UNIX_GETENV: POP_SUBR_ARGS; - /* get value of environment variable, or NIL */ - TopOfStack = unix_getenv(args); break; + case sb_UNIX_FULLNAME: + POP_SUBR_ARGS; + /* Get Unix person-name (GECOS field) */ + TopOfStack = unix_fullname(args); + break; - case sb_UNIX_GETPARM: POP_SUBR_ARGS; - /* get built in parameter */ - TopOfStack = unix_getparm(args); break; + case sb_UNIX_GETENV: + POP_SUBR_ARGS; + /* get value of environment variable, or NIL */ + TopOfStack = unix_getenv(args); + break; - case sb_SUSPEND_LISP: POP_SUBR_ARGS; - /* Suspend Maiko */ - TopOfStack = suspend_lisp(args); - break; - case sb_MONITOR_CONTROL : POP_SUBR_ARGS; - /* MONITOR CONTROL STOP(0) or RESUME(1) */ + case sb_UNIX_GETPARM: + POP_SUBR_ARGS; + /* get built in parameter */ + TopOfStack = unix_getparm(args); + break; + + case sb_SUSPEND_LISP: + POP_SUBR_ARGS; + /* Suspend Maiko */ + TopOfStack = suspend_lisp(args); + break; + case sb_MONITOR_CONTROL: + POP_SUBR_ARGS; +/* MONITOR CONTROL STOP(0) or RESUME(1) */ #ifdef PROFILE - moncontrol(args[0] & 1); + moncontrol(args[0] & 1); #endif /* PROFILE */ - break; + break; - /*****************/ - /* Character I/O */ - /*****************/ - case sb_CHAR_OPENFILE: POP_SUBR_ARGS; /* Char-device openfile. */ - TopOfStack = CHAR_openfile(args); - break; + /*****************/ + /* Character I/O */ + /*****************/ + case sb_CHAR_OPENFILE: + POP_SUBR_ARGS; /* Char-device openfile. */ + TopOfStack = CHAR_openfile(args); + break; - case sb_CHAR_BIN: POP_SUBR_ARGS; /* Char-device bin. */ - { - TopOfStack = CHAR_bin(args[0], args[1]); - break; - } - break; + case sb_CHAR_BIN: + POP_SUBR_ARGS; /* Char-device bin. */ + { + TopOfStack = CHAR_bin(args[0], args[1]); + break; + } + break; - case sb_CHAR_BOUT: POP_SUBR_ARGS; /* Char-device bout. */ - { - TopOfStack = CHAR_bout(args[0], args[1], args[2]); - break; - } - break; + case sb_CHAR_BOUT: + POP_SUBR_ARGS; /* Char-device bout. */ + { + TopOfStack = CHAR_bout(args[0], args[1], args[2]); + break; + } + break; + case sb_CHAR_IOCTL: + POP_SUBR_ARGS; /* Char-device IOCTL. */ + { + TopOfStack = CHAR_ioctl(args); + break; + } + break; - case sb_CHAR_IOCTL: POP_SUBR_ARGS; /* Char-device IOCTL. */ - { - TopOfStack = CHAR_ioctl(args); - break; - } - break; + case sb_CHAR_CLOSEFILE: + POP_SUBR_ARGS; /* Char-device CLOSEFILE. */ + { + TopOfStack = CHAR_closefile(args); + break; + } + break; - case sb_CHAR_CLOSEFILE: POP_SUBR_ARGS; /* Char-device CLOSEFILE. */ - { - TopOfStack = CHAR_closefile(args); - break; - } - break; + case sb_CHAR_BINS: + POP_SUBR_ARGS; /* Char-device \BINS. */ + { + TopOfStack = CHAR_bins(args); + break; + } + break; - case sb_CHAR_BINS: POP_SUBR_ARGS; /* Char-device \BINS. */ - { - TopOfStack = CHAR_bins(args); - break; - } - break; - - case sb_CHAR_BOUTS: POP_SUBR_ARGS; /* Char-device \BOUTS. */ - { - TopOfStack = CHAR_bouts(args); - break; - } - break; - - - case sb_TCP_OP: POP_SUBR_ARGS; /* TCP operations */ - { - TopOfStack = subr_TCP_ops(args[0], args[1], args[2], - args[3], args[4], args[5]); - break; - } - break; + case sb_CHAR_BOUTS: + POP_SUBR_ARGS; /* Char-device \BOUTS. */ + { + TopOfStack = CHAR_bouts(args); + break; + } + break; + case sb_TCP_OP: + POP_SUBR_ARGS; /* TCP operations */ + { + TopOfStack = subr_TCP_ops(args[0], args[1], args[2], args[3], args[4], args[5]); + break; + } + break; #ifdef TRUECOLOR - case sb_PICTURE_OP: { - POP_SUBR_ARGS; - TopOfStack = Picture_Op( args ); - } - break; - case sb_TRUE_COLOR_OP: { - POP_SUBR_ARGS; - TopOfStack = TrueColor_Op( args ); - } - break; + case sb_PICTURE_OP: { + POP_SUBR_ARGS; + TopOfStack = Picture_Op(args); + } break; + case sb_TRUE_COLOR_OP: { + POP_SUBR_ARGS; + TopOfStack = TrueColor_Op(args); + } break; #ifdef VIDEO - case sb_VIDEO_OP: { - POP_SUBR_ARGS; - TopOfStack = Video_Op( args ); - } - break; + case sb_VIDEO_OP: { + POP_SUBR_ARGS; + TopOfStack = Video_Op(args); + } break; #endif /* VIDEO */ #endif /* TRUECOLOR */ + case sb_PUPLEVEL1STATE: + POP_SUBR_ARGS; /* Do nothing with PUP on sun */ + break; - case sb_PUPLEVEL1STATE: POP_SUBR_ARGS; /* Do nothing with PUP on sun */ - break; + case sb_WITH_SYMBOL: + POP_SUBR_ARGS; /* Symbol lookup */ + { + TopOfStack = with_symbol(args[0], args[1], args[2], args[3], args[4], args[5]); + break; + } - case sb_WITH_SYMBOL: POP_SUBR_ARGS; /* Symbol lookup */ - { - TopOfStack = with_symbol(args[0], args[1], args[2], args[3], - args[4], args[5]); - break; - } - - case 0222: /* Cause an interrupt to occur. Used by */ - /* Lisp INTERRUPTED to re-set an interrupt */ - /* when it's uninterruptable. */ - { - POP_SUBR_ARGS; - Irq_Stk_Check = Irq_Stk_End=0; - *PENDINGINTERRUPT68k = ATOM_T; - TopOfStack = ATOM_T; - break; - } - /*******************/ - /* CLX Support ops */ - /*******************/ + case 0222: /* Cause an interrupt to occur. Used by */ + /* Lisp INTERRUPTED to re-set an interrupt */ + /* when it's uninterruptable. */ + { + POP_SUBR_ARGS; + Irq_Stk_Check = Irq_Stk_End = 0; + *PENDINGINTERRUPT68k = ATOM_T; + TopOfStack = ATOM_T; + break; + } +/*******************/ +/* CLX Support ops */ +/*******************/ #ifdef NEVER /* CLX */ - case sb_OPEN_SOCKET: { - POP_SUBR_ARGS; - TopOfStack = Open_Socket( args ); - break; - } - case sb_CLOSE_SOCKET: - { - TopOfStack = Close_Socket(); - break; - } - case sb_READ_SOCKET: - { - POP_SUBR_ARGS; - TopOfStack = Read_Socket( args ); - break; - } - case sb_WRITE_SOCKET: - { - POP_SUBR_ARGS; - TopOfStack = Write_Socket( args ); - break; - } - case 0244: /* KB_TRANSITION */ - { - POP_SUBR_ARGS; - TopOfStack = Kbd_Transition( args ); - break; - } + case sb_OPEN_SOCKET: { + POP_SUBR_ARGS; + TopOfStack = Open_Socket(args); + break; + } + case sb_CLOSE_SOCKET: { + TopOfStack = Close_Socket(); + break; + } + case sb_READ_SOCKET: { + POP_SUBR_ARGS; + TopOfStack = Read_Socket(args); + break; + } + case sb_WRITE_SOCKET: { + POP_SUBR_ARGS; + TopOfStack = Write_Socket(args); + break; + } + case 0244: /* KB_TRANSITION */ + { + POP_SUBR_ARGS; + TopOfStack = Kbd_Transition(args); + break; + } #endif /* CLX */ - #ifndef NOFORN - /*****************************************/ - /* foreign-function-call support subrs */ - /*****************************************/ - case sb_CALL_C_FN: - { - POP_SUBR_ARGS; - TopOfStack = call_c_fn( args ); /* args[0]=fnaddr, args[1]=fn type */ - break; - } - case sb_DLD_LINK: - { - POP_SUBR_ARGS; - TopOfStack = Mdld_link( args ); - break; - } - case sb_DLD_UNLINK_BY_FILE: - { - POP_SUBR_ARGS; - TopOfStack = Mdld_unlink_by_file( args ); - break; - } - case sb_DLD_UNLINK_BY_SYMBOL: - { - POP_SUBR_ARGS; - TopOfStack = Mdld_unlink_by_symbol( args ); - break; - } - case sb_DLD_GET_SYMBOL: - { - POP_SUBR_ARGS; - TopOfStack = Mdld_get_symbol( args ); - break; - } - case sb_DLD_GET_FUNC: - { - POP_SUBR_ARGS; - TopOfStack = Mdld_get_func( args ); - break; - } - case sb_DLD_FUNCTION_EXECUTABLE_P: - { - POP_SUBR_ARGS; - TopOfStack = Mdld_function_executable_p( args ); - break; - } - case sb_DLD_LIST_UNDEFINED_SYM: - { - POP_SUBR_ARGS; - TopOfStack = Mdld_list_undefined_sym( ); - break; - } - case sb_MALLOC: - { - POP_SUBR_ARGS; - TopOfStack = c_malloc( args ); - break; - } - case sb_FREE: - { - POP_SUBR_ARGS; - TopOfStack = c_free( args ); - break; - } - case sb_PUT_C_BASEBYTE: - { - POP_SUBR_ARGS; - TopOfStack = put_c_basebyte( args ); - break; - } - case sb_GET_C_BASEBYTE: - { - POP_SUBR_ARGS; - TopOfStack = get_c_basebyte( args ); - break; - } - case sb_SMASHING_APPLY: - { - POP_SUBR_ARGS; - TopOfStack = smashing_c_fn( args ); - break; - } + /*****************************************/ + /* foreign-function-call support subrs */ + /*****************************************/ + case sb_CALL_C_FN: { + POP_SUBR_ARGS; + TopOfStack = call_c_fn(args); /* args[0]=fnaddr, args[1]=fn type */ + break; + } + case sb_DLD_LINK: { + POP_SUBR_ARGS; + TopOfStack = Mdld_link(args); + break; + } + case sb_DLD_UNLINK_BY_FILE: { + POP_SUBR_ARGS; + TopOfStack = Mdld_unlink_by_file(args); + break; + } + case sb_DLD_UNLINK_BY_SYMBOL: { + POP_SUBR_ARGS; + TopOfStack = Mdld_unlink_by_symbol(args); + break; + } + case sb_DLD_GET_SYMBOL: { + POP_SUBR_ARGS; + TopOfStack = Mdld_get_symbol(args); + break; + } + case sb_DLD_GET_FUNC: { + POP_SUBR_ARGS; + TopOfStack = Mdld_get_func(args); + break; + } + case sb_DLD_FUNCTION_EXECUTABLE_P: { + POP_SUBR_ARGS; + TopOfStack = Mdld_function_executable_p(args); + break; + } + case sb_DLD_LIST_UNDEFINED_SYM: { + POP_SUBR_ARGS; + TopOfStack = Mdld_list_undefined_sym(); + break; + } + case sb_MALLOC: { + POP_SUBR_ARGS; + TopOfStack = c_malloc(args); + break; + } + case sb_FREE: { + POP_SUBR_ARGS; + TopOfStack = c_free(args); + break; + } + case sb_PUT_C_BASEBYTE: { + POP_SUBR_ARGS; + TopOfStack = put_c_basebyte(args); + break; + } + case sb_GET_C_BASEBYTE: { + POP_SUBR_ARGS; + TopOfStack = get_c_basebyte(args); + break; + } + case sb_SMASHING_APPLY: { + POP_SUBR_ARGS; + TopOfStack = smashing_c_fn(args); + break; + } #endif /* NOFORN */ #ifdef MNW - case sb_FILL_IN: - { - POP_SUBR_ARGS; - TopOfStack = init_mnw_instance( args ); - break; - } - case sb_QUERY_WINDOWS: - { - break; - } - case sb_MNW_OP: - { - POP_SUBR_ARGS; - TopOfStack = dispatch_mnw_method( args ); - break; - } + case sb_FILL_IN: { + POP_SUBR_ARGS; + TopOfStack = init_mnw_instance(args); + break; + } + case sb_QUERY_WINDOWS: { + break; + } + case sb_MNW_OP: { + POP_SUBR_ARGS; + TopOfStack = dispatch_mnw_method(args); + break; + } #endif /* MNW */ - #ifdef LPSOLVE - /* Linear-programming solver interface from Lisp */ - case sb_LP_SETUP: - { - POP_SUBR_ARGS; - TopOfStack = lpsetup(args[0], args[1], args[2], args[3], args[4], - args[5], args[6], args[7], args[8], args[9], - args[10]); - break; - } - case sb_LP_RUN: - { - POP_SUBR_ARGS; - TopOfStack = lpmain(args[0]); - break; - } + /* Linear-programming solver interface from Lisp */ + case sb_LP_SETUP: { + POP_SUBR_ARGS; + TopOfStack = lpsetup(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], + args[8], args[9], args[10]); + break; + } + case sb_LP_RUN: { + POP_SUBR_ARGS; + TopOfStack = lpmain(args[0]); + break; + } #endif /* LPSOLVE */ - default : - { - char errtext[200]; - sprintf ( errtext, - "OP_subrcall: Invalid alpha byte 0%o", ((*(PC+1)) & 0xff)); - printf ( "%s\n", errtext ); - error(errtext); - break; - } - - }/* switch end */ + default: { + char errtext[200]; + sprintf(errtext, "OP_subrcall: Invalid alpha byte 0%o", ((*(PC + 1)) & 0xff)); + printf("%s\n", errtext); + error(errtext); + break; + } - PC += 3; /* Move PC forward to next opcode */ + } /* switch end */ - }/* OP_subrcall */ + PC += 3; /* Move PC forward to next opcode */ + +} /* OP_subrcall */ diff --git a/src/subr0374.c b/src/subr0374.c old mode 100755 new mode 100644 index 06d4724..cd23668 --- a/src/subr0374.c +++ b/src/subr0374.c @@ -1,7 +1,7 @@ -/* $Id: subr0374.c,v 1.3 1999/05/31 23:35:43 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: subr0374.c,v 1.3 1999/05/31 23:35:43 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: subr0374.c,v 1.3 1999/05/31 23:35:43 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -26,12 +26,12 @@ static char *id = "$Id: subr0374.c,v 1.3 1999/05/31 23:35:43 sybalsky Exp $ Copy /********************************************************/ /* - subr_k_trace() + subr_k_trace() - subr----0130 for katana trace - first argument is base address of - error message in Lisp. - second argument is length of message. + subr----0130 for katana trace + first argument is base address of + error message in Lisp. + second argument is length of message. */ /********************************************************/ @@ -40,16 +40,13 @@ static char *id = "$Id: subr0374.c,v 1.3 1999/05/31 23:35:43 sybalsky Exp $ Copy #include "adr68k.h" #include "lspglob.h" -LispPTR subr_k_trace(LispPTR *args) -{ - int len; - char *base; +LispPTR subr_k_trace(LispPTR *args) { + int len; + char *base; - len = 0xFFFF & args[1]; - base = (char *)Addr68k_from_LADDR(args[0]); - while(len-- > 0) - putc(*base++ , stderr); - putc('\n', stderr); - return (NIL); + len = 0xFFFF & args[1]; + base = (char *)Addr68k_from_LADDR(args[0]); + while (len-- > 0) putc(*base++, stderr); + putc('\n', stderr); + return (NIL); } - diff --git a/src/sxhash.c b/src/sxhash.c old mode 100755 new mode 100644 index d2dbda4..5c508d1 --- a/src/sxhash.c +++ b/src/sxhash.c @@ -1,8 +1,7 @@ -/* $Id: sxhash.c,v 1.4 2001/12/24 01:09:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: sxhash.c,v 1.4 2001/12/24 01:09:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: sxhash.c,v 1.4 2001/12/24 01:09:06 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,11 +16,8 @@ static char *id = "$Id: sxhash.c,v 1.4 2001/12/24 01:09:06 sybalsky Exp $ Copyri #include "version.h" - #include - - #include "lispemul.h" #include "lspglob.h" #include "lispmap.h" @@ -35,13 +31,11 @@ static char *id = "$Id: sxhash.c,v 1.4 2001/12/24 01:09:06 sybalsky Exp $ Copyri #include "arith.h" - - /** Follows definition in LLARRAYELT: **/ -#define EQHASHINGBITS(item) ( (((item)>>16)&0xFFFF) ^ ( (((item)&0x1FFF)<<3) ^ (((item)>>9)& 0x7f) ) ) +#define EQHASHINGBITS(item) \ + ((((item) >> 16) & 0xFFFF) ^ ((((item)&0x1FFF) << 3) ^ (((item) >> 9) & 0x7f))) - -unsigned short sxhash (LispPTR obj); +unsigned short sxhash(LispPTR obj); unsigned short sxhash_rotate(short unsigned int value); unsigned short sxhash_string(OneDArray *obj); unsigned short sxhash_bitvec(OneDArray *obj); @@ -50,7 +44,6 @@ unsigned short sxhash_pathname(LispPTR obj); unsigned short stringequalhash(LispPTR obj); unsigned short stringhash(LispPTR obj); - /****************************************************************/ /* */ /* SXHASH */ @@ -58,17 +51,12 @@ unsigned short stringhash(LispPTR obj); /* C-coded version of the hashing function SXHASH */ /* */ /****************************************************************/ -typedef - struct - { - LispPTR object; - } SXHASHARG; +typedef struct { LispPTR object; } SXHASHARG; -LispPTR SX_hash (register SXHASHARG *args) -{ - return(S_POSITIVE | ( 0xFFFF & (sxhash(args->object)))); - /* Smash the top of the stack to a 0xe, offset */ - } +LispPTR SX_hash(register SXHASHARG *args) { + return (S_POSITIVE | (0xFFFF & (sxhash(args->object)))); + /* Smash the top of the stack to a 0xe, offset */ +} /*****************************************************************/ /* sxhash */ @@ -78,159 +66,126 @@ LispPTR SX_hash (register SXHASHARG *args) /* Fails to handle ratios, complex's, bitvectors pathnames & odd */ /* cases */ /*****************************************************************/ -unsigned short sxhash (LispPTR obj) -{ - /* unsigned short hashOffset; Not Used */ - unsigned int cell; - unsigned typen; - OneDArray* str; - switch (SEGMASK & obj) - { - case S_POSITIVE: - case S_NEGATIVE: return(obj & 0xFFFF); - default: switch (typen=GetTypeNumber(obj)) - { - case TYPE_FIXP: return((FIXP_VALUE(obj)) & 0xFFFF); - case TYPE_FLOATP: cell = (unsigned int) FIXP_VALUE(obj); - return((cell&0xFFFF)^(cell>>16)); +unsigned short sxhash(LispPTR obj) { + /* unsigned short hashOffset; Not Used */ + unsigned int cell; + unsigned typen; + OneDArray *str; + switch (SEGMASK & obj) { + case S_POSITIVE: + case S_NEGATIVE: return (obj & 0xFFFF); + default: + switch (typen = GetTypeNumber(obj)) { + case TYPE_FIXP: return ((FIXP_VALUE(obj)) & 0xFFFF); + case TYPE_FLOATP: + cell = (unsigned int)FIXP_VALUE(obj); + return ((cell & 0xFFFF) ^ (cell >> 16)); #ifdef BIGATOMS - case TYPE_NEWATOM: /* as for LITATOM... */ -#endif /* BIGATOMS */ + case TYPE_NEWATOM: /* as for LITATOM... */ +#endif /* BIGATOMS */ - case TYPE_LITATOM: return(EQHASHINGBITS(obj)); - case TYPE_LISTP: return(sxhash_list(obj)); - case TYPE_PATHNAME: return(sxhash_pathname(obj)); - case TYPE_ONED_ARRAY: - case TYPE_GENERAL_ARRAY: str = (OneDArray *) - Addr68k_from_LADDR(obj); - if (str->stringp) - return(sxhash_string(str)); - if (str->bitp) - return(sxhash_bitvec(str)); - return(EQHASHINGBITS(obj)); - case TYPE_BIGNUM: - { - LispPTR contents; - contents = ((BIGNUM *)Addr68k_from_LADDR(obj)) - -> contents; - return ( (unsigned short) car(contents) + - ( ((unsigned short) car(cdr(contents))) <<12)); - } + case TYPE_LITATOM: return (EQHASHINGBITS(obj)); + case TYPE_LISTP: return (sxhash_list(obj)); + case TYPE_PATHNAME: return (sxhash_pathname(obj)); + case TYPE_ONED_ARRAY: + case TYPE_GENERAL_ARRAY: + str = (OneDArray *)Addr68k_from_LADDR(obj); + if (str->stringp) return (sxhash_string(str)); + if (str->bitp) return (sxhash_bitvec(str)); + return (EQHASHINGBITS(obj)); + case TYPE_BIGNUM: { + LispPTR contents; + contents = ((BIGNUM *)Addr68k_from_LADDR(obj))->contents; + return ((unsigned short)car(contents) + (((unsigned short)car(cdr(contents))) << 12)); + } - case TYPE_COMPLEX: { - COMPLEX *object; - object = (COMPLEX *) - Addr68k_from_LADDR(obj); - return (sxhash(object->real) - ^ sxhash(object->imaginary)); - } - case TYPE_RATIO: { - RATIO *object; - object = (RATIO *) - Addr68k_from_LADDR(obj); - return (sxhash(object->numerator) ^ - sxhash(object->denominator)); - } + case TYPE_COMPLEX: { + COMPLEX *object; + object = (COMPLEX *)Addr68k_from_LADDR(obj); + return (sxhash(object->real) ^ sxhash(object->imaginary)); + } + case TYPE_RATIO: { + RATIO *object; + object = (RATIO *)Addr68k_from_LADDR(obj); + return (sxhash(object->numerator) ^ sxhash(object->denominator)); + } - - default: return(EQHASHINGBITS(obj)); - } + default: return (EQHASHINGBITS(obj)); } } - +} #ifndef SUN3_OS3_OR_OS4_IL /* Rotates the 16-bit work to the left 7 bits (or to the right 9 bits) */ -unsigned short sxhash_rotate(short unsigned int value) -{ - return ((value<<7) | ((value>>9) & 0x7f)); - } +unsigned short sxhash_rotate(short unsigned int value) { + return ((value << 7) | ((value >> 9) & 0x7f)); +} #endif - -unsigned short sxhash_string(OneDArray *obj) -{ - unsigned i, len, offset; - register unsigned short hash = 0; - len = (unsigned)obj ->fillpointer; - if (len > 13) len = 13; - offset = (unsigned)obj -> offset; - switch (obj -> typenumber) - { - case THIN_CHAR_TYPENUMBER: { - register char *thin; - register unsigned i; - thin = ((char *) - (Addr68k_from_LADDR(obj->base))) - + offset; - for (i=0;ibase))) - + offset; - for (i=0;ifillpointer; + if (len > 13) len = 13; + offset = (unsigned)obj->offset; + switch (obj->typenumber) { + case THIN_CHAR_TYPENUMBER: { + register char *thin; + register unsigned i; + thin = ((char *)(Addr68k_from_LADDR(obj->base))) + offset; + for (i = 0; i < len; i++) hash = sxhash_rotate(hash ^ GETBYTE(thin++)); + } break; + case FAT_CHAR_TYPENUMBER: { + register unsigned short *fat; + register unsigned i; + fat = ((unsigned short *)(Addr68k_from_LADDR(obj->base))) + offset; + for (i = 0; i < len; i++) hash = sxhash_rotate(hash ^ GETWORD(fat++)); + } break; + default: error("SXHASH of a string not made of chars!\n"); } + return (hash); +} -unsigned short sxhash_bitvec(OneDArray *obj) -{ - unsigned short *base; - unsigned i, len, offset, bitoffset; - unsigned short hash = 0; - len = (unsigned)obj -> fillpointer; - offset = (unsigned)obj -> offset; - base = ((unsigned short *)(Addr68k_from_LADDR(obj->base))) + (offset>>4); - if (offset == 0) - { - hash = (*base); - if (len<16) hash = hash >> (16-len); - } - else - { - bitoffset = offset & 15; - hash = (GETWORD(base++)<<(bitoffset)) | (GETWORD(base)>>(16-bitoffset)); - if ((len-offset) < 16) hash = hash >>(16-(len-offset)); - } - return(hash); +unsigned short sxhash_bitvec(OneDArray *obj) { + unsigned short *base; + unsigned i, len, offset, bitoffset; + unsigned short hash = 0; + len = (unsigned)obj->fillpointer; + offset = (unsigned)obj->offset; + base = ((unsigned short *)(Addr68k_from_LADDR(obj->base))) + (offset >> 4); + if (offset == 0) { + hash = (*base); + if (len < 16) hash = hash >> (16 - len); + } else { + bitoffset = offset & 15; + hash = (GETWORD(base++) << (bitoffset)) | (GETWORD(base) >> (16 - bitoffset)); + if ((len - offset) < 16) hash = hash >> (16 - (len - offset)); } + return (hash); +} - -unsigned short sxhash_list(LispPTR obj) -{ - unsigned short hash = 0; - int counter; - for (counter = 0; (counter<13)&&(GetTypeNumber(obj)==TYPE_LISTP); counter++) - { - hash = sxhash_rotate(hash^sxhash(car(obj))); - obj = cdr(obj); - } - return(hash); +unsigned short sxhash_list(LispPTR obj) { + unsigned short hash = 0; + int counter; + for (counter = 0; (counter < 13) && (GetTypeNumber(obj) == TYPE_LISTP); counter++) { + hash = sxhash_rotate(hash ^ sxhash(car(obj))); + obj = cdr(obj); } + return (hash); +} -unsigned short sxhash_pathname(LispPTR obj) -{ - unsigned short hash = 0; - PATHNAME *path; - path = (PATHNAME *)(Addr68k_from_LADDR(obj)); - hash = sxhash_rotate( sxhash(path->host) ^ sxhash(path->device)); - hash = sxhash_rotate(hash^sxhash(path->type)); - hash = sxhash_rotate(hash^sxhash(path->version)); - hash = sxhash_rotate(hash^sxhash(path->directory)); - hash = sxhash_rotate(hash^sxhash(path->name)); - return(hash); - } +unsigned short sxhash_pathname(LispPTR obj) { + unsigned short hash = 0; + PATHNAME *path; + path = (PATHNAME *)(Addr68k_from_LADDR(obj)); + hash = sxhash_rotate(sxhash(path->host) ^ sxhash(path->device)); + hash = sxhash_rotate(hash ^ sxhash(path->type)); + hash = sxhash_rotate(hash ^ sxhash(path->version)); + hash = sxhash_rotate(hash ^ sxhash(path->directory)); + hash = sxhash_rotate(hash ^ sxhash(path->name)); + return (hash); +} /****************************************************************/ /* */ @@ -241,75 +196,64 @@ unsigned short sxhash_pathname(LispPTR obj) /* */ /****************************************************************/ +LispPTR STRING_EQUAL_HASHBITS(SXHASHARG *args) { + return (S_POSITIVE | (0xFFFF & (stringequalhash(args->object)))); +} /* STRING_EQUAL_HASHBITS */ -LispPTR STRING_EQUAL_HASHBITS(SXHASHARG *args) -{ - return(S_POSITIVE | ( 0xFFFF & (stringequalhash(args->object)))); - } /* STRING_EQUAL_HASHBITS */ - -unsigned short stringequalhash(LispPTR obj) -{ - unsigned i, len, offset, fatp, ind; - register unsigned short hash = 0; - PNCell *pnptr; - DLword *base; - PLCell *Prop; - OneDArray *str; - switch (GetTypeNumber(obj)) - { +unsigned short stringequalhash(LispPTR obj) { + unsigned i, len, offset, fatp, ind; + register unsigned short hash = 0; + PNCell *pnptr; + DLword *base; + PLCell *Prop; + OneDArray *str; + switch (GetTypeNumber(obj)) { #ifdef BIGATOMS - case TYPE_NEWATOM: /* as for LITATOM; it's all in the macros below. */ -#endif /* BIGATOMS */ + case TYPE_NEWATOM: /* as for LITATOM; it's all in the macros below. */ +#endif /* BIGATOMS */ - case TYPE_LITATOM: ind = ((int)obj)&POINTERMASK; - pnptr = (PNCell *) GetPnameCell(ind); - base= (DLword *)Addr68k_from_LADDR(pnptr->pnamebase); - Prop = (PLCell *) GetPropCell(ind); - fatp = Prop->fatpnamep; - offset = 1; - len = GETBYTE((unsigned char *)base); - break; - case TYPE_ONED_ARRAY: - case TYPE_GENERAL_ARRAY: str = (OneDArray *) - Addr68k_from_LADDR(obj); - if (str->stringp) - { - fatp=(str->typenumber) == FAT_CHAR_TYPENUMBER; - base = Addr68k_from_LADDR(str->base); - offset = str->offset; - len = str->fillpointer; - } - else return(EQHASHINGBITS(obj)); - break; - default: return(EQHASHINGBITS(obj)); - }; + case TYPE_LITATOM: + ind = ((int)obj) & POINTERMASK; + pnptr = (PNCell *)GetPnameCell(ind); + base = (DLword *)Addr68k_from_LADDR(pnptr->pnamebase); + Prop = (PLCell *)GetPropCell(ind); + fatp = Prop->fatpnamep; + offset = 1; + len = GETBYTE((unsigned char *)base); + break; + case TYPE_ONED_ARRAY: + case TYPE_GENERAL_ARRAY: + str = (OneDArray *)Addr68k_from_LADDR(obj); + if (str->stringp) { + fatp = (str->typenumber) == FAT_CHAR_TYPENUMBER; + base = Addr68k_from_LADDR(str->base); + offset = str->offset; + len = str->fillpointer; + } else + return (EQHASHINGBITS(obj)); + break; + default: return (EQHASHINGBITS(obj)); + }; - - if (fatp) - { - register unsigned short *fat; - register unsigned i; - fat = ((unsigned short *) base) + offset; - for (i=0;iobject)))); +} /* STRING_HASHBITS */ -LispPTR STRING_HASHBITS(SXHASHARG *args) -{ - return(S_POSITIVE | ( 0xFFFF & (stringhash(args->object)))); - } /* STRING_HASHBITS */ - -unsigned short stringhash(LispPTR obj) -{ - unsigned i, len, offset, fatp, ind; - register unsigned short hash = 0; - PNCell *pnptr; - DLword *base; - PLCell *Prop; - OneDArray *str; - switch (GetTypeNumber(obj)) - { +unsigned short stringhash(LispPTR obj) { + unsigned i, len, offset, fatp, ind; + register unsigned short hash = 0; + PNCell *pnptr; + DLword *base; + PLCell *Prop; + OneDArray *str; + switch (GetTypeNumber(obj)) { #ifdef BIGATOMS - case TYPE_NEWATOM: /* as for LITATOM; it's all in the macros below. */ -#endif /* BIGATOMS */ + case TYPE_NEWATOM: /* as for LITATOM; it's all in the macros below. */ +#endif /* BIGATOMS */ - case TYPE_LITATOM: ind = ((int)obj)&POINTERMASK; - pnptr = (PNCell *) GetPnameCell(ind); - base= (DLword *)Addr68k_from_LADDR(pnptr->pnamebase); - Prop = (PLCell *) GetPropCell(ind); - fatp = Prop->fatpnamep; - offset = 1; - len = GETBYTE((unsigned char *) base); - break; - case TYPE_ONED_ARRAY: - case TYPE_GENERAL_ARRAY: str = (OneDArray *) - Addr68k_from_LADDR(obj); - if (str->stringp) - { - fatp=(str->typenumber) == FAT_CHAR_TYPENUMBER; - base = Addr68k_from_LADDR(str->base); - offset = str->offset; - len = str->fillpointer; - } - else return(EQHASHINGBITS(obj)); - break; - default: return(EQHASHINGBITS(obj)); - }; /* switch */ + case TYPE_LITATOM: + ind = ((int)obj) & POINTERMASK; + pnptr = (PNCell *)GetPnameCell(ind); + base = (DLword *)Addr68k_from_LADDR(pnptr->pnamebase); + Prop = (PLCell *)GetPropCell(ind); + fatp = Prop->fatpnamep; + offset = 1; + len = GETBYTE((unsigned char *)base); + break; + case TYPE_ONED_ARRAY: + case TYPE_GENERAL_ARRAY: + str = (OneDArray *)Addr68k_from_LADDR(obj); + if (str->stringp) { + fatp = (str->typenumber) == FAT_CHAR_TYPENUMBER; + base = Addr68k_from_LADDR(str->base); + offset = str->offset; + len = str->fillpointer; + } else + return (EQHASHINGBITS(obj)); + break; + default: return (EQHASHINGBITS(obj)); + }; /* switch */ - - if (fatp) - { - register unsigned short *fat; - register unsigned i; - fat = ((unsigned short *) base) + offset; - for (i=0;i #include #include @@ -59,7 +56,7 @@ int KeyboardFd; int DisplayWidth, DisplayHeight, DisplayRasterWidth, DisplayType; int DisplayByteSize; -short *DisplayRegion68k; /* 68k addr of #{}22,0 */ +short *DisplayRegion68k; /* 68k addr of #{}22,0 */ struct cursor CurrentCursor, InvisibleCursor; struct winlock DisplayLockArea; @@ -72,332 +69,300 @@ extern IFPAGE *InterfacePage; int DebugDSP = T; ******************************************/ /************** provide below so can skip the include files *******/ -#define BITSPER_DLWORD 16 -#define SUN2BW 1 -#define SUN4COLOR 2 -#define CURSORWIDTH 16 -#define CURSORHEIGHT 16 -#define DBPRINT(X) printf X +#define BITSPER_DLWORD 16 +#define SUN2BW 1 +#define SUN4COLOR 2 +#define CURSORWIDTH 16 +#define CURSORHEIGHT 16 +#define DBPRINT(X) printf X /************** provide above so can skip the include files *******/ - - /* ================================================================ */ -init_display2(display_addr, display_max) - int display_addr, display_max; +init_display2(display_addr, display_max) int display_addr, display_max; { - int mmapstat; - int ioctlresult; - char *texture_base, *malloc(); - struct fbtype my_screen; - char groups[PIXPG_OVERLAY+1]; - struct fbgattr FBattr; - struct pixrect *ColorFb; - int mask, kbtype; + int mmapstat; + int ioctlresult; + char *texture_base, *malloc(); + struct fbtype my_screen; + char groups[PIXPG_OVERLAY + 1]; + struct fbgattr FBattr; + struct pixrect *ColorFb; + int mask, kbtype; - if( (LispWindowFd = win_screennew( &LispScreen )) == -1){ - perror("init_display: can't create LispWindow\n"); - exit( -1 ); - } - else { + if ((LispWindowFd = win_screennew(&LispScreen)) == -1) { + perror("init_display: can't create LispWindow\n"); + exit(-1); + } else { #ifdef KBINT - int_io_open(LispWindowFd); + int_io_open(LispWindowFd); #endif - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); - } + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); + } - DisplayRegion68k = (short *) display_addr; + DisplayRegion68k = (short *)display_addr; - if( (FrameBufferFd = open( LispScreen.scr_fbname, 2 )) == -1){ - perror("init_display: can't open FrameBuffer\n"); - exit( -1 ); - } + if ((FrameBufferFd = open(LispScreen.scr_fbname, 2)) == -1) { + perror("init_display: can't open FrameBuffer\n"); + exit(-1); + } - if( (KeyboardFd = open( LispScreen.scr_kbdname, 2 )) == -1){ - perror("init_display: can't open Keyboard\n"); - exit( -1 ); - } + if ((KeyboardFd = open(LispScreen.scr_kbdname, 2)) == -1) { + perror("init_display: can't open Keyboard\n"); + exit(-1); + } - DBPRINT(("LispScreen.scr_kbdname %s\n", LispScreen.scr_kbdname)); - DBPRINT(("LispScreen.scr_fbname %s\n", LispScreen.scr_fbname )); + DBPRINT(("LispScreen.scr_kbdname %s\n", LispScreen.scr_kbdname)); + DBPRINT(("LispScreen.scr_fbname %s\n", LispScreen.scr_fbname)); - if ( ioctl ( KeyboardFd, KIOCTYPE, &kbtype ) != 0 ) { - perror ( "ioctl(KIOCTYPE,..) fails" ); - } - else { - DBPRINT(("ioctl(KIOCTYPE): %d\n", kbtype )); - } + if (ioctl(KeyboardFd, KIOCTYPE, &kbtype) != 0) { + perror("ioctl(KIOCTYPE,..) fails"); + } else { + DBPRINT(("ioctl(KIOCTYPE): %d\n", kbtype)); + } - /* initialize Display parameters */ - if (ioctl(FrameBufferFd, FBIOGTYPE , &my_screen)== -1) { - perror("init_display: can't find screen parameters\n"); - exit( -1 ); - } - DisplayWidth = my_screen.fb_width; - DisplayHeight = my_screen.fb_height; - DisplayRasterWidth = DisplayWidth / BITSPER_DLWORD; - if ((DisplayWidth * DisplayHeight) > display_max){ - DisplayHeight = display_max / DisplayWidth; - } + /* initialize Display parameters */ + if (ioctl(FrameBufferFd, FBIOGTYPE, &my_screen) == -1) { + perror("init_display: can't find screen parameters\n"); + exit(-1); + } + DisplayWidth = my_screen.fb_width; + DisplayHeight = my_screen.fb_height; + DisplayRasterWidth = DisplayWidth / BITSPER_DLWORD; + if ((DisplayWidth * DisplayHeight) > display_max) { DisplayHeight = display_max / DisplayWidth; } - DBPRINT(("FBIOGTYPE w x h = %d x %d\n", DisplayWidth, DisplayHeight)); - DBPRINT((" type = %d\n", my_screen.fb_type )); - DBPRINT((" bpp = %d\n", my_screen.fb_depth )); + DBPRINT(("FBIOGTYPE w x h = %d x %d\n", DisplayWidth, DisplayHeight)); + DBPRINT((" type = %d\n", my_screen.fb_type)); + DBPRINT((" bpp = %d\n", my_screen.fb_depth)); -/** now attempt to use the FBIOGATTR call for more information **/ + /** now attempt to use the FBIOGATTR call for more information **/ - ioctlresult = ioctl(FrameBufferFd, FBIOGATTR, &FBattr); - if(ioctlresult >= 0 ) { - DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type)); - DBPRINT((" (real) w x h = %d x %d\n", FBattr.fbtype.fb_width, - FBattr.fbtype.fb_height)); - DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type )); - DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth )); - DBPRINT((" emuls = %d %d %d %d %d\n", - FBattr.emu_types[0], - FBattr.emu_types[1], - FBattr.emu_types[2], - FBattr.emu_types[3], - FBattr.emu_types[4] )); - } - else { - DBPRINT(("ioctl(fd,FBIOGATTR,&FBattr) => %d\n", ioctlresult)); - } + ioctlresult = ioctl(FrameBufferFd, FBIOGATTR, &FBattr); + if (ioctlresult >= 0) { + DBPRINT(("FBIOGATTR realtype = %d\n", FBattr.real_type)); + DBPRINT((" (real) w x h = %d x %d\n", FBattr.fbtype.fb_width, FBattr.fbtype.fb_height)); + DBPRINT((" (real) type = %d\n", FBattr.fbtype.fb_type)); + DBPRINT((" (real) bpp = %d\n", FBattr.fbtype.fb_depth)); + DBPRINT((" emuls = %d %d %d %d %d\n", FBattr.emu_types[0], FBattr.emu_types[1], + FBattr.emu_types[2], FBattr.emu_types[3], FBattr.emu_types[4])); + } else { + DBPRINT(("ioctl(fd,FBIOGATTR,&FBattr) => %d\n", ioctlresult)); + } - ColorFb = pr_open("/dev/fb"); + ColorFb = pr_open("/dev/fb"); - DBPRINT(("pixrect w, h, depth = %d %d %d\n", - ColorFb->pr_size.x, - ColorFb->pr_size.y, ColorFb->pr_depth )); + DBPRINT(("pixrect w, h, depth = %d %d %d\n", ColorFb->pr_size.x, ColorFb->pr_size.y, + ColorFb->pr_depth)); - pr_getattributes( ColorFb, &mask ); - DBPRINT((" getattrmask = %d\n", mask )); + pr_getattributes(ColorFb, &mask); + DBPRINT((" getattrmask = %d\n", mask)); - groups[0]=0; groups[1]=0; groups[2]=0; groups[3]=0; groups[4]=0; - pr_available_plane_groups( ColorFb, sizeof(groups), groups); - DBPRINT(("plane groups = current: %d\n", groups[0] )); - DBPRINT((" mono : %d\n", groups[1] )); - DBPRINT((" 8bitcol: %d\n", groups[2] )); - DBPRINT((" ovrlyen: %d\n", groups[3] )); - DBPRINT((" ovrly : %d\n", groups[4] )); + groups[0] = 0; + groups[1] = 0; + groups[2] = 0; + groups[3] = 0; + groups[4] = 0; + pr_available_plane_groups(ColorFb, sizeof(groups), groups); + DBPRINT(("plane groups = current: %d\n", groups[0])); + DBPRINT((" mono : %d\n", groups[1])); + DBPRINT((" 8bitcol: %d\n", groups[2])); + DBPRINT((" ovrlyen: %d\n", groups[3])); + DBPRINT((" ovrly : %d\n", groups[4])); - pr_available_plane_groups( ColorFb, sizeof(groups), groups); + pr_available_plane_groups(ColorFb, sizeof(groups), groups); - /* try to clear enable plane if it exists */ + /* try to clear enable plane if it exists */ - if (groups[PIXPG_OVERLAY] && - groups[PIXPG_OVERLAY_ENABLE] ){ - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb, 0, 0, ColorFb->pr_width, - ColorFb->pr_height, PIX_SET, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY); - } + if (groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } - { int currgroup; - currgroup = pr_get_plane_group( ColorFb ); - DBPRINT(("current planegroup: %d, unknown: %d\n", - currgroup, currgroup == PIXPG_CURRENT )); - } + { + int currgroup; + currgroup = pr_get_plane_group(ColorFb); + DBPRINT(("current planegroup: %d, unknown: %d\n", currgroup, currgroup == PIXPG_CURRENT)); + } /* ================================================================ */ #ifdef NOTUSED - if (my_screen.fb_type == FBTYPE_SUN2BW){ - if ( ioctlresult ) >= 0) { - if (FBattr.real_type == FBTYPE_SUN4COLOR) { - /* must be color display cgfour */ - /* we've already gotten the plane groups from above */ - if (groups[PIXPG_OVERLAY] && - groups[PIXPG_OVERLAY_ENABLE] ){ - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb, 0, 0, - ColorFb->pr_width, - ColorFb->pr_height, PIX_SET, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY); - } - } - else { /* not cgfour */ - printf("initdisplay: Unsupported FBTYPE %d\n", - FBattr.real_type); - } - } /* if ioctlresult...... */ - }/* if ...FBTYPE_SUN2BW end */ + if (my_screen.fb_type == FBTYPE_SUN2BW) { + if (ioctlresult) >= 0) { + if (FBattr.real_type == FBTYPE_SUN4COLOR) { + /* must be color display cgfour */ + /* we've already gotten the plane groups from above */ + if (groups[PIXPG_OVERLAY] && groups[PIXPG_OVERLAY_ENABLE]) { + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } + } else { /* not cgfour */ + printf("initdisplay: Unsupported FBTYPE %d\n", FBattr.real_type); + } + } /* if ioctlresult...... */ + } /* if ...FBTYPE_SUN2BW end */ #endif -/* ================================================================ */ + /* ================================================================ */ - DisplayLockArea.wl_rect.r_width = DisplayWidth; - DisplayLockArea.wl_rect.r_height = DisplayHeight; - init_cursor(); - DisplayByteSize= ((DisplayWidth * DisplayHeight / 8 + (getpagesize()-1) ) - & -getpagesize()); + DisplayLockArea.wl_rect.r_width = DisplayWidth; + DisplayLockArea.wl_rect.r_height = DisplayHeight; + init_cursor(); + DisplayByteSize = ((DisplayWidth * DisplayHeight / 8 + (getpagesize() - 1)) & -getpagesize()); - DBPRINT(("Display Addr: 0x%x\n",DisplayRegion68k)); - DBPRINT(("length: 0x%x\n",DisplayByteSize)); - DBPRINT(("page size: 0x%x\n",getpagesize())); + DBPRINT(("Display Addr: 0x%x\n", DisplayRegion68k)); + DBPRINT(("length: 0x%x\n", DisplayByteSize)); + DBPRINT(("page size: 0x%x\n", getpagesize())); - mmapstat = (int)mmap( DisplayRegion68k, - DisplayByteSize, - PROT_READ | PROT_WRITE, + mmapstat = (int)mmap(DisplayRegion68k, DisplayByteSize, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif - MAP_SHARED, - FrameBufferFd, 0 ); + MAP_SHARED, + FrameBufferFd, 0); - DBPRINT(("after mmap: 0x%x\n",mmapstat)); + DBPRINT(("after mmap: 0x%x\n", mmapstat)); - if(mmapstat == -1){ - perror("init_display: ERROR at mmap system call\n"); - exit( 0 ); - } + if (mmapstat == -1) { + perror("init_display: ERROR at mmap system call\n"); + exit(0); + } - DBPRINT(("before clear display()\n")); + DBPRINT(("before clear display()\n")); - clear_display(); + clear_display(); - DBPRINT(("after clear_display()\n")); + DBPRINT(("after clear_display()\n")); - /* initialize pixrects used in pilotbitblt (internal will change) */ - SrcePixRect = mem_point( 0, 0, 1, NULL ); - DestPixRect = mem_point( 0, 0, 1, NULL ); + /* initialize pixrects used in pilotbitblt (internal will change) */ + SrcePixRect = mem_point(0, 0, 1, NULL); + DestPixRect = mem_point(0, 0, 1, NULL); - DBPRINT(("before set_cursor\n")); + DBPRINT(("before set_cursor\n")); } /* ================================================================ */ -init_cursor() - { - CursorBitMap = mem_create( CURSORWIDTH, CURSORHEIGHT, 1 ); - mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3;/* 2(byte) */ - CurrentCursor.cur_xhot = 0; - CurrentCursor.cur_yhot = 0; - CurrentCursor.cur_shape = CursorBitMap; - CurrentCursor.cur_function = PIX_SRC | PIX_DST; +init_cursor() { + CursorBitMap = mem_create(CURSORWIDTH, CURSORHEIGHT, 1); + mpr_mdlinebytes(CursorBitMap) = CURSORWIDTH >> 3; /* 2(byte) */ + CurrentCursor.cur_xhot = 0; + CurrentCursor.cur_yhot = 0; + CurrentCursor.cur_shape = CursorBitMap; + CurrentCursor.cur_function = PIX_SRC | PIX_DST; - /* Invisible Cursor */ - InvisibleCursorBitMap = mem_create( 0, 0, 1 ); - InvisibleCursor.cur_xhot = 0; - InvisibleCursor.cur_yhot = 0; - InvisibleCursor.cur_shape = InvisibleCursorBitMap; - InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST; + /* Invisible Cursor */ + InvisibleCursorBitMap = mem_create(0, 0, 1); + InvisibleCursor.cur_xhot = 0; + InvisibleCursor.cur_yhot = 0; + InvisibleCursor.cur_shape = InvisibleCursorBitMap; + InvisibleCursor.cur_function = /*PIX_SRC |*/ PIX_DST; - win_setcursor( LispWindowFd, &InvisibleCursor); - win_setmouseposition(LispWindowFd, 0, 0); - } + win_setcursor(LispWindowFd, &InvisibleCursor); + win_setmouseposition(LispWindowFd, 0, 0); +} /* ================================================================ */ -display_before_exit() - { - clear_display(); +display_before_exit() { + clear_display(); - win_screendestroy( LispWindowFd ); + win_screendestroy(LispWindowFd); #ifdef KBINT - int_io_close(LispWindowFd); + int_io_close(LispWindowFd); #endif - close( LispWindowFd ); - } + close(LispWindowFd); +} /* ================================================================ */ -clear_display() - { - register short *word; - register int w, h; - word = DisplayRegion68k; - for (h = DisplayHeight; (h--);) - { - for (w = DisplayRasterWidth; (w--);) {*word++ = 0;} - } - } +clear_display() { + register short *word; + register int w, h; + word = DisplayRegion68k; + for (h = DisplayHeight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *word++ = 0; } + } +} /* ================================================================ */ -paint_display() - { - register short *word; - register int w, h; - word = DisplayRegion68k; - for (h = DisplayHeight; (h--);) - { - for (w = DisplayRasterWidth; (w--);) {*word++ = w;} - } - } +paint_display() { + register short *word; + register int w, h; + word = DisplayRegion68k; + for (h = DisplayHeight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *word++ = w; } + } +} /* ================================================================ */ #define BYTESPER_PAGE 512 -read_datum( lispworld ) - char *lispworld; - { - int srcefile; /* fd */ - int i, j, sysout_size; - int lispworld_offset; - struct stat stat_buf; - char *charptr; - int readresult; - char bigbuff [ BYTESPER_PAGE ]; +read_datum(lispworld) char *lispworld; +{ + int srcefile; /* fd */ + int i, j, sysout_size; + int lispworld_offset; + struct stat stat_buf; + char *charptr; + int readresult; + char bigbuff[BYTESPER_PAGE]; - srcefile = open("fake.sysout", O_RDONLY, NULL); + srcefile = open("fake.sysout", O_RDONLY, NULL); - /* get sysout file size in halfpage(256) */ - if (fstat( srcefile, &stat_buf) == -1) { - perror("read_datum: can't get srcefile size (fstat fails)"); - exit(-1); - } - sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2; + /* get sysout file size in halfpage(256) */ + if (fstat(srcefile, &stat_buf) == -1) { + perror("read_datum: can't get srcefile size (fstat fails)"); + exit(-1); + } + sysout_size = stat_buf.st_size / BYTESPER_PAGE * 2; - DBPRINT(("file size = %d\n", stat_buf.st_size )); - DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2)); + DBPRINT(("file size = %d\n", stat_buf.st_size)); + DBPRINT(("sysout size / 2 = 0x%x\n", sysout_size / 2)); - lispworld_offset = 0; - for (i = 0; i < (sysout_size / 2); i++) { - lispworld_offset += BYTESPER_PAGE; - charptr = (char *) lispworld + lispworld_offset; + lispworld_offset = 0; + for (i = 0; i < (sysout_size / 2); i++) { + lispworld_offset += BYTESPER_PAGE; + charptr = (char *)lispworld + lispworld_offset; #ifdef BUFFER - readresult = read(srcefile, bigbuff, BYTESPER_PAGE); - for ( j = 0; j < BYTESPER_PAGE; j++ ) { - *(charptr + j) = bigbuff [ j ]; - } + readresult = read(srcefile, bigbuff, BYTESPER_PAGE); + for (j = 0; j < BYTESPER_PAGE; j++) { *(charptr + j) = bigbuff[j]; } #else - readresult = read(srcefile, charptr, BYTESPER_PAGE); + readresult = read(srcefile, charptr, BYTESPER_PAGE); #endif - if ( readresult == -1) { - printf("read_datum: can't read srcefile file at %d\n", i); - perror("read() error was"); - exit(-1); - }; - }; - DBPRINT(("srcefile is read completely\n")); - close(srcefile); - } + if (readresult == -1) { + printf("read_datum: can't read srcefile file at %d\n", i); + perror("read() error was"); + exit(-1); + }; + }; + DBPRINT(("srcefile is read completely\n")); + close(srcefile); +} /* ================================================================ */ -int_io_open() {}; /* stubs for other parts of our prog. */ -int_io_close() {}; /* stubs for other parts of our prog. */ +int_io_open(){}; /* stubs for other parts of our prog. */ +int_io_close(){}; /* stubs for other parts of our prog. */ +main() { + int maxdisplayregion; /* in what units? */ + int realaddr; -main() - { - int maxdisplayregion; /* in what units? */ - int realaddr; + realaddr = valloc(5000000); + if (realaddr == 0) { + printf("valloc returns 0\n"); + } else { + maxdisplayregion = 4000000; /* assume 4Mb display reg. */ + init_display2(realaddr, maxdisplayregion); + paint_display(); + sleep(4); - realaddr = valloc( 5000000 ); - if ( realaddr == 0 ) { - printf ( "valloc returns 0\n" ); - } - else { - maxdisplayregion = 4000000; /* assume 4Mb display reg. */ - init_display2( realaddr, maxdisplayregion ); - paint_display(); - sleep ( 4 ); + DBPRINT(("before read_datum\n")); + read_datum(realaddr); - DBPRINT(("before read_datum\n")); - read_datum( realaddr ); - - sleep ( 4 ); - display_before_exit(); - } - } + sleep(4); + display_before_exit(); + } +} diff --git a/src/testtool.c b/src/testtool.c old mode 100755 new mode 100644 index 8f6f69e..7029cfa --- a/src/testtool.c +++ b/src/testtool.c @@ -1,8 +1,7 @@ -/* $Id: testtool.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: testtool.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: testtool.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,41 +16,39 @@ static char *id = "$Id: testtool.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ Copy #include "version.h" - - /***************************************************************/ /* - file name : testtool.c + file name : testtool.c - For Debugging Aids + For Debugging Aids - Including : - dump_check_atoms() - print_atomname(index) - dump_dtd() - check_type_68k(type,ptr) - type_num(LISPPTR) - dump_conspage(base , linking ) - trace_listpDTD() - a68k( lispptr) - laddr(addr68k) - dump_fnobj(index) - dump_fnbody(lisp-codeaddr) - doko() - dumpl(laddr) - ptintPC() - all_stack_dump(start,end) + Including : + dump_check_atoms() + print_atomname(index) + dump_dtd() + check_type_68k(type,ptr) + type_num(LISPPTR) + dump_conspage(base , linking ) + trace_listpDTD() + a68k( lispptr) + laddr(addr68k) + dump_fnobj(index) + dump_fnbody(lisp-codeaddr) + doko() + dumpl(laddr) + ptintPC() + all_stack_dump(start,end) - date : 14 May 1987 takeshi - 15 May 1987 take - 1 June 1987 take - 21 June 1987 NMitani - 9 Sep. 1987 take + date : 14 May 1987 takeshi + 15 May 1987 take + 1 June 1987 take + 21 June 1987 NMitani + 9 Sep. 1987 take */ #include -#include +#include #ifdef AIX #include #endif /* AIX */ @@ -69,11 +66,9 @@ static char *id = "$Id: testtool.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ Copy #include "dbprint.h" #include "tosfns.h" - - -#define URMAXFXNUM 100 -#define URSCAN_ALINK 0 -#define URSCAN_CLINK 1 +#define URMAXFXNUM 100 +#define URSCAN_ALINK 0 +#define URSCAN_CLINK 1 extern int URaid_scanlink; extern int URaid_currentFX; extern FX *URaid_FXarray[]; @@ -90,27 +85,25 @@ void print_package_name(int index); /************************************************************************/ void print_atomname(LispPTR index) - /* atomindex */ +/* atomindex */ { + char *pname; + DLword length; + PNCell *pnptr; - char *pname; - DLword length; - PNCell *pnptr; + pnptr = (PNCell *)GetPnameCell(index); + print_package_name(pnptr->pkg_index); + pname = (char *)Addr68k_from_LADDR(pnptr->pnamebase); - pnptr =(PNCell *)GetPnameCell( index); - print_package_name(pnptr->pkg_index); - pname=(char *) Addr68k_from_LADDR(pnptr->pnamebase); + length = (DLword)GETBYTE(pname++); - length = (DLword) GETBYTE(pname++); - - while(length >0){ - putchar(GETBYTE(pname++)); - length--; - } + while (length > 0) { + putchar(GETBYTE(pname++)); + length--; + } } /* end print_atomname */ - /************************************************************************/ /* */ /* F I N D _ P A C K A G E _ F R O M _ N A M E */ @@ -119,112 +112,80 @@ void print_atomname(LispPTR index) #define PACKAGES_LIMIT 255 /** GET PACKAGE INDEX from PACKAGE FULL NAME */ -int find_package_from_name(char *packname, int len) -{ - int index; - PACKAGE *package; - NEWSTRINGP *namestring; - DLword len2; - char *pname; +int find_package_from_name(char *packname, int len) { + int index; + PACKAGE *package; + NEWSTRINGP *namestring; + DLword len2; + char *pname; - for(index =1; index <= PACKAGES_LIMIT; index++) - { - package = (PACKAGE *)Addr68k_from_LADDR( - aref1(*Package_from_Index_word, index)); - namestring = (NEWSTRINGP*)Addr68k_from_LADDR(package->NAME); - pname = (char*)Addr68k_from_LADDR(namestring->base); - if(namestring->offset != 0) - { - pname += namestring->offset; - } + for (index = 1; index <= PACKAGES_LIMIT; index++) { + package = (PACKAGE *)Addr68k_from_LADDR(aref1(*Package_from_Index_word, index)); + namestring = (NEWSTRINGP *)Addr68k_from_LADDR(package->NAME); + pname = (char *)Addr68k_from_LADDR(namestring->base); + if (namestring->offset != 0) { pname += namestring->offset; } - len2 = (DLword)(namestring->fillpointer); - if(len == len2) - { - if(compare_chars(pname, packname, len)==T) - { - return(index); - } - } - } /* for end */ - return(-1); + len2 = (DLword)(namestring->fillpointer); + if (len == len2) { + if (compare_chars(pname, packname, len) == T) { return (index); } + } + } /* for end */ + return (-1); } - /************************************************************************/ /* */ /* P R I N T _ P A C K A G E _ N A M E */ /* */ /************************************************************************/ +void print_package_name(int index) { + PACKAGE *package; + NEWSTRINGP *namestring; + DLword len; + char *pname; -void print_package_name(int index) -{ - PACKAGE *package; - NEWSTRINGP *namestring; - DLword len; - char *pname; - - if(index == 0) - { - printf("#:"); - return; - } - package = (PACKAGE *)Addr68k_from_LADDR( - aref1(*Package_from_Index_word, index)); - namestring = (NEWSTRINGP*)Addr68k_from_LADDR(package->NAME); - pname = (char*)Addr68k_from_LADDR(namestring->base); - if(namestring->offset != 0) - { - pname += namestring->offset; - printf("OFFSET:\n"); - } - len = (DLword)(namestring->fillpointer); - - if(compare_chars(pname , "INTERLISP", len) == T) - { - printf("IL:"); - return; - } - else if(compare_chars(pname , "LISP", len) == T) - { - printf("CL:"); - return; - } - else if(compare_chars(pname , "XEROX-COMMON-LISP", len) == T) - { - printf("XCL:"); - return; - } - else if(compare_chars(pname , "SYSTEM", len) == T) - { - printf("SI:"); - return; - } - else if(compare_chars(pname , "KEYWORD", len) == T) - { - printf(":"); - return; - } - else if(compare_chars(pname , "COMPILER", len) == T) - { - printf("XCLC:"); - return; - } - else - { - while(len >0) - { - putchar(GETBYTE(pname++)); - len--; - } - putchar(':'); - return; - } - - } /*print_package_name */ + if (index == 0) { + printf("#:"); + return; + } + package = (PACKAGE *)Addr68k_from_LADDR(aref1(*Package_from_Index_word, index)); + namestring = (NEWSTRINGP *)Addr68k_from_LADDR(package->NAME); + pname = (char *)Addr68k_from_LADDR(namestring->base); + if (namestring->offset != 0) { + pname += namestring->offset; + printf("OFFSET:\n"); + } + len = (DLword)(namestring->fillpointer); + if (compare_chars(pname, "INTERLISP", len) == T) { + printf("IL:"); + return; + } else if (compare_chars(pname, "LISP", len) == T) { + printf("CL:"); + return; + } else if (compare_chars(pname, "XEROX-COMMON-LISP", len) == T) { + printf("XCL:"); + return; + } else if (compare_chars(pname, "SYSTEM", len) == T) { + printf("SI:"); + return; + } else if (compare_chars(pname, "KEYWORD", len) == T) { + printf(":"); + return; + } else if (compare_chars(pname, "COMPILER", len) == T) { + printf("XCLC:"); + return; + } else { + while (len > 0) { + putchar(GETBYTE(pname++)); + len--; + } + putchar(':'); + return; + } +} /*print_package_name */ /************************************************************************/ /* */ @@ -234,54 +195,48 @@ void print_package_name(int index) /* */ /************************************************************************/ -void dump_dtd(void) -{ - extern DLword *DTDspace; - struct dtd *dtdp; - DLword cnt; +void dump_dtd(void) { + extern DLword *DTDspace; + struct dtd *dtdp; + DLword cnt; + + dtdp = (struct dtd *)DTDspace; + dtdp++; + + for (cnt = 0; cnt < INIT_TYPENUM; cnt++) { + printf("DTD[ %d ] for ", cnt + 1); +#ifdef BIGVM + print_atomname(dtdp->dtd_name); +#else + print_atomname(dtdp->dtd_namelo + (dtdp->dtd_namehi << 16)); +#endif /* BIGVM */ + putchar('\n'); + +#ifdef BIGVM + printf(" dtd_name = %d\n", dtdp->dtd_name); +#else + printf(" dtd_name = %d\n", dtdp->dtd_namelo + (dtdp->dtd_namehi << 16)); +#endif /* BIGVM */ + printf(" dtd_size = %d\n", dtdp->dtd_size); + printf(" dtd_free = %d\n", dtdp->dtd_free); + printf(" dtd_obsolate = %d\n", dtdp->dtd_obsolate); + printf(" dtd_finalizable = %d\n", dtdp->dtd_finalizable); + printf(" dtd_lockedp = %d\n", dtdp->dtd_lockedp); + printf(" dtd_hunkp = %d\n", dtdp->dtd_hunkp); + printf(" dtd_gctype = %d\n", dtdp->dtd_gctype); + printf(" dtd_descrs = %d\n", dtdp->dtd_descrs); + printf(" dtd_typespecs = %d\n", dtdp->dtd_typespecs); + printf(" dtd_ptrs = %d\n", dtdp->dtd_ptrs); + printf(" dtd_oldcnt = %d\n", dtdp->dtd_oldcnt); + printf(" dtd_cnt0 = %d\n", dtdp->dtd_cnt0); + printf(" dtd_nextpage = %d\n", dtdp->dtd_nextpage); + printf(" dtd_typeentry = 0x%x\n", dtdp->dtd_typeentry); + printf(" dtd_supertype = %d\n", dtdp->dtd_supertype); - dtdp = (struct dtd *)DTDspace; dtdp++; + } - for (cnt = 0; cnt < INIT_TYPENUM; cnt ++) - { - printf("DTD[ %d ] for ",cnt+1); -#ifdef BIGVM - print_atomname(dtdp->dtd_name); -#else - print_atomname(dtdp->dtd_namelo + (dtdp->dtd_namehi << 16)); -#endif /* BIGVM */ - putchar('\n'); - -#ifdef BIGVM - printf(" dtd_name = %d\n",dtdp->dtd_name); -#else - printf(" dtd_name = %d\n",dtdp->dtd_namelo + - (dtdp->dtd_namehi << 16)); -#endif /* BIGVM */ - printf(" dtd_size = %d\n",dtdp->dtd_size); - printf(" dtd_free = %d\n",dtdp->dtd_free); - printf(" dtd_obsolate = %d\n",dtdp->dtd_obsolate); - printf(" dtd_finalizable = %d\n",dtdp->dtd_finalizable); - printf(" dtd_lockedp = %d\n",dtdp->dtd_lockedp); - printf(" dtd_hunkp = %d\n",dtdp->dtd_hunkp); - printf(" dtd_gctype = %d\n",dtdp->dtd_gctype); - printf(" dtd_descrs = %d\n",dtdp->dtd_descrs); - printf(" dtd_typespecs = %d\n",dtdp->dtd_typespecs); - printf(" dtd_ptrs = %d\n",dtdp->dtd_ptrs); - printf(" dtd_oldcnt = %d\n",dtdp->dtd_oldcnt); - printf(" dtd_cnt0 = %d\n",dtdp->dtd_cnt0); - printf(" dtd_nextpage = %d\n",dtdp->dtd_nextpage); - printf(" dtd_typeentry = 0x%x\n",dtdp->dtd_typeentry); - printf(" dtd_supertype = %d\n",dtdp->dtd_supertype); - - dtdp++; - } - - } /* end dump dtd */ - - - +} /* end dump dtd */ /************************************************************************/ /* */ @@ -292,22 +247,16 @@ void dump_dtd(void) /* */ /************************************************************************/ -void check_type_68k(int type, LispPTR *ptr) -{ - if (type != (GetTypeNumber(LADDR_from_68k(ptr)) ) ) - { - - printf("Mismatching occur !!! LispAddr 0x%x type %d\n",LADDR_from_68k(ptr) - ,type); - exit(-1); +void check_type_68k(int type, LispPTR *ptr) { + if (type != (GetTypeNumber(LADDR_from_68k(ptr)))) { + printf("Mismatching occur !!! LispAddr 0x%x type %d\n", LADDR_from_68k(ptr), type); + exit(-1); } - printf("LispPTR 0x%x is the datatype %d\n", LADDR_from_68k(ptr) - ,GetTypeNumber(LADDR_from_68k(ptr)) ); + printf("LispPTR 0x%x is the datatype %d\n", LADDR_from_68k(ptr), + GetTypeNumber(LADDR_from_68k(ptr))); } - - /************************************************************************/ /* */ /* t y p e _ n u m */ @@ -316,18 +265,14 @@ void check_type_68k(int type, LispPTR *ptr) /* */ /************************************************************************/ -int type_num(LispPTR lispptr) -{ +int type_num(LispPTR lispptr) { int type; type = GetTypeNumber(lispptr); - printf("LispPTR 0x%x is datatype %dth\n",lispptr,type); - return(type); + printf("LispPTR 0x%x is datatype %dth\n", lispptr, type); + return (type); } - - - /************************************************************************/ /* */ /* d u m p _ c o n s p a g e */ @@ -337,48 +282,39 @@ int type_num(LispPTR lispptr) /************************************************************************/ void dump_conspage(struct conspage *base, int linking) - /* target conspage address */ - /* look for chaiing conspage ? T/NIL */ - { - - ConsCell *cell; - int i; +/* target conspage address */ +/* look for chaiing conspage ? T/NIL */ +{ + ConsCell *cell; + int i; lp: - printf("conspage at 0x%x(lisp) has %d free cells , next available cell offset is %d ,and next page is 0x%x(lisp)\n", - LADDR_from_68k(base), (0xff & base->count), - (0xff & base->next_cell), base->next_page ); + printf( + "conspage at 0x%x(lisp) has %d free cells , next available cell offset is %d ,and next page " + "is 0x%x(lisp)\n", + LADDR_from_68k(base), (0xff & base->count), (0xff & base->next_cell), base->next_page); + for (i = 0, cell = (ConsCell *)base + 1; i < 127; i++, cell++) { + printf(" LADDR : %d = Cell[ %d ]## cdr_code= %d ,car = %d\n", LADDR_from_68k(cell), i + 1, + cell->cdr_code, cell->car_field); + } - for( i = 0 , cell = (ConsCell *)base+1; i <127; i++,cell++) - { - printf(" LADDR : %d = Cell[ %d ]## cdr_code= %d ,car = %d\n", - LADDR_from_68k(cell),i+1,cell->cdr_code,cell->car_field); + if ((linking == T) && (base->next_page != NIL_PTR)) { + base = (struct conspage *)Addr68k_from_LPAGE(base->next_page); + goto lp; + } - } - - if ((linking==T) && (base->next_page != NIL_PTR)) - { - base =(struct conspage *) Addr68k_from_LPAGE(base->next_page); - goto lp; - } - - - } /* end dump_conspage */ +} /* end dump_conspage */ /*********************************/ /* trace the link in ListpDTD->dtd_nextpage */ -void trace_listpDTD(void) -{ -extern struct dtd *ListpDTD; - printf("Dump conspages from ListpDTD chain\n"); - dump_conspage((struct conspage *)Addr68k_from_LPAGE(ListpDTD->dtd_nextpage) , T); - +void trace_listpDTD(void) { + extern struct dtd *ListpDTD; + printf("Dump conspages from ListpDTD chain\n"); + dump_conspage((struct conspage *)Addr68k_from_LPAGE(ListpDTD->dtd_nextpage), T); } - - /************************************************************************/ /* */ /* a 6 8 k */ @@ -387,14 +323,11 @@ extern struct dtd *ListpDTD; /* */ /************************************************************************/ -void a68k(LispPTR lispptr) -{ - DLword *val; - val = Addr68k_from_LADDR(lispptr); - printf("68k: 0x%x (%d)\n", val, val); - } - - +void a68k(LispPTR lispptr) { + DLword *val; + val = Addr68k_from_LADDR(lispptr); + printf("68k: 0x%x (%d)\n", val, val); +} /************************************************************************/ /* */ @@ -404,16 +337,11 @@ void a68k(LispPTR lispptr) /* */ /************************************************************************/ -void laddr(DLword *addr68k) -{ - int val; - val = LADDR_from_68k(addr68k); - printf("LADDR : 0x%x (%d)\n", val, val); - } - - - - +void laddr(DLword *addr68k) { + int val; + val = LADDR_from_68k(addr68k); + printf("LADDR : 0x%x (%d)\n", val, val); +} /************************************************************************/ /* */ @@ -425,59 +353,49 @@ void laddr(DLword *addr68k) /************************************************************************/ void dump_fnbody(LispPTR fnblockaddr) - /* atom index */ - { - struct fnhead *fnobj; - DefCell *defcell68k; - LispPTR cell; - DLbyte *scratch; - int i; +/* atom index */ +{ + struct fnhead *fnobj; + DefCell *defcell68k; + LispPTR cell; + DLbyte *scratch; + int i; + fnobj = (struct fnhead *)Addr68k_from_LADDR(fnblockaddr); - fnobj = (struct fnhead *)Addr68k_from_LADDR(fnblockaddr); + printf("***DUMP Func Obj << "); + printf("start at 0x%x lisp address(0x%x 68k)\n", LADDR_from_68k(fnobj), fnobj); + print(fnobj->framename); + putchar('\n'); - printf("***DUMP Func Obj << "); - printf("start at 0x%x lisp address(0x%x 68k)\n", - LADDR_from_68k(fnobj),fnobj); + printf("stkmin : %d\n", fnobj->stkmin); + printf("na : %d\n", fnobj->na); + printf("pv : %d\n", fnobj->pv); + printf("startpc : %d\n", fnobj->startpc); + printf("argtype : %d\n", fnobj->argtype); + printf("framename : %d\n", fnobj->framename); + printf("ntsize : %d\n", fnobj->ntsize); + printf("nlocals : %d\n", fnobj->nlocals); + printf("fvaroffset: %d\n", fnobj->fvaroffset); - print(fnobj->framename); - putchar('\n'); - - printf("stkmin : %d\n",fnobj->stkmin); - printf("na : %d\n",fnobj->na); - printf("pv : %d\n",fnobj->pv); - printf("startpc : %d\n",fnobj->startpc); - printf("argtype : %d\n",fnobj->argtype); - printf("framename : %d\n",fnobj->framename); - printf("ntsize : %d\n",fnobj->ntsize); - printf("nlocals : %d\n",fnobj->nlocals); - printf("fvaroffset: %d\n",fnobj->fvaroffset); - - scratch= (DLbyte *)fnobj; - for (i= 20; i<(fnobj->startpc); i+=2) - { - int word; - word = (int)(0xffff & (GETWORD((DLword *)(scratch+i)))) ; - printf(" 0x%x(0x%x 68k): 0%6o 0x%4x\n", - LADDR_from_68k(scratch+i), scratch+i, - word, word); - } - - scratch= (DLbyte *)fnobj + (fnobj->startpc); - for (i= 0; i< 2000; i++) - { - int len = print_opcode(fnobj->startpc+i, scratch, fnobj); - if (len < 1) return; - scratch += len; - i += (len -1); - } + scratch = (DLbyte *)fnobj; + for (i = 20; i < (fnobj->startpc); i += 2) { + int word; + word = (int)(0xffff & (GETWORD((DLword *)(scratch + i)))); + printf(" 0x%x(0x%x 68k): 0%6o 0x%4x\n", LADDR_from_68k(scratch + i), scratch + i, word, word); + } + scratch = (DLbyte *)fnobj + (fnobj->startpc); + for (i = 0; i < 2000; i++) { + int len = print_opcode(fnobj->startpc + i, scratch, fnobj); + if (len < 1) return; + scratch += len; + i += (len - 1); + } } /*dump_fnbody end */ - - /************************************************************************/ /* */ /* d u m p _ f n o b j */ @@ -489,22 +407,19 @@ void dump_fnbody(LispPTR fnblockaddr) #define DUMPSIZE 40 void dump_fnobj(LispPTR index) - /* atom index */ - { - struct fnhead *fnobj; - LispPTR *defcell68k; - LispPTR cell; - DLbyte *scratch; - int i; +/* atom index */ +{ + struct fnhead *fnobj; + LispPTR *defcell68k; + LispPTR cell; + DLbyte *scratch; + int i; + defcell68k = GetDEFCELL68k(index); - defcell68k = GetDEFCELL68k(index); - - dump_fnbody(*defcell68k); - - } /*dump_fnobj end */ - + dump_fnbody(*defcell68k); +} /*dump_fnobj end */ /************************************************************************/ /* */ @@ -514,180 +429,387 @@ void dump_fnobj(LispPTR index) /* */ /************************************************************************/ - /* Opcode names, by opcode */ -char * opcode_table[256] = - { "-X-", "CAR", "CDR", "LISTP", "NTYPX", "TYPEP", "DTEST", "UNWIND", - "FN0", "FN1", "FN2", "FN3", "FN4", "FNX", "APPLYFN", "CHECKAPPLY*", - "RETURN", "BIND", "UNBIND", "DUNBIND", "RPLPTR.N", "GCREF", "ASSOC", "GVAR_", - "RPLACA", "RPLACD", "CONS", "CMLASSOC", "FMEMB", "CMLMEMBER", "FINDKEY", "CREATECELL", - "BIN", "BOUT", "PROLOG", "RESTLIST", "MISCN", "<>", "RPLCONS", "LISTGET", - "ELT", "NTHCHC", "SETA", "RPLCHARCODE", "EVAL", "ENVCALL", "TYPECHECK.N", "STKSCAN", - "BUSBLT", "MISC8", "UBFLOAT3", "TYPEMASK.N", "PROLOG", "PROLOG", "PROLOG", "PROLOG", - "PSEUDOCOLOR", "<>", "EQL", "DRAWLINE", "STORE.N", "COPY.N", "RAID", "\\RETURN", - "IVAR0", "IVAR1", "IVAR2", "IVAR3", "IVAR4", "IVAR5", "IVAR6", "IVARX", - "PVAR0", "PVAR1", "PVAR2", "PVAR3", "PVAR4", "PVAR5", "PVAR6", "PVARX", - "FVAR0", "FVAR1", "FVAR2", "FVAR3", "FVAR4", "FVAR5", "FVAR6", "FVARX", - "PVAR_0", "PVAR_1", "PVAR_2", "PVAR_3", "PVAR_4", "PVAR_5", "PVAR_6", "PVAR_X", - "GVAR", "ARG0", "IVARX_", "FVARX_", "COPY", "MYARGCOUNT", "MYALINK", "ACONST", - "'NIL", "'T", "'0", "'1", "SIC", "SNIC", "SICX", "GCONST", - "ATOMNUMBER", "READFLAGS", "READRP", "WRITEMAP", "RPPORT", "WPRTPORT", "PILOTBBT", "RCLK", - "MISC1", "MISC2", "RECCELL", "GCSCAN1", "GCSCAN2", "SUBRCALL", "CONTEXT", "<>", - "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", - "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", "JUMP", - "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", - "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", "FJUMP", - "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", - "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", "TJUMP", - "JUMPX", "JUMPXX", "FJUMPX", "TJUMPX", "NFJUMPX", "NTJUMPX", "AREF1", "ASET1", - "PVAR_0^", "PVAR_1^", "PVAR_2^", "PVAR_3^", "PVAR_4^", "PVAR_5^", "PVAR_6^", "POP", - "POP.N", "ATOMCELL.N", "GETBASEBYTE", "INSTANCEP", "BLT", "MISC10", "<>", "PUTBASEBYTE", - "GETBASE.N", "GETBASEPTR.N", "GETBITS.N.FD", "<>", "CMLEQUAL", "PUTBASE.N", "PUTBASEPTR.N", "PUTBITS.N.FD", - "ADDBASE", "VAG2", "HILOC", "LOLOC", "PLUS2", "DIFFERENCE", "TIMES2", "QUOTIENT", - "IPLUS2", "IDIFFERENCE", "ITIMES2", "IQUOTIENT", "IREMAINDER", "IPLUS.N", "IDIFFERENCE.N", "<>", - "LLSH1", "LLSH8", "LRSH1", "LRSH8", "LOGOR2", "LOGAND2", "LOGXOR2", "LSH", - "FPLUS2", "FIDFFERENCE", "FTIMES2", "FQUOTIENT", "UBFLOAT2", "UBFLOAT1", "AREF2", "ASET2", - "EQ", "IGREATERP", "FGREATERP", "GREATERP", "EQUAL", "MAKENUMBER", "BOXIPLUS", "BOSIDIFFERENCE", - "FLOATBLT", "FFTSTEP", "MISC3", "MISC4", "UPCTRACE", "SWAP", "NOP", "CL=" - - }; +/* Opcode names, by opcode */ +char *opcode_table[256] = {"-X-", + "CAR", + "CDR", + "LISTP", + "NTYPX", + "TYPEP", + "DTEST", + "UNWIND", + "FN0", + "FN1", + "FN2", + "FN3", + "FN4", + "FNX", + "APPLYFN", + "CHECKAPPLY*", + "RETURN", + "BIND", + "UNBIND", + "DUNBIND", + "RPLPTR.N", + "GCREF", + "ASSOC", + "GVAR_", + "RPLACA", + "RPLACD", + "CONS", + "CMLASSOC", + "FMEMB", + "CMLMEMBER", + "FINDKEY", + "CREATECELL", + "BIN", + "BOUT", + "PROLOG", + "RESTLIST", + "MISCN", + "<>", + "RPLCONS", + "LISTGET", + "ELT", + "NTHCHC", + "SETA", + "RPLCHARCODE", + "EVAL", + "ENVCALL", + "TYPECHECK.N", + "STKSCAN", + "BUSBLT", + "MISC8", + "UBFLOAT3", + "TYPEMASK.N", + "PROLOG", + "PROLOG", + "PROLOG", + "PROLOG", + "PSEUDOCOLOR", + "<>", + "EQL", + "DRAWLINE", + "STORE.N", + "COPY.N", + "RAID", + "\\RETURN", + "IVAR0", + "IVAR1", + "IVAR2", + "IVAR3", + "IVAR4", + "IVAR5", + "IVAR6", + "IVARX", + "PVAR0", + "PVAR1", + "PVAR2", + "PVAR3", + "PVAR4", + "PVAR5", + "PVAR6", + "PVARX", + "FVAR0", + "FVAR1", + "FVAR2", + "FVAR3", + "FVAR4", + "FVAR5", + "FVAR6", + "FVARX", + "PVAR_0", + "PVAR_1", + "PVAR_2", + "PVAR_3", + "PVAR_4", + "PVAR_5", + "PVAR_6", + "PVAR_X", + "GVAR", + "ARG0", + "IVARX_", + "FVARX_", + "COPY", + "MYARGCOUNT", + "MYALINK", + "ACONST", + "'NIL", + "'T", + "'0", + "'1", + "SIC", + "SNIC", + "SICX", + "GCONST", + "ATOMNUMBER", + "READFLAGS", + "READRP", + "WRITEMAP", + "RPPORT", + "WPRTPORT", + "PILOTBBT", + "RCLK", + "MISC1", + "MISC2", + "RECCELL", + "GCSCAN1", + "GCSCAN2", + "SUBRCALL", + "CONTEXT", + "<>", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "JUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "FJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "TJUMP", + "JUMPX", + "JUMPXX", + "FJUMPX", + "TJUMPX", + "NFJUMPX", + "NTJUMPX", + "AREF1", + "ASET1", + "PVAR_0^", + "PVAR_1^", + "PVAR_2^", + "PVAR_3^", + "PVAR_4^", + "PVAR_5^", + "PVAR_6^", + "POP", + "POP.N", + "ATOMCELL.N", + "GETBASEBYTE", + "INSTANCEP", + "BLT", + "MISC10", + "<>", + "PUTBASEBYTE", + "GETBASE.N", + "GETBASEPTR.N", + "GETBITS.N.FD", + "<>", + "CMLEQUAL", + "PUTBASE.N", + "PUTBASEPTR.N", + "PUTBITS.N.FD", + "ADDBASE", + "VAG2", + "HILOC", + "LOLOC", + "PLUS2", + "DIFFERENCE", + "TIMES2", + "QUOTIENT", + "IPLUS2", + "IDIFFERENCE", + "ITIMES2", + "IQUOTIENT", + "IREMAINDER", + "IPLUS.N", + "IDIFFERENCE.N", + "<>", + "LLSH1", + "LLSH8", + "LRSH1", + "LRSH8", + "LOGOR2", + "LOGAND2", + "LOGXOR2", + "LSH", + "FPLUS2", + "FIDFFERENCE", + "FTIMES2", + "FQUOTIENT", + "UBFLOAT2", + "UBFLOAT1", + "AREF2", + "ASET2", + "EQ", + "IGREATERP", + "FGREATERP", + "GREATERP", + "EQUAL", + "MAKENUMBER", + "BOXIPLUS", + "BOSIDIFFERENCE", + "FLOATBLT", + "FFTSTEP", + "MISC3", + "MISC4", + "UPCTRACE", + "SWAP", + "NOP", + "CL=" +}; -int print_opcode(int pc, DLbyte *addr, struct fnhead *fnobj) -{ - /* Print the opcode at addr, including args, and return length */ - /* if this opcode is the last, return -1 */ - int op = (int) (0xFF & GETBYTE(addr)); - int i; - extern unsigned int oplength[256]; - int len =oplength[op]+1; +int print_opcode(int pc, DLbyte *addr, struct fnhead *fnobj) { + /* Print the opcode at addr, including args, and return length */ + /* if this opcode is the last, return -1 */ + int op = (int)(0xFF & GETBYTE(addr)); + int i; + extern unsigned int oplength[256]; + int len = oplength[op] + 1; - printf(" 0%o (0x%x) ", pc, pc); - for (i=0; iframename); - putchar('\n'); - printf(" PC cnt = 0%o\n" ,tmp.pc=((UNSIGNED)(PC)- (UNSIGNED)FuncObj) ); - tmp.func= FuncObj->framename; - return(tmp); - } +struct doko { + LispPTR func; + int pc; +}; +struct doko doko(void) { + struct doko tmp; + printf(" At "); + print_atomname(FuncObj->framename); + putchar('\n'); + printf(" PC cnt = 0%o\n", tmp.pc = ((UNSIGNED)(PC) - (UNSIGNED)FuncObj)); + tmp.func = FuncObj->framename; + return (tmp); +} /**** dump specified area (in 32 bit width) ***/ -void dumpl(LispPTR laddr) -{ - int i; - LispPTR *ptr; +void dumpl(LispPTR laddr) { + int i; + LispPTR *ptr; - ptr = (LispPTR *)Addr68k_from_LADDR(laddr); + ptr = (LispPTR *)Addr68k_from_LADDR(laddr); - - for(i=0; i< 40; i++,ptr++) - printf("LADDR 0x%x : %d\n", LADDR_from_68k(ptr), *ptr); - - } + for (i = 0; i < 40; i++, ptr++) printf("LADDR 0x%x : %d\n", LADDR_from_68k(ptr), *ptr); +} /**** dump specified area (in 16 bit width) ***/ -void dumps(LispPTR laddr) -{ - int i; - DLword *ptr; +void dumps(LispPTR laddr) { + int i; + DLword *ptr; - ptr = (DLword *)Addr68k_from_LADDR(laddr); - - - for(i=0; i< 40; i++,ptr++) - printf("LADDR 0x%x : %d\n", LADDR_from_68k(ptr), (GETWORD(ptr)& 0xffff)); - - } - - - -/***********************/ -void printPC(void) -{ - unsigned short pc; - - pc =(UNSIGNED)PC - (UNSIGNED)FuncObj; - - printf("PC: O%o ",pc); - } - - -/***************************/ -int countchar(char *string) -{ - int cnt=0; - - while(*string != '\0') { string++; cnt++;} - - return(cnt); - } - - -void dump_bf(Bframe *bf) -{ - DLword *ptr; - printf("\n*** Basic Frame"); - if (BFRAMEPTR(bf)->flags != 4) - { - printf("\nInvalid basic frame"); - return; - }; - - if (BFRAMEPTR(bf)->residual) {goto printflags;} - - ptr = Addr68k_from_LADDR( STK_OFFSET + bf->ivar); - if ( (((DLword*)bf - ptr) > 512) || (( (UNSIGNED)ptr & 1) != 0) ) - { - printf("\nInvalid basic frame"); - return; - } - while(ptr < (DLword *)bf) - { - printf("\n %x : %x %x", LADDR_from_68k(ptr), - GETWORD(ptr), GETWORD(ptr+1)); - print(*ptr); - ptr+=2; - } - -printflags: - printf("\n %x : %x %x ",LADDR_from_68k(bf),*bf, *(bf+1)); - putchar('['); - if (BFRAMEPTR(bf)->residual) printf("Residual, "); - if (BFRAMEPTR(bf)->padding) printf("Padded, "); - printf("usecnt=%d ] ",BFRAMEPTR(bf)->usecnt); - printf("ivar : 0x%x",BFRAMEPTR(bf)->ivar); + ptr = (DLword *)Addr68k_from_LADDR(laddr); + for (i = 0; i < 40; i++, ptr++) + printf("LADDR 0x%x : %d\n", LADDR_from_68k(ptr), (GETWORD(ptr) & 0xffff)); } -void dump_fx(struct frameex1 *fx_addr68k) -{ - DLword *next68k; - DLword *ptr; - LispPTR atomindex; +/***********************/ +void printPC(void) { + unsigned short pc; - ptr = (DLword *)fx_addr68k; + pc = (UNSIGNED)PC - (UNSIGNED)FuncObj; - if(fx_addr68k->flags != 6) - { - printf("\nInvalid frame,NOT FX"); - return; - }; + printf("PC: O%o ", pc); +} +/***************************/ +int countchar(char *string) { + int cnt = 0; - atomindex = get_framename((struct frameex1 *)fx_addr68k); - printf("\n*** Frame Extension for "); - print(atomindex); - printf("\n %x : %x %x ",LADDR_from_68k(ptr),GETWORD(ptr), GETWORD(ptr+1)); + while (*string != '\0') { + string++; + cnt++; + } - putchar('['); - if(fx_addr68k->fast) printf("F,"); - if(fx_addr68k->incall) printf("incall, "); - if(fx_addr68k->validnametable) printf("V, "); - printf("usecnt = %d]; alink",fx_addr68k->usecount); - if(fx_addr68k->alink & 1) - printf("[SLOWP]"); + return (cnt); +} +void dump_bf(Bframe *bf) { + DLword *ptr; + printf("\n*** Basic Frame"); + if (BFRAMEPTR(bf)->flags != 4) { + printf("\nInvalid basic frame"); + return; + }; - ptr+=2; - printf("\n %x : %x %x fnheadlo, fnheadhi\n", - LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr+1)); + if (BFRAMEPTR(bf)->residual) { goto printflags; } - ptr+=2; - printf("\n %x : %x %x next, pc\n", - LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr+1)); + ptr = Addr68k_from_LADDR(STK_OFFSET + bf->ivar); + if ((((DLword *)bf - ptr) > 512) || (((UNSIGNED)ptr & 1) != 0)) { + printf("\nInvalid basic frame"); + return; + } + while (ptr < (DLword *)bf) { + printf("\n %x : %x %x", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr + 1)); + print(*ptr); + ptr += 2; + } - ptr+=2; - printf("\n %x : %x %x LoNmTbl, HiNmTbl\n",LADDR_from_68k(ptr),GETWORD(ptr), GETWORD(ptr+1)); +printflags: + printf("\n %x : %x %x ", LADDR_from_68k(bf), *bf, *(bf + 1)); + putchar('['); + if (BFRAMEPTR(bf)->residual) printf("Residual, "); + if (BFRAMEPTR(bf)->padding) printf("Padded, "); + printf("usecnt=%d ] ", BFRAMEPTR(bf)->usecnt); + printf("ivar : 0x%x", BFRAMEPTR(bf)->ivar); +} - ptr+=2; - printf("\n %x : %x %x #blink, #clink\n",LADDR_from_68k(ptr),GETWORD(ptr), GETWORD(ptr+1)); +void dump_fx(struct frameex1 *fx_addr68k) { + DLword *next68k; + DLword *ptr; + LispPTR atomindex; + ptr = (DLword *)fx_addr68k; - /* should pay attention to the name table like RAID does */ + if (fx_addr68k->flags != 6) { + printf("\nInvalid frame,NOT FX"); + return; + }; - next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock+STK_OFFSET)); - if (fx_addr68k == CURRENTFX) {next68k = CurrentStackPTR + 2;} + atomindex = get_framename((struct frameex1 *)fx_addr68k); + printf("\n*** Frame Extension for "); + print(atomindex); + printf("\n %x : %x %x ", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr + 1)); - if ((next68k < ptr) || (((UNSIGNED)next68k & 1) != 0) ) - {printf ("\nNext block invalid"); return;} + putchar('['); + if (fx_addr68k->fast) printf("F,"); + if (fx_addr68k->incall) printf("incall, "); + if (fx_addr68k->validnametable) printf("V, "); + printf("usecnt = %d]; alink", fx_addr68k->usecount); + if (fx_addr68k->alink & 1) printf("[SLOWP]"); + ptr += 2; + printf("\n %x : %x %x fnheadlo, fnheadhi\n", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr + 1)); - while(next68k > ptr) - { - ptr+=2; - printf("\n %x : %x %x", - LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr+1)); - } - } /* end dump_fx */ + ptr += 2; + printf("\n %x : %x %x next, pc\n", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr + 1)); + ptr += 2; + printf("\n %x : %x %x LoNmTbl, HiNmTbl\n", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr + 1)); + + ptr += 2; + printf("\n %x : %x %x #blink, #clink\n", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr + 1)); + + /* should pay attention to the name table like RAID does */ + + next68k = (DLword *)Addr68k_from_LADDR((fx_addr68k->nextblock + STK_OFFSET)); + if (fx_addr68k == CURRENTFX) { next68k = CurrentStackPTR + 2; } + + if ((next68k < ptr) || (((UNSIGNED)next68k & 1) != 0)) { + printf("\nNext block invalid"); + return; + } + + while (next68k > ptr) { + ptr += 2; + printf("\n %x : %x %x", LADDR_from_68k(ptr), GETWORD(ptr), GETWORD(ptr + 1)); + } +} /* end dump_fx */ /***************************************************************/ /* - Func Name : dump_stackframe - Desc : For Debugging Aids - Changed 8 JUN 1987 TAKE + Func Name : dump_stackframe + Desc : For Debugging Aids + Changed 8 JUN 1987 TAKE */ /***************************************************************/ -void dump_stackframe(struct frameex1 *fx_addr68k) -{ - Bframe *bf; - if((fx_addr68k->alink & 1)==0) - { /* FAST */ - bf = (Bframe *)(((DLword *)fx_addr68k) - 2 ); - } - else - { /* SLOW */ - bf =(Bframe *) Addr68k_from_LADDR((fx_addr68k->blink+ STK_OFFSET)); - } - dump_bf(bf); - dump_fx((struct frameex1 *)fx_addr68k); +void dump_stackframe(struct frameex1 *fx_addr68k) { + Bframe *bf; + if ((fx_addr68k->alink & 1) == 0) { /* FAST */ + bf = (Bframe *)(((DLword *)fx_addr68k) - 2); + } else { /* SLOW */ + bf = (Bframe *)Addr68k_from_LADDR((fx_addr68k->blink + STK_OFFSET)); } + dump_bf(bf); + dump_fx((struct frameex1 *)fx_addr68k); +} - - -void dump_CSTK(int before) -{ - DLword *ptr; - ptr= CurrentStackPTR - before; - while(ptr != CurrentStackPTR) - { - printf("\n%x : %x ",LADDR_from_68k(ptr),GETWORD(ptr)); - ptr++; - } - printf("\nCurrentSTKP : %x ",LADDR_from_68k(CurrentStackPTR)); - printf("\ncontents : %x ",*((LispPTR *)(CurrentStackPTR-1))); - }/* dump_CSTK end */ - - +void dump_CSTK(int before) { + DLword *ptr; + ptr = CurrentStackPTR - before; + while (ptr != CurrentStackPTR) { + printf("\n%x : %x ", LADDR_from_68k(ptr), GETWORD(ptr)); + ptr++; + } + printf("\nCurrentSTKP : %x ", LADDR_from_68k(CurrentStackPTR)); + printf("\ncontents : %x ", *((LispPTR *)(CurrentStackPTR - 1))); +} /* dump_CSTK end */ /******************************************/ /* BTV */ -void btv(void) -{ - struct frameex1 *fx_addr68k; - LispPTR atomindex; - struct frameex1 *get_nextFX(FX *fx); +void btv(void) { + struct frameex1 *fx_addr68k; + LispPTR atomindex; + struct frameex1 *get_nextFX(FX * fx); - fx_addr68k = CURRENTFX; + fx_addr68k = CURRENTFX; loop: - dump_stackframe(fx_addr68k); - if( fx_addr68k->alink == 0 ) - {printf ("\n BTV end"); return;}; + dump_stackframe(fx_addr68k); + if (fx_addr68k->alink == 0) { + printf("\n BTV end"); + return; + }; - fx_addr68k= get_nextFX(fx_addr68k); - goto loop; - } /*end btv*/ + fx_addr68k = get_nextFX(fx_addr68k); + goto loop; +} /*end btv*/ -int get_framename(struct frameex1 *fx_addr68k) -{ - struct fnhead *fnheader; - LispPTR scratch; +int get_framename(struct frameex1 *fx_addr68k) { + struct fnhead *fnheader; + LispPTR scratch; - /* Get FNHEAD */ +/* Get FNHEAD */ #ifdef BIGVM - if(fx_addr68k->validnametable==0) - { - scratch = (unsigned int)(fx_addr68k->fnheader); - } - else - { - scratch = (unsigned int)(fx_addr68k->nametable); - } -#else - if(fx_addr68k->validnametable==0) - { - scratch = (unsigned int)(fx_addr68k->hi2fnheader << 16); - scratch |= (unsigned int)(fx_addr68k->lofnheader); - } - else - { - scratch = (unsigned int)(fx_addr68k->hi2nametable << 16); - scratch |= (unsigned int)(fx_addr68k->lonametable); - } -#endif /* BIGVM */ - fnheader = (struct fnhead *)Addr68k_from_LADDR( scratch ); - return(fnheader->framename); - }/* get_framename end */ - - -FX *get_nextFX(FX *fx) -{ - DLword *pv; - - if(URaid_scanlink==URSCAN_ALINK) - return((FX *)Addr68k_from_StkOffset(GETALINK(fx))); - else - return((FX *)Addr68k_from_StkOffset(GETCLINK(fx))); - - } /* get_nextFX end */ - - - -int MAKEATOM(char *string) -{ - int length; - length = countchar(string); - return(make_atom(string,0,length,0)); + if (fx_addr68k->validnametable == 0) { + scratch = (unsigned int)(fx_addr68k->fnheader); + } else { + scratch = (unsigned int)(fx_addr68k->nametable); } +#else + if (fx_addr68k->validnametable == 0) { + scratch = (unsigned int)(fx_addr68k->hi2fnheader << 16); + scratch |= (unsigned int)(fx_addr68k->lofnheader); + } else { + scratch = (unsigned int)(fx_addr68k->hi2nametable << 16); + scratch |= (unsigned int)(fx_addr68k->lonametable); + } +#endif /* BIGVM */ + fnheader = (struct fnhead *)Addr68k_from_LADDR(scratch); + return (fnheader->framename); +} /* get_framename end */ +FX *get_nextFX(FX *fx) { + DLword *pv; + if (URaid_scanlink == URSCAN_ALINK) + return ((FX *)Addr68k_from_StkOffset(GETALINK(fx))); + else + return ((FX *)Addr68k_from_StkOffset(GETCLINK(fx))); + +} /* get_nextFX end */ + +int MAKEATOM(char *string) { + int length; + length = countchar(string); + return (make_atom(string, 0, length, 0)); +} /************************************************************************/ /* */ @@ -991,20 +1060,16 @@ int MAKEATOM(char *string) /* */ /************************************************************************/ -DLword *MakeAtom68k(char *string) -{ - int index; - index = make_atom(string, 0, countchar(string), 0); +DLword *MakeAtom68k(char *string) { + int index; + index = make_atom(string, 0, countchar(string), 0); #ifdef BIGVM - index = (ATOMS_HI << 16) + (index * 10) + NEWATOM_VALUE_OFFSET; + index = (ATOMS_HI << 16) + (index * 10) + NEWATOM_VALUE_OFFSET; #else - index = VALS_OFFSET + (index << 1); -#endif /* BIGVM */ - return ( Addr68k_from_LADDR( index ) ); - } - - - + index = VALS_OFFSET + (index << 1); +#endif /* BIGVM */ + return (Addr68k_from_LADDR(index)); +} /************************************************************************/ /* */ @@ -1013,21 +1078,19 @@ DLword *MakeAtom68k(char *string) /* Print the top-level value of a given atom; for use in dbx. */ /* */ /************************************************************************/ -void GETTOPVAL(char *string) -{ - int index; - LispPTR *cell68k; +void GETTOPVAL(char *string) { + int index; + LispPTR *cell68k; - index=MAKEATOM(string); - if (index != -1) /* Only print if there's such an atom */ - { - cell68k= (LispPTR *)GetVALCELL68k(index); - print(*cell68k); - } - else printf("'%s': no such symbol.\n", string); + index = MAKEATOM(string); + if (index != -1) /* Only print if there's such an atom */ + { + cell68k = (LispPTR *)GetVALCELL68k(index); + print(*cell68k); + } else + printf("'%s': no such symbol.\n", string); } - /************************************************************************/ /* */ /* S _ T O P V A L */ @@ -1038,40 +1101,32 @@ void GETTOPVAL(char *string) /* */ /************************************************************************/ -void S_TOPVAL(char *string) -{ - int index; - LispPTR *cell68k; - int length; - char dummy[256]; +void S_TOPVAL(char *string) { + int index; + LispPTR *cell68k; + int length; + char dummy[256]; - dummy[0]='\\'; - for(length=1; *string != '\0'; length++,string++) - { - dummy[length] = *string; - } - - index=make_atom(dummy,0,length,0); - cell68k= (LispPTR *)GetVALCELL68k(index); - print(*cell68k); - } + dummy[0] = '\\'; + for (length = 1; *string != '\0'; length++, string++) { dummy[length] = *string; } + index = make_atom(dummy, 0, length, 0); + cell68k = (LispPTR *)GetVALCELL68k(index); + print(*cell68k); +} /***************/ -int S_MAKEATOM(char *string) -{ - int index=0; - int length; - char dummy[256]; +int S_MAKEATOM(char *string) { + int index = 0; + int length; + char dummy[256]; - dummy[0]='\\'; - for(length=1; *string != '\0'; length++,string++) - { dummy[length] = *string;} + dummy[0] = '\\'; + for (length = 1; *string != '\0'; length++, string++) { dummy[length] = *string; } - - index=make_atom(dummy,0,length,0); - printf("#Atomindex : %d\n",index); - return(index); + index = make_atom(dummy, 0, length, 0); + printf("#Atomindex : %d\n", index); + return (index); } /****************************************************************************/ @@ -1081,228 +1136,209 @@ int S_MAKEATOM(char *string) jmp_buf SD_jumpbuf; #define SDMAXLINE 30 -#define SD_morep if(++sdlines>SDMAXLINE){ int temp;\ - printf("\nPress Return:(to quit Esc and Ret):");\ - temp = getchar();fflush(stdin);\ - sdlines=0;if(temp==27)longjmp(SD_jumpbuf,1) ;} - +#define SD_morep \ + if (++sdlines > SDMAXLINE) { \ + int temp; \ + printf("\nPress Return:(to quit Esc and Ret):"); \ + temp = getchar(); \ + fflush(stdin); \ + sdlines = 0; \ + if (temp == 27) longjmp(SD_jumpbuf, 1); \ + } #ifndef BYTESWAP -typedef struct stack_header - { - unsigned flags1 : 3; - unsigned flags2 : 5; - unsigned usecount : 8; - } STKH; +typedef struct stack_header { + unsigned flags1 : 3; + unsigned flags2 : 5; + unsigned usecount : 8; +} STKH; #define STKHPTR(ptr) (ptr) #else -typedef struct stack_header - { - unsigned usecount : 8; - unsigned flags2 : 5; - unsigned flags1 : 3; - } STKH; +typedef struct stack_header { + unsigned usecount : 8; + unsigned flags2 : 5; + unsigned flags1 : 3; +} STKH; -#define STKHPTR(ptr) ((STKH *) (2^(UNSIGNED)(ptr))) +#define STKHPTR(ptr) ((STKH *)(2 ^ (UNSIGNED)(ptr))) #endif /* BYTESWAP */ - - - void all_stack_dump(DLword start, DLword end, DLword silent) - /* Stack offset in DLword */ +/* Stack offset in DLword */ { STKH *stkptr; - DLword *start68k,*end68k,*orig68k; - DLword size,dummy; - int sdlines=0; - extern IFPAGE *InterfacePage; + DLword *start68k, *end68k, *orig68k; + DLword size, dummy; + int sdlines = 0; + extern IFPAGE *InterfacePage; - if(start==0) start68k= Stackspace + InterfacePage->stackbase; - else start68k = Addr68k_from_LADDR(STK_OFFSET | start); + if (start == 0) + start68k = Stackspace + InterfacePage->stackbase; + else + start68k = Addr68k_from_LADDR(STK_OFFSET | start); - if(end==0) end68k= Stackspace+ InterfacePage->endofstack; - else end68k = Addr68k_from_LADDR(STK_OFFSET | end); + if (end == 0) + end68k = Stackspace + InterfacePage->endofstack; + else + end68k = Addr68k_from_LADDR(STK_OFFSET | end); - stkptr= (STKH *)start68k; + stkptr = (STKH *)start68k; + while (((DLword *)stkptr) < end68k) { + dummy = LADDR_from_68k(stkptr); + switch (STKHPTR(stkptr)->flags1) { + case STK_GUARD: + case STK_FSB: + if ((STKHPTR(stkptr)->flags2 != 0) || (STKHPTR(stkptr)->usecount != 0)) { goto badblock; }; + size = GETWORD(((DLword *)stkptr) + 1); + if (STKHPTR(stkptr)->flags1 == STK_GUARD) + printf("\n0x%x GUARD, size : 0x%x", LADDR_from_68k(stkptr), size); + else + printf("\n0x%x FSB, size : 0x%x", LADDR_from_68k(stkptr), size); - while(((DLword*)stkptr) < end68k ) - { - dummy = LADDR_from_68k(stkptr); - switch (STKHPTR(stkptr)->flags1 ) { - case STK_GUARD : - case STK_FSB : - if( (STKHPTR(stkptr)->flags2 !=0) || (STKHPTR(stkptr)->usecount!=0) ) - {goto badblock;}; - size = GETWORD(((DLword *)stkptr) +1); - if(STKHPTR(stkptr)->flags1 == STK_GUARD) - printf("\n0x%x GUARD, size : 0x%x", - LADDR_from_68k(stkptr),size ); - else printf("\n0x%x FSB, size : 0x%x", - LADDR_from_68k(stkptr),size); + if (size <= 0 || size > ((DLword *)end68k - (DLword *)stkptr)) { goto badblock; }; - if(size <=0 || - size > ((DLword*)end68k-(DLword*)stkptr)) - {goto badblock;}; + SD_morep; + size = GETWORD(((DLword *)stkptr) + 1); + checksize: + if (size <= 0 || size > ((DLword *)end68k - (DLword *)stkptr)) { goto badblock; }; + stkptr = (STKH *)(((DLword *)stkptr) + size); + break; - SD_morep; - size = GETWORD(((DLword *)stkptr) +1); - checksize: - if(size <=0 || size > ((DLword*)end68k-(DLword*)stkptr)) - {goto badblock;}; - stkptr = (STKH *) (((DLword *) stkptr) + size); - break; + case STK_FX: + /*if((((FX *)stkptr)->pc < 24) || + (((FX *)stkptr)->alink==0) || + (STKHPTR(stkptr)->usecount > 31)) + {goto badblock;};*/ + if (silent) { + SD_morep; + printf("\n0x%x: FX for ", LADDR_from_68k(stkptr)); + print(get_framename((struct frameex1 *)stkptr)); + printf(" ["); + if (((FX *)stkptr)->fast) printf("fast,"); + if (((FX *)stkptr)->native) printf("native,"); + if (((FX *)stkptr)->incall) printf("incall,"); + if (((FX *)stkptr)->validnametable) printf("V,"); + if (((FX *)stkptr)->nopush) printf("nopush,"); + printf("]"); + } else { + dump_fx((struct frameex1 *)stkptr); + } - case STK_FX : - /*if((((FX *)stkptr)->pc < 24) || - (((FX *)stkptr)->alink==0) || - (STKHPTR(stkptr)->usecount > 31)) - {goto badblock;};*/ - if (silent) - { SD_morep; - printf("\n0x%x: FX for ",LADDR_from_68k(stkptr)); - print(get_framename((struct frameex1 *)stkptr)); - printf(" ["); - if(((FX *)stkptr)->fast) printf("fast,"); - if(((FX *)stkptr)->native) printf("native,"); - if(((FX *)stkptr)->incall) printf("incall,"); - if(((FX *)stkptr)->validnametable) printf("V,"); - if(((FX *)stkptr)->nopush) printf("nopush,"); - printf("]"); - } - else {dump_fx((struct frameex1 *)stkptr);} + if ((FX *)stkptr == CURRENTFX) { + printf(" <-***current***"); + size = EndSTKP - (DLword *)stkptr; + } else { + size = Addr68k_from_LADDR(STK_OFFSET | ((FX *)stkptr)->nextblock) - (DLword *)stkptr; + }; + goto checksize; + default: + orig68k = (DLword *)stkptr; - if((FX *)stkptr == CURRENTFX) { - printf(" <-***current***"); - size= EndSTKP - (DLword*)stkptr; - } - else { - size = Addr68k_from_LADDR(STK_OFFSET| ((FX *)stkptr)->nextblock) - (DLword*)stkptr; + while (STKHPTR(stkptr)->flags1 != STK_BF) { + if (STKHPTR(stkptr)->flags1 != STK_NOTFLG) { goto badblock; }; + stkptr = (STKH *)(((DLword *)stkptr) + DLWORDSPER_CELL); + }; - }; - goto checksize; - default : - orig68k =(DLword*) stkptr; + if ((BFRAMEPTR(stkptr))->residual) { + if ((DLword *)stkptr != orig68k) { + printf("\n$$$Bad BF(res):0x%x", LADDR_from_68k(stkptr)); + goto incptr; + } + } else { + if (BFRAMEPTR(stkptr)->ivar != StkOffset_from_68K(orig68k)) { + printf("\n$$$BF doesn't point TopIVAR:0x%x\n", LADDR_from_68k(stkptr)); + goto incptr; + } + } - while(STKHPTR(stkptr)->flags1 != STK_BF) { - if(STKHPTR(stkptr)->flags1!=STK_NOTFLG){goto badblock;}; - stkptr = (STKH *) (((DLword *)stkptr) + DLWORDSPER_CELL); - }; + if (silent) { + SD_morep; + printf("\n0x%x BF, ", LADDR_from_68k(stkptr)); + putchar('['); + if (BFRAMEPTR(stkptr)->residual) printf("Res,"); + if (BFRAMEPTR(stkptr)->padding) printf("Pad,"); + printf("ivar : 0x%x]", BFRAMEPTR(stkptr)->ivar); + } else + dump_bf((Bframe *)stkptr); - if((BFRAMEPTR(stkptr))->residual) - { if((DLword*) stkptr != orig68k) - { - printf("\n$$$Bad BF(res):0x%x",LADDR_from_68k(stkptr)); - goto incptr; - } - } - else - { - if(BFRAMEPTR(stkptr)->ivar - != StkOffset_from_68K(orig68k)) - { - printf("\n$$$BF doesn't point TopIVAR:0x%x\n",LADDR_from_68k(stkptr)); - goto incptr; - } - } + stkptr = (STKH *)(((DLword *)stkptr) + 2); + break; + badblock: + SD_morep; + printf("\n0x%x: Invalid, %x %x", LADDR_from_68k(stkptr), GETWORD(stkptr), + GETWORD(stkptr + 1)); + incptr: + stkptr = (STKH *)(((DLword *)stkptr) + 2); + break; - if(silent) - { SD_morep; - printf("\n0x%x BF, ",LADDR_from_68k(stkptr)); - putchar('['); - if (BFRAMEPTR(stkptr)->residual) printf("Res,"); - if (BFRAMEPTR(stkptr)->padding) printf("Pad,"); - printf("ivar : 0x%x]", BFRAMEPTR(stkptr)->ivar); - } else dump_bf((Bframe *)stkptr); - - stkptr = (STKH*) (((DLword *)stkptr) + 2); - break; - - badblock: SD_morep; - printf("\n0x%x: Invalid, %x %x",LADDR_from_68k(stkptr), GETWORD(stkptr), GETWORD(stkptr+1)); - incptr: stkptr = (STKH *) (((DLword *)stkptr) + 2); - break; - - } /* case end */ - + } /* case end */ } /* while end */ -printf("\n<< That's All , last stack :0x%x >>\n",InterfacePage->endofstack); - + printf("\n<< That's All , last stack :0x%x >>\n", InterfacePage->endofstack); } - /************************************************************/ -void dtd_chain(DLword type) -{ - struct dtd *dtdp; - LispPTR next; - LispPTR *next68k; +void dtd_chain(DLword type) { + struct dtd *dtdp; + LispPTR next; + LispPTR *next68k; - dtdp=(struct dtd *)GetDTD(type); + dtdp = (struct dtd *)GetDTD(type); - next=dtdp->dtd_free; - next68k=(LispPTR *) Addr68k_from_LADDR(next); + next = dtdp->dtd_free; + next68k = (LispPTR *)Addr68k_from_LADDR(next); - while((*next68k) != 0) - { - if(type != GetTypeNumber(next)) { - printf("BAD cell in next dtdfree\n"); - return; } - print(next); - putchar('\n'); - - next= *next68k; - next68k=(LispPTR *) Addr68k_from_LADDR(next); - } - printf("That's All !\n"); - - }/* dtd_chain end **/ + while ((*next68k) != 0) { + if (type != GetTypeNumber(next)) { + printf("BAD cell in next dtdfree\n"); + return; + } + print(next); + putchar('\n'); + next = *next68k; + next68k = (LispPTR *)Addr68k_from_LADDR(next); + } + printf("That's All !\n"); +} /* dtd_chain end **/ #ifdef DTDDEBUG -void check_dtd_chain(type) - DLword type; - { - register LispPTR next, onext; - LispPTR before; +void check_dtd_chain(type) DLword type; +{ + register LispPTR next, onext; + LispPTR before; - onext = 0; - next = ((struct dtd *)GetDTD(type))->dtd_free; - next &= POINTERMASK; + onext = 0; + next = ((struct dtd *)GetDTD(type))->dtd_free; + next &= POINTERMASK; - while (next != NIL) - { + while (next != NIL) { + if (next & 1) { + error("Free pointer is ODD!"); + return; + } - if (next & 1) - { - error("Free pointer is ODD!"); - return; - } + if (next & 0x8000000) error("impossibly-big free pointer!"); - if (next & 0x8000000) error("impossibly-big free pointer!"); - - if (type != GetTypeNumber(next)) - { - error("BAD cell in next dtdfree "); - return; - } + if (type != GetTypeNumber(next)) { + error("BAD cell in next dtdfree "); + return; + } onext = next; - next = *((LispPTR *)Addr68k_from_LADDR(next)); - next &= POINTERMASK; - } + next = *((LispPTR *)Addr68k_from_LADDR(next)); + next &= POINTERMASK; } +} #endif - /************************************************************************/ /* */ /* T R A C E _ F N C A L L */ @@ -1317,26 +1353,25 @@ void check_dtd_chain(type) /* */ /************************************************************************/ -void Trace_FNCall(int numargs, int atomindex, int arg1, LispPTR *tos) -{ - printf("Calling a %d-arg FN: ", numargs); - print_atomname(atomindex); - printf("("); - if (numargs > 1) - { - int i; - for (i = -(numargs-2); i<1; i++) - { prindatum(*(tos+i)); printf(", "); } - } - if(numargs) prindatum(arg1); - printf(").\n"); - fflush(stdout); +void Trace_FNCall(int numargs, int atomindex, int arg1, LispPTR *tos) { + printf("Calling a %d-arg FN: ", numargs); + print_atomname(atomindex); + printf("("); + if (numargs > 1) { + int i; + for (i = -(numargs - 2); i < 1; i++) { + prindatum(*(tos + i)); + printf(", "); + } } + if (numargs) prindatum(arg1); + printf(").\n"); + fflush(stdout); +} -void Trace_APPLY(int atomindex) -{ - printf("APPLYing an atom: "); - print_atomname(atomindex); - printf(".\n"); - fflush(stdout); - } +void Trace_APPLY(int atomindex) { + printf("APPLYing an atom: "); + print_atomname(atomindex); + printf(".\n"); + fflush(stdout); +} diff --git a/src/timeoday.c b/src/timeoday.c old mode 100755 new mode 100644 index 2de8626..6a471f0 --- a/src/timeoday.c +++ b/src/timeoday.c @@ -1,7 +1,7 @@ -/* $Id: timeoday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: timeoday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: timeoday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,16 +16,14 @@ static char *id = "$Id: timeoday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ Copy #include "version.h" - #include #include -gettimeofday(time, ptr) - struct timeval *time; - int ptr; +gettimeofday(time, ptr) struct timeval *time; +int ptr; { - struct rusage stats; - getrusage(RUSAGE_SELF, &stats); - time->tv_sec = stats.ru_utime.tv_sec; - time->tv_usec = stats.ru_utime.tv_usec; + struct rusage stats; + getrusage(RUSAGE_SELF, &stats); + time->tv_sec = stats.ru_utime.tv_sec; + time->tv_usec = stats.ru_utime.tv_usec; } diff --git a/src/timeofday.c b/src/timeofday.c old mode 100755 new mode 100644 index 9fc798a..4b5d7d9 --- a/src/timeofday.c +++ b/src/timeofday.c @@ -1,7 +1,7 @@ -/* $Id: timeofday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: timeofday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: timeofday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,16 +16,14 @@ static char *id = "$Id: timeofday.c,v 1.2 1999/01/03 02:07:37 sybalsky Exp $ Cop #include "version.h" - #include #include -gettimeofday(time, ptr) - struct timeval *time; - int ptr; +gettimeofday(time, ptr) struct timeval *time; +int ptr; { - struct rusage stats; - getrusage(RUSAGE_SELF, &stats); - time->tv_sec = stats.ru_utime.tv_sec; - time->tv_usec = stats.ru_utime.tv_usec; + struct rusage stats; + getrusage(RUSAGE_SELF, &stats); + time->tv_sec = stats.ru_utime.tv_sec; + time->tv_usec = stats.ru_utime.tv_usec; } diff --git a/src/timer.c b/src/timer.c old mode 100755 new mode 100644 index ac1b575..4fbd22f --- a/src/timer.c +++ b/src/timer.c @@ -1,7 +1,6 @@ -/* $Id: timer.c,v 1.5 2001/12/26 22:17:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: timer.c,v 1.5 2001/12/26 22:17:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: timer.c,v 1.5 2001/12/26 22:17:05 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* t i m e r . c */ @@ -11,10 +10,6 @@ static char *id = "$Id: timer.c,v 1.5 2001/12/26 22:17:05 sybalsky Exp $ Copyrig /* */ /************************************************************************/ - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -29,51 +24,49 @@ static char *id = "$Id: timer.c,v 1.5 2001/12/26 22:17:05 sybalsky Exp $ Copyrig #include "version.h" - - #ifdef DOS #include #include -#include /* "#pragma interrupt" & '_chain_intr'*/ -#include /* defines REGS & other structs */ -#include /* define NULL */ +#include /* "#pragma interrupt" & '_chain_intr'*/ +#include /* defines REGS & other structs */ +#include /* define NULL */ #include #define SIGVTALRM SIGUSR1 #define SIGIO SIGREAD /****************************************************************************** * Global variables ******************************************************************************/ -void (*prev_int_1c)(); /* keeps address of previous 1c handlr*/ - /* used for chaining & restore at exit*/ +void (*prev_int_1c)(); /* keeps address of previous 1c handlr*/ + /* used for chaining & restore at exit*/ #pragma interrupt(DOStimer) -void DOStimer(); +void DOStimer(); -unsigned long tick_count = 0; /* approx 18 ticks per sec */ +unsigned long tick_count = 0; /* approx 18 ticks per sec */ #define USETIMEFN #else -#include +#include #endif /* DOS */ -#include -#include -#include -#include +#include +#include +#include +#include #ifdef ISC -#include -#include -#include -#include +#include +#include +#include +#include #define SIGIO SIGPOLL #define USETIMEFN #else #ifndef DOS -#include +#include #endif /* DOS */ #endif /* ISC */ #ifdef SYSVONLY -extern long timezone; /* seconds difference GMT to local */ +extern long timezone; /* seconds difference GMT to local */ #endif #ifdef OS5 @@ -87,51 +80,45 @@ extern int ether_fd; #include #endif -#include +#include #ifdef AIXPS2 -#include +#include #endif /* AIXPS2 */ - /* Apollo and Sun have different ideas about the name of this field */ #ifdef APOLLO #define sv_flags sv_onstack #endif - #ifdef OSF1 - /* This is where FPE_FLTOVF & friends are defined */ +/* This is where FPE_FLTOVF & friends are defined */ #include #endif /* OSF1 */ - - -#include "lispemul.h" -#include "emlglob.h" -#include "lspglob.h" -#include "adr68k.h" -#include "lsptypes.h" -#include "arith.h" -#include "lispmap.h" -#include "stack.h" -#include "dbprint.h" +#include "lispemul.h" +#include "emlglob.h" +#include "lspglob.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "arith.h" +#include "lispmap.h" +#include "stack.h" +#include "dbprint.h" #ifdef XWINDOW #include "devif.h" extern DspInterface currentdsp; #endif /* XWINDOW */ - -#define LISP_UNIX_TIME_DIFF 29969152 -#define LISP_ALTO_TIME_MASK 0x80000000 +#define LISP_UNIX_TIME_DIFF 29969152 +#define LISP_ALTO_TIME_MASK 0x80000000 #ifdef __STDC__ -#define UNIX_ALTO_TIME_DIFF 2177452800U +#define UNIX_ALTO_TIME_DIFF 2177452800U #else -#define UNIX_ALTO_TIME_DIFF 2177452800 +#define UNIX_ALTO_TIME_DIFF 2177452800 #endif /* __STDC__ */ - /* Interlisp time is signed; MIN.FIXP = "01-JAN-01 00:00:00 GMT" * Interlisp 0 is at "19-Jan-69 12:14:08 PST" * Unix begins at " 1-Jan-70 0:00:00 GMT" @@ -143,20 +130,20 @@ extern DspInterface currentdsp; * to get Alto time. */ -int TIMEOUT_TIME; /* For file system timeout */ -char *getenv(); +int TIMEOUT_TIME; /* For file system timeout */ +char *getenv(); #ifdef XWINDOW #define FALSE 0 -#define TRUE !FALSE +#define TRUE !FALSE int Event_Req = FALSE; #endif /* XWINDOW */ +#define ERRCHK(expr, str) \ + if (expr == -1) perror(str) - -#define ERRCHK(expr, str) if (expr == -1) perror(str) - -#define SIGERRCHK(set, str) if (set == SIG_ERR) perror(str) +#define SIGERRCHK(set, str) \ + if (set == SIG_ERR) perror(str) void update_miscstats(); @@ -170,14 +157,11 @@ void update_miscstats(); /* */ /************************************************************************/ -void init_miscstats() - { - MiscStats->starttime = gettime(0); - MiscStats->gctime = 0; - update_miscstats(); - } - - +void init_miscstats() { + MiscStats->starttime = gettime(0); + MiscStats->gctime = 0; + update_miscstats(); +} /************************************************************************/ /* */ @@ -189,61 +173,51 @@ void init_miscstats() /* */ /************************************************************************/ -void update_miscstats() - { +void update_miscstats() { #ifdef DOS - struct dostime_t dtm; /* holds DOS time, so we can get .01 secs */ - _dos_gettime(&dtm); + struct dostime_t dtm; /* holds DOS time, so we can get .01 secs */ + _dos_gettime(&dtm); - MiscStats->totaltime = (time(0)*1000) + (10 * dtm.hsecond); - MiscStats->swapwaittime = 0; - MiscStats->pagefaults = 0; /* can't tell this on ISC */ - MiscStats->swapwrites = 0; - MiscStats->diskiotime = 0; /* ?? not available ?? */ - MiscStats->diskops = 0; - MiscStats->secondstmp = - MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF); + MiscStats->totaltime = (time(0) * 1000) + (10 * dtm.hsecond); + MiscStats->swapwaittime = 0; + MiscStats->pagefaults = 0; /* can't tell this on ISC */ + MiscStats->swapwrites = 0; + MiscStats->diskiotime = 0; /* ?? not available ?? */ + MiscStats->diskops = 0; + MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF); #elif !defined(USETIMEFN) - struct timeval timev; - struct rusage ru; + struct timeval timev; + struct rusage ru; - getrusage(RUSAGE_SELF, &ru); + getrusage(RUSAGE_SELF, &ru); - MiscStats->totaltime = ru.ru_utime.tv_sec * 1000 - + ru.ru_utime.tv_usec /1000; - MiscStats->swapwaittime = ru.ru_stime.tv_sec * 1000 - + ru.ru_stime.tv_usec /1000; - MiscStats->pagefaults = ru.ru_minflt + ru.ru_majflt; - MiscStats->swapwrites = ru.ru_majflt; - MiscStats->diskiotime = 0; /* ?? not available ?? */ - MiscStats->diskops = ru.ru_inblock - /* ?? this doesn't work ??? - + ru.ru_outblock */ - ; - gettimeofday(&timev, NULL); - MiscStats->secondstmp = - MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF); + MiscStats->totaltime = ru.ru_utime.tv_sec * 1000 + ru.ru_utime.tv_usec / 1000; + MiscStats->swapwaittime = ru.ru_stime.tv_sec * 1000 + ru.ru_stime.tv_usec / 1000; + MiscStats->pagefaults = ru.ru_minflt + ru.ru_majflt; + MiscStats->swapwrites = ru.ru_majflt; + MiscStats->diskiotime = 0; /* ?? not available ?? */ + MiscStats->diskops = ru.ru_inblock + /* ?? this doesn't work ??? + + ru.ru_outblock */ + ; + gettimeofday(&timev, NULL); + MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF); #else - struct tms ru; + struct tms ru; - times(&ru); /* Get system time used */ + times(&ru); /* Get system time used */ + + MiscStats->totaltime = + ru.tms_utime * 10 + ru.tms_stime * 10 + ru.tms_cutime * 10 + ru.tms_cstime * 10; + MiscStats->swapwaittime = ru.tms_stime * 10 + ru.tms_cstime * 10; + MiscStats->pagefaults = 0; /* can't tell this on ISC */ + MiscStats->swapwrites = 0; + MiscStats->diskiotime = 0; /* ?? not available ?? */ + MiscStats->diskops = 0; + MiscStats->secondstmp = MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF); - MiscStats->totaltime = ru.tms_utime*10 + ru.tms_stime*10 - + ru.tms_cutime*10 + ru.tms_cstime*10; - MiscStats->swapwaittime = ru.tms_stime*10 - + ru.tms_cstime*10; - MiscStats->pagefaults = 0; /* can't tell this on ISC */ - MiscStats->swapwrites = 0; - MiscStats->diskiotime = 0; /* ?? not available ?? */ - MiscStats->diskops = 0; - MiscStats->secondstmp = - MiscStats->secondsclock = (time(0) + UNIX_ALTO_TIME_DIFF); - #endif /* DOS */ - - } - - +} /************************************************************************/ /* */ @@ -257,24 +231,19 @@ void update_miscstats() /* */ /************************************************************************/ -DLword *createcell68k(); +DLword *createcell68k(); -LispPTR subr_gettime(args) - LispPTR args[]; - { - int result; - result = gettime(args[0] & 0xffff); - if (args[1]) - { - *((int*)Addr68k_from_LADDR(args[1]) ) = result; - return (args[1]); - } - else N_ARITH_SWITCH(result); +LispPTR subr_gettime(args) LispPTR args[]; +{ + int result; + result = gettime(args[0] & 0xffff); + if (args[1]) { + *((int *)Addr68k_from_LADDR(args[1])) = result; + return (args[1]); + } else + N_ARITH_SWITCH(result); } - - - /************************************************************************/ /* */ /* g e t t i m e */ @@ -294,79 +263,72 @@ LispPTR subr_gettime(args) /* */ /************************************************************************/ -int gettime(casep) - int casep; - { +int gettime(casep) int casep; +{ #ifndef USETIMEFN - struct timeval timev; - struct timezone tz; + struct timeval timev; + struct timezone tz; #elif DOS - struct dostime_t dtm; /* for hundredths of secs */ + struct dostime_t dtm; /* for hundredths of secs */ #endif /* USETIMEFN */ - switch (casep) - { - - case 0: /* elapsed time in alto milliseconds */ + switch (casep) { + case 0: /* elapsed time in alto milliseconds */ #ifdef USETIMEFN #ifdef DOS - _dos_gettime(&dtm); - return ((time(0)+UNIX_ALTO_TIME_DIFF)*1000) + (10 * dtm.hsecond); -#else /* DOS */ - return ((time(0)+UNIX_ALTO_TIME_DIFF))*1000; + _dos_gettime(&dtm); + return ((time(0) + UNIX_ALTO_TIME_DIFF) * 1000) + (10 * dtm.hsecond); +#else /* DOS */ + return ((time(0) + UNIX_ALTO_TIME_DIFF)) * 1000; #endif /* DOS */ -#else /* USETIMEFN */ - gettimeofday(&timev, NULL); - return((timev.tv_sec + UNIX_ALTO_TIME_DIFF)*1000 - + timev.tv_usec/1000); +#else /* USETIMEFN */ + gettimeofday(&timev, NULL); + return ((timev.tv_sec + UNIX_ALTO_TIME_DIFF) * 1000 + timev.tv_usec / 1000); #endif /* USETIMEFN */ - case 1: /* starting elapsed time in milliseconds */ - return(MiscStats->starttime); + case 1: /* starting elapsed time in milliseconds */ return (MiscStats->starttime); - case 2: /* run time, this process, in milliseconds */ - update_miscstats(); - return(MiscStats->totaltime); + case 2: /* run time, this process, in milliseconds */ + update_miscstats(); + return (MiscStats->totaltime); - case 3: /* total GC time in milliseconds */ - return(MiscStats->gctime); + case 3: /* total GC time in milliseconds */ return (MiscStats->gctime); - case 4: /* current time of day in Alto format */ + case 4: /* current time of day in Alto format */ #ifdef USETIMEFN - return(time(0) + UNIX_ALTO_TIME_DIFF); + return (time(0) + UNIX_ALTO_TIME_DIFF); #else - gettimeofday(&timev, NULL); - return (timev.tv_sec + UNIX_ALTO_TIME_DIFF); + gettimeofday(&timev, NULL); + return (timev.tv_sec + UNIX_ALTO_TIME_DIFF); #endif - case 5: /* current time of day in Interlisp format */ + case 5: /* current time of day in Interlisp format */ #ifdef USETIMEFN - return(time(0) + LISP_UNIX_TIME_DIFF); + return (time(0) + LISP_UNIX_TIME_DIFF); #else - gettimeofday(&timev, NULL); - return(timev.tv_sec + LISP_UNIX_TIME_DIFF); + gettimeofday(&timev, NULL); + return (timev.tv_sec + LISP_UNIX_TIME_DIFF); #endif - case 6: - return (98); /* this is wrong, only works in PST */ + case 6: + return (98); /* this is wrong, only works in PST */ - case 7: - return (305); /* this is wrong, only works in PST */ + case 7: + return (305); /* this is wrong, only works in PST */ - case 8: + case 8: #ifdef OS5 - return (timezone/3600); /* timezone, extern, is #secs diff GMT to local. */ - + return (timezone / 3600); /* timezone, extern, is #secs diff GMT to local. */ + #elif USETIMEFN - return (timezone/3600); /* timezone, extern, is #secs diff GMT to local. */ + return (timezone / 3600); /* timezone, extern, is #secs diff GMT to local. */ #else - gettimeofday(&timev, &tz); - return (tz.tz_minuteswest/60); /* only integral timezones work */ + gettimeofday(&timev, &tz); + return (tz.tz_minuteswest / 60); /* only integral timezones work */ #endif - default: return (0); - } + default: return (0); } - +} /************************************************************************/ /* */ @@ -380,43 +342,35 @@ int gettime(casep) /* */ /************************************************************************/ -void subr_settime(args) - LispPTR args[]; - { +void subr_settime(args) LispPTR args[]; +{ #ifdef DOS - struct dostime_t dostime; - struct dosdate_t dosday; - struct tm uxtime; + struct dostime_t dostime; + struct dosdate_t dosday; + struct tm uxtime; - uxtime = *localtime((time_t *)(*((int*)Addr68k_from_LADDR(args[0])) - - UNIX_ALTO_TIME_DIFF)); - dostime.hsecond = 0; - dostime.second = uxtime.tm_sec; - dostime.minute = uxtime.tm_min; - dostime.hour = uxtime.tm_hour; - _dos_settime(&dostime); + uxtime = *localtime((time_t *)(*((int *)Addr68k_from_LADDR(args[0])) - UNIX_ALTO_TIME_DIFF)); + dostime.hsecond = 0; + dostime.second = uxtime.tm_sec; + dostime.minute = uxtime.tm_min; + dostime.hour = uxtime.tm_hour; + _dos_settime(&dostime); - dosday.day = uxtime.tm_mday; - dosday.month = uxtime.tm_mon; - dosday.year = uxtime.tm_year; - dosday.dayofweek = uxtime.tm_wday; - _dos_setdate(&dosday); + dosday.day = uxtime.tm_mday; + dosday.month = uxtime.tm_mon; + dosday.year = uxtime.tm_year; + dosday.dayofweek = uxtime.tm_wday; + _dos_setdate(&dosday); #elif defined(SYSVONLY) - time_t newTime = (time_t) (*((int*)Addr68k_from_LADDR(args[0])) - - UNIX_ALTO_TIME_DIFF); - stime(&newTime); + time_t newTime = (time_t)(*((int *)Addr68k_from_LADDR(args[0])) - UNIX_ALTO_TIME_DIFF); + stime(&newTime); #else - struct timeval timev; - timev.tv_sec = *((int*)Addr68k_from_LADDR(args[0])) - - UNIX_ALTO_TIME_DIFF; - settimeofday(&timev, NULL); + struct timeval timev; + timev.tv_sec = *((int *)Addr68k_from_LADDR(args[0])) - UNIX_ALTO_TIME_DIFF; + settimeofday(&timev, NULL); #endif /* DOS */ - } /* end subr_settime */ - - - - +} /* end subr_settime */ /************************************************************************/ /* */ @@ -429,18 +383,15 @@ void subr_settime(args) /* */ /************************************************************************/ -void subr_copytimestats(args) - LispPTR args[]; - { - MISCSTATS *source; - MISCSTATS *dest; - source = (MISCSTATS*) Addr68k_from_LADDR(args[0]); - dest = (MISCSTATS*) Addr68k_from_LADDR(args[1]); - update_miscstats(); - *dest = *source; - } - - +void subr_copytimestats(args) LispPTR args[]; +{ + MISCSTATS *source; + MISCSTATS *dest; + source = (MISCSTATS *)Addr68k_from_LADDR(args[0]); + dest = (MISCSTATS *)Addr68k_from_LADDR(args[1]); + update_miscstats(); + *dest = *source; +} /************************************************************************/ /* */ @@ -452,35 +403,32 @@ void subr_copytimestats(args) /* */ /************************************************************************/ -LispPTR N_OP_rclk(tos) - register LispPTR tos; - { - unsigned int usec; +LispPTR N_OP_rclk(tos) register LispPTR tos; +{ + unsigned int usec; #ifdef DOS - struct dostime_t dtm; + struct dostime_t dtm; #endif /* DOS */ #ifdef USETIMEFN #ifdef DOS - _dos_gettime(&dtm); - usec = (time(0)*1000000) + (10000 * dtm.hsecond); + _dos_gettime(&dtm); + usec = (time(0) * 1000000) + (10000 * dtm.hsecond); #else - usec = time(0)*1000000; + usec = time(0) * 1000000; #endif /* DOS */ #else - struct timeval timev; + struct timeval timev; - gettimeofday(&timev, NULL); - usec = (timev.tv_sec * 1000000) + timev.tv_usec; + gettimeofday(&timev, NULL); + usec = (timev.tv_sec * 1000000) + timev.tv_usec; #endif /* USETIMEFN */ - *((unsigned int *)(Addr68k_from_LADDR(tos))) = usec; - return(tos); - } /* end N_OP_rclk */ - - + *((unsigned int *)(Addr68k_from_LADDR(tos))) = usec; + return (tos); +} /* end N_OP_rclk */ /**********************************************************************/ - /* update_timer called periodically */ +/* update_timer called periodically */ /************************************************************************/ /* */ @@ -493,19 +441,15 @@ LispPTR N_OP_rclk(tos) /* */ /************************************************************************/ -void update_timer() - { +void update_timer() { #ifdef USETIMEFN - MiscStats -> secondstmp = MiscStats->secondsclock - = time(0) + UNIX_ALTO_TIME_DIFF; + MiscStats->secondstmp = MiscStats->secondsclock = time(0) + UNIX_ALTO_TIME_DIFF; #else - struct timeval timev; - gettimeofday(&timev, NIL); - MiscStats->secondstmp = MiscStats->secondsclock - = (timev.tv_sec + UNIX_ALTO_TIME_DIFF); + struct timeval timev; + gettimeofday(&timev, NIL); + MiscStats->secondstmp = MiscStats->secondsclock = (timev.tv_sec + UNIX_ALTO_TIME_DIFF); #endif /* USETIMEFN */ - } - +} /************************************************************************/ /* */ @@ -518,31 +462,30 @@ void update_timer() /* */ /************************************************************************/ - /**********************************************************************/ /* timer interrupt handling system - int_init() should be called before first entering dispatch loop. - int_timer_init() is called by int_init() and arms the timer interrupt. - int_io_init() is called by int_init() and arms the I/O interrupt. - int_timer_service() catches the timer signal and sets - Irq_Stk_Check & Irq_Stk_End to 0 - so the rest of the system will see it and respond. - int_block() and int_unblock() block timer interrupts and release them. - int_io_open(fd) should be called whenever a file that should interrupt - us is opened; it enables the interrupt on that fd. - int_io_close(fd) should be called whenever a file that should interrupt - us is closed; it disables the interrupt on that fd. + int_init() should be called before first entering dispatch loop. + int_timer_init() is called by int_init() and arms the timer interrupt. + int_io_init() is called by int_init() and arms the I/O interrupt. + int_timer_service() catches the timer signal and sets + Irq_Stk_Check & Irq_Stk_End to 0 + so the rest of the system will see it and respond. + int_block() and int_unblock() block timer interrupts and release them. + int_io_open(fd) should be called whenever a file that should interrupt + us is opened; it enables the interrupt on that fd. + int_io_close(fd) should be called whenever a file that should interrupt + us is closed; it disables the interrupt on that fd. */ /* TIMER_INTERVAL usec ~ 20 per second. This should live in some - machine-configuration - file somewhere - it can be changed as the -t parameter to lisp*/ + machine-configuration + file somewhere - it can be changed as the -t parameter to lisp*/ #ifdef sparc -int TIMER_INTERVAL = 100000; +int TIMER_INTERVAL = 100000; #else -int TIMER_INTERVAL = 25000; +int TIMER_INTERVAL = 25000; #endif int FileIOFlag = 0; @@ -564,33 +507,34 @@ extern u_int LispWindowFd; static struct sigvec timerv; #endif /* SYSVSIGNALS */ -#if (defined(OS4) || defined(SYSVONLY)) || defined(MACOSX) ||defined(FREEBSD) +#if (defined(OS4) || defined(SYSVONLY)) || defined(MACOSX) || defined(FREEBSD) void int_timer_service(sig, code, scp) #else int int_timer_service(sig, code, scp) #endif /* OS4 | SYSVONLY | MACOSX | FREEBSD */ -int sig, code; + int sig, + code; struct sigcontext *scp; { -/* this may have to do more in the future, like check for nested interrupts, - etc... */ + /* this may have to do more in the future, like check for nested interrupts, + etc... */ - Irq_Stk_Check = 0; - Irq_Stk_End = 0; - TimerFlag = 1; + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + TimerFlag = 1; #ifdef XWINDOW - Event_Req = TRUE; + Event_Req = TRUE; #endif #ifdef HPTIMERBUG - { -struct itimerval timert, tmpt; - timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; - timert.it_interval.tv_usec = 0; - timert.it_value.tv_usec = TIMER_INTERVAL; - setitimer(ITIMER_VIRTUAL, &timert, 0); - } + { + struct itimerval timert, tmpt; + timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; + timert.it_interval.tv_usec = 0; + timert.it_value.tv_usec = TIMER_INTERVAL; + setitimer(ITIMER_VIRTUAL, &timert, 0); + } #endif /* HPTIMERBUG */ #ifdef SYSVSIGNALS @@ -600,9 +544,6 @@ struct itimerval timert, tmpt; #endif /* SYSVSIGNALS */ } - - - /************************************************************************/ /* */ /* */ @@ -618,61 +559,57 @@ void int_timer_init() { #ifdef DOS -/****************************************************************************** -* All code and data touched during the processing of an interrupt should -* locked prior to receiving any interrupts. This prevents the Timer -* function from being swapped out during an interrupt. -******************************************************************************/ - _dpmi_lockregion((void *)TimerFlag, sizeof(TimerFlag)); - _dpmi_lockregion((void *)Irq_Stk_End, sizeof(Irq_Stk_End)); - _dpmi_lockregion((void *)Irq_Stk_Check, sizeof(Irq_Stk_Check)); - _dpmi_lockregion((void *)tick_count, sizeof(tick_count)); - _dpmi_lockregion((void *)&DOStimer, 4096); - _dpmi_lockregion((void *)prev_int_1c, sizeof(prev_int_1c)); - - /* Set up the DOS time handler. */ - prev_int_1c = _dos_getvect(0x1c); /* get addr of currnt 1c hndlr, */ - /* if any*/ - _dos_setvect(0x1c, DOStimer); /* hook our int handler to timer int */ + /****************************************************************************** + * All code and data touched during the processing of an interrupt should + * locked prior to receiving any interrupts. This prevents the Timer + * function from being swapped out during an interrupt. + ******************************************************************************/ + _dpmi_lockregion((void *)TimerFlag, sizeof(TimerFlag)); + _dpmi_lockregion((void *)Irq_Stk_End, sizeof(Irq_Stk_End)); + _dpmi_lockregion((void *)Irq_Stk_Check, sizeof(Irq_Stk_Check)); + _dpmi_lockregion((void *)tick_count, sizeof(tick_count)); + _dpmi_lockregion((void *)&DOStimer, 4096); + _dpmi_lockregion((void *)prev_int_1c, sizeof(prev_int_1c)); + /* Set up the DOS time handler. */ + prev_int_1c = _dos_getvect(0x1c); /* get addr of currnt 1c hndlr, */ + /* if any*/ + _dos_setvect(0x1c, DOStimer); /* hook our int handler to timer int */ #elif SIGVTALRM -struct itimerval timert, tmpt; + struct itimerval timert, tmpt; #ifdef SYSVSIGNALS - SIGERRCHK(sigset(SIGVTALRM, int_timer_service), "sigset vtalrm"); + SIGERRCHK(sigset(SIGVTALRM, int_timer_service), "sigset vtalrm"); #else -/* first set up the signal handler */ - timerv.sv_handler = int_timer_service; - timerv.sv_mask = timerv.sv_flags = 0; - sigvec(SIGVTALRM, &timerv, 0); + /* first set up the signal handler */ + timerv.sv_handler = int_timer_service; + timerv.sv_mask = timerv.sv_flags = 0; + sigvec(SIGVTALRM, &timerv, 0); #endif /* SYSVSIGNALS */ - /* then attach a timer to it and turn it loose */ #ifdef HPTIMERBUG - /* HPUX on the series 700 trashes the timer if you use */ - /* the auto-reset feature (interval != 0), so have to */ - /* move the reset into the timer handler (above). */ - timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; - timert.it_interval.tv_usec = 0; - timert.it_value.tv_usec = TIMER_INTERVAL; + /* HPUX on the series 700 trashes the timer if you use */ + /* the auto-reset feature (interval != 0), so have to */ + /* move the reset into the timer handler (above). */ + timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; + timert.it_interval.tv_usec = 0; + timert.it_value.tv_usec = TIMER_INTERVAL; #else - timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; - timert.it_interval.tv_usec = timert.it_value.tv_usec = TIMER_INTERVAL; + timert.it_interval.tv_sec = timert.it_value.tv_sec = 0; + timert.it_interval.tv_usec = timert.it_value.tv_usec = TIMER_INTERVAL; #endif /* HPTIMERBUG */ - timerclear(&tmpt.it_value); - timerclear(&tmpt.it_interval); - setitimer(ITIMER_VIRTUAL, &timert, &tmpt); - getitimer(ITIMER_VIRTUAL, &tmpt); + timerclear(&tmpt.it_value); + timerclear(&tmpt.it_interval); + setitimer(ITIMER_VIRTUAL, &timert, &tmpt); + getitimer(ITIMER_VIRTUAL, &tmpt); - DBPRINT(("Timer interval set to %d usec\n", timert.it_value.tv_usec)); + DBPRINT(("Timer interval set to %d usec\n", timert.it_value.tv_usec)); #endif /* DOS or SIGVTALRM */ } - - /************************************************************************/ /* */ /* */ @@ -684,36 +621,31 @@ struct itimerval timert, tmpt; /* */ /************************************************************************/ - -void int_io_open(fd) -int fd; +void int_io_open(fd) int fd; { #ifdef DOS - /* would turn on DOS kbd signal handler here */ +/* would turn on DOS kbd signal handler here */ #elif KBINT - DBPRINT(("int_io_opening %d\n", fd)); - if(fcntl(fd, F_SETOWN, getpid()) == -1 ) { + DBPRINT(("int_io_opening %d\n", fd)); + if (fcntl(fd, F_SETOWN, getpid()) == -1) { #ifdef DEBUG - perror("fcntl F_SETOWN ERROR"); + perror("fcntl F_SETOWN ERROR"); #endif - }; - if(fcntl(fd, F_SETFL, fcntl (fd, F_GETFL, 0) | FASYNC) == -1) - perror("fcntl F_SETFL error"); + }; + if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FASYNC) == -1) perror("fcntl F_SETFL error"); #endif } -void int_io_close(fd) -int fd; +void int_io_close(fd) int fd; { #ifdef DOS - /* Turn off signaller here */ -#elif KBINT - fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~FASYNC); +/* Turn off signaller here */ +#elif KBINT + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~FASYNC); #endif } - /************************************************************************/ /* */ /* i n t _ i o _ i n i t */ @@ -725,58 +657,56 @@ int fd; /* */ /************************************************************************/ -void int_io_init() - { +void int_io_init() { #ifndef SYSVSIGNALS - static struct sigvec timerv; - static struct sigvec poll_timerv; + static struct sigvec timerv; + static struct sigvec poll_timerv; #endif /* SYSVSIGNALS */ - extern void getsignaldata(); + extern void getsignaldata(); - /* first set up the signal handler */ +/* first set up the signal handler */ #ifndef SYSVSIGNALS #ifdef KBINT - timerv.sv_handler = getsignaldata; - timerv.sv_mask = timerv.sv_flags = 0; - sigvec(SIGIO, &timerv, 0); - - DBPRINT(("I/O interrupts enabled\n")); + timerv.sv_handler = getsignaldata; + timerv.sv_mask = timerv.sv_flags = 0; + sigvec(SIGIO, &timerv, 0); + + DBPRINT(("I/O interrupts enabled\n")); #endif /* KBINT */ -#else /* SYSVSIGNALS in effect... */ +#else /* SYSVSIGNALS in effect... */ #ifdef ISC - { - int res = sigset(SIGIO, getsignaldata); - if (res==SIG_ERR) perror("sigset for I/O polling"); - if (ioctl(ConnectionNumber(currentdsp->display_id), I_SETSIG, S_INPUT) < 0) perror("ioctl on X fd - SETSIG"); - } + { + int res = sigset(SIGIO, getsignaldata); + if (res == SIG_ERR) perror("sigset for I/O polling"); + if (ioctl(ConnectionNumber(currentdsp->display_id), I_SETSIG, S_INPUT) < 0) + perror("ioctl on X fd - SETSIG"); + } #else #ifndef DOS - SIGERRCHK(sigset(SIGIO, getsignaldata), "sigset io"); + SIGERRCHK(sigset(SIGIO, getsignaldata), "sigset io"); #ifdef XWINDOW - if (ioctl(ConnectionNumber(currentdsp->display_id) , I_SETSIG, S_INPUT) < 0) perror("ioctl on X fd - SETSIG"); + if (ioctl(ConnectionNumber(currentdsp->display_id), I_SETSIG, S_INPUT) < 0) + perror("ioctl on X fd - SETSIG"); #endif /* XWINDOW */ #ifdef USE_DLPI - DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); - if (ether_fd > 0) if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) - { - perror("init_ether: I_SETSIG failed:\n"); - close(ether_fd); - ether_fd = -1; - return; - } + DBPRINT(("INIT ETHER: Doing I_SETSIG.\n")); + if (ether_fd > 0) + if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) { + perror("init_ether: I_SETSIG failed:\n"); + close(ether_fd); + ether_fd = -1; + return; + } #endif /* USE_DLPI */ #endif /* DOS */ #endif /* ISC */ #endif /* SYSVSIGNALS */ - - } int oldmask = 0; - /************************************************************************/ /* */ /* i n t _ b l o c k */ @@ -788,37 +718,34 @@ int oldmask = 0; /* */ /************************************************************************/ -void int_block() -{ +void int_block() { /* temporarily turn off interrupts */ #ifdef DOS _dos_setvect(0x1c, prev_int_1c); #else /* DOS */ #ifdef SYSVSIGNALS #ifdef SIGVTALRM - sighold(SIGVTALRM); + sighold(SIGVTALRM); #endif /* SIGVTALRM */ - sighold(SIGIO); - sighold(SIGALRM); + sighold(SIGIO); + sighold(SIGALRM); #ifdef SIGXFSZ - sighold(SIGXFSZ); + sighold(SIGXFSZ); #endif /* SIGXFSZ */ #else - oldmask= sigblock(sigmask(SIGVTALRM) | sigmask(SIGIO) - | sigmask(SIGALRM) + oldmask = sigblock(sigmask(SIGVTALRM) | sigmask(SIGIO) | sigmask(SIGALRM) #ifndef HPUX - | sigmask(SIGXFSZ) + | sigmask(SIGXFSZ) #endif /* HPUX */ #ifdef FLTINT - | sigmask(SIGFPE) + | sigmask(SIGFPE) #endif -); + ); #endif /* SYSVSIGNALS */ #endif /* DOS */ } - /************************************************************************/ /* */ /* */ @@ -830,29 +757,27 @@ void int_block() /* */ /************************************************************************/ -void int_unblock() -{ +void int_unblock() { #ifdef DOS - _dos_setvect(0x1c, DOStimer); + _dos_setvect(0x1c, DOStimer); #else /* DOS */ #ifdef SYSVSIGNALS #ifdef SIGVTALRM - ERRCHK(sigrelse(SIGVTALRM), "sigrelse vtalrm"); + ERRCHK(sigrelse(SIGVTALRM), "sigrelse vtalrm"); #endif /* SIGVTALRM */ - ERRCHK(sigrelse(SIGIO), "sigrelse io"); - ERRCHK(sigrelse(SIGALRM), "sigrelse alrm"); + ERRCHK(sigrelse(SIGIO), "sigrelse io"); + ERRCHK(sigrelse(SIGALRM), "sigrelse alrm"); #ifdef SIGXFSZ - ERRCHK(sigrelse(SIGXFSZ), "sigrelse XFSZ"); -#endif /* SIGXFSZ */ + ERRCHK(sigrelse(SIGXFSZ), "sigrelse XFSZ"); +#endif /* SIGXFSZ */ #else - sigsetmask(oldmask); + sigsetmask(oldmask); #endif /* SYSVSIGNALS */ #endif /* DOS */ } -void int_timer_on () {int_unblock();} -void int_timer_off() {int_block ();} - +void int_timer_on() { int_unblock(); } +void int_timer_off() { int_block(); } /************************************************************************/ /* */ @@ -865,40 +790,34 @@ void int_timer_off() {int_block ();} /* */ /************************************************************************/ - #ifdef NEVER -void int_timer_off() -{ +void int_timer_off() { #ifdef SYSVSIGNALS #ifndef ISC -sigignore(SIGVTALRM); + sigignore(SIGVTALRM); #endif /* ISC */ #else -struct sigvec tmpv, timeroffv; + struct sigvec tmpv, timeroffv; -timeroffv.sv_handler = SIG_IGN; -timeroffv.sv_mask = timeroffv.sv_flags = 0; -sigvec(SIGVTALRM, &timeroffv, &tmpv); + timeroffv.sv_handler = SIG_IGN; + timeroffv.sv_mask = timeroffv.sv_flags = 0; + sigvec(SIGVTALRM, &timeroffv, &tmpv); #endif /* SYSVSIGNALS */ - } -void int_timer_on() -{ +void int_timer_on() { #ifdef SYSVSIGNALS #ifdef SIGVTALRM - SIGERRCHK(sigset(SIGVTALRM, int_timer_service), "sigset vtalrm"); + SIGERRCHK(sigset(SIGVTALRM, int_timer_service), "sigset vtalrm"); #endif /* SIGVTALRM */ #else -struct sigvec tmpv; + struct sigvec tmpv; -sigvec(SIGVTALRM, &timerv, &tmpv); + sigvec(SIGVTALRM, &timerv, &tmpv); #endif /* SYSVSIGNALS */ - - } #endif /* NEVER */ @@ -918,79 +837,68 @@ sigvec(SIGVTALRM, &timerv, &tmpv); /* The global used to signal floating-point errors */ int FP_error = 0; -void int_fp_service(sig, code, scp) - int sig, code; - struct sigcontext *scp; - { - switch(code) - { +void int_fp_service(sig, code, scp) int sig, code; +struct sigcontext *scp; +{ + switch (code) { #ifdef AIXPS2 - case FPM_DENORM: - case FPM_DIVIDE_0: - case FPM_UNDERFLOW: - case FPM_OVERFLOW: - case FPM_PRECISION: + case FPM_DENORM: + case FPM_DIVIDE_0: + case FPM_UNDERFLOW: + case FPM_OVERFLOW: + case FPM_PRECISION: #elif OSF1 - case FPE_FLTDIV: - case FPE_FLTOVF: - case FPE_FLTUND: - case FPE_FLTRES: - case FPE_FLTINV: - case FPE_FLTSUB: + case FPE_FLTDIV: + case FPE_FLTOVF: + case FPE_FLTUND: + case FPE_FLTRES: + case FPE_FLTINV: + case FPE_FLTSUB: #else #ifndef ISC - case FPE_FLTDIV_TRAP: - case FPE_FLTUND_TRAP: - case FPE_FLTOVF_TRAP: - case FPE_FLTOPERR_TRAP: + case FPE_FLTDIV_TRAP: + case FPE_FLTUND_TRAP: + case FPE_FLTOVF_TRAP: + case FPE_FLTOPERR_TRAP: #endif /* ISC */ #endif /* AIXPS2 */ - FP_error = code; - break; - default: - { + FP_error = code; + break; + default: { #ifdef DEBUG - char stuff[100]; - sprintf(stuff, "Unexpected FP error signal code: %d", code); - perror(stuff); + char stuff[100]; + sprintf(stuff, "Unexpected FP error signal code: %d", code); + perror(stuff); #else - FP_error = code; + FP_error = code; #endif - } - } -#ifdef SYSVSIGNALS - sigset(SIGFPE, int_fp_service); -#endif /* SYSVSIGNALS */ + } } +#ifdef SYSVSIGNALS + sigset(SIGFPE, int_fp_service); +#endif /* SYSVSIGNALS */ +} - - -int_fp_init() - { /* first set up the signal handler */ +int_fp_init() { /* first set up the signal handler */ #ifndef ISC #ifdef AIXPS2 - if(sigset(SIGFPE, int_fp_service)) + if (sigset(SIGFPE, int_fp_service)) #elif OS5 - if(sigset(SIGFPE, int_fp_service)) + if (sigset(SIGFPE, int_fp_service)) #elif OSF1 - if(SIG_ERR == sigset(SIGFPE, int_fp_service)) + if (SIG_ERR == sigset(SIGFPE, int_fp_service)) #else - if(ieee_handler("set", "all", int_fp_service)) + if (ieee_handler("set", "all", int_fp_service)) #endif /* AIXPS2 */ - perror("Sigvec for FPE failed"); - DBPRINT(("FP interrupts enabled\n")); + perror("Sigvec for FPE failed"); + DBPRINT(("FP interrupts enabled\n")); #endif /* ISC */ - - } +} #endif /* FLTINT */ - - - - /************************************************************************/ /* */ /* t i m e o u t _ e r r o r */ @@ -1002,24 +910,21 @@ int_fp_init() /* */ /************************************************************************/ -jmp_buf jmpbuf; -void timeout_error() - { - /* - * Following printf changes the contents of jmpbuf! - * This would lead to horrible segmentation violation. - */ +jmp_buf jmpbuf; +void timeout_error() { +/* + * Following printf changes the contents of jmpbuf! + * This would lead to horrible segmentation violation. + */ /* printf("File access timed out.\n"); */ #ifdef SYSVSIGNALS #ifdef SIGALRM - sigset(SIGALRM, timeout_error); + sigset(SIGALRM, timeout_error); #endif #endif /* SYSVSIGNALS */ - longjmp(jmpbuf, 1); - } - - + longjmp(jmpbuf, 1); +} /************************************************************************/ /* */ @@ -1032,45 +937,40 @@ void timeout_error() /* */ /************************************************************************/ -void int_file_init() - { +void int_file_init() { #ifndef SYSVSIGNALS - static struct sigvec timerv; + static struct sigvec timerv; #endif /* SYSVSIGNALS */ - char *envtime; - int timeout_time; + char *envtime; + int timeout_time; - /* first set up the signal handler */ +/* first set up the signal handler */ #ifndef SYSVSIGNALS - timerv.sv_handler = timeout_error; - timerv.sv_mask = timerv.sv_flags = 0; - sigvec(SIGALRM, &timerv, 0); + timerv.sv_handler = timeout_error; + timerv.sv_mask = timerv.sv_flags = 0; + sigvec(SIGALRM, &timerv, 0); #else #ifdef SIGALRM #ifdef ISC - sigset(SIGALRM, timeout_error); + sigset(SIGALRM, timeout_error); #else - sigset(SIGALRM, timeout_error); + sigset(SIGALRM, timeout_error); #endif /* ISC */ #endif /* SIGALRM */ #endif /* SYSVSIGNALS */ - - /* Set Timeout period */ - if((envtime = getenv("LDEFILETIMEOUT")) == NULL) - { - TIMEOUT_TIME = 10; - } + /* Set Timeout period */ + if ((envtime = getenv("LDEFILETIMEOUT")) == NULL) { + TIMEOUT_TIME = 10; + } else { + if ((timeout_time = atoi(envtime)) > 0) + TIMEOUT_TIME = timeout_time; else - { - if( (timeout_time = atoi(envtime)) > 0) TIMEOUT_TIME = timeout_time; - else TIMEOUT_TIME = 10; - } - DBPRINT(("File timeout interrupts enabled\n")); + TIMEOUT_TIME = 10; } - - + DBPRINT(("File timeout interrupts enabled\n")); +} /************************************************************************/ /* */ @@ -1083,66 +983,55 @@ void int_file_init() /* */ /************************************************************************/ -void panicuraid(sig, code, scp, addr) - int sig, code; - struct sigcontext *scp; - { - static char errormsg[200]; - static char *stdmsg = -"Please record the signal and code information\n\ +void panicuraid(sig, code, scp, addr) int sig, code; +struct sigcontext *scp; +{ + static char errormsg[200]; + static char *stdmsg = + "Please record the signal and code information\n\ and do a 'v' before trying anything else."; - int i; + int i; - for (i=0; i<200; i++) errormsg[i]=0; + for (i = 0; i < 200; i++) errormsg[i] = 0; - switch (sig) - { + switch (sig) { #ifdef SIGBUS - case SIGBUS: sprintf(errormsg, - "BUS error (code %d) at address 0x%x.\n%s", - code, addr, stdmsg); - break; -#endif /* SIGBUS */ - case SIGSEGV: sprintf(errormsg, - "SEGV error (code %d) at address 0x%x.\n%s", - code, addr, stdmsg); - break; - case SIGILL: sprintf(errormsg, - "Illegal instruction (code %d) at address 0x%x.\n%s", - code, addr, stdmsg); - break; + case SIGBUS: + sprintf(errormsg, "BUS error (code %d) at address 0x%x.\n%s", code, addr, stdmsg); + break; +#endif /* SIGBUS */ + case SIGSEGV: + sprintf(errormsg, "SEGV error (code %d) at address 0x%x.\n%s", code, addr, stdmsg); + break; + case SIGILL: + sprintf(errormsg, "Illegal instruction (code %d) at address 0x%x.\n%s", code, addr, stdmsg); + break; #ifdef SIGPIPE - case SIGPIPE: sprintf(errormsg, - "Broken PIPE (code %d) at address 0x%x.\n%s", - code, addr, stdmsg); - break; + case SIGPIPE: + sprintf(errormsg, "Broken PIPE (code %d) at address 0x%x.\n%s", code, addr, stdmsg); + break; #endif /* SGPIPE */ #ifdef SIGHUP - case SIGHUP: sprintf(errormsg, - "HANGUP signalled (code %d) at address 0x%x.\n%s", - code, addr, stdmsg); - /* Assume that a user tried to exit UNIX shell */ + case SIGHUP: + sprintf(errormsg, "HANGUP signalled (code %d) at address 0x%x.\n%s", code, addr, stdmsg); +/* Assume that a user tried to exit UNIX shell */ #ifdef SYSVONLY - kill(0, SIGKILL); exit(0); + kill(0, SIGKILL); + exit(0); #else - killpg(getpgrp(0), SIGKILL);exit(0); + killpg(getpgrp(0), SIGKILL); + exit(0); #endif /* SYSVONLY */ - break; + break; #endif /* SIGHUP */ - case SIGFPE: sprintf(errormsg, - "FP error (code %d) at address 0x%x.\n%s", - code, addr, stdmsg); - break; - default: sprintf(errormsg, "Uncaught SIGNAL %d (code %d).\n%s", - sig, code, stdmsg); - } - - error(errormsg); - + case SIGFPE: + sprintf(errormsg, "FP error (code %d) at address 0x%x.\n%s", code, addr, stdmsg); + break; + default: sprintf(errormsg, "Uncaught SIGNAL %d (code %d).\n%s", sig, code, stdmsg); } - - + error(errormsg); +} /************************************************************************/ /* */ @@ -1154,93 +1043,89 @@ and do a 'v' before trying anything else."; /* uraid and get a clue about why you're dying. */ /* */ /************************************************************************/ -void int_panic_init() - { +void int_panic_init() { #ifdef SYSVSIGNALS #ifdef ISC - sigset(SIGHUP, panicuraid); - sigset(SIGQUIT, panicuraid); - sigset(SIGILL, panicuraid); + sigset(SIGHUP, panicuraid); + sigset(SIGQUIT, panicuraid); + sigset(SIGILL, panicuraid); #ifdef SIGEMT - sigset(SIGEMT, panicuraid); + sigset(SIGEMT, panicuraid); #endif - sigset(SIGBUS, panicuraid); - sigset(SIGSEGV, panicuraid); + sigset(SIGBUS, panicuraid); + sigset(SIGSEGV, panicuraid); #ifdef SIGSYS - sigset(SIGSYS, panicuraid); + sigset(SIGSYS, panicuraid); #endif - sigset(SIGTERM, panicuraid); + sigset(SIGTERM, panicuraid); #elif DOS -#else - sigset(SIGHUP, panicuraid); - sigset(SIGQUIT, panicuraid); - sigset(SIGILL, panicuraid); +#else + sigset(SIGHUP, panicuraid); + sigset(SIGQUIT, panicuraid); + sigset(SIGILL, panicuraid); #ifdef SIGEMT - sigset(SIGEMT, panicuraid); + sigset(SIGEMT, panicuraid); #endif - sigset(SIGBUS, panicuraid); - sigset(SIGSEGV, panicuraid); + sigset(SIGBUS, panicuraid); + sigset(SIGSEGV, panicuraid); #ifdef SIGSYS - sigset(SIGSYS, panicuraid); + sigset(SIGSYS, panicuraid); #endif - sigset(SIGTERM, panicuraid); + sigset(SIGTERM, panicuraid); #ifndef FLTINT #ifdef OSF1 - sigignore(SIGFPE); + sigignore(SIGFPE); #endif /* OSF1 */ #endif /* FLTINT */ #endif #else - static struct sigvec panicv; - static struct sigvec ignorev; + static struct sigvec panicv; + static struct sigvec ignorev; - /* first set up the signal handlers: */ + /* first set up the signal handlers: */ - panicv.sv_handler = panicuraid; - panicv.sv_mask = panicv.sv_flags = 0; - ignorev.sv_handler = SIG_IGN; - ignorev.sv_mask = ignorev.sv_flags = 0; + panicv.sv_handler = panicuraid; + panicv.sv_mask = panicv.sv_flags = 0; + ignorev.sv_handler = SIG_IGN; + ignorev.sv_mask = ignorev.sv_flags = 0; - /* Now arrange for signals to be handled properly: */ + /* Now arrange for signals to be handled properly: */ - sigvec(SIGHUP, &panicv, 0); -/* sigvec(SIGINT, &panicv, 0); */ - sigvec(SIGQUIT, &panicv, 0); - sigvec(SIGILL, &panicv, 0); + sigvec(SIGHUP, &panicv, 0); + /* sigvec(SIGINT, &panicv, 0); */ + sigvec(SIGQUIT, &panicv, 0); + sigvec(SIGILL, &panicv, 0); /* sigvec(SIGTRAP, &panicv, 0); */ #ifdef OS4 - sigvec(SIGABRT, &panicv, 0); + sigvec(SIGABRT, &panicv, 0); #endif /* OS4 */ #ifdef SIGEMT - sigvec(SIGEMT, &panicv, 0); + sigvec(SIGEMT, &panicv, 0); #endif - sigvec(SIGBUS, &panicv, 0); - sigvec(SIGSEGV, &panicv, 0); + sigvec(SIGBUS, &panicv, 0); + sigvec(SIGSEGV, &panicv, 0); #ifdef SIGSYS - sigvec(SIGSYS, &panicv, 0); + sigvec(SIGSYS, &panicv, 0); #endif -/* sigvec(SIGPIPE, &panicv, 0); Caused trouble with TCP; now ignored: */ - sigvec(SIGPIPE, &ignorev, 0); - sigvec(SIGTERM, &panicv, 0); + /* sigvec(SIGPIPE, &panicv, 0); Caused trouble with TCP; now ignored: */ + sigvec(SIGPIPE, &ignorev, 0); + sigvec(SIGTERM, &panicv, 0); #ifdef OS4 - sigvec(SIGXCPU, &panicv, 0); - sigvec(SIGLOST, &panicv, 0); + sigvec(SIGXCPU, &panicv, 0); + sigvec(SIGLOST, &panicv, 0); #endif /* OS4 */ - sigvec(SIGUSR1, &panicv, 0); - sigvec(SIGUSR2, &panicv, 0); + sigvec(SIGUSR1, &panicv, 0); + sigvec(SIGUSR2, &panicv, 0); #ifndef FLTINT #ifdef OSF1 - sigignore(SIGFPE); + sigignore(SIGFPE); #endif /* OSF1 */ #endif #endif /* SYSVSIGNALS */ - - DBPRINT(("Panic interrupts enabled\n")); - } - - + DBPRINT(("Panic interrupts enabled\n")); +} /************************************************************************/ /* */ @@ -1250,22 +1135,21 @@ void int_panic_init() /* */ /************************************************************************/ -void int_init() - { - int_timer_init(); /* periodic interrupt timer */ - int_io_init(); /* SIGIO and SIGPOLL async I/O handlers */ - int_file_init(); /* file-io TIMEOUT support */ - /* int_panic_init(); /* catch for all other dangerous interrupts */ +void int_init() { + int_timer_init(); /* periodic interrupt timer */ + int_io_init(); /* SIGIO and SIGPOLL async I/O handlers */ + int_file_init(); /* file-io TIMEOUT support */ + /* int_panic_init(); /* catch for all other dangerous interrupts */ #ifdef FLTINT - int_fp_init(); /* Floating-point exception handler */ + int_fp_init(); /* Floating-point exception handler */ #else #ifdef OSF1 - sigignore(SIGFPE); + sigignore(SIGFPE); #endif #endif - int_unblock(); /* Turn on interrupts */ + int_unblock(); /* Turn on interrupts */ } #ifdef DOS @@ -1286,27 +1170,24 @@ void int_init() * Note that as little as possible should be done within a timer interrupt, * since further clock ticks are disabled until the interrupt returns. ******************************************************************************/ -void DOStimer() -{ - /* if (--tick_count == 0) { */ - Irq_Stk_Check = 0; - Irq_Stk_End = 0; - TimerFlag = 1; - /* _dos_setvect(0x1c, prev_int_1c); - } else if (tick_count <= 0) { */ - /* I'm dead, uninstal me */ - /* _dos_setvect(0x1c, prev_int_1c); - tick_count = 0; - } */ - _chain_intr(prev_int_1c); /* call previous int 1c handlr, if any*/ +void DOStimer() { + /* if (--tick_count == 0) { */ + Irq_Stk_Check = 0; + Irq_Stk_End = 0; + TimerFlag = 1; + /* _dos_setvect(0x1c, prev_int_1c); + } else if (tick_count <= 0) { */ + /* I'm dead, uninstal me */ + /* _dos_setvect(0x1c, prev_int_1c); + tick_count = 0; + } */ + _chain_intr(prev_int_1c); /* call previous int 1c handlr, if any*/ /* (pts to 'ret' if no prev installed)*/ } -void alarm( sec ) - unsigned long sec; +void alarm(sec) unsigned long sec; { /* tick_count = sec * 18; _dos_setvect(0x1c, DOStimer); */ } #endif /* DOS */ - diff --git a/src/truecolor.c b/src/truecolor.c old mode 100755 new mode 100644 index 171452a..4a35d9a --- a/src/truecolor.c +++ b/src/truecolor.c @@ -1,8 +1,7 @@ -/* $Id: truecolor.c,v 1.2 1999/01/03 02:07:38 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: truecolor.c,v 1.2 1999/01/03 02:07:38 sybalsky Exp $ (C) Copyright Venue, All Rights + * Reserved */ static char *id = "$Id: truecolor.c,v 1.2 1999/01/03 02:07:38 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,7 +16,6 @@ static char *id = "$Id: truecolor.c,v 1.2 1999/01/03 02:07:38 sybalsky Exp $ Cop #include "version.h" - #include #include #include @@ -33,352 +31,290 @@ static char *id = "$Id: truecolor.c,v 1.2 1999/01/03 02:07:38 sybalsky Exp $ Cop #include "picture.h" #define FALSE 0 -#define TRUE !FALSE +#define TRUE !FALSE -#define COLOR_INIT 0 -#define COLOR_OVERLAYREGION 1 -#define COLOR_VIDEOREGION 2 -#define COLOR_VIDEOINIT 3 +#define COLOR_INIT 0 +#define COLOR_OVERLAYREGION 1 +#define COLOR_VIDEOREGION 2 +#define COLOR_VIDEOINIT 3 -#define IntToFixp(C, Lisp) { \ - int *base; \ - base = (int *) Addr68k_from_LADDR((unsigned int)Lisp); \ - *base = C; \ -} +#define IntToFixp(C, Lisp) \ + { \ + int *base; \ + base = (int *)Addr68k_from_LADDR((unsigned int)Lisp); \ + *base = C; \ + } - -extern int displaywidth - , displayheight - , DisplayRasterWidth; +extern int displaywidth, displayheight, DisplayRasterWidth; extern int ScreenLocked; -extern DLword *EmCursorX68K - , *EmCursorY68K; +extern DLword *EmCursorX68K, *EmCursorY68K; extern Pixrect *TrueColorFb; extern int FrameBufferFd; extern int Inited_Video; int Inited_TrueColor = NIL; -int -TrueColor_Op( args ) -LispPTR *args; +int TrueColor_Op(args) LispPTR *args; { - int op - , ret_value = NIL; -/* - N_GETNUMBER( args[0], op, bad_arg ); -*/ - op = (DLword) args[0]; + int op, ret_value = NIL; + /* + N_GETNUMBER( args[0], op, bad_arg ); + */ + op = (DLword)args[0]; - switch( op ) { - case COLOR_INIT: - ret_value = TrueColor_Initialize( args[1] ); - break; - case COLOR_VIDEOINIT: - ret_value = TrueColor_VideoInitialize( args[1] ); - break; - case COLOR_OVERLAYREGION: { - int left - , top - , bottom - , width - , height; - if( args[1] != NIL_PTR ) { - LispPTR region - , value; - int bottom; - /* get lisp region elements */ - region = args[1]; - value = car( region ); - N_GETNUMBER( value, left, bad_arg ); - region = cdr( region ); - value = car( region ); - N_GETNUMBER( value, bottom, bad_arg ); - region = cdr( region ); - value = car( region ); - N_GETNUMBER( value, width, bad_arg ); - region = cdr( region ); - value = car( region ); - N_GETNUMBER( value, height, bad_arg ); - top = displayheight - ( bottom + height ); - if( args[2] == ATOM_T ) { - Overlay_Region( left, top, width, height, TRUE ); - } else { - Overlay_Region( left, top, width, height, FALSE ); - } /* end if( args[2] ) */ - ret_value = T; - } /* end if( arg[1] ) */ - } /* end case */ - break; - case COLOR_VIDEOREGION: { - int left - , top - , bottom - , width - , height; - if( args[1] != NIL_PTR ) { - LispPTR region - , value; - int bottom; - /* get lisp region elements */ - region = args[1]; - value = car( region ); - N_GETNUMBER( value, left, bad_arg ); - region = cdr( region ); - value = car( region ); - N_GETNUMBER( value, bottom, bad_arg ); - region = cdr( region ); - value = car( region ); - N_GETNUMBER( value, width, bad_arg ); - region = cdr( region ); - value = car( region ); - N_GETNUMBER( value, height, bad_arg ); - top = displayheight - ( bottom + height ); - } else { - left = 0; - top = 0; - width = displaywidth; - height = displayheight; - } /* end if( arg[1] ) */ + switch (op) { + case COLOR_INIT: ret_value = TrueColor_Initialize(args[1]); break; + case COLOR_VIDEOINIT: ret_value = TrueColor_VideoInitialize(args[1]); break; + case COLOR_OVERLAYREGION: { + int left, top, bottom, width, height; + if (args[1] != NIL_PTR) { + LispPTR region, value; + int bottom; + /* get lisp region elements */ + region = args[1]; + value = car(region); + N_GETNUMBER(value, left, bad_arg); + region = cdr(region); + value = car(region); + N_GETNUMBER(value, bottom, bad_arg); + region = cdr(region); + value = car(region); + N_GETNUMBER(value, width, bad_arg); + region = cdr(region); + value = car(region); + N_GETNUMBER(value, height, bad_arg); + top = displayheight - (bottom + height); + if (args[2] == ATOM_T) { + Overlay_Region(left, top, width, height, TRUE); + } else { + Overlay_Region(left, top, width, height, FALSE); + } /* end if( args[2] ) */ + ret_value = T; + } /* end if( arg[1] ) */ + } /* end case */ + break; + case COLOR_VIDEOREGION: { + int left, top, bottom, width, height; + if (args[1] != NIL_PTR) { + LispPTR region, value; + int bottom; + /* get lisp region elements */ + region = args[1]; + value = car(region); + N_GETNUMBER(value, left, bad_arg); + region = cdr(region); + value = car(region); + N_GETNUMBER(value, bottom, bad_arg); + region = cdr(region); + value = car(region); + N_GETNUMBER(value, width, bad_arg); + region = cdr(region); + value = car(region); + N_GETNUMBER(value, height, bad_arg); + top = displayheight - (bottom + height); + } else { + left = 0; + top = 0; + width = displaywidth; + height = displayheight; + } /* end if( arg[1] ) */ - if( args[2] == NIL_PTR ) { /* video region clear */ - cgeight_video_region( left, top, width, height, FALSE ); - } else { /* video region set */ - cgeight_video_region( left, top, width, height, TRUE ); - } /* end if( args[2] ) */ - ret_value = T; - } /* end case */ - break; - defaults: - break; - } /* end switch( op ) */ + if (args[2] == NIL_PTR) { /* video region clear */ + cgeight_video_region(left, top, width, height, FALSE); + } else { /* video region set */ + cgeight_video_region(left, top, width, height, TRUE); + } /* end if( args[2] ) */ + ret_value = T; + } /* end case */ + break; + defaults: + break; + } /* end switch( op ) */ bad_arg: - return( ret_value ); - + return (ret_value); + } /* end TrueColor_Op */ extern int Inited_Color; extern int DisplayType; -Pixrect *OverlayCursor - , *OverlaySave; +Pixrect *OverlayCursor, *OverlaySave; DLword *OverlayRegion68k; -int -TrueColor_Initialize( overlay_bmbase ) -LispPTR overlay_bmbase; +int TrueColor_Initialize(overlay_bmbase) LispPTR overlay_bmbase; { - unsigned int pict - , *ret_value; - Pixrect *source; - int mmapstat - , size; - + unsigned int pict, *ret_value; + Pixrect *source; + int mmapstat, size; - if( Inited_Color ) { - printf( "cgeight_init_color_display: 8 bits color display has already initialized.\n" ); - } /* end if( Inited_Color ) */ + if (Inited_Color) { + printf("cgeight_init_color_display: 8 bits color display has already initialized.\n"); + } /* end if( Inited_Color ) */ - if( Inited_TrueColor ) { - printf( "cgeight_init_color_display: 24 bits color display has already initialized.\n"); - } /* end if( Inited_TrueColor ) */ + if (Inited_TrueColor) { + printf("cgeight_init_color_display: 24 bits color display has already initialized.\n"); + } /* end if( Inited_TrueColor ) */ - if( DisplayType != SUNMEMCOLOR ) { - error( "cgeight_init_color_display: Unsupported FBreal_type %d\n", - DisplayType ); - } /* end if( DisplayType ) */ + if (DisplayType != SUNMEMCOLOR) { + error("cgeight_init_color_display: Unsupported FBreal_type %d\n", DisplayType); + } /* end if( DisplayType ) */ - OverlayRegion68k = Addr68k_from_LADDR( overlay_bmbase ); - size = ( (displaywidth * displayheight/8 + (getpagesize()-1) ) - & -getpagesize() ); + OverlayRegion68k = Addr68k_from_LADDR(overlay_bmbase); + size = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); - ScreenLocked = T; - taking_mouse_down(); + ScreenLocked = T; + taking_mouse_down(); - pict = (unsigned int)cgeight_init_color_display(); + pict = (unsigned int)cgeight_init_color_display(); - source = mem_point( displaywidth, displayheight, 1 - , OverlayRegion68k ); - pr_set_plane_group( TrueColorFb, PIXPG_OVERLAY_ENABLE ); - pr_rop( TrueColorFb, 0, 0, displaywidth, displayheight - , PIX_SRC, source, 0, 0 ); - pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + source = mem_point(displaywidth, displayheight, 1, OverlayRegion68k); + pr_set_plane_group(TrueColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(TrueColorFb, 0, 0, displaywidth, displayheight, PIX_SRC, source, 0, 0); + pr_set_plane_group(TrueColorFb, PIXPG_24BIT_COLOR); - mmapstat = (int)mmap( OverlayRegion68k, - size, - PROT_READ | PROT_WRITE, + mmapstat = (int)mmap(OverlayRegion68k, size, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif - MAP_SHARED, - FrameBufferFd, 0x20000 ); + MAP_SHARED, + FrameBufferFd, 0x20000); - if( mmapstat == -1 ) { - perror( "TrueColor_Initialize: ERROR at mmap system call\n" ); - exit( 0 ); - } /* end if( mmapstat ) */ + if (mmapstat == -1) { + perror("TrueColor_Initialize: ERROR at mmap system call\n"); + exit(0); + } /* end if( mmapstat ) */ - OverlayCursor = mem_create( 16, 16, 32 ); - OverlaySave = mem_create( 16, 16, 32 ); - - Inited_TrueColor = TRUE; + OverlayCursor = mem_create(16, 16, 32); + OverlaySave = mem_create(16, 16, 32); - taking_mouse_up( *EmCursorX68K, *EmCursorY68K ); - overlay_mouse_up( *EmCursorX68K, *EmCursorY68K ); - ScreenLocked = NIL; + Inited_TrueColor = TRUE; - ret_value = (unsigned int*)createcell68k(TYPE_FIXP); - *ret_value = pict; - return( LADDR_from_68k(ret_value) ); + taking_mouse_up(*EmCursorX68K, *EmCursorY68K); + overlay_mouse_up(*EmCursorX68K, *EmCursorY68K); + ScreenLocked = NIL; + + ret_value = (unsigned int *)createcell68k(TYPE_FIXP); + *ret_value = pict; + return (LADDR_from_68k(ret_value)); } /* end TrueColor_Initialize */ DLword *VideoEnableRegion68k; -int -TrueColor_VideoInitialize( videoenable_bmbase ) -LispPTR videoenable_bmbase; +int TrueColor_VideoInitialize(videoenable_bmbase) LispPTR videoenable_bmbase; { - Pixrect *source; - int mmapstat - , size; - - ScreenLocked = T; + Pixrect *source; + int mmapstat, size; - clear_video_region(); - Video_Initialize( FrameBufferFd ); + ScreenLocked = T; - VideoEnableRegion68k = Addr68k_from_LADDR( videoenable_bmbase ); - size = ( (displaywidth * displayheight/8 + (getpagesize()-1) ) - & -getpagesize() ); + clear_video_region(); + Video_Initialize(FrameBufferFd); - source = mem_point( displaywidth, displayheight, 1 - , VideoEnableRegion68k ); - pr_set_plane_group( TrueColorFb, PIXPG_VIDEO_ENABLE ); - pr_rop( TrueColorFb, 0, 0, displaywidth, displayheight - , PIX_SRC, source, 0, 0 ); - pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + VideoEnableRegion68k = Addr68k_from_LADDR(videoenable_bmbase); + size = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); - mmapstat = (int)mmap( VideoEnableRegion68k, - size, - PROT_READ | PROT_WRITE, + source = mem_point(displaywidth, displayheight, 1, VideoEnableRegion68k); + pr_set_plane_group(TrueColorFb, PIXPG_VIDEO_ENABLE); + pr_rop(TrueColorFb, 0, 0, displaywidth, displayheight, PIX_SRC, source, 0, 0); + pr_set_plane_group(TrueColorFb, PIXPG_24BIT_COLOR); + + mmapstat = (int)mmap(VideoEnableRegion68k, size, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif - MAP_SHARED, - FrameBufferFd, 0x533000 ); + MAP_SHARED, + FrameBufferFd, 0x533000); - if( mmapstat == -1 ) { - perror( "TrueColor_VideoInitialize: ERROR at mmap system call\n" ); - exit( 0 ); - } /* end if( mmapstat ) */ - - ScreenLocked = NIL; - return( T ); + if (mmapstat == -1) { + perror("TrueColor_VideoInitialize: ERROR at mmap system call\n"); + exit(0); + } /* end if( mmapstat ) */ + + ScreenLocked = NIL; + return (T); } /* TrueColor_VideoInitialize */ -int -Overlay_Region( left, top, width, height, flg ) -int left - , top - , width - , height - , flg; +int Overlay_Region(left, top, width, height, flg) int left, top, width, height, flg; { - ScreenLocked = T; - overlay_mouse_down(); + ScreenLocked = T; + overlay_mouse_down(); - cgeight_overlay_region( left, top, width, height - , (flg ? FALSE : TRUE) ); + cgeight_overlay_region(left, top, width, height, (flg ? FALSE : TRUE)); + + overlay_mouse_up(*EmCursorX68K, *EmCursorY68K); + ScreenLocked = NIL; - overlay_mouse_up( *EmCursorX68K, *EmCursorY68K ); - ScreenLocked = NIL; - } /* end Overlay_Region */ #ifdef TRUECOLOR -#define TrackCursor(cx,cy) { \ - *CLastUserActionCell68k = MiscStats->secondstmp; \ - overlay_mouse_down(); \ - taking_mouse_down(); \ - taking_mouse_up(cx,cy); \ - overlay_mouse_up(cx,cy); \ - *EmCursorX68K= cx; \ - *EmCursorY68K= cy; \ - } +#define TrackCursor(cx, cy) \ + { \ + *CLastUserActionCell68k = MiscStats->secondstmp; \ + overlay_mouse_down(); \ + taking_mouse_down(); \ + taking_mouse_up(cx, cy); \ + overlay_mouse_up(cx, cy); \ + *EmCursorX68K = cx; \ + *EmCursorY68K = cy; \ + } #endif /* TRUECOLOR */ +extern Pixrect *OverlaySave, *OverlayCursor; -extern Pixrect *OverlaySave - , *OverlayCursor; - -overlay_mouse_up( newx, newy ) -int newx - , newy; +overlay_mouse_up(newx, newy) int newx, newy; { - pr_set_plane_group( TrueColorFb, PIXPG_OVERLAY_ENABLE ); - pr_rop( TrueColorFb, newx, newy, 16, 16, PIX_SRC - , OverlaySave, 0, 0 ); - pr_rop( TrueColorFb, 0, 0, 16, 16, PIX_SRC|PIX_DST - , OverlayCursor, newx, newy ); - pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); + pr_set_plane_group(TrueColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(TrueColorFb, newx, newy, 16, 16, PIX_SRC, OverlaySave, 0, 0); + pr_rop(TrueColorFb, 0, 0, 16, 16, PIX_SRC | PIX_DST, OverlayCursor, newx, newy); + pr_set_plane_group(TrueColorFb, PIXPG_24BIT_COLOR); } /* end overlay_mouse_up */ -extern int LastCursorX - , LastCursorY; +extern int LastCursorX, LastCursorY; -overlay_mouse_down() -{ - pr_set_plane_group( TrueColorFb, PIXPG_OVERLAY_ENABLE ); - pr_rop( OverlaySave, 0, 0, 16, 16, PIX_SRC - , TrueColorFb, LastCursorX, LastCursorY ); - pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); +overlay_mouse_down() { + pr_set_plane_group(TrueColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(OverlaySave, 0, 0, 16, 16, PIX_SRC, TrueColorFb, LastCursorX, LastCursorY); + pr_set_plane_group(TrueColorFb, PIXPG_24BIT_COLOR); -}/* end overlay_mouse_down */ +} /* end overlay_mouse_down */ -truecolor_before_exit() -{ - if( Inited_TrueColor ) { - { /* fill region */ - int h, w; - unsigned short *ptr; - ptr = (unsigned short*)OverlayRegion68k; - for( h = displayheight; (h--); ) { - for( w = DisplayRasterWidth; (w--); ) { - *(ptr++) = ~0; - } /* end for( w ) */ - } /* end for( h ) */ - } +truecolor_before_exit() { + if (Inited_TrueColor) { + { /* fill region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short *)OverlayRegion68k; + for (h = displayheight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *(ptr++) = ~0; } /* end for( w ) */ + } /* end for( h ) */ + } - pr_set_plane_group( TrueColorFb, PIXPG_24BIT_COLOR ); - pr_rop( TrueColorFb, 0, 0, displaywidth, displayheight - , PIX_SRC | PIX_COLOR( 0xffffff ), 0, 0, 0 ); + pr_set_plane_group(TrueColorFb, PIXPG_24BIT_COLOR); + pr_rop(TrueColorFb, 0, 0, displaywidth, displayheight, PIX_SRC | PIX_COLOR(0xffffff), 0, 0, 0); #ifdef VIDEO - if( Inited_Video ) { - { /* clear video enable region */ - int h, w; - unsigned short *ptr; - ptr = (unsigned short*)VideoEnableRegion68k; - for( h = displayheight; (h--); ) { - for( w = DisplayRasterWidth; (w--); ) { - *(ptr++) = 0xffff; - } /* end for( w ) */ - } /* end for( h ) */ - } + if (Inited_Video) { + { /* clear video enable region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short *)VideoEnableRegion68k; + for (h = displayheight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *(ptr++) = 0xffff; } /* end for( w ) */ + } /* end for( h ) */ + } - Video_Close(); + Video_Close(); - } /* end if( Inited_Video ) */ + } /* end if( Inited_Video ) */ #endif /* VIDEO */ + pr_close(TrueColorFb); - pr_close( TrueColorFb ); - - } /* end if( Inited_TrueColor ) */ + } /* end if( Inited_TrueColor ) */ } /* truecolor_before_exit */ @@ -390,114 +326,93 @@ extern int Video_OnOff_Flg; static int video_onoff; #endif /* VIDEO */ +truecolor_before_raid() { + int size; -truecolor_before_raid() -{ - int size; + if (Inited_TrueColor) { + size = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); - if( Inited_TrueColor ) { - size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) - & -getpagesize()); + if ((HideOverlayRegion = valloc(size)) == 0) { + printf("can't valloc hide space\n"); + return (-1); + } /* end if( HideOverlayRegion ) */ - if( (HideOverlayRegion = valloc( size )) == 0 ) { - printf( "can't valloc hide space\n" ); - return( -1 ); - } /* end if( HideOverlayRegion ) */ + copy_region(OverlayRegion68k, HideOverlayRegion, DisplayRasterWidth, displayheight); - copy_region( OverlayRegion68k, HideOverlayRegion - , DisplayRasterWidth, displayheight ); - - { /* fill region */ - int h, w; - unsigned short *ptr; - ptr = (unsigned short*)OverlayRegion68k; - for( h = displayheight; (h--); ) { - for( w = DisplayRasterWidth; (w--); ) { - *(ptr++) = 0xffff; - } /* end for( w ) */ - } /* end for( h ) */ - } - } /* end if( Inited_TrueColor ) */ - -#ifdef VIDEO - if( Inited_Video ) { - if( ( video_onoff = Video_OnOff_Flg) ) Video_OnOff( FALSE ); - if( (HideVideoEnableRegion = valloc( size )) == 0 ) { - printf( "can't valloc hide space\n" ); - return( -1 ); - } /* end if( HideVideoEnableRegion ) */ - - copy_region( VideoEnableRegion68k, HideVideoEnableRegion - , DisplayRasterWidth, displayheight ); - - { /* clear video enable region */ - int h, w; - unsigned short *ptr; - ptr = (unsigned short*)VideoEnableRegion68k; - for( h = displayheight; (h--); ) { - for( w = DisplayRasterWidth; (w--); ) { - *(ptr++) = 0xffff; - } /* end for( w ) */ - } /* end for( h ) */ - } - } /* end if( Inited_Video ) */ -#endif /* VIDEO */ - - -} /* end truecolor_before_raid */ - -truecolor_after_raid() -{ - int size - , mmapstat; - - if( Inited_TrueColor ) { - size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) - & -getpagesize()); - - - mmapstat = (int)mmap( OverlayRegion68k, - size, - PROT_READ | PROT_WRITE, -#ifdef OS4 - MAP_FIXED | -#endif - MAP_SHARED, - FrameBufferFd, 0x20000 ); - - if( mmapstat == -1 ) { - perror( "TrueColor_Initialize: ERROR at mmap system call\n" ); - exit( 0 ); - } /* end if( mmapstat ) */ - - copy_region( HideOverlayRegion, OverlayRegion68k - , DisplayRasterWidth, displayheight ); - free( HideOverlayRegion ); - } /* end if( Inited_TrueColor ) */ + { /* fill region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short *)OverlayRegion68k; + for (h = displayheight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *(ptr++) = 0xffff; } /* end for( w ) */ + } /* end for( h ) */ + } + } /* end if( Inited_TrueColor ) */ #ifdef VIDEO - if( Inited_Video ) { - mmapstat = (int)mmap( VideoEnableRegion68k, - size, - PROT_READ | PROT_WRITE, -#ifdef OS4 - MAP_FIXED | -#endif - MAP_SHARED, - FrameBufferFd, 0x533000 ); + if (Inited_Video) { + if ((video_onoff = Video_OnOff_Flg)) Video_OnOff(FALSE); + if ((HideVideoEnableRegion = valloc(size)) == 0) { + printf("can't valloc hide space\n"); + return (-1); + } /* end if( HideVideoEnableRegion ) */ - if( mmapstat == -1 ) { - perror( "TrueColor_VideoInitialize: ERROR at mmap system call\n" ); - exit( 0 ); - } /* end if( mmapstat ) */ + copy_region(VideoEnableRegion68k, HideVideoEnableRegion, DisplayRasterWidth, displayheight); - copy_region( HideVideoEnableRegion, VideoEnableRegion68k - , DisplayRasterWidth, displayheight ); - free( HideVideoEnableRegion ); - if( video_onoff ) Video_OnOff( TRUE ); - - } /* end if( Inited_Video ) */ + { /* clear video enable region */ + int h, w; + unsigned short *ptr; + ptr = (unsigned short *)VideoEnableRegion68k; + for (h = displayheight; (h--);) { + for (w = DisplayRasterWidth; (w--);) { *(ptr++) = 0xffff; } /* end for( w ) */ + } /* end for( h ) */ + } + } /* end if( Inited_Video ) */ #endif /* VIDEO */ +} /* end truecolor_before_raid */ + +truecolor_after_raid() { + int size, mmapstat; + + if (Inited_TrueColor) { + size = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); + + mmapstat = (int)mmap(OverlayRegion68k, size, PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x20000); + + if (mmapstat == -1) { + perror("TrueColor_Initialize: ERROR at mmap system call\n"); + exit(0); + } /* end if( mmapstat ) */ + + copy_region(HideOverlayRegion, OverlayRegion68k, DisplayRasterWidth, displayheight); + free(HideOverlayRegion); + } /* end if( Inited_TrueColor ) */ + +#ifdef VIDEO + if (Inited_Video) { + mmapstat = (int)mmap(VideoEnableRegion68k, size, PROT_READ | PROT_WRITE, +#ifdef OS4 + MAP_FIXED | +#endif + MAP_SHARED, + FrameBufferFd, 0x533000); + + if (mmapstat == -1) { + perror("TrueColor_VideoInitialize: ERROR at mmap system call\n"); + exit(0); + } /* end if( mmapstat ) */ + + copy_region(HideVideoEnableRegion, VideoEnableRegion68k, DisplayRasterWidth, displayheight); + free(HideVideoEnableRegion); + if (video_onoff) Video_OnOff(TRUE); + + } /* end if( Inited_Video ) */ +#endif /* VIDEO */ } /* end truecolor_after_raid */ diff --git a/src/tstsout.c b/src/tstsout.c old mode 100755 new mode 100644 index 43a6404..f3dc308 --- a/src/tstsout.c +++ b/src/tstsout.c @@ -1,11 +1,10 @@ -/* $Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyright (C) Venue"; /* * tstsout.c */ - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -20,7 +19,6 @@ static char *id = "$Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyr #include "version.h" - #include #include #include @@ -36,59 +34,53 @@ static char *id = "$Id: tstsout.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyr #include "ifpage.h" #include "dbprint.h" -#define IFPAGE_ADDRESS 512 -#define MBYTE 0x100000 /* 1 Mbyte */ -extern int errno; +#define IFPAGE_ADDRESS 512 +#define MBYTE 0x100000 /* 1 Mbyte */ +extern int errno; /* JDS protoize char *valloc(size_t); */ -void check_sysout(char *sysout_file_name) -{ - int sysout; /* SysoutFile descriptor */ +void check_sysout(char *sysout_file_name) { + int sysout; /* SysoutFile descriptor */ - IFPAGE ifpage; /* IFPAGE */ + IFPAGE ifpage; /* IFPAGE */ - char errmsg [ 255 ]; + char errmsg[255]; - /* - * first read the IFPAGE(InterfacePage) - */ + /* + * first read the IFPAGE(InterfacePage) + */ - /* open SysoutFile */ - sysout = open(sysout_file_name, O_RDONLY, NULL); - if (sysout == -1) { - sprintf( errmsg, - "sysout_loader: can't open sysout file: %s", - sysout_file_name); - perror( errmsg ); - exit(-1); - } - /* seek to IFPAGE */ - if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { - perror("sysout_loader: can't seek to IFPAGE"); - exit(-1); - } - /* reads IFPAGE into scratch_page */ - if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) { - perror("sysout_loader: can't read IFPAGE"); - exit(-1); - } + /* open SysoutFile */ + sysout = open(sysout_file_name, O_RDONLY, NULL); + if (sysout == -1) { + sprintf(errmsg, "sysout_loader: can't open sysout file: %s", sysout_file_name); + perror(errmsg); + exit(-1); + } + /* seek to IFPAGE */ + if (lseek(sysout, IFPAGE_ADDRESS, 0) == -1) { + perror("sysout_loader: can't seek to IFPAGE"); + exit(-1); + } + /* reads IFPAGE into scratch_page */ + if (read(sysout, &ifpage, sizeof(IFPAGE)) == -1) { + perror("sysout_loader: can't read IFPAGE"); + exit(-1); + } #ifdef BYTESWAP - word_swap_page(&ifpage, (3+sizeof(IFPAGE))/4); + word_swap_page(&ifpage, (3 + sizeof(IFPAGE)) / 4); #endif - close(sysout); - printf("%d", ifpage.minbversion); + close(sysout); + printf("%d", ifpage.minbversion); } -int main(int argc, char **argv) -{ - if (argc != 2) - { - printf("You forgot to supply a file name."); - return(-1); - } - check_sysout(argv[1]); - exit(0); +int main(int argc, char **argv) { + if (argc != 2) { + printf("You forgot to supply a file name."); + return (-1); + } + check_sysout(argv[1]); + exit(0); } - diff --git a/src/tty.c b/src/tty.c old mode 100755 new mode 100644 index 450bd52..81bf3b8 --- a/src/tty.c +++ b/src/tty.c @@ -1,8 +1,6 @@ /* $Id: tty.c,v 1.2 1999/01/03 02:07:39 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: tty.c,v 1.2 1999/01/03 02:07:39 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,247 +15,225 @@ static char *id = "$Id: tty.c,v 1.2 1999/01/03 02:07:39 sybalsky Exp $ Copyright #include "version.h" - #include "tty.h" DLTTY_OUT_COMMAND *DLTTYPortCmd; -DLTTY_IN_CSB *DLTTYIn; -DLTTY_OUT_CSB *DLTTYOut; +DLTTY_IN_CSB *DLTTYIn; +DLTTY_OUT_CSB *DLTTYOut; -char *TTY_Dev; -int TTY_Fd; +char *TTY_Dev; +int TTY_Fd; extern int LispReadFds; struct sgttyb TTY_Mode; -tty_init() -{ +tty_init() { #ifdef TRACE - printf( "TRACE: tty_init()\n" ); + printf("TRACE: tty_init()\n"); #endif - TTY_Dev = "/dev/ttyb"; /* Modify device name */ - TTY_Fd = (-1); + TTY_Dev = "/dev/ttyb"; /* Modify device name */ + TTY_Fd = (-1); - DLTTYPortCmd = (DLTTY_OUT_COMMAND*) Addr68k_from_LADDR( IOPAGE_OFFSET+20 ); - DLTTYIn = (DLTTY_IN_CSB*) Addr68k_from_LADDR( IOPAGE_OFFSET+36 ); - DLTTYOut = (DLTTY_OUT_CSB*) Addr68k_from_LADDR( IOPAGE_OFFSET+34 ); + DLTTYPortCmd = (DLTTY_OUT_COMMAND *)Addr68k_from_LADDR(IOPAGE_OFFSET + 20); + DLTTYIn = (DLTTY_IN_CSB *)Addr68k_from_LADDR(IOPAGE_OFFSET + 36); + DLTTYOut = (DLTTY_OUT_CSB *)Addr68k_from_LADDR(IOPAGE_OFFSET + 34); } /* tty_init end */ -tty_open() -{ - int stat; +tty_open() { + int stat; #ifdef TRACE - printf( "TRACE: tty_open()\n" ); + printf("TRACE: tty_open()\n"); #endif - - if ( TTY_Fd < 0 ) { - if (( TTY_Fd = open( TTY_Dev, O_RDWR )) >=0 ) { - stat = ioctl( TTY_Fd, TIOCGETP, &TTY_Mode ); - TTY_Mode.sg_flags = RAW; - stat = ioctl( TTY_Fd, TIOCSETP, &TTY_Mode ); + if (TTY_Fd < 0) { + if ((TTY_Fd = open(TTY_Dev, O_RDWR)) >= 0) { + stat = ioctl(TTY_Fd, TIOCGETP, &TTY_Mode); + TTY_Mode.sg_flags = RAW; + stat = ioctl(TTY_Fd, TIOCSETP, &TTY_Mode); - LispReadFds |= ( 1 << TTY_Fd ); + LispReadFds |= (1 << TTY_Fd); #ifdef TTYINT - int_io_open(TTY_Fd); + int_io_open(TTY_Fd); #endif - } else { - error( "TTY: tty_open" ); - } - } + } else { + error("TTY: tty_open"); + } + } } /* tty_open end */ - -tty_close() -{ - int stat; +tty_close() { + int stat; #ifdef TRACE - printf( "TRACE: tty_close()\n" ); + printf("TRACE: tty_close()\n"); #endif - if ( TTY_Fd >= 0 ) { - - LispReadFds &= ~( 1 << TTY_Fd ); - stat = close( TTY_Fd ); + if (TTY_Fd >= 0) { + LispReadFds &= ~(1 << TTY_Fd); + stat = close(TTY_Fd); #ifdef TTYINT - int_io_close(TTY_Fd); + int_io_close(TTY_Fd); #endif - TTY_Fd = (-1); - - } + TTY_Fd = (-1); + } } /* tty_close end */ -TTY_get() -{ - char indata[256]; - int count; +TTY_get() { + char indata[256]; + int count; #ifdef TRACE - printf( "TRACE: tty_get()\n" ); + printf("TRACE: tty_get()\n"); #endif - if (( TTY_Fd >=0 ) && !DLTTYIn->state ) { + if ((TTY_Fd >= 0) && !DLTTYIn->state) { + DLTTYIn->in_data = '\0'; /* Clear Previous Data */ - DLTTYIn->in_data = '\0'; /* Clear Previous Data */ - - if (( count = read( TTY_Fd, indata, 1 )) == 1) { - DLTTYIn->in_data = indata[0]; - DLTTYIn->state = 1; - } else { - error( "TTY: tty_get" ); - } - - } + if ((count = read(TTY_Fd, indata, 1)) == 1) { + DLTTYIn->in_data = indata[0]; + DLTTYIn->state = 1; + } else { + error("TTY: tty_get"); + } + } } /* TTY_get end */ -tty_put() -{ - int count; - char c; +tty_put() { + int count; + char c; #ifdef TRACE - printf( "TRACE: tty_put()\n" ); + printf("TRACE: tty_put()\n"); #endif - if ( TTY_Fd >= 0 ) { + if (TTY_Fd >= 0) { + c = DLTTYPortCmd->outdata; + if ((count = write(TTY_Fd, &c, 1)) != 1) { error("TTY: tty_put()"); } + } +} /* tty_put end */ - c = DLTTYPortCmd->outdata; - if (( count = write( TTY_Fd, &c, 1 )) != 1) { - error( "TTY: tty_put()" ); - } - } -} /* tty_put end */ - -tty_breakon() -{ - int stat; +tty_breakon() { + int stat; #ifdef TRACE - printf( "TRACE: tty_breakon()\n" ); + printf("TRACE: tty_breakon()\n"); #endif - if ( TTY_Fd >= 0 ) { - stat = ioctl( TTY_Fd, TIOCSBRK, 0 ); - } + if (TTY_Fd >= 0) { stat = ioctl(TTY_Fd, TIOCSBRK, 0); } } /* tty_breakon end */ -tty_breakoff() -{ - int stat; +tty_breakoff() { + int stat; #ifdef TRACE - printf( "TRACE: tty_breakoff()\n" ); + printf("TRACE: tty_breakoff()\n"); #endif - if ( TTY_Fd >= 0 ) { - stat = ioctl( TTY_Fd, TIOCCBRK, 0 ); - } + if (TTY_Fd >= 0) { stat = ioctl(TTY_Fd, TIOCCBRK, 0); } } /* tty_breakoff end */ -TTY_cmd() -{ +TTY_cmd() { #ifdef TRACE - printf( "TRACE: tty_cmd()\n" ); + printf("TRACE: tty_cmd()\n"); #endif - if ( DLTTYPortCmd->command >= PUT_CHAR ) { + if (DLTTYPortCmd->command >= PUT_CHAR) { + if (DLTTYPortCmd->command == PUT_CHAR) + tty_put(); + else if (DLTTYPortCmd->command == SET_PARAM) + tty_setparam(); + else if (DLTTYPortCmd->command == TTY_ON) + tty_open(); + else if (DLTTYPortCmd->command == TTY_OFF) + tty_close(); + else if (DLTTYPortCmd->command == TTY_BREAK_ON) + tty_breakon(); + else if (DLTTYPortCmd->command == TTY_BREAK_OFF) + tty_breakoff(); + else + error("TTY: tty_cmd"); - if ( DLTTYPortCmd->command == PUT_CHAR ) tty_put(); - else if ( DLTTYPortCmd->command == SET_PARAM ) tty_setparam(); - else if ( DLTTYPortCmd->command == TTY_ON ) tty_open(); - else if ( DLTTYPortCmd->command == TTY_OFF ) tty_close(); - else if ( DLTTYPortCmd->command == TTY_BREAK_ON ) tty_breakon(); - else if ( DLTTYPortCmd->command == TTY_BREAK_OFF ) tty_breakoff(); - else - error( "TTY: tty_cmd"); - - DLTTYPortCmd->command &= ~PUT_CHAR; - } + DLTTYPortCmd->command &= ~PUT_CHAR; + } } /* TTY_cmd end */ - -tty_setparam() -{ + +tty_setparam() { #ifdef TRACE - printf( "TRACE: tty_setpram()\n" ); + printf("TRACE: tty_setpram()\n"); #endif - if ( DLTTYPortCmd->outdata & SET_BAUD_RATE ) tty_setbaudrate(); + if (DLTTYPortCmd->outdata & SET_BAUD_RATE) tty_setbaudrate(); } /* tty_setpram end */ -tty_setbaudrate() -{ - char baudrate; - int stat; +tty_setbaudrate() { + char baudrate; + int stat; #ifdef TRACE - printf( "TRACE: tty_setbaudrete()\n" ); + printf("TRACE: tty_setbaudrete()\n"); #endif - if ( TTY_Fd >= 0 ) { - if (( baudrate = tty_baudtosymbol( DLTTYOut->line_speed )) != -1 ) { - TTY_Mode.sg_ispeed = baudrate; - TTY_Mode.sg_ospeed = baudrate; - stat = ioctl( TTY_Fd, TIOCSETP, &TTY_Mode ); - } else { - error( "TTY: tty_setbaudrate" ); - } - } + if (TTY_Fd >= 0) { + if ((baudrate = tty_baudtosymbol(DLTTYOut->line_speed)) != -1) { + TTY_Mode.sg_ispeed = baudrate; + TTY_Mode.sg_ospeed = baudrate; + stat = ioctl(TTY_Fd, TIOCSETP, &TTY_Mode); + } else { + error("TTY: tty_setbaudrate"); + } + } } /* tty_setbaudrate end */ - -tty_baudtosymbol(aBaud) - short aBaud; -{ +tty_baudtosymbol(aBaud) short aBaud; +{ #ifdef TRASE - printf("TRASE: tty_baudtosymbol(%x)\n",aBaud); + printf("TRASE: tty_baudtosymbol(%x)\n", aBaud); #endif - if( aBaud== 0 ) return(B50); - if( aBaud== 1 ) return(B75); - if( aBaud== 2 ) return(B110); - if( aBaud== 3 ) return(B134); - if( aBaud== 4 ) return(B150); - if( aBaud== 5 ) return(B300); - if( aBaud== 6 ) return(B600); - if( aBaud== 7 ) return(B1200); - if( aBaud==10 ) return(B2400); - if( aBaud==12 ) return(B4800); - if( aBaud==14 ) return(B9600); - if( aBaud==15 ) return(EXTA); - return(-1); + if (aBaud == 0) return (B50); + if (aBaud == 1) return (B75); + if (aBaud == 2) return (B110); + if (aBaud == 3) return (B134); + if (aBaud == 4) return (B150); + if (aBaud == 5) return (B300); + if (aBaud == 6) return (B600); + if (aBaud == 7) return (B1200); + if (aBaud == 10) return (B2400); + if (aBaud == 12) return (B4800); + if (aBaud == 14) return (B9600); + if (aBaud == 15) return (EXTA); + return (-1); } /* tty_baudtosymbol */ -tty_debug( name ) - char *name; +tty_debug(name) char *name; { - int stat; - struct sgttyb mode; - - printf("DEBUG: %s\n",name); - printf("DEBUG: \t\tTTY_Dev = \"%s\"\n",TTY_Dev); - printf("DEBUG: \t\tTTY_Fd = %d\n",TTY_Fd); + int stat; + struct sgttyb mode; - if ( TTY_Fd >= 0 ) { - stat = ioctl( TTY_Fd, TIOCGETP, &mode ); - printf("DEBUG: \t\tTTY_Mode.sg_ispeed = %#x\n",mode.sg_ispeed); - printf("DEBUG: \t\tTTY_Mode.sg_ospeed = %#x\n",mode.sg_ospeed); - printf("DEBUG: \t\tTTY_Mode.sg_erase = %#x\n",mode.sg_erase); - printf("DEBUG: \t\tTTY_Mode.sg_kill = %#x\n",mode.sg_kill); - printf("DEBUG: \t\tTTY_Mode.sg_flags = %#x\n",mode.sg_flags); - } + printf("DEBUG: %s\n", name); + printf("DEBUG: \t\tTTY_Dev = \"%s\"\n", TTY_Dev); + printf("DEBUG: \t\tTTY_Fd = %d\n", TTY_Fd); + + if (TTY_Fd >= 0) { + stat = ioctl(TTY_Fd, TIOCGETP, &mode); + printf("DEBUG: \t\tTTY_Mode.sg_ispeed = %#x\n", mode.sg_ispeed); + printf("DEBUG: \t\tTTY_Mode.sg_ospeed = %#x\n", mode.sg_ospeed); + printf("DEBUG: \t\tTTY_Mode.sg_erase = %#x\n", mode.sg_erase); + printf("DEBUG: \t\tTTY_Mode.sg_kill = %#x\n", mode.sg_kill); + printf("DEBUG: \t\tTTY_Mode.sg_flags = %#x\n", mode.sg_flags); + } + + printf("DEBUG:\n"); + printf("DEBUG: \t\tSymbol Address Contents\n"); + printf("DEBUG: \t\tIOPAGE %#x\n", Addr68k_from_LADDR(IOPAGE_OFFSET)); + printf("DEBUG: \t\tDLTTYPortCmd %#x %#x\n", DLTTYPortCmd, *(DLword *)DLTTYPortCmd); + printf("DEBUG: \t\tDLTTYOut %#x %#x\n", DLTTYOut, *(DLword *)DLTTYOut); + printf("DEBUG: \t\t %#x\n", *(DLword *)(DLTTYOut + 1)); + printf("DEBUG: \t\tDLTTYIn %#x %#x\n", DLTTYIn, *(DLword *)DLTTYIn); + printf("DEBUG: \t\t %#x\n", *(DLword *)(DLTTYIn + 1)); - printf("DEBUG:\n" ); - printf("DEBUG: \t\tSymbol Address Contents\n"); - printf("DEBUG: \t\tIOPAGE %#x\n",Addr68k_from_LADDR(IOPAGE_OFFSET)); - printf("DEBUG: \t\tDLTTYPortCmd %#x %#x\n",DLTTYPortCmd,*(DLword*) DLTTYPortCmd); - printf("DEBUG: \t\tDLTTYOut %#x %#x\n",DLTTYOut,*(DLword*) DLTTYOut); - printf("DEBUG: \t\t %#x\n",*(DLword*) (DLTTYOut+1)); - printf("DEBUG: \t\tDLTTYIn %#x %#x\n",DLTTYIn,*(DLword*) DLTTYIn); - printf("DEBUG: \t\t %#x\n",*(DLword*) (DLTTYIn+1)); - } /* tty_debug end */ diff --git a/src/typeof.c b/src/typeof.c old mode 100755 new mode 100644 index 56ed6fe..396ccbd --- a/src/typeof.c +++ b/src/typeof.c @@ -1,8 +1,7 @@ -/* $Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -17,17 +16,13 @@ static char *id = "$Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyri #include "version.h" - - - - /****************************************************************/ /* LISTP(3Q),NTYPEX(4Q),TYPEP(5Q),DTEST(6Q) ,INSTANCEP(303Q) */ /****************************************************************/ /* - changed : Jan. 13 1987 take - changed : Feb. 05 1987 take - changed : Jul. 24 1987 take + changed : Jan. 13 1987 take + changed : Feb. 05 1987 take + changed : Jul. 24 1987 take */ @@ -37,7 +32,6 @@ static char *id = "$Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyri #include "lispmap.h" #include "lspglob.h" - /************************************************************************/ /* */ /* N _ O P _ d t e s t */ @@ -46,26 +40,20 @@ static char *id = "$Id: typeof.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyri /* */ /************************************************************************/ -LispPTR N_OP_dtest(register LispPTR tos, register int atom_index) -{ - register struct dtd *dtd68k ; +LispPTR N_OP_dtest(register LispPTR tos, register int atom_index) { + register struct dtd *dtd68k; - for(dtd68k=(struct dtd *) GetDTD(GetTypeNumber(tos)); + for (dtd68k = (struct dtd *)GetDTD(GetTypeNumber(tos)); #ifdef BIGVM - atom_index != dtd68k->dtd_name; + atom_index != dtd68k->dtd_name; #else - atom_index != dtd68k->dtd_namelo+(dtd68k->dtd_namehi<<16) ; + atom_index != dtd68k->dtd_namelo + (dtd68k->dtd_namehi << 16); #endif /* BIGVM */ - dtd68k=(struct dtd *) GetDTD(dtd68k->dtd_supertype)) - { - if( dtd68k->dtd_supertype == 0) ERROR_EXIT(tos); - } - return(tos); - } /* OP_DTEST END */ - - - - + dtd68k = (struct dtd *)GetDTD(dtd68k->dtd_supertype)) { + if (dtd68k->dtd_supertype == 0) ERROR_EXIT(tos); + } + return (tos); +} /* OP_DTEST END */ /************************************************************************/ /* */ @@ -75,22 +63,19 @@ LispPTR N_OP_dtest(register LispPTR tos, register int atom_index) /* */ /************************************************************************/ -LispPTR N_OP_instancep(register LispPTR tos, register int atom_index) -{ - register unsigned int type ; - register struct dtd *dtd68k ; +LispPTR N_OP_instancep(register LispPTR tos, register int atom_index) { + register unsigned int type; + register struct dtd *dtd68k; - for( dtd68k=(struct dtd *)GetDTD(GetTypeNumber(tos)); + for (dtd68k = (struct dtd *)GetDTD(GetTypeNumber(tos)); #ifdef BIGVM - atom_index != dtd68k->dtd_name; + atom_index != dtd68k->dtd_name; #else - atom_index != dtd68k->dtd_namelo+(dtd68k->dtd_namehi<<16) ; + atom_index != dtd68k->dtd_namelo + (dtd68k->dtd_namehi << 16); #endif /* BIGVM */ - dtd68k=(struct dtd *)GetDTD(dtd68k->dtd_supertype) ) - { - if( dtd68k->dtd_supertype== 0) { return(NIL_PTR); } - } - return(ATOM_T); - - } /* N_OP_instancep END */ + dtd68k = (struct dtd *)GetDTD(dtd68k->dtd_supertype)) { + if (dtd68k->dtd_supertype == 0) { return (NIL_PTR); } + } + return (ATOM_T); +} /* N_OP_instancep END */ diff --git a/src/ubf1.c b/src/ubf1.c old mode 100755 new mode 100644 index 632d87d..222364d --- a/src/ubf1.c +++ b/src/ubf1.c @@ -1,7 +1,6 @@ /* $Id: ubf1.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: ubf1.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,9 +15,6 @@ static char *id = "$Id: ubf1.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyrigh #include "version.h" - - - #include #include "lispemul.h" #include "adr68k.h" @@ -29,7 +25,7 @@ static char *id = "$Id: ubf1.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyrigh #include "medleyfp.h" #include "my.h" /************************************************************ - OP_ubfloat1 -- op 355 == UBFLOAT1 + OP_ubfloat1 -- op 355 == UBFLOAT1 355/0 BOX 355/1 UNBOX 355/2 ABS @@ -37,37 +33,32 @@ static char *id = "$Id: ubf1.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyrigh 355/4 UFIX ***********************************************************/ -LispPTR N_OP_ubfloat1(int arg, int alpha) -{ +LispPTR N_OP_ubfloat1(int arg, int alpha) { switch (alpha) { case 0: /* box */ - { + { register DLword *wordp; DLword *createcell68k(unsigned int type); wordp = createcell68k(TYPE_FLOATP); *((int *)wordp) = arg; - return(LADDR_from_68k(wordp)); - } + return (LADDR_from_68k(wordp)); + } case 1: /* unbox */ - { + { float dest; int ret; N_MakeFloat(arg, dest, arg); ret = *(int *)&dest; - return(ret); - } - case 2: /* abs */ - return(0x7FFFFFFF & arg); - case 3: /* neg */ - return(0x80000000 ^ arg); + return (ret); + } + case 2: /* abs */ return (0x7FFFFFFF & arg); + case 3: /* neg */ return (0x80000000 ^ arg); case 4: /* ufix */ - { + { register float temp; int val; temp = *(float *)&arg; - if ( (temp > ((float) 0x7fffffff)) || - (temp < ((float) 0x80000000)) ) - ERROR_EXIT(arg); + if ((temp > ((float)0x7fffffff)) || (temp < ((float)0x80000000))) ERROR_EXIT(arg); #ifdef I386 I386Reset; #endif /* I386 */ @@ -77,18 +68,9 @@ LispPTR N_OP_ubfloat1(int arg, int alpha) I386Round; #endif N_ARITH_SWITCH(val); - } + } default: ERROR_EXIT(arg); - }/* end switch */ -}/* end N_OP_ubfloat1() */ - - /* end module */ - - - - - - - - + } /* end switch */ +} /* end N_OP_ubfloat1() */ +/* end module */ diff --git a/src/ubf2.c b/src/ubf2.c old mode 100755 new mode 100644 index 7d30a50..06d2e19 --- a/src/ubf2.c +++ b/src/ubf2.c @@ -3,10 +3,6 @@ static char *id = "$Id: ubf2.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyrigh /* ubf2.c */ - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -21,16 +17,13 @@ static char *id = "$Id: ubf2.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyrigh #include "version.h" - - - #include #include #include "lispemul.h" #include "medleyfp.h" /************************************************************ - OP_ub2 -- op 354 == UBFLOAT2 + OP_ub2 -- op 354 == UBFLOAT2 354/0 ADD 354/1 SUB 354/2 ISUB @@ -42,40 +35,49 @@ static char *id = "$Id: ubf2.c,v 1.3 1999/05/31 23:35:44 sybalsky Exp $ Copyrigh 354/8 REM 354/9 AREF ***********************************************************/ -LispPTR N_OP_ubfloat2(int a2, int a1, int alpha) -{ -REGISTER float arg1, arg2; -float ans; -int ret; +LispPTR N_OP_ubfloat2(int a2, int a1, int alpha) { + REGISTER float arg1, arg2; + float ans; + int ret; -/* Unboxed floating point args (a1, a2) look like float, but */ -/* can't be declared as such because all float args get passed */ -/* as double. (That can be avoided in ansi C.) Instead, they */ -/* are declared int and accessed as float through cast pointers. */ -/* The return value is handled similarly. */ + /* Unboxed floating point args (a1, a2) look like float, but */ + /* can't be declared as such because all float args get passed */ + /* as double. (That can be avoided in ansi C.) Instead, they */ + /* are declared int and accessed as float through cast pointers. */ + /* The return value is handled similarly. */ - - arg1 = *(float *)&a1; + arg1 = *(float *)&a1; arg2 = *(float *)&a2; FPCLEAR; switch (alpha) { - case 0: /* add */ ans = arg1 + arg2; break; - case 1: /* sub */ ans = arg2 - arg1; break; + case 0: /* add */ ans = arg1 + arg2; break; + case 1: /* sub */ ans = arg2 - arg1; break; case 2: /* isub */ ans = arg1 - arg2; break; - case 3: /* mul */ ans = arg1 * arg2; break; - case 4: /* div */ ans = arg2 / arg1; break; - case 5: /* gt */ if (arg2 > arg1) return(ATOM_T); else return(NIL_PTR); - case 6: /* max */ if (arg2 > arg1) return(a2); else return(a1); - case 7: /* min */ if (arg2 > arg1) return(a1); else return(a2); - case 8: /* rem */ ans = fmod(arg2,arg1); break; + case 3: /* mul */ ans = arg1 * arg2; break; + case 4: /* div */ ans = arg2 / arg1; break; + case 5: /* gt */ + if (arg2 > arg1) + return (ATOM_T); + else + return (NIL_PTR); + case 6: /* max */ + if (arg2 > arg1) + return (a2); + else + return (a1); + case 7: /* min */ + if (arg2 > arg1) + return (a1); + else + return (a2); + case 8: /* rem */ ans = fmod(arg2, arg1); break; default: ERROR_EXIT(a1); - }/* end switch */ + } /* end switch */ - ret = *(int *)&ans; /* Convert it back to int for 32 bit storage */ + ret = *(int *)&ans; /* Convert it back to int for 32 bit storage */ if (FPTEST(ans)) ERROR_EXIT(a1); - return(ret); + return (ret); +} /* end N_OP_ub2() */ -}/* end N_OP_ub2() */ - - /* end module */ +/* end module */ diff --git a/src/ubf3.c b/src/ubf3.c old mode 100755 new mode 100644 index 8d4d408..1faff47 --- a/src/ubf3.c +++ b/src/ubf3.c @@ -3,7 +3,6 @@ static char *id = "$Id: ubf3.c,v 1.3 1999/05/31 23:35:45 sybalsky Exp $ Copyrigh /* ubf3.c */ - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,10 +17,6 @@ static char *id = "$Id: ubf3.c,v 1.3 1999/05/31 23:35:45 sybalsky Exp $ Copyrigh #include "version.h" - - - - #include #include "lispemul.h" #include "lspglob.h" @@ -30,31 +25,30 @@ static char *id = "$Id: ubf3.c,v 1.3 1999/05/31 23:35:45 sybalsky Exp $ Copyrigh #include "medleyfp.h" /************************************************************ - N_OP_ubfloat3 -- op 062 + N_OP_ubfloat3 -- op 062 062/0 POLY ***********************************************************/ -LispPTR N_OP_ubfloat3(int arg3, LispPTR arg2, LispPTR arg1, int alpha) -{ - REGISTER float val; - REGISTER float ans; - REGISTER float *fptr; - register int degree; - int ret; - float flot; +LispPTR N_OP_ubfloat3(int arg3, LispPTR arg2, LispPTR arg1, int alpha) { + REGISTER float val; + REGISTER float ans; + REGISTER float *fptr; + register int degree; + int ret; + float flot; - val = *(float *)&arg3; /* why? */ - if (alpha) ERROR_EXIT(arg1); - FPCLEAR; - if ((arg1 & SEGMASK) != S_POSITIVE) ERROR_EXIT(arg1); - degree = 0xFFFF & arg1; - fptr = (float *)Addr68k_from_LADDR(arg2); - ans = *((float *)fptr); - while (degree--) ans = (ans * val) + *((float *)(++fptr)); - if (FPTEST(ans)) ERROR_EXIT(arg1); /* relies on contagion of inf, nan? */ - flot = ans; - ret = *(int *)&flot; /* why? */ - return(ret); - }/* end N_OP_ubfloat3() */ + val = *(float *)&arg3; /* why? */ + if (alpha) ERROR_EXIT(arg1); + FPCLEAR; + if ((arg1 & SEGMASK) != S_POSITIVE) ERROR_EXIT(arg1); + degree = 0xFFFF & arg1; + fptr = (float *)Addr68k_from_LADDR(arg2); + ans = *((float *)fptr); + while (degree--) ans = (ans * val) + *((float *)(++fptr)); + if (FPTEST(ans)) ERROR_EXIT(arg1); /* relies on contagion of inf, nan? */ + flot = ans; + ret = *(int *)&flot; /* why? */ + return (ret); +} /* end N_OP_ubfloat3() */ - /* end module */ +/* end module */ diff --git a/src/ufn.c b/src/ufn.c old mode 100755 new mode 100644 index e7394cc..a9ba6c1 --- a/src/ufn.c +++ b/src/ufn.c @@ -3,17 +3,15 @@ static char *id = "$Id: ufn.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright /******************************************************************/ /* - File Name : ufn.c(for use with SYSOUT) - Including : ufn + File Name : ufn.c(for use with SYSOUT) + Including : ufn - Created : jun 8, 1987 by T.Shimizu + Created : jun 8, 1987 by T.Shimizu */ /******************************************************************/ - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -28,8 +26,6 @@ static char *id = "$Id: ufn.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright #include "version.h" - - #include "lispemul.h" #include "address.h" #include "adr68k.h" @@ -43,41 +39,38 @@ static char *id = "$Id: ufn.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright #ifdef C_ONLY -#define GetUFNEntry(num) (((UFN *)UFNTable) + (num)) - +#define GetUFNEntry(num) (((UFN *)UFNTable) + (num)) /******************************************************************/ /* - Func Name : ufn - Desc : call Lisp UFN func - TopOfStack; - PC ; + Func Name : ufn + Desc : call Lisp UFN func + TopOfStack; + PC ; - Created : May 29, 1987 by T.Shimizu - Changed : Jun 17 1987 take - Aug 25 1987 take - Sep 4 1987 NMitani - Oct 07 1987 take - Nov 13 1987 take +8 & Simple STKCHK - Nov 25 1987 take(tmp_fn) + Created : May 29, 1987 by T.Shimizu + Changed : Jun 17 1987 take + Aug 25 1987 take + Sep 4 1987 NMitani + Oct 07 1987 take + Nov 13 1987 take +8 & Simple STKCHK + Nov 25 1987 take(tmp_fn) */ /******************************************************************/ -ufn(bytecode) -DLword bytecode ; +ufn(bytecode) DLword bytecode; { - register DefCell *defcell68k ; /* Definition Cell PTR */ - register int pv_num ; /* scratch for pv */ + register DefCell *defcell68k; /* Definition Cell PTR */ + register int pv_num; /* scratch for pv */ register UFN *entry68k; register struct fnhead *tmp_fn; - register unsigned int arg_num ; /* Num of args */ - register int rest ; /* use for arignments */ - + register unsigned int arg_num; /* Num of args */ + register int rest; /* use for arignments */ #ifdef TRACE - printPC(); - print_atomname("TRACE : ufn() 0%o ",bytecode); + printPC(); + print_atomname("TRACE : ufn() 0%o ", bytecode); #endif PushCStack; @@ -85,143 +78,129 @@ DLword bytecode ; entry68k = (UFN *)GetUFNEntry(bytecode); /*changing I/F 17-jun*/ #ifdef TRACE - if(entry68k->atom_name) - printf("Atom number: %d\n", 0xffff && entry68k->atom_name); - else - error("UNF not specified"); + if (entry68k->atom_name) + printf("Atom number: %d\n", 0xffff && entry68k->atom_name); + else + error("UNF not specified"); #endif - switch(entry68k->byte_num) - { - case 0 : break; - case 1 : /*PushStack(SPOS_HI | Get_BYTE(PC+1));*/ - CurrentStackPTR +=2; - GETWORD(CurrentStackPTR)=SPOS_HI; - GETWORD(CurrentStackPTR+1)=(DLword)Get_code_BYTE(PC+1); - /* I think we don't have to shift alpha byte eight bit before save it. */ + switch (entry68k->byte_num) { + case 0: break; + case 1: /*PushStack(SPOS_HI | Get_BYTE(PC+1));*/ + CurrentStackPTR += 2; + GETWORD(CurrentStackPTR) = SPOS_HI; + GETWORD(CurrentStackPTR + 1) = (DLword)Get_code_BYTE(PC + 1); +/* I think we don't have to shift alpha byte eight bit before save it. */ #ifdef DEBUG - printf("***ufn: case 1\n"); + printf("***ufn: case 1\n"); #endif - break; + break; - case 2 : /*PushStack(S_POSITIVE |Get_DLword(PC+1));*/ - CurrentStackPTR +=2; - GETWORD(CurrentStackPTR) = SPOS_HI ; - GETWORD(CurrentStackPTR+1) = (DLword)((Get_code_BYTE(PC+1) << 8) | Get_code_BYTE(PC+2)); + case 2: /*PushStack(S_POSITIVE |Get_DLword(PC+1));*/ + CurrentStackPTR += 2; + GETWORD(CurrentStackPTR) = SPOS_HI; + GETWORD(CurrentStackPTR + 1) = (DLword)((Get_code_BYTE(PC + 1) << 8) | Get_code_BYTE(PC + 2)); #ifdef DEBUG - printf("***ufn: case 2\n"); + printf("***ufn: case 2\n"); #endif - break; - default : error("ufn : Bad UFN MP 9351 "); - break; - } - - /* Get Next Block offset form OPCODE byte */ - CURRENTFX->nextblock = (LADDR_from_68k(CurrentStackPTR) & 0x0ffff) - - (entry68k->arg_num<<1) +2 /** +1 **/ ; - - /* Setup IVar */ - IVar = Addr68k_from_LADDR((((LispPTR)(CURRENTFX->nextblock)) | STK_OFFSET)) ; - -#ifdef LISPTRACE - print(entry68k->atom_name);printf(": "); - {int cnt; - for(cnt=0;cntpc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) + entry68k->byte_num +1; - - - - defcell68k =(DefCell *) GetDEFCELL68k(entry68k->atom_name) ; - - if( defcell68k->ccodep == 0 ) - { /* This LispFunc is NOT compiled object . We must use Interpreter*/ - printf("UFN: UFN func isn't compiled OBJ \n"); - defcell68k = (DefCell *)GetDEFCELL68k(ATOM_INTERPRETER); - PushStack(TopOfStack); /* Move AtomIndex to CSTK */ - - } - - - /* Nov 25 87 take */ - tmp_fn = (struct fnhead *)Addr68k_from_LADDR( defcell68k->defpointer ) ; - -/* stack overflow check STK_SAFE is redundant?? */ - if ( (UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin +STK_SAFE) >= (UNSIGNED)StkLimO ) - { - /**printf("#### STKOVER in UFN case\n");**/ - - DOSTACKOVERFLOW(entry68k->arg_num,entry68k->byte_num); /* After STKOVR, retry current OPCODE */ - - } - - FuncObj =tmp_fn ; - - if( FuncObj->na >= 0 ) - { - /* This Function is Spread Type */ - /* Arguments on Stack Adjustment */ - rest = entry68k->arg_num - FuncObj->na ; - - while(rest <0) { - PushStack(NIL_PTR) ; - rest++; - } - CurrentStackPTR -= (rest<<1) ; - } /* if end */ - - /* Set up BF */ - CurrentStackPTR +=2; - GETWORD(CurrentStackPTR) = BF_MARK ; - GETWORD(CurrentStackPTR+1) = CURRENTFX->nextblock ; - CurrentStackPTR +=2; -/* *(++CurrentStackPTR) = CURRENTFX->nextblock ; */ - - /* Set up FX */ - GETWORD(CurrentStackPTR) = FX_MARK; - - - ((struct frameex1 *)CurrentStackPTR)->alink = LADDR_from_68k(PVar); - PVar = (DLword *)CurrentStackPTR + FRAMESIZE ; -#ifdef BIGVM - ((struct frameex1 *)CurrentStackPTR)->fnheader = - (defcell68k->defpointer) ; -#else - ((struct frameex1 *)CurrentStackPTR)->lofnheader = - (defcell68k->defpointer) & 0x0ffff ; - ((struct frameex1 *)CurrentStackPTR)->hi2fnheader = - ((defcell68k->defpointer) & SEGMASK) >> 16 ; -#endif /* BIGVM */ - - CurrentStackPTR = PVar ; - - /* Set up PVar area */ - pv_num = FuncObj->pv +1 ; - - while(pv_num > 0) { - *((LispPTR *)CurrentStackPTR) = 0x0ffff0000 ; - CurrentStackPTR += DLWORDSPER_CELL ; - *((LispPTR *)CurrentStackPTR) = 0x0ffff0000 ; - CurrentStackPTR += DLWORDSPER_CELL ; - pv_num--; + break; + default: error("ufn : Bad UFN MP 9351 "); break; } -/* CurrentStackPTR ++ ;*/ + /* Get Next Block offset form OPCODE byte */ + CURRENTFX->nextblock = + (LADDR_from_68k(CurrentStackPTR) & 0x0ffff) - (entry68k->arg_num << 1) + 2 /** +1 **/; - /* Set PC points New Function's first OPCODE */ - PC =(ByteCode *) ((UNSIGNED)FuncObj + FuncObj->startpc) ; + /* Setup IVar */ + IVar = Addr68k_from_LADDR((((LispPTR)(CURRENTFX->nextblock)) | STK_OFFSET)); -/** TopOfStack = (FuncObj->startpc -1) >> 1;**/ +#ifdef LISPTRACE + print(entry68k->atom_name); + printf(": "); + { + int cnt; + for (cnt = 0; cnt < arg_num; cnt++) { + printf(" IVAR%d :", cnt); + print(*((LispPTR *)(IVar + (cnt * 2)))); + } + } + printf("\n"); +#endif + /* Set PC to the Next Instruction and save into FX */ + CURRENTFX->pc = ((UNSIGNED)PC - (UNSIGNED)FuncObj) + entry68k->byte_num + 1; + + defcell68k = (DefCell *)GetDEFCELL68k(entry68k->atom_name); + + if (defcell68k->ccodep == 0) { /* This LispFunc is NOT compiled object . We must use Interpreter*/ + printf("UFN: UFN func isn't compiled OBJ \n"); + defcell68k = (DefCell *)GetDEFCELL68k(ATOM_INTERPRETER); + PushStack(TopOfStack); /* Move AtomIndex to CSTK */ + } + + /* Nov 25 87 take */ + tmp_fn = (struct fnhead *)Addr68k_from_LADDR(defcell68k->defpointer); + + /* stack overflow check STK_SAFE is redundant?? */ + if ((UNSIGNED)(CurrentStackPTR + tmp_fn->stkmin + STK_SAFE) >= (UNSIGNED)StkLimO) { + /**printf("#### STKOVER in UFN case\n");**/ + + DOSTACKOVERFLOW(entry68k->arg_num, entry68k->byte_num); /* After STKOVR, retry current OPCODE */ + } + + FuncObj = tmp_fn; + + if (FuncObj->na >= 0) { + /* This Function is Spread Type */ + /* Arguments on Stack Adjustment */ + rest = entry68k->arg_num - FuncObj->na; + + while (rest < 0) { + PushStack(NIL_PTR); + rest++; + } + CurrentStackPTR -= (rest << 1); + } /* if end */ + + /* Set up BF */ + CurrentStackPTR += 2; + GETWORD(CurrentStackPTR) = BF_MARK; + GETWORD(CurrentStackPTR + 1) = CURRENTFX->nextblock; + CurrentStackPTR += 2; + /* *(++CurrentStackPTR) = CURRENTFX->nextblock ; */ + + /* Set up FX */ + GETWORD(CurrentStackPTR) = FX_MARK; + + ((struct frameex1 *)CurrentStackPTR)->alink = LADDR_from_68k(PVar); + PVar = (DLword *)CurrentStackPTR + FRAMESIZE; +#ifdef BIGVM + ((struct frameex1 *)CurrentStackPTR)->fnheader = (defcell68k->defpointer); +#else + ((struct frameex1 *)CurrentStackPTR)->lofnheader = (defcell68k->defpointer) & 0x0ffff; + ((struct frameex1 *)CurrentStackPTR)->hi2fnheader = ((defcell68k->defpointer) & SEGMASK) >> 16; +#endif /* BIGVM */ + + CurrentStackPTR = PVar; + + /* Set up PVar area */ + pv_num = FuncObj->pv + 1; + + while (pv_num > 0) { + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; + CurrentStackPTR += DLWORDSPER_CELL; + *((LispPTR *)CurrentStackPTR) = 0x0ffff0000; + CurrentStackPTR += DLWORDSPER_CELL; + pv_num--; + } + + /* CurrentStackPTR ++ ;*/ + + /* Set PC points New Function's first OPCODE */ + PC = (ByteCode *)((UNSIGNED)FuncObj + FuncObj->startpc); + + /** TopOfStack = (FuncObj->startpc -1) >> 1;**/ } /* end ufn */ - #endif - diff --git a/src/ufs.c b/src/ufs.c old mode 100755 new mode 100644 index 69b5e76..f272487 --- a/src/ufs.c +++ b/src/ufs.c @@ -1,9 +1,6 @@ /* $Id: ufs.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: ufs.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,48 +15,45 @@ static char *id = "$Id: ufs.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright #include "version.h" - - - -#include +#include #ifndef DOS -#include +#include #if defined(SYSVONLY) || defined(MACOSX) || defined(FREEBSD) -#include +#include #else -#include +#include #endif /* SYSVONLY */ -#include +#include #ifndef INDIGO - /* Indigo has this duplicated in dirent.h, sigh. */ +/* Indigo has this duplicated in dirent.h, sigh. */ #ifndef OS5 #ifndef HPUX #ifndef FREEBSD -#include +#include #endif #endif #endif #endif /* INDIGO */ -#include -#include +#include +#include #ifndef AIX #ifndef APOLLO #ifndef MACOSX #ifndef FREEBSD -#include +#include #endif /* FREEBSD */ #endif /* MACOSX */ #endif /* APOLLO */ #endif /* AIX */ #if defined(SYSVONLY) || defined(FREEBSD) -#include -#include +#include +#include #endif /* SYSVONLY | FREEBSD */ -#include +#include #else /* DOS */ #include #include @@ -67,35 +61,35 @@ static char *id = "$Id: ufs.c,v 1.2 1999/01/03 02:07:41 sybalsky Exp $ Copyright #include #include -#include /* "#pragma interrupt" & '_chain_intr'*/ +#include /* "#pragma interrupt" & '_chain_intr'*/ #include #include -#include /* _XSTACK struct definition */ +#include /* _XSTACK struct definition */ #define MAXPATHLEN _MAX_PATH -#define MAXNAMLEN _MAX_PATH +#define MAXNAMLEN _MAX_PATH #define index strchr #define rindex strrchr #define alarm(x) 1 #endif /* DOS */ -#include -#include -#include -#include -#include "lispemul.h" -#include "lispmap.h" -#include "adr68k.h" -#include "lsptypes.h" -#include "lspglob.h" -#include "arith.h" -#include "stream.h" -#include "timeout.h" -#include "locfile.h" -#include "dbprint.h" +#include +#include +#include +#include +#include "lispemul.h" +#include "lispmap.h" +#include "adr68k.h" +#include "lsptypes.h" +#include "lspglob.h" +#include "arith.h" +#include "stream.h" +#include "timeout.h" +#include "locfile.h" +#include "dbprint.h" -int *Lisp_errno; -int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ +int *Lisp_errno; +int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. */ /***********************************************/ /* file-system-specific defns */ @@ -109,21 +103,22 @@ int Dummy_errno; /* If errno cell is not provided by Lisp, dummy_errno is used. #endif #define DRIVESEP ':' - /* Used to limit DOS filenames to 8.3 format */ +/* Used to limit DOS filenames to 8.3 format */ #ifdef DOS #define NameValid extensionp ? (extlen < 3) : (namelen < 8) -#define CountNameChars { extensionp ? extlen++ : namelen++; } +#define CountNameChars \ + { extensionp ? extlen++ : namelen++; } #else - /* Other file systems don't care */ +/* Other file systems don't care */ #define NameValid 1 #define CountNameChars #endif /* DOS */ #ifdef DOS -void (*prev_int_24)(); /* keeps address of previous 24 handlr*/ +void (*prev_int_24)(); /* keeps address of previous 24 handlr*/ #pragma interrupt(Int24) /* @@ -133,22 +128,21 @@ void (*prev_int_24)(); /* keeps address of previous 24 handlr*/ * DOS issues. * */ -void Int24(void) -{ - unsigned deverr, errcode; +void Int24(void) { + unsigned deverr, errcode; - union REGS regs; - _XSTACK *stk; + union REGS regs; + _XSTACK *stk; stk = (_XSTACK *)_get_stk_frame(); /* get ptr to the V86 _XSTACK frame */ deverr = stk->eax; if ((deverr & 0x00008000) == 0) /* is a disk error */ - { - stk->eax = _HARDERR_FAIL; - stk->opts |= _STK_NOINT; /* set _STK_NOINT to prevent V86 call */ - _chain_intr(prev_int_24); /* call previous int 24 handlr, if any*/ - /* (pts to 'ret' if no prev installed)*/ - } + { + stk->eax = _HARDERR_FAIL; + stk->opts |= _STK_NOINT; /* set _STK_NOINT to prevent V86 call */ + _chain_intr(prev_int_24); /* call previous int 24 handlr, if any*/ + /* (pts to 'ret' if no prev installed)*/ + } } /* @@ -157,10 +151,9 @@ void Int24(void) * Description: Initialize the hosts filesystem by installing * the "critical error handler". */ -init_host_filesystem() -{ +init_host_filesystem() { prev_int_24 = _dos_getvect(0x24); /* get addr of current handler, if any */ - _dos_setvect(0x24, Int24); /* hook our int handler to interrupt */ + _dos_setvect(0x24, Int24); /* hook our int handler to interrupt */ _dpmi_lockregion((void *)prev_int_24, sizeof(prev_int_24)); _dpmi_lockregion((void *)&Int24, 4096); } @@ -171,8 +164,7 @@ init_host_filesystem() * Description: Cleanup the filesystem specific patches. * */ -exit_host_filesystem() -{ +exit_host_filesystem() { _dos_setvect(0x24, prev_int_24); /* unhook our handlr, install previous*/ _dpmi_unlockregion((void *)prev_int_24, sizeof(prev_int_24)); _dpmi_unlockregion((void *)&Int24, 4096); @@ -180,8 +172,7 @@ exit_host_filesystem() #endif /* DOS */ - -/* +/* * Name: UFS_getfilename * * Argument: LispPTR *args args[0] @@ -198,7 +189,7 @@ exit_host_filesystem() * Value: If succeed, returns the Lisp smallp which represents the length * of the recognized full file name, otherwise Lisp NIL. * - * Side Effect: If succeed, name area (args[2]) will be replaced with the + * Side Effect: If succeed, name area (args[2]) will be replaced with the * recognized full file name. * * Description: @@ -208,81 +199,75 @@ exit_host_filesystem() * can open the file with the specified mode or not. */ -LispPTR UFS_getfilename(args) - register LispPTR *args; +LispPTR UFS_getfilename(args) register LispPTR *args; { - register char *base; - register int len, rval; - char lfname[MAXPATHLEN], file[MAXPATHLEN]; + register char *base; + register int len, rval; + char lfname[MAXPATHLEN], file[MAXPATHLEN]; - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - - LispStringLength(args[0], len, rval); - len += 1; /* Add 1 for tuminating NULL char. */ - if (len > MAXPATHLEN) FileNameTooLong(NIL); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[3])); - LispStringToCString(args[0], lfname, MAXPATHLEN); - /* - * Convert a Lisp file name to UNIX one. This is a UNIX device method. - * Thus we don't need to convert a version field. Third argument for - * unixpathname specifies it. - */ + LispStringLength(args[0], len, rval); + len += 1; /* Add 1 for tuminating NULL char. */ + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], lfname, MAXPATHLEN); +/* + * Convert a Lisp file name to UNIX one. This is a UNIX device method. + * Thus we don't need to convert a version field. Third argument for + * unixpathname specifies it. + */ #ifdef DOS - if (unixpathname(lfname, file, 0, 0, 0, 0, 0) == 0) return(NIL); + if (unixpathname(lfname, file, 0, 0, 0, 0, 0) == 0) return (NIL); #else - if (unixpathname(lfname, file, 0, 0) == 0) return(NIL); + if (unixpathname(lfname, file, 0, 0) == 0) return (NIL); #endif /* DOS */ - switch (args[1]) { + switch (args[1]) { + case RECOG_OLD: + case RECOG_OLDEST: + /* + * "Old" and "Oldest" means the "existing" file. All we have to do + * is to make sure it is an existing file or not. + */ + TIMEOUT(rval = access(file, F_OK)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } + break; - case RECOG_OLD: - case RECOG_OLDEST: - /* - * "Old" and "Oldest" means the "existing" file. All we have to do - * is to make sure it is an existing file or not. - */ - TIMEOUT(rval = access(file, F_OK)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } - break; + case RECOG_NEW: + case RECOG_OLD_NEW: + case RECOG_NON: + /* + * "New" file means the "not existing" file. UNIX device always + * recognizes a not existing file as if, the subsequent OPENFILE will + * find the truth. + * "Non" reognition is used to recognize a sysout file. + */ + break; + } + /* + * Now, we convert a file name back to Lisp format. The version field have not + * to be converted. The fourth argument for lisppathname specifies it. + */ + if (lisppathname(file, lfname, 0, 0) == 0) return (NIL); - case RECOG_NEW: - case RECOG_OLD_NEW: - case RECOG_NON: - /* - * "New" file means the "not existing" file. UNIX device always - * recognizes a not existing file as if, the subsequent OPENFILE will - * find the truth. - * "Non" reognition is used to recognize a sysout file. - */ - break; - } - /* - * Now, we convert a file name back to Lisp format. The version field have not - * to be converted. The fourth argument for lisppathname specifies it. - */ - if (lisppathname(file, lfname, 0, 0) == 0) return(NIL); - - STRING_BASE(args[2], base); - len = strlen(lfname); + STRING_BASE(args[2], base); + len = strlen(lfname); #ifndef BYTESWAP - strncpy(base, lfname, len + 1); + strncpy(base, lfname, len + 1); #else - StrNCpyFromCToLisp(base, lfname, len + 1); + StrNCpyFromCToLisp(base, lfname, len + 1); #endif /* BYTESWAP */ - - return(GetSmallp(len)); + return (GetSmallp(len)); } - - - -/* +/* * Name: UFS_deletefile * * Argument: LispPTR *args args[0] @@ -301,43 +286,39 @@ LispPTR UFS_getfilename(args) * a specified file. */ -LispPTR UFS_deletefile(args) - register LispPTR *args; +LispPTR UFS_deletefile(args) register LispPTR *args; { - char file[MAXPATHLEN], fbuf[MAXPATHLEN]; - register int len, rval; - - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); - - LispStringLength(args[0], len, rval); - len += 1; - if (len > MAXPATHLEN) FileNameTooLong(NIL); + char file[MAXPATHLEN], fbuf[MAXPATHLEN]; + register int len, rval; - LispStringToCString(args[0], fbuf, MAXPATHLEN); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[1])); + + LispStringLength(args[0], len, rval); + len += 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); #ifdef DOS - if (unixpathname(fbuf, file, 0, 0, 0, 0, 0) == 0) return(NIL); + if (unixpathname(fbuf, file, 0, 0, 0, 0, 0) == 0) return (NIL); #else - if (unixpathname(fbuf, file, 0, 0) == 0) return(NIL); + if (unixpathname(fbuf, file, 0, 0) == 0) return (NIL); #endif /* DOS */ - /* - * On UNIX device, all we have to do is just to unlink the file. - */ - TIMEOUT(rval = unlink(file)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } + /* + * On UNIX device, all we have to do is just to unlink the file. + */ + TIMEOUT(rval = unlink(file)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } - return(ATOM_T); + return (ATOM_T); } - - - -/* +/* * Name: UFS_renamefile * * Argument: LispPTR *args args[0] @@ -360,48 +341,44 @@ LispPTR UFS_deletefile(args) * a specified file. */ -LispPTR UFS_renamefile(args) - register LispPTR *args; +LispPTR UFS_renamefile(args) register LispPTR *args; { - char fbuf[MAXPATHLEN], src[MAXPATHLEN], dst[MAXPATHLEN]; - int rval, len; - - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - - LispStringLength(args[0], len, rval); - len += 1; - if (len > MAXPATHLEN) FileNameTooLong(NIL); + char fbuf[MAXPATHLEN], src[MAXPATHLEN], dst[MAXPATHLEN]; + int rval, len; - LispStringLength(args[1], len, rval); - len += 1; - if (len > MAXPATHLEN) FileNameTooLong(NIL); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - LispStringToCString(args[0], fbuf, MAXPATHLEN); + LispStringLength(args[0], len, rval); + len += 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringLength(args[1], len, rval); + len += 1; + if (len > MAXPATHLEN) FileNameTooLong(NIL); + + LispStringToCString(args[0], fbuf, MAXPATHLEN); #ifdef DOS - if (unixpathname(fbuf, src, 0, 0, 0, 0, 0) == 0) return(NIL); + if (unixpathname(fbuf, src, 0, 0, 0, 0, 0) == 0) return (NIL); #else - if (unixpathname(fbuf, src, 0, 0) == 0) return(NIL); + if (unixpathname(fbuf, src, 0, 0) == 0) return (NIL); #endif /* DOS */ - LispStringToCString(args[1], fbuf, MAXPATHLEN); + LispStringToCString(args[1], fbuf, MAXPATHLEN); #ifdef DOS - if (unixpathname(fbuf, dst, 0, 0, 0, 0, 0) == 0) return(NIL); + if (unixpathname(fbuf, dst, 0, 0, 0, 0, 0) == 0) return (NIL); #else - if (unixpathname(fbuf, dst, 0, 0) == 0) return(NIL); + if (unixpathname(fbuf, dst, 0, 0) == 0) return (NIL); #endif /* DOS */ - TIMEOUT(rval = rename(src, dst)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } + TIMEOUT(rval = rename(src, dst)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } - return(ATOM_T); + return (ATOM_T); } - - - /* * Name: UFS_directorynamep * @@ -434,60 +411,55 @@ LispPTR UFS_renamefile(args) * the directory name representation. */ -LispPTR UFS_directorynamep(args) - register LispPTR *args; +LispPTR UFS_directorynamep(args) register LispPTR *args; { - char dirname[MAXPATHLEN]; - char fullname[MAXPATHLEN]; - register int len, rval; - register char *base; - struct stat sbuf; + char dirname[MAXPATHLEN]; + char fullname[MAXPATHLEN]; + register int len, rval; + register char *base; + struct stat sbuf; - ERRSETJMP(NIL); - Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - - LispStringLength(args[0], len, rval); - len += 1; - /* -2 for the initial and trail directory delimitor. */ - if (len > MAXPATHLEN - 2) FileNameTooLong(NIL); + ERRSETJMP(NIL); + Lisp_errno = (int *)(Addr68k_from_LADDR(args[2])); - LispStringToCString(args[0], dirname, MAXPATHLEN); + LispStringLength(args[0], len, rval); + len += 1; + /* -2 for the initial and trail directory delimitor. */ + if (len > MAXPATHLEN - 2) FileNameTooLong(NIL); - /* Convert Xerox Lisp file naming convention to Unix one. */ + LispStringToCString(args[0], dirname, MAXPATHLEN); + +/* Convert Xerox Lisp file naming convention to Unix one. */ #ifdef DOS - if (unixpathname(dirname, fullname, 0, 0, 0, 0, 0) == 0) return(NIL); + if (unixpathname(dirname, fullname, 0, 0, 0, 0, 0) == 0) return (NIL); #else - if (unixpathname(dirname, fullname, 0, 0) == 0) return(NIL); + if (unixpathname(dirname, fullname, 0, 0) == 0) return (NIL); #endif /* DOS */ - TIMEOUT(rval = stat(fullname, &sbuf)); - if (rval == -1) { - *Lisp_errno = errno; - return(NIL); - } + TIMEOUT(rval = stat(fullname, &sbuf)); + if (rval == -1) { + *Lisp_errno = errno; + return (NIL); + } - if ((sbuf.st_mode & S_IFMT) != S_IFDIR) return(NIL); - - /* Convert Unix file naming convention to Xerox Lisp one. */ - if (lisppathname(fullname, dirname, 1, 0) == 0) return(NIL); - - len = strlen(dirname); - STRING_BASE(args[1], base); - -#ifndef BYTESWAP - strncpy(base, dirname, len + 1); + if ((sbuf.st_mode & S_IFMT) != S_IFDIR) return (NIL); + + /* Convert Unix file naming convention to Xerox Lisp one. */ + if (lisppathname(fullname, dirname, 1, 0) == 0) return (NIL); + + len = strlen(dirname); + STRING_BASE(args[1], base); + +#ifndef BYTESWAP + strncpy(base, dirname, len + 1); #else - StrNCpyFromCToLisp(base, dirname, len + 1); + StrNCpyFromCToLisp(base, dirname, len + 1); #endif /* BYTESWAP */ - - return(GetSmallp(len)); + return (GetSmallp(len)); } - - - -/* +/* * Name: unixpathname * * Argument: char *src Xerox Lisp syntax pathname. @@ -522,388 +494,383 @@ LispPTR UFS_directorynamep(args) * */ #ifdef DOS -int unixpathname(src, dst, versionp, genp, drive, extlenptr, rawname) - char *drive; - int *extlenptr; - char *rawname; +int unixpathname(src, dst, versionp, genp, drive, extlenptr, rawname) char *drive; +int *extlenptr; +char *rawname; #else int unixpathname(src, dst, versionp, genp) #endif /* DOS */ - register char *src; - register char *dst; - register int versionp; - register int genp; +register char *src; +register char *dst; +register int versionp; +register int genp; { - register char *cp, *dp, *np, *rp; - register int newdirflg; - char name[64]; - char lfname[MAXPATHLEN], fbuf1[MAXPATHLEN], fbuf2[MAXPATHLEN]; - char ver1[VERSIONLEN], ver2[VERSIONLEN]; - struct passwd *pwd; - + register char *cp, *dp, *np, *rp; + register int newdirflg; + char name[64]; + char lfname[MAXPATHLEN], fbuf1[MAXPATHLEN], fbuf2[MAXPATHLEN]; + char ver1[VERSIONLEN], ver2[VERSIONLEN]; + struct passwd *pwd; + #ifdef DOS - int namelen = 0, extlen = 0; /* lengths of name & extension */ - int extensionp = 0; /* T if we're in the extension */ - int version = 1; /* version # for this file */ + int namelen = 0, extlen = 0; /* lengths of name & extension */ + int extensionp = 0; /* T if we're in the extension */ + int version = 1; /* version # for this file */ +#endif /* DOS */ + +/* If there's a drive letter, it and a colon come first */ +#ifdef DOS + if (drive && (*drive)) { + *dst++ = *drive; + *dst++ = DRIVESEP; + } #endif /* DOS */ + /* + * The UNIX root directory is represented as "<" in Xerox Lisp generic + * file system code. + */ + if (strcmp(src, "<") == 0) { + strcpy(dst, DIRSEPSTR); + return (1); + } - /* If there's a drive letter, it and a colon come first */ + /* Copy src to protect it from destructive modification. */ + strcpy(lfname, src); + +/* + * If versionp is specified, we have to deal with the version field first, + * because the quotation mark which quotes the semicolon might be lost + * in the course of the following conversion. + */ #ifdef DOS - if (drive && (*drive)) - { - *dst++ = *drive; - *dst++ = DRIVESEP; - } -#endif /* DOS */ - - /* - * The UNIX root directory is represented as "<" in Xerox Lisp generic - * file system code. - */ - if (strcmp(src, "<") == 0) { - strcpy(dst, DIRSEPSTR); - return(1); - } - - /* Copy src to protect it from destructive modification. */ - strcpy(lfname, src); - - /* - * If versionp is specified, we have to deal with the version field first, - * because the quotation mark which quotes the semicolon might be lost - * in the course of the following conversion. - */ -#ifdef DOS - if (versionp) LispVersionToUnixVersion(lfname, version) - else version = -1; + if (versionp) LispVersionToUnixVersion(lfname, version) else version = -1; #else - if (versionp) LispVersionToUnixVersion(lfname); + if (versionp) LispVersionToUnixVersion(lfname); #endif /* DOS */ - cp = lfname; - dp = dst; + cp = lfname; + dp = dst; - /* - * We have to deal with the case in which the pathname is started with - * the meta character ('.', '~'). - */ + /* + * We have to deal with the case in which the pathname is started with + * the meta character ('.', '~'). + */ - switch (*cp) { - - case '.': - switch (*(cp + 1)) { - - case '.': - if (*(cp + 2) == '>' || *(cp +2) == '\0') { - /* - * "..>" or ".." means the parent directory of the - * user's current working directory. - */ - if (getwd(dst) == 0) return(0); + switch (*cp) { + case '.': + switch (*(cp + 1)) { + case '.': + if (*(cp + 2) == '>' || *(cp + 2) == '\0') { + /* + * "..>" or ".." means the parent directory of the + * user's current working directory. + */ + if (getwd(dst) == 0) return (0); #ifdef DOS - dp = max(strrchr(dst,'/'),strrchr(dst,DIRSEP)); + dp = max(strrchr(dst, '/'), strrchr(dst, DIRSEP)); #else - dp = strrchr(dst, '/'); + dp = strrchr(dst, '/'); #endif /* DOS */ - - dp++; - if (*(cp + 2) == '\0') - cp += 2; - else - cp += 3; - } else { - /* Insert the initial directory delimiter. */ - *dp++ = DIRSEP; - } - break; + + dp++; + if (*(cp + 2) == '\0') + cp += 2; + else + cp += 3; + } else { + /* Insert the initial directory delimiter. */ + *dp++ = DIRSEP; + } + break; #ifdef DOS - case '/': - case DIRSEP: + case '/': + case DIRSEP: #endif - case '>': - /* ".>" means the user's current working directory. */ - if (getwd(dst) == 0) return(0); - while (*dp != '\0') dp++; + case '>': + /* ".>" means the user's current working directory. */ + if (getwd(dst) == 0) return (0); + while (*dp != '\0') dp++; - *dp++ = DIRSEP; - cp += 2; - break; - - case '\0': - /* "." also means the user's current working directory. */ - if (getwd(dst) == 0) return(0); - while (*dp != '\0') dp++; + *dp++ = DIRSEP; + cp += 2; + break; - *dp++ = DIRSEP; - cp++; - break; + case '\0': + /* "." also means the user's current working directory. */ + if (getwd(dst) == 0) return (0); + while (*dp != '\0') dp++; - default: - /* Insert the initial directory delimiter. */ - *dp++ = DIRSEP; - break; - } - break; + *dp++ = DIRSEP; + cp++; + break; + + default: + /* Insert the initial directory delimiter. */ + *dp++ = DIRSEP; + break; + } + break; #ifndef DOS - case '~': - if (*(cp + 1) == '>' || *(cp + 1) == '\0') { - /* "~>" or "~" means the user's home directory. */ - TIMEOUT(pwd = getpwuid(getuid())); - if (pwd == NULL) return(0); + case '~': + if (*(cp + 1) == '>' || *(cp + 1) == '\0') { + /* "~>" or "~" means the user's home directory. */ + TIMEOUT(pwd = getpwuid(getuid())); + if (pwd == NULL) return (0); - strcpy(dst, pwd->pw_dir); - while (*dp != '\0') dp++; - if (*(dp -1) != DIRSEP) { - /* - * Usually system administrators specify the users' - * home directories in the /etc/passwd without - * the trail directory delimiter. - */ - *dp++ = DIRSEP; - } - if (*(cp + 1) == '\0') - cp++; - else - cp += 2; - } else { - /* - * In this case, we assume some user's home directory - * is specifed in the form "~username". - */ - for (++cp, np = name; *cp != '\0' && *cp != '>';) *np++ = *cp++ ; - *np = '\0'; - TIMEOUT(pwd = getpwnam(name)); - if (pwd == NULL) return(0); + strcpy(dst, pwd->pw_dir); + while (*dp != '\0') dp++; + if (*(dp - 1) != DIRSEP) { + /* + * Usually system administrators specify the users' + * home directories in the /etc/passwd without + * the trail directory delimiter. + */ + *dp++ = DIRSEP; + } + if (*(cp + 1) == '\0') + cp++; + else + cp += 2; + } else { + /* + * In this case, we assume some user's home directory + * is specifed in the form "~username". + */ + for (++cp, np = name; *cp != '\0' && *cp != '>';) *np++ = *cp++; + *np = '\0'; + TIMEOUT(pwd = getpwnam(name)); + if (pwd == NULL) return (0); - strcpy(dst, pwd->pw_dir); - while (*dp != '\0') dp++; - if (*(dp -1) != DIRSEP) { - /* - * Usually system administrators specify the users' - * home directories in the /etc/passwd without - * the trail directory delimiter. - */ - *dp++ = DIRSEP; - } + strcpy(dst, pwd->pw_dir); + while (*dp != '\0') dp++; + if (*(dp - 1) != DIRSEP) { + /* + * Usually system administrators specify the users' + * home directories in the /etc/passwd without + * the trail directory delimiter. + */ + *dp++ = DIRSEP; + } - if (*cp == '>') cp++; - } - break; + if (*cp == '>') cp++; + } + break; #else - /* For DOS, ignore ~> or ~/ or ~ */ - case '~': - if (*(cp + 1) == '>' || *(cp + 1) == '\0') - { - /* "~>" or "~" means the user's home directory. */ + /* For DOS, ignore ~> or ~/ or ~ */ + case '~': + if (*(cp + 1) == '>' || *(cp + 1) == '\0') { + /* "~>" or "~" means the user's home directory. */ - *dp++ = DIRSEP; - if (*(cp + 1) == '\0') cp++; - else cp += 2; - } - else - { - /* - * In this case, we assume some user's home directory - * is specifed in the form "~username". - */ - for (++cp, np = name; *cp != '\0' && *cp != '>';) *np++ = *cp++ ; - *dp++ = DIRSEP; + *dp++ = DIRSEP; + if (*(cp + 1) == '\0') + cp++; + else + cp += 2; + } else { + /* + * In this case, we assume some user's home directory + * is specifed in the form "~username". + */ + for (++cp, np = name; *cp != '\0' && *cp != '>';) *np++ = *cp++; + *dp++ = DIRSEP; - if (*cp == '>') cp++; - } - break; + if (*cp == '>') cp++; + } + break; #endif /* DOS */ - default: - *dp++ = '/'; /* Insert the initial directory delimiter. */ - break; - } + default: + *dp++ = '/'; /* Insert the initial directory delimiter. */ + break; + } - /* - * At this point, cp is placed at the point from which the source pathname - * will be scaned, and dp is placed at the point on dst from which the - * pathname will be copied. - */ + /* + * At this point, cp is placed at the point from which the source pathname + * will be scaned, and dp is placed at the point on dst from which the + * pathname will be copied. + */ - newdirflg = 1; - while (*cp != '\0') { - if (newdirflg) { - /* - * The new directory component starts. We have to care about - * the meta characters again. This time, the tilde character - * has no special meaning. - */ - switch (*cp) { + newdirflg = 1; + while (*cp != '\0') { + if (newdirflg) { + /* + * The new directory component starts. We have to care about + * the meta characters again. This time, the tilde character + * has no special meaning. + */ + switch (*cp) { + case '.': + switch (*(cp + 1)) { + case '.': + /* "..>" or ".." */ + if (*(cp + 2) == '>' || *(cp + 2) == '\0') { + /* + * We have to check if we have already + * backed to the root directory or not. + */ + if ((dp - 1) != dst) { + /* + * We are not at the root + * directory. Back to the + * parent directory. + */ + for (dp -= 2; *dp != '/'; dp--) {} + dp++; + } + if (*(cp + 2) == '\0') + cp += 2; + else + cp += 3; + } else { + /* + * (IL:DIRECTORY "{DSK}.") is translated + * as (IL:DIRECTORY "{DSK}~>.;*"). + * The Lisp directory is translated as + * like "/users/akina/..~*~" by + * unixpathname. Although such + * file name representaion makes no sense, + * to avoid infinite loop, skip the + * first period here, as well as down + * a newdirflg. + */ + cp++; + newdirflg = 0; + } + break; - case '.': - switch (*(cp + 1)) { + case '>': + /* ".>" */ + cp += 2; + break; - case '.': - /* "..>" or ".." */ - if (*(cp + 2) == '>' || *(cp + 2) == '\0') { - /* - * We have to check if we have already - * backed to the root directory or not. - */ - if ((dp - 1) != dst) { - /* - * We are not at the root - * directory. Back to the - * parent directory. - */ - for (dp -= 2; *dp != '/'; dp--) {} - dp++; - } - if (*(cp + 2) == '\0') - cp += 2; - else - cp += 3; - } else { - /* - * (IL:DIRECTORY "{DSK}.") is translated - * as (IL:DIRECTORY "{DSK}~>.;*"). - * The Lisp directory is translated as - * like "/users/akina/..~*~" by - * unixpathname. Although such - * file name representaion makes no sense, - * to avoid infinite loop, skip the - * first period here, as well as down - * a newdirflg. - */ - cp++; - newdirflg = 0; - } - break; + case '\0': + /* "." */ + cp++; + break; - case '>': - /* ".>" */ - cp += 2; - break; - - case '\0': - /* "." */ - cp++; - break; + default: + *dp++ = *cp++; + newdirflg = 0; + break; + } + break; - default: - *dp++ = *cp++; - newdirflg = 0; - break; - } - break; + case '\'': + /* + * The first character of the new directory component + * is a quotation mark which is the quote character + * in the Xerox Lisp file naming convention. Copy the + * next character and skip the quoted character. + */ + *dp++ = *(cp + 1); + cp += 2; + newdirflg = 0; + break; - case '\'': - /* - * The first character of the new directory component - * is a quotation mark which is the quote character - * in the Xerox Lisp file naming convention. Copy the - * next character and skip the quoted character. - */ - *dp++ = *(cp + 1); - cp += 2; - newdirflg = 0; - break; - - default: - *dp++ = *cp++; - newdirflg = 0; - break; - } - } else { - switch (*cp) { + default: + *dp++ = *cp++; + newdirflg = 0; + break; + } + } else { + switch (*cp) { #ifdef DOS - case '/': /* in DOS, must xlate / also. */ -#endif /* DOS */ - case '>': - /* - * Xerox Lisp directory delimiter '>' is translated into - * UNIX one, '/'. - */ - *dp = DIRSEP; - dp++; - cp++; - newdirflg = 1; /* Turn on the new directory flag. */ + case '/': /* in DOS, must xlate / also. */ +#endif /* DOS */ + case '>': + /* + * Xerox Lisp directory delimiter '>' is translated into + * UNIX one, '/'. + */ + *dp = DIRSEP; + dp++; + cp++; + newdirflg = 1; /* Turn on the new directory flag. */ #ifdef DOS - namelen = extlen = 0; - rp = dp; /* remember where raw filename starts */ -#endif /* DOS */ - break; - - case '\'': - /* - * The special characters in the Xerox Lisp file naming - * convention are quoted with the quote character. - * They are all valid in the UNIX file naming convention. - * So only we have to do is to skip the quotation mark - * and copy the next character. - */ + namelen = extlen = 0; + rp = dp; /* remember where raw filename starts */ +#endif /* DOS */ + break; + + case '\'': +/* + * The special characters in the Xerox Lisp file naming + * convention are quoted with the quote character. + * They are all valid in the UNIX file naming convention. + * So only we have to do is to skip the quotation mark + * and copy the next character. + */ #ifdef DOS if (NameValid) *dp++ = *(cp + 1); - CountNameChars; + CountNameChars; #endif /* DOS */ - cp += 2; - break; + cp += 2; + break; #ifdef DOS case '.': /* start of extension, if not already */ - if (!extensionp) *dp++ = *cp++; else cp++; + if (!extensionp) + *dp++ = *cp++; + else + cp++; extensionp = 1; break; #endif /* DOS */ - default: - if (NameValid) *dp++ = *cp++; else cp++; - CountNameChars; - break; - } - } - } - *dp = '\0'; - if (!newdirflg && !genp) { - /* - * If the last chracter in dst is a period, it have to be handled - * specially, because it might be used to specify that src has no - * extension field. This case can be distinguish by examining the - * character just before the period. - * If the specified pathname is one like "~>..", the last meta character - * matches this case. Thus we check newdirflg first so as not to be - * confused by this case. - * - * Only case in which genp is 1 is unixpathname is used to convert - * a pattern which is used to enumerate directory. In this csae, - * for the convinience of the pattern matching routines, we don't - * care about the last period character. - */ - strcpy(fbuf1, lfname); - strcpy(fbuf2, dst); - separate_version(fbuf1, ver1, 1); - separate_version(fbuf2, ver2, 1); - for (cp = fbuf1; *cp; cp++) {} - for (dp = fbuf2; *dp; dp++) {} - if (*(cp - 1) == '.') { - if (*(cp - 2) != '\'' || - ((cp - 3) > fbuf1 && *(cp - 3) == '\'')) { - /* - * The last period is not been quoted. It is used - * to specify the no extension case. We have to - * omit this period. - */ - *(dp - 1) = '\0'; - } - } + default: + if (NameValid) + *dp++ = *cp++; + else + cp++; + CountNameChars; + break; + } + } + } + *dp = '\0'; + if (!newdirflg && !genp) { + /* + * If the last chracter in dst is a period, it have to be handled + * specially, because it might be used to specify that src has no + * extension field. This case can be distinguish by examining the + * character just before the period. + * If the specified pathname is one like "~>..", the last meta character + * matches this case. Thus we check newdirflg first so as not to be + * confused by this case. + * + * Only case in which genp is 1 is unixpathname is used to convert + * a pattern which is used to enumerate directory. In this csae, + * for the convinience of the pattern matching routines, we don't + * care about the last period character. + */ + strcpy(fbuf1, lfname); + strcpy(fbuf2, dst); + separate_version(fbuf1, ver1, 1); + separate_version(fbuf2, ver2, 1); + for (cp = fbuf1; *cp; cp++) {} + for (dp = fbuf2; *dp; dp++) {} + if (*(cp - 1) == '.') { + if (*(cp - 2) != '\'' || ((cp - 3) > fbuf1 && *(cp - 3) == '\'')) { + /* + * The last period is not been quoted. It is used + * to specify the no extension case. We have to + * omit this period. + */ + *(dp - 1) = '\0'; + } + } #ifdef DOS - if (version >= 0) sprintf(ver2, "%d", version); - else *ver2 = '\0'; + if (version >= 0) + sprintf(ver2, "%d", version); + else + *ver2 = '\0'; #endif /* DOS */ - ConcNameAndVersion(fbuf2, ver2, dst); - } - return(1); + ConcNameAndVersion(fbuf2, ver2, dst); + } + return (1); } - - - -/* +/* * Name: lisppathname * * Argument: char *fullname UNIX full pathname. @@ -940,255 +907,237 @@ int unixpathname(src, dst, versionp, genp) * */ -int lisppathname(fullname, lispname, dirp, versionp) - register char *fullname; - register char *lispname; - register int dirp; - register int versionp; +int lisppathname(fullname, lispname, dirp, versionp) register char *fullname; +register char *lispname; +register int dirp; +register int versionp; { - register char *cp, *dp, *lnamep, *cnamep; - char namebuf[MAXPATHLEN], fbuf[MAXPATHLEN], ver[VERSIONLEN], drive; - register int i, mask, extensionp; - - if (strcmp(fullname, DIRSEPSTR) == 0) { - strcpy(lispname, "<"); - return(1); - } - /* Split off the drive, if there is one. */ - if (fullname[1] == DRIVESEP) - { - *lispname++ = *fullname++; - *lispname++ = *fullname++; + register char *cp, *dp, *lnamep, *cnamep; + char namebuf[MAXPATHLEN], fbuf[MAXPATHLEN], ver[VERSIONLEN], drive; + register int i, mask, extensionp; + + if (strcmp(fullname, DIRSEPSTR) == 0) { + strcpy(lispname, "<"); + return (1); + } + /* Split off the drive, if there is one. */ + if (fullname[1] == DRIVESEP) { + *lispname++ = *fullname++; + *lispname++ = *fullname++; + } + + if (!dirp) { + /* + * The characters which are dealt with specialy (i.e. are quoted) + * in the Xerox Lisp file naming convention are all valid in UNIX + * file name convetion. So the conversion rule is almost + * straightforward except the "extension" field. Only glancing + * the UNIX file name, we cannot determine which period character + * should be quoted in the result Xerox Lisp file name when more + * than one period are included in the UNIX file name. In such + * case, we have to refer to the Xerox Lisp file name representation + * which is specified the user. Thus, at first, extract the + * name field from the original Lisp file name. + */ + cp = lispname; + lnamep = cp - 1; + while (*cp != '\0') { + switch (*cp) { + case '>': + lnamep = cp + 1; + cp++; + break; + + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; + + default: cp++; break; } + } + /* Name field in the UNIX file name representation. */ + cnamep = strrchr(fullname, DIRSEP) + 1; + } else { + cnamep = fullname + strlen(fullname); + } - if (!dirp) { - /* - * The characters which are dealt with specialy (i.e. are quoted) - * in the Xerox Lisp file naming convention are all valid in UNIX - * file name convetion. So the conversion rule is almost - * straightforward except the "extension" field. Only glancing - * the UNIX file name, we cannot determine which period character - * should be quoted in the result Xerox Lisp file name when more - * than one period are included in the UNIX file name. In such - * case, we have to refer to the Xerox Lisp file name representation - * which is specified the user. Thus, at first, extract the - * name field from the original Lisp file name. - */ - cp = lispname; - lnamep = cp - 1; - while (*cp != '\0') { - switch (*cp) { - - case '>': - lnamep = cp + 1; - cp++; - break; + /* + * Convertion rule of file name from UNIX to Xerox Lisp. + * UNIX Lisp + * / < only if it is used as a root directory + * delimiter. + * / > if used as a directory delimiter for other + * directories than root directory. + * > '> + * ; '; + * ' '' + * . '. only if it is used as a part of the extension + * field. + * others as if + */ - case '\'': - if (*(cp + 1) != '\0') - cp += 2; - else - cp++; - break; + cp = fullname + 1; + dp = namebuf; + *dp++ = '<'; - default: - cp++; - break; - } - } - /* Name field in the UNIX file name representation. */ - cnamep = strrchr(fullname, DIRSEP) + 1; - } else { - cnamep = fullname + strlen(fullname); - } + if (*cp == '<') { + /* + * If the first character of the initial directory is '<', + * it should be quoted in the result Lisp file name. + */ + *dp++ = '\''; + *dp++ = *cp++; + } - /* - * Convertion rule of file name from UNIX to Xerox Lisp. - * UNIX Lisp - * / < only if it is used as a root directory - * delimiter. - * / > if used as a directory delimiter for other - * directories than root directory. - * > '> - * ; '; - * ' '' - * . '. only if it is used as a part of the extension - * field. - * others as if - */ - - cp = fullname + 1; - dp = namebuf; - *dp++ = '<'; - - if (*cp == '<') { - /* - * If the first character of the initial directory is '<', - * it should be quoted in the result Lisp file name. - */ - *dp++ = '\''; - *dp++ = *cp++; - } - - while (cp < cnamep) { - switch (*cp) { - - case '>': - case ';': + while (cp < cnamep) { + switch (*cp) { + case '>': + case ';': #ifndef DOS - case '\'': + case '\'': #endif /* DOS */ - *dp++ = '\''; - *dp++ = *cp++; - break; + *dp++ = '\''; + *dp++ = *cp++; + break; #ifdef DOS - case '/': + case '/': #endif - case DIRSEP: - *dp++ = '>'; - cp++; - break; + case DIRSEP: + *dp++ = '>'; + cp++; + break; - default: - *dp++ = *cp++; - break; - } - } + default: *dp++ = *cp++; break; + } + } - if (dirp) { - if (*(dp - 1) != '>' || *(dp - 2) == '\'') *dp++ = '>'; - *dp = '\0'; - strcpy(lispname, namebuf); - return(1); - } + if (dirp) { + if (*(dp - 1) != '>' || *(dp - 2) == '\'') *dp++ = '>'; + *dp = '\0'; + strcpy(lispname, namebuf); + return (1); + } - /* - * Be careful dealing with the extenstion field. If we encounter with the - * period mark which was quoted in the original Lisp file name, we have - * to quote it in the result file name. - * First we count the period mark included in the Lisp file name, and - * remember the position of the quoted period. Then when we met the - * period while we are converting the UNIX file name into Lisp one, - * examine it if it is a quoted one or not, then if so, we quote it. - */ + /* + * Be careful dealing with the extenstion field. If we encounter with the + * period mark which was quoted in the original Lisp file name, we have + * to quote it in the result file name. + * First we count the period mark included in the Lisp file name, and + * remember the position of the quoted period. Then when we met the + * period while we are converting the UNIX file name into Lisp one, + * examine it if it is a quoted one or not, then if so, we quote it. + */ - mask = 0; - i = 1; - lnamep++; + mask = 0; + i = 1; + lnamep++; - while (*lnamep) { - if (*lnamep == '.') { - if (lnamep != lispname && *(lnamep - 1) == '\'') mask |= i; - i <<= 1; - } - lnamep++; - } - - i = 1; - while (*cp) { - switch (*cp) { + while (*lnamep) { + if (*lnamep == '.') { + if (lnamep != lispname && *(lnamep - 1) == '\'') mask |= i; + i <<= 1; + } + lnamep++; + } + + i = 1; + while (*cp) { + switch (*cp) { #ifdef DOS - case DIRSEP: *dp++ = '/'; cp++; break; + case DIRSEP: + *dp++ = '/'; + cp++; + break; #endif - case '>': - case ';': - case '\'': - *dp++ = '\''; - *dp++ = *cp++; - break; + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; - case '.': - if ((i & mask) == i) { - /* This period should be quoted. */ - *dp++ = '\''; - *dp++ = *cp++; - } else { - *dp++ = *cp++; - } - i <<= 1; - break; + case '.': + if ((i & mask) == i) { + /* This period should be quoted. */ + *dp++ = '\''; + *dp++ = *cp++; + } else { + *dp++ = *cp++; + } + i <<= 1; + break; - default: - *dp++ = *cp++; - break; - } - } + default: *dp++ = *cp++; break; + } + } - *dp = '\0'; + *dp = '\0'; - /* - * exntensionp indicates whether exentsion field is included in a file name - * or not. If extenstion field is not included, we have to add a period - * to specify empty extension field. - */ - strcpy(fbuf, namebuf); - dp = cp = fbuf; - while (*cp) { - switch (*cp) { + /* + * exntensionp indicates whether exentsion field is included in a file name + * or not. If extenstion field is not included, we have to add a period + * to specify empty extension field. + */ + strcpy(fbuf, namebuf); + dp = cp = fbuf; + while (*cp) { + switch (*cp) { + case '>': + dp = cp; + cp++; + break; - case '>': - dp = cp; - cp++; - break; + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; - case '\'': - if (*(cp + 1) != '\0') - cp += 2; - else - cp++; - break; + default: cp++; break; + } + } + cp = dp + 1; + if (versionp) separate_version(fbuf, ver, 1); + extensionp = 0; + while (*cp && !extensionp) { + switch (*cp) { + case '.': extensionp = 1; break; - default: - cp++; - break; - } - } - cp = dp + 1; - if (versionp) separate_version(fbuf, ver, 1); - extensionp = 0; - while (*cp && !extensionp) { - switch (*cp) { + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; - case '.': - extensionp = 1; - break; + default: cp++; break; + } + } + if (!extensionp) { + *cp++ = '.'; + *cp = '\0'; + } + if (versionp && *ver != '\0') { + ConcNameAndVersion(fbuf, ver, namebuf); + } else { + strcpy(namebuf, fbuf); + } - case '\'': - if (*(cp + 1) != '\0') - cp += 2; - else - cp++; - break; + /* + * Now, it's time to convert the version field. + */ + if (!dirp && versionp) UnixVersionToLispVersion(namebuf, 0); - default: - cp++; - break; - } - } - if (!extensionp) { - *cp++ = '.'; - *cp = '\0'; - } - if (versionp && *ver != '\0') { - ConcNameAndVersion(fbuf, ver, namebuf); - } else { - strcpy(namebuf, fbuf); - } - - /* - * Now, it's time to convert the version field. - */ - if (!dirp && versionp) UnixVersionToLispVersion(namebuf, 0); - - strcpy(lispname, namebuf); - return(1); + strcpy(lispname, namebuf); + return (1); } - - - -/* +/* * Name: quote_fname * * Argument: char *file The root file name in UNIX format. "Root" @@ -1216,83 +1165,73 @@ int lisppathname(fullname, lispname, dirp, versionp) * Lisp sense or not. */ -int quote_fname(file) - register char *file; +int quote_fname(file) register char *file; { - register char *cp, *dp; - register int extensionp; - char fbuf[MAXNAMLEN + 1], namebuf[MAXNAMLEN + 1], ver[VERSIONLEN]; - - cp = file; - dp = fbuf; + register char *cp, *dp; + register int extensionp; + char fbuf[MAXNAMLEN + 1], namebuf[MAXNAMLEN + 1], ver[VERSIONLEN]; - while (*cp) { - switch (*cp) { + cp = file; + dp = fbuf; - case '>': - case ';': - case '\'': - *dp++ = '\''; - *dp++ = *cp++; - break; + while (*cp) { + switch (*cp) { + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; - default: - *dp++ = *cp++; - break; - } - } - *dp = '\0'; + default: *dp++ = *cp++; break; + } + } + *dp = '\0'; - /* - * exntensionp indicates whether exentsion field is included in a file - * name or not. If extenstion field is not included, we have to add a - * period to specify empty extension field. - */ - separate_version(fbuf, ver, 1); - cp = fbuf; - extensionp = 0; - while (*cp && !extensionp) { - switch (*cp) { + /* + * exntensionp indicates whether exentsion field is included in a file + * name or not. If extenstion field is not included, we have to add a + * period to specify empty extension field. + */ + separate_version(fbuf, ver, 1); + cp = fbuf; + extensionp = 0; + while (*cp && !extensionp) { + switch (*cp) { + case '.': + if (*(cp + 1)) extensionp = 1; + cp++; + break; - case '.': - if (*(cp + 1)) extensionp = 1; - cp++; - break; + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; - case '\'': - if (*(cp + 1) != '\0') - cp += 2; - else - cp++; - break; - - default: - cp++; - break; - } - } - if (!extensionp) { - if (*(cp - 1) == '.') { - *(cp - 1) = '\''; - *cp++ = '.'; - } - *cp++ = '.'; - *cp = '\0'; - } - if (*ver != '\0') { - ConcNameAndVersion(fbuf, ver, namebuf); - } else { - strcpy(namebuf, fbuf); - } - UnixVersionToLispVersion(namebuf, 1); - strcpy(file, namebuf); - return (1); + default: cp++; break; + } + } + if (!extensionp) { + if (*(cp - 1) == '.') { + *(cp - 1) = '\''; + *cp++ = '.'; + } + *cp++ = '.'; + *cp = '\0'; + } + if (*ver != '\0') { + ConcNameAndVersion(fbuf, ver, namebuf); + } else { + strcpy(namebuf, fbuf); + } + UnixVersionToLispVersion(namebuf, 1); + strcpy(file, namebuf); + return (1); } - - - -/* +/* * Name: quote_fname_ufs * * Argument: char *file The root file name in UNIX format. "Root" @@ -1311,76 +1250,66 @@ int quote_fname(file) * and being converted to {UNIX} name. */ -int quote_fname_ufs(file) - register char *file; +int quote_fname_ufs(file) register char *file; { - register char *cp, *dp; - register int extensionp; - char fbuf[MAXNAMLEN + 1]; - - cp = file; - dp = fbuf; + register char *cp, *dp; + register int extensionp; + char fbuf[MAXNAMLEN + 1]; - while (*cp) { - switch (*cp) { + cp = file; + dp = fbuf; - case '>': - case ';': - case '\'': - *dp++ = '\''; - *dp++ = *cp++; - break; + while (*cp) { + switch (*cp) { + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; - default: - *dp++ = *cp++; - break; - } - } - *dp = '\0'; + default: *dp++ = *cp++; break; + } + } + *dp = '\0'; - /* - * exntensionp indicates whether exentsion field is included in a file - * name or not. If extenstion field is not included, we have to add a - * period to specify empty extension field. - */ - cp = fbuf; - extensionp = 0; - while (*cp && !extensionp) { - switch (*cp) { + /* + * exntensionp indicates whether exentsion field is included in a file + * name or not. If extenstion field is not included, we have to add a + * period to specify empty extension field. + */ + cp = fbuf; + extensionp = 0; + while (*cp && !extensionp) { + switch (*cp) { + case '.': + if (*(cp + 1)) extensionp = 1; + cp++; + break; - case '.': - if (*(cp + 1)) extensionp = 1; - cp++; - break; + case '\'': + if (*(cp + 1) != '\0') + cp += 2; + else + cp++; + break; - case '\'': - if (*(cp + 1) != '\0') - cp += 2; - else - cp++; - break; - - default: - cp++; - break; - } - } - if (!extensionp) { - if (*(cp - 1) == '.') { - *(cp - 1) = '\''; - *cp++ = '.'; - } - *cp++ = '.'; - *cp = '\0'; - } - strcpy(file, fbuf); - return (1); + default: cp++; break; + } + } + if (!extensionp) { + if (*(cp - 1) == '.') { + *(cp - 1) = '\''; + *cp++ = '.'; + } + *cp++ = '.'; + *cp = '\0'; + } + strcpy(file, fbuf); + return (1); } - - - -/* +/* * Name: quote_dname * * Argument: char *dir The directory name in UNIX format. Does not @@ -1397,38 +1326,34 @@ int quote_fname_ufs(file) * name. Both {DSK} and {UNIX} uses this routine. */ -int quote_dname(dir) - register char *dir; +int quote_dname(dir) register char *dir; { - register char *cp, *dp; - char fbuf[MAXNAMLEN + 1]; - - cp = dir; - dp = fbuf; + register char *cp, *dp; + char fbuf[MAXNAMLEN + 1]; - while (*cp) { - switch (*cp) { + cp = dir; + dp = fbuf; - case '>': - case ';': - case '\'': - *dp++ = '\''; - *dp++ = *cp++; - break; + while (*cp) { + switch (*cp) { + case '>': + case ';': + case '\'': + *dp++ = '\''; + *dp++ = *cp++; + break; - default: - *dp++ = *cp++; - break; - } - } - *dp = '\0'; + default: *dp++ = *cp++; break; + } + } + *dp = '\0'; - if (*(dp - 1) == '.') { - /* Trail period should be quoted. */ - *(dp - 1) = '\''; - *dp++ = '.'; - } + if (*(dp - 1) == '.') { + /* Trail period should be quoted. */ + *(dp - 1) = '\''; + *dp++ = '.'; + } - strcpy(dir, fbuf); - return (1); + strcpy(dir, fbuf); + return (1); } diff --git a/src/unixcomm.c b/src/unixcomm.c old mode 100755 new mode 100644 index 6ca49b6..985621c --- a/src/unixcomm.c +++ b/src/unixcomm.c @@ -1,17 +1,12 @@ /* %Z% %M% Version %I% (%G%). copyright venue & Fuji Xerox */ static char *id = "%Z% %M% %I% %G% (venue & Fuji Xerox)"; - - /* Unix Interface Communications */ - - - /************************************************************************/ /* */ /* (C) Copyright 1989-1995 by Venue. All Rights Reserved. */ @@ -26,11 +21,10 @@ Unix Interface Communications #include "version.h" - #include "lispemul.h" #ifndef DOS - /* FULLSLAVENAME => use a full file name for slave PTY */ +/* FULLSLAVENAME => use a full file name for slave PTY */ #ifdef INDIGO #define FULLSLAVENAME #elif OS5 @@ -76,9 +70,8 @@ Unix Interface Communications #include #endif /* HPUX */ - #ifdef sun - /* to get S_IFIFO defn for creating fifos */ +/* to get S_IFIFO defn for creating fifos */ #include #endif /* sun */ @@ -96,60 +89,52 @@ Unix Interface Communications #include "inlinePS2.h" #endif /* GCC386 */ - -static __inline__ int -SAFEREAD(int f, char *b, int c) -{ - int res; - loop: - res = read(f, b, c); - if ( (res < 0) ) - { - if ( errno == EINTR || errno == EAGAIN ) goto loop; - perror("reading UnixPipeIn"); - } - return (res); +static __inline__ int SAFEREAD(int f, char *b, int c) { + int res; +loop: + res = read(f, b, c); + if ((res < 0)) { + if (errno == EINTR || errno == EAGAIN) goto loop; + perror("reading UnixPipeIn"); + } + return (res); } -#include "locfile.h" /* for LispStringToCString. */ +#include "locfile.h" /* for LispStringToCString. */ /* JDS fixing protoypes char *malloc(size_t); */ int NPROCS = 100; - /* The following globals are used to communicate between Unix subprocesses and LISP */ - /* One of these structures exists for every possible file descriptor */ /* type field encodes kind of stream: */ -#define UJUNUSED 0 /* Unused */ -#define UJSHELL -1 /* PTY shell */ -#define UJPROCESS -2 /* random process */ -#define UJSOCKET -3 /* socket open for connections */ -#define UJSOSTREAM -4 /* connection from a UJSOCKET */ +#define UJUNUSED 0 /* Unused */ +#define UJSHELL -1 /* PTY shell */ +#define UJPROCESS -2 /* random process */ +#define UJSOCKET -3 /* socket open for connections */ +#define UJSOSTREAM -4 /* connection from a UJSOCKET */ - /* These are indexed by WRITE socket# */ +/* These are indexed by WRITE socket# */ struct unixjob { - char *pathname; /* used by Lisp direct socket access subr */ - int readsock; /* Socket to READ from for this job. */ - int PID; /* process ID associated with this slot */ - int status; /* status returned by subprocess (not shell) */ + char *pathname; /* used by Lisp direct socket access subr */ + int readsock; /* Socket to READ from for this job. */ + int PID; /* process ID associated with this slot */ + int status; /* status returned by subprocess (not shell) */ int type; }; -struct unixjob *UJ; /* allocated at run time */ +struct unixjob *UJ; /* allocated at run time */ -long StartTime; /* Time, for creating pipe filenames */ +long StartTime; /* Time, for creating pipe filenames */ #define valid_slot(slot) ((slot) >= 0 && (slot) < NPROCS && UJ[slot].type) -char shcom[2048]; /* Here because I'm suspicious of */ - /* large allocations on the stack */ - - +char shcom[2048]; /* Here because I'm suspicious of */ + /* large allocations on the stack */ /************************************************************************/ /* */ @@ -163,20 +148,17 @@ char shcom[2048]; /* Here because I'm suspicious of */ int find_process_slot(register int pid) /* Find a slot with the specified pid */ - - { - register int slot; - - for (slot = 0; slot < NPROCS; slot++) - if (UJ[slot].PID == pid) - { - DBPRINT(("find_process_slot = %d.\n", slot)); - return slot; - } - return -1; - } +{ + register int slot; + for (slot = 0; slot < NPROCS; slot++) + if (UJ[slot].PID == pid) { + DBPRINT(("find_process_slot = %d.\n", slot)); + return slot; + } + return -1; +} /************************************************************************/ /* */ @@ -187,8 +169,7 @@ int find_process_slot(register int pid) /* */ /************************************************************************/ -void wait_for_comm_processes(void) -{ +void wait_for_comm_processes(void) { int pid; int slot; int res; @@ -198,32 +179,27 @@ void wait_for_comm_processes(void) write(UnixPipeOut, d, 4); SAFEREAD(UnixPipeIn, d, 4); - pid = (d[0]<<8) | d[1]; - while ((pid != 0) && (pid != 65535)) - { - slot = find_process_slot(pid); - /* Ignore processes that we didn't start (shouldn't happen but - occasionally does) */ - if (slot >= 0) - { - if (d[2] == 0) - { - DBPRINT(("Process %d exited status %d\n", pid, d[3])); - UJ[slot].status = d[3]; - } - else - { - DBPRINT(("Process %d terminated with signal %d\n", pid, d[2])); - UJ[slot].status = (d[2] << 8); - } - } - /* Look for another stopped process. */ - d[0] = 'W'; - write(UnixPipeOut, d, 4); - SAFEREAD(UnixPipeIn, d,4); - - pid = (d[0]<<8) | d[1]; + pid = (d[0] << 8) | d[1]; + while ((pid != 0) && (pid != 65535)) { + slot = find_process_slot(pid); + /* Ignore processes that we didn't start (shouldn't happen but + occasionally does) */ + if (slot >= 0) { + if (d[2] == 0) { + DBPRINT(("Process %d exited status %d\n", pid, d[3])); + UJ[slot].status = d[3]; + } else { + DBPRINT(("Process %d terminated with signal %d\n", pid, d[2])); + UJ[slot].status = (d[2] << 8); + } } + /* Look for another stopped process. */ + d[0] = 'W'; + write(UnixPipeOut, d, 4); + SAFEREAD(UnixPipeIn, d, 4); + + pid = (d[0] << 8) | d[1]; + } } /************************************************************************/ @@ -234,36 +210,32 @@ void wait_for_comm_processes(void) /* socket descriptor. Has ONE string buffer. */ /************************************************************************/ #ifndef ISC -char *build_socket_pathname(int desc) -{ +char *build_socket_pathname(int desc) { static char PathName[50]; sprintf(PathName, "/tmp/LPU%d-%d", StartTime, desc); - return(PathName); + return (PathName); } #else -char *build_upward_socket_pathname(desc) -int desc; +char *build_upward_socket_pathname(desc) int desc; { static char UpPathName[50]; sprintf(UpPathName, "/tmp/LPU%d-%d", StartTime, desc); - return(UpPathName); + return (UpPathName); } -char *build_downward_socket_pathname(desc) -int desc; +char *build_downward_socket_pathname(desc) int desc; { static char DownPathName[50]; sprintf(DownPathName, "/tmp/LPD%d-%d", StartTime, desc); - return(DownPathName); + return (DownPathName); } #endif /* ISC */ - /************************************************************************/ /* */ /* c l o s e _ u n i x _ d e s c r i p t o r s */ @@ -273,49 +245,44 @@ int desc; /* */ /************************************************************************/ - void close_unix_descriptors(void) /* Get ready to shut Maiko down */ { int slot; for (slot = 0; slot < NPROCS; slot++) { - /* If this slot has an active job */ - switch(UJ[slot].type) { + switch (UJ[slot].type) { + case UJSHELL: + if (kill(UJ[slot].PID, SIGKILL) < 0) perror("Killing shell"); + UJ[slot].PID = 0; + DBPRINT(("Kill 5 closing shell desc %d.\n", slot)); + close(slot); + break; - case UJSHELL: - if (kill(UJ[slot].PID, SIGKILL)<0) perror("Killing shell"); - UJ[slot].PID = 0; - DBPRINT(("Kill 5 closing shell desc %d.\n", slot)); - close(slot); - break; + case UJPROCESS: + if (kill(UJ[slot].PID, SIGKILL) < 0) perror("Killing process"); + UJ[slot].PID = 0; + DBPRINT(("Kill 5 closing process desc %d.\n", slot)); + close(slot); + break; - case UJPROCESS: - if (kill(UJ[slot].PID, SIGKILL)<0) perror("Killing process"); - UJ[slot].PID = 0; - DBPRINT(("Kill 5 closing process desc %d.\n", slot)); - close(slot); - break; + case UJSOCKET: + close(slot); + if (UJ[slot].pathname != NULL) { + /* socket created directly from Lisp; pathname is in .pathname */ + DBPRINT(("Closing socket %d bound to %s\n", slot, UJ[slot].pathname)); + unlink(UJ[slot].pathname); + free(UJ[slot].pathname); + UJ[slot].pathname = NULL; + } + break; - case UJSOCKET: - close(slot); - if(UJ[slot].pathname != NULL) { - /* socket created directly from Lisp; pathname is in .pathname */ - DBPRINT(("Closing socket %d bound to %s\n", slot, UJ[slot].pathname)); - unlink(UJ[slot].pathname); - free(UJ[slot].pathname); - UJ[slot].pathname = NULL; - } - break; - - case UJSOSTREAM: - close(slot); - break; + case UJSOSTREAM: close(slot); break; } UJ[slot].type = UJUNUSED; } -/* make sure everyone's really dead before proceeding */ + /* make sure everyone's really dead before proceeding */ wait_for_comm_processes(); } @@ -331,49 +298,37 @@ void close_unix_descriptors(void) /* Get ready to shut Maiko down */ /* */ /************************************************************************/ -int FindUnixPipes(void) -{ +int FindUnixPipes(void) { char *envtmp, *getenv(const char *); register int i; struct unixjob cleareduj; DBPRINT(("Entering FindUnixPipes\n")); UnixPipeIn = UnixPipeOut = StartTime = UnixPID = -1; - if(envtmp = getenv("LDEPIPEIN")) - UnixPipeIn = atoi(envtmp); - if(envtmp = getenv("LDEPIPEOUT")) - UnixPipeOut = atoi(envtmp); - if(envtmp = getenv("LDESTARTTIME")) - StartTime = atoi(envtmp); - if(envtmp = getenv("LDEUNIXPID")) - UnixPID = atoi(envtmp); + if (envtmp = getenv("LDEPIPEIN")) UnixPipeIn = atoi(envtmp); + if (envtmp = getenv("LDEPIPEOUT")) UnixPipeOut = atoi(envtmp); + if (envtmp = getenv("LDESTARTTIME")) StartTime = atoi(envtmp); + if (envtmp = getenv("LDEUNIXPID")) UnixPID = atoi(envtmp); - /* This is a good place to initialize stuff like the UJ table */ +/* This is a good place to initialize stuff like the UJ table */ #ifdef SYSVONLY NPROCS = sysconf(_SC_OPEN_MAX); #else NPROCS = getdtablesize(); #endif /* SYSVONLY */ - UJ = (struct unixjob *) malloc(NPROCS * sizeof(struct unixjob)); + UJ = (struct unixjob *)malloc(NPROCS * sizeof(struct unixjob)); cleareduj.status = -1; cleareduj.pathname = NULL; cleareduj.PID = 0; cleareduj.readsock = 0; cleareduj.type = UJUNUSED; - for(i=0; i< NPROCS; i++) UJ[i] = cleareduj; + for (i = 0; i < NPROCS; i++) UJ[i] = cleareduj; DBPRINT(("NPROCS is %d; leaving FindUnixPipes\n", NPROCS)); - return (UnixPipeIn == -1 - || UnixPipeOut == -1 - || StartTime == -1 - || UnixPID == -1); + return (UnixPipeIn == -1 || UnixPipeOut == -1 || StartTime == -1 || UnixPID == -1); } - - - - /************************************************************************/ /* */ /* F i n d A v a i l a b l e P t y */ @@ -392,36 +347,34 @@ int FindUnixPipes(void) /* */ /************************************************************************/ - #define PTYLETTERS "pqr" #define PTYNUMBERS "0123456789abcdef" /* Find the first PTY pair that is not in use */ -int FindAvailablePty(char *Master, char *Slave) -{ +int FindAvailablePty(char *Master, char *Slave) { int res, flags; char *let, *num; #ifdef INDIGO - - let = (char *) _getpty(&res, O_RDWR|O_NDELAY, 0600, 0); - strcpy(Slave, let); + + let = (char *)_getpty(&res, O_RDWR | O_NDELAY, 0600, 0); + strcpy(Slave, let); #elif OS5 - res = open("/dev/ptmx", O_RDWR); - if (res < 0) { perror("ptmx open"); return(-1); } - grantpt(res); - unlockpt(res); - strcpy(Slave, ptsname(res)); - DBPRINT(("slave pyt name is %s.\n", Slave)); + res = open("/dev/ptmx", O_RDWR); + if (res < 0) { + perror("ptmx open"); + return (-1); + } + grantpt(res); + unlockpt(res); + strcpy(Slave, ptsname(res)); + DBPRINT(("slave pyt name is %s.\n", Slave)); #else /* From p to r */ - for (let = PTYLETTERS; *let != 0; let++) - - /* and 0 to f */ + for (let = PTYLETTERS; *let != 0; let++) /* and 0 to f */ for (num = PTYNUMBERS; *num != 0; num++) { - sprintf(Master, "/dev/pty%c%c", *let, *num); sprintf(Slave, "%c%c", *let, *num); DBPRINT(("Trying %s. ", Master)); @@ -429,25 +382,24 @@ int FindAvailablePty(char *Master, char *Slave) res = open(Master, O_RDWR); #endif - if (res != -1) - { - flags = fcntl(res, F_GETFL, 0); + if (res != -1) { + flags = fcntl(res, F_GETFL, 0); #ifdef ISC - flags |= O_NONBLOCK; + flags |= O_NONBLOCK; #else - flags |= FNDELAY; + flags |= FNDELAY; #endif /* ISC */ - flags = fcntl(res, F_SETFL, flags); - return(res); - } + flags = fcntl(res, F_SETFL, flags); + return (res); + } #ifndef FULLSLAVENAME - } +} #endif /* because we commented out the for above also... */ - return(-1); +return (-1); } -void WriteLispStringToPipe (LispPTR lispstr); +void WriteLispStringToPipe(LispPTR lispstr); /************************************************************************/ /* */ @@ -490,722 +442,682 @@ void WriteLispStringToPipe (LispPTR lispstr); /* */ /************************************************************************/ +LispPTR Unix_handlecomm(LispPTR *args) { + int command, c, dest, PID, i, slot, sock, res; + LispPTR retval; + unsigned char d[4], b[1]; + unsigned char ch; + unsigned char buf[1]; -LispPTR Unix_handlecomm(LispPTR *args) -{ - int command,c, dest, PID, i, slot, sock, res; - LispPTR retval; - unsigned char d[4], b[1]; - unsigned char ch; - unsigned char buf[1]; + /* Get command */ + N_GETNUMBER(args[0], command, bad); + DBPRINT(("Unix_handlecomm: trying %d\n", command)); - - /* Get command */ - N_GETNUMBER(args[0], command, bad); - DBPRINT(("Unix_handlecomm: trying %d\n", command)); - - switch(command) - { - - case 0: /* Fork pipe process */ - { - char *UpPipeName, *DownPipeName, *PipeName; - int res, slot, PipeFD, sockFD; + switch (command) { + case 0: /* Fork pipe process */ + { + char *UpPipeName, *DownPipeName, *PipeName; + int res, slot, PipeFD, sockFD; #ifndef ISC - /* First create the socket */ - struct sockaddr_un sock; - sockFD = socket(AF_UNIX, SOCK_STREAM, 0); - if (sockFD < 0) { perror("socket open"); return(NIL);} + /* First create the socket */ + struct sockaddr_un sock; + sockFD = socket(AF_UNIX, SOCK_STREAM, 0); + if (sockFD < 0) { + perror("socket open"); + return (NIL); + } - /* then bind it to a canonical pathname */ - PipeName = build_socket_pathname(sockFD); - sock.sun_family = AF_UNIX; - strcpy(sock.sun_path, PipeName); - if (bind(sockFD, (struct sockaddr *) &sock, - strlen(PipeName)+sizeof(sock.sun_family)) < 0) - { - close(sockFD); - perror("binding sockets"); - unlink(PipeName); - return(NIL); - } + /* then bind it to a canonical pathname */ + PipeName = build_socket_pathname(sockFD); + sock.sun_family = AF_UNIX; + strcpy(sock.sun_path, PipeName); + if (bind(sockFD, (struct sockaddr *)&sock, strlen(PipeName) + sizeof(sock.sun_family)) < 0) { + close(sockFD); + perror("binding sockets"); + unlink(PipeName); + return (NIL); + } - DBPRINT(("Socket %d bound to name %s.\n", sockFD, PipeName)); + DBPRINT(("Socket %d bound to name %s.\n", sockFD, PipeName)); - if(listen(sockFD, 1)<0) perror("Listen"); + if (listen(sockFD, 1) < 0) perror("Listen"); #else - sockFD = open("/tmp/dummyforlisp" , O_CREAT); - UpPipeName = build_upward_socket_pathname(sockFD); - DownPipeName = build_downward_socket_pathname(sockFD); + sockFD = open("/tmp/dummyforlisp", O_CREAT); + UpPipeName = build_upward_socket_pathname(sockFD); + DownPipeName = build_downward_socket_pathname(sockFD); - DBPRINT(("Downward FIFO: %s\n", DownPipeName)); - DBPRINT(("Upward FIFO: %s\n", UpPipeName)); + DBPRINT(("Downward FIFO: %s\n", DownPipeName)); + DBPRINT(("Upward FIFO: %s\n", UpPipeName)); #ifdef sun - if ((mknod(UpPipeName, 0777|S_IFIFO, 0) < 0) && (errno != EEXIST)) - { - perror("Making Upward FIFO"); - printf("(named %s).\n", UpPipeName); fflush(stdout); - } - if ((mknod(DownPipeName, 0777|S_IFIFO, 0)<0) && (errno != EEXIST)) - { - perror("Making Downward FIFO"); - printf("(named %s).\n", DownPipeName); fflush(stdout); - } + if ((mknod(UpPipeName, 0777 | S_IFIFO, 0) < 0) && (errno != EEXIST)) { + perror("Making Upward FIFO"); + printf("(named %s).\n", UpPipeName); + fflush(stdout); + } + if ((mknod(DownPipeName, 0777 | S_IFIFO, 0) < 0) && (errno != EEXIST)) { + perror("Making Downward FIFO"); + printf("(named %s).\n", DownPipeName); + fflush(stdout); + } #else - if (mkfifo(UpPipeName, 0777) < 0) - { - perror("Making Upward FIFO"); - printf("(named %s).\n", UpPipeName); fflush(stdout); - } - if (mkfifo(DownPipeName, 0777) < 0) - { - perror("Making Downward FIFO"); - printf("(named %s).\n", DownPipeName); fflush(stdout); - } + if (mkfifo(UpPipeName, 0777) < 0) { + perror("Making Upward FIFO"); + printf("(named %s).\n", UpPipeName); + fflush(stdout); + } + if (mkfifo(DownPipeName, 0777) < 0) { + perror("Making Downward FIFO"); + printf("(named %s).\n", DownPipeName); + fflush(stdout); + } #endif /* SUNs */ - PipeFD= open(DownPipeName, O_WRONLY | O_NDELAY); - if (PipeFD < 0) - { - perror("Opening Down pipe from lisp"); - printf("(Name is %s.)\n",DownPipeName); fflush(stdout); - close(sockFD); - return(NIL); - } - dup2(PipeFD,sockFD); - unlink("/tmp/dummyforlisp"); + PipeFD = open(DownPipeName, O_WRONLY | O_NDELAY); + if (PipeFD < 0) { + perror("Opening Down pipe from lisp"); + printf("(Name is %s.)\n", DownPipeName); + fflush(stdout); + close(sockFD); + return (NIL); + } + dup2(PipeFD, sockFD); + unlink("/tmp/dummyforlisp"); - PipeFD = open(UpPipeName, O_RDONLY | O_NDELAY); - if (PipeFD < 0) - { - perror("Opening Up pipe from lisp"); - printf("(Name is %s.)\n", UpPipeName); fflush(stdout); - close(sockFD); - return(NIL); - } + PipeFD = open(UpPipeName, O_RDONLY | O_NDELAY); + if (PipeFD < 0) { + perror("Opening Up pipe from lisp"); + printf("(Name is %s.)\n", UpPipeName); + fflush(stdout); + close(sockFD); + return (NIL); + } #endif /* ISC */ + d[0] = 'F'; + d[3] = sockFD; + write(UnixPipeOut, d, 4); + WriteLispStringToPipe(args[1]); - d[0] = 'F'; - d[3] = sockFD; - write(UnixPipeOut, d, 4); - WriteLispStringToPipe(args[1]); + DBPRINT(("Sending cmd string: %s\n", shcom)); - DBPRINT(("Sending cmd string: %s\n", shcom)); + /* Get status */ + SAFEREAD(UnixPipeIn, d, 4); - /* Get status */ - SAFEREAD(UnixPipeIn, d, 4); - - /* If it worked, return job # */ - if (d[3] == 1) - { + /* If it worked, return job # */ + if (d[3] == 1) { #ifndef ISC - case0_lp: - TIMEOUT(PipeFD = accept(sockFD, (struct sockaddr *) 0, - (int *) 0)); - if (PipeFD < 0) - { - if (errno == EINTR) goto case0_lp; - perror("Accept."); - close(sockFD); - if (unlink(PipeName)<0) perror("Unlink"); - return(NIL); - } + case0_lp: + TIMEOUT(PipeFD = accept(sockFD, (struct sockaddr *)0, (int *)0)); + if (PipeFD < 0) { + if (errno == EINTR) goto case0_lp; + perror("Accept."); + close(sockFD); + if (unlink(PipeName) < 0) perror("Unlink"); + return (NIL); + } #endif /* oldPIPEway */ - res = fcntl(PipeFD, F_GETFL, 0); + res = fcntl(PipeFD, F_GETFL, 0); #ifdef ISC - res |= O_NONBLOCK; + res |= O_NONBLOCK; #else - res |= FNDELAY; + res |= FNDELAY; #endif /* ISC */ - res = fcntl(PipeFD, F_SETFL, res); - if (res < 0) - { - perror("setting up fifo to nodelay"); - return(NIL); - } + res = fcntl(PipeFD, F_SETFL, res); + if (res < 0) { + perror("setting up fifo to nodelay"); + return (NIL); + } #ifdef ISC - UJ[sockFD].type = UJPROCESS; - UJ[sockFD].status = -1; - UJ[sockFD].PID = (d[1]<<8) | d[2]; - UJ[sockFD].readsock = PipeFD; + UJ[sockFD].type = UJPROCESS; + UJ[sockFD].status = -1; + UJ[sockFD].PID = (d[1] << 8) | d[2]; + UJ[sockFD].readsock = PipeFD; #else - UJ[PipeFD].type = UJPROCESS; - UJ[PipeFD].status = -1; - UJ[PipeFD].PID = (d[1]<<8) | d[2]; - UJ[PipeFD].readsock = 0; - close(sockFD); - unlink(PipeName); + UJ[PipeFD].type = UJPROCESS; + UJ[PipeFD].status = -1; + UJ[PipeFD].PID = (d[1] << 8) | d[2]; + UJ[PipeFD].readsock = 0; + close(sockFD); + unlink(PipeName); #endif /* ISC */ - - /* unlink(UpPipeName); - unlink(DownPipeName); */ +/* unlink(UpPipeName); +unlink(DownPipeName); */ #ifdef ISC - return(GetSmallp(sockFD)); + return (GetSmallp(sockFD)); #else - return(GetSmallp(PipeFD)); + return (GetSmallp(PipeFD)); #endif /* ISC */ - } - else - { - DBPRINT(("Fork request failed.")); + } else { + DBPRINT(("Fork request failed.")); #ifdef ISC - close(sockFD); close(PipeFD); - unlink(UpPipeName); - unlink(DownPipeName); + close(sockFD); + close(PipeFD); + unlink(UpPipeName); + unlink(DownPipeName); #else - close(sockFD); - unlink(PipeName); + close(sockFD); + unlink(PipeName); #endif /* ISC */ - return(NIL); - } - break; - } + return (NIL); + } + break; + } - case 1: /* Write byte */ - /* Get job #, Byte */ - N_GETNUMBER(args[1], slot, bad); - N_GETNUMBER(args[2], dest, bad); ch = dest; /* ch is a char */ + case 1: /* Write byte */ + /* Get job #, Byte */ + N_GETNUMBER(args[1], slot, bad); + N_GETNUMBER(args[2], dest, bad); + ch = dest; /* ch is a char */ - if (valid_slot(slot) && (UJ[slot].status == -1)) - switch(UJ[slot].type) { + if (valid_slot(slot) && (UJ[slot].status == -1)) switch (UJ[slot].type) { + case UJPROCESS: + case UJSHELL: + case UJSOSTREAM: + dest = write(slot, &ch, 1); + if (dest == 0) { + wait_for_comm_processes(); + return (NIL); + } else + return (GetSmallp(1)); + break; - case UJPROCESS: - case UJSHELL: - case UJSOSTREAM: - dest = write(slot, &ch, 1); - if (dest == 0) { - wait_for_comm_processes(); - return(NIL); - } - else return(GetSmallp(1)); - break; + default: return (NIL); + } + break; - default: return(NIL); - } - break; + case 2: /* Read byte */ + /**********************************************************/ + /* */ + /* NB that it is possible for the other end of the stream */ + /* to have terminated, and hence status != -1. */ + /* EVEN IF THERE ARE STILL CHARACTERS TO READ. */ + /* */ + /**********************************************************/ - case 2: /* Read byte */ - /**********************************************************/ - /* */ - /* NB that it is possible for the other end of the stream */ - /* to have terminated, and hence status != -1. */ - /* EVEN IF THERE ARE STILL CHARACTERS TO READ. */ - /* */ - /**********************************************************/ + N_GETNUMBER(args[1], slot, bad); /* Get job # */ - N_GETNUMBER(args[1], slot, bad); /* Get job # */ + if (!valid_slot(slot)) return (NIL); /* No fd open; punt the read */ - if (!valid_slot(slot)) return(NIL); /* No fd open; punt the read */ + if (UJ[slot].readsock) + sock = UJ[slot].readsock; + else + sock = slot; - if(UJ[slot].readsock) sock = UJ[slot].readsock; else sock = slot; + switch (UJ[slot].type) { + case UJPROCESS: + case UJSHELL: + case UJSOSTREAM: + TIMEOUT(dest = read(sock, buf, 1)); + if (dest > 0) return (GetSmallp(buf[0])); + /* Something's amiss; check our process status */ + wait_for_comm_processes(); + if ((dest == 0) && + (UJ[slot].status == -1)) { /* No available chars, but other guy still running */ + DBPRINT(("dest = 0, status still -1\n")); + return (ATOM_T); + } + if ((UJ[slot].status == -1) && + ((errno == EWOULDBLOCK) || + (errno == EAGAIN))) { /* No available chars, but other guy still running */ + DBPRINT((" dest<0, EWOULDBLOCK\n")); + return (ATOM_T); + } + /* At this point, we either got an I/O error, or there */ + /* were no chars available and the other end has terminated. */ + /* Either way, signal EOF. */ + DBPRINT(("Indicating EOF from PTY desc %d.\n", slot)); + return (NIL); + break; - switch(UJ[slot].type) { + default: return (NIL); break; + } + break; - case UJPROCESS: - case UJSHELL: - case UJSOSTREAM: - TIMEOUT(dest = read(sock, buf, 1)); - if (dest > 0) return(GetSmallp(buf[0])); - /* Something's amiss; check our process status */ - wait_for_comm_processes(); - if ((dest == 0) && (UJ[slot].status == -1)) - { /* No available chars, but other guy still running */ - DBPRINT(("dest = 0, status still -1\n")); - return(ATOM_T); - } - if ((UJ[slot].status == -1) && - ((errno == EWOULDBLOCK) || (errno == EAGAIN)) ) - { /* No available chars, but other guy still running */ - DBPRINT((" dest<0, EWOULDBLOCK\n")); - return(ATOM_T); - } - /* At this point, we either got an I/O error, or there */ - /* were no chars available and the other end has terminated. */ - /* Either way, signal EOF. */ - DBPRINT(("Indicating EOF from PTY desc %d.\n", slot)); - return(NIL); - break; + case 3: /* Kill process */ + /* Maiko uses this as CLOSEF, so "process" is a misnomer */ - default: - return(NIL); - break; - } - break; + N_GETNUMBER(args[1], slot, bad); + DBPRINT(("Killing process in slot %.\n", slot)); - case 3: /* Kill process */ - /* Maiko uses this as CLOSEF, so "process" is a misnomer */ + if (valid_slot(slot)) switch (UJ[slot].type) { + case UJSHELL: + case UJPROCESS: + /* First check to see it hasn't already died */ + if (UJ[slot].status == -1) { + int i; + /* Kill the job */ + kill(UJ[slot].PID, SIGKILL); + for (i = 0; i < 10; i++) { + /* Waiting for the process to exit is possibly risky. + Sending SIGKILL is always supposed to kill + a process, but on very rare occurrences this doesn't + happen because of a Unix kernel bug, usually a user- + written device driver which hasn't been fully + debugged. So we time it out just be safe. */ + if (UJ[slot].status != -1) break; + wait_for_comm_processes(); + sleep(1); + } + } + break; + } + else + return (ATOM_T); - N_GETNUMBER(args[1], slot, bad); + switch (UJ[slot].type) { + case UJSHELL: + DBPRINT(("Kill 3 closing shell desc %d.\n", slot)); + close(slot); + break; - DBPRINT(("Killing process in slot %.\n", slot)); + case UJPROCESS: + DBPRINT(("Kill 3 closing process desc %d.\n", slot)); + close(slot); + if (UJ[slot].readsock) close(UJ[slot].readsock); + break; - if (valid_slot(slot)) - switch(UJ[slot].type) - { + case UJSOSTREAM: + DBPRINT(("Kill 3 closing stream socket desc %d.\n", slot)); + close(slot); + break; - case UJSHELL: - case UJPROCESS: - /* First check to see it hasn't already died */ - if (UJ[slot].status == -1) - { - int i; - /* Kill the job */ - kill(UJ[slot].PID, SIGKILL); - for (i = 0; i < 10; i++) - { - /* Waiting for the process to exit is possibly risky. - Sending SIGKILL is always supposed to kill - a process, but on very rare occurrences this doesn't - happen because of a Unix kernel bug, usually a user- - written device driver which hasn't been fully - debugged. So we time it out just be safe. */ - if (UJ[slot].status != -1) break; - wait_for_comm_processes(); - sleep(1); - } - } - break; + case UJSOCKET: + DBPRINT(("Kill 3 closing raw socket desc %d.\n", slot)); + close(slot); + DBPRINT(("Unlinking %s\n", UJ[slot].pathname)); + if (UJ[slot].pathname) { + if (unlink(UJ[slot].pathname) < 0) perror("Kill 3 unlink"); + free(UJ[slot].pathname); + UJ[slot].pathname = NULL; + } + break; + } + UJ[slot].type = UJUNUSED; + UJ[slot].readsock = UJ[slot].PID = 0; + UJ[slot].pathname = NULL; - } - else return(ATOM_T); + /* If status available, return it, otherwise T */ + return (GetSmallp(UJ[slot].status)); + break; - switch(UJ[slot].type) { + case 4: + case 11: /* Fork PTY process */ + { + char MasterFD[20], SlavePTY[32]; + int Master, res, slot; + unsigned short len; - case UJSHELL: - DBPRINT(("Kill 3 closing shell desc %d.\n", slot)); - close(slot); - break; + Master = FindAvailablePty(MasterFD, SlavePTY); + slot = Master; + DBPRINT(("Fork Shell; Master PTY = %d. Slave=%c%c.\n", Master, SlavePTY[0], SlavePTY[1])); + if (Master < 0) { + printf("Open of lisp side of PTY failed.\n"); + fflush(stdout); + return (NIL); + } - case UJPROCESS: - DBPRINT(("Kill 3 closing process desc %d.\n", slot)); - close(slot); if (UJ[slot].readsock) close(UJ[slot].readsock); - break; - - case UJSOSTREAM: - DBPRINT(("Kill 3 closing stream socket desc %d.\n", slot)); - close(slot); - break; - - case UJSOCKET: - DBPRINT(("Kill 3 closing raw socket desc %d.\n", slot)); - close(slot); - DBPRINT(("Unlinking %s\n", UJ[slot].pathname)); - if(UJ[slot].pathname) { - if(unlink(UJ[slot].pathname) < 0) - perror("Kill 3 unlink"); - free(UJ[slot].pathname); - UJ[slot].pathname = NULL; - } - break; - } - UJ[slot].type = UJUNUSED; - UJ[slot].readsock = UJ[slot].PID = 0; - UJ[slot].pathname = NULL; - - /* If status available, return it, otherwise T */ - return(GetSmallp(UJ[slot].status)); - break; - - - case 4: case 11: /* Fork PTY process */ - { - char MasterFD[20], SlavePTY[32]; - int Master, res, slot; - unsigned short len; - - Master = FindAvailablePty(MasterFD, SlavePTY); - slot = Master; - DBPRINT(("Fork Shell; Master PTY = %d. Slave=%c%c.\n", - Master, SlavePTY[0], SlavePTY[1])); - if (Master < 0) - { - printf("Open of lisp side of PTY failed.\n"); - fflush(stdout); - return(NIL); - } - - d[0] = (command == 4) ? 'S': 'P'; - d[1] = SlavePTY[0]; - d[2] = SlavePTY[1]; - d[3] = slot; - write(UnixPipeOut, d, 4); + d[0] = (command == 4) ? 'S' : 'P'; + d[1] = SlavePTY[0]; + d[2] = SlavePTY[1]; + d[3] = slot; + write(UnixPipeOut, d, 4); #ifdef FULLSLAVENAME - len = strlen(SlavePTY) + 1; - write(UnixPipeOut, &len, 2); - write(UnixPipeOut, SlavePTY, len); + len = strlen(SlavePTY) + 1; + write(UnixPipeOut, &len, 2); + write(UnixPipeOut, SlavePTY, len); #endif - if (command != 4) - { /* New style has arg1 = termtype, arg2 = command */ - WriteLispStringToPipe (args[1]); - WriteLispStringToPipe (args[2]); - } + if (command != 4) { /* New style has arg1 = termtype, arg2 = command */ + WriteLispStringToPipe(args[1]); + WriteLispStringToPipe(args[2]); + } - /* Get status */ - SAFEREAD(UnixPipeIn, d, 4); + /* Get status */ + SAFEREAD(UnixPipeIn, d, 4); - /* If successful, return job # */ - DBPRINT(("Pipe/fork result = %d.\n", d[3])); - if (d[3] == 1) - { - /* Set up the IO not to block */ - res = fcntl(Master, F_GETFL, 0); + /* If successful, return job # */ + DBPRINT(("Pipe/fork result = %d.\n", d[3])); + if (d[3] == 1) { + /* Set up the IO not to block */ + res = fcntl(Master, F_GETFL, 0); #ifdef ISC - res |= O_NONBLOCK; + res |= O_NONBLOCK; #else - res |= FNDELAY; + res |= FNDELAY; #endif /* ISC */ - res = fcntl(Master, F_SETFL, res); + res = fcntl(Master, F_SETFL, res); - UJ[slot].type = UJSHELL; /* so we can find them */ - UJ[slot].PID = (d[1]<<8) | d[2]; -printf("Shell job %d, PID = %d\n", slot, UJ[slot].PID); - UJ[slot].status = -1; - DBPRINT(("Forked pty in slot %d.\n", slot)); - return(GetSmallp(slot)); - } - else - { - printf("Fork failed.\n"); fflush(stdout); - printf("d = %d, %d, %d, %d\n",d[0],d[1],d[2],d[3]); - close(Master); - return(NIL); - } - break; - } + UJ[slot].type = UJSHELL; /* so we can find them */ + UJ[slot].PID = (d[1] << 8) | d[2]; + printf("Shell job %d, PID = %d\n", slot, UJ[slot].PID); + UJ[slot].status = -1; + DBPRINT(("Forked pty in slot %d.\n", slot)); + return (GetSmallp(slot)); + } else { + printf("Fork failed.\n"); + fflush(stdout); + printf("d = %d, %d, %d, %d\n", d[0], d[1], d[2], d[3]); + close(Master); + return (NIL); + } + break; + } - case 5: /* Kill all the subprocesses */ + case 5: /* Kill all the subprocesses */ close_unix_descriptors(); return (ATOM_T); - close_unix_descriptors(); - return(ATOM_T); + case 6: /* Kill this subprocess */ + d[0] = 'C'; - case 6: /* Kill this subprocess */ - d[0] = 'C'; + /* Get job # */ + N_GETNUMBER(args[1], dest, bad); + d[1] = dest; - /* Get job # */ - N_GETNUMBER(args[1], dest, bad); - d[1] = dest; + d[3] = 1; + write(UnixPipeOut, d, 4); - d[3] = 1; - write(UnixPipeOut, d, 4); + /* Get status */ + SAFEREAD(UnixPipeIn, d, 4); - /* Get status */ - SAFEREAD(UnixPipeIn, d, 4); - - switch(UJ[dest].type) { + switch (UJ[dest].type) { + case UJSHELL: + DBPRINT(("Kill 5 closing shell desc %d.\n", dest)); + close(dest); + break; - case UJSHELL: - DBPRINT(("Kill 5 closing shell desc %d.\n", dest)); - close(dest); - break; + case UJPROCESS: + DBPRINT(("Kill 5 closing process desc %d.\n", dest)); + close(dest); + if (UJ[dest].readsock) close(UJ[dest].readsock); + UJ[dest].readsock = 0; + break; - case UJPROCESS: - DBPRINT(("Kill 5 closing process desc %d.\n", dest)); - close(dest); if(UJ[dest].readsock) close(UJ[dest].readsock); - UJ[dest].readsock=0; - break; + case UJSOCKET: + /* close a socket; be sure and unlink the file handle */ + DBPRINT(("Kill 5 closing raw socket desc %d.\n", dest)); + close(dest); + if (UJ[dest].pathname != NULL) { + unlink(UJ[dest].pathname); + free(UJ[dest].pathname); + UJ[dest].pathname = NULL; + } /* else return an error somehow... */ + break; - case UJSOCKET: - /* close a socket; be sure and unlink the file handle */ - DBPRINT(("Kill 5 closing raw socket desc %d.\n", dest)); - close(dest); - if(UJ[dest].pathname != NULL) { - unlink(UJ[dest].pathname); - free(UJ[dest].pathname); - UJ[dest].pathname = NULL; - } /* else return an error somehow... */ - break; + case UJSOSTREAM: + DBPRINT(("Kill 5 closing socket stream %d.\n", dest)); + close(dest); + break; + } - case UJSOSTREAM: - DBPRINT(("Kill 5 closing socket stream %d.\n", dest)); - close(dest); - break; - } + UJ[dest].type = UJUNUSED; + UJ[dest].readsock = UJ[dest].PID = 0; + return (ATOM_T); + /* break; */ - UJ[dest].type = UJUNUSED; - UJ[dest].readsock = UJ[dest].PID = 0; - return(ATOM_T); - /* break; */ + case 7: /* Current job status */ + N_GETNUMBER(args[1], slot, bad); /* Get job # */ + wait_for_comm_processes(); /* Make sure we're up to date */ - case 7: /* Current job status */ + if (UJ[slot].status == -1) + return (ATOM_T); + else + return (GetSmallp(UJ[slot].status)); + break; - N_GETNUMBER(args[1], slot, bad); /* Get job # */ - wait_for_comm_processes(); /* Make sure we're up to date */ + case 8: /* Return largest supported command */ return (GetSmallp(15)); - if (UJ[slot].status == -1) return (ATOM_T); - else return(GetSmallp(UJ[slot].status)); - break; + case 9: /* Read buffer */ + /**********************************************************/ + /* */ + /* NB that it is possible for the other end of the stream */ + /* to have terminated, and hence ForkedStatus != -1. */ + /* EVEN IF THERE ARE STILL CHARACTERS TO READ. */ + /* */ + /**********************************************************/ - case 8: /* Return largest supported command */ + { + char *bufp; + int terno; /* holds errno thru sys calls after I/O fails */ - return(GetSmallp(15)); - + N_GETNUMBER(args[1], slot, bad); /* Get job # */ + if (!valid_slot(slot)) return (NIL); /* No fd open; punt the read */ - case 9: /* Read buffer */ - /**********************************************************/ - /* */ - /* NB that it is possible for the other end of the stream */ - /* to have terminated, and hence ForkedStatus != -1. */ - /* EVEN IF THERE ARE STILL CHARACTERS TO READ. */ - /* */ - /**********************************************************/ + if (UJ[slot].readsock) + sock = UJ[slot].readsock; + else + sock = slot; - { char *bufp; - int terno; /* holds errno thru sys calls after I/O fails */ + bufp = (char *)(Addr68k_from_LADDR(args[2])); /* User buffer */ + DBPRINT(("Read buffer slot %d, type is %d\n", slot, UJ[slot].type)); - N_GETNUMBER(args[1], slot, bad); /* Get job # */ - if (!valid_slot(slot)) return(NIL); /* No fd open; punt the read */ - - if (UJ[slot].readsock) sock = UJ[slot].readsock; else sock = slot; - - bufp = (char*)(Addr68k_from_LADDR(args[2])); /* User buffer */ - DBPRINT(("Read buffer slot %d, type is %d\n", slot, UJ[slot].type)); - - switch(UJ[slot].type) { - case UJSHELL: - case UJPROCESS: - case UJSOSTREAM: - dest = read(sock, bufp, 512); + switch (UJ[slot].type) { + case UJSHELL: + case UJPROCESS: + case UJSOSTREAM: dest = read(sock, bufp, 512); #ifdef BYTESWAP - word_swap_page(bufp, 128); + word_swap_page(bufp, 128); #endif /* BYTESWAP */ - if (dest > 0) - { /* Got characters. If debugging, print len &c */ - /* printf("got %d chars\n", dest); */ - return(GetSmallp(dest)); - } + if (dest > 0) { /* Got characters. If debugging, print len &c */ + /* printf("got %d chars\n", dest); */ + return (GetSmallp(dest)); + } - /* Something's amiss; update process status */ - DBPRINT(("Problem: Got status %d from read, errno %d.\n", dest, errno)); + /* Something's amiss; update process status */ + DBPRINT(("Problem: Got status %d from read, errno %d.\n", dest, errno)); #ifndef ISC - wait_for_comm_processes(); /* make sure we're up to date */ - if (((dest == 0) || (errno == EINTR) || (errno == 0) || - (errno == EAGAIN) || - (errno == EWOULDBLOCK)) && (UJ[slot].status == -1)) - /* No available chars, but other guy still running */ - return(ATOM_T); + wait_for_comm_processes(); /* make sure we're up to date */ + if (((dest == 0) || (errno == EINTR) || (errno == 0) || (errno == EAGAIN) || + (errno == EWOULDBLOCK)) && + (UJ[slot].status == -1)) + /* No available chars, but other guy still running */ + return (ATOM_T); #else - if (dest == 0) wait_for_comm_processes(); /* make sure we're up to date, because dest==0 means no process is writing there. */ - if (((errno == EINTR) || (errno == 0) || - (errno == EAGAIN) || - (errno == EWOULDBLOCK)) && (dest == -1) && (UJ[slot].status == -1)) - /* No available chars, but other guy still running */ - return(ATOM_T); + if (dest == 0) + wait_for_comm_processes(); /* make sure we're up to date, because dest==0 means no + process is writing there. */ + if (((errno == EINTR) || (errno == 0) || (errno == EAGAIN) || (errno == EWOULDBLOCK)) && + (dest == -1) && (UJ[slot].status == -1)) + /* No available chars, but other guy still running */ + return (ATOM_T); #endif /* ISC */ - /* At this point, we either got an I/O error, or there */ - /* were no chars available and the other end has terminated. */ - /* Either way, signal EOF. */ - DBPRINT(("read failed; dest = %d, errno = %d, status = %d\n", - dest, terno, UJ[slot].status)); - DBPRINT(("Indicating EOF from PTY desc %d.\n", slot)); - return(NIL); + /* At this point, we either got an I/O error, or there */ + /* were no chars available and the other end has terminated. */ + /* Either way, signal EOF. */ + DBPRINT(("read failed; dest = %d, errno = %d, status = %d\n", dest, terno, + UJ[slot].status)); + DBPRINT(("Indicating EOF from PTY desc %d.\n", slot)); + return (NIL); - default: - return(NIL); - } - } + default: return (NIL); + } + } - case 10: /* Change window */ - { int rows, cols, pgrp, pty; -#if (!defined( HPUX) && !defined(RISCOS)) - struct winsize w; + case 10: /* Change window */ + { + int rows, cols, pgrp, pty; +#if (!defined(HPUX) && !defined(RISCOS)) + struct winsize w; #endif /* HPUX */ - /* Get job #, rows, columns */ - N_GETNUMBER(args[1], slot, bad); - N_GETNUMBER(args[2], rows, bad); - N_GETNUMBER(args[3], cols, bad); + /* Get job #, rows, columns */ + N_GETNUMBER(args[1], slot, bad); + N_GETNUMBER(args[2], rows, bad); + N_GETNUMBER(args[3], cols, bad); #if (!defined(HPUX) && !defined(RISCOS)) - if (valid_slot(slot) - && (UJ[slot].type == UJSHELL) - && (UJ[slot].status == -1)) - { - w.ws_row = rows; - w.ws_col = cols; - w.ws_xpixel = 0; /* not used */ - w.ws_ypixel = 0; - pty = slot; - /* Change window size, then - notify process group of the change */ - if ((ioctl(pty, TIOCSWINSZ, &w) >= 0) && + if (valid_slot(slot) && (UJ[slot].type == UJSHELL) && (UJ[slot].status == -1)) { + w.ws_row = rows; + w.ws_col = cols; + w.ws_xpixel = 0; /* not used */ + w.ws_ypixel = 0; + pty = slot; + /* Change window size, then + notify process group of the change */ + if ((ioctl(pty, TIOCSWINSZ, &w) >= 0) && #ifdef ISC - (tcgetpgrp(pty) >= 0) && + (tcgetpgrp(pty) >= 0) && #else - (ioctl(pty, TIOCGPGRP, &pgrp) >= 0) && + (ioctl(pty, TIOCGPGRP, &pgrp) >= 0) && #endif /* ISC */ #ifdef SYSVONLY - (kill(-pgrp, SIGWINCH) >= 0)) + (kill(-pgrp, SIGWINCH) >= 0)) #else - (killpg(pgrp, SIGWINCH) >= 0)) + (killpg(pgrp, SIGWINCH) >= 0)) #endif /* RISCOS */ - return (ATOM_T); - return(GetSmallp(errno)); - } + return (ATOM_T); + return (GetSmallp(errno)); + } #endif /* HPUX | RISCOS */ - return(NIL); - } + return (NIL); + } #ifndef ISC - case 12: /* create Unix socket */ + case 12: /* create Unix socket */ - { - int res, sockFD; - struct sockaddr_un sock; + { + int res, sockFD; + struct sockaddr_un sock; - - /* First open the socket */ - sockFD = socket(AF_UNIX, SOCK_STREAM, 0); - if (sockFD < 0) - { perror("socket open"); - return(NIL);} - /* Then get a process slot and blit the pathname of the - socket into it */ - /* need to type-check the string here */ - LispStringToCString(args[1], shcom, 2048); - UJ[sockFD].pathname = malloc(strlen(shcom) + 1); - strcpy(UJ[sockFD].pathname, shcom); - /* Then bind it to the pathname, and get it listening properly */ - - sock.sun_family = AF_UNIX; - strcpy(sock.sun_path, shcom); - if (bind(sockFD, (struct sockaddr *) &sock, - strlen(shcom)+sizeof(sock.sun_family)) < 0) - { - close(sockFD); - free(UJ[sockFD].pathname); - UJ[sockFD].type = UJUNUSED; - perror("binding Lisp sockets"); - return(NIL); - } - DBPRINT(("Socket %d bound to name %s.\n", sockFD, shcom)); - if(listen(sockFD, 1)<0) perror("Listen"); - /* Set up the IO not to block */ - res = fcntl(sockFD, F_GETFL, 0); -#ifdef ISC - res |= O_NONBLOCK; -#else - res |= FNDELAY; -#endif /* ISC */ - res = fcntl(sockFD, F_SETFL, res); - - /* things seem sane, fill out the rest of the UJ slot and return */ - UJ[sockFD].status = -1; - UJ[sockFD].PID = -1; - UJ[sockFD].type = UJSOCKET; - - return(GetSmallp(sockFD)); - } - break; -#else - error("Socket creation not supported on ISC"); -#endif /* ISC */ - - - case 13: /* try to accept */ - { - /* returns file descriptor if successful, - -1 if no connection available, - NIL if failure */ - int sockFD, newFD; - - N_GETNUMBER(args[1], sockFD, bad); - if(UJ[sockFD].type == UJSOCKET && - UJ[sockFD].pathname != NULL) { - /* sockFD SHOULD be non-blocking; - but I'll time this out just in case */ - case13_lp: - TIMEOUT(newFD = accept(sockFD, (struct sockaddr *) 0, - (int *) 0)); - if (newFD < 0) - if (errno == EINTR) goto case13_lp; - else if (errno == EWOULDBLOCK) - return (GetSmallp(-1)); - else { - perror("Lisp socket accept"); - return (NIL); - } - else { - UJ[newFD].status = -1; - UJ[newFD].PID = -1; - UJ[newFD].type = UJSOSTREAM; - return(GetSmallp(newFD)); - } - } else return(NIL); - } - break; - - - case 14: /* return type of socket */ - { - int streamFD; - - N_GETNUMBER(args[1], streamFD, bad); - if(valid_slot(streamFD)) - return GetSmallp(UJ[streamFD].type); - else return NIL; - } - break; - - - - case 15: /* Write buffer */ - { char *bufp; - N_GETNUMBER(args[1], slot, bad); /* Get job # */ - bufp = (char*)(Addr68k_from_LADDR(args[2])); /* User buffer */ - N_GETNUMBER(args[3], i, bad); /* # to write */ - DBPRINT(("Write buffer, type is %d\n", UJ[slot].type)); - - switch(UJ[slot].type) { - case UJSHELL: - case UJPROCESS: - case UJSOSTREAM: -#ifdef BYTESWAP - word_swap_page(bufp, (i+3)>>2); -#endif /* BYTESWAP */ - - dest = write(slot, bufp, i); -#ifdef BYTESWAP - word_swap_page(bufp, (i+3)>>2); -#endif /* BYTESWAP */ - - if (dest > 0) return(GetSmallp(dest)); - /* Something's amiss; update process status */ - wait_for_comm_processes(); /* make sure we're up to date */ - if (((dest == 0) || - (errno == EWOULDBLOCK)) && (UJ[slot].status == -1)) - /* No room to write, but other guy still running */ - return(ATOM_T); - /* At this point, we either got an I/O error, or there */ - /* were no chars available and the other end has terminated. */ - /* Either way, signal EOF. */ - DBPRINT(("Indicating write failure from PTY desc %d.\n", slot)); - return(NIL); - } - } - - default: return(NIL); - } - - bad: - DBPRINT(("Bad input value.")); - return(NIL); + /* First open the socket */ + sockFD = socket(AF_UNIX, SOCK_STREAM, 0); + if (sockFD < 0) { + perror("socket open"); + return (NIL); } + /* Then get a process slot and blit the pathname of the + socket into it */ + /* need to type-check the string here */ + LispStringToCString(args[1], shcom, 2048); + UJ[sockFD].pathname = malloc(strlen(shcom) + 1); + strcpy(UJ[sockFD].pathname, shcom); + /* Then bind it to the pathname, and get it listening properly */ + sock.sun_family = AF_UNIX; + strcpy(sock.sun_path, shcom); + if (bind(sockFD, (struct sockaddr *)&sock, strlen(shcom) + sizeof(sock.sun_family)) < 0) { + close(sockFD); + free(UJ[sockFD].pathname); + UJ[sockFD].type = UJUNUSED; + perror("binding Lisp sockets"); + return (NIL); + } + DBPRINT(("Socket %d bound to name %s.\n", sockFD, shcom)); + if (listen(sockFD, 1) < 0) perror("Listen"); + /* Set up the IO not to block */ + res = fcntl(sockFD, F_GETFL, 0); +#ifdef ISC + res |= O_NONBLOCK; +#else + res |= FNDELAY; +#endif /* ISC */ + res = fcntl(sockFD, F_SETFL, res); + /* things seem sane, fill out the rest of the UJ slot and return */ + UJ[sockFD].status = -1; + UJ[sockFD].PID = -1; + UJ[sockFD].type = UJSOCKET; + return (GetSmallp(sockFD)); + } break; +#else + error("Socket creation not supported on ISC"); +#endif /* ISC */ + + case 13: /* try to accept */ + { + /* returns file descriptor if successful, + -1 if no connection available, + NIL if failure */ + int sockFD, newFD; + + N_GETNUMBER(args[1], sockFD, bad); + if (UJ[sockFD].type == UJSOCKET && UJ[sockFD].pathname != NULL) { + /* sockFD SHOULD be non-blocking; + but I'll time this out just in case */ + case13_lp: + TIMEOUT(newFD = accept(sockFD, (struct sockaddr *)0, (int *)0)); + if (newFD < 0) + if (errno == EINTR) + goto case13_lp; + else if (errno == EWOULDBLOCK) + return (GetSmallp(-1)); + else { + perror("Lisp socket accept"); + return (NIL); + } + else { + UJ[newFD].status = -1; + UJ[newFD].PID = -1; + UJ[newFD].type = UJSOSTREAM; + return (GetSmallp(newFD)); + } + } else + return (NIL); + } break; + + case 14: /* return type of socket */ + { + int streamFD; + + N_GETNUMBER(args[1], streamFD, bad); + if (valid_slot(streamFD)) + return GetSmallp(UJ[streamFD].type); + else + return NIL; + } break; + + case 15: /* Write buffer */ + { + char *bufp; + N_GETNUMBER(args[1], slot, bad); /* Get job # */ + bufp = (char *)(Addr68k_from_LADDR(args[2])); /* User buffer */ + N_GETNUMBER(args[3], i, bad); /* # to write */ + DBPRINT(("Write buffer, type is %d\n", UJ[slot].type)); + + switch (UJ[slot].type) { + case UJSHELL: + case UJPROCESS: + case UJSOSTREAM: +#ifdef BYTESWAP + word_swap_page(bufp, (i + 3) >> 2); +#endif /* BYTESWAP */ + + dest = write(slot, bufp, i); +#ifdef BYTESWAP + word_swap_page(bufp, (i + 3) >> 2); +#endif /* BYTESWAP */ + + if (dest > 0) return (GetSmallp(dest)); + /* Something's amiss; update process status */ + wait_for_comm_processes(); /* make sure we're up to date */ + if (((dest == 0) || (errno == EWOULDBLOCK)) && (UJ[slot].status == -1)) + /* No room to write, but other guy still running */ + return (ATOM_T); + /* At this point, we either got an I/O error, or there */ + /* were no chars available and the other end has terminated. */ + /* Either way, signal EOF. */ + DBPRINT(("Indicating write failure from PTY desc %d.\n", slot)); + return (NIL); + } + } + + default: return (NIL); + } + +bad: + DBPRINT(("Bad input value.")); + return (NIL); +} /************************************************************************/ /* */ @@ -1217,13 +1129,13 @@ printf("Shell job %d, PID = %d\n", slot, UJ[slot].PID); /* */ /************************************************************************/ -void WriteLispStringToPipe (LispPTR lispstr) -{ unsigned short len; - LispStringToCString(lispstr, shcom, 2048); - /* Write string length, then string */ - len = strlen(shcom) + 1; - write(UnixPipeOut, &len, 2); - write(UnixPipeOut, shcom, len); - } +void WriteLispStringToPipe(LispPTR lispstr) { + unsigned short len; + LispStringToCString(lispstr, shcom, 2048); + /* Write string length, then string */ + len = strlen(shcom) + 1; + write(UnixPipeOut, &len, 2); + write(UnixPipeOut, shcom, len); +} #endif /* DOS */ diff --git a/src/unixfork.c b/src/unixfork.c old mode 100755 new mode 100644 index e35233b..5603887 --- a/src/unixfork.c +++ b/src/unixfork.c @@ -1,7 +1,7 @@ -/* $Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* Code to fork a subprocess for Unix communication */ @@ -22,7 +22,6 @@ static char *id = "$Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ Copy /* */ /************************************************************************/ - #include "version.h" #include @@ -44,7 +43,6 @@ static char *id = "$Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ Copy #define FULLSLAVENAME #endif - #include #ifndef USETERMIOS #include @@ -56,7 +54,6 @@ static char *id = "$Id: unixfork.c,v 1.6 2001/12/26 22:17:05 sybalsky Exp $ Copy #endif /* INDIGO */ #endif /* USETERMIOS */ - #ifdef OSF1 #define _CLOCK_ID_T typedef int clockid_t; @@ -64,7 +61,6 @@ typedef int clockid_t; #include #endif /* OSF1 */ - #ifdef HPUX #include #include @@ -96,33 +92,30 @@ typedef int clockid_t; #include #endif - -static __inline__ int +static __inline__ int #ifdef OS4 -SAFEREAD( f, b, c) +SAFEREAD(f, b, c) #else -SAFEREAD(int f, char *b, int c) +SAFEREAD(int f, char *b, int c) #endif { - int res; - loop: - res = read(f, b, c); - if ( (res < 0) ) - { - if ( errno == EINTR || errno == EAGAIN ) goto loop; - perror("reading UnixPipeIn"); - } - return (res); + int res; +loop: + res = read(f, b, c); + if ((res < 0)) { + if (errno == EINTR || errno == EAGAIN) goto loop; + perror("reading UnixPipeIn"); + } + return (res); } /* The following globals are used to communicate between Unix subprocesses and LISP */ +long StartTime; /* Time, for creating pipe filenames */ -long StartTime; /* Time, for creating pipe filenames */ - -char shcom[512]; /* Here because I'm suspicious of */ - /* large allocations on the stack */ +char shcom[512]; /* Here because I'm suspicious of */ + /* large allocations on the stack */ /* fork_Unix is the secondary process spawned right after LISP is started, to avoid having TWO 8 mbyte images sitting around. It listens @@ -131,20 +124,20 @@ char shcom[512]; /* Here because I'm suspicious of */ Byte 0: Command character, one of: S: Fork PTY (shell) process. This is used for CHAT windows. - P: New version of S, takes 2 string args. - F: Fork piped shell, takes 1 string arg. - 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. + P: New version of S, takes 2 string args. + F: Fork piped shell, takes 1 string arg. + 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] - [For F, process # for pipe naming] + [For S&P, pty letter] + [For F, process # for pipe naming] Byte 2: Value, used as follows: Only used for W command, contains byte to write - [For S&P, pty number] + [For S&P, pty number] Byte 3: Slot number. In the case of F & P commands, additional data follows the 4 byte packet. @@ -161,26 +154,21 @@ of the packet received except: R: Byte 2 is value of byte read from stdin, if any Byte 3 is 1 if successful, 2 if EOF, 0 if nothing waiting W: Bytes 0 & 1 are the Process ID of the terminated process - Bytes 2 & 3 are the high & low bytes of the exit status. + Bytes 2 & 3 are the high & low bytes of the exit status. K: Bytes 1 and 2 are the high and low bytes of the exit status of the process. - Byte 3 is 1 if an exit status was available. + 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 + Byte 1 and Byte 2 are the process ID of OCR process */ - - -fork_Unix() -{ - - int LispToUnix[2], /* Incoming pipe from LISP */ - UnixToLisp[2], /* Outgoing pipe to LISP */ - UnixPID, - LispPipeIn, LispPipeOut, res, slot; +fork_Unix() { + int LispToUnix[2], /* Incoming pipe from LISP */ + UnixToLisp[2], /* Outgoing pipe to LISP */ + UnixPID, LispPipeIn, LispPipeOut, res, slot; pid_t pid; char IOBuf[4]; @@ -197,8 +185,8 @@ fork_Unix() exit(-1); } - StartTime = time(0); /* Save the time, to create filenames with */ - StartTime &= 0xFFFFFF; /* as a positive number! */ + StartTime = time(0); /* Save the time, to create filenames with */ + StartTime &= 0xFFFFFF; /* as a positive number! */ /* interrupts need to be blocked here so subprocess won't see them */ #ifdef SYSVSIGNALS @@ -208,18 +196,15 @@ fork_Unix() sighold(SIGXFSZ); sighold(SIGFPE); #else - sigblock(sigmask(SIGVTALRM) | sigmask(SIGIO) - | sigmask(SIGALRM) + sigblock(sigmask(SIGVTALRM) | sigmask(SIGIO) | sigmask(SIGALRM) #ifndef HPUX - | sigmask(SIGXFSZ) + | sigmask(SIGXFSZ) #endif /* HPUX */ - | sigmask(SIGFPE) - ); + | sigmask(SIGFPE)); #endif /* SYSVSIGNALS */ - - if ((UnixPID = fork()) == -1) { /* Fork off small version of the emulator */ + if ((UnixPID = fork()) == -1) { /* Fork off small version of the emulator */ perror("fork"); exit(-1); } @@ -229,9 +214,9 @@ fork_Unix() and put their numbers in the environment so parent can find them */ /* JDS - NB that sprintf doesn't always return a string! */ - char* tempstring; + char *tempstring; - tempstring = (char *) malloc(30); + tempstring = (char *)malloc(30); sprintf(tempstring, "LDEPIPEIN=%d", UnixToLisp[0]); putenv(tempstring); @@ -249,7 +234,7 @@ fork_Unix() close(LispToUnix[0]); close(UnixToLisp[1]); - return(1); + return (1); } LispPipeIn = LispToUnix[0]; @@ -258,321 +243,297 @@ fork_Unix() close(UnixToLisp[0]); res = fcntl(LispPipeIn, F_GETFL, 0); - res &= (65535-FNDELAY); + res &= (65535 - FNDELAY); res = fcntl(LispPipeIn, F_SETFL, res); while (1) { int len; len = 0; - while (len != 4) - { - if ((len = SAFEREAD(LispPipeIn, IOBuf, 4)) <0) - { /* Get packet */ - perror("Packet read by slave"); - /* kill_comm_processes(); */ - exit(0); - } - if (len != 4) - { - DBPRINT(("Input packet wrong length: %d.\n", len)); - exit(0); - } + while (len != 4) { + if ((len = SAFEREAD(LispPipeIn, IOBuf, 4)) < 0) { /* Get packet */ + perror("Packet read by slave"); + /* kill_comm_processes(); */ + exit(0); + } + if (len != 4) { + DBPRINT(("Input packet wrong length: %d.\n", len)); + exit(0); + } } slot = IOBuf[3]; - IOBuf[3] = 1; /* Start by signalling success in return-code */ + IOBuf[3] = 1; /* Start by signalling success in return-code */ - switch(IOBuf[0]) { - - case 'S': case 'P': /* Fork PTY shell */ - if (slot >= 0) - { /* Found a free slot */ - char termtype[32]; + switch (IOBuf[0]) { + case 'S': + case 'P': /* Fork PTY shell */ + if (slot >= 0) { /* Found a free slot */ + char termtype[32]; #ifdef FULLSLAVENAME - char slavepty[32]; /* For slave pty name */ + char slavepty[32]; /* For slave pty name */ - if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading slave pty len"); - if (SAFEREAD(LispPipeIn, slavepty, tmp) < 0) perror("Slave reading slave pty id"); + if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading slave pty len"); + if (SAFEREAD(LispPipeIn, slavepty, tmp) < 0) perror("Slave reading slave pty id"); #endif /* INDIGO */ - if (IOBuf[0] == 'P') - { /* The new style, which takes term type & command to csh */ - if(SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length"); - if(SAFEREAD(LispPipeIn, termtype, tmp) < 0) perror("Slave reading termtype"); - if(SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length"); - if (tmp > 510) cmdstring = (char *)malloc(tmp+5); - else cmdstring = shcom; + if (IOBuf[0] == 'P') { /* The new style, which takes term type & command to csh */ + if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length"); + if (SAFEREAD(LispPipeIn, termtype, tmp) < 0) perror("Slave reading termtype"); + if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length"); + if (tmp > 510) + cmdstring = (char *)malloc(tmp + 5); + else + cmdstring = shcom; - if(SAFEREAD(LispPipeIn, cmdstring, tmp) < 0) perror("Slave reading shcom"); - } - else /* old style, no args */ - { termtype[0] = 0; cmdstring[0] = 0; } + if (SAFEREAD(LispPipeIn, cmdstring, tmp) < 0) perror("Slave reading shcom"); + } else /* old style, no args */ + { + termtype[0] = 0; + cmdstring[0] = 0; + } - /* Alloc a PTY and fork */ +/* Alloc a PTY and fork */ #ifdef FULLSLAVENAME - pid = ForkUnixShell(slot, slavepty, termtype, cmdstring); + pid = ForkUnixShell(slot, slavepty, termtype, cmdstring); #else - pid = ForkUnixShell(slot, IOBuf[1], IOBuf[2], termtype, cmdstring); + pid = ForkUnixShell(slot, IOBuf[1], IOBuf[2], termtype, cmdstring); #endif - if (pid == -1) - { - printf("Impossible failure from ForkUnixShell??\n"); - fflush(stdout); - IOBuf[3] = 0; - } - else - { - /* ForkUnixShell sets the pid and standard in/out variables */ - IOBuf[1] = (pid >> 8)& 0xFF; - IOBuf[2] = pid & 0xFF; - } + if (pid == -1) { + printf("Impossible failure from ForkUnixShell??\n"); + fflush(stdout); + IOBuf[3] = 0; + } else { + /* ForkUnixShell sets the pid and standard in/out variables */ + IOBuf[1] = (pid >> 8) & 0xFF; + IOBuf[2] = pid & 0xFF; + } + } else { + printf("Can't get process slot for PTY shell.\n"); + fflush(stdout); + IOBuf[3] = 0; } - else - { - printf("Can't get process slot for PTY shell.\n"); - fflush(stdout); - IOBuf[3] = 0; - } - break; + break; - case 'F': /* Fork pipe command */ - if (slot >= 0) - { + case 'F': /* Fork pipe command */ + if (slot >= 0) { + /* Read in the length of the shell command, and then the command */ + if (SAFEREAD(LispPipeIn, (char *)&tmp, 2) < 0) perror("Slave reading cmd length"); + if (tmp > 510) + cmdstring = (char *)malloc(tmp + 5); + else + cmdstring = shcom; + if (SAFEREAD(LispPipeIn, cmdstring, tmp) < 0) perror("Slave reading cmd"); + DBPRINT(("Cmd len = %d.\n", tmp)); + DBPRINT(("Rev'd cmd string: %s\n", cmdstring)); + pid = fork(); /* Fork */ - /* Read in the length of the shell command, and then the command */ - if(SAFEREAD(LispPipeIn, (char *)&tmp, 2)<0) perror("Slave reading cmd length"); - if (tmp > 510) cmdstring = (char *)malloc(tmp+5); - else cmdstring = shcom; - if(SAFEREAD(LispPipeIn, cmdstring, tmp)<0) perror("Slave reading cmd"); - DBPRINT(("Cmd len = %d.\n", tmp)); - DBPRINT(("Rev'd cmd string: %s\n", cmdstring)); - pid = fork(); /* Fork */ - - if (pid == 0) - { - int i; - int status, sock; + if (pid == 0) { + int i; + int status, sock; #ifndef ISC - struct sockaddr_un addr; - char PipeName[40]; - sock = socket(AF_UNIX, SOCK_STREAM, 0); - if (sock < 0) {perror("slave socket"); exit(0);} - sprintf(PipeName, "/tmp/LPU%ld-%d", StartTime, slot); - addr.sun_family = AF_UNIX; - strcpy(addr.sun_path, PipeName); - status = connect(sock, (struct sockaddr *)&addr, - strlen(PipeName)+sizeof(addr.sun_family)); - if(status<0) - { - perror("slave connect"); - printf("Name = %s.\n", PipeName); fflush(stdout); - exit(0); - } - else - { - DBPRINT(("Slave connected on %s.\n", PipeName)); - } + struct sockaddr_un addr; + char PipeName[40]; + sock = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock < 0) { + perror("slave socket"); + exit(0); + } + sprintf(PipeName, "/tmp/LPU%ld-%d", StartTime, slot); + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, PipeName); + status = + connect(sock, (struct sockaddr *)&addr, strlen(PipeName) + sizeof(addr.sun_family)); + if (status < 0) { + perror("slave connect"); + printf("Name = %s.\n", PipeName); + fflush(stdout); + exit(0); + } else { + DBPRINT(("Slave connected on %s.\n", PipeName)); + } - /* Copy the pipes onto stdin, stdout, and stderr */ - dup2(sock,0); - dup2(sock,1); - dup2(sock,2); + /* Copy the pipes onto stdin, stdout, and stderr */ + dup2(sock, 0); + dup2(sock, 1); + dup2(sock, 2); #else - /* New, FIFO-based communication regime */ - int down, up; /* fifo fds */ - char DownFIFO[48], UpFIFO[48]; + /* New, FIFO-based communication regime */ + int down, up; /* fifo fds */ + char DownFIFO[48], UpFIFO[48]; - sprintf(DownFIFO, "/tmp/LPD%d-%d", StartTime, slot); - sprintf(UpFIFO, "/tmp/LPU%d-%d", StartTime, slot); + sprintf(DownFIFO, "/tmp/LPD%d-%d", StartTime, slot); + sprintf(UpFIFO, "/tmp/LPU%d-%d", StartTime, slot); - if ((down = open(DownFIFO, O_RDONLY | O_NDELAY)) < 0) - { - perror("slave opening down fifo"); - exit(0); - } - if ((up = open(UpFIFO, O_WRONLY | O_NDELAY)) < 0) - { - perror("slave opening up fifo"); - exit(0); - } + if ((down = open(DownFIFO, O_RDONLY | O_NDELAY)) < 0) { + perror("slave opening down fifo"); + exit(0); + } + if ((up = open(UpFIFO, O_WRONLY | O_NDELAY)) < 0) { + perror("slave opening up fifo"); + exit(0); + } - /* Copy the fifos onto stdin, stdout, and stderr */ - dup2(down,0); - dup2(up,1); - dup2(up,2); + /* Copy the fifos onto stdin, stdout, and stderr */ + dup2(down, 0); + dup2(up, 1); + dup2(up, 2); - /* unlink(DownFIFO); - unlink(UpFIFO); */ +/* unlink(DownFIFO); + unlink(UpFIFO); */ #endif /* oldPIPEway */ - #ifdef SYSVONLY - /* Make sure everything else is closed POSIX has no getdtab... */ - for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) - close(i); + /* Make sure everything else is closed POSIX has no getdtab... */ + for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) close(i); #else - /* Make sure everything else is closed */ - for (i = 3; i < getdtablesize(); i++) - close(i); + /* Make sure everything else is closed */ + for (i = 3; i < getdtablesize(); i++) close(i); #endif /* HPUX */ - - /* Run the shell command and get the result */ - status = system(cmdstring); - if (cmdstring != shcom) free(cmdstring); - /* Comment out to fix USAR 11302 (FXAR 320) - unlink(PipeName); - */ - _exit((status & ~0xff) ? (status >> 8) : status); - } - - /* Check for error doing the fork */ - if (pid == (pid_t)-1) - { - perror("unixcomm: fork"); - IOBuf[3] = 0; - } - else - { - IOBuf[1] = (pid >> 8)& 0xFF; - IOBuf[2] = pid & 0xFF; - - } - } else - { - printf("No process slots available.\n"); - IOBuf[3] = 0; /* Couldn't get a process slot */ - } - break; - - - case 'W': /* Wait for a process to die. */ - { - int pid; -#if defined(SYSVONLY) || defined(WAITINT) - int status; -#else - union wait status; -#endif /* SYSVONLY */ - - int slot; - -#if defined(SYSVONLY) || defined(WAITINT) - status = 0; -#else - status.w_status = 0; -#endif /* SYSVONLY */ - - IOBuf[0] = 0; IOBuf[1] = 0; - DBPRINT(("About to wait for processes.\n")); -#ifdef SYSVONLY - retry1: - pid = waitpid(-1, &status, WNOHANG); - if (pid == -1 && errno == EINTR) goto retry1; -#else - pid = wait3(&status, WNOHANG, 0); -#endif /* SYSVONLY */ - if (pid > 0) - - { - /* Ignore processes which are suspended but haven't exited - (this shouldn't happen) */ -#if defined(SYSVONLY) || defined(WAITINT) - if (WIFSTOPPED(status )) break; - IOBuf[3] = status >>8; - IOBuf[2] = status & 0xFF; -#else - if (status.w_stopval == WSTOPPED) break; - IOBuf[3] = status.w_T.w_Retcode; - IOBuf[2] = status.w_T.w_Termsig; -#endif /* SYSVONLY */ - - IOBuf[1] = pid & 0xFF; - IOBuf[0] = (pid>>8) & 0xFF; + /* Run the shell command and get the result */ + status = system(cmdstring); + if (cmdstring != shcom) free(cmdstring); + /* Comment out to fix USAR 11302 (FXAR 320) + unlink(PipeName); + */ + _exit((status & ~0xff) ? (status >> 8) : status); } - DBPRINT(("wait3 returned pid = %d.\n", pid)); + + /* Check for error doing the fork */ + if (pid == (pid_t)-1) { + perror("unixcomm: fork"); + IOBuf[3] = 0; + } else { + IOBuf[1] = (pid >> 8) & 0xFF; + IOBuf[2] = pid & 0xFF; + } + } else { + printf("No process slots available.\n"); + IOBuf[3] = 0; /* Couldn't get a process slot */ + } + break; + + case 'W': /* Wait for a process to die. */ + { + int pid; +#if defined(SYSVONLY) || defined(WAITINT) + int status; +#else + union wait status; +#endif /* SYSVONLY */ + + int slot; + +#if defined(SYSVONLY) || defined(WAITINT) + status = 0; +#else + status.w_status = 0; +#endif /* SYSVONLY */ + + IOBuf[0] = 0; + IOBuf[1] = 0; + DBPRINT(("About to wait for processes.\n")); +#ifdef SYSVONLY + retry1: + pid = waitpid(-1, &status, WNOHANG); + if (pid == -1 && errno == EINTR) goto retry1; +#else + pid = wait3(&status, WNOHANG, 0); +#endif /* SYSVONLY */ + if (pid > 0) + + { +/* Ignore processes which are suspended but haven't exited + (this shouldn't happen) */ +#if defined(SYSVONLY) || defined(WAITINT) + if (WIFSTOPPED(status)) break; + IOBuf[3] = status >> 8; + IOBuf[2] = status & 0xFF; +#else + if (status.w_stopval == WSTOPPED) break; + IOBuf[3] = status.w_T.w_Retcode; + IOBuf[2] = status.w_T.w_Termsig; +#endif /* SYSVONLY */ + + IOBuf[1] = pid & 0xFF; + IOBuf[0] = (pid >> 8) & 0xFF; + } + DBPRINT(("wait3 returned pid = %d.\n", pid)); } break; - case 'C': /* Close stdin to subprocess */ - - break; - - - case 'K': /* Kill subprocess */ - - break; + case 'C': /* Close stdin to subprocess */ break; + case 'K': /* Kill subprocess */ break; #ifdef OCR - case 'w': /* Wait paticular process to die */ + case 'w': /* Wait paticular process to die */ { - int pid, res, status; + int pid, res, status; - pid = IOBuf[1] << 8 | IOBuf[2]; + 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; + retry: + res = waitpid(pid, &status, WNOHANG); + if (res == -1 && errno == EINTR) goto retry; - 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; + 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; - 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); - } + 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; - (void)ocr_proc(ppid); - OCR_sv = -1; - exit(1); - } + 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); + } - 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; + (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 */ @@ -580,9 +541,6 @@ fork_Unix() } } - - - /************************************************************************/ /* */ /* F o r k U n i x S h e l l */ @@ -593,7 +551,6 @@ fork_Unix() /* */ /************************************************************************/ - /* Creates a PTY connection to a csh */ #ifdef FULLSLAVENAME @@ -601,138 +558,127 @@ ForkUnixShell(slot, PtySlave, termtype, shellarg) #else ForkUnixShell(slot, ltr, numb, termtype, shellarg) #endif - int slot; + int slot; #ifdef FULLSLAVENAME - char * PtySlave; +char *PtySlave; #else - char ltr, numb; +char ltr, numb; #endif - char *termtype, *shellarg; +char *termtype, *shellarg; - { +{ #ifdef FULLSLAVENAME - char buf[1]; + char buf[1]; #else - char PtySlave[20], buf[1]; + char PtySlave[20], buf[1]; #endif - int res, PID, MasterFD, SlaveFD; + int res, PID, MasterFD, SlaveFD; #ifdef USETERMIOS - struct termios tio; + struct termios tio; #else - struct sgttyb tio; + struct sgttyb tio; #endif /* USETERMIOS */ + PID = fork(); - PID = fork(); + if (PID == 0) { + char envstring[64]; + char *argvec[4]; - if (PID == 0) - { - char envstring[64]; - char *argvec[4]; - #ifndef SYSVONLY - /* Divorce ourselves from /dev/tty */ - res = open("/dev/tty", O_RDWR); - if (res >= 0) - { - (void) ioctl(res, TIOCNOTTY, (char *)0); - (void) close(res); - } - else - { - perror("Slave TTY"); - exit(0); - } + /* Divorce ourselves from /dev/tty */ + res = open("/dev/tty", O_RDWR); + if (res >= 0) { + (void)ioctl(res, TIOCNOTTY, (char *)0); + (void)close(res); + } else { + perror("Slave TTY"); + exit(0); + } #else - if( 0 > setsid()) /* create us a new session for tty purposes */ - perror("setsid"); + if (0 > setsid()) /* create us a new session for tty purposes */ + perror("setsid"); #endif - /* Open the slave side */ +/* Open the slave side */ #ifndef FULLSLAVENAME - sprintf(PtySlave, "/dev/tty%c%c", ltr, numb); + sprintf(PtySlave, "/dev/tty%c%c", ltr, numb); #endif - SlaveFD = open(PtySlave, O_RDWR); - if (SlaveFD == -1) - { - perror("Slave Open"); - perror(PtySlave); - exit(0); - } + SlaveFD = open(PtySlave, O_RDWR); + if (SlaveFD == -1) { + perror("Slave Open"); + perror(PtySlave); + exit(0); + } #ifdef OS5 - ioctl(SlaveFD, I_PUSH, "ptem"); - ioctl(SlaveFD, I_PUSH, "ldterm"); + ioctl(SlaveFD, I_PUSH, "ptem"); + ioctl(SlaveFD, I_PUSH, "ldterm"); #endif /* OS5 */ #ifndef USETERMIOS -/* This is the old way we set up terminal (OS 3), using an - obsolete ioctl and wrong flags for a display. */ - ioctl(SlaveFD, TIOCGETP, (char *)&tio); - tio.sg_flags |= CRMOD; - tio.sg_flags |= ECHO; - ioctl(SlaveFD, TIOCSETP, (char *)&tio); + /* This is the old way we set up terminal (OS 3), using an + obsolete ioctl and wrong flags for a display. */ + ioctl(SlaveFD, TIOCGETP, (char *)&tio); + tio.sg_flags |= CRMOD; + tio.sg_flags |= ECHO; + ioctl(SlaveFD, TIOCSETP, (char *)&tio); #else - /* Set up as basic display terminal: canonical erase, - kill processing, echo, backspace to erase, echo ctrl - chars as ^x, kill line by backspacing */ +/* Set up as basic display terminal: canonical erase, + kill processing, echo, backspace to erase, echo ctrl + chars as ^x, kill line by backspacing */ #if defined(MACOSX) || defined(FREEBSD) - tcgetattr(SlaveFD, &tio); + tcgetattr(SlaveFD, &tio); #else - ioctl(SlaveFD, TCGETS, (char *)&tio); + ioctl(SlaveFD, TCGETS, (char *)&tio); #endif #ifdef INDIGO - tio.c_lflag |= ICANON | ECHO | ECHOE; + tio.c_lflag |= ICANON | ECHO | ECHOE; #else - tio.c_lflag |= ICANON | ECHO | ECHOE | ECHOCTL | ECHOKE; + tio.c_lflag |= ICANON | ECHO | ECHOE | ECHOCTL | ECHOKE; #endif /* INDIGO */ #if defined(MACOSX) || defined(FREEBSD) - tcsetattr(SlaveFD, TCSANOW, &tio); + tcsetattr(SlaveFD, TCSANOW, &tio); #else - ioctl(SlaveFD, TCSETS, (char *)&tio); + ioctl(SlaveFD, TCSETS, (char *)&tio); #endif #endif /* USETERMIOS */ - (void) dup2(SlaveFD, 0); - (void) dup2(SlaveFD, 1); - (void) dup2(SlaveFD, 2); - (void) close(SlaveFD); + (void)dup2(SlaveFD, 0); + (void)dup2(SlaveFD, 1); + (void)dup2(SlaveFD, 2); + (void)close(SlaveFD); - /* set the LDESHELL variable so the underlying .cshrc can see it and - configure the shell appropriately, though this may not be so important any more */ - putenv("LDESHELL=YES"); + /* set the LDESHELL variable so the underlying .cshrc can see it and + configure the shell appropriately, though this may not be so important any more */ + putenv("LDESHELL=YES"); - if ((termtype[0] != 0) && (strlen(termtype) < 59)) - { /* set the TERM environment var */ - sprintf(envstring, "TERM=%s", termtype); - putenv(envstring); - } - /* Start up csh */ - argvec[0] = "csh"; - if (shellarg[0] != 0) - { /* setup to run command */ - argvec[1] = "-c"; /* read commands from next arg */ - argvec[2] = shellarg; - argvec[3] = (char *) 0; - } - else argvec[1] = (char *) 0; + if ((termtype[0] != 0) && (strlen(termtype) < 59)) { /* set the TERM environment var */ + sprintf(envstring, "TERM=%s", termtype); + putenv(envstring); + } + /* Start up csh */ + argvec[0] = "csh"; + if (shellarg[0] != 0) { /* setup to run command */ + argvec[1] = "-c"; /* read commands from next arg */ + argvec[2] = shellarg; + argvec[3] = (char *)0; + } else + argvec[1] = (char *)0; - execv("/bin/csh", argvec); + execv("/bin/csh", argvec); - /* Should never get here */ - perror("execv"); - exit(0); - } - else - { /* not the forked process. */ - if (shellarg != shcom) free(shellarg); - } - - /* Set the process group so all the kids get the bullet too - if (setpgrp(PID, PID) != 0) - perror("setpgrp"); */ - - return(PID); + /* Should never get here */ + perror("execv"); + exit(0); + } else { /* not the forked process. */ + if (shellarg != shcom) free(shellarg); } + /* Set the process group so all the kids get the bullet too + if (setpgrp(PID, PID) != 0) + perror("setpgrp"); */ + + return (PID); +} diff --git a/src/unwind.c b/src/unwind.c old mode 100755 new mode 100644 index 6b5e2ca..e2445da --- a/src/unwind.c +++ b/src/unwind.c @@ -1,10 +1,7 @@ -/* $Id: unwind.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: unwind.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: unwind.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -19,15 +16,13 @@ static char *id = "$Id: unwind.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ Copyri #include "version.h" - - /******************************************************************/ /* - File Name : unwind.c + File Name : unwind.c - Created : jul 17, 1987 by T.Shimizu - Changed : Sept 21 1988 BK + Created : jul 17, 1987 by T.Shimizu + Changed : Sept 21 1988 BK */ /******************************************************************/ @@ -37,75 +32,64 @@ static char *id = "$Id: unwind.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ Copyri #include "stack.h" #include "lspglob.h" - -UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep) -{ register int num ; /* number of UNBOUND slot */ - register LispPTR *endptr; /* unwind limit */ +UNSIGNED N_OP_unwind(register LispPTR *cstkptr, register LispPTR tos, int n, int keep) { + register int num; /* number of UNBOUND slot */ + register LispPTR *endptr; /* unwind limit */ register LispPTR *lastpvar; /* points PVar slot that is unbounded. */ + /* Slots: + ----------------- + | | <- PVar + ----------------- + | . | + | . | + ----------------- + | | ALL OF THE FOLLOWING LOCATIONS SCANNED: + ----------------------------------------------------------------- + | tos if keep | <- endptr (PVar[n]) <- Result (no keep) | + ----------------- | + | | <- Result (keep) | + ----------------- | + | | | + ----------------- | + | . | | + | . | | + ----------------- | + | tos pushed | <- Start CSTKPTR | + ----------------------------------------------------------------- + | | <- CSTKPTR temporarily bumped pushing tos + ----------------- -/* Slots: - ----------------- - | | <- PVar - ----------------- - | . | - | . | - ----------------- - | | ALL OF THE FOLLOWING LOCATIONS SCANNED: - ----------------------------------------------------------------- - | tos if keep | <- endptr (PVar[n]) <- Result (no keep) | - ----------------- | - | | <- Result (keep) | - ----------------- | - | | | - ----------------- | - | . | | - | . | | - ----------------- | - | tos pushed | <- Start CSTKPTR | - ----------------------------------------------------------------- - | | <- CSTKPTR temporarily bumped pushing tos - ----------------- + NOTE: upon return the emulator does a POP to get the new tos value - NOTE: upon return the emulator does a POP to get the new tos value + */ -*/ + endptr = (LispPTR *)PVar + n; /* set unwind limit */ - -endptr = (LispPTR *) PVar + n; /* set unwind limit */ - -if (endptr > cstkptr) { - CurrentStackPTR = (DLword *) cstkptr; - ERROR_EXIT(tos); - } -*cstkptr++ = tos; - - /* UNBOUND MARK loop */ - -while (cstkptr > endptr) - { - /* Look for the Next BIND marker */ - - if( (num = (int) *--cstkptr) < 0 ) - { - - /* Now UNBIND the PVARS indicated by the BIND marker */ - - lastpvar = (LispPTR *) (2 + PVar + (unsigned short) num) ; - num = ~(num >> 16) + 1; - for(; --num > 0; ) - { *--lastpvar = 0xffffffff ; /* Mark as UNBOUND */ } - }; - }; - - -/* endptr = cstkptr */ - - if(keep) - { - *(cstkptr++) = tos; + if (endptr > cstkptr) { + CurrentStackPTR = (DLword *)cstkptr; + ERROR_EXIT(tos); } - return((UNSIGNED) cstkptr); + *cstkptr++ = tos; + + /* UNBOUND MARK loop */ + + while (cstkptr > endptr) { + /* Look for the Next BIND marker */ + + if ((num = (int)*--cstkptr) < 0) { + /* Now UNBIND the PVARS indicated by the BIND marker */ + + lastpvar = (LispPTR *)(2 + PVar + (unsigned short)num); + num = ~(num >> 16) + 1; + for (; --num > 0;) { *--lastpvar = 0xffffffff; /* Mark as UNBOUND */ } + }; + }; + + /* endptr = cstkptr */ + + if (keep) { *(cstkptr++) = tos; } + return ((UNSIGNED)cstkptr); } /* N_OP_unwind */ @@ -113,122 +97,108 @@ while (cstkptr > endptr) /******************************************************************/ /* - SUBR: FIND_THE_BLIP + SUBR: FIND_THE_BLIP - find the blip down in the stack. Similar to the LISP - SI::UNWIND-TO-BLIP, except the target is returned instead - of doing the unwinding. Note that the unwider parameter - must already be properly set by the caller (i.e. to the - alink if necessary). + find the blip down in the stack. Similar to the LISP + SI::UNWIND-TO-BLIP, except the target is returned instead + of doing the unwinding. Note that the unwider parameter + must already be properly set by the caller (i.e. to the + alink if necessary). */ /******************************************************************/ #define SMALLP(x) (((unsigned int)x >> 16) == (S_POSITIVE >> 16)) -LispPTR find_the_blip(blip, throwp, unwinder) - register LispPTR blip; - register LispPTR throwp; - FX *unwinder; +LispPTR find_the_blip(blip, throwp, unwinder) register LispPTR blip; +register LispPTR throwp; +FX *unwinder; -{ register LispPTR target; - register FX *target_addr; - register LispPTR pc = NIL_PTR; +{ + register LispPTR target; + register FX *target_addr; + register LispPTR pc = NIL_PTR; -LispPTR CATCH_RETURN_PC_ATOM = parse_atomstring("SI::*CATCH-RETURN-PC*"); -LispPTR CHATCH_RETURN_TO_ATOM = parse_atomstring("SI::*CATCH-RETURN-TO*"); -LispPTR CATCH_RETURN_FROM_ATOM = parse_atomstring("SI::*CATCH-RETURN-FROM*"); - - for (target = (LispPTR) unwinder; - FX_INVALIDP(target); - GETCLINK(target_addr)) { - target_addr = (FX *) Addr68k_from_StkOffset(target); - if (blip == *target_addr) { - register LispPTR var_name_in_frame = - variable_name_in_frame(target_addr, (FVPVAR << 8) + 1); - if (var_name_in_frame == CHATCH_RETURN_TO_ATOM) { - if (throwp) { - pc = pvar_value_in_frame(target_addr, CATCH_RETURN_PC_ATOM); - if !(SMALLP(pc)) - error("Catch return-to frame lacks PC"); - } - goto cons_result; - } else - if (var_name_in_frame == CATCH_RETURN_FROM_ATOM) { - if (throwp) {target = GETCLINK(target_addr); }; - goto cons_result; - } - } /* if blip */ - }; /* for */ + LispPTR CATCH_RETURN_PC_ATOM = parse_atomstring("SI::*CATCH-RETURN-PC*"); + LispPTR CHATCH_RETURN_TO_ATOM = parse_atomstring("SI::*CATCH-RETURN-TO*"); + LispPTR CATCH_RETURN_FROM_ATOM = parse_atomstring("SI::*CATCH-RETURN-FROM*"); + for (target = (LispPTR)unwinder; FX_INVALIDP(target); GETCLINK(target_addr)) { + target_addr = (FX *)Addr68k_from_StkOffset(target); + if (blip == *target_addr) { + register LispPTR var_name_in_frame = variable_name_in_frame(target_addr, (FVPVAR << 8) + 1); + if (var_name_in_frame == CHATCH_RETURN_TO_ATOM) { + if (throwp) { + pc = pvar_value_in_frame(target_addr, CATCH_RETURN_PC_ATOM); + if + !(SMALLP(pc))error("Catch return-to frame lacks PC"); + } + goto cons_result; + } else if (var_name_in_frame == CATCH_RETURN_FROM_ATOM) { + if (throwp) { target = GETCLINK(target_addr); }; + goto cons_result; + } + } /* if blip */ + }; /* for */ no_result: - return(NIL_PTR); + return (NIL_PTR); cons_result: - return(cons(StkOffset_from_68K(target), pc)); + return (cons(StkOffset_from_68K(target), pc)); } - - - -LispPTR variable_name_in_frame(fx_addr, code) - FX *fx_addr; - register LispPTR code; +LispPTR variable_name_in_frame(fx_addr, code) FX *fx_addr; +register LispPTR code; { - register DLword *name_ptr; - register DLword *name_bind_ptr; - register DLword *name_table_base; - register DLword value; + register DLword *name_ptr; + register DLword *name_bind_ptr; + register DLword *name_table_base; + register DLword value; - name_table_base = Addr68k_from_LADDR(GETNAMETABLE(fx_addr)); - name_ptr = name_table_base + FNHEADSIZE; - name_table_base = name_ptr + ((FNHEAD *) name_table_base)->ntsize; + name_table_base = Addr68k_from_LADDR(GETNAMETABLE(fx_addr)); + name_ptr = name_table_base + FNHEADSIZE; + name_table_base = name_ptr + ((FNHEAD *)name_table_base)->ntsize; - while (value = GETWORD(name_ptr++)) do { - if (code == GETWORD(name_bind_ptr++)) {return(value) } ; - }; /* while */ - return(NIL_PTR); + while (value = GETWORD(name_ptr++)) do { + if (code == GETWORD(name_bind_ptr++)) { return (value) }; + }; /* while */ + return (NIL_PTR); }; /* variable_name_in_frame */ - - - /******************************************************************/ /* - pvar_value_in_frame searches through the name table for - frame_addr looking for the binding of atom_index. It - returns the PVAR value of the binding if the PVAR is found - & it is bound. + pvar_value_in_frame searches through the name table for + frame_addr looking for the binding of atom_index. It + returns the PVAR value of the binding if the PVAR is found + & it is bound. */ /******************************************************************/ -LispPTR pvar_value_in_frame(frame_addr, atom_index) - register FX *frame_addr; - register LispPTR atom_index; +LispPTR pvar_value_in_frame(frame_addr, atom_index) register FX *frame_addr; +register LispPTR atom_index; { - register DLword *name_ptr; - register DLword *name_bind_ptr; - register DLword *name_table_base; - register DLword value; + register DLword *name_ptr; + register DLword *name_bind_ptr; + register DLword *name_table_base; + register DLword value; - name_table_base = Addr68k_from_LADDR(GETNAMETABLE(frame_addr)); - name_ptr = name_table_base + FNHEADSIZE; - name_table_base = name_ptr + ((FNHEAD *) name_table_base)->ntsize; + name_table_base = Addr68k_from_LADDR(GETNAMETABLE(frame_addr)); + name_ptr = name_table_base + FNHEADSIZE; + name_table_base = name_ptr + ((FNHEAD *)name_table_base)->ntsize; - while (value = GETWORD(name_ptr++)) do { - if (value == atom_index) { - register DLword bind_info = GETWORD(name_bind_ptr); - if ((bind_info >> 8) == FVPVAR) { - register LispPTR slot_value = - *((LispPTR *) (FRAMESIZE + (DLword *) frame_addr) + - (bind_info - (FVPVAR << 8))) - if (slot_value > 0) { return(slot_value & POINTERMASK); }; - }; - }; - name_bind_ptr++; - }; /* while */ - return(NIL_PTR); + while (value = GETWORD(name_ptr++)) do { + if (value == atom_index) { + register DLword bind_info = GETWORD(name_bind_ptr); + if ((bind_info >> 8) == FVPVAR) { + register LispPTR slot_value = *((LispPTR *)(FRAMESIZE + (DLword *)frame_addr) + + (bind_info - (FVPVAR << 8))) if (slot_value > 0) { + return (slot_value & POINTERMASK); + }; + }; + }; + name_bind_ptr++; + }; /* while */ + return (NIL_PTR); }; /* pvar_value_in_frame */ - #endif diff --git a/src/uraid.c b/src/uraid.c old mode 100755 new mode 100644 index 75f5594..4cf1507 --- a/src/uraid.c +++ b/src/uraid.c @@ -1,7 +1,6 @@ /* @(#) uraid.c Version 1.52 (4/23/92). copyright Venue & Fuji Xerox */ static char *id = "@(#) uraid.c 1.52 4/23/92 (Venue & Fuji Xerox)"; - /************************************************************************/ /* */ /* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ @@ -16,8 +15,6 @@ static char *id = "@(#) uraid.c 1.52 4/23/92 (Venue & Fuji Xerox)"; #include "version.h" - - /************************************************************************/ /************************************************************************/ /* */ @@ -28,7 +25,6 @@ static char *id = "@(#) uraid.c 1.52 4/23/92 (Venue & Fuji Xerox)"; /************************************************************************/ /************************************************************************/ - #include #include @@ -37,7 +33,6 @@ static char *id = "@(#) uraid.c 1.52 4/23/92 (Venue & Fuji Xerox)"; #define vfork fork #endif /* ISC */ - #ifdef INDIGO #define vfork fork #endif /* INDIGO */ @@ -113,9 +108,6 @@ extern int Dispcolorsize; extern DLword *ColorDisplayRegion68k; #endif /* COLOR */ - - - /***********************************************************************/ /* File name : uraid.c @@ -157,22 +149,21 @@ v filename Save the virtual memory on the filename(Not Bootable) */ /************************************************************************/ #ifndef NOPIXRECT - extern int black, white; - extern struct pixrect *ColorDisplayPixrect, - *DisplayRegionPixrect; +extern int black, white; +extern struct pixrect *ColorDisplayPixrect, *DisplayRegionPixrect; #endif /* NOPIXRECT */ extern int DisplayRasterWidth; -extern unsigned int LispReadFds,LispWindowFd,LispKbdFd; +extern unsigned int LispReadFds, LispWindowFd, LispKbdFd; #ifndef NOPIXRECT -extern struct pixrect *CursorBitMap,*InvisibleCursorBitMap; +extern struct pixrect *CursorBitMap, *InvisibleCursorBitMap; #endif /* NOPIXRECT */ extern struct cursor CurrentCursor, InvisibleCursor; extern struct screen LispScreen; -extern int displaywidth,displayheight; +extern int displaywidth, displayheight; extern DLword *DisplayRegion68k; -extern int FrameBufferFd,ether_fd,RS232C_Fd; -extern u_int EtherReadFds; +extern int FrameBufferFd, ether_fd, RS232C_Fd; +extern u_int EtherReadFds; LispPTR RadiAtomIndex; LispPTR RaidPackageIndex; @@ -183,16 +174,17 @@ char *HideColorDisp68k; extern int Inited_Color; #endif /* COLOR */ - #ifdef DOS -char *URaid_summary1 = "<>\n\ +char *URaid_summary1 = + "<>\n\ c\t\t\tChecks all user stack contents\n\ f number\t\tDisplays stack frame for that frame number (decimal)\n\ k type\t\t\tChanges the type of stack link following. (a|c)\n\ l [type]\t\tBack Trace for specified type stack. (k|m|r|g|p|u|)\n\ \t\t\tDisplay next frame.\n"; -char *URaid_summary2 = "<>\n\ +char *URaid_summary2 = + "<>\n\ a litatom\t\tDisplays the top-level value of the litatom\n\ B Xaddress\t\tPrint the contents of the arrayblock at that address.\n\ d litatom\t\tDisplays the definition cell for the litatom\n\ @@ -206,7 +198,8 @@ x Xaddress [xnum]\tHex-Dump xnum (16-bit) words starting at Xaddress\n\ @ litatom val\t\tSets TOPVAL of litatom to Decimal-val\n\ < Xaddress Xval\t\tSets the (16-bit) word at the address to Xval\n"; -char *URaid_summary3 = "<>\n\ +char *URaid_summary3 = + "<>\n\ e\t\t\tExit to DOS\n\ h\t\t\tDo a HARDRESET\n\ q\t\t\tReturns from URAID with NO change\n\ @@ -216,7 +209,8 @@ v filename\t\tSave the virtual memory on the filename(Not Bootable)\n\ !\t\t\tPrints the error message passed from the emulator\n\ ?\t\t\tDisplay this summary"; #else -char *URaid_summary = "---URAID command summary---\n\ +char *URaid_summary = + "---URAID command summary---\n\ <>\n\ c\t\t\tChecks all user stack contents\n\ f number\t\tDisplays stack frame for that frame number (decimal)\n\ @@ -246,34 +240,32 @@ v filename\t\tSave the virtual memory on the filename(Not Bootable)\n\ ?\t\t\tDisplay this summary"; #endif /* DOS */ -#define ADD_RANGEP(address) if((address < 0) || (POINTERMASK < address)) \ - { \ - printf("Address out of range.\n"); \ - return(T); \ - } +#define ADD_RANGEP(address) \ + if ((address < 0) || (POINTERMASK < address)) { \ + printf("Address out of range.\n"); \ + return (T); \ + } extern int get_package_atom(); -#define URMAXCOMM 512 -#define URMAXFXNUM 2000 -#define URSCAN_ALINK 0 -#define URSCAN_CLINK 1 +#define URMAXCOMM 512 +#define URMAXFXNUM 2000 +#define URSCAN_ALINK 0 +#define URSCAN_CLINK 1 /*** URaid G vals ***/ - int URaid_scanlink= URSCAN_ALINK; - int URaid_currentFX=URMAXFXNUM +1; - FX *URaid_FXarray[URMAXFXNUM]; - int URaid_ArrMAXIndex; - - char URaid_inputstring[URMAXCOMM]; - char URaid_comm; - char URaid_arg1[URMAXCOMM/2]; - char URaid_arg2[URMAXCOMM/2]; - int URaid_argnum; - char *URaid_errmess; - - extern int PrintMaxLevel; /* for print level */ +int URaid_scanlink = URSCAN_ALINK; +int URaid_currentFX = URMAXFXNUM + 1; +FX *URaid_FXarray[URMAXFXNUM]; +int URaid_ArrMAXIndex; +char URaid_inputstring[URMAXCOMM]; +char URaid_comm; +char URaid_arg1[URMAXCOMM / 2]; +char URaid_arg2[URMAXCOMM / 2]; +int URaid_argnum; +char *URaid_errmess; +extern int PrintMaxLevel; /* for print level */ /***********************************************************************/ /* @@ -289,50 +281,43 @@ extern int get_package_atom(); /***********************************************************************/ LispPTR make_atom(); - LispPTR parse_atomstring(string) - char *string; - { - char *start,*packageptr,*nameptr; - int flag=0; - int packagelen=0; - int namelen=0; - int cnt; - LispPTR aindex; +LispPTR parse_atomstring(string) char *string; +{ + char *start, *packageptr, *nameptr; + int flag = 0; + int packagelen = 0; + int namelen = 0; + int cnt; + LispPTR aindex; - for(cnt=0,start=string; *string != '\0' ; string++,cnt++) - { - if(*string ==':') - { - packagelen= cnt; - packageptr=start; - nameptr=string+1; - cnt=0; - *string=0; - } - } - if(packagelen==0) - { /* treat as IL: */ - nameptr=start; - namelen = cnt; - } - else namelen = cnt -1; - - if((packagelen == 0) || (strncmp(packageptr, "IL",packagelen ) == 0)) - {/* default IL: */ - aindex=make_atom(nameptr,0,namelen,T); - if(aindex == 0xffffffff) - { printf("trying IL:\n"); - aindex = get_package_atom(nameptr,namelen,"INTERLISP",9,0); - } - } - else aindex = get_package_atom(nameptr,namelen,packageptr,packagelen,0); - - if(aindex== 0xffffffff) return(0xffffffff); - printf("INDEX : %d\n",aindex& 0xffff); - return(aindex & 0xffff); + for (cnt = 0, start = string; *string != '\0'; string++, cnt++) { + if (*string == ':') { + packagelen = cnt; + packageptr = start; + nameptr = string + 1; + cnt = 0; + *string = 0; + } } + if (packagelen == 0) { /* treat as IL: */ + nameptr = start; + namelen = cnt; + } else + namelen = cnt - 1; + if ((packagelen == 0) || (strncmp(packageptr, "IL", packagelen) == 0)) { /* default IL: */ + aindex = make_atom(nameptr, 0, namelen, T); + if (aindex == 0xffffffff) { + printf("trying IL:\n"); + aindex = get_package_atom(nameptr, namelen, "INTERLISP", 9, 0); + } + } else + aindex = get_package_atom(nameptr, namelen, packageptr, packagelen, 0); + if (aindex == 0xffffffff) return (0xffffffff); + printf("INDEX : %d\n", aindex & 0xffff); + return (aindex & 0xffff); +} /***********************************************************************/ /* @@ -345,33 +330,25 @@ LispPTR make_atom(); */ /***********************************************************************/ -void uraid_commclear() -{ +void uraid_commclear() { memset(URaid_inputstring, 0, URMAXCOMM); - memset(URaid_arg1, 0, URMAXCOMM/2); - memset(URaid_arg2, 0, URMAXCOMM/2); + memset(URaid_arg1, 0, URMAXCOMM / 2); + memset(URaid_arg2, 0, URMAXCOMM / 2); - URaid_comm=0; - URaid_argnum=0; + URaid_comm = 0; + URaid_argnum = 0; } - - - -void copy_region ( src, dst, width, h ) -register short *src, *dst; +void copy_region(src, dst, width, h) register short *src, *dst; int width; register int h; - { - register int w; - - for (; (h--);) { - for ( w = width; (w--);) { - GETWORD(dst++ )= GETWORD(src++); - } - } - } +{ + register int w; + for (; (h--);) { + for (w = width; (w--);) { GETWORD(dst++) = GETWORD(src++); } + } +} /***********************************************************************/ /* @@ -385,507 +362,472 @@ register int h; */ /***********************************************************************/ -LispPTR uraid_commands() -{ - int num,address,val,tmp; - LispPTR index; - DefCell *defcell68k; +LispPTR uraid_commands() { + int num, address, val, tmp; + LispPTR index; + DefCell *defcell68k; #ifndef DOS #if defined(SYSVONLY) || defined(WAITINT) -int status; + int status; #else - union wait status; + union wait status; #endif /* SYSVONLY */ #endif /* DOS */ - if(URaid_argnum == -1){ - /* disp next FX */ - if(URaid_currentFX > URaid_ArrMAXIndex) - { - printf("There is no more stack.\n"); - return(T); - } - else - { - sf(URaid_FXarray[URaid_currentFX++]); - return(T); - } + if (URaid_argnum == -1) { + /* disp next FX */ + if (URaid_currentFX > URaid_ArrMAXIndex) { + printf("There is no more stack.\n"); + return (T); + } else { + sf(URaid_FXarray[URaid_currentFX++]); + return (T); + } } - switch(URaid_comm) - { - - /*** Displaying STACK stuff */ + switch (URaid_comm) { +/*** Displaying STACK stuff */ #ifdef DOS - case '1' : printf("%s\n", URaid_summary1); - break; - case '2' : printf("%s\n", URaid_summary2); - break; - case '3' : printf("%s\n", URaid_summary3); - break; + case '1': printf("%s\n", URaid_summary1); break; + case '2': printf("%s\n", URaid_summary2); break; + case '3': printf("%s\n", URaid_summary3); break; #endif /* DOS */ - case 'c' : stack_check(0); - break; - case 'C' : all_stack_dump(0,0,T); - break; - case 'f' : /**if((URaid_arg1[0] < '0') || (URaid_arg1[0] > '9')){ - printf("Illegal argument, not a number\n"); - return(T); - }**/ - if(URaid_argnum==1) /* f comm only */ - { - printf("DUMP-STACK: f decimal-FXnumber\n"); - return(T); - } - if( sscanf(URaid_arg1,"%d",&num) <= 0) - { /* com read fails */ - printf("Illegal argument, not decimal number\n"); - return(T); - } - if((num > URaid_ArrMAXIndex) || (num < 0)) - { - printf("Frame number doesn't exist.\n"); - return(T); - } - sf(URaid_FXarray[num]); - URaid_currentFX = num+1; - break; - case 'k' : if((URaid_arg1[0] == 'A')||(URaid_arg1[0] == 'a')) - URaid_scanlink =URSCAN_ALINK; - else if((URaid_arg1[0] == 'C')||(URaid_arg1[0] == 'c')) - URaid_scanlink = URSCAN_CLINK; - else - printf("Link type should be A or C\n"); - break; - case 'l' : if(URaid_argnum ==1) - { - bt(); /* default case CURRENTFX */ - return(T); - } - switch(URaid_arg1[0]) - { - case 'k' : printf("IFP->KBDFXP :\n"); - bt1(Addr68k_from_StkOffset(InterfacePage->kbdfxp)); - break; - case 'm' : printf("IFP->MISCFXP :\n"); - bt1(Addr68k_from_StkOffset(InterfacePage->miscfxp)); - break; - case 'r' : printf("IFP->RESETFXP :\n"); - bt1(Addr68k_from_StkOffset(InterfacePage->resetfxp)); - break; - case 'g' : printf("IFP->GCFXP :\n"); - bt1(Addr68k_from_StkOffset(InterfacePage->gcfxp)); + case 'c': stack_check(0); break; + case 'C': all_stack_dump(0, 0, T); break; + case 'f': /**if((URaid_arg1[0] < '0') || (URaid_arg1[0] > '9')){ + printf("Illegal argument, not a number\n"); + return(T); + }**/ + if (URaid_argnum == 1) /* f comm only */ + { + printf("DUMP-STACK: f decimal-FXnumber\n"); + return (T); + } + if (sscanf(URaid_arg1, "%d", &num) <= 0) { /* com read fails */ + printf("Illegal argument, not decimal number\n"); + return (T); + } + if ((num > URaid_ArrMAXIndex) || (num < 0)) { + printf("Frame number doesn't exist.\n"); + return (T); + } + sf(URaid_FXarray[num]); + URaid_currentFX = num + 1; + break; + case 'k': + if ((URaid_arg1[0] == 'A') || (URaid_arg1[0] == 'a')) + URaid_scanlink = URSCAN_ALINK; + else if ((URaid_arg1[0] == 'C') || (URaid_arg1[0] == 'c')) + URaid_scanlink = URSCAN_CLINK; + else + printf("Link type should be A or C\n"); + break; + case 'l': + if (URaid_argnum == 1) { + bt(); /* default case CURRENTFX */ + return (T); + } + switch (URaid_arg1[0]) { + case 'k': + printf("IFP->KBDFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->kbdfxp)); + break; + case 'm': + printf("IFP->MISCFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->miscfxp)); + break; + case 'r': + printf("IFP->RESETFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->resetfxp)); + break; + case 'g': + printf("IFP->GCFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->gcfxp)); - break; - case 'p' : printf("IFP->FAULTFXP :\n"); - bt1(Addr68k_from_StkOffset(InterfacePage->faultfxp)); + break; + case 'p': + printf("IFP->FAULTFXP :\n"); + bt1(Addr68k_from_StkOffset(InterfacePage->faultfxp)); - break; - case 'u' : bt(); - break; - default : printf("2nd argument should be k,m,r,g,p,u or null.\n"); - break; - } /* switch end */ - break; + break; + case 'u': bt(); break; + default: printf("2nd argument should be k,m,r,g,p,u or null.\n"); break; + } /* switch end */ + break; - /* Displaying the memory contents stuff */ - case 'a' : /* GETTOPVAL */ - if(URaid_argnum != 2) - { - printf("GETTOPVAL: a litatom\n"); - return(T); - } - if((index = parse_atomstring(URaid_arg1))== - 0xffffffff ){ - printf("No such atom.\n"); - return(T); - } - print(*((LispPTR*)GetVALCELL68k(index))); - break; - case 'd' : /* DEFCELL */ - if(URaid_argnum != 2){ - printf("GETD: d litatom\n"); - return(T); - } - if((index = parse_atomstring(URaid_arg1))== - 0xffffffff){ - printf("No such atom.\n"); - return(T); - } - defcell68k= (DefCell*)GetDEFCELL68k(index); - if(defcell68k->ccodep) { - printf("{CCODEP}0x%x\n",defcell68k->defpointer); - return(T); - } - else{ - print(defcell68k->defpointer); - return(T); - } - break; + /* Displaying the memory contents stuff */ + case 'a': /* GETTOPVAL */ + if (URaid_argnum != 2) { + printf("GETTOPVAL: a litatom\n"); + return (T); + } + if ((index = parse_atomstring(URaid_arg1)) == 0xffffffff) { + printf("No such atom.\n"); + return (T); + } + print(*((LispPTR *)GetVALCELL68k(index))); + break; + case 'd': /* DEFCELL */ + if (URaid_argnum != 2) { + printf("GETD: d litatom\n"); + return (T); + } + if ((index = parse_atomstring(URaid_arg1)) == 0xffffffff) { + printf("No such atom.\n"); + return (T); + } + defcell68k = (DefCell *)GetDEFCELL68k(index); + if (defcell68k->ccodep) { + printf("{CCODEP}0x%x\n", defcell68k->defpointer); + return (T); + } else { + print(defcell68k->defpointer); + return (T); + } + break; - case 'M' : /* Machine States */ - printf("TOS : 0x%x\n",TopOfStack); - printf("CSTKP : 0x%x\n",LADDR_from_68k(CurrentStackPTR)); - printf("PVAR : 0x%x\n",LADDR_from_68k(PVar)); - printf("IVAR : 0x%x\n",LADDR_from_68k(IVar)); - printPC(); putchar('\n'); - break; - case 'm' : /* MOVD */ - if(URaid_argnum != 3) - { - printf("MOVD: m \n"); - return(T); - } - { DefCell *fromfunc,*tofunc; - LispPTR fromindex,toindex; - if((fromindex = parse_atomstring(URaid_arg1))==0xffffffff){ - printf("No such function (from)\n"); - return(T); - } - if((toindex = parse_atomstring(URaid_arg2))==0xffffffff){ - printf("No such function (to)\n"); - return(T); - } + case 'M': /* Machine States */ + printf("TOS : 0x%x\n", TopOfStack); + printf("CSTKP : 0x%x\n", LADDR_from_68k(CurrentStackPTR)); + printf("PVAR : 0x%x\n", LADDR_from_68k(PVar)); + printf("IVAR : 0x%x\n", LADDR_from_68k(IVar)); + printPC(); + putchar('\n'); + break; + case 'm': /* MOVD */ + if (URaid_argnum != 3) { + printf("MOVD: m \n"); + return (T); + } + { + DefCell *fromfunc, *tofunc; + LispPTR fromindex, toindex; + if ((fromindex = parse_atomstring(URaid_arg1)) == 0xffffffff) { + printf("No such function (from)\n"); + return (T); + } + if ((toindex = parse_atomstring(URaid_arg2)) == 0xffffffff) { + printf("No such function (to)\n"); + return (T); + } - fromfunc= (DefCell*)GetDEFCELL68k(fromindex); - tofunc= (DefCell*)GetDEFCELL68k(toindex); - tofunc->defpointer = fromfunc->defpointer; - print(toindex); - printf(" is smashed with "); - print(fromindex);putchar('\n'); + fromfunc = (DefCell *)GetDEFCELL68k(fromindex); + tofunc = (DefCell *)GetDEFCELL68k(toindex); + tofunc->defpointer = fromfunc->defpointer; + print(toindex); + printf(" is smashed with "); + print(fromindex); + putchar('\n'); + } - } + break; + case 'O': { /* print instance from Laddr. Not documented */ + int objaddr; + if (URaid_argnum == 1) { + printf("PRINT-INSTANCE: O HEX-LispAddress\n"); + return (T); + } + if (sscanf(URaid_arg1, "%x", &objaddr) <= 0) { + printf("Arg not HEX number\n"); + return (T); + } + print(objaddr); + } break; + case 't': /* Object TYPE */ + if (URaid_argnum != 2) { + printf("PRINTTYPENAME: t Xaddress\n"); + return (T); + } - break; - case 'O' : { /* print instance from Laddr. Not documented */ - int objaddr; - if(URaid_argnum ==1) - { - printf("PRINT-INSTANCE: O HEX-LispAddress\n"); - return(T); - } - if(sscanf(URaid_arg1,"%x",&objaddr) - <=0) { - printf("Arg not HEX number\n"); - return(T); - } - print(objaddr); - } - break; - case 't' : /* Object TYPE */ - if(URaid_argnum != 2){ - printf("PRINTTYPENAME: t Xaddress\n"); - return(T); - } + /**HEXNUMP(URaid_arg1,"Not Address");**/ + if (sscanf(URaid_arg1, "%x", &address) <= 0) { + printf("Arg not HEX number\n"); + return (T); + } + ADD_RANGEP(address); - /**HEXNUMP(URaid_arg1,"Not Address");**/ - if(sscanf(URaid_arg1,"%x",&address)<=0) - { - printf("Arg not HEX number\n"); - return(T); - } - ADD_RANGEP(address); + switch (address >> 16) { + case ATOM_HI: + printf("{ATOM}"); + printf("0x%x\n", address); + break; + case STK_HI: + printf("{STK}"); + printf("0x%x\n", address); + break; + case PLIS_HI: + printf("{PLIST}"); + printf("0x%x\n", address); + break; + case FPTOVP_HI: + printf("{FPTOVP}"); + printf("0x%x\n", address); + break; + case PNP_HI: + printf("{PNP}"); + printf("0x%x\n", address); + break; + case DEFS_HI: + printf("{DEF}"); + printf("0x%x\n", address); + break; + case VALS_HI: + printf("{VAL}"); + printf("0x%x\n", address); + break; + case DISPLAY_HI: + case DISPLAY_HI + 1: + printf("{DISPLAY}"); + printf("0x%x\n", address); + break; + default: + num = GetTypeNumber(address); + putchar('{'); + print_atomname((DLword *)GetDTD(num)); + putchar('}'); + break; + } /* switch end */ - switch(address >> 16) { - case ATOM_HI : printf("{ATOM}"); - printf("0x%x\n",address); - break; - case STK_HI : printf("{STK}"); - printf("0x%x\n",address); - break; - case PLIS_HI : printf("{PLIST}"); - printf("0x%x\n",address); - break; - case FPTOVP_HI : printf("{FPTOVP}"); - printf("0x%x\n",address); - break; - case PNP_HI : printf("{PNP}"); - printf("0x%x\n",address); - break; - case DEFS_HI : printf("{DEF}"); - printf("0x%x\n",address); - break; - case VALS_HI : printf("{VAL}"); - printf("0x%x\n",address); - break; - case DISPLAY_HI : - case DISPLAY_HI+1 :printf("{DISPLAY}"); - printf("0x%x\n",address); - break; - default: - num= GetTypeNumber(address); - putchar('{'); - print_atomname((DLword *)GetDTD(num)); - putchar('}'); - break; - } /* switch end */ + break; +#define GetPROPCELL68k(index) ((LispPTR *)Plistspace + (index)) - break; -#define GetPROPCELL68k(index) ((LispPTR *)Plistspace + (index) ) + case 'p': /* property list */ + if (URaid_argnum != 2) { + printf("GETPROPLIST : p litatom\n"); + return (T); + } + if ((index = parse_atomstring(URaid_arg1)) == 0xffffffff) { + printf("No such atom\n"); + return (T); + } + print(*(GetPROPCELL68k(index)) & POINTERMASK); + break; - case 'p' : /* property list */ - if(URaid_argnum != 2){ - printf("GETPROPLIST : p litatom\n"); - return(T); - } - if((index = parse_atomstring(URaid_arg1)) == - 0xffffffff){ - printf("No such atom\n"); - return(T); - } - print(*(GetPROPCELL68k(index)) & POINTERMASK ); - break; - - case 'w' : /* Disp CurrentFunc name & PC */ - doko(); - break; + case 'w': /* Disp CurrentFunc name & PC */ doko(); break; #define XDUMPW 8 - case 'x' : /* HEX dump "x Xaddress Xnum" */ - /* Obsolete - HEXNUMP(URaid_arg1,"Not Address"); - HEXNUMP(URaid_arg2,"Not number"); - ***/ - if(URaid_argnum==1) - { /* for help */ - printf("HEX-DUMP: x Xaddress [Xnum]\n"); - return(T); - } - if(sscanf(URaid_arg1,"%x",&address)<=0) - { /* arg1 not HEX */ - printf("Arg(Xaddress) not Xaddress\n"); - return(T); - } - switch(sscanf(URaid_arg2,"%x",&num)) - { - case -1 : /* Use defaultval for word-num */ - num = XDUMPW; - break; - case 0 : /* Illegal number */ - printf("Arg(Xnum) not Xnum\n"); - return(T); - /* break; */ - default : break; - } - if(num < 0) - { - printf("Dump words num should be positive\n"); - return(T); - } - /* Address range check */ - ADD_RANGEP(address); - ADD_RANGEP(address+num); + case 'x': /* HEX dump "x Xaddress Xnum" */ + /* Obsolete + HEXNUMP(URaid_arg1,"Not Address"); + HEXNUMP(URaid_arg2,"Not number"); + ***/ + if (URaid_argnum == 1) { /* for help */ + printf("HEX-DUMP: x Xaddress [Xnum]\n"); + return (T); + } + if (sscanf(URaid_arg1, "%x", &address) <= 0) { /* arg1 not HEX */ + printf("Arg(Xaddress) not Xaddress\n"); + return (T); + } + switch (sscanf(URaid_arg2, "%x", &num)) { + case -1: /* Use defaultval for word-num */ num = XDUMPW; break; + case 0: /* Illegal number */ + printf("Arg(Xnum) not Xnum\n"); + return (T); + /* break; */ + default: break; + } + if (num < 0) { + printf("Dump words num should be positive\n"); + return (T); + } + /* Address range check */ + ADD_RANGEP(address); + ADD_RANGEP(address + num); - { int i; - DLword *ptr,*endptr; - ptr=(DLword*)Addr68k_from_LADDR(address); - endptr=ptr+num; + { + int i; + DLword *ptr, *endptr; + ptr = (DLword *)Addr68k_from_LADDR(address); + endptr = ptr + num; - while(ptr < endptr) - { - printf("0x%x : ",LADDR_from_68k(ptr)); + while (ptr < endptr) { + printf("0x%x : ", LADDR_from_68k(ptr)); - for(i=0; - ((ptr = 0) + val |= S_POSITIVE; + else { + val = val & 0xffff; + val |= S_NEGATIVE; + } + } + } + printf("Old value is "); + print(*((LispPTR *)GetVALCELL68k(index))); + putchar('\n'); + *((LispPTR *)GetVALCELL68k(index)) = (LispPTR)val; + print(val); + break; - if((val < -65536)||(65535 < val)){ - printf("Bad Val range\n"); - return(T); - } - if(val >=0) - val |= S_POSITIVE; - else { val = val & 0xffff; - val |= S_NEGATIVE; - } - } + case '<': + if (URaid_argnum != 3) { + printf("Mem modify: < Xaddre Xval\n"); + return (T); + } + /* Assignment */ + /* OBSOLETE + HEXNUMP(URaid_arg1,"Not Address"); + HEXNUMP(URaid_arg2,"Not Proper Value"); + ***/ - } - printf("Old value is "); - print(*((LispPTR*)GetVALCELL68k(index))); - putchar('\n'); - *((LispPTR*)GetVALCELL68k(index)) =(LispPTR) val; - print(val); - break; + if (sscanf(URaid_arg1, "%x", &address) <= 0) { + printf("Arg(Xaddress) not Xaddress\n"); + return (T); + } + if (sscanf(URaid_arg2, "%x", &val) <= 0) { + printf("Arg(Xval) not Xaddress\n"); + return (T); + } + ADD_RANGEP(address); + if (val < 0 || val > 0xffff) { + printf("Xval invalid (16 bit range exceeded).\n"); + return (T); + } - case '<' : if(URaid_argnum != 3){ - printf("Mem modify: < Xaddre Xval\n"); - return(T); - } - /* Assignment */ - /* OBSOLETE - HEXNUMP(URaid_arg1,"Not Address"); - HEXNUMP(URaid_arg2,"Not Proper Value"); - ***/ + { + DLword *ptr; + ptr = (DLword *)Addr68k_from_LADDR(address); + *ptr = val; + printf("0x%x : 0x%x\n", address, *ptr); + } + break; - if(sscanf(URaid_arg1,"%x",&address) <=0) - { - printf("Arg(Xaddress) not Xaddress\n"); - return(T); - } - if(sscanf(URaid_arg2,"%x",&val) <=0) - { - printf("Arg(Xval) not Xaddress\n"); - return(T); - } - - ADD_RANGEP(address); - if(val <0 || val > 0xffff){ - printf("Xval invalid (16 bit range exceeded).\n"); - return(T); - } - - { DLword *ptr; - ptr =(DLword*)Addr68k_from_LADDR(address); - *ptr=val; - printf("0x%x : 0x%x\n",address,*ptr); - } - break; - -/****MISC ****/ - case 'q' : /* return with do Nothing */ - printf("Return to Lisp?[confirm](Y or N)<"); - {int c; - c= getchar(); - if((c=='Y')||(c=='y')) { - /*TopOfStack = NIL;*/ - return(NIL); - } - } - fflush(stdin); - URaid_currentFX=URMAXFXNUM +1; - return(T); - /* break; */ - case 'h' : /* HARDRESET */ - printf("HARDRESET?[confirm](Y or N)<"); - { int c; - c= getchar(); - if((c=='Y')||(c=='y')) - { - /*PC+= 3; for currentfx->pc ajust:MOve to subr */ - contextsw(ResetFXP,2,0); - /*PC -= 3; in subr.c it increments by 3 */ - fflush(stdin); - return(NIL); /* return to dispatch */ - } - - } - fflush(stdin); - break; - case 'e' : /* exit to UNIX */ + /****MISC ****/ + case 'q': /* return with do Nothing */ + printf("Return to Lisp?[confirm](Y or N)<"); + { + int c; + c = getchar(); + if ((c == 'Y') || (c == 'y')) { + /*TopOfStack = NIL;*/ + return (NIL); + } + } + fflush(stdin); + URaid_currentFX = URMAXFXNUM + 1; + return (T); + /* break; */ + case 'h': /* HARDRESET */ + printf("HARDRESET?[confirm](Y or N)<"); + { + int c; + c = getchar(); + if ((c == 'Y') || (c == 'y')) { + /*PC+= 3; for currentfx->pc ajust:MOve to subr */ + contextsw(ResetFXP, 2, 0); + /*PC -= 3; in subr.c it increments by 3 */ + fflush(stdin); + return (NIL); /* return to dispatch */ + } + } + fflush(stdin); + break; + case 'e': /* exit to UNIX */ #ifdef DOS - printf("Exit to DOS?[confirm](Y or N)<"); -#else /* DOS */ - printf("Exit to UNIX?[confirm](Y or N)<"); + printf("Exit to DOS?[confirm](Y or N)<"); +#else /* DOS */ + printf("Exit to UNIX?[confirm](Y or N)<"); #endif /* DOS */ - { int c; - c= getchar(); - if((c=='Y')||(c=='y')) - exit(0); - } - fflush(stdin); - URaid_currentFX=URMAXFXNUM +1; - break; - case 's' : /* SHELL */ - switch (vfork()) { - case -1: - (void)fprintf(stderr, "uraid: Fork failed.\n"); - exit(1); + { + int c; + c = getchar(); + if ((c == 'Y') || (c == 'y')) exit(0); + } + fflush(stdin); + URaid_currentFX = URMAXFXNUM + 1; + break; + case 's': /* SHELL */ + switch (vfork()) { + case -1: (void)fprintf(stderr, "uraid: Fork failed.\n"); exit(1); - case 0: - (void)execl("/bin/sh", "sh", "-i", 0); - exit(1); + case 0: (void)execl("/bin/sh", "sh", "-i", 0); exit(1); - default: - break; - } + default: break; + } #ifndef DOS - (void)wait(&status); - /* system("/bin/sh -i"); */ + (void)wait(&status); +/* system("/bin/sh -i"); */ #endif /* DOS */ - return(T); - /* break; */ - case 'v' : if(URaid_argnum != 2){ - printf("VMEMSAVE: v filename (it's NOT bootable)\n"); - return(T); - } + return (T); + /* break; */ + case 'v': + if (URaid_argnum != 2) { + printf("VMEMSAVE: v filename (it's NOT bootable)\n"); + return (T); + } #ifndef DISPLAYBUFFER - copy_region ( HideDisp68k, - DisplayRegion68k, - DisplayRasterWidth, - displayheight ); + copy_region(HideDisp68k, DisplayRegion68k, DisplayRasterWidth, displayheight); #endif /* DISPLAYBUFFER */ - if(vmem_save(URaid_arg1) != NIL){ + if (vmem_save(URaid_arg1) != NIL) { #ifndef DISPLAYBUFFER - clear_display(); + clear_display(); #endif /* DISPLAYBUFFER */ - printf("VMEMSAVE fails\n"); - } - else { - clear_display(); - printf("VMEMSAVE finished, but it's not bootable\n"); - } - break; - case '(' : if(URaid_argnum==1) num = 2; + printf("VMEMSAVE fails\n"); + } else { + clear_display(); + printf("VMEMSAVE finished, but it's not bootable\n"); + } + break; + case '(': + if (URaid_argnum == 1) + num = 2; - else if((URaid_arg1[0] < '0') || (URaid_arg1[0] > '9')){ - printf("Illegal argument, not number\n"); - return(T); - } - else - sscanf(URaid_arg1,"%d",&num); + else if ((URaid_arg1[0] < '0') || (URaid_arg1[0] > '9')) { + printf("Illegal argument, not number\n"); + return (T); + } else + sscanf(URaid_arg1, "%d", &num); - PrintMaxLevel = num; - printf("PrintLevel is set to %d.",num); - break; - case '?' : + PrintMaxLevel = num; + printf("PrintLevel is set to %d.", num); + break; + case '?': #ifdef DOS - printf(" 1: <>\n 2: <>\n 3: <>\n"); + printf( + " 1: <>\n 2: <>\n 3: <>\n"); #else - printf("%s\n",URaid_summary); + printf("%s\n", URaid_summary); #endif /* DOS */ - break; - case '!' : printf("Error message is: %s\n",URaid_errmess); - break; + break; + case '!': printf("Error message is: %s\n", URaid_errmess); break; - default : printf("Unsupported command.\n"); - break; + default: printf("Unsupported command.\n"); break; } /* switch end */ -return(T); + return (T); } - - - /************************************************************************/ /* */ /* device_before_raid() */ @@ -901,169 +843,151 @@ return(T); /************************************************************************/ #ifdef DISPLAYBUFFER -extern struct pixrect *ColorDisplayPixrect,*DisplayRegionPixrect; +extern struct pixrect *ColorDisplayPixrect, *DisplayRegionPixrect; #endif #ifdef SUNDISPLAY -#define SV_ACQUIRE "/bin/sunview1/sv_acquire" -#define SV_RELEASE "/bin/sunview1/sv_release" +#define SV_ACQUIRE "/bin/sunview1/sv_acquire" +#define SV_RELEASE "/bin/sunview1/sv_release" #endif /* SUNDISPLAY */ - -int device_before_raid() - { - int keytrans; - int size; - int munmapstat; - struct pixrect *fb; - extern char *alloc_hideDISP(); +int device_before_raid() { + int keytrans; + int size; + int munmapstat; + struct pixrect *fb; + extern char *alloc_hideDISP(); #ifdef SUNDISPLAY - union wait status; + union wait status; #endif /* SUNDISPLAY */ - int_timer_off(); + int_timer_off(); #if (defined(XWINDOW) && defined(SYSVSIGNALS) && defined(SIGIO)) - sigrelse(SIGIO); /* So X events still get recognized. */ -#endif /* XWINDOW + SYSVSIGNALS + SIGIO */ + sigrelse(SIGIO); /* So X events still get recognized. */ +#endif /* XWINDOW + SYSVSIGNALS + SIGIO */ #ifdef SUNDISPLAY - win_setcursor(LispWindowFd, &InvisibleCursor); + win_setcursor(LispWindowFd, &InvisibleCursor); #ifdef KBINT - int_io_close(LispWindowFd); + int_io_close(LispWindowFd); #endif #endif /* SUNDISPLAY */ #ifdef NOETHER #else #ifdef ETHERINT - if(ether_fd > 0) /* check ether is used or not */ - int_io_close(ether_fd); + if (ether_fd > 0) /* check ether is used or not */ + int_io_close(ether_fd); #endif #endif /* NOETHER */ #ifdef RS232INT - int_io_close(RS232C_Fd); + int_io_close(RS232C_Fd); #endif #ifdef SUNDISPLAY - mess_reset(); /* turn off console-msg handling */ + mess_reset(); /* turn off console-msg handling */ #ifdef FX_AR_124 - /* For AR 124. Type4 driver bug?? by m.matsuda */ - { long i; for( i=0; i<900000; i++ ); } + /* For AR 124. Type4 driver bug?? by m.matsuda */ + { + long i; + for (i = 0; i < 900000; i++) + ; + } #endif /* FX_AR_124 */ + if ((LispKbdFd = open(LispScreen.scr_kbdname, O_RDWR)) == -1) { + fprintf(stderr, "can't open %s\n", LispScreen.scr_kbdname); + return (-1); + } - if( (LispKbdFd = open( LispScreen.scr_kbdname , O_RDWR)) == -1) - { - fprintf( stderr, "can't open %s\n", LispScreen.scr_kbdname); - return( -1 ); - } - - keytrans = TR_EVENT; /* keyboard encodes key */ - if(ioctl( LispKbdFd, KIOCTRANS, &keytrans)== -1) - { - fprintf( stderr, "Error at ioctl errno =%d\n", errno); - return( -1 ); - } - close( LispKbdFd ); - close( LispWindowFd ); + keytrans = TR_EVENT; /* keyboard encodes key */ + if (ioctl(LispKbdFd, KIOCTRANS, &keytrans) == -1) { + fprintf(stderr, "Error at ioctl errno =%d\n", errno); + return (-1); + } + close(LispKbdFd); + close(LispWindowFd); #ifdef TRUECOLOR - truecolor_before_raid(); + truecolor_before_raid(); #endif /* TRUECOLOR */ - #ifndef DISPLAYBUFFER - size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) - & -getpagesize()); + size = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); - if((HideDisp68k= malloc(size)) == 0) - { - printf("can't malloc hide space\n"); - return(-1); - } + if ((HideDisp68k = malloc(size)) == 0) { + printf("can't malloc hide space\n"); + return (-1); + } - copy_region ( DisplayRegion68k, - HideDisp68k, - DisplayRasterWidth, - displayheight ); + copy_region(DisplayRegion68k, HideDisp68k, DisplayRasterWidth, displayheight); #endif /* DISPLAYBUFFER */ - #ifdef COLOR - save_colormap(); + save_colormap(); #ifndef DISPLAYBUFFER - if( Inited_Color ) { -#else - if( MonoOrColor == COLOR_SCREEN ) { + if (Inited_Color) { +#else + if (MonoOrColor == COLOR_SCREEN) { #endif /* DISPLAYBUFFER */ - /* save color image */ - size = ((displaywidth * displayheight + (getpagesize()-1) ) - & -getpagesize()); /* 8 bit depth */ - if((HideColorDisp68k= malloc(size)) == 0){ - printf("can't malloc hide space\n"); - return(-1); - } - copy_region( ColorDisplayRegion68k, - HideColorDisp68k, - DisplayRasterWidth * 8, - displayheight ); - } /* end if(MonoOrColor) */ + /* save color image */ + size = + ((displaywidth * displayheight + (getpagesize() - 1)) & -getpagesize()); /* 8 bit depth */ + if ((HideColorDisp68k = malloc(size)) == 0) { + printf("can't malloc hide space\n"); + return (-1); + } + copy_region(ColorDisplayRegion68k, HideColorDisp68k, DisplayRasterWidth * 8, displayheight); + } /* end if(MonoOrColor) */ #endif /* COLOR */ - - - clear_display(); + clear_display(); #ifdef DISPLAYBUFFER - pr_close(ColorDisplayPixrect); - close(FrameBufferFd); + pr_close(ColorDisplayPixrect); + close(FrameBufferFd); #endif - if (Win_security_p) { - switch (vfork()) { - case -1: /* Error */ - (void)fprintf(stderr, "display_before_exit: Fork failed.\n"); - exit(1); + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ (void)fprintf(stderr, "display_before_exit: Fork failed.\n"); exit(1); - case 0: /* Child */ - (void)execl(SV_RELEASE, "sv_release", 0); - /* should not return */ - (void)fprintf(stderr, - "display_before_exit: exec for sv_release failed\n"); - exit(1); + case 0: /* Child */ + (void)execl(SV_RELEASE, "sv_release", 0); + /* should not return */ + (void)fprintf(stderr, "display_before_exit: exec for sv_release failed\n"); + exit(1); - default: /* Parent */ - /* do nothing */ - break; - } - (void)wait(&status); /* child dies after changing 16 */ - - if (status.w_retcode != 0) { - (void)fprintf(stderr, - "device_before_raid: failed to set ownership of win devices\n"); - exit(1); - } + default: /* Parent */ + /* do nothing */ + break; } + (void)wait(&status); /* child dies after changing 16 */ + + if (status.w_retcode != 0) { + (void)fprintf(stderr, "device_before_raid: failed to set ownership of win devices\n"); + exit(1); + } + } #endif /* SUNDISPLAY */ #if defined(XWINDOW) || defined(DOS) - (currentdsp->cleardisplay)(currentdsp); - (currentdsp->device.before_raid)(currentdsp); + (currentdsp->cleardisplay)(currentdsp); + (currentdsp->device.before_raid)(currentdsp); #ifdef DOS - (currentmouse->device.before_raid)(currentmouse); - (currentkbd->device.before_raid)(currentkbd); + (currentmouse->device.before_raid)(currentmouse); + (currentkbd->device.before_raid)(currentkbd); #endif /* DOS */ #endif /* XWINDOW || DOS */ - return(0); - } - + return (0); +} /** char *alloc_hideDISP(size) @@ -1111,7 +1035,6 @@ int size; } ****/ - /***********************************************************************/ /* func name : device_after_raid() @@ -1126,75 +1049,68 @@ int size; * Seems like a bad return type or bad code, returning 0, -1, or NIL * NBriggs May 2017 */ -#define KB_ALLUP 0xffff +#define KB_ALLUP 0xffff -int device_after_raid() - { - extern DLword *EmMouseX68K, *EmMouseY68K, - *EmKbdAd068K, *EmRealUtilin68K; - extern DLword *EmKbdAd168K,*EmKbdAd268K,*EmKbdAd368K, - *EmKbdAd468K,*EmKbdAd568K; - LispReadFds = 0; - if(re_init_display(DISPLAY_OFFSET,65536 * 16 *2)== -1) - return(-1); - set_cursor(); - init_keyboard(1); +int device_after_raid() { + extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K; + extern DLword *EmKbdAd168K, *EmKbdAd268K, *EmKbdAd368K, *EmKbdAd468K, *EmKbdAd568K; + LispReadFds = 0; + if (re_init_display(DISPLAY_OFFSET, 65536 * 16 * 2) == -1) return (-1); + set_cursor(); + init_keyboard(1); #ifdef TRUECOLOR - truecolor_after_raid(); + truecolor_after_raid(); #endif /* TRUECOLOR */ - #ifdef NOETHER #else - init_ether(); + init_ether(); #ifdef USE_DLPI - if (ether_fd > 0) if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) - { - perror("after-uraid: I_SETSIG for ether failed:\n"); - close(ether_fd); - ether_fd = -1; - return(-1); - } + if (ether_fd > 0) + if (ioctl(ether_fd, I_SETSIG, S_INPUT) != 0) { + perror("after-uraid: I_SETSIG for ether failed:\n"); + close(ether_fd); + ether_fd = -1; + return (-1); + } #endif /* USE_DLPI */ #endif /* NOETHER */ #ifdef XWINDOW #ifdef I_SETSIG - if (ioctl(ConnectionNumber(currentdsp->display_id), I_SETSIG, S_INPUT) < 0) perror("SETSIG on X fd failed"); + if (ioctl(ConnectionNumber(currentdsp->display_id), I_SETSIG, S_INPUT) < 0) + perror("SETSIG on X fd failed"); #endif /* I_SETSIG */ #endif /* XWINDOW */ - int_init(); + int_init(); #ifdef SUNDISPLAY - LispReadFds |= (1 << LispWindowFd) ; + LispReadFds |= (1 << LispWindowFd); #endif /* SUNDISPLAY */ #ifdef NOETHER #else - LispReadFds |= EtherReadFds; + LispReadFds |= EtherReadFds; #endif /* NOETHER */ #ifdef XWINDOW - (currentdsp->device.after_raid)(currentdsp); - LispReadFds |= (1 << ConnectionNumber(currentdsp->display_id)); - flush_display_buffer(); + (currentdsp->device.after_raid)(currentdsp); + LispReadFds |= (1 << ConnectionNumber(currentdsp->display_id)); + flush_display_buffer(); #elif DOS - (currentdsp->device.after_raid)(currentdsp); - (currentmouse->device.after_raid)(currentmouse, currentdsp); - (currentkbd->device.after_raid)(currentkbd); - flush_display_buffer(); + (currentdsp->device.after_raid)(currentdsp); + (currentmouse->device.after_raid)(currentmouse, currentdsp); + (currentkbd->device.after_raid)(currentkbd); + flush_display_buffer(); #endif /* XWINDOW | DOS */ - int_timer_on(); - *EmKbdAd068K= *EmRealUtilin68K= *EmKbdAd168K= - *EmKbdAd268K= *EmKbdAd368K= - *EmKbdAd468K= *EmKbdAd568K=KB_ALLUP ; - return(0); - } /* device_after_raid */ - - + int_timer_on(); + *EmKbdAd068K = *EmRealUtilin68K = *EmKbdAd168K = *EmKbdAd268K = *EmKbdAd368K = *EmKbdAd468K = + *EmKbdAd568K = KB_ALLUP; + return (0); +} /* device_after_raid */ /***********************************************************************/ /* @@ -1211,333 +1127,281 @@ int device_after_raid() /***********************************************************************/ #ifndef COLOR -int re_init_display(lisp_display_addr, display_max) - int lisp_display_addr, display_max; - { - int mmapstat, size; - struct pixrect *ColorFb; - extern struct pixrect *ColorDisplayPixrect,*DisplayRegionPixrect; - extern int DisplayType; +int re_init_display(lisp_display_addr, display_max) int lisp_display_addr, display_max; +{ + int mmapstat, size; + struct pixrect *ColorFb; + extern struct pixrect *ColorDisplayPixrect, *DisplayRegionPixrect; + extern int DisplayType; #ifdef SUNDISPLAY - union wait status; + union wait status; - if (Win_security_p) { - switch (vfork()) { - case -1: /* Error */ - (void)fprintf(stderr, "re_init_display: Fork failed.\n"); - exit(1); + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ (void)fprintf(stderr, "re_init_display: Fork failed.\n"); exit(1); - case 0: /* Child */ - (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); - /* should not return */ - (void)fprintf(stderr, "re_init_display: exec for sv_acquire failed\n"); - exit(1); + case 0: /* Child */ + (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); + /* should not return */ + (void)fprintf(stderr, "re_init_display: exec for sv_acquire failed\n"); + exit(1); - default: /* Parent */ - /* do nothing */ - break; - } - (void)wait(&status); /* child dies after changing 6 */ - - if (status.w_retcode != 0) { - (void)fprintf(stderr, - "re_init_display: failed to set ownership of win devices\n"); - exit(1); - } + default: /* Parent */ + /* do nothing */ + break; } + (void)wait(&status); /* child dies after changing 6 */ - mess_init(); - if( (LispWindowFd = win_screennew( &LispScreen )) == -1) - { - fprintf( stderr, "init_display: can't create LispWindow\n"); - return( -1 ); - } - else - { + if (status.w_retcode != 0) { + (void)fprintf(stderr, "re_init_display: failed to set ownership of win devices\n"); + exit(1); + } + } + + mess_init(); + if ((LispWindowFd = win_screennew(&LispScreen)) == -1) { + fprintf(stderr, "init_display: can't create LispWindow\n"); + return (-1); + } else { #ifdef KBINT - int_io_open(LispWindowFd); - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); + int_io_open(LispWindowFd); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); #ifdef FX_AR_124 - /* For AR 124. Type4 driver bug?? by m.matsuda */ - { long i; for( i=0 ; i<900000 ; i++ ) ; } + /* For AR 124. Type4 driver bug?? by m.matsuda */ + { + long i; + for (i = 0; i < 900000; i++) + ; + } #endif /* FX_AR_124 */ #endif - } + } #ifndef DISPLAYBUFFER -/* for CGFOUR dev */ - if(DisplayType == SUN4COLOR) - { - ColorFb = pr_open("/dev/fb"); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, - PIX_SET, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY); - } -#else /* DISPLAYBUFFER is T */ + /* for CGFOUR dev */ + if (DisplayType == SUN4COLOR) { + ColorFb = pr_open("/dev/fb"); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } +#else /* DISPLAYBUFFER is T */ /* ColorDisplayPixrect = pr_open("/dev/fb"); pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); - pr_putcolormap(ColorDisplayPixrect, + pr_putcolormap(ColorDisplayPixrect, (1<pr_depth)-1, 1, &black, &black, &black); ***/ #endif /* DISPLAYBUFFER */ - - init_cursor(); + init_cursor(); #ifndef DISPLAYBUFFER - size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) - & -getpagesize()); - mmapstat = (int) - mmap( DisplayRegion68k, - size, - PROT_READ | PROT_WRITE, + size = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); + mmapstat = (int)mmap(DisplayRegion68k, size, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif /* OS4 */ - MAP_SHARED, - FrameBufferFd, 0 ); + MAP_SHARED, + FrameBufferFd, 0); - if(mmapstat == -1) - { - fprintf( stderr, "re_init_display: ERROR at mmap system call\n"); - fprintf( stderr, "errno = %d\n\n", errno ); - return( 0 ); - } + if (mmapstat == -1) { + fprintf(stderr, "re_init_display: ERROR at mmap system call\n"); + fprintf(stderr, "errno = %d\n\n", errno); + return (0); + } - copy_region ( HideDisp68k, - DisplayRegion68k, - DisplayRasterWidth, - displayheight ); + copy_region(HideDisp68k, DisplayRegion68k, DisplayRasterWidth, displayheight); - free(HideDisp68k); + free(HideDisp68k); #endif /* DISPLAYBUFFER */ - #ifdef DISPLAYBUFFER - ColorDisplayPixrect = pr_open("/dev/fb"); - flush_display_buffer(); + ColorDisplayPixrect = pr_open("/dev/fb"); + flush_display_buffer(); /* refresh_CG6; */ #endif /* DISPLAYBUFFER */ #endif /* SUNDISPLAY */ - - return(0); - } + return (0); +} #else /* COLOR */ -re_init_display(lisp_display_addr, display_max) - int lisp_display_addr, display_max; - { - int mmapstat, size; - struct pixrect *ColorFb; -/* - extern struct pixrect *color_source; -*/ - struct pixrect *color_source; - extern int DisplayType; +re_init_display(lisp_display_addr, display_max) int lisp_display_addr, display_max; +{ + int mmapstat, size; + struct pixrect *ColorFb; + /* + extern struct pixrect *color_source; + */ + struct pixrect *color_source; + extern int DisplayType; #ifdef SUNDISPLAY - union wait status; + union wait status; - if (Win_security_p) { - switch (vfork()) { - case -1: /* Error */ - (void)fprintf(stderr, "re_init_display: Fork failed.\n"); - exit(1); + if (Win_security_p) { + switch (vfork()) { + case -1: /* Error */ (void)fprintf(stderr, "re_init_display: Fork failed.\n"); exit(1); - case 0: /* Child */ - (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); - /* should not return */ - (void)fprintf(stderr, "re_init_display: exec for sv_acquire failed\n"); - exit(1); + case 0: /* Child */ + (void)execl(SV_ACQUIRE, "sv_acquire", "0", "256", "250", 0); + /* should not return */ + (void)fprintf(stderr, "re_init_display: exec for sv_acquire failed\n"); + exit(1); - default: /* Parent */ - /* do nothing */ - break; - } - (void)wait(&status); /* child dies after changing 6 */ - - if (status.w_retcode != 0) { - (void)fprintf(stderr, - "re_init_display: failed to set ownership of win devices\n"); - exit(1); - } + default: /* Parent */ + /* do nothing */ + break; } + (void)wait(&status); /* child dies after changing 6 */ - mess_init(); - if( (LispWindowFd = win_screennew( &LispScreen )) == -1) - { - fprintf( stderr, "init_display: can't create LispWindow\n"); - return( -1 ); - } - else - { + if (status.w_retcode != 0) { + (void)fprintf(stderr, "re_init_display: failed to set ownership of win devices\n"); + exit(1); + } + } + + mess_init(); + if ((LispWindowFd = win_screennew(&LispScreen)) == -1) { + fprintf(stderr, "init_display: can't create LispWindow\n"); + return (-1); + } else { #ifdef KBINT - int_io_open(LispWindowFd); - fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0)| FNDELAY); + int_io_open(LispWindowFd); + fcntl(LispWindowFd, F_SETFL, fcntl(LispWindowFd, F_GETFL, 0) | FNDELAY); #endif - } + } #ifdef DISPLAYBUFFER - if( (FrameBufferFd = open( LispScreen.scr_fbname, 2 )) == -1){ - perror("init_display: can't open FrameBuffer\n"); - exit( -1 ); - } + if ((FrameBufferFd = open(LispScreen.scr_fbname, 2)) == -1) { + perror("init_display: can't open FrameBuffer\n"); + exit(-1); + } #endif /* DISPLAYBUFFER */ + restore_colormap(); - restore_colormap(); - - if( MonoOrColor == MONO_SCREEN ) { + if (MonoOrColor == MONO_SCREEN) { #ifndef DISPLAYBUFFER - /* for CGFOUR dev */ - if(DisplayType == SUN4COLOR) { - ColorFb = pr_open("/dev/fb"); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, - PIX_SET, 0, 0, 0); - pr_set_plane_group(ColorFb, PIXPG_OVERLAY); - } -#else /* DISPLAYBUFFER is T */ - /* ColorDisplayPixrect = pr_open("/dev/fb"); - pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); - pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); - pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); - pr_putcolormap(ColorDisplayPixrect, - (1<pr_depth)-1, 1, - &black, &black, &black); + /* for CGFOUR dev */ + if (DisplayType == SUN4COLOR) { + ColorFb = pr_open("/dev/fb"); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_SET, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY); + } +#else /* DISPLAYBUFFER is T */ +/* ColorDisplayPixrect = pr_open("/dev/fb"); + pr_putcolormap(ColorDisplayPixrect, 1, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, 0, 1, &white, &white, &white); + pr_putcolormap(ColorDisplayPixrect, 255, 1, &black, &black, &black); + pr_putcolormap(ColorDisplayPixrect, + (1<pr_depth)-1, 1, + &black, &black, &black); ***/ #endif /* DISPLAYBUFFER */ - - init_cursor(); + init_cursor(); #ifndef DISPLAYBUFFER - size = ((displaywidth * displayheight / 8 + (getpagesize()-1) ) - & -getpagesize()); + size = ((displaywidth * displayheight / 8 + (getpagesize() - 1)) & -getpagesize()); - mmapstat = (int) - mmap( DisplayRegion68k, - size, - PROT_READ | PROT_WRITE, + mmapstat = (int)mmap(DisplayRegion68k, size, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif /* OS4 */ - MAP_SHARED, - FrameBufferFd, 0 ); - if( Inited_Color ) - mmapstat = (int) - mmap( ColorDisplayRegion68k, - Dispcolorsize, - PROT_READ | PROT_WRITE, + MAP_SHARED, + FrameBufferFd, 0); + if (Inited_Color) + mmapstat = (int)mmap(ColorDisplayRegion68k, Dispcolorsize, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif /* OS4 */ - MAP_SHARED, - FrameBufferFd, 0x40000 ); + MAP_SHARED, + FrameBufferFd, 0x40000); - if(mmapstat == -1) - { - fprintf( stderr, "re_init_display: ERROR at mmap system call\n"); - fprintf( stderr, "errno = %d\n\n", errno ); - return( 0 ); - } - /* restore mono image */ - copy_region ( HideDisp68k, - DisplayRegion68k, - DisplayRasterWidth, - displayheight ); + if (mmapstat == -1) { + fprintf(stderr, "re_init_display: ERROR at mmap system call\n"); + fprintf(stderr, "errno = %d\n\n", errno); + return (0); + } + /* restore mono image */ + copy_region(HideDisp68k, DisplayRegion68k, DisplayRasterWidth, displayheight); - free(HideDisp68k); + free(HideDisp68k); - if( Inited_Color ) { /* restore color image */ - copy_region( HideColorDisp68k - , ColorDisplayRegion68k - , DisplayRasterWidth * 8 - , displayheight ); - free(HideColorDisp68k); - } /* end if( Inited_Color ) */ + if (Inited_Color) { /* restore color image */ + copy_region(HideColorDisp68k, ColorDisplayRegion68k, DisplayRasterWidth * 8, displayheight); + free(HideColorDisp68k); + } /* end if( Inited_Color ) */ #endif /* DISPLAYBUFFER */ - #ifdef DISPLAYBUFFER - ColorDisplayPixrect = pr_open("/dev/fb"); - flush_display_buffer(); - /* refresh_CG6; */ + ColorDisplayPixrect = pr_open("/dev/fb"); + flush_display_buffer(); +/* refresh_CG6; */ #endif /* DISPLAYBUFFER */ - - } else { /* MonoOrColor is COLOR_SCREEN */ - ColorFb = pr_open("/dev/fb"); + } else { /* MonoOrColor is COLOR_SCREEN */ + ColorFb = pr_open("/dev/fb"); #ifdef DISPLAYBUFFER - ColorDisplayPixrect = ColorFb; + ColorDisplayPixrect = ColorFb; #endif /* DISPLAYBUFFER */ - color_source = mem_point(displaywidth,displayheight,8,ColorDisplayRegion68k); - pr_rop(ColorFb,0,0,displaywidth,displayheight,PIX_SRC,color_source,0,0); + color_source = mem_point(displaywidth, displayheight, 8, ColorDisplayRegion68k); + pr_rop(ColorFb, 0, 0, displaywidth, displayheight, PIX_SRC, color_source, 0, 0); #ifndef DISPLAYBUFFER - pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); - pr_rop(ColorFb,0,0,ColorFb->pr_width, ColorFb->pr_height, - PIX_CLR, 0, 0, 0); + pr_set_plane_group(ColorFb, PIXPG_OVERLAY_ENABLE); + pr_rop(ColorFb, 0, 0, ColorFb->pr_width, ColorFb->pr_height, PIX_CLR, 0, 0, 0); #endif /* DISPLAYBUFFER */ - pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); - init_cursor(); - mmapstat = (int)mmap(ColorDisplayRegion68k , - Dispcolorsize, - PROT_READ | PROT_WRITE, + pr_set_plane_group(ColorFb, PIXPG_8BIT_COLOR); + init_cursor(); + mmapstat = (int)mmap(ColorDisplayRegion68k, Dispcolorsize, PROT_READ | PROT_WRITE, #ifdef OS4 - MAP_FIXED | + MAP_FIXED | #endif - MAP_SHARED, - FrameBufferFd, 0x40000 ); - if(mmapstat == -1){ - perror("cgfour_init_color_display: ERROR at mmap system call\n"); - error("cgfour_init_color_display: ERROR at mmap system call\n You may be able to continue by typing 'q'"); -/* printf("MMAP FAIL:BMBASE=0x%x\nNATIVE:= 0x%x\nLISPBASEN:= 0x%x\n", - color_bitmapbase,ColorDisplayRegion68k,Lisp_world); -*/ - return(NIL); - } /* end if(mmapstat) */ + MAP_SHARED, + FrameBufferFd, 0x40000); + if (mmapstat == -1) { + perror("cgfour_init_color_display: ERROR at mmap system call\n"); + error( + "cgfour_init_color_display: ERROR at mmap system call\n You may be able to continue by " + "typing 'q'"); + /* printf("MMAP FAIL:BMBASE=0x%x\nNATIVE:= 0x%x\nLISPBASEN:= 0x%x\n", + color_bitmapbase,ColorDisplayRegion68k,Lisp_world); + */ + return (NIL); + } /* end if(mmapstat) */ #ifndef DISPLAYBUFFER - /* restore mono image */ - copy_region ( HideDisp68k, - DisplayRegion68k, - DisplayRasterWidth, - displayheight ); + /* restore mono image */ + copy_region(HideDisp68k, DisplayRegion68k, DisplayRasterWidth, displayheight); - free(HideDisp68k); + free(HideDisp68k); #endif /* DISPLAYBUFFER */ + /* restore coloe image */ + copy_region(HideColorDisp68k, ColorDisplayRegion68k, DisplayRasterWidth * 8, displayheight); - /* restore coloe image */ - copy_region ( HideColorDisp68k, - ColorDisplayRegion68k, - DisplayRasterWidth * 8, - displayheight ); - - free(HideColorDisp68k); - } /* end if(MonoOrColor) */ + free(HideColorDisp68k); + } /* end if(MonoOrColor) */ #endif /* SUNDISPLAY */ - - return(0); - } + return (0); +} #endif /* COLOR */ - diff --git a/src/usrsubr.c b/src/usrsubr.c old mode 100755 new mode 100644 index 2644e93..71024ad --- a/src/usrsubr.c +++ b/src/usrsubr.c @@ -1,10 +1,7 @@ -/* $Id: usrsubr.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: usrsubr.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: usrsubr.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ Copyright (C) Venue"; - - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -24,26 +21,27 @@ static char *id = "$Id: usrsubr.c,v 1.3 1999/05/31 23:35:46 sybalsky Exp $ Copyr /** User defined subrs here. Do NOT attempt to use this unless you FULLY understand the dependencies of the LDE architecture. **/ -#define DO_UFN {return(-1);} +#define DO_UFN \ + { return (-1); } -int UserSubr(int user_subr_index, int num_args, int *args) -{ -int result = 0; +int UserSubr(int user_subr_index, int num_args, int *args) { + int result = 0; -/* *** remove the printf when finished debugging your user subr *** */ + /* *** remove the printf when finished debugging your user subr *** */ - printf("debug: case: 0x%x, args: 0x%x\n",user_subr_index, num_args); - {int i; - for (i = 0; i < num_args; i++) printf("debug: arg[%d]: 0x%x\n",i,args[i]); - }; + printf("debug: case: 0x%x, args: 0x%x\n", user_subr_index, num_args); + { + int i; + for (i = 0; i < num_args; i++) printf("debug: arg[%d]: 0x%x\n", i, args[i]); + }; + switch (user_subr_index) { + case 0: + printf("sample UFN\n"); + result = args[0]; + break; + default: DO_UFN; + } - switch (user_subr_index) { - - case 0: printf("sample UFN\n"); result = args[0]; break; - default: DO_UFN; - } - - return(result); + return (result); } - diff --git a/src/uutils.c b/src/uutils.c old mode 100755 new mode 100644 index adb1c00..3e450c7 --- a/src/uutils.c +++ b/src/uutils.c @@ -1,7 +1,7 @@ -/* $Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -16,8 +16,6 @@ static char *id = "$Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyri #include "version.h" - - /************************************************************************/ /* */ /* U U T I L S . C */ @@ -26,7 +24,6 @@ static char *id = "$Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyri /* */ /************************************************************************/ - #ifndef DOS #include #endif @@ -56,8 +53,6 @@ static char *id = "$Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyri #define gethostid() 0 #endif /* OS5 */ - - /************************************************************************/ /* */ /* l i s p _ s t r i n g _ t o _ c _ s t r i n g */ @@ -68,40 +63,36 @@ static char *id = "$Id: uutils.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyri /* */ /************************************************************************/ -int lisp_string_to_c_string(LispPTR Lisp, char *C, int length) -{ - register OneDArray *arrayp; - register char *base; +int lisp_string_to_c_string(LispPTR Lisp, char *C, int length) { + register OneDArray *arrayp; + register char *base; - if (GetTypeNumber(Lisp) != TYPE_ONED_ARRAY) {return (-1);} + if (GetTypeNumber(Lisp) != TYPE_ONED_ARRAY) { return (-1); } - arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); - if (arrayp->fillpointer >= length) {return(-1);} /* too long */ + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); + if (arrayp->fillpointer >= length) { return (-1); } /* too long */ - switch(arrayp->typenumber){ - case THIN_CHAR_TYPENUMBER: - base = ((char *)(Addr68k_from_LADDR(arrayp->base))) + - ((int)(arrayp->offset)); + switch (arrayp->typenumber) { + case THIN_CHAR_TYPENUMBER: + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) + ((int)(arrayp->offset)); #ifndef BYTESWAP - strncpy(C, base, arrayp->fillpointer); + strncpy(C, base, arrayp->fillpointer); #else - { register int i,length ; - register char *dp; - for(i=0,dp=C, length = arrayp->fillpointer; - ifillpointer; i < length; i++) { + *dp++ = (char)(GETBYTE(base++)); + } + } #endif /* BYTESWAP */ - C[arrayp->fillpointer] = '\0'; - return 0; - default: - return -1; - } + C[arrayp->fillpointer] = '\0'; + return 0; + default: return -1; + } } - - /************************************************************************/ /* */ /* c _ s t r i n g _ t o _ l i s p _ s t r i n g */ @@ -114,47 +105,42 @@ int lisp_string_to_c_string(LispPTR Lisp, char *C, int length) /* */ /************************************************************************/ -int c_string_to_lisp_string(char *C, LispPTR Lisp) -{ - register OneDArray *arrayp; - char *base; - register int length; +int c_string_to_lisp_string(char *C, LispPTR Lisp) { + register OneDArray *arrayp; + char *base; + register int length; - length = strlen(C); - if (GetTypeNumber(Lisp) != TYPE_ONED_ARRAY) {return (-1);} + length = strlen(C); + if (GetTypeNumber(Lisp) != TYPE_ONED_ARRAY) { return (-1); } - arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); - if (arrayp->totalsize < length+1) {return(-1);} - /* too short for C string */ + arrayp = (OneDArray *)(Addr68k_from_LADDR(Lisp)); + if (arrayp->totalsize < length + 1) { return (-1); } + /* too short for C string */ - switch(arrayp->typenumber){ - case THIN_CHAR_TYPENUMBER: - base = ((char *)(Addr68k_from_LADDR(arrayp->base))) + - ((int)(arrayp->offset)); + switch (arrayp->typenumber) { + case THIN_CHAR_TYPENUMBER: + base = ((char *)(Addr68k_from_LADDR(arrayp->base))) + ((int)(arrayp->offset)); #ifndef BYTESWAP - strcpy(base, C); + strcpy(base, C); #else - { register int i; - register char *dp; - for(i=0,dp = C;i <= length + 1;i++) - { - int ch = *dp++; + { + register int i; + register char *dp; + for (i = 0, dp = C; i <= length + 1; i++) { + int ch = *dp++; #ifdef DOS - if (ch == '\\') dp++; /* skip 2nd \ in \\ in C strings */ + if (ch == '\\') dp++; /* skip 2nd \ in \\ in C strings */ #endif /* DOS */ - GETBYTE(base++) = ch; - } - } + GETBYTE(base++) = ch; + } + } #endif /* BYTESWAP */ - return 0; - default: - return -1; - } + return 0; + default: return -1; + } } - - /************************************************************************/ /* */ /* c h e c k _ u n i x _ p a s s w o r d */ @@ -163,8 +149,7 @@ int c_string_to_lisp_string(char *C, LispPTR Lisp) /* */ /************************************************************************/ -LispPTR check_unix_password(LispPTR *args) -{ +LispPTR check_unix_password(LispPTR *args) { #ifndef DOS struct passwd *pwd; char *password, *getpass(const char *); @@ -174,26 +159,22 @@ LispPTR check_unix_password(LispPTR *args) char salt[3]; char name[100], pass[100]; - if (lisp_string_to_c_string(args[0], name, sizeof name)) {return NIL;} - if (lisp_string_to_c_string(args[1], pass, sizeof pass)) {return NIL;} + if (lisp_string_to_c_string(args[0], name, sizeof name)) { return NIL; } + if (lisp_string_to_c_string(args[1], pass, sizeof pass)) { return NIL; } - if ((pwd = getpwnam(name)) == 0) { - return(NIL); /* can't find entry for name */ - } + if ((pwd = getpwnam(name)) == 0) { return (NIL); /* can't find entry for name */ } salt[0] = pwd->pw_passwd[0]; salt[1] = pwd->pw_passwd[1]; salt[2] = '\0'; if (strcmp((char *)crypt(pass, salt), pwd->pw_passwd) == 0) - return(ATOM_T); + return (ATOM_T); else - return(NIL); + return (NIL); #else return ATOM_T; #endif /* DOS */ } - - /************************************************************************/ /* */ /* */ @@ -202,21 +183,16 @@ LispPTR check_unix_password(LispPTR *args) /* */ /************************************************************************/ -LispPTR unix_username(LispPTR *args) -{ +LispPTR unix_username(LispPTR *args) { #ifndef DOS struct passwd *pwd; - if ((pwd = getpwuid(getuid())) == NULL) - return NIL; - if (c_string_to_lisp_string(pwd->pw_name, args[0])) - return NIL; + if ((pwd = getpwuid(getuid())) == NULL) return NIL; + if (c_string_to_lisp_string(pwd->pw_name, args[0])) return NIL; #endif /* DOS */ return ATOM_T; } - - /************************************************************************/ /* */ /* u n i x _ g e t p a r m */ @@ -246,40 +222,37 @@ LispPTR unix_username(LispPTR *args) /* */ /************************************************************************/ -char* getenv(const char *); +char *getenv(const char *); -LispPTR unix_getparm(LispPTR *args) -{ - char envname[20], result[128], *envvalue; - if (lisp_string_to_c_string(args[0], envname, sizeof envname)) - return NIL; - if (strcmp(envname, "MACH") == 0) - { +LispPTR unix_getparm(LispPTR *args) { + char envname[20], result[128], *envvalue; + if (lisp_string_to_c_string(args[0], envname, sizeof envname)) return NIL; + if (strcmp(envname, "MACH") == 0) { #if defined(sparc) - envvalue = "sparc"; + envvalue = "sparc"; #else #if defined(I386) - envvalue = "i386"; + envvalue = "i386"; #else #ifdef RS6000 - envvalue = "rs/6000"; + envvalue = "rs/6000"; #else #ifdef HP9000 - envvalue = "hp9000"; + envvalue = "hp9000"; #else #ifdef ISC - envvalue = "i386"; + envvalue = "i386"; #else #ifdef INDIGO - envvalue = "mips"; + envvalue = "mips"; #else #ifdef RISCOS - envvalue = "mips"; + envvalue = "mips"; #else #ifdef DOS - envvalue = "386"; + envvalue = "386"; #else - envvalue = "mc68020"; + envvalue = "mc68020"; #endif #endif #endif @@ -288,34 +261,32 @@ LispPTR unix_getparm(LispPTR *args) #endif #endif #endif - } - else if (strcmp(envname, "ARCH") == 0) - { + } else if (strcmp(envname, "ARCH") == 0) { #if defined(sparc) - envvalue = "sun4"; + envvalue = "sun4"; #else #if defined(I386) - envvalue = "sun386"; + envvalue = "sun386"; #else #ifdef RS6000 - envvalue = "rs/6000"; + envvalue = "rs/6000"; #else #ifdef HP9000 - envvalue = "hp9000"; + envvalue = "hp9000"; #else #ifdef ISC - envvalue = "i386"; + envvalue = "i386"; #else #ifdef INDIGO - envvalue = "mips"; + envvalue = "mips"; #else #ifdef RISCOS - envvalue = "mips"; -#else -#ifdef DOS - envvalue = "dos"; + envvalue = "mips"; #else - envvalue = "sun3"; +#ifdef DOS + envvalue = "dos"; +#else + envvalue = "sun3"; #endif #endif #endif @@ -324,100 +295,77 @@ LispPTR unix_getparm(LispPTR *args) #endif #endif #endif - } - else if (strcmp(envname, "DISPLAY") == 0) - { + } else if (strcmp(envname, "DISPLAY") == 0) { #if defined(XWINDOW) - envvalue = "X"; + envvalue = "X"; #else #if defined(DISPLAYBUFFER) - envvalue = "BUFFERED"; -#else - envvalue = "DIRECT"; + envvalue = "BUFFERED"; +#else + envvalue = "DIRECT"; #endif /* DISPLAYBUFFER */ #endif /* XWINDOW */ - - } -#ifndef DOS - else if (strcmp(envname, "HOSTNAME") == 0) - { - if (gethostname(result, sizeof result)) return NIL; - envvalue = result; - } - else if (strcmp(envname, "LOGNAME") == 0) - { - struct passwd *pwd; - if ((pwd = getpwuid(getuid())) == NULL) return NIL; - envvalue = pwd->pw_name; - } - else if (strcmp(envname, "FULLUSERNAME") == 0) - { - struct passwd *pwd; - if ((pwd = getpwuid(getuid())) == NULL) return NIL; - envvalue = pwd->pw_gecos; - } - else if (strcmp(envname, "HOSTID") == 0) - { - sprintf(result, "%x", gethostid()); - envvalue = result; - } -#endif /* DOS */ - else return NIL; - - if (c_string_to_lisp_string(envvalue, args[1])) return NIL; - return ATOM_T; } - - - -/************************************************************************/ -/* */ -/* */ -/* */ -/* */ -/* */ -/************************************************************************/ - -LispPTR unix_getenv(LispPTR *args) -{ - char envname[20], *envvalue; - if (lisp_string_to_c_string(args[0], envname, sizeof envname)) - return NIL; - envvalue = getenv(envname); - if (!envvalue) - return NIL; - if (c_string_to_lisp_string(envvalue, args[1])) - return NIL; - return ATOM_T; -} - - - -/************************************************************************/ -/* */ -/* */ -/* */ -/* */ -/* */ -/************************************************************************/ - -LispPTR unix_fullname(LispPTR *args) -{ #ifndef DOS - struct passwd *pwd; - - if ((pwd = getpwuid(getuid())) == NULL) - return NIL; - if (c_string_to_lisp_string(pwd->pw_gecos, args[0])) - return NIL; + else if (strcmp(envname, "HOSTNAME") == 0) { + if (gethostname(result, sizeof result)) return NIL; + envvalue = result; + } else if (strcmp(envname, "LOGNAME") == 0) { + struct passwd *pwd; + if ((pwd = getpwuid(getuid())) == NULL) return NIL; + envvalue = pwd->pw_name; + } else if (strcmp(envname, "FULLUSERNAME") == 0) { + struct passwd *pwd; + if ((pwd = getpwuid(getuid())) == NULL) return NIL; + envvalue = pwd->pw_gecos; + } else if (strcmp(envname, "HOSTID") == 0) { + sprintf(result, "%x", gethostid()); + envvalue = result; + } #endif /* DOS */ + else + return NIL; + + if (c_string_to_lisp_string(envvalue, args[1])) return NIL; return ATOM_T; } +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ +LispPTR unix_getenv(LispPTR *args) { + char envname[20], *envvalue; + if (lisp_string_to_c_string(args[0], envname, sizeof envname)) return NIL; + envvalue = getenv(envname); + if (!envvalue) return NIL; + if (c_string_to_lisp_string(envvalue, args[1])) return NIL; + return ATOM_T; +} +/************************************************************************/ +/* */ +/* */ +/* */ +/* */ +/* */ +/************************************************************************/ + +LispPTR unix_fullname(LispPTR *args) { +#ifndef DOS + struct passwd *pwd; + + if ((pwd = getpwuid(getuid())) == NULL) return NIL; + if (c_string_to_lisp_string(pwd->pw_gecos, args[0])) return NIL; +#endif /* DOS */ + return ATOM_T; +} /************************************************************************/ /* */ @@ -427,75 +375,68 @@ LispPTR unix_fullname(LispPTR *args) /* */ /************************************************************************/ -extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, - *EmRealUtilin68K,*EmUtilin68K; -extern DLword *EmKbdAd168K,*EmKbdAd268K,*EmKbdAd368K, - *EmKbdAd468K,*EmKbdAd568K; +extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K, *EmUtilin68K; +extern DLword *EmKbdAd168K, *EmKbdAd268K, *EmKbdAd368K, *EmKbdAd468K, *EmKbdAd568K; -LispPTR suspend_lisp(LispPTR *args) -{ +LispPTR suspend_lisp(LispPTR *args) { #ifndef DOS - extern DLword *CTopKeyevent; - extern LispPTR *KEYBUFFERING68k; + extern DLword *CTopKeyevent; + extern LispPTR *KEYBUFFERING68k; - DLword w, r; - KBEVENT *kbevent; + DLword w, r; + KBEVENT *kbevent; + if (device_before_raid() < 0) { + OSMESSAGE_PRINT(printf("Can't suspend\n")); + return NIL; + } - if(device_before_raid() < 0) - { - OSMESSAGE_PRINT( printf("Can't suspend\n") ); - return NIL; - } + OSMESSAGE_PRINT(printf("suspending...\n")); - OSMESSAGE_PRINT( printf("suspending...\n") ); - - /* Send a terminal-stop signal to the whole process-group, not - just this process, so that if we are running as part of a - C-shell file the shell will be suspended too. */ +/* Send a terminal-stop signal to the whole process-group, not + just this process, so that if we are running as part of a + C-shell file the shell will be suspended too. */ #ifdef SYSVONLY - kill(0, SIGTSTP); + kill(0, SIGTSTP); #else - killpg(getpgrp(0), SIGTSTP); + killpg(getpgrp(0), SIGTSTP); #endif /* SYSVONLY */ + OSMESSAGE_PRINT(printf("resuming\n")); + device_after_raid(); + r = RING_READ(CTopKeyevent); + w = RING_WRITE(CTopKeyevent); - OSMESSAGE_PRINT( printf("resuming\n") ); - device_after_raid(); + /*NO CARE about event queue FULL */ - r=RING_READ(CTopKeyevent); - w=RING_WRITE(CTopKeyevent); + GETWORD(EmKbdAd068K) = KB_ALLUP; + GETWORD(EmKbdAd168K) = KB_ALLUP; + GETWORD(EmKbdAd268K) = KB_ALLUP; + GETWORD(EmKbdAd368K) = KB_ALLUP; + GETWORD(EmKbdAd468K) = KB_ALLUP; + GETWORD(EmKbdAd568K) = KB_ALLUP; + GETWORD(EmRealUtilin68K) = KB_ALLUP; - /*NO CARE about event queue FULL */ + kbevent = (KBEVENT *)(CTopKeyevent + w); - GETWORD(EmKbdAd068K)= KB_ALLUP; - GETWORD(EmKbdAd168K)= KB_ALLUP; - GETWORD(EmKbdAd268K)= KB_ALLUP; - GETWORD(EmKbdAd368K)= KB_ALLUP; - GETWORD(EmKbdAd468K)= KB_ALLUP; - GETWORD(EmKbdAd568K)= KB_ALLUP; - GETWORD(EmRealUtilin68K)= KB_ALLUP; + /* RCLK(kbevent->time); */ - kbevent=(KBEVENT*)(CTopKeyevent+ w); + kbevent->W0 = GETWORD(EmKbdAd068K); + kbevent->W1 = GETWORD(EmKbdAd168K); + kbevent->W2 = GETWORD(EmKbdAd268K); + kbevent->W3 = GETWORD(EmKbdAd368K); + kbevent->W4 = GETWORD(EmKbdAd468K); + kbevent->W5 = GETWORD(EmKbdAd568K); + kbevent->WU = GETWORD(EmRealUtilin68K); -/* RCLK(kbevent->time); */ + if (r == 0) /* Queue was empty */ + ((RING *)CTopKeyevent)->read = w; - kbevent->W0= GETWORD(EmKbdAd068K); - kbevent->W1= GETWORD(EmKbdAd168K); - kbevent->W2= GETWORD(EmKbdAd268K); - kbevent->W3= GETWORD(EmKbdAd368K); - kbevent->W4= GETWORD(EmKbdAd468K); - kbevent->W5= GETWORD(EmKbdAd568K); - kbevent->WU= GETWORD(EmRealUtilin68K); - - if(r==0) /* Queue was empty */ - ((RING*)CTopKeyevent)->read=w; - - if(w >= MAXKEYEVENT) - ((RING*)CTopKeyevent)->write = MINKEYEVENT; - else - ((RING*)CTopKeyevent)->write = w + KEYEVENTSIZE; + if (w >= MAXKEYEVENT) + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + else + ((RING *)CTopKeyevent)->write = w + KEYEVENTSIZE; #endif /* DOS, which doesn't support suspend-lisp */ - return ATOM_T; - } + return ATOM_T; +} diff --git a/src/vars3.c b/src/vars3.c old mode 100755 new mode 100644 index ecc9ab9..f0b8502 --- a/src/vars3.c +++ b/src/vars3.c @@ -1,8 +1,6 @@ -/* $Id: vars3.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: vars3.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: vars3.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-99 Venue. All Rights Reserved. */ @@ -17,16 +15,15 @@ static char *id = "$Id: vars3.c,v 1.4 2001/12/24 01:09:07 sybalsky Exp $ Copyrig #include "version.h" - -#include -#include "lispemul.h" -#include "lspglob.h" -#include "lispmap.h" -#include "adr68k.h" -#include "emlglob.h" -#include "cell.h" -#include "lsptypes.h" -#include "stack.h" +#include +#include "lispemul.h" +#include "lspglob.h" +#include "lispmap.h" +#include "adr68k.h" +#include "emlglob.h" +#include "cell.h" +#include "lsptypes.h" +#include "stack.h" /* def. of car_cell moved to cell.h */ @@ -35,160 +32,150 @@ struct cadr_cell cadr(LispPTR cell_adr); /******************************************* cadr - common routine. - used by OP_assoc, OP_fmemb + common routine. + used by OP_assoc, OP_fmemb *******************************************/ -struct cadr_cell -cadr(LispPTR cell_adr) - /* address of cell */ - /* Lisp address (word addressing) */ +struct cadr_cell cadr(LispPTR cell_adr) +/* address of cell */ +/* Lisp address (word addressing) */ { -ConsCell *pcons; -struct cadr_cell cadr1; /* return value */ -short offset; + ConsCell *pcons; + struct cadr_cell cadr1; /* return value */ + short offset; + if (Listp(cell_adr) == NIL) + if (cell_adr == NIL) { + cadr1.car_cell = 0; + cadr1.cdr_cell = 0; + return (cadr1); + } else { + cadr1.car_cell = car(cell_adr); + cadr1.cdr_cell = cdr(cell_adr); + return (cadr1); + } - if( Listp(cell_adr) == NIL) - if(cell_adr == NIL){ - cadr1.car_cell = 0; - cadr1.cdr_cell = 0; - return(cadr1); - } else { - cadr1.car_cell = car(cell_adr); - cadr1.cdr_cell = cdr(cell_adr); - return(cadr1); - } + pcons = (ConsCell *)Addr68k_from_LADDR(cell_adr); + while (pcons->cdr_code == CDR_INDIRECT) { + /* CDR indirect */ + cell_adr = pcons->car_field; + pcons = (ConsCell *)Addr68k_from_LADDR(pcons->car_field); + } /* skip CDR_INDIRECT cell */ - pcons = (ConsCell *)Addr68k_from_LADDR(cell_adr); - while( pcons->cdr_code == CDR_INDIRECT ){ - /* CDR indirect */ - cell_adr = pcons->car_field; - pcons = (ConsCell *)Addr68k_from_LADDR(pcons->car_field); - }/* skip CDR_INDIRECT cell */ - - cadr1.car_cell = pcons->car_field; + cadr1.car_cell = pcons->car_field; - if( pcons->cdr_code == CDR_NIL ){ - /* CDR nil */ - cadr1.cdr_cell = NIL_PTR; - return(cadr1); - } + if (pcons->cdr_code == CDR_NIL) { + /* CDR nil */ + cadr1.cdr_cell = NIL_PTR; + return (cadr1); + } #ifdef NEWCDRCODING - offset = (0x7 & pcons->cdr_code) << 1; - if(pcons->cdr_code > CDR_NIL){ - /* CDR on page */ - cadr1.cdr_cell = cell_adr + offset; - }else{ - /* CDR different page */ - pcons = (ConsCell *)Addr68k_from_LADDR( (cell_adr) + offset) ; - cadr1.cdr_cell = pcons->car_field; - } + offset = (0x7 & pcons->cdr_code) << 1; + if (pcons->cdr_code > CDR_NIL) { + /* CDR on page */ + cadr1.cdr_cell = cell_adr + offset; + } else { + /* CDR different page */ + pcons = (ConsCell *)Addr68k_from_LADDR((cell_adr) + offset); + cadr1.cdr_cell = pcons->car_field; + } #else - offset = (0x7F & pcons->cdr_code) << 1; - if(pcons->cdr_code > CDR_NIL){ - /* CDR on page */ - cadr1.cdr_cell = (mPAGEMASK & cell_adr) | offset; - }else{ - /* CDR different page */ - pcons = (ConsCell *)Addr68k_from_LADDR( ((mPAGEMASK & cell_adr) | offset) ); - cadr1.cdr_cell = pcons->car_field; - } + offset = (0x7F & pcons->cdr_code) << 1; + if (pcons->cdr_code > CDR_NIL) { + /* CDR on page */ + cadr1.cdr_cell = (mPAGEMASK & cell_adr) | offset; + } else { + /* CDR different page */ + pcons = (ConsCell *)Addr68k_from_LADDR(((mPAGEMASK & cell_adr) | offset)); + cadr1.cdr_cell = pcons->car_field; + } #endif /* NEWCDRCODING */ - return(cadr1); + return (cadr1); } - - /*********************************************************** N_OP_arg0 - Entry: ARG0 opcode[0141] + Entry: ARG0 opcode[0141] - - TopOfStack : slot number of IVAR area - - return : the contents of the slot. + + TopOfStack : slot number of IVAR area + + return : the contents of the slot. - No effect to CurrentStack. + No effect to CurrentStack. ************************************************************/ -LispPTR N_OP_arg0(register LispPTR tos) -{ -register int num; -register DLword *bf; /* index of Basic frame */ -register int nargs; +LispPTR N_OP_arg0(register LispPTR tos) { + register int num; + register DLword *bf; /* index of Basic frame */ + register int nargs; - - if( (SEGMASK & tos ) != S_POSITIVE){ - /* error("OP_arg0: Bad TopOfStack\n"); */ - ERROR_EXIT(tos); - }else - num = 0xFFFF & tos; - if(CURRENTFX->alink & 0x1){ - /* slow */ - bf = Stackspace + CURRENTFX->blink; - }else{ - /* fast */ - bf = ((DLword *)CURRENTFX) - BFSIZE; - /* bf : pointer to 1st word of BasicFramePointer */ - } - nargs = ((UNSIGNED)bf - (UNSIGNED)IVar)>>2; - /* nargs : number of IVAR slots */ - if((num ==0) || (num > nargs)){ - /* error("OP_arg0: Bad argument number\n"); */ - ERROR_EXIT(tos); - } - return(*((int *)IVar + num - 1)); + if ((SEGMASK & tos) != S_POSITIVE) { + /* error("OP_arg0: Bad TopOfStack\n"); */ + ERROR_EXIT(tos); + } else + num = 0xFFFF & tos; + if (CURRENTFX->alink & 0x1) { + /* slow */ + bf = Stackspace + CURRENTFX->blink; + } else { + /* fast */ + bf = ((DLword *)CURRENTFX) - BFSIZE; + /* bf : pointer to 1st word of BasicFramePointer */ + } + nargs = ((UNSIGNED)bf - (UNSIGNED)IVar) >> 2; + /* nargs : number of IVAR slots */ + if ((num == 0) || (num > nargs)) { + /* error("OP_arg0: Bad argument number\n"); */ + ERROR_EXIT(tos); + } + return (*((int *)IVar + num - 1)); } - /******************************************* N_OP_assoc - Entry: ASSOC opcode[026] + Entry: ASSOC opcode[026] + + TopOfStack -- A-list (cons cell of Lisp address) + *(int *)(CurrentStackPTR) -- Key (cons cell of Lisp address) - TopOfStack -- A-list (cons cell of Lisp address) - *(int *)(CurrentStackPTR) -- Key (cons cell of Lisp address) - *******************************************/ +LispPTR N_OP_assoc(register LispPTR key, register LispPTR list) { + REGISTER struct cadr_cell cadr1; + register LispPTR cdr; /* address of (cdr A-list); Lisp address */ -LispPTR N_OP_assoc(register LispPTR key, register LispPTR list) -{ -REGISTER struct cadr_cell cadr1; -register LispPTR cdr; /* address of (cdr A-list); Lisp address */ + if (list == NIL_PTR) { return (NIL_PTR); } + if (!Listp(list)) { return (NIL_PTR); } - if (list == NIL_PTR) { return(NIL_PTR); } - - if (!Listp( list )) { return(NIL_PTR); } - - S_N_CHECKANDCADR(list, cadr1, list); + S_N_CHECKANDCADR(list, cadr1, list); - do{ - cdr = cadr1.cdr_cell; /* the rest of A-list */ - if(Listp(cadr1.car_cell) && key == car(cadr1.car_cell)){ - /* cons data found */ - return(cadr1.car_cell); - } - /* search the rest of A-list */ - if(Listp(cdr)) - cadr1 = cadr(cdr); - else cdr = NIL; - /* check for interrupts and punt to handle one safely */ - if (!Irq_Stk_End) { - TopOfStack = cdr; /* for next execution */ - TIMER_EXIT(cdr); - } - }while(cdr != NIL_PTR); + do { + cdr = cadr1.cdr_cell; /* the rest of A-list */ + if (Listp(cadr1.car_cell) && key == car(cadr1.car_cell)) { + /* cons data found */ + return (cadr1.car_cell); + } + /* search the rest of A-list */ + if (Listp(cdr)) + cadr1 = cadr(cdr); + else + cdr = NIL; + /* check for interrupts and punt to handle one safely */ + if (!Irq_Stk_End) { + TopOfStack = cdr; /* for next execution */ + TIMER_EXIT(cdr); + } + } while (cdr != NIL_PTR); - return(NIL_PTR); + return (NIL_PTR); } - diff --git a/src/vesainit.c b/src/vesainit.c old mode 100755 new mode 100644 index d9b1aa6..a38ff6e --- a/src/vesainit.c +++ b/src/vesainit.c @@ -1,7 +1,7 @@ -/* $Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ Copyright (C) Venue"; - /************************************************************************/ /* */ /* (C) Copyright 1992, 1993, 1994, 1995 Venue. All Rights Reserved. */ @@ -16,9 +16,6 @@ static char *id = "$Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ Copy #include "version.h" - - - /************************************************************************/ /* */ /* V E S A I N I T . C */ @@ -27,9 +24,9 @@ static char *id = "$Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ Copy /* */ /************************************************************************/ -#include /* #pragma interrupt & _get_stk_frame */ +#include /* #pragma interrupt & _get_stk_frame */ #include -#include /* _XSTACK struct definition */ +#include /* _XSTACK struct definition */ #include #include #include @@ -39,33 +36,32 @@ static char *id = "$Id: vesainit.c,v 1.2 1999/01/03 02:07:44 sybalsky Exp $ Copy #include "lispemul.h" #include "devif.h" -#define VESA 0x4f -#define SUCESS 0x00 - /* VESA functions */ -#define _DESCRIBEMODE 0x1 -#define _SETMODE 0x2 -#define _GETCURRENTMODE 0x3 +#define VESA 0x4f +#define SUCESS 0x00 +/* VESA functions */ +#define _DESCRIBEMODE 0x1 +#define _SETMODE 0x2 +#define _GETCURRENTMODE 0x3 - /* VESA modevector indexes */ -#define _DISPLAYWIDTH 0x12 -#define _DISPLAYHEIGHT 0x14 -#define _COLORPLANES 0x18 -#define _BITSPERPIXEL 0x19 - -#define VESA_MODE_SUPPORTED_P(vector) ((((short *)vector)[0] & 1)? TRUE : FALSE) -#define VESA_OPT_INFO_P(vector) ((((short *)vector)[0] & 2)? TRUE : FALSE) -#define VESA_COLOR_MODE_P(vector) ((((short *)vector)[0] & 4)? TRUE : FALSE) -#define VESA_GRAPHICS_MODE_P(vector) ((((short *)vector)[0] & 8)? TRUE : FALSE) -#define VESA_SWITCH_BANK(vector) ((PFV)(((long *)vector)[3])) -#define VESA_DSP_SEGSIZE(vector) ((long)( 0xffff & ((short *)vector)[3])) -#define VESA_DSP_STARTSEG_A(vector) ((long)( 0xffff & ((short *)vector)[4])) -#define VESA_DSP_WIDTH(vector) ((long)(((short *)vector)[9])) -#define VESA_DSP_HEIGHT(vector) ((long)(((short *)vector)[10])) -#define VESA_DSP_COLORS(vector) ((long)( 1 << (((char *)vector)[0x19]))) -#define VESA_DSP_BPP(vector) ((long)(((char *)vector)[0x19])) -#define VESA_DSP_NUM_OF_BANKS(vector) ((long)(((char *)vector)[0x1a])) -#define VESA_DSP_BANK_SIZE(vector) ((long)(((char *)vector)[0x1c])) +/* VESA modevector indexes */ +#define _DISPLAYWIDTH 0x12 +#define _DISPLAYHEIGHT 0x14 +#define _COLORPLANES 0x18 +#define _BITSPERPIXEL 0x19 +#define VESA_MODE_SUPPORTED_P(vector) ((((short *)vector)[0] & 1) ? TRUE : FALSE) +#define VESA_OPT_INFO_P(vector) ((((short *)vector)[0] & 2) ? TRUE : FALSE) +#define VESA_COLOR_MODE_P(vector) ((((short *)vector)[0] & 4) ? TRUE : FALSE) +#define VESA_GRAPHICS_MODE_P(vector) ((((short *)vector)[0] & 8) ? TRUE : FALSE) +#define VESA_SWITCH_BANK(vector) ((PFV)(((long *)vector)[3])) +#define VESA_DSP_SEGSIZE(vector) ((long)(0xffff & ((short *)vector)[3])) +#define VESA_DSP_STARTSEG_A(vector) ((long)(0xffff & ((short *)vector)[4])) +#define VESA_DSP_WIDTH(vector) ((long)(((short *)vector)[9])) +#define VESA_DSP_HEIGHT(vector) ((long)(((short *)vector)[10])) +#define VESA_DSP_COLORS(vector) ((long)(1 << (((char *)vector)[0x19]))) +#define VESA_DSP_BPP(vector) ((long)(((char *)vector)[0x19])) +#define VESA_DSP_NUM_OF_BANKS(vector) ((long)(((char *)vector)[0x1a])) +#define VESA_DSP_BANK_SIZE(vector) ((long)(((char *)vector)[0x1c])) #define MAKE_SEG(low_flat) ((FP_OFF(low_flat) & 0xfffffff0) >> 4) #define MAKE_OFF(low_flat) (FP_OFF(low_flat & 0x0000000f)) @@ -90,42 +86,39 @@ extern long dos_cursor_invissible(); extern int dostaking_mouse_down(); extern int dostaking_mouse_up(); -void VESA_Intrpt_Hndlr(void); -void *VESA_prev_hndlr; /* addr of previous 0x10 intercept */ +void VESA_Intrpt_Hndlr(void); +void *VESA_prev_hndlr; /* addr of previous 0x10 intercept */ extern int dosdisplaymode; /**************************************************************/ /* V E S A _ c a l l */ /* General utility function for doing a BIOS call to the VESA */ -/* bios. */ +/* bios. */ /**************************************************************/ -VESA_call(class, subfunc) - int class, subfunc; +VESA_call(class, subfunc) int class, subfunc; { union REGS inregs, outregs; inregs.h.ah = VESA; inregs.h.al = class; inregs.x.bx = subfunc; - int86( 0x10, &inregs, &outregs ); - return( (outregs.h.al == VESA) && (outregs.h.ah == SUCESS)); + int86(0x10, &inregs, &outregs); + return ((outregs.h.al == VESA) && (outregs.h.ah == SUCESS)); } -unsigned long set_DAC_color(args) - LispPTR args[]; +unsigned long set_DAC_color(args) LispPTR args[]; { union REGS inregs, outregs; inregs.x.ax = 0x1010; - inregs.x.bx = (unsigned char) (args[0] & 0xff); - inregs.h.dh = (unsigned char) (args[1] & 0xff); - inregs.h.ch = (unsigned char) (args[2] & 0xff); - inregs.h.cl = (unsigned char) (args[3] & 0xff); - int86( 0x10, &inregs, &outregs ); + inregs.x.bx = (unsigned char)(args[0] & 0xff); + inregs.h.dh = (unsigned char)(args[1] & 0xff); + inregs.h.ch = (unsigned char)(args[2] & 0xff); + inregs.h.cl = (unsigned char)(args[3] & 0xff); + int86(0x10, &inregs, &outregs); } - /**************************************************************/ /* V E S A _ c u r r e n t m o d e */ /* Returns the current VESA mode for the display. */ @@ -143,31 +136,29 @@ unsigned long set_DAC_color(args) /* 0x107 1280x1024 & 256 colors (Not tested yet) */ /* */ /**************************************************************/ -int VESA_currentmode() -{ +int VESA_currentmode() { union REGS inregs, outregs; inregs.h.ah = VESA; inregs.h.al = _GETCURRENTMODE; inregs.x.bx = 0; - int86( 0x10, &inregs, &outregs ); - if ( (outregs.h.al == VESA) && (outregs.h.ah == SUCESS)) { + int86(0x10, &inregs, &outregs); + if ((outregs.h.al == VESA) && (outregs.h.ah == SUCESS)) { return (outregs.x.bx); } else { - return ( FALSE ); + return (FALSE); } } -int VESA_setmode( mode, clearscreen) - int mode, clearscreen; +int VESA_setmode(mode, clearscreen) int mode, clearscreen; { union REGS inregs, outregs; inregs.h.ah = VESA; inregs.h.al = _SETMODE | ((clearscreen) ? 0x8000 : 0); inregs.x.bx = mode; - int86( 0x10, &inregs, &outregs ); - return ( (outregs.h.al == VESA) && (outregs.h.ah == SUCESS) ); + int86(0x10, &inregs, &outregs); + return ((outregs.h.al == VESA) && (outregs.h.ah == SUCESS)); } #define VESABUFLEN 256 @@ -175,41 +166,37 @@ char VESAmodevector[VESABUFLEN]; char *VESAmodebytes = VESAmodevector; /* VESA_describemode */ -int VESA_describemode( mode ) - int mode; +int VESA_describemode(mode) int mode; { union REGS inregs, outregs; int i; unsigned buf; TPRINT(("Enter VESA_describemode\n")); - VESA_prev_hndlr = _dos_getvect(0x10); /* get current 10 intercept, if any */ + VESA_prev_hndlr = _dos_getvect(0x10); /* get current 10 intercept, if any */ _dos_setvect(0x10, VESA_Intrpt_Hndlr); /* install our int 10 intercept */ - if ( _dos_allocmem( VESABUFLEN, &buf ) != 0 ) return( -1 ); + if (_dos_allocmem(VESABUFLEN, &buf) != 0) return (-1); inregs.w.eax = 0x4f01; inregs.w.ebx = buf; inregs.w.ecx = mode; - int86( 0x10, &inregs, &outregs ); + int86(0x10, &inregs, &outregs); if (outregs.x.ax == VESA) { - for (i = 0; i < VESABUFLEN; i++) { - VESAmodebytes[i] = ((char *)buf)[i]; - } + for (i = 0; i < VESABUFLEN; i++) { VESAmodebytes[i] = ((char *)buf)[i]; } } else { - return ( -1 ); + return (-1); } - _dos_freemem( buf ); /* release the buffer */ + _dos_freemem(buf); /* release the buffer */ _dos_setvect(0x10, VESA_prev_hndlr); /* re-install previous 10 intercept */ TPRINT(("Exit VESA_describemode\n")); - return( 0 ); + return (0); } -void VESA_Intrpt_Hndlr(void) -{ - int inbuffer, func; +void VESA_Intrpt_Hndlr(void) { + int inbuffer, func; _XSTACK *stk_ptr; /* get ptr to _XSTACK - regs, etc */ @@ -218,96 +205,86 @@ void VESA_Intrpt_Hndlr(void) func = (unsigned short)stk_ptr->eax; /* get function */ if (((stk_ptr->flg & _FLAG_VM) == 0) /* process only if NOT virtual mode*/ - && (func == 0x4f01)) { /* AND only if func 4f */ - inbuffer = stk_ptr->ebx; /* get ebx as passed (flat addr) */ + && (func == 0x4f01)) { /* AND only if func 4f */ + inbuffer = stk_ptr->ebx; /* get ebx as passed (flat addr) */ stk_ptr->edi = MAKE_OFF(inbuffer); /* convert to seg:off form */ - stk_ptr->es = MAKE_SEG(inbuffer); /* service requires it in es:di */ + stk_ptr->es = MAKE_SEG(inbuffer); /* service requires it in es:di */ - ((PFV)VESA_prev_hndlr)(); /* call VESA getmode */ + ((PFV)VESA_prev_hndlr)(); /* call VESA getmode */ } else { - _chain_intr(VESA_prev_hndlr); /* always best to chain to prev int*/ + _chain_intr(VESA_prev_hndlr); /* always best to chain to prev int*/ } } -void VESA_beforeraid( dsp ) - DspInterface dsp; +void VESA_beforeraid(dsp) DspInterface dsp; { TPRINT(("Enter VESA_beforeraid\n")); - _setvideomode( _DEFAULTMODE ); - _clearscreen( _GCLEARSCREEN ); + _setvideomode(_DEFAULTMODE); + _clearscreen(_GCLEARSCREEN); TPRINT(("Exit VESA_beforeraid\n")); } -void VESA_afterraid( dsp ) - DspInterface dsp; +void VESA_afterraid(dsp) DspInterface dsp; { TPRINT(("Enter VESA_afterraid\n")); - VESA_setmode( dsp->graphicsmode , TRUE); + VESA_setmode(dsp->graphicsmode, TRUE); TPRINT(("Exit VESA_afterraid\n")); } -void VESA_enter( dsp ) - DspInterface dsp; +void VESA_enter(dsp) DspInterface dsp; { union REGS regs; TPRINT(("Enter VESA_enter\n")); - VESA_setmode( dsp->graphicsmode , TRUE); - if (!((VESA_describemode( dsp->graphicsmode ) == 0))){ - _setvideomode( _DEFAULTMODE ); - _clearscreen( _GCLEARSCREEN ); - fprintf( stderr, "Can't set VESA mode %o.\n", dsp->graphicsmode ); - exit(0); - } + VESA_setmode(dsp->graphicsmode, TRUE); + if (!((VESA_describemode(dsp->graphicsmode) == 0))) { + _setvideomode(_DEFAULTMODE); + _clearscreen(_GCLEARSCREEN); + fprintf(stderr, "Can't set VESA mode %o.\n", dsp->graphicsmode); + exit(0); + } /* Get the segaddr. An addr. is a seg shifted 4 bits! */ dsp->DisplayStartAddr = VESA_DSP_STARTSEG_A(VESAmodebytes) << 4; /* Get the size. */ dsp->DisplaySegSize = (VESA_DSP_SEGSIZE(VESAmodebytes) << 10); /* How many bits in the segment addr. */ - switch(VESA_DSP_SEGSIZE(VESAmodebytes)){ - case 64: - dsp->DisplaySegMagnitude = 0x10; - break; - case 128: - dsp->DisplaySegMagnitude = 0x11; - break; - case 256: - dsp->DisplaySegMagnitude = 0x12; - break; + switch (VESA_DSP_SEGSIZE(VESAmodebytes)) { + case 64: dsp->DisplaySegMagnitude = 0x10; break; + case 128: dsp->DisplaySegMagnitude = 0x11; break; + case 256: dsp->DisplaySegMagnitude = 0x12; break; } dsp->SwitchBank = NULL; - if(VESA_OPT_INFO_P(VESAmodebytes)){ + if (VESA_OPT_INFO_P(VESAmodebytes)) { dsp->Display.width = VESA_DSP_WIDTH(VESAmodebytes); dsp->Display.height = VESA_DSP_HEIGHT(VESAmodebytes); - } - else { /* Drat! No optional info. Hardcode. */ - switch(dsp->graphicsmode){ - case 0x100: - dsp->Display.width = 640; - dsp->Display.height = 400; - break; - case 0x101: - dsp->Display.width = 640; - dsp->Display.height = 480; - break; - case 0x102: - case 0x103: - dsp->Display.width = 800; - dsp->Display.height = 600; - break; - case 0x104: - case 0x105: - dsp->Display.width = 1024; - dsp->Display.height = 768; - break; - case 0x106: - case 0x107: - dsp->Display.width = 1280; - dsp->Display.height = 1024; - break; + } else { /* Drat! No optional info. Hardcode. */ + switch (dsp->graphicsmode) { + case 0x100: + dsp->Display.width = 640; + dsp->Display.height = 400; + break; + case 0x101: + dsp->Display.width = 640; + dsp->Display.height = 480; + break; + case 0x102: + case 0x103: + dsp->Display.width = 800; + dsp->Display.height = 600; + break; + case 0x104: + case 0x105: + dsp->Display.width = 1024; + dsp->Display.height = 768; + break; + case 0x106: + case 0x107: + dsp->Display.width = 1280; + dsp->Display.height = 1024; + break; } } dsp->colors = VESA_DSP_COLORS(VESAmodebytes); @@ -319,7 +296,7 @@ void VESA_enter( dsp ) _dpmi_lockregion(¤tdsp, sizeof(currentdsp)); _dpmi_lockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); - _dpmi_lockregion(DisplayRegion68k, 1600*1208/8); + _dpmi_lockregion(DisplayRegion68k, 1600 * 1208 / 8); /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ _dpmi_lockregion(dsp, sizeof(*dsp)); @@ -331,14 +308,13 @@ void VESA_enter( dsp ) TPRINT(("Exit VESA_enter\n")); } -void VESA_exit( dsp ) - DspInterface dsp; +void VESA_exit(dsp) DspInterface dsp; { TPRINT(("Enter VESA_exit\n")); /* Unlock the following to avoid waste of mainmem. */ _dpmi_unlockregion(¤tdsp, sizeof(currentdsp)); _dpmi_unlockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); - _dpmi_unlockregion(DisplayRegion68k, 1600*1208/8); + _dpmi_unlockregion(DisplayRegion68k, 1600 * 1208 / 8); _dpmi_unlockregion(dsp->bitblt_to_screen, 0x2000); _dpmi_unlockregion(dsp->mouse_invissible, 0x2000); @@ -346,34 +322,31 @@ void VESA_exit( dsp ) _dpmi_unlockregion((void *)&docopy, 0x2000); _dpmi_unlockregion(dsp, sizeof(*dsp)); - _setvideomode( _DEFAULTMODE ); - _clearscreen( _GCLEARSCREEN ); + _setvideomode(_DEFAULTMODE); + _clearscreen(_GCLEARSCREEN); TPRINT(("Exit VESA_exit\n")); } -VESA_errorexit( s, errno ) - char *s; - int errno; +VESA_errorexit(s, errno) char *s; +int errno; { - _setvideomode( _DEFAULTMODE ); - _clearscreen( _GCLEARSCREEN ); - fprintf( stderr, s ); + _setvideomode(_DEFAULTMODE); + _clearscreen(_GCLEARSCREEN); + fprintf(stderr, s); fflush(stderr); exit(errno); } -void tmpclearbanks(dsp) - DspInterface dsp; +void tmpclearbanks(dsp) DspInterface dsp; { TPRINT(("Enter tmpclearbanks\n")); -/* Dosclearbanks(dsp); */ + /* Dosclearbanks(dsp); */ TPRINT(("Exit tmpclearbanks\n")); } -unsigned long tmpbbt(dsp, buffer, left, top, swidth, height) - DspInterface dsp; - char *buffer; - long left, top, swidth, height; +unsigned long tmpbbt(dsp, buffer, left, top, swidth, height) DspInterface dsp; +char *buffer; +long left, top, swidth, height; { TPRINT(("Enter tmpbbt\n")); TPRINT(("Mode display is: %d\n", dsp->graphicsmode)); @@ -384,93 +357,81 @@ unsigned long tmpbbt(dsp, buffer, left, top, swidth, height) TPRINT(("Exit tmpbbt\n")); } -VESA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) - DspInterface dsp; - char *lispbitmap; - int width_hint, height_hint, depth_hint; +VESA_init(dsp, lispbitmap, width_hint, height_hint, depth_hint) DspInterface dsp; +char *lispbitmap; +int width_hint, height_hint, depth_hint; { TPRINT(("Enter VESA_init\n")); /* Kludge. going away soon. */ dsp->graphicsmode = dosdisplaymode; /* A graphics mode is requested. Test its validity */ - if ( dsp->graphicsmode == 0 ) { + if (dsp->graphicsmode == 0) { /* No mode requested. Find a suitable mode from hints. */ - switch ( depth_hint ) { + switch (depth_hint) { case 0: case 1: - if ((VESA_describemode( 0x104 ) == 0) && - (VESA_MODE_SUPPORTED_P( VESAmodevector ))) - dsp->graphicsmode = 0x104; - else if ((VESA_describemode( 0x102 ) == 0) && - (VESA_MODE_SUPPORTED_P( VESAmodevector ))) - dsp->graphicsmode = 0x102; - else VESA_errorexit("Displaymode not supported", -1); - break; + if ((VESA_describemode(0x104) == 0) && (VESA_MODE_SUPPORTED_P(VESAmodevector))) + dsp->graphicsmode = 0x104; + else if ((VESA_describemode(0x102) == 0) && (VESA_MODE_SUPPORTED_P(VESAmodevector))) + dsp->graphicsmode = 0x102; + else + VESA_errorexit("Displaymode not supported", -1); + break; case 8: - if ((VESA_describemode( 0x105 ) == 0) && - (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ - dsp->graphicsmode = 0x105; - } - else if ((VESA_describemode( 0x103 ) == 0) && - (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ - dsp->graphicsmode = 0x103; - } - else if ((VESA_describemode( 0x101 ) == 0) && - (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ - dsp->graphicsmode = 0x101; - } - else if ((VESA_describemode( 0x100 ) == 0) && - (VESA_MODE_SUPPORTED_P( VESAmodevector ))){ - dsp->graphicsmode = 0x100; - } - else VESA_errorexit("Displaymode not supported", -1); - break; - default: - VESA_errorexit("Requested display depth not supported", -1); - } + if ((VESA_describemode(0x105) == 0) && (VESA_MODE_SUPPORTED_P(VESAmodevector))) { + dsp->graphicsmode = 0x105; + } else if ((VESA_describemode(0x103) == 0) && (VESA_MODE_SUPPORTED_P(VESAmodevector))) { + dsp->graphicsmode = 0x103; + } else if ((VESA_describemode(0x101) == 0) && (VESA_MODE_SUPPORTED_P(VESAmodevector))) { + dsp->graphicsmode = 0x101; + } else if ((VESA_describemode(0x100) == 0) && (VESA_MODE_SUPPORTED_P(VESAmodevector))) { + dsp->graphicsmode = 0x100; + } else + VESA_errorexit("Displaymode not supported", -1); + break; + default: VESA_errorexit("Requested display depth not supported", -1); } - else if (!((VESA_describemode( dsp->graphicsmode ) == 0) && - (VESA_MODE_SUPPORTED_P( VESAmodevector )))){ + } else if (!((VESA_describemode(dsp->graphicsmode) == 0) && + (VESA_MODE_SUPPORTED_P(VESAmodevector)))) { VESA_errorexit("Can't find suitable VESA mode.\n", -1); } - - switch ( dsp->graphicsmode ) { - case 0x100: - case 0x101: - dsp->BytesPerLine = 640; - dsp->bitblt_to_screen = &tmpbbt; - break; - case 0x102: - dsp->BytesPerLine = 100; - dsp->bitblt_to_screen = &Dosbbt1; - break; - case 0x103: - dsp->BytesPerLine = 800; - dsp->bitblt_to_screen = &tmpbbt; - break; - case 0x104: - dsp->BytesPerLine = 128; - dsp->bitblt_to_screen = &Dosbbt2; - break; - case 0x105: - dsp->BytesPerLine = 1024; - dsp->bitblt_to_screen = &tmpbbt; - break; - case 0x106: - dsp->BytesPerLine = 160; - dsp->bitblt_to_screen = &Dosbbt2; - break; - case 0x107: - dsp->BytesPerLine = 1280; - dsp->bitblt_to_screen = &tmpbbt; + + switch (dsp->graphicsmode) { + case 0x100: + case 0x101: + dsp->BytesPerLine = 640; + dsp->bitblt_to_screen = &tmpbbt; break; - default: - VESA_errorexit("Displaymode not supported", -1); + case 0x102: + dsp->BytesPerLine = 100; + dsp->bitblt_to_screen = &Dosbbt1; + break; + case 0x103: + dsp->BytesPerLine = 800; + dsp->bitblt_to_screen = &tmpbbt; + break; + case 0x104: + dsp->BytesPerLine = 128; + dsp->bitblt_to_screen = &Dosbbt2; + break; + case 0x105: + dsp->BytesPerLine = 1024; + dsp->bitblt_to_screen = &tmpbbt; + break; + case 0x106: + dsp->BytesPerLine = 160; + dsp->bitblt_to_screen = &Dosbbt2; + break; + case 0x107: + dsp->BytesPerLine = 1280; + dsp->bitblt_to_screen = &tmpbbt; + break; + default: VESA_errorexit("Displaymode not supported", -1); } TPRINT(("Mode display is: %d\n", dsp->graphicsmode)); - + dsp->device.locked = FALSE; dsp->device.active = FALSE; @@ -479,7 +440,7 @@ VESA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) dsp->device.before_raid = &VESA_beforeraid; dsp->device.after_raid = &VESA_afterraid; - + dsp->drawline = &GenericPanic; dsp->cleardisplay = &tmpclearbanks; @@ -499,5 +460,4 @@ VESA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) dsp->mouse_vissible = (PFV)&dostaking_mouse_up; TPRINT(("Exit VESA_init\n")); - } diff --git a/src/vgainit.c b/src/vgainit.c old mode 100755 new mode 100644 index caf863a..f25b2c1 --- a/src/vgainit.c +++ b/src/vgainit.c @@ -1,9 +1,7 @@ -/* $Id: vgainit.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: vgainit.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: vgainit.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -17,10 +15,8 @@ static char *id = "$Id: vgainit.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - #include #include #include "lispemul.h" @@ -38,16 +34,15 @@ extern void docopy(); extern void GenericPanic(); -void VGA_setmax( dsp ) - DspInterface dsp; +void VGA_setmax(dsp) DspInterface dsp; { struct videoconfig vc; - if( !_setvideomode( _MAXRESMODE ) ) { - fprintf ( stderr, "Can't set graphics mode.\n" ); - exit( 1 ); + if (!_setvideomode(_MAXRESMODE)) { + fprintf(stderr, "Can't set graphics mode.\n"); + exit(1); } - _getvideoconfig( &vc ); + _getvideoconfig(&vc); dsp->Display.width = vc.numxpixels; dsp->Display.height = vc.numypixels; dsp->bitsperpixel = vc.bitsperpixel; @@ -56,7 +51,7 @@ void VGA_setmax( dsp ) /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ _dpmi_lockregion(¤tdsp, sizeof(currentdsp)); _dpmi_lockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); - _dpmi_lockregion(DisplayRegion68k, 1600*1208/8); + _dpmi_lockregion(DisplayRegion68k, 1600 * 1208 / 8); /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ _dpmi_lockregion(dsp, sizeof(*dsp)); @@ -66,13 +61,12 @@ void VGA_setmax( dsp ) _dpmi_lockregion((void *)&docopy, 0x2000); } -void VGA_exit( dsp ) - DspInterface dsp; +void VGA_exit(dsp) DspInterface dsp; { /* Unlock the following to avoid waste of mainmem. */ _dpmi_unlockregion(¤tdsp, sizeof(currentdsp)); _dpmi_unlockregion(&DisplayRegion68k, sizeof(DisplayRegion68k)); - _dpmi_unlockregion(DisplayRegion68k, 1600*1208/8); + _dpmi_unlockregion(DisplayRegion68k, 1600 * 1208 / 8); /* These are needed in the interrupt processing. Lock'em to prevent pagefaults. */ _dpmi_unlockregion(dsp, sizeof(*dsp)); @@ -81,69 +75,56 @@ void VGA_exit( dsp ) _dpmi_unlockregion(dsp->mouse_vissible, 0x2000); _dpmi_unlockregion((void *)&docopy, 0x2000); - _setvideomode( _DEFAULTMODE ); - _clearscreen( _GCLEARSCREEN ); -} - -unsigned long VGA_not_color( dsp ) - DspInterface dsp; -{ - printf( "Colormode not set!\n"); - fflush(stdout); - return(0); -} - -unsigned long VGA_colornum( dsp ) - DspInterface dsp; -{ /* Return the number of available colors */ - return(1 << dsp->bitsperpixel); -} - -unsigned long VGA_possiblecolors( dsp ) - DspInterface dsp; -{ - return(dsp->colors); -} - -void VGA_mono_drawline( dsp, startX, startY, width, height, function, color, - thickness, butt, clipX, clipY, clipWidth, clipHeight, dashing) - DspInterface dsp; - unsigned long startX, startY, width, height; - int function; - unsigned long color, thickness; - int butt; - unsigned long clipX, clipY, clipWidth, clipHeight; - LispPTR *dashing; - -{ - _moveto_w( startX, startY ); - _lineto_w( width, height ); -} - -void VGA_color_drawline ( dsp, startX, startY, width, height, function, color, - thickness, butt, clipX, clipY, clipWidth, clipHeight, dashing) - DspInterface dsp; - unsigned long startX, startY, width, height; - int function; - unsigned long color, thickness; - int butt; - unsigned long clipX, clipY, clipWidth, clipHeight; - LispPTR *dashing; - -{ - -} - -void VGA_cleardisplay ( dsp ) - DspInterface dsp; -{ + _setvideomode(_DEFAULTMODE); _clearscreen(_GCLEARSCREEN); } -VGA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) - DspInterface dsp; - char *lispbitmap; - int width_hint, height_hint, depth_hint; +unsigned long VGA_not_color(dsp) DspInterface dsp; +{ + printf("Colormode not set!\n"); + fflush(stdout); + return (0); +} + +unsigned long VGA_colornum(dsp) DspInterface dsp; +{ /* Return the number of available colors */ + return (1 << dsp->bitsperpixel); +} + +unsigned long VGA_possiblecolors(dsp) DspInterface dsp; +{ return (dsp->colors); } + +void VGA_mono_drawline(dsp, startX, startY, width, height, function, color, thickness, butt, clipX, + clipY, clipWidth, clipHeight, dashing) DspInterface dsp; +unsigned long startX, startY, width, height; +int function; +unsigned long color, thickness; +int butt; +unsigned long clipX, clipY, clipWidth, clipHeight; +LispPTR *dashing; + +{ + _moveto_w(startX, startY); + _lineto_w(width, height); +} + +void VGA_color_drawline(dsp, startX, startY, width, height, function, color, thickness, butt, clipX, + clipY, clipWidth, clipHeight, dashing) DspInterface dsp; +unsigned long startX, startY, width, height; +int function; +unsigned long color, thickness; +int butt; +unsigned long clipX, clipY, clipWidth, clipHeight; +LispPTR *dashing; + +{} + +void VGA_cleardisplay(dsp) DspInterface dsp; +{ _clearscreen(_GCLEARSCREEN); } + +VGA_init(dsp, lispbitmap, width_hint, height_hint, depth_hint) DspInterface dsp; +char *lispbitmap; +int width_hint, height_hint, depth_hint; { struct videoconfig vc; @@ -152,7 +133,7 @@ VGA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) dsp->device.before_raid = (PFV)&VGA_exit; dsp->device.after_raid = (PFV)&VGA_setmax; - + dsp->drawline = (PFV)&VGA_mono_drawline; dsp->cleardisplay = (PFV)&VGA_cleardisplay; @@ -170,7 +151,7 @@ VGA_init( dsp, lispbitmap, width_hint, height_hint, depth_hint ) dsp->scroll_region = (PFUL)&GenericPanic; dsp->DisplayStartAddr = 0xa0000; - dsp->DisplaySegSize = 0x10000; /* 64K segments */ + dsp->DisplaySegSize = 0x10000; /* 64K segments */ dsp->DisplaySegMagnitude = 0x10; /* How many bits in the addr. */ dsp->BytesPerLine = 80; dsp->LinesPerBank = 512; diff --git a/src/vmemsave.c b/src/vmemsave.c old mode 100755 new mode 100644 index b039356..b3139e1 --- a/src/vmemsave.c +++ b/src/vmemsave.c @@ -1,8 +1,7 @@ -/* $Id: vmemsave.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: vmemsave.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: vmemsave.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-1995 Venue. All Rights Reserved. */ @@ -17,10 +16,6 @@ static char *id = "$Id: vmemsave.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ Copy #include "version.h" - - - - /* * vmemsave.c * @@ -87,15 +82,15 @@ static char *id = "$Id: vmemsave.c,v 1.2 1999/01/03 02:07:45 sybalsky Exp $ Copy #endif /* Error return values from VMEMSAVE */ -#define COMPLETESYSOUT NIL -#define BADFILENAME S_POSITIVE | 1 -#define NOFILESPACE S_POSITIVE | 2 -#define FILECANNOTOPEN S_POSITIVE | 3 -#define FILECANNOTSEEK S_POSITIVE | 4 -#define FILECANNOTWRITE S_POSITIVE | 5 -#define FILETIMEOUT S_POSITIVE | 6 +#define COMPLETESYSOUT NIL +#define BADFILENAME S_POSITIVE | 1 +#define NOFILESPACE S_POSITIVE | 2 +#define FILECANNOTOPEN S_POSITIVE | 3 +#define FILECANNOTSEEK S_POSITIVE | 4 +#define FILECANNOTWRITE S_POSITIVE | 5 +#define FILETIMEOUT S_POSITIVE | 6 -struct stat DEBUG_stat; +struct stat DEBUG_stat; extern int LispWindowFd; extern struct pixrect *CursorBitMap, *InvisibleCursorBitMap; @@ -107,12 +102,11 @@ extern DspInterface currentdsp; #endif /* DOS */ #undef roundup -#define roundup( a, b) ((((unsigned)(a)+(b)-1)/(b))*(b)) - -extern int *Lisp_errno; -extern int Dummy_errno; /* Used if errno cell isn't provided by Lisp.*/ -extern int please_fork; +#define roundup(a, b) ((((unsigned)(a) + (b)-1) / (b)) * (b)) +extern int *Lisp_errno; +extern int Dummy_errno; /* Used if errno cell isn't provided by Lisp.*/ +extern int please_fork; /************************************************************************/ /* */ @@ -123,17 +117,15 @@ extern int please_fork; /* */ /************************************************************************/ -int lispstringP(Lisp) - LispPTR Lisp; - { - switch( ((OneDArray *)(Addr68k_from_LADDR(Lisp)))->typenumber ) - { - case THIN_CHAR_TYPENUMBER: - case FAT_CHAR_TYPENUMBER: return(1); +int lispstringP(Lisp) LispPTR Lisp; +{ + switch (((OneDArray *)(Addr68k_from_LADDR(Lisp)))->typenumber) { + case THIN_CHAR_TYPENUMBER: + case FAT_CHAR_TYPENUMBER: return (1); - default: return(0); - } + default: return (0); } +} LispPTR vmem_save(register char *sysout_file_name); @@ -173,76 +165,65 @@ LispPTR vmem_save(register char *sysout_file_name); /* */ /************************************************************************/ -LispPTR vmem_save0(args) - register LispPTR *args; - { - register char *def; - char pathname[MAXPATHLEN], sysout[MAXPATHLEN], host[MAXNAMLEN]; +LispPTR vmem_save0(args) register LispPTR *args; +{ + register char *def; + char pathname[MAXPATHLEN], sysout[MAXPATHLEN], host[MAXNAMLEN]; #ifdef DOS - char pwd[MAXNAMLEN]; - char drive[1]; + char pwd[MAXNAMLEN]; + char drive[1]; #else - struct passwd *pwd; + struct passwd *pwd; #endif /* DOS */ - char *getenv(); - - Lisp_errno = &Dummy_errno; + char *getenv(); + + Lisp_errno = &Dummy_errno; #ifdef DEMO - return FILECANNOTOPEN; + return FILECANNOTOPEN; #else - if((args[0] != NIL) && lispstringP(args[0])) - { - /* Check of lispstringP is safer for LispStringToCString */ - LispStringToCString(args[0], pathname, MAXPATHLEN); - separate_host(pathname, host); + if ((args[0] != NIL) && lispstringP(args[0])) { + /* Check of lispstringP is safer for LispStringToCString */ + LispStringToCString(args[0], pathname, MAXPATHLEN); + separate_host(pathname, host); #ifdef DOS - if (!unixpathname(pathname, sysout, 0, 0, drive, 0, 0)) return(BADFILENAME); + if (!unixpathname(pathname, sysout, 0, 0, drive, 0, 0)) return (BADFILENAME); #else - if (!unixpathname(pathname, sysout, 0, 0)) return(BADFILENAME); + if (!unixpathname(pathname, sysout, 0, 0)) return (BADFILENAME); #endif /* DOS */ - return(vmem_save(sysout)); - } - else - { - if((def = getenv("LDEDESTSYSOUT")) == 0) - { + return (vmem_save(sysout)); + } else { + if ((def = getenv("LDEDESTSYSOUT")) == 0) { #ifdef DOS - if(getcwd(pwd,MAXNAMLEN) == NULL) return(FILETIMEOUT); - strcpy(sysout,pwd); - strcat(sysout, "/lisp.vm"); + if (getcwd(pwd, MAXNAMLEN) == NULL) return (FILETIMEOUT); + strcpy(sysout, pwd); + strcat(sysout, "/lisp.vm"); #else - pwd = getpwuid(getuid()); /* NEED TIMEOUT */ - if (pwd == (struct passwd *)NULL) return(FILETIMEOUT); - strcpy(sysout, pwd->pw_dir); - strcat(sysout, "/lisp.virtualmem"); + pwd = getpwuid(getuid()); /* NEED TIMEOUT */ + if (pwd == (struct passwd *)NULL) return (FILETIMEOUT); + strcpy(sysout, pwd->pw_dir); + strcat(sysout, "/lisp.virtualmem"); #endif /* DOS */ - } - else - { - if (*def == '~' && - (*(def + 1) == '/' || *(def + 1) == '\0')) - { + } else { + if (*def == '~' && (*(def + 1) == '/' || *(def + 1) == '\0')) { #ifdef DOS - if(getcwd(pwd,MAXNAMLEN) == NULL) return(FILETIMEOUT); - strcpy(sysout,pwd); + if (getcwd(pwd, MAXNAMLEN) == NULL) return (FILETIMEOUT); + strcpy(sysout, pwd); #else - pwd = getpwuid(getuid()); /* NEED TIMEOUT */ - if (pwd == (struct passwd *)NULL) return(FILETIMEOUT); - strcpy(sysout, pwd->pw_dir); + pwd = getpwuid(getuid()); /* NEED TIMEOUT */ + if (pwd == (struct passwd *)NULL) return (FILETIMEOUT); + strcpy(sysout, pwd->pw_dir); #endif /* DOS */ - strcat(sysout, def + 1); - } - else - { - strcpy(sysout, def); - } - } - return(vmem_save(sysout)); + strcat(sysout, def + 1); + } else { + strcpy(sysout, def); } -#endif /* DEMO */ + } + return (vmem_save(sysout)); } +#endif /* DEMO */ +} /************************************************************************/ /* */ @@ -254,80 +235,69 @@ LispPTR vmem_save0(args) /* */ /************************************************************************/ -int twowords(i,j) /* the difference between two DLwords. */ - DLword *i, *j; - { - return(*i - *j); - } - +int twowords(i, j) /* the difference between two DLwords. */ + DLword *i, + *j; +{ return (*i - *j); } #define FPTOVP_ENTRY (FPTOVP_OFFSET >> 8) -void sort_fptovp(fptovp, size) - DLword *fptovp; - int size; - { - int oldloc, newloc, oldsize, i; - DLword *fptr; +void sort_fptovp(fptovp, size) DLword *fptovp; +int size; +{ + int oldloc, newloc, oldsize, i; + DLword *fptr; - for(fptr = fptovp, i=0; - GETWORD(fptr) != FPTOVP_ENTRY && i < size; - fptr++, i++); + for (fptr = fptovp, i = 0; GETWORD(fptr) != FPTOVP_ENTRY && i < size; fptr++, i++) + ; - if(GETWORD(fptr) != FPTOVP_ENTRY) - { - DBPRINT((stderr, "Couldn't find FPTOVP_ENTRY; not munging\n")); - return; - } - oldloc = fptr - fptovp; + if (GETWORD(fptr) != FPTOVP_ENTRY) { + DBPRINT((stderr, "Couldn't find FPTOVP_ENTRY; not munging\n")); + return; + } + oldloc = fptr - fptovp; - /* Found old fptovp table location, now sort the table */ - qsort(fptovp, size, sizeof(DLword), twowords); + /* Found old fptovp table location, now sort the table */ + qsort(fptovp, size, sizeof(DLword), twowords); ONE_MORE_TIME: /* Tacky, but why repeat code? */ - /* Look up FPTOVP_ENTRY again; if it's moved, need to shuffle stuff */ - for(fptr = fptovp, i=0; - GETWORD(fptr) != FPTOVP_ENTRY && i < size; - fptr++, i++); + /* Look up FPTOVP_ENTRY again; if it's moved, need to shuffle stuff */ + for (fptr = fptovp, i = 0; GETWORD(fptr) != FPTOVP_ENTRY && i < size; fptr++, i++) + ; - if(GETWORD(fptr) != FPTOVP_ENTRY) error("Couldn't find FPTOVP_ENTRY second time!\n"); - newloc = fptr - fptovp; + if (GETWORD(fptr) != FPTOVP_ENTRY) error("Couldn't find FPTOVP_ENTRY second time!\n"); + newloc = fptr - fptovp; - /* Supposedly all we have to do is adjust the fptovpstart and nactivepages - the ifpage */ - InterfacePage->fptovpstart += (newloc - oldloc); - oldsize = size; - for(fptr = fptovp + (size-1); GETWORD(fptr) == 0xffff; - fptr--, InterfacePage->nactivepages--, size--); + /* Supposedly all we have to do is adjust the fptovpstart and nactivepages + the ifpage */ + InterfacePage->fptovpstart += (newloc - oldloc); + oldsize = size; + for (fptr = fptovp + (size - 1); GETWORD(fptr) == 0xffff; + fptr--, InterfacePage->nactivepages--, size--) + ; - if(size != oldsize) - DBPRINT(("Found %d holes in fptovp table\n", oldsize - size)); + if (size != oldsize) DBPRINT(("Found %d holes in fptovp table\n", oldsize - size)); - /* Sanity check; it's just possible there are duplicate entries... */ - { - int dupcount = 0; - for(fptr = fptovp, i=1; - idevice.locked++; - (currentdsp->mouse_invissible)(currentdsp, IOPage68K); + /* For DOS, must also take the mouse cursor away (it's */ + /* written into the display-region bitmap). */ + currentdsp->device.locked++; + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); #endif /* SUNDISPLAY || DOS */ + /* set FPTOVP */ + fptovp = FPtoVP + 1; - /* set FPTOVP */ - fptovp = FPtoVP + 1; + /* set VMEMSIZE */ + vmemsize = InterfacePage->nactivepages; - /* set VMEMSIZE */ - vmemsize = InterfacePage->nactivepages; + /* [HH:6-Jan-89] + Sequnce of save image + (1) Sysout image is saved to a temporary file, tempname. + (2) if a specified file, sysout_file_name, is exist, the file is removed. + (3) the temporary file is renamed to the specified file. + */ -/* [HH:6-Jan-89] - Sequnce of save image - (1) Sysout image is saved to a temporary file, tempname. - (2) if a specified file, sysout_file_name, is exist, the file is removed. - (3) the temporary file is renamed to the specified file. -*/ - - SETJMP(FILETIMEOUT); + SETJMP(FILETIMEOUT); #ifdef DOS - /* Bloddy 8 char filenames in dos ... /jarl */ - make_old_version(tempname, sysout_file_name); -#else /* DOS */ - sprintf(tempname, "%s-temp", sysout_file_name); + /* Bloddy 8 char filenames in dos ... /jarl */ + make_old_version(tempname, sysout_file_name); +#else /* DOS */ + sprintf(tempname, "%s-temp", sysout_file_name); #endif /* DOS */ - /* Confirm protection of specified file by open/close */ + /* Confirm protection of specified file by open/close */ - TIMEOUT(sysout=open(sysout_file_name, O_WRONLY, 0666)); - if (sysout == -1) - { - /* No file error skip return. */ - if(errno != 2) return(FILECANNOTOPEN); /* No such file error.*/ - } - else TIMEOUT( rval = close(sysout) ); + TIMEOUT(sysout = open(sysout_file_name, O_WRONLY, 0666)); + if (sysout == -1) { + /* No file error skip return. */ + if (errno != 2) return (FILECANNOTOPEN); /* No such file error.*/ + } else + TIMEOUT(rval = close(sysout)); - /* open temp file */ - TIMEOUT(sysout=open(tempname, O_WRONLY | O_CREAT | O_TRUNC, 0666)); - if (sysout == -1) - { - err_mess("open", errno); - return(FILECANNOTOPEN); - } - - - InterfacePage->machinetype = KATANA; + /* open temp file */ + TIMEOUT(sysout = open(tempname, O_WRONLY | O_CREAT | O_TRUNC, 0666)); + if (sysout == -1) { + err_mess("open", errno); + return (FILECANNOTOPEN); + } + InterfacePage->machinetype = KATANA; #ifdef NEW_STORAGE - /* Restore storagefull state */ - if(((*STORAGEFULLSTATE_word) & 0xffff)== SFS_NOTSWITCHABLE) - { - /* This sysout uses only 8 Mbyte lisp space. - It may be able to use this SYSOUT which has more than - 8 Mbyte lisp space. - To enable to expand lisp space, \\STORAGEFULLSTATE - should be NIL. - */ - *STORAGEFULLSTATE_word = NIL; - InterfacePage->storagefullstate=NIL; - } - else - { - /* Otherwise, just restore storagefullstate in IFPAGE */ - InterfacePage->storagefullstate = (*STORAGEFULLSTATE_word) & 0xffff ; - } + /* Restore storagefull state */ + if (((*STORAGEFULLSTATE_word) & 0xffff) == SFS_NOTSWITCHABLE) { + /* This sysout uses only 8 Mbyte lisp space. + It may be able to use this SYSOUT which has more than + 8 Mbyte lisp space. + To enable to expand lisp space, \\STORAGEFULLSTATE + should be NIL. + */ + *STORAGEFULLSTATE_word = NIL; + InterfacePage->storagefullstate = NIL; + } else { + /* Otherwise, just restore storagefullstate in IFPAGE */ + InterfacePage->storagefullstate = (*STORAGEFULLSTATE_word) & 0xffff; + } #endif /* NEW_STORAGE */ - - - /* First, sort fptovp table, trying to get pages contiguous */ +/* First, sort fptovp table, trying to get pages contiguous */ #ifndef BIGVM #ifndef BYTESWAP - /* Byte-swapped machines don't sort the table right. */ - sort_fptovp(fptovp, vmemsize); + /* Byte-swapped machines don't sort the table right. */ + sort_fptovp(fptovp, vmemsize); #endif #endif - /* store vmem to sysoutfile */ + /* store vmem to sysoutfile */ - for (i = 0; i < vmemsize; i++) - { - if (GETPAGEOK(fptovp,i) != 0177777) - { - int oldfptovp = GETFPTOVP(fptovp, i); - int contig_pages = 0; + for (i = 0; i < vmemsize; i++) { + if (GETPAGEOK(fptovp, i) != 0177777) { + int oldfptovp = GETFPTOVP(fptovp, i); + int contig_pages = 0; #ifdef BYTESWAP - int pc; + int pc; #endif /* BYTESWAP */ - register char *base_addr; + register char *base_addr; - TIMEOUT( rval=lseek(sysout, i * BYTESPER_PAGE, 0) ); - if (rval == -1) - { - err_mess("lseek", errno); - return(FILECANNOTSEEK); - } - base_addr = (char *)(Lisp_world + (GETFPTOVP(fptovp,i) * DLWORDSPER_PAGE)); - - /* Now, let's see how many pages we can dump */ - while(GETFPTOVP(fptovp,i) == oldfptovp - && i < vmemsize) { - contig_pages++, oldfptovp++, i++; - } - i--; /* Previous loop always overbumps i */ - DBPRINT(("%4d: writing %d pages from %x\n", - i, contig_pages, base_addr - (char*)Lisp_world)); - -#ifdef BYTESWAP - word_swap_page(base_addr, - contig_pages*BYTESPER_PAGE/4); -#endif /* BYTESWAP */ - - if(contig_pages > maxpages) { - char *ba = base_addr; - int pc = contig_pages; - while (pc > maxpages) { - TIMEOUT(rval = write(sysout, ba, maxpages * BYTESPER_PAGE)); - if (rval == -1) { - err_mess("write", errno); - return(FILECANNOTWRITE); - } - ba += maxpages * BYTESPER_PAGE; - pc -= maxpages; - } - if(pc > 0) - TIMEOUT(rval = write(sysout, ba, pc * BYTESPER_PAGE)); - } else { int oldTT = TIMEOUT_TIME; - /* As we can spend longer than TIMEOUT_TIME doing a big - write, we adjust the timeout temporarily here */ - TIMEOUT_TIME += contig_pages>>3; - TIMEOUT( rval=write(sysout, - base_addr, - contig_pages * BYTESPER_PAGE) ); - TIMEOUT_TIME = oldTT; - } -#ifdef BYTESWAP - word_swap_page(base_addr, - contig_pages*BYTESPER_PAGE/4); -#endif /* BYTESWAP */ - - if (rval == -1) - { - err_mess("write", errno); - return(FILECANNOTWRITE); - } - } + TIMEOUT(rval = lseek(sysout, i * BYTESPER_PAGE, 0)); + if (rval == -1) { + err_mess("lseek", errno); + return (FILECANNOTSEEK); } + base_addr = (char *)(Lisp_world + (GETFPTOVP(fptovp, i) * DLWORDSPER_PAGE)); + /* Now, let's see how many pages we can dump */ + while (GETFPTOVP(fptovp, i) == oldfptovp && i < vmemsize) { + contig_pages++, oldfptovp++, i++; + } + i--; /* Previous loop always overbumps i */ + DBPRINT(("%4d: writing %d pages from %x\n", i, contig_pages, base_addr - (char *)Lisp_world)); +#ifdef BYTESWAP + word_swap_page(base_addr, contig_pages * BYTESPER_PAGE / 4); +#endif /* BYTESWAP */ - /* seek to IFPAGE */ - TIMEOUT(rval=lseek(sysout, (long)FP_IFPAGE, 0)); - if (rval == -1) - { - err_mess("lseek", errno); - return(FILECANNOTSEEK); + if (contig_pages > maxpages) { + char *ba = base_addr; + int pc = contig_pages; + while (pc > maxpages) { + TIMEOUT(rval = write(sysout, ba, maxpages * BYTESPER_PAGE)); + if (rval == -1) { + err_mess("write", errno); + return (FILECANNOTWRITE); + } + ba += maxpages * BYTESPER_PAGE; + pc -= maxpages; + } + if (pc > 0) TIMEOUT(rval = write(sysout, ba, pc * BYTESPER_PAGE)); + } else { + int oldTT = TIMEOUT_TIME; + /* As we can spend longer than TIMEOUT_TIME doing a big + write, we adjust the timeout temporarily here */ + TIMEOUT_TIME += contig_pages >> 3; + TIMEOUT(rval = write(sysout, base_addr, contig_pages * BYTESPER_PAGE)); + TIMEOUT_TIME = oldTT; } #ifdef BYTESWAP - word_swap_page((char *) InterfacePage, - BYTESPER_PAGE/4); + word_swap_page(base_addr, contig_pages * BYTESPER_PAGE / 4); #endif /* BYTESWAP */ - TIMEOUT(rval=write(sysout, (char *) InterfacePage, BYTESPER_PAGE) ); + if (rval == -1) { + err_mess("write", errno); + return (FILECANNOTWRITE); + } + } + } + + /* seek to IFPAGE */ + TIMEOUT(rval = lseek(sysout, (long)FP_IFPAGE, 0)); + if (rval == -1) { + err_mess("lseek", errno); + return (FILECANNOTSEEK); + } #ifdef BYTESWAP - word_swap_page((char *) InterfacePage, - BYTESPER_PAGE/4); + word_swap_page((char *)InterfacePage, BYTESPER_PAGE / 4); #endif /* BYTESWAP */ - if (rval == -1) - { - err_mess("write", errno); - return(FILECANNOTWRITE); - } + TIMEOUT(rval = write(sysout, (char *)InterfacePage, BYTESPER_PAGE)); +#ifdef BYTESWAP + word_swap_page((char *)InterfacePage, BYTESPER_PAGE / 4); +#endif /* BYTESWAP */ + + if (rval == -1) { + err_mess("write", errno); + return (FILECANNOTWRITE); + } #ifdef OS5 - /* Seems to write all pages at close, so timeout - is WAY to short, no matter how big. JDS 960925 */ - rval = close(sysout); -#else - TIMEOUT( rval = close(sysout) ); + /* Seems to write all pages at close, so timeout + is WAY to short, no matter how big. JDS 960925 */ + rval = close(sysout); +#else + TIMEOUT(rval = close(sysout)); #endif /* OS5 */ - if(rval == -1) - { - return(FILECANNOTWRITE); - } + if (rval == -1) { return (FILECANNOTWRITE); } - TIMEOUT(rval = unlink(sysout_file_name)); - if (rval == -1) - { - /* No file error skip return. */ - if(errno != 2) /* No such file error.*/ return(FILECANNOTOPEN); - } + TIMEOUT(rval = unlink(sysout_file_name)); + if (rval == -1) { + /* No file error skip return. */ + if (errno != 2) /* No such file error.*/ + return (FILECANNOTOPEN); + } - TIMEOUT( rval=rename(tempname, sysout_file_name) ); - if( rval== -1) - { - fprintf(stderr,"sysout is saved to temp file, %s.", tempname); - return(FILECANNOTWRITE); - } + TIMEOUT(rval = rename(tempname, sysout_file_name)); + if (rval == -1) { + fprintf(stderr, "sysout is saved to temp file, %s.", tempname); + return (FILECANNOTWRITE); + } - /* restore cursor image to screen */ +/* restore cursor image to screen */ #ifdef SUNDISPLAY #ifdef OLD_CURSOR - win_setcursor( LispWindowFd, &CurrentCursor); + win_setcursor(LispWindowFd, &CurrentCursor); #else - ScreenLocked=T; - /*EmCursorBitMap68K = bmptr ;*/ - taking_mouse_up(*EmCursorX68K,*EmCursorY68K); - ScreenLocked=NIL; + ScreenLocked = T; + /*EmCursorBitMap68K = bmptr ;*/ + taking_mouse_up(*EmCursorX68K, *EmCursorY68K); + ScreenLocked = NIL; #endif /* OLD_CURSOR */ #elif DOS - /* Must also put the mouse back. */ - (currentdsp->mouse_vissible)( IOPage68K->dlmousex, IOPage68K->dlmousey ); - currentdsp->device.locked--; + /* Must also put the mouse back. */ + (currentdsp->mouse_vissible)(IOPage68K->dlmousex, IOPage68K->dlmousey); + currentdsp->device.locked--; #endif /* SUNDISPLAY */ - - /*printf("vmem is saved completely.\n");*/ - return(COMPLETESYSOUT); - } - - - + /*printf("vmem is saved completely.\n");*/ + return (COMPLETESYSOUT); +} /************************************************************************/ /* */ @@ -642,30 +577,23 @@ extern int UnixPID; /* Make sure that we kill off any Unix subprocesses before we go away */ -void lisp_finish() - { - char d[4]; +void lisp_finish() { + char d[4]; - DBPRINT(("finish lisp_finish\n")); + DBPRINT(("finish lisp_finish\n")); - if( please_fork ) - { /* if lde runs with -NF(No fork), */ - /* following 5 lines don't work well. */ - d[0] = 'E'; - d[3] = 1; - /* These only happen if the fork really succeeded: - /* if (UnixPipeOut >= 0) write(UnixPipeOut, d, 4); */ - /* if (UnixPipeIn >= 0 read(UnixPipeIn, d, 4);*/ /* Make sure it's finished */ - /* if (UnixPID >= 0) kill(UnixPID, SIGKILL);*/ /* Then kill fork_Unix itself */ - } - device_before_exit(); -#ifdef DOS - exit_host_filesystem(); -#endif /* DOS */ - exit(1); - + if (please_fork) { /* if lde runs with -NF(No fork), */ + /* following 5 lines don't work well. */ + d[0] = 'E'; + d[3] = 1; + /* These only happen if the fork really succeeded: + /* if (UnixPipeOut >= 0) write(UnixPipeOut, d, 4); */ + /* if (UnixPipeIn >= 0 read(UnixPipeIn, d, 4);*/ /* Make sure it's finished */ + /* if (UnixPID >= 0) kill(UnixPID, SIGKILL);*/ /* Then kill fork_Unix itself */ } - - - - + device_before_exit(); +#ifdef DOS + exit_host_filesystem(); +#endif /* DOS */ + exit(1); +} diff --git a/src/xbbt.c b/src/xbbt.c old mode 100755 new mode 100644 index 888c9d0..1f816d6 --- a/src/xbbt.c +++ b/src/xbbt.c @@ -1,8 +1,6 @@ /* $Id: xbbt.c,v 1.2 1999/01/03 02:07:46 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: xbbt.c,v 1.2 1999/01/03 02:07:46 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -18,8 +16,6 @@ static char *id = "$Id: xbbt.c,v 1.2 1999/01/03 02:07:46 sybalsky Exp $ Copyrigh #include "version.h" - - #include #include @@ -31,8 +27,6 @@ static char *id = "$Id: xbbt.c,v 1.2 1999/01/03 02:07:46 sybalsky Exp $ Copyrigh extern DspInterface currentdsp; - - /************************************************************************/ /* */ /* c l i p p i n g _ X b i t b l t */ @@ -43,69 +37,52 @@ extern DspInterface currentdsp; /* dummy is the placeholder for the bitmap to be blitted */ /* */ /************************************************************************/ -unsigned long -clipping_Xbitblt(dsp, dummy, x, y, w, h) - DspInterface dsp; - int dummy, x, y, w, h; -{ +unsigned long clipping_Xbitblt(dsp, dummy, x, y, w, h) DspInterface dsp; +int dummy, x, y, w, h; +{ int temp_x, temp_y, LowerRightX, LowerRightY; LowerRightX = dsp->Vissible.x + dsp->Vissible.width; LowerRightY = dsp->Vissible.y + dsp->Vissible.height; - temp_x = x + w - 1; - temp_y = y + h - 1; + temp_x = x + w - 1; + temp_y = y + h - 1; - if ( (temp_x < dsp->Vissible.x) - || (x > LowerRightX) - || (temp_y < dsp->Vissible.y) - || (y > LowerRightY)) return(0); - - if ( ( x >= dsp->Vissible.x ) - && ( temp_x <= LowerRightX ) - && ( y >= dsp->Vissible.y ) - && ( temp_y <= LowerRightY ) ) - { - XLOCK; - XPutImage( dsp->display_id, - dsp->DisplayWindow, - dsp->Copy_GC, - &dsp->ScreenBitmap, - x , y, x - dsp->Vissible.x, - y - dsp->Vissible.y, w, h ); - XFlush(dsp->display_id); - XUNLOCK; - return(0); - } - - if ( x < dsp->Vissible.x ) - { - w -= dsp->Vissible.x - x; - x = dsp->Vissible.x; - } - - if ( temp_x > LowerRightX ) w -= temp_x - LowerRightX; - - if ( y < dsp->Vissible.y ) - { - h -= dsp->Vissible.y - y; - y = dsp->Vissible.y; - } - - if ( temp_y > LowerRightY ) h -= temp_y - LowerRightY; - - if ((w>0) && (h>0)) - { - XLOCK; - XPutImage( dsp->display_id, - dsp->DisplayWindow, - dsp->Copy_GC, - &dsp->ScreenBitmap, - x , y, x - dsp->Vissible.x, - y - dsp->Vissible.y, w, h ); - XFlush(dsp->display_id); - XUNLOCK; - } - return(0); + if ((temp_x < dsp->Vissible.x) || (x > LowerRightX) || (temp_y < dsp->Vissible.y) || + (y > LowerRightY)) + return (0); -} /* end clipping_Xbitblt */ + if ((x >= dsp->Vissible.x) && (temp_x <= LowerRightX) && (y >= dsp->Vissible.y) && + (temp_y <= LowerRightY)) { + XLOCK; + XPutImage(dsp->display_id, dsp->DisplayWindow, dsp->Copy_GC, &dsp->ScreenBitmap, x, y, + x - dsp->Vissible.x, y - dsp->Vissible.y, w, h); + XFlush(dsp->display_id); + XUNLOCK; + return (0); + } + + if (x < dsp->Vissible.x) { + w -= dsp->Vissible.x - x; + x = dsp->Vissible.x; + } + + if (temp_x > LowerRightX) w -= temp_x - LowerRightX; + + if (y < dsp->Vissible.y) { + h -= dsp->Vissible.y - y; + y = dsp->Vissible.y; + } + + if (temp_y > LowerRightY) h -= temp_y - LowerRightY; + + if ((w > 0) && (h > 0)) { + XLOCK; + XPutImage(dsp->display_id, dsp->DisplayWindow, dsp->Copy_GC, &dsp->ScreenBitmap, x, y, + x - dsp->Vissible.x, y - dsp->Vissible.y, w, h); + XFlush(dsp->display_id); + XUNLOCK; + } + return (0); + +} /* end clipping_Xbitblt */ diff --git a/src/xc.c b/src/xc.c old mode 100755 new mode 100644 index b1f2425..50c0f19 --- a/src/xc.c +++ b/src/xc.c @@ -1,9 +1,6 @@ /* $Id: xc.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: xc.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue"; - - - /************************************************************************/ /* */ /* (C) Copyright 1989-95 Venue. All Rights Reserved. */ @@ -18,7 +15,6 @@ static char *id = "$Id: xc.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright #include "version.h" - /************************************************************************/ /* */ /* M A I N D I S P A T C H L O O P */ @@ -36,15 +32,14 @@ static char *id = "$Id: xc.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright #include #ifdef DOS -#include /* Defines "#pragma interrupt" */ -#include /* _XSTACK struct definition */ -#include /* Defines REGS & other structs */ -#else /* DOS */ +#include /* Defines "#pragma interrupt" */ +#include /* _XSTACK struct definition */ +#include /* Defines REGS & other structs */ +#else /* DOS */ #include #endif /* DOS */ #include - #include "lispemul.h" #include "emlglob.h" #include "address.h" @@ -61,7 +56,7 @@ static char *id = "$Id: xc.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright #include "arith.h" #include "stream.h" -#include "tos1defs.h" +#include "tos1defs.h" #include "tosret.h" #include "tosfns.h" #include "inlineC.h" @@ -85,27 +80,24 @@ extern MouseInterface currentmouse; typedef struct conspage ConsPage; typedef ByteCode *InstPtr; - #ifdef GCC386 - register InstPtr pccache asm("si"); - register LispPTR *cspcache asm("di"); - register LispPTR tscache asm("bx"); +register InstPtr pccache asm("si"); +register LispPTR *cspcache asm("di"); +register LispPTR tscache asm("bx"); #include "inlnPS2.h" #elif (DOS && OPDISP) #include "inlndos.h" - register InstPtr pccache asm("si"); - register LispPTR *cspcache asm("di"); - register LispPTR tscache asm("bx"); +register InstPtr pccache asm("si"); +register LispPTR *cspcache asm("di"); +register LispPTR tscache asm("bx"); #endif /* DOS */ - - /* Used to just be ifdef sparc, but want to be able to turn */ - /* off the inline code even on sparc machines. */ +/* Used to just be ifdef sparc, but want to be able to turn */ +/* off the inline code even on sparc machines. */ #ifdef SPARCDISP #include "inlnSPARC.h" #endif /* SPARCDISP */ - #ifdef I386 #include "inln386i.h" #endif @@ -114,29 +106,29 @@ typedef ByteCode *InstPtr; #include "profile.h" /* trick now is that pccache points one ahead... */ -#define PCMAC (pccache-1) -#define PCMACL pccache -#define CSTKPTR ((LispPTR *) cspcache) -#define PVAR ((LispPTR *) PVar) -#define IVAR ((LispPTR *) IVar) -#define BCE_CURRENTFX ((struct frameex2 *)((DLword *) PVAR - FRAMESIZE)) +#define PCMAC (pccache - 1) +#define PCMACL pccache +#define CSTKPTR ((LispPTR *)cspcache) +#define PVAR ((LispPTR *)PVar) +#define IVAR ((LispPTR *)IVar) +#define BCE_CURRENTFX ((struct frameex2 *)((DLword *)PVAR - FRAMESIZE)) -#define CSTKPTRL (cspcache) -#define PVARL PVar -#define IVARL IVar +#define CSTKPTRL (cspcache) +#define PVARL PVar +#define IVARL IVar extern DLword *createcell68k(unsigned int type); #ifdef DOS -extern unsigned char inchar; +extern unsigned char inchar; extern unsigned short kn; #endif #ifdef XWINDOW -extern int Event_Req; /* != 0 when it's time to check X events - on machines that don't get them reliably - (e.g. Suns running OpenWindows) */ -#endif /* XWINDOW */ +extern int Event_Req; /* != 0 when it's time to check X events + on machines that don't get them reliably + (e.g. Suns running OpenWindows) */ +#endif /* XWINDOW */ #ifndef ISC #ifndef DOS @@ -146,43 +138,36 @@ InstPtr optable[512]; #endif /* DOS */ #endif /* ISC */ - - #ifdef PCTRACE - /* For keeping a trace table (ring buffer) of 100 last PCs */ -int pc_table[100], /* The PC */ - op_table[100]; /* The opcode at that PC */ -LispPTR fn_table[100]; /* The code block the PC is in (Lisp ptr) */ -int pccounter = 0; /* ring-buffer counter */ -#endif /* PCTRACE */ +/* For keeping a trace table (ring buffer) of 100 last PCs */ +int pc_table[100], /* The PC */ + op_table[100]; /* The opcode at that PC */ +LispPTR fn_table[100]; /* The code block the PC is in (Lisp ptr) */ +int pccounter = 0; /* ring-buffer counter */ +#endif /* PCTRACE */ int dbgflag = 0; -int extended_frame; /*indicates if soft stack overflow */ +int extended_frame; /*indicates if soft stack overflow */ - -int n_mask_array[16] = { 1, 3, 7, 0xf, - 0x1f, 0x3f, 0x7f, 0xff, - 0x1ff, 0x3ff, 0x7ff, 0xfff, - 0x1fff, 0x3fff, 0x7fff, 0xffff}; +int n_mask_array[16] = {1, 3, 7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, + 0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff}; extern int TIMER_INTERVAL; - -void dispatch(void) -{ - register InstPtr pccache; +void dispatch(void) { + register InstPtr pccache; #ifdef I386 - InstPtr *table; + InstPtr *table; #elif DOS - InstPtr * table; + InstPtr *table; #else #if defined(OPDISP) || defined(SPARCDISP) #ifdef ISC InstPtr *table; #else -register InstPtr *table; + register InstPtr *table; #endif #endif /* OPDISP */ #endif /* I386 */ @@ -190,853 +175,1258 @@ register InstPtr *table; #ifdef ISC #elif (DOS && OPDISP) #else - register LispPTR *cspcache; - register LispPTR tscache; + register LispPTR *cspcache; + register LispPTR tscache; #endif /* ISC */ #ifdef sparc - register struct state *stateptrcache = MState; + register struct state *stateptrcache = MState; #undef MState #define MState stateptrcache #endif #if (defined(I386) || defined(ISC)) - int SaveD6; + int SaveD6; #else #ifdef OPDISP #ifndef DOS - register int SaveD6; + register int SaveD6; #endif #endif #endif #ifdef UNSAFE - register int Save_D5_shift_amount; + register int Save_D5_shift_amount; #endif -/* OP_FN_COMMON arguments */ + /* OP_FN_COMMON arguments */ - DefCell *fn_defcell; - LispPTR fn_atom_index; - int fn_opcode_size; - int fn_num_args; - int fn_apply; - LispPTR fn_loc_defcell; + DefCell *fn_defcell; + LispPTR fn_atom_index; + int fn_opcode_size; + int fn_num_args; + int fn_apply; + LispPTR fn_loc_defcell; - RET; - CLR_IRQ; + RET; + CLR_IRQ; #ifndef ISC #ifndef DOS #ifdef OPDISP - table = optable; + table = optable; #endif #endif #endif /* ISC */ - #ifdef SPARCDISP - table = (InstPtr *) compute_dispatch_table(); + table = (InstPtr *)compute_dispatch_table(); #endif #ifdef UNSAFE - Save_D5_shift_amount = 15; + Save_D5_shift_amount = 15; #endif #ifdef I386 - goto setup_table; + goto setup_table; #else #ifdef OPDISP #ifdef ISC - asm(" leal optable,%%eax \n\ - movl %%eax,%0" : "=g" (table) : "0" (table)); - goto nextopcode; + asm(" leal optable,%%eax \n\ + movl %%eax,%0" + : "=g"(table) + : "0"(table)); + goto nextopcode; #elif (DOS && OPDISP) - asm(" lea eax,optable \n\ - mov %0,%%eax" : "=g" (table) : "0" (table)); - asm volatile("fldcw WORD PTR CODE32:FP_noint"); /* Turn off FP interrupts */ - goto nextopcode; + asm(" lea eax,optable \n\ + mov %0,%%eax" + : "=g"(table) + : "0"(table)); + asm volatile("fldcw WORD PTR CODE32:FP_noint"); /* Turn off FP interrupts */ + goto nextopcode; #else - SaveD6 = 0; - goto setup_table; + SaveD6 = 0; + goto setup_table; #endif /* ISC */ #else - goto nextopcode; + goto nextopcode; #endif /* OPDISP */ #endif /* I386 */ + /* INLINE OPCODE FAIL ENTRY POINTS, CALL EXTERNAL ROUTINES HERE */ + OPCODEFAIL; + /* OPCODE FAIL ENTRY POINTS, CALL UFNS HERE */ + UFN_CALLS; - -/* INLINE OPCODE FAIL ENTRY POINTS, CALL EXTERNAL ROUTINES HERE */ - OPCODEFAIL; -/* OPCODE FAIL ENTRY POINTS, CALL UFNS HERE */ - - UFN_CALLS; - -op_ufn: -{ +op_ufn : { #ifdef ISC - UFN *entry68k; + UFN *entry68k; #else - register UFN *entry68k; + register UFN *entry68k; #endif - entry68k = (UFN *)GetUFNEntry(Get_BYTE_PCMAC0); - fn_num_args = entry68k->arg_num; - fn_opcode_size = entry68k->byte_num+1; - fn_atom_index = entry68k->atom_name; - fn_defcell = (DefCell *) GetDEFCELL68k(fn_atom_index); - fn_apply = 2 + entry68k->byte_num; /* code for UFN entry */ - goto op_fn_common; + entry68k = (UFN *)GetUFNEntry(Get_BYTE_PCMAC0); + fn_num_args = entry68k->arg_num; + fn_opcode_size = entry68k->byte_num + 1; + fn_atom_index = entry68k->atom_name; + fn_defcell = (DefCell *)GetDEFCELL68k(fn_atom_index); + fn_apply = 2 + entry68k->byte_num; /* code for UFN entry */ + goto op_fn_common; }; -/* FUNCTION CALL TAIL ROUTINE */ + /* FUNCTION CALL TAIL ROUTINE */ - OP_FN_COMMON; + OP_FN_COMMON; /* DISPATCH "LOOP" */ -nextopcode : +nextopcode: #ifdef MYOPTRACE - if ((struct fnhead *)Addr68k_from_LADDR(0x2ed600) == FuncObj) - { - quick_stack_check(); + if ((struct fnhead *)Addr68k_from_LADDR(0x2ed600) == FuncObj) { + quick_stack_check(); #endif /* MYOPTRACE */ - OPTPRINT(("Dispatch, PC = 0x%x, op = 0%o. TOS = 0x%x.\n", (int)PCMAC, Get_BYTE_PCMAC0, TOPOFSTACK)); + OPTPRINT( + ("Dispatch, PC = 0x%x, op = 0%o. TOS = 0x%x.\n", (int)PCMAC, Get_BYTE_PCMAC0, TOPOFSTACK)); #ifdef MYOPTRACE - } + } #endif /* MYOPTRACE */ - #ifdef PCTRACE /* Tracing PC/Function/Opcode in a ring buffer */ pc_table[pccounter] = (int)PCMAC - (int)FuncObj; - fn_table[pccounter] = (LispPTR) LADDR_from_68k(FuncObj); + fn_table[pccounter] = (LispPTR)LADDR_from_68k(FuncObj); op_table[pccounter] = Get_BYTE_PCMAC0; if (99 == pccounter++) pccounter = 0; #endif /* PCTRACE */ -/* quick_stack_check();*/ /* JDS 2/12/98 */ + /* quick_stack_check();*/ /* JDS 2/12/98 */ - -switch (Get_BYTE_PCMAC0) { - - case 000 : CASE000: { goto op_ufn; } /* unused */ - case 001 : CASE001: OPCAR; - case 002 : CASE002: OPCDR; - case 003 : CASE003: LISTP; - case 004 : CASE004: NTYPEX; - case 005 : CASE005: TYPEP(Get_BYTE_PCMAC1); - case 056 : CASE056: - case 006 : CASE006: DTEST(Get_AtomNo_PCMAC1); - case 007 : CASE007: UNWIND(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + switch (Get_BYTE_PCMAC0) { + case 000: + CASE000 : { goto op_ufn; } /* unused */ + case 001: + CASE001: + OPCAR; + case 002: + CASE002: + OPCDR; + case 003: + CASE003: + LISTP; + case 004: + CASE004: + NTYPEX; + case 005: + CASE005: + TYPEP(Get_BYTE_PCMAC1); + case 056: + CASE056: + case 006: + CASE006: + DTEST(Get_AtomNo_PCMAC1); + case 007: + CASE007: + UNWIND(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); #ifdef NATIVETRAN - ret_to_fn0: asm("_ret_to_fn0:"); - asm(" .globl _ret_to_fn0"); - RET_FROM_NATIVE; + ret_to_fn0: + asm("_ret_to_fn0:"); + asm(" .globl _ret_to_fn0"); + RET_FROM_NATIVE; #endif - case 010 : CASE010: FN0; + case 010: + CASE010: + FN0; #ifdef NATIVETRAN - ret_to_fn1: asm("_ret_to_fn1:"); - asm(" .globl _ret_to_fn1"); - RET_FROM_NATIVE; + ret_to_fn1: + asm("_ret_to_fn1:"); + asm(" .globl _ret_to_fn1"); + RET_FROM_NATIVE; #endif - case 011 : CASE011: FN1; + case 011: + CASE011: + FN1; #ifdef NATIVETRAN - ret_to_fn2: asm("_ret_to_fn2:"); - asm(" .globl _ret_to_fn2"); - RET_FROM_NATIVE; + ret_to_fn2: + asm("_ret_to_fn2:"); + asm(" .globl _ret_to_fn2"); + RET_FROM_NATIVE; #endif - case 012 : CASE012: FN2; + case 012: + CASE012: + FN2; #ifdef NATIVETRAN - ret_to_fn3: asm("_ret_to_fn3:"); - asm(" .globl _ret_to_fn3"); - RET_FROM_NATIVE; + ret_to_fn3: + asm("_ret_to_fn3:"); + asm(" .globl _ret_to_fn3"); + RET_FROM_NATIVE; #endif - case 013 : CASE013: FN3; + case 013: + CASE013: + FN3; #ifdef NATIVETRAN - ret_to_fn4: asm("_ret_to_fn4:"); - asm(" .globl _ret_to_fn4"); - RET_FROM_NATIVE; + ret_to_fn4: + asm("_ret_to_fn4:"); + asm(" .globl _ret_to_fn4"); + RET_FROM_NATIVE; #endif - case 014 : CASE014: FN4; + case 014: + CASE014: + FN4; #ifdef NATIVETRAN - ret_to_fnx: asm("_ret_to_fnx:"); - asm(" .globl _ret_to_fnx"); - RET_FROM_NATIVE; + ret_to_fnx: + asm("_ret_to_fnx:"); + asm(" .globl _ret_to_fnx"); + RET_FROM_NATIVE; #endif - case 015 : CASE015: FNX; + case 015: + CASE015: + FNX; #ifdef NATIVETRAN - ret_to_apply: asm("_ret_to_apply:"); - asm(" .globl _ret_to_apply"); - RET_FROM_NATIVE; + ret_to_apply: + asm("_ret_to_apply:"); + asm(" .globl _ret_to_apply"); + RET_FROM_NATIVE; #endif - case 016 : CASE016: APPLY; + case 016: + CASE016: + APPLY; - case 017 : CASE017: CHECKAPPLY; - case 020 : CASE020: RETURN; + case 017: + CASE017: + CHECKAPPLY; + case 020: + CASE020: + RETURN; - case 021 : CASE021: BIND; - case 022 : CASE022: UNBIND; - case 023 : CASE023: DUNBIND; - case 024 : CASE024: RPLPTR(Get_BYTE_PCMAC1); - case 025 : CASE025: GCREF(Get_BYTE_PCMAC1); - case 026 : CASE026: ASSOC; - case 027 : CASE027: - GVAR_(Get_AtomNo_PCMAC1); - case 030 : CASE030: RPLACA; - case 031 : CASE031: RPLACD; - case 032 : CASE032: CONS; - case 033 : CASE033: CLASSOC; - case 034 : CASE034: FMEMB; - case 035 : CASE035: CLFMEMB; - case 036 : CASE036: FINDKEY(Get_BYTE_PCMAC1); - case 037 : CASE037: CREATECELL; - case 040 : CASE040: BIN; - case 041 : CASE041: { goto op_ufn; } /* BOUT */ - case 042 : CASE042: { goto op_ufn; } /* POPDISP - prolog only */ - case 043 : CASE043: RESTLIST(Get_BYTE_PCMAC1); - case 044 : CASE044: MISCN(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); - case 045 : CASE045: { goto op_ufn; } /* unused */ - case 046 : CASE046: RPLCONS; - case 047 : CASE047: LISTGET; - case 050 : CASE050: { goto op_ufn; } /* unused */ - case 051 : CASE051: { goto op_ufn; } /* unused */ - case 052 : CASE052: { goto op_ufn; } /* unused */ - case 053 : CASE053: { goto op_ufn; } /* unused */ - case 054 : CASE054: EVAL; + case 021: + CASE021: + BIND; + case 022: + CASE022: + UNBIND; + case 023: + CASE023: + DUNBIND; + case 024: + CASE024: + RPLPTR(Get_BYTE_PCMAC1); + case 025: + CASE025: + GCREF(Get_BYTE_PCMAC1); + case 026: + CASE026: + ASSOC; + case 027: + CASE027: + GVAR_(Get_AtomNo_PCMAC1); + case 030: + CASE030: + RPLACA; + case 031: + CASE031: + RPLACD; + case 032: + CASE032: + CONS; + case 033: + CASE033: + CLASSOC; + case 034: + CASE034: + FMEMB; + case 035: + CASE035: + CLFMEMB; + case 036: + CASE036: + FINDKEY(Get_BYTE_PCMAC1); + case 037: + CASE037: + CREATECELL; + case 040: + CASE040: + BIN; + case 041: + CASE041 : { goto op_ufn; } /* BOUT */ + case 042: + CASE042 : { goto op_ufn; } /* POPDISP - prolog only */ + case 043: + CASE043: + RESTLIST(Get_BYTE_PCMAC1); + case 044: + CASE044: + MISCN(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + case 045: + CASE045 : { goto op_ufn; } /* unused */ + case 046: + CASE046: + RPLCONS; + case 047: + CASE047: + LISTGET; + case 050: + CASE050 : { goto op_ufn; } /* unused */ + case 051: + CASE051 : { goto op_ufn; } /* unused */ + case 052: + CASE052 : { goto op_ufn; } /* unused */ + case 053: + CASE053 : { goto op_ufn; } /* unused */ + case 054: + CASE054: + EVAL; #ifdef NATIVETRAN - ret_to_envcall: asm("_ret_to_envcall:"); - asm(" .globl _ret_to_envcall"); - RET_FROM_NATIVE; + ret_to_envcall: + asm("_ret_to_envcall:"); + asm(" .globl _ret_to_envcall"); + RET_FROM_NATIVE; #endif - case 055 : CASE055: ENVCALL; + case 055: + CASE055: + ENVCALL; -/* case 056 : CASE056: @ 006 */ - case 057 : CASE057: STKSCAN; - case 060 : CASE060: { goto op_ufn; } /* BUSBLT - DLion only */ - case 061 : CASE061: { goto op_ufn; } /* MISC8 - no longer used */ - case 062 : CASE062: UBFLOAT3(Get_BYTE_PCMAC1); - case 063 : CASE063: TYPEMASK(Get_BYTE_PCMAC1); - case 064 : CASE064: { goto op_ufn; } /* rdprologptr */ - case 065 : CASE065: { goto op_ufn; } /* rdprologtag */ - case 066 : CASE066: { goto op_ufn; } /* writeptr&tag */ - case 067 : CASE067: { goto op_ufn; } /* writeptr&0tag */ - case 070 : CASE070: MISC7(Get_BYTE_PCMAC1); /* misc7 (pseudocolor, fbitmapbit) */ - case 071 : CASE071: { goto op_ufn; } /* dovemisc - dove only */ - case 072 : CASE072: EQLOP; - case 073 : CASE073: DRAWLINE; - case 074 : CASE074: STOREN(Get_BYTE_PCMAC1); - case 075 : CASE075: COPYN(Get_BYTE_PCMAC1); - case 076 : CASE076: { goto op_ufn; } /* RAID */ - case 077 : CASE077: { goto op_ufn; } /* \RETURN */ + /* case 056 : CASE056: @ 006 */ + case 057: + CASE057: + STKSCAN; + case 060: + CASE060 : { goto op_ufn; } /* BUSBLT - DLion only */ + case 061: + CASE061 : { goto op_ufn; } /* MISC8 - no longer used */ + case 062: + CASE062: + UBFLOAT3(Get_BYTE_PCMAC1); + case 063: + CASE063: + TYPEMASK(Get_BYTE_PCMAC1); + case 064: + CASE064 : { goto op_ufn; } /* rdprologptr */ + case 065: + CASE065 : { goto op_ufn; } /* rdprologtag */ + case 066: + CASE066 : { goto op_ufn; } /* writeptr&tag */ + case 067: + CASE067 : { goto op_ufn; } /* writeptr&0tag */ + case 070: + CASE070: + MISC7(Get_BYTE_PCMAC1); /* misc7 (pseudocolor, fbitmapbit) */ + case 071: + CASE071 : { goto op_ufn; } /* dovemisc - dove only */ + case 072: + CASE072: + EQLOP; + case 073: + CASE073: + DRAWLINE; + case 074: + CASE074: + STOREN(Get_BYTE_PCMAC1); + case 075: + CASE075: + COPYN(Get_BYTE_PCMAC1); + case 076: + CASE076 : { goto op_ufn; } /* RAID */ + case 077: + CASE077 : { goto op_ufn; } /* \RETURN */ + case 0100: + CASE100: + IVARMACRO(0); + case 0101: + CASE101: + IVARMACRO(1); + case 0102: + CASE102: + IVARMACRO(2); + case 0103: + CASE103: + IVARMACRO(3); + case 0104: + CASE104: + IVARMACRO(4); + case 0105: + CASE105: + IVARMACRO(5); + case 0106: + CASE106: + IVARMACRO(6); + case 0107: + CASE107: + IVARX(Get_BYTE_PCMAC1); + case 0110: + CASE110: + PVARMACRO(0); + case 0111: + CASE111: + PVARMACRO(1); + case 0112: + CASE112: + PVARMACRO(2); + case 0113: + CASE113: + PVARMACRO(3); + case 0114: + CASE114: + PVARMACRO(4); + case 0115: + CASE115: + PVARMACRO(5); + case 0116: + CASE116: + PVARMACRO(6); - case 0100 : CASE100: IVARMACRO (0); - case 0101 : CASE101: IVARMACRO (1); - case 0102 : CASE102: IVARMACRO (2); - case 0103 : CASE103: IVARMACRO (3); - case 0104 : CASE104: IVARMACRO (4); - case 0105 : CASE105: IVARMACRO (5); - case 0106 : CASE106: IVARMACRO (6); - case 0107 : CASE107: IVARX (Get_BYTE_PCMAC1); + case 0117: + CASE117: + PVARX(Get_BYTE_PCMAC1); - case 0110 : CASE110: PVARMACRO (0); - case 0111 : CASE111: PVARMACRO (1); - case 0112 : CASE112: PVARMACRO (2); - case 0113 : CASE113: PVARMACRO (3); - case 0114 : CASE114: PVARMACRO (4); - case 0115 : CASE115: PVARMACRO (5); - case 0116 : CASE116: PVARMACRO (6); + case 0120: + CASE120: + FVAR(0); + case 0121: + CASE121: + FVAR(2); + case 0122: + CASE122: + FVAR(4); + case 0123: + CASE123: + FVAR(6); + case 0124: + CASE124: + FVAR(8); + case 0125: + CASE125: + FVAR(10); + case 0126: + CASE126: + FVAR(12); + case 0127: + CASE127: + FVARX(Get_BYTE_PCMAC1); - case 0117 : CASE117: PVARX(Get_BYTE_PCMAC1); + case 0130: + CASE130: + PVARSETMACRO(0); + case 0131: + CASE131: + PVARSETMACRO(1); + case 0132: + CASE132: + PVARSETMACRO(2); + case 0133: + CASE133: + PVARSETMACRO(3); + case 0134: + CASE134: + PVARSETMACRO(4); + case 0135: + CASE135: + PVARSETMACRO(5); + case 0136: + CASE136: + PVARSETMACRO(6); - case 0120 : CASE120: FVAR(0); - case 0121 : CASE121: FVAR(2); - case 0122 : CASE122: FVAR(4); - case 0123 : CASE123: FVAR(6); - case 0124 : CASE124: FVAR(8); - case 0125 : CASE125: FVAR(10); - case 0126 : CASE126: FVAR(12); - case 0127 : CASE127: FVARX(Get_BYTE_PCMAC1); - - case 0130 : CASE130: PVARSETMACRO (0); - case 0131 : CASE131: PVARSETMACRO (1); - case 0132 : CASE132: PVARSETMACRO (2); - case 0133 : CASE133: PVARSETMACRO (3); - case 0134 : CASE134: PVARSETMACRO (4); - case 0135 : CASE135: PVARSETMACRO (5); - case 0136 : CASE136: PVARSETMACRO (6); + case 0137: + CASE137: + PVARX_(Get_BYTE_PCMAC1); - case 0137 : CASE137: PVARX_(Get_BYTE_PCMAC1); - - case 0140 : CASE140: GVAR(Get_AtomNo_PCMAC1); - case 0141 : CASE141: ARG0; - case 0142 : CASE142: IVARX_(Get_BYTE_PCMAC1); - case 0143 : CASE143: FVARX_(Get_BYTE_PCMAC1); - case 0144 : CASE144: COPY; - case 0145 : CASE145: MYARGCOUNT; - case 0146 : CASE146: MYALINK; + case 0140: + CASE140: + GVAR(Get_AtomNo_PCMAC1); + case 0141: + CASE141: + ARG0; + case 0142: + CASE142: + IVARX_(Get_BYTE_PCMAC1); + case 0143: + CASE143: + FVARX_(Get_BYTE_PCMAC1); + case 0144: + CASE144: + COPY; + case 0145: + CASE145: + MYARGCOUNT; + case 0146: + CASE146: + MYALINK; -/******** Aconst ********/ - case 0147 : CASE147: { PUSH(Get_AtomNo_PCMAC1); nextop_atom;} - case 0150 : CASE150: { PUSHATOM(NIL_PTR ); } - case 0151 : CASE151: { PUSHATOM(ATOM_T ); } - case 0152 : CASE152: { PUSHATOM(S_POSITIVE ); } /* '0 */ - case 0153 : CASE153: { PUSHATOM(0xE0001 ); } /* '1 */ + /******** Aconst ********/ + case 0147: + CASE147 : { + PUSH(Get_AtomNo_PCMAC1); + nextop_atom; + } + case 0150: + CASE150 : { PUSHATOM(NIL_PTR); } + case 0151: + CASE151 : { PUSHATOM(ATOM_T); } + case 0152: + CASE152 : { PUSHATOM(S_POSITIVE); } /* '0 */ + case 0153: + CASE153 : { PUSHATOM(0xE0001); } /* '1 */ -/********* SIC ********/ - case 0154 : CASE154: { - PUSH(S_POSITIVE | Get_BYTE_PCMAC1); - nextop2; - } + /********* SIC ********/ + case 0154: + CASE154 : { + PUSH(S_POSITIVE | Get_BYTE_PCMAC1); + nextop2; + } -/********* SNIC ********/ - case 0155 : CASE155: { - PUSH(S_NEGATIVE | 0xff00 | Get_BYTE_PCMAC1); - nextop2; - } + /********* SNIC ********/ + case 0155: + CASE155 : { + PUSH(S_NEGATIVE | 0xff00 | Get_BYTE_PCMAC1); + nextop2; + } -/********* SICX ********/ - case 0156 : CASE156:{ - PUSH(S_POSITIVE | Get_DLword_PCMAC1); - nextop3; - } + /********* SICX ********/ + case 0156: + CASE156 : { + PUSH(S_POSITIVE | Get_DLword_PCMAC1); + nextop3; + } -/********* GCONST ********/ - case 0157 : CASE157: { - PUSH(Get_Pointer_PCMAC1); - nextop_ptr; - } - - case 0160 : CASE160: { goto op_ufn; } /* unused */ - case 0161 : CASE161: { goto op_ufn; } /* readflags */ - case 0162 : CASE162: { goto op_ufn; } /* readrp */ - case 0163 : CASE163: { goto op_ufn; } /* writemap */ - case 0164 : CASE164: { goto op_ufn; } /* readprinterport */ - case 0165 : CASE165: { goto op_ufn; } /* writeprinterport */ + /********* GCONST ********/ + case 0157: + CASE157 : { + PUSH(Get_Pointer_PCMAC1); + nextop_ptr; + } - case 0166 : CASE166: PILOTBITBLT; - case 0167 : CASE167: RCLK; - case 0170 : CASE170: { goto op_ufn; } /* MISC1, dorado only */ - case 0171 : CASE171: { goto op_ufn; } /* MISC2, dorado only */ - case 0172 : CASE172: RECLAIMCELL; - case 0173 : CASE173: GCSCAN1; - case 0174 : CASE174: GCSCAN2; - case 0175 : CASE175: { EXT; OP_subrcall(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); RET; NATIVE_NEXTOP0; }; - case 0176 : CASE176: { CONTEXTSWITCH; } - case 0177 : CASE177: { goto op_ufn; } /* RETCALL */ + case 0160: + CASE160 : { goto op_ufn; } /* unused */ + case 0161: + CASE161 : { goto op_ufn; } /* readflags */ + case 0162: + CASE162 : { goto op_ufn; } /* readrp */ + case 0163: + CASE163 : { goto op_ufn; } /* writemap */ + case 0164: + CASE164 : { goto op_ufn; } /* readprinterport */ + case 0165: + CASE165 : { goto op_ufn; } /* writeprinterport */ -/* JUMP */ + case 0166: + CASE166: + PILOTBITBLT; + case 0167: + CASE167: + RCLK; + case 0170: + CASE170 : { goto op_ufn; } /* MISC1, dorado only */ + case 0171: + CASE171 : { goto op_ufn; } /* MISC2, dorado only */ + case 0172: + CASE172: + RECLAIMCELL; + case 0173: + CASE173: + GCSCAN1; + case 0174: + CASE174: + GCSCAN2; + case 0175: + CASE175 : { + EXT; + OP_subrcall(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + RET; + NATIVE_NEXTOP0; + }; + case 0176: + CASE176 : { CONTEXTSWITCH; } + case 0177: + CASE177 : { goto op_ufn; } /* RETCALL */ - case 0200 : CASE200: { JUMPMACRO(2); } - case 0201 : CASE201: { JUMPMACRO(3); } - case 0202 : CASE202: { JUMPMACRO(4); } - case 0203 : CASE203: { JUMPMACRO(5); } - case 0204 : CASE204: { JUMPMACRO(6); } - case 0205 : CASE205: { JUMPMACRO(7); } - case 0206 : CASE206: { JUMPMACRO(8); } - case 0207 : CASE207: { JUMPMACRO(9); } - case 0210 : CASE210: { JUMPMACRO(10); } - case 0211 : CASE211: { JUMPMACRO(11); } - case 0212 : CASE212: { JUMPMACRO(12); } - case 0213 : CASE213: { JUMPMACRO(13); } - case 0214 : CASE214: { JUMPMACRO(14); } - case 0215 : CASE215: { JUMPMACRO(15); } - case 0216 : CASE216: { JUMPMACRO(16); } - case 0217 : CASE217: { JUMPMACRO(17); } + /* JUMP */ + case 0200: + CASE200 : { JUMPMACRO(2); } + case 0201: + CASE201 : { JUMPMACRO(3); } + case 0202: + CASE202 : { JUMPMACRO(4); } + case 0203: + CASE203 : { JUMPMACRO(5); } + case 0204: + CASE204 : { JUMPMACRO(6); } + case 0205: + CASE205 : { JUMPMACRO(7); } + case 0206: + CASE206 : { JUMPMACRO(8); } + case 0207: + CASE207 : { JUMPMACRO(9); } + case 0210: + CASE210 : { JUMPMACRO(10); } + case 0211: + CASE211 : { JUMPMACRO(11); } + case 0212: + CASE212 : { JUMPMACRO(12); } + case 0213: + CASE213 : { JUMPMACRO(13); } + case 0214: + CASE214 : { JUMPMACRO(14); } + case 0215: + CASE215 : { JUMPMACRO(15); } + case 0216: + CASE216 : { JUMPMACRO(16); } + case 0217: + CASE217 : { JUMPMACRO(17); } -/* FJUMP */ + /* FJUMP */ - case 0220 : CASE220: { FJUMPMACRO(2); } - case 0221 : CASE221: { FJUMPMACRO(3); } - case 0222 : CASE222: { FJUMPMACRO(4); } - case 0223 : CASE223: { FJUMPMACRO(5); } - case 0224 : CASE224: { FJUMPMACRO(6); } - case 0225 : CASE225: { FJUMPMACRO(7); } - case 0226 : CASE226: { FJUMPMACRO(8); } - case 0227 : CASE227: { FJUMPMACRO(9); } - case 0230 : CASE230: { FJUMPMACRO(10); } - case 0231 : CASE231: { FJUMPMACRO(11); } - case 0232 : CASE232: { FJUMPMACRO(12); } - case 0233 : CASE233: { FJUMPMACRO(13); } - case 0234 : CASE234: { FJUMPMACRO(14); } - case 0235 : CASE235: { FJUMPMACRO(15); } - case 0236 : CASE236: { FJUMPMACRO(16); } - case 0237 : CASE237: { FJUMPMACRO(17); } + case 0220: + CASE220 : { FJUMPMACRO(2); } + case 0221: + CASE221 : { FJUMPMACRO(3); } + case 0222: + CASE222 : { FJUMPMACRO(4); } + case 0223: + CASE223 : { FJUMPMACRO(5); } + case 0224: + CASE224 : { FJUMPMACRO(6); } + case 0225: + CASE225 : { FJUMPMACRO(7); } + case 0226: + CASE226 : { FJUMPMACRO(8); } + case 0227: + CASE227 : { FJUMPMACRO(9); } + case 0230: + CASE230 : { FJUMPMACRO(10); } + case 0231: + CASE231 : { FJUMPMACRO(11); } + case 0232: + CASE232 : { FJUMPMACRO(12); } + case 0233: + CASE233 : { FJUMPMACRO(13); } + case 0234: + CASE234 : { FJUMPMACRO(14); } + case 0235: + CASE235 : { FJUMPMACRO(15); } + case 0236: + CASE236 : { FJUMPMACRO(16); } + case 0237: + CASE237 : { FJUMPMACRO(17); } -/* TJUMP */ + /* TJUMP */ - case 0240 : CASE240: { TJUMPMACRO(2); } - case 0241 : CASE241: { TJUMPMACRO(3); } - case 0242 : CASE242: { TJUMPMACRO(4); } - case 0243 : CASE243: { TJUMPMACRO(5); } - case 0244 : CASE244: { TJUMPMACRO(6); } - case 0245 : CASE245: { TJUMPMACRO(7); } - case 0246 : CASE246: { TJUMPMACRO(8); } - case 0247 : CASE247: { TJUMPMACRO(9); } - case 0250 : CASE250: { TJUMPMACRO(10); } - case 0251 : CASE251: { TJUMPMACRO(11); } - case 0252 : CASE252: { TJUMPMACRO(12); } - case 0253 : CASE253: { TJUMPMACRO(13); } - case 0254 : CASE254: { TJUMPMACRO(14); } - case 0255 : CASE255: { TJUMPMACRO(15); } - case 0256 : CASE256: { TJUMPMACRO(16); } - case 0257 : CASE257: { TJUMPMACRO(17); } + case 0240: + CASE240 : { TJUMPMACRO(2); } + case 0241: + CASE241 : { TJUMPMACRO(3); } + case 0242: + CASE242 : { TJUMPMACRO(4); } + case 0243: + CASE243 : { TJUMPMACRO(5); } + case 0244: + CASE244 : { TJUMPMACRO(6); } + case 0245: + CASE245 : { TJUMPMACRO(7); } + case 0246: + CASE246 : { TJUMPMACRO(8); } + case 0247: + CASE247 : { TJUMPMACRO(9); } + case 0250: + CASE250 : { TJUMPMACRO(10); } + case 0251: + CASE251 : { TJUMPMACRO(11); } + case 0252: + CASE252 : { TJUMPMACRO(12); } + case 0253: + CASE253 : { TJUMPMACRO(13); } + case 0254: + CASE254 : { TJUMPMACRO(14); } + case 0255: + CASE255 : { TJUMPMACRO(15); } + case 0256: + CASE256 : { TJUMPMACRO(16); } + case 0257: + CASE257 : { TJUMPMACRO(17); } -/******* JUMPX ********/ - case 0260 : CASE260: { - CHECK_INTERRUPT; - PCMACL += Get_SBYTE_PCMAC1; nextop0; - } + /******* JUMPX ********/ + case 0260: + CASE260 : { + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } -/******* JUMPXX ********/ - case 0261 : CASE261: { - CHECK_INTERRUPT; - PCMACL += (Get_SBYTE_PCMAC1<<8) | Get_BYTE_PCMAC2; nextop0; - } + /******* JUMPXX ********/ + case 0261: + CASE261 : { + CHECK_INTERRUPT; + PCMACL += (Get_SBYTE_PCMAC1 << 8) | Get_BYTE_PCMAC2; + nextop0; + } -/******* FJumpx *******/ - case 0262 : CASE262: { - if(TOPOFSTACK != 0) {goto PopNextop2;} - CHECK_INTERRUPT; - POP; - PCMACL += Get_SBYTE_PCMAC1; - nextop0; - } + /******* FJumpx *******/ + case 0262: + CASE262 : { + if (TOPOFSTACK != 0) { goto PopNextop2; } + CHECK_INTERRUPT; + POP; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } -/******* TJumpx *******/ + /******* TJumpx *******/ - case 0263 : CASE263: { - if(TOPOFSTACK == 0) {goto PopNextop2;} - CHECK_INTERRUPT; - POP; - PCMACL += Get_SBYTE_PCMAC1; - nextop0; - } + case 0263: + CASE263 : { + if (TOPOFSTACK == 0) { goto PopNextop2; } + CHECK_INTERRUPT; + POP; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } -/******* NFJumpx *******/ + /******* NFJumpx *******/ - case 0264 : CASE264: { - if(TOPOFSTACK != 0) {goto PopNextop2;} - CHECK_INTERRUPT; - PCMACL += Get_SBYTE_PCMAC1; - nextop0; - } + case 0264: + CASE264 : { + if (TOPOFSTACK != 0) { goto PopNextop2; } + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } -/******* NTJumpx *******/ + /******* NTJumpx *******/ - case 0265 : CASE265: { - if(TOPOFSTACK == 0) {goto PopNextop2;} - CHECK_INTERRUPT; - PCMACL += Get_SBYTE_PCMAC1; - nextop0; - } + case 0265: + CASE265 : { + if (TOPOFSTACK == 0) { goto PopNextop2; } + CHECK_INTERRUPT; + PCMACL += Get_SBYTE_PCMAC1; + nextop0; + } - case 0266 : CASE266: AREF1; - case 0267 : CASE267: ASET1; + case 0266: + CASE266: + AREF1; + case 0267: + CASE267: + ASET1; - case 0270 : CASE270: PVARSETPOPMACRO(0); - case 0271 : CASE271: PVARSETPOPMACRO(1); - case 0272 : CASE272: PVARSETPOPMACRO(2); - case 0273 : CASE273: PVARSETPOPMACRO(3); - case 0274 : CASE274: PVARSETPOPMACRO(4); - case 0275 : CASE275: PVARSETPOPMACRO(5); - case 0276 : CASE276: PVARSETPOPMACRO(6); + case 0270: + CASE270: + PVARSETPOPMACRO(0); + case 0271: + CASE271: + PVARSETPOPMACRO(1); + case 0272: + CASE272: + PVARSETPOPMACRO(2); + case 0273: + CASE273: + PVARSETPOPMACRO(3); + case 0274: + CASE274: + PVARSETPOPMACRO(4); + case 0275: + CASE275: + PVARSETPOPMACRO(5); + case 0276: + CASE276: + PVARSETPOPMACRO(6); - case 0277 : CASE277: { POP; nextop1; } + case 0277: + CASE277 : { + POP; + nextop1; + } - case 0300 : CASE300: POPN(Get_BYTE_PCMAC1); - case 0301 : CASE301: ATOMCELL_N(Get_BYTE_PCMAC1); - case 0302 : CASE302: GETBASEBYTE; - case 0303 : CASE303: INSTANCEP(Get_AtomNo_PCMAC1); - case 0304 : CASE304: BLT; - case 0305 : CASE305: {goto op_ufn; } /* MISC10 */ - case 0306 : CASE306: {goto op_ufn; } /* P-MISC2 ??? */ - case 0307 : CASE307: PUTBASEBYTE; - case 0310 : CASE310: GETBASE_N(Get_BYTE_PCMAC1); - case 0311 : CASE311: GETBASEPTR_N(Get_BYTE_PCMAC1); - case 0312 : CASE312: GETBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); - case 0313 : CASE313: {goto op_ufn; } /* unused */ - case 0314 : CASE314: CLEQUAL; - case 0315 : CASE315: PUTBASE_N(Get_BYTE_PCMAC1); - case 0316 : CASE316: PUTBASEPTR_N(Get_BYTE_PCMAC1); - case 0317 : CASE317: PUTBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + case 0300: + CASE300: + POPN(Get_BYTE_PCMAC1); + case 0301: + CASE301: + ATOMCELL_N(Get_BYTE_PCMAC1); + case 0302: + CASE302: + GETBASEBYTE; + case 0303: + CASE303: + INSTANCEP(Get_AtomNo_PCMAC1); + case 0304: + CASE304: + BLT; + case 0305: + CASE305 : { goto op_ufn; } /* MISC10 */ + case 0306: + CASE306 : { goto op_ufn; } /* P-MISC2 ??? */ + case 0307: + CASE307: + PUTBASEBYTE; + case 0310: + CASE310: + GETBASE_N(Get_BYTE_PCMAC1); + case 0311: + CASE311: + GETBASEPTR_N(Get_BYTE_PCMAC1); + case 0312: + CASE312: + GETBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); + case 0313: + CASE313 : { goto op_ufn; } /* unused */ + case 0314: + CASE314: + CLEQUAL; + case 0315: + CASE315: + PUTBASE_N(Get_BYTE_PCMAC1); + case 0316: + CASE316: + PUTBASEPTR_N(Get_BYTE_PCMAC1); + case 0317: + CASE317: + PUTBITS_N_M(Get_BYTE_PCMAC1, Get_BYTE_PCMAC2); - case 0320 : CASE320: N_OP_ADDBASE; - case 0321 : CASE321: N_OP_VAG2; - case 0322 : CASE322: N_OP_HILOC; - case 0323 : CASE323: N_OP_LOLOC; - case 0324 : CASE324: PLUS2; /* PLUS */ - case 0325 : CASE325: DIFFERENCE; /* DIFFERENCE */ - case 0326 : CASE326: TIMES2; /* TIMES2 */ - case 0327 : CASE327: QUOTIENT /* QUOTIENT */ - case 0330 : CASE330: IPLUS2; /* IPLUS2 only while PLUS has no float */ - case 0331 : CASE331: IDIFFERENCE; /* IDIFFERENCE only while no float */ - case 0332 : CASE332: ITIMES2; /* ITIMES2 only while no float */ - case 0333 : CASE333: IQUOTIENT; /* IQUOTIENT */ - case 0334 : CASE334: IREMAINDER; - case 0335 : CASE335: IPLUS_N(Get_BYTE_PCMAC1); - case 0336 : CASE336: IDIFFERENCE_N(Get_BYTE_PCMAC1); - case 0337 : CASE337: { goto op_ufn; } /* BASE-< */ - case 0340 : CASE340: LLSH1; - case 0341 : CASE341: LLSH8; - case 0342 : CASE342: LRSH1; - case 0343 : CASE343: LRSH8; - case 0344 : CASE344: LOGOR; - case 0345 : CASE345: LOGAND; - case 0346 : CASE346: LOGXOR; - case 0347 : CASE347: LSH; - case 0350 : CASE350: FPLUS2; - case 0351 : CASE351: FDIFFERENCE; - case 0352 : CASE352: FTIMES2; - case 0353 : CASE353: FQUOTIENT; - case 0354 : CASE354: UBFLOAT2(Get_BYTE_PCMAC1); - case 0355 : CASE355: UBFLOAT1(Get_BYTE_PCMAC1); - case 0356 : CASE356: AREF2; - case 0357 : CASE357: ASET2; + case 0320: + CASE320: + N_OP_ADDBASE; + case 0321: + CASE321: + N_OP_VAG2; + case 0322: + CASE322: + N_OP_HILOC; + case 0323: + CASE323: + N_OP_LOLOC; + case 0324: + CASE324: + PLUS2; /* PLUS */ + case 0325: + CASE325: + DIFFERENCE; /* DIFFERENCE */ + case 0326: + CASE326: + TIMES2; /* TIMES2 */ + case 0327: + CASE327: + QUOTIENT /* QUOTIENT */ + case 0330 : CASE330 : IPLUS2; /* IPLUS2 only while PLUS has no float */ + case 0331: + CASE331: + IDIFFERENCE; /* IDIFFERENCE only while no float */ + case 0332: + CASE332: + ITIMES2; /* ITIMES2 only while no float */ + case 0333: + CASE333: + IQUOTIENT; /* IQUOTIENT */ + case 0334: + CASE334: + IREMAINDER; + case 0335: + CASE335: + IPLUS_N(Get_BYTE_PCMAC1); + case 0336: + CASE336: + IDIFFERENCE_N(Get_BYTE_PCMAC1); + case 0337: + CASE337 : { goto op_ufn; } /* BASE-< */ + case 0340: + CASE340: + LLSH1; + case 0341: + CASE341: + LLSH8; + case 0342: + CASE342: + LRSH1; + case 0343: + CASE343: + LRSH8; + case 0344: + CASE344: + LOGOR; + case 0345: + CASE345: + LOGAND; + case 0346: + CASE346: + LOGXOR; + case 0347: + CASE347: + LSH; + case 0350: + CASE350: + FPLUS2; + case 0351: + CASE351: + FDIFFERENCE; + case 0352: + CASE352: + FTIMES2; + case 0353: + CASE353: + FQUOTIENT; + case 0354: + CASE354: + UBFLOAT2(Get_BYTE_PCMAC1); + case 0355: + CASE355: + UBFLOAT1(Get_BYTE_PCMAC1); + case 0356: + CASE356: + AREF2; + case 0357: + CASE357: + ASET2; - case 0360 : CASE360: { - if(TOPOFSTACK == POP_TOS_1) - TOPOFSTACK = ATOM_T; - else TOPOFSTACK = NIL_PTR; - nextop1; - } + case 0360: + CASE360 : { + if (TOPOFSTACK == POP_TOS_1) + TOPOFSTACK = ATOM_T; + else + TOPOFSTACK = NIL_PTR; + nextop1; + } - case 0361 : CASE361: IGREATERP; /* IGREATERP if no float */ - case 0362 : CASE362: FGREATERP; - case 0363 : CASE363: GREATERP; - case 0364 : CASE364: ILEQUAL; - case 0365 : CASE365: MAKENUMBER; - case 0366 : CASE366: BOXIPLUS; - case 0367 : CASE367: BOXIDIFFERENCE; - case 0370 : CASE370: { goto op_ufn; } /* FLOATBLT */ - case 0371 : CASE371: { goto op_ufn; } /* FFTSTEP */ - case 0372 : CASE372: MISC3(Get_BYTE_PCMAC1); - case 0373 : CASE373: MISC4(Get_BYTE_PCMAC1); - case 0374 : CASE374: { goto op_ufn; } /* upctrace */ - case 0375 : CASE375: SWAP; - case 0376 : CASE376: NOP; - case 0377 : CASE377: CLARITHEQUAL; + case 0361: + CASE361: + IGREATERP; /* IGREATERP if no float */ + case 0362: + CASE362: + FGREATERP; + case 0363: + CASE363: + GREATERP; + case 0364: + CASE364: + ILEQUAL; + case 0365: + CASE365: + MAKENUMBER; + case 0366: + CASE366: + BOXIPLUS; + case 0367: + CASE367: + BOXIDIFFERENCE; + case 0370: + CASE370 : { goto op_ufn; } /* FLOATBLT */ + case 0371: + CASE371 : { goto op_ufn; } /* FFTSTEP */ + case 0372: + CASE372: + MISC3(Get_BYTE_PCMAC1); + case 0373: + CASE373: + MISC4(Get_BYTE_PCMAC1); + case 0374: + CASE374 : { goto op_ufn; } /* upctrace */ + case 0375: + CASE375: + SWAP; + case 0376: + CASE376: + NOP; + case 0377: + CASE377: + CLARITHEQUAL; #ifdef OPDISP #ifdef ISC -case 0400 : goto setup_table; /* to defeat optimizer, so optable exists */ + case 0400: + goto setup_table; /* to defeat optimizer, so optable exists */ #elif (DOS && OPDISP) -case 0400: goto setup_table; + case 0400: goto setup_table; #endif /* ISC */ #endif /* OPDISP */ - - #ifdef I386 - /* to defeat the damn optimizer, make it look like */ - /* we might branch to the error labels. */ - case 0400 : goto plus_err; - case 0401 : goto iplus_err; - case 0402 : goto iplusn_err; - case 0403 : goto idiff_err; - case 0404 : goto diff_err; - case 0405 : goto idiffn_err; - case 0406 : goto greaterp_err; - case 0411 : goto igreaterp_err; - case 0407 : goto llsh8_err; - case 0410 : goto lrsh1_err; - case 0414 : goto lrsh8_err; - case 0417 : goto llsh1_err; - case 0413 : goto logor_err; - case 0412 : goto logand_err; - case 0416 : goto logxor_err; - case 0415 : goto addbase_err; + /* to defeat the damn optimizer, make it look like */ + /* we might branch to the error labels. */ + case 0400: goto plus_err; + case 0401: goto iplus_err; + case 0402: goto iplusn_err; + case 0403: goto idiff_err; + case 0404: goto diff_err; + case 0405: goto idiffn_err; + case 0406: goto greaterp_err; + case 0411: goto igreaterp_err; + case 0407: goto llsh8_err; + case 0410: goto lrsh1_err; + case 0414: goto lrsh8_err; + case 0417: goto llsh1_err; + case 0413: goto logor_err; + case 0412: goto logand_err; + case 0416: goto logxor_err; + case 0415: goto addbase_err; #endif - - default: error("should not default"); - } /* switch */ + default: error("should not default"); + + } /* switch */ #ifdef NATIVETRAN /************************************************************************/ /* NATIVE CODE INTERFACE */ /************************************************************************/ - /* FORIEGN -> DISPATCH */ /* Return to current frame ext */ c_ret_to_dispatch: - asm(" .globl _c_ret_to_dispatch"); - asm("_c_ret_to_dispatch:"); - PCMACL = (ByteCode *) FuncObj + BCE_CURRENTFX->pc; - goto ret_to_dispatch; /* assume optimizer will remove */ + asm(" .globl _c_ret_to_dispatch"); + asm("_c_ret_to_dispatch:"); + PCMACL = (ByteCode *)FuncObj + BCE_CURRENTFX->pc; + goto ret_to_dispatch; /* assume optimizer will remove */ /* NATIVE -> DISPATCH */ /* Return to current frame ext */ ret_to_dispatch: - asm(" .globl _ret_to_dispatch"); - asm("_ret_to_dispatch:"); - RET_FROM_NATIVE; - nextop0; + asm(" .globl _ret_to_dispatch"); + asm("_ret_to_dispatch:"); + RET_FROM_NATIVE; + nextop0; /* NATIVE -> DISPATCH */ /* Execute opcode in current frame ext */ ret_to_unimpl: - asm(" .globl _ret_to_unimpl"); - asm("_ret_to_unimpl:"); - SaveD6 = 0x100; - /* HACK. Reg. d6 is set to dispatch to native_check */ - /* so need to do switch instead of dispatch! */ - RET_FROM_NATIVE; - goto nextopcode; + asm(" .globl _ret_to_unimpl"); + asm("_ret_to_unimpl:"); + SaveD6 = 0x100; + /* HACK. Reg. d6 is set to dispatch to native_check */ + /* so need to do switch instead of dispatch! */ + RET_FROM_NATIVE; + goto nextopcode; /* NATIVE -> UFN(PC) */ ret_to_ufn: - asm(" .globl _ret_to_ufn"); - asm("_ret_to_ufn:"); - RET_FROM_NATIVE; - goto op_ufn; + asm(" .globl _ret_to_ufn"); + asm("_ret_to_ufn:"); + RET_FROM_NATIVE; + goto op_ufn; /* DISPATCH -> NATIVE? */ /* Return to current frame ext? */ - + native_check: - SaveD6 = 0; - NATIVE_NEXTOP0; + SaveD6 = 0; + NATIVE_NEXTOP0; /* NATIVE -> TIMER */ /* Return to Execute timer interrupt */ ret_to_timer: - asm("_ret_to_timer:"); - asm(" .globl _ret_to_timer"); - SaveD6 = 0x100; - RET_FROM_NATIVE; - goto check_interrupt; /* assume optimizer will remove */ + asm("_ret_to_timer:"); + asm(" .globl _ret_to_timer"); + SaveD6 = 0x100; + RET_FROM_NATIVE; + goto check_interrupt; /* assume optimizer will remove */ #else -native_check: +native_check: #ifndef DOS #ifdef OPDISP - SaveD6 = 0x000; + SaveD6 = 0x000; #endif #endif /* DOS */ - goto nextopcode; + goto nextopcode; #endif /************************************************************************/ /* TIMER INTERRUPT CHECK ROUTINE */ /************************************************************************/ check_interrupt: -#if (defined(NATIVETRAN) || defined(SUN3_OS3_OR_OS4_IL) || defined(I386) || defined(ISC)) - asm_label_check_interrupt(); +#if (defined(NATIVETRAN) || defined(SUN3_OS3_OR_OS4_IL) || defined(I386) || defined(ISC)) + asm_label_check_interrupt(); #endif - if ( (UNSIGNED)CSTKPTR > (UNSIGNED)EndSTKP ) - {EXT; - error("Unrecoverable Stack Overflow"); - RET; - } + if ((UNSIGNED)CSTKPTR > (UNSIGNED)EndSTKP) { + EXT; + error("Unrecoverable Stack Overflow"); + RET; + } - /* Check for an IRQ request */ + /* Check for an IRQ request */ -{register int need_irq; - static int period_cnt=60; -extern int KBDEventFlg; -extern int ETHEREventCount; -extern LispPTR DOBUFFEREDTRANSITION_index; -extern LispPTR INTERRUPTFRAME_index; -extern LispPTR *KEYBUFFERING68k; -extern LispPTR *PENDINGINTERRUPT68k; -extern LispPTR ATOM_STARTED; -extern LispPTR *PERIODIC_INTERRUPT68k; -extern LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; -extern LispPTR PERIODIC_INTERRUPTFRAME_index; -extern LispPTR *Reclaim_cnt_word; -extern LispPTR DORECLAIM_index; -extern int URaid_req; + { + register int need_irq; + static int period_cnt = 60; + extern int KBDEventFlg; + extern int ETHEREventCount; + extern LispPTR DOBUFFEREDTRANSITION_index; + extern LispPTR INTERRUPTFRAME_index; + extern LispPTR *KEYBUFFERING68k; + extern LispPTR *PENDINGINTERRUPT68k; + extern LispPTR ATOM_STARTED; + extern LispPTR *PERIODIC_INTERRUPT68k; + extern LispPTR *PERIODIC_INTERRUPT_FREQUENCY68k; + extern LispPTR PERIODIC_INTERRUPTFRAME_index; + extern LispPTR *Reclaim_cnt_word; + extern LispPTR DORECLAIM_index; + extern int URaid_req; - /* Check for an Stack Overflow */ -/* JDS 22 May 96 -- >= below used to be just >, changed because we got - stack oflows with last frame right at end of stack, leading to loops, - odd bugs, ... */ -/**** Changed back to > 31 July 97 ****/ -re_check_stack: - need_irq = 0; - if ( ((UNSIGNED)(CSTKPTR+1) > Irq_Stk_Check) && - (Irq_Stk_End > 0) && - (Irq_Stk_Check > 0) ) - { - HARD_PUSH(TOPOFSTACK); - EXT; - extended_frame = NIL; - if (do_stackoverflow(NIL)) { -stackoverflow_help: - period_cnt=60; need_irq = T; - error("Stack Overflow, MUST HARDRESET!"); - RET; TOPOFSTACK = NIL_PTR; - } - else { RET; POP; } - Irq_Stk_Check = (UNSIGNED)EndSTKP-STK_MIN(FuncObj); - need_irq = (Irq_Stk_End == 0) || extended_frame; - *PENDINGINTERRUPT68k |= extended_frame; - Irq_Stk_End = (UNSIGNED) EndSTKP; - } + /* Check for an Stack Overflow */ + /* JDS 22 May 96 -- >= below used to be just >, changed because we got + stack oflows with last frame right at end of stack, leading to loops, + odd bugs, ... */ + /**** Changed back to > 31 July 97 ****/ + re_check_stack: + need_irq = 0; + if (((UNSIGNED)(CSTKPTR + 1) > Irq_Stk_Check) && (Irq_Stk_End > 0) && (Irq_Stk_Check > 0)) { + HARD_PUSH(TOPOFSTACK); + EXT; + extended_frame = NIL; + if (do_stackoverflow(NIL)) { + stackoverflow_help: + period_cnt = 60; + need_irq = T; + error("Stack Overflow, MUST HARDRESET!"); + RET; + TOPOFSTACK = NIL_PTR; + } else { + RET; + POP; + } + Irq_Stk_Check = (UNSIGNED)EndSTKP - STK_MIN(FuncObj); + need_irq = (Irq_Stk_End == 0) || extended_frame; + *PENDINGINTERRUPT68k |= extended_frame; + Irq_Stk_End = (UNSIGNED)EndSTKP; + } - /* Check for an IRQ request */ + /* Check for an IRQ request */ - if ((Irq_Stk_End <= 0) || (Irq_Stk_Check <= 0) || need_irq) { - if (StkOffset_from_68K(CSTKPTR) > InterfacePage->stackbase) { - - /* Interrupts not Disabled */ + if ((Irq_Stk_End <= 0) || (Irq_Stk_Check <= 0) || need_irq) { + if (StkOffset_from_68K(CSTKPTR) > InterfacePage->stackbase) { +/* Interrupts not Disabled */ #ifndef KBINT - getsignaldata(); + getsignaldata(); #endif #ifdef OS4 - getsignaldata(); + getsignaldata(); #endif - EXT; - update_timer(); - - /*** If SPY is running, check to see if it ***/ - /*** needs an interrupt; give it one, if so. ***/ - if(*PERIODIC_INTERRUPT68k!=NIL) - { - if(period_cnt>0) period_cnt--; - else - { - cause_interruptcall(PERIODIC_INTERRUPTFRAME_index); - if(*PERIODIC_INTERRUPT_FREQUENCY68k==NIL) - period_cnt=0; - else - period_cnt=(*PERIODIC_INTERRUPT_FREQUENCY68k & 0xffff) - *(1000000/60) /TIMER_INTERVAL; - /* number of 1/60 second periods between interrupts. - TIMER_INTERVAL is the number of microseconds between - timer interrupts. The calculation here avoids some - overflow errors although there is some roundoff - if the interrupt frequency number is too low, - it will bottom out and just set period_cnt to 0 */ - } - } + EXT; + update_timer(); + /*** If SPY is running, check to see if it ***/ + /*** needs an interrupt; give it one, if so. ***/ + if (*PERIODIC_INTERRUPT68k != NIL) { + if (period_cnt > 0) + period_cnt--; + else { + cause_interruptcall(PERIODIC_INTERRUPTFRAME_index); + if (*PERIODIC_INTERRUPT_FREQUENCY68k == NIL) + period_cnt = 0; + else + period_cnt = + (*PERIODIC_INTERRUPT_FREQUENCY68k & 0xffff) * (1000000 / 60) / TIMER_INTERVAL; + /* number of 1/60 second periods between interrupts. + TIMER_INTERVAL is the number of microseconds between + timer interrupts. The calculation here avoids some + overflow errors although there is some roundoff + if the interrupt frequency number is too low, + it will bottom out and just set period_cnt to 0 */ + } + } #ifdef DOS - if(currentkbd->URaid == TRUE){ - currentkbd->URaid = NIL; - (currentkbd->device.exit)(currentkbd); /* Install the original handler */ - error("Call URaid by User Interrupt"); - } - else if(currentmouse->Cursor.Moved){ - union REGS regs; + if (currentkbd->URaid == TRUE) { + currentkbd->URaid = NIL; + (currentkbd->device.exit)(currentkbd); /* Install the original handler */ + error("Call URaid by User Interrupt"); + } else if (currentmouse->Cursor.Moved) { + union REGS regs; - currentdsp->device.locked++; + currentdsp->device.locked++; - /* Remove the mouse from the old place on the screen */ - (currentdsp->mouse_invissible)(currentdsp, IOPage68K); + /* Remove the mouse from the old place on the screen */ + (currentdsp->mouse_invissible)(currentdsp, IOPage68K); - /* Find the new delta */ - regs.w.eax = 0x000B; /* Function 0xB = get delta mickeys */ - int86(0x33, ®s, ®s); - currentmouse->Cursor.New.x += (short)regs.w.ecx; - currentmouse->Cursor.New.y += (short)regs.w.edx; + /* Find the new delta */ + regs.w.eax = 0x000B; /* Function 0xB = get delta mickeys */ + int86(0x33, ®s, ®s); + currentmouse->Cursor.New.x += (short)regs.w.ecx; + currentmouse->Cursor.New.y += (short)regs.w.edx; - if(currentmouse->Cursor.New.x < 0) - currentmouse->Cursor.New.x = 0; - else if(currentmouse->Cursor.New.x > (currentdsp->Display.width - 1)) - currentmouse->Cursor.New.x = currentdsp->Display.width - 1; + if (currentmouse->Cursor.New.x < 0) + currentmouse->Cursor.New.x = 0; + else if (currentmouse->Cursor.New.x > (currentdsp->Display.width - 1)) + currentmouse->Cursor.New.x = currentdsp->Display.width - 1; - if(currentmouse->Cursor.New.y < 0) - currentmouse->Cursor.New.y = 0; - else if(currentmouse->Cursor.New.y > (currentdsp->Display.height - 1)) - currentmouse->Cursor.New.y = currentdsp->Display.height - 1; + if (currentmouse->Cursor.New.y < 0) + currentmouse->Cursor.New.y = 0; + else if (currentmouse->Cursor.New.y > (currentdsp->Display.height - 1)) + currentmouse->Cursor.New.y = currentdsp->Display.height - 1; - IOPage68K->dlmousex = - IOPage68K->dlcursorx = - currentmouse->Cursor.New.x; - IOPage68K->dlmousey = - IOPage68K->dlcursory = - currentmouse->Cursor.New.y; - - /* Paint the mouse back up on the screen on the new place */ - (currentdsp->mouse_vissible)( currentmouse->Cursor.New.x, - currentmouse->Cursor.New.y); - currentmouse->Cursor.Moved = FALSE; - currentdsp->device.locked--; - } + IOPage68K->dlmousex = IOPage68K->dlcursorx = currentmouse->Cursor.New.x; + IOPage68K->dlmousey = IOPage68K->dlcursory = currentmouse->Cursor.New.y; + /* Paint the mouse back up on the screen on the new place */ + (currentdsp->mouse_vissible)(currentmouse->Cursor.New.x, currentmouse->Cursor.New.y); + currentmouse->Cursor.Moved = FALSE; + currentdsp->device.locked--; + } #else - if(URaid_req ==T){ - URaid_req=NIL; - error("Call URaid by User Interrupt"); - } + if (URaid_req == T) { + URaid_req = NIL; + error("Call URaid by User Interrupt"); + } #endif /* DOS */ - else if((KBDEventFlg>0)&&(*KEYBUFFERING68k==ATOM_T)) { - *KEYBUFFERING68k= ATOM_STARTED; - cause_interruptcall(DOBUFFEREDTRANSITION_index); - KBDEventFlg --; - } - else if(*Reclaim_cnt_word == S_POSITIVE) { - *Reclaim_cnt_word=NIL; - cause_interruptcall(DORECLAIM_index); - } - else if (*PENDINGINTERRUPT68k!=NIL) - { INTSTAT2 * intstate = ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); - unsigned char newints = (intstate->pendingmask) & ~(intstate->handledmask); - /* if (newints) */ - { - intstate->handledmask |= intstate->pendingmask; - *PENDINGINTERRUPT68k=NIL; - cause_interruptcall(INTERRUPTFRAME_index); - } - } - else if (ETHEREventCount>0) - { INTSTAT * intstate = ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); - if (!(intstate->ETHERInterrupt) && - !(((INTSTAT2 *)intstate)->handledmask & 0x40)) - { - intstate->ETHERInterrupt=1; - ((INTSTAT2 *)intstate)->handledmask |= - ((INTSTAT2 *)intstate)->pendingmask; - cause_interruptcall(INTERRUPTFRAME_index); - ETHEREventCount--; - } - else *PENDINGINTERRUPT68k = ATOM_T; - } - RET; - CLR_IRQ; - } /* Interrupts not Disabled */ - else { - /* Clear out IRQ (loses pending interrupt request - if interrupts are disabled) */ - CLR_IRQ; - goto re_check_stack; - } - } - -} - - nextop0; + else if ((KBDEventFlg > 0) && (*KEYBUFFERING68k == ATOM_T)) { + *KEYBUFFERING68k = ATOM_STARTED; + cause_interruptcall(DOBUFFEREDTRANSITION_index); + KBDEventFlg--; + } else if (*Reclaim_cnt_word == S_POSITIVE) { + *Reclaim_cnt_word = NIL; + cause_interruptcall(DORECLAIM_index); + } else if (*PENDINGINTERRUPT68k != NIL) { + INTSTAT2 *intstate = ((INTSTAT2 *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + unsigned char newints = (intstate->pendingmask) & ~(intstate->handledmask); + /* if (newints) */ + { + intstate->handledmask |= intstate->pendingmask; + *PENDINGINTERRUPT68k = NIL; + cause_interruptcall(INTERRUPTFRAME_index); + } + } else if (ETHEREventCount > 0) { + INTSTAT *intstate = ((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word)); + if (!(intstate->ETHERInterrupt) && !(((INTSTAT2 *)intstate)->handledmask & 0x40)) { + intstate->ETHERInterrupt = 1; + ((INTSTAT2 *)intstate)->handledmask |= ((INTSTAT2 *)intstate)->pendingmask; + cause_interruptcall(INTERRUPTFRAME_index); + ETHEREventCount--; + } else + *PENDINGINTERRUPT68k = ATOM_T; + } + RET; + CLR_IRQ; + } /* Interrupts not Disabled */ + else { + /* Clear out IRQ (loses pending interrupt request + if interrupts are disabled) */ + CLR_IRQ; + goto re_check_stack; + } + } + } + nextop0; /************************************************************************/ /* Common Jump Tails (they have to jump anyway, so use common Tail) */ /************************************************************************/ PopNextop1: - POP; - nextop1; + POP; + nextop1; PopNextop2: - POP; - nextop2; + POP; + nextop2; /************************************************************************/ /* */ @@ -1047,273 +1437,278 @@ PopNextop2: /************************************************************************/ #ifdef OPDISP - setup_table: +setup_table: #ifndef ISC - SaveD6 = 0; + SaveD6 = 0; #ifdef UNSAFE - Save_D5_shift_amount = 15; + Save_D5_shift_amount = 15; #endif + { + int i; + for (i = 0; i < 256; i++) { table[i] = (InstPtr)op_ufn; }; + } + { + int i; + for (i = 256; i < 512; i++) { table[i] = (InstPtr)native_check; }; + } + table[001] = (InstPtr)case001; + table[002] = (InstPtr)case002; + table[003] = (InstPtr)case003; + table[004] = (InstPtr)case004; + table[005] = (InstPtr)case005; + table[006] = (InstPtr)case006; + table[007] = (InstPtr)case007; + table[010] = (InstPtr)case010; + table[011] = (InstPtr)case011; + table[012] = (InstPtr)case012; + table[013] = (InstPtr)case013; + table[014] = (InstPtr)case014; + table[015] = (InstPtr)case015; + table[016] = (InstPtr)case016; + table[017] = (InstPtr)case017; + table[020] = (InstPtr)case020; + table[021] = (InstPtr)case021; + table[022] = (InstPtr)case022; + table[023] = (InstPtr)case023; + table[024] = (InstPtr)case024; + table[025] = (InstPtr)case025; + table[026] = (InstPtr)case026; + table[027] = (InstPtr)case027; + table[030] = (InstPtr)case030; + table[031] = (InstPtr)case031; + table[032] = (InstPtr)case032; + table[033] = (InstPtr)case033; + table[034] = (InstPtr)case034; + table[035] = (InstPtr)case035; + table[036] = (InstPtr)case036; + table[037] = (InstPtr)case037; + table[040] = (InstPtr)case040; + table[041] = (InstPtr)case041; + table[042] = (InstPtr)case042; + table[043] = (InstPtr)case043; + table[044] = (InstPtr)case044; + table[045] = (InstPtr)case045; + table[046] = (InstPtr)case046; + table[047] = (InstPtr)case047; - {int i; for (i = 0; i < 256; i++) { table[i] = (InstPtr) op_ufn; };} - {int i; for (i = 256; i < 512; i++) - { table[i] = (InstPtr) native_check; }; - } - table[001] = (InstPtr) case001; - table[002] = (InstPtr) case002; - table[003] = (InstPtr) case003; - table[004] = (InstPtr) case004; - table[005] = (InstPtr) case005; - table[006] = (InstPtr) case006; - table[007] = (InstPtr) case007; - table[010] = (InstPtr) case010; - table[011] = (InstPtr) case011; - table[012] = (InstPtr) case012; - table[013] = (InstPtr) case013; - table[014] = (InstPtr) case014; - table[015] = (InstPtr) case015; - table[016] = (InstPtr) case016; - table[017] = (InstPtr) case017; - table[020] = (InstPtr) case020; - table[021] = (InstPtr) case021; - table[022] = (InstPtr) case022; - table[023] = (InstPtr) case023; - table[024] = (InstPtr) case024; - table[025] = (InstPtr) case025; - table[026] = (InstPtr) case026; - table[027] = (InstPtr) case027; - table[030] = (InstPtr) case030; - table[031] = (InstPtr) case031; - table[032] = (InstPtr) case032; - table[033] = (InstPtr) case033; - table[034] = (InstPtr) case034; - table[035] = (InstPtr) case035; - table[036] = (InstPtr) case036; - table[037] = (InstPtr) case037; - table[040] = (InstPtr) case040; - table[041] = (InstPtr) case041; - table[042] = (InstPtr) case042; - table[043] = (InstPtr) case043; - table[044] = (InstPtr) case044; - table[045] = (InstPtr) case045; - table[046] = (InstPtr) case046; - table[047] = (InstPtr) case047; + table[054] = (InstPtr)case054; + table[055] = (InstPtr)case055; + table[056] = (InstPtr)case056; + table[057] = (InstPtr)case057; - table[054] = (InstPtr) case054; - table[055] = (InstPtr) case055; - table[056] = (InstPtr) case056; - table[057] = (InstPtr) case057; + table[062] = (InstPtr)case062; + table[063] = (InstPtr)case063; - table[062] = (InstPtr) case062; - table[063] = (InstPtr) case063; + table[070] = (InstPtr)case070; - table[070] = (InstPtr) case070; + table[072] = (InstPtr)case072; + table[073] = (InstPtr)case073; + table[074] = (InstPtr)case074; + table[075] = (InstPtr)case075; - table[072] = (InstPtr) case072; - table[073] = (InstPtr) case073; - table[074] = (InstPtr) case074; - table[075] = (InstPtr) case075; - - table[0100] = (InstPtr) case100; - table[0101] = (InstPtr) case101; - table[0102] = (InstPtr) case102; - table[0103] = (InstPtr) case103; - table[0104] = (InstPtr) case104; - table[0105] = (InstPtr) case105; - table[0106] = (InstPtr) case106; - table[0107] = (InstPtr) case107; - table[0110] = (InstPtr) case110; - table[0111] = (InstPtr) case111; - table[0112] = (InstPtr) case112; - table[0113] = (InstPtr) case113; - table[0114] = (InstPtr) case114; - table[0115] = (InstPtr) case115; - table[0116] = (InstPtr) case116; - table[0117] = (InstPtr) case117; - table[0120] = (InstPtr) case120; - table[0121] = (InstPtr) case121; - table[0122] = (InstPtr) case122; - table[0123] = (InstPtr) case123; - table[0124] = (InstPtr) case124; - table[0125] = (InstPtr) case125; - table[0126] = (InstPtr) case126; - table[0127] = (InstPtr) case127; - table[0130] = (InstPtr) case130; - table[0131] = (InstPtr) case131; - table[0132] = (InstPtr) case132; - table[0133] = (InstPtr) case133; - table[0134] = (InstPtr) case134; - table[0135] = (InstPtr) case135; - table[0136] = (InstPtr) case136; - table[0137] = (InstPtr) case137; - table[0140] = (InstPtr) case140; - table[0141] = (InstPtr) case141; - table[0142] = (InstPtr) case142; - table[0143] = (InstPtr) case143; - table[0144] = (InstPtr) case144; - table[0145] = (InstPtr) case145; - table[0146] = (InstPtr) case146; - table[0147] = (InstPtr) case147; - table[0150] = (InstPtr) case150; - table[0151] = (InstPtr) case151; - table[0152] = (InstPtr) case152; - table[0153] = (InstPtr) case153; - table[0154] = (InstPtr) case154; - table[0155] = (InstPtr) case155; - table[0156] = (InstPtr) case156; - table[0157] = (InstPtr) case157; - table[0160] = (InstPtr) case160; - table[0161] = (InstPtr) case161; - table[0162] = (InstPtr) case162; - table[0163] = (InstPtr) case163; - table[0164] = (InstPtr) case164; - table[0165] = (InstPtr) case165; - table[0166] = (InstPtr) case166; - table[0167] = (InstPtr) case167; - table[0170] = (InstPtr) case170; - table[0171] = (InstPtr) case171; - table[0172] = (InstPtr) case172; - table[0173] = (InstPtr) case173; - table[0174] = (InstPtr) case174; - table[0175] = (InstPtr) case175; - table[0176] = (InstPtr) case176; - table[0177] = (InstPtr) case177; - table[0200] = (InstPtr) case200; - table[0201] = (InstPtr) case201; - table[0202] = (InstPtr) case202; - table[0203] = (InstPtr) case203; - table[0204] = (InstPtr) case204; - table[0205] = (InstPtr) case205; - table[0206] = (InstPtr) case206; - table[0207] = (InstPtr) case207; - table[0210] = (InstPtr) case210; - table[0211] = (InstPtr) case211; - table[0212] = (InstPtr) case212; - table[0213] = (InstPtr) case213; - table[0214] = (InstPtr) case214; - table[0215] = (InstPtr) case215; - table[0216] = (InstPtr) case216; - table[0217] = (InstPtr) case217; - table[0220] = (InstPtr) case220; - table[0221] = (InstPtr) case221; - table[0222] = (InstPtr) case222; - table[0223] = (InstPtr) case223; - table[0224] = (InstPtr) case224; - table[0225] = (InstPtr) case225; - table[0226] = (InstPtr) case226; - table[0227] = (InstPtr) case227; - table[0230] = (InstPtr) case230; - table[0231] = (InstPtr) case231; - table[0232] = (InstPtr) case232; - table[0233] = (InstPtr) case233; - table[0234] = (InstPtr) case234; - table[0235] = (InstPtr) case235; - table[0236] = (InstPtr) case236; - table[0237] = (InstPtr) case237; - table[0240] = (InstPtr) case240; - table[0241] = (InstPtr) case241; - table[0242] = (InstPtr) case242; - table[0243] = (InstPtr) case243; - table[0244] = (InstPtr) case244; - table[0245] = (InstPtr) case245; - table[0246] = (InstPtr) case246; - table[0247] = (InstPtr) case247; - table[0250] = (InstPtr) case250; - table[0251] = (InstPtr) case251; - table[0252] = (InstPtr) case252; - table[0253] = (InstPtr) case253; - table[0254] = (InstPtr) case254; - table[0255] = (InstPtr) case255; - table[0256] = (InstPtr) case256; - table[0257] = (InstPtr) case257; - table[0260] = (InstPtr) case260; - table[0261] = (InstPtr) case261; - table[0262] = (InstPtr) case262; - table[0263] = (InstPtr) case263; - table[0264] = (InstPtr) case264; - table[0265] = (InstPtr) case265; - table[0266] = (InstPtr) case266; - table[0267] = (InstPtr) case267; - table[0270] = (InstPtr) case270; - table[0271] = (InstPtr) case271; - table[0272] = (InstPtr) case272; - table[0273] = (InstPtr) case273; - table[0274] = (InstPtr) case274; - table[0275] = (InstPtr) case275; - table[0276] = (InstPtr) case276; - table[0277] = (InstPtr) case277; - table[0300] = (InstPtr) case300; - table[0301] = (InstPtr) case301; - table[0302] = (InstPtr) case302; - table[0303] = (InstPtr) case303; - table[0304] = (InstPtr) case304; - table[0305] = (InstPtr) case305; - table[0306] = (InstPtr) case306; - table[0307] = (InstPtr) case307; - table[0310] = (InstPtr) case310; - table[0311] = (InstPtr) case311; - table[0312] = (InstPtr) case312; - table[0313] = (InstPtr) case313; - table[0314] = (InstPtr) case314; - table[0315] = (InstPtr) case315; - table[0316] = (InstPtr) case316; - table[0317] = (InstPtr) case317; - table[0320] = (InstPtr) case320; - table[0321] = (InstPtr) case321; - table[0322] = (InstPtr) case322; - table[0323] = (InstPtr) case323; - table[0324] = (InstPtr) case324; - table[0325] = (InstPtr) case325; - table[0326] = (InstPtr) case326; - table[0327] = (InstPtr) case327; - table[0330] = (InstPtr) case330; - table[0331] = (InstPtr) case331; - table[0332] = (InstPtr) case332; - table[0333] = (InstPtr) case333; - table[0334] = (InstPtr) case334; - table[0335] = (InstPtr) case335; - table[0336] = (InstPtr) case336; - table[0337] = (InstPtr) case337; - table[0340] = (InstPtr) case340; - table[0341] = (InstPtr) case341; - table[0342] = (InstPtr) case342; - table[0343] = (InstPtr) case343; - table[0344] = (InstPtr) case344; - table[0345] = (InstPtr) case345; - table[0346] = (InstPtr) case346; - table[0347] = (InstPtr) case347; - table[0350] = (InstPtr) case350; - table[0351] = (InstPtr) case351; - table[0352] = (InstPtr) case352; - table[0353] = (InstPtr) case353; - table[0354] = (InstPtr) case354; - table[0355] = (InstPtr) case355; - table[0356] = (InstPtr) case356; - table[0357] = (InstPtr) case357; - table[0360] = (InstPtr) case360; - table[0361] = (InstPtr) case361; - table[0362] = (InstPtr) case362; - table[0363] = (InstPtr) case363; - table[0364] = (InstPtr) case364; - table[0365] = (InstPtr) case365; - table[0366] = (InstPtr) case366; - table[0367] = (InstPtr) case367; - table[0370] = (InstPtr) case370; - table[0371] = (InstPtr) case371; - table[0372] = (InstPtr) case372; - table[0373] = (InstPtr) case373; - table[0374] = (InstPtr) case374; - table[0375] = (InstPtr) case375; - table[0376] = (InstPtr) case376; - table[0377] = (InstPtr) case377; - goto nextopcode; + table[0100] = (InstPtr)case100; + table[0101] = (InstPtr)case101; + table[0102] = (InstPtr)case102; + table[0103] = (InstPtr)case103; + table[0104] = (InstPtr)case104; + table[0105] = (InstPtr)case105; + table[0106] = (InstPtr)case106; + table[0107] = (InstPtr)case107; + table[0110] = (InstPtr)case110; + table[0111] = (InstPtr)case111; + table[0112] = (InstPtr)case112; + table[0113] = (InstPtr)case113; + table[0114] = (InstPtr)case114; + table[0115] = (InstPtr)case115; + table[0116] = (InstPtr)case116; + table[0117] = (InstPtr)case117; + table[0120] = (InstPtr)case120; + table[0121] = (InstPtr)case121; + table[0122] = (InstPtr)case122; + table[0123] = (InstPtr)case123; + table[0124] = (InstPtr)case124; + table[0125] = (InstPtr)case125; + table[0126] = (InstPtr)case126; + table[0127] = (InstPtr)case127; + table[0130] = (InstPtr)case130; + table[0131] = (InstPtr)case131; + table[0132] = (InstPtr)case132; + table[0133] = (InstPtr)case133; + table[0134] = (InstPtr)case134; + table[0135] = (InstPtr)case135; + table[0136] = (InstPtr)case136; + table[0137] = (InstPtr)case137; + table[0140] = (InstPtr)case140; + table[0141] = (InstPtr)case141; + table[0142] = (InstPtr)case142; + table[0143] = (InstPtr)case143; + table[0144] = (InstPtr)case144; + table[0145] = (InstPtr)case145; + table[0146] = (InstPtr)case146; + table[0147] = (InstPtr)case147; + table[0150] = (InstPtr)case150; + table[0151] = (InstPtr)case151; + table[0152] = (InstPtr)case152; + table[0153] = (InstPtr)case153; + table[0154] = (InstPtr)case154; + table[0155] = (InstPtr)case155; + table[0156] = (InstPtr)case156; + table[0157] = (InstPtr)case157; + table[0160] = (InstPtr)case160; + table[0161] = (InstPtr)case161; + table[0162] = (InstPtr)case162; + table[0163] = (InstPtr)case163; + table[0164] = (InstPtr)case164; + table[0165] = (InstPtr)case165; + table[0166] = (InstPtr)case166; + table[0167] = (InstPtr)case167; + table[0170] = (InstPtr)case170; + table[0171] = (InstPtr)case171; + table[0172] = (InstPtr)case172; + table[0173] = (InstPtr)case173; + table[0174] = (InstPtr)case174; + table[0175] = (InstPtr)case175; + table[0176] = (InstPtr)case176; + table[0177] = (InstPtr)case177; + table[0200] = (InstPtr)case200; + table[0201] = (InstPtr)case201; + table[0202] = (InstPtr)case202; + table[0203] = (InstPtr)case203; + table[0204] = (InstPtr)case204; + table[0205] = (InstPtr)case205; + table[0206] = (InstPtr)case206; + table[0207] = (InstPtr)case207; + table[0210] = (InstPtr)case210; + table[0211] = (InstPtr)case211; + table[0212] = (InstPtr)case212; + table[0213] = (InstPtr)case213; + table[0214] = (InstPtr)case214; + table[0215] = (InstPtr)case215; + table[0216] = (InstPtr)case216; + table[0217] = (InstPtr)case217; + table[0220] = (InstPtr)case220; + table[0221] = (InstPtr)case221; + table[0222] = (InstPtr)case222; + table[0223] = (InstPtr)case223; + table[0224] = (InstPtr)case224; + table[0225] = (InstPtr)case225; + table[0226] = (InstPtr)case226; + table[0227] = (InstPtr)case227; + table[0230] = (InstPtr)case230; + table[0231] = (InstPtr)case231; + table[0232] = (InstPtr)case232; + table[0233] = (InstPtr)case233; + table[0234] = (InstPtr)case234; + table[0235] = (InstPtr)case235; + table[0236] = (InstPtr)case236; + table[0237] = (InstPtr)case237; + table[0240] = (InstPtr)case240; + table[0241] = (InstPtr)case241; + table[0242] = (InstPtr)case242; + table[0243] = (InstPtr)case243; + table[0244] = (InstPtr)case244; + table[0245] = (InstPtr)case245; + table[0246] = (InstPtr)case246; + table[0247] = (InstPtr)case247; + table[0250] = (InstPtr)case250; + table[0251] = (InstPtr)case251; + table[0252] = (InstPtr)case252; + table[0253] = (InstPtr)case253; + table[0254] = (InstPtr)case254; + table[0255] = (InstPtr)case255; + table[0256] = (InstPtr)case256; + table[0257] = (InstPtr)case257; + table[0260] = (InstPtr)case260; + table[0261] = (InstPtr)case261; + table[0262] = (InstPtr)case262; + table[0263] = (InstPtr)case263; + table[0264] = (InstPtr)case264; + table[0265] = (InstPtr)case265; + table[0266] = (InstPtr)case266; + table[0267] = (InstPtr)case267; + table[0270] = (InstPtr)case270; + table[0271] = (InstPtr)case271; + table[0272] = (InstPtr)case272; + table[0273] = (InstPtr)case273; + table[0274] = (InstPtr)case274; + table[0275] = (InstPtr)case275; + table[0276] = (InstPtr)case276; + table[0277] = (InstPtr)case277; + table[0300] = (InstPtr)case300; + table[0301] = (InstPtr)case301; + table[0302] = (InstPtr)case302; + table[0303] = (InstPtr)case303; + table[0304] = (InstPtr)case304; + table[0305] = (InstPtr)case305; + table[0306] = (InstPtr)case306; + table[0307] = (InstPtr)case307; + table[0310] = (InstPtr)case310; + table[0311] = (InstPtr)case311; + table[0312] = (InstPtr)case312; + table[0313] = (InstPtr)case313; + table[0314] = (InstPtr)case314; + table[0315] = (InstPtr)case315; + table[0316] = (InstPtr)case316; + table[0317] = (InstPtr)case317; + table[0320] = (InstPtr)case320; + table[0321] = (InstPtr)case321; + table[0322] = (InstPtr)case322; + table[0323] = (InstPtr)case323; + table[0324] = (InstPtr)case324; + table[0325] = (InstPtr)case325; + table[0326] = (InstPtr)case326; + table[0327] = (InstPtr)case327; + table[0330] = (InstPtr)case330; + table[0331] = (InstPtr)case331; + table[0332] = (InstPtr)case332; + table[0333] = (InstPtr)case333; + table[0334] = (InstPtr)case334; + table[0335] = (InstPtr)case335; + table[0336] = (InstPtr)case336; + table[0337] = (InstPtr)case337; + table[0340] = (InstPtr)case340; + table[0341] = (InstPtr)case341; + table[0342] = (InstPtr)case342; + table[0343] = (InstPtr)case343; + table[0344] = (InstPtr)case344; + table[0345] = (InstPtr)case345; + table[0346] = (InstPtr)case346; + table[0347] = (InstPtr)case347; + table[0350] = (InstPtr)case350; + table[0351] = (InstPtr)case351; + table[0352] = (InstPtr)case352; + table[0353] = (InstPtr)case353; + table[0354] = (InstPtr)case354; + table[0355] = (InstPtr)case355; + table[0356] = (InstPtr)case356; + table[0357] = (InstPtr)case357; + table[0360] = (InstPtr)case360; + table[0361] = (InstPtr)case361; + table[0362] = (InstPtr)case362; + table[0363] = (InstPtr)case363; + table[0364] = (InstPtr)case364; + table[0365] = (InstPtr)case365; + table[0366] = (InstPtr)case366; + table[0367] = (InstPtr)case367; + table[0370] = (InstPtr)case370; + table[0371] = (InstPtr)case371; + table[0372] = (InstPtr)case372; + table[0373] = (InstPtr)case373; + table[0374] = (InstPtr)case374; + table[0375] = (InstPtr)case375; + table[0376] = (InstPtr)case376; + table[0377] = (InstPtr)case377; + goto nextopcode; #elif GCC385 - /* This is the optable for 386's under gcc */ + /* This is the optable for 386's under gcc */ -asm volatile(" .data \n\ + asm volatile( + " .data \n\ .align 4"); -asm volatile("optable: \n\ + asm volatile( + "optable: \n\ .long _op000 \n\ .long _op001 \n\ .long _op002 \n\ @@ -1344,7 +1739,8 @@ asm volatile("optable: \n\ .long _op033 \n\ "); -asm volatile("\n\ + asm volatile( + "\n\ .long _op034 \n\ .long _op035 \n\ .long _op036 \n\ @@ -1576,10 +1972,11 @@ asm volatile("\n\ .text"); #elif (DOS && OPDISP) - /* This is the optable for 386's under gcc & Turbo Assembler */ + /* This is the optable for 386's under gcc & Turbo Assembler */ -asm volatile(" align 4"); -asm volatile("optable: \n\ + asm volatile(" align 4"); + asm volatile( + "optable: \n\ DD _op000 \n\ DD _op001 \n\ DD _op002 \n\ @@ -1610,7 +2007,8 @@ asm volatile("optable: \n\ DD _op033 \n\ "); -asm volatile("\n\ + asm volatile( + "\n\ DD _op034 \n\ DD _op035 \n\ DD _op036 \n\ @@ -1839,19 +2237,14 @@ asm volatile("\n\ DD _op375 \n\ DD _op376 \n\ DD _op377"); - asm volatile("\n\ + asm volatile( + "\n\ FP_noint: DW 003fh ;; No interrupts, round to closest, 24bit precision"); - #endif /* ISC */ - #endif /* OPDISP */ +} - - } - - -int retfun(void) {return(0);} +int retfun(void) { return (0); } void do_brk(void) {} - diff --git a/src/xcursor.c b/src/xcursor.c old mode 100755 new mode 100644 index 7488e8e..1c1282c --- a/src/xcursor.c +++ b/src/xcursor.c @@ -1,8 +1,7 @@ -/* $Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989-1995, 2000 Venue. */ @@ -18,8 +17,6 @@ static char *id = "$Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyr #include "version.h" - - #include #if defined(MACOSX) || defined(FREEBSD) #include @@ -37,21 +34,15 @@ static char *id = "$Id: xcursor.c,v 1.4 2001/12/26 22:17:06 sybalsky Exp $ Copyr #include "dbprint.h" #include "devif.h" -extern IOPAGE *IOPage; +extern IOPAGE *IOPage; extern XGCValues gcv; -extern int Lisp_Xinitialized - , Bitmap_Pad - , Default_Depth; +extern int Lisp_Xinitialized, Bitmap_Pad, Default_Depth; XImage CursorImage; -Pixmap CursorPixmap_source - , CursorPixmap_mask; -GC cursor_source_gc - , cursor_mask_gc; -XColor cursor_fore_xcsd - , cursor_back_xcsd - , xced; +Pixmap CursorPixmap_source, CursorPixmap_mask; +GC cursor_source_gc, cursor_mask_gc; +XColor cursor_fore_xcsd, cursor_back_xcsd, xced; extern Colormap Colors; extern DspInterface currentdsp; @@ -72,9 +63,7 @@ int cursor_sw; /* ADD these to the positions we get in SetMouseXY calls. This */ /* way, X and lisp agree where the mouse is */ -int Current_Hot_X = 0, - Current_Hot_Y = 0; - +int Current_Hot_X = 0, Current_Hot_Y = 0; void set_Xcursor(DspInterface, unsigned char *, int, int, Cursor *, int); @@ -87,27 +76,18 @@ void set_Xcursor(DspInterface, unsigned char *, int, int, Cursor *, int); /* */ /************************************************************************/ -void Init_XCursor() -{ +void Init_XCursor() { int i; - DLword *newbm = (DLword *) (IOPage->dlcursorbitmap); + DLword *newbm = (DLword *)(IOPage->dlcursorbitmap); - TPRINT(( "TRACE: Init_DisplayCursor()\n" )); + TPRINT(("TRACE: Init_DisplayCursor()\n")); /* this is guaranteed to be our first cursor, isn't it? */ - cursorlist = (struct MXCURSOR *) malloc(sizeof(struct MXCURSOR)); + cursorlist = (struct MXCURSOR *)malloc(sizeof(struct MXCURSOR)); cursorlist->next = NULL; - for(i=0; ibitmap[i] = newbm[i]; - set_Xcursor( currentdsp, (unsigned char *)newbm, 0, 0, &(cursorlist->Xid), 1); - DefineCursor(currentdsp->display_id, - currentdsp->DisplayWindow, - &(cursorlist->Xid)); -} /* end Init_XCursor */ - - - - - + for (i = 0; i < CURSORHEIGHT; i++) cursorlist->bitmap[i] = newbm[i]; + set_Xcursor(currentdsp, (unsigned char *)newbm, 0, 0, &(cursorlist->Xid), 1); + DefineCursor(currentdsp->display_id, currentdsp->DisplayWindow, &(cursorlist->Xid)); +} /* end Init_XCursor */ /************************************************************************/ /* */ @@ -124,62 +104,53 @@ void Init_XCursor() /* */ /************************************************************************/ -void Set_XCursor( x, y ) - int x, y; +void Set_XCursor(x, y) int x, y; { /* compare cursor in IOPage memory with cursors we've seen before */ register struct MXCURSOR *clp, *clbp; - register DLword *newbm = ((DLword *) (IOPage->dlcursorbitmap)); + register DLword *newbm = ((DLword *)(IOPage->dlcursorbitmap)); register int i; - - XLOCK; /* No signals while setting the cursor */ - for(clp = cursorlist; clp != NULL; clbp = clp, clp = clp->next) { - for(i=0; i< CURSORHEIGHT; i++) - if(clp->bitmap[i] != newbm[i]) break; - if(i == CURSORHEIGHT) break; + XLOCK; /* No signals while setting the cursor */ + for (clp = cursorlist; clp != NULL; clbp = clp, clp = clp->next) { + for (i = 0; i < CURSORHEIGHT; i++) + if (clp->bitmap[i] != newbm[i]) break; + if (i == CURSORHEIGHT) break; } - if(clp == NULL) { /* it isn't there, push on a new one */ - clp = (struct MXCURSOR *) malloc(sizeof (struct MXCURSOR)); + if (clp == NULL) { /* it isn't there, push on a new one */ + clp = (struct MXCURSOR *)malloc(sizeof(struct MXCURSOR)); /* and fill it up with the current new cursor */ - for(i=0; i< CURSORHEIGHT; i++) - clp->bitmap[i] = newbm[i]; + for (i = 0; i < CURSORHEIGHT; i++) clp->bitmap[i] = newbm[i]; #ifdef NEWXCURSOR /* JDS 000521 Added "15-" to fix cursor troubles at window edge */ - set_Xcursor( currentdsp, (unsigned char *) newbm, x, 15-y, &(clp->Xid), 1); + set_Xcursor(currentdsp, (unsigned char *)newbm, x, 15 - y, &(clp->Xid), 1); #else - set_Xcursor( currentdsp, (unsigned char *) newbm, 0, 0, &(clp->Xid), 1); + set_Xcursor(currentdsp, (unsigned char *)newbm, 0, 0, &(clp->Xid), 1); #endif /* NEWXCURSOR */ clp->next = cursorlist; cursorlist = clp; + } else + /* found it, move it to the front of the list + (this should reduce search time on the average by keeping + the popular cursors near the front of the list) + */ + if (clp != cursorlist) { /* don't move if it's already there */ + clbp->next = clp->next; + clp->next = cursorlist; + cursorlist = clp; } - else - /* found it, move it to the front of the list - (this should reduce search time on the average by keeping - the popular cursors near the front of the list) - */ - if(clp != cursorlist) { /* don't move if it's already there */ - clbp->next = clp->next; - clp->next = cursorlist; - cursorlist = clp; - } - DefineCursor(currentdsp->display_id, - currentdsp->DisplayWindow, - &(clp->Xid)); - XUNLOCK; /* Signals OK now */ + DefineCursor(currentdsp->display_id, currentdsp->DisplayWindow, &(clp->Xid)); + XUNLOCK; /* Signals OK now */ #ifdef NEWXCURSOR /* Save the hotspot for later position reporting/setting */ Current_Hot_X = x; - Current_Hot_Y = 15-y; /* Added 15- to fix window-edge trouble */ -#endif /* NEWXCURSOR */ - -} /* end Set_XCursor */ - - + Current_Hot_Y = 15 - y; /* Added 15- to fix window-edge trouble */ +#endif /* NEWXCURSOR */ +} /* end Set_XCursor */ /************************************************************************/ /* */ @@ -189,67 +160,63 @@ void Set_XCursor( x, y ) /* */ /************************************************************************/ -void init_Xcursor(display, window) - Display *display; +void init_Xcursor(display, window) Display *display; { + TPRINT(("TRACE: init_Xcursor()\n")); - TPRINT(( "TRACE: init_Xcursor()\n" )); + XLOCK; /* Take no X signals during this activity (ISC 386) */ - XLOCK; /* Take no X signals during this activity (ISC 386) */ - - CursorImage.width = CURSORWIDTH; - CursorImage.height = CURSORHEIGHT; - CursorImage.xoffset = 0; - CursorImage.format = XYBitmap; -#if (defined (XV11R1) || defined(BYTESWAP)) - CursorImage.byte_order = LSBFirst; -#else /* XV11R1 | BYTESWAP */ - CursorImage.byte_order = MSBFirst; + CursorImage.width = CURSORWIDTH; + CursorImage.height = CURSORHEIGHT; + CursorImage.xoffset = 0; + CursorImage.format = XYBitmap; +#if (defined(XV11R1) || defined(BYTESWAP)) + CursorImage.byte_order = LSBFirst; +#else /* XV11R1 | BYTESWAP */ + CursorImage.byte_order = MSBFirst; #endif /* XV11R1 | BYTESWAP */ - CursorImage.bitmap_unit = BITSPER_DLWORD; + CursorImage.bitmap_unit = BITSPER_DLWORD; #ifdef AIX - CursorImage.bitmap_pad = 32; + CursorImage.bitmap_pad = 32; #else - CursorImage.bitmap_pad = Bitmap_Pad; + CursorImage.bitmap_pad = Bitmap_Pad; #endif /* AIX */ - CursorImage.depth = 1; - CursorImage.bytes_per_line = BITSPER_DLWORD/8; - CursorImage.bitmap_bit_order = MSBFirst; + CursorImage.depth = 1; + CursorImage.bytes_per_line = BITSPER_DLWORD / 8; + CursorImage.bitmap_bit_order = MSBFirst; - CursorPixmap_source = XCreatePixmap( display, window , CURSORWIDTH, CURSORHEIGHT, 1); - CursorPixmap_mask = XCreatePixmap( display, window , CURSORWIDTH, CURSORHEIGHT, 1); + CursorPixmap_source = XCreatePixmap(display, window, CURSORWIDTH, CURSORHEIGHT, 1); + CursorPixmap_mask = XCreatePixmap(display, window, CURSORWIDTH, CURSORHEIGHT, 1); - gcv.function = GXcopy; - gcv.foreground = BlackPixelOfScreen( ScreenOfDisplay( display, DefaultScreen(display))); - gcv.background = WhitePixelOfScreen( ScreenOfDisplay( display, DefaultScreen(display))); + gcv.function = GXcopy; + gcv.foreground = BlackPixelOfScreen(ScreenOfDisplay(display, DefaultScreen(display))); + gcv.background = WhitePixelOfScreen(ScreenOfDisplay(display, DefaultScreen(display))); #ifdef AIX - gcv.plane_mask = 1; + gcv.plane_mask = 1; #endif /* AIX */ - cursor_source_gc = XCreateGC( display, window - , GCForeground|GCBackground|GCFunction + cursor_source_gc = XCreateGC(display, window, + GCForeground | GCBackground | GCFunction #ifdef AIX - |GCPlaneMask + | GCPlaneMask #endif /* AIX */ - , &gcv ); - cursor_mask_gc = XCreateGC( display, window - , GCForeground|GCBackground|GCFunction + , + &gcv); + cursor_mask_gc = XCreateGC(display, window, + GCForeground | GCBackground | GCFunction #ifdef AIX - |GCPlaneMask + | GCPlaneMask #endif /* AIX */ - , &gcv ); + , + &gcv); - XAllocNamedColor( display, Colors, "black" - , &cursor_fore_xcsd, &xced ); - XAllocNamedColor( display, Colors, "white" - , &cursor_back_xcsd, &xced ); - - XUNLOCK; /* OK to take signals again */ - - } /* end init_Xcursor */ + XAllocNamedColor(display, Colors, "black", &cursor_fore_xcsd, &xced); + XAllocNamedColor(display, Colors, "white", &cursor_back_xcsd, &xced); + XUNLOCK; /* OK to take signals again */ +} /* end init_Xcursor */ /************************************************************************/ /* */ @@ -259,13 +226,10 @@ void init_Xcursor(display, window) /* */ /************************************************************************/ -void set_Xcursor( dsp, bitmap, hotspot_x, hotspot_y, return_cursor, from_lisp ) - DspInterface dsp; - unsigned char *bitmap; - int hotspot_x - , hotspot_y - , from_lisp; - Cursor *return_cursor; +void set_Xcursor(dsp, bitmap, hotspot_x, hotspot_y, return_cursor, from_lisp) DspInterface dsp; +unsigned char *bitmap; +int hotspot_x, hotspot_y, from_lisp; +Cursor *return_cursor; { extern unsigned char reversedbits[]; unsigned char image[32]; @@ -273,33 +237,29 @@ void set_Xcursor( dsp, bitmap, hotspot_x, hotspot_y, return_cursor, from_lisp ) Pixmap Cursor_src, Cursor_msk; Screen *screen; -#ifdef BYTESWAP - if (from_lisp) for (i=0; i<32; i++) image[i] = reversedbits[bitmap[i^3]]; - else for ( i=0; i<32; i++) image[i] = reversedbits[bitmap[i]]; +#ifdef BYTESWAP + if (from_lisp) + for (i = 0; i < 32; i++) image[i] = reversedbits[bitmap[i ^ 3]]; + else + for (i = 0; i < 32; i++) image[i] = reversedbits[bitmap[i]]; #else - for ( i=0; i<32; i++) image[i] = reversedbits[bitmap[i]]; + for (i = 0; i < 32; i++) image[i] = reversedbits[bitmap[i]]; #endif /* BYTESWAP */ XLOCK; - screen = ScreenOfDisplay( dsp->display_id, DefaultScreen( dsp->display_id )); - Cursor_src = XCreatePixmapFromBitmapData(dsp->display_id, - dsp->DisplayWindow, - image, 16, 16, 1, 0, - 1); /* Has to have a depth of 1! */ - Cursor_msk = XCreatePixmapFromBitmapData(dsp->display_id, - dsp->DisplayWindow, - image, 16, 16, 1, 0, - 1); /* Has to have a depth of 1! */ - *return_cursor = XCreatePixmapCursor( dsp->display_id - , Cursor_src, Cursor_msk - , &cursor_fore_xcsd, &cursor_back_xcsd - , hotspot_x, hotspot_y ); + screen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)); + Cursor_src = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, image, 16, 16, 1, 0, + 1); /* Has to have a depth of 1! */ + Cursor_msk = XCreatePixmapFromBitmapData(dsp->display_id, dsp->DisplayWindow, image, 16, 16, 1, 0, + 1); /* Has to have a depth of 1! */ + *return_cursor = XCreatePixmapCursor(dsp->display_id, Cursor_src, Cursor_msk, &cursor_fore_xcsd, + &cursor_back_xcsd, hotspot_x, hotspot_y); /* Should free these now (doc says server may not copy them) */ XFreePixmap(dsp->display_id, Cursor_src); XFreePixmap(dsp->display_id, Cursor_msk); - XFlush( dsp->display_id ); + XFlush(dsp->display_id); XUNLOCK; -} /* end set_Xcursor */ +} /* end set_Xcursor */ diff --git a/src/xinit.c b/src/xinit.c old mode 100755 new mode 100644 index 9a21d2f..dec558f --- a/src/xinit.c +++ b/src/xinit.c @@ -1,8 +1,6 @@ -/* $Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ static char *id = "$Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -18,8 +16,6 @@ static char *id = "$Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ Copyrig #include "version.h" - - #include #include #include @@ -62,36 +58,29 @@ static char *id = "$Id: xinit.c,v 1.5 2001/12/26 22:17:06 sybalsky Exp $ Copyrig #endif /* ISC */ #define FALSE 0 -#define TRUE !FALSE +#define TRUE !FALSE #define PERCENT_OF_SCREEN 95 -#define DISPLAY_MAX 65536*16*2 /* same magic number is */ - /* in loadsysout.c */ +#define DISPLAY_MAX 65536 * 16 * 2 /* same magic number is */ + /* in loadsysout.c */ extern DLword *Lisp_world; extern int Lisp_Xinitialized; extern char Display_Name[128]; extern DLword *DisplayRegion68k; int xsync = False; -int Byte_Order - , Bitmap_Bit_Order - , Bitmap_Pad - , Default_Depth - , Display_Height - , Display_Width; +int Byte_Order, Bitmap_Bit_Order, Bitmap_Pad, Default_Depth, Display_Height, Display_Width; int LispWindowRequestedX = 0; -int LispWindowRequestedY = 0; +int LispWindowRequestedY = 0; int LispWindowRequestedWidth = DEF_WIN_WIDTH; int LispWindowRequestedHeight = DEF_WIN_HEIGHT; -int LispDisplayRequestedX, - LispDisplayRequestedY, - LispDisplayRequestedWidth, - LispDisplayRequestedHeight; +int LispDisplayRequestedX, LispDisplayRequestedY, LispDisplayRequestedWidth, + LispDisplayRequestedHeight; Colormap Colors; -int XLocked = 0; /* non-zero while doing X ops, to avoid signals */ +int XLocked = 0; /* non-zero while doing X ops, to avoid signals */ extern int LispReadFds; extern PFUL GenericReturnT(); extern PFUL clipping_Xbitblt(); @@ -103,17 +92,16 @@ extern PFUL clipping_Xbitblt(); /* Turn on the X window we've been using for display. */ /* */ /************************************************************************/ -void init_Xevent(dsp) - DspInterface dsp; -{ +void init_Xevent(dsp) DspInterface dsp; +{ int GravMask, BarMask, LispMask, DisplayMask; - GravMask = ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask; + GravMask = + ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask; BarMask = GravMask; DisplayMask = GravMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask; LispMask = StructureNotifyMask; - XSelectInput(dsp->display_id, dsp->LispWindow, dsp->EnableEventMask); XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask); XSelectInput(dsp->display_id, dsp->HorScrollBar, BarMask); @@ -128,12 +116,11 @@ void init_Xevent(dsp) #ifdef SYSVONLY #ifndef LINUX #ifndef MACOSX - ioctl(ConnectionNumber(dsp->display_id) - , I_SETSIG, S_INPUT); /* so we see X events fast */ + ioctl(ConnectionNumber(dsp->display_id), I_SETSIG, S_INPUT); /* so we see X events fast */ #endif #endif #endif /* SYSVONLY */ -} /*end init_Xevent */ +} /*end init_Xevent */ /************************************************************************/ /* */ @@ -142,25 +129,22 @@ void init_Xevent(dsp) /* Turn off the X window we've been using for display. */ /* */ /************************************************************************/ -void lisp_Xexit(dsp) - DspInterface dsp; - { +void lisp_Xexit(dsp) DspInterface dsp; +{ #ifdef SYSVONLY #ifndef LINUX #ifndef MACOSX - ioctl(ConnectionNumber(dsp->display_id) - , I_SETSIG, 0); /* so no interrupts happen during */ + ioctl(ConnectionNumber(dsp->display_id), I_SETSIG, 0); /* so no interrupts happen during */ #endif #endif #endif /* SYSVONLY */ - XDestroySubwindows( dsp->display_id, dsp->LispWindow ); - XDestroyWindow( dsp->display_id, dsp->LispWindow ); - XCloseDisplay( dsp->display_id ); - - Lisp_Xinitialized = FALSE; - } /* end lisp_Xexit */ + XDestroySubwindows(dsp->display_id, dsp->LispWindow); + XDestroyWindow(dsp->display_id, dsp->LispWindow); + XCloseDisplay(dsp->display_id); + Lisp_Xinitialized = FALSE; +} /* end lisp_Xexit */ /************************************************************************/ /* */ @@ -170,26 +154,23 @@ void lisp_Xexit(dsp) /* the X windows we use for Medley's display. */ /* */ /************************************************************************/ -void Xevent_before_raid(dsp) - DspInterface dsp; - { - TPRINT(( "TRACE: Xevent_before_raid()\n" )); - - XSelectInput( dsp->display_id, dsp->LispWindow, NoEventMask ); - XSelectInput( dsp->display_id, dsp->DisplayWindow, NoEventMask ); - XSelectInput( dsp->display_id, dsp->VerScrollBar, NoEventMask ); - XSelectInput( dsp->display_id, dsp->HorScrollBar, NoEventMask ); - XSelectInput( dsp->display_id, dsp->NEGrav, NoEventMask); - XSelectInput( dsp->display_id, dsp->SEGrav, NoEventMask); - XSelectInput( dsp->display_id, dsp->SWGrav, NoEventMask); - XSelectInput (dsp->display_id, dsp->NWGrav, NoEventMask); - - XLOCK; - XFlush( dsp->display_id ); - XUNLOCK; - } /* end Xevent_before_raid */ +void Xevent_before_raid(dsp) DspInterface dsp; +{ + TPRINT(("TRACE: Xevent_before_raid()\n")); + XSelectInput(dsp->display_id, dsp->LispWindow, NoEventMask); + XSelectInput(dsp->display_id, dsp->DisplayWindow, NoEventMask); + XSelectInput(dsp->display_id, dsp->VerScrollBar, NoEventMask); + XSelectInput(dsp->display_id, dsp->HorScrollBar, NoEventMask); + XSelectInput(dsp->display_id, dsp->NEGrav, NoEventMask); + XSelectInput(dsp->display_id, dsp->SEGrav, NoEventMask); + XSelectInput(dsp->display_id, dsp->SWGrav, NoEventMask); + XSelectInput(dsp->display_id, dsp->NWGrav, NoEventMask); + XLOCK; + XFlush(dsp->display_id); + XUNLOCK; +} /* end Xevent_before_raid */ /************************************************************************/ /* */ @@ -199,20 +180,16 @@ void Xevent_before_raid(dsp) /* from the X server in the windows we use for the display. */ /* */ /************************************************************************/ -void Xevent_after_raid(dsp) - DspInterface dsp; +void Xevent_after_raid(dsp) DspInterface dsp; { - init_Xevent( dsp ); - (dsp->bitblt_to_screen)( dsp, 0, - dsp->Vissible.x, - dsp->Vissible.y, - dsp->Vissible.width, - dsp->Vissible.height ); - XLOCK; - XFlush( dsp->display_id ); - XUNLOCK; + init_Xevent(dsp); + (dsp->bitblt_to_screen)(dsp, 0, dsp->Vissible.x, dsp->Vissible.y, dsp->Vissible.width, + dsp->Vissible.height); + XLOCK; + XFlush(dsp->display_id); + XUNLOCK; - } /* end Xevent_after_raid */ +} /* end Xevent_after_raid */ /************************************************************************/ /* */ @@ -224,17 +201,14 @@ void Xevent_after_raid(dsp) /* */ /* */ /************************************************************************/ -void Open_Display( dsp ) - DspInterface dsp; +void Open_Display(dsp) DspInterface dsp; { - LispReadFds |= (1 << ConnectionNumber(dsp->display_id)); #ifndef ISC #ifndef HPUX fcntl(ConnectionNumber(dsp->display_id), F_SETOWN, getpid()); -#endif /* HPUX */ -#endif /* ISC */ - +#endif /* HPUX */ +#endif /* ISC */ /****************************************************/ /* If debugging, set the X connection so that */ @@ -244,19 +218,17 @@ void Open_Display( dsp ) /****************************************************/ XSynchronize(dsp->display_id, xsync); - Colors = DefaultColormapOfScreen ( ScreenOfDisplay( dsp->display_id, - DefaultScreen( dsp->display_id ) ) ); + Colors = + DefaultColormapOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id))); /* When we make the initial screen we haven't yet read in the */ /* displayregion bitmap. Fix this now. */ - if (dsp->ScreenBitmap.data == NULL) - dsp->ScreenBitmap.data = (char *)DisplayRegion68k; + if (dsp->ScreenBitmap.data == NULL) dsp->ScreenBitmap.data = (char *)DisplayRegion68k; - Create_LispWindow(dsp); /* Make the main window */ + Create_LispWindow(dsp); /* Make the main window */ Lisp_Xinitialized = TRUE; - init_Xevent( dsp ); /* Turn on the intrpts. */ -} /* end OpenDisplay */ - + init_Xevent(dsp); /* Turn on the intrpts. */ +} /* end OpenDisplay */ /*********************************************************************/ /* */ @@ -282,25 +254,20 @@ void Open_Display( dsp ) /* */ /*********************************************************************/ -DspInterface X_init( DspInterface dsp, - char *lispbitmap, - int width_hint, - int height_hint, - int depth_hint ) -{ +DspInterface X_init(DspInterface dsp, char *lispbitmap, int width_hint, int height_hint, + int depth_hint) { Screen *Xscreen; dsp->identifier = Display_Name; /* This is a hack. The display name */ - /* has to dealt with in a more */ - /* gracefull way. */ + /* has to dealt with in a more */ + /* gracefull way. */ /* Try to open the X display. If this isn't possible, we just */ /* return FALSE. */ - if( (dsp->display_id = XOpenDisplay( dsp->identifier )) == NULL ) - return(NULL); + if ((dsp->display_id = XOpenDisplay(dsp->identifier)) == NULL) return (NULL); /* Load the dsp structure */ - Xscreen = ScreenOfDisplay( dsp->display_id, DefaultScreen( dsp->display_id ) ); + Xscreen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)); /* Set the scrollbar and border widths */ dsp->ScrollBarWidth = SCROLL_WIDTH; @@ -310,30 +277,26 @@ DspInterface X_init( DspInterface dsp, dsp->Vissible.y = LispDisplayRequestedY; /* Set the width and height of the display. */ - if ( height_hint == 0 ){ - dsp->Display.height = HeightOfScreen( Xscreen ) - - OUTER_SB_WIDTH(dsp); /* In the default case, - adjust for scroll gadgets*/ - } - else dsp->Display.height = bound(WIN_MIN_HEIGHT, - height_hint, - WIN_MAX_HEIGHT); + if (height_hint == 0) { + dsp->Display.height = + HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case, + adjust for scroll gadgets*/ + } else + dsp->Display.height = bound(WIN_MIN_HEIGHT, height_hint, WIN_MAX_HEIGHT); - if ( width_hint == 0 ){ - dsp->Display.width = WidthOfScreen( Xscreen ) - - OUTER_SB_WIDTH(dsp); /* In the default case, - adjust for scroll gadgets*/ - } - else dsp->Display.width = bound(WIN_MIN_WIDTH, - width_hint, - WIN_MAX_WIDTH); + if (width_hint == 0) { + dsp->Display.width = + WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp); /* In the default case, + adjust for scroll gadgets*/ + } else + dsp->Display.width = bound(WIN_MIN_WIDTH, width_hint, WIN_MAX_WIDTH); /************************************************************/ /* Set the size of ScreenBitMap */ /* The display's width is rounded to a 32-bit multiple, */ /* so that little-Endian machines can display right. */ /************************************************************/ - dsp->Display.width = ((dsp->Display.width+31) >> 5) << 5; + dsp->Display.width = ((dsp->Display.width + 31) >> 5) << 5; dsp->device.enter = (PFV)Open_Display; dsp->device.exit = (PFV)lisp_Xexit; @@ -349,53 +312,49 @@ DspInterface X_init( DspInterface dsp, dsp->set_color_map_entry = (PFUL)GenericReturnT; /* Set the geometry of the Vissible (Lisp) window. */ - dsp->Vissible.width = bound(OUTER_SB_WIDTH(dsp), - LispWindowRequestedWidth, - min(dsp->Display.width, - (WidthOfScreen( Xscreen ) - - OUTER_SB_WIDTH(dsp)))); - dsp->Vissible.height = bound(OUTER_SB_WIDTH(dsp), - LispWindowRequestedHeight, - min(dsp->Display.height, - (HeightOfScreen( Xscreen ) - - OUTER_SB_WIDTH(dsp)))); + dsp->Vissible.width = + bound(OUTER_SB_WIDTH(dsp), LispWindowRequestedWidth, + min(dsp->Display.width, (WidthOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp)))); + dsp->Vissible.height = + bound(OUTER_SB_WIDTH(dsp), LispWindowRequestedHeight, + min(dsp->Display.height, (HeightOfScreen(Xscreen) - OUTER_SB_WIDTH(dsp)))); /* Initialize the screen image structure. */ - dsp->ScreenBitmap.width = dsp->Display.width; - dsp->ScreenBitmap.height = dsp->Display.height; + dsp->ScreenBitmap.width = dsp->Display.width; + dsp->ScreenBitmap.height = dsp->Display.height; dsp->ScreenBitmap.xoffset = 0; - dsp->bitsperpixel = DefaultDepthOfScreen( ScreenOfDisplay( dsp->display_id, - DefaultScreen( dsp->display_id ) ) ); + dsp->bitsperpixel = + DefaultDepthOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id))); #if (defined(BYTESWAP)) - dsp->ScreenBitmap.byte_order = LSBFirst; -#else /* BYTESWAP */ - dsp->ScreenBitmap.byte_order = MSBFirst; -#endif /* BYTESWAP */ + dsp->ScreenBitmap.byte_order = LSBFirst; +#else /* BYTESWAP */ + dsp->ScreenBitmap.byte_order = MSBFirst; +#endif /* BYTESWAP */ - dsp->ScreenBitmap.data = (char *)(lispbitmap?Addr68k_from_LADDR((LispPTR)lispbitmap):0); - - switch(depth_hint){ - case 8: /* Color Screen */ - dsp->ScreenBitmap.format = ZPixmap; - dsp->ScreenBitmap.bitmap_unit = BitmapUnit( dsp->display_id ); - dsp->ScreenBitmap.bitmap_bit_order = MSBFirst; - dsp->ScreenBitmap.bitmap_pad = 32; - dsp->ScreenBitmap.depth = 8; - dsp->ScreenBitmap.bits_per_pixel = 8; - dsp->ScreenBitmap.bytes_per_line = (dsp->Display.width); - dsp->ScreenBitmap.red_mask = 7; - dsp->ScreenBitmap.green_mask = 7; - dsp->ScreenBitmap.blue_mask = 3; - break; - default: /* B/W Screen */ - dsp->ScreenBitmap.format = XYBitmap; - dsp->ScreenBitmap.bitmap_unit = BitmapUnit( dsp->display_id ); - dsp->ScreenBitmap.bitmap_bit_order = MSBFirst; - dsp->ScreenBitmap.bitmap_pad = 32; - dsp->ScreenBitmap.depth = 1; - dsp->ScreenBitmap.bytes_per_line = ((dsp->Display.width+(BITSPER_DLWORD-1)) - /BITSPER_DLWORD) * (BITSPER_DLWORD/8); - break; + dsp->ScreenBitmap.data = (char *)(lispbitmap ? Addr68k_from_LADDR((LispPTR)lispbitmap) : 0); + + switch (depth_hint) { + case 8: /* Color Screen */ + dsp->ScreenBitmap.format = ZPixmap; + dsp->ScreenBitmap.bitmap_unit = BitmapUnit(dsp->display_id); + dsp->ScreenBitmap.bitmap_bit_order = MSBFirst; + dsp->ScreenBitmap.bitmap_pad = 32; + dsp->ScreenBitmap.depth = 8; + dsp->ScreenBitmap.bits_per_pixel = 8; + dsp->ScreenBitmap.bytes_per_line = (dsp->Display.width); + dsp->ScreenBitmap.red_mask = 7; + dsp->ScreenBitmap.green_mask = 7; + dsp->ScreenBitmap.blue_mask = 3; + break; + default: /* B/W Screen */ + dsp->ScreenBitmap.format = XYBitmap; + dsp->ScreenBitmap.bitmap_unit = BitmapUnit(dsp->display_id); + dsp->ScreenBitmap.bitmap_bit_order = MSBFirst; + dsp->ScreenBitmap.bitmap_pad = 32; + dsp->ScreenBitmap.depth = 1; + dsp->ScreenBitmap.bytes_per_line = + ((dsp->Display.width + (BITSPER_DLWORD - 1)) / BITSPER_DLWORD) * (BITSPER_DLWORD / 8); + break; } - return( dsp ); + return (dsp); } diff --git a/src/xlspwin.c b/src/xlspwin.c old mode 100755 new mode 100644 index c8d339b..59c1d9e --- a/src/xlspwin.c +++ b/src/xlspwin.c @@ -1,8 +1,7 @@ -/* $Id: xlspwin.c,v 1.4 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: xlspwin.c,v 1.4 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: xlspwin.c,v 1.4 2001/12/26 22:17:07 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, */ @@ -20,8 +19,6 @@ static char *id = "$Id: xlspwin.c,v 1.4 2001/12/26 22:17:07 sybalsky Exp $ Copyr #include "version.h" - - #include #include #include @@ -36,51 +33,35 @@ static char *id = "$Id: xlspwin.c,v 1.4 2001/12/26 22:17:07 sybalsky Exp $ Copyr #include "devif.h" #include "dbprint.h" -extern DLword *EmKbdAd068K - , *EmKbdAd168K - , *EmKbdAd268K - , *EmKbdAd368K - , *EmKbdAd468K - , *EmKbdAd568K - , *EmRealUtilin68K; +extern DLword *EmKbdAd068K, *EmKbdAd168K, *EmKbdAd268K, *EmKbdAd368K, *EmKbdAd468K, *EmKbdAd568K, + *EmRealUtilin68K; extern DLword *CTopKeyevent; extern LispPTR *KEYBUFFERING68k; -extern int URaid_req - , KBDEventFlg; +extern int URaid_req, KBDEventFlg; extern DLword *DisplayRegion68k; -extern int Current_Hot_X, Current_Hot_Y; /* X Cursor hotspots */ +extern int Current_Hot_X, Current_Hot_Y; /* X Cursor hotspots */ extern char Window_Title[255]; extern char Icon_Title[255]; -extern int save_argc; -extern char **save_argv; +extern int save_argc; +extern char **save_argv; extern DspInterface currentdsp; -Pixmap IconPixmap; -GC CopyInvert_GC; -extern GC cursor_source_gc; -XGCValues gcv; -XEvent report; +Pixmap IconPixmap; +GC CopyInvert_GC; +extern GC cursor_source_gc; +XGCValues gcv; +XEvent report; -Cursor WaitCursor, - DefaultCursor, - VertScrollCursor, - VertThumbCursor, - ScrollUpCursor, - ScrollDownCursor, - HorizScrollCursor, - HorizThumbCursor, - ScrollLeftCursor, - ScrollRightCursor; +Cursor WaitCursor, DefaultCursor, VertScrollCursor, VertThumbCursor, ScrollUpCursor, + ScrollDownCursor, HorizScrollCursor, HorizThumbCursor, ScrollLeftCursor, ScrollRightCursor; -extern int LispWindowRequestedX, - LispWindowRequestedY, - LispWindowRequestedWidht, - LispWindowRequestedHeight; +extern int LispWindowRequestedX, LispWindowRequestedY, LispWindowRequestedWidht, + LispWindowRequestedHeight; /************************************************************************/ /* */ @@ -90,387 +71,254 @@ extern int LispWindowRequestedX, /* */ /************************************************************************/ -void Create_LispWindow(dsp) - DspInterface dsp; +void Create_LispWindow(dsp) DspInterface dsp; { - XSizeHints szhint; - XWMHints Lisp_WMhints; - XClassHint xclasshint; - XTextProperty IconText, WindowNameText; + XSizeHints szhint; + XWMHints Lisp_WMhints; + XClassHint xclasshint; + XTextProperty IconText, WindowNameText; XSetWindowAttributes Lisp_SetWinAttributes; Screen *screen; Window lspwinRoot; int lspwinX, lspwinY, Col2, Row2, Col3, Row3, GravSize; - unsigned int lspwinHeight , lspwinWidth, lspwinBorder, lspwinDepth; + unsigned int lspwinHeight, lspwinWidth, lspwinBorder, lspwinDepth; char *WT, *IT; WT = Window_Title; IT = Icon_Title; - GravSize = (int)(dsp->ScrollBarWidth/2) - (dsp->InternalBorderWidth); + GravSize = (int)(dsp->ScrollBarWidth / 2) - (dsp->InternalBorderWidth); Col2 = dsp->Vissible.width; Row2 = dsp->Vissible.height; - Col3 = dsp->Vissible.width + (int)(OUTER_SB_WIDTH(dsp)/2); - Row3 = dsp->Vissible.height + (int)(OUTER_SB_WIDTH(dsp)/2); + Col3 = dsp->Vissible.width + (int)(OUTER_SB_WIDTH(dsp) / 2); + Row3 = dsp->Vissible.height + (int)(OUTER_SB_WIDTH(dsp) / 2); - screen = ScreenOfDisplay( dsp->display_id, DefaultScreen( dsp->display_id )); - dsp->LispWindow = XCreateSimpleWindow( dsp->display_id, - RootWindowOfScreen( screen ), - LispWindowRequestedX, /* Default upper left */ - LispWindowRequestedY, /* Default upper left */ - dsp->Vissible.width + OUTER_SB_WIDTH( dsp ), /* Default width */ - dsp->Vissible.height + OUTER_SB_WIDTH( dsp ), /* Default height */ - 0, /* Default border */ - BlackPixelOfScreen( screen ), - WhitePixelOfScreen( screen ) ); + screen = ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)); + dsp->LispWindow = XCreateSimpleWindow( + dsp->display_id, RootWindowOfScreen(screen), LispWindowRequestedX, /* Default upper left */ + LispWindowRequestedY, /* Default upper left */ + dsp->Vissible.width + OUTER_SB_WIDTH(dsp), /* Default width */ + dsp->Vissible.height + OUTER_SB_WIDTH(dsp), /* Default height */ + 0, /* Default border */ + BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); Lisp_SetWinAttributes.bit_gravity = dsp->BitGravity; Lisp_SetWinAttributes.override_redirect = False; - Lisp_SetWinAttributes.backing_store = DoesBackingStore( screen ); + Lisp_SetWinAttributes.backing_store = DoesBackingStore(screen); - XChangeWindowAttributes( dsp->display_id - , dsp->LispWindow - , CWBitGravity | CWOverrideRedirect - , &Lisp_SetWinAttributes ); + XChangeWindowAttributes(dsp->display_id, dsp->LispWindow, CWBitGravity | CWOverrideRedirect, + &Lisp_SetWinAttributes); dsp->DisableEventMask = NoEventMask; - dsp->EnableEventMask = ButtonPressMask | - ButtonReleaseMask | - EnterWindowMask | - LeaveWindowMask | - StructureNotifyMask | - PointerMotionMask | - ExposureMask | - KeyPressMask | - KeyReleaseMask; + dsp->EnableEventMask = ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | + StructureNotifyMask | PointerMotionMask | ExposureMask | KeyPressMask | + KeyReleaseMask; /* Have to make the GC before we make the icon. */ - gcv.function = GXcopy; - gcv.foreground = BlackPixelOfScreen( ScreenOfDisplay( dsp->display_id, - DefaultScreen( dsp->display_id ))); - gcv.background = WhitePixelOfScreen( ScreenOfDisplay( dsp->display_id, - DefaultScreen( dsp->display_id ))); - dsp->Copy_GC = XCreateGC( dsp->display_id, dsp->LispWindow - , GCForeground | GCBackground | GCFunction - , &gcv ); + gcv.function = GXcopy; + gcv.foreground = + BlackPixelOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id))); + gcv.background = + WhitePixelOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id))); + dsp->Copy_GC = + XCreateGC(dsp->display_id, dsp->LispWindow, GCForeground | GCBackground | GCFunction, &gcv); - szhint.max_width = dsp->Display.width + OUTER_SB_WIDTH( dsp ); - szhint.max_height = dsp->Display.height + OUTER_SB_WIDTH( dsp ); - szhint.min_width = OUTER_SB_WIDTH( dsp ); - szhint.min_height = OUTER_SB_WIDTH( dsp ); + szhint.max_width = dsp->Display.width + OUTER_SB_WIDTH(dsp); + szhint.max_height = dsp->Display.height + OUTER_SB_WIDTH(dsp); + szhint.min_width = OUTER_SB_WIDTH(dsp); + szhint.min_height = OUTER_SB_WIDTH(dsp); szhint.win_gravity = dsp->BitGravity; szhint.flags = PMaxSize | PWinGravity | PSize | PPosition; Lisp_WMhints.icon_pixmap = make_Xicon(dsp); Lisp_WMhints.input = True; - Lisp_WMhints.flags = IconPixmapHint | InputHint; + Lisp_WMhints.flags = IconPixmapHint | InputHint; xclasshint.res_name = *save_argv; xclasshint.res_class = *save_argv; - XStringListToTextProperty(&WT , 1, &WindowNameText); + XStringListToTextProperty(&WT, 1, &WindowNameText); XStringListToTextProperty(&IT, 1, &IconText); - XSetWMProperties( dsp->display_id, - dsp->LispWindow, - &WindowNameText, - &IconText, - save_argv, - save_argc, - &szhint, - &Lisp_WMhints, - &xclasshint); + XSetWMProperties(dsp->display_id, dsp->LispWindow, &WindowNameText, &IconText, save_argv, + save_argc, &szhint, &Lisp_WMhints, &xclasshint); - XSelectInput( dsp->display_id, dsp->LispWindow, dsp->EnableEventMask ); + XSelectInput(dsp->display_id, dsp->LispWindow, dsp->EnableEventMask); init_Xcursor(dsp->display_id, dsp->LispWindow); - dsp->DisplayWindow = XCreateSimpleWindow( dsp->display_id, - dsp->LispWindow, - 0, 0, dsp->Vissible.width, dsp->Vissible.height, 0, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - XChangeWindowAttributes( dsp->display_id - , dsp->DisplayWindow - , CWBitGravity | CWOverrideRedirect | CWBackingStore - , &Lisp_SetWinAttributes ); - XSelectInput( dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask ); - XMapWindow( dsp->display_id, dsp->DisplayWindow ); + dsp->DisplayWindow = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, 0, 0, + dsp->Vissible.width, dsp->Vissible.height, 0, + BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); + XChangeWindowAttributes(dsp->display_id, dsp->DisplayWindow, + CWBitGravity | CWOverrideRedirect | CWBackingStore, + &Lisp_SetWinAttributes); + XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask); + XMapWindow(dsp->display_id, dsp->DisplayWindow); /*********************************************************************/ /* Create all the vanilla pixmaps and cursors for the display window */ /*********************************************************************/ - dsp->ScrollBarPixmap = - XCreatePixmapFromBitmapData( dsp->display_id, - dsp->LispWindow, - check_bits, - check_width, - check_height, - BlackPixelOfScreen( screen ), - WhitePixelOfScreen( screen ), - DefaultDepthOfScreen( screen )); - dsp->GravityOnPixmap = - XCreatePixmapFromBitmapData(dsp->display_id, - dsp->LispWindow, - check_bits, - 16, 16, - BlackPixelOfScreen( screen ), - WhitePixelOfScreen( screen ), - DefaultDepthOfScreen( screen )); + dsp->ScrollBarPixmap = XCreatePixmapFromBitmapData( + dsp->display_id, dsp->LispWindow, check_bits, check_width, check_height, + BlackPixelOfScreen(screen), WhitePixelOfScreen(screen), DefaultDepthOfScreen(screen)); + dsp->GravityOnPixmap = XCreatePixmapFromBitmapData( + dsp->display_id, dsp->LispWindow, check_bits, 16, 16, BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen), DefaultDepthOfScreen(screen)); - dsp->GravityOffPixmap = - XCreatePixmapFromBitmapData(dsp->display_id, - dsp->LispWindow, - plain_bits, - 16, 16, - BlackPixelOfScreen( screen ), - WhitePixelOfScreen( screen ), - DefaultDepthOfScreen( screen )); + dsp->GravityOffPixmap = XCreatePixmapFromBitmapData( + dsp->display_id, dsp->LispWindow, plain_bits, 16, 16, BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen), DefaultDepthOfScreen(screen)); - set_Xcursor( dsp - , (char*) default_cursor.cuimage - , (int) default_cursor.cuhotspotx - , (int) (15 - default_cursor.cuhotspoty) - , &DefaultCursor, 0 ); - set_Xcursor( dsp - , (char*) wait_cursor.cuimage - , (int) wait_cursor.cuhotspotx - , (int) (15 - wait_cursor.cuhotspoty) - , &WaitCursor, 0 ); - set_Xcursor( dsp - , (char*)scrolldown_cursor.cuimage - , (int) scrolldown_cursor.cuhotspotx - , (int) (15 - scrolldown_cursor.cuhotspoty) - , &ScrollDownCursor, 0 ); - set_Xcursor( dsp - , (char*)scrollleft_cursor.cuimage - , (int) scrollleft_cursor.cuhotspotx - , (int) (15 - scrollleft_cursor.cuhotspoty) - , &ScrollLeftCursor , 0); - set_Xcursor( dsp - , (char*)vertscroll_cursor.cuimage - , (int) vertscroll_cursor.cuhotspotx - , (int) (15 - vertscroll_cursor.cuhotspoty) - , &VertScrollCursor, 0 ); - set_Xcursor( dsp - , (char*)vertthumb_cursor.cuimage - , (int) vertthumb_cursor.cuhotspotx - , (int) (15 - vertthumb_cursor.cuhotspoty) - , &VertThumbCursor, 0 ); - set_Xcursor( dsp - , (char*)horizscroll_cursor.cuimage - , (int) horizscroll_cursor.cuhotspotx - , (int) (15 - horizscroll_cursor.cuhotspoty) - , &HorizScrollCursor, 0 ); - set_Xcursor( dsp - , (char*)horizthumb_cursor.cuimage - , (int) horizthumb_cursor.cuhotspotx - , (int) (15 - horizthumb_cursor.cuhotspoty) - , &HorizThumbCursor, 0 ); - set_Xcursor( dsp - , (char*)scrollright_cursor.cuimage - , (int) scrollright_cursor.cuhotspotx - , (int) (15 - scrollright_cursor.cuhotspoty) - , &ScrollRightCursor, 0 ); - set_Xcursor( dsp - , (char*)scrollup_cursor.cuimage - , (int) scrollup_cursor.cuhotspotx - , (int) (15 - scrollup_cursor.cuhotspoty) - , &ScrollUpCursor, 0 ); + set_Xcursor(dsp, (char *)default_cursor.cuimage, (int)default_cursor.cuhotspotx, + (int)(15 - default_cursor.cuhotspoty), &DefaultCursor, 0); + set_Xcursor(dsp, (char *)wait_cursor.cuimage, (int)wait_cursor.cuhotspotx, + (int)(15 - wait_cursor.cuhotspoty), &WaitCursor, 0); + set_Xcursor(dsp, (char *)scrolldown_cursor.cuimage, (int)scrolldown_cursor.cuhotspotx, + (int)(15 - scrolldown_cursor.cuhotspoty), &ScrollDownCursor, 0); + set_Xcursor(dsp, (char *)scrollleft_cursor.cuimage, (int)scrollleft_cursor.cuhotspotx, + (int)(15 - scrollleft_cursor.cuhotspoty), &ScrollLeftCursor, 0); + set_Xcursor(dsp, (char *)vertscroll_cursor.cuimage, (int)vertscroll_cursor.cuhotspotx, + (int)(15 - vertscroll_cursor.cuhotspoty), &VertScrollCursor, 0); + set_Xcursor(dsp, (char *)vertthumb_cursor.cuimage, (int)vertthumb_cursor.cuhotspotx, + (int)(15 - vertthumb_cursor.cuhotspoty), &VertThumbCursor, 0); + set_Xcursor(dsp, (char *)horizscroll_cursor.cuimage, (int)horizscroll_cursor.cuhotspotx, + (int)(15 - horizscroll_cursor.cuhotspoty), &HorizScrollCursor, 0); + set_Xcursor(dsp, (char *)horizthumb_cursor.cuimage, (int)horizthumb_cursor.cuhotspotx, + (int)(15 - horizthumb_cursor.cuhotspoty), &HorizThumbCursor, 0); + set_Xcursor(dsp, (char *)scrollright_cursor.cuimage, (int)scrollright_cursor.cuhotspotx, + (int)(15 - scrollright_cursor.cuhotspoty), &ScrollRightCursor, 0); + set_Xcursor(dsp, (char *)scrollup_cursor.cuimage, (int)scrollup_cursor.cuhotspotx, + (int)(15 - scrollup_cursor.cuhotspoty), &ScrollUpCursor, 0); /********************************/ /* Make all the toolkit windows */ /********************************/ - dsp->VerScrollBar = XCreateSimpleWindow( dsp->display_id, - dsp->LispWindow, - Col2, - 0-dsp->InternalBorderWidth, /* y */ - dsp->ScrollBarWidth, /* width */ - dsp->Vissible.height, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - DefineCursor( dsp->display_id, dsp->VerScrollBar, &VertScrollCursor ); - XMapWindow( dsp->display_id, dsp->VerScrollBar ); + dsp->VerScrollBar = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col2, + 0 - dsp->InternalBorderWidth, /* y */ + dsp->ScrollBarWidth, /* width */ + dsp->Vissible.height, dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); + DefineCursor(dsp->display_id, dsp->VerScrollBar, &VertScrollCursor); + XMapWindow(dsp->display_id, dsp->VerScrollBar); - dsp->HorScrollBar = XCreateSimpleWindow( dsp->display_id, - dsp->LispWindow, - 0-dsp->InternalBorderWidth, - Row2, /* y */ - dsp->Vissible.width, /* width */ - dsp->ScrollBarWidth, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - DefineCursor( dsp->display_id, dsp->HorScrollBar, &HorizScrollCursor ); - XChangeWindowAttributes( dsp->display_id - , dsp->HorScrollBar - , CWOverrideRedirect - , &Lisp_SetWinAttributes ); - XMapWindow( dsp->display_id, dsp->HorScrollBar ); + dsp->HorScrollBar = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, + 0 - dsp->InternalBorderWidth, Row2, /* y */ + dsp->Vissible.width, /* width */ + dsp->ScrollBarWidth, dsp->InternalBorderWidth, + BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); + DefineCursor(dsp->display_id, dsp->HorScrollBar, &HorizScrollCursor); + XChangeWindowAttributes(dsp->display_id, dsp->HorScrollBar, CWOverrideRedirect, + &Lisp_SetWinAttributes); + XMapWindow(dsp->display_id, dsp->HorScrollBar); - dsp->VerScrollButton = XCreateSimpleWindow( dsp->display_id, - dsp->VerScrollBar, - 0-dsp->InternalBorderWidth, /* x */ - (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height), /* y */ - dsp->ScrollBarWidth, /* width */ - (int)((dsp->Vissible.height*dsp->Vissible.height) / dsp->Display.height) + 1, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - XChangeWindowAttributes( dsp->display_id - , dsp->VerScrollButton - , CWOverrideRedirect - , &Lisp_SetWinAttributes ); - XSetWindowBackgroundPixmap( dsp->display_id, - dsp->VerScrollButton, - dsp->ScrollBarPixmap ); - XClearWindow( dsp->display_id, dsp->VerScrollButton ); - XMapWindow( dsp->display_id, dsp->VerScrollButton ); + dsp->VerScrollButton = XCreateSimpleWindow( + dsp->display_id, dsp->VerScrollBar, 0 - dsp->InternalBorderWidth, /* x */ + (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height), /* y */ + dsp->ScrollBarWidth, /* width */ + (int)((dsp->Vissible.height * dsp->Vissible.height) / dsp->Display.height) + 1, + dsp->InternalBorderWidth, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen)); + XChangeWindowAttributes(dsp->display_id, dsp->VerScrollButton, CWOverrideRedirect, + &Lisp_SetWinAttributes); + XSetWindowBackgroundPixmap(dsp->display_id, dsp->VerScrollButton, dsp->ScrollBarPixmap); + XClearWindow(dsp->display_id, dsp->VerScrollButton); + XMapWindow(dsp->display_id, dsp->VerScrollButton); - dsp->HorScrollButton = XCreateSimpleWindow( dsp->display_id, - dsp->HorScrollBar, - (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width), - 0-dsp->InternalBorderWidth, /* y */ - (int)((dsp->Vissible.width*dsp->Vissible.width)/ dsp->Display.width) + 1, - dsp->ScrollBarWidth, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - XChangeWindowAttributes( dsp->display_id - , dsp->HorScrollButton - , CWOverrideRedirect - , &Lisp_SetWinAttributes ); - XSetWindowBackgroundPixmap( dsp->display_id, - dsp->HorScrollButton, - dsp->ScrollBarPixmap ); - XClearWindow( dsp->display_id, dsp->HorScrollButton ); - XMapWindow( dsp->display_id, dsp->HorScrollButton ); + dsp->HorScrollButton = XCreateSimpleWindow( + dsp->display_id, dsp->HorScrollBar, + (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width), + 0 - dsp->InternalBorderWidth, /* y */ + (int)((dsp->Vissible.width * dsp->Vissible.width) / dsp->Display.width) + 1, + dsp->ScrollBarWidth, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XChangeWindowAttributes(dsp->display_id, dsp->HorScrollButton, CWOverrideRedirect, + &Lisp_SetWinAttributes); + XSetWindowBackgroundPixmap(dsp->display_id, dsp->HorScrollButton, dsp->ScrollBarPixmap); + XClearWindow(dsp->display_id, dsp->HorScrollButton); + XMapWindow(dsp->display_id, dsp->HorScrollButton); - dsp->NWGrav = XCreateSimpleWindow( dsp->display_id, - dsp->LispWindow, - Col2, Row2, GravSize, GravSize, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - XSetWindowBackgroundPixmap( dsp->display_id - , dsp->NWGrav - , dsp->GravityOnPixmap ); - DefineCursor( dsp->display_id, dsp->NWGrav, &DefaultCursor ); - XChangeWindowAttributes( dsp->display_id - , dsp->NWGrav - , CWOverrideRedirect - , &Lisp_SetWinAttributes ); - XClearWindow( dsp->display_id, dsp->NWGrav ); - XMapWindow( dsp->display_id, dsp->NWGrav ); + dsp->NWGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col2, Row2, GravSize, + GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap(dsp->display_id, dsp->NWGrav, dsp->GravityOnPixmap); + DefineCursor(dsp->display_id, dsp->NWGrav, &DefaultCursor); + XChangeWindowAttributes(dsp->display_id, dsp->NWGrav, CWOverrideRedirect, &Lisp_SetWinAttributes); + XClearWindow(dsp->display_id, dsp->NWGrav); + XMapWindow(dsp->display_id, dsp->NWGrav); - dsp->SEGrav = XCreateSimpleWindow( dsp->display_id, - dsp->LispWindow, - Col3, Row3, GravSize, GravSize, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - XSetWindowBackgroundPixmap( dsp->display_id - , dsp->SEGrav - , dsp->GravityOffPixmap ); - DefineCursor( dsp->display_id, dsp->SEGrav, &DefaultCursor ); - XChangeWindowAttributes( dsp->display_id - , dsp->SEGrav - , CWOverrideRedirect - , &Lisp_SetWinAttributes ); - XClearWindow( dsp->display_id, dsp->NWGrav ); - XMapWindow( dsp->display_id, dsp->SEGrav ); + dsp->SEGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col3, Row3, GravSize, + GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap(dsp->display_id, dsp->SEGrav, dsp->GravityOffPixmap); + DefineCursor(dsp->display_id, dsp->SEGrav, &DefaultCursor); + XChangeWindowAttributes(dsp->display_id, dsp->SEGrav, CWOverrideRedirect, &Lisp_SetWinAttributes); + XClearWindow(dsp->display_id, dsp->NWGrav); + XMapWindow(dsp->display_id, dsp->SEGrav); - dsp->SWGrav = XCreateSimpleWindow( dsp->display_id, - dsp->LispWindow, - Col2, Row3, GravSize, GravSize, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - XSetWindowBackgroundPixmap( dsp->display_id - , dsp->SWGrav - , dsp->GravityOffPixmap ); - DefineCursor( dsp->display_id, dsp->SWGrav, &DefaultCursor ); - XClearWindow( dsp->display_id, dsp->NWGrav ); - XMapWindow( dsp->display_id, dsp->SWGrav ); + dsp->SWGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col2, Row3, GravSize, + GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap(dsp->display_id, dsp->SWGrav, dsp->GravityOffPixmap); + DefineCursor(dsp->display_id, dsp->SWGrav, &DefaultCursor); + XClearWindow(dsp->display_id, dsp->NWGrav); + XMapWindow(dsp->display_id, dsp->SWGrav); - dsp->NEGrav = XCreateSimpleWindow( dsp->display_id, - dsp->LispWindow, - Col3, Row2, GravSize, GravSize, - dsp->InternalBorderWidth, - BlackPixelOfScreen(screen), - WhitePixelOfScreen(screen)); - XSetWindowBackgroundPixmap( dsp->display_id - , dsp->NEGrav - , dsp->GravityOffPixmap ); - DefineCursor( dsp->display_id, dsp->NEGrav, &DefaultCursor ); - XClearWindow( dsp->display_id, dsp->NWGrav ); - XMapWindow( dsp->display_id, dsp->NEGrav ); + dsp->NEGrav = XCreateSimpleWindow(dsp->display_id, dsp->LispWindow, Col3, Row2, GravSize, + GravSize, dsp->InternalBorderWidth, BlackPixelOfScreen(screen), + WhitePixelOfScreen(screen)); + XSetWindowBackgroundPixmap(dsp->display_id, dsp->NEGrav, dsp->GravityOffPixmap); + DefineCursor(dsp->display_id, dsp->NEGrav, &DefaultCursor); + XClearWindow(dsp->display_id, dsp->NWGrav); + XMapWindow(dsp->display_id, dsp->NEGrav); /* DefineCursor( dsp->display_id, dsp->DisplayWindow, &WaitCursor ); */ XLOCK; - XMapWindow( dsp->display_id, dsp->LispWindow ); + XMapWindow(dsp->display_id, dsp->LispWindow); XFlush(dsp->display_id); XUNLOCK; -} +} - -void lisp_Xvideocolor( flag ) -int flag; +void lisp_Xvideocolor(flag) int flag; { XLOCK; - XCopyArea( currentdsp->display_id - , currentdsp->DisplayWindow - , currentdsp->DisplayWindow - , currentdsp->Copy_GC - , 0, 0 - , currentdsp->Vissible.width - , currentdsp->Vissible.height - , 0, 0 ); + XCopyArea(currentdsp->display_id, currentdsp->DisplayWindow, currentdsp->DisplayWindow, + currentdsp->Copy_GC, 0, 0, currentdsp->Vissible.width, currentdsp->Vissible.height, 0, + 0); /* Cursor */ gcv.function = GXcopy; - XChangeGC( currentdsp->display_id, cursor_source_gc , GCFunction , &gcv ); + XChangeGC(currentdsp->display_id, cursor_source_gc, GCFunction, &gcv); /* JDS 011213: Remember set_xcursor does 15-y val, so do it here! */ - Set_XCursor( Current_Hot_X, 15-Current_Hot_Y ); + Set_XCursor(Current_Hot_X, 15 - Current_Hot_Y); XFlush(currentdsp->display_id); XUNLOCK; - + } /* end lisp_Xvideocolor */ +extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ - - -extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ - -void set_Xmouseposition( x, y ) - int x - , y; +void set_Xmouseposition(x, y) int x, y; { - int dest_x - , dest_y; - - TPRINT(( "set_Xmouseposition(%d,%d)\n", x, y )); - - dest_x = (x&0xFFFF) + Current_Hot_X - currentdsp->Vissible.x; - dest_y = (y&0xFFFF) + Current_Hot_Y - currentdsp->Vissible.y; - - if( (dest_x>=0) && (dest_x<= currentdsp->Vissible.width) - && (dest_y>=0) && (dest_y<=currentdsp->Vissible.height) ) { + int dest_x, dest_y; + + TPRINT(("set_Xmouseposition(%d,%d)\n", x, y)); + + dest_x = (x & 0xFFFF) + Current_Hot_X - currentdsp->Vissible.x; + dest_y = (y & 0xFFFF) + Current_Hot_Y - currentdsp->Vissible.y; + + if ((dest_x >= 0) && (dest_x <= currentdsp->Vissible.width) && (dest_y >= 0) && + (dest_y <= currentdsp->Vissible.height)) { XLOCK; - XWarpPointer( currentdsp->display_id, (Window)NULL, currentdsp->DisplayWindow - , 0, 0 - , 0, 0 - , dest_x, dest_y ); - XFlush( currentdsp->display_id ); + XWarpPointer(currentdsp->display_id, (Window)NULL, currentdsp->DisplayWindow, 0, 0, 0, 0, + dest_x, dest_y); + XFlush(currentdsp->display_id); XUNLOCK; } -} /* end set_Xmouseposition */ - +} /* end set_Xmouseposition */ /************************************************************************/ /* */ @@ -481,65 +329,59 @@ void set_Xmouseposition( x, y ) /* */ /************************************************************************/ -void DoRing() - { - DLword w - , r; - KBEVENT *kbevent; - - TPRINT(( "TRACE: DoRing()\n" )); +void DoRing() { + DLword w, r; + KBEVENT *kbevent; + TPRINT(("TRACE: DoRing()\n")); do_ring: - if(((*EmKbdAd268K) & 2113) == 0) - { /*Ctrl-shift-NEXT*/ - error("****** EMERGENCY Interrupt ******"); - *EmKbdAd268K=KB_ALLUP; /*reset*/ - ((RING*)CTopKeyevent)->read=0; /* reset queue */ - ((RING*)CTopKeyevent)->write=MINKEYEVENT; - /*return(0);*/ - } - else if(((*EmKbdAd268K) & 2114) == 0) - { /* Ctrl-Shift-DEL */ - *EmKbdAd268K=KB_ALLUP; /*reset*/ - URaid_req=T; - ((RING*)CTopKeyevent)->read=0; /* reset queue */ - ((RING*)CTopKeyevent)->write=MINKEYEVENT; - /*return(0);*/ - } - + if (((*EmKbdAd268K) & 2113) == 0) { /*Ctrl-shift-NEXT*/ + error("****** EMERGENCY Interrupt ******"); + *EmKbdAd268K = KB_ALLUP; /*reset*/ + ((RING *)CTopKeyevent)->read = 0; /* reset queue */ + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + /*return(0);*/ + } else if (((*EmKbdAd268K) & 2114) == 0) { /* Ctrl-Shift-DEL */ + *EmKbdAd268K = KB_ALLUP; /*reset*/ + URaid_req = T; + ((RING *)CTopKeyevent)->read = 0; /* reset queue */ + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + /*return(0);*/ + } + #ifdef OS4_TYPE4BUG - else if(((*EmKbdAd268K) & 2120) == 0) - { /* Ctrl-Shift-Return */ - *EmKbdAd268K=KB_ALLUP; /*reset*/ - URaid_req=T; - ((RING*)CTopKeyevent)->read=0; /* reset queue */ - ((RING*)CTopKeyevent)->write=MINKEYEVENT; - } + else if (((*EmKbdAd268K) & 2120) == 0) { /* Ctrl-Shift-Return */ + *EmKbdAd268K = KB_ALLUP; /*reset*/ + URaid_req = T; + ((RING *)CTopKeyevent)->read = 0; /* reset queue */ + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + } #endif - r=RING_READ(CTopKeyevent); - w=RING_WRITE(CTopKeyevent); + r = RING_READ(CTopKeyevent); + w = RING_WRITE(CTopKeyevent); - if(r==w) /* event queqe FULL */ - goto KBnext; + if (r == w) /* event queqe FULL */ + goto KBnext; - kbevent=(KBEVENT*)(CTopKeyevent+ w); -/* RCLK(kbevent->time); */ - kbevent->W0= *EmKbdAd068K; - kbevent->W1= *EmKbdAd168K; - kbevent->W2= *EmKbdAd268K; - kbevent->W3= *EmKbdAd368K; - kbevent->W4= *EmKbdAd468K; - kbevent->W5= *EmKbdAd568K; - kbevent->WU= *EmRealUtilin68K; + kbevent = (KBEVENT *)(CTopKeyevent + w); + /* RCLK(kbevent->time); */ + kbevent->W0 = *EmKbdAd068K; + kbevent->W1 = *EmKbdAd168K; + kbevent->W2 = *EmKbdAd268K; + kbevent->W3 = *EmKbdAd368K; + kbevent->W4 = *EmKbdAd468K; + kbevent->W5 = *EmKbdAd568K; + kbevent->WU = *EmRealUtilin68K; - if(r==0) /* Queue was empty */ - ((RING*)CTopKeyevent)->read=w; - if(w >= MAXKEYEVENT) ((RING*)CTopKeyevent)->write = MINKEYEVENT; - else ((RING*)CTopKeyevent)->write = w + KEYEVENTSIZE; + if (r == 0) /* Queue was empty */ + ((RING *)CTopKeyevent)->read = w; + if (w >= MAXKEYEVENT) + ((RING *)CTopKeyevent)->write = MINKEYEVENT; + else + ((RING *)CTopKeyevent)->write = w + KEYEVENTSIZE; - KBnext: - if(*KEYBUFFERING68k ==NIL) *KEYBUFFERING68k=ATOM_T; - - } +KBnext: + if (*KEYBUFFERING68k == NIL) *KEYBUFFERING68k = ATOM_T; +} diff --git a/src/xmkicon.c b/src/xmkicon.c old mode 100755 new mode 100644 index 56393ba..cf55f74 --- a/src/xmkicon.c +++ b/src/xmkicon.c @@ -1,8 +1,7 @@ -/* $Id: xmkicon.c,v 1.3 2001/12/24 01:09:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: xmkicon.c,v 1.3 2001/12/24 01:09:09 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: xmkicon.c,v 1.3 2001/12/24 01:09:09 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -18,10 +17,6 @@ static char *id = "$Id: xmkicon.c,v 1.3 2001/12/24 01:09:09 sybalsky Exp $ Copyr #include "version.h" - - - - #include #include @@ -34,15 +29,12 @@ static char *id = "$Id: xmkicon.c,v 1.3 2001/12/24 01:09:09 sybalsky Exp $ Copyr XImage IconImage; -extern int Bitmap_Pad , Default_Depth, Lisp_icon_width, Lisp_icon_height; +extern int Bitmap_Pad, Default_Depth, Lisp_icon_width, Lisp_icon_height; extern char Lisp_icon[]; extern Pixmap IconPixmap; extern char iconpixmapfile[1024]; - - - /************************************************************************/ /* */ /* m a k e _ X i c o n */ @@ -51,56 +43,48 @@ extern char iconpixmapfile[1024]; /* */ /************************************************************************/ -Pixmap make_Xicon( dsp ) - DspInterface dsp; - { - unsigned int width, height; - int value, x_hot, y_hot; - char *getenv(); - -#ifdef TRACE - printf( "In make_Xicon().\n" ); +Pixmap make_Xicon(dsp) DspInterface dsp; +{ + unsigned int width, height; + int value, x_hot, y_hot; + char *getenv(); + +#ifdef TRACE + printf("In make_Xicon().\n"); #endif - value = XReadBitmapFile(dsp->display_id, - RootWindow(dsp->display_id, 0), - iconpixmapfile, - &width, &height, - &IconPixmap, - &x_hot, &y_hot); - if (value == BitmapOpenFailed) { - IconImage.width = Lisp_icon_width; - IconImage.height = Lisp_icon_height; - IconImage.xoffset = 0; - IconImage.format = XYBitmap; - IconImage.data = (char*) Lisp_icon; + value = XReadBitmapFile(dsp->display_id, RootWindow(dsp->display_id, 0), iconpixmapfile, &width, + &height, &IconPixmap, &x_hot, &y_hot); + if (value == BitmapOpenFailed) { + IconImage.width = Lisp_icon_width; + IconImage.height = Lisp_icon_height; + IconImage.xoffset = 0; + IconImage.format = XYBitmap; + IconImage.data = (char *)Lisp_icon; #if defined(BYTESWAP) - IconImage.byte_order = LSBFirst; -#else /* BYTESWAP */ - IconImage.byte_order = MSBFirst; + IconImage.byte_order = LSBFirst; +#else /* BYTESWAP */ + IconImage.byte_order = MSBFirst; #endif /* BYTESWAP */ - IconImage.bitmap_unit = 8; - IconImage.bitmap_pad = Bitmap_Pad; - IconImage.depth = 1; - IconImage.bytes_per_line = Lisp_icon_width/8; + IconImage.bitmap_unit = 8; + IconImage.bitmap_pad = Bitmap_Pad; + IconImage.depth = 1; + IconImage.bytes_per_line = Lisp_icon_width / 8; #if defined(X_ICON_IN_X_BITMAP_FORMAT) - IconImage.bitmap_bit_order = LSBFirst; + IconImage.bitmap_bit_order = LSBFirst; #else - IconImage.bitmap_bit_order = MSBFirst; + IconImage.bitmap_bit_order = MSBFirst; #endif - IconPixmap = XCreatePixmap( dsp->display_id, dsp->LispWindow - , Lisp_icon_width , Lisp_icon_height - , DefaultDepthOfScreen( ScreenOfDisplay( dsp->display_id, - DefaultScreen( dsp->display_id ) ) ) ); + IconPixmap = XCreatePixmap( + dsp->display_id, dsp->LispWindow, Lisp_icon_width, Lisp_icon_height, + DefaultDepthOfScreen(ScreenOfDisplay(dsp->display_id, DefaultScreen(dsp->display_id)))); - XPutImage( dsp->display_id, IconPixmap, dsp->Copy_GC, &IconImage - , 0, 0, 0, 0 - , Lisp_icon_width, Lisp_icon_height ); + XPutImage(dsp->display_id, IconPixmap, dsp->Copy_GC, &IconImage, 0, 0, 0, 0, Lisp_icon_width, + Lisp_icon_height); - } - else if (value == BitmapFileInvalid) - fprintf(stderr, "Iconpixmapfile %s contains invalid bitmap data\n", iconpixmapfile); - else if (value == BitmapNoMemory) - fprintf(stderr, "Not enough memory to allocate icon pixmap\n"); - return( IconPixmap ); - } /* end make_Xicon */ + } else if (value == BitmapFileInvalid) + fprintf(stderr, "Iconpixmapfile %s contains invalid bitmap data\n", iconpixmapfile); + else if (value == BitmapNoMemory) + fprintf(stderr, "Not enough memory to allocate icon pixmap\n"); + return (IconPixmap); +} /* end make_Xicon */ diff --git a/src/xrdopt.c b/src/xrdopt.c old mode 100755 new mode 100644 index 338dd91..302c68f --- a/src/xrdopt.c +++ b/src/xrdopt.c @@ -1,8 +1,7 @@ -/* $Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -18,20 +17,15 @@ static char *id = "$Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ Copyri #include "version.h" - - - - - #include #include #include #include #ifndef NOETHER #ifndef USE_DLPI -#include /* needed for Ethernet stuff below */ -#endif /* USE_DLPI */ -#endif /* NOETHER */ +#include /* needed for Ethernet stuff below */ +#endif /* USE_DLPI */ +#endif /* NOETHER */ #ifdef SYSVONLY #include #endif /* SYSVONLY */ @@ -48,57 +42,53 @@ static char *id = "$Id: xrdopt.c,v 1.6 2001/12/26 22:17:07 sybalsky Exp $ Copyri XrmDatabase commandlineDB, applicationDB, serverDB, homeDB, rDB; int opTableEntries = 33; -extern int LispWindowRequestedX, - LispWindowRequestedY, - LispWindowRequestedWidth, - LispWindowRequestedHeight; +extern int LispWindowRequestedX, LispWindowRequestedY, LispWindowRequestedWidth, + LispWindowRequestedHeight; -extern int LispDisplayRequestedX, - LispDisplayRequestedY, - LispDisplayRequestedWidth, - LispDisplayRequestedHeight; +extern int LispDisplayRequestedX, LispDisplayRequestedY, LispDisplayRequestedWidth, + LispDisplayRequestedHeight; extern int xsync; XrmOptionDescRec opTable[] = { - {"-help", "*help", XrmoptionIsArg, (caddr_t) NULL}, - {"-h", "*help", XrmoptionIsArg, (caddr_t) NULL}, - {"-sysout", "*sysout", XrmoptionSepArg, (caddr_t) NULL}, - {"-display", "*display", XrmoptionSepArg, (caddr_t) NULL}, - {"-d", "*display", XrmoptionSepArg, (caddr_t) NULL}, - {"-borderWidth", "*borderWidth", XrmoptionSepArg, (caddr_t) NULL}, - {"-bw", "*borderWidth", XrmoptionSepArg, (caddr_t) NULL}, - {"-screen", "*screen", XrmoptionSepArg, (caddr_t) NULL}, - {"-sc", "*screen", XrmoptionSepArg, (caddr_t) NULL}, - {"-geometry", "*geometry", XrmoptionSepArg, (caddr_t) NULL}, - {"-g", "*geometry", XrmoptionSepArg, (caddr_t) NULL}, - {"-foreground", "*foreground", XrmoptionSepArg, (caddr_t) NULL}, - {"-fg", "*foreground", XrmoptionSepArg, (caddr_t) NULL}, - {"-background", "*background", XrmoptionSepArg, (caddr_t) NULL}, - {"-bg", "*background", XrmoptionSepArg, (caddr_t) NULL}, - {"-title", "*title", XrmoptionSepArg, (caddr_t) NULL}, - {"-t", "*title", XrmoptionSepArg, (caddr_t) NULL}, - {"-icontitle", "*icontitle", XrmoptionSepArg, (caddr_t) NULL}, - {"-it", "*icontitle", XrmoptionSepArg, (caddr_t) NULL}, - {"-iconbitmap", "*iconbitmap", XrmoptionSepArg, (caddr_t) NULL}, - {"-ibm", "*iconbitmap", XrmoptionSepArg, (caddr_t) NULL}, - {"-key", "*key", XrmoptionSepArg, (caddr_t) NULL}, - {"-k", "*key", XrmoptionSepArg, (caddr_t) NULL}, - {"-timer", "*timer", XrmoptionSepArg, (caddr_t) NULL}, - {"-xpages", "*maxpages", XrmoptionSepArg, (caddr_t) NULL}, - {"-m", "*memory", XrmoptionSepArg, (caddr_t) NULL}, - {"-NF", "*NoFork", XrmoptionIsArg, (caddr_t) NULL}, - {"-NoFork", "*NoFork", XrmoptionIsArg, (caddr_t) NULL}, - {"-INIT", "*Init", XrmoptionIsArg, (caddr_t) NULL}, - {"-EtherNet", "*EtherNet", XrmoptionSepArg, (caddr_t) NULL}, - {"-E", "*EtherNet", XrmoptionSepArg, (caddr_t) NULL}, - {"-autorepeat", "*autorepeat", XrmoptionSepArg, (caddr_t) NULL}, - {"-xsync", "*xsync", XrmoptionIsArg, (caddr_t) NULL}, - }; - /* autorepeat is a global setting for X, not anything that - Medley has to be concerned with. Item kept for historical - reasons /jarl - */ + {"-help", "*help", XrmoptionIsArg, (caddr_t)NULL}, + {"-h", "*help", XrmoptionIsArg, (caddr_t)NULL}, + {"-sysout", "*sysout", XrmoptionSepArg, (caddr_t)NULL}, + {"-display", "*display", XrmoptionSepArg, (caddr_t)NULL}, + {"-d", "*display", XrmoptionSepArg, (caddr_t)NULL}, + {"-borderWidth", "*borderWidth", XrmoptionSepArg, (caddr_t)NULL}, + {"-bw", "*borderWidth", XrmoptionSepArg, (caddr_t)NULL}, + {"-screen", "*screen", XrmoptionSepArg, (caddr_t)NULL}, + {"-sc", "*screen", XrmoptionSepArg, (caddr_t)NULL}, + {"-geometry", "*geometry", XrmoptionSepArg, (caddr_t)NULL}, + {"-g", "*geometry", XrmoptionSepArg, (caddr_t)NULL}, + {"-foreground", "*foreground", XrmoptionSepArg, (caddr_t)NULL}, + {"-fg", "*foreground", XrmoptionSepArg, (caddr_t)NULL}, + {"-background", "*background", XrmoptionSepArg, (caddr_t)NULL}, + {"-bg", "*background", XrmoptionSepArg, (caddr_t)NULL}, + {"-title", "*title", XrmoptionSepArg, (caddr_t)NULL}, + {"-t", "*title", XrmoptionSepArg, (caddr_t)NULL}, + {"-icontitle", "*icontitle", XrmoptionSepArg, (caddr_t)NULL}, + {"-it", "*icontitle", XrmoptionSepArg, (caddr_t)NULL}, + {"-iconbitmap", "*iconbitmap", XrmoptionSepArg, (caddr_t)NULL}, + {"-ibm", "*iconbitmap", XrmoptionSepArg, (caddr_t)NULL}, + {"-key", "*key", XrmoptionSepArg, (caddr_t)NULL}, + {"-k", "*key", XrmoptionSepArg, (caddr_t)NULL}, + {"-timer", "*timer", XrmoptionSepArg, (caddr_t)NULL}, + {"-xpages", "*maxpages", XrmoptionSepArg, (caddr_t)NULL}, + {"-m", "*memory", XrmoptionSepArg, (caddr_t)NULL}, + {"-NF", "*NoFork", XrmoptionIsArg, (caddr_t)NULL}, + {"-NoFork", "*NoFork", XrmoptionIsArg, (caddr_t)NULL}, + {"-INIT", "*Init", XrmoptionIsArg, (caddr_t)NULL}, + {"-EtherNet", "*EtherNet", XrmoptionSepArg, (caddr_t)NULL}, + {"-E", "*EtherNet", XrmoptionSepArg, (caddr_t)NULL}, + {"-autorepeat", "*autorepeat", XrmoptionSepArg, (caddr_t)NULL}, + {"-xsync", "*xsync", XrmoptionIsArg, (caddr_t)NULL}, +}; +/* autorepeat is a global setting for X, not anything that + Medley has to be concerned with. Item kept for historical + reasons /jarl + */ char Display_Name[128]; char iconpixmapfile[1024]; @@ -107,7 +97,7 @@ char Icon_Title[255]; extern char sysout_name[], keystring[]; extern int sysout_size, for_makeinit, please_fork, Scroll_Border; - /* diagnostic flag for sysout dumping */ +/* diagnostic flag for sysout dumping */ /* extern int maxpages; */ extern char keystring[]; @@ -118,7 +108,7 @@ int Lisp_Border = 2; #ifndef NOETHER extern int ether_fd; extern u_char ether_host[6]; -#ifndef USE_DLPI +#ifndef USE_DLPI extern struct sockaddr_nit snit; #endif /* USE_DLPI */ #endif /* NOETHER */ @@ -131,24 +121,27 @@ extern struct sockaddr_nit snit; /* */ /************************************************************************/ -void print_Xusage( prog ) - char *prog; - { - fprintf(stderr, " %s options:\n", prog); - fprintf(stderr, " [-sysout] [] -path to the Medley image\n"); - fprintf(stderr, " -k[ey] -see manual for details\n"); - fprintf(stderr, " -h[elp] -prints this text\n"); - fprintf(stderr, " -d[isplay] :.\n"); - fprintf(stderr, " -g[eometry] -size & placement for the medley window on your X screen\n"); - fprintf(stderr, " -sc[reen] -size & placement for the medley display\n"); - fprintf(stderr, " -t[itle] -titlebar text for the window manager\n"); - fprintf(stderr, " -icontitle | -it -text for the medley icon\n"); - fprintf(stderr, " -iconbitmap | -ibm -bitmap for the medley icon\n"); - fprintf(stderr, " -xsync -turn XSyncronize on. (default is off)\n\n"); - fprintf(stderr, "If you have any further questions, please refer to the manual or\n"); - fprintf(stderr, "call our tech support at (800)228-5325 or (510)763-0516.\n\n"); - exit(0); - } /* end print_Xusage() */ +void print_Xusage(prog) char *prog; +{ + fprintf(stderr, " %s options:\n", prog); + fprintf(stderr, " [-sysout] [] -path to the Medley image\n"); + fprintf(stderr, " -k[ey] -see manual for details\n"); + fprintf(stderr, " -h[elp] -prints this text\n"); + fprintf(stderr, " -d[isplay] :.\n"); + fprintf(stderr, + " -g[eometry] -size & placement for the medley window on your X " + "screen\n"); + fprintf(stderr, + " -sc[reen] -size & placement for the medley display\n"); + fprintf(stderr, " -t[itle] -titlebar text for the window manager\n"); + fprintf(stderr, " -icontitle | -it -text for the medley icon\n"); + fprintf(stderr, " -iconbitmap | -ibm -bitmap for the medley icon\n"); + fprintf(stderr, + " -xsync -turn XSyncronize on. (default is off)\n\n"); + fprintf(stderr, "If you have any further questions, please refer to the manual or\n"); + fprintf(stderr, "call our tech support at (800)228-5325 or (510)763-0516.\n\n"); + exit(0); +} /* end print_Xusage() */ /************************************************************************/ /* */ @@ -158,17 +151,16 @@ void print_Xusage( prog ) /* */ /************************************************************************/ -void print_lispusage( prog ) - char *prog; - { - TPRINT(( "TRACE: print_lisp_usage()\n" )); +void print_lispusage(prog) char *prog; +{ + TPRINT(("TRACE: print_lisp_usage()\n")); - /* Lisp Option */ - fprintf(stderr,"lde[ether] [sysout] [-k access-key]"); - fprintf(stderr," [-E ]"); - fprintf(stderr,"\n"); + /* Lisp Option */ + fprintf(stderr, "lde[ether] [sysout] [-k access-key]"); + fprintf(stderr, " [-E ]"); + fprintf(stderr, "\n"); - } /* end print_lisp_usage() */ +} /* end print_lisp_usage() */ /************************************************************************/ /* */ @@ -178,261 +170,195 @@ void print_lispusage( prog ) /* */ /************************************************************************/ -void read_Xoption( argc, argv ) - int *argc; - char **argv; +void read_Xoption(argc, argv) int *argc; +char **argv; { - int bitmask; - XrmValue value; - char *str_type[30], tmp[1024], *envname; - Display *xdisplay; - int i; + int bitmask; + XrmValue value; + char *str_type[30], tmp[1024], *envname; + Display *xdisplay; + int i; - /**********************************************/ - /* */ - /* Take care of -help & -info flags, which */ - /* aren't handled correctly by the X code. */ - /* */ - /**********************************************/ + /**********************************************/ + /* */ + /* Take care of -help & -info flags, which */ + /* aren't handled correctly by the X code. */ + /* */ + /**********************************************/ - for (i = 1; i < *argc; i++) - { - if (argv[i] && ((strcmp(argv[i], "-info") == 0) || - (strcmp(argv[i], "-INFO") == 0))) { - print_info_lines(); + for (i = 1; i < *argc; i++) { + if (argv[i] && ((strcmp(argv[i], "-info") == 0) || (strcmp(argv[i], "-INFO") == 0))) { + print_info_lines(); } - if (argv[i] && - ((strcmp(argv[i], "-help") == 0) || - (strcmp(argv[i], "-HELP") == 0))) - { - print_Xusage( argv[0] ); + if (argv[i] && ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "-HELP") == 0))) { + print_Xusage(argv[0]); exit(0); } - } + } + /* Now let X handle the parsing. */ - /* Now let X handle the parsing. */ - - (void)XrmInitialize(); - /* If the first argv lacks '-' in front it is the sysout. */ + (void)XrmInitialize(); +/* If the first argv lacks '-' in front it is the sysout. */ #ifdef NEVEFR -/* JDS 12/20/01: app name should always be "ldex", not what's in argv?? */ - XrmParseCommand(&commandlineDB, opTable, opTableEntries, argv[0], argc, argv); + /* JDS 12/20/01: app name should always be "ldex", not what's in argv?? */ + XrmParseCommand(&commandlineDB, opTable, opTableEntries, argv[0], argc, argv); #endif - XrmParseCommand(&commandlineDB, opTable, opTableEntries, "ldex", argc, argv); + XrmParseCommand(&commandlineDB, opTable, opTableEntries, "ldex", argc, argv); - if (XrmGetResource(commandlineDB, "ldex.help", "Ldex.Help", - str_type, &value) == True) { - print_Xusage( argv[0] ); - } - - if(*argc == 2) /* There was probably a sysoutarg */ - { - sysout_name[0] = '\0'; - (void)strcat(sysout_name, argv[1]); - } - else if ((envname = (char *)getenv("LDESRCESYSOUT")) != NULL) - { - strcpy(sysout_name, envname); - } - else if ((envname = (char *)getenv("LDESOURCESYSOUT")) != NULL) - strcpy(sysout_name, envname); - else { - envname = (char *)getenv("HOME"); - (void)strcat(sysout_name, envname); - (void)strcat(sysout_name, "/lisp.virtualmem"); - - if( access(sysout_name, R_OK) != 0) - { - (void)strcat(sysout_name, ""); - } - } - - /* In order to access other DB's we have to open the main display now */ - /* This is just temporary. We'll need this display struct to open the */ - /* main databases for medley. After it is used the display will be */ - /* closed and the opening of the other displays will follow the standard */ - /* protocoll. */ - - if (XrmGetResource(commandlineDB, - "ldex.display", "Ldex.Display", - str_type, &value) == True) { - (void) strncpy(Display_Name, value.addr, (int)value.size); - } - else if (getenv("DISPLAY") == (char *)NULL){ - fprintf( stderr, "Can't find a display. Either set the shell\n"); - fprintf( stderr, "variabel DISPLAY to an appropriate display\n"); - fprintf( stderr, "or provide a -display argument.\n"); - print_Xusage( argv[0] ); - } - else { - envname = (char *)getenv("DISPLAY"); - (void)strcpy(Display_Name, envname); - } - if( (xdisplay = XOpenDisplay( Display_Name )) != NULL ) - { - /* read the other databases */ - /* Start with app-defaults/medley */ - (void)strcpy(tmp, "/usr/lib/X11/app-defaults/"); - (void)strcat(tmp, "medley"); - applicationDB = XrmGetFileDatabase(tmp); - if (applicationDB != NULL){ - (void)XrmMergeDatabases(applicationDB, &rDB); - } - /* Then try the displays defaults */ - if (XResourceManagerString(xdisplay) != NULL) { - serverDB = XrmGetStringDatabase(XResourceManagerString(xdisplay)); - if (serverDB != NULL){ - (void)XrmMergeDatabases(serverDB, &rDB); - } - } - XCloseDisplay(xdisplay); - } else { - fprintf( stderr, "Open_Display: cannot connect to display %s." - ,XDisplayName(Display_Name)); - exit(-1); - } + if (XrmGetResource(commandlineDB, "ldex.help", "Ldex.Help", str_type, &value) == True) { + print_Xusage(argv[0]); + } + if (*argc == 2) /* There was probably a sysoutarg */ + { + sysout_name[0] = '\0'; + (void)strcat(sysout_name, argv[1]); + } else if ((envname = (char *)getenv("LDESRCESYSOUT")) != NULL) { + strcpy(sysout_name, envname); + } else if ((envname = (char *)getenv("LDESOURCESYSOUT")) != NULL) + strcpy(sysout_name, envname); + else { envname = (char *)getenv("HOME"); - (void)strcat(tmp, envname); - (void)strcat(tmp, "/.Xdefaults"); - if( access(tmp, R_OK) != 0) { - serverDB = XrmGetFileDatabase(tmp); - if (serverDB != NULL){ - (void)XrmMergeDatabases(serverDB, &rDB); + (void)strcat(sysout_name, envname); + (void)strcat(sysout_name, "/lisp.virtualmem"); + + if (access(sysout_name, R_OK) != 0) { (void)strcat(sysout_name, ""); } + } + + /* In order to access other DB's we have to open the main display now */ + /* This is just temporary. We'll need this display struct to open the */ + /* main databases for medley. After it is used the display will be */ + /* closed and the opening of the other displays will follow the standard */ + /* protocoll. */ + + if (XrmGetResource(commandlineDB, "ldex.display", "Ldex.Display", str_type, &value) == True) { + (void)strncpy(Display_Name, value.addr, (int)value.size); + } else if (getenv("DISPLAY") == (char *)NULL) { + fprintf(stderr, "Can't find a display. Either set the shell\n"); + fprintf(stderr, "variabel DISPLAY to an appropriate display\n"); + fprintf(stderr, "or provide a -display argument.\n"); + print_Xusage(argv[0]); + } else { + envname = (char *)getenv("DISPLAY"); + (void)strcpy(Display_Name, envname); + } + if ((xdisplay = XOpenDisplay(Display_Name)) != NULL) { + /* read the other databases */ + /* Start with app-defaults/medley */ + (void)strcpy(tmp, "/usr/lib/X11/app-defaults/"); + (void)strcat(tmp, "medley"); + applicationDB = XrmGetFileDatabase(tmp); + if (applicationDB != NULL) { (void)XrmMergeDatabases(applicationDB, &rDB); } + /* Then try the displays defaults */ + if (XResourceManagerString(xdisplay) != NULL) { + serverDB = XrmGetStringDatabase(XResourceManagerString(xdisplay)); + if (serverDB != NULL) { (void)XrmMergeDatabases(serverDB, &rDB); } + } + XCloseDisplay(xdisplay); + } else { + fprintf(stderr, "Open_Display: cannot connect to display %s.", XDisplayName(Display_Name)); + exit(-1); + } + + envname = (char *)getenv("HOME"); + (void)strcat(tmp, envname); + (void)strcat(tmp, "/.Xdefaults"); + if (access(tmp, R_OK) != 0) { + serverDB = XrmGetFileDatabase(tmp); + if (serverDB != NULL) { (void)XrmMergeDatabases(serverDB, &rDB); } + } + + /* Now for the commandline */ + (void)XrmMergeDatabases(commandlineDB, &rDB); + + if (XrmGetResource(rDB, "ldex.sysout", "Ldex.Sysout", str_type, &value) == True) { + /* Get Sysout */ + (void)strncpy(sysout_name, value.addr, (int)value.size); + } + if (sysout_name == NULL) { + fprintf(stderr, "Coudn't find a sysout to run;\n"); + print_Xusage(argv[0]); + } + + if (XrmGetResource(rDB, "ldex.title", "Ldex.Title", str_type, &value) == True) { + (void)strncpy(Window_Title, value.addr, (int)value.size); + } else { + (void)strcpy(Window_Title, WINDOW_NAME); + } + if (XrmGetResource(rDB, "ldex.icontitle", "Ldex.icontitle", str_type, &value) == True) { + (void)strncpy(Icon_Title, value.addr, (int)value.size); + } else { + (void)strcpy(Icon_Title, "Medley"); + } + + if (XrmGetResource(rDB, "ldex.iconbitmap", "Ldex.Iconbitmap", str_type, &value) == True) { + (void)strncpy(iconpixmapfile, value.addr, (int)value.size); + } + + /* Old style geometry definition. */ + if (XrmGetResource(rDB, "ldex.geometry", "Ldex.geometry", str_type, &value) == True) { + /* Get Geometry */ + (void)strncpy(tmp, value.addr, (int)value.size); + bitmask = XParseGeometry(tmp, &LispWindowRequestedX, &LispWindowRequestedY, + &LispWindowRequestedWidth, &LispWindowRequestedHeight); + } + if (XrmGetResource(rDB, "ldex.screen", "Ldex.screen", str_type, &value) == True) { + /* Get Geometry */ + (void)strncpy(tmp, value.addr, (int)value.size); + bitmask = XParseGeometry(tmp, &LispDisplayRequestedX, &LispDisplayRequestedY, + &LispDisplayRequestedWidth, &LispDisplayRequestedHeight); + } + + (void)strcpy(tmp, ""); /* Clear the string */ + + if (XrmGetResource(rDB, "ldex.NoFork", "Ldex.NoFork", str_type, &value) == True) { + please_fork = 0; + } + + /* if (XrmGetResource(rDB, + "ldex.maxpages", + "Ldex.maxpages", + str_type, &value) == True) { + (void)strncpy(tmp, value.addr, (int)value.size); + maxpages = atoi(tmp); } - } + */ + if (XrmGetResource(rDB, "ldex.memory", "Ldex.memory", str_type, &value) == True) { + (void)strncpy(tmp, value.addr, (int)value.size); + sysout_size = atoi(tmp); + } - /* Now for the commandline */ - (void)XrmMergeDatabases(commandlineDB, &rDB); + if (XrmGetResource(rDB, "ldex.Init", "Ldex.Init", str_type, &value) == True) { for_makeinit = 1; } - if (XrmGetResource(rDB, - "ldex.sysout", - "Ldex.Sysout", - str_type, &value) == True) { - /* Get Sysout */ - (void)strncpy(sysout_name, value.addr, (int)value.size); - } - if (sysout_name == NULL) { - fprintf(stderr, "Coudn't find a sysout to run;\n"); - print_Xusage( argv[0] ); - } - - if (XrmGetResource(rDB, - "ldex.title", - "Ldex.Title", - str_type, &value) == True) { - (void)strncpy(Window_Title, value.addr, (int)value.size); - } else { - (void)strcpy(Window_Title, - WINDOW_NAME); - } - if (XrmGetResource(rDB, - "ldex.icontitle", - "Ldex.icontitle", - str_type, &value) == True) { - (void)strncpy(Icon_Title, value.addr, (int)value.size); - } else { - (void)strcpy(Icon_Title, "Medley"); - } - - if (XrmGetResource(rDB, - "ldex.iconbitmap", - "Ldex.Iconbitmap", - str_type, &value) == True) { - (void)strncpy(iconpixmapfile, value.addr, (int)value.size); - } - - /* Old style geometry definition. */ - if (XrmGetResource(rDB, - "ldex.geometry", - "Ldex.geometry", - str_type, &value) == True) { - /* Get Geometry */ - (void)strncpy(tmp, value.addr, (int)value.size); - bitmask = XParseGeometry(tmp , &LispWindowRequestedX, &LispWindowRequestedY - , &LispWindowRequestedWidth, &LispWindowRequestedHeight ); } - if (XrmGetResource(rDB, - "ldex.screen", - "Ldex.screen", - str_type, &value) == True) { - /* Get Geometry */ - (void)strncpy(tmp, value.addr, (int)value.size); - bitmask = XParseGeometry(tmp , &LispDisplayRequestedX, &LispDisplayRequestedY - , &LispDisplayRequestedWidth, &LispDisplayRequestedHeight ); - } - - (void)strcpy(tmp, ""); /* Clear the string */ - - if (XrmGetResource(rDB, - "ldex.NoFork", - "Ldex.NoFork", - str_type, &value) == True) { - please_fork = 0; - } - -/* if (XrmGetResource(rDB, - "ldex.maxpages", - "Ldex.maxpages", - str_type, &value) == True) { - (void)strncpy(tmp, value.addr, (int)value.size); - maxpages = atoi(tmp); - } -*/ - if (XrmGetResource(rDB, - "ldex.memory", - "Ldex.memory", - str_type, &value) == True) { - (void)strncpy(tmp, value.addr, (int)value.size); - sysout_size = atoi(tmp); - } - - if (XrmGetResource(rDB, - "ldex.Init", - "Ldex.Init", - str_type, &value) == True) { - for_makeinit = 1; - } - - if (XrmGetResource(rDB, - "ldex.key", - "Ldex.key", - str_type, &value) == True) { - (void)strncpy(keystring, value.addr, (int)value.size); - } - if (XrmGetResource(rDB, - "ldex.xsync", - "Ldex.xsync", - str_type, &value) == True) { - xsync = True; - } + if (XrmGetResource(rDB, "ldex.key", "Ldex.key", str_type, &value) == True) { + (void)strncpy(keystring, value.addr, (int)value.size); + } + if (XrmGetResource(rDB, "ldex.xsync", "Ldex.xsync", str_type, &value) == True) { xsync = True; } #ifdef NOETHER #else - if (XrmGetResource(rDB, - "ldex.EtherNet", - "Ldex.EtherNet", - str_type, &value) == True) { - int b0, b1, b2, b3, b4, b5; - (void)strncpy(tmp, value.addr, (int)value.size); + if (XrmGetResource(rDB, "ldex.EtherNet", "Ldex.EtherNet", str_type, &value) == True) { + int b0, b1, b2, b3, b4, b5; + (void)strncpy(tmp, value.addr, (int)value.size); #ifdef USE_DLPI - if (sscanf(tmp,"%d:%x:%x:%x:%x:%x:%x",ðer_fd, - &b0, &b1, &b2, &b3, &b4, &b5) == 7) + if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5) == 7) #else - if (sscanf(tmp,"%d:%x:%x:%x:%x:%x:%x:%s",ðer_fd, - &b0, &b1, &b2, &b3, &b4, &b5, snit.snit_ifname) == 8) + if (sscanf(tmp, "%d:%x:%x:%x:%x:%x:%x:%s", ðer_fd, &b0, &b1, &b2, &b3, &b4, &b5, + snit.snit_ifname) == 8) #endif /* USE_DLPI */ - { - ether_host[0] = b0; ether_host[1] = b1; - ether_host[2] = b2; ether_host[3] = b3; - ether_host[4] = b4; ether_host[5] = b5; - } else { - fprintf(stderr, "Missing or bogus -E argument\n"); - ether_fd = -1; - exit(1); - } + { + ether_host[0] = b0; + ether_host[1] = b1; + ether_host[2] = b2; + ether_host[3] = b3; + ether_host[4] = b4; + ether_host[5] = b5; + } else { + fprintf(stderr, "Missing or bogus -E argument\n"); + ether_fd = -1; + exit(1); } + } #endif /* NOETHER */ -} /* end readXoption */ - - +} /* end readXoption */ diff --git a/src/xscroll.c b/src/xscroll.c old mode 100755 new mode 100644 index f92688a..7452dda --- a/src/xscroll.c +++ b/src/xscroll.c @@ -1,8 +1,7 @@ -/* $Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -18,7 +17,6 @@ static char *id = "$Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ Copyr #include "version.h" - #include #include @@ -30,13 +28,11 @@ static char *id = "$Id: xscroll.c,v 1.2 1999/01/03 02:07:48 sybalsky Exp $ Copyr int ScrollPitch = SCROLL_PITCH; - /* Move the DisplayWindow and the ScrollButtons to a new */ /* position. newX, newY refers to the uppre left corner */ /* of the LispDisplay */ -void Scroll( dsp, newX, newY) - DspInterface dsp; - int newX, newY; +void Scroll(dsp, newX, newY) DspInterface dsp; +int newX, newY; { /* Limit the newX and newY values. */ dsp->Vissible.x = bound(0, newX, dsp->Display.width - dsp->Vissible.width); @@ -45,45 +41,27 @@ void Scroll( dsp, newX, newY) newX = (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width); newY = (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height); - XMoveWindow( dsp->display_id, dsp->HorScrollButton, newX, -dsp->InternalBorderWidth); - XMoveWindow( dsp->display_id, dsp->VerScrollButton, -dsp->InternalBorderWidth, newY ); + XMoveWindow(dsp->display_id, dsp->HorScrollButton, newX, -dsp->InternalBorderWidth); + XMoveWindow(dsp->display_id, dsp->VerScrollButton, -dsp->InternalBorderWidth, newY); - (dsp->bitblt_to_screen)( dsp, 0, dsp->Vissible.x, dsp->Vissible.y, - dsp->Vissible.width, dsp->Vissible.height); -}/* end Scroll */ + (dsp->bitblt_to_screen)(dsp, 0, dsp->Vissible.x, dsp->Vissible.y, dsp->Vissible.width, + dsp->Vissible.height); +} /* end Scroll */ -void JumpScrollVer( dsp, y ) - DspInterface dsp; -{ - Scroll( dsp, dsp->Vissible.x, (int)((dsp->Display.width *y) / dsp->Vissible.height)); -} +void JumpScrollVer(dsp, y) DspInterface dsp; +{ Scroll(dsp, dsp->Vissible.x, (int)((dsp->Display.width * y) / dsp->Vissible.height)); } -void JumpScrollHor( dsp, x ) - DspInterface dsp; -{ - Scroll( dsp, (int)((dsp->Display.width *x) / dsp->Vissible.width), dsp->Vissible.y); -} +void JumpScrollHor(dsp, x) DspInterface dsp; +{ Scroll(dsp, (int)((dsp->Display.width * x) / dsp->Vissible.width), dsp->Vissible.y); } -void ScrollLeft( dsp ) - DspInterface dsp; -{ - Scroll( dsp, dsp->Vissible.x - ScrollPitch, dsp->Vissible.y); -} +void ScrollLeft(dsp) DspInterface dsp; +{ Scroll(dsp, dsp->Vissible.x - ScrollPitch, dsp->Vissible.y); } -void ScrollRight( dsp ) - DspInterface dsp; -{ - Scroll( dsp, dsp->Vissible.x + ScrollPitch, dsp->Vissible.y); -} +void ScrollRight(dsp) DspInterface dsp; +{ Scroll(dsp, dsp->Vissible.x + ScrollPitch, dsp->Vissible.y); } -void ScrollUp( dsp ) - DspInterface dsp; -{ - Scroll( dsp, dsp->Vissible.x, dsp->Vissible.y - ScrollPitch); -} +void ScrollUp(dsp) DspInterface dsp; +{ Scroll(dsp, dsp->Vissible.x, dsp->Vissible.y - ScrollPitch); } -void ScrollDown( dsp ) - DspInterface dsp; -{ - Scroll( dsp, dsp->Vissible.x, dsp->Vissible.y + ScrollPitch); -} +void ScrollDown(dsp) DspInterface dsp; +{ Scroll(dsp, dsp->Vissible.x, dsp->Vissible.y + ScrollPitch); } diff --git a/src/xwinman.c b/src/xwinman.c old mode 100755 new mode 100644 index bde27fd..b268b9e --- a/src/xwinman.c +++ b/src/xwinman.c @@ -1,8 +1,7 @@ -/* $Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved */ +/* $Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ (C) Copyright Venue, All Rights Reserved + */ static char *id = "$Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ Copyright (C) Venue"; - - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 2000 Venue. */ @@ -16,12 +15,8 @@ static char *id = "$Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ Copyr /* */ /************************************************************************/ - #include "version.h" - - - #include #include @@ -37,182 +32,142 @@ static char *id = "$Id: xwinman.c,v 1.3 2001/12/26 22:17:07 sybalsky Exp $ Copyr int Mouse_Included = FALSE; -extern Cursor WaitCursor, - DefaultCursor, - VertScrollCursor, - VertThumbCursor, - ScrollUpCursor, - ScrollDownCursor, - HorizScrollCursor, - HorizThumbCursor, - ScrollLeftCursor, - ScrollRightCursor; +extern Cursor WaitCursor, DefaultCursor, VertScrollCursor, VertThumbCursor, ScrollUpCursor, + ScrollDownCursor, HorizScrollCursor, HorizThumbCursor, ScrollLeftCursor, ScrollRightCursor; -extern DspInterface currentdsp, colordsp; +extern DspInterface currentdsp, colordsp; -extern DLword *EmCursorX68K - , *EmCursorY68K; -extern DLword *EmMouseX68K - , *EmMouseY68K - , *EmKbdAd068K - , *EmRealUtilin68K; +extern DLword *EmCursorX68K, *EmCursorY68K; +extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K; extern LispPTR *CLastUserActionCell68k; extern MISCSTATS *MiscStats; extern int KBDEventFlg; extern u_char *SUNLispKeyMap; -#define KEYCODE_OFFSET 7 /* Sun Keycode offset */ - -#define MOUSE_LEFT 13 -#define MOUSE_MIDDLE 15 -#define MOUSE_RIGHT 14 - - +#define KEYCODE_OFFSET 7 /* Sun Keycode offset */ +#define MOUSE_LEFT 13 +#define MOUSE_MIDDLE 15 +#define MOUSE_RIGHT 14 /* bound: return b if it is between a and c otherwise it returns a or c */ -int bound( a, b, c) - int a, b, c; +int bound(a, b, c) int a, b, c; { - if (b <= a) return( a ); - else if ( b >= c ) return( c ); - else return( b ); + if (b <= a) + return (a); + else if (b >= c) + return (c); + else + return (b); } - - - - -void Set_BitGravity( event, dsp, window, grav ) - XButtonEvent *event; - DspInterface dsp; - Window window; - int grav; +void Set_BitGravity(event, dsp, window, grav) XButtonEvent *event; +DspInterface dsp; +Window window; +int grav; { XSetWindowAttributes Lisp_SetWinAttributes; Window OldWindow; /* Change Background Pixmap of Gravity Window */ XLOCK; - switch( dsp->BitGravity ) { - case NorthWestGravity: OldWindow = dsp->NWGrav; - break; - case NorthEastGravity: OldWindow = dsp->NEGrav; - break; - case SouthWestGravity: OldWindow = dsp->SWGrav; - break; - case SouthEastGravity: OldWindow = dsp->SEGrav; - break; + switch (dsp->BitGravity) { + case NorthWestGravity: OldWindow = dsp->NWGrav; break; + case NorthEastGravity: OldWindow = dsp->NEGrav; break; + case SouthWestGravity: OldWindow = dsp->SWGrav; break; + case SouthEastGravity: OldWindow = dsp->SEGrav; break; }; dsp->BitGravity = grav; - XSetWindowBackgroundPixmap( event->display , OldWindow - , dsp->GravityOffPixmap ); - XClearWindow( event->display, OldWindow ); + XSetWindowBackgroundPixmap(event->display, OldWindow, dsp->GravityOffPixmap); + XClearWindow(event->display, OldWindow); - XSetWindowBackgroundPixmap( event->display , window - , dsp->GravityOnPixmap ); - XClearWindow( event->display, window ); + XSetWindowBackgroundPixmap(event->display, window, dsp->GravityOnPixmap); + XClearWindow(event->display, window); XUNLOCK; -} /* end Set_BitGravity */ +} /* end Set_BitGravity */ - -void lisp_Xconfigure( dsp, x, y, lspWinWidth, lspWinHeight ) - DspInterface dsp; - int x, y, lspWinWidth, lspWinHeight; +void lisp_Xconfigure(dsp, x, y, lspWinWidth, lspWinHeight) DspInterface dsp; +int x, y, lspWinWidth, lspWinHeight; { int GravSize, Col2, Row2, Col3, Row3; /* The Vissible width and height changes when */ /* we configure the window. Make them */ /* stay within bounds. */ - dsp->Vissible.width = bound(OUTER_SB_WIDTH(dsp)+2, - lspWinWidth, - dsp->Display.width + OUTER_SB_WIDTH(dsp)) - OUTER_SB_WIDTH(dsp); - dsp->Vissible.height = bound(OUTER_SB_WIDTH(dsp)+2, - lspWinHeight, - dsp->Display.height + OUTER_SB_WIDTH(dsp)) - OUTER_SB_WIDTH(dsp); + dsp->Vissible.width = + bound(OUTER_SB_WIDTH(dsp) + 2, lspWinWidth, dsp->Display.width + OUTER_SB_WIDTH(dsp)) - + OUTER_SB_WIDTH(dsp); + dsp->Vissible.height = + bound(OUTER_SB_WIDTH(dsp) + 2, lspWinHeight, dsp->Display.height + OUTER_SB_WIDTH(dsp)) - + OUTER_SB_WIDTH(dsp); - GravSize = (int)(dsp->ScrollBarWidth/2) - (dsp->InternalBorderWidth); + GravSize = (int)(dsp->ScrollBarWidth / 2) - (dsp->InternalBorderWidth); Col2 = dsp->Vissible.width; Row2 = dsp->Vissible.height; - Col3 = dsp->Vissible.width + (int)(OUTER_SB_WIDTH(dsp)/2); - Row3 = dsp->Vissible.height + (int)(OUTER_SB_WIDTH(dsp)/2); + Col3 = dsp->Vissible.width + (int)(OUTER_SB_WIDTH(dsp) / 2); + Row3 = dsp->Vissible.height + (int)(OUTER_SB_WIDTH(dsp) / 2); XLOCK; - XMoveResizeWindow( dsp->display_id, dsp->DisplayWindow, 0, 0, dsp->Vissible.width, dsp->Vissible.height); + XMoveResizeWindow(dsp->display_id, dsp->DisplayWindow, 0, 0, dsp->Vissible.width, + dsp->Vissible.height); /* Scroll bars */ - XMoveResizeWindow( dsp->display_id, dsp->VerScrollBar, - Col2, 0-dsp->InternalBorderWidth, /* y */ - dsp->ScrollBarWidth, /* width */ - dsp->Vissible.height); /* height */ - XMoveResizeWindow( dsp->display_id, - dsp->HorScrollBar, - 0-dsp->InternalBorderWidth, Row2, /* y */ - dsp->Vissible.width, /* width */ - dsp->ScrollBarWidth); /* height */ + XMoveResizeWindow(dsp->display_id, dsp->VerScrollBar, Col2, 0 - dsp->InternalBorderWidth, /* y */ + dsp->ScrollBarWidth, /* width */ + dsp->Vissible.height); /* height */ + XMoveResizeWindow(dsp->display_id, dsp->HorScrollBar, 0 - dsp->InternalBorderWidth, Row2, /* y */ + dsp->Vissible.width, /* width */ + dsp->ScrollBarWidth); /* height */ /* Scroll buttons */ - XMoveResizeWindow( dsp->display_id, - dsp->HorScrollButton, - (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width), /* x */ - 0-dsp->InternalBorderWidth, /* y */ - (int)((dsp->Vissible.width*dsp->Vissible.width)/ dsp->Display.width) + 1, /* width */ - dsp->ScrollBarWidth); /* height */ - XMoveResizeWindow( dsp->display_id, - dsp->VerScrollButton, - 0-dsp->InternalBorderWidth, /* x */ - (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height), /* y */ - dsp->ScrollBarWidth, /* width */ - (int)((dsp->Vissible.height*dsp->Vissible.height) / dsp->Display.height) + 1); /* height */ + XMoveResizeWindow( + dsp->display_id, dsp->HorScrollButton, + (int)((dsp->Vissible.x * dsp->Vissible.width) / dsp->Display.width), /* x */ + 0 - dsp->InternalBorderWidth, /* y */ + (int)((dsp->Vissible.width * dsp->Vissible.width) / dsp->Display.width) + 1, /* width */ + dsp->ScrollBarWidth); /* height */ + XMoveResizeWindow( + dsp->display_id, dsp->VerScrollButton, 0 - dsp->InternalBorderWidth, /* x */ + (int)((dsp->Vissible.y * dsp->Vissible.height) / dsp->Display.height), /* y */ + dsp->ScrollBarWidth, /* width */ + (int)((dsp->Vissible.height * dsp->Vissible.height) / dsp->Display.height) + 1); /* height */ /* Gravity windows */ - XMoveResizeWindow( dsp->display_id, dsp->NWGrav, Col2, Row2, GravSize, GravSize); - XMoveResizeWindow( dsp->display_id, dsp->NEGrav, Col3, Row2, GravSize, GravSize); - XMoveResizeWindow( dsp->display_id, dsp->SEGrav, Col3, Row3, GravSize, GravSize); - XMoveResizeWindow( dsp->display_id, dsp->SWGrav, Col2, Row3, GravSize, GravSize); - Scroll( dsp, dsp->Vissible.x, dsp->Vissible.y ); + XMoveResizeWindow(dsp->display_id, dsp->NWGrav, Col2, Row2, GravSize, GravSize); + XMoveResizeWindow(dsp->display_id, dsp->NEGrav, Col3, Row2, GravSize, GravSize); + XMoveResizeWindow(dsp->display_id, dsp->SEGrav, Col3, Row3, GravSize, GravSize); + XMoveResizeWindow(dsp->display_id, dsp->SWGrav, Col2, Row3, GravSize, GravSize); + Scroll(dsp, dsp->Vissible.x, dsp->Vissible.y); XFlush(dsp->display_id); XUNLOCK; -} /* end lisp_Xconfigure */ +} /* end lisp_Xconfigure */ - -void enable_Xkeyboard( dsp ) - DspInterface dsp; +void enable_Xkeyboard(dsp) DspInterface dsp; { - XLOCK; - XSelectInput( dsp->display_id, - dsp->DisplayWindow, - dsp->EnableEventMask ); - XFlush( dsp->display_id ); - XUNLOCK; + XLOCK; + XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->EnableEventMask); + XFlush(dsp->display_id); + XUNLOCK; } - - -void disable_Xkeyboard( dsp ) - DspInterface dsp; +void disable_Xkeyboard(dsp) DspInterface dsp; { - XLOCK; - XSelectInput( dsp->display_id, - dsp->DisplayWindow, - dsp->DisableEventMask ); - XFlush( dsp->display_id ); - XUNLOCK; + XLOCK; + XSelectInput(dsp->display_id, dsp->DisplayWindow, dsp->DisableEventMask); + XFlush(dsp->display_id); + XUNLOCK; } -void beep_Xkeyboard( dsp ) - DspInterface dsp; +void beep_Xkeyboard(dsp) DspInterface dsp; { #ifdef TRACE - printf( "TRACE: beep_Xkeyboard()\n" ); + printf("TRACE: beep_Xkeyboard()\n"); #endif - XLOCK; - XBell( dsp->display_id, (int) 50 ); - XFlush( dsp->display_id ); - XUNLOCK; - + XLOCK; + XBell(dsp->display_id, (int)50); + XFlush(dsp->display_id); + XUNLOCK; } /* end beep_Xkeyboard */ @@ -224,196 +179,163 @@ void beep_Xkeyboard( dsp ) /* */ /************************************************************************/ -extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ - -void -getXsignaldata(dsp) - DspInterface dsp; - { - XEvent report; - - while( XPending( dsp->display_id ) ) - { - XNextEvent( dsp->display_id, &report ); - if( report.xany.window == dsp->DisplayWindow ) /* Try the most important window first. */ - switch(report.type) { - case MotionNotify : - *CLastUserActionCell68k = MiscStats->secondstmp; - *EmCursorX68K = (*((DLword *)EmMouseX68K)) = (short) ((report.xmotion.x + dsp->Vissible.x)&0xFFFF) - Current_Hot_X; - *EmCursorY68K = (*((DLword *)EmMouseY68K)) = (short) ((report.xmotion.y + dsp->Vissible.y)&0xFFFF) - Current_Hot_Y; - DoRing(); - if(( KBDEventFlg ) > 0) Irq_Stk_End=Irq_Stk_Check=0; - break; - case KeyPress : - kb_trans( SUNLispKeyMap[(report.xkey.keycode)-KEYCODE_OFFSET], FALSE ); - DoRing(); - if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; - break; - case KeyRelease : - kb_trans( SUNLispKeyMap[(report.xkey.keycode)-KEYCODE_OFFSET], TRUE ); - DoRing(); - if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; - break; - case ButtonPress : - switch (report.xbutton.button) { - case Button1: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_LEFT, FALSE ); - break; - case Button2: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_MIDDLE, FALSE ); - break; - case Button3: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_RIGHT, FALSE ); - break; - default: - break; - } - DoRing(); - if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; - break; - case ButtonRelease : - switch (report.xbutton.button) { - case Button1: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_LEFT, TRUE ); - break; - case Button2: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_MIDDLE, TRUE); - break; - case Button3: PUTBASEBIT68K( EmRealUtilin68K, MOUSE_RIGHT, TRUE ); - break; - default: - break; - } - DoRing(); - if((KBDEventFlg += 1) > 0) Irq_Stk_End=Irq_Stk_Check=0; - break; - case EnterNotify : - Mouse_Included = TRUE; - break; - case LeaveNotify : - Mouse_Included = FALSE; - break; - case Expose : - XLOCK; - (dsp->bitblt_to_screen)( dsp, 0, - report.xexpose.x+dsp->Vissible.x, - report.xexpose.y+dsp->Vissible.y, - report.xexpose.width, - report.xexpose.height ); - XUNLOCK; - break; - default: - break; - } - else if( report.xany.window == dsp->LispWindow ) - switch(report.xany.type) { - case ConfigureNotify : - lisp_Xconfigure(dsp, report.xconfigure.x, report.xconfigure.y, - report.xconfigure.width, report.xconfigure.height); - break; - case EnterNotify : - enable_Xkeyboard( currentdsp ); - break; - case LeaveNotify : - break; - case MapNotify : - /* Turn the blitting to the screen on */ - break; - case UnmapNotify : - /* Turn the blitting to the screen off */ - break; - default: - break; - } - else if ( report.xany.window == dsp->HorScrollBar ) - switch(report.type) { - case ButtonPress : - switch( report.xbutton.button ) { - case Button1: - DefineCursor( dsp->display_id, dsp->HorScrollBar, &ScrollLeftCursor ); - ScrollLeft( dsp, report ); - break; - case Button2: - DefineCursor( dsp->display_id, dsp->HorScrollBar, &HorizThumbCursor ); - break; - case Button3: - DefineCursor( dsp->display_id, dsp->HorScrollBar, &ScrollRightCursor ); - ScrollRight( dsp, report ); - break; - default: - break; - } /* end switch */ - break; - case ButtonRelease : - switch( report.xbutton.button ) { - case Button1: - DefineCursor( dsp->display_id, report.xany.window, &HorizScrollCursor ); - break; - case Button2: - JumpScrollHor( dsp, report.xbutton.x ); - DefineCursor( dsp->display_id, report.xany.window, &HorizScrollCursor ); - break; - case Button3: - DefineCursor( dsp->display_id, report.xany.window, &HorizScrollCursor ); - break; - default: - break; - } /* end switch */ - default: - break; - } - else if ( report.xany.window == dsp->VerScrollBar ) - switch(report.type) { - case ButtonPress : - switch( report.xbutton.button ) { - case Button1: - DefineCursor( dsp->display_id, report.xany.window, &ScrollUpCursor ); - ScrollUp( dsp ); - break; - case Button2: - DefineCursor( dsp->display_id, report.xany.window, &VertThumbCursor ); - break; - case Button3: - DefineCursor( dsp->display_id, report.xany.window, &ScrollDownCursor ); - ScrollDown( dsp ); - break; - default: - break; - } /* end switch */ - break; - case ButtonRelease : - switch( report.xbutton.button ) { - case Button1: - DefineCursor( dsp->display_id, report.xany.window, &VertScrollCursor ); - break; - case Button3: - DefineCursor( dsp->display_id, report.xany.window, &VertScrollCursor ); - break; - case Button2: - JumpScrollVer( dsp, report.xbutton.y ); - DefineCursor( dsp->display_id, report.xany.window, &VertScrollCursor ); - break; - default: - break; - } /* end switch */ - break; - default: - break; - } - else if (( report.xany.window == dsp->NEGrav ) && - ( report.xany.type == ButtonPress) && - ((report.xbutton.button & 0xFF) == Button1)) - Set_BitGravity(&report.xbutton, dsp, dsp->NEGrav, NorthEastGravity); - else if (( report.xany.window == dsp->SEGrav ) && - ( report.xany.type == ButtonPress) && - ((report.xbutton.button & 0xFF) == Button1)) - Set_BitGravity(&report.xbutton, dsp, dsp->SEGrav, SouthEastGravity); - else if (( report.xany.window == dsp->SWGrav ) && - ( report.xany.type == ButtonPress) && - ((report.xbutton.button & 0xFF) == Button1)) - Set_BitGravity(&report.xbutton, dsp, dsp->SWGrav, SouthWestGravity); - else if (( report.xany.window == dsp->NWGrav ) && - ( report.xany.type == ButtonPress) && - ((report.xbutton.button & 0xFF) == Button1)) - Set_BitGravity(&report.xbutton, dsp, dsp->NWGrav, NorthWestGravity); - XFlush(dsp->display_id); - } /* end while */ - } /* end getXsignaldata() */ - +extern int Current_Hot_X, Current_Hot_Y; /* Cursor hotspot */ +void getXsignaldata(dsp) DspInterface dsp; +{ + XEvent report; + while (XPending(dsp->display_id)) { + XNextEvent(dsp->display_id, &report); + if (report.xany.window == dsp->DisplayWindow) /* Try the most important window first. */ + switch (report.type) { + case MotionNotify: + *CLastUserActionCell68k = MiscStats->secondstmp; + *EmCursorX68K = (*((DLword *)EmMouseX68K)) = + (short)((report.xmotion.x + dsp->Vissible.x) & 0xFFFF) - Current_Hot_X; + *EmCursorY68K = (*((DLword *)EmMouseY68K)) = + (short)((report.xmotion.y + dsp->Vissible.y) & 0xFFFF) - Current_Hot_Y; + DoRing(); + if ((KBDEventFlg) > 0) Irq_Stk_End = Irq_Stk_Check = 0; + break; + case KeyPress: + kb_trans(SUNLispKeyMap[(report.xkey.keycode) - KEYCODE_OFFSET], FALSE); + DoRing(); + if ((KBDEventFlg += 1) > 0) Irq_Stk_End = Irq_Stk_Check = 0; + break; + case KeyRelease: + kb_trans(SUNLispKeyMap[(report.xkey.keycode) - KEYCODE_OFFSET], TRUE); + DoRing(); + if ((KBDEventFlg += 1) > 0) Irq_Stk_End = Irq_Stk_Check = 0; + break; + case ButtonPress: + switch (report.xbutton.button) { + case Button1: PUTBASEBIT68K(EmRealUtilin68K, MOUSE_LEFT, FALSE); break; + case Button2: PUTBASEBIT68K(EmRealUtilin68K, MOUSE_MIDDLE, FALSE); break; + case Button3: PUTBASEBIT68K(EmRealUtilin68K, MOUSE_RIGHT, FALSE); break; + default: break; + } + DoRing(); + if ((KBDEventFlg += 1) > 0) Irq_Stk_End = Irq_Stk_Check = 0; + break; + case ButtonRelease: + switch (report.xbutton.button) { + case Button1: PUTBASEBIT68K(EmRealUtilin68K, MOUSE_LEFT, TRUE); break; + case Button2: PUTBASEBIT68K(EmRealUtilin68K, MOUSE_MIDDLE, TRUE); break; + case Button3: PUTBASEBIT68K(EmRealUtilin68K, MOUSE_RIGHT, TRUE); break; + default: break; + } + DoRing(); + if ((KBDEventFlg += 1) > 0) Irq_Stk_End = Irq_Stk_Check = 0; + break; + case EnterNotify: Mouse_Included = TRUE; break; + case LeaveNotify: Mouse_Included = FALSE; break; + case Expose: + XLOCK; + (dsp->bitblt_to_screen)(dsp, 0, report.xexpose.x + dsp->Vissible.x, + report.xexpose.y + dsp->Vissible.y, report.xexpose.width, + report.xexpose.height); + XUNLOCK; + break; + default: break; + } + else if (report.xany.window == dsp->LispWindow) + switch (report.xany.type) { + case ConfigureNotify: + lisp_Xconfigure(dsp, report.xconfigure.x, report.xconfigure.y, report.xconfigure.width, + report.xconfigure.height); + break; + case EnterNotify: enable_Xkeyboard(currentdsp); break; + case LeaveNotify: break; + case MapNotify: + /* Turn the blitting to the screen on */ + break; + case UnmapNotify: + /* Turn the blitting to the screen off */ + break; + default: break; + } + else if (report.xany.window == dsp->HorScrollBar) + switch (report.type) { + case ButtonPress: + switch (report.xbutton.button) { + case Button1: + DefineCursor(dsp->display_id, dsp->HorScrollBar, &ScrollLeftCursor); + ScrollLeft(dsp, report); + break; + case Button2: + DefineCursor(dsp->display_id, dsp->HorScrollBar, &HorizThumbCursor); + break; + case Button3: + DefineCursor(dsp->display_id, dsp->HorScrollBar, &ScrollRightCursor); + ScrollRight(dsp, report); + break; + default: break; + } /* end switch */ + break; + case ButtonRelease: + switch (report.xbutton.button) { + case Button1: + DefineCursor(dsp->display_id, report.xany.window, &HorizScrollCursor); + break; + case Button2: + JumpScrollHor(dsp, report.xbutton.x); + DefineCursor(dsp->display_id, report.xany.window, &HorizScrollCursor); + break; + case Button3: + DefineCursor(dsp->display_id, report.xany.window, &HorizScrollCursor); + break; + default: break; + } /* end switch */ + default: break; + } + else if (report.xany.window == dsp->VerScrollBar) + switch (report.type) { + case ButtonPress: + switch (report.xbutton.button) { + case Button1: + DefineCursor(dsp->display_id, report.xany.window, &ScrollUpCursor); + ScrollUp(dsp); + break; + case Button2: + DefineCursor(dsp->display_id, report.xany.window, &VertThumbCursor); + break; + case Button3: + DefineCursor(dsp->display_id, report.xany.window, &ScrollDownCursor); + ScrollDown(dsp); + break; + default: break; + } /* end switch */ + break; + case ButtonRelease: + switch (report.xbutton.button) { + case Button1: + DefineCursor(dsp->display_id, report.xany.window, &VertScrollCursor); + break; + case Button3: + DefineCursor(dsp->display_id, report.xany.window, &VertScrollCursor); + break; + case Button2: + JumpScrollVer(dsp, report.xbutton.y); + DefineCursor(dsp->display_id, report.xany.window, &VertScrollCursor); + break; + default: break; + } /* end switch */ + break; + default: break; + } + else if ((report.xany.window == dsp->NEGrav) && (report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(&report.xbutton, dsp, dsp->NEGrav, NorthEastGravity); + else if ((report.xany.window == dsp->SEGrav) && (report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(&report.xbutton, dsp, dsp->SEGrav, SouthEastGravity); + else if ((report.xany.window == dsp->SWGrav) && (report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(&report.xbutton, dsp, dsp->SWGrav, SouthWestGravity); + else if ((report.xany.window == dsp->NWGrav) && (report.xany.type == ButtonPress) && + ((report.xbutton.button & 0xFF) == Button1)) + Set_BitGravity(&report.xbutton, dsp, dsp->NWGrav, NorthWestGravity); + XFlush(dsp->display_id); + } /* end while */ +} /* end getXsignaldata() */ diff --git a/src/z2.c b/src/z2.c old mode 100755 new mode 100644 index 89aea82..d701991 --- a/src/z2.c +++ b/src/z2.c @@ -5,16 +5,15 @@ static char *id = "$Id: z2.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyright */ /***********************************************************************/ /* - File Name : z2.c + File Name : z2.c - Including : N_OP_clfmemb -- op 035 - N_OP_classoc -- op 033 - N_OP_restlist -- op 043 + Including : N_OP_clfmemb -- op 035 + N_OP_classoc -- op 033 + N_OP_restlist -- op 043 */ /**********************************************************************/ - /************************************************************************/ /* */ /* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1995 Venue. */ @@ -30,8 +29,6 @@ static char *id = "$Id: z2.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyright #include "version.h" - - #include #include "lispemul.h" #include "emlglob.h" @@ -48,135 +45,125 @@ static char *id = "$Id: z2.c,v 1.3 1999/05/31 23:35:47 sybalsky Exp $ Copyright struct cadr_cell cadr(LispPTR cell_adr); /* N_OP_classoc() OP 33Q */ -LispPTR N_OP_classoc(LispPTR key, LispPTR list) -{ -REGISTER struct cadr_cell cadr1; -register LispPTR cdrcell; /* address of (cdr A-list); Lisp address */ - +LispPTR N_OP_classoc(LispPTR key, LispPTR list) { + REGISTER struct cadr_cell cadr1; + register LispPTR cdrcell; /* address of (cdr A-list); Lisp address */ switch (key & SEGMASK) { - case S_POSITIVE: break; - case S_NEGATIVE: break; - case S_CHARACTER: break; + case S_POSITIVE: break; + case S_NEGATIVE: break; + case S_CHARACTER: break; case ATOM_OFFSET: break; default: ERROR_EXIT(list); } /* JRB - Don Charnley claims the code below should be identical to the - code in IL:ASSOC, so I copied my new and exciting version over */ + code in IL:ASSOC, so I copied my new and exciting version over */ - if (list == NIL_PTR) { return(NIL_PTR); } + if (list == NIL_PTR) { return (NIL_PTR); } - if (GetTypeNumber( list ) != TYPE_LISTP) { return(NIL_PTR); } + if (GetTypeNumber(list) != TYPE_LISTP) { return (NIL_PTR); } + S_N_CHECKANDCADR(list, cadr1, list); - S_N_CHECKANDCADR(list, cadr1, list); + do { + cdrcell = cadr1.cdr_cell; /* the rest of A-list */ + if (Listp(cadr1.car_cell) && key == car(cadr1.car_cell)) { + /* cons data found */ + return (cadr1.car_cell); + } + /* search the rest of A-list */ + if (Listp(cdrcell)) + cadr1 = cadr(cdrcell); + else + cdrcell = NIL; + /* check for interrupts and punt to handle one safely */ + if (!Irq_Stk_End) { + TopOfStack = cdrcell; /* for continuation */ + TIMER_EXIT(cdrcell); + } + } while (cdrcell != NIL_PTR); - do{ - cdrcell = cadr1.cdr_cell; /* the rest of A-list */ - if(Listp(cadr1.car_cell) && key == car(cadr1.car_cell)){ - /* cons data found */ - return(cadr1.car_cell); - } - /* search the rest of A-list */ - if(Listp(cdrcell)) - cadr1 = cadr(cdrcell); - else cdrcell = NIL; - /* check for interrupts and punt to handle one safely */ - if (!Irq_Stk_End) { - TopOfStack = cdrcell; /* for continuation */ - TIMER_EXIT(cdrcell); - } - }while(cdrcell != NIL_PTR); - - return(NIL_PTR); + return (NIL_PTR); } /* end N_OP_classoc() */ /* (CL:FMEMB item list) OP 35Q */ -LispPTR N_OP_clfmemb(register LispPTR item, register LispPTR list) -{ /* OP 35Q */ - +LispPTR N_OP_clfmemb(register LispPTR item, register LispPTR list) { /* OP 35Q */ switch (item & SEGMASK) { - case S_POSITIVE: break; - case S_NEGATIVE: break; - case S_CHARACTER: break; + case S_POSITIVE: break; + case S_NEGATIVE: break; + case S_CHARACTER: break; case ATOM_OFFSET: break; default: ERROR_EXIT(list); } /* JRB - Don Charnley claims the code below should be identical to IL:FMEMB, - so I copied it */ + so I copied it */ - while(Listp(list)) { - if(item == car(list)) - return list; - list = cdr(list); - /* if we get an interrupt, punt so we can handle it safely */ - if(!Irq_Stk_End) { - TopOfStack = list; /* for continuation */ - TIMER_EXIT(list); - } - } - if(list) ERROR_EXIT( list); - return list; + while (Listp(list)) { + if (item == car(list)) return list; + list = cdr(list); + /* if we get an interrupt, punt so we can handle it safely */ + if (!Irq_Stk_End) { + TopOfStack = list; /* for continuation */ + TIMER_EXIT(list); + } + } + if (list) ERROR_EXIT(list); + return list; } /* end N_OP_clfmemb() */ - /************************************************************ - 43 RESTLIST + 43 RESTLIST - alpha = skip -- number of args to skip - tos = last -- last arg# - tos-1 = tail + alpha = skip -- number of args to skip + tos = last -- last arg# + tos-1 = tail - IF tail = NIL THEN - page _ NEXTCONSPAGE - GOTO make - ELSE - AddRef tail - page _ CONSPAGE[tail] - GOTO make - make: - get [cnt,,next] from page - make1: - tail _ CONSCELL (CAR = IVar(last), CDR = tail) - AddRef IVar(last) - IF skip = last THEN GOTO fin - last _ last - 1 - GOTO make1 - noroomonconspage: - fin: - store updated [cnt,,next] - update ListpDTD:COUNTER - DelRef tail - IF noroomonconspage THEN UFN - ELSEIF ListpDTD:COUNTER overflow then GCPUNT - ELSEIF overflow entries then GCHANDLEOVERFLOW - ELSE NEXTOPCODE + IF tail = NIL THEN + page _ NEXTCONSPAGE + GOTO make + ELSE + AddRef tail + page _ CONSPAGE[tail] + GOTO make + make: + get [cnt,,next] from page + make1: + tail _ CONSCELL (CAR = IVar(last), CDR = tail) + AddRef IVar(last) + IF skip = last THEN GOTO fin + last _ last - 1 + GOTO make1 + noroomonconspage: + fin: + store updated [cnt,,next] + update ListpDTD:COUNTER + DelRef tail + IF noroomonconspage THEN UFN + ELSEIF ListpDTD:COUNTER overflow then GCPUNT + ELSEIF overflow entries then GCHANDLEOVERFLOW + ELSE NEXTOPCODE - alpha = skip -- number of args to skip - tos = last -- last arg# - tos-1 = tail + alpha = skip -- number of args to skip + tos = last -- last arg# + tos-1 = tail - AddRef tail + AddRef tail make1: tail , cons(IVar(last), tail) - AddRef IVar(last) - IF skip = last THEN GOTO fin - last _ last - 1 - GOTO make1 + AddRef IVar(last) + IF skip = last THEN GOTO fin + last _ last - 1 + GOTO make1 fin: DelRef tail ***********************************************************/ -LispPTR N_OP_restlist(register LispPTR tail, register int last, register int skip) -{ - +LispPTR N_OP_restlist(register LispPTR tail, register int last, register int skip) { last &= 0xFFFF; - while (skip <= last) { - tail = cons(GetLongWord(IVar + (--last << 1)), tail); - } - return(tail); -}/* end N_OP_restlist() */ + while (skip <= last) { tail = cons(GetLongWord(IVar + (--last << 1)), tail); } + return (tail); +} /* end N_OP_restlist() */ - /* end module */ +/* end module */