* The context pointer is assumed to refer to a client task structure that was
* initialized earlier by client_open().
*/
-static void client_pre_select(struct sched *s, void *context)
+static void client_pre_monitor(struct sched *s, void *context)
{
int ret;
struct client_task *ct = context;
for (i = 0; i < num_inputs; i++)
len += strlen(lls_input(i, ct->lpr)) + 1;
- p = command = para_malloc(len);
+ p = command = alloc(len);
for (i = 0; i < num_inputs; i++) {
const char *str = lls_input(i, ct->lpr);
strcpy(p, str);
return send_sb(ct, 0, command, len, SBD_COMMAND, false);
}
+/* Find out if the given string is contained in the features vector. */
static bool has_feature(const char *feature, struct client_task *ct)
{
- return find_arg(feature, ct->features) >= 0? true : false;
+ if (!ct->features)
+ return false;
+ for (int i = 0; ct->features[i]; i++)
+ if (strcmp(feature, ct->features[i]) == 0)
+ return i;
+ return false;
}
/*
* The context pointer refers to a client task structure that was initialized
* earlier by client_open().
*/
-static int client_post_select(struct sched *s, void *context)
+static int client_post_monitor(struct sched *s, void *context)
{
struct client_task *ct = context;
int ret = 0;
free(sbb.iov.iov_base);
if (ret < 0)
goto out;
- ct->challenge_hash = para_malloc(HASH2_SIZE);
-
+ ct->challenge_hash = alloc(HASH2_SIZE);
if (has_feature("sha256", ct)) {
hash2_function((char *)crypt_buf, APC_CHALLENGE_SIZE, ct->challenge_hash);
hash2_to_asc(ct->challenge_hash, buf);
ct->task = task_register(&(struct task_info) {
.name = "client",
- .pre_select = client_pre_select,
- .post_select = client_post_select,
+ .pre_monitor = client_pre_monitor,
+ .post_monitor = client_post_monitor,
.context = ct,
}, s);
return 1;
PARA_INFO_LOG("user: %s\n", user);
PARA_INFO_LOG("key file: %s\n", kf);
PARA_INFO_LOG("loglevel: %d\n", ll);
- ct = para_calloc(sizeof(*ct));
+ ct = zalloc(sizeof(*ct));
ct->scc.fd = -1;
ct->lpr = lpr;
ct->key_file = kf;