Skip to content
Extraits de code Groupes Projets
Vérifiée Valider a565dff1 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Add 2 args to lektord

parent 4e4e5d2e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!87Resolve "Segfault on exit"
...@@ -40,14 +40,28 @@ main(int argc, char *argv[]) ...@@ -40,14 +40,28 @@ main(int argc, char *argv[])
{ {
struct passwd *pw = getpwuid(getuid()); struct passwd *pw = getpwuid(getuid());
char exe[PATH_MAX]; char exe[PATH_MAX];
int autoclear, check_exclusive = 1, opt;
char *conf_file = safe_zero_malloc(PATH_MAX * sizeof(char));
pthread_t th; pthread_t th;
executable_name = "lektord"; executable_name = "lektord";
UNUSED(argv);
if (argc <= 1) if (argc <= 1)
goto normal_launch; goto normal_launch;
/* Check args */
while ((opt = getopt(argc, argv, "Ff:")) != -1) {
switch (opt) {
case 'F':
check_exclusive = 0;
break;
case 'f':
strncpy(conf_file, optarg, PATH_MAX);
break;
default:
help__(); help__();
return EXIT_FAILURE; exit(EXIT_SUCCESS);
}
}
normal_launch: normal_launch:
LOG_INFO_SCT("GENERAL", "Lektor launched by user %s (shell: %s, home: %s)", LOG_INFO_SCT("GENERAL", "Lektor launched by user %s (shell: %s, home: %s)",
...@@ -62,16 +76,25 @@ normal_launch: ...@@ -62,16 +76,25 @@ normal_launch:
/* Init the server */ /* Init the server */
struct lkt_state srv; struct lkt_state srv;
int autoclear, check_exclusive = 1;
char *db_path = safe_malloc(PATH_MAX * sizeof(char)); char *db_path = safe_malloc(PATH_MAX * sizeof(char));
char *conf_file = safe_malloc(PATH_MAX * sizeof(char));
char *kara_dir = safe_malloc(PATH_MAX * sizeof(char)); char *kara_dir = safe_malloc(PATH_MAX * sizeof(char));
memset(&srv, 0, sizeof(struct lkt_state)); memset(&srv, 0, sizeof(struct lkt_state));
/* Initialize the system. */ /* Initialize the system. */
RETURN_UNLESS(database_new(&srv.db), "Failed to initialize the memory database", 1); if (!database_new(&srv.db)) {
RETURN_IF (config_detect_file(conf_file, PATH_MAX), "Failed to find a config file", 1); LOG_ERROR_SCT("INIT", "%s", "Failed to init memory db");
RETURN_IF (config_new(srv.db, conf_file), "Failed to read configuration file", 1); exit(EXIT_FAILURE);
}
if (conf_file[0] == '\0' && config_detect_file(conf_file, PATH_MAX)) {
LOG_ERROR_SCT("INIT", "%s", "Failed to find a config file");
exit(EXIT_FAILURE);
}
if (config_new(srv.db, conf_file)) {
LOG_ERROR_SCT("INIT", "%s", "Failed to read the config");
exit(EXIT_FAILURE);
}
free(conf_file); free(conf_file);
/* Finish to initialize. */ /* Finish to initialize. */
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter