• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得windowscocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Virtual machine Management Terminal User Interface


Commit MetaInfo

Révision78c1896fbc5d5bdd0085782907d83b59364df9dc (tree)
l'heure2022-07-31 10:46:46
AuteurKoine Yuusuke(koinec) <koinec@user...>
CommiterKoine Yuusuke(koinec)

Message de Log

Create: KeyVal module source code. (for Guest/HVisor information parameters)

Change Summary

Modification

--- a/src/Makefile
+++ b/src/Makefile
@@ -32,6 +32,7 @@ TARGET = vmtui
3232 OBJS_MAIN = vmtui_main.o
3333 OBJS_PARTS = common.o \
3434 errinfo.o \
35+ keyval.o \
3536 hvisor.o \
3637 guest.o \
3738 request.o \
@@ -59,6 +60,7 @@ OBJS_PARTS = common.o \
5960 HEADER = vmtui.h \
6061 common.h \
6162 errinfo.h \
63+ keyval.h \
6264 hvisor.h \
6365 guest.h \
6466 request.h \
@@ -99,7 +101,8 @@ TEST_OBJS = test_vmtui.o \
99101 test_hvctl.o \
100102 test_errinfo.o \
101103 test_guestctl.o \
102- test_configfile.o
104+ test_configfile.o \
105+ test_keyval.o
103106 TEST_RESULT = test_result.log
104107
105108 CALLGRAPH = CallGraph.txt
@@ -121,6 +124,9 @@ common.o: common.c $(HEADER)
121124 errinfo.o: errinfo.c $(HEADER)
122125 $(CC) -c -o errinfo.o $(FLAGS_COMPILE) $(FLAGS_DEBUG) \
123126 errinfo.c
127+keyval.o: keyval.c $(HEADER)
128+ $(CC) -c -o keyval.o $(FLAGS_COMPILE) $(FLAGS_DEBUG) \
129+ keyval.c
124130 hvisor.o: hvisor.c $(HEADER)
125131 $(CC) -c -o hvisor.o $(FLAGS_COMPILE) $(FLAGS_DEBUG) \
126132 hvisor.c
@@ -222,6 +228,9 @@ test_errinfo.o: test_errinfo.c
222228 test_configfile.o: test_configfile.c
223229 $(CC) -c -o test_configfile.o $(TEST_FLAGS_COMPILE) $(FLAGS_DEBUG) \
224230 test_configfile.c
231+test_keyval.o: test_keyval.c
232+ $(CC) -c -o test_keyval.o $(TEST_FLAGS_COMPILE) $(FLAGS_DEBUG) \
233+ test_keyval.c
225234
226235
227236 $(CALLGRAPH):
--- /dev/null
+++ b/src/keyval.c
@@ -0,0 +1,94 @@
1+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+ VMTUI (Virtual machine Management Terminal User Interface)
3+
4+ Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are met:
8+
9+ 1. Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ 2. Redistributions in binary form must reproduce the above copyright
12+ notice, this list of conditions and the following disclaimer in the
13+ documentation and/or other materials provided with the distribution.
14+
15+ THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+ IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
27+
28+
29+#define VMTUI_SRC_KEYVAL
30+#include "vmtui.h"
31+
32+/*
33+clear
34+delete
35+modify
36+append
37+*/
38+
39+/* ===========================================================================*/
40+/* ===========================================================================*/
41+/* ===========================================================================*/
42+/* ===========================================================================*/
43+
44+/* ===========================================================================*/
45+VMTUI_KEYVAL_EXTERN
46+int
47+ KeyVal_Init(
48+ KeyVal_Info *p_keyval,
49+ int i_allocs ) {
50+
51+ KeyVal_Item *p_item;
52+
53+ if( 0 == i_allocs ) { i_allocs = KEYVAL_DEFAULT_ALLOCS; }
54+
55+ p_item = (KeyVal_Item *)malloc( sizeof( KeyVal_Item ) * i_allocs );
56+ if( NULL == p_item ) {
57+ return -0x01;
58+ }
59+
60+ memset( p_item, 0x00, (sizeof( KeyVal_Item ) * i_allocs ));
61+
62+ p_keyval->p_items = p_item;
63+ p_keyval->i_allocs = i_allocs;
64+ p_keyval->i_used = 0;
65+
66+ return 0x00;
67+}
68+
69+/* ===========================================================================*/
70+VMTUI_KEYVAL_EXTERN
71+int
72+ KeyVal_Term(
73+ KeyVal_Info *p_keyval ) {
74+
75+ if( NULL == p_keyval ) {
76+ return -0x01;
77+ }
78+
79+ if( NULL == p_keyval->p_items ) {
80+ return -0x02;
81+ }
82+
83+ free( p_keyval->p_items );
84+ p_keyval->p_items = NULL;
85+
86+ p_keyval->i_allocs = 0;
87+ p_keyval->i_used = 0;
88+
89+ return 0x00;
90+}
91+
92+
93+/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
94+
--- /dev/null
+++ b/src/keyval.h
@@ -0,0 +1,83 @@
1+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+ VMTUI (Virtual machine Management Terminal User Interface)
3+
4+ Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are met:
8+
9+ 1. Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ 2. Redistributions in binary form must reproduce the above copyright
12+ notice, this list of conditions and the following disclaimer in the
13+ documentation and/or other materials provided with the distribution.
14+
15+ THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+ IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
27+
28+#ifndef VMTUI_HEADER_KEYVAL
29+#define VMTUI_HEADER_KEYVAL
30+
31+#include "vmtui.h"
32+
33+#define KEYVAL_DEFAULT_ALLOCS 128
34+#define KEYVAL_MAXLEN_KEY 64
35+#define KEYVAL_MAXLEN_STRVAL 256
36+
37+typedef struct {
38+ Byte b_type;
39+
40+ union {
41+ int i_val;
42+ DWord dw_val;
43+ char str_val[KEYVAL_MAXLEN_STRVAL];
44+ char *pstr_val;
45+ };
46+} KeyVal_Data;
47+
48+
49+typedef struct {
50+ Byte b_depth;
51+
52+ #define KEYVAL_TYPE_NONE 0x00
53+ #define KEYVAL_TYPE_INT 0x01
54+ #define KEYVAL_TYPE_DWORD 0x02
55+ #define KEYVAL_TYPE_STRING 0x03
56+ #define KEYVAL_TYPE_STRPTR 0x04
57+
58+ DWord dw_keyhash;
59+ int i_child;
60+ int i_next;
61+
62+ char str_key[KEYVAL_MAXLEN_KEY];
63+
64+} KeyVal_Item;
65+
66+typedef struct {
67+ int i_allocs;
68+ int i_used;
69+ KeyVal_Item *p_items;
70+} KeyVal_Info;
71+
72+#ifdef VMTUI_SRC_KEYVAL
73+ #define VMTUI_KEYVAL_EXTERN
74+#else
75+ #define VMTUI_KEYVAL_EXTERN extern
76+#endif
77+VMTUI_KEYVAL_EXTERN int KeyVal_Init( KeyVal_Info *p_keyval, int i_allocs );
78+VMTUI_KEYVAL_EXTERN int KeyVal_Term( KeyVal_Info *p_keyval );
79+
80+#endif
81+
82+/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
83+
--- /dev/null
+++ b/src/test_keyval.c
@@ -0,0 +1,105 @@
1+/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2+ VMTUI (Virtual machine Management Terminal User Interface)
3+
4+ Copyright(C) 2022- Koine Yuusuke(koinec). All Rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without
7+ modification, are permitted provided that the following conditions are met:
8+
9+ 1. Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ 2. Redistributions in binary form must reproduce the above copyright
12+ notice, this list of conditions and the following disclaimer in the
13+ documentation and/or other materials provided with the distribution.
14+
15+ THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY EXPRESS
16+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18+ IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE LIABLE FOR ANY
19+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
27+
28+
29+#define VMTUI_SRC_TEST_KEYVAL
30+#include "vmtui.h"
31+#include "test_vmtui.h"
32+
33+
34+/* ===========================================================================*/
35+/*
36+void
37+ Test_KeyVal_Function_OK001( void ) {
38+
39+ int i_err;
40+
41+ CU_ASSERT( 0x00 == i_err );
42+
43+ return;
44+}
45+*/
46+
47+/* ===========================================================================*/
48+void
49+ Test_KeyVal_InitTerm_001( void ) {
50+
51+ int i_err;
52+ KeyVal_Info t_keyval;
53+
54+ // Phase 1 ----
55+ i_err = KeyVal_Init( &t_keyval, 0 );
56+ CU_ASSERT( 0x00 == i_err );
57+
58+ CU_ASSERT( KEYVAL_DEFAULT_ALLOCS == t_keyval.i_allocs );
59+ CU_ASSERT( 0 == t_keyval.i_used );
60+ CU_ASSERT( NULL != t_keyval.p_items );
61+
62+ i_err = KeyVal_Term( &t_keyval );
63+ CU_ASSERT( 0x00 == i_err );
64+
65+ CU_ASSERT( 0 == t_keyval.i_allocs );
66+ CU_ASSERT( 0 == t_keyval.i_used );
67+ CU_ASSERT( NULL == t_keyval.p_items );
68+
69+ // Phase 2 ----
70+ i_err = KeyVal_Init( &t_keyval, 1024 );
71+ CU_ASSERT( 0x00 == i_err );
72+
73+ CU_ASSERT( 1024 == t_keyval.i_allocs );
74+ CU_ASSERT( 0 == t_keyval.i_used );
75+ CU_ASSERT( NULL != t_keyval.p_items );
76+
77+ i_err = KeyVal_Term( &t_keyval );
78+ CU_ASSERT( 0x00 == i_err );
79+
80+ CU_ASSERT( 0 == t_keyval.i_allocs );
81+ CU_ASSERT( 0 == t_keyval.i_used );
82+ CU_ASSERT( NULL == t_keyval.p_items );
83+
84+ return;
85+}
86+
87+
88+/* ===========================================================================*/
89+VMTUI_TEST_KEYVAL_EXTERN
90+int
91+ Test_KeyVal(
92+ void ) {
93+
94+ CU_pSuite pt_keyval;
95+
96+ pt_keyval = CU_add_suite( "VMTUI_KeyVal", NULL, NULL );
97+
98+ CU_add_test( pt_keyval, "VMTUI_KeyVal_InitTerm_001", Test_KeyVal_InitTerm_001 );
99+
100+ return 0x00;
101+}
102+
103+
104+/* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
105+
--- a/src/test_vmtui.c
+++ b/src/test_vmtui.c
@@ -46,6 +46,7 @@ int
4646 Test_GuestCtl();
4747 Test_ErrInfo();
4848 Test_ConfigFile();
49+ Test_KeyVal();
4950
5051 CU_basic_run_tests();
5152 CU_cleanup_registry();
--- a/src/test_vmtui.h
+++ b/src/test_vmtui.h
@@ -80,6 +80,13 @@ VMTUI_TEST_ERRINFO_EXTERN int Test_ErrInfo( void );
8080 #endif
8181 VMTUI_TEST_CONFIGFILE_EXTERN int Test_ConfigFile( void );
8282
83+#ifdef VMTUI_SRC_TEST_KEYVAL
84+ #define VMTUI_TEST_KEYVAL_EXTERN
85+#else
86+ #define VMTUI_TEST_KEYVAL_EXTERN extern
87+#endif
88+VMTUI_TEST_KEYVAL_EXTERN int Test_KeyVal( void );
89+
8390 #endif
8491
8592 /* EOF of @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
--- a/src/vmtui.h
+++ b/src/vmtui.h
@@ -75,6 +75,7 @@ typedef unsigned long QWord;
7575
7676 #include "common.h"
7777 #include "errinfo.h"
78+#include "keyval.h"
7879 #include "guest.h"
7980 #include "request.h"
8081 #include "hvisor.h"