/* * Copyright 1992-1999 Silicon Graphics, Inc. * All Rights Reserved. * * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; * the contents of this file may not be disclosed to third parties, copied or * duplicated in any form, in whole or in part, without the prior written * permission of Silicon Graphics, Inc. * * RESTRICTED RIGHTS LEGEND: * Use, duplication or disclosure by the Government is subject to restrictions * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data * and Computer Software clause at DFARS 252.227-7013, and/or in similar or * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - * rights reserved under the Copyright Laws of the United States. */ #include "ui.h" int verify_action_uid(char *actuname) { struct passwd *ptr; uid_t act_uid = 0; setpwent(); while ((ptr = getpwent()) != NULL) { if (strcasecmp(actuname, ptr->pw_name) == 0) { if (act_uid == ptr->pw_uid) { endpwent(); return 0;} endpwent(); return 1; } } endpwent(); return 2; } /* This function reads from the database and brings up the different parameters for the select action */ static const char szErrMsgEventMonDead[] = "Event monitoring daemon is not running\n"; void action_parameters(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection, ssdb_Error_Handle error_handle,CMDPAIR *cmdp) { ssdb_Request_Handle req_handle; int number_of_records,rec_sequence; const char **vector; char common_string[2]; int action_id,key,multiselect,common_int; create_help(hError,"setup_actions_update"); if(!get_variable(hError,cmdp,INTTYPE,"multiselect",common_string,&multiselect,100)) return; if(!get_variable(hError,cmdp,INTTYPE,"actionid",common_string,&action_id,101)) return; if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select action_id,timeoutval,dsmthrottle,dsmfrequency,action,retrycount,userstring,action_desc " "from event_action where action_id = '%d'",action_id))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0) { Body("There are no actions in the database.\n"); ssdbFreeRequest(error_handle,req_handle); return ; } /* Create the java pieces here */ Body("\n"); Body(" \n"); Body("SGI Embedded Support Partner - ver.1.0\n"); if (!(read_java_scritps("##ACTION_PARAM","##ACTION_PARAM_END"))) { ssdbFreeRequest(error_handle,req_handle); sscError(hError,"Error reading java script for this operation\n"); return ; } Body("\n"); Body("\n"); Body("\n"); Body("
\n"); TableBegin("border=0 cellpadding=0 cellspacing=0 width=100%"); RowBegin(""); CellBegin("bgcolor=\"#cccc99\" width=15"); Body("    \n"); CellEnd(); CellBegin("bgcolor=\"#cccc99\""); Body("SETUP > Actions > Update\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("align=right colspan=2"); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2 "); Body("  \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); CellBegin(""); vector = ssdbGetRow(error_handle,req_handle); TableBegin("border=0 cellpadding=0 cellspacing=0"); RowBegin("valign=top"); CellBegin(""); Body("Action description:\n"); CellEnd(); CellBegin(""); Body("  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%s",vector[7]); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Actual action command string:\n"); CellEnd(); CellBegin(""); Body("  \n"); CellEnd(); CellBegin(""); FormatedBody("",vector[4]); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("  \n"); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body("Enter a username to execute the action:\n"); CellEnd(); CellBegin(""); Body("  \n"); CellEnd(); CellBegin(""); FormatedBody("",vector[6]); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body("Enter action timeout (in multiples of 5)\n"); CellEnd(); CellBegin(""); Body("  \n"); CellEnd(); CellBegin(""); FormatedBody(" seconds",atoi(vector[1])); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body("Enter the number of times that the event must be registered before an action will be taken:\n"); CellEnd(); CellBegin(""); Body("  \n"); CellEnd(); CellBegin(""); FormatedBody("",atoi(vector[2])); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body("Enter the number of retry times (up to 23; more than 4 not recommended):\n"); CellEnd(); CellBegin(""); Body("  \n"); CellEnd(); CellBegin(""); FormatedBody("",atoi(vector[5])); CellEnd(); RowEnd(); ssdbFreeRequest(error_handle,req_handle); TableEnd(); Body("

   \n"); FormatedBody("",action_id); FormatedBody(""); CellEnd(); RowEnd(); TableEnd(); Body("

\n"); Body("\n"); Body("\n"); } /* This function is dual purpose. With multiselect 1, the function is used for update and with multiselect 0, the function is used to add a new action */ void update_action_params(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection, ssdb_Error_Handle error_handle,CMDPAIR *cmdp) { ssdb_Request_Handle req_handle; const char **vector; char user_name[32],action_description[80],action_name[255],sys_id[32],common_string[2],act_str[255]; int number_of_records,actionid, key,action_timeout,dsmthrottle,dsmfrequency,retryt,multiselect,common_int,last_id; if(!get_variable(hError,cmdp,INTTYPE,"multiselect",common_string,&multiselect,102)) return; if (multiselect) if(!get_variable(hError,cmdp,INTTYPE,"actionid",common_string,&actionid,103)) return; if(!get_variable(hError,cmdp,INTTYPE,"action_timeout",common_string,&action_timeout,104)) return; if(!get_variable(hError,cmdp,INTTYPE,"dsmthrottle",common_string,&dsmthrottle,105)) return; /*if(!get_variable(hError,cmdp,INTTYPE,"dsmfrequency",common_string,&dsmfrequency,106)) return; */ if(!get_variable(hError,cmdp,INTTYPE,"retryt",common_string,&retryt,107)) return; if(!get_variable(hError,cmdp,CHARTYPE,"user_name",user_name,&common_int,108)) return; else { if(verify_action_uid(user_name) != 1) { Body("Embedded Support Partner\n"); Body("\n"); Body("\n"); TableBegin("border=0 cellpadding=0 cellspacing=0 width=100%"); RowBegin(""); CellBegin("bgcolor=\"#cccc99\" width=15"); Body("    \n"); CellEnd(); CellBegin("bgcolor=\"#cccc99\""); if(multiselect) Body("SETUP > Actions > Update > ERROR\n"); else Body("SETUP > Actions > Add > ERROR\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" 

 \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); CellBegin(""); if(verify_action_uid(user_name) == 0) Body("Username is invalid. Action cannot be executed by root.\n\n"); if(verify_action_uid(user_name) == 2) FormatedBody("Username \"%s\" is not valid.\n",user_name); CellEnd(); RowEnd(); TableEnd(); Body("\n"); return; } } if (!multiselect) { if(!get_variable(hError,cmdp,CHARTYPE,"action_description",action_description,&common_int,110)) return; if(!get_variable(hError,cmdp,CHARTYPE,"action_name",action_name,&common_int,111)) return; if(!get_variable(hError,cmdp,CHARTYPE,"sys_id",sys_id,&common_int,112)) return; } /* lock the table */ if(!(ssdbLockTable(error_handle,connection,"event_action"))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } /* Update fucntion here. Get additional parameter for update of actions */ if (multiselect) { if(!get_variable(hError,cmdp,CHARTYPE,"act_str",act_str,&common_int,109)) return; if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_UPDATE, "update event_action set dsmthrottle=%d,retrycount=%d,timeoutval=%d,userstring=\"%s\",action=\"%s\"" " where action_id = %d",dsmthrottle,retryt,action_timeout,user_name,act_str,actionid))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } } /* Insert a new action */ else { if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_INSERT, "insert into event_action values ('%s',NULL,'',%d,0,\"%s\",%d,%d,\"%s\",\"%s\",0,0)", sys_id,dsmthrottle,action_description,retryt,action_timeout,user_name,action_name))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } } ssdbFreeRequest(error_handle,req_handle); if (!ssdbUnLockTable(error_handle,connection)) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } /* Let the event manager know that there was a configuration change */ if(configure_rule("UPDATE -1")) { ssdbFreeRequest(error_handle,req_handle); sscError(hError, (char*) szErrMsgEventMonDead ); return; } /* Select the new values from the db for the confirmation screen. In the case of insertion of new action, get the last inserted id() as the event_action id's are automatically generated */ if (multiselect) { if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select action_desc,action,userstring,timeoutval,dsmthrottle,dsmfrequency,retrycount " "from event_action where action_id = %d",actionid))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } } else { if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select last_insert_id()"))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0) { Body("Last inserted ID read failed\n"); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); ssdbFreeRequest(error_handle,req_handle); return ; } vector = ssdbGetRow(error_handle,req_handle); if(vector) { last_id = atoi(vector[0]); ssdbFreeRequest(error_handle,req_handle); if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select action_desc,action,userstring,timeoutval,dsmthrottle,dsmfrequency,retrycount " "from event_action where action_id = %d",last_id))) { sscError(hError,"Database API Error: \"%s\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } } } if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0) { Body("There are no actions in the database.\n"); ssdbFreeRequest(error_handle,req_handle); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return ; } else { Body("\n"); Body("\n"); Body("SGI Embedded Support Partner - ver.1.0\n"); Body("\n"); Body("\n"); Body("

\n"); TableBegin("border=0 cellpadding=0 cellspacing=0 width=100%"); RowBegin(""); CellBegin("bgcolor=\"#cccc99\" width=15"); Body("    \n"); CellEnd(); CellBegin("bgcolor=\"#cccc99\""); if(multiselect) Body("SETUP > Actions > Update\n"); else Body("SETUP > Actions > Add\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" 

 \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); CellBegin(""); vector = ssdbGetRow(error_handle,req_handle); TableBegin("border=0 cellpadding=0 cellspacing=0"); RowBegin("valign=top"); CellBegin(""); Body("Action description:\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%s",vector[0]); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body("Action command string\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%s",vector[1]); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("A username to execute the action\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%s",vector[2]); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Action timeout\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%d seconds",atoi(vector[3])); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Number of times the event must be registered before an action will be taken\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%d",atoi(vector[4])); CellEnd(); RowEnd(); /*@row @cell @   @endcell @endrow @row @cell @ Delay time between the event and an action @endcell @cell @     :   @endcell @cell colspan=2 @format "%d seconds" atoi(vector[5]) @endcell @endrow */ RowBegin(""); CellBegin(""); Body("  \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Retry times\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2 "); FormatedBody("%d",atoi(vector[6])); CellEnd(); RowEnd(); ssdbFreeRequest(error_handle,req_handle); TableEnd(); CellEnd(); RowEnd(); TableEnd(); Body("

\n"); Body("\n"); Body("\n"); } } void delete_action(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection, ssdb_Error_Handle error_handle,CMDPAIR *cmdp) { ssdb_Request_Handle req_handle; int number_of_records,key,deletebutton,action_id,common_int; char actionbuffer[80], sys_id[32],common_string[2]; if (!get_variable(hError,cmdp,INTTYPE,"actionid",common_string,&action_id,113)) return; if(!get_variable(hError,cmdp,CHARTYPE,"sys_id",sys_id,&common_int,114)) return; if(!get_variable(hError,cmdp,CHARTYPE,"action_desc",actionbuffer,&common_int,115)) return; if(!get_variable(hError,cmdp,INTTYPE,"proceeddel",common_string,&deletebutton,116)) return; if (deletebutton) { if (!(ssdbLockTable(error_handle,connection,"actions_taken,event_action,event_actionref"))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE, "delete from event_actionref where action_id = %d and sys_id = '%s'",action_id,sys_id))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } ssdbFreeRequest(error_handle,req_handle); if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE, "delete from actions_taken where action_id = %d and sys_id = '%s'",action_id,sys_id))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } ssdbFreeRequest(error_handle,req_handle); if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_DELETE, "delete from event_action where action_id = %d and sys_id = '%s'",action_id,sys_id))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); if (!ssdbUnLockTable(error_handle,connection)) sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } ssdbFreeRequest(error_handle,req_handle); if (!ssdbUnLockTable(error_handle,connection)) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } if(configure_rule("UPDATE -1")) { sscError(hError, (char*) szErrMsgEventMonDead ); return; } } Body("\n"); Body("\n"); Body("SGI Embedded Support Partner - ver.1.0\n"); Body("\n"); Body("\n"); Body("\n"); TableBegin("border=0 cellpadding=0 cellspacing=0 width=100%"); RowBegin(""); CellBegin("bgcolor=\"#cccc99\" width=15"); Body("    \n"); CellEnd(); CellBegin("bgcolor=\"#cccc99\""); Body("SETUP > Actions > Delete\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); CellBegin(""); if (deletebutton) { Body("The following action has been deleted from the SGI Embedded Support Partner database:\n"); FormatedBody("",actionbuffer); } else Body("Request for deletion cancelled.\n"); CellEnd(); RowEnd(); TableEnd(); Body(" \n"); } int deletelistset(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection, ssdb_Error_Handle error_handle,CMDPAIR *cmdp) { ssdb_Request_Handle req_handle; int key,number_of_records,rec_sequence,action_id,common_int,row_num,balance_rows,total_pages,pageno,firstpage,lastpage,bottom; const char **vector; char actionbuffer[80],sys_id[32],common_string[2]; if(!get_variable(hError,cmdp,CHARTYPE,"sys_id",sys_id,&common_int,117)) return 0; if(!get_variable(hError,cmdp,INTTYPE,"actionid",common_string,&action_id,118)) return 0; if(!get_variable(hError,cmdp,INTTYPE,"row_num",common_string,&row_num,119)) return 0; if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select action_desc from event_action where action_id = %d and sys_id = '%s'",action_id,sys_id))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return 0; } if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0) { Body("There are no records for this operation\n"); ssdbFreeRequest(error_handle,req_handle); return (number_of_records); } vector = ssdbGetRow(error_handle,req_handle); if (vector) strcpy (actionbuffer, vector[0]); else strcpy (actionbuffer,"Unknown"); ssdbFreeRequest(error_handle,req_handle); if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select DISTINCT event_type.type_desc from event_type,event_actionref " "where event_actionref.action_id = %d " "and event_actionref.type_id = event_type.type_id " "and event_actionref.sys_id = '%s' " "order by event_type.type_id",action_id,sys_id))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return 0; } number_of_records = getnumrecords(hError,error_handle,req_handle); create_help (hError,"setup_actions_delete"); Body("\n"); Body("\n"); Body("SGI Embedded Support Partner - ver.1.0\n"); if (!(read_java_scritps("##DELETELISTSET","##DELETELISTSET_END"))) { sscError(hError,"Error reading java script for this operation\n"); ssdbFreeRequest(error_handle,req_handle); return 0; } Body("\n"); Body("\n"); Body("
\n"); TableBegin("border=0 cellpadding=0 cellspacing=0 width=100%"); RowBegin(""); CellBegin("bgcolor=\"#cccc99\" width=15"); Body("    \n"); CellEnd(); CellBegin("bgcolor=\"#cccc99\""); Body("SETUP > Actions > Delete\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("align=right colspan=2"); Body("\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); CellBegin(""); if (number_of_records) { FormatedBody("The following events will be affected as a result of %s action deletion:",actionbuffer); Body("

\n"); TableBegin("BORDER=0 CELLSPACING = 0 CELLPADDING=0"); RowBegin(""); CellBegin("align=right"); total_pages = number_of_records/10; if (number_of_records%10) total_pages++; pageno = row_num/10; pageno++; FormatedBody("Page %d of %d",pageno,total_pages); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); TableBegin("border=4 cellpadding=6 cellspacing=1"); RowBegin("align=center"); CellBegin(""); Body("No\n"); CellEnd(); CellBegin(""); Body("Event Description\n"); CellEnd(); RowEnd(); balance_rows = row_num + 10; if (balance_rows > number_of_records) balance_rows = number_of_records; ssdbRequestSeek(error_handle,req_handle,row_num,0); for (rec_sequence = row_num; rec_sequence < balance_rows; rec_sequence++) { RowBegin(""); vector = ssdbGetRow(error_handle,req_handle); if (vector) { CellBegin(""); FormatedBody("%d",rec_sequence); CellEnd(); CellBegin(""); FormatedBody("%s",vector[0]); CellEnd(); } RowEnd(); } TableEnd(); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); if(total_pages > 1) { RowBegin(""); CellBegin("align=center"); firstpage = ((pageno-1)/10)*10+1; lastpage = firstpage+9; if (lastpage >= total_pages) lastpage = total_pages; if (firstpage > 1) { FormatedBody("\"first   ",0,sys_id,action_id); FormatedBody("\"previous   ",(firstpage-11)*10,sys_id,action_id); } for (rec_sequence = firstpage; rec_sequence <= lastpage; rec_sequence++) { if (rec_sequence == pageno) FormatedBody("%d  ",rec_sequence); else FormatedBody("%d   ",10*(rec_sequence-1),sys_id,action_id,rec_sequence); } if (lastpage < total_pages) { if(number_of_records%10 == 0) bottom = number_of_records -10; else bottom = number_of_records -(number_of_records%10); FormatedBody("\"next   ",(firstpage+9)*10,sys_id,action_id); FormatedBody("\"last   ",bottom,sys_id,action_id); } CellEnd(); RowEnd(); } TableEnd(); Body("

Would you like to proceed with the deletion?\n"); } else { FormatedBody("There are no events for the action %s. Would you like to proceed with the deletion?",actionbuffer); } Body("

\n"); Body("\n"); Body("   \n"); Body("\n"); FormatedBody("",actionbuffer); FormatedBody("",action_id); FormatedBody("",sys_id); Body(" \n"); CellEnd(); RowEnd(); TableEnd(); Body("

\n"); ssdbFreeRequest(error_handle,req_handle); return 1; } void view_action_page(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection, ssdb_Error_Handle error_handle,CMDPAIR *cmdp) { ssdb_Request_Handle req_handle; int key,number_of_records,rec_sequence,multiselect,action_select,common_int,pageno; const char **vector; char actionbuffer[80],sys_id[32],common_string[2]; if(!get_variable(hError,cmdp,CHARTYPE,"sys_id",sys_id,&common_int,120)) return; if(!get_variable(hError,cmdp,INTTYPE,"action_select",common_string,&action_select,121)) return; if(!action_select) create_help(hError,"screens_action_setup"); Body(" SGI Embedded Support Partner - ver.1.0\n"); if(!action_select) { if (!(read_java_scritps("##ACTIONSETUP","##ACTIONSETUP_END"))) { sscError(hError,"Error reading java script for this operation\n"); return ; } } Body("\n"); Body("\n"); if (!action_select) Body("
\n"); else Body("\n"); TableBegin("border=0 cellpadding=0 cellspacing=0 width=100%"); RowBegin(""); CellBegin("bgcolor=\"#cccc99\" width=15"); Body("    \n"); CellEnd(); CellBegin("bgcolor=\"#cccc99\""); if (!action_select) Body("SETUP > Actions > View Current Setup > View Action Setup \n"); else Body("SETUP > Actions > View Current Setup > View Available Actions List\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" \n"); CellEnd(); RowEnd(); if(!action_select) { RowBegin(""); CellBegin("align=right colspan=2"); Body("\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" 

 \n"); CellEnd(); CellBegin(""); Body("Choose an action whose description you want to view:

\n"); create_action_list(hError,session,connection,error_handle,cmdp); CellEnd(); RowEnd(); } else { RowBegin(""); CellBegin(""); Body(" 

 \n"); CellEnd(); CellBegin(""); view_action_list(hError,session,connection,error_handle,cmdp); FormatedBody("",sys_id); CellEnd(); RowEnd(); } TableEnd(); Body("

\n"); } void action_report_by_action(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection, ssdb_Error_Handle error_handle,CMDPAIR *cmdp) { ssdb_Request_Handle req_handle; int key,number_of_records,rec_sequence,multiselect,actionid,common_int; const char **vector; char common_string[2]; if(!get_variable(hError,cmdp,INTTYPE,"actionid",common_string,&actionid,122)) return; Body("SGI Embedded Support Partner - ver.1.0\n"); Body("\n"); Body("
\n"); TableBegin("border=0 cellpadding=0 cellspacing=0 width=100%"); RowBegin(""); CellBegin("bgcolor=\"#cccc99\" width=15"); Body("    \n"); CellEnd(); CellBegin("bgcolor=\"#cccc99\""); Body("SETUP > Actions > View Current Setup > View Action Setup\n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin("colspan=2"); Body(" 

 \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); CellBegin(""); if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select action_desc,action,userstring,timeoutval,dsmthrottle,dsmfrequency,retrycount " "from event_action where action_id = %d",actionid))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0) { Body("There are no actions in the database.\n"); ssdbFreeRequest(error_handle,req_handle); return ; } else { TableBegin("border=0 cellpadding=0 cellspacing=0"); vector = ssdbGetRow(error_handle,req_handle); if(vector) { RowBegin("valign=top"); CellBegin(""); Body("Action command string\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%s",vector[1]); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin("valign=top"); CellBegin(""); Body("Action description:\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%s",vector[0]); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Execute this action as\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%s",vector[2]); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Action timeout\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%d seconds",atoi(vector[3])); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Number of times the event must be registered before an action will be taken\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%d",atoi(vector[4])); CellEnd(); RowEnd(); /*@row @cell @   @endcell @endrow @row @cell @ Delay time between the event and an action @endcell @cell @     :   @endcell @cell colspan=2 @format "%d seconds" atoi(vector[5]) @endcell @endrow */ RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body("Retry times\n"); CellEnd(); CellBegin(""); Body("    :  \n"); CellEnd(); CellBegin("colspan=2"); FormatedBody("%d",atoi(vector[6])); CellEnd(); RowEnd(); } ssdbFreeRequest(error_handle,req_handle); TableEnd(); CellEnd(); RowEnd(); TableEnd(); Body("

\n"); } } void view_action_list(sscErrorHandle hError, mySession *session,ssdb_Connection_Handle connection, ssdb_Error_Handle error_handle,CMDPAIR *cmdp) { ssdb_Request_Handle req_handle; int key,number_of_records,rec_sequence,common_int,row_num,balance_rows,total_pages,pageno,firstpage,lastpage,bottom; const char **vector; char sys_id[32],common_string[2]; if(!get_variable(hError,cmdp,CHARTYPE,"sys_id",sys_id,&common_int,123)) return; if(!get_variable(hError,cmdp,INTTYPE,"row_num",common_string,&row_num,124)) return; if (!(req_handle = ssdbSendRequest(error_handle,connection,SSDB_REQTYPE_SELECT, "select action_desc,action from event_action where private=0 and sys_id = '%s'",sys_id))) { sscError(hError,"Database API Error: \"%s\"\n\n",ssdbGetLastErrorString(error_handle)); return; } if ((number_of_records = getnumrecords(hError,error_handle,req_handle)) == 0) { Body("There are no actions in the database.\n"); ssdbFreeRequest(error_handle,req_handle); return ; } else { TableBegin("BORDER=0 CELLSPACING = 0 CELLPADDING=0"); RowBegin(""); CellBegin("align=right"); total_pages = number_of_records/10; if (number_of_records%10) total_pages++; pageno = row_num/10; pageno++; FormatedBody("Page %d of %d",pageno,total_pages); CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); TableBegin("BORDER=4 CELLSPACING = 1 CELLPADDING=6"); RowBegin("ALIGN=CENTER"); CellBegin("align=right"); Body("No.\n"); CellEnd(); CellBegin(""); Body("Action Description\n"); CellEnd(); CellBegin(""); Body("Action Command String\n"); CellEnd(); RowEnd(); balance_rows = row_num + 10; if (balance_rows > number_of_records) balance_rows = number_of_records; ssdbRequestSeek(error_handle,req_handle,row_num,0); for (rec_sequence = row_num; rec_sequence < balance_rows; rec_sequence++) { RowBegin("valign=top"); vector = ssdbGetRow(error_handle,req_handle); if(vector) { CellBegin(""); FormatedBody("%d",rec_sequence+1); CellEnd(); CellBegin(""); FormatedBody("%s",vector[0]); CellEnd(); CellBegin(""); FormatedBody("%s",vector[1]); CellEnd(); } RowEnd(); } ssdbFreeRequest(error_handle,req_handle); TableEnd();; } CellEnd(); RowEnd(); RowBegin(""); CellBegin(""); Body(" \n"); CellEnd(); RowEnd(); if(total_pages > 1) { RowBegin(""); CellBegin("align=center"); firstpage = ((pageno-1)/10)*10+1; lastpage = firstpage+9; if (lastpage >= total_pages) lastpage = total_pages; if (firstpage > 1) { FormatedBody("\"first   ",0,sys_id); FormatedBody("\"previous   ",(firstpage-11)*10,sys_id); } for (rec_sequence = firstpage; rec_sequence <= lastpage; rec_sequence++) { if (rec_sequence == pageno) FormatedBody("%d  ",rec_sequence); else FormatedBody("%d   ",10*(rec_sequence-1),sys_id,rec_sequence); } if (lastpage < total_pages) { if(number_of_records%10 == 0) bottom = number_of_records -10; else bottom = number_of_records - (number_of_records%10); FormatedBody("\"next   ",(firstpage+9)*10,sys_id); FormatedBody("\"last   ",bottom,sys_id); } CellEnd(); RowEnd(); } TableEnd(); }