FACT++  1.0
static unsigned do_dis_add_service_dns ( char *  name,
char *  type,
void *  address,
int  size,
void(*)()  user_routine,
long  tag,
long  dnsid 
)
static

Definition at line 229 of file dis_old.c.

References serv::address, check_service_name(), create_dns(), serv::def, serv::delay_delete, DIM_ERROR, DIMSVCDUPLC, DIMSVCFORMT, 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, Memory::free(), 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, size, serv::size, SRC_DIS, str, serv::tag, serv::tid, serv::to_delete, serv::type, user_routine(), serv::user_routine, and serv::user_secs.

Referenced by dis_add_service_dns(), dis_start_serving_dns(), and do_dis_add_service().

231 {
232  register SERVICE *new_serv;
233  register int service_id;
234  char str[512];
236  DIS_DNS_CONN *dnsp;
237  extern DIS_DNS_CONN *dis_find_dns(long);
238 
239  dis_init();
240  {
241  DISABLE_AST
242  if(!check_service_name(name))
243  {
244  strcpy(str,"Service name too long: ");
245  strcat(str,name);
247  ENABLE_AST
248  return((unsigned) 0);
249  }
250  if( find_service(name) )
251  {
252  strcpy(str,"Duplicate Service: ");
253  strcat(str,name);
255  ENABLE_AST
256  return((unsigned) 0);
257  }
258  new_serv = (SERVICE *)malloc( sizeof(SERVICE) );
259  strncpy( new_serv->name, name, MAX_NAME );
260  if(type != (char *)0)
261  {
262  if (strlen(type) >= MAX_NAME)
263  {
264  strcpy(str,"Format String Too Long: ");
265  strcat(str,name);
267  free(new_serv);
268  ENABLE_AST
269  return((unsigned) 0);
270  }
271  if (! get_format_data(new_serv->format_data, type))
272  {
273  strcpy(str,"Bad Format String: ");
274  strcat(str,name);
276  free(new_serv);
277  ENABLE_AST
278  return((unsigned) 0);
279  }
280  strcpy(new_serv->def,type);
281  }
282  else
283  {
284  new_serv->format_data[0].par_bytes = 0;
285  new_serv->def[0] = '\0';
286  }
287  new_serv->type = 0;
288  new_serv->address = (int *)address;
289  new_serv->size = size;
290  new_serv->user_routine = user_routine;
291  new_serv->tag = tag;
292  new_serv->registered = 0;
293  new_serv->quality = 0;
294  new_serv->user_secs = 0;
295  new_serv->tid = 0;
296  new_serv->delay_delete = 0;
297  new_serv->to_delete = 0;
298  dnsp = dis_find_dns(dnsid);
299  if(!dnsp)
300  dnsp = create_dns(dnsid);
301  new_serv->dnsp = dnsp;
302  service_id = id_get((void *)new_serv, SRC_DIS);
303  new_serv->id = service_id;
304  new_serv->request_head = (REQUEST *)malloc(sizeof(REQUEST));
305  dll_init( (DLL *) (new_serv->request_head) );
306  dis_hash_service_insert(new_serv);
307 /*
308  Dis_n_services++;
309 */
310  dnsp->dis_n_services++;
311  ENABLE_AST
312  }
313  return((unsigned)service_id);
314 }
#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
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
#define DIMSVCFORMT
Definition: dim_common.h:289
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
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
#define DIMSVCDUPLC
Definition: dim_common.h:288
void(* user_routine)()
Definition: dis.c:79
SERVICE * find_service(char *name)
Definition: dis_old.c:2143
int size
Definition: db_dim_server.c:17
static void error_handler(int conn_id, int severity, int errcode, char *reason)
Definition: dis_old.c:2827
int * address
Definition: dis.c:77
void free(void *mem)
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: