IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12916


Ignore:
Timestamp:
Apr 18, 2007, 4:10:12 PM (19 years ago)
Author:
rhl
Message:

pmConfig no longer owns arg[cv];

Location:
trunk/psModules/src/config
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.h

    r12906 r12916  
    55 *  @author Eugene Magnier, IfA
    66 *
    7  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-04-18 22:42:33 $
     7 *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-04-19 02:10:12 $
    99 *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    6161
    6262/// Allocator for pmConfig
    63 pmConfig *pmConfigAlloc(int *argc,      /// Number of command-line arguments
    64                         char **argv     /// Command-line arguments
    65                        );
     63pmConfig *pmConfigAlloc();
    6664
    6765/// Set static configuration information
     
    8482pmConfig *pmConfigRead(int *argc,       ///< Number of command-line arguments
    8583                       char **argv, ///< Array of command-line arguments
    86                        char *defaultRecipe ///< name of top-level recipe for this program
     84                       const char *defaultRecipe ///< name of top-level recipe for this program
    8785                      );
    8886
     
    143141/// Given the 'file' and 'list' arguments (e.g., "-file" and "-list"), find the arguments associated with
    144142/// these words and interpret them as lists of files.  Return an array of the resulting filenames.
    145 psArray *pmConfigFileSets(pmConfig *config, ///< Configuration, containing command-line arguments
     143psArray *pmConfigFileSets(int *argc,    ///< Number of arguments (I/O)
     144                          char **argv,  ///< Array of arguments
    146145                          const char *file, ///< CL argument specifying a filename
    147146                          const char *list ///< CL argument specifying a text file with a list of filenames
     
    153152/// stuffs the array of filenames into the metadata under "name".
    154153bool pmConfigFileSetsMD(psMetadata *metadata, ///< Metadata into which to stuff the array
    155                         pmConfig *config, ///< Configuration (which command-line arguments)
     154                        int *argc,    ///< Number of arguments (I/O)
     155                        char **argv,  ///< Array of arguments
    156156                        const char *name, ///< Name for array in the metadata
    157157                        const char *file, ///< CL argument specifying a filename
  • trunk/psModules/src/config/pmConfigRecipes.c

    r12890 r12916  
    5151
    5252// this function may be called several times.  it attempts to load the recipe data from one of
    53 // three locations: config->site, config->camera, and config->argv.  We cannot read the recipes
     53// three locations: config->site, config->camera, and argv.  We cannot read the recipes
    5454// from config->camera until a camera has been read BUT, the argv recipes must override the
    5555// camera and site recipes.
     
    124124
    125125// search for options of the form -D KEY VALUE or -D RECIPE:KEY VALUE
    126 bool pmConfigLoadRecipeOptions (pmConfig *config, char *flag)
     126bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag)
    127127{
    128128    bool success;
     
    140140
    141141    // -D key value (all added as string)
    142     while ((argNum = psArgumentGet (*config->argc, config->argv, flag))) {
    143         psArgumentRemove (argNum, config->argc, config->argv);
     142    while ((argNum = psArgumentGet (*argc, argv, flag))) {
     143        psArgumentRemove (argNum, argc, argv);
    144144
    145145        // do we have enough arguments?
    146         if (argNum + 1 >= *config->argc) {
     146        if (argNum + 1 >= *argc) {
    147147            psError(PS_ERR_IO, true, "insufficient parameters for command-line argument -D");
    148148            return false;
     
    152152        const char *recipeName = NULL;
    153153        char *key;
    154         psArray *words = psStringSplitArray(config->argv[argNum], ":", false);
     154        psArray *words = psStringSplitArray(argv[argNum], ":", false);
    155155        switch (words->n) {
    156156        case 1:
     
    182182        bool valid = false;
    183183        if (!strcmp (flag, "-D")) {
    184             psMetadataAddStr (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", config->argv[argNum+1]);
     184            psMetadataAddStr (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", argv[argNum+1]);
    185185            valid = true;
    186186        }
    187187        if (!strcmp (flag, "-Di")) {
    188             psMetadataAddS32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atoi(config->argv[argNum+1]));
     188            psMetadataAddS32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atoi(argv[argNum+1]));
    189189            valid = true;
    190190        }
    191191        if (!strcmp (flag, "-Df")) {
    192             psMetadataAddF32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atof(config->argv[argNum+1]));
     192            psMetadataAddF32 (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", atof(argv[argNum+1]));
    193193            valid = true;
    194194        }
    195195        if (!strcmp (flag, "-Db")) {
    196             if (!strcasecmp (config->argv[argNum+1], "true")) {
     196            if (!strcasecmp (argv[argNum+1], "true")) {
    197197                psMetadataAddBool (recipe, PS_LIST_TAIL, key, PS_META_REPLACE, "", true);
    198198            } else {
     
    204204        assert (valid);  // flag may be: -D, -Df, -Di, -Db
    205205
    206         psArgumentRemove (argNum, config->argc, config->argv);
    207         psArgumentRemove (argNum, config->argc, config->argv);
     206        psArgumentRemove (argNum, argc, argv);
     207        psArgumentRemove (argNum, argc, argv);
    208208    }
    209209    return true;
     
    214214// if VALUE is not an exiting file, it is a symbolic lookup: it is saved on config->recipeSymbols
    215215// for later interpolation (pmConfigReadRecipes with option CL)
    216 bool pmConfigLoadRecipeArguments (pmConfig *config)
     216bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config)
    217217{
    218218    bool success;
     
    228228    // Go through the command-line arguments
    229229    int argNum; // Argument number for "-recipe"
    230     while ((argNum = psArgumentGet(*config->argc, config->argv, "-recipe")) > 0) {
    231         psArgumentRemove(argNum, config->argc, config->argv);
    232         if (argNum + 1 >= *config->argc) {
     230    while ((argNum = psArgumentGet(*argc, argv, "-recipe")) > 0) {
     231        psArgumentRemove(argNum, argc, argv);
     232        if (argNum + 1 >= *argc) {
    233233            psError(PS_ERR_IO, false, "-recipe command-line switch provided without the required recipe and source\n");
    234234            return false;
    235235        }
    236236
    237         char *recipeName = psStringCopy(config->argv[argNum]); // Name of the recipe
    238         psArgumentRemove(argNum, config->argc, config->argv);
    239         char *recipeSource = psStringCopy(config->argv[argNum]); // Source of the recipe
    240         psArgumentRemove(argNum, config->argc, config->argv);
     237        char *recipeName = psStringCopy(argv[argNum]); // Name of the recipe
     238        psArgumentRemove(argNum, argc, argv);
     239        char *recipeSource = psStringCopy(argv[argNum]); // Source of the recipe
     240        psArgumentRemove(argNum, argc, argv);
    241241
    242242        if (access(recipeSource, R_OK) == 0) {
  • trunk/psModules/src/config/pmConfigRecipes.h

    r11251 r12916  
    66 *  @author Eugene Magnier, IfA
    77 *
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-01-24 01:05:41 $
     8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-04-19 02:10:12 $
    1010 *  Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1111 */
     
    2626
    2727
    28 bool pmConfigLoadRecipeArguments (pmConfig *config);
    29 bool pmConfigLoadRecipeOptions (pmConfig *config, char *flag);
     28bool pmConfigLoadRecipeArguments (int *argc, char **argv, pmConfig *config);
     29bool pmConfigLoadRecipeOptions (int *argc, char **argv, pmConfig *config, char *flag);
    3030psMetadata *pmConfigRecipeOptions (pmConfig *config, char *recipe);
    3131
Note: See TracChangeset for help on using the changeset viewer.