Sélectionner une révision Git
server.c 14,44 Kio
#define _POSIX_C_SOURCE 200808L
#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 <lektor/segv.h>
#include <fcntl.h>
#include <sys/types.h>
#include <wait.h>
#include <spawn.h>
#include <libgen.h>
#include <limits.h>
#include <locale.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>
#include <termios.h>
#if defined (LKT_STATIC_MODULE)
REG_DECLARE(sdl2_reg)
REG_DECLARE(repo_reg)
#endif
/* The environment */
extern char **environ;
/* Disable echo in the console, only for the program */
struct termios ___tty_cur, ___tty_save;
static int ___tty_must_be_restored = 0;
__attribute__((constructor))
static void ___tty_disable_echo(void)
{
GOTO_IF((tcgetattr(STDIN_FILENO, &___tty_cur) == -1),
"Failed to get termios flags", error);
___tty_save = ___tty_cur;
___tty_cur.c_lflag &= ~ ECHO;
GOTO_IF((tcsetattr(STDIN_FILENO, TCSAFLUSH, &___tty_cur) == -1),
"Failed to turned of echo in termios flags", error);
___tty_must_be_restored = 1;
return;
error:
/* Fails silently for the moment */
return;
}
__attribute__((destructor))
static void ___tty_enable_echo(void)
{
if (!___tty_must_be_restored) {
LOG_DEBUG("INIT", "No need to restore the tty");
return;
}
if (tcsetattr(STDIN_FILENO, TCSANOW, &___tty_save) == -1)
LOG_ERROR("INIT", "Failed to reset termios flags");
errno = 0;