Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

thd_idcode.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 #include "mrilib.h"
00008 #include <time.h>
00009 #include "thd.h"
00010 
00011 /*-----------------------------------------------------------------------*/
00012 /*! Routine to return a (hopefully) unique ID code to be used to identify
00013     a dataset to other datasets.
00014 -------------------------------------------------------------------------*/
00015 
00016 MCW_idcode MCW_new_idcode(void)
00017 {
00018    MCW_idcode newid ;
00019    time_t tnow ;
00020    int nn ;
00021 
00022    UNIQ_idcode_fill( newid.str ) ;  /* thd_md5.c */
00023 
00024    tnow = time(NULL) ;
00025    MCW_strncpy( newid.date , ctime(&tnow) , MCW_IDDATE ) ;
00026    nn = strlen(newid.date) ;
00027    if( nn > 0 && newid.date[nn-1] == '\n' ) newid.date[nn-1] = '\0' ;
00028 
00029    return newid ;
00030 }
00031 
00032 /*-----------------------------------------------------------------------*/
00033 /*! Replace the string part of the ID code with a deterministic hash.
00034 -------------------------------------------------------------------------*/
00035 
00036 void MCW_hash_idcode( char *hstring , THD_3dim_dataset *dset ) /* 06 May 2005 */
00037 {
00038    char *hhh , *rp , rpath[2048] ;
00039    if( hstring == NULL || *hstring == '\0' && !ISVALID_DSET(dset) ) return ;
00040    rp = realpath( hstring , rpath ) ; if( rp == NULL ) rp = hstring ;
00041    hhh = UNIQ_hashcode(rp) ;
00042    MCW_strncpy( dset->idcode.str+3, hhh+3, MCW_IDSIZE-3 ); free((void *)hhh);
00043    return ;
00044 }
 

Powered by Plone

This site conforms to the following standards: