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  

3dnewid.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

void Syntax (void)
int main (int argc, char *argv[])

Function Documentation

int main int    argc,
char *    argv[]
 

---------- Adapted from 3dZeropad.c by RWCox - 08 Aug 2001 ----------*

Definition at line 46 of file 3dnewid.c.

References AFNI_logger(), argc, free, getenv(), THD_3dim_dataset::idcode, machdep(), mainENTRY, MCW_new_idcode, MCW_idcode::str, Syntax(), THD_delete_3dim_dataset(), THD_open_one_dataset(), THD_write_3dim_dataset(), tross_Append_History(), and UUID_idcode().

00047 {
00048    THD_3dim_dataset * dset ;
00049    int iarg ;
00050    MCW_idcode idc ;
00051    char str[256] ;
00052 
00053    if( argc < 2 || strncmp(argv[1],"-help",4) == 0 ) Syntax() ;
00054 
00055    iarg = 1 ;
00056 
00057    mainENTRY("3dnewid main"); machdep();
00058 
00059    if( strcmp(argv[1],"-fun") == 0 ){         /* 22 May 2000: for fun */
00060       int nid=0 , ii ;
00061       char *eee = getenv("UUID") ;
00062       if( argc > 2 ) nid = strtol(argv[2],NULL,10) ;
00063       if( nid <= 0 ) nid = 1 ;
00064       if( eee == NULL ){
00065         for( ii=0 ; ii < nid ; ii++ ){
00066           idc = MCW_new_idcode() ; printf("%s\n",idc.str) ;
00067         }
00068       } else {                                /* 20 Aug 2002: test of niml.c */
00069         for( ii=0 ; ii < nid ; ii++ ){
00070           eee = UUID_idcode(); printf("%s\n",eee); free(eee);
00071         }
00072       }
00073       exit(0) ;
00074    }
00075 
00076    /*-- OK, not for fun --*/
00077 
00078    AFNI_logger("3dnewid",argc,argv) ;
00079 
00080    for( ; iarg < argc ; iarg++ ){
00081       dset = THD_open_one_dataset( argv[iarg] ) ;
00082       if( dset == NULL ){
00083          fprintf(stderr,"** Skipping dataset %s\n",argv[iarg]) ;
00084          continue ;
00085       }
00086       dset->idcode = MCW_new_idcode() ;
00087       sprintf(str,"3dnewid %s\n",argv[iarg]) ;
00088       tross_Append_History( dset , str) ;
00089       THD_write_3dim_dataset( NULL , NULL , dset , False ) ;
00090       THD_delete_3dim_dataset( dset , False ) ;
00091    }
00092    exit(0) ;
00093 }

void Syntax void   
 

31 July 1996: be more specific about errors *

Definition at line 9 of file 3dnewid.c.

00010 {
00011    printf(
00012     "Assigns a new ID code to a dataset; this is useful when making\n"
00013     "a copy of a dataset, so that the internal ID codes remain unique.\n\n"
00014     "Usage: 3dnewid dataset [dataset ...]\n"
00015     " or\n"
00016     "       3dnewid -fun [n]\n"
00017     "       to see what n randomly generated ID codes look like.\n"
00018     "       (If the integer n is not present, 1 ID code is printed.)\n"
00019     "\n"
00020     "How ID codes are created (here and in other AFNI programs):\n"
00021     "----------------------------------------------------------\n"
00022     "The AFNI ID code generator attempts to create a globally unique\n"
00023     "string identifier, using the following steps.\n"
00024     "1) A long string is created from the system identifier\n"
00025     "   information ('uname -a'), the current epoch time in seconds\n"
00026     "   and microseconds, the process ID, and the number of times\n"
00027     "   the current process has called the ID code function.\n"
00028     "2) This string is then hashed into a 128 bit code using the\n"
00029     "   MD5 algorithm. (cf. file thd_md5.c)\n"
00030     "3) This bit code is then converted to a 22 character string\n"
00031     "   using Base64 encoding, replacing '/' with '-' and '+' with '_'.\n"
00032     "   With these changes, the ID code can be used as a Unix filename\n"
00033     "   or an XML name string. (cf. file thd_base64.c)\n"
00034     "4) A 4 character prefix is attached at the beginning to produce\n"
00035     "   the final ID code.  If you set the environment variable\n"
00036     "   IDCODE_PREFIX to something, then its first 3 characters and an\n"
00037     "   underscore will be used for the prefix of the new ID code,\n"
00038     "   provided that the first character is alphabetic and the other\n"
00039     "   2 alphanumeric; otherwise, the default prefix 'NIH_' will be\n"
00040     "   used.\n"
00041     "The source code is function UNIQ_idcode() in file niml.c.\n"
00042    ) ;
00043    exit(0) ;
00044 }
 

Powered by Plone

This site conforms to the following standards: