Giter Site home page Giter Site logo

neopallium / nixio Goto Github PK

View Code? Open in Web Editor NEW
58.0 11.0 23.0 1.53 MB

System, Networking and I/O library for Lua. This is an unoffical fork of NIXO from: http://luci.subsignal.org/

Home Page: http://neopallium.github.com/nixio/

License: Apache License 2.0

Lua 27.30% Shell 0.16% C 70.51% Makefile 2.03%

nixio's Issues

build failures with openssl 3.0

Hi. Just noticed that nixio fails to build with openssl 3.0 due to deprecated functions.

sudo luarocks-5.1 make
mkdir -p dist/usr/local/share/lua/5.1
cp -pR lua/* dist/usr/local/share/lua/5.1 2>/dev/null || true
for i in $(find dist -name .svn); do rm -rf $i || true; done
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/address.o src/address.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/poll.o src/poll.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/io.o src/io.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/file.o src/file.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/splice.o src/splice.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/process.o src/process.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/syslog.o src/syslog.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/bit.o src/bit.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/binary.o src/binary.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/fs.o src/fs.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC -c -o src/user.o src/user.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/usr/include -fPIC  -c -o src/tls-crypto.o src/tls-crypto.c
src/tls-crypto.c: In function 'nixio_crypto_hash__init':
src/tls-crypto.c:38:17: error: 'MD5_Init' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   38 |                 MD5_Init((MD5_CTX*)hash->ctx);
      |                 ^~~~~~~~
In file included from src/nixio-tls.h:9,
                 from src/tls-crypto.c:19:
/usr/include/openssl/md5.h:49:27: note: declared here
   49 | OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
      |                           ^~~~~~~~
src/tls-crypto.c:39:17: error: 'MD5_Init' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   39 |                 hash->init = (nixio_hash_initcb)MD5_Init;
      |                 ^~~~
/usr/include/openssl/md5.h:49:27: note: declared here
   49 | OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
      |                           ^~~~~~~~
src/tls-crypto.c:40:17: error: 'MD5_Update' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   40 |                 hash->update = (nixio_hash_updatecb)MD5_Update;
      |                 ^~~~
/usr/include/openssl/md5.h:50:27: note: declared here
   50 | OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
      |                           ^~~~~~~~~~
src/tls-crypto.c:41:17: error: 'MD5_Final' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   41 |                 hash->final = (nixio_hash_finalcb)MD5_Final;
      |                 ^~~~
/usr/include/openssl/md5.h:51:27: note: declared here
   51 | OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
      |                           ^~~~~~~~~
src/tls-crypto.c:50:17: error: 'SHA1_Init' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   50 |                 SHA1_Init((SHA_CTX*)hash->ctx);
      |                 ^~~~~~~~~
In file included from /usr/include/openssl/x509.h:41,
                 from /usr/include/openssl/ssl.h:31,
                 from src/nixio-tls.h:8:
/usr/include/openssl/sha.h:49:27: note: declared here
   49 | OSSL_DEPRECATEDIN_3_0 int SHA1_Init(SHA_CTX *c);
      |                           ^~~~~~~~~
src/tls-crypto.c:51:17: error: 'SHA1_Init' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   51 |                 hash->init = (nixio_hash_initcb)SHA1_Init;
      |                 ^~~~
/usr/include/openssl/sha.h:49:27: note: declared here
   49 | OSSL_DEPRECATEDIN_3_0 int SHA1_Init(SHA_CTX *c);
      |                           ^~~~~~~~~
src/tls-crypto.c:52:17: error: 'SHA1_Update' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   52 |                 hash->update = (nixio_hash_updatecb)SHA1_Update;
      |                 ^~~~
/usr/include/openssl/sha.h:50:27: note: declared here
   50 | OSSL_DEPRECATEDIN_3_0 int SHA1_Update(SHA_CTX *c, const void *data, size_t len);
      |                           ^~~~~~~~~~~
src/tls-crypto.c:53:17: error: 'SHA1_Final' is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   53 |                 hash->final = (nixio_hash_finalcb)SHA1_Final;
      |                 ^~~~
/usr/include/openssl/sha.h:51:27: note: declared here
   51 | OSSL_DEPRECATEDIN_3_0 int SHA1_Final(unsigned char *md, SHA_CTX *c);
      |                           ^~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:72: src/tls-crypto.o] Error 1

Error: Build error: Failed building.

installing on Debian/jessy fails with compiler warning

using gcc (Debian 4.9.0-6) 4.9.0,
luarocks install

gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/include/lua5.1 -fPIC -c -o src/bind.o src/bind.c
src/bind.c: In function ‘nixio_sock_accept’:
src/bind.c:259:29: error: argument to ‘sizeof’ in ‘memcpy’ call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
memcpy(clsock, sock, sizeof(clsock));
^
cc1: all warnings being treated as errors
Makefile:59: recipe for target 'src/bind.o' failed

Build failure on OSX 10.11

This library doesn't build properly with clang 7.0.2 on OSX:

$ luarocks install nixio OPENSSL_DIR=/usr/local/Cellar/openssl/1.0.2d_1/
Installing https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/nixio-0.3-1.src.rock...
Using https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/nixio-0.3-1.src.rock... switching to 'build' mode
mkdir -p dist/usr/local/share/lua/5.1
cp -pR lua/* dist/usr/local/share/lua/5.1 2>/dev/null || true
for i in $(find dist -name .svn); do rm -rf $i || true; done
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/Users/michael/local/torch/install/include -fPIC -c -o src/nixio.o src/nixio.c
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/Users/michael/local/torch/install/include -fPIC -c -o src/socket.o src/socket.c
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/Users/michael/local/torch/install/include -fPIC -c -o src/sockopt.o src/sockopt.c
env MACOSX_DEPLOYMENT_TARGET=10.8 gcc  -O2 --std=gnu99 -Wall -Werror -pedantic  -O2 -fPIC -I/Users/michael/local/torch/install/include -fPIC -c -o src/bind.o src/bind.c
src/bind.c:259:30: error: 'memcpy' call operates on objects of type 'nixio_sock'
      (aka 'struct nixio_socket') while the size is based on a different type 'nixio_sock *'
      (aka 'struct nixio_socket *') [-Werror,-Wsizeof-pointer-memaccess]
        memcpy(clsock, sock, sizeof(clsock));
               ~~~~~~               ^~~~~~
src/bind.c:259:30: note: did you mean to dereference the argument to 'sizeof' (and multiply it by
      the number of elements)?
        memcpy(clsock, sock, sizeof(clsock));
                                    ^~~~~~
1 error generated.
make: *** [src/bind.o] Error 1

Error: Build error: Failed building.

I'm willing to retry with gcc, but how can I specify which compiler to use?

build failures with gcc5+?

Not sure what this is trying to do even

src/process.c: In function ‘nixio__exec’:
src/process.c:76:26: error: comparison of constant ‘4’ with boolean expression is always true [-Werror=bool-compare]
     if (!lua_type(L, -2) != LUA_TSTRING || !lua_isstring(L, -1)) {
                          ^
src/process.c:76:26: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]

new rockspec version 0.3.2 and into luarocks repo?

nixio doesn't build anymore with gcc 4.8.0+ on luarocks's version 0.3.1

A commit was made to fix this in scm over here:
07f91ad

However, in the default luarocks build server, the rockspec is still 0.3.1 with an older version of the source.

It would be great to issue a new version so that nixio build by default in luarocks without having to manually pull the scm rockspec

luarocks install nixio fails

on a fresh ubuntu 1204 machine, "sudo luarocks install nixio" doesn't work properly. It installs a broken nixio that doesn't have the fix for 7220cef

I don't know where luarocks is fetching it from exactly?

Build Fails on Mac OSX Lion

Sad panda...

Using luarocks, I get the following build error:

Installing http://luarocks.org/repositories/rocks/nixio-0.3-1.src.rock...
Using http://luarocks.org/repositories/rocks/nixio-0.3-1.src.rock... switching to 'build' mode
Archive: /private/tmp/luarocks_luarocks-rock-nixio-0.3-1-1647/nixio-0.3-1.src.rock
inflating: nixio-0.3-1.rockspec
inflating: nixio-0.3.tar.bz2
mkdir -p dist/usr/local/share/lua/5.1
cp -pR lua/* dist/usr/local/share/lua/5.1 2>/dev/null || true
for i in $(find dist -name .svn); do rm -rf $i || true; done
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/nixio.o src/nixio.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/socket.o src/socket.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/sockopt.o src/sockopt.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/bind.o src/bind.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/address.o src/address.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/poll.o src/poll.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/io.o src/io.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/file.o src/file.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/splice.o src/splice.c
cc1: warnings being treated as errors
src/splice.c: In function ‘nixio_sendfile’:
src/splice.c:143: warning: passing argument 4 of ‘sendfile’ makes pointer from integer without a cast
src/splice.c:143: warning: passing argument 6 of ‘sendfile’ makes integer from pointer without a cast
src/splice.c:143: error: too many arguments to function ‘sendfile’
make: *** [src/splice.o] Error 1

Error: Build error: Failed building.

If i use the link directly on the from github, I get a different error:

mkdir -p dist/usr/local/share/lua/5.1
cp -pR lua/* dist/usr/local/share/lua/5.1 2>/dev/null || true
for i in $(find dist -name .svn); do rm -rf $i || true; done
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/nixio.o src/nixio.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/socket.o src/socket.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/sockopt.o src/sockopt.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/bind.o src/bind.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/address.o src/address.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/poll.o src/poll.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/io.o src/io.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/file.o src/file.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/splice.o src/splice.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/process.o src/process.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/syslog.o src/syslog.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/bit.o src/bit.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/binary.o src/binary.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/fs.o src/fs.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/user.o src/user.c
export MACOSX_DEPLOYMENT_TARGET=10.3; gcc -O2 --std=gnu99 -D__DARWIN__ -Wall -Werror -pedantic -O2 -fPIC -I/usr/local/include/luajit-2.0 -fPIC -c -o src/tls-crypto.o src/tls-crypto.c
In file included from /usr/include/openssl/ssl.h:173,
from src/nixio-tls.h:8,
from src/tls-crypto.c:19:
/usr/include/AvailabilityMacros.h:109:14: error: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
make: *** [src/tls-crypto.o] Error 1

Error: Build error: Failed building.


How can I help?

nixio.bit.check is meant to accept multiple flags but doesn't

At least on the documentation at http://luci.subsignal.org/api/nixio/modules/nixio.bit.html#check the check function is meant to check all flag arguments. On both my local fedora installation via luarocks, and my openwrt installation, this is clearly not happening:

root@OpenWrt:~# lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio (double int32)
> nix = require("nixio")
> x = 6
> =nix.bit.check(x, 2)
true
> =nix.bit.check(x,3)
false
> =nix.bit.check(x,2,3)
true
> =nix.bit.check(x,3,2)
false
> 

Only the first flag is checked. This matches up with the source at https://github.com/Neopallium/nixio/blob/master/src/bit.c#L103 which is clearly only checking the first argument.

Now, this clearly works as implemented, but the docs are not right at least.

hi, can nixio socket object been passed to another thread?

hi neo,

I am using lua-handlers to write a http server. Now I want to process static files in other threads, so after parse the http request, I need to pass the file uri and nixio socket object to other threads (I use lua-llthreads), other threads use nixion.sendfile to server files, so they must get the socket object to response correctly. How should I do to pass socket object?

Expect your reply.
Thank you.

lstat patch (fs.c)

Patch replace stat to lstat.


diff -Naur -- old/src/fs.c new/src/fs.c
--- old/src/fs.c 2012-02-04 04:21:34.000000000 +0000
+++ new/src/fs.c 2012-04-19 05:01:26.259000163 +0000
@@ -355,7 +355,7 @@

static int nixio_lstat(lua_State *L) {
nixio_stat_t buf;

  • if (stat(luaL_checkstring(L, 1), &buf)) {
  • if (lstat(luaL_checkstring(L, 1), &buf)) {
    return nixio__perror(L);
    } else {
    nixio__push_stat(L, &buf);

Reading from standard input?

I have an applications that uses sockets to distribute data read from the standard input. I don't see how I can get a file descriptor for standard files for nixio. (the ones from Lua like io.input() do not work)

compile failure on fedora 19

luarocks install nixio failed, and building from source gives me the same error

karlp@pojak:~/src/nixio (master)$ make
mkdir -p dist/usr/local/share/lua/5.1
cp -pR lua/* dist/usr/local/share/lua/5.1 2>/dev/null || true
for i in $(find dist -name .svn); do rm -rf $i || true; done
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic    -fPIC -c -o src/nixio.o src/nixio.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic    -fPIC -c -o src/socket.o src/socket.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic    -fPIC -c -o src/sockopt.o src/sockopt.c 
gcc  -O2 --std=gnu99 -Wall -Werror -pedantic    -fPIC -c -o src/bind.o src/bind.c 
src/bind.c: In function ‘nixio_sock_accept’:
src/bind.c:259:29: error: argument to ‘sizeof’ in ‘memcpy’ call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
  memcpy(clsock, sock, sizeof(clsock));
                             ^
cc1: all warnings being treated as errors
make: *** [src/bind.o] Error 1
karlp@pojak:~/src/nixio (master)$ gcc --version
gcc (GCC) 4.8.1 20130603 (Red Hat 4.8.1-1)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

karlp@pojak:~/src/nixio (master)$

Adding the dereference makes it it compile, but it is correct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.