Example #1
0
LIST_PTR x_ipc_listMake2(const void *item1, const void *item2)
{
  LIST_PTR list;
  
  list = x_ipc_listCreate();
  x_ipc_listInsertItem(item2, list);
  x_ipc_listInsertItem(item1, list);
  
  return list;
}
Example #2
0
static FORMAT_PTR Enum_Format(Format_Parse_Ptr parser, BOOLEAN *error)
{ 
  TokenPtr Token;
  FORMAT_PTR Form, subform;
  LIST_PTR format_list;
  int num_formats, i, maxVal;
  
  num_formats = 0;
  Token = NextToken(parser);
  if (Token->Type == COLON_TOK) {
    Token = NextToken(parser);
    if (Token->Type != INT_TOK) {
      *error = TRUE;
      ParserError(Token, parser, "an integer");
      return NULL;
    } else {
      maxVal = Token->value.num;
    }
  } else {
    format_list = x_ipc_listCreate();
    do {
      if (num_formats > 0) Token = NextToken(parser);
      if (Token->Type != STR_TOK) {
	*error = TRUE;
	ParserError(Token, parser, "a string");
	return NULL;
      } else {
	Form = new_n_formatter(Token->value.str);
	/* More efficient for Lisp if all enum format names are upper case */
	LOCK_M_MUTEX;
	if (IS_LISP_MODULE()) {
	  upcase(Form->formatter.name);
	}
	UNLOCK_M_MUTEX;
	x_ipc_listInsertItem((char *)Form, format_list);
	num_formats++;
      }
      Token = NextToken(parser);
    } while (Token->Type == COMMA_TOK);
    UngetToken(parser, Token);
    maxVal = num_formats - 1;
  }
  
  Form = new_a_formatter(EnumFMT, num_formats+2);
  Form->formatter.a[1].i = maxVal;
  if (num_formats > 0) {
    /* Index from high to low since "format_list" 
       has formatters in reverse order */
    subform = (FORMAT_PTR)x_ipc_listFirst(format_list);
    for(i=num_formats;i>0;i--) {
      Form->formatter.a[i+1].f = subform;
      subform = (FORMAT_PTR)x_ipc_listNext(format_list);
    }
    x_ipc_listFree(&format_list);
  }
  return Form;
}
Example #3
0
LIST_PTR x_ipc_listMake1(const void *item)
{
  LIST_PTR list;
  
  list = x_ipc_listCreate();
  
  x_ipc_listInsertItem(item, list);
  
  return list;
}
Example #4
0
/* no longer used */
static X_IPC_RETURN_VALUE_TYPE x_ipcAllocateDataBuffer(int32 size)
{
  DATA_MSG_BUF_PTR dataMsgBuf;
  
  /* Creates an unallocated data message buffer */
  dataMsgBuf = dataMsgBufferCreate(size);
  LOCK_M_MUTEX;
  x_ipc_listInsertItem((char *)dataMsgBuf, (GET_M_GLOBAL(dataMsgBufferList)));
  
  if (size > (GET_M_GLOBAL(DMmax))) (GET_M_GLOBAL(DMmax)) = size;
  if (size < (GET_M_GLOBAL(DMmin))) (GET_M_GLOBAL(DMmin)) = size;
  UNLOCK_M_MUTEX;
  
  return Success;
}
Example #5
0
static DISPATCH_HND_PTR chooseMsgHandler(MSG_PTR msg)
{
  int32 size;
  LIST_PTR hndList;
  DISPATCH_HND_PTR hnd, nextHnd, retHnd;
  
  hndList = msg->hndList;
  size = x_ipc_listLength(hndList);
  
  hnd = (DISPATCH_HND_PTR)x_ipc_listFirst(hndList);
  
  if (!size) {
    size = 1;
    hnd = NEW(DISPATCH_HND_TYPE);
    hnd->sd = 0;
    hnd->localId =0;
    hnd->msg = NULL;
    hnd->hndProc = NULL;
    hnd->hndOrg = GET_S_GLOBAL(x_ipcServerModGlobal);
    hnd->hndData = NULL;
    hnd->msgList = NULL;
    hnd->resource = resourceCreate(0, 0, msg->msgData->name, 1);
    hnd->resource->capacity = 0;
    hnd->hndLanguage = C_LANGUAGE;
#ifdef NMP_IPC
    hnd->clientData = NO_CLIENT_DATA;
#endif
    
    x_ipc_listInsertItem((char *)hnd, msg->hndList);
  }
  
  if (size > 1) {
    retHnd = hnd;
    nextHnd = (DISPATCH_HND_PTR)x_ipc_listNext(hndList);
    while (nextHnd && nextHnd->hndData &&
	   STREQ(hnd->hndData->hndName, nextHnd->hndData->hndName)) {
      if (resourceAvailableRes(nextHnd->resource))
	retHnd = nextHnd;
      nextHnd = (DISPATCH_HND_PTR)x_ipc_listNext(hndList);
    }
    hnd = !nextHnd ? retHnd : NULL;
  }
  
  return hnd;
}
Example #6
0
static FORMAT_PTR Struct_Format(Format_Parse_Ptr parser, BOOLEAN *error)
{ 
  FORMAT_PTR Form, subform;
  LIST_PTR format_list;
  int num_formats, i;
  
  format_list = x_ipc_listCreate();
  num_formats = 0;
  
  if (parser->TokenList->Type != RBRACE_TOK) {
    while (1) {
      x_ipc_listInsertItem((char *)Parse(parser, TRUE, error), format_list);
      num_formats++;
      if (parser->TokenList->Type == COMMA_TOK) {
	(void)NextToken(parser);
      } else if (parser->TokenList->Type == RBRACE_TOK) {
	break;
      } else {
	*error = TRUE;
	ParserError(NextToken(parser), parser, "','");
	return NULL;
      }
    }
  }
  
  Form = new_a_formatter(StructFMT, num_formats+1);
  /* Index from high to low since "format_list" 
     has formatters in reverse order */
  subform = (FORMAT_PTR)x_ipc_listFirst(format_list);
  for(i=num_formats;i>0;i--) {
    Form->formatter.a[i].f = subform;
    subform = (FORMAT_PTR)x_ipc_listNext(format_list);
  }
  
  x_ipc_listFree(&format_list);
  return Form;
}
Example #7
0
HND_PTR x_ipc_selfRegisterHnd(int sd, MODULE_PTR hndOrg, 
			HND_DATA_PTR hndData, X_IPC_HND_FN hndProc)
{
  int32 localId;
  MSG_PTR msg;
  HND_PTR hnd;
  HND_KEY_TYPE hndKey;
  
  msg = x_ipc_findOrRegisterMessage(hndData->msgName);
  
  hndKey.num = sd;
  hndKey.str = hndData->hndName;
  
  LOCK_CM_MUTEX;
  hnd = GET_HANDLER(&hndKey);
  UNLOCK_CM_MUTEX;
  if (!hnd) {
    hnd = NEW(HND_TYPE);
    hnd->sd = sd;
    hnd->localId = 0;
    hnd->msg = NULL;
    hnd->hndProc = hndProc;
    hnd->hndOrg = hndOrg;
    hnd->hndData = hndData;
    hnd->msgList = x_ipc_listCreate();
    hnd->resource = NULL;
    hnd->hndLanguage = C_LANGUAGE; /* The default */
#ifdef NMP_IPC
    hnd->clientData = NO_CLIENT_DATA;
    hnd->isRegistered = TRUE;
#endif
    
    LOCK_CM_MUTEX;
    ADD_HANDLER(&hndKey, hnd);
    
    localId = x_ipc_idTableInsert((char *)hnd, GET_C_GLOBAL(hndIdTable));
    UNLOCK_CM_MUTEX;
    
    hnd->localId = localId;
    
    if (hndProc)
      hnd->hndData->refId = localId;
  } else {
    LOCK_M_MUTEX;
    if (!IS_LISP_MODULE() && hndProc != hnd->hndProc) {
      /* 24-Jun-91: fedor: the warning is not meaningful for lisp because each
	 re-register will cause a pointer change - lisp functions are not at
	 static locations like c */
      X_IPC_MOD_WARNING1("\nWARNING: Procedure change ignored for existing handler %s.\n",
			 hnd->hndData->hndName);
    }
    UNLOCK_M_MUTEX;
  }

  /* 3-Sep-90: fedor: NULL forces initial module cache of a message. */
  hnd->msg = NULL;
  
  if (!x_ipc_listMemberItem((char *)hnd, msg->hndList))
    x_ipc_listInsertItem((char *)hnd, msg->hndList); 
  
  if (!x_ipc_listMemberItem((char *)msg, hnd->msgList))
    x_ipc_listInsertItem((char *)msg, hnd->msgList);
  
  return hnd;
}