Changeset 86919e in git for resources


Ignore:
Timestamp:
Jul 9, 2013, 6:11:06 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
9eb3048810619c2e3a21b42e75704afa4aa18af5
Parents:
f88e07c79359c9680861c6db7a48478e2119bc60
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2013-07-09 18:11:06+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2013-07-09 22:25:11+02:00
Message:
Better debug output for resources + minor improvements
Location:
resources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • resources/feResource.cc

    rf88e07 r86919e  
    151151}
    152152
    153 char* feGetResource(const char id)
    154 {
    155   return feResource(feGetResourceConfig(id), -1);
     153char* feGetResource(const char id, int warn)
     154{
     155  return feResource(feGetResourceConfig(id), warn);
    156156}
    157157
     
    181181    feArgv0 = strdup(argv0);
    182182#ifdef RESOURCE_DEBUG
    183   printf("feInitResources: entering with argv0=%s=\n", feArgv0);
     183  printf("feInitResources(argv0: '%s'): entering...\n", feArgv0);
    184184#endif
    185185  // init some Resources
     
    192192  char* path = feResource('p');
    193193#ifdef RESOURCE_DEBUG
    194   printf("feInitResources: setting path with argv0=%s=\n", path);
     194  printf("feInitResources(argv0): setting path with '%s'\n", path);
    195195#endif
    196196#ifdef HAVE_PUTENV
     
    219219  }
    220220#ifdef RESOURCE_DEBUG
    221   printf("feInitResources: entering with argv0=%s=\n", feArgv0);
     221  printf("feInitResources(): entering...\n");
    222222#endif
    223223  // init some Resources
     
    275275  /*assume(config != NULL);*/
    276276#ifdef RESOURCE_DEBUG
    277   printf("feInitResource: entering for %s\n", config->key);
     277  printf("feInitResource(config->key: '%s', warn: '%d') : entering ...\n", config->key, warn);
    278278#endif
    279279
     
    287287    {
    288288#ifdef RESOURCE_DEBUG
    289       printf("feInitResource: Found value from env:%s\n", evalue);
     289      printf("feInitResource(config,warn): Found value from env:%s\n", evalue);
    290290#endif
    291291      strcpy(value, evalue);
     
    296296      {
    297297#ifdef RESOURCE_DEBUG
    298         printf("feInitResource: Set value of %s to =%s=\n", config->key, value);
     298        printf("feInitResource(config,warn): Set value of config (with key: '%s') to '%s'\n", config->key, value);
    299299#endif
    300300        config->value = strdup(value);
     
    326326    char* executable = feResource('S');
    327327#ifdef RESOURCE_DEBUG
    328       printf("feInitResource: Get %s from %s\n", config->key, executable);
     328      printf("feInitResource(config,warn): Get '%s' from \"%s\"\n", config->key, executable);
    329329#endif
    330330    if (executable != NULL)
     
    346346  else if (config->fmt == NULL)
    347347  {
    348     printf("Bug >>Wrong Resource Specification of %s<< at %s:%d\n",config->key,__FILE__,__LINE__);
     348    printf("Bug >>Wrong Resource Specification of '%s'<< at \"%s:%d\"\n",config->key,__FILE__,__LINE__);
     349    // TODO: printf -> WarnS???
    349350    return NULL;
    350351  }
     
    355356  {
    356357#ifdef RESOURCE_DEBUG
    357     printf("feInitResource: Set value of %s to =%s=\n", config->key, value);
     358    printf("feInitResource(config,warn): Set value of '%s' to \"%s\"\n", config->key, value);
    358359#endif
    359360    config->value = strdup(value);
     
    371372        config->value = strdup(value);
    372373#ifdef RESOURCE_DEBUG
    373         printf("feInitResource: Set value of %s to =%s=\n", config->key, config->value);
     374        printf("feInitResource(config,warn): Set value of '%s' to \"%s\"\n", config->key, config->value);
    374375#endif
    375376        return config->value;
     
    382383  if (warn > 0 || (warn < 0 && config->value != NULL))
    383384  {
    384     printf("// ** Could not get %s.\n", config->key);
    385     printf("// ** Either set environment variable %s to %s,\n",
     385    printf("// ** Could not get '%s'.\n", config->key);
     386    printf("// ** Either set environment variable '%s' to '%s',\n",
    386387         config->env, config->key);
    387388    feSprintf(value, config->fmt, warn);
    388     printf("// ** or make sure that %s is at %s\n", config->key, value);
    389   }
    390 #ifdef RESOURCE_DEBUG
    391       printf("feInitResource: Set value of %s to NULL", config->key);
     389    printf("// ** or make sure that '%s' is at \"%s\"\n", config->key, value);
     390  }
     391#ifdef RESOURCE_DEBUG
     392  printf("feInitResource(config,warn): Set value of '%s' to NULL", config->key);
    392393#endif
    393394  config->value = NULL;
     
    417418#endif
    418419#ifdef RESOURCE_DEBUG
    419   printf("feGetExpandedExecutable: calling find_exec with =%s=\n", feArgv0);
     420  printf("feGetExpandedExecutable: calling find_exec with \"%s\"\n", feArgv0);
    420421#endif
    421422  char executable[MAXRESOURCELEN];
    422423  char* value = omFindExec(feArgv0, executable);
    423424#ifdef RESOURCE_DEBUG
    424   printf("feGetExpandedExecutable: find_exec exited with =%s=%d\n", executable, access(executable, X_OK));
     425  printf("feGetExpandedExecutable: find_exec exited with \"%s\": %d\n", executable, access(executable, X_OK));
    425426#endif
    426427  if (value == NULL)
    427428  {
    428     printf("Bug >>Could not get expanded executable from %s<< at %s:%d\n",feArgv0,__FILE__,__LINE__);
     429    printf("Bug >>Could not get expanded executable from \"%s\"<< at %s:%d\n",feArgv0,__FILE__,__LINE__);
    429430    return NULL;
    430431  }
     
    436437{
    437438#ifdef RESOURCE_DEBUG
    438   printf("feVerifyResourceValue: entering with =%s=\n", value);
    439   printf("%d:%d\n", access(value, R_OK), access(value, X_OK));
     439  printf("feVerifyResourceValue(type: %d, value: \"%s\"): entering\n", (int)type, value);
     440  printf("Access: ROK: %d, XOK: %d\n", access(value, R_OK), access(value, X_OK));
    440441#endif
    441442  switch(type)
     
    590591    path_comps[i] = feCleanUpFile(path_comps[i]);
    591592#ifdef RESOURCE_DEBUG
    592   PrintS("feCleanUpPath: after CleanUpName: ");
     593  printf("feCleanUpPath: after CleanUpName: ");
    593594  for (i=0; i<n_comps; i++)
    594     Print("%s:", path_comps[i]);
    595   Print("\n");
     595    printf("%s:", path_comps[i]);
     596  printf("\n");
    596597#endif
    597598
     
    600601#ifdef RESOURCE_DEBUG
    601602    if (access(path_comps[i], X_OK | R_OK))
    602       Print("feCleanUpPath: remove %d:%s -- can not access\n", i, path_comps[i]);
     603      printf("feCleanUpPath: remove %d:%s -- can not access\n", i, path_comps[i]);
    603604#endif
    604605    if ( ! access(path_comps[i], X_OK | R_OK))
     
    611612          // found a duplicate
    612613#ifdef RESOURCE_DEBUG
    613           Print("feCleanUpPath: remove %d:%s -- equal to %d:%s\n", j, path_comps[j], i, path_comps[i]);
     614          printf("feCleanUpPath: remove %d:%s -- equal to %d:%s\n", j, path_comps[j], i, path_comps[i]);
    614615#endif
    615616          j = i+1;
     
    649650  free(path_comps);
    650651#ifdef RESOURCE_DEBUG
    651   Print("feCleanUpPath: leaving with path=%s=\n", opath);
     652  printf("feCleanUpPath: leaving with path=%s=\n", opath);
    652653#endif
    653654  return opath;
  • resources/feResource.h

    rf88e07 r86919e  
    4040char* feResource(const char* key, int warn = -1);
    4141
    42 char* feGetResource(const char id);
     42char* feGetResource(const char id, int warn = -1);
    4343
    4444// char* feResourceDefault(const char id);
Note: See TracChangeset for help on using the changeset viewer.