Exemplo n.º 1
0
void x_ipc_hashTableStats(HASH_TABLE_PTR hashTable)
{
  HASH_ELEM_PTR elem;
  int32 i, num=0, max=0, full=0, length;
  
  if (hashTable) {
    for (i=0;i < hashTable->size; i++) {
      elem = hashTable->table[i];
      if (elem) {
	full++;
	length = 0;
	while (elem) {
	  num++;
	  length++;
	  elem = elem->next;
	}
	if (length > max) 
	  max = length;
      }
    }
    X_IPC_MOD_WARNING2("x_ipc_hashTableStats: Has %d elements in %d slots\n",
		  num, full);
    X_IPC_MOD_WARNING2("   Out of %d slots (%.0f percent full)\n", 
		  hashTable->size, 100*((double)full/hashTable->size));
    X_IPC_MOD_WARNING2("   Average list is %.1f; maximum is %d\n", 
		  (double)num/full, max);
  } else {
    X_IPC_MOD_WARNING("x_ipc_hashTableStats: No Hash Table\n");
  }
}
Exemplo n.º 2
0
static FORMAT_PTR Named_Format(Format_Parse_Ptr parser, TokenPtr Token)
{ 
  NAMED_FORMAT_PTR namedFormat;
  FORMAT_PTR format;
  
  if (parser->formatStack == NULL) {
    parser->formatStack = x_ipc_strListCreate();
  }
  
  if (x_ipc_strListMemberItem(Token->value.str, parser->formatStack)) {
    /* found a recursive definition. just return pointer */
    return new_n_formatter(Token->value.str);
  }
  
  x_ipc_strListPush(strdup(Token->value.str), parser->formatStack);

  LOCK_M_MUTEX;
  namedFormat = 
    (NAMED_FORMAT_PTR)x_ipc_hashTableFind(Token->value.str,
				    GET_M_GLOBAL(formatNamesTable));
  UNLOCK_M_MUTEX;
  if (!namedFormat) {
#ifdef NMP_IPC
    if (GET_C_GLOBAL(serverRead) != CENTRAL_SERVER_ID) {
      if (x_ipcQueryCentral(X_IPC_NAMED_FORM_QUERY,
			  &Token->value.str, &format) != Success ||
	  !format) {
        X_IPC_MOD_WARNING2("Warning: Named Format %s is not registered\n%s\n",
			   Token->value.str, parser->ParseString);
        format = new_f_formatter(BadFormatFMT, NULL);
      }
    } else
#endif
      {
	X_IPC_MOD_WARNING2("Warning: Named Format %s is not registered\n%s\n",
			   Token->value.str, parser->ParseString);
	format = new_f_formatter(BadFormatFMT, NULL);
      }
  } else {
    /* Need to use the named formatter -- parse it now */
    if (!namedFormat->parsed) {
      namedFormat->format = 
	(FORMAT_PTR)ParseFormatString(namedFormat->definition);
      namedFormat->parsed = TRUE;
    }
    format = copyFormatter(namedFormat->format);
  }
  
  x_ipcFree((void *)x_ipc_strListPopItem(parser->formatStack));
  return format;
}
Exemplo n.º 3
0
X_IPC_REF_PTR x_ipcReserveModResource(const char *modName, const char *resName)
{
  int32 refId;
  MSG_PTR msg;
  X_IPC_REF_PTR ref;
  ADD_HND_FORM_TYPE addForm;
  
  addForm.hndName = modName;
  addForm.resName = resName;
  
  refId = 0;
  
  if (x_ipcQuery(X_IPC_RESERVE_MOD_RESOURCE_QUERY, (void *)&addForm,
	       (void *)&refId) != Success)
    return NULL;
  
  if (refId < 0) {
    X_IPC_MOD_WARNING( "\nWARNING: Ignoring reservation request.\n");
    X_IPC_MOD_WARNING2( "%s of module %s is already reserved by this module.\n", 
		  resName, modName);
    ref = CREATE_NULL_REF();
  }
  else {
    msg = x_ipc_msgFind(X_IPC_RESERVE_MOD_RESOURCE_QUERY);
    if (msg == NULL) return NULL;
    ref = x_ipcRefCreate(msg, X_IPC_RESERVE_MOD_RESOURCE_QUERY, refId);
  }
  
  return ref;
}
Exemplo n.º 4
0
static void ParserError(TokenPtr bad_token, Format_Parse_Ptr parser,
			char *expecting)
{ 
  int i;
  
  X_IPC_MOD_WARNING2( "Format Parsing Error: Expected %s.\n%s\n", 
		expecting, parser->ParseString);
  for (i=0; i<bad_token->Loc; i++) X_IPC_MOD_WARNING( " ");
/*  X_IPC_MOD_ERROR("^\n");*/
}
Exemplo n.º 5
0
/* Check that the format is OK for IPC, and set the "dataHandle" to
   point to the data (either a byte-array or IPC_VARCONTENT_PTR) to be sent.
   Last argument added to make this re-entrant, but without need for malloc */
IPC_RETURN_TYPE ipcDataToSend (CONST_FORMAT_PTR format, const char *msgName,
			       unsigned int length, BYTE_ARRAY content,
			       void **dataHandle, IPC_VARCONTENT_PTR varcontent)
{
  FORMAT_CLASS_TYPE formatClass;
  
  if (!format) {
    if (length == 0 || length == IPC_FIXED_LENGTH) {
      *dataHandle = NULL;
      return IPC_OK;
    } else {
      X_IPC_MOD_WARNING2("Illegal length argument %d for zero-length message\n %s",
		    length, msgName);
      RETURN_ERROR(IPC_Message_Lengths_Differ);
    }
  } else {
    formatClass = ipcFormatClassType(format);
    if (formatClass != FixedArrayFMT && formatClass != VarArrayFMT) {
      X_IPC_MOD_WARNING1("Illegal format for message %s\n", msgName);
      RETURN_ERROR(IPC_Illegal_Formatter);
    } else if (!ipcCheckPublishLength(length, format, formatClass)) {
      X_IPC_MOD_WARNING3("Illegal length argument %d for %s-length message %s\n",
		    length, (formatClass==FixedArrayFMT ? "fixed" : "variable"),
		    msgName);
      RETURN_ERROR(IPC_Message_Lengths_Differ);
    } else if (formatClass == FixedArrayFMT) {
      *dataHandle = content;
      return IPC_OK;
    } else { /* VarArrayFMT */
      varcontent->length = length;
      varcontent->content = content;
      *dataHandle = (void *)varcontent;
      return IPC_OK;
    }
  }
}