Initial commit
authorArmaan Bhojwani <me@armaanb.net>
Mon, 10 May 2021 02:11:55 +0000 (22:11 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 10 May 2021 02:26:28 +0000 (22:26 -0400)
.gitignore [new file with mode: 0644]
LICENSE [new file with mode: 0644]
Makefile [new file with mode: 0644]
README [new file with mode: 0644]
acheam.pc [new file with mode: 0644]
man/libacheam.3.scd [new file with mode: 0644]
man/tolowerw.3.scd [new symlink]
man/toupperw.3.scd [new file with mode: 0644]
src/acheam.h [new file with mode: 0644]
src/tolowerw.c [new file with mode: 0644]
src/toupperw.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..6d5e378
--- /dev/null
@@ -0,0 +1,4 @@
+*.o
+*.so
+man/*
+!man/*.scd
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..f3fa714
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2021 Armaan Bhojwani
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..522fd86
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,34 @@
+DESTDIR  ?= /usr/local
+CFLAGS   := -Wall -Wextra -pedantic -std=c99 -fPIC ${CFLAGS}
+
+all: lib man
+
+lib:
+       ${CC} -shared ${LDFLAGS} ${OBJS} -o acheam.so src/*.c ${CFLAGS}
+
+man:
+       for i in man/*.scd; do \
+               scdoc < $$i > $$(echo "$$i" | rev | cut -f 2- -d '.' | rev); \
+       done
+
+install: all
+       mkdir -p ${DESTDIR}/include \
+               ${DESTDIR}/lib/pkgconfig \
+               ${DESTDIR}/man/man3
+
+       cp acheam.so    ${DESTDIR}/lib
+       cp acheam.pc    ${DESTDIR}/lib/pkgconfig
+       cp src/acheam.h ${DESTDIR}/include
+       cp man/*.3      ${DESTDIR}/man/man3/
+
+uninstall:
+       rm ${DESTDIR}/include/acheam.h \
+               ${DESTDIR}/lib/acheam.so \
+               ${DESTDIR}/lib/pkgconfig/acheam.pc
+
+       for i in man/*.scd; do \
+               rm ${DESTDIR}/man/man3/$$(basename "$$i" ".scd"); \
+       done
+
+.POSIX:
+.PHONY: all man
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..5312152
--- /dev/null
+++ b/README
@@ -0,0 +1,13 @@
+libacheam
+---------
+
+Personal C library to make writing programs a bit faster. Fully documented 0
+dependency POSIX C99. Manpages require scdoc to build (but that's also 0
+dependency C99).
+
+Installation:
+       make install
+
+Further documentation can be found in libacheam(3).
+
+Copyright MIT License Armaan Bhojwani 2021.
diff --git a/acheam.pc b/acheam.pc
new file mode 100644 (file)
index 0000000..d1b243d
--- /dev/null
+++ b/acheam.pc
@@ -0,0 +1,11 @@
+prefix=/usr/local
+exec_prefix=${prefix}
+includedir=${prefix}/include
+libdir=${prefix}/lib
+
+Name: libacheam
+Version: 0.0.0
+Description: Armaan's personal C library
+Requires:
+Cflags: -I${includedir}/
+Libs: -L${libdir} -lacheam
diff --git a/man/libacheam.3.scd b/man/libacheam.3.scd
new file mode 100644 (file)
index 0000000..468d6d1
--- /dev/null
@@ -0,0 +1,20 @@
+libacheam(3)
+
+# NAME
+libacheam - Armaan's personal C library
+
+# DESCRIPTION
+Like many advancing C programmers, I soon found the C standard library
+inadequate for my day to day needs. This library is a way for me to fix that in
+my own projects. It will grow as I need it to, but probably not very quickly.
+I've designed it to be as portable and permissive as possible (with one
+exception being that it is written in C99 instead of ANSI C).
+
+# SEE ALSO
+toupperw(3), tolowerw(3)
+
+# LICENSE
+MIT License Armaan Bhojwani 2021.
+
+# BUGS, PATCHES, SOURCE
+https://sr.ht/~armaan/libacheam
diff --git a/man/tolowerw.3.scd b/man/tolowerw.3.scd
new file mode 120000 (symlink)
index 0000000..2307051
--- /dev/null
@@ -0,0 +1 @@
+toupperw.3.scd
\ No newline at end of file
diff --git a/man/toupperw.3.scd b/man/toupperw.3.scd
new file mode 100644 (file)
index 0000000..885627e
--- /dev/null
@@ -0,0 +1,25 @@
+toupperw(3)
+
+# NAME
+toupperw, tolowerw - convert strings to uppercase or lowercase
+
+# SYNOPSIS
+```
+#include <acheam.h>
+
+char * toupperw(char *);
+char * tolowerw(char *);
+```
+
+# DESCRIPTION
+Like ctype.h's toupper() and tolower(), except that it can take full strings
+instead of just single characters.
+
+# RETURN VALUE
+A pointer to the converted string.
+
+# SEE ALSO
+toupper(3), tolower(3)
+
+# COLOPHON
+This page is a part of libacheam(3).
diff --git a/src/acheam.h b/src/acheam.h
new file mode 100644 (file)
index 0000000..df3460e
--- /dev/null
@@ -0,0 +1,2 @@
+char * tolowerw(char *input);
+char * toupperw(char *input);
diff --git a/src/tolowerw.c b/src/tolowerw.c
new file mode 100644 (file)
index 0000000..386ce2d
--- /dev/null
@@ -0,0 +1,15 @@
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+char *
+tolowerw(char *inp)
+{
+       char *tmp = calloc(strlen(inp), sizeof(char));
+       strcpy(tmp, inp);
+       for (int i = 0; tmp[i]; i++){
+               tmp[i] = tolower(tmp[i]);
+       }
+       return tmp;
+}
+
diff --git a/src/toupperw.c b/src/toupperw.c
new file mode 100644 (file)
index 0000000..99ac102
--- /dev/null
@@ -0,0 +1,15 @@
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+char *
+toupperw(char *inp)
+{
+       char *tmp = calloc(strlen(inp), sizeof(char));
+       strcpy(tmp, inp);
+       for (int i = 0; tmp[i]; i++){
+               tmp[i] = toupper(tmp[i]);
+       }
+       return tmp;
+}
+