From: Florian G. <re...@us...> - 2007-12-15 23:30:54
|
Update of /cvsroot/perfparse/_perfparse/libpp_mysql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9112/libpp_mysql Modified Files: dbms.c del_policy.c del_policy.h Log Message: advanced logging macros - is it a problem to use C99 Style macros? Index: dbms.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_mysql/dbms.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** dbms.c 10 Dec 2007 18:55:09 -0000 1.9 --- dbms.c 15 Dec 2007 23:30:56 -0000 1.10 *************** *** 87,90 **** --- 87,91 ---- double dData(int iCol) { + pp_log_func; if (result_row[iCol] && result_row[iCol][0]) return atof(result_row[iCol]); *************** *** 104,108 **** void libpp_mysql_query(char*file, int line, const char *sql) { ! pp_log(__FILE__,__LINE__,LOG_DEBUG_SQL,"SQL execution: \"%s\"\n", sql); freeResult(); --- 105,109 ---- void libpp_mysql_query(char*file, int line, const char *sql) { ! pp_log_func; pp_log(__FILE__,__LINE__,LOG_DEBUG_SQL,"SQL execution: \"%s\"\n", sql); freeResult(); *************** *** 123,126 **** --- 124,128 ---- int libpp_mysql_query_int(char*file, int line, const char *sql) { + pp_log_func; int iRet; MYSQL_ROW row; *************** *** 149,152 **** --- 151,155 ---- const char *libpp_mysql_query_char(char*file, int line, const char *sql) { + pp_log_func; static char *sRet = NULL; MYSQL_RES *result; *************** *** 178,181 **** --- 181,185 ---- void libpp_mysql_query_no_return(char*file, int line, const char *sql) { + pp_log_func; MYSQL_RES *discaud; *************** *** 204,207 **** --- 208,212 ---- void freeResult(void) { + pp_log_func; if (query_result) { mysql_free_result(query_result); *************** *** 214,217 **** --- 219,223 ---- int rows(void) { + pp_log_func; if (query_result) return mysql_num_rows(query_result); *************** *** 222,225 **** --- 228,232 ---- int now_connect(int bTerminate) { + pp_log_func; if(NULL == sql_failure) sql_failure = pp_mysql_default_sql_failure; if (!mysql_init (&db_mysql)) { *************** *** 265,268 **** --- 272,276 ---- char* getRegistry(const char*host, const char*key, time_t *tm) { + pp_log_func; char *value=NULL; g_string_printf(s_SQL, "SELECT rvalue,ctime from perfdata_registry WHERE host = '%s' ", sql_escape(host,PERCENT_ESCAPE_CHAR)); Index: del_policy.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_mysql/del_policy.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** del_policy.c 13 Dec 2007 22:25:18 -0000 1.6 --- del_policy.c 15 Dec 2007 23:30:56 -0000 1.7 *************** *** 55,59 **** int isPolicyDefined(char *sPolicyName) { ! g_string_printf(s_SQL, "SELECT COUNT(*) FROM perfdata_delete_policy WHERE policy_name = '%s'", --- 55,59 ---- int isPolicyDefined(char *sPolicyName) { ! pp_log_func; g_string_printf(s_SQL, "SELECT COUNT(*) FROM perfdata_delete_policy WHERE policy_name = '%s'", *************** *** 67,71 **** int getPolicy(char *sPolicyName) { ! g_string_printf(s_SQL, "SELECT delete_policy FROM perfdata_delete_policy WHERE policy_name = '%s'", --- 67,71 ---- int getPolicy(char *sPolicyName) { ! pp_log_func; g_string_printf(s_SQL, "SELECT delete_policy FROM perfdata_delete_policy WHERE policy_name = '%s'", *************** *** 86,89 **** --- 86,90 ---- char *pval2sql(int iPolicy) { + pp_log_func; static char sPolicy[10]; *************** *** 98,101 **** --- 99,103 ---- int sql2pval(const char *sPolicy) { + pp_log_func; if (!sPolicy || !strcmp(sPolicy, "NULL") || sPolicy[0] == 0) return -1; *************** *** 107,110 **** --- 109,113 ---- char *ptype2sql(int iType) { + pp_log_func; switch (iType) { case DP_USER: return "'user'"; *************** *** 121,124 **** --- 124,128 ---- int sql2ptype(const char *sIn) { + pp_log_func; if (!strcmp(sIn, "user")) return DP_USER; if (!strcmp(sIn, "host")) return DP_HOST; *************** *** 133,136 **** --- 137,141 ---- void validateDefaultDP() { + pp_log_func; /* Ensure the default policies exist. */ *************** *** 143,153 **** for (s = sDefaultDP[0]; sDefaultDP[i][0]; s = sDefaultDP[++i]) { ! g_string_printf(s_SQL, "SELECT count(*) FROM perfdata_delete_policy WHERE policy_name = '%s'", ! sql_escape(gettext(s),PERCENT_ESCAPE_CHAR)); if (!query_int(s_SQL->str)) { ! g_string_printf(s_SQL, "INSERT perfdata_delete_policy (policy_name, delete_policy) VALUES ('%s',%d)", ! sql_escape(gettext(s),PERCENT_ESCAPE_CHAR), DEFAULT_DELETE_POLICY_DAYS); query_no_return(s_SQL->str); --- 148,158 ---- for (s = sDefaultDP[0]; sDefaultDP[i][0]; s = sDefaultDP[++i]) { ! g_string_printf(s_SQL, "SELECT count(*) FROM perfdata_delete_policy WHERE policy_id = %d", ! i); if (!query_int(s_SQL->str)) { ! g_string_printf(s_SQL, "INSERT INTO perfdata_delete_policy (policy_name, delete_policy_seconds) VALUES ('%s',%d)", ! sql_escape(gettext(s),PERCENT_ESCAPE_CHAR), DEL_POLICY_UNDEFINED); query_no_return(s_SQL->str); *************** *** 162,165 **** --- 167,171 ---- int isDefaultDP(char *sPolicy) { + pp_log_func; /* Is this a dafault policy */ *************** *** 177,184 **** int getDefaultPolicy(int i) { ! g_string_printf(s_SQL, "SELECT delete_policy FROM perfdata_delete_policy WHERE policy_name = '%s'", ! sql_escape(gettext(sDefaultDP[i]),PERCENT_ESCAPE_CHAR)); ! return sql2pval(query_char(s_SQL->str)); } --- 183,192 ---- int getDefaultPolicy(int i) { ! pp_log_func; ! g_string_printf(s_SQL, "SELECT delete_policy FROM perfdata_delete_policy WHERE policy_id = %d", ! i); ! //return sql2pval(query_char(s_SQL->str)); ! return(query_int(s_SQL->str)); } *************** *** 186,199 **** int getDefaultBinPolicy() { ! return getDefaultPolicy(0); } int getDefaultRawPolicy() { ! return getDefaultPolicy(1); } char *getPolicyDesc(int iPolicy) { static char s[20]; --- 194,210 ---- int getDefaultBinPolicy() { ! pp_log_func; ! return getDefaultPolicy(DEFAULT_BIN_POLICY_ID); } int getDefaultRawPolicy() { ! pp_log_func; ! return getDefaultPolicy(DEFAULT_RAW_POLICY_ID); } char *getPolicyDesc(int iPolicy) { + pp_log_func; static char s[20]; *************** *** 218,223 **** void getRawHostPolicy(t_raw_policyinfo *policyinfo) { ! pp_log(__FILE__,__LINE__,LOG_DEBUG_FUNCTION,_("getRawHostPolicy() called")); ! g_string_printf(s_SQL, "SELECT raw_delete_policy_individual,policy_name,delete_policy_seconds FROM perfdata_host h left join perfdata_delete_policy p on h.raw_delete_policy_id=p.policy_id WHERE host_id = '%d'", policyinfo->iHostId); --- 229,234 ---- void getRawHostPolicy(t_raw_policyinfo *policyinfo) { ! pp_log_func; ! g_string_printf(s_SQL, "SELECT raw_delete_policy_individual,policy_name,delete_policy_seconds FROM perfdata_host h left join perfdata_delete_policy p on h.raw_delete_policy_id=p.policy_id WHERE host_id = '%d'", policyinfo->iHostId); *************** *** 240,245 **** void getRawGroupPolicy(t_raw_policyinfo *policyinfo) { ! pp_log(__FILE__,__LINE__,LOG_DEBUG_FUNCTION,_("getRawGroupPolicy() called")); ! g_string_printf(s_SQL,"SELECT g.raw_delete_policy_individual,policy_name,delete_policy_seconds FROM perfdata_host_groups hg, perfdata_groups g left join perfdata_delete_policy p on g.raw_delete_policy_id=p.policy_id WHERE g.group_id=hg.group_id AND hg.host_id = '%d'", policyinfo->iHostId); --- 251,256 ---- void getRawGroupPolicy(t_raw_policyinfo *policyinfo) { ! pp_log_func; ! g_string_printf(s_SQL,"SELECT g.raw_delete_policy_individual,policy_name,delete_policy_seconds FROM perfdata_host_groups hg, perfdata_groups g left join perfdata_delete_policy p on g.raw_delete_policy_id=p.policy_id WHERE g.group_id=hg.group_id AND hg.host_id = '%d'", policyinfo->iHostId); *************** *** 277,280 **** --- 288,292 ---- int getBinHostPolicy(char *sHost) { + pp_log_func; g_string_printf(s_SQL, "SELECT bin_delete_policy FROM perfdata_host WHERE host_name = '%s'", sql_escape(sHost,PERCENT_ESCAPE_CHAR)); *************** *** 286,289 **** --- 298,302 ---- TPolicyList *getPolicyList() { + pp_log_func; static TPolicyList *first = NULL; TPolicyList *p, *prev; *************** *** 319,322 **** --- 332,336 ---- void destroyPolicyList(TPolicyList *first) { + pp_log_func; /* [TODO] */ } Index: del_policy.h =================================================================== RCS file: /cvsroot/perfparse/_perfparse/libpp_mysql/del_policy.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** del_policy.h 13 Dec 2007 22:25:18 -0000 1.4 --- del_policy.h 15 Dec 2007 23:30:56 -0000 1.5 *************** *** 12,15 **** --- 12,18 ---- #define DEL_POLICY_INFINITY -2 + #define DEFAULT_RAW_POLICY_ID 1 + #define DEFAULT_BIN_POLICY_ID 0 + enum { DEL_POLICY_SOURCE_NONE, *************** *** 53,56 **** --- 56,61 ---- char *getPolicyDesc(int iPolicy); void getRawHostPolicy(t_raw_policyinfo *policyinfo); + void getRawGroupPolicy(t_raw_policyinfo *policyinfo); + int getBinHostPolicy(char *sHost); |