Commit da186818 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed compilation warning in sev_dbms.

parent c9ee7d02
...@@ -2020,11 +2020,11 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid, ...@@ -2020,11 +2020,11 @@ int sev_dbms::get_values(pwr_tStatus* sts, void* thread, pwr_tOid oid,
thread, item.tablename, item.options, starttime, 1, &startid); thread, item.tablename, item.options, starttime, 1, &startid);
if (*sts == SEV__NOROWS) if (*sts == SEV__NOROWS)
get_id_range(sts, thread, &item, item.options, &startid, 0); get_id_range(sts, thread, &item, item.options, &startid, 0);
get_id_value(thread, item.tablename, startid, type, size, get_id_value(thread, item.tablename, startid, type, size,
startval); startval);
startvalue = startval; startvalue = startval;
} else { } else {
// Get id for starttime // Get id for starttime
*sts = get_closest_time( *sts = get_closest_time(
thread, item.tablename, item.options, starttime, 1, &startid); thread, item.tablename, item.options, starttime, 1, &startid);
...@@ -4043,7 +4043,7 @@ int sev_dbms::get_closest_time(void* thread, char* tablename, ...@@ -4043,7 +4043,7 @@ int sev_dbms::get_closest_time(void* thread, char* tablename,
} }
int sev_dbms::get_id_value(void* thread, char* tablename, int sev_dbms::get_id_value(void* thread, char* tablename,
unsigned int id, pwr_eType type, int size, unsigned int id, pwr_eType type, int size,
void *value) void *value)
{ {
char query[200]; char query[200];
...@@ -4717,9 +4717,9 @@ int sev_dbms::handle_objectchange( ...@@ -4717,9 +4717,9 @@ int sev_dbms::handle_objectchange(
} }
int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid, int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid,
pwr_tMask options, pwr_tMask eventtypemask, pwr_tMask options, pwr_tMask eventtypemask,
pwr_tMask eventpriomask, char *eventtext, char *eventname, pwr_tMask eventpriomask, char *eventtext, char *eventname,
pwr_tTime *starttime, pwr_tTime *endtime, unsigned int numevents, pwr_tTime *starttime, pwr_tTime *endtime, unsigned int numevents,
std::vector<sev_event> &list) std::vector<sev_event> &list)
{ {
sev_item item; sev_item item;
...@@ -4728,7 +4728,7 @@ int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid, ...@@ -4728,7 +4728,7 @@ int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid,
return 0; return 0;
} }
char query[700]; char query[1300];
char starttimstr[40]; char starttimstr[40];
char endtimstr[40]; char endtimstr[40];
pwr_tTime stime, etime; pwr_tTime stime, etime;
...@@ -4839,140 +4839,140 @@ int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid, ...@@ -4839,140 +4839,140 @@ int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid,
if (eventtypemask) { if (eventtypemask) {
bool first = true; bool first = true;
sprintf(&where_part[strlen(where_part)], " and ("); sprintf(&where_part[strlen(where_part)], " and (");
if (eventtypemask & sev_mEventType_Ack) { if (eventtypemask & sev_mEventType_Ack) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Ack); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Ack);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Block) { if (eventtypemask & sev_mEventType_Block) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Block); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Block);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Cancel) { if (eventtypemask & sev_mEventType_Cancel) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Cancel); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Cancel);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_CancelBlock) { if (eventtypemask & sev_mEventType_CancelBlock) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_CancelBlock); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_CancelBlock);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Missing) { if (eventtypemask & sev_mEventType_Missing) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Missing); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Missing);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Reblock) { if (eventtypemask & sev_mEventType_Reblock) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Reblock); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Reblock);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Return) { if (eventtypemask & sev_mEventType_Return) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Return); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Return);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Unblock) { if (eventtypemask & sev_mEventType_Unblock) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Unblock); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Unblock);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_InfoSuccess) { if (eventtypemask & sev_mEventType_InfoSuccess) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_InfoSuccess); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_InfoSuccess);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Alarm) { if (eventtypemask & sev_mEventType_Alarm) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Alarm); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Alarm);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_MaintenanceAlarm) { if (eventtypemask & sev_mEventType_MaintenanceAlarm) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_MaintenanceAlarm); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_MaintenanceAlarm);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_SystemAlarm) { if (eventtypemask & sev_mEventType_SystemAlarm) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_SystemAlarm); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_SystemAlarm);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_UserAlarm1) { if (eventtypemask & sev_mEventType_UserAlarm1) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm1); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm1);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_UserAlarm2) { if (eventtypemask & sev_mEventType_UserAlarm2) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm2); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm2);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_UserAlarm3) { if (eventtypemask & sev_mEventType_UserAlarm3) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm3); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm3);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_UserAlarm4) { if (eventtypemask & sev_mEventType_UserAlarm4) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm4); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_UserAlarm4);
first = false; first = false;
} }
if (eventtypemask & sev_mEventType_Info) { if (eventtypemask & sev_mEventType_Info) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Info); sprintf(&where_part[strlen(where_part)], "eventtype = %d", mh_eEvent_Info);
first = false; first = false;
} }
sprintf(&where_part[strlen(where_part)], ")"); sprintf(&where_part[strlen(where_part)], ")");
} }
if (eventpriomask) { if (eventpriomask) {
bool first = true; bool first = true;
sprintf(&where_part[strlen(where_part)], " and ("); sprintf(&where_part[strlen(where_part)], " and (");
if (eventpriomask & sev_mEventPrio_A) { if (eventpriomask & sev_mEventPrio_A) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_A); sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_A);
first = false; first = false;
} }
if (eventpriomask & sev_mEventPrio_B) { if (eventpriomask & sev_mEventPrio_B) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_B); sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_B);
first = false; first = false;
} }
if (eventpriomask & sev_mEventPrio_C) { if (eventpriomask & sev_mEventPrio_C) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_C); sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_C);
first = false; first = false;
} }
if (eventpriomask & sev_mEventPrio_D) { if (eventpriomask & sev_mEventPrio_D) {
if (!first) if (!first)
sprintf(&where_part[strlen(where_part)], " or "); sprintf(&where_part[strlen(where_part)], " or ");
sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_C); sprintf(&where_part[strlen(where_part)], "eventprio = %d", mh_eEventPrio_C);
first = false; first = false;
} }
sprintf(&where_part[strlen(where_part)], ")"); sprintf(&where_part[strlen(where_part)], ")");
} }
if (!streq(eventtext, "")) if (!streq(eventtext, ""))
...@@ -5045,7 +5045,7 @@ int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid, ...@@ -5045,7 +5045,7 @@ int sev_dbms::get_events(pwr_tStatus *sts, void *thread, pwr_tOid oid,
strncpy(e.eventname, row[j++], sizeof(e.eventname)); strncpy(e.eventname, row[j++], sizeof(e.eventname));
list.push_back(e); list.push_back(e);
} }
printf("ecnt %d\n", list.size()); printf("ecnt %ld\n", list.size());
mysql_free_result(result); mysql_free_result(result);
*sts = SEV__SUCCESS; *sts = SEV__SUCCESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment