Skip to content

Commit 8ebbc1e

Browse files
committed
Work in progress. Import githooks to this project.
1 parent 3e6503f commit 8ebbc1e

File tree

5 files changed

+139
-3
lines changed

5 files changed

+139
-3
lines changed

.editorconfig

+26-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,31 @@ charset = utf-8
55
end_of_line = lf
66
insert_final_newline = true
77
indent_size = 4
8+
tab_width = 4
89
indent_style = space
910

10-
[{Makefile, *,mk}]
11-
insend_style = tab
11+
[*.{c, cpp, h, hpp, cxx, hxx, rs, go, java}]
12+
charset = utf-8
13+
end_of_line = lf
14+
insert_final_newline = true
15+
indent_size = 4
16+
tab_width = 4
17+
indent_style = space
18+
19+
[*.{yaml, json}]
20+
charset = utf-8
21+
end_of_line = lf
22+
insert_final_newline = false
23+
indent_size = 2
24+
tab_width = 2
25+
indent_style = space
26+
27+
[Makefile]
28+
indent_style = tab
29+
indent_size = 8
30+
tab_width = 8
31+
32+
[*.mk]
33+
indent_style = tab
34+
indent_size = 8
35+
tab_width = 8

.githooks/pre-commit

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
echo
4+
count=0
5+
replacedirective=0
6+
7+
echo "Checking for merge conflicts"
8+
for f in `git diff HEAD --name-only --diff-filter=M`; do
9+
if [[ -f $f ]] && [[ $f != .githooks/* ]]; then
10+
if [[ $(grep -c "<<<<<<" $f) -gt 0 ]] || [[ $(grep -c ">>>>>>" $f) -gt 0 ]]; then
11+
echo "$(tput setaf 1)! $f$(tput sgr0)"
12+
((count += 1))
13+
fi
14+
fi
15+
done
16+
17+
if [ $count != 0 ]; then
18+
echo "$(tput setaf 1)$count$(tput sgr0) files conflict, please resolve conflicts."
19+
exit 1;
20+
else
21+
echo "$(tput setaf 2)No conflicts, continuing with commit.$(tput sgr0)"
22+
fi
23+

scripts/devinit.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
GIT_VERSION=$(git --version | cut -d" " -f3)
4+
GIT_REQUIRED_VERSION=2.9.0
5+
6+
if [ "$(printf '%s\n' "$GIT_REQUIRED_VERSION" "$GIT_VERSION" | sort -V | head -n1)" = "$GIT_REQUIRED_VERSION" ]; then
7+
echo "GIT >= 2.9, installing .githooks directory"
8+
git config core.hooksPath .githooks
9+
else
10+
echo "Copying githooks to .git"
11+
#find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
12+
fi

src/e4cli.c

+78-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,83 @@
1818
#define E4_STORE_FILE
1919
#include "e4/e4.h"
2020

21+
const char cli_commands[] = "
22+
The following commands can be used:
23+
24+
!setid
25+
!setkey
26+
!genkey
27+
!settopickey
28+
!s, !subscribe
29+
!u, !unsubscribe
30+
!c, !changetopic
31+
!e, !e4msg
32+
!m, !clearmsg
33+
!l, !list state
34+
!z, !zero state
35+
!q, !quit
36+
";
37+
38+
void repl() {
39+
40+
char line[256] = {0};
41+
int i = 0;
42+
43+
while (fgets(line, sizeof(line), stdin) != NULL) {
44+
45+
char* command = NULL;
46+
char* arg = NULL;
47+
48+
int linelen = strlen(line);
49+
50+
51+
// user pressed enter/entered nothing except a newline.
52+
if (linelen == 1 ) {
53+
continue;
54+
}
55+
56+
// remove trailing new line from fgets()
57+
if (linelen >= 1 && line[l-1] == '\n') {
58+
line[--linelen] = 0;
59+
}
60+
61+
if (line[0] != '!')
62+
{
63+
// TODO: what do we do here?
64+
continue;
65+
}
66+
67+
for (i=1; i < linelen; i++ ){
68+
if (i == linelen-1) {
69+
command = &line[1];
70+
break;
71+
}
72+
if (line[i]==' ') {
73+
line[i] = 0;
74+
command = &line[1];
75+
// don't assign if i = linelen-1; potential buffer overflow.
76+
if ( i+1 < linelen ) {
77+
arg = &line[i+];
78+
}
79+
break
80+
}
81+
82+
}
83+
84+
if ( command == NULL ) {
85+
// error, let's do something about it?
86+
continue
87+
}
88+
89+
if (strcmp(commmand, "")
90+
91+
}
92+
}
93+
94+
void init() {
95+
96+
}
97+
2198
int main(int argc, char** argv) {
2299

23-
}
100+
}

src/mqtt.c

Whitespace-only changes.

0 commit comments

Comments
 (0)