FACT++  1.0
int publishInt ( IntItem *  intItem)

Definition at line 3249 of file feeserver.c.

References add_int_item_node(), dis_add_service, findCharItem(), findIntItem(), findItem(), Memory::free(), id, Memory::malloc(), and sprintf().

3249  {
3250  unsigned int id;
3251  char* serviceName = 0;
3252 
3253  // check for right state
3254  if (state != COLLECTING) {
3255  return FEE_WRONG_STATE;
3256  }
3257 
3258  // Testing for NULL - Pointer
3259  // !! Attention: if pointer is not initialized and also NOT set to NULL, this won't help !!
3260  if (intItem == 0) {
3261 # ifdef __DEBUG
3262  printf("Bad intItem, not published\n");
3263  fflush(stdout);
3264 # endif
3265  return FEE_NULLPOINTER;
3266  }
3267  if (intItem->name == 0 || intItem->location == 0) {
3268 # ifdef __DEBUG
3269  printf("Bad intItem, not published\n");
3270  fflush(stdout);
3271 # endif
3272  return FEE_NULLPOINTER;
3273  }
3274 
3275  // Check name for duplicate here
3276  // Check in Float list
3277  if (findItem(intItem->name) != 0) {
3278 # ifdef __DEBUG
3279  printf("Item name already published in float list, int item discarded.\n");
3280  fflush(stdout);
3281 # endif
3282  return FEE_ITEM_NAME_EXISTS;
3283  }
3284  // Check in INT list
3285  if (findIntItem(intItem->name) != 0) {
3286 # ifdef __DEBUG
3287  printf("Item name already published in int list, new int item discarded.\n");
3288  fflush(stdout);
3289 # endif
3290  return FEE_ITEM_NAME_EXISTS;
3291  }
3292  // Check in Char service list
3293  if (findCharItem(intItem->name) != 0) {
3294 # ifdef __DEBUG
3295  printf("Item name already published in char list, int item discarded.\n");
3296  fflush(stdout);
3297 # endif
3298  return FEE_ITEM_NAME_EXISTS;
3299  }
3300 
3301 
3302  // -- add intItem as service --
3303  serviceName = (char*) malloc(serverNameLength + strlen(intItem->name) + 2);
3304  if (serviceName == 0) {
3305  return FEE_INSUFFICIENT_MEMORY;
3306  }
3307  // terminate string with '\0'
3308  serviceName[sprintf(serviceName, "%s_%s", serverName, intItem->name)] = 0;
3309  id = dis_add_service(serviceName, "I", (int*) intItem->location,
3310  sizeof(int), 0, 0);
3311  free(serviceName);
3312  add_int_item_node(id, intItem);
3313 
3314  return FEE_OK;
3315 }
ItemNode * findItem(char *name)
Definition: feeserver.c:3045
CharItemNode * findCharItem(char *name)
Definition: feeserver.c:4107
void * malloc()
Definition: EventBuilder.cc:99
char id[4]
Definition: FITS.h:71
static int serverNameLength
Definition: feeserver.c:189
void add_int_item_node(unsigned int _id, IntItem *_int_item)
Definition: feeserver.c:3317
static char * serverName
Definition: feeserver.c:183
void free(void *mem)
#define dis_add_service
Definition: dis.h:12
IntItemNode * findIntItem(char *name)
Definition: feeserver.c:3378
sprintf(name1,"NewService%d", i)

+ Here is the call graph for this function: