[CVS] RPM: rpm-5_4: rpm/rpmio/ librpmio.vers poptIO.c rpmio.c rpmodbc....

2012-03-18 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   18-Mar-2012 15:02:14
  Branch: rpm-5_4  Handle: 2012031814021400

  Modified files:   (Branch: rpm-5_4)
rpm/rpmio   librpmio.vers poptIO.c rpmio.c rpmodbc.c rpmodbc.h
todbc.c

  Log:
- odbc: shorter names please.

  Summary:
RevisionChanges Path
2.199.2.8   +11 -11 rpm/rpmio/librpmio.vers
1.94.2.3+1  -1  rpm/rpmio/poptIO.c
1.230.2.5   +2  -2  rpm/rpmio/rpmio.c
1.1.2.3 +28 -28 rpm/rpmio/rpmodbc.c
1.1.2.3 +24 -24 rpm/rpmio/rpmodbc.h
1.1.2.2 +98 -13 rpm/rpmio/todbc.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmio/librpmio.vers
  
  $ cvs diff -u -r2.199.2.7 -r2.199.2.8 librpmio.vers
  --- rpm/rpmio/librpmio.vers   17 Mar 2012 19:25:03 -  2.199.2.7
  +++ rpm/rpmio/librpmio.vers   18 Mar 2012 14:02:14 -  2.199.2.8
  @@ -211,6 +211,17 @@
   _Mknod;
   Mount;
   noLibio;
  +_odbc_debug;
  +odbcColumns;
  +odbcConnect;
  +odbcDisconnect;
  +odbcFetch;
  +odbcListDataSources;
  +odbcListDrivers;
  +odbcNCols;
  +odbcNew;
  +odbcPrepare;
  +odbcTables;
   Open;
   _Open;
   Opendir;
  @@ -553,17 +564,6 @@
   rpmnixNew;
   _rpmnss_init;
   rpmnssImplVecs;
  -_rpmodbc_debug;
  -rpmodbcColumns;
  -rpmodbcConnect;
  -rpmodbcDisconnect;
  -rpmodbcFetch;
  -rpmodbcListDataSources;
  -rpmodbcListDrivers;
  -rpmodbcNCols;
  -rpmodbcNew;
  -rpmodbcPrepare;
  -rpmodbcTables;
   _rpmperl_debug;
   rpmperlNew;
   rpmperlRun;
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmio/poptIO.c
  
  $ cvs diff -u -r1.94.2.2 -r1.94.2.3 poptIO.c
  --- rpm/rpmio/poptIO.c17 Mar 2012 15:53:15 -  1.94.2.2
  +++ rpm/rpmio/poptIO.c18 Mar 2012 14:02:14 -  1.94.2.3
  @@ -664,7 +664,7 @@
N_(Debug Mongo DB connection), NULL},
{ nixdebug, '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, _rpmnix_debug, 
-1,
N_(Debug embedded Nix interpreter), NULL},
  - { rpmodbcdebug, '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, 
_rpmodbc_debug, -1,
  + { odbcdebug, '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, _odbc_debug, -1,
N_(Debug embedded ODBC interface), NULL},
{ rpmperldebug, '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, 
_rpmperl_debug, -1,
N_(Debug embedded Perl interpreter), NULL},
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmio/rpmio.c
  
  $ cvs diff -u -r1.230.2.4 -r1.230.2.5 rpmio.c
  --- rpm/rpmio/rpmio.c 17 Mar 2012 15:53:15 -  1.230.2.4
  +++ rpm/rpmio/rpmio.c 18 Mar 2012 14:02:14 -  1.230.2.5
  @@ -3246,7 +3246,7 @@
   #ifdef   NOTYET
   extern rpmioPool _rpmnixPool;
   #endif
  -extern rpmioPool _rpmodbcPool;
  +extern rpmioPool _odbcPool;
   extern rpmioPool _rpmperlPool;
   extern rpmioPool _rpmpythonPool;
   extern rpmioPool _rpmrubyPool;
  @@ -3295,7 +3295,7 @@
   _rpmbagPool = rpmioFreePool(_rpmbagPool);
   _rpmcvsPool = rpmioFreePool(_rpmcvsPool);
   _rpmgitPool = rpmioFreePool(_rpmgitPool);
  -_rpmodbcPool = rpmioFreePool(_rpmodbcPool);
  +_odbcPool = rpmioFreePool(_odbcPool);
   _rpmsvnPool = rpmioFreePool(_rpmsvnPool);
   _rpmtpmPool = rpmioFreePool(_rpmtpmPool);
   
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmio/rpmodbc.c
  
  $ cvs diff -u -r1.1.2.2 -r1.1.2.3 rpmodbc.c
  --- rpm/rpmio/rpmodbc.c   17 Mar 2012 19:25:03 -  1.1.2.2
  +++ rpm/rpmio/rpmodbc.c   18 Mar 2012 14:02:14 -  1.1.2.3
  @@ -19,17 +19,17 @@
   #include debug.h
   
   /*@unchecked@*/
  -int _rpmodbc_debug = -1;
  +int _odbc_debug = -1;
   
   #define  SPEW(_t, _rc, _odbc)\
  -  { if ((_t) || _rpmodbc_debug ) \
  +  { if ((_t) || _odbc_debug ) \
fprintf(stderr, -- %s(%p) rc %d\n, __FUNCTION__, (_odbc), \
(_rc)); \
 }
   
   /*==*/
   
  -int rpmodbcConnect(rpmodbc odbc,
  +int odbcConnect(ODBC_t odbc,
const char * db, const char * u, const char * pw)
   {
   int rc = -1;
  @@ -56,7 +56,7 @@
   return rc;
   }
   
  -int rpmodbcDisconnect(rpmodbc odbc)
  +int odbcDisconnect(ODBC_t odbc)
   {
   int rc = 0;
   
  @@ -72,7 

[CVS] RPM: rpm-5_4: rpm/rpmio/ rpmurl.h url.c

2012-03-18 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   18-Mar-2012 15:19:31
  Branch: rpm-5_4  Handle: 2012031814193100

  Modified files:   (Branch: rpm-5_4)
rpm/rpmio   rpmurl.h url.c

  Log:
- url: stub in some additional schemes for development use.

  Summary:
RevisionChanges Path
1.41.4.2+5  -0  rpm/rpmio/rpmurl.h
1.73.4.2+24 -0  rpm/rpmio/url.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmio/rpmurl.h
  
  $ cvs diff -u -r1.41.4.1 -r1.41.4.2 rpmurl.h
  --- rpm/rpmio/rpmurl.h1 Jan 2011 14:39:56 -   1.41.4.1
  +++ rpm/rpmio/rpmurl.h18 Mar 2012 14:19:31 -  1.41.4.2
  @@ -21,6 +21,11 @@
   URL_IS_HTTPS = 5,/*! https://... */
   URL_IS_HKP   = 6,/*! hkp://... */
   URL_IS_MONGO = 7,/*! mongo://... and mongodb://... */
  +#define  URL_IS_GIT  16
  +#define  URL_IS_SVN  17
  +#define  URL_IS_SQLITE   32
  +#define  URL_IS_MYSQL33
  +#define  URL_IS_POSTGRES 34
   } urltype;
   
   #define  URLMAGIC0xd00b1ed0U
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmio/url.c
  
  $ cvs diff -u -r1.73.4.1 -r1.73.4.2 url.c
  --- rpm/rpmio/url.c   1 Jan 2011 14:39:56 -   1.73.4.1
  +++ rpm/rpmio/url.c   18 Mar 2012 14:19:31 -  1.73.4.2
  @@ -34,6 +34,14 @@
   #define  IPPORT_MONGO27017
   #endif
   
  +#ifdef   NOTYET
  +#define URL_IS_GIT
  +#define URL_IS_SVN
  +#define URL_IS_SQLITE
  +#define URL_IS_MYSQL
  +#define URL_IS_POSTGRES
  +#endif
  +
   /**
*/
   /*@-redecl@*/
  @@ -378,6 +386,13 @@
   { https://;,sizeof(https://;)-1,   URL_IS_HTTPS },
   { mongo://,sizeof(mongo://)-1,   URL_IS_MONGO },
   { mongodb://,  sizeof(mongodb://)-1, URL_IS_MONGO },
  +
  +{ git://,  sizeof(git://)-1, URL_IS_GIT },
  +{ svn://,  sizeof(svn://)-1, URL_IS_SVN },
  +{ sqlite://,   sizeof(sqlite://)-1,  URL_IS_SQLITE },
  +{ mysql://,sizeof(mysql://)-1,   URL_IS_MYSQL },
  +{ postgres://, sizeof(postgres://)-1, URL_IS_POSTGRES },
  +
   { -,   sizeof(-)-1,  URL_IS_DASH },
   { NULL,  0,  URL_IS_UNKNOWN }
   };
  @@ -549,6 +564,15 @@
u-port = IPPORT_HTTPS;
else if (u-ut == URL_IS_MONGO)
u-port = IPPORT_MONGO;
  +
  +#ifdef   NOTYET
  +#define URL_IS_GIT
  +#define URL_IS_SVN
  +#define URL_IS_SQLITE
  +#define URL_IS_MYSQL
  +#define URL_IS_POSTGRES
  +#endif
  +
   }
   
   myurl = _free(myurl);
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm-5_4: rpm/rpmio/ tsvn.c

2012-03-18 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   18-Mar-2012 16:35:53
  Branch: rpm-5_4  Handle: 2012031815355300

  Modified files:   (Branch: rpm-5_4)
rpm/rpmio   tsvn.c

  Log:
- svn: typo.

  Summary:
RevisionChanges Path
1.1.2.2 +1  -1  rpm/rpmio/tsvn.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmio/tsvn.c
  
  $ cvs diff -u -r1.1.2.1 -r1.1.2.2 tsvn.c
  --- rpm/rpmio/tsvn.c  29 Feb 2012 04:22:27 -  1.1.2.1
  +++ rpm/rpmio/tsvn.c  18 Mar 2012 15:35:53 -  1.1.2.2
  @@ -7,7 +7,7 @@
   #include debug.h
   
   static struct poptOption rpmsvnOptionsTable[] = {
  - { debug, 'd', POPT_ARG_VAL,   _rpmmg_debug, -1,  NULL, 
NULL },
  + { debug, 'd', POPT_ARG_VAL,   _rpmsvn_debug, -1, NULL, 
NULL },
 POPT_AUTOHELP
 POPT_TABLEEND
   };
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm-5_4: rpm/rpmio/ rpmodbc.c rpmodbc.h todbc.c

2012-03-18 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   18-Mar-2012 16:47:06
  Branch: rpm-5_4  Handle: 2012031815470600

  Modified files:   (Branch: rpm-5_4)
rpm/rpmio   rpmodbc.c rpmodbc.h todbc.c

  Log:
- odbc: use a uri to carry around connect info.

  Summary:
RevisionChanges Path
1.1.2.4 +41 -13 rpm/rpmio/rpmodbc.c
1.1.2.4 +2  -4  rpm/rpmio/rpmodbc.h
1.1.2.3 +15 -9  rpm/rpmio/todbc.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmio/rpmodbc.c
  
  $ cvs diff -u -r1.1.2.3 -r1.1.2.4 rpmodbc.c
  --- rpm/rpmio/rpmodbc.c   18 Mar 2012 14:02:14 -  1.1.2.3
  +++ rpm/rpmio/rpmodbc.c   18 Mar 2012 15:47:06 -  1.1.2.4
  @@ -11,6 +11,7 @@
   #include rpmiotypes.h
   #include rpmio.h   /* for *Pool methods */
   #include rpmlog.h
  +#include rpmmacro.h
   #include rpmurl.h
   
   #define  _RPMODBC_INTERNAL
  @@ -29,15 +30,30 @@
   
   /*==*/
   
  -int odbcConnect(ODBC_t odbc,
  - const char * db, const char * u, const char * pw)
  +int odbcConnect(ODBC_t odbc, const char * uri)
   {
  +const char * db = NULL;
  +urlinfo u = NULL;
   int rc = -1;
   
  -fprintf(stderr, -- %s(%p,%s,%s,%s)\n, __FUNCTION__, odbc, db, u, pw);
  -odbc-db = xstrdup(db);
  -odbc-u = xstrdup(u);
  -odbc-pw = xstrdup(pw);
  +fprintf(stderr, -- %s(%p,%s)\n, __FUNCTION__, odbc, uri);
  +
  +if (uri) {
  + const char * dbpath = NULL;
  + int ut = urlPath(uri, dbpath);
  +assert(ut == URL_IS_MYSQL || ut == URL_IS_POSTGRES);
  + rc = urlSplit(uri, u);
  + db = rpmExpand(u-scheme, _, basename((char *)dbpath), NULL);
  +} else {
  + u = odbc-u;
  + db = xstrdup(odbc-db);
  +}
  +assert(u);
  +assert(db);
  +
  +fprintf(stderr, \tdb: %s\n, db);
  +fprintf(stderr, \t u: %s\n, u-user);
  +fprintf(stderr, \tpw: %s\n, u-password);
   
   #if defined(WITH_UNIXODBC)
   assert(odbc-env);
  @@ -46,13 +62,15 @@
   assert(odbc-dbc);
   }
   
  +/* XXX FIXME: odbc-u-user and odbc-u-password */
   rc = SQLConnect(odbc-dbc,
(SQLCHAR *) db, SQL_NTS,
  - (SQLCHAR *) u, SQL_NTS,
  - (SQLCHAR *) pw, SQL_NTS);
  + (SQLCHAR *) u-user, SQL_NTS,
  + (SQLCHAR *) u-password, SQL_NTS);
   #endif
   
   SPEW(0, rc, odbc);
  +db = _free(db);
   return rc;
   }
   
  @@ -293,10 +311,8 @@
   }
   #endif
   
  -odbc-pw = _free(odbc-pw);
  -odbc-u = _free(odbc-u);
   odbc-db = _free(odbc-db);
  -
  +odbc-u = urlFree(odbc-u, __FUNCTION__);
   odbc-fn = _free(odbc-fn);
   }
   
  @@ -319,14 +335,26 @@
   return odbc;
   }
   
  +static char * _odbc_uri = mysql://luser:jasnl@localhost/test;
  +
   ODBC_t odbcNew(const char * fn, int flags)
   {
   ODBC_t odbc = odbcGetPool(_odbcPool);
   
  -if (fn)
  - odbc-fn = xstrdup(fn);
  +if (fn == NULL)
  + fn = _odbc_uri;
  +odbc-fn = xstrdup(fn);
   odbc-flags = flags;
   
  +{const char * dbpath = NULL;
  + int ut = urlPath(fn, dbpath);
  + urlinfo u = NULL;
  + int xx = urlSplit(fn, u);
  +assert(ut == URL_IS_MYSQL || ut == URL_IS_POSTGRES);
  + odbc-db = rpmExpand(u-scheme, _, basename((char *)dbpath), NULL);
  + odbc-u = urlLink(u, __FUNCTION__);
  +}
  +
   #if defined(WITH_UNIXODBC)
   SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, odbc-env);
   assert(odbc-env);
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmio/rpmodbc.h
  
  $ cvs diff -u -r1.1.2.3 -r1.1.2.4 rpmodbc.h
  --- rpm/rpmio/rpmodbc.h   18 Mar 2012 14:02:14 -  1.1.2.3
  +++ rpm/rpmio/rpmodbc.h   18 Mar 2012 15:47:06 -  1.1.2.4
  @@ -22,9 +22,8 @@
   const char * fn;
   int flags;
   
  +void * u;
   const char * db;
  -const char * u;
  -const char * pw;
   
   void * env;
   void * dbc;
  @@ -92,8 +91,7 @@
/*@globals fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/;
   
  -int odbcConnect(ODBC_t odbc,
  - const char * db, const char * u, const char * pw)
  +int odbcConnect(ODBC_t odbc, /*@null@*/ const char * uri)
/*@*/;
   
   int odbcDisconnect(ODBC_t odbc)
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmio/todbc.c
  
  $ cvs diff -u -r1.1.2.2 -r1.1.2.3 todbc.c
  --- 

[CVS] RPM: rpm-5_4: rpm/rpmio/ librpmio.vers rpmodbc.c rpmodbc.h todbc...

2012-03-18 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   18-Mar-2012 20:26:15
  Branch: rpm-5_4  Handle: 2012031819261400

  Modified files:   (Branch: rpm-5_4)
rpm/rpmio   librpmio.vers rpmodbc.c rpmodbc.h todbc.c

  Log:
- odbc: WIP.

  Summary:
RevisionChanges Path
2.199.2.9   +3  -1  rpm/rpmio/librpmio.vers
1.1.2.5 +194 -53rpm/rpmio/rpmodbc.c
1.1.2.5 +3  -3  rpm/rpmio/rpmodbc.h
1.1.2.4 +72 -20 rpm/rpmio/todbc.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmio/librpmio.vers
  
  $ cvs diff -u -r2.199.2.8 -r2.199.2.9 librpmio.vers
  --- rpm/rpmio/librpmio.vers   18 Mar 2012 14:02:14 -  2.199.2.8
  +++ rpm/rpmio/librpmio.vers   18 Mar 2012 19:26:14 -  2.199.2.9
  @@ -215,12 +215,14 @@
   odbcColumns;
   odbcConnect;
   odbcDisconnect;
  -odbcFetch;
  +odbcExecute;
  +odbcExecDirect;
   odbcListDataSources;
   odbcListDrivers;
   odbcNCols;
   odbcNew;
   odbcPrepare;
  +odbcPrint;
   odbcTables;
   Open;
   _Open;
  @@ .
  patch -p0 '@@ .'
  Index: rpm/rpmio/rpmodbc.c
  
  $ cvs diff -u -r1.1.2.4 -r1.1.2.5 rpmodbc.c
  --- rpm/rpmio/rpmodbc.c   18 Mar 2012 15:47:06 -  1.1.2.4
  +++ rpm/rpmio/rpmodbc.c   18 Mar 2012 19:26:14 -  1.1.2.5
  @@ -20,23 +20,48 @@
   #include debug.h
   
   /*@unchecked@*/
  -int _odbc_debug = -1;
  +int _odbc_debug = 0;
  +
  +#define DBG(_t, _l) \
  +  if ((_t) || _odbc_debug) fprintf _l
   
   #define  SPEW(_t, _rc, _odbc)\
  -  { if ((_t) || _odbc_debug ) \
  +  { if ((_t) || _odbc_debug) \
fprintf(stderr, -- %s(%p) rc %d\n, __FUNCTION__, (_odbc), \
(_rc)); \
 }
   
   /*==*/
  +static int Xchkodbc(/*@unused@*/ ODBC_t odbc, const char * msg,
  +int error, int printit,
  +const char * func, const char * fn, unsigned ln)
  +{
  +int rc = error;
  +
  +/* XXX filter SQL_NO_DATA(100) return. */
  +if (printit  !SQL_SUCCEEDED(rc)  rc != SQL_NO_DATA) {
  +#define odbc_strerror(_e)  /* XXX odbc_strerror? */
  +rpmlog(RPMLOG_ERR, %s:%s:%u: %s(%d): %s\n,
  +func, fn, ln, msg, rc, odbc_strerror(rc));
  +}
  +
  +return rc;
  +}
  +#define CHECK(_odbc, _msg, _error)  \
  +Xchkodbc(_odbc, _msg, _error, _odbc_debug, __FUNCTION__, __FILE__, 
__LINE__)
  +
  +/*==*/
   
   int odbcConnect(ODBC_t odbc, const char * uri)
   {
   const char * db = NULL;
   urlinfo u = NULL;
   int rc = -1;
  +int xx;
   
  -fprintf(stderr, -- %s(%p,%s)\n, __FUNCTION__, odbc, uri);
  +DBG(0, (stderr, -- %s(%p,%s)\n, __FUNCTION__, odbc, uri));
  +
  +/*XXX FIXME: SQLConnect by DSN should be done here. */
   
   if (uri) {
const char * dbpath = NULL;
  @@ -51,22 +76,56 @@
   assert(u);
   assert(db);
   
  -fprintf(stderr, \tdb: %s\n, db);
  -fprintf(stderr, \t u: %s\n, u-user);
  -fprintf(stderr, \tpw: %s\n, u-password);
  +DBG(0, (stderr, \tdb: %s\n, db));
  +DBG(0, (stderr, \t u: %s\n, u-user));
  +DBG(0, (stderr, \tpw: %s\n, u-password));
   
   #if defined(WITH_UNIXODBC)
   assert(odbc-env);
   if (odbc-dbc == NULL) {
  - SQLAllocHandle(SQL_HANDLE_DBC, odbc-env, odbc-dbc);
  + xx = CHECK(odbc, SQLAllocHandle(DBC),
  + SQLAllocHandle(SQL_HANDLE_DBC, odbc-env, odbc-dbc));
   assert(odbc-dbc);
   }
   
  -/* XXX FIXME: odbc-u-user and odbc-u-password */
  -rc = SQLConnect(odbc-dbc,
  - (SQLCHAR *) db, SQL_NTS,
  - (SQLCHAR *) u-user, SQL_NTS,
  - (SQLCHAR *) u-password, SQL_NTS);
  +rc = CHECK(odbc, SQLConnect,
  + SQLConnect(odbc-dbc,
  + (SQLCHAR *) db, SQL_NTS,
  + (SQLCHAR *) u-user, SQL_NTS,
  + (SQLCHAR *) u-password, SQL_NTS));
  +
  + /* XXX FIXME: SQLDriverConnect should print once?. */
  +if (rc == 0) {
  + SQLCHAR dbms_name[256];
  + SQLCHAR dbms_ver[256];
  + SQLUINTEGER getdata_support;
  + SQLUSMALLINT max_concur_act;
  +
  + xx = CHECK(odbc, SQLGetInfo(DBMS_NAME),
  + SQLGetInfo(odbc-dbc, SQL_DBMS_NAME, (SQLPOINTER)dbms_name,
  + sizeof(dbms_name), NULL));
  + xx = CHECK(odbc, SQLGetInfo(DBMS_NAME),
  + SQLGetInfo(odbc-dbc, 

[CVS] RPM: rpm-5_4: rpm/rpmio/ todbc.c

2012-03-18 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   19-Mar-2012 03:08:36
  Branch: rpm-5_4  Handle: 2012031902083500

  Modified files:   (Branch: rpm-5_4)
rpm/rpmio   todbc.c

  Log:
- odbc: use C99 trickey w static arrays  anonymous pointers using C
macros.

  Summary:
RevisionChanges Path
1.1.2.5 +90 -21 rpm/rpmio/todbc.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmio/todbc.c
  
  $ cvs diff -u -r1.1.2.4 -r1.1.2.5 todbc.c
  --- rpm/rpmio/todbc.c 18 Mar 2012 19:26:14 -  1.1.2.4
  +++ rpm/rpmio/todbc.c 19 Mar 2012 02:08:35 -  1.1.2.5
  @@ -102,37 +102,106 @@
   }
   
   /*==*/
  -static const char *const _odbc_stmts[] = {
  -SHOW DATABASES;,
  -USE test;,
  -SHOW TABLES;,
  -DROP TABLE Packages;,
  +typedef struct _PARAM_s * _PARAM_t;
  +
  +struct _PARAM_s {
  +SQLUSMALLINT ParameterNumber;
  +SQLSMALLINT ValueType;
  +SQLSMALLINT ParameterType;
  +SQLULEN LengthPrecision;
  +SQLSMALLINT ParameterScale;
  +SQLPOINTER ParameterValue;
  +SQLLEN * Strlen_or_Ind;
  +};
  +
  +typedef struct _STMT_s * _STMT_t;
  +struct _STMT_s {
  +const char * sql;
  +_PARAM_t * params;
  +};
  +
  +/* XXX c99 only */
  +#define  _mkSTMT(_sql, _params)  \
  +  (struct _STMT_s) { .sql = _sql, .params = _params }
  +
  +#ifdefNOTYET /* XXX todo++ */
  +#define  _mkP1(_chararray) \
  +  (_PARAM_t) { \
  +(struct _PARAM_s) { \
  + .ParameterNumber = 1, \
  + .ValueType = SQL_C_CHAR, \
  + .ParameterType = SQL_CHAR, \
  + .LengthPrecision = sizeof(_chararray), \
  + .ParameterScale = 0, \
  + .ParameterValue = _chararray, \
  + .Strlen_or_Ind = NULL, \
  +}, \
  +  }
  +#endif
  +
  +static _STMT_t _odbc_stmts[] = {
  +  _mkSTMT(SHOW DATABASES, NULL),
  +  _mkSTMT(USE test, NULL),
  +  _mkSTMT(SHOW TABLES, NULL),
  +  _mkSTMT(DROP TABLE Packages IF EXISTS, NULL),
  +  _mkSTMT(
   CREATE TABLE Packages (\n\
   i INTEGER PRIMARY KEY NOT NULL,\n\
   Nvra VARCHAR(64)\n\
  -);,
  -DESCRIBE Packages;,
  -INSERT INTO Packages VALUES( 1, 'Bing' );,
  -INSERT INTO Packages VALUES( 2, 'Bang' );,
  -INSERT INTO Packages VALUES( 3, 'Boom' );,
  -SELECT * from Packages;,
  -DROP TABLE Packages;,
  -NULL
  +), NULL),
  +  _mkSTMT(DESCRIBE Packages, NULL),
  +  _mkSTMT(INSERT INTO Packages VALUES( 1, 'Bing' ), NULL),
  +  _mkSTMT(INSERT INTO Packages VALUES( 2, 'Bang' ), NULL),
  +  _mkSTMT(INSERT INTO Packages VALUES( 3, 'Boom' ), NULL),
  +  _mkSTMT(SELECT * FROM Packages, NULL),
  +  _mkSTMT(DROP TABLE Packages, NULL),
  +  NULL
   };
   
  -static int odbcRun(ODBC_t odbc, const char *const stmts[], void * _fp)
  +#undef   _mkSTMT
  +
  +static int odbcBind(ODBC_t odbc, _PARAM_t param)
  +{
  +int rc = CHECK(odbc, SQLBindParam,
  + SQLBindParam(odbc-stmt,
  + param-ParameterNumber,
  + param-ValueType,
  + param-ParameterType,
  + param-LengthPrecision,
  + param-ParameterScale,
  + param-ParameterValue,
  + param-Strlen_or_Ind));
  +
  +SPEW(0, rc, odbc);
  +return rc;
  +}
  +
  +static int odbcStmt(ODBC_t odbc, _STMT_t stmt, void * _fp)
   {
   FILE * fp = (_fp ? _fp : stderr);
  -const char * s;
   int rc = -1;
  -int i;
  +const char * s = stmt-sql;
  +_PARAM_t * params = stmt-params;
   
  -for (i = 0; (s = stmts[i]) != NULL; i++) {
   fprintf(fp, == %s\n, s);
  - rc = odbcPrepare(odbc, s, 0);
  - rc = odbcExecute(odbc);
  - rc = odbcPrint(odbc, fp);
  -}
  +rc = odbcPrepare(odbc, s, 0);
  +
  +while (params  *params)
  + rc = odbcBind(odbc, *params++);
  +
  +rc = odbcExecute(odbc);
  +rc = odbcPrint(odbc, fp);
  +
  +SPEW(0, rc, odbc);
  +return rc;
  +}
  +
  +static int odbcRun(ODBC_t odbc, _STMT_t * stmts, void * _fp)
  +{
  +int rc = -1;
  +
  +while (stmts  *stmts)
  + rc = odbcStmt(odbc, *stmts++, _fp);
   
   SPEW(0, rc, odbc);
   return rc;
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm-5_4: rpm/rpmio/ rpmodbc.c

2012-03-18 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   19-Mar-2012 05:50:00
  Branch: rpm-5_4  Handle: 201203190450

  Modified files:   (Branch: rpm-5_4)
rpm/rpmio   rpmodbc.c

  Log:
- odbc: rescuscitate builds that do not have --with-unixodbc.

  Summary:
RevisionChanges Path
1.1.2.6 +2  -0  rpm/rpmio/rpmodbc.c
  

  patch -p0 '@@ .'
  Index: rpm/rpmio/rpmodbc.c
  
  $ cvs diff -u -r1.1.2.5 -r1.1.2.6 rpmodbc.c
  --- rpm/rpmio/rpmodbc.c   18 Mar 2012 19:26:14 -  1.1.2.5
  +++ rpm/rpmio/rpmodbc.c   19 Mar 2012 04:50:00 -  1.1.2.6
  @@ -32,6 +32,7 @@
 }
   
   /*==*/
  +#if defined(WITH_UNIXODBC)
   static int Xchkodbc(/*@unused@*/ ODBC_t odbc, const char * msg,
   int error, int printit,
   const char * func, const char * fn, unsigned ln)
  @@ -49,6 +50,7 @@
   }
   #define CHECK(_odbc, _msg, _error)  \
   Xchkodbc(_odbc, _msg, _error, _odbc_debug, __FUNCTION__, __FILE__, 
__LINE__)
  +#endif   /* WITH_UNIXODBC */
   
   /*==*/
   
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org