summaryrefslogtreecommitdiffstats
path: root/src/librcc.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-05 03:15:53 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-05 03:15:53 +0000
commit9922cef1af71786ae788903b52a8968e5775d510 (patch)
treebadf23fc2701946b61df1d15227736783e44a754 /src/librcc.c
parenta21deef1c62467b21500f94dfb2ab3d58e69cb85 (diff)
downloadlibrcc-9922cef1af71786ae788903b52a8968e5775d510.tar.gz
librcc-9922cef1af71786ae788903b52a8968e5775d510.tar.bz2
librcc-9922cef1af71786ae788903b52a8968e5775d510.tar.xz
librcc-9922cef1af71786ae788903b52a8968e5775d510.zip
Save / Load
Diffstat (limited to 'src/librcc.c')
-rw-r--r--src/librcc.c71
1 files changed, 64 insertions, 7 deletions
diff --git a/src/librcc.c b/src/librcc.c
index d6acc72..5b6a66f 100644
--- a/src/librcc.c
+++ b/src/librcc.c
@@ -1,22 +1,79 @@
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include "../config.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif /* HAVE_SYS_TYPES_H */
+
+#ifdef HAVE_PWD_H
+# include <pwd.h>
+#endif /* HAVE_PWD_H */
+
#include <librcd.h>
#include "internal.h"
#include "rccconfig.h"
#include "rccenca.h"
#include "rcclist.h"
+#include "rccenca.h"
+#include "rccxml.h"
-
+static int initialized = 0;
+char *rcc_home_dir = NULL;
int rccInit() {
- /*DS: Load addition languages from config! */
- return rccEncaInit();
+ int err;
+ char *tmp;
+
+#ifdef HAVE_PWD_H
+ struct passwd *pw;
+#endif /* HAVE_PWD_H */
+
+ if (initialized) return 0;
+
+ tmp = getenv ("HOME");
+ if (tmp) rcc_home_dir = strdup (tmp);
+#ifdef HAVE_PWD_H
+ else {
+ setpwent ();
+ pw = getpwuid(getuid ());
+ endpwent ();
+ if ((pw)&&(pw->pw_dir)) rcc_home_dir = strdup (pw->pw_dir);
+ }
+#endif /* HAVE_PWD_H */
+ if (!rcc_home_dir) rcc_home_dir = strdup("/");
+
+
+ err = rccEncaInit();
+ if (!err) err = rccXmlInit();
+
+ if (err) {
+ rccFree();
+ return err;
+ }
+
+ initialized = 1;
+
+ return 0;
}
void rccFree() {
+ rccXmlFree();
rccEncaFree();
+
+ if (rcc_home_dir) {
+ free(rcc_home_dir);
+ rcc_home_dir = NULL;
+ }
+
+ initialized = 0;
}
rcc_context rccCreateContext(const char *locale_variable, unsigned int max_languages, unsigned int max_classes, rcc_class_ptr defclasses, rcc_init_flags flags) {
@@ -137,8 +194,10 @@ rcc_context rccCreateContext(const char *locale_variable, unsigned int max_langu
}
}
- for (i=0;i<RCC_MAX_OPTIONS;i++)
- ctx->options[i] = 0;
+ for (i=0;i<RCC_MAX_OPTIONS;i++) {
+ ctx->options[i] = rccGetOptionDefaultValue((rcc_option)i);
+ ctx->default_options[i] = 1;
+ }
ctx->configure = 1;
@@ -258,12 +317,10 @@ rcc_alias_id rccRegisterLanguageAlias(rcc_context ctx, rcc_language_alias *alias
}
rcc_class_id rccRegisterClass(rcc_context ctx, rcc_class *cl) {
- puts("yes");
if ((!ctx)||(!cl)) return -1;
if (ctx->configuration_lock) return -3;
if (ctx->n_classes == ctx->max_classes) return -2;
- puts(" -----> New class");
ctx->configure = 1;
ctx->classes[ctx->n_classes++] = cl;
ctx->classes[ctx->n_classes] = NULL;