X-NEWS: cerritos.edu vmsnet.sources: 348 Relay-Version: VMS News - V6.0-1 14/11/90 VAX/VMS V5.3; site cerritos.edu Path: cerritos.edu!usc!rutgers!maverick.ksu.ksu.edu!deimos.cis.ksu.edu!mccall!miclon!ibmpcug!ctssuk!VERKADE Newsgroups: vmsnet.sources Subject: DWUTILS V1.0 part 2 of 6 Message-ID: <901223133545.00000F02@MARVIN.CTSS.CO.UK> From: VERKADE@CTSS.CO.UK (Herman Verkade) Date: 23 Dec 90 13:35:45 GMT Followup-To: vmsnet.sources.d Organization: CompuThoughts Software Solutions (UK) Ltd. Keywords: DECwindows utilities Lines: 465 -+-+-+-+-+-+-+-+ START OF PART 2 -+-+-+-+-+-+-+-+ X`09 on one of them, quits all sessions. Be careful! X XThe programming interface is available from a shareable image library: XSYS$LIBRARY:DWSTART_SHARE.EXE. Programs that use it should link against this Ximage in the same way as they link against the DECwindows images and the C Xrun-time library. The shareable image also supplies a few other routines tha Vt Xare used internally, but can be usefull for the programmer: X X`09char *DWS_Get_Local_NodeName() - Returns a pointer to a buffer X`09`09containing the local node name. X X`09char *DWS_Get_DisplayName() - Return a pointer to a buffer containing X`09`09the name of the display that is currently pointed to by X`09`09DECW$DISPLAY, for example MARVIN::0.0 X XTo rebuild, use the makefile of execute MAKEFILE.COM (That is the command fi Vle Xgenerated by my make on a complete rebuild). X XThe following files are part of the DWSTART utility: X X`09SYS$COMMON:`5BSYSEXE`5DDWSTART.CLD X`09SYS$COMMON:`5BSYSEXE`5DDWSTART_MAIN.EXE X`09SYS$COMMON:`5BSYSEXE`5DDWSTART_SERVER.EXE X`09SYS$COMMON:`5BSYSLIB`5DDWSTART_SHARE.EXE X XThe server process requires SYSNAM privilege to create a permanent display a Vnd Xneeds to be installed. It is linked against the shareable image, so that nee Vds Xto be installed as well: X X`09$ INSTALL ADD SYS$SYSTEM:DWSTART_SERVER/PRIV=SYSNAM X`09$ INSTALL ADD SYS$SHARE:DWSTART_SHARE X XTo make the DWSTART command permanently available, type: X X`09$ SET COMMAND SYS$SYSTEM:DWSTART /TAB=SYS$LIBRARY:DCLTABLES.EXE - X`09`09/OUTPUT=SYS$COMMON:`5BSYSLIB`5DDCLTABLES.EXE X`09$ INSTALL REPLACE SYS$LIBRARY:DCLTABLES X XAfter this you will need to log out and back in again. X XTo make DWSTART available across the network from other systems, you must Xdefine the network object: X X`09$ MC NCP X`09NCP> DEFINE OBJECT DWSTART NUMBER 0 - X`09_NCP> FILE SYS$SYSTEM:DWSTART_SERVER.EXE X`09NCP> SET OBJ DECW_START ALL X`09NCP> EXIT X`09$ X $ CALL UNPACK DWSTART.TXT;3 403325407 $ create 'f' X/* X * Module:`09DWstart_Application.c X * Author:`09Herman Verkade X * Description:`09Program to start a DECwindows application on a remote node X * X * Revision History: X * X * 6-dec-1990 000 HHV `09- New Module X */ X X#include "DWstart_Share.h" X X#include ssdef X#include descrip X Xunsigned int ErrorHandler(unsigned int*, unsigned int*); X Xglobalref int DwStart_Commands`5B`5D; X`0C Xunsigned int DWS_Start_Application(Node, Command, AST, Param) Xchar *Node, *Command; Xvoid (*AST)(int); Xint Param; X`7B X unsigned int Status; X unsigned short Channel; X $DESCRIPTOR(DscCommand, ""); X $DESCRIPTOR(DscDisplay, DisplayName); X X lib$establish(ErrorHandler); X `20 X/* X * Get the name and unit number of the current display and the name of the X * local node. These are needed in various parts, so we store them in some X * global variables. X */ X DscDisplay.dsc$w_length = TranslateLogical("DECW$DISPLAY", DisplayName, X`09 sizeof(DisplayName), 1); X Status = sys$assign(&DscDisplay, &Channel, 0, 0); X if (!(Status & 1)) lib$signal(DWSTART_ASSIGNERR, 1, &DscDisplay, Status, V 0); X X DisplayUnit = GetUnitNumber(Channel); X Status = sys$dassgn(Channel); X if (!(Status & 1)) lib$signal(DWSTART_DASSGNERR, 1, &DscDisplay, Status, V 0); X X LocalNodeName = DWS_Get_Local_NodeName(); X X AstRoutine = AST;`09/* Save for use in the subroutines */ X AstParam = Param; X X if (Node) `7B X`09SendToRemote(Node, Command); X `7D else `7B X`09DscCommand.dsc$a_pointer = Command; X`09DscCommand.dsc$w_length = strlen(Command); X`09cli$dcl_parse(&DscCommand, DwStart_Commands); X`09cli$dispatch(); X`09if (DeliverAST) `7B X`09 (*AstRoutine)(AstParam); X`09`7D X `7D X return(SS$_NORMAL); X`7D X Xunsigned int ErrorHandler(Signal, Mechanism) Xunsigned int *Signal, *Mechanism; X`7B X unsigned int Status; X int i; X static char Active; X X if (!Active && Signal`5B1`5D != SS$_UNWIND) `7B X`09Active = 1; X`09Resignal(Signal);`09/* See if caller wants to display the error */ X`09Active = 0; X`09if (!(Signal`5B1`5D & 1)) `7B`09`09/* The underlying code depends on */ X`09 Mechanism`5B3`5D = Signal`5B1`5D;`09/* an unwind if anything goes wro Vng */ X`09 sys$unwind(0, 0); X`09 return; X`09`7D X`09return(SS$_CONTINUE); X `7D X return(SS$_RESIGNAL); X`7D X`0C X/* X * The following routines are called by the CLI dispatcher to start some X * application. They're all pretty basic and new ones can be added easily. X * X * I think LOGINOUT resets the process name, so that bit might be a bit X * ineffective. The input file name needs to be parsed, because SYS$LOGIN X * is unknown to the new process. X * X * The DeliverAST variable is checked by the main routine. If it is kept at V 0, X * the AST will not be delivered until the created process ends. X */ XStartSessionManager() X`7B X char OutputFileName`5B128`5D; X char ProcessName`5B32`5D; X X sprintf(ProcessName, "DECW$SM_%d", DisplayUnit); X ParseFileName("SYS$LOGIN:DECW_SM_REMOTE.LOG", OutputFileName, X`09 sizeof(OutputFileName) - 1); X CreateProcess("SYS$COMMON:`5BSYSMGR`5DDECW$STARTSM.COM", OutputFileName, X`09 ProcessName, 1, 0); X DeliverAST = 1; X return(SS$_NORMAL); X`7D X XStartMailProcess() X`7B X char OutputFileName`5B128`5D; X char ProcessName`5B32`5D; X X sprintf(ProcessName, "DECW$MAIL_%d", DisplayUnit); X CreateMailbox(); X ParseFileName("SYS$LOGIN:DECW_MAIL.LOG", OutputFileName, X`09 sizeof(OutputFileName) - 1); X CreateProcess(MailBox, OutputFileName, ProcessName, 1, 0); X SendCommand("$ MC DECW$MAIL", 1); X SendCommand("$ STOP/ID=0", 0); X CloseMailbox(); X DeliverAST = 1; X return(SS$_NORMAL); X`7D X XStartLoginScreen() X`7B X char OutputFileName`5B128`5D; X char ProcessName`5B32`5D; X X sprintf(ProcessName, "DECW$LOGIN_%d", DisplayUnit); X CreateMailbox(); X ParseFileName("SYS$LOGIN:DECW_STARTLOGIN.LOG", OutputFileName, X`09 sizeof(OutputFileName) - 1); X CreateProcess(MailBox, OutputFileName, ProcessName, 1, 0); X SendCommand("$ RUN SYS$SYSTEM:DECW$STARTLOGIN", 1); X SendCommand("$ STOP/ID=0", 0); X CloseMailbox(); X DeliverAST = 1; X return(SS$_NORMAL); X`7D $ CALL UNPACK DWSTART_APPLICATION.C;36 1416113789 $ create 'f' X! X! Module:`09DWstart_Commands.cld X! Author:`09Herman Verkade X! Description:`09Definitions for DWstart X! X! Revision History: X! X! 20-nov-1990 000 HHV`09- New module X! X Xdefine verb DECTERM X`09routine StartDECterm X`09qualifier WAIT X`09qualifier COMMAND, value(list, type=$quoted_string) X`09qualifier RESOURCE_FILE, value(required, type=$file) X`09qualifier X_POSITION, value(required, type=$number) X`09qualifier Y_POSITION, value(required, type=$number) X`09qualifier FOREGROUND, value(required, type=$quoted_string) X`09qualifier BACKGROUND, value(required, type=$quoted_string) X`09qualifier TITLE_BAR, value(required, type=$quoted_string) X`09qualifier ICON_NAME, value(required, type=$quoted_string) X Xdefine verb SESSION_MANAGER X`09routine StartSessionManager X Xdefine verb MAIL X`09routine StartMailProcess X Xdefine verb LOGIN_SCREEN X`09routine StartLoginScreen X Xdefine verb DT_CONTROLLER X`09routine StartDECtermController $ CALL UNPACK DWSTART_COMMANDS.CLD;14 1242111969 $ create 'f' X/* X * Module:`09DWstart_DECterm.c X * Author:`09Herman Verkade X * Description:`09Program to start a DECwindows application on a remote node X * X * Revision History: X * X * 19-oct-1990 001 HHV`09- Rewrite everything into one image with CLI interf Vace X * 10-sep-1990 000 HHV `09- New Module X */ X X#include "DWstart_Share.h" X X#ifdef V52 X/* Note: The DECwTermPort routine has a bug in V5.2. A routine to fix this i Vs X * at the end of this module, but the optimizer messes things up by expandin Vg X * this fix inline. Therefore we need the following line: X */ X#pragma noinline(fix_DECwTermPort_bug, fix2) X#endif X X#include ssdef X#include descrip X X#include prcdef X#include dvidef X#include iodef X#include lnmdef X#include climsgdef X Xstatic char Terminal`5B50`5D;`09/* Must be 50 !! */ X`0C X/* X * Routine to start one of those DECW$TE_nn processes. Under V5.2 DWSTART wi Vll X * need to do this explicitly. On later versions, it can save you a few seco Vnds X * on creation of DECterms, if you start this process at login. X */ XStartDECtermController() X`7B X char OutputFileName`5B128`5D; X char ProcessName`5B32`5D; X X CreateMailbox(); X sprintf(ProcessName, "DECW$TE_%d", DisplayUnit); X ParseFileName("SYS$LOGIN:DECW_TE.LOG", OutputFileName, X`09 sizeof(OutputFileName) - 1); X CreateProcess(MailBox, OutputFileName, ProcessName, 1, 0); X SendCommand("$ MC DECW$TERMINAL", 1); X SendCommand("$ STOP/ID=0", 0); X CloseMailbox(); X DeliverAST = 1; X return(SS$_NORMAL); X`7D X`0C X/* X * Start a DECterm process. We need a DECterm and a process. If /COMMAND was X * given, the process gets input from a mailboxes and we force the commands X * into this mailbox. If no /COMMAND was given, we give it the DECterm as X * input to allow the user to do whatever he likes. X * X * The /WAIT qualifier specifies whether the originator wants to wait for th Ve X * process to finish, or just for the startup to finish. X */ XStartDECterm() X`7B X unsigned int Status; X int Wait; X char *p1, *p2; X char CommandLine`5BCOMMAND_LEN + 1`5D; X unsigned short CommandLineLen; X $DESCRIPTOR(DscWait, "WAIT"); X $DESCRIPTOR(DscCommand, "COMMAND"); X $DESCRIPTOR(DscCommandLine, CommandLine); X X CreateDECterm(); X Status = cli$present(&DscWait); X if (Status & 1) `7B X`09Wait = 1; X `7D else if (Status == CLI$_ABSENT `7C`7C Status == CLI$_NEGATED) `7B X`09Wait = 0; X `7D else `7B X`09lib$signal(Status); X `7D X Status = cli$present(&DscCommand); X if (Status & 1) `7B X`09CreateMailbox(); X`09CreateProcess(MailBox, Terminal, Terminal, 1, Wait); X`09sprintf(CommandLine, "$ DEFINE SYS$INPUT %s", Terminal); X`09SendCommand(CommandLine, 1); X`09while ((Status = cli$get_value(&DscCommand, &DscCommandLine, X`09`09&CommandLineLen)) & 1) `7B X`09 CommandLine`5BCommandLineLen`5D = '\0'; X`09 for (p1 = p2 = CommandLine; *p1; p1++) `7B X`09`09if (*p1 != '\"') `7B X`09`09 *p2++ = *p1; X`09`09`7D X`09 `7D X`09 *p2 = '\0'; X`09 SendCommand(CommandLine, 0); X`09`7D X`09if (Status != CLI$_ABSENT) `7B X`09 lib$signal(Status); X`09`7D X`09SendCommand("$ STOP/ID=0", 0); X`09CloseMailbox(); X `7D else `7B X`09CreateProcess(Terminal, Terminal, Terminal, 1, Wait); X `7D X DeliverAST = !Wait; X return(SS$_NORMAL); X`7D X`0C X/* X * CreateDECterm: Create a DECterm using the DECwTermPort routine. It gets X * additional info from the command and passes this to DECwTermPort. X */ Xvoid CreateDECterm() X`7B X unsigned int Status; X unsigned short RetLen; X char ResourceFileName`5BFILENAME_LEN + 1`5D, *ResourceFile, ParameterTex Vt`5B64`5D; X char Customization`5B1024`5D, *Cust; X $DESCRIPTOR(DscResourceFile, "RESOURCE_FILE"); X $DESCRIPTOR(DscXPosition, "X_POSITION"); X $DESCRIPTOR(DscYPosition, "Y_POSITION"); X $DESCRIPTOR(DscTitleBar, "TITLE_BAR"); X $DESCRIPTOR(DscIconName, "ICON_NAME"); X $DESCRIPTOR(DscBackGround, "BACKGROUND"); X $DESCRIPTOR(DscForeGround, "FOREGROUND"); X $DESCRIPTOR(DscResourceFileName, ResourceFileName); X $DESCRIPTOR(DscParameterText, ParameterText); X X Status = cli$get_value(&DscResourceFile, &DscResourceFileName, &RetLen); X if ((Status & 1)) `7B X`09ResourceFileName`5BRetLen`5D = '\0'; X`09ResourceFile = ResourceFileName; X `7D else if (Status == CLI$_NEGATED `7C`7C Status == CLI$_ABSENT) `7B X`09ResourceFile = 0; X `7D else `7B X`09lib$signal(Status); X `7D X X Cust = Customization; X X Status = cli$get_value(&DscXPosition, &DscParameterText, &RetLen); X if ((Status & 1)) `7B X`09ParameterText`5BRetLen`5D = '\0'; X`09sprintf(Cust, "DECW$TERMINAL.x:\t%s\n", ParameterText); X`09Cust += strlen(Cust); X `7D else if (Status != CLI$_NEGATED && Status != CLI$_ABSENT) `7B X`09lib$signal(Status); X `7D X X Status = cli$get_value(&DscYPosition, &DscParameterText, &RetLen); X if ((Status & 1)) `7B X`09ParameterText`5BRetLen`5D = '\0'; X`09sprintf(Cust, "DECW$TERMINAL.y:\t%s\n", ParameterText); X`09Cust += strlen(Cust); X `7D else if (Status != CLI$_NEGATED && Status != CLI$_ABSENT) `7B X`09lib$signal(Status); X `7D X X Status = cli$get_value(&DscBackGround, &DscParameterText, &RetLen); X if ((Status & 1)) `7B X`09ParameterText`5BRetLen`5D = '\0'; X`09sprintf(Cust, "DECW$TERMINAL.main.terminal.foreground:\t%s\n", ParameterT Vext); X`09Cust += strlen(Cust); X `7D else if (Status != CLI$_NEGATED && Status != CLI$_ABSENT) `7B X`09lib$signal(Status); X `7D X X Status = cli$get_value(&DscForeGround, &DscParameterText, &RetLen); X if ((Status & 1)) `7B X`09ParameterText`5BRetLen`5D = '\0'; X`09sprintf(Cust, "DECW$TERMINAL.main.terminal.background:\t%s\n", ParameterT Vext); X`09Cust += strlen(Cust); X `7D else if (Status != CLI$_NEGATED && Status != CLI$_ABSENT) `7B X`09lib$signal(Status); X `7D X X Status = cli$get_value(&DscTitleBar, &DscParameterText, &RetLen); X if ((Status & 1)) `7B X`09ParameterText`5BRetLen`5D = '\0'; X `7D else if (Status == CLI$_NEGATED `7C`7C Status == CLI$_ABSENT) `7B X`09sprintf(ParameterText, "Terminal session for user %s on node %s", X`09`09cuserid(0), LocalNodeName); X `7D else `7B X`09lib$signal(Status); X `7D X X sprintf(Cust, "DECW$TERMINAL.title:\t%s\n", ParameterText); X Cust += strlen(Cust); X X Status = cli$get_value(&DscIconName, &DscParameterText, &RetLen); X if ((Status & 1)) `7B X`09ParameterText`5BRetLen`5D = '\0'; X `7D else if (Status == CLI$_NEGATED `7C`7C Status == CLI$_ABSENT) `7B X`09sprintf(ParameterText, "%s::%s", LocalNodeName, cuserid(0)); X `7D else `7B X`09lib$signal(Status); X `7D X X sprintf(Cust, "DECW$TERMINAL.iconName:\t%s\n", ParameterText); X Cust += strlen(Cust); X X#ifdef V52 X/* X * V5.2 fails if no DECW$TE is available. Later versions of VMS create the X * process if necesary. X */ X CheckForController(); X fix_DECwTermPort_bug(); X#endif X +-+-+-+-+-+-+-+- END OF PART 2 +-+-+-+-+-+-+-+-