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

Definition at line 234 of file dis.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, Serving, 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().

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