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

Definition at line 403 of file dis_old.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, 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().

404 {
405  register SERVICE *new_serv;
406  register int service_id;
407  char str[512];
409  DIS_DNS_CONN *dnsp;
410  extern DIS_DNS_CONN *dis_find_dns(long);
411 
412  dis_init();
413  {
414  DISABLE_AST
415  if(!check_service_name(name))
416  {
417  strcpy(str,"Command name too long: ");
418  strcat(str,name);
420  ENABLE_AST
421  return((unsigned) 0);
422  }
423  if( find_service(name) )
424  {
425  ENABLE_AST
426  return((unsigned) 0);
427  }
428  new_serv = (SERVICE *)malloc(sizeof(SERVICE));
429  strncpy(new_serv->name, name, MAX_NAME);
430  if(type != (char *)0)
431  {
432  if( !get_format_data(new_serv->format_data, type))
433  {
434  ENABLE_AST
435  return((unsigned) 0);
436  }
437  strcpy(new_serv->def,type);
438  }
439  else
440  {
441  new_serv->format_data[0].par_bytes = 0;
442  new_serv->def[0] = '\0';
443  }
444  new_serv->type = COMMAND;
445  new_serv->address = 0;
446  new_serv->size = 0;
447  if(user_routine)
448  new_serv->user_routine = user_routine;
449  else
450  new_serv->user_routine = std_cmnd_handler;
451  new_serv->tag = tag;
452  new_serv->tid = 0;
453  new_serv->registered = 0;
454  new_serv->quality = 0;
455  new_serv->user_secs = 0;
456  new_serv->delay_delete = 0;
457  new_serv->to_delete = 0;
458  service_id = id_get((void *)new_serv, SRC_DIS);
459  new_serv->id = service_id;
460  dnsp = dis_find_dns(dnsid);
461  if(!dnsp)
462  dnsp = create_dns(dnsid);
463  new_serv->dnsp = dnsp;
464  new_serv->request_head = (REQUEST *)malloc(sizeof(REQUEST));
465  dll_init( (DLL *) (new_serv->request_head) );
466  dis_hash_service_insert(new_serv);
467 /*
468  Dis_n_services++;
469 */
470  dnsp->dis_n_services++;
471  ENABLE_AST
472  }
473  return((unsigned) service_id);
474 }
#define MAX_NAME
Definition: dim.h:182
DIS_DNS_CONN * dnsp
Definition: dis.c:87
unsigned service_id
Definition: db_dim_client.c:22
static int get_format_data(FORMAT_STR *format_data, char *def)
Definition: dis_old.c:533
int to_delete
Definition: dis.c:89
int dis_hash_service_insert(SERVICE *servp)
Definition: dis_old.c:2879
#define COMMAND
Definition: dim_common.h:10
char str[80]
Definition: test_client.c:7
DIS_DNS_CONN * dis_find_dns(long dnsid)
Definition: dis_old.c:2962
int registered
Definition: dis.c:81
char name[MAX_NAME]
Definition: dis.c:72
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
void std_cmnd_handler(long *tag, int *cmnd_buff, int *size)
Definition: dis_old.c:2426
short par_bytes
Definition: dim.h:218
FORMAT_STR format_data[MAX_NAME/4]
Definition: dis.c:76
static void dis_init()
Definition: dis_old.c:216
#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
void(* user_routine)()
Definition: dis.c:79
SERVICE * find_service(char *name)
Definition: dis_old.c:2143
static void error_handler(int conn_id, int severity, int errcode, char *reason)
Definition: dis_old.c:2827
int * address
Definition: dis.c:77
static int check_service_name(char *name)
Definition: dis_old.c:209
char def[MAX_NAME]
Definition: dis.c:75
int id_get(void *ptr, SRC_TYPES type)
Definition: conn_handler.c:152
int size
Definition: dis.c:78
int tid
Definition: dis.c:85
dnsid
Definition: README_v19.txt:372
Definition: dis.c:52
static DIS_DNS_CONN * create_dns(long dnsid)
Definition: dis_old.c:957
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: