Finalizing swig binding for python, and works, see https://github.com/JulienPalard/ashttp
This commit is contained in:
parent
031d9d0fb4
commit
7afaf12a38
3
Makefile
3
Makefile
|
@ -32,8 +32,7 @@ test: $(OBJ_TEST)
|
||||||
$(CC) $(OBJ_TEST) -L . -l$(NAME) -o test
|
$(CC) $(OBJ_TEST) -L . -l$(NAME) -o test
|
||||||
|
|
||||||
python_module:
|
python_module:
|
||||||
swig -python *.i
|
swig -python -threads *.i
|
||||||
python setup.py build_ext --inplace
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@make $(NAME)
|
@make $(NAME)
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
INSTALL
|
||||||
|
=======
|
||||||
|
|
||||||
|
Python module
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Run :
|
||||||
|
$ make python_module && su -c 'python setup.py install'
|
||||||
|
|
||||||
Overview
|
Overview
|
||||||
========
|
========
|
||||||
|
|
||||||
|
|
|
@ -56,5 +56,6 @@ struct vt100_headless
|
||||||
void fork(const char *progname, char **argv);
|
void fork(const char *progname, char **argv);
|
||||||
char **getlines();
|
char **getlines();
|
||||||
int main_loop();
|
int main_loop();
|
||||||
|
void stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,20 +33,6 @@ static void restore_termios(struct vt100_headless *this, int fd)
|
||||||
ioctl(fd, TCSETS, &this->backup);
|
ioctl(fd, TCSETS, &this->backup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static void debug(struct vt100_headless *this, char *title) */
|
|
||||||
/* { */
|
|
||||||
/* unsigned int argc; */
|
|
||||||
|
|
||||||
/* fprintf(stderr, "%s ", title); */
|
|
||||||
/* for (argc = 0; argc < this->term->argc; ++argc) */
|
|
||||||
/* { */
|
|
||||||
/* fprintf(stderr, "%d", this->term->argv[argc]); */
|
|
||||||
/* if (argc != this->term->argc - 1) */
|
|
||||||
/* fprintf(stderr, ", "); */
|
|
||||||
/* } */
|
|
||||||
/* fprintf(stderr, "\n"); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
static void strdump(char *str)
|
static void strdump(char *str)
|
||||||
{
|
{
|
||||||
|
@ -62,6 +48,11 @@ static void strdump(char *str)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void vt100_headless_stop(struct vt100_headless *this)
|
||||||
|
{
|
||||||
|
this->should_quit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
int vt100_headless_main_loop(struct vt100_headless *this)
|
int vt100_headless_main_loop(struct vt100_headless *this)
|
||||||
{
|
{
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
@ -69,7 +60,7 @@ int vt100_headless_main_loop(struct vt100_headless *this)
|
||||||
int retval;
|
int retval;
|
||||||
ssize_t read_size;
|
ssize_t read_size;
|
||||||
|
|
||||||
while (42)
|
while (!this->should_quit)
|
||||||
{
|
{
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(this->master, &rfds);
|
FD_SET(this->master, &rfds);
|
||||||
|
|
|
@ -14,6 +14,7 @@ struct vt100_headless
|
||||||
int master;
|
int master;
|
||||||
struct termios backup;
|
struct termios backup;
|
||||||
struct lw_terminal_vt100 *term;
|
struct lw_terminal_vt100 *term;
|
||||||
|
int should_quit;
|
||||||
void (*changed)(struct vt100_headless *this);
|
void (*changed)(struct vt100_headless *this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,5 +24,6 @@ int vt100_headless_main_loop(struct vt100_headless *this);
|
||||||
void delete_vt100_headless(struct vt100_headless *this);
|
void delete_vt100_headless(struct vt100_headless *this);
|
||||||
struct vt100_headless *new_vt100_headless(void);
|
struct vt100_headless *new_vt100_headless(void);
|
||||||
const char **vt100_headless_getlines(struct vt100_headless *this);
|
const char **vt100_headless_getlines(struct vt100_headless *this);
|
||||||
|
void vt100_headless_stop(struct vt100_headless *this);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -887,11 +887,13 @@ const char **lw_terminal_vt100_getlines(struct lw_terminal_vt100 *vt100)
|
||||||
{
|
{
|
||||||
unsigned int y;
|
unsigned int y;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&vt100->mutex);
|
||||||
for (y = 0; y < vt100->height; ++y)
|
for (y = 0; y < vt100->height; ++y)
|
||||||
if (y < vt100->margin_top || y > vt100->margin_bottom)
|
if (y < vt100->margin_top || y > vt100->margin_bottom)
|
||||||
vt100->lines[y] = vt100->frozen_screen + FROZEN_SCREEN_PTR(vt100, 0, y);
|
vt100->lines[y] = vt100->frozen_screen + FROZEN_SCREEN_PTR(vt100, 0, y);
|
||||||
else
|
else
|
||||||
vt100->lines[y] = vt100->screen + SCREEN_PTR(vt100, 0, y);
|
vt100->lines[y] = vt100->screen + SCREEN_PTR(vt100, 0, y);
|
||||||
|
pthread_mutex_unlock(&vt100->mutex);
|
||||||
return (const char **)vt100->lines;
|
return (const char **)vt100->lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,7 +969,9 @@ free_this:
|
||||||
|
|
||||||
void lw_terminal_vt100_read_str(struct lw_terminal_vt100 *this, char *buffer)
|
void lw_terminal_vt100_read_str(struct lw_terminal_vt100 *this, char *buffer)
|
||||||
{
|
{
|
||||||
|
pthread_mutex_lock(&this->mutex);
|
||||||
lw_terminal_parser_read_str(this->lw_terminal, buffer);
|
lw_terminal_parser_read_str(this->lw_terminal, buffer);
|
||||||
|
pthread_mutex_unlock(&this->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lw_terminal_vt100_destroy(struct lw_terminal_vt100 *this)
|
void lw_terminal_vt100_destroy(struct lw_terminal_vt100 *this)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef __LW_TERMINAL_VT100_H__
|
#ifndef __LW_TERMINAL_VT100_H__
|
||||||
#define __LW_TERMINAL_VT100_H__
|
#define __LW_TERMINAL_VT100_H__
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
#include "lw_terminal_parser.h"
|
#include "lw_terminal_parser.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -64,6 +65,7 @@ struct lw_terminal_vt100
|
||||||
char *lines[80];
|
char *lines[80];
|
||||||
void (*master_write)(void *user_data, void *buffer, size_t len);
|
void (*master_write)(void *user_data, void *buffer, size_t len);
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lw_terminal_vt100 *lw_terminal_vt100_init(void *user_data,
|
struct lw_terminal_vt100 *lw_terminal_vt100_init(void *user_data,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user