summaryrefslogtreecommitdiff
path: root/mail-filter/gps/files/gps-numeric.diff
blob: 17de74da4a376659d3790c064c95b486c60b1bbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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 @@
 
 
 
+