~ubuntu-branches/ubuntu/saucy/sane-backends/saucy

« back to all changes in this revision

Viewing changes to sanei/sanei_config.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-14 14:28:56 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110214142856-6gxjetg88q9zctid
Tags: 1.0.22-0ubuntu1
* New upstream release
* debian/control:
  - Use standards version 3.9.1
* debian/patches/allow_dll.d_symlinks.patch:
* debian/patches/fix_epson2_cancel.patch:
* debian/patches/fix_epson2_commands.patch:
* debian/patches/fix_xerox_mfp_color_mode.patch:
* debian/patches/genesys_disable_raw_data_log.patch:
* debian/patches/no_translations.patch:
* debian/patches/saned_exit_avahi_process.patch:
* debian/patches/scsi_perfection_2450.patch:
* debian/patches/scsi_scanjet_4c.patch:
* debian/patches/xerox_mfp_new_ids.patch:
  - Applied upstream
* debian/watch:
  - Dropped, the URL is not consistent between releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
#include <FindDirectory.h>
77
77
#endif
78
78
 
79
 
static const char *dir_list;
 
79
static char *dir_list;
80
80
 
81
 
FILE *
82
 
sanei_config_open (const char *filename)
 
81
const char *
 
82
sanei_config_get_paths ()
83
83
{
84
 
  char *copy, *next, *dir, result[PATH_MAX];
85
 
  FILE *fp = 0;
 
84
#ifdef __BEOS__
 
85
  char result[PATH_MAX];
 
86
#endif
 
87
  void *mem;
 
88
  char *dlist;
86
89
  size_t len;
87
 
  void *mem = 0;
88
90
 
89
91
  if (!dir_list)
90
92
    {
91
93
      DBG_INIT();
92
94
 
93
 
      dir_list = getenv ("SANE_CONFIG_DIR");
 
95
      dlist = getenv ("SANE_CONFIG_DIR");
 
96
      if (dlist)
 
97
        dir_list = strdup (dlist);
94
98
#ifdef __BEOS__
95
99
      /* ~/config/settings/SANE takes precedence over /etc/sane.d/ */
96
100
      if (!dir_list)
99
103
            {
100
104
              strcat(result,"/SANE");
101
105
              strcat(result,DIR_SEP); /* do append the default ones */
102
 
              dir_list = result;
 
106
              dir_list = strdup (result);
103
107
            }
104
108
        }
105
109
#endif
110
114
            {
111
115
              /* append default search directories: */
112
116
              mem = malloc (len + sizeof (DEFAULT_DIRS));
113
 
 
114
117
              memcpy (mem, dir_list, len);
115
118
              memcpy ((char *) mem + len, DEFAULT_DIRS, sizeof (DEFAULT_DIRS));
 
119
              free (dir_list);
116
120
              dir_list = mem;
117
121
            }
118
122
        }
119
123
      else
120
 
        dir_list = DEFAULT_DIRS;
121
 
    }
122
 
 
123
 
  copy = strdup (dir_list);
124
 
 
125
 
  if (mem)
126
 
    free(mem);
 
124
        {
 
125
          /* Create a copy, since we might call free on it */
 
126
          dir_list = strdup (DEFAULT_DIRS);
 
127
        }
 
128
    }
 
129
  DBG (5, "sanei_config_get_paths: using config directories  %s\n", dir_list);
 
130
 
 
131
  return dir_list;
 
132
}
 
133
 
 
134
FILE *
 
135
sanei_config_open (const char *filename)
 
136
{
 
137
  char *next, *dir, result[PATH_MAX];
 
138
  const char *cfg_dir_list;
 
139
  FILE *fp;
 
140
  char *copy;
 
141
 
 
142
  cfg_dir_list = sanei_config_get_paths ();
 
143
  if (!cfg_dir_list)
 
144
    {
 
145
      DBG(2, "sanei_config_open: could not find config file `%s'\n", filename);
 
146
      return NULL;
 
147
    }
 
148
 
 
149
  copy = strdup (cfg_dir_list);
127
150
 
128
151
  for (next = copy; (dir = strsep (&next, DIR_SEP)) != 0; )
129
152
    {