changes
This commit is contained in:
parent
8ce1196012
commit
2ae47fca0b
@ -47,10 +47,15 @@ class_descriptor_t pgworker = {
|
||||
|
||||
typedef struct pg_container_handle_s {
|
||||
int counter;
|
||||
cfgl_t *cfg;
|
||||
char *sql_statement;
|
||||
char *input_delimiter;
|
||||
char *output_format_string;
|
||||
} pg_container_handle_t;
|
||||
|
||||
typedef struct pg_worker_handle_s {
|
||||
int counter;
|
||||
pg_container_handle_t *pch;
|
||||
} pg_worker_handle_t;
|
||||
|
||||
|
||||
@ -58,6 +63,10 @@ typedef struct pg_worker_handle_s {
|
||||
int pg_worker_init(cfgl_t *cfg, void **handle) {
|
||||
pg_container_handle_t *pch = (pg_container_handle_t*)htmalloc(sizeof(pg_container_handle_t));
|
||||
pch->counter = 0;
|
||||
pch->cfg = cfg;
|
||||
pch->sql_statement = findcfgl(pch->cfg, "sql_statement");
|
||||
pch->input_delimiter = findcfgl(pch->cfg, "input_delimiter");
|
||||
pch->output_format_string = findcfgl(pch->cfg, "output_format_string", "$0");
|
||||
*handle = pch;
|
||||
return 0;
|
||||
}
|
||||
@ -71,6 +80,7 @@ int pg_worker_destroy(void *handle) {
|
||||
int pg_worker_work_setup(void *handle, void **work_handle) {
|
||||
pg_worker_handle_t *pwh = (pg_worker_handle_t*)htmalloc(sizeof(pg_worker_handle_t));
|
||||
pwh->counter = 0;
|
||||
pwh->pch = handle;
|
||||
*work_handle = pwh;
|
||||
return 0;
|
||||
}
|
||||
@ -81,12 +91,62 @@ int pg_worker_work_destroy(void *handle, void *work_handle) {
|
||||
}
|
||||
|
||||
int pg_worker_work(void *handle, void *work_handle, char *input, char *output) {
|
||||
int res;
|
||||
pg_container_handle_t *pch = (pg_container_handle_t*) handle;
|
||||
pg_worker_handle_t *pwh = (pg_worker_handle_t*) work_handle;
|
||||
|
||||
sprintf(output, "pg-worker receives %s (pch %p, pwh %p) (called %d)\n",
|
||||
input, pch, pwh, pwh->counter++);
|
||||
|
||||
res = process(pwh, input, output);
|
||||
|
||||
return SMM_OK;
|
||||
}
|
||||
|
||||
int process(pg_worker_handle_t *pwh, char *input, char *output) {
|
||||
/* pwh->pch->psql_statement is something like
|
||||
SELECT m.mailRoutingAddress
|
||||
FROM mailAddress_t m,
|
||||
domain_t d
|
||||
WHERE m.address = $1 AND
|
||||
d.name = $2 AND
|
||||
d.id = m.domain
|
||||
*/
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
A:
|
||||
- An instance of the pgworker will get an SQL-statement.
|
||||
- The SQL-statement may contain multiple parameter.
|
||||
- A separator token to be used in the input from sendmail will be defined.
|
||||
- The SQL-statement contains one result parameter.
|
||||
- A cache file can be defined.
|
||||
|
||||
B:
|
||||
- Multiple instances of the pgworker will get exactly the same SQL-statement.
|
||||
- The SQL-statement may contain multiple parameter.
|
||||
- A separator token to be used in the input from sendmail will be defined.
|
||||
- The SQL-statement contains multiple result parameters, usually as many
|
||||
as instances are using it.
|
||||
- A position argument to identify the result parameter for the particular
|
||||
instance will be defined.
|
||||
- If a cache file should be used, the same cache file can be used of instances
|
||||
using the same SQL-statement.
|
||||
|
||||
C:
|
||||
- As B, but for each instance a list of position arguments can be given
|
||||
to return multiple output results.
|
||||
- A separator token for the different result items must be given.
|
||||
|
||||
D:
|
||||
- As C, but instead of a separator token a format string must be given.
|
||||
|
||||
E:
|
||||
- As D, but instead of given output positions in a separate list, the position
|
||||
numbers will be used directly in the format string.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user