FACT++  1.0
int updateFeeService ( char *  serviceName)

Definition at line 2914 of file feeserver.c.

References createLogMessage(), data, dis_update_service, findCharItem(), findIntItem(), findItem(), Memory::free(), Memory::malloc(), size, and sprintf().

2914  {
2915  char msg[80];
2916  ItemNode* node = 0;
2917  IntItemNode* intNode = 0;
2918  CharItemNode* charNode = 0;
2919  int nRet = 0;
2920 # ifdef __DEBUG
2921  char* addr = 0;
2922  char* data = 0;
2923  int size = 0;
2924 # endif
2925 
2926  if (state != RUNNING) {
2927  return FEE_WRONG_STATE;
2928  }
2929  if (serviceName == 0) {
2930  return FEE_NULLPOINTER;
2931  }
2932 
2933  // find desired service
2934  node = findItem(serviceName);
2935  if (node == 0) {
2936  //check in IntItemList
2937  intNode = findIntItem(serviceName);
2938  }
2939  if ((node == 0) || (intNode == 0)) {
2940  //check in CharItemList
2941  charNode = findCharItem(serviceName);
2942  }
2943 
2944  // check node
2945  if ((node == 0) && (intNode == 0) && (charNode == 0)) {
2946  // message is NOT sent in findItem(), findIntItem() or findCharItem()
2947  msg[sprintf(msg, "Item %s not found in list.", serviceName)] = 0;
2948  createLogMessage(MSG_WARNING, msg, 0);
2949 # ifdef __DEBUG
2950  printf("Item %s not found in list.\n", serviceName);
2951  fflush(stdout);
2952 # endif
2953  return FEE_INVALID_PARAM;
2954  } else {
2955  if (node != 0) {
2956  nRet = dis_update_service(node->id);
2957 # ifdef __DEBUG
2958 /* printf("CE triggered an updated on %d clients for service %s [float]: %f\n", */
2959 /* nRet, node->item->name, *(node->item->location)); */
2960 /* fflush(stdout); */
2961 # endif
2962  } else if (intNode != 0) {
2963  nRet = dis_update_service(intNode->id);
2964 # ifdef __DEBUG
2965 /* printf("CE triggered an updated on %d clients for service %s [int]: %d\n", */
2966 /* nRet, intNode->intItem->name, *(intNode->intItem->location)); */
2967 /* fflush(stdout); */
2968 # endif
2969  } else {
2970  nRet = dis_update_service(charNode->id);
2971 # ifdef __DEBUG
2972  (charNode->charItem->user_routine)(&(charNode->charItem->tag),
2973  (int**) &addr, &size);
2974  data = (char*) malloc(size +1);
2975  strncpy(data, addr, size);
2976  data[size] = 0;
2977 /* printf("CE triggered an updated on %d clients for service %s [char]: %s\n", */
2978 /* nRet, charNode->charItem->name, data); */
2979 /* fflush(stdout); */
2980  free(data);
2981 # endif
2982  }
2983  }
2984 
2985  // return number of updated clients
2986  return nRet;
2987 }
Definition: dns.c:26
ItemNode * findItem(char *name)
Definition: feeserver.c:3045
CharItemNode * findCharItem(char *name)
Definition: feeserver.c:4107
void * malloc()
Definition: EventBuilder.cc:99
void createLogMessage(unsigned int type, char *description, char *origin)
Definition: feeserver.c:1530
#define dis_update_service
Definition: dis.h:18
int size
Definition: db_dim_server.c:17
float data[4 *1440]
void free(void *mem)
IntItemNode * findIntItem(char *name)
Definition: feeserver.c:3378
sprintf(name1,"NewService%d", i)

+ Here is the call graph for this function: