/* * RUNWPI.CMD - V1.0 C.Langanke 2007 * * Syntax: runwpi.cmd wpifile * * runwpi launches the specified wpi file */ /* The first comment is used as online help text */ /* ***** BEGIN LICENSE BLOCK ***** * Version: CDDL 1.0 * * The contents of this file are subject to the COMMON DEVELOPMENT AND * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of * the License at http://www.sun.com/cddl/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is * "netlabs.org Open Source Archive Administrator/Client" * * The Original Distribution Package is named * "netlabs.org Open Source Archive Administrator/Client" * and maintained and distributed by the Initial Developer * and/or netlabs.org only. * * In addition to the CDDL the following applies: * If you modify the Original Code, you may distribute it only * as a part of a distribution package where * - the name of the package, created directories or * OS2.INI entries do not contain any of the terms * - "netlabs.org Open Source Archive" * - "NOSA" * - "NOSAC" * - "NOSAADM" * - neither netlabs.org nor the Initial Developer is stated as * the vendor or originator of the resulting Distribution Package, * which contains the Modified Code. * * The Initial Developer of the Original Code is * netlabs.org: Christian Langanke . * Portions created by the Initial Developer are Copyright (C) 1999-2008 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * ***** END LICENSE BLOCK ***** */ SIGNAL ON HALT TitleLine = STRIP(SUBSTR(SourceLine(2), 3)); PARSE VAR TitleLine CmdName'.CMD 'Info Title = CmdName Info env = 'OS2ENVIRONMENT'; TRUE = (1 = 1); FALSE = (0 = 1); CrLf = '0d0a'x; Redirection = '> NUL 2>&1'; '@ECHO OFF' /* OS/2 Error codes */ ERROR.NO_ERROR = 0; ERROR.INVALID_FUNCTION = 1; ERROR.FILE_NOT_FOUND = 2; ERROR.PATH_NOT_FOUND = 3; ERROR.ACCESS_DENIED = 5; ERROR.NOT_ENOUGH_MEMORY = 8; ERROR.INVALID_FORMAT = 11; ERROR.INVALID_DATA = 13; ERROR.NO_MORE_FILES = 18; ERROR.WRITE_FAULT = 29; ERROR.READ_FAULT = 30; ERROR.GEN_FAILURE = 31; ERROR.INVALID_PARAMETER = 87; ERROR.OPEN_FAILED = 110; ERROR.ENVVAR_NOT_FOUND = 203; GlobalVars = 'Title CmdName CrLf env TRUE FALSE Redirection ERROR.'; /* eventually show help */ ARG Parm . IF ((Parm = '') | (POS('/?', Parm) > 0)) THEN DO rc = ShowHelp(); EXIT( ERROR.INVALID_PARAMETER); END; /* load sysutils */ call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs /* default values */ rc = ERROR.NO_ERROR; DO 1 /* get parms */ PARSE ARG WpiFile .; WpiFile = STRIP( WpiFile); IF (WpiFile = '') THEN DO SAY 'error: no WPI file specified.'; rc = ERROR.INVALID_PARAMETER; LEAVE; END; /* determine full path of warpin file */ WPIFullPath = STREAM( WpiFile, 'C', 'QUERY EXISTS'); IF (WPIFullPath = '') THEN DO SAY 'error: WPI file nof found:' WpiFile; rc = ERROR.FILE_NOT_FOUND; LEAVE; END; /* search warpin installation */ PARSE VALUE SysIni( , 'WarpIN', 'Path') WITH WarpINPath'0'x; IF (WarpINPath = 'ERROR:') THEN DO SAY 'error: WarpIN installation not found.'; rc = ERROR.PATH_NOT_FOUND; LEAVE; END; /* change to WarpIN directory */ rc = SETLOCAL(); rcx = DIRECTORY( WarpINPath); /* execute WPI */ ' start WarpIN' WPIFullPath; END; EXIT( rc); /* ------------------------------------------------------------------------- */ HALT: SAY 'Interrupted by user.'; EXIT( ERROR.GEN_FAILURE); /* ------------------------------------------------------------------------- */ ShowHelp: PROCEDURE EXPOSE (GlobalVars) /* show title */ SAY; SAY Title; SAY; PARSE SOURCE . . ThisFile /* skip header */ DO i = 1 TO 3 rc = LINEIN(ThisFile); END; /* show help text */ ThisLine = LINEIN(Thisfile); DO WHILE (ThisLine \= ' */') SAY SUBSTR(ThisLine, 3); ThisLine = LINEIN(Thisfile); END; /* close file */ rc = LINEOUT(Thisfile); RETURN('');