93 lines
2.5 KiB
C
93 lines
2.5 KiB
C
/*
|
|
Copyright (C) 2004, Wolfgang Hottgenroth
|
|
|
|
This file is part of smmapdfw.
|
|
|
|
smmapdfw is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
smmapdfw is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with smmapdfw. If not, write to the Free Software Foundation, 59
|
|
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <syslog.h>
|
|
|
|
#include <libpq-fe.h>
|
|
|
|
#include <containers_public.h>
|
|
|
|
#include "htmalloc.h"
|
|
#include "smmapd.h"
|
|
|
|
|
|
int pg_worker_init(cfgl_t *cfg, void **handle);
|
|
int pg_worker_destroy(void *handle);
|
|
int pg_worker_work_setup(void *handle, void **work_handle);
|
|
int pg_worker_work_destroy(void *handle, void *work_handle);
|
|
int pg_worker_work(void *handle, void *work_handle, char *input, char *output);
|
|
|
|
class_descriptor_t pgworker = {
|
|
"pgworker",
|
|
&pg_worker_init,
|
|
&pg_worker_destroy,
|
|
&pg_worker_work_setup,
|
|
&pg_worker_work,
|
|
&pg_worker_work_destroy
|
|
};
|
|
|
|
|
|
typedef struct pg_container_handle_s {
|
|
int counter;
|
|
} pg_container_handle_t;
|
|
|
|
typedef struct pg_worker_handle_s {
|
|
int counter;
|
|
} pg_worker_handle_t;
|
|
|
|
|
|
|
|
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;
|
|
*handle = pch;
|
|
return 0;
|
|
}
|
|
|
|
int pg_worker_destroy(void *handle) {
|
|
pg_container_handle_t *pch = (pg_container_handle_t*)handle;
|
|
free(pch);
|
|
return 0;
|
|
}
|
|
|
|
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;
|
|
*work_handle = pwh;
|
|
return 0;
|
|
}
|
|
|
|
int pg_worker_work_destroy(void *handle, void *work_handle) {
|
|
syslog(LOG_DEBUG, "pg_worker_destroy: freeing the worker handle");
|
|
free(work_handle);
|
|
}
|
|
|
|
int pg_worker_work(void *handle, void *work_handle, char *input, char *output) {
|
|
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++);
|
|
return SMM_OK;
|
|
}
|
|
|
|
|
|
|