Overview
Comment: | unbreak build (oops sorry about that) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b4009ca1bd19bcf34e0e7553cfa1ac47 |
User & Date: | lexi on 2024-05-07 19:25:37 |
Other Links: | manifest | tags |
Context
2024-07-17
| ||
20:10 | add missing subtitle support check-in: 362f9a6647 user: lexi tags: trunk | |
2024-05-07
| ||
19:25 | unbreak build (oops sorry about that) check-in: b4009ca1bd user: lexi tags: trunk | |
2024-03-15
| ||
18:02 | fix incorrect plural check-in: 3f5d6b4b81 user: lexi tags: trunk | |
Changes
Added bind/bind.h version [9c4f9e0a4b].
> > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#pragma once #include <lua.h> #include <lauxlib.h> #include <stddef.h> #include <stdbool.h> #include <stdint.h> #define _luafn(name) static int LX_##name (lua_State* l) #define _export(name) lua_pushcfunction(l, LX_##name), lua_setfield(l, -2, #name); #define _luaret_bool(b) {lua_pushboolean(l, b); return 1;} #define _luaAPI(mod, ...) int luaopen_bind_##mod (lua_State* l) { \ lua_newtable(l); \ __VA_ARGS__; \ return 1; \ } /* this comment serves only to unfuck a GCC bug */ |
Added bind/net.c version [c79d47efa1].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
#include "bind.h" #include <curl/curl.h> #define _str(...) #__VA_ARGS__ #define _e_tag "(native-bind " __FILE__ ":" _str(__LINE__) ") " static size_t buffer_string ( char* ptr, size_t size, size_t nmemb, void* dest ) { luaL_Buffer* const data = dest; luaL_addlstring(data, ptr, size*nmemb); return size*nmemb; } _luafn(fetchURI) { const char* p_uri = luaL_checkstring(l,1); CURL* h = curl_easy_init(); if (!h) { lua_pushstring(l, _e_tag "libcurl failed to init"); lua_error(l); } // int unwind = lua_gettop(l); luaL_Buffer download; luaL_buffinit(l, &download); char ebuf [CURL_ERROR_SIZE]; curl_easy_setopt(h, CURLOPT_URL, p_uri); curl_easy_setopt(h, CURLOPT_WRITEFUNCTION, buffer_string); curl_easy_setopt(h, CURLOPT_WRITEDATA, &download); curl_easy_setopt(h, CURLOPT_FOLLOWLOCATION,true); curl_easy_setopt(h, CURLOPT_ERRORBUFFER, ebuf); CURLcode e = curl_easy_perform(h); if (e == 0) { curl_easy_cleanup(h); luaL_pushresult(&download); return 1; } else { // lua_settop(l,unwind); lua_pushnil(l); lua_pushstring(l, ebuf); return 2; } } _luaAPI(net, _export(fetchURI)); |
Added bind/posix.c version [68a13b3104].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include "bind.h" #include <unistd.h> #include <stdio.h> #include <assert.h> _luafn(getcwd) { /* getcwd() */ size_t bufsz = 256; /* VLA resize hack */ for (;;) { char cwd [bufsz]; if (getcwd(cwd, bufsz) == NULL) { assert(bufsz < (2 * 1024*1024)); /* sanity check */ bufsz = bufsz * 2; continue; } lua_pushstring(l, cwd); return 1; } } _luafn(isatty) { /* isatty(stream) */ luaL_Stream* stream = lua_touserdata(l, 1); if (stream == NULL) return 0; int fd = fileno(stream -> f); _luaret_bool(isatty(fd)); } _luaAPI(posix, _export(getcwd); _export(isatty)); |
Added bind/strutils.c version [9bbacd41f1].
> > > > > > > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include "bind.h" _luafn(rangematch) { luaL_checkstring(l, 1); luaL_checknumber(l, 2); luaL_checkstring(l, 3); size_t strl = 0, matl = 0, start = lua_tointeger(l, 2)-1; const char* str = lua_tolstring(l, 1, &strl); const char* mat = lua_tolstring(l, 3, &matl); size_t to; if (start > strl || (to = start + matl) > strl) { _luaret_bool(false); } for (size_t i = start; i<to; ++i) { if (str[i] != mat[i - start]) _luaret_bool(false); } _luaret_bool(true); } _luaAPI(strutils, _export(rangematch)); |
Added shell.nix version [0124789a13].
> > > > > > > > > > > > > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
{pkgs ? import <nixpkgs> {}, ...}: let debuggable = d: d.overrideAttrs(o: rec { dontStrip = true; }); in pkgs.mkShell { buildInputs = with pkgs; [ lua5_4 curl ]; shellHook = '' exec fish ''; NIX_ENFORCE_PURITY = false; } |