rpm  5.4.10
Macros | Functions | Variables
rpmsql.c File Reference
#include "system.h"
#include <popt.h>
#include "rpmio_internal.h"
#include <rpmmacro.h>
#include <rpmdir.h>
#include <rpmurl.h>
#include <mire.h>
#include <rpmsql.h>
#include "debug.h"
Include dependency graph for rpmsql.c:

Go to the source code of this file.

Macros

#define _RPMIOB_INTERNAL   /* rpmiobSlurp */
 
#define _RPMSQL_INTERNAL
 
#define _RPMVT_INTERNAL
 
#define _RPMVC_INTERNAL
 
#define readline(sql, p)   local_getline(sql, p)
 
#define add_history(X)
 
#define read_history(X)
 
#define write_history(X)
 
#define stifle_history(X)
 
#define VTDBG(_vt, _l)   if ((_vt)->debug) fprintf _l
 
#define VTDBGNOISY(_vt, _l)   if ((_vt)->debug < 0) fprintf _l
 
#define VCDBG(_vc, _l)   if ((_vc)->debug) fprintf _l
 
#define VCDBGNOISY(_vc, _l)   if ((_vc)->debug < 0) fprintf _l
 
#define rpmsqlDebugDump(_sql)   _rpmsqlDebugDump(_sql, __FUNCTION__, __FILE__, __LINE__)
 

Functions

static void rpmvtFini (void *_VT)
 rpmvt pool destructor. More...
 
static rpmvt rpmvtGetPool (rpmioPool pool)
 
rpmvt rpmvtNew (void *db, void *pModule, const char *const *argv, rpmvd vd)
 
static void rpmvcFini (void *_VC)
 rpmvc pool destructor. More...
 
static rpmvc rpmvcGetPool (rpmioPool pool)
 
rpmvc rpmvcNew (rpmvt vt, int nrows)
 
static void _rpmsqlDebugDump (rpmsql sql, const char *_func, const char *_fn, unsigned _ln)
 
static rpmsql rpmsqlI (void)
 Return the global interpreter, creating laziliy if needed. More...
 
static void rpmsqlFini (void *_sql)
 rpmsql pool destructor. More...
 
static rpmsql rpmsqlGetPool (rpmioPool pool)
 
const char ** rpmsqlArgv (rpmsql sql, int *argcp)
 Return arguments from a sql interpreter. More...
 
rpmsql rpmsqlNew (char **av, uint32_t flags)
 Create and load a sql interpreter. More...
 
rpmRC rpmsqlRun (rpmsql sql, const char *str, const char **resultp)
 Execute sql from STRING | FILE | STDIN | INTERACTIVE. More...
 

Variables

int _rpmsql_debug = 0
 
int _rpmvt_debug = 0
 
int _rpmvc_debug = 0
 
rpmsql _rpmsqlI = NULL
 
volatile int _rpmsqlSeenInterrupt
 
rpmioPool _rpmvtPool
 
rpmioPool _rpmvcPool
 
rpmioPool _rpmsqlPool
 

Macro Definition Documentation

§ _RPMIOB_INTERNAL

#define _RPMIOB_INTERNAL   /* rpmiobSlurp */

Definition at line 5 of file rpmsql.c.

§ _RPMSQL_INTERNAL

#define _RPMSQL_INTERNAL

Definition at line 22 of file rpmsql.c.

§ _RPMVC_INTERNAL

#define _RPMVC_INTERNAL

Definition at line 24 of file rpmsql.c.

§ _RPMVT_INTERNAL

#define _RPMVT_INTERNAL

Definition at line 23 of file rpmsql.c.

§ add_history

#define add_history (   X)

Definition at line 35 of file rpmsql.c.

Referenced by rpmsqlI().

§ read_history

#define read_history (   X)

Definition at line 36 of file rpmsql.c.

Referenced by rpmsqlRun().

§ readline

#define readline (   sql,
 
)    local_getline(sql, p)

Definition at line 34 of file rpmsql.c.

Referenced by rpmsqlI().

§ rpmsqlDebugDump

#define rpmsqlDebugDump (   _sql)    _rpmsqlDebugDump(_sql, __FUNCTION__, __FILE__, __LINE__)

Definition at line 854 of file rpmsql.c.

Referenced by rpmsqlI().

§ stifle_history

#define stifle_history (   X)

Definition at line 38 of file rpmsql.c.

Referenced by rpmsqlRun().

§ VCDBG

#define VCDBG (   _vc,
  _l 
)    if ((_vc)->debug) fprintf _l

Definition at line 577 of file rpmsql.c.

Referenced by rpmvcNew().

§ VCDBGNOISY

#define VCDBGNOISY (   _vc,
  _l 
)    if ((_vc)->debug < 0) fprintf _l

Definition at line 578 of file rpmsql.c.

Referenced by rpmvcFini(), and rpmvcNew().

§ VTDBG

#define VTDBG (   _vt,
  _l 
)    if ((_vt)->debug) fprintf _l

Definition at line 64 of file rpmsql.c.

Referenced by rpmvtNew().

§ VTDBGNOISY

#define VTDBGNOISY (   _vt,
  _l 
)    if ((_vt)->debug < 0) fprintf _l

Definition at line 65 of file rpmsql.c.

Referenced by rpmvtFini().

§ write_history

#define write_history (   X)

Definition at line 37 of file rpmsql.c.

Referenced by rpmsqlRun().

Function Documentation

§ _rpmsqlDebugDump()

static void _rpmsqlDebugDump ( rpmsql  sql,
const char *  _func,
const char *  _fn,
unsigned  _ln 
)
static

Definition at line 814 of file rpmsql.c.

References _rpmsqlI, and argvCount().

§ rpmsqlArgv()

const char** rpmsqlArgv ( rpmsql  sql,
int *  argcp 
)

Return arguments from a sql interpreter.

Parameters
sqlsql interpreter
Return values
*argcpno. of arguments
Returns
sql interpreter args

Definition at line 5225 of file rpmsql.c.

References _, _free(), argvAppend(), argvCount(), argvFree(), and stpcpy().

§ rpmsqlFini()

static void rpmsqlFini ( void *  _sql)
static

rpmsql pool destructor.

Definition at line 5155 of file rpmsql.c.

References _free(), argvFree(), Fclose(), rpmiobFree(), and rpmsqlCmd().

Referenced by rpmsqlGetPool().

§ rpmsqlGetPool()

static rpmsql rpmsqlGetPool ( rpmioPool  pool)
static

Definition at line 5209 of file rpmsql.c.

References _rpmsql_debug, _rpmsqlPool, rpmioGetPool(), rpmioNewPool(), and rpmsqlFini().

Referenced by rpmsqlNew().

§ rpmsqlI()

static rpmsql rpmsqlI ( void  )
static

§ rpmsqlNew()

rpmsql rpmsqlNew ( char **  av,
uint32_t  flags 
)

Create and load a sql interpreter.

Parameters
avsql interpreter args (or NULL)
flagssql interpreter flags
Returns
new sql interpreter

Definition at line 5295 of file rpmsql.c.

References _free(), _rpmsql_debug, Access(), argvAppend(), argvCount(), argvPrint(), F_ISSET, Fclose(), fdDup(), getenv(), R_OK, rpmExpand(), rpmGetPath(), rpmiobNew(), rpmsqlCmd(), rpmsqlGetPool(), rpmsqlI(), rpmsqlLink(), and xstrdup().

Referenced by expandMacro(), psmWait(), rpmsqlI(), and sql_open().

§ rpmsqlRun()

rpmRC rpmsqlRun ( rpmsql  sql,
const char *  str,
const char **  resultp 
)

Execute sql from STRING | FILE | STDIN | INTERACTIVE.

The str argument is used to determine how it should be run: A leading '/' indicates a FILE, containing SQL commands. A "-" or "stdin" argument used STD for SQL commands. An empty "" string assumes INTERACTIVE, like STDIN but with prompts. Otherwise, the STRING argument is treated as a sql command.

Parameters
sqlsql interpreter (NULL uses global interpreter)
strsql string to execute (NULL returns RPMRC_FAIL)
*resultpsql interpreter result
Returns
RPMRC_OK on success

Definition at line 5397 of file rpmsql.c.

References _, _free(), Fclose(), fdDup(), Fdopen(), Ferror(), Fflush(), _FD_s::flags, Fopen(), Fwrite(), read_history, rpmExpand(), rpmiobRTrim(), rpmiobStr(), RPMRC_FAIL, rpmsqlI(), stifle_history, write_history, xisspace(), and xstrdup().

Referenced by expandMacro(), and psmWait().

§ rpmvcFini()

static void rpmvcFini ( void *  _VC)
static

rpmvc pool destructor.

Definition at line 583 of file rpmsql.c.

References VCDBGNOISY.

Referenced by rpmvcGetPool().

§ rpmvcGetPool()

static rpmvc rpmvcGetPool ( rpmioPool  pool)
static

Definition at line 599 of file rpmsql.c.

References _rpmvc_debug, _rpmvcPool, rpmioGetPool(), rpmioNewPool(), and rpmvcFini().

Referenced by rpmvcNew().

§ rpmvcNew()

rpmvc rpmvcNew ( rpmvt  vt,
int  nrows 
)

§ rpmvtFini()

static void rpmvtFini ( void *  _VT)
static

rpmvt pool destructor.

Definition at line 70 of file rpmsql.c.

References argvFree(), and VTDBGNOISY.

Referenced by rpmvtGetPool().

§ rpmvtGetPool()

static rpmvt rpmvtGetPool ( rpmioPool  pool)
static

Definition at line 92 of file rpmsql.c.

References _rpmvt_debug, _rpmvtPool, rpmioGetPool(), rpmioNewPool(), and rpmvtFini().

Referenced by rpmvtNew().

§ rpmvtNew()

rpmvt rpmvtNew ( void *  db,
void *  pModule,
const char *const *  argv,
rpmvd  vd 
)

Variable Documentation

§ _rpmsql_debug

int _rpmsql_debug = 0

Definition at line 43 of file rpmsql.c.

Referenced by rpmsqlGetPool(), rpmsqlI(), and rpmsqlNew().

§ _rpmsqlI

rpmsql _rpmsqlI = NULL

Definition at line 52 of file rpmsql.c.

Referenced by _rpmsqlDebugDump(), rpmioClean(), and rpmsqlI().

§ _rpmsqlPool

rpmioPool _rpmsqlPool

Definition at line 5207 of file rpmsql.c.

Referenced by rpmioClean(), and rpmsqlGetPool().

§ _rpmsqlSeenInterrupt

volatile int _rpmsqlSeenInterrupt

Definition at line 55 of file rpmsql.c.

Referenced by rpmsqlI().

§ _rpmvc_debug

int _rpmvc_debug = 0

Definition at line 49 of file rpmsql.c.

Referenced by rpmvcGetPool(), and rpmvcNew().

§ _rpmvcPool

rpmioPool _rpmvcPool

Definition at line 597 of file rpmsql.c.

Referenced by rpmioClean(), and rpmvcGetPool().

§ _rpmvt_debug

int _rpmvt_debug = 0

Definition at line 46 of file rpmsql.c.

Referenced by rpmvtGetPool(), and rpmvtNew().

§ _rpmvtPool

rpmioPool _rpmvtPool

Definition at line 90 of file rpmsql.c.

Referenced by rpmioClean(), and rpmvtGetPool().