From 4b383874b60fc2d25318921574eb73f0c806cfbd Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Tue, 30 Apr 2019 15:53:55 -0500 Subject: [PATCH] Standardizing for PKGBUILD --- .gitignore | 2 + Bash/header | 15 +++++ C/ll.h | 135 ++++++++++++++++++++++++++++++++++++++++ CSharp/Configure.csharp | 2 + Java/PortTest.java | 35 +++++++++++ LICENSE | 27 ++++++++ Makefile | 29 +++++++++ PKGBUILD | 46 ++++++++++++++ 8 files changed, 291 insertions(+) create mode 100644 .gitignore create mode 100644 C/ll.h create mode 100644 Java/PortTest.java create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 PKGBUILD diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e9648f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +pkg/ +src/ diff --git a/Bash/header b/Bash/header index 87536c7..98ac30f 100644 --- a/Bash/header +++ b/Bash/header @@ -249,3 +249,18 @@ function getmagnetlink { echo '<'$magnetlink'>' fi } + +### AniNIX Foundation help ### + +function findaninixcheckouts { + find /usr/local/src/ -type f -name config -exec egrep -l 'url[[:space:]]=[[:space:]]/srv/foundation|url[[:space:]]=[[:space:]]https://aninix.net|url[[:space:]]=[[:space:]]([a-zA-Z0-9])+@aninix.net' {} \; 2>/dev/null | sed 's#.git/config$##' +} + +function aninixgitstatus { + for i in `findaninixcheckouts`; do + infoheader BEGIN REPORT for "$i" + git -C "$i" status + infoheader END REPORT + echo + done +} diff --git a/C/ll.h b/C/ll.h new file mode 100644 index 0000000..a3d39a6 --- /dev/null +++ b/C/ll.h @@ -0,0 +1,135 @@ +#include +#include +#include +#include + +#define DEBUG 0 + +/* This is a library for a singly-linked list with O(n) searchtime. + It is intended to be used for small, changing datasets in the bot +*/ + +//The struct specification +typedef struct { + char * data; + void * next; +} LLElem; + +/* Print the list */ +void ll_printall(LLElem * root) { + if (DEBUG) printf("printing\n"); + while (root != NULL) { + printf("%s\n",root->data); + root = root->next; + } + putchar('\n'); +} + +/* Returns 1 on true, 0 on false */ +int ll_contains(char * data, LLElem * root) { + if (data == NULL) return 0; + while (root != NULL) { + if (!strcmp(root->data,data)) { + return 1; + } + root = root->next; + } + return 0; +} + +/* Add an element and return the new tree */ +LLElem * ll_add(char * new_data, LLElem * root) { + char * newString = calloc(strlen(new_data),1); + strncpy(newString,new_data,strlen(new_data)); + if (root == NULL) { + root = calloc(sizeof(LLElem),1); + root->data = newString; + root->next = NULL; + if (DEBUG) printf("Creating root %d with:\n%s\n:done\n\n",root,newString); + if (DEBUG) ll_printall(root); + return root; + } else { + if (!ll_contains(new_data,root)) { + LLElem * curr = root; + while (curr->next != NULL) { + curr = (LLElem *) curr->next; + } + curr->next = calloc(sizeof(LLElem),1); + curr = (LLElem *) curr->next; + curr->data = newString; + curr->next = NULL; + if (DEBUG) printf("Appending to %d:\n%s\n:done\n\n",root,newString); + if (DEBUG) ll_printall(root); + return root; + } + } + return NULL; +} + + +/* Remove an element */ +LLElem * ll_remove(char * old_data, LLElem * root) { + LLElem * tmp; + //TODO paused here -- need to rewrite. + return NULL; +} + +/* Delete and free the contents of a list */ +void ll_removeall(LLElem * root) { + while (root != NULL) { + root = ll_remove(root->data,root); + } +} + +/* read the contents of a file, comma-delimited, into a file */ +LLElem * ll_read(char * filename, int * count) { + FILE * fd = fopen(filename,"r"); + if (fd == NULL) { + if (DEBUG) printf("No file found.\n"); + return NULL; + } else { + if (DEBUG) printf("File opened.\n"); + } + char * buffer, * tmp; + int fcount = 0; + fseek(fd,0,SEEK_END); + size_t size = ftell(fd); + fseek(fd,0,SEEK_SET); + buffer=calloc(size,1); + fread(buffer,size,1,fd); + char entry[size]; //create a buffer with the maximum size + bzero(entry,size);//zero the buffer + int ccount=0; //ccount is the current character location. + int tmpsize=0; //tmpsize will be the size of the buffer + LLElem * root = NULL; + while (ccount < size) { + if (buffer[ccount]==10) { + entry[tmpsize]=0; + //if (DEBUG) printf("%s -> --%s--\n",entry,buffer); + if (entry != NULL && strlen(entry)) { + fcount++; + root = ll_add(entry,root); + //if (DEBUG) printf("Added --%s--\n\n",entry); + tmpsize=0; + } + + } else { + entry[tmpsize] = buffer[ccount]; + tmpsize++; + } + ccount++; + } + if (count != NULL) *count=fcount; + return root; +} + +/* Print the list */ +char * ll_get(int num,LLElem * root) { + if (DEBUG) printf("printing\n"); + while (num-- && root != NULL) { + if (DEBUG) printf("%s,",root->data); + root = root->next; + } + if (num && root != NULL) return root->data; + return NULL; +} diff --git a/CSharp/Configure.csharp b/CSharp/Configure.csharp index e5addab..ac1d7cc 100644 --- a/CSharp/Configure.csharp +++ b/CSharp/Configure.csharp @@ -20,6 +20,7 @@ namespace AniNIX.Shared { String line; while (true) { line = fileReader.ReadLine(); + ReportMessage.Log(Verbosity.Verbose,String.Format("Read line: {0}",line)); if (line == null) break; //Ignore comments prefixed with '#' if (line.StartsWith("#")) continue; @@ -57,6 +58,7 @@ namespace AniNIX.Shared { } return foundEntries; } + /// /// If a conf section doesn't use key=value syntax, use this to grab the lines instead. /// diff --git a/Java/PortTest.java b/Java/PortTest.java new file mode 100644 index 0000000..739d7b5 --- /dev/null +++ b/Java/PortTest.java @@ -0,0 +1,35 @@ +import java.io.ObjectOutputStream; +import java.net.Socket; +import java.io.PrintWriter; +import java.io.IOException; + +public class PortTest { + + + private String host; + private int port; + + public PortTest(String host, int port) { + this.host=host; + this.port=port; + } + + public void Test() { + try { + Socket socket = new Socket(this.host,this.port); + PrintWriter out = new PrintWriter(socket.getOutputStream(),true); + out.println(""); + System.out.println("OK"); + } catch (Exception e) { System.out.println(e.getMessage()); } + } + + public static void main(String[] args) { + try { + PortTest t = new PortTest(args[0],Integer.parseInt(args[1])); + t.Test(); + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..878d895 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +# http://www.wtfpl.net/about/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + + ANINIX ADDENDUM + + Trademark Pending 2017 (https://aninix.net/irc/) + + The "AniNIX" name and |> logo is trademark-pending as of 2017. All + AniNIX materials can be reproduced and re-used, though you must + contact the admins of the network to get written permission to use + the AniNIX name. + + Attribution is appreciated for other materials but not legally + required or necessary. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e0bc265 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +installdir = ${pkgdir}/opt/aninix/SharedLibraries/ +targets = Bash C CSharp + +compile: + @echo Nothing to compile. + +install: compile + mkdir -p ${installdir} + for target in ${targets}; do rsync -avzl "$$target" ${installdir}; done + make checkperm + +clean: + for i in `cat .gitignore`; do rm -Rf $$i; done + +uninstall: + rm -Rf ${installdir} + +test: + @echo Nothing to do. + +checkperm: + chmod -R 0755 ${installdir} + chown root:root ${installdir} + +diff: ${INSTALLFIR} + diff -rc . ${installdir} + +reverse: + rsync -avzlp ${installdir} . diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..aabe4de --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,46 @@ +# Maintainer: Shikoba Kage +pkgname=aninix-shared-libraries +pkgver=0.1.e7c96f9 +pkgver() { + printf "0.1.""$(git rev-parse --short HEAD)" +} +pkgrel=1 +epoch= +pkgdesc="AniNIX::Foundation/SharedLibraries \\\\ Shared code libraries that all the AniNIX projects should use -- this should reduce error and code duplication" +arch=("x86_64") +url="https://aninix.net/foundation/SharedLibraries" +license=('custom') +groups=() +depends=('mono>=5.0.0' 'curl' 'grep' 'bash>=4.4' 'git>=2.13') +makedepends=('make>=4.2') +checkdepends=() +optdepends=() +provides=('aninix-shared-libraries') +conflicts=() +replaces=() +backup=() +options=() +install= +changelog= +source=() +noextract=() +md5sums=() +validpgpkeys=() + +prepare() { + git pull +} + +build() { + make -C .. +} + +check() { + printf 'quit\n\n' | make -C "${srcdir}/.." test +} + +package() { + export pkgdir="${pkgdir}" + make -C .. install + install -D -m644 ../LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" +}