Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
SUMA_StripPath.c
Go to the documentation of this file.00001
00002
00003 #include "SUMA_suma.h"
00004
00005 #undef STAND_ALONE
00006
00007 #if defined SUMA_StripPath_STAND_ALONE
00008 #define STAND_ALONE
00009 #elif defined SUMA_ParseName_STAND_ALONE
00010 #define STAND_ALONE
00011 #endif
00012
00013 #ifdef STAND_ALONE
00014
00015 SUMA_SurfaceViewer *SUMAg_cSV;
00016 SUMA_SurfaceViewer *SUMAg_SVv = NULL;
00017
00018 int SUMAg_N_SVv = 0;
00019 SUMA_DO *SUMAg_DOv;
00020 int SUMAg_N_DOv = 0;
00021 SUMA_CommonFields *SUMAg_CF;
00022 #else
00023 extern SUMA_CommonFields *SUMAg_CF;
00024 #endif
00025
00026
00027 #ifdef SUMA_StripPath_STAND_ALONE
00028 void usageSUMA_StripPath ()
00029
00030 {
00031 printf ("\nUsage: SUMA_StripPath <Name> \n");
00032 printf ("\t \n\n");
00033 printf ("To Compile:\ngcc -DSUMA_StripPath_STAND_ALONE -Wall -o $1 $1.c -SUMA_lib.a -I/usr/X11R6/include -I./ \n\n");
00034 printf ("\t\t Ziad S. Saad SSCC/NIMH/NIH ziad@nih.gov \tThu Jan 24 10:55:18 EST 2002 \n");
00035 exit (0);
00036 }
00037
00038 int main (int argc,char *argv[])
00039 {
00040 char FuncName[100];
00041 SUMA_FileName Test;
00042
00043
00044 sprintf (FuncName,"SUMA_StripPath-Main-");
00045
00046
00047 if (argc < 2)
00048 {
00049 usageSUMA_StripPath ();
00050 exit (1);
00051 }
00052
00053 Test = SUMA_StripPath (argv[1]);
00054 if (Test.Path)
00055 {
00056 fprintf(stdout,"%s %s", Test.Path, Test.FileName);
00057 SUMA_free(Test.Path);
00058 if (Test.FileName) SUMA_free(Test.FileName);
00059 }
00060 fprintf (stdout,"\n");
00061
00062 return (0);
00063 }
00064 #endif
00065
00066 #ifdef SUMA_ParseName_STAND_ALONE
00067 void usageParseName_Main ()
00068
00069 {
00070 printf ("\nUsage: SUMA_ParseName <Name> \n");
00071 printf ("\t breaks a file name into path, filename and extension components.\n");
00072 printf ("\t The program outputs: Path FileName FileName_NoExtension Extension\n");
00073 printf ("\t Empty attributes are represented by (null).\n");
00074 printf ("\t\t Ziad S. Saad SSCC/NIMH/NIH ziad@nih.gov \t Thu Jan 9 15:48:09 EST 2003\n");
00075 exit (0);
00076 }
00077
00078 int main (int argc,char *argv[])
00079 {
00080 static char FuncName[]={"SUMA_ParseName_Main"};
00081 SUMA_PARSED_NAME *Test;
00082
00083 SUMAg_CF = SUMA_Create_CommonFields ();
00084 if (SUMAg_CF == NULL) {
00085 fprintf(SUMA_STDERR,"Error %s: Failed in SUMA_Create_CommonFields\n", FuncName);
00086 exit(1);
00087 }
00088
00089
00090 if (argc < 2)
00091 {
00092 usageParseName_Main ();
00093 exit (1);
00094 }
00095
00096 Test = SUMA_ParseFname (argv[1]);
00097 if (!Test) {
00098 fprintf (SUMA_STDERR,"(null) (null) (null) (null)\n");
00099 }else {
00100 if (Test->Path[0] != '\0') fprintf (SUMA_STDERR,"%s ", Test->Path);
00101 else fprintf (SUMA_STDERR,"(null) ");
00102 if (Test->FileName[0] != '\0') fprintf (SUMA_STDERR,"%s ", Test->FileName);
00103 else fprintf (SUMA_STDERR,"(null) ");
00104 if (Test->FileName_NoExt[0] != '\0') fprintf (SUMA_STDERR,"%s ", Test->FileName_NoExt);
00105 else fprintf (SUMA_STDERR,"(null) ");
00106 if (Test->Ext[0] != '\0') fprintf (SUMA_STDERR,"%s ", Test->Ext);
00107 else fprintf (SUMA_STDERR,"(null) ");
00108 fprintf (SUMA_STDERR,"\n");
00109 }
00110
00111 if (Test) SUMA_Free_Parsed_Name (Test);
00112
00113 exit (0);
00114 }
00115 #endif
00116