Esempio n. 1
0
int enter_client_xlookup(struct katcp_dispatch *d, struct xlookup_entry *table)
{
  struct mul_client *ci;

  if(table == NULL){
    return -1;
  }

  ci = get_multi_katcp(d);
  if(ci == NULL){
    return -1;
  }

  if(ci->c_xlookup == NULL){
    ci->c_xlookup = create_xlookup();
    if(ci->c_xlookup == NULL){
      return -1;
    }
  }

  if(prepare_xlookup(ci->c_xlookup, table, NULL)){
    return -1;
  }

  continue_katcp(d, 0, &run_client_xlookup);

  return run_xlookup(ci, arg_count_katcp(d));
}
Esempio n. 2
0
struct kcs_sm_op *pushstack_setup_statemachine_kcs(struct katcp_dispatch *d, struct kcs_sm_state *s)
{
#define ARG_BASE 5
  struct katcp_type *t;
  struct katcp_tobject *o;
  struct kcs_sm_op *op;
  char **data, *type;
  void *ptemp, *stemp;
  int num, i;

  stemp = NULL;

  type = arg_string_katcp(d, 4);

  if (type == NULL || s == NULL)
    return NULL;
  
  t = find_name_type_katcp(d, type);
  if (t == NULL){
    log_message_katcp(d, KATCP_LEVEL_INFO, NULL, "invalid type: %s\n", type); 
    return NULL;
  }
  
  num = arg_count_katcp(d) - ARG_BASE;
  
  data = malloc(sizeof(char *) * (num + 1));
  if (data == NULL)
    return NULL;
  
  for (i=0; i<num; i++){
    data[i] = arg_string_katcp(d, ARG_BASE + i);
#ifdef DEBUG
    fprintf(stderr, "statemachine: pushsetup data[%d of %d]: %s\n", i+1, num, data[i]);
#endif
  }
  data[num] = NULL; 
  
#ifdef DEBUG
  fprintf(stderr, "statemachine: call type parse function\n");
#endif
  ptemp = (*t->t_parse)(d, data);
  
  if (data[0] != NULL)
    stemp = search_type_katcp(d, t, data[0], ptemp);

  free(data);

  if (ptemp == NULL){
#ifdef DEBUG
    fprintf(stderr, "statemachine: type parse fn failed\n");
#endif
    //return NULL;  
  }

  if (stemp == NULL){
#ifdef DEBUG
    fprintf(stderr, "statemachine: type search fn failed\n");
#endif
    (*t->t_free)(ptemp);
    return NULL;
  }

  o = create_tobject_katcp(stemp, t, 0);
  if (o == NULL){
    (*t->t_free)(stemp);
#ifdef DEBUG
    fprintf(stderr, "statemachine: pushsetup could not create stack obj\n");
#endif
    return NULL;
  }
  
  op = create_sm_op_kcs(&pushstack_statemachine_kcs, o);
  if (op == NULL){
    (*t->t_free)(stemp);
    destroy_tobject_katcp(o);
    return NULL;
  }

#ifdef DEBUG
  fprintf(stderr, "statemachine: pushsetup created op (%p)\n", op);
#endif

  return op;
#undef ARG_BASE
}