]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_pgsql.cpp
Add extra parameter to OnUserPreNotice and OnUserPrePrivmsg, CUList &exempt_list...
[user/henk/code/inspircd.git] / src / modules / extra / m_pgsql.cpp
index 1790fdfef228e14ae11e21c6cc62cd5f58743317..ca74f4223cd8ca225fed2a5b5e67db0f9ef1b263 100644 (file)
@@ -69,13 +69,13 @@ enum SQLstatus { CREAD, CWRITE, WREAD, WWRITE, RREAD, RWRITE };
 class SQLhost
 {
  public:
-       std::string             id;             /* Database handle id */
-       std::string     host;   /* Database server hostname */
+       std::string     id;     /* Database handle id */
+       std::string     host;   /* Database server hostname */
        unsigned int    port;   /* Database server port */
-       std::string     name;   /* Database name */
-       std::string     user;   /* Database username */
-       std::string     pass;   /* Database password */
-       bool                    ssl;    /* If we should require SSL */
+       std::string     name;   /* Database name */
+       std::string     user;   /* Database username */
+       std::string     pass;   /* Database password */
+       bool            ssl;    /* If we should require SSL */
  
        SQLhost()
        {
@@ -87,6 +87,8 @@ class SQLhost
        }
 };
 
+/** Used to resolve sql server hostnames
+ */
 class SQLresolver : public Resolver
 {
  private:
@@ -94,7 +96,7 @@ class SQLresolver : public Resolver
        ModulePgSQL* mod;
  public:
        SQLresolver(ModulePgSQL* m, InspIRCd* Instance, const SQLhost& hi)
-       : Resolver(Instance, hi.host, DNS_QUERY_FORWARD), host(hi), mod(m)
+       : Resolver(Instance, hi.host, DNS_QUERY_FORWARD, (Module*)m), host(hi), mod(m)
        {
        }
 
@@ -523,7 +525,7 @@ public:
                
                sqlsuccess = new char[strlen(SQLSUCCESS)+1];
                
-               strcpy(sqlsuccess, SQLSUCCESS);
+               strlcpy(sqlsuccess, SQLSUCCESS, strlen(SQLSUCCESS)+1);
 
                OnRehash("");
        }
@@ -657,7 +659,7 @@ public:
                
        virtual Version GetVersion()
        {
-               return Version(1, 0, 0, 0, VF_VENDOR|VF_SERVICEPROVIDER);
+               return Version(1, 1, 0, 0, VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
        }
        
        virtual ~ModulePgSQL()
@@ -847,6 +849,9 @@ bool SQLConn::DoConnectedPoll()
                        {
                                /* ..and the result */
                                PgSQLresult reply(us, to, query.id, result);
+
+                               /* Fix by brain, make sure the original query gets sent back in the reply */
+                               reply.query = query.query.q;
                                
                                Instance->Log(DEBUG, "Got result, status code: %s; error message: %s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result));      
                                
@@ -1123,8 +1128,7 @@ SQLerror SQLConn::DoQuery(SQLrequest &req)
 #ifdef PGSQL_HAS_ESCAPECONN
                                                len = PQescapeStringConn(sql, queryend, req.query.p.front().c_str(), req.query.p.front().length(), &error);
 #else
-                                               len = PQescapeStringConn(queryend, req.query.p.front().c_str(), req.query.p.front().length());
-                                               error = 0;
+                                               len = PQescapeString         (queryend, req.query.p.front().c_str(), req.query.p.front().length());
 #endif
                                                if(error)
                                                {
@@ -1163,13 +1167,13 @@ SQLerror SQLConn::DoQuery(SQLrequest &req)
                        {
                                Instance->Log(DEBUG, "Dispatched query successfully");
                                qinprog = true;
-                               DELETE(query);
+                               delete[] query;
                                return SQLerror();
                        }
                        else
                        {
                                Instance->Log(DEBUG, "Failed to dispatch query: %s", PQerrorMessage(sql));
-                               DELETE(query);
+                               delete[] query;
                                return SQLerror(QSEND_FAIL, PQerrorMessage(sql));
                        }
                }