aboutsummaryrefslogtreecommitdiff
path: root/src/meta.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-02-17 18:36:54 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-02-17 18:36:54 +0200
commit317095181674a01651602ddf6817e888d0ad5280 (patch)
treeda9a84a50223918408dfb578813c6fb098c1870c /src/meta.c
parent3277cd4abfa20e8b2499f052a6eb3792d8aa6cce (diff)
downloadwydawca-317095181674a01651602ddf6817e888d0ad5280.tar.gz
wydawca-317095181674a01651602ddf6817e888d0ad5280.tar.bz2
Begin rewriting method system
* src/builtin.c, src/builtin.h: New files. * src/Makefile.am (wydawca_SOURCES): Add builtin.c and builtin.h * src/config.c: New keyword access-method.query * src/update-2.0.awk: Update. * src/meta.c: Remove quote_string (replaced by method_quote_string). (meta_escape): Add `handle' argument. * src/method.c (struct method_descr): New methods: open, close, quote. Updated methods: free, run, get. All callers updated. (method_quote_string): New function. * src/process.c (scan_directory_pair): Init all access methods at once. * src/sql.c: Take name of the SQL connection from method->parmv[0]. Adapt to changes to the method subsystem. * src/sql.h: Likewise. * src/wydawca.h (struct access_method): New members id, parmc, parmv, storage. Remove union v. (meta_escape): Take 3 arguments. (method_new): Take 2 arguments. (method_open, method_close, method_quote_string): New proto. (method_run, method_result): Change signature. * src/mail.c, src/triplet.c, src/verify.c * etc/wydawca.rc: Update.
Diffstat (limited to 'src/meta.c')
-rw-r--r--src/meta.c43
1 files changed, 4 insertions, 39 deletions
diff --git a/src/meta.c b/src/meta.c
index 4516df2..eb51a78 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -115,52 +115,17 @@ meta_expand_string (const char *string, struct metadef *def, void *data)
return res;
}
-/* Quote non-printable characters in INPUT. Point *OUTPUT to the malloc'ed
- quoted string. Return its length. */
-static size_t
-quote_string (struct access_method *method, const char *input, char **poutput)
-{
- size_t size, len;
- int quote;
- char *output;
-
- if (!input)
- {
- *poutput = xmalloc (1);
- (*poutput)[0] = 0;
- return 1;
- }
-
- switch (method->type)
- {
- case method_sql:
- len = strlen (input);
- size = 2 * len + 1;
- output = xmalloc (size);
- mysql_real_escape_string (&method->v.sqlconn->mysql, output, input, len);
- size = strlen (output);
- break;
-
- default:
- size = argcv_quoted_length (input, &quote);
- output = xmalloc (size);
- argcv_quote_copy (output, input);
- break;
- }
-
- *poutput = output;
- return size;
-}
-
void
-meta_escape (struct access_method *method, struct metadef *def)
+meta_escape (struct access_method *method, void *handle, struct metadef *def)
{
for (; def->kw; def++)
{
if (def->value)
{
char *newval;
- quote_string (method, def->value, &newval);
+
+ /* FIXME: Return value? */
+ method_quote_string (method, handle, def->value, &newval, NULL);
if (def->storage)
free (def->storage);
def->value = def->storage = newval;

Return to:

Send suggestions and report system problems to the System administrator.