first commit
This commit is contained in:
commit
66d7627b44
8 changed files with 163 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
config.h
|
||||
**/*.swp
|
||||
**/*~
|
||||
**/*.o
|
||||
**/*.core
|
||||
**/*.pem
|
||||
vgcore*
|
||||
se
|
||||
24
LICENSE
Normal file
24
LICENSE
Normal file
|
|
@ -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 <organization> 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 <COPYRIGHT HOLDER> ''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 <COPYRIGHT HOLDER> 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.
|
||||
52
Makefile
Normal file
52
Makefile
Normal file
|
|
@ -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
|
||||
26
README
Normal file
26
README
Normal file
|
|
@ -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.
|
||||
2
config.def.h
Normal file
2
config.def.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
22
config.mk
Normal file
22
config.mk
Normal file
|
|
@ -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
|
||||
29
se.c
Normal file
29
se.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <se.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
||||
0
se.h
Normal file
0
se.h
Normal file
Loading…
Add table
Add a link
Reference in a new issue