24 #include <sys/queue.h>
25 #include <sys/types.h>
31 #define DEFAULT_FREQUENCY_THRESHOLD 100
32 #define DEFAULT_CONDITIONAL_PROBABILITY_THRESHOLD 0.2
41 vfprintf(stderr, format, l);
42 r = fprintf(stderr,
"\n");
64 switch ((pid = fork())) {
71 fprintf(stderr,
"%d\n", pid);
75 int null_fd = open(
"/dev/null", O_RDWR, 0);
80 if (null_fd > 2) { close(null_fd); }
87 atouint64_t(
const char *s)
90 for (r = 0; *s; s++) {
99 struct evkeyvalq *get_args,
100 const char **query,
const char **types,
101 const char **client_id,
const char **target_name,
102 const char **learn_target_name,
103 const char **callback,
105 int *frequency_threshold,
106 double *conditional_probability_threshold,
108 grn_obj *pass_through_parameters)
110 struct evkeyval *
get;
112 if (query) { *query = NULL; }
113 if (types) { *types = NULL; }
114 if (client_id) { *client_id = NULL; }
115 if (target_name) { *target_name = NULL; }
116 if (learn_target_name) { *learn_target_name = NULL; }
117 if (callback) { *callback = NULL; }
118 if (millisec) { *millisec = 0; }
119 if (frequency_threshold) {
122 if (conditional_probability_threshold) {
125 if (limit) { *limit = -1; }
127 TAILQ_FOREACH(
get, get_args, next) {
131 key_length = strlen(
get->key);
132 switch (key_length) {
136 switch(
get->key[0]) {
150 *client_id =
get->value;
155 *millisec = atouint64_t(
get->value);
161 *target_name =
get->value;
165 if (learn_target_name) {
166 *learn_target_name =
get->value;
170 if (frequency_threshold) {
171 *frequency_threshold = atoi(
get->value);
175 if (conditional_probability_threshold) {
176 *conditional_probability_threshold = strtod(
get->value, NULL);
181 *limit = atoi(
get->value);
185 is_pass_through_parameter =
GRN_TRUE;
190 switch (
get->key[0]) {
192 if (!strcmp(
get->key,
"callback")) {
194 *callback =
get->value;
197 is_pass_through_parameter =
GRN_TRUE;
201 is_pass_through_parameter =
GRN_TRUE;
205 if (is_pass_through_parameter && pass_through_parameters) {
212 get->value, strlen(
get->value));