eee535bf55589b6af3a81490f34e1e758c10a419
[m6w6/ext-pq] / src / php_pq_misc.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: pq |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2013, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13
14 #ifndef PHP_PQ_ERROR_H
15 #define PHP_PQ_ERROR_H
16
17 #include <libpq-fe.h>
18
19 #if PHP_VERSION_ID < 50500
20 #undef SUCCESS
21 #undef FAILURE
22 typedef enum {
23 SUCCESS = 0,
24 FAILURE = -1
25 } ZEND_RESULT_CODE;
26 #endif
27
28 #include "php_pqres.h"
29
30 /* clear result object associated with a result handle */
31 extern void php_pqres_clear(PGresult *r);
32 /* clear any asynchronous results */
33 extern void php_pqconn_clear(PGconn *conn);
34 /* safe wrappers to clear any asynchronous wrappers before querying synchronously */
35 extern PGresult *php_pq_exec(PGconn *conn, const char *query);
36 extern PGresult *php_pq_exec_params(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const * paramValues, const int *paramLengths, const int *paramFormats, int resultFormat);
37 extern PGresult *php_pq_prepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes);
38 extern PGresult *php_pq_exec_prepared(PGconn *conn, const char *stmtName, int nParams, const char *const * paramValues, const int *paramLengths, const int *paramFormats, int resultFormat);
39
40 /* TSRM morony */
41 #if PHP_VERSION_ID >= 50700
42 # define z_is_true(z) zend_is_true(z TSRMLS_CC)
43 #else
44 # define z_is_true zend_is_true
45 #endif
46
47 /* trim LF from EOL */
48 extern char *php_pq_rtrim(char *e);
49
50 /* R, W, RW */
51 extern const char *php_pq_strmode(long mode);
52
53 /* compare array index */
54 extern int php_pq_compare_index(const void *lptr, const void *rptr TSRMLS_DC);
55
56 #define PHP_PQerrorMessage(c) php_pq_rtrim(PQerrorMessage((c)))
57 #define PHP_PQresultErrorMessage(r) php_pq_rtrim(PQresultErrorMessage((r)))
58
59 extern zend_class_entry *php_pqdt_class_entry;
60 extern zval *php_pqdt_from_string(zval *zv, char *input_fmt, char *dt_str, size_t dt_len, char *output_fmt, zval *ztimezone TSRMLS_DC);
61 extern void php_pqdt_to_string(zval *zdt, const char *format, char **str_buf, size_t *str_len TSRMLS_DC);
62
63 extern zend_class_entry *php_pqconv_class_entry;
64
65 extern HashTable *php_pq_parse_array(php_pqres_t *res, const char *val_str, size_t val_len, Oid typ TSRMLS_DC);
66
67
68 extern PHP_MINIT_FUNCTION(pq_misc);
69
70 #endif
71
72 /*
73 * Local variables:
74 * tab-width: 4
75 * c-basic-offset: 4
76 * End:
77 * vim600: noet sw=4 ts=4 fdm=marker
78 * vim<600: noet sw=4 ts=4
79 */