backlog of changes from the uconsole
This commit is contained in:
73
Wip/bitch/gtk4.c
Normal file
73
Wip/bitch/gtk4.c
Normal file
@@ -0,0 +1,73 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define BUF 100
|
||||
|
||||
static GtkApplication *app;
|
||||
|
||||
static void activate(GtkApplication *app, gpointer user_data);
|
||||
static void button_pressed(GtkWidget *button, gpointer data);
|
||||
|
||||
static void
|
||||
activate(GtkApplication *app, gpointer user_data){
|
||||
GtkWidget *box;
|
||||
GtkWidget *button;
|
||||
int c;
|
||||
char *s;
|
||||
GtkWidget *scrolledwindow;
|
||||
GtkWidget *window;
|
||||
|
||||
window = gtk_application_window_new(app);
|
||||
gtk_window_set_title(GTK_WINDOW(window), "Bitch");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), h, v);
|
||||
|
||||
scrolledwindow = gtk_scrolled_window_new();
|
||||
gtk_scrolled_window_set_overlay_scrolling(GTK_SCROLLED_WINDOW(scrolledwindow), 1);
|
||||
gtk_window_set_child(GTK_WINDOW(window), scrolledwindow);
|
||||
|
||||
box = gtk_list_box_new();
|
||||
//gtk_widget_set_halign(box, GTK_ALIGN_CENTER);
|
||||
//gtk_widget_set_valign(box, GTK_ALIGN_CENTER);
|
||||
gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrolledwindow), box);
|
||||
|
||||
for(;;){
|
||||
if(sip() == NULL)
|
||||
break;
|
||||
button = gtk_button_new_with_label(buf);
|
||||
g_signal_connect(
|
||||
button, "clicked", G_CALLBACK(button_pressed), NULL
|
||||
);
|
||||
gtk_list_box_insert(GTK_LIST_BOX(box), button, -1);
|
||||
}
|
||||
|
||||
gtk_window_present(GTK_WINDOW(window));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
button_pressed(GtkWidget *button, gpointer data){
|
||||
|
||||
switch(f){
|
||||
case 'w':
|
||||
g_print("%s\n", gtk_button_get_label(GTK_BUTTON(button)));
|
||||
break;
|
||||
case 'x':
|
||||
system(gtk_button_get_label(GTK_BUTTON(button)));
|
||||
break;
|
||||
}
|
||||
if(shy)
|
||||
g_application_quit(G_APPLICATION(app));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int setup(){
|
||||
app = gtk_application_new(
|
||||
"org.trinity.femaledog", G_APPLICATION_FLAGS_NONE
|
||||
);
|
||||
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
|
||||
status = g_application_run(G_APPLICATION(app), 1, fake_argv);
|
||||
g_object_unref(app);
|
||||
|
||||
return status;
|
||||
}
|
||||
42
Wip/bitch/motif.c
Normal file
42
Wip/bitch/motif.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/PushB.h>
|
||||
|
||||
static XtAppContext app_context;
|
||||
|
||||
static void activate(void);
|
||||
static void button_pressed(
|
||||
Widget w, XtPointer client_data, XmPushButtonCallbackStruct *cbs
|
||||
);
|
||||
|
||||
void setup(void){
|
||||
Widget button;
|
||||
Widget top_wid;
|
||||
|
||||
top_wid = XtVaAppInitialize(
|
||||
&app_context, "Bitch", NULL, 0, &fake_argc, fake_argv, NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
for(;;){
|
||||
if(sip() == NULL)
|
||||
break;
|
||||
|
||||
button = XmCreatePushButton(top_wid, buf, NULL, 0);
|
||||
XtManageChild(button);
|
||||
XtAddCallback(button, XmNactivateCallback, button_pressed, NULL);
|
||||
}
|
||||
|
||||
XtRealizeWidget(top_wid);
|
||||
XtAppMainLoop(app_context);
|
||||
}
|
||||
|
||||
static void
|
||||
button_pressed(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
XmPushButtonCallbackStruct *cbs
|
||||
){
|
||||
printf("pressed\n");
|
||||
if(shy)
|
||||
XtAppSetExitFlag(app_context);
|
||||
}
|
||||
65
Wip/bitswap/bitswap.c
Normal file
65
Wip/bitswap/bitswap.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include <stdio.h> /* fgetc(3), fprintf(3), fputc(3), stderr, stdin, stdout,
|
||||
* EOF */
|
||||
#include <sysexits.h> /* EX_OK, EX_USAGE */
|
||||
#include <unistd.h> /* getopt(3) */
|
||||
|
||||
/* untested */
|
||||
|
||||
int
|
||||
usage(char *argv0) {
|
||||
(void)fprintf(stderr, "Usage: %s\n", argv0);
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int c;
|
||||
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "")) != -1) {
|
||||
switch (c) {
|
||||
default: return usage(argv[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// Swapping algorithm: For example, say c is 0b0101_0101 */
|
||||
// /* <<< <<<< */
|
||||
// c <<= 7; /* Now 0b010_1010_1000_0000 */
|
||||
// /* ^ >^ */
|
||||
// c |= (c & (1 << 8)) >> 2; /* Now 0b010_1010_1000_0000 */
|
||||
// /* ^> >>^ */
|
||||
// c |= (c & (1 << 9)) >> 4; /* Now 0b010_1010_1010_0000 */
|
||||
// /* ^>> >>>^ */
|
||||
// c |= (c & (1 << 10)) >> 6; /* Now 0b010_1010_1010_0000 */
|
||||
// /* ^>>> >>>> ^ */
|
||||
// c |= (c & (1 << 11)) >> 8; /* Now 0b010_1010_1010_1000 */
|
||||
// /* ^ >>>> >>>> >^ */
|
||||
// c |= (c & (1 << 12)) >> 10; /* Now 0b010_1010_1010_1000 */
|
||||
// /* ^> >>>> >>>> >>^ */
|
||||
// c |= (c & (1 << 13)) >> 12; /* Now 0b010_1010_1010_1010 */
|
||||
// /* ^>> >>>> >>>> >>>^ */
|
||||
// c |= (c & (1 << 14)) >> 14; /* Now 0b010_1010_1010_1010 */
|
||||
// /* & 0b000_0000_1111_1111 */
|
||||
// c &= 0xFF; /* Now 0b1010_1010 */
|
||||
#endif
|
||||
|
||||
{
|
||||
int c;
|
||||
int i;
|
||||
|
||||
while ((c = fgetc(stdin)) != EOF) {
|
||||
for (c <<= 7, i = 8; i <= 14; ++i)
|
||||
{ c |= (c & (1 << i)) >> ((i - 7) * 2); }
|
||||
|
||||
if (fputc(c, stdout) == EOF)
|
||||
{ perror(argv[0]); return EX_IOERR; }
|
||||
}
|
||||
if (ferror(stdin) != 0) { perror(argv[0]); return EX_IOERR; }
|
||||
}
|
||||
|
||||
return EX_OK;
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
int
|
||||
isblank(int c){
|
||||
return c == '\t'
|
||||
|| c == ' ';
|
||||
}
|
||||
|
||||
int
|
||||
isspace(int c){
|
||||
return isblank(c)
|
||||
|| c == '\n'
|
||||
|| c == '\v'
|
||||
|| c == '\f'
|
||||
|| c == '\r';
|
||||
}
|
||||
|
||||
int
|
||||
isgraph(int c){ return c >= '!' && c <= '~'; }
|
||||
|
||||
int
|
||||
isprint(int c){ return c == ' ' || isgraph(c); }
|
||||
|
||||
int
|
||||
iscntrl(int c){ return !isprint(c); }
|
||||
|
||||
int
|
||||
isdigit(int c){ return c >= '0' && c <= '9'; }
|
||||
|
||||
int
|
||||
islower(int c){ return c >= 'a' && c <= 'z'; }
|
||||
|
||||
int
|
||||
isupper(int c){ return c >= 'A' && c <= 'Z'; }
|
||||
|
||||
int
|
||||
isxdigit(int c){
|
||||
return
|
||||
isdigit(c)
|
||||
|| (c >= 'a' && c <= 'f')
|
||||
|| (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
||||
int
|
||||
isalpha(int c){ return islower(c) || isupper(c); }
|
||||
|
||||
int
|
||||
isalnum(int c){ return isalpha(c) || isdigit(c) };
|
||||
|
||||
int
|
||||
ispunct(int c){ return c != ' ' && !isalnum(c) };
|
||||
|
||||
int
|
||||
tolower(int c){ return c - isupper(c) * ('A' - 'a'); }
|
||||
|
||||
int
|
||||
toupper(int c){ return c + islower(c) * ('A' - 'a'); }
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef _CTYPE_H
|
||||
# define CTYPE_H
|
||||
int isblank(int c);
|
||||
int isspace(int c);
|
||||
int isgraph(int c);
|
||||
int isprint(int c);
|
||||
int iscntrl(int c);
|
||||
int isdigit(int c);
|
||||
int islower(int c);
|
||||
int isupper(int c);
|
||||
int isxdigit(int c);
|
||||
int isalpha(int c);
|
||||
int isalnum(int c);
|
||||
int ispunct(int c);
|
||||
int tolower(int c);
|
||||
int toupper(int c);
|
||||
#endif /* ifndef _CTYPE_H */
|
||||
@@ -1,53 +0,0 @@
|
||||
char *
|
||||
strchr(const char *s, int c){
|
||||
char *r;
|
||||
|
||||
for(r = s; ; ++r){
|
||||
if(*r == c)
|
||||
return r;
|
||||
if(*r == '\0')
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
strrchr(const char *s, int c){
|
||||
char *r;
|
||||
char *p;
|
||||
|
||||
for(p = s, r = NULL; ; ++p){
|
||||
if(*p == c)
|
||||
r = p;
|
||||
if(*p == '\0')
|
||||
break;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
char *
|
||||
strchrnul(const char *s, int c){
|
||||
char *r;
|
||||
|
||||
for(r = s; ; ++r)
|
||||
if(*r == c || r == '\0')
|
||||
return r;
|
||||
}
|
||||
|
||||
size_t
|
||||
strlen(const char *s){
|
||||
size_t r;
|
||||
|
||||
for(r = 0; s[r] != '\0'; ++r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
size_t
|
||||
strnlen(const char *s, size_t maxlen){
|
||||
size_t r;
|
||||
|
||||
for(r = 0; s[r] != '\0' && r < maxlen; ++r);
|
||||
|
||||
return r;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef _STRING_H
|
||||
# define _STRING_H
|
||||
char * strchr(const char *s, int c);
|
||||
char * strrchr(const char *s, int c);
|
||||
char *strchrnul(const char *s, int c);
|
||||
size_t strlen(const char *s);
|
||||
size_t strnlen(const char *s, size_t maxlen);
|
||||
#endif /* ifndef _STRING_H */
|
||||
@@ -1,12 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdio.h> /* fprintf(3), stderr */
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> /* getopt(3) */
|
||||
|
||||
/* The philosophical bits - /should this be a shell script?/ -
|
||||
* are more complicated than the actual program. sed(1) is not currently a part
|
||||
* of this project so there shouldn't be reliance on it. */
|
||||
static int lines = 10; /* POSIX.1 */
|
||||
static char *program_name = "head";
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
char *argv0 = argv[0];
|
||||
size_t i;
|
||||
int c;
|
||||
extern char *optarg;
|
||||
extern int opterr, optind, optopt;
|
||||
|
||||
|
||||
if(argc > 0)
|
||||
program_name = argv[0];
|
||||
|
||||
while((c = getopt(argc, argv, "n:")) != -1)
|
||||
switch(c){
|
||||
case 'n':
|
||||
break;
|
||||
default:
|
||||
#ifdef IGIT /* parse -[digit] options */
|
||||
#endif /* ifdef IGIT */
|
||||
usage: fprintf(stderr, "Usage: %s (-n [lines]) (file...)\n",
|
||||
program_name);
|
||||
return EX_USAGE;
|
||||
}
|
||||
|
||||
@@ -9,3 +9,5 @@ def main(buffer, command):
|
||||
except Exception as err:
|
||||
print("%s" % str(err))
|
||||
return buffer
|
||||
|
||||
bang = main
|
||||
|
||||
@@ -3,10 +3,7 @@ import sys
|
||||
from buffer import Buffer
|
||||
from get_command import get_command
|
||||
|
||||
def version():
|
||||
print("it.py line editor; ALPHA 2021")
|
||||
return None
|
||||
|
||||
#$
|
||||
def main(buffer, supplied_command):
|
||||
if supplied_command != [] and len(supplied_command) > 1:
|
||||
command = supplied_command[1:]
|
||||
@@ -21,7 +18,8 @@ def main(buffer, supplied_command):
|
||||
if command == []:
|
||||
continue
|
||||
|
||||
if command[0] in buffer.modules.keys() or buffer.import_module_(command[0]):
|
||||
if (command[0] in buffer.modules.keys()
|
||||
or buffer.import_module_(command[0])):
|
||||
buffer = buffer.modules[command[0]].main(buffer, command)
|
||||
if type(buffer) is int:
|
||||
break
|
||||
|
||||
@@ -3,57 +3,59 @@
|
||||
char **
|
||||
getpaths(void)
|
||||
{
|
||||
char *p;
|
||||
char **q;
|
||||
char *path;
|
||||
size_t path_s;
|
||||
char *path_temp;
|
||||
char **paths;
|
||||
size_t paths_s;
|
||||
|
||||
if((path_temp = getenv(PATH_NAME)) == NULL){
|
||||
errno = ENOMEM; /* Cannot allocate memory */
|
||||
return NULL;
|
||||
{
|
||||
char *path_temp;
|
||||
size_t path_s;
|
||||
|
||||
if((path_temp = getenv(PATH_NAME)) == NULL)
|
||||
goto bail;
|
||||
|
||||
/* How long is path? */
|
||||
for(path_s = 0; path_temp[path_s] != '\0'; ++path_s);
|
||||
/* path_s has the size of the path string, not including the null
|
||||
* terminator */
|
||||
|
||||
/* getenv's return value mustn't be modified so copy it into memory we
|
||||
* control */
|
||||
if((path = malloc((sizeof *path) * (path_s + 1))) == NULL)
|
||||
goto bail;
|
||||
|
||||
memcpy(path, path_temp, path_s + 1);
|
||||
}
|
||||
|
||||
/* How long is path? */
|
||||
for(path_s = 0; path_temp[path_s] != '\0'; ++path_s);
|
||||
/* path_s has the size of the path string, not including the null
|
||||
* terminator */
|
||||
{
|
||||
char *p;
|
||||
char **q;
|
||||
size_t paths_s;
|
||||
|
||||
/* getenv's return value mustn't be modified so copy it into memory we
|
||||
* control */
|
||||
if((path = malloc(sizeof(char) * (path_s + 1))) == NULL){
|
||||
errno = ENOMEM; /* Cannot allocate memory */
|
||||
return NULL;
|
||||
}
|
||||
memcpy(path, path_temp, path_s + 1);
|
||||
path_temp = NULL;
|
||||
path_s = 0; /* This shouldn't be necessary anymore */
|
||||
/* How many paths in $PATH? */
|
||||
for(paths_s = 1, p = path; *p != '\0'; paths_s += *p++ == PATH_DELIMITER);
|
||||
|
||||
/* How many paths in $PATH? */
|
||||
for(paths_s = 1, p = path; *p != '\0'; paths_s += *p++ == PATH_DELIMITER);
|
||||
if((paths = malloc((sizeof *paths) * (paths_s + 1))) == NULL)
|
||||
goto bail1;
|
||||
|
||||
if((paths = malloc(sizeof(char *) * (paths_s + 1))) == NULL){
|
||||
free(path);
|
||||
errno = ENOMEM; /* Cannot allocate memory */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Replace all instances of the path delimiter with 0, and then put the
|
||||
* next path beginning into paths. */
|
||||
/* This way we can get multiple strings out of one span of memory. */
|
||||
for(*paths = p = path, q = paths + 1; *p != '\0';)
|
||||
if(*p++ == PATH_DELIMITER){
|
||||
*(p - 1) = '\0';
|
||||
*q++ = p;
|
||||
}
|
||||
/* Replace all instances of the path delimiter with 0, and then put the
|
||||
* next path beginning into paths. */
|
||||
/* This way we can get multiple strings out of one span of memory. */
|
||||
for(*paths = p = path, q = paths + 1; *p != '\0';)
|
||||
if(*p++ == PATH_DELIMITER){
|
||||
*(p - 1) = '\0';
|
||||
*q++ = p;
|
||||
}
|
||||
|
||||
paths[path_s] = NULL;
|
||||
paths[path_s] = NULL;
|
||||
}
|
||||
|
||||
/* Because paths[0] will always be path, we can just free(*paths) at
|
||||
* the end and discard path */
|
||||
path = NULL;
|
||||
|
||||
return paths;
|
||||
|
||||
bail1: free(path);
|
||||
bail: errno = ENOMEM; /* Cannot allocate memory */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
102
Wip/lsd/Makefile
Normal file
102
Wip/lsd/Makefile
Normal file
@@ -0,0 +1,102 @@
|
||||
include hyperlinks.mk
|
||||
|
||||
all: fhs learn
|
||||
|
||||
fhs:
|
||||
# Filesystem Hierarchy Standard 3.0, 2015
|
||||
# https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf
|
||||
|
||||
# section 3.2
|
||||
mkdir -p "$(PREFIX)/bin"
|
||||
mkdir -p "$(PREFIX)/boot"
|
||||
mkdir -p "$(PREFIX)/dev"
|
||||
mkdir -p "$(PREFIX)/etc"
|
||||
mkdir -p "$(PREFIX)/lib"
|
||||
mkdir -p "$(PREFIX)/media"
|
||||
mkdir -p "$(PREFIX)/mnt"
|
||||
mkdir -p "$(PREFIX)/opt"
|
||||
mkdir -p "$(PREFIX)/run"
|
||||
mkdir -p "$(PREFIX)/sbin"
|
||||
mkdir -p "$(PREFIX)/srv"
|
||||
mkdir -p "$(PREFIX)/tmp"
|
||||
mkdir -p "$(PREFIX)/usr"
|
||||
mkdir -p "$(PREFIX)/var"
|
||||
|
||||
# section 3.7.4
|
||||
mkdir -p "$(PREFIX)/etc/opt"
|
||||
|
||||
# section 4.2
|
||||
mkdir -p "$(PREFIX)/usr/bin"
|
||||
mkdir -p "$(PREFIX)/usr/lib"
|
||||
mkdir -p "$(PREFIX)/usr/local"
|
||||
mkdir -p "$(PREFIX)/usr/sbin"
|
||||
mkdir -p "$(PREFIX)/usr/share"
|
||||
|
||||
# section 4.3
|
||||
mkdir -p "$(PREFIX)/usr/include"
|
||||
mkdir -p "$(PREFIX)/var/spool"
|
||||
mkdir -p "$(PREFIX)/var/tmp"
|
||||
mkdir -p "$(PREFIX)/var/lock"
|
||||
ln -s "$(PREFIX)/usr/spool" "$(PREFIX)/var/spool"
|
||||
ln -s "$(PREFIX)/usr/tmp" "$(PREFIX)/var/tmp"
|
||||
ln -s "$(PREFIX)/usr/spool/locks" "$(PREFIX)/var/lock"
|
||||
|
||||
# section 4.6
|
||||
mkdir -p "$(PREFIX)/usr/lib"
|
||||
|
||||
# section 4.9
|
||||
mkdir -p "$(PREFIX)/usr/local"
|
||||
|
||||
# section 4.9.2
|
||||
mkdir -p "$(PREFIX)/usr/local/bin"
|
||||
#mkdir -p "$(PREFIX)/usr/local/etc" # see section 4.9.3
|
||||
mkdir -p "$(PREFIX)/usr/local/games"
|
||||
mkdir -p "$(PREFIX)/usr/local/include"
|
||||
mkdir -p "$(PREFIX)/usr/local/lib"
|
||||
mkdir -p "$(PREFIX)/usr/local/man"
|
||||
mkdir -p "$(PREFIX)/usr/local/sbin"
|
||||
mkdir -p "$(PREFIX)/usr/local/share"
|
||||
mkdir -p "$(PREFIX)/usr/local/src"
|
||||
|
||||
# section 4.9.3
|
||||
ln -s "$(PREFIX)/usr/local/etc" "$(PREFIX)/etc/local"
|
||||
|
||||
# section 4.11.6
|
||||
mkdir -p "$(PREFIX)/usr/share/man"
|
||||
|
||||
# section 4.11.7
|
||||
mkdir -p "$(PREFIX)/usr/share/misc"
|
||||
|
||||
# section 4.12
|
||||
mkdir -p "$(PREFIX)/usr/src"
|
||||
|
||||
# section 5.2
|
||||
mkdir -p "$(PREFIX)/var/lib"
|
||||
mkdir -p "$(PREFIX)/var/local"
|
||||
mkdir -p "$(PREFIX)/var/log"
|
||||
mkdir -p "$(PREFIX)/var/opt"
|
||||
#mkdir -p "$(PREFIX)/var/run" # see section 5.13.2
|
||||
|
||||
# section 5.8.2
|
||||
mkdir -p "$(PREFIX)/var/lib/misc"
|
||||
|
||||
# section 5.13.2
|
||||
ln -s "$(PREFIX)/var/run" "$(PREFIX)/run"
|
||||
|
||||
# section 6.1.10
|
||||
mkdir -p "$(PREFIX)/var/spool/cron"
|
||||
|
||||
$(PREFIX)/usr/src/linux: fhs
|
||||
git clone "$(LINUX_UPSTREAM_GIT)" "$(PREFIX)/usr/src/linux.tmp"
|
||||
mv "$(PREFIX)/usr/src/linux.tmp" "$(PREFIX)/usr/src/linux"
|
||||
|
||||
$(PREFIX)/usr/src/musl: fhs
|
||||
git clone "$(MUSL_UPSTREAM_GIT)" "$(PREFIX)/usr/src/musl.tmp"
|
||||
mv "$(PREFIX)/usr/src/musl.tmp" "$(PREFIX)/usr/src/musl"
|
||||
|
||||
musl: $(PREFIX)/usr/src/musl
|
||||
cd "$(PREFIX)/usr/src/musl"
|
||||
./configure --prefix="$(PREFIX)"
|
||||
$(MAKE) install
|
||||
|
||||
.PHONY: all
|
||||
4
Wip/lsd/hyperlinks.mk
Normal file
4
Wip/lsd/hyperlinks.mk
Normal file
@@ -0,0 +1,4 @@
|
||||
GCC_UPSTREAM_GIT=git://gcc.gnu.org/git/gcc.git
|
||||
LINUX_UPSTREAM_GIT=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
|
||||
MUSL_UPSTREAM_GIT=git://git.musl-libc.org/musl
|
||||
PKGSRC_UPSTREAM_HTTPS=https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.xz
|
||||
65
Wip/lsd/trilsd.7
Normal file
65
Wip/lsd/trilsd.7
Normal file
@@ -0,0 +1,65 @@
|
||||
.TH TRINITX 7
|
||||
|
||||
.SH PRONUNCIATION
|
||||
"Try LSD"
|
||||
|
||||
.SH SYNOPSIS
|
||||
.I TriLSD
|
||||
is a UNIX-like software distribution built upon the Linux kernel and the
|
||||
musl C standard library, with nearly all configuration options left to the
|
||||
user's own device.
|
||||
|
||||
.SH BASE SYSTEM
|
||||
A
|
||||
.I TriLSD
|
||||
system always has the following packages:
|
||||
dash,
|
||||
the GNU compiler collection,
|
||||
GNU make,
|
||||
musl,
|
||||
and
|
||||
linux and util-linux.
|
||||
.PP
|
||||
In addition,
|
||||
.I TriLSD
|
||||
needs a core utilities package.
|
||||
The GNU coreutils are a popular choice but Busybox or your own may be used.
|
||||
.PP
|
||||
.I TriLSD
|
||||
also needs an initialization system.
|
||||
OpenRC is the suggested choice but others may be used.
|
||||
SystemD is discouraged; it's mentioned for its popularity and frowned upon for
|
||||
its generally lax security.
|
||||
|
||||
.SH INSTALLATION
|
||||
To install
|
||||
.I TriLSD
|
||||
most of the POSIX specified utilities including awk, git(1), GNU make, and a C
|
||||
compiler that can build the GNU compiler collection must be installed.
|
||||
|
||||
.PP
|
||||
For the installation process see
|
||||
.RB try (1)
|
||||
|
||||
.SH PACKAGE MANAGEMENT
|
||||
.I TriLSD
|
||||
does not come with a package manager; the user may choose whatever
|
||||
system-independent package manager they prefer.
|
||||
|
||||
.SH CONTRIBUTING
|
||||
Pay attention to projects' guidelines for distributions.
|
||||
.PP
|
||||
musl guidelines: https://wiki.musl-libc.org/guidelines-for-distributions.html
|
||||
|
||||
.SH HISTORY
|
||||
The
|
||||
.I TriLSD
|
||||
project was started 2021-12-28 as Trinitx.
|
||||
|
||||
.SH COPYRIGHT
|
||||
.I TriLSD
|
||||
documentation and all in-house tools are part of the public domain.
|
||||
Components of the distribution are of course subject to their own licenses.
|
||||
|
||||
.SH SEE ALSO
|
||||
.RB try (1)
|
||||
8
Wip/rss/Cargo.toml
Normal file
8
Wip/rss/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "rss"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
@@ -1,37 +0,0 @@
|
||||
# pig\_birth
|
||||
|
||||
Initializes the pig.
|
||||
|
||||
# pig\_feed
|
||||
|
||||
Refreshes all the feed in the pigpen.
|
||||
|
||||
# pig\_fetch
|
||||
|
||||
Fetches the feed for the pigpen.
|
||||
|
||||
Not intended to be called on its own.
|
||||
|
||||
# pig\_latin
|
||||
|
||||
Prints internal pig details for a given feed file.
|
||||
|
||||
# pig\_name
|
||||
|
||||
Prints the file name for a given pig feed.
|
||||
|
||||
# pig\_pen
|
||||
|
||||
Prints the location of the pigpen, which houses all stowed pig feed.
|
||||
|
||||
A given feed will be stored as `"$(pig_pen)/$(pig_name)`.
|
||||
|
||||
# pig\_recall
|
||||
|
||||
Prints the contents of a given feed URL.
|
||||
|
||||
If the URL isn't already stowed, stows it before printing.
|
||||
|
||||
# pig\_stow
|
||||
|
||||
Stows fetched feed in the pigpen.
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
argv0="$0"
|
||||
|
||||
depend(){
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
printf "%s: %s: Could not find dependency.\n" "$argv0" "$1" \
|
||||
1>&2
|
||||
exit 69 # sysexits(3) EX_UNAVAILABLE
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
depend curl
|
||||
depend jq
|
||||
depend xq
|
||||
|
||||
mkdir "$(pig_pen)"
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
for file in "$(pig_pen)"/*; do
|
||||
pig_latin "$file" \
|
||||
| jq '.feed_url' \
|
||||
| xargs pig_stow &
|
||||
done
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
curl -so - -- "$1"
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
while str isvalue "$1"; do
|
||||
case "$1" in
|
||||
*xml)
|
||||
xq '.feed.pig' <"$1" ;;
|
||||
*json)
|
||||
jq '.feed.pig' <"$1" ;;
|
||||
esac
|
||||
done
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf "%s\n" "$1" \
|
||||
| tr -cd '[:alnum:]'
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
str isvalue "$1" \
|
||||
&& printf "Usage: %s\n" "$0" 1>&2 \
|
||||
&& exit 64 \
|
||||
|| str isvalue "$PIGPEN" \
|
||||
&& printf "%s\n" "$PIGPEN" \
|
||||
&& exit 0 \
|
||||
|| str isvalue "$XDG_CONFIG_HOME" \
|
||||
&& printf "%s\n" "$XDG_CONFIG_HOME" \
|
||||
&& exit 0 \
|
||||
|| printf "%s/.pigpen\n" "$HOME" \
|
||||
&& exit 0 \
|
||||
|| exit 1
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
filename="$(pig_pen)/$(pig_name "$1")"
|
||||
|
||||
test -e "$filename" || pig_stow "$1"
|
||||
cat "$filename"
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
while str isvalue "$1"; do
|
||||
|
||||
pig_fetch "$1" | xq -x "$(
|
||||
printf '.
|
||||
* { feed: { pig: {
|
||||
feed_url: "%b",
|
||||
pet_sound: "oink",
|
||||
stow_date: "%b",
|
||||
version: "0"
|
||||
} } }' "$1" "$(date '+%Y-%m-%dT%T')"\
|
||||
| tr -d '[:space:]' \
|
||||
)" >"$(pig_pen)/$(pig_name "$1")"
|
||||
|
||||
shift
|
||||
done
|
||||
9
Wip/rss/src/main.rs
Normal file
9
Wip/rss/src/main.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use json;
|
||||
fn feed() {
|
||||
|
||||
}
|
||||
fn stow(title: String) {
|
||||
|
||||
}
|
||||
fn main() {
|
||||
}
|
||||
182
Wip/rss/youtube
182
Wip/rss/youtube
@@ -1,182 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
argv0="$0"
|
||||
|
||||
PIGPEN="$(pig_pen)"
|
||||
|
||||
latin(){
|
||||
case "$1" in
|
||||
*json) jq '.feed.pig' <"$1" ;;
|
||||
*xml) xq '.feed.pig' <"$1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
list_channels(){
|
||||
pscat \
|
||||
[ sh -c "for file in \"$PIGPEN\"/*.xml; \
|
||||
do xq '{(.feed.link[0].\"@href\"): .feed.title}' \"\$file\"; \
|
||||
done 2>/dev/null" ] \
|
||||
[ sh -c "for file in \"$PIGPEN\"/*.json; \
|
||||
do jq '{(.feed.link[0].\"@href\"): .feed.title}' \"\$file\"; \
|
||||
done 2>/dev/null" ] \
|
||||
[ printf "\n" ] \
|
||||
| sed \
|
||||
-e '/{/d' \
|
||||
-e '/}/d' \
|
||||
-e 's/^ \"//g' \
|
||||
-e 's/\": \"/ /g' \
|
||||
-e 's/\,$//g' \
|
||||
-e 's/\"$//g'
|
||||
}
|
||||
|
||||
list_videos(){
|
||||
file="$(printf "$PIGPEN"/$( \
|
||||
list_channels \
|
||||
| sed "/$1/q" \
|
||||
| tail -n 1 \
|
||||
| cut -f 1 \
|
||||
| xargs pig_name \
|
||||
)*)"
|
||||
case "$file" in
|
||||
*json)
|
||||
jq \
|
||||
'reduce .feed.entry[] as $item (
|
||||
{};
|
||||
. + { ($item.link."@href"): $item.title }
|
||||
)' "$file"
|
||||
;;
|
||||
*xml)
|
||||
xq \
|
||||
'reduce .feed.entry[] as $item (
|
||||
{};
|
||||
. + { ($item.link."@href"): $item.title }
|
||||
)' "$file"
|
||||
;;
|
||||
*)
|
||||
printf "No file found!\n" 1>&2
|
||||
true
|
||||
;;
|
||||
esac | sed \
|
||||
-e '1d' \
|
||||
-e '$d' \
|
||||
-e 's/\": \"/ /g' \
|
||||
-e 's/^ \"//g' \
|
||||
-e 's/\,$//g' \
|
||||
-e 's/\"$//g' # this is really hacky
|
||||
|
||||
}
|
||||
|
||||
stow(){
|
||||
name="$PIGPEN/$(pig_name "$1")"
|
||||
pig_fetch "$1" | xq "$(
|
||||
date '+%Y-%m-%dT%T' \
|
||||
| xargs printf '
|
||||
. * { feed: { pig: {
|
||||
feed_url: "%b",
|
||||
pet_sound: "choo",
|
||||
stow_date: "%b",
|
||||
version: "0"
|
||||
} } }' "$1" \
|
||||
)" >"$name.json"
|
||||
rm -f "$name.xml"
|
||||
}
|
||||
|
||||
watch(){
|
||||
youtube-dl -F "$1"
|
||||
printf "Pick a format [22]: "
|
||||
input="$(head -n 1 | tr -d '\n')"
|
||||
str isalnum "$input" \
|
||||
&& str isdigit $input \
|
||||
|| input=22 \
|
||||
&& youtube-dl -f $input "$1" -o - \
|
||||
| mpv -
|
||||
}
|
||||
|
||||
usage(){
|
||||
printf "\
|
||||
Usage: %s
|
||||
list_channels
|
||||
list_videos [channel name]
|
||||
listen [video URL]
|
||||
refresh (channel name...)
|
||||
subscribe [channel URL...]
|
||||
watch [video URL]
|
||||
watch_latest [channel name]
|
||||
" "$argv0" 1>&2
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
list_channels)
|
||||
! str isvalue "$2" \
|
||||
|| usage
|
||||
list_channels
|
||||
;;
|
||||
list_videos) # do something with youtube-dl?
|
||||
list_videos "$2"
|
||||
;;
|
||||
listen)
|
||||
str isvalue "$2" \
|
||||
|| usage
|
||||
while str isvalue "$2"
|
||||
do youtube-dl "$2" -f bestaudio -o - \
|
||||
| mpv -
|
||||
shift
|
||||
done
|
||||
;;
|
||||
refresh)
|
||||
if ! str isvalue "$2"
|
||||
then for file in "$PIGPEN"/*
|
||||
do stow "$( \
|
||||
latin "$file" \
|
||||
| jq -r '.feed_url' \
|
||||
)"
|
||||
done
|
||||
else
|
||||
while str isvalue "$2"
|
||||
do stow "$( \
|
||||
latin "$( \
|
||||
list_channels \
|
||||
| grep "$2" \
|
||||
| cut -f 2 \
|
||||
)" | jq '.feed_url' \
|
||||
)"
|
||||
shift
|
||||
done
|
||||
fi
|
||||
;;
|
||||
subscribe)
|
||||
str isvalue "$2" \
|
||||
|| usage
|
||||
while str isvalue "$2"
|
||||
do stow "http://www.youtube.com/feeds/videos.xml?channel_id=$(
|
||||
youtube-dl \
|
||||
--get-filename \
|
||||
--playlist-items 1 \
|
||||
-o '%(channel_id)s' \
|
||||
"$2" \
|
||||
)"
|
||||
shift
|
||||
done
|
||||
;;
|
||||
watch) # needs work
|
||||
str isvalue "$2" \
|
||||
|| usage
|
||||
while str isvalue "$2"
|
||||
do watch "$2"
|
||||
done
|
||||
;;
|
||||
watch_latest)
|
||||
str isvalue "$2" \
|
||||
|| usage
|
||||
watch "$( \
|
||||
list_videos "$2" \
|
||||
| head -n 1 \
|
||||
| cut -f 1 \
|
||||
)"
|
||||
;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
@@ -1,13 +1,8 @@
|
||||
TARGETS = sysexits sysexits.h
|
||||
CFLAGS = -I..
|
||||
all: sysexits sysexits.h
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGETS)
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $@.c
|
||||
sysexits: sysexits.c
|
||||
|
||||
sysexits.h: sysexits
|
||||
./sysexits >sysexits.h
|
||||
|
||||
.PHONY: all
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "arraylen.h"
|
||||
|
||||
/* Thanks to u/smcameron on Reddit. */
|
||||
|
||||
@@ -12,7 +11,7 @@
|
||||
* technicality.
|
||||
* I implemented sysexits(3) in the enum method before reading the BSD 4.0
|
||||
* source to see how they did it. */
|
||||
#define ENUM 1
|
||||
#define DEFINE 1
|
||||
|
||||
static char *program_name = "sysexits";
|
||||
|
||||
|
||||
21
Wip/sysexits/sysexits.h
Normal file
21
Wip/sysexits/sysexits.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _SYSEXITS_H
|
||||
# define _SYSEXITS_H
|
||||
enum{
|
||||
EX_OK = 0,
|
||||
EX_USAGE = 64,
|
||||
EX_DATAERR = 65,
|
||||
EX_NOINPUT = 66,
|
||||
EX_NOUSER = 67,
|
||||
EX_NOHOST = 68,
|
||||
EX_UNAVAILABLE = 69,
|
||||
EX_SOFTWARE = 70,
|
||||
EX_OSERR = 71,
|
||||
EX_OSFILE = 72,
|
||||
EX_CANTCREAT = 73,
|
||||
EX_IOERR = 74,
|
||||
EX_TEMPFAIL = 75,
|
||||
EX_PROTOCOL = 76,
|
||||
EX_NOPERM = 77,
|
||||
EX_CONFIG = 78
|
||||
};
|
||||
#endif /* ifndef _SYSEXITS_H */
|
||||
@@ -1,3 +0,0 @@
|
||||
- move executables somewhere in path
|
||||
- `$ toki_update` to fetch dictionary
|
||||
- `$ toki_sitelen` to tokiponize
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
toki_ucsur "$@" | utf8
|
||||
Reference in New Issue
Block a user