Finalizing swig binding for python, and works, see https://github.com/JulienPalard/ashttp

This commit is contained in:
Julien 2011-10-29 15:36:03 +02:00
parent 031d9d0fb4
commit 7afaf12a38
7 changed files with 25 additions and 17 deletions

View File

@ -32,8 +32,7 @@ test: $(OBJ_TEST)
$(CC) $(OBJ_TEST) -L . -l$(NAME) -o test
python_module:
swig -python *.i
python setup.py build_ext --inplace
swig -python -threads *.i
all:
@make $(NAME)

View File

@ -1,3 +1,12 @@
INSTALL
=======
Python module
-------------
Run :
$ make python_module && su -c 'python setup.py install'
Overview
========

View File

@ -56,5 +56,6 @@ struct vt100_headless
void fork(const char *progname, char **argv);
char **getlines();
int main_loop();
void stop();
}
};

View File

@ -33,20 +33,6 @@ static void restore_termios(struct vt100_headless *this, int fd)
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
static void strdump(char *str)
{
@ -62,6 +48,11 @@ static void strdump(char *str)
}
#endif
void vt100_headless_stop(struct vt100_headless *this)
{
this->should_quit = 1;
}
int vt100_headless_main_loop(struct vt100_headless *this)
{
char buffer[4096];
@ -69,7 +60,7 @@ int vt100_headless_main_loop(struct vt100_headless *this)
int retval;
ssize_t read_size;
while (42)
while (!this->should_quit)
{
FD_ZERO(&rfds);
FD_SET(this->master, &rfds);

View File

@ -14,6 +14,7 @@ struct vt100_headless
int master;
struct termios backup;
struct lw_terminal_vt100 *term;
int should_quit;
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);
struct vt100_headless *new_vt100_headless(void);
const char **vt100_headless_getlines(struct vt100_headless *this);
void vt100_headless_stop(struct vt100_headless *this);
#endif

View File

@ -887,11 +887,13 @@ const char **lw_terminal_vt100_getlines(struct lw_terminal_vt100 *vt100)
{
unsigned int y;
pthread_mutex_lock(&vt100->mutex);
for (y = 0; y < vt100->height; ++y)
if (y < vt100->margin_top || y > vt100->margin_bottom)
vt100->lines[y] = vt100->frozen_screen + FROZEN_SCREEN_PTR(vt100, 0, y);
else
vt100->lines[y] = vt100->screen + SCREEN_PTR(vt100, 0, y);
pthread_mutex_unlock(&vt100->mutex);
return (const char **)vt100->lines;
}
@ -967,7 +969,9 @@ free_this:
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);
pthread_mutex_unlock(&this->mutex);
}
void lw_terminal_vt100_destroy(struct lw_terminal_vt100 *this)

View File

@ -1,6 +1,7 @@
#ifndef __LW_TERMINAL_VT100_H__
#define __LW_TERMINAL_VT100_H__
#include <pthread.h>
#include "lw_terminal_parser.h"
/*
@ -64,6 +65,7 @@ struct lw_terminal_vt100
char *lines[80];
void (*master_write)(void *user_data, void *buffer, size_t len);
void *user_data;
pthread_mutex_t mutex;
};
struct lw_terminal_vt100 *lw_terminal_vt100_init(void *user_data,