summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2026-07-11 16:01:16 +0200
committerThomas Schmucker <ts@its1.de>2026-07-11 16:01:16 +0200
commit3c9cc7d383df019dacbd80480730723fe4b20b44 (patch)
tree9f04e09e48a77889f9bdb530c982c59e02c0818a
parent7046da7c9c6e9a486e5d98f8a180d3b0e898debe (diff)
downloaduse-berkeley-db-185-3c9cc7d383df019dacbd80480730723fe4b20b44.tar.gz
use-berkeley-db-185-3c9cc7d383df019dacbd80480730723fe4b20b44.tar.bz2
use-berkeley-db-185-3c9cc7d383df019dacbd80480730723fe4b20b44.zip
Infrastruktur hinzugefügt
-rw-r--r--.clang-format45
-rw-r--r--.clang-tidy19
-rw-r--r--.gitignore3
-rw-r--r--compile_flags.txt4
-rw-r--r--config.mk2
-rw-r--r--makefile24
-rw-r--r--src/db-test.c (renamed from db-test.c)16
7 files changed, 107 insertions, 6 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..21efcac
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,45 @@
1---
2AccessModifierOffset: -4
3AlignConsecutiveAssignments: 'true'
4AlignConsecutiveDeclarations: 'true'
5AlignEscapedNewlines: Left
6AlignTrailingComments: 'true'
7AlwaysBreakAfterReturnType: TopLevelDefinitions
8BreakBeforeBraces: Stroustrup
9BreakConstructorInitializers: BeforeComma
10BreakInheritanceList: BeforeComma
11ColumnLimit: '0'
12CompactNamespaces: 'false'
13Cpp11BracedListStyle: 'false'
14FixNamespaceComments: 'true'
15IncludeBlocks: Regroup
16IncludeCategories:
17 - Regex: '^.*(precomp|pch|stdafx)'
18 Priority: -1
19 - Regex: '^<.*>'
20 Priority: 1
21 - Regex: '^".*"'
22 Priority: 2
23 - Regex: '.*'
24 Priority: 3
25IndentCaseLabels: 'false'
26IndentPPDirectives: AfterHash
27IndentWidth: '4'
28IndentWrappedFunctionNames: 'false'
29KeepEmptyLinesAtTheStartOfBlocks: 'false'
30PointerAlignment: Right
31SortIncludes: 'true'
32SpaceAfterCStyleCast: 'true'
33SpaceAfterTemplateKeyword: 'false'
34SpaceBeforeAssignmentOperators: 'true'
35SpaceBeforeParens: ControlStatements
36SpaceBeforeRangeBasedForLoopColon: 'false'
37SpaceInEmptyParentheses: 'false'
38SpacesInAngles: 'false'
39SpacesInCStyleCastParentheses: 'false'
40SpacesInConditionalStatement: 'true'
41SpacesInParentheses: 'false'
42Standard: Auto
43TabWidth: '4'
44UseTab: ForIndentation
45...
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..0bceb5b
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,19 @@
1---
2Checks: "*,
3 -abseil-*,
4 -altera-*,
5 -android-*,
6 -fuchsia-*,
7 -google-*,
8 -llvm*,
9 -modernize-use-trailing-return-type,
10 -zircon-*,
11 -readability-else-after-return,
12 -readability-static-accessed-through-instance,
13 -readability-avoid-const-params-in-decls,
14 -cppcoreguidelines-non-private-member-variables-in-classes,
15 -misc-non-private-member-variables-in-classes,
16"
17WarningsAsErrors: ''
18HeaderFilterRegex: ''
19FormatStyle: none
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3a5e204
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
1bin/
2obj/
3database.db
diff --git a/compile_flags.txt b/compile_flags.txt
new file mode 100644
index 0000000..d87afcf
--- /dev/null
+++ b/compile_flags.txt
@@ -0,0 +1,4 @@
1-Wall
2-Werror
3-pedantic
4-std=c99
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..ed945d9
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,2 @@
1CFLAGS=-Wall -Werror -pedantic -std=c99
2LDFLAGS=
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..da7631a
--- /dev/null
+++ b/makefile
@@ -0,0 +1,24 @@
1include config.mk
2
3BIN=bin/db-test
4OBJS=obj/db-test.o
5
6release: $(BIN)
7release: CFLAGS+=-DNDEBUG -O2
8
9debug: $(BIN)
10debug: CFLAGS+=-g
11
12$(BIN): $(OBJS) | bin
13 cc $(LDFLAGS) $^ -o $@
14
15obj/%.o: src/%.c | obj
16 cc $(CFLAGS) -c $< -o $@
17
18bin obj:
19 mkdir -p $@
20
21clean:
22 rm -rf bin obj
23
24.PHONY: release debug clean
diff --git a/db-test.c b/src/db-test.c
index 2789ce0..439ed79 100644
--- a/db-test.c
+++ b/src/db-test.c
@@ -1,22 +1,24 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdio.h>
3#include <stdlib.h> 2#include <stdlib.h>
4#include <limits.h> 3#include <limits.h>
5 4
6#include <db.h> 5#include <db.h>
7#include <fcntl.h> 6#include <fcntl.h>
8 7
8#define USERNAME_LENGTH 20
9#define FULLNAME_LENGTH 50
10
9typedef struct { 11typedef struct {
10 char username[20]; 12 char username[USERNAME_LENGTH];
11 char fullname[50]; 13 char fullname[FULLNAME_LENGTH];
12 int age; 14 int age;
13} user_type; 15} user_type;
14 16
15int main(void) 17int main(void)
16{ 18{
17 DB *db = dbopen("database.db", O_RDWR | O_CREAT, 0644, DB_BTREE, NULL); 19 DB *db = dbopen("./database.db", O_RDWR | O_CREAT, 0644, DB_BTREE, NULL); // NOLINT
18 if ( db != NULL ) { 20 if ( db != NULL ) {
19 fprintf(stderr, "Datenbank eröffnet...\n"); 21 (void) fprintf(stderr, "Datenbank eröffnet...\n");
20 22
21#if INSERT 23#if INSERT
22 user_type users[] = { 24 user_type users[] = {
@@ -50,7 +52,9 @@ int main(void)
50#endif 52#endif
51 53
52 { 54 {
53 DBT key, data; 55 DBT key;
56 DBT data;
57
54 int err = db->seq(db, &key, &data, R_FIRST); 58 int err = db->seq(db, &key, &data, R_FIRST);
55 while ( !err ) { 59 while ( !err ) {
56 user_type *user = data.data; 60 user_type *user = data.data;