From 66d7627b44511320eeb86b909c7c0563fb6c5331 Mon Sep 17 00:00:00 2001 From: Lorenzo Torres Date: Thu, 4 Sep 2025 19:56:16 +0200 Subject: [PATCH] first commit --- .gitignore | 8 ++++++++ LICENSE | 24 ++++++++++++++++++++++++ Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ README | 26 ++++++++++++++++++++++++++ config.def.h | 2 ++ config.mk | 22 ++++++++++++++++++++++ se.c | 29 +++++++++++++++++++++++++++++ se.h | 0 8 files changed, 163 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README create mode 100644 config.def.h create mode 100644 config.mk create mode 100644 se.c create mode 100644 se.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cfc27fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +config.h +**/*.swp +**/*~ +**/*.o +**/*.core +**/*.pem +vgcore* +se diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c71ceed --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2025, Lorenzo Torres +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..47b0009 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +# se - simple editor +# See LICENSE file for copyright and license details. + +include config.mk + +SRC = se.c +HDR = config.def.h se.h +OBJ = ${SRC:.c=.o} + +all: options se + +options: + @echo se build options: + @echo "CFLAGS = ${CFLAGS}" + @echo "LDFLAGS = ${LDFLAGS}" + @echo "CC = ${CC}" + +.c.o: + ${CC} -c ${CFLAGS} $< + +${OBJ}: config.h config.mk + +config.h: + cp config.def.h $@ + +se: ${OBJ} + ${CC} -o $@ ${OBJ} ${LDFLAGS} + +clean: + rm -f se ${OBJ} se-${VERSION}.tar.gz + +dist: clean + mkdir -p se-${VERSION} + cp -R LICENSE Makefile README config.mk\ + se.1 ${HDR} ${SRC} se-${VERSION} + tar -cf se-${VERSION}.tar se-${VERSION} + gzip se-${VERSION}.tar + rm -rf se-${VERSION} + +install: all + mkdir -p ${DESTDIR}${PREFIX}/bin + cp -f se ${DESTDIR}${PREFIX}/bin + chmod 755 ${DESTDIR}${PREFIX}/bin/se + mkdir -p ${DESTDIR}${MANPREFIX}/man1 + sed "s/VERSION/${VERSION}/g" < se.1 > ${DESTDIR}${MANPREFIX}/man1/se.1 + chmod 644 ${DESTDIR}${MANPREFIX}/man1/se.1 + +uninstall: + rm -f ${DESTDIR}${PREFIX}/bin/se\ + ${DESTDIR}${MANPREFIX}/man1/se.1 + +.PHONY: all options clean dist install uninstall diff --git a/README b/README new file mode 100644 index 0000000..d551d31 --- /dev/null +++ b/README @@ -0,0 +1,26 @@ +se - simple editor +============================ +TODO: description + + +Requirements +------------ +The only requirement is a posix compliant system with a C99 +compiler and make. + + +Installation +------------ +Edit config.mk to match your local setup (se is installed into +/usr/local by default). + +Afterwards enter the following command to build and install se (if +necessary as root): + + make clean install + + +Configuration +------------- +The configuration of se is done by creating a custom config.h +and (re)compiling the source code. diff --git a/config.def.h b/config.def.h new file mode 100644 index 0000000..db2a0fa --- /dev/null +++ b/config.def.h @@ -0,0 +1,2 @@ +/* See LICENSE file for copyright and license details. */ + diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..588591a --- /dev/null +++ b/config.mk @@ -0,0 +1,22 @@ +# se version +VERSION = 0.1 + +# Customize below to fit your system + +# paths +PREFIX = /usr +MANPREFIX = ${PREFIX}/share/man + +# OpenBSD (uncomment) +#MANPREFIX = ${PREFIX}/man + +# includes and libs +INCS = -I. +LIBS = +# flags +CFLAGS := -std=c99 -pedantic -Wall -O0 ${INCS} -DVERSION=\"${VERSION}\" +CFLAGS := ${CFLAGS} -g +LDFLAGS = ${LIBS} + +# compiler +CC = cc diff --git a/se.c b/se.c new file mode 100644 index 0000000..50fd644 --- /dev/null +++ b/se.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include + +struct pt_piece { + size_t start, length; + struct pt_piece *next; + struct pt_piece *prev; + uint8_t original; +}; + +struct pt_piece *pt_create_piece(size_t start, size_t length, uint8_t original) +{ + struct pt_piece *piece = (struct pt_piece *) malloc(sizeof(struct pt_piece)); + piece->start = start; + piece->length = length; + piece->next = NULL; + piece->prev = NULL; + piece->original = original; +} + +int main(void) +{ + printf("Hello world!\n"); + + return 0; +} diff --git a/se.h b/se.h new file mode 100644 index 0000000..e69de29