/[mailutils]/mailutils/auth/pgsql.c
ViewVC logotype

Diff of /mailutils/auth/pgsql.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by gray, Wed Apr 23 11:44:13 2003 UTC revision 1.2 by gray, Sat Jul 26 11:06:13 2003 UTC
# Line 22  Line 22 
22  #ifdef HAVE_PGSQL  #ifdef HAVE_PGSQL
23  #include <sql.h>  #include <sql.h>
24  #include <libpq-fe.h>  #include <libpq-fe.h>
25    #include <ctype.h>
26    
27  static PGconn *  static PGconn *
28  pg_connect ()  pg_connect ()
# Line 81  pg_auth_common (PGresult *res, char *que Line 82  pg_auth_common (PGresult *res, char *que
82    
83    ntuples = PQntuples (res);    ntuples = PQntuples (res);
84    nfields = PQnfields (res);    nfields = PQnfields (res);
85    if (ntuples > 1 && nfields)    if ((ntuples > 1 && nfields) || ntuples == 0)
86      {      {
87        mu_error (ngettext("query returned %d tuple: %s",        mu_error (ngettext("query returned %d tuple: %s",
88                           "query returned %d tuples: %s",                           "query returned %d tuples: %s",
89                           ntuples),                           ntuples),
90                  ntuples, query_str);                  ntuples, query_str);
91          if (ntuples == 0)
92            return 1;
93      }      }
94        
95    if (nfields < 6)    if (nfields < 6)
# Line 105  pg_auth_common (PGresult *res, char *que Line 108  pg_auth_common (PGresult *res, char *que
108    homedir = chop (PQgetvalue (res, 0, 4));    homedir = chop (PQgetvalue (res, 0, 4));
109    shell = chop (PQgetvalue (res, 0, 5));    shell = chop (PQgetvalue (res, 0, 5));
110        
111    if (ntuples == 7)    if (nfields == 7)
112      {      {
113        mailbox_name = strdup (chop (PQgetvalue (res, 0, 6)));        mailbox_name = strdup (chop (PQgetvalue (res, 0, 6)));
114      }      }
# Line 133  pg_auth_common (PGresult *res, char *que Line 136  pg_auth_common (PGresult *res, char *que
136  }  }
137    
138  int  int
139  pg_auth_sql_by_name (void *return_data, void *key,  pg_auth_sql_by_name (struct mu_auth_data **return_data, void *key,
140                       void *func_data ARG_UNUSED,                       void *func_data ARG_UNUSED,
141                       void *call_data ARG_UNUSED)                       void *call_data ARG_UNUSED)
142  {  {
# Line 171  pg_auth_sql_by_name (void *return_data, Line 174  pg_auth_sql_by_name (void *return_data,
174      }      }
175    else    else
176      {      {
177        rc = pg_auth_common (res, query_str,        rc = pg_auth_common (res, query_str, return_data);
                            (struct mu_auth_data **)return_data);  
178        PQclear(res);        PQclear(res);
179      }      }
180    
# Line 183  pg_auth_sql_by_name (void *return_data, Line 185  pg_auth_sql_by_name (void *return_data,
185  }  }
186    
187  int  int
188  pg_auth_sql_by_uid (void *return_data, void *key,  pg_auth_sql_by_uid (struct mu_auth_data **return_data, void *key,
189                      void *func_data ARG_UNUSED,                      void *func_data ARG_UNUSED,
190                      void *call_data ARG_UNUSED)                      void *call_data ARG_UNUSED)
191  {  {
# Line 222  pg_auth_sql_by_uid (void *return_data, v Line 224  pg_auth_sql_by_uid (void *return_data, v
224      }      }
225    else    else
226      {      {
227        rc = pg_auth_common (res, query_str,        rc = pg_auth_common (res, query_str, return_data);
                            (struct mu_auth_data **)return_data);  
228        PQclear(res);        PQclear(res);
229      }      }
230    
# Line 234  pg_auth_sql_by_uid (void *return_data, v Line 235  pg_auth_sql_by_uid (void *return_data, v
235  }  }
236    
237  int  int
238  pg_sql_authenticate (void *return_data ARG_UNUSED, void *key,  pg_sql_authenticate (struct mu_auth_data **return_data ARG_UNUSED, void *key,
239                       void *func_data ARG_UNUSED, void *call_data)                       void *func_data ARG_UNUSED, void *call_data)
240  {  {
241    PGconn *conn;    PGconn *conn;
# Line 278  pg_sql_authenticate (void *return_data A Line 279  pg_sql_authenticate (void *return_data A
279            char *p;            char *p;
280            int ntuples = PQntuples (res);            int ntuples = PQntuples (res);
281            int nfields = PQnfields (res);            int nfields = PQnfields (res);
282            if (ntuples > 1 && nfields)            if ((ntuples > 1 && nfields) || ntuples == 0)
283              {              {
284                mu_error (ngettext("query returned %d tuple: %s",                mu_error (ngettext("query returned %d tuple: %s",
285                                   "query returned %d tuples: %s",                                   "query returned %d tuples: %s",
286                                   ntuples),                                   ntuples),
287                          ntuples, query_str);                          ntuples, query_str);
288                  if (ntuples == 0)
289                    return 1;
290              }              }
291                        
292            if (nfields > 1)            if (nfields > 1)

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26