Skip to content

Commit

Permalink
Convert indentation to spaces
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
  • Loading branch information
Jianhui Zhao committed Jan 8, 2018
1 parent 506f4e1 commit 29f6f77
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 31 deletions.
6 changes: 3 additions & 3 deletions example/helloworld.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void uwsc_onopen(struct uwsc_client *cl)

static void uwsc_onmessage(struct uwsc_client *cl, char *data, uint64_t len, enum websocket_op op)
{
printf("recv:[%.*s]\n", (int)len, data);
printf("recv:[%.*s]\n", (int)len, data);
}

static void uwsc_onerror(struct uwsc_client *cl)
Expand All @@ -66,15 +66,15 @@ int main(int argc, char **argv)
cl = uwsc_new("ws://127.0.0.1:81/lua");
//cl = uwsc_new("wss://127.0.0.1:81/lua");

cl->onopen = uwsc_onopen;
cl->onopen = uwsc_onopen;
cl->onmessage = uwsc_onmessage;
cl->onerror = uwsc_onerror;
cl->onclose = uwsc_onclose;

uloop_run();
uloop_done();

cl->free(cl);
cl->free(cl);

return 0;
}
1 change: 0 additions & 1 deletion src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ void __uwsc_log(const char *filename, int line, int priority, const char *format
fprintf(stderr, "%s\n", buf);
#endif
}

16 changes: 8 additions & 8 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

int get_nonce(uint8_t *dest, int len)
{
FILE *fp;
size_t n;
FILE *fp;
size_t n;

fp = fopen("/dev/urandom", "r");
if (fp) {
n = fread(dest, len, 1, fp);
fclose(fp);
return n;
}
fp = fopen("/dev/urandom", "r");
if (fp) {
n = fread(dest, len, 1, fp);
fclose(fp);
return n;
}

return -1;
}
Expand Down
1 change: 0 additions & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ const struct ustream_ssl_ops *init_ustream_ssl();
#endif

#endif

36 changes: 18 additions & 18 deletions src/uwsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,42 @@ enum uwsc_error_code {
};

enum client_state {
CLIENT_STATE_INIT,
CLIENT_STATE_HANDSHAKE,
CLIENT_STATE_MESSAGE
CLIENT_STATE_INIT,
CLIENT_STATE_HANDSHAKE,
CLIENT_STATE_MESSAGE
};

enum websocket_op {
WEBSOCKET_OP_CONTINUE = 0x0,
WEBSOCKET_OP_TEXT = 0x1,
WEBSOCKET_OP_BINARY = 0x2,
WEBSOCKET_OP_CLOSE = 0x8,
WEBSOCKET_OP_PING = 0x9,
WEBSOCKET_OP_PONG = 0xA
WEBSOCKET_OP_CONTINUE = 0x0,
WEBSOCKET_OP_TEXT = 0x1,
WEBSOCKET_OP_BINARY = 0x2,
WEBSOCKET_OP_CLOSE = 0x8,
WEBSOCKET_OP_PING = 0x9,
WEBSOCKET_OP_PONG = 0xA
};

struct uwsc_frame {
uint8_t fin;
uint8_t opcode;
uint64_t payload_len;
char *payload;
uint8_t fin;
uint8_t opcode;
uint64_t payload_len;
char *payload;
};

struct uwsc_client {
struct ustream *us;
struct ustream *us;
struct ustream_fd sfd;
enum client_state state;
enum client_state state;
struct uwsc_frame frame;
struct uloop_timeout timeout;
enum uwsc_error_code error;

#if (UWSC_SSL_SUPPORT)
struct ustream_ssl ussl;
struct ustream_ssl_ctx *ssl_ctx;
const struct ustream_ssl_ops *ssl_ops;
struct ustream_ssl_ctx *ssl_ctx;
const struct ustream_ssl_ops *ssl_ops;
#endif

void (*onopen)(struct uwsc_client *cl);
void (*onopen)(struct uwsc_client *cl);
void (*onmessage)(struct uwsc_client *cl, char *data, uint64_t len, enum websocket_op op);
void (*onerror)(struct uwsc_client *cl);
void (*onclose)(struct uwsc_client *cl);
Expand Down

0 comments on commit 29f6f77

Please sign in to comment.