]> Nishi Git Mirror - dataworks.git/commitdiff
add files
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 16 May 2024 11:26:58 +0000 (11:26 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Thu, 16 May 2024 11:26:58 +0000 (11:26 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@2 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

.clang-format [new file with mode: 0644]
Library/Makefile [new file with mode: 0644]
Library/parser.c [new file with mode: 0644]
Makefile [new file with mode: 0644]
Platforms/win32.mk [new file with mode: 0644]
Platforms/win64.mk [new file with mode: 0644]
replace.pl [new file with mode: 0755]

diff --git a/.clang-format b/.clang-format
new file mode 100644 (file)
index 0000000..53f287c
--- /dev/null
@@ -0,0 +1,12 @@
+---
+# $Id$
+Language: Cpp
+UseTab: Always
+TabWidth: 8
+IndentWidth: 8
+PointerAlignment: Left
+ColumnLimit: 1024
+AllowShortIfStatementsOnASingleLine: Always
+AllowShortBlocksOnASingleLine: Never
+AllowShortLoopsOnASingleLine: true
+SpaceBeforeParens: Never
diff --git a/Library/Makefile b/Library/Makefile
new file mode 100644 (file)
index 0000000..98c6b99
--- /dev/null
@@ -0,0 +1,17 @@
+# $Id$
+
+.PHONY: all clean
+.SUFFIXES: .c .o
+
+OBJS = parser.o
+
+all: $(LIB_PREFIX)dataworks$(LIB_SUFFIX)
+
+$(LIB_PREFIX)dataworks$(LIB_SUFFIX): $(OBJS)
+       $(CC) -shared $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+
+.c.o:
+       $(CC) $(CFLAGS) -fPIC -c -o $@ $<
+
+clean:
+       rm -f *.o $(LIB_PREFIX)dataworks$(LIB_SUFFIX)
diff --git a/Library/parser.c b/Library/parser.c
new file mode 100644 (file)
index 0000000..9865328
--- /dev/null
@@ -0,0 +1,27 @@
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Nishi.                                                  */
+/* Redistribution and use in source and binary forms, with or without modific */
+/* ation, are permitted provided that the following conditions are met:       */
+/*     1. Redistributions of source code must retain the above copyright noti */
+/* ce, this list of conditions and the following disclaimer.                  */
+/*     2. Redistributions in binary form must reproduce the above copyright n */
+/* otice, this list of conditions and the following disclaimer in the documen */
+/* tation and/or other materials provided with the distribution.              */
+/*     3. Neither the name of the copyright holder nor the names of its contr */
+/* ibutors may be used to endorse or promote products derived from this softw */
+/* are without specific prior written permission.                             */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */
+/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */
+/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */
+/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS  */
+/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */
+/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */
+/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */
+/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */
+/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */
+/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY  */
+/* OF SUCH DAMAGE.                                                            */
+/* -------------------------------------------------------------------------- */
+/* --- END LICENSE --- */
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..27ee9e1
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,36 @@
+# $Id$
+CC = cc
+CFLAGS = -std=c99
+LDFLAGS =
+LIBS =
+LIB_PREFIX = lib
+LIB_SUFFIX = .so
+
+.if "$(PLATFORM)" != ""
+.include "Platforms/$(PLATFORM).mk"
+.endif
+
+COMPILE_FLAGS = CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" LIB_PREFIX="$(LIB_PREFIX)" LIB_SUFFIX="$(LIB_SUFFIX)"
+
+.PHONY: all replace format clean ./Library
+
+all: ./Library
+
+./Library::
+       $(MAKE) -C $@ $(COMPILE_FLAGS)
+
+FILES = `find . -name "*.c" -or -name "*.h"`
+
+replace:
+       for i in $(FILES); do \
+                echo -n "$$i ... "; \
+                perl replace.pl < $$i > $$i.new; \
+                mv $$i.new $$i; \
+                echo "done"; \
+        done
+
+format:
+       clang-format -i $(FILES)
+
+clean:
+       $(MAKE) -C ./Library clean $(COMPILE_FLAGS)
diff --git a/Platforms/win32.mk b/Platforms/win32.mk
new file mode 100644 (file)
index 0000000..7731baf
--- /dev/null
@@ -0,0 +1,3 @@
+CC = i686-w64-mingw32-gcc
+LIB_PREFIX =
+LIB_SUFFIX = .dll
diff --git a/Platforms/win64.mk b/Platforms/win64.mk
new file mode 100644 (file)
index 0000000..aa1d938
--- /dev/null
@@ -0,0 +1,3 @@
+CC = x86_64-w64-mingw32-gcc
+LIB_PREFIX =
+LIB_SUFFIX = .dll
diff --git a/replace.pl b/replace.pl
new file mode 100755 (executable)
index 0000000..98f6aab
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+# $Id$
+# To put LICENSE into the source code
+
+use IO::Handle;
+
+my $str = "";
+while(<STDIN>){
+       $str = $str . $_;
+}
+
+my $rep = 74;
+
+my $repl = "/* " . ("-" x $rep) . " */\n";
+
+my $io = IO::Handle->new();
+
+if(open $io, '<', "HEADER"){
+       my $len = 0;
+       while(<$io>){
+               my @list = $_ =~ /.{1,$rep}/g;
+               for my $s (@list){
+                       if(length($s) > $len){
+                               $len = length($s);
+                       }
+               }
+       }
+       $io->close;
+       open $io, '<', "HEADER";
+       while(<$io>){
+               my @list = $_ =~ /.{1,$rep}/g;
+               for my $s (@list){
+                       $repl = $repl . "/* " . (" " x ($rep - $len - 1)) . "$s" . (" " x ($len - length($s) + 1)) . " */\n";
+               }
+       }
+       $repl = $repl . "/* " . ("-" x $rep) . " */\n";
+}
+
+$io = IO::Handle->new();
+
+open $io, '<', "LICENSE" or die "$!";
+
+while(<$io>){
+       my @list = $_ =~ /.{1,$rep}/g;
+       for my $s (@list){
+               $repl = $repl . "/* $s" . (" " x ($rep - length($s))) . " */\n";
+       }
+}
+
+$io->close;
+
+$repl = $repl . "/* " . ("-" x $rep) . " */\n";
+
+$str =~ s/\/\* --- START LICENSE --- \*\/\n(.+\n)?\/\* --- END LICENSE --- \*\//\/\* --- START LICENSE --- \*\/\n$repl\/\* --- END LICENSE --- \*\//gs;
+print $str;