Skip to content

Commit 418caf1

Browse files
committed
beginning work on server
1 parent 1bc35a6 commit 418caf1

File tree

10 files changed

+103
-51
lines changed

10 files changed

+103
-51
lines changed

.cproject

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<option id="gnu.c.compiler.option.misc.other.835723838" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0" valueType="string"/>
3131
<option id="gnu.c.compiler.option.misc.verbose.1371801120" name="Verbose (-v)" superClass="gnu.c.compiler.option.misc.verbose" value="true" valueType="boolean"/>
3232
<option id="gnu.c.compiler.option.misc.ansi.183199256" name="Support ANSI programs (-ansi)" superClass="gnu.c.compiler.option.misc.ansi" value="false" valueType="boolean"/>
33-
<option id="gnu.c.compiler.option.include.paths.224587811" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"/>
33+
<option id="gnu.c.compiler.option.include.paths.224587811" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/>
3434
<option id="gnu.c.compiler.option.include.files.1297155078" name="Include files (-include)" superClass="gnu.c.compiler.option.include.files"/>
3535
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.671860280" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
3636
</tool>
@@ -50,8 +50,9 @@
5050
</toolChain>
5151
</folderInfo>
5252
<sourceEntries>
53-
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
54-
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
53+
<entry excluding="websocket|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
54+
<entry excluding="websocket" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
55+
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/websocket"/>
5556
</sourceEntries>
5657
</configuration>
5758
</storageModule>
@@ -98,8 +99,9 @@
9899
</toolChain>
99100
</folderInfo>
100101
<sourceEntries>
101-
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
102-
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
102+
<entry excluding="websocket|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
103+
<entry excluding="websocket" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
104+
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/websocket"/>
103105
</sourceEntries>
104106
</configuration>
105107
</storageModule>

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
AUTOMAKE_OPTIONS = foreign
22

33
bin_PROGRAMS = websocket-client
4-
websocket_client_SOURCES = src/utf8.h src/utf8.c src/cwebsocket.h src/cwebsocket.c src/main.c
4+
websocket_client_SOURCES = src/websocket/utf8.h src/websocket/utf8.c src/websocket/cwebsocket_client.h src/websocket/cwebsocket_client.c src/client.c
55

66
#LDFLAGS = -L/usr/local/lib -lcrypto
77

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
AC_PREREQ([2.69])
55
AC_INIT([cwebsocket], [0.01], [root@localhost])
66
AM_INIT_AUTOMAKE([1.9 foreign])
7-
AC_CONFIG_SRCDIR([src/main.c])
7+
AC_CONFIG_SRCDIR([src/client.c])
88
AC_CONFIG_HEADERS([config.h])
99

1010
if test -z $CFLAGS; then

src/main.c renamed to src/client.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include <stdio.h>
2626
#include <signal.h>
27-
#include "cwebsocket.h"
27+
#include "websocket/cwebsocket_client.h"
2828

2929
cwebsocket_client websocket_client;
3030

@@ -79,24 +79,9 @@ void signal_handler(int sig) {
7979

8080
void print_program_header() {
8181

82-
fprintf(stderr, "****************************************************************************\n");
83-
fprintf(stderr, "* cwebsocket: A fast, lightweight websocket client/server *\n");
84-
fprintf(stderr, "* *\n");
85-
fprintf(stderr, "* Copyright (c) 2014 Jeremy Hahn *\n");
86-
fprintf(stderr, "* *\n");
87-
fprintf(stderr, "* cwebsocket is free software: you can redistribute it and/or modify *\n");
88-
fprintf(stderr, "* it under the terms of the GNU Lesser General Public License as published *\n");
89-
fprintf(stderr, "* by the Free Software Foundation, either version 3 of the License, or *\n");
90-
fprintf(stderr, "* (at your option) any later version. *\n");
91-
fprintf(stderr, "* *\n");
92-
fprintf(stderr, "* cwebsocket is distributed in the hope that it will be useful, *\n");
93-
fprintf(stderr, "* but WITHOUT ANY WARRANTY; without even the implied warranty of *\n");
94-
fprintf(stderr, "* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\n");
95-
fprintf(stderr, "* GNU Lesser General Public License for more details. *\n");
96-
fprintf(stderr, "* *\n");
97-
fprintf(stderr, "* You should have received a copy of the GNU Lesser General Public License *\n");
98-
fprintf(stderr, "* along with cwebsocket. If not, see <http://www.gnu.org/licenses/>. *\n");
99-
fprintf(stderr, "****************************************************************************\n");
82+
fprintf(stderr, "\n");
83+
fprintf(stderr, " cwebsocket: A fast, lightweight websocket client/server\n");
84+
fprintf(stderr, " Copyright (c) 2014 Jeremy Hahn\n");
10085
fprintf(stderr, "\n");
10186
}
10287

src/server.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2014 Jeremy Hahn
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/

src/utf8.c

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/cwebsocket.c renamed to src/websocket/cwebsocket_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#include "cwebsocket.h"
25+
#include "cwebsocket_client.h"
2626

2727
void cwebsocket_init() {
2828
const rlim_t kStackSize = STACK_SIZE_MIN * 1024 * 1024;
File renamed without changes.

src/websocket/utf8.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* cwebsocket: A fast, lightweight websocket client/server
3+
*
4+
* Copyright (c) 2014 Jeremy Hahn
5+
*
6+
* This file is part of cwebsocket.
7+
*
8+
* cwebsocket is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published
10+
* by the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* cwebsocket is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with cwebsocket. If not, see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
#include "utf8.h"
23+
24+
int utf8_count_code_points(uint8_t* s, size_t* count) {
25+
26+
uint32_t codepoint;
27+
uint32_t state = 0;
28+
29+
for(*count = 0; *s; ++s)
30+
if(!utf8_decode(&state, &codepoint, *s))
31+
*count += 1;
32+
33+
return state != UTF8_ACCEPT;
34+
}
35+
36+
uint32_t inline utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
37+
38+
uint32_t type = utf8d[byte];
39+
*codep = (*state != UTF8_ACCEPT) ?
40+
(byte & 0x3fu) | (*codep << 6) :
41+
(0xff >> type) & (byte);
42+
43+
*state = utf8d[256 + *state*16 + type];
44+
return *state;
45+
}

src/utf8.h renamed to src/websocket/utf8.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/**
2+
* cwebsocket: A fast, lightweight websocket client/server
3+
*
4+
* Copyright (c) 2014 Jeremy Hahn
5+
*
6+
* This file is part of cwebsocket.
7+
*
8+
* cwebsocket is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published
10+
* by the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* cwebsocket is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with cwebsocket. If not, see <http://www.gnu.org/licenses/>.
20+
*/
21+
122
#ifndef UTF8_H_
223
#define UTF8_H_
324

0 commit comments

Comments
 (0)