StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MyPackage.cxx
1 // $Id: MyPackage.cxx,v 1.1 2009/11/24 19:02:50 fine Exp $
2 //*-- Author : Valery Fine(fine@bnl.gov) 24/11/2009
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include "TString.h"
6 #include "TSystem.h"
7 
8 namespace {
9 // the text inside of namespace is a copy of the standalone application
10 // #include "MyPackage.cxx"
11 void usage(const char *name) {
12  printf( "\n\nUsage: %s [input_file [ output_file]]\n",name);
13  printf( "-----\n");
14 }
15 
16 int main(int argc, char * argv[])
17 {
18  const char *packageName="No_name";
19  printf("Hello World %d: \n", argc);
20  switch (argc) {
21  case 3: printf("\tThe output file name <%s>\n", argv[2]);
22  case 2: printf("\tThe input file name <%s>\n", argv[1]);
23  case 1: printf("\tThe package name <%s>", argv[0]);
24  packageName = argv[0];
25  break;
26  default:
27  printf("\tNo paramater\n");
28  break;
29  }
30  usage(packageName);
31  return 0;
32 }
33 
34 }
35 
36 int MyPackage(const char *infile="$USER/example.list"
37  , const char *outfile = "$SCRATCH/example.root")
38 {
39  TString sInFile = infile;
40  TString sOutFile = outfile;
41  // expand the environment variables if needed
42  gSystem->ExpandPathName(sInFile);
43  gSystem->ExpandPathName(sOutFile);
44 
45  char *argv[] = {(char*)"MyPackage",(char*) sInFile.Data(),(char*) sOutFile.Data() };
46 
47  printf( "\n\nUsage: root.exe -b -l -q \'%s.cxx+[(\"input_file\" [,\"output_file\"])\']\n",argv[0]);
48  printf( "------ The square brackets [] are to show the optional components\n");
49 
50  return main(3, argv);
51 }
52