FACT++  1.0
int publishChar ( CharItem *  charItem)

— NEW FEATURE SINCE VERSION 0.8.2b [Char channel] (2007-07-28) — ///

Definition at line 3938 of file feeserver.c.

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

3938  {
3939  unsigned int id;
3940  char* serviceName = 0;
3941 
3942  // check for right state
3943  if (state != COLLECTING) {
3944  return FEE_WRONG_STATE;
3945  }
3946 
3947  // Testing for NULL - Pointer
3948  // !! Attention: if pointer is not initialized and also NOT set to NULL, this won't help !!
3949  if (charItem == 0) {
3950 # ifdef __DEBUG
3951  printf("Bad charItem, not published\n");
3952  fflush(stdout);
3953 # endif
3954  return FEE_NULLPOINTER;
3955  }
3956  if (charItem->name == 0 || charItem->user_routine == 0) {
3957 # ifdef __DEBUG
3958  printf("Bad charItem, not published\n");
3959  fflush(stdout);
3960 # endif
3961  return FEE_NULLPOINTER;
3962  }
3963 
3964  // Check name for duplicate here
3965  // Check in Float list
3966  if (findItem(charItem->name) != 0) {
3967 # ifdef __DEBUG
3968  printf("Item name already published in float list, char item discarded.\n");
3969  fflush(stdout);
3970 # endif
3971  return FEE_ITEM_NAME_EXISTS;
3972  }
3973  // Check in INT list
3974  if (findIntItem(charItem->name) != 0) {
3975 # ifdef __DEBUG
3976  printf("Item name already published in int list, char item discarded.\n");
3977  fflush(stdout);
3978 # endif
3979  return FEE_ITEM_NAME_EXISTS;
3980  }
3981  // Check in CHAR list
3982  if (findCharItem(charItem->name) != 0) {
3983 # ifdef __DEBUG
3984  printf("Item name already published in char list, new char item discarded.\n");
3985  fflush(stdout);
3986 # endif
3987  return FEE_ITEM_NAME_EXISTS;
3988  }
3989 
3990  // -- add charItem as service --
3991  serviceName = (char*) malloc(serverNameLength + strlen(charItem->name) + 2);
3992  if (serviceName == 0) {
3993  return FEE_INSUFFICIENT_MEMORY;
3994  }
3995  // terminate string with '\0'
3996  serviceName[sprintf(serviceName, "%s_%s", serverName, charItem->name)] = 0;
3997  // add service in DIM
3998  id = dis_add_service(serviceName, "C", 0, 0, charItem->user_routine,
3999  charItem->tag);
4000  free(serviceName);
4001 
4002  // !!! implement add_char_item_node() func !!!
4003  add_char_item_node(id, charItem);
4004 
4005  return FEE_OK;
4006 }
ItemNode * findItem(char *name)
Definition: feeserver.c:3045
void add_char_item_node(unsigned int _id, CharItem *_char_item)
Definition: feeserver.c:4056
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
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: