00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __RXV_SPIN_H__
00022 #define __RXV_SPIN_H__
00023
00070 #define RXV_SPIN_STDC_HEADERS 1
00071 #define RXV_SPIN_HAVE_UNISTD_H 1
00072 #define RXV_SPIN_HAVE_SYS_TYPES_H 1
00073 #define RXV_SPIN_HAVE_APR_STRINGS_H 1
00074 #define RXV_SPIN_HAVE_APR_POOLS_H 1
00075 #define RXV_SPIN_HAVE_APR_HASH_H 1
00076 #define RXV_SPIN_HAVE_APR_TIME_H 1
00077 #define RXV_SPIN_HAVE_APR_DSO_H 1
00078 #define RXV_SPIN_HAVE_APR_BUCKETS_H 1
00079 #define RXV_SPIN_HAVE_APR_DBD_H 1
00080 #define RXV_SPIN_HAVE_APREQ_PARAM_H 1
00081 #define RXV_SPIN_HAVE_APREQ_COOKIE_H 1
00082 #define RXV_SPIN_HAVE_APREQ_MODULE_H 1
00083 #define RXV_SPIN_HAVE_HTTPD_H 1
00084 #define RXV_SPIN_HAVE_HTTP_REQUEST_H 1
00085 #define RXV_SPIN_HAVE_AP_REGEX_H 1
00086
00087 #include <stdio.h>
00088 #if RXV_SPIN_STDC_HEADERS
00089 #include <stdlib.h>
00090 #include <stddef.h>
00091 #include <stdarg.h>
00092 #include <string.h>
00093 #endif
00094 #if RXV_SPIN_HAVE_UNISTD_H
00095 #include <unistd.h>
00096 #endif
00097 #if RXV_SPIN_HAVE_SYS_TYPES_H
00098 #include <sys/types.h>
00099 #endif
00100
00101 #if RXV_SPIN_HAVE_APR_STRINGS_H
00102 #include <apr_strings.h>
00103 #endif
00104 #if RXV_SPIN_HAVE_APR_POOLS_H
00105 #include <apr_pools.h>
00106 #endif
00107 #if RXV_SPIN_HAVE_APR_HASH_H
00108 #include <apr_hash.h>
00109 #endif
00110 #if RXV_SPIN_HAVE_APR_TIME_H
00111 #include <apr_time.h>
00112 #endif
00113 #if RXV_SPIN_HAVE_APR_DSO_H
00114 #include <apr_dso.h>
00115 #endif
00116 #if RXV_SPIN_HAVE_APR_BUCKETS_H
00117 #include <apr_buckets.h>
00118 #endif
00119 #if RXV_SPIN_HAVE_APR_DBD_H
00120 #include <apr_dbd.h>
00121 #endif
00122
00123 #if RXV_SPIN_HAVE_APREQ_PARAM_H
00124 #include <apreq_param.h>
00125 #endif
00126 #if RXV_SPIN_HAVE_APREQ_COOKIE_H
00127 #include <apreq_cookie.h>
00128 #endif
00129 #if RXV_SPIN_HAVE_APREQ_MODULE_H
00130 #include <apreq_module.h>
00131 #endif
00132
00133
00134 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00135 #undef PACKAGE_BUGREPORT
00136 #undef PACKAGE_NAME
00137 #undef PACKAGE_STRING
00138 #undef PACKAGE_TARNAME
00139 #undef PACKAGE_VERSION
00140 #endif
00141
00142 #if RXV_SPIN_HAVE_HTTPD_H
00143 #include <httpd.h>
00144 #endif
00145
00146
00147 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00148 #undef PACKAGE_BUGREPORT
00149 #undef PACKAGE_NAME
00150 #undef PACKAGE_STRING
00151 #undef PACKAGE_TARNAME
00152 #undef PACKAGE_VERSION
00153 #define PACKAGE_BUGREPORT RXV_SPIN_PACKAGE_BUGREPORT
00154 #define PACKAGE_NAME RXV_SPIN_PACKAGE_NAME
00155 #define PACKAGE_STRING RXV_SPIN_PACKAGE_STRING
00156 #define PACKAGE_TARNAME RXV_SPIN_PACKAGE_TARNAME
00157 #define PACKAGE_VERSION RXV_SPIN_PACKAGE_VERSION
00158 #endif
00159
00160 #if RXV_SPIN_HAVE_HTTP_REQUEST_H
00161 #include <http_request.h>
00162 #endif
00163 #if RXV_SPIN_HAVE_AP_REGEX_H
00164 #include <ap_regex.h>
00165 #endif
00166
00174 typedef enum{
00175 RXV_SPIN_TRIM_LEFT=1,
00176 RXV_SPIN_TRIM_RIGHT
00177 } rxv_spin_trim_e;
00178
00179 typedef struct rxv_spin_data rxv_spin_data_t;
00180 typedef struct rxv_spin_curs rxv_spin_curs_t;
00191 typedef struct rxv_spin_ctx rxv_spin_ctx_t;
00200
00201
00217 rxv_spin_data_t *rxv_spin_datum(apr_pool_t *pool,const char *str,
00218 rxv_spin_data_t *data);
00219
00241 rxv_spin_data_t *rxv_spin_mdatum(apr_pool_t *pool,const char *str,
00242 apr_size_t size,rxv_spin_data_t *data);
00243
00254 char *rxv_spin_string(rxv_spin_data_t *single);
00255
00275 apr_hash_t *rxv_spin_guts(rxv_spin_data_t *rows);
00276
00288 apr_size_t rxv_spin_size(rxv_spin_data_t *data);
00289
00290 #define rxv_spin_multi(d) (!rxv_spin_string(d) && rxv_spin_size(d)>0)
00291
00292 #define rxv_spin_single(d) (!rxv_spin_multi(d))
00293
00314 rxv_spin_data_t *rxv_spin_column(apr_pool_t *pool,const char *name,
00315 rxv_spin_data_t *data,...)
00316 #if defined(__GNUC__) && __GNUC__ >= 4
00317 __attribute__((sentinel))
00318 #endif
00319 ;
00320
00344 rxv_spin_data_t *rxv_spin_parse(apr_pool_t *pool,const char *name,
00345 char *str,const char *sep,
00346 rxv_spin_data_t *data);
00347
00364 rxv_spin_data_t *rxv_spin_brigade(apr_pool_t *pool,const char *name,
00365 apr_bucket_brigade *bb,
00366 rxv_spin_data_t *data);
00367
00384 rxv_spin_data_t *rxv_spin_null(apr_pool_t *pool,const char *name,
00385 apr_size_t size,rxv_spin_data_t *data);
00386
00407 rxv_spin_data_t *rxv_spin_rows(apr_pool_t *pool,rxv_spin_data_t *data,...)
00408 #if defined(__GNUC__) && __GNUC__ >= 4
00409 __attribute__((sentinel))
00410 #endif
00411 ;
00412
00428 apr_size_t rxv_spin_first(apr_pool_t *pool,rxv_spin_data_t *rows,...)
00429 #if defined(__GNUC__) && __GNUC__ >= 4
00430 __attribute__((sentinel))
00431 #endif
00432 ;
00433
00449 apr_size_t rxv_spin_next(rxv_spin_curs_t *curs);
00450
00461 rxv_spin_data_t *rxv_spin_this(rxv_spin_curs_t *curs);
00462
00475 rxv_spin_data_t *rxv_spin_entry(rxv_spin_data_t *rows,const char *name,
00476 apr_size_t index);
00477
00496 rxv_spin_data_t *rxv_spin_resize(rxv_spin_data_t *data,apr_size_t size);
00497
00517 rxv_spin_data_t *rxv_spin_copy(apr_pool_t *pool,rxv_spin_data_t *src,
00518 rxv_spin_data_t *data);
00519
00531 char *rxv_spin_slower(const char *str);
00532
00544 char *rxv_spin_supper(const char *str);
00545
00559 char *rxv_spin_strim(const char *str,rxv_spin_trim_e what);
00560 #define rxv_spin_strim2(s) \
00561 rxv_spin_strim((s),(RXV_SPIN_TRIM_LEFT|RXV_SPIN_TRIM_RIGHT))
00562
00563 #define rxv_spin_striml(s) \
00564 rxv_spin_strim((s),(RXV_SPIN_TRIM_LEFT))
00565
00566 #define rxv_spin_strimr(s) \
00567 rxv_spin_strim((s),(RXV_SPIN_TRIM_RIGHT))
00568
00570 #define rxv_spin_lower(s) \
00571 ((s)?(rxv_spin_single(s) \
00572 ?rxv_spin_datum(NULL,rxv_spin_slower(rxv_spin_string(s)),(s)) \
00573 :NULL) \
00574 :NULL)
00575
00576 #define rxv_spin_upper(s) \
00577 ((s)?(rxv_spin_single(s) \
00578 ?rxv_spin_datum(NULL,rxv_spin_supper(rxv_spin_string(s)),(s)) \
00579 :NULL) \
00580 :NULL)
00581
00582 #define rxv_spin_trim(s,w) \
00583 ((s)?(rxv_spin_single(s) \
00584 ?rxv_spin_datum(NULL,rxv_spin_strim(rxv_spin_string(s),(w)),(s)) \
00585 :NULL) \
00586 :NULL)
00587
00588 #define rxv_spin_trim2(s) \
00589 rxv_spin_trim((s),(RXV_SPIN_TRIM_LEFT|RXV_SPIN_TRIM_RIGHT))
00590
00591 #define rxv_spin_triml(s) \
00592 rxv_spin_trim((s),(RXV_SPIN_TRIM_LEFT))
00593
00594 #define rxv_spin_trimr(s) \
00595 rxv_spin_trim((s),(RXV_SPIN_TRIM_RIGHT))
00596
00605
00606
00617 apr_pool_t *rxv_spin_pool(rxv_spin_ctx_t *ctx);
00618
00629 apr_pool_t *rxv_spin_ppool(rxv_spin_ctx_t *ctx);
00630
00641 rxv_spin_data_t *rxv_spin_data(rxv_spin_ctx_t *ctx);
00642
00653 request_rec *rxv_spin_r(rxv_spin_ctx_t *ctx);
00654
00665 apreq_handle_t *rxv_spin_req(rxv_spin_ctx_t *ctx);
00666
00677 void *rxv_spin_xget(rxv_spin_ctx_t *ctx);
00678
00690 void *rxv_spin_xset(rxv_spin_ctx_t *ctx,void *extra);
00691
00703 rxv_spin_data_t *rxv_spin_get(rxv_spin_ctx_t *ctx,const char *key);
00704 #define rxv_spin_sget(ctx,key) \
00705 rxv_spin_string(rxv_spin_get((ctx),(key)))
00706
00736 rxv_spin_data_t *rxv_spin_set(rxv_spin_ctx_t *ctx,
00737 const char *key,rxv_spin_data_t *value);
00738 #define rxv_spin_sset(ctx,key,val) \
00739 rxv_spin_set((ctx),(key),rxv_spin_datum(rxv_spin_pool(ctx),(val),NULL))
00740
00741 #define rxv_spin_del(ctx,key) rxv_spin_set((ctx),(key),NULL)
00742
00746
00747
00766 rxv_spin_data_t *rxv_spin_app_get(rxv_spin_ctx_t *ctx,const char *key);
00767 #define rxv_spin_app_sget(ctx,key) \
00768 rxv_spin_string(rxv_spin_app_get((ctx),(key)))
00769
00789 rxv_spin_data_t *rxv_spin_app_set(rxv_spin_ctx_t *ctx,
00790 const char *key,rxv_spin_data_t *val);
00791 #define rxv_spin_app_sset(ctx,key,val) \
00792 rxv_spin_app_set((ctx),(key),rxv_spin_datum(rxv_spin_pool(ctx),(val),NULL))
00793
00807 apr_status_t rxv_spin_app_del(rxv_spin_ctx_t *ctx,const char *key);
00808
00820 rxv_spin_data_t *rxv_spin_ses_get(rxv_spin_ctx_t *ctx,const char *key);
00821 #define rxv_spin_ses_sget(ctx,key) \
00822 rxv_spin_string(rxv_spin_ses_get((ctx),(key)))
00823
00843 rxv_spin_data_t *rxv_spin_ses_set(rxv_spin_ctx_t *ctx,
00844 const char *key,rxv_spin_data_t *val);
00845 #define rxv_spin_ses_sset(ctx,key,val) \
00846 rxv_spin_ses_set((ctx),(key),rxv_spin_datum(rxv_spin_pool(ctx),(val),NULL))
00847
00861 apr_status_t rxv_spin_ses_del(rxv_spin_ctx_t *ctx,const char *key);
00862
00876 void rxv_spin_ses_kill(rxv_spin_ctx_t *ctx);
00877
00894 char *rxv_spin_ses_id(rxv_spin_ctx_t *ctx);
00895
00911 int rxv_spin_ses_valid(rxv_spin_ctx_t *ctx);
00912
00923 apr_time_t rxv_spin_ses_atime(rxv_spin_ctx_t *ctx);
00924
00927 typedef struct rxv_spin_db rxv_spin_db_t;
00928 typedef struct rxv_spin_db_txn rxv_spin_db_txn_t;
00947 apr_pool_t *rxv_spin_db_pool(rxv_spin_db_t *db);
00948
00959 char *rxv_spin_db_cinfo(rxv_spin_db_t *db);
00960
00971 const apr_dbd_driver_t *rxv_spin_db_driver(rxv_spin_db_t *db);
00972
00983 apr_dbd_t *rxv_spin_db_handle(rxv_spin_db_t *db);
00984
00997 apr_dbd_transaction_t *rxv_spin_db_txn(rxv_spin_db_txn_t *txn);
00998
01021 rxv_spin_db_t *rxv_spin_db_open(rxv_spin_ctx_t *ctx,const char *conninfo);
01022
01034 apr_status_t rxv_spin_db_close(rxv_spin_ctx_t *ctx,rxv_spin_db_t *db);
01035
01051 apr_status_t rxv_spin_db_status(rxv_spin_ctx_t *ctx,rxv_spin_db_t *db);
01052
01067 rxv_spin_data_t *rxv_spin_db_data(apr_pool_t *pool,rxv_spin_db_t *db,
01068 apr_dbd_results_t *dbdres);
01069
01084 rxv_spin_data_t *rxv_spin_db_select(apr_pool_t *pool,rxv_spin_db_t *db,
01085 const char *query);
01086
01099 int rxv_spin_db_query(apr_pool_t *pool,rxv_spin_db_t *db,const char *query);
01100
01126 rxv_spin_data_t *rxv_spin_db_pselect(apr_pool_t *pool,rxv_spin_db_t *db,
01127 const char *query,...)
01128 #if defined(__GNUC__) && __GNUC__ >= 4
01129 __attribute__((sentinel))
01130 #endif
01131 ;
01132
01158 int rxv_spin_db_pquery(apr_pool_t *pool,rxv_spin_db_t *db,
01159 const char *query,...)
01160 #if defined(__GNUC__) && __GNUC__ >= 4
01161 __attribute__((sentinel))
01162 #endif
01163 ;
01164
01180 rxv_spin_db_txn_t *rxv_spin_db_start(apr_pool_t *pool,rxv_spin_db_t *db);
01181
01192 apr_status_t rxv_spin_db_end(rxv_spin_db_txn_t *txn);
01193
01214 void *rxv_spin_conn_get(rxv_spin_ctx_t *ctx,const char *conninfo);
01215
01250 void *rxv_spin_conn_set(rxv_spin_ctx_t *ctx,
01251 const char *conninfo,void *conn,
01252 apr_status_t (*cleanup)(void *data));
01253
01263 typedef void (*rxv_spin_init_t)(rxv_spin_ctx_t *ctx);
01265 typedef int (*rxv_spin_prepare_t)(rxv_spin_ctx_t *ctx);
01267 typedef int (*rxv_spin_service_t)(rxv_spin_ctx_t *ctx);
01272
01273
01295 apr_status_t rxv_spin_dso_load(rxv_spin_ctx_t *ctx,const char *path,
01296 apr_dso_handle_t **handle);
01297
01318 char *rxv_spin_hash(apr_pool_t *pool,const char *uniq);
01319
01332 char *rxv_spin_hmac(apr_pool_t *pool,const char *uniq,const char *salt);
01333
01336 #endif