Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 6d5b096d2756ae625e2d7c28c7a9d8466539ebfa
  • master par défaut protégée
  • rust-playlist-sync
  • rust
  • fix-qt-deprecated-qvariant-type
  • fix-mpris-qtwindow-race-condition
  • rust-appimage-wayland
  • windows-build-rebased
  • v2.5 protégée
  • v2.4 protégée
  • v2.3-1 protégée
  • v2.3 protégée
  • v2.2 protégée
  • v2.1 protégée
  • v2.0 protégée
  • v1.8-3 protégée
  • v1.8-2 protégée
  • v1.8-1 protégée
  • v1.8 protégée
  • v1.7 protégée
  • v1.6 protégée
  • v1.5 protégée
  • v1.4 protégée
  • v1.3 protégée
  • v1.2 protégée
  • v1.1 protégée
  • v1.0 protégée
27 résultats

server.c

Blame
  • 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':