home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / schematk / src_1152.lha / Schematik_main.m < prev    next >
Encoding:
Text File  |  1993-03-09  |  4.6 KB  |  116 lines

  1. /* Copyright รก 1991 Gustavus Adolphus College.  All rights reserved.
  2.  *
  3.  * Schematik was developed by Gustavus Adolphus College (GAC) with
  4.  * support from NeXT Computer, Inc.  Permission to copy this software,
  5.  * to redistribute it, and to use it for any purpose is granted,
  6.  * subject to the following restrictions and understandings.
  7.  *
  8.  * 1. Any copy made of this software must include this copyright
  9.  * notice in full.
  10.  *
  11.  * 2. Users of this software agree to make their best efforts (a) to
  12.  * return to the GAC Mathematics and Computer Science Department any
  13.  * improvements or extensions that they make, so that these may be
  14.  * included in future releases; and (b) to inform GAC of noteworthy
  15.  * uses of this software.
  16.  *
  17.  * 3. All materials developed as a consequence of the use of this
  18.  * software shall duly acknowledge such use, in accordance with the
  19.  * usual standards of acknowledging credit in academic research.
  20.  *
  21.  * 4. GAC makes no express or implied warranty or representation of
  22.  * any kind with respect to this software, including any warranty
  23.  * that the operation of this software will be error-free.  ANY
  24.  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
  25.  * PURPOSE IS HEREBY DISCLAIMED.  GAC is under no obligation to
  26.  * provide any services, by way of maintenance, update, or otherwise.
  27.  *
  28.  * 5. In conjunction with products arising from the use of this
  29.  * material, there shall be no use of the name of Gustavus Adolphus
  30.  * College nor of any adaptation thereof in any advertising,
  31.  * promotional, or sales literature without prior written consent
  32.  * from GAC in each case.
  33.  */
  34.  
  35. #import "defines.h"
  36. #import "Main.h"
  37. #import "Agent.subproj/PrefAgent.h"
  38. #import "Main.subproj/SchemeProtocol.h"
  39. #import <stdlib.h>
  40. #import <string.h>
  41. #import <syslog.h>
  42.  
  43. #define NIBFILE    "Schematik.nib"
  44.  
  45. char *stlchr(const char *, int);
  46. static void exit_monitor(void);
  47. char *appDirectory;
  48.  
  49. void main(int argc, char *argv[])
  50. {
  51.     atexit(exit_monitor);
  52.     appDirectory = stlchr(NXCopyStringBuffer(argv[0]), PATHSEPARATOR);
  53.     NXApp = [Main new];
  54.     DEBUG_ASSERT(NXApp!=nil)
  55.     [[NXApp prefAgent] loadLocalMainMenu:NIBFILE];
  56.     [NXApp addWindowsItem:[NXApp interactionWindow] title:INTERWINDOWTITLE filename:NO];
  57.     [NXApp run];
  58.     [NXApp free];
  59.     exit(0);
  60. }
  61.  
  62. static void exit_monitor()
  63. {
  64.     if(schemePid){
  65.       int result=kill(schemePid, 9);
  66.       if (result<0)
  67.         syslog(LOG_WARNING|LOG_LOCAL1, "Scheme kill unsuccessful in exit_monitor().  Scheme pid:%i  errno=%i (%s).", schemePid, errno, strerror(errno));
  68.       else
  69.         schemePid=0;
  70.     }
  71.   }
  72.  
  73. char *stlchr(char *path, int chr)
  74. {
  75.     int x=strlen(path);
  76.  
  77.     while (x)
  78.       if (path[--x]==chr)
  79.         {
  80.           path[x] = '\0';
  81.           break;
  82.         }
  83.     return (path);
  84. }
  85.  
  86. #ifdef DEBUG
  87. void translateencoding(char *encoding, void *argFrame, int offset)
  88. {
  89.     switch (*encoding)
  90.       {
  91.     case _C_CHR : DEBUG_PRINTF "(char)%c ",marg_getValue(argFrame,offset,char)); break;
  92.     case _C_UCHR: DEBUG_PRINTF "(unsigned char)%c ",marg_getValue(argFrame,offset,unsigned char)); break;
  93.     case _C_INT : DEBUG_PRINTF "(int)%i ",marg_getValue(argFrame,offset,int)); break;
  94.     case _C_UINT: DEBUG_PRINTF "(unsigned)%u ",marg_getValue(argFrame,offset,unsigned)); break;
  95.     case _C_SHT : DEBUG_PRINTF "(short)%hi ",marg_getValue(argFrame,offset,short)); break;
  96.     case _C_USHT: DEBUG_PRINTF "(unsigned short)%hu ",marg_getValue(argFrame,offset,unsigned short)); break;
  97.     case _C_LNG : DEBUG_PRINTF "(long)%li ",marg_getValue(argFrame,offset,long)); break;
  98.     case _C_ULNG: DEBUG_PRINTF "(unsigned long)%lu ",marg_getValue(argFrame,offset,unsigned long)); break;
  99.     case _C_FLT : DEBUG_PRINTF "(float)%g ",marg_getValue(argFrame,offset,double)); break;
  100.     case _C_DBL : DEBUG_PRINTF "(double)%g ",marg_getValue(argFrame,offset,double)); break;
  101.     case _C_VOID: DEBUG_PRINTF "(void) "); break;
  102.     case _C_SEL : DEBUG_PRINTF "(SEL)%s ",sel_getName(marg_getValue(argFrame,offset,SEL))); break;
  103.     case _C_ID  : DEBUG_PRINTF "(id)%s ",[marg_getValue(argFrame,offset,id) name]); break;
  104.     case _C_BFLD: DEBUG_PRINTF "(bitfield)%i ",marg_getValue(argFrame,offset,int)); break;
  105.     case _C_CHARPTR : DEBUG_PRINTF "(char *)%s ",marg_getValue(argFrame,offset,char *)); break;
  106.     case _C_CLASS   : DEBUG_PRINTF "(Class)%s ",marg_getValue(argFrame,offset,Class)->name); break;
  107.     case _C_ARY_B   : DEBUG_PRINTF "(array) "); break;
  108.     case _C_STRUCT_B: DEBUG_PRINTF "(struct) "); break;
  109.     case _C_UNION_B : DEBUG_PRINTF "(union) "); break;
  110.     case _C_PTR     : DEBUG_PRINTF "(pointer) "); break;
  111.     case _C_UNDEF   : DEBUG_PRINTF "<unknown> "); break;
  112.     default         : DEBUG_PRINTF "<unsupported> "); break;
  113.       }
  114. }
  115. #endif
  116.