ObjectNode *op_DefFn (ExecuteHandler execute, Context *context, Node *node){ const char *func_name = node->childs[0].name; FunctionObj *fo = (FunctionObj *)malloc(sizeof(FunctionObj)); int starts_with = 1; if(strcmp(node->childs[1].name, "args") == 0){ fo->args_length = node->childs[1].childs_length; fo->args = (char **)malloc(sizeof(char *) * fo->args_length); for(int i = 0; i < fo->args_length; i++){ fo->args[i] = node->childs[1].childs[i].name; } starts_with = 2; } else{ fo->args_length = 0; fo->args = 0; } fo->context = context; fo->node_length = node->childs_length - starts_with; fo->nodes = malloc(sizeof(Node *) * fo->node_length); for(int i = starts_with; i < node->childs_length; i++) fo->nodes[i - starts_with] = &node->childs[i]; ObjectNode *tmp = newObjectNode(NTYPE_FUNC, (void *)fo); context_set(context, func_name, tmp); return newObjectNode(NTYPE_NONE, 0); }
ObjectNode *op_Alias (ExecuteHandler execute, Context *context, Node *node){ const char *func_name = node->childs[0].name; ObjectNode *tmp = context_get(context, node->childs[1].name); //(char *)newObjectNode(2, &node->childs[1]); context_set(context, func_name, tmp); return newObjectNode(NTYPE_NONE, 0); }
static int doit_v5 (const char *host, int port, const char *user, int passive_flag, int debug_flag, int keepalive_flag, int tcp_flag) { int ret; kx_context context; krb5_make_context (&context); context_set (&context, host, user, port, debug_flag, keepalive_flag, tcp_flag); ret = doit (&context, passive_flag); context_destroy (&context); return ret; }
void addOp(Context *context, char *token, OpHandler handler){ context_set(context, token, (void *) newObjectNode(NTYPE_BUILTIN_FUNC, handler)); }