Changeset f323dd1 in git for findexec


Ignore:
Timestamp:
Feb 29, 2012, 5:18:58 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
8d8cd944663cf80b3fd163a42279526ce163a5fd
Parents:
d8b0f69f9828897dca663d5bb516369b1b0ac64a
Message:
chg: move feResource to findexec lib
Location:
findexec
Files:
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • findexec/Makefile.am

    rd8b0f69 rf323dd1  
    1616INCLUDES = -I${top_srcdir} -I${top_builddir}
    1717
    18 SOURCES  = omFindExec.c
     18SOURCES  = omFindExec.c feResource.cc
    1919libfindexec_la_SOURCES   = $(SOURCES)
    2020libfindexec_g_la_SOURCES = $(SOURCES)
     
    2222libfindexec_includedir  =$(includedir)/singular/findexec/
    2323
    24 libfindexec_include_HEADERS = omFindExec.h
     24libfindexec_include_HEADERS = omFindExec.h feResource.h
    2525
    2626
  • findexec/feResource.cc

    rd8b0f69 rf323dd1  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id$ */
    54/*
    65* ABSTRACT: management of resources
     
    109#include <unistd.h>
    1110#include <string.h>
    12 #include <unistd.h>
     11#include <stdio.h>
    1312#include <sys/param.h>
    1413
     
    3433
    3534
    36 #include <reporter/reporter.h>
     35//#include <reporter/reporter.h>
    3736//char* feResource(const char id, int warn = -1);
    3837//char* feResource(const char* key, int warn = -1);
     
    4140// #define RESOURCE_DEBUG
    4241
    43 #define SINGULAR_DEFAULT_DIR "/usr/local/Singular/"S_VERSION1
     42#define SINGULAR_DEFAULT_DIR "/usr/local/Singular/"PACKAGE_VERSION
    4443
    4544/*****************************************************************
     
    4847 *
    4948 *****************************************************************/
    50 typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType;
    51 
    52 typedef struct feResourceConfig_s
    53 {
    54   const char*           key;   // key to identify resource
    55   const char            id;    // char id to identify resource
    56   feResourceType  type;  // type of Resource
    57   const char*           env;   // env variable to look for
    58   const char*           fmt;   // format string -- see below for epxlaination
    59   char*                 value; // what it was set to: may be changed
    60 } feResourceConfig_s;
    61 typedef feResourceConfig_s * feResourceConfig;
    62 
    6349// feSprintf transforms format strings as follows:
    6450// 1.) substrings of the form %c (c being a letter) are replaced by respective resource value
     
    6854// 1.) '/' characters are replaced by respective directory - separators
    6955// 2.) ';' characters are replaced by respective path separators
    70 static feResourceConfig_s feResourceConfigs[] =
     56feResourceConfig_s feResourceConfigs[] =
    7157{
    7258  {"SearchPath",    's', feResPath,  NULL,
     
    9682  {"HtmlHelpFile",'C',  feResFile,  "SINGULAR_CHM_FILE",    "%r/doc/Manual.chm",    (char *)""},
    9783#endif
    98   {"ManualUrl", 'u',    feResUrl,   "SINGULAR_URL",         "http://www.singular.uni-kl.de/Manual/"S_VERSION1,    (char *)""},
     84  {"ManualUrl", 'u',    feResUrl,   "SINGULAR_URL",         "http://www.singular.uni-kl.de/Manual/"PACKAGE_VERSION,    (char *)""},
    9985  {"ExDir",     'm',    feResDir,   "SINGULAR_EXAMPLES_DIR","%r/examples",          (char *)""},
    10086  {"Path",      'p',    feResPath,  NULL,                   "%b;$PATH",             (char *)""},
     
    130116static char* feInitResource(feResourceConfig config, int warn);
    131117static char* feGetExpandedExecutable();
    132 static BOOLEAN feVerifyResourceValue(feResourceType type, char* value);
     118static int feVerifyResourceValue(feResourceType type, char* value);
    133119static char* feCleanResourceValue(feResourceType type, char* value);
    134120static char* feCleanUpFile(char* fname);
     
    278264static char* feInitResource(feResourceConfig config, int warn)
    279265{
    280   assume(config != NULL);
     266  /*assume(config != NULL);*/
    281267#ifdef RESOURCE_DEBUG
    282268  printf("feInitResource: entering for %s\n", config->key);
     
    351337  else if (config->fmt == NULL)
    352338  {
    353     sprintf(value, "Wrong Resource Specification of %s", config->key);
    354     dReportBug(value);
     339    printf("Bug >>Wrong Resource Specification of %s<< at %s:%d\n",config->key,__FILE__,__LINE__);
    355340    return NULL;
    356341  }
     
    388373  if (warn > 0 || (warn < 0 && config->value != NULL))
    389374  {
    390     Warn("Could not get %s. ", config->key);
    391     Warn("Either set environment variable %s to %s,",
     375    printf("// ** Could not get %s. ", config->key);
     376    printf("// ** Either set environment variable %s to %s,",
    392377         config->env, config->key);
    393378    feSprintf(value, config->fmt, warn);
    394     Warn("or make sure that %s is at %s", config->key, value);
     379    printf("// ** or make sure that %s is at %s", config->key, value);
    395380  }
    396381#ifdef RESOURCE_DEBUG
     
    405390  if (feArgv0 == NULL || *feArgv0 == '\0')
    406391  {
    407     if (feArgv0 == NULL) dReportBug("feArgv0 == NULL");
    408     else dReportBug("feArgv0 == ''");
     392    if (feArgv0 == NULL)
     393      printf("Bug >>feArgv0 == NULL<< at %s:%d\n",__FILE__,__LINE__);
     394    else
     395      printf("Bug >>feArgv0 == ''<< at %s:%d\n",__FILE__,__LINE__);
    409396    return NULL;
    410397  }
     
    430417  if (value == NULL)
    431418  {
    432     char message[MAXRESOURCELEN];
    433     sprintf(message, "Could not get expanded executable from %s", feArgv0);
    434     dReportBug(message);
     419    printf("Bug >>Could not get expanded executable from %s<< at %s:%d\n",feArgv0,__FILE__,__LINE__);
    435420    return NULL;
    436421  }
     
    439424
    440425
    441 static BOOLEAN feVerifyResourceValue(feResourceType type, char* value)
     426static int feVerifyResourceValue(feResourceType type, char* value)
    442427{
    443428#ifdef RESOURCE_DEBUG
     
    449434      case feResUrl:
    450435      case feResPath:
    451         return TRUE;
     436        return 1;
    452437
    453438      case feResFile:
     
    459444
    460445      default:
    461         return FALSE;
     446        return 0;
    462447  }
    463448}
     
    663648static void mystrcpy(char* d, char* s)
    664649{
    665   assume(d != NULL && s != NULL);
     650  /*assume(d != NULL && s != NULL);*/
    666651  while (*s != '\0')
    667652  {
     
    727712}
    728713
    729 void feStringAppendResources(int warn)
    730 {
    731   int i = 0;
    732   char* r;
    733   StringAppend("%-10s:\t%s\n", "argv[0]", feArgv0);
    734   while (feResourceConfigs[i].key != NULL)
    735   {
    736     r = feResource(feResourceConfigs[i].key, warn);
    737     StringAppend("%-10s:\t%s\n", feResourceConfigs[i].key,
    738                  (r != NULL ? r : ""));
    739     i++;
    740   }
    741 }
  • findexec/feResource.h

    rd8b0f69 rf323dd1  
    1717 *
    1818 *****************************************************************/
     19typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType;
     20
     21typedef struct feResourceConfig_s
     22{
     23  const char*           key;   // key to identify resource
     24  const char            id;    // char id to identify resource
     25  feResourceType  type;  // type of Resource
     26  const char*           env;   // env variable to look for
     27  const char*           fmt;   // format string -- see below for epxlaination
     28  char*                 value; // what it was set to: may be changed
     29} feResourceConfig_s;
     30typedef feResourceConfig_s * feResourceConfig;
     31
     32extern feResourceConfig_s feResourceConfigs[];
     33
    1934// returns value of Resource as read-only string, or NULL
    2035// if Resource not found
     
    3651// Re-inits resources, should be called after changing env. variables
    3752void feReInitResources();
    38 // Prints resources into string with StringAppend, etc
    39 void feStringAppendResources(int warn = -1);
    4053#endif /* end ifdef __cplusplus */
    4154
Note: See TracChangeset for help on using the changeset viewer.