Skip to content

Commit

Permalink
updated headers
Browse files Browse the repository at this point in the history
  • Loading branch information
cryi committed Jan 4, 2021
1 parent 56cd20b commit c7c7bea
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 36 deletions.
3 changes: 1 addition & 2 deletions src/lprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "lua.h"
#include "lualib.h"
#include "lutil.h"

#include "stream.h"
#include <stdlib.h>
#include <string.h>

Expand All @@ -15,7 +15,6 @@
#include <sys/wait.h>
#include <unistd.h>
#endif
//#include "stream.h" passed from spawn.h

/* proc -- pid */
static int process_pid(lua_State *L) {
Expand Down
1 change: 1 addition & 0 deletions src/stdioChannel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef STDIO_CHANNEL_H_
#define STDIO_CHANNEL_H_

#include "lauxlib.h"
#include "stream.h"

#define STDIO_STDIN 0
Expand Down
72 changes: 38 additions & 34 deletions src/stream.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
#include "lua.h"

#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

#define ELI_STREAM_R_METATABLE "ELI_STREAM_R_METATABLE"
#define ELI_STREAM_W_METATABLE "ELI_STREAM_W_METATABLE"
#define ELI_STREAM_RW_METATABLE "ELI_STREAM_RW_METATABLE"

typedef struct ELI_STREAM {
int fd;
int closed;
int nonblocking;
int notDisposable;
} ELI_STREAM;

typedef enum ELI_STREAM_KIND {
ELI_STREAM_R_KIND,
ELI_STREAM_W_KIND,
ELI_STREAM_RW_KIND,
ELI_STREAM_INVALID_KIND
} ELI_STREAM_KIND;

int stream_read(lua_State *L, int fd, const char *opt, int nonblocking);
int stream_read_bytes(lua_State *L, int fd, size_t length, int nonblocking);
int stream_write(lua_State *L, int fd, const char *data, size_t datasize);
int stream_is_nonblocking(int fd);
int stream_set_nonblocking(int fd, int nonblocking);
int stream_as_filestream(lua_State *L, int fd, const char *mode);
int stream_close(int fd);
ELI_STREAM *new_stream();
#ifndef ELI_STREAM_EXTRA_H_
#define ELI_STREAM_EXTRA_H_

#include "lua.h"

#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif

#define ELI_STREAM_R_METATABLE "ELI_STREAM_R_METATABLE"
#define ELI_STREAM_W_METATABLE "ELI_STREAM_W_METATABLE"
#define ELI_STREAM_RW_METATABLE "ELI_STREAM_RW_METATABLE"

typedef struct ELI_STREAM {
int fd;
int closed;
int nonblocking;
int notDisposable;
} ELI_STREAM;

typedef enum ELI_STREAM_KIND {
ELI_STREAM_R_KIND,
ELI_STREAM_W_KIND,
ELI_STREAM_RW_KIND,
ELI_STREAM_INVALID_KIND
} ELI_STREAM_KIND;

int stream_read(lua_State *L, int fd, const char *opt, int nonblocking);
int stream_read_bytes(lua_State *L, int fd, size_t length, int nonblocking);
int stream_write(lua_State *L, int fd, const char *data, size_t datasize);
int stream_is_nonblocking(int fd);
int stream_set_nonblocking(int fd, int nonblocking);
int stream_as_filestream(lua_State *L, int fd, const char *mode);
int stream_close(int fd);
ELI_STREAM *new_stream();
#endif

0 comments on commit c7c7bea

Please sign in to comment.