xp_comm_proj/rd_dicom/Papyrus3/PapyList3.c
/********************************************************************************/
/*										*/
/*	FreeCell : Deletes the given item as well as its content. Deletes the 	*/
/* 	content selectively depending on the values of the parameters.This 	*/
/*	allows to reuse the modules, the groups and the sequences in multiple 	*/
/*	data sets.								*/
/*	return : papNoError if OK, standard error message otherwise.		*/
/*										*/
/********************************************************************************/
FreeCell : Deletes the given item as well as its content. Deletes the
content selectively depending on the values of the parameters.This
allows to reuse the modules, the groups and the sequences in multiple
data sets.
return : papNoError if OK, standard error message otherwise.
FreeCell : Deletes the given item as well as its content . Deletes the content selectively depending on the values of the parameters . This allows to reuse the modules the groups and the sequences in multiple data sets . return : papNoError if OK standard error message otherwise .
PapyShort
FreeCell (PapyShort inFileNb, Papy_List **ioToFreeP, int inDelAll, int inDelGroup, int inDelSeq)
{
  PapyShort	theErr = 0;
  if (inDelAll)
    switch ((*ioToFreeP)->object->whoAmI)
    {
      case papItem :
        DeleteList (inFileNb, (Papy_List **) &((*ioToFreeP)->object->item), inDelAll, inDelGroup, inDelSeq);
        break;
      case papModule :
        theErr = Papy3ModuleFree (&((*ioToFreeP)->object->module), 
        		          (*ioToFreeP)->object->objID, inDelSeq);
        if (theErr < 0) RETURN (theErr);
        break;
      case papRecord :
        theErr = Papy3RecordFree (&((*ioToFreeP)->object->record), 
        		          (*ioToFreeP)->object->objID, inDelSeq);
        if (theErr < 0) RETURN (theErr);
        break;
      case papGroup :
        if (inDelGroup)
          if ((theErr = Papy3GroupFree (&((*ioToFreeP)->object->group), inDelSeq)) < 0)
            RETURN (theErr);
        break;
      case papTmpFile :
	      {
	        char *tmpFilename, myStr [32];
	        tmpFilename = (char *) ecalloc3 ((PapyULong) 256, (PapyULong) sizeof (char));
	        strcpy (tmpFilename, gPapFilename [inFileNb]);
	        Papy3FPrint (myStr, "%d", (*ioToFreeP)->object->objID);
	        strcat (myStr, ".dcm");
	        strcat (myStr, "\0");
	        if ((*ioToFreeP)->object->objID      < 10)
		      strcat (tmpFilename, "000");
	        else if ((*ioToFreeP)->object->objID < 100)
		      strcat (tmpFilename, "00");
	        else if ((*ioToFreeP)->object->objID < 1000)
		      strcat (tmpFilename, "0");
	        strcat (tmpFilename, myStr);
	        if (gIsPapyFile [inFileNb] == PAPYRUS3)
	        {
	          if ((theErr = Papy3FDelete (tmpFilename, (*ioToFreeP)->object->file)) != 0)
	          RETURN (papDeleteFile);
	        } 
	        efree3 ((void **) &tmpFilename);
	        if ((*ioToFreeP)->object->file != NULL)
	          efree3 ((void **) &((*ioToFreeP)->object->file));
	      }
        break;
      default :
        break;
    } 
  (*ioToFreeP)->object->item          = NULL;
  (*ioToFreeP)->object->module        = NULL;
  (*ioToFreeP)->object->group         = NULL;
  (*ioToFreeP)->object->tmpFileLength = 0L;
  efree3 ((void **) &((*ioToFreeP)->object));
  efree3 ((void **) ioToFreeP);
  RETURN (theErr);
}
PapyShort FreeCell ( PapyShort inFileNb , Papy_List * * ioToFreeP , int inDelAll , int inDelGroup , int inDelSeq ) { PapyShort theErr = 0 ; if ( inDelAll ) switch ( ( * ioToFreeP ) -> object -> whoAmI ) { case papItem : DeleteList ( inFileNb , ( Papy_List * * ) & ( ( * ioToFreeP ) -> object -> item ) , inDelAll , inDelGroup , inDelSeq ) ; break ; case papModule : theErr = Papy3ModuleFree ( & ( ( * ioToFreeP ) -> object -> module ) , ( * ioToFreeP ) -> object -> objID , inDelSeq ) ; if ( theErr < 0 ) RETURN ( theErr ) ; break ; case papRecord : theErr = Papy3RecordFree ( & ( ( * ioToFreeP ) -> object -> record ) , ( * ioToFreeP ) -> object -> objID , inDelSeq ) ; if ( theErr < 0 ) RETURN ( theErr ) ; break ; case papGroup : if ( inDelGroup ) if ( ( theErr = Papy3GroupFree ( & ( ( * ioToFreeP ) -> object -> group ) , inDelSeq ) ) < 0 ) RETURN ( theErr ) ; break ; case papTmpFile : { char * tmpFilename , myStr [ 32 ] ; tmpFilename = ( char * ) ecalloc3 ( ( PapyULong ) 256 , ( PapyULong ) sizeof ( char ) ) ; strcpy ( tmpFilename , gPapFilename [ inFileNb ] ) ; Papy3FPrint ( myStr , " " , ( * ioToFreeP ) -> object -> objID ) ; strcat ( myStr , " " ) ; strcat ( myStr , " \0 " ) ; if ( ( * ioToFreeP ) -> object -> objID < 10 ) strcat ( tmpFilename , " " ) ; else if ( ( * ioToFreeP ) -> object -> objID < 100 ) strcat ( tmpFilename , " " ) ; else if ( ( * ioToFreeP ) -> object -> objID < 1000 ) strcat ( tmpFilename , " " ) ; strcat ( tmpFilename , myStr ) ; if ( gIsPapyFile [ inFileNb ] == PAPYRUS3 ) { if ( ( theErr = Papy3FDelete ( tmpFilename , ( * ioToFreeP ) -> object -> file ) ) != 0 ) RETURN ( papDeleteFile ) ; } efree3 ( ( void * * ) & tmpFilename ) ; if ( ( * ioToFreeP ) -> object -> file != NULL ) efree3 ( ( void * * ) & ( ( * ioToFreeP ) -> object -> file ) ) ; } break ; default : break ; } ( * ioToFreeP ) -> object -> item = NULL ; ( * ioToFreeP ) -> object -> module = NULL ; ( * ioToFreeP ) -> object -> group = NULL ; ( * ioToFreeP ) -> object -> tmpFileLength = 0L ; efree3 ( ( void * * ) & ( ( * ioToFreeP ) -> object ) ) ; efree3 ( ( void * * ) ioToFreeP ) ; RETURN ( theErr ) ; }
FreeCell : Deletes the given item as well as its content.
FreeCell : Deletes the given item as well as its content .
/* free the content of the cell if the toDel parameter is set to TRUE */ /* build the name of the temp file containing the data set */ /* it will look like <<filenameXXXX.dcm>> */ /* delete the tmp file only if the result is a PAPYRUS file  */ /* if ...PAPYRUS file */ /* switch ...type of the content of the object */ /* make all the pointers of the object point to NULL */ /* free the cell */