From: nishi Date: Mon, 20 May 2024 03:37:36 +0000 (+0000) Subject: update things X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=868fbb557c99467c03ee2953750db778cc620a77;p=dataworks.git update things git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@39 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Client/Makefile b/Client/Makefile index 669ad72..d0b21c1 100644 --- a/Client/Makefile +++ b/Client/Makefile @@ -8,7 +8,7 @@ OBJS = main.o all: dataworks$(EXEC_SUFFIX) dataworks$(EXEC_SUFFIX): $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -ldataworks + $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) ../Library/$(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX) .c.o: $(CC) -I../Library $(CFLAGS) -c -o $@ $< diff --git a/Client/main.c b/Client/main.c index 7487beb..0160e4c 100644 --- a/Client/main.c +++ b/Client/main.c @@ -118,7 +118,7 @@ int main(int argc, char** argv) { printf("Bad database file or non-existent.\n"); return 1; } - printf("Opened the database (Version %d).\n", db->version); + printf("Opened the database (Version %d).\n", dataworks_database_get_version(db)); printf("\n"); printf("Type a command (.help) for the help\n"); printf("\n"); diff --git a/Library/Makefile b/Library/Makefile index d572074..cd7c733 100644 --- a/Library/Makefile +++ b/Library/Makefile @@ -5,11 +5,14 @@ OBJS = parser.o database.o util.o dataworks.o -all: $(LIB_PREFIX)dataworks$(LIB_SUFFIX) +all: $(LIB_PREFIX)dataworks$(LIB_SUFFIX) $(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX) $(LIB_PREFIX)dataworks$(LIB_SUFFIX): $(OBJS) $(CC) -shared $(LDFLAGS) -o $@ $(OBJS) $(LIBS) +$(STATICLIB_PREFIX)dataworks$(STATICLIB_SUFFIX): $(OBJS) + $(AR) rcs $@ $(OBJS) + .c.o: $(CC) $(CFLAGS) -DPLATFORM_M=\"$(PLATFORM_M)\" -DPLATFORM_P=\"$(PLATFORM_P)\" -fPIC -c -o $@ $< diff --git a/Library/database.c b/Library/database.c index a20b94b..c27d2db 100644 --- a/Library/database.c +++ b/Library/database.c @@ -78,8 +78,17 @@ struct dataworks_db* dataworks_database_open(const char* fname) { uint16_t ver; __dw_native_endian(be_ver, uint16_t, ver = __converted); __dw_unlockfile(fp); - struct dataworks_db* db = malloc(sizeof(*db)); - db->fp = fp; - db->version = ver; - return db; + if(ver == 1){ + struct dataworks_db* db = malloc(sizeof(*db)); + db->fp = fp; + db->version = ver; + return db; + }else{ + fclose(fp); + return NULL; + } +} + +int dataworks_database_get_version(struct dataworks_db* db){ + return db->version; } diff --git a/Library/dw_database.h b/Library/dw_database.h index a96ed9c..62561f8 100644 --- a/Library/dw_database.h +++ b/Library/dw_database.h @@ -83,6 +83,15 @@ int dataworks_database_create(const char* fname); */ struct dataworks_db* dataworks_database_open(const char* fname); +/** + * @~english + * @brief Get the version of the database. + * @param db Database + * @return Version of the database + * + */ +int dataworks_database_get_version(struct dataworks_db* db); + #ifdef __cplusplus } #endif diff --git a/Makefile b/Makefile index fe96d6a..351be58 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include common-decl.mk .if "$(PLATFORM)" != "" -.include Platforms/$(PLATFORM).mk +include Platforms/$(PLATFORM).mk .endif include common.mk diff --git a/Platforms/win32.mk b/Platforms/win32.mk index 89e53e3..41051fa 100644 --- a/Platforms/win32.mk +++ b/Platforms/win32.mk @@ -1,6 +1,9 @@ CC = i686-w64-mingw32-gcc +AR = i686-w64-mingw32-gcc-ar LIB_PREFIX = LIB_SUFFIX = .dll EXEC_SUFFIX = .exe +STATICLIB_PREFIX = +STATICLIB_SUFFIX = .a PLATFORM_M = i686 PLATFORM_P = i686 diff --git a/Platforms/win64.mk b/Platforms/win64.mk index 299c725..5b8ecb1 100644 --- a/Platforms/win64.mk +++ b/Platforms/win64.mk @@ -1,6 +1,9 @@ CC = x86_64-w64-mingw32-gcc +AR = x86_64-w64-mingw32-gcc-ar LIB_PREFIX = LIB_SUFFIX = .dll EXEC_SUFFIX = .exe +STATICLIB_PREFIX = +STATICLIB_SUFFIX = .a PLATFORM_M = x86_64 PLATFORM_P = x86_64 diff --git a/common-decl.mk b/common-decl.mk index ea523c7..0207893 100644 --- a/common-decl.mk +++ b/common-decl.mk @@ -1,11 +1,14 @@ # $Id$ CC = cc +AR = gcc-ar CFLAGS = -std=c99 -D_DEFAULT_SOURCE LDFLAGS = -L`pwd`/Library LIBS = LIB_PREFIX = lib LIB_SUFFIX = .so +STATICLIB_PREFIX = lib +STATICLIB_SUFFIX = .a EXEC_SUFFIX = PLATFORM_M = `uname -m` PLATFORM_P = `uname -p` diff --git a/common.mk b/common.mk index ef4cde3..5a6aff1 100644 --- a/common.mk +++ b/common.mk @@ -44,6 +44,7 @@ archive-prepare: all mkdir -p dataworks-dist/Library mkdir -p dataworks-dist/Document cp Library/*$(LIB_SUFFIX) dataworks-dist/Library/ + cp Library/*$(STATICLIB_SUFFIX) dataworks-dist/Library/ cp Library/*.h dataworks-dist/Library/ cp Client/dataworks$(EXEC_SUFFIX) dataworks-dist/Client/ cp -rf Document/doc/html dataworks-dist/Document/html