From 82e3758dc7327ad3d5dc1a6d06b48298000b6751 Mon Sep 17 00:00:00 2001 From: nishi Date: Thu, 13 Jun 2024 02:26:33 +0000 Subject: [PATCH] adding stuff git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@288 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- Client/client.c | 2 ++ Grammar/dw.l | 2 ++ Grammar/dw.y | 2 ++ Library/database.c | 2 ++ Library/database_db.c | 2 ++ Library/database_record.c | 2 ++ Library/database_table.c | 2 ++ Library/dataworks.c | 2 ++ Library/dataworks.h | 2 ++ Library/dw_database.h | 2 ++ Library/dw_parser.h | 2 ++ Library/dw_util.h | 2 ++ Library/exec.c | 2 ++ Library/parser.c | 2 ++ Library/util.c | 2 ++ RemoteClient/hayes.c | 7 +++++ RemoteClient/rcli.c | 59 +++++++++++++++++++++++++++++++++++++-- RemoteClient/tcpip.c | 36 ++++++++++++++++++++++++ Server/hayes.c | 2 ++ Server/server.c | 2 ++ Server/tcpip.c | 2 ++ 21 files changed, 135 insertions(+), 3 deletions(-) diff --git a/Client/client.c b/Client/client.c index fd4455c..b0bb669 100644 --- a/Client/client.c +++ b/Client/client.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Grammar/dw.l b/Grammar/dw.l index 98055cc..c34c73b 100644 --- a/Grammar/dw.l +++ b/Grammar/dw.l @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Grammar/dw.y b/Grammar/dw.y index 6a6e528..508c7d9 100644 --- a/Grammar/dw.y +++ b/Grammar/dw.y @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/database.c b/Library/database.c index b0770a4..3f6a24c 100644 --- a/Library/database.c +++ b/Library/database.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/database_db.c b/Library/database_db.c index 6ade2f5..bf588a6 100644 --- a/Library/database_db.c +++ b/Library/database_db.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/database_record.c b/Library/database_record.c index 6efe830..be89ba0 100644 --- a/Library/database_record.c +++ b/Library/database_record.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/database_table.c b/Library/database_table.c index 6aa70be..8288d42 100644 --- a/Library/database_table.c +++ b/Library/database_table.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/dataworks.c b/Library/dataworks.c index b6677cf..904d6bc 100644 --- a/Library/dataworks.c +++ b/Library/dataworks.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/dataworks.h b/Library/dataworks.h index 673e595..b684303 100644 --- a/Library/dataworks.h +++ b/Library/dataworks.h @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/dw_database.h b/Library/dw_database.h index 906436b..66b1ced 100644 --- a/Library/dw_database.h +++ b/Library/dw_database.h @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/dw_parser.h b/Library/dw_parser.h index aa1c21b..cbf0f5c 100644 --- a/Library/dw_parser.h +++ b/Library/dw_parser.h @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/dw_util.h b/Library/dw_util.h index 736c19d..6ae6c5d 100644 --- a/Library/dw_util.h +++ b/Library/dw_util.h @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/exec.c b/Library/exec.c index fa629e5..0d3d58a 100644 --- a/Library/exec.c +++ b/Library/exec.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/parser.c b/Library/parser.c index 70bdbfa..d8b018e 100644 --- a/Library/parser.c +++ b/Library/parser.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Library/util.c b/Library/util.c index 1ef6b46..14d3fba 100644 --- a/Library/util.c +++ b/Library/util.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/RemoteClient/hayes.c b/RemoteClient/hayes.c index a2b35fc..1630827 100644 --- a/RemoteClient/hayes.c +++ b/RemoteClient/hayes.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ @@ -25,3 +27,8 @@ /* OF SUCH DAMAGE. */ /* -------------------------------------------------------------------------- */ /* --- END LICENSE --- */ + +extern int argc; +extern char** argv; + +int rcli_init(void) {} diff --git a/RemoteClient/rcli.c b/RemoteClient/rcli.c index ab24a2f..7efbe4d 100644 --- a/RemoteClient/rcli.c +++ b/RemoteClient/rcli.c @@ -1,5 +1,58 @@ /* $Id$ */ -/* --- START LICNESE --- */ -/* --- END LICNESE --- */ +/* --- START LICENSE --- */ +/* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ +/* Copyright (c) 2024 Crabware. */ +/* 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 --- */ -int main() {} +#include +#include +#include + +#include +#include + +int argc; +char** argv; + +int rcli_init(void); + +bool option(const char* str, const char* shortopt, const char* longopt) { + char* dos_shortopt = __dw_strcat("/", shortopt); + char* dos_longopt = __dw_strcat("/", longopt); + char* nix_shortopt = __dw_strcat("-", shortopt); + char* nix_longopt = __dw_strcat("--", longopt); + if(__dw_strcaseequ(str, dos_longopt) || __dw_strcaseequ(str, nix_longopt) || strcmp(str, dos_shortopt) == 0 || strcmp(str, nix_shortopt) == 0) return true; + return false; +} + +int main(int _argc, char** _argv) { + printf("DataWorks Remote Client version %s %s %s\n", dataworks_get_version(), dataworks_get_compile_date(), dataworks_get_platform()); + argc = _argc; + argv = _argv; + int st = rcli_init(); + if(st != 0) return st; +} diff --git a/RemoteClient/tcpip.c b/RemoteClient/tcpip.c index a2b35fc..fe0b376 100644 --- a/RemoteClient/tcpip.c +++ b/RemoteClient/tcpip.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ @@ -25,3 +27,37 @@ /* OF SUCH DAMAGE. */ /* -------------------------------------------------------------------------- */ /* --- END LICENSE --- */ + +#include +#include + +extern int argc; +extern char** argv; + +int port; + +bool option(const char* str, const char* shortopt, const char* longopt); + +int rcli_init(void) { + printf("Using BSD TCP/IP\n"); + int i; + for(i = 1; i < argc; i++) { + if(argv[i][0] == '/' || argv[i][0] == '-') { + if(option(argv[i], "p", "port")) { + i++; + port = atoi(argv[i]); + } else if(option(argv[i], "h", "help")) { + printf("\n"); + printf("Usage: %s [options] database\n", argv[0]); + printf("You can use double-dash or slash for long-format flag, and single-dash or slash for short-foramt flag.\n"); + printf("Options:\n"); + printf("\t-p --port [port] Specify the port to be listened on\n"); + exit(0); + } else { + fprintf(stderr, "Invalid option: %s\n", argv[i]); + return 1; + } + } + } + return 0; +} diff --git a/Server/hayes.c b/Server/hayes.c index f47612a..cef2789 100644 --- a/Server/hayes.c +++ b/Server/hayes.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Server/server.c b/Server/server.c index f471cae..efbbf25 100644 --- a/Server/server.c +++ b/Server/server.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ diff --git a/Server/tcpip.c b/Server/tcpip.c index db4bcb9..ff25f9e 100644 --- a/Server/tcpip.c +++ b/Server/tcpip.c @@ -1,6 +1,8 @@ /* $Id$ */ /* --- START LICENSE --- */ /* -------------------------------------------------------------------------- */ +/* DataWorks - Simple DBMS */ +/* -------------------------------------------------------------------------- */ /* Copyright (c) 2024 Crabware. */ /* Redistribution and use in source and binary forms, with or without modific */ /* ation, are permitted provided that the following conditions are met: */ -- 2.43.0