/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/hydrotrend/hydrocommandline.c

Go to the documentation of this file.
00001 /*
00002  *  HydroCommandLine.c
00003  *
00004  *
00005  *  Author:    A.J. Kettner (April 2003)
00006  * 
00007  *  HydroCommandline handles the commandline imput to set web variables
00008  *  and the output directory structure.
00009  * 
00010  *  
00011  * Variable             Def.Location            Type            Units   Usage
00012  * --------             ------------            ----            -----   -----
00013  * input_in             HydroCommandline.c      char            -               string variable to set the input directory
00014  * 
00015  */
00016 
00017 #include <string.h>
00018 #include "hydroclimate.h"
00019 #include "hydroinout.h"
00020 #include "hydroparams.h"
00021 #include "hydroalloc_mem.h"
00022 #define MAXLENGTH (80)
00023 #define TEST1 (2)
00024 #define TEST5 (5)
00025  
00026 /*-----------------------------
00027  *  Start of HydroCommandLine
00028  *-----------------------------*/
00029 int hydrocommandline(int *argc,char **argv)
00030 { 
00031 
00032 /*-------------------
00033  *  Local Variables
00034  *-------------------*/
00035 int err, jj;
00036 char input_in[300];
00037 
00038 /*------------------------
00039  *  Initialize Variables
00040  *------------------------*/
00041 err = 0;
00042 
00043         for (jj=0; jj<*argc; jj++){
00044                 strcpy(commandlinearg[jj],argv[jj]);
00045         }
00046 
00047         if (*argc == 1){
00048    /*---------------------------------------------------
00049     *  argc = 1 creats standard output filenames named
00050     *  HYDRO.*
00051     *---------------------------------------------------*/
00052                 strcpy(commandlinearg[1],DUMMY);
00053                 fprintf(stderr, "\n  Hydrotrend started without project title. Output will \n");
00054                 fprintf(stderr, "  be written to standard output files, named %s.\n",commandlinearg[1]);
00055                 fprintf(stderr, "  Old files will be overwritten!!\n\n");
00056         }
00057         
00058         if (*argc == 2)
00059    /*------------------------------------------------
00060     *  argc = 2 makes it possible to make different
00061     *  filenames per each run.
00062     *------------------------------------------------*/
00063                 for( jj=0; jj<MAXLENGTH; jj++ ){
00064                         if (commandlinearg[1][jj] == '%' || commandlinearg[1][jj] == '*' || commandlinearg[1][jj] == '#'
00065                                         || commandlinearg[1][jj] == '@' || commandlinearg[1][jj] == '-' || commandlinearg[1][jj] == '^'
00066                                         || commandlinearg[1][jj] == '"' || commandlinearg[1][jj] == '?' || commandlinearg[1][jj] == '!'
00067                                         || commandlinearg[1][jj] == '.' || commandlinearg[1][jj] == ',' || commandlinearg[1][jj] == '$'){
00068                                 fprintf(stderr, "  HydroTrend ERROR: Incorrect command line \n");
00069                                 fprintf(stderr, "    You can use only characters and numbers to name the project. \n");
00070                                 fprintf(stderr, "Don't use %c.\n",commandlinearg[1][jj]);
00071                                 err++;
00072                         }
00073                         commandlinearg[1][jj]=toupper(commandlinearg[1][jj]);
00074                 }
00075 
00076         if (*argc == 3){
00077    /*------------------------------------------------
00078     *  argc = 3 is reserved for the web application,
00079     *  so only use a third argument for the web
00080     *------------------------------------------------*/
00081                 for ( jj=0; jj<MAXLENGTH; jj++ )
00082                         if (commandlinearg[2][jj] != '0' && commandlinearg[2][jj] != '1' && commandlinearg[2][jj] != '2'
00083                                         && commandlinearg[2][jj] != '3' && commandlinearg[2][jj] != '4' && commandlinearg[2][jj] != '5'
00084                                         && commandlinearg[2][jj] != '6' && commandlinearg[2][jj] != '7' && commandlinearg[2][jj] != '8'
00085                                         && commandlinearg[2][jj] != '9'){
00086                                 commandlinearg[2][jj]  = '/';
00087                                 commandlinearg[2][jj+1]= '\0';
00088                                 jj = MAXLENGTH;
00089                         }
00090                 webflag=1;
00091             strcpy (input_in,   INPUTSTRING);
00092         strcat (input_in,   commandlinearg[2]);
00093             strcat (input_in,   commandlinearg[1]);
00094         strcat (ffnameinput,input_in);
00095             strcpy (ffnamehyps, input_in);
00096         strcpy (ffnameinputgw_r, input_in);
00097             strcat (ffnameinputgw_r, fnameclimateext);
00098         strcat (ffnameinput,fnameinputext);
00099             strcat (ffnamehyps, fnamehypsext);          
00100         }
00101 
00102         if (*argc >3){
00103    /*-----------------------------------------------
00104     *  argc > 3 does not exist. It will handle the
00105     *  output as if argc = 1.
00106     *-----------------------------------------------*/
00107                 strcpy(commandlinearg[1],DUMMY);
00108                 fprintf(stderr, "  HydroTrend ERROR: Incorrect command line \n");
00109                 fprintf(stderr, "    argc should equal 1 or 2 \n");
00110                 fprintf(stderr, "    argc = %d \n", *argc);
00111                 fprintf(stderr, "    HydroTrend does not use more than 2 command line arguments. \n");
00112                 fprintf(stderr, "    Ignoring all arguments. \n");
00113                 fprintf(stderr, "    Output will be written to standard output files, named %s.\n",commandlinearg[1]);
00114         }
00115 
00116         return(err);
00117 } /* HydroCommandLine.c */ 

Generated on Fri Jan 4 18:04:14 2008 for sedflux by  doxygen 1.5.2