Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 2548561

Browse files
committed
Be ANSI C friendly.
1 parent 7047c7c commit 2548561

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CC?=gcc
2-
CFLAGS=-DPLATFORM_POSIX
2+
CFLAGS=-ansi -DPLATFORM_POSIX
33

44
session.o: http.h session.c
55
$(CC) $(CFLAGS) -c session.c -o $@

http.h

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// libhttp - A HTTP client and server library.
1+
/*
2+
* libhttp - A HTTP (RFC 2616) library for C.
3+
*/
24

35
#ifndef http_h
46
#define http_h
@@ -12,54 +14,60 @@ typedef struct http_message_s http_message;
1214
typedef int (*http_stream_cb)(http_stream* stream, void* context);
1315

1416
enum http_error_codes {
15-
HTTP_ENOTIMPL // Not yet implemented.
17+
HTTP_ENOTIMPL /* Not yet implemented. */
1618
};
1719

1820
enum http_message_type {
1921
HTTP_MESSAGE_REQUEST,
2022
HTTP_MESSAGE_RESPONSE
2123
};
2224

23-
// Streams provide an interface for writing data to the socket
24-
// bound to a session. They are responsible for handling any
25-
// encoding/decoding of the data. Data will be written or read from
26-
// buffers supplied and returning number of bytes actually transferred.
27-
// Note: these methods may or may not block depending on the
28-
// underlying socket's mode.
25+
/* Streams provide an interface for writing data to the socket
26+
* bound to a session. They are responsible for handling any
27+
* encoding/decoding of the data. Data will be written or read from
28+
* buffers supplied and returning number of bytes actually transferred.
29+
* Note: these methods may or may not block depending on the
30+
* underlying socket's mode.
31+
*/
2932
size_t http_stream_read(char* buffer, size_t size);
3033
size_t http_stream_write(const char* buffer, size_t size);
3134

32-
// A session represents a connection between a client and the server.
33-
// Create a socket connected to the server or accept incoming client
34-
// from listening socket. Initialize a new HTTP session using this socket.
35-
// Closing the session also closes the underlying socket.
35+
/* A session represents a connection between a client and the server.
36+
* Create a socket connected to the server or accept incoming client
37+
* from listening socket. Initialize a new HTTP session using this socket.
38+
* Closing the session also closes the underlying socket.
39+
*/
3640
http_session* http_session_init(int sockfd);
3741
void http_session_close(http_session* session);
3842

39-
// Parsing of messages arriving from a session.
40-
// Clients will parse responses while servers parse requests.
43+
/* Parsing of messages arriving from a session.
44+
* Clients will parse responses while servers parse requests.
45+
*/
4146
http_message* http_session_parse_request(http_session* session);
4247
http_message* http_session_parse_response(http_session* session);
4348

44-
// Compose a new message for sending with a session.
45-
// Clients will compose requests while servers compose responses.
49+
/* Compose a new message for sending with a session.
50+
* Clients will compose requests while servers compose responses.
51+
*/
4652
http_message* http_request(const char* method, const char* uri);
4753
http_message* http_response(int status_code, const char* reason_phrase);
4854

49-
// Append a new header to the message if a field with
50-
// this name does not yet exist. If it already exists then
51-
// the new value will be appended follow RFC2616 4.2 guidelines.
55+
/* Append a new header to the message if a field with
56+
* this name does not yet exist. If it already exists then
57+
* the new value will be appended follow RFC2616 4.2 guidelines.
58+
*/
5259
void http_message_append_header(http_message* msg, const char* name, const char* value);
5360

54-
// Type of message: request or response.
61+
/* Type of message: request or response. */
5562
int http_message_get_type(http_message* msg);
5663

57-
// Set a stream callback for reading or writing the message body.
58-
// A parsed (incoming) message will read while a composed (outgoing)
59-
// message will be writing.
64+
/* Set a stream callback for reading or writing the message body.
65+
* A parsed (incoming) message will read while a composed (outgoing)
66+
* message will be writing.
67+
*/
6068
void http_message_set_body_cb(http_message* msg, http_stream_cb cb, void* context);
6169

62-
// Send a fully composed message with a session.
70+
/* Send a fully composed message with a session. */
6371
int http_session_send_message(http_session* session, const http_message* msg);
6472

6573
#endif

session.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ void http_session_close(http_session* session) {
2525
}
2626

2727
http_message* http_session_parse_request(http_session* session) {
28-
// TODO: implement
28+
/* TODO: implement */
2929
return NULL;
3030
}
3131

3232
http_message* http_session_parse_response(http_session* session) {
33-
// TODO: implement
33+
/* TODO: implement */
3434
return NULL;
3535
}
3636

3737
int http_session_send_message(http_session* session, const http_message* msg) {
38-
// TODO: implement
38+
/* TODO: implement */
3939
return HTTP_ENOTIMPL;
4040
}
4141

0 commit comments

Comments
 (0)