rename from xmllib to xemil

This commit is contained in:
Nishi 2025-12-23 02:05:29 +09:00
commit 25cc3877b2
Signed by: nishi
GPG key ID: 27EF69B208EB9343
8 changed files with 30 additions and 30 deletions

View file

@ -10,15 +10,15 @@ SO = .so
.PHONY: all format clean
.SUFFIXES: .c .o
all: libxmllib$(SO)
all: libxemil$(SO)
format:
clang-format --verbose -i `find src include -name "*.c" -or -name "*.h"` example.c
example: example.c libxmllib$(SO)
$(CC) -o $@ example.c -I include -Wl,-R. -L. -lxmllib
example: example.c libxemil$(SO)
$(CC) -o $@ example.c -I include -Wl,-R. -L. -lxemil
libxmllib$(SO): $(OBJS)
libxemil$(SO): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
.c.o:

View file

@ -1,4 +1,4 @@
#include <xmllib.h>
#include <xemil.h>
#define INDENT 2
@ -46,7 +46,7 @@ int main(int argc, char** argv) {
int i;
for(i = 1; i < argc; i++) {
xmllib_t* h = xl_open_file(argv[i]);
xemil_t* h = xl_open_file(argv[i]);
if(h != NULL) {
printf("%s:\n", argv[i]);
if(xl_parse(h)) {

View file

@ -1,5 +1,5 @@
#ifndef __XMLLIB_H__
#define __XMLLIB_H__
#ifndef __XEMIL_H__
#define __XEMIL_H__
#include <stdio.h>
#include <stdlib.h>
@ -9,16 +9,16 @@
#define XLDECL extern
typedef struct xl_driver xl_driver_t;
typedef struct xmllib xmllib_t;
typedef struct xemil xemil_t;
typedef struct xl_node xl_node_t;
typedef struct xl_attribute xl_attribute_t;
#define XL_SKIPPABLE(x) (((x) == ' ') || ((x) == '\t') || ((x) == '\n') || ((x) == '\r'))
struct xl_driver {
int (*open)(xmllib_t* handle);
int (*read)(xmllib_t* handle, void* data, int size);
void (*close)(xmllib_t* handle);
int (*open)(xemil_t* handle);
int (*read)(xemil_t* handle, void* data, int size);
void (*close)(xemil_t* handle);
};
enum XL_NODE_TYPE {
@ -50,7 +50,7 @@ struct xl_node {
xl_node_t* next;
};
struct xmllib {
struct xemil {
xl_driver_t* driver;
void* drv_opaque;
void* drv_arg;
@ -62,16 +62,16 @@ extern "C" {
#endif
/* core.c */
XLDECL xmllib_t* xl_open(xl_driver_t* driver, void* arg);
XLDECL xemil_t* xl_open(xl_driver_t* driver, void* arg);
XLDECL int xl_parse(xmllib_t* handle);
XLDECL int xl_parse(xemil_t* handle);
XLDECL void xl_close(xmllib_t* handle);
XLDECL void xl_close(xemil_t* handle);
/* file.c */
XLDECL xl_driver_t* xl_driver_file;
XLDECL xmllib_t* xl_open_file(const char* filename);
XLDECL xemil_t* xl_open_file(const char* filename);
/* util.c */
XLDECL char* xl_util_trim(const char* str);

View file

@ -1,4 +1,4 @@
#include <xmllib.h>
#include <xemil.h>
void xl_array_push(int** array, int value) {
if((*array) == NULL) {

View file

@ -1,7 +1,7 @@
#include <xmllib.h>
#include <xemil.h>
xmllib_t* xl_open(xl_driver_t* driver, void* arg) {
xmllib_t* handle = malloc(sizeof(*handle));
xemil_t* xl_open(xl_driver_t* driver, void* arg) {
xemil_t* handle = malloc(sizeof(*handle));
memset(handle, 0, sizeof(*handle));
handle->driver = driver;
@ -132,7 +132,7 @@ static xl_attribute_t* xl_parse_attribute(const char* str) {
return first;
}
int xl_parse(xmllib_t* handle) {
int xl_parse(xemil_t* handle) {
jmp_buf err;
int* state = NULL;
char* node = NULL;
@ -416,7 +416,7 @@ void recursive_free(xl_node_t* node) {
free(node);
}
void xl_close(xmllib_t* handle) {
void xl_close(xemil_t* handle) {
if(handle->root != NULL) recursive_free(handle->root);
handle->driver->close(handle);

View file

@ -1,16 +1,16 @@
#include <xmllib.h>
#include <xemil.h>
static int xl_driver_file_open(xmllib_t* handle) {
static int xl_driver_file_open(xemil_t* handle) {
if((handle->drv_opaque = fopen(handle->drv_arg, "rb")) == NULL) return 0;
return 1;
}
static int xl_driver_file_read(xmllib_t* handle, void* data, int size) {
static int xl_driver_file_read(xemil_t* handle, void* data, int size) {
return fread(data, 1, size, handle->drv_opaque);
}
static void xl_driver_file_close(xmllib_t* handle) {
static void xl_driver_file_close(xemil_t* handle) {
fclose(handle->drv_opaque);
}
@ -21,6 +21,6 @@ xl_driver_t xl_driver_file_rec = {
};
xl_driver_t* xl_driver_file = &xl_driver_file_rec;
xmllib_t* xl_open_file(const char* filename) {
xemil_t* xl_open_file(const char* filename) {
return xl_open(xl_driver_file, (void*)filename);
}

View file

@ -1,4 +1,4 @@
#include <xmllib.h>
#include <xemil.h>
#define CAST_I32(x) ((int)(x))

View file

@ -1,4 +1,4 @@
#include <xmllib.h>
#include <xemil.h>
char* xl_util_trim(const char* str) {
char* s = malloc(strlen(str) + 1);