More docgen fixes.

This commit is contained in:
Dominik Picheta
2014-09-13 16:45:07 +01:00
parent d28088f0f5
commit 0047172274
9 changed files with 171 additions and 233 deletions

View File

@@ -78,17 +78,17 @@ proc tryExec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]): bool {
tags: [FReadDB, FWriteDb].} =
## tries to execute the query and returns true if successful, false otherwise.
var q = dbFormat(query, args)
return mysql.RealQuery(db, q, q.len) == 0'i32
return mysql.realQuery(db, q, q.len) == 0'i32
proc rawExec(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) =
var q = dbFormat(query, args)
if mysql.RealQuery(db, q, q.len) != 0'i32: dbError(db)
if mysql.realQuery(db, q, q.len) != 0'i32: dbError(db)
proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {.
tags: [FReadDB, FWriteDb].} =
## executes the query and raises EDB if not successful.
var q = dbFormat(query, args)
if mysql.RealQuery(db, q, q.len) != 0'i32: dbError(db)
if mysql.realQuery(db, q, q.len) != 0'i32: dbError(db)
proc newRow(L: int): TRow =
newSeq(result, L)
@@ -96,8 +96,8 @@ proc newRow(L: int): TRow =
proc properFreeResult(sqlres: mysql.PRES, row: cstringArray) =
if row != nil:
while mysql.FetchRow(sqlres) != nil: discard
mysql.FreeResult(sqlres)
while mysql.fetchRow(sqlres) != nil: discard
mysql.freeResult(sqlres)
iterator fastRows*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
@@ -105,13 +105,13 @@ iterator fastRows*(db: TDbConn, query: TSqlQuery,
## fast, but potenially dangerous: If the for-loop-body executes another
## query, the results can be undefined. For MySQL this is the case!.
rawExec(db, query, args)
var sqlres = mysql.UseResult(db)
var sqlres = mysql.useResult(db)
if sqlres != nil:
var L = int(mysql.NumFields(sqlres))
var L = int(mysql.numFields(sqlres))
var result = newRow(L)
var row: cstringArray
while true:
row = mysql.FetchRow(sqlres)
row = mysql.fetchRow(sqlres)
if row == nil: break
for i in 0..L-1:
setLen(result[i], 0)
@@ -124,11 +124,11 @@ proc getRow*(db: TDbConn, query: TSqlQuery,
## retrieves a single row. If the query doesn't return any rows, this proc
## will return a TRow with empty strings for each column.
rawExec(db, query, args)
var sqlres = mysql.UseResult(db)
var sqlres = mysql.useResult(db)
if sqlres != nil:
var L = int(mysql.NumFields(sqlres))
var L = int(mysql.numFields(sqlres))
result = newRow(L)
var row = mysql.FetchRow(sqlres)
var row = mysql.fetchRow(sqlres)
if row != nil:
for i in 0..L-1:
setLen(result[i], 0)
@@ -140,24 +140,24 @@ proc getAllRows*(db: TDbConn, query: TSqlQuery,
## executes the query and returns the whole result dataset.
result = @[]
rawExec(db, query, args)
var sqlres = mysql.UseResult(db)
var sqlres = mysql.useResult(db)
if sqlres != nil:
var L = int(mysql.NumFields(sqlres))
var L = int(mysql.numFields(sqlres))
var row: cstringArray
var j = 0
while true:
row = mysql.FetchRow(sqlres)
row = mysql.fetchRow(sqlres)
if row == nil: break
setLen(result, j+1)
newSeq(result[j], L)
for i in 0..L-1: result[j][i] = $row[i]
inc(j)
mysql.FreeResult(sqlres)
mysql.freeResult(sqlres)
iterator rows*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
## same as `FastRows`, but slower and safe.
for r in items(GetAllRows(db, query, args)): yield r
## same as `fastRows`, but slower and safe.
for r in items(getAllRows(db, query, args)): yield r
proc getValue*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): string {.tags: [FReadDB].} =
@@ -165,7 +165,7 @@ proc getValue*(db: TDbConn, query: TSqlQuery,
## result dataset. Returns "" if the dataset contains no rows or the database
## value is NULL.
result = ""
for row in FastRows(db, query, args):
for row in fastRows(db, query, args):
result = row[0]
break
@@ -174,16 +174,16 @@ proc tryInsertId*(db: TDbConn, query: TSqlQuery,
## executes the query (typically "INSERT") and returns the
## generated ID for the row or -1 in case of an error.
var q = dbFormat(query, args)
if mysql.RealQuery(db, q, q.len) != 0'i32:
if mysql.realQuery(db, q, q.len) != 0'i32:
result = -1'i64
else:
result = mysql.InsertId(db)
result = mysql.insertId(db)
proc insertId*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} =
## executes the query (typically "INSERT") and returns the
## generated ID for the row.
result = TryInsertID(db, query, args)
result = tryInsertID(db, query, args)
if result < 0: dbError(db)
proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
@@ -192,7 +192,7 @@ proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
## runs the query (typically "UPDATE") and returns the
## number of affected rows
rawExec(db, query, args)
result = mysql.AffectedRows(db)
result = mysql.affectedRows(db)
proc close*(db: TDbConn) {.tags: [FDb].} =
## closes the database connection.
@@ -202,7 +202,7 @@ proc open*(connection, user, password, database: string): TDbConn {.
tags: [FDb].} =
## opens a database connection. Raises `EDb` if the connection could not
## be established.
result = mysql.Init(nil)
result = mysql.init(nil)
if result == nil: dbError("could not open database connection")
let
colonPos = connection.find(':')
@@ -210,9 +210,9 @@ proc open*(connection, user, password, database: string): TDbConn {.
else: substr(connection, 0, colonPos-1)
port: int32 = if colonPos < 0: 0'i32
else: substr(connection, colonPos+1).parseInt.int32
if mysql.RealConnect(result, host, user, password, database,
if mysql.realConnect(result, host, user, password, database,
port, nil, 0) == nil:
var errmsg = $mysql.error(result)
db_mysql.Close(result)
db_mysql.close(result)
dbError(errmsg)

View File

@@ -37,7 +37,7 @@ proc dbError(db: TDbConn) {.noreturn.} =
## raises an EDb exception.
var e: ref EDb
new(e)
e.msg = $PQerrorMessage(db)
e.msg = $pqErrorMessage(db)
raise e
proc dbError*(msg: string) {.noreturn.} =
@@ -68,17 +68,17 @@ proc tryExec*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): bool {.tags: [FReadDB, FWriteDb].} =
## tries to execute the query and returns true if successful, false otherwise.
var q = dbFormat(query, args)
var res = PQExec(db, q)
result = PQresultStatus(res) == PGRES_COMMAND_OK
PQclear(res)
var res = pqExec(db, q)
result = pqresultStatus(res) == PGRES_COMMAND_OK
pqclear(res)
proc exec*(db: TDbConn, query: TSqlQuery, args: varargs[string, `$`]) {.
tags: [FReadDB, FWriteDb].} =
## executes the query and raises EDB if not successful.
var q = dbFormat(query, args)
var res = PQExec(db, q)
if PQresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
PQclear(res)
var res = pqExec(db, q)
if pqresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
pqclear(res)
proc newRow(L: int): TRow =
newSeq(result, L)
@@ -87,13 +87,13 @@ proc newRow(L: int): TRow =
proc setupQuery(db: TDbConn, query: TSqlQuery,
args: varargs[string]): PPGresult =
var q = dbFormat(query, args)
result = PQExec(db, q)
if PQresultStatus(result) != PGRES_TUPLES_OK: dbError(db)
result = pqExec(db, q)
if pqresultStatus(result) != PGRES_TUPLES_OK: dbError(db)
proc setRow(res: PPGresult, r: var TRow, line, cols: int32) =
for col in 0..cols-1:
setLen(r[col], 0)
var x = PQgetvalue(res, line, col)
var x = pqgetvalue(res, line, col)
add(r[col], x)
iterator fastRows*(db: TDbConn, query: TSqlQuery,
@@ -102,41 +102,41 @@ iterator fastRows*(db: TDbConn, query: TSqlQuery,
## fast, but potenially dangerous: If the for-loop-body executes another
## query, the results can be undefined. For Postgres it is safe though.
var res = setupQuery(db, query, args)
var L = PQnfields(res)
var L = pqnfields(res)
var result = newRow(L)
for i in 0..PQntuples(res)-1:
for i in 0..pqntuples(res)-1:
setRow(res, result, i, L)
yield result
PQclear(res)
pqclear(res)
proc getRow*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
## retrieves a single row. If the query doesn't return any rows, this proc
## will return a TRow with empty strings for each column.
var res = setupQuery(db, query, args)
var L = PQnfields(res)
var L = pqnfields(res)
result = newRow(L)
setRow(res, result, 0, L)
PQclear(res)
pqclear(res)
proc getAllRows*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): seq[TRow] {.tags: [FReadDB].} =
## executes the query and returns the whole result dataset.
result = @[]
for r in FastRows(db, query, args):
for r in fastRows(db, query, args):
result.add(r)
iterator rows*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): TRow {.tags: [FReadDB].} =
## same as `FastRows`, but slower and safe.
for r in items(GetAllRows(db, query, args)): yield r
## same as `fastRows`, but slower and safe.
for r in items(getAllRows(db, query, args)): yield r
proc getValue*(db: TDbConn, query: TSqlQuery,
args: varargs[string, `$`]): string {.tags: [FReadDB].} =
## executes the query and returns the first column of the first row of the
## result dataset. Returns "" if the dataset contains no rows or the database
## value is NULL.
var x = PQgetvalue(setupQuery(db, query, args), 0, 0)
var x = pqgetvalue(setupQuery(db, query, args), 0, 0)
result = if isNil(x): "" else: $x
proc tryInsertID*(db: TDbConn, query: TSqlQuery,
@@ -145,10 +145,10 @@ proc tryInsertID*(db: TDbConn, query: TSqlQuery,
## generated ID for the row or -1 in case of an error. For Postgre this adds
## ``RETURNING id`` to the query, so it only works if your primary key is
## named ``id``.
var x = PQgetvalue(setupQuery(db, TSqlQuery(string(query) & " RETURNING id"),
var x = pqgetvalue(setupQuery(db, TSqlQuery(string(query) & " RETURNING id"),
args), 0, 0)
if not isNil(x):
result = ParseBiggestInt($x)
result = parseBiggestInt($x)
else:
result = -1
@@ -158,7 +158,7 @@ proc insertID*(db: TDbConn, query: TSqlQuery,
## generated ID for the row. For Postgre this adds
## ``RETURNING id`` to the query, so it only works if your primary key is
## named ``id``.
result = TryInsertID(db, query, args)
result = tryInsertID(db, query, args)
if result < 0: dbError(db)
proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
@@ -167,14 +167,14 @@ proc execAffectedRows*(db: TDbConn, query: TSqlQuery,
## executes the query (typically "UPDATE") and returns the
## number of affected rows.
var q = dbFormat(query, args)
var res = PQExec(db, q)
if PQresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
result = parseBiggestInt($PQcmdTuples(res))
PQclear(res)
var res = pqExec(db, q)
if pqresultStatus(res) != PGRES_COMMAND_OK: dbError(db)
result = parseBiggestInt($pqcmdTuples(res))
pqclear(res)
proc close*(db: TDbConn) {.tags: [FDb].} =
## closes the database connection.
if db != nil: PQfinish(db)
if db != nil: pqfinish(db)
proc open*(connection, user, password, database: string): TDbConn {.
tags: [FDb].} =
@@ -195,7 +195,7 @@ proc open*(connection, user, password, database: string): TDbConn {.
##
## Note that the connection parameter is not used but exists to maintain
## the nim db api.
result = PQsetdbLogin(nil, nil, nil, nil, database, user, password)
if PQStatus(result) != CONNECTION_OK: dbError(result) # result = nil
result = pqsetdbLogin(nil, nil, nil, nil, database, user, password)
if pqStatus(result) != CONNECTION_OK: dbError(result) # result = nil

View File

@@ -1,63 +0,0 @@
#
#
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## This module contains simple high-level procedures for dealing with the
## web. Use cases:
##
## * requesting URLs
## * sending and retrieving emails
## * sending and retrieving files from an FTP server
##
## Currently only requesting URLs is implemented. The implementation depends
## on the libcurl library!
##
## **Deprecated since version 0.8.8:** Use the
## `httpclient <httpclient.html>`_ module instead.
##
{.deprecated.}
import libcurl, streams
proc curlwrapperWrite(p: pointer, size, nmemb: int,
data: pointer): int {.cdecl.} =
var stream = cast[PStream](data)
stream.writeData(p, size*nmemb)
return size*nmemb
proc URLretrieveStream*(url: string): PStream =
## retrieves the given `url` and returns a stream which one can read from to
## obtain the contents. Returns nil if an error occurs.
result = newStringStream()
var hCurl = easy_init()
if hCurl == nil: return nil
if easy_setopt(hCurl, OPT_URL, url) != E_OK: return nil
if easy_setopt(hCurl, OPT_WRITEFUNCTION,
curlwrapperWrite) != E_OK: return nil
if easy_setopt(hCurl, OPT_WRITEDATA, result) != E_OK: return nil
if easy_perform(hCurl) != E_OK: return nil
easy_cleanup(hCurl)
proc URLretrieveString*(url: string): TaintedString =
## retrieves the given `url` and returns the contents. Returns nil if an
## error occurs.
var stream = newStringStream()
var hCurl = easy_init()
if hCurl == nil: return
if easy_setopt(hCurl, OPT_URL, url) != E_OK: return
if easy_setopt(hCurl, OPT_WRITEFUNCTION,
curlwrapperWrite) != E_OK: return
if easy_setopt(hCurl, OPT_WRITEDATA, stream) != E_OK: return
if easy_perform(hCurl) != E_OK: return
easy_cleanup(hCurl)
result = stream.data.TaintedString
when isMainModule:
echo URLretrieveString("http://nim-code.org/")

View File

@@ -22,8 +22,6 @@
##
## run(handleRequest, TPort(80))
##
## **Warning:** The API of this module is unstable, and therefore is subject
## to change.
import parseutils, strutils, os, osproc, strtabs, streams, sockets, asyncio
@@ -90,14 +88,14 @@ proc serveFile*(client: TSocket, filename: string) =
headers(client, filename)
const bufSize = 8000 # != 8K might be good for memory manager
var buf = alloc(bufsize)
while True:
while true:
var bytesread = readBuffer(f, buf, bufsize)
if bytesread > 0:
var byteswritten = send(client, buf, bytesread)
if bytesread != bytesWritten:
dealloc(buf)
close(f)
OSError(OSLastError())
raiseOSError(osLastError())
if bytesread != bufSize: break
dealloc(buf)
close(f)
@@ -228,9 +226,9 @@ proc open*(s: var TServer, port = TPort(80), reuseAddr = false) =
## creates a new server at port `port`. If ``port == 0`` a free port is
## acquired that can be accessed later by the ``port`` proc.
s.socket = socket(AF_INET)
if s.socket == InvalidSocket: OSError(OSLastError())
if s.socket == invalidSocket: raiseOSError(osLastError())
if reuseAddr:
s.socket.setSockOpt(OptReuseAddr, True)
s.socket.setSockOpt(OptReuseAddr, true)
bindAddr(s.socket, port)
listen(s.socket)
@@ -238,7 +236,7 @@ proc open*(s: var TServer, port = TPort(80), reuseAddr = false) =
s.port = getSockName(s.socket)
else:
s.port = port
s.client = InvalidSocket
s.client = invalidSocket
s.reqMethod = ""
s.body = ""
s.path = ""
@@ -346,7 +344,7 @@ proc next*(s: var TServer) =
# XXX we ignore "HTTP/1.1" etc. for now here
var query = 0
var last = i
while last < data.len and data[last] notin whitespace:
while last < data.len and data[last] notin Whitespace:
if data[last] == '?' and query == 0: query = last
inc(last)
if query > 0:
@@ -466,7 +464,7 @@ proc nextAsync(s: PAsyncHTTPServer) =
# XXX we ignore "HTTP/1.1" etc. for now here
var query = 0
var last = i
while last < data.len and data[last] notin whitespace:
while last < data.len and data[last] notin Whitespace:
if data[last] == '?' and query == 0: query = last
inc(last)
if query > 0:
@@ -483,7 +481,7 @@ proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: TSo
## Creates an Asynchronous HTTP server at ``port``.
var capturedRet: PAsyncHTTPServer
new(capturedRet)
capturedRet.asyncSocket = AsyncSocket()
capturedRet.asyncSocket = asyncSocket()
capturedRet.asyncSocket.handleAccept =
proc (s: PAsyncSocket) =
nextAsync(capturedRet)
@@ -491,7 +489,7 @@ proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: TSo
capturedRet.query)
if quit: capturedRet.asyncSocket.close()
if reuseAddr:
capturedRet.asyncSocket.setSockOpt(OptReuseAddr, True)
capturedRet.asyncSocket.setSockOpt(OptReuseAddr, true)
capturedRet.asyncSocket.bindAddr(port, address)
capturedRet.asyncSocket.listen()
@@ -500,7 +498,7 @@ proc asyncHTTPServer*(handleRequest: proc (server: PAsyncHTTPServer, client: TSo
else:
capturedRet.port = port
capturedRet.client = InvalidSocket
capturedRet.client = invalidSocket
capturedRet.reqMethod = ""
capturedRet.body = ""
capturedRet.path = ""

View File

@@ -729,7 +729,7 @@ type
len*: int # output length pointer
is_null*: Pmy_bool # Pointer to null indicator
buffer*: pointer # buffer to get/put data
error*: pmy_bool # set this if you want to track data truncations happened during fetch
error*: PMy_bool # set this if you want to track data truncations happened during fetch
buffer_type*: Tenum_field_types # buffer type
buffer_length*: int # buffer length, must be set for str/binary
# Following are for internal use. Set by mysql_stmt_bind_param
@@ -904,7 +904,7 @@ proc shutdown*(MySQL: PMySQL, shutdown_level: Tenum_shutdown_level): cint{.stdca
dynlib: lib, importc: "mysql_shutdown".}
proc dump_debug_info*(MySQL: PMySQL): cint{.stdcall, dynlib: lib,
importc: "mysql_dump_debug_info".}
proc refresh*(MySQL: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib,
proc refresh*(sql: PMySQL, refresh_options: cuint): cint{.stdcall, dynlib: lib,
importc: "mysql_refresh".}
proc kill*(MySQL: PMySQL, pid: int): cint{.stdcall, dynlib: lib, importc: "mysql_kill".}
proc set_server_option*(MySQL: PMySQL, option: Tenum_mysql_set_option): cint{.stdcall,
@@ -1040,7 +1040,7 @@ const
NO_DATA* = 100
DATA_TRUNCATED* = 101
proc reload*(MySQL: PMySQL): cint
proc reload*(x: PMySQL): cint
when defined(USE_OLD_FUNCTIONS):
proc connect*(MySQL: PMySQL, host: cstring, user: cstring, passwd: cstring): PMySQL{.stdcall,
dynlib: lib, importc: "mysql_connect".}
@@ -1059,7 +1059,7 @@ proc IS_NOT_NULL(n: int32): bool =
proc IS_BLOB(n: int32): bool =
result = (n and BLOB_FLAG) != 0
proc IS_NUM_FIELD(f: pst_mysql_field): bool =
proc IS_NUM_FIELD(f: Pst_mysql_field): bool =
result = (f.flags and NUM_FLAG) != 0
proc IS_NUM(t: Tenum_field_types): bool =
@@ -1071,7 +1071,7 @@ proc INTERNAL_NUM_FIELD(f: Pst_mysql_field): bool =
((f.ftype != FIELD_TYPE_TIMESTAMP) or (f.len == 14) or (f.len == 8)) or
(f.ftype == FIELD_TYPE_YEAR)
proc reload(mysql: PMySQL): cint =
result = refresh(mysql, REFRESH_GRANT)
proc reload(x: PMySQL): cint =
result = refresh(x, REFRESH_GRANT)
{.pop.}

View File

@@ -145,182 +145,182 @@ type
p*: pointer
proc PQconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
proc pqconnectStart*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
importc: "PQconnectStart".}
proc PQconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
proc pqconnectPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
dynlib: dllName, importc: "PQconnectPoll".}
proc PQconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
proc pqconnectdb*(conninfo: cstring): PPGconn{.cdecl, dynlib: dllName,
importc: "PQconnectdb".}
proc PQsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
proc pqsetdbLogin*(pghost: cstring, pgport: cstring, pgoptions: cstring,
pgtty: cstring, dbName: cstring, login: cstring, pwd: cstring): PPGconn{.
cdecl, dynlib: dllName, importc: "PQsetdbLogin".}
proc PQsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn
proc PQfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
proc PQconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
proc pqsetdb*(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): Ppgconn
proc pqfinish*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQfinish".}
proc pqconndefaults*(): PPQconninfoOption{.cdecl, dynlib: dllName,
importc: "PQconndefaults".}
proc PQconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
proc pqconninfoFree*(connOptions: PPQconninfoOption){.cdecl, dynlib: dllName,
importc: "PQconninfoFree".}
proc PQresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqresetStart*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQresetStart".}
proc PQresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
proc pqresetPoll*(conn: PPGconn): PostgresPollingStatusType{.cdecl,
dynlib: dllName, importc: "PQresetPoll".}
proc PQreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
proc PQrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqreset*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQreset".}
proc pqrequestCancel*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQrequestCancel".}
proc PQdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
proc PQuser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
proc PQpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".}
proc PQhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
proc PQport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
proc PQtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
proc PQoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
proc pqdb*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQdb".}
proc pquser*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQuser".}
proc pqpass*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQpass".}
proc pqhost*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQhost".}
proc pqport*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQport".}
proc pqtty*(conn: PPGconn): cstring{.cdecl, dynlib: dllName, importc: "PQtty".}
proc pqoptions*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
importc: "PQoptions".}
proc PQstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName,
proc pqstatus*(conn: PPGconn): TConnStatusType{.cdecl, dynlib: dllName,
importc: "PQstatus".}
proc PQtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
proc pqtransactionStatus*(conn: PPGconn): PGTransactionStatusType{.cdecl,
dynlib: dllName, importc: "PQtransactionStatus".}
proc PQparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
proc pqparameterStatus*(conn: PPGconn, paramName: cstring): cstring{.cdecl,
dynlib: dllName, importc: "PQparameterStatus".}
proc PQprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqprotocolVersion*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQprotocolVersion".}
proc PQerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
proc pqerrorMessage*(conn: PPGconn): cstring{.cdecl, dynlib: dllName,
importc: "PQerrorMessage".}
proc PQsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqsocket*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQsocket".}
proc PQbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqbackendPID*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQbackendPID".}
proc PQclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqclientEncoding*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQclientEncoding".}
proc PQsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
proc pqsetClientEncoding*(conn: PPGconn, encoding: cstring): int32{.cdecl,
dynlib: dllName, importc: "PQsetClientEncoding".}
when defined(USE_SSL):
# Get the SSL structure associated with a connection
proc PQgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
proc pqgetssl*(conn: PPGconn): PSSL{.cdecl, dynlib: dllName,
importc: "PQgetssl".}
proc PQsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
proc pqsetErrorVerbosity*(conn: PPGconn, verbosity: PGVerbosity): PGVerbosity{.
cdecl, dynlib: dllName, importc: "PQsetErrorVerbosity".}
proc PQtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName,
proc pqtrace*(conn: PPGconn, debug_port: TFile){.cdecl, dynlib: dllName,
importc: "PQtrace".}
proc PQuntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
proc PQsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
proc pquntrace*(conn: PPGconn){.cdecl, dynlib: dllName, importc: "PQuntrace".}
proc pqsetNoticeReceiver*(conn: PPGconn, theProc: PQnoticeReceiver, arg: pointer): PQnoticeReceiver{.
cdecl, dynlib: dllName, importc: "PQsetNoticeReceiver".}
proc PQsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
proc pqsetNoticeProcessor*(conn: PPGconn, theProc: PQnoticeProcessor,
arg: pointer): PQnoticeProcessor{.cdecl,
dynlib: dllName, importc: "PQsetNoticeProcessor".}
proc PQexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
proc pqexec*(conn: PPGconn, query: cstring): PPGresult{.cdecl, dynlib: dllName,
importc: "PQexec".}
proc PQexecParams*(conn: PPGconn, command: cstring, nParams: int32,
proc pqexecParams*(conn: PPGconn, command: cstring, nParams: int32,
paramTypes: POid, paramValues: cstringArray,
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
cdecl, dynlib: dllName, importc: "PQexecParams".}
proc PQexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
proc pqexecPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
paramValues: cstringArray,
paramLengths, paramFormats: ptr int32, resultFormat: int32): PPGresult{.
cdecl, dynlib: dllName, importc: "PQexecPrepared".}
proc PQsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
proc pqsendQuery*(conn: PPGconn, query: cstring): int32{.cdecl, dynlib: dllName,
importc: "PQsendQuery".}
proc PQsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
proc pqsendQueryParams*(conn: PPGconn, command: cstring, nParams: int32,
paramTypes: POid, paramValues: cstringArray,
paramLengths, paramFormats: ptr int32,
resultFormat: int32): int32{.cdecl, dynlib: dllName,
importc: "PQsendQueryParams".}
proc PQsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
proc pqsendQueryPrepared*(conn: PPGconn, stmtName: cstring, nParams: int32,
paramValues: cstringArray,
paramLengths, paramFormats: ptr int32,
resultFormat: int32): int32{.cdecl, dynlib: dllName,
importc: "PQsendQueryPrepared".}
proc PQgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
proc pqgetResult*(conn: PPGconn): PPGresult{.cdecl, dynlib: dllName,
importc: "PQgetResult".}
proc PQisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqisBusy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQisBusy".}
proc PQconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqconsumeInput*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQconsumeInput".}
proc PQnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
proc pqnotifies*(conn: PPGconn): PPGnotify{.cdecl, dynlib: dllName,
importc: "PQnotifies".}
proc PQputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
proc pqputCopyData*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.
cdecl, dynlib: dllName, importc: "PQputCopyData".}
proc PQputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
proc pqputCopyEnd*(conn: PPGconn, errormsg: cstring): int32{.cdecl,
dynlib: dllName, importc: "PQputCopyEnd".}
proc PQgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
proc pqgetCopyData*(conn: PPGconn, buffer: cstringArray, async: int32): int32{.
cdecl, dynlib: dllName, importc: "PQgetCopyData".}
proc PQgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
proc pqgetline*(conn: PPGconn, str: cstring, len: int32): int32{.cdecl,
dynlib: dllName, importc: "PQgetline".}
proc PQputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
proc pqputline*(conn: PPGconn, str: cstring): int32{.cdecl, dynlib: dllName,
importc: "PQputline".}
proc PQgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
proc pqgetlineAsync*(conn: PPGconn, buffer: cstring, bufsize: int32): int32{.
cdecl, dynlib: dllName, importc: "PQgetlineAsync".}
proc PQputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
proc pqputnbytes*(conn: PPGconn, buffer: cstring, nbytes: int32): int32{.cdecl,
dynlib: dllName, importc: "PQputnbytes".}
proc PQendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqendcopy*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQendcopy".}
proc PQsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
proc pqsetnonblocking*(conn: PPGconn, arg: int32): int32{.cdecl,
dynlib: dllName, importc: "PQsetnonblocking".}
proc PQisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
proc pqisnonblocking*(conn: PPGconn): int32{.cdecl, dynlib: dllName,
importc: "PQisnonblocking".}
proc PQflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
proc PQfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
proc pqflush*(conn: PPGconn): int32{.cdecl, dynlib: dllName, importc: "PQflush".}
proc pqfn*(conn: PPGconn, fnid: int32, result_buf, result_len: ptr int32,
result_is_int: int32, args: PPQArgBlock, nargs: int32): PPGresult{.
cdecl, dynlib: dllName, importc: "PQfn".}
proc PQresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName,
proc pqresultStatus*(res: PPGresult): TExecStatusType{.cdecl, dynlib: dllName,
importc: "PQresultStatus".}
proc PQresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName,
proc pqresStatus*(status: TExecStatusType): cstring{.cdecl, dynlib: dllName,
importc: "PQresStatus".}
proc PQresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
proc pqresultErrorMessage*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
importc: "PQresultErrorMessage".}
proc PQresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
proc pqresultErrorField*(res: PPGresult, fieldcode: int32): cstring{.cdecl,
dynlib: dllName, importc: "PQresultErrorField".}
proc PQntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
proc pqntuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
importc: "PQntuples".}
proc PQnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
proc pqnfields*(res: PPGresult): int32{.cdecl, dynlib: dllName,
importc: "PQnfields".}
proc PQbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
proc pqbinaryTuples*(res: PPGresult): int32{.cdecl, dynlib: dllName,
importc: "PQbinaryTuples".}
proc PQfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
proc pqfname*(res: PPGresult, field_num: int32): cstring{.cdecl,
dynlib: dllName, importc: "PQfname".}
proc PQfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
proc pqfnumber*(res: PPGresult, field_name: cstring): int32{.cdecl,
dynlib: dllName, importc: "PQfnumber".}
proc PQftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
proc pqftable*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
importc: "PQftable".}
proc PQftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
proc pqftablecol*(res: PPGresult, field_num: int32): int32{.cdecl,
dynlib: dllName, importc: "PQftablecol".}
proc PQfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
proc pqfformat*(res: PPGresult, field_num: int32): int32{.cdecl,
dynlib: dllName, importc: "PQfformat".}
proc PQftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
proc pqftype*(res: PPGresult, field_num: int32): Oid{.cdecl, dynlib: dllName,
importc: "PQftype".}
proc PQfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
proc pqfsize*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
importc: "PQfsize".}
proc PQfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
proc pqfmod*(res: PPGresult, field_num: int32): int32{.cdecl, dynlib: dllName,
importc: "PQfmod".}
proc PQcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
proc pqcmdStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
importc: "PQcmdStatus".}
proc PQoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
proc pqoidStatus*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
importc: "PQoidStatus".}
proc PQoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
proc pqoidValue*(res: PPGresult): Oid{.cdecl, dynlib: dllName,
importc: "PQoidValue".}
proc PQcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
proc pqcmdTuples*(res: PPGresult): cstring{.cdecl, dynlib: dllName,
importc: "PQcmdTuples".}
proc PQgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
proc pqgetvalue*(res: PPGresult, tup_num: int32, field_num: int32): cstring{.
cdecl, dynlib: dllName, importc: "PQgetvalue".}
proc PQgetlength*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
proc pqgetlength*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
cdecl, dynlib: dllName, importc: "PQgetlength".}
proc PQgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
proc pqgetisnull*(res: PPGresult, tup_num: int32, field_num: int32): int32{.
cdecl, dynlib: dllName, importc: "PQgetisnull".}
proc PQclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
proc PQfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
proc PQmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{.
proc pqclear*(res: PPGresult){.cdecl, dynlib: dllName, importc: "PQclear".}
proc pqfreemem*(p: pointer){.cdecl, dynlib: dllName, importc: "PQfreemem".}
proc pqmakeEmptyPGresult*(conn: PPGconn, status: TExecStatusType): PPGresult{.
cdecl, dynlib: dllName, importc: "PQmakeEmptyPGresult".}
proc PQescapeString*(till, `from`: cstring, len: int): int{.cdecl,
proc pqescapeString*(till, `from`: cstring, len: int): int{.cdecl,
dynlib: dllName, importc: "PQescapeString".}
proc PQescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
proc pqescapeBytea*(bintext: cstring, binlen: int, bytealen: var int): cstring{.
cdecl, dynlib: dllName, importc: "PQescapeBytea".}
proc PQunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl,
proc pqunescapeBytea*(strtext: cstring, retbuflen: var int): cstring{.cdecl,
dynlib: dllName, importc: "PQunescapeBytea".}
proc PQprint*(fout: TFile, res: PPGresult, ps: PPQprintOpt){.cdecl,
proc pqprint*(fout: TFile, res: PPGresult, ps: PPQprintOpt){.cdecl,
dynlib: dllName, importc: "PQprint".}
proc PQdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32,
proc pqdisplayTuples*(res: PPGresult, fp: TFile, fillAlign: int32,
fieldSep: cstring, printHeader: int32, quiet: int32){.
cdecl, dynlib: dllName, importc: "PQdisplayTuples".}
proc PQprintTuples*(res: PPGresult, fout: TFile, printAttName: int32,
proc pqprintTuples*(res: PPGresult, fout: TFile, printAttName: int32,
terseOutput: int32, width: int32){.cdecl, dynlib: dllName,
importc: "PQprintTuples".}
proc lo_open*(conn: PPGconn, lobjId: Oid, mode: int32): int32{.cdecl,
@@ -343,8 +343,8 @@ proc lo_import*(conn: PPGconn, filename: cstring): Oid{.cdecl, dynlib: dllName,
importc: "lo_import".}
proc lo_export*(conn: PPGconn, lobjId: Oid, filename: cstring): int32{.cdecl,
dynlib: dllName, importc: "lo_export".}
proc PQmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
proc pqmblen*(s: cstring, encoding: int32): int32{.cdecl, dynlib: dllName,
importc: "PQmblen".}
proc PQenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
proc PQsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): ppgconn =
result = PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")
proc pqenv2encoding*(): int32{.cdecl, dynlib: dllName, importc: "PQenv2encoding".}
proc pqsetdb(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME: cstring): PPgConn =
result = pqSetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, "", "")

View File

@@ -88,8 +88,8 @@ const
SQLITE_REINDEX* = 27
SQLITE_DENY* = 1
SQLITE_IGNORE* = 2 # Original from sqlite3.h:
##define SQLITE_STATIC ((void(*)(void *))0)
##define SQLITE_TRANSIENT ((void(*)(void *))-1)
#define SQLITE_STATIC ((void(*)(void *))0)
#define SQLITE_TRANSIENT ((void(*)(void *))-1)
SQLITE_DETERMINISTIC* = 0x800
const

View File

@@ -42,8 +42,11 @@ News
and is now a Nimble package.
- Many wrappers have been moved into their own repositories and are now
Nimble packages including ``lua``, ``opengl``, ``x11``, ``nim-zmq``,
``gtk2``, ``mongo``, ``cairo``, ``tcl`` and ``python``. They can be
``gtk2``, ``mongo``, ``cairo``, ``tcl``, ``python`` and
`more <https://github.com/Araq/Nimrod/issues/623>`_. They can be
found under the `nim-code <https://github.com/nimrod-code>`_ organisation.
- Removed the deprecated ``web`` module, the ``httpclient`` module should
be used instead.
Language Additions
------------------

View File

@@ -39,7 +39,7 @@ UNIX. We don't believe this to be a coincidence. - Jeremy S. Anderson."""
doc: "endb;intern;apis;lib;manual;tut1;tut2;nimc;overview;filters"
doc: "tools;niminst;nimgrep;gc;estp;idetools;docgen;koch;backends.txt"
pdf: "manual;lib;tut1;tut2;nimc;niminst;gc"
srcdoc2: "system.nim;impure/graphics;wrappers/sdl"
srcdoc2: "system.nim"
srcdoc2: "core/macros;pure/marshal;core/typeinfo;core/unsigned"
srcdoc2: "impure/re;pure/sockets;pure/typetraits"
srcdoc: "system/threads.nim;system/channels.nim;js/dom"
@@ -47,7 +47,7 @@ srcdoc2: "pure/os;pure/strutils;pure/math;pure/matchers;pure/algorithm"
srcdoc2: "pure/complex;pure/times;pure/osproc;pure/pegs;pure/dynlib"
srcdoc2: "pure/parseopt;pure/parseopt2;pure/hashes;pure/strtabs;pure/lexbase"
srcdoc2: "pure/parsecfg;pure/parsexml;pure/parsecsv;pure/parsesql"
srcdoc2: "pure/streams;pure/terminal;pure/cgi;impure/web;pure/unicode"
srcdoc2: "pure/streams;pure/terminal;pure/cgi;pure/unicode"
srcdoc2: "impure/zipfiles;pure/htmlgen;pure/parseutils;pure/browsers"
srcdoc2: "impure/db_postgres;impure/db_mysql;impure/db_sqlite"
srcdoc2: "pure/httpserver;pure/httpclient;pure/smtp;impure/ssl;pure/fsmonitor"
@@ -67,14 +67,14 @@ srcdoc2: "pure/rawsockets;pure/asynchttpserver;pure/net;pure/selectors;pure/futu
srcdoc2: "wrappers/expat;wrappers/readline/history"
srcdoc2: "wrappers/libsvm.nim;wrappers/libuv"
srcdoc2: "wrappers/zip/zlib;wrappers/zip/libzip"
srcdoc2: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
srcdoc2: "pure/md5;wrappers/mysql;wrappers/iup"
srcdoc2: "posix/posix;wrappers/odbcsql"
srcdoc2: "wrappers/tre;wrappers/openssl;wrappers/pcre"
srcdoc2: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
srcdoc2: "wrappers/readline/readline;wrappers/readline/rltypedefs"
srcdoc2: "wrappers/joyent_http_parser"
webdoc: "wrappers/libcurl;pure/md5;wrappers/mysql;wrappers/iup"
webdoc: "pure/md5;wrappers/mysql;wrappers/iup"
webdoc: "wrappers/sqlite3;wrappers/postgres;wrappers/tinyc"
webdoc: "wrappers/expat;wrappers/pcre"
webdoc: "wrappers/tre;wrappers/openssl"