/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos720 src/bos/usr/sbin/drmgr/sample_scripts/IBM_template.c.S 1.1 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* Restricted Materials of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2000,2002 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ static char sccsid[] = "@(#)08 1.1 src/bos/usr/sbin/drmgr/sample_scripts/IBM_template.c.S, cmdcfg, bos720 8/22/02 11:46:47"; /* * FILE NAME : IBM_XYZ_template.c * * ORIGINS: 27 * * This file is a DLPAR application framework * related C source file. This file can * be compiled to obtain a binary, and this * can be registered with DLPAR subsystem for callouts * during DLPAR operations. * * Application developers can use this template file * to develop their interface to drmgr. This will * enable them to make their applications DLPAR aware. */ #include #include #include /****** Various commands issued to DLPAR scripts from drmgr * These have to match the (indices wise) array of strings * that follows soon. */ #define SCRIPTINFO 0 #define REGISTER 1 #define USAGE 2 #define CHECKRELEASE 3 #define PRERELEASE 4 #define POSTRELEASE 5 #define UNOPRERELEASE 6 #define CHECKACQUIRE 7 #define PREACQUIRE 8 #define POSTACQUIRE 9 #define UNDOPREACQUIRE 10 char * DR_script_commands[] = { "scriptinfo", "register", "usage", "checkrelease", "prerelease", "postrelease", "undoprerelease", "checkacquire", "preacquire", "postacquire", "undopreacquire" }; int str_to_cmd(char * cmd_str); int process_scriptinfo(void); int process_register(void); int process_usage(char * resource); int process_checkrelease(char * resource); int process_prerelease(char * resource); int process_undoprerelease(char * resource); int process_postrelease(char * resource); /***************************************************** * main: Starting point for the C code DLPAR example *****************************************************/ int main(int argc, char * argv[]) { char *command_str = "dummy"; char *resource_name ="dummy"; int command; int ret_code = 0; char **env_vars; int i; env_vars = getpenv(PENV_USR); if(env_vars == NULL) { /* error */ fprintf(stderr, "script(%s):getpenv failed\n", argv[0]); } /* One can browse the environment variable list to find the required environment variable value. for(i=0;env_vars[i];i++) { fprintf(stderr, "%s\n", env_vars[i]); } */ switch(argc) { case 0: case 1: /* error. we expect command atleast */ return(-1); case 2: command_str = argv[1]; break; case 3: command_str = argv[1]; resource_name = argv[2]; break; default: return(-2); } /* end of switch */ command = str_to_cmd(command_str); switch(command) { case SCRIPTINFO: ret_code = process_scriptinfo(); break; case REGISTER: ret_code = process_register(); break; case USAGE: ret_code = process_usage(resource_name); break; case CHECKRELEASE: break; case PRERELEASE: ret_code = process_prerelease(resource_name); break; case POSTRELEASE: ret_code = process_postrelease(resource_name); break; case UNOPRERELEASE: ret_code = process_undoprerelease(resource_name); break; case CHECKACQUIRE: ret_code = 10; break; case PREACQUIRE: ret_code = 10; break; case POSTACQUIRE: ret_code = 10; break; case UNDOPREACQUIRE: ret_code = 10; break; } /* end of switch */ exit(ret_code); } /* end of main */ /***************************************************** * str_to_cmd : probes the internal table and converts * a command string to command numeral. *****************************************************/ int str_to_cmd(char * cmd_str) { int i; for(i=0;i