Exemplo n.º 1
0
char *lisp_Data_Flag(void)
{
  char *lispDataFlag;

  LOCK_M_MUTEX;
  lispDataFlag = LISP_DATA_FLAG();
  UNLOCK_M_MUTEX;

  return lispDataFlag;
}
Exemplo n.º 2
0
/* 25-Jun-91: fedor: this is really a cheap shot at making ref data work
   for lisp - lets hope it works. */
int32 x_ipcRefDataLisp(X_IPC_REF_PTR ref)
{
  int32 refId, sd;
  MSG_PTR msg;
  X_IPC_REF_PTR waitRef;
  X_IPC_RETURN_VALUE_TYPE returnValue;
  char *lispDataFlag;
  
  msg = x_ipc_msgFind(X_IPC_REF_DATA_QUERY);
  if (msg == NULL) return 0;
  
  if (!ref->msg) {
    if (!ref->name) {
      /* 17-Jun-91: fedor: start enforcing correct refs */
      X_IPC_MOD_ERROR1("ERROR: x_ipcReferenceData: Badly Formed Reference: %d\n",
		  ref->refId);
      return 0;
    }
    ref->msg = x_ipc_msgFind(ref->name);
    if (ref->msg == NULL) return 0;
  }
  
  /* 17-Jun-91: fedor: check if any message form */
  if (!ref->msg->msgData->msgFormat)
    return 0;
  
  refId = x_ipc_nextSendMessageRef();
  returnValue = x_ipc_sendMessage((X_IPC_REF_PTR)NULL, msg, 
				  (char *)&ref->refId, (char *)NULL, refId);
  
  if (returnValue != Success) {
    X_IPC_MOD_ERROR("ERROR: x_ipcReferenceData: x_ipc_sendMessage Failed.\n");
    return 0;
  }
  waitRef = x_ipcRefCreate(ref->msg, ref->name, refId);
  
  LOCK_CM_MUTEX;
  sd = GET_C_GLOBAL(serverRead);
  lispDataFlag = LISP_DATA_FLAG();
  UNLOCK_CM_MUTEX;
  returnValue = x_ipc_waitForReplyFrom(waitRef, lispDataFlag, TRUE,
				       WAITFOREVER, sd);
  
  x_ipcRefFree(waitRef);
  
  if (returnValue == NullReply) {
    /* 17-Jun-91: fedor: if NullReply then nothing else was malloced. */
    return 0;
  }
  else
    return 1;
}
Exemplo n.º 3
0
DATA_MSG_PTR x_ipc_dataMsgCreate(int32 parentRef, int32 intent, int32 classId,
				 int32 dispatchRef, int32 msgRef,
				 CONST_FORMAT_PTR msgFormat,
				 const void *msgData,
				 CONST_FORMAT_PTR classFormat,
				 const void *classData)
{
#ifdef LISP
  BUFFER_TYPE buffer;
  char *lispDataFlag;
#endif /* LISP */
  DATA_MSG_PTR dataMsg;
  int32 classTotal, msgTotal;
  
  msgTotal = 0;
  
  if (msgData && msgFormat) {
    if (msgFormat->type == BadFormatFMT) return NULL;
#ifdef LISP
    LOCK_M_MUTEX;
    if (msgData == LISP_DATA_FLAG()) {
      (*(GET_M_GLOBAL(lispBufferSizeGlobal)))(&msgTotal, msgFormat);
      UNLOCK_M_MUTEX;
    } else
      UNLOCK_M_MUTEX;
#endif /* LISP */
      msgTotal = x_ipc_bufferSize(msgFormat, msgData);
  }
  
  if (classData && classFormat)
    classTotal = x_ipc_bufferSize(classFormat, classData);
  else
    classTotal = 0;
  
  dataMsg = x_ipc_dataMsgAlloc(classTotal + sizeof(DATA_MSG_TYPE));
  
  dataMsg->dataRefCountPtr = (int32 *)x_ipcMalloc(sizeof(int32));
  *(dataMsg->dataRefCountPtr) = 1;
  dataMsg->refCount = 0;
  dataMsg->vec = NULL;
  
  dataMsg->msgTotal = msgTotal;
  dataMsg->classTotal = classTotal;
  
  dataMsg->parentRef = parentRef;
  dataMsg->intent = intent;
  dataMsg->classId = classId;
  dataMsg->dispatchRef = dispatchRef;
  dataMsg->msgRef = msgRef;
  
#ifdef LISP
  LOCK_M_MUTEX;
  lispDataFlag = LISP_DATA_FLAG();
  UNLOCK_M_MUTEX;
  if ((msgTotal != 0) && (msgData == lispDataFlag)) {
    dataMsg->msgData = (char *)x_ipcMalloc(msgTotal);
    buffer.buffer = dataMsg->msgData;
    buffer.bstart = 0;
    LOCK_M_MUTEX;
    (*(GET_M_GLOBAL(lispEncodeMsgGlobal)))(msgFormat, &buffer);
    UNLOCK_M_MUTEX;
    dataMsg->vec = x_ipc_createVectorization(msgFormat,
					     (char *)msgData,dataMsg->msgData,
					     msgTotal);
  } else
#endif
    { 
      x_ipc_encodeMsgData(msgFormat, msgData, dataMsg, 0);
    }
  
  if (classTotal) {
    dataMsg->classData = (char *)dataMsg + sizeof(DATA_MSG_TYPE);
    x_ipc_encodeData(classFormat, classData, dataMsg->classData, 0, classTotal);
  }
  else
    dataMsg->classData = NULL;
  
  /* Include the pointer to the original data. */
  dataMsg->dataStruct = (const char *)msgData;
  dataMsg->dataByteOrder = BYTE_ORDER;
  dataMsg->classByteOrder = BYTE_ORDER;
  dataMsg->alignment = (ALIGNMENT_TYPE)ALIGN;
  
  return dataMsg;
}