From 04a644869e45e556dfa7a677b13cb9d7ad9d60a0 Mon Sep 17 00:00:00 2001 From: ge Date: Fri, 1 May 2026 22:23:43 +0300 Subject: [PATCH] chore --- .gitignore | 2 + README.md | 12 +++-- const_default.c.v => constants_default.c.v | 0 const_freebsd.v => constants_freebsd.v | 0 const_linux.v => constants_linux.v | 0 if.c.v => interfaces.c.v | 0 make.vsh | 2 +- mkconst.sh | 46 ------------------- tcp.v | 5 -- examples_test.v => tests/examples_test.v | 0 if_test.v => tests/if_test.v | 0 {protocol => tests}/protocol_test.v | 0 .../socket_addr_test.v | 0 socket_test.v => tests/socket_test.v | 0 udp.v | 3 -- 15 files changed, 10 insertions(+), 60 deletions(-) rename const_default.c.v => constants_default.c.v (100%) rename const_freebsd.v => constants_freebsd.v (100%) rename const_linux.v => constants_linux.v (100%) rename if.c.v => interfaces.c.v (100%) delete mode 100755 mkconst.sh delete mode 100644 tcp.v rename examples_test.v => tests/examples_test.v (100%) rename if_test.v => tests/if_test.v (100%) rename {protocol => tests}/protocol_test.v (100%) rename socket_addr_test.v => tests/socket_addr_test.v (100%) rename socket_test.v => tests/socket_test.v (100%) delete mode 100644 udp.v diff --git a/.gitignore b/.gitignore index 33d591b..f92ea77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # Binaries for programs and plugins main netio +make +examples/*[^.v] *.exe *.exe~ *.so diff --git a/README.md b/README.md index 234dfea..63e44a0 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,14 @@ `netio` is a flexible networking library for V programming language. -Differences with the V standard library `net` module: +Features: -* Provides the low-level wrappers around C API. +* Provides the low-level wrappers around C sockets API. * Supports any kind of sockets, socket options, address families and protocols. - -The `netio.protocol` submodule provides access to the operatins system protocols database. +* Working with network interfaces (limited for now). +* The `netio.protocol` submodule provides access to the operatins system protocols database. `netio` is tested only on Linux, but should work on all POSIX-compliant operating systems. -Microfost Windows support is not planned yet. +Microsoft Windows support is not planned yet. + +See examples/ dir in source code repository for usage examples. diff --git a/const_default.c.v b/constants_default.c.v similarity index 100% rename from const_default.c.v rename to constants_default.c.v diff --git a/const_freebsd.v b/constants_freebsd.v similarity index 100% rename from const_freebsd.v rename to constants_freebsd.v diff --git a/const_linux.v b/constants_linux.v similarity index 100% rename from const_linux.v rename to constants_linux.v diff --git a/if.c.v b/interfaces.c.v similarity index 100% rename from if.c.v rename to interfaces.c.v diff --git a/make.vsh b/make.vsh index 970dee6..758edc1 100755 --- a/make.vsh +++ b/make.vsh @@ -1,4 +1,4 @@ -#!/usr/bin/env -S v run +#!/usr/bin/env v import os import rand diff --git a/mkconst.sh b/mkconst.sh deleted file mode 100755 index 12d1297..0000000 --- a/mkconst.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -program_linux=' -#include -#include -#include -' - -program_freebsd=' -#include -#include -#include -' - -system=$(uname -s) - -case $system in - Linux) PROGRAM=$program_linux;; - FreeBSD) PROGRAM=$program_freebsd;; - *) echo $0: $system is unsupported >&2; exit 1;; -esac - -KIND=$1 -KIND=${KIND:-"SocketType,SocketLevel,SocketOption,AddrFamily,AddrInfoFlag,NameInfoFlag,MsgFlag"} - -echo module netio -echo -echo '/*' -echo -e "\tThis file is generated by mkconst.sh, DO NOT EDIT." -echo '*/' -echo - -echo "$PROGRAM" | ${CC:-"cc"} -x c - -E -dM ${CFLAGS:-""} | -awk -v KIND=$KIND ' - $1 != "#define" || $2 ~ /\(/ || $3 == "" {next} - $2 ~ /^_/ {next} - $2 ~ /^[a-z]/ {next} - $2 ~ /^SOCK_/ && KIND ~ "SocketType" {printf "pub const %s = SocketType(C.%s)\n", tolower($2), $2} - $2 ~ /^(SOL|IPPROTO)_/ && KIND ~ "SocketLevel" {printf "pub const %s = SocketLevel(C.%s)\n", tolower($2), $2} - $2 ~ /^(SO|IP|IPV6)_/ && KIND ~ "SocketOption" {printf "pub const %s = SocketOption(C.%s)\n", tolower($2), $2} - $2 ~ /^AF_/ && KIND ~ "AddrFamily" {printf "pub const %s = AddrFamily(C.%s)\n", tolower($2), $2} - $2 ~ /^AI_/ && KIND ~ "AddrInfoFlag" {printf "pub const %s = AddrInfoFlag(C.%s)\n", tolower($2), $2} - $2 ~ /^NI_/ && KIND ~ "NameInfoFlag" {printf "pub const %s = NameInfoFlag(C.%s)\n", tolower($2), $2} - $2 ~ /^MSG_/ && KIND ~ "MsgFlag" {printf "pub const %s = MsgFlag(C.%s)\n", tolower($2), $2} - KIND ~ "Any" {printf "%s\n", $0} - {next}' | sort -k 2 -V diff --git a/tcp.v b/tcp.v deleted file mode 100644 index 08ba4cf..0000000 --- a/tcp.v +++ /dev/null @@ -1,5 +0,0 @@ -module netio - -pub struct TCPListener {} - -pub struct TCPStream {} diff --git a/examples_test.v b/tests/examples_test.v similarity index 100% rename from examples_test.v rename to tests/examples_test.v diff --git a/if_test.v b/tests/if_test.v similarity index 100% rename from if_test.v rename to tests/if_test.v diff --git a/protocol/protocol_test.v b/tests/protocol_test.v similarity index 100% rename from protocol/protocol_test.v rename to tests/protocol_test.v diff --git a/socket_addr_test.v b/tests/socket_addr_test.v similarity index 100% rename from socket_addr_test.v rename to tests/socket_addr_test.v diff --git a/socket_test.v b/tests/socket_test.v similarity index 100% rename from socket_test.v rename to tests/socket_test.v diff --git a/udp.v b/udp.v deleted file mode 100644 index 7520b33..0000000 --- a/udp.v +++ /dev/null @@ -1,3 +0,0 @@ -module netio - -pub struct UDPSocket {}