Sélectionner une révision Git
server.c 5,76 Kio
#define _POSIX_C_SOURCE 200809L
#include <lektor/lktconfig.h>
#include <lektor/common.h>
#include <lektor/config.h>
#include <lektor/net.h>
#include <lektor/cmd.h>
#include <lektor/reg.h>
#include <lektor/database.h>
#include <lektor/commands.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <pthread.h>
#include <sys/stat.h>
#if defined (LKT_STATIC_MODULE)
REG_DECLARE(sdl2_reg)
REG_DECLARE(repo_reg)
#endif
/* Recursive mkdir, where the last word of the string is a file, not a folder. */
static inline void
__mkdir(const char *dir)
{
char tmp[PATH_MAX];
char *p = NULL;
safe_snprintf(tmp, sizeof(tmp), "%s", dir);
size_t len = strlen(tmp);
/* In our case, the final word is always a file, not a folder. */
if (tmp[len - 1] == '/')
tmp[len - 1] = 0;
for (p = tmp + 1; *p; p++) {
if(*p == '/') {
*p = 0;
mkdir(tmp, 00700);
*p = '/';
}
}
/* Don't do final mkdir here, because in our case the final word in the string
* is a file, not a folder.
* mkdir(tmp, S_IRWXU); */
}
int
main(int argc, char *argv[])
{
REG_BEGIN(server_reg)
#if defined (LKT_STATIC_MODULE)
REG_REGISTER("repo", repo_reg)
REG_REGISTER("sdl2", sdl2_reg)
#endif
REG_END()
char exe[PATH_MAX];
int autoclear, check_exclusive = 1, opt;
char *conf_file = safe_zero_malloc(PATH_MAX * sizeof(char));
executable_name = "lektord";
/* Check args */
while ((opt = getopt(argc, argv, "hFf:")) != -1) {
switch (opt) {
case 'F':
check_exclusive = 0;
break;
case 'f':