Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 345217
Collapse All | Expand All

(-)a/scm/custom-rt.scm (-1 / +4 lines)
Lines 63-69 Link Here
63
(define custom-file-path
63
(define custom-file-path
64
  (lambda (gsym)
64
  (lambda (gsym)
65
    (let* ((group-name (symbol->string gsym))
65
    (let* ((group-name (symbol->string gsym))
66
	   (path (string-append (get-config-path! #f)
66
           (config-path (get-config-path #f))
67
           (path (string-append (if config-path
68
                                  config-path
69
                                  "")
67
				"/customs/custom-"
70
				"/customs/custom-"
68
				group-name
71
				group-name
69
				".scm")))
72
				".scm")))
(-)a/scm/dynlib.scm (-6 / +7 lines)
Lines 34-47 Link Here
34
(define uim-dynlib-load-path
34
(define uim-dynlib-load-path
35
  (if (setugid?)
35
  (if (setugid?)
36
      (list (string-append (sys-pkglibdir) "/plugin"))
36
      (list (string-append (sys-pkglibdir) "/plugin"))
37
      (let ((home-dir (or (home-directory (user-name)) ""))
37
      (let* ((ld-library-path (getenv "LD_LIBRARY_PATH"))
38
	    (ld-library-path (getenv "LD_LIBRARY_PATH")))
38
             (config-path (get-config-path #f))
39
             (user-plugin-path (if config-path
40
                                 (string-append config-path "/plugin")
41
                                 '())))
39
	(filter string?
42
	(filter string?
40
		(append (list (getenv "LIBUIM_PLUGIN_LIB_DIR")
43
		(append (list (getenv "LIBUIM_PLUGIN_LIB_DIR")
41
			      (if home-dir
44
                              user-plugin-path
42
				  (string-append (get-config-path! #f) "/plugin")
45
                              (string-append (sys-pkglibdir) "/plugin"))
43
				  '())
44
			      (string-append (sys-pkglibdir) "/plugin"))
45
			;; XXX
46
			;; XXX
46
			(if ld-library-path
47
			(if ld-library-path
47
			    (string-split ld-library-path ":")
48
			    (string-split ld-library-path ":")
(-)a/scm/plugin.scm (-9 / +9 lines)
Lines 39-50 Link Here
39
(define uim-plugin-scm-load-path
39
(define uim-plugin-scm-load-path
40
  (if (setugid?)
40
  (if (setugid?)
41
      (list (sys-pkgdatadir))
41
      (list (sys-pkgdatadir))
42
      (let ((home-dir (or (home-directory (user-name)) ""))
42
      (let ((config-path (get-config-path #f))
43
            (scm-paths (string-split (load-path) ":")))
43
            (scm-paths (string-split (load-path) ":")))
44
	(filter string?
44
	(filter string?
45
		(append scm-paths
45
		(append scm-paths
46
		      (if home-dir
46
		      (if config-path
47
			  (list (string-append (get-config-path! #f) "/plugin"))
47
			  (list (string-append config-path "/plugin"))
48
			  '())
48
			  '())
49
		      (list (sys-pkgdatadir)))))))
49
		      (list (sys-pkgdatadir)))))))
50
50
Lines 71-79 Link Here
71
;; TODO: write test
71
;; TODO: write test
72
(define load-module-conf
72
(define load-module-conf
73
  (lambda ()
73
  (lambda ()
74
    (let* ((home-dir (or (home-directory (user-name)) ""))
74
    (let* ((config-path (get-config-path #f))
75
	   (user-module-dir (if home-dir
75
	   (user-module-dir (if config-path
76
				(string-append (get-config-path! #f) "/plugin/")
76
				(string-append config-path "/plugin/")
77
				#f))
77
				#f))
78
	   (conf-file "installed-modules.scm")
78
	   (conf-file "installed-modules.scm")
79
	   (user-conf-file (if user-module-dir
79
	   (user-conf-file (if user-module-dir
Lines 100-108 Link Here
100
;; TODO: write test
100
;; TODO: write test
101
(define load-enabled-modules
101
(define load-enabled-modules
102
  (lambda ()
102
  (lambda ()
103
    (let* ((home-dir (or (home-directory (user-name)) ""))
103
    (let* ((config-path (get-config-path #f))
104
	   (user-module-dir (if home-dir
104
	   (user-module-dir (if config-path
105
				(string-append (get-config-path! #f) "/plugin/")
105
				(string-append config-path "/plugin/")
106
				#f))
106
				#f))
107
	   (file "loader.scm")
107
	   (file "loader.scm")
108
	   (user-file (if user-module-dir
108
	   (user-file (if user-module-dir
(-)a/uim/uim-helper.c (-1 / +5 lines)
Lines 207-213 uim_helper_get_pathname(char *helper_path, int len) Link Here
207
  return UIM_TRUE;
207
  return UIM_TRUE;
208
208
209
 path_error:
209
 path_error:
210
  uim_fatal_error("uim_helper_get_pathname()");
210
#if USE_UIM_NOTIFY && !UIM_NON_LIBUIM_PROG
211
  uim_notify_fatal("uim_helper_get_pathname() failed");
212
#else
213
  fprintf(stderr, "uim_helper_get_pathname() failed\n");
214
#endif
211
  helper_path[0] = '\0';
215
  helper_path[0] = '\0';
212
216
213
  UIM_CATCH_ERROR_END();
217
  UIM_CATCH_ERROR_END();
(-)a/uim/uim-posix.c (-14 / +56 lines)
Lines 141-161 home_directory(uim_lisp user_) Link Here
141
  return MAKE_STR(home);
141
  return MAKE_STR(home);
142
}
142
}
143
143
144
uim_bool
144
static uim_bool
145
uim_check_dir(const char *dir)
145
uim_check_dir_internal(const char *dir, int need_prepare)
146
{
146
{
147
  struct stat st;
147
  struct stat st;
148
148
149
  if (stat(dir, &st) < 0)
149
  if (stat(dir, &st) < 0)
150
    return (mkdir(dir, 0700) < 0) ? UIM_FALSE : UIM_TRUE;
150
    if (need_prepare)	  
151
      return (mkdir(dir, 0700) < 0) ? UIM_FALSE : UIM_TRUE;
152
    else
153
      return UIM_FALSE;
151
  else {
154
  else {
152
    mode_t mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;
155
    mode_t mode = S_IFDIR | S_IRUSR | S_IWUSR | S_IXUSR;
153
    return ((st.st_mode & mode) == mode) ? UIM_TRUE : UIM_FALSE;
156
    return ((st.st_mode & mode) == mode) ? UIM_TRUE : UIM_FALSE;
154
  }
157
  }
155
}
158
}
156
159
160
/* FIXME: use appropriate name for this API */
161
uim_bool
162
uim_check_dir(const char *dir)
163
{
164
  int need_prepare = UIM_TRUE;
165
166
  return uim_check_dir_internal(dir, need_prepare);
167
}
168
157
static uim_lisp
169
static uim_lisp
158
c_check_dir(uim_lisp dir_)
170
c_prepare_dir(uim_lisp dir_)
159
{
171
{
160
  if (!uim_check_dir(REFER_C_STR(dir_))) {
172
  if (!uim_check_dir(REFER_C_STR(dir_))) {
161
    return uim_scm_f();
173
    return uim_scm_f();
Lines 163-170 c_check_dir(uim_lisp dir_) Link Here
163
  return uim_scm_t();
175
  return uim_scm_t();
164
}
176
}
165
177
166
uim_bool
178
static uim_bool
167
uim_get_config_path(char *path, int len, int is_getenv)
179
uim_get_config_path_internal(char *path, int len, int is_getenv, int need_prepare)
168
{
180
{
169
  char home[MAXPATHLEN];
181
  char home[MAXPATHLEN];
170
182
Lines 174-207 uim_get_config_path(char *path, int len, int is_getenv) Link Here
174
  if (!uim_get_home_directory(home, sizeof(home), getuid()) && is_getenv) {
186
  if (!uim_get_home_directory(home, sizeof(home), getuid()) && is_getenv) {
175
    char *home_env = getenv("HOME");
187
    char *home_env = getenv("HOME");
176
188
177
    if (!home_env)
189
    if (!home_env) {
190
      path[0] = '\0';
178
      return UIM_FALSE;
191
      return UIM_FALSE;
192
    }
179
193
180
    if (strlcpy(home, home_env, sizeof(home)) >= sizeof(home))
194
    if (strlcpy(home, home_env, sizeof(home)) >= sizeof(home)) {
195
      path[0] = '\0';
181
      return UIM_FALSE;
196
      return UIM_FALSE;
197
    }
182
  }
198
  }
183
199
184
  if (snprintf(path, len, "%s/.uim.d", home) == -1)
200
  if (snprintf(path, len, "%s/.uim.d", home) < 0) {
201
    path[0] = '\0';
185
    return UIM_FALSE;
202
    return UIM_FALSE;
203
  }
186
204
187
  if (!uim_check_dir(path)) {
205
  if (!uim_check_dir_internal(path, need_prepare)) {
188
    return UIM_FALSE;
206
    return UIM_FALSE;
189
  }
207
  }
190
208
191
  return UIM_TRUE;
209
  return UIM_TRUE;
192
}
210
}
193
211
212
/* FIXME: use appropriate name for this API */
213
uim_bool
214
uim_get_config_path(char *path, int len, int is_getenv)
215
{
216
  int need_prepare = UIM_TRUE;
217
218
  return uim_get_config_path_internal(path, len, is_getenv, need_prepare);
219
}
220
194
static uim_lisp
221
static uim_lisp
195
c_get_config_path(uim_lisp is_getenv_)
222
c_prepare_config_path(uim_lisp is_getenv_)
196
{
223
{
197
  char path[MAXPATHLEN];
224
  char path[MAXPATHLEN];
225
  int need_prepare = UIM_TRUE;
198
226
199
  if (!uim_get_config_path(path, sizeof(path), C_BOOL(is_getenv_)))
227
  if (!uim_get_config_path_internal(path, sizeof(path), C_BOOL(is_getenv_), need_prepare))
200
    return uim_scm_f();
228
    return uim_scm_f();
201
  return MAKE_STR(path);
229
  return MAKE_STR(path);
202
}
230
}
203
231
204
static uim_lisp
232
static uim_lisp
233
c_get_config_path(uim_lisp is_getenv_)
234
{
235
  char path[MAXPATHLEN];
236
  int need_prepare = UIM_FALSE;
237
  int exist;
238
239
  /* No need to check the existence of path in this function */
240
  exist = uim_get_config_path_internal(path, sizeof(path), C_BOOL(is_getenv_), need_prepare);
241
242
  return MAKE_STR(path);
243
}
244
245
static uim_lisp
205
file_stat_mode(uim_lisp filename, mode_t mode)
246
file_stat_mode(uim_lisp filename, mode_t mode)
206
{
247
{
207
  struct stat st;
248
  struct stat st;
Lines 391-398 uim_init_posix_subrs(void) Link Here
391
  uim_scm_init_proc0("user-name", user_name);
432
  uim_scm_init_proc0("user-name", user_name);
392
  uim_scm_init_proc1("home-directory", home_directory);
433
  uim_scm_init_proc1("home-directory", home_directory);
393
434
394
  uim_scm_init_proc1("create/check-directory!", c_check_dir);
435
  uim_scm_init_proc1("create/check-directory!", c_prepare_dir);
395
  uim_scm_init_proc1("get-config-path!", c_get_config_path);
436
  uim_scm_init_proc1("get-config-path!", c_prepare_config_path);
437
  uim_scm_init_proc1("get-config-path", c_get_config_path);
396
438
397
  uim_scm_init_proc1("file-readable?", file_readablep);
439
  uim_scm_init_proc1("file-readable?", file_readablep);
398
  uim_scm_init_proc1("file-writable?", file_writablep);
440
  uim_scm_init_proc1("file-writable?", file_writablep);

Return to bug 345217