Here's the patch for sqXWindow.c allowing a startup document file and additional parameters. See #getSystemAttribute:
Unix hackers: this would fail if uname() is not available via <sys/utsname.h>. Is there any system without this? I tested it on Linux, SunOS and IRIX.
/bert
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="param.diff" Content-ID: Pine.LNX.3.96.990830154027.7353B@balloon.cs.uni-magdeburg.de Content-Description:
*** ftp/sqXWindow.c Wed Jun 9 17:03:54 1999 --- src/sqXWindow.c Mon Aug 30 10:35:44 1999 *************** *** 31,36 **** --- 31,37 ---- #include <sys/time.h> #include <sys/types.h> #include <sys/param.h> + #include <sys/utsname.h> #include <unistd.h> #include <errno.h> #include <signal.h> *************** *** 2485,2517 **** static char *getSpecialAttribute(int id) { static char buf[256]; switch (id) { ! case 1: /* Squeak PID */ sprintf(buf, "%d", getpid()); ! return buf; } - buf[0]= '\0'; return buf; }
int attributeSize(int id) { ! if (id + 1 >= initialArgc) return 0; ! if (id < 0) ! return strlen(getSpecialAttribute(-id)); ! else ! return strlen(initialArgv[id + 1]); }
int getAttributeIntoLength(int id, int byteArrayIndex, int length) { char *attrIndex= (char *)byteArrayIndex; char *arg; ! if (id + 1>= initialArgc) return 0; ! if (id < 0) ! arg= getSpecialAttribute(-id); else ! arg= initialArgv[id + 1]; while (length--) *attrIndex++= *arg++; return 0; --- 2491,2537 ---- static char *getSpecialAttribute(int id) { static char buf[256]; + struct utsname info; + uname(&info); switch (id) { ! case -1: sprintf(buf, "%d", getpid()); ! break; ! case 1001: /* OS */ ! strcpy(buf, info.sysname); ! break; ! case 1002: /* OS version */ ! strcpy(buf, info.release); ! break; ! case 1003: /* processor type */ ! strcpy(buf, info.machine); ! break; ! default: ! buf[0]= '\0'; } return buf; }
int attributeSize(int id) { ! if (id < 0 || id > 1000) ! return strlen(getSpecialAttribute(id)); ! if (id < initialArgc) ! return strlen(initialArgv[id]); ! return 0; }
int getAttributeIntoLength(int id, int byteArrayIndex, int length) { char *attrIndex= (char *)byteArrayIndex; char *arg; ! if (id < 0 || id > 1000) ! arg= getSpecialAttribute(id); else ! if (id < initialArgc) ! arg= initialArgv[id]; ! else ! return 0; while (length--) *attrIndex++= *arg++; return 0; *************** *** 2574,2581 **** { char *ev;
! initialArgv= argv; ! initialArgc= 0;
/* defaults */
--- 2595,2609 ---- { char *ev;
! initialArgc= 3; /* VM name + image name + document name */ ! initialArgv= malloc((argc+3) * sizeof(char*)); /* +3 is worst case */ ! if (!initialArgv) { ! fprintf(stderr, "memory allocation failed\n"); ! exit(1); ! } ! initialArgv[0]= argv[0]; ! initialArgv[1]= shortImageName; ! initialArgv[2]= ""; /* document */
/* defaults */
*************** *** 2728,2745 **** exit(0); }
! /* assume the argument is meant for Squeak, and silently ignore it */ ! initialArgv[initialArgc++]= *argv++; ! --argc; }
! if (argc) ! { ! strcpy(shortImageName, *argv); ! initialArgv[initialArgc++]= *argv++; --argc; ! } ! initialArgv[initialArgc]= (char *)0;
if (0 == strstr(shortImageName, ".image")) strcat(shortImageName, ".image"); --- 2769,2794 ---- exit(0); }
! /* first unrecognized option - keep for Squeak */ ! /* but print a warning because we got no image file yet */ ! fprintf(stderr, "Warning: no imagefile specified " ! "but additional parameters found\n"); ! break; }
! if (argc && **argv != '-') { ! strcpy(shortImageName, *argv++); --argc; ! } ! ! if (argc && **argv != '-') { ! initialArgv[2]= *argv++; ! --argc; ! } ! ! while (argc--) ! initialArgv[initialArgc++]= *argv++; ! initialArgv[initialArgc]= NULL;
if (0 == strstr(shortImageName, ".image")) strcat(shortImageName, ".image");
squeak-dev@lists.squeakfoundation.org