FACT++  1.0
static unsigned do_dis_add_cmnd_dns ( char *  name,
char *  type,
void(*)()  user_routine,
dim_long  tag,
dim_long  dnsid 
)
static

Definition at line 413 of file dis.c.

References serv::address, check_service_name(), COMMAND, create_dns(), serv::def, serv::delay_delete, DIM_ERROR, DIMSVCTOOLG, dis_find_dns(), dis_hash_service_insert(), dis_init(), dis_dns_ent::dis_n_services, dll_init(), serv::dnsp, error_handler(), find_service(), serv::format_data, get_format_data(), serv::id, id_get(), Memory::malloc(), MAX_NAME, serv::name, FORMAT_STR::par_bytes, serv::quality, serv::registered, serv::request_head, service_id, Serving, serv::size, SRC_DIS, std_cmnd_handler(), str, serv::tag, serv::tid, serv::to_delete, serv::type, user_routine(), serv::user_routine, and serv::user_secs.

Referenced by dis_add_cmnd_dns(), dis_start_serving_dns(), and do_dis_add_cmnd().

414 {
415  register SERVICE *new_serv;
416  register int service_id;
417  char str[512];
419  DIS_DNS_CONN *dnsp;
421 
422  dis_init();
423  {
424  DISABLE_AST
425  if(Serving == -1)
426  {
427  ENABLE_AST
428  return((unsigned) 0);
429  }
430  if(!check_service_name(name))
431  {
432  strcpy(str,"Command name too long: ");
433  strcat(str,name);
434  error_handler(0, DIM_ERROR, DIMSVCTOOLG, str, -1);
435  ENABLE_AST
436  return((unsigned) 0);
437  }
438  if( find_service(name) )
439  {
440  ENABLE_AST
441  return((unsigned) 0);
442  }
443  new_serv = (SERVICE *)malloc(sizeof(SERVICE));
444  strncpy(new_serv->name, name, (size_t)MAX_NAME);
445  if(type != (char *)0)
446  {
447  if( !get_format_data(new_serv->format_data, type))
448  {
449  ENABLE_AST
450  return((unsigned) 0);
451  }
452  strcpy(new_serv->def,type);
453  }
454  else
455  {
456  new_serv->format_data[0].par_bytes = 0;
457  new_serv->def[0] = '\0';
458  }
459  new_serv->type = COMMAND;
460  new_serv->address = 0;
461  new_serv->size = 0;
462  if(user_routine)
463  new_serv->user_routine = user_routine;
464  else
465  new_serv->user_routine = std_cmnd_handler;
466  new_serv->tag = tag;
467  new_serv->tid = 0;
468  new_serv->registered = 0;
469  new_serv->quality = 0;
470  new_serv->user_secs = 0;
471  new_serv->delay_delete = 0;
472  new_serv->to_delete = 0;
473  service_id = id_get((void *)new_serv, SRC_DIS);
474  new_serv->id = service_id;
475  dnsp = dis_find_dns(dnsid);
476  if(!dnsp)
477  dnsp = create_dns(dnsid);
478  new_serv->dnsp = dnsp;
479  new_serv->request_head = (REQUEST *)malloc(sizeof(REQUEST));
480  dll_init( (DLL *) (new_serv->request_head) );
481  dis_hash_service_insert(new_serv);
482 /*
483  Dis_n_services++;
484 */
485  dnsp->dis_n_services++;
486  ENABLE_AST
487  }
488  return((unsigned) service_id);
489 }
#define MAX_NAME
Definition: dim.h:182
static void error_handler(int conn_id, int severity, int errcode, char *reason, int exit)
Definition: dis.c:3199
DIS_DNS_CONN * dnsp
Definition: dis.c:87
unsigned service_id
Definition: db_dim_client.c:22
int to_delete
Definition: dis.c:89
#define COMMAND
Definition: dim_common.h:10
char str[80]
Definition: test_client.c:7
void std_cmnd_handler(dim_long *tag, int *cmnd_buff, int *size)
Definition: dis.c:2736
int registered
Definition: dis.c:81
char name[MAX_NAME]
Definition: dis.c:72
int dis_hash_service_insert(SERVICE *servp)
Definition: dis.c:3259
SERVICE * find_service(char *name)
Definition: dis.c:2429
void * malloc()
Definition: EventBuilder.cc:99
int type
Definition: dis.c:74
int dis_n_services
Definition: dis.c:43
void dll_init(DLL *head)
Definition: dll.c:14
dim_long tag
Definition: dis.c:80
short par_bytes
Definition: dim.h:218
FORMAT_STR format_data[MAX_NAME/4]
Definition: dis.c:76
#define DIMSVCTOOLG
Definition: dim_common.h:291
Definition: dim.h:530
int delay_delete
Definition: dis.c:88
Definition: dis.c:69
int type
int user_secs
Definition: dis.c:83
REQUEST * request_head
Definition: dis.c:86
static DIS_DNS_CONN * create_dns(dim_long dnsid)
Definition: dis.c:1047
long dim_long
Definition: dim_common.h:57
DIS_DNS_CONN * dis_find_dns(dim_long dnsid)
Definition: dis.c:3360
void(* user_routine)()
Definition: dis.c:79
static int get_format_data(FORMAT_STR *format_data, char *def)
Definition: dis.c:548
static int check_service_name(char *name)
Definition: dis.c:213
int * address
Definition: dis.c:77
void dis_init()
Definition: dis.c:220
char def[MAX_NAME]
Definition: dis.c:75
int id_get(void *ptr, SRC_TYPES type)
Definition: conn_handler.c:152
static int Serving
Definition: dis.c:124
int size
Definition: dis.c:78
int tid
Definition: dis.c:85
dnsid
Definition: README_v19.txt:372
Definition: dis.c:52
static void user_routine(void *tagp, void *bufp, int *size)
Definition: diccpp.cxx:11
int quality
Definition: dis.c:82
int id
Definition: dis.c:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function: