Esempio n. 1
0
CONDITION
DUL_AddSinglePresentationCtx(DUL_ASSOCIATESERVICEPARAMETERS* params,
			DUL_SC_ROLE proposedRole, DUL_SC_ROLE acceptedRole,
			DUL_PRESENTATIONCONTEXTID contextID,
			unsigned char result, const char* abstractSyntax,
			const char** xferSyntaxes, int xferSyntaxCount)
{
  LST_HEAD* lst;
  DUL_TRANSFERSYNTAX* transfer;
  DUL_PRESENTATIONCONTEXT* ctx;
  CONDITION cond;


  ctx = (DUL_PRESENTATIONCONTEXT *) CTN_MALLOC(sizeof(*ctx));
  if (ctx == NULL)
    return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR),
				  "DUL_AddSinglePresentationCtx", sizeof(*ctx));

  (void) memset(ctx, 0, sizeof(*ctx));
  lst = LST_Create();
  if (lst == NULL)
    return COND_PushCondition(DUL_LISTCREATEFAILED,
	      DUL_Message(DUL_LISTCREATEFAILED), "DUL_AddSinglePresentationCtx");

  (ctx)->presentationContextID = contextID;
  (ctx)->result = result;
  (ctx)->proposedSCRole = proposedRole;
  (ctx)->acceptedSCRole = acceptedRole;
  strcpy((ctx)->abstractSyntax, abstractSyntax);

  strcpy((ctx)->acceptedTransferSyntax, "");
  for (; xferSyntaxCount-- > 0; xferSyntaxes++) {
    if (strlen(*xferSyntaxes) != 0) {
      transfer = CTN_MALLOC(sizeof(*transfer));
      if (transfer == NULL)
	return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR),
			      "DUL_AddSinglePresentationCtx", sizeof(*transfer));
      strcpy(transfer->transferSyntax, *xferSyntaxes);
      if (LST_Enqueue(&lst, transfer) != LST_NORMAL)
	return COND_PushCondition(DUL_LISTERROR, DUL_Message(DUL_LISTERROR),
					  "DUL_AddSinglePresentationCtx");
    }
  }

  (ctx)->proposedTransferSyntax = lst;
  cond = LST_Enqueue(&params->requestedPresentationContext,ctx);
  if (cond != LST_NORMAL) {
    return COND_PushCondition(DUL_LISTERROR, DUL_Message(DUL_LISTERROR),
	    "DUL_AddSinglePresentationCtx");
    /* Memory Leak here */
  }
  return DUL_NORMAL;


}
Esempio n. 2
0
CONDITION
DUL_MakePresentationCtx(DUL_PRESENTATIONCONTEXT ** ctx,
		     DUL_SC_ROLE proposedSCRole, DUL_SC_ROLE acceptedSCRole,
		      DUL_PRESENTATIONCONTEXTID ctxID, unsigned char result,
			const char *abstractSyntax, const char *transferSyntax,...)
{
    va_list
	args;
    LST_HEAD
	* lst;
    DUL_TRANSFERSYNTAX
	* transfer;
#ifdef lint
    char __builtin_va_alist;
#endif

    *ctx = (DUL_PRESENTATIONCONTEXT *) CTN_MALLOC(sizeof(**ctx));
    if (*ctx == NULL)
	return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR),
				  "DUL_MakePresentationCtx", sizeof(**ctx));

    (void) memset(*ctx, 0, sizeof(**ctx));
    lst = LST_Create();
    if (lst == NULL)
	return COND_PushCondition(DUL_LISTCREATEFAILED,
	      DUL_Message(DUL_LISTCREATEFAILED), "DUL_MakePresentationCtx");

    (*ctx)->presentationContextID = ctxID;
    (*ctx)->result = result;
    (*ctx)->proposedSCRole = proposedSCRole;
    (*ctx)->acceptedSCRole = acceptedSCRole;
    strcpy((*ctx)->abstractSyntax, abstractSyntax);

    va_start(args, transferSyntax);
    strcpy((*ctx)->acceptedTransferSyntax, transferSyntax);
    while ((transferSyntax = va_arg(args, char *)) != NULL) {
	if (strlen(transferSyntax) != 0) {
	    transfer = CTN_MALLOC(sizeof(*transfer));
	    if (transfer == NULL)
		return COND_PushCondition(DUL_MALLOCERROR, DUL_Message(DUL_MALLOCERROR),
			      "DUL_MakePresentationCtx", sizeof(*transfer));
	    strcpy(transfer->transferSyntax, transferSyntax);
	    if (LST_Enqueue(&lst, transfer) != LST_NORMAL)
		return COND_PushCondition(DUL_LISTERROR, DUL_Message(DUL_LISTERROR),
					  "DUL_MakePresentationCtx");
	}
    }
    va_end(args);
    (*ctx)->proposedTransferSyntax = lst;
    return DUL_NORMAL;
}
Esempio n. 3
0
CONDITION
MSG_BuildReferencedItemSequence(MSG_REFERENCED_ITEM * item,
				LST_HEAD ** list)
{
    CONDITION
	cond;
    DCM_SEQUENCE_ITEM
	* sq;

    if (*list == NULL) {
	*list = LST_Create();
	if (*list == NULL)
	    return COND_PushCondition(MSG_LISTFAILURE,
	    MSG_Message(MSG_LISTFAILURE), "MSG_BuildReferencedItemSequence");
    }
    sq = CTN_MALLOC(sizeof(*sq));
    if (sq == NULL)
	return COND_PushCondition(MSG_MALLOCFAILURE,
				MSG_Message(MSG_MALLOCFAILURE), sizeof(*sq),
				  "MSG_BuildReferencedItemSequence");

    cond = MSG_BuildCommand(item, &sq->object);
    if (cond != MSG_NORMAL)
	return cond;

    cond = LST_Enqueue(list, item);
    if (cond != LST_NORMAL)
	return COND_PushCondition(MSG_LISTFAILURE,
	   MSG_Message(MSG_LISTFAILURE), "MSG_BuildReferencedItemSequence");
    return MSG_NORMAL;
}
Esempio n. 4
0
CONDITION
DCM_ListToString(LST_HEAD * list, long offset, char **string)
{
    GENERIC
	* g;
    char
       *c,
       *p;
    long
        length;

    *string = NULL;
    if (list == NULL)
	return DCM_NORMAL;

    g = LST_Head(&list);
    if (g == NULL)
	return DCM_NORMAL;

    (void) LST_Position(&list, g);

    length = 0;
    while (g != NULL) {
	c = ((char *) g) + offset;
	length += strlen(c) + 1;
	g = LST_Next(&list);
    }

    p = CTN_MALLOC(length);
    if (p == NULL)
	return COND_PushCondition(DCM_MALLOCFAILURE,
		DCM_Message(DCM_MALLOCFAILURE), length, "DCM_ListToString");

    *string = p;
    g = LST_Head(&list);
    if (g == NULL)
	return COND_PushCondition(DCM_LISTFAILURE, DCM_Message(DCM_LISTFAILURE),
				  "DCM_ListToString");
    (void) LST_Position(&list, g);

    length = 0;
    while (g != NULL) {
	c = ((char *) g) + offset;
	length = strlen(c);
	(void) memcpy(p, c, length);
	p += length;
	*p++ = '\\';
	g = LST_Next(&list);
    }
    *--p = '\0';
    return DCM_NORMAL;
}
Esempio n. 5
0
char* UID_Translate(const char* value)
{
  int idx;
  const char* copyValue;
  char* rtnValue;

  copyValue = value;
  for (idx = 0; idx < DIM_OF(uidMap); idx++) {
    if (strcmp(value, uidMap[idx].aValue) == 0) {
      copyValue = uidMap[idx].bValue;
      break;
    }
  }

  rtnValue = (char*) CTN_MALLOC(strlen(copyValue) + 1);
  strcpy(rtnValue, copyValue);
  return rtnValue;
}
Esempio n. 6
0
CONDITION
DCM_GetFileMeta(DCM_OBJECT ** callerObject, DCM_FILE_META ** fileMeta)
{
    CONDITION 		cond;
    PRIVATE_OBJECT 	**object;

    object = (PRIVATE_OBJECT **) callerObject;
    cond = checkObject(object, "DCM_GetFileMeta");
    if (cond != DCM_NORMAL)	return cond;

    memset(&meta, 0, sizeof(meta));

    cond = DCM_ParseObject(callerObject, metaRequired, (int) DIM_OF(metaRequired), metaOptional, (int) DIM_OF(metaOptional), NULL);
    if (cond != DCM_NORMAL)	return cond;		/* repair */

    *fileMeta = CTN_MALLOC(sizeof(DCM_FILE_META));
    if (*fileMeta == NULL) return 0;		/* repair */

    **fileMeta = meta;
    return DCM_NORMAL;
}