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: Revision Changes 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 -0000 2.199.2.7 +++ rpm/rpmio/librpmio.vers 18 Mar 2012 14:02:14 -0000 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.c 17 Mar 2012 15:53:15 -0000 1.94.2.2 +++ rpm/rpmio/poptIO.c 18 Mar 2012 14:02:14 -0000 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 -0000 1.230.2.4 +++ rpm/rpmio/rpmio.c 18 Mar 2012 14:02:14 -0000 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 -0000 1.1.2.2 +++ rpm/rpmio/rpmodbc.c 18 Mar 2012 14:02:14 -0000 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 +72,7 @@ return rc; } -int rpmodbcListDataSources(rpmodbc odbc, void *_fp) +int odbcListDataSources(ODBC_t odbc, void *_fp) { int rc = 0; FILE * fp = (_fp ? _fp : stderr); @@ -102,7 +102,7 @@ return rc; } -int rpmodbcListDrivers(rpmodbc odbc, void *_fp) +int odbcListDrivers(ODBC_t odbc, void *_fp) { int rc = 0; FILE * fp = (_fp ? _fp : stderr); @@ -132,7 +132,7 @@ return rc; } -int rpmodbcTables(rpmodbc odbc) +int odbcTables(ODBC_t odbc) { int rc = 0; @@ -152,7 +152,7 @@ return rc; } -int rpmodbcColumns(rpmodbc odbc) +int odbcColumns(ODBC_t odbc) { int rc = 0; @@ -172,7 +172,7 @@ return rc; } -int rpmodbcNCols(rpmodbc odbc) +int odbcNCols(ODBC_t odbc) { int rc = 0; @@ -190,7 +190,7 @@ return rc; } -int rpmodbcExecDirect(rpmodbc odbc, const char * s, size_t ns) +int odbcExecDirect(ODBC_t odbc, const char * s, size_t ns) { int rc = 0; @@ -212,7 +212,7 @@ return rc; } -int rpmodbcPrepare(rpmodbc odbc, const char * s, size_t ns) +int odbcPrepare(ODBC_t odbc, const char * s, size_t ns) { int rc = 0; @@ -234,7 +234,7 @@ return rc; } -int rpmodbcExecute(rpmodbc odbc) +int odbcExecute(ODBC_t odbc) { int rc = -1; @@ -250,7 +250,7 @@ return rc; } -int rpmodbcFetch(rpmodbc odbc) +int odbcFetch(ODBC_t odbc) { int rc = 0; @@ -268,11 +268,11 @@ /*==============================================================*/ -static void rpmodbcFini(void * _odbc) +static void odbcFini(void * _odbc) /*@globals fileSystem @*/ /*@modifies *_odbc, fileSystem @*/ { - rpmodbc odbc = _odbc; + ODBC_t odbc = _odbc; #if defined(WITH_UNIXODBC) if (odbc->desc) { @@ -301,27 +301,27 @@ } /*@unchecked@*/ /*@only@*/ /*@null@*/ -rpmioPool _rpmodbcPool = NULL; +rpmioPool _odbcPool = NULL; -static rpmodbc rpmodbcGetPool(/*@null@*/ rpmioPool pool) - /*@globals _rpmodbcPool, fileSystem @*/ - /*@modifies pool, _rpmodbcPool, fileSystem @*/ +static ODBC_t odbcGetPool(/*@null@*/ rpmioPool pool) + /*@globals _odbcPool, fileSystem @*/ + /*@modifies pool, _odbcPool, fileSystem @*/ { - rpmodbc odbc; + ODBC_t odbc; - if (_rpmodbcPool == NULL) { - _rpmodbcPool = rpmioNewPool("odbc", sizeof(*odbc), -1, _rpmodbc_debug, - NULL, NULL, rpmodbcFini); - pool = _rpmodbcPool; + if (_odbcPool == NULL) { + _odbcPool = rpmioNewPool("odbc", sizeof(*odbc), -1, _odbc_debug, + NULL, NULL, odbcFini); + pool = _odbcPool; } - odbc = (rpmodbc) rpmioGetPool(pool, sizeof(*odbc)); + odbc = (ODBC_t) rpmioGetPool(pool, sizeof(*odbc)); memset(((char *)odbc)+sizeof(odbc->_item), 0, sizeof(*odbc)-sizeof(odbc->_item)); return odbc; } -rpmodbc rpmodbcNew(const char * fn, int flags) +ODBC_t odbcNew(const char * fn, int flags) { - rpmodbc odbc = rpmodbcGetPool(_rpmodbcPool); + ODBC_t odbc = odbcGetPool(_odbcPool); if (fn) odbc->fn = xstrdup(fn); @@ -333,5 +333,5 @@ SQLSetEnvAttr(odbc->env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0); #endif - return rpmodbcLink(odbc); + return odbcLink(odbc); } @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmodbc.h ============================================================================ $ cvs diff -u -r1.1.2.2 -r1.1.2.3 rpmodbc.h --- rpm/rpmio/rpmodbc.h 17 Mar 2012 19:25:03 -0000 1.1.2.2 +++ rpm/rpmio/rpmodbc.h 18 Mar 2012 14:02:14 -0000 1.1.2.3 @@ -8,16 +8,16 @@ /** \ingroup rpmio */ /*@unchecked@*/ -extern int _rpmodbc_debug; +extern int _odbc_debug; /** \ingroup rpmio */ -typedef /*@refcounted@*/ struct rpmodbc_s * rpmodbc; +typedef /*@refcounted@*/ struct ODBC_s * ODBC_t; #if defined(_RPMODBC_INTERNAL) /** \ingroup rpmio */ -struct rpmodbc_s { +struct ODBC_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ const char * fn; int flags; @@ -53,10 +53,10 @@ * @return NULL on last dereference */ /*@unused@*/ /*@null@*/ -rpmodbc rpmodbcUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmodbc odbc) +ODBC_t odbcUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ ODBC_t odbc) /*@modifies odbc @*/; -#define rpmodbcUnlink(_odbc) \ - ((rpmodbc)rpmioUnlinkPoolItem((rpmioItem)(_odbc), __FUNCTION__, __FILE__, __LINE__)) +#define odbcUnlink(_odbc) \ + ((ODBC_t)rpmioUnlinkPoolItem((rpmioItem)(_odbc), __FUNCTION__, __FILE__, __LINE__)) /** * Reference a odbc wrapper instance. @@ -64,10 +64,10 @@ * @return new odbc wrapper reference */ /*@unused@*/ /*@newref@*/ /*@null@*/ -rpmodbc rpmodbcLink (/*@null@*/ rpmodbc odbc) +ODBC_t odbcLink (/*@null@*/ ODBC_t odbc) /*@modifies odbc @*/; -#define rpmodbcLink(_odbc) \ - ((rpmodbc)rpmioLinkPoolItem((rpmioItem)(_odbc), __FUNCTION__, __FILE__, __LINE__)) +#define odbcLink(_odbc) \ + ((ODBC_t)rpmioLinkPoolItem((rpmioItem)(_odbc), __FUNCTION__, __FILE__, __LINE__)) /** * Destroy a odbc wrapper. @@ -75,11 +75,11 @@ * @return NULL on last dereference */ /*@null@*/ -rpmodbc rpmodbcFree(/*@killref@*/ /*@null@*/rpmodbc odbc) +ODBC_t odbcFree(/*@killref@*/ /*@null@*/ODBC_t odbc) /*@globals fileSystem @*/ /*@modifies odbc, fileSystem @*/; -#define rpmodbcFree(_odbc) \ - ((rpmodbc)rpmioFreePoolItem((rpmioItem)(_odbc), __FUNCTION__, __FILE__, __LINE__)) +#define odbcFree(_odbc) \ + ((ODBC_t)rpmioFreePoolItem((rpmioItem)(_odbc), __FUNCTION__, __FILE__, __LINE__)) /** * Create and load a odbc wrapper. @@ -88,42 +88,42 @@ * @return new odbc wrapper */ /*@newref@*/ /*@null@*/ -rpmodbc rpmodbcNew(const char * fn, int flags) +ODBC_t odbcNew(const char * fn, int flags) /*@globals fileSystem, internalState @*/ /*@modifies fileSystem, internalState @*/; -int rpmodbcConnect(rpmodbc odbc, +int odbcConnect(ODBC_t odbc, const char * db, const char * u, const char * pw) /*@*/; -int rpmodbcDisconnect(rpmodbc odbc) +int odbcDisconnect(ODBC_t odbc) /*@*/; -int rpmodbcListDataSources(rpmodbc odbc, void *_fp) +int odbcListDataSources(ODBC_t odbc, void *_fp) /*@*/; -int rpmodbcListDrivers(rpmodbc odbc, void *_fp) +int odbcListDrivers(ODBC_t odbc, void *_fp) /*@*/; -int rpmodbcTables(rpmodbc odbc) +int odbcTables(ODBC_t odbc) /*@*/; -int rpmodbcColumns(rpmodbc odbc) +int odbcColumns(ODBC_t odbc) /*@*/; -int rpmodbcNCols(rpmodbc odbc) +int odbcNCols(ODBC_t odbc) /*@*/; -int rpmodbcExecDirect(rpmodbc odbc, const char * s, size_t ns) +int odbcExecDirect(ODBC_t odbc, const char * s, size_t ns) /*@*/; -int rpmodbcPrepare(rpmodbc odbc, const char * s, size_t ns) +int odbcPrepare(ODBC_t odbc, const char * s, size_t ns) /*@*/; -int rpmodbcExecute(rpmodbc odbc) +int odbcExecute(ODBC_t odbc) /*@*/; -int rpmodbcFetch(rpmodbc odbc) +int odbcFetch(ODBC_t odbc) /*@*/; #ifdef __cplusplus @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/todbc.c ============================================================================ $ cvs diff -u -r1.1.2.1 -r1.1.2.2 todbc.c --- rpm/rpmio/todbc.c 17 Mar 2012 19:25:03 -0000 1.1.2.1 +++ rpm/rpmio/todbc.c 18 Mar 2012 14:02:14 -0000 1.1.2.2 @@ -10,10 +10,86 @@ #include "debug.h" +#define SPEW(_t, _rc, _odbc) \ + { if ((_t) || _odbc_debug ) \ + fprintf(stderr, "<-- %s(%p) rc %d\n", __FUNCTION__, (_odbc), \ + (_rc)); \ + } + +static char * _odbc_uri = "mysql://luser:jasnl@localhost/test"; +static int _odbc_flags = 0; + static char * _odbc_db = "mysql_test"; static char * _odbc_u = "luser"; static char * _odbc_pw = "jasnl"; +/*==============================================================*/ + +static int odbcOpen(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcClose(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcCOpen(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcCClose(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcCDup(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcCDel(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcCGet(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcCPut(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +static int odbcCCount(ODBC_t odbc) +{ + int rc = -1; +SPEW(0, rc, odbc); + return rc; +} + +/*==============================================================*/ + static struct poptOption rpmsvnOptionsTable[] = { { "debug", 'd', POPT_ARG_VAL, &_rpmmg_debug, -1, NULL, NULL }, POPT_AUTOHELP @@ -24,23 +100,20 @@ main(int argc, char *argv[]) { poptContext con = rpmioInit(argc, argv, rpmsvnOptionsTable); - rpmodbc odbc; + ODBC_t odbc = odbcNew(_odbc_uri, _odbc_flags); + FILE * _odbc_fp = stderr; int rc = 0; int xx; -_rpmodbc_debug = -1; + rc = odbcListDrivers(odbc, _odbc_fp); + rc = odbcListDataSources(odbc, _odbc_fp); - odbc = rpmodbcNew(NULL, 0); + rc = odbcConnect(odbc, _odbc_db, _odbc_u, _odbc_pw); - rc = rpmodbcListDrivers(odbc, NULL); - rc = rpmodbcListDataSources(odbc, NULL); - - rc = rpmodbcConnect(odbc, _odbc_db, _odbc_u, _odbc_pw); - - xx = rpmodbcColumns(odbc); - odbc->ncols = rpmodbcNCols(odbc); + xx = odbcColumns(odbc); + odbc->ncols = odbcNCols(odbc); odbc->nrows = 0; - while ((xx = rpmodbcFetch(odbc)) != SQL_NO_DATA) { + while ((xx = odbcFetch(odbc)) != SQL_NO_DATA) { int i; fprintf(stdout, "Row %d\n", odbc->nrows++); @@ -57,9 +130,21 @@ } } - rc = rpmodbcDisconnect(odbc); + rc = odbcDisconnect(odbc); + + xx = odbcOpen(odbc); + xx = odbcCOpen(odbc); + + xx = odbcCDup(odbc); + xx = odbcCDel(odbc); + xx = odbcCGet(odbc); + xx = odbcCPut(odbc); + xx = odbcCCount(odbc); + + xx = odbcCClose(odbc); + xx = odbcClose(odbc); - odbc = rpmodbcFree(odbc); + odbc = odbcFree(odbc); con = rpmioFini(con); /*@i@*/ urlFreeCache(); @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org