summaryrefslogtreecommitdiff
path: root/mail-filter/gps/files/gps-numeric.diff
diff options
context:
space:
mode:
Diffstat (limited to 'mail-filter/gps/files/gps-numeric.diff')
-rw-r--r--mail-filter/gps/files/gps-numeric.diff55
1 files changed, 55 insertions, 0 deletions
diff --git a/mail-filter/gps/files/gps-numeric.diff b/mail-filter/gps/files/gps-numeric.diff
new file mode 100644
index 0000000..17de74d
--- /dev/null
+++ b/mail-filter/gps/files/gps-numeric.diff
@@ -0,0 +1,55 @@
+--- src/db.cpp 2005-03-02 22:12:17.000000000 +0100
++++ src/db.cpp 2006-11-21 19:03:17.000000000 +0100
+@@ -71,17 +71,37 @@
+ if(itr != params.end()) {
+ if((*itr).length() < (tempCharBuf-1) ) {
+ const char *value = (*itr).c_str();
+- char szBuf[tempCharBuf];
+- strcpy(szBuf,value);
+- if(verbose) {
+- if(string(key) == "password")
+- syslog(LOG_DEBUG,"setting DB option: %s to: (hidden)",key);
+- else
+- syslog(LOG_DEBUG,"setting DB option: %s to: %s",key,szBuf);
+-
++ // check if it is numeric
++ bool bNonDigit = false;
++ for( size_t i = 0; i < (*itr).size(); ++i )
++ {
++ if( !isdigit( value[i] ) ) {
++ bNonDigit = true;
++ break;
++ }
++ }
++ if(bNonDigit || (string(key) == "password") ) { // string value
++ char szBuf[tempCharBuf];
++ strcpy(szBuf,value);
++ if(verbose) {
++ if(string(key) == "password")
++ syslog(LOG_DEBUG,"setting DB option: %s to: (hidden)",key);
++ else
++ syslog(LOG_DEBUG,"setting DB option: %s to: %s",key,szBuf);
++
++ }
++ if(dbi_conn_set_option(_con, key, szBuf) != 0)
++ throw runtime_error( getConError("dbi_conn_set_option "+(*itr)) );
++ } else { // numeric value
++ int iVal = -1;
++ stringstream stm;
++ stm << (*itr);
++ stm >> iVal;
++ if(verbose)
++ syslog(LOG_DEBUG,"setting DB option: %s to: %d",key,iVal);
++ if(dbi_conn_set_option_numeric(_con, key, iVal) != 0)
++ throw runtime_error( getConError("dbi_conn_set_option "+(*itr)) );
+ }
+- if(dbi_conn_set_option(_con, key, szBuf) != 0)
+- throw runtime_error( getConError("dbi_conn_set_option "+(*itr)) );
+ }
+ }
+ }
+@@ -422,3 +442,4 @@
+
+
+
++