Permalink
Browse files

source code re-indent

The source files in src/ were all reindented with GNU indent right now.
No other changes. The following options were used in the conversion:

indent \
--braces-on-if-line \
--braces-after-struct-decl-line \
--no-space-after-casts \
--line-length 79 \
--comment-line-length 79 \
--cuddle-else \
--no-tabs \
--indent-level 2 \
--no-space-after-for \
--no-space-after-if \
--no-space-after-while \
--no-space-after-function-call-names \
--dont-break-procedure-type \
-T spdy_syn_stream \
-T spdy_data \
-T spdy_control_frame \
-T spdy_data_frame \
-T spdy_frame \
-T spdy_headers \
-T spdy_nv_pair \
-T spdy_nv_block \
-T spdy_rst_stream \
-T spdy_stream \
-T spdy_syn_reply \
-T spdy_zlib_context \
-T spindly_demux_t \
-T size_t
  • Loading branch information...
1 parent 6f010c9 commit 35e98771959c60cbcd7183a847c6770b7644cbae @bagder committed Jan 16, 2012
Showing with 1,201 additions and 1,252 deletions.
  1. +49 −48 bin/create_nv_block.c
  2. +72 −67 bin/read_dump.c
  3. +67 −73 bin/read_stream.c
  4. +10 −3 src/spdy_bytes.h
  5. +135 −147 src/spdy_control_frame.c
  6. +12 −16 src/spdy_data.c
  7. +54 −55 src/spdy_data_frame.c
  8. +50 −56 src/spdy_frame.c
  9. +45 −51 src/spdy_headers.c
  10. +0 −1 src/spdy_log.h
  11. +219 −230 src/spdy_nv_block.c
  12. +13 −12 src/spdy_rst_stream.c
  13. +162 −171 src/spdy_stream.c
  14. +45 −49 src/spdy_syn_reply.c
  15. +58 −61 src/spdy_syn_stream.c
  16. +184 −184 src/spdy_zlib.c
  17. +13 −17 src/spindly_phys.c
  18. +13 −11 src/spindly_stream.c
View
@@ -4,56 +4,57 @@
#include "spdy_nv_block.h"
-int main(int argc, char *argv[]) {
- spdy_nv_block nvb;
- nvb.count = 0;
- nvb.pairs = NULL;
+int main(int argc, char *argv[])
+{
+ spdy_nv_block nvb;
+ nvb.count = 0;
+ nvb.pairs = NULL;
- int i;
- for(i=1; i < argc; i++) {
- /* strtok manipulates the string, so we need to copy it to keep
- argv[i] consistent. */
- char *tmp_argv = malloc(strlen(argv[i])+1);
- char *tmp_argv_ref = tmp_argv;
- if(!tmp_argv)
- exit(1);
- memcpy(tmp_argv, argv[i], strlen(argv[i])+1);
- char *pair_name = strtok(tmp_argv, "=");
- if(!pair_name)
- exit(1);
- char *pair_value = strtok(NULL, "=");
- if(!pair_value)
- exit(1);
- nvb.pairs = realloc(nvb.pairs, sizeof(spdy_nv_pair)*(nvb.count + 1));
- spdy_nv_pair *nvp = &nvb.pairs[nvb.count];
- nvp->name = malloc(strlen(pair_name)+1);
- if(!nvp->name)
- exit(1);
- strcpy(nvp->name, pair_name);
- nvp->values = malloc(strlen(pair_value)+1);
- if(!nvp->values)
- exit(1);
- strcpy(nvp->values, pair_value);
- nvp->values_count=1;
+ int i;
+ for(i = 1; i < argc; i++) {
+ /* strtok manipulates the string, so we need to copy it to keep
+ argv[i] consistent. */
+ char *tmp_argv = malloc(strlen(argv[i]) + 1);
+ char *tmp_argv_ref = tmp_argv;
+ if(!tmp_argv)
+ exit(1);
+ memcpy(tmp_argv, argv[i], strlen(argv[i]) + 1);
+ char *pair_name = strtok(tmp_argv, "=");
+ if(!pair_name)
+ exit(1);
+ char *pair_value = strtok(NULL, "=");
+ if(!pair_value)
+ exit(1);
+ nvb.pairs = realloc(nvb.pairs, sizeof(spdy_nv_pair) * (nvb.count + 1));
+ spdy_nv_pair *nvp = &nvb.pairs[nvb.count];
+ nvp->name = malloc(strlen(pair_name) + 1);
+ if(!nvp->name)
+ exit(1);
+ strcpy(nvp->name, pair_name);
+ nvp->values = malloc(strlen(pair_value) + 1);
+ if(!nvp->values)
+ exit(1);
+ strcpy(nvp->values, pair_value);
+ nvp->values_count = 1;
- nvb.count++;
+ nvb.count++;
- free(tmp_argv_ref);
- }
+ free(tmp_argv_ref);
+ }
- char *nv_block_data=NULL;
- size_t nv_block_data_size=0;
- spdy_nv_block_pack(&nv_block_data, &nv_block_data_size, &nvb);
- printf("Size: %d\n", nv_block_data_size);
- for(i = 0; i < nv_block_data_size; i++) {
- printf("%02x ", nv_block_data[i]);
- /* Printed 8 bytes, make a newline. */
- if(((i+1) % 8) == 0) {
- printf("\n");
- } else if(((i+1) % 4) == 0) {
- printf(" ");
- }
- }
- printf("\n");
- exit(0);
+ char *nv_block_data = NULL;
+ size_t nv_block_data_size = 0;
+ spdy_nv_block_pack(&nv_block_data, &nv_block_data_size, &nvb);
+ printf("Size: %d\n", nv_block_data_size);
+ for(i = 0; i < nv_block_data_size; i++) {
+ printf("%02x ", nv_block_data[i]);
+ /* Printed 8 bytes, make a newline. */
+ if(((i + 1) % 8) == 0) {
+ printf("\n");
+ } else if(((i + 1) % 4) == 0) {
+ printf(" ");
+ }
+ }
+ printf("\n");
+ exit(0);
}
View
@@ -11,104 +11,109 @@
#include "spdy_zlib.h"
#include "spdy_error.h"
-void handle_data_frame(spdy_frame *frame) {
- spdy_data_frame *data_frm = (spdy_data_frame*)&frame->frame.data;
- printf("Data frame:\n");
- printf("\tStream ID: % 5d\n", data_frm->stream_id);
- printf("\tFlags: % 5d\n", data_frm->flags);
- printf("\tLength: % 5d\n", data_frm->length);
+void handle_data_frame(spdy_frame *frame)
+{
+ spdy_data_frame *data_frm = (spdy_data_frame *)&frame->frame.data;
+ printf("Data frame:\n");
+ printf("\tStream ID: % 5d\n", data_frm->stream_id);
+ printf("\tFlags: % 5d\n", data_frm->flags);
+ printf("\tLength: % 5d\n", data_frm->length);
}
-void handle_control_frame(spdy_frame *frame) {
+void handle_control_frame(spdy_frame *frame)
+{
int i;
spdy_syn_stream *syn_stream = NULL;
- spdy_syn_reply* syn_reply = NULL;
- spdy_control_frame *ctrl_frm =
- (spdy_control_frame*)&frame->frame.control;
- printf("Control frame:\n");
- printf("\tVersion: % 5d\n", ctrl_frm->version);
- printf("\tType: % 5d (%s)\n",
- ctrl_frm->type,
- spdy_control_frame_get_type_name(ctrl_frm->type));
- printf("\tFlags: % 5d\n", ctrl_frm->flags);
- printf("\tLength: % 5d\n", ctrl_frm->length);
- switch(ctrl_frm->type) {
- case SPDY_CTRL_SYN_STREAM:
- syn_stream = (spdy_syn_stream *)&ctrl_frm->obj.syn_stream;
- printf("\tStream-ID: % 5d\n", syn_stream->stream_id);
- printf("\tAssociated: % 5d\n", syn_stream->associated_to);
- printf("\tPriority: % 5d\n", syn_stream->priority);
- printf("\tNV Block: % 5d\n", syn_stream->nv_block.count);
- for(i=0; i < syn_stream->nv_block.count; i++) {
- printf("\t\t%s: %s\n", syn_stream->nv_block.pairs[i].name, syn_stream->nv_block.pairs[i].values);
- }
- break;
- case SPDY_CTRL_SYN_REPLY:
- syn_reply = (spdy_syn_reply*)&ctrl_frm->obj.syn_reply;
- printf("\tStream-ID: % 5d\n", syn_reply->stream_id);
- printf("\tNV Block: % 5d\n", syn_reply->nv_block.count);
- for(i=0; i < syn_reply->nv_block.count; i++) {
- printf("\t\t%s: %s\n", syn_reply->nv_block.pairs[i].name, syn_reply->nv_block.pairs[i].values);
- }
- break;
- default:
- printf("Unknown frame type.");
- break;
+ spdy_syn_reply *syn_reply = NULL;
+ spdy_control_frame *ctrl_frm = (spdy_control_frame *)&frame->frame.control;
+ printf("Control frame:\n");
+ printf("\tVersion: % 5d\n", ctrl_frm->version);
+ printf("\tType: % 5d (%s)\n",
+ ctrl_frm->type, spdy_control_frame_get_type_name(ctrl_frm->type));
+ printf("\tFlags: % 5d\n", ctrl_frm->flags);
+ printf("\tLength: % 5d\n", ctrl_frm->length);
+ switch (ctrl_frm->type) {
+ case SPDY_CTRL_SYN_STREAM:
+ syn_stream = (spdy_syn_stream *)&ctrl_frm->obj.syn_stream;
+ printf("\tStream-ID: % 5d\n", syn_stream->stream_id);
+ printf("\tAssociated: % 5d\n", syn_stream->associated_to);
+ printf("\tPriority: % 5d\n", syn_stream->priority);
+ printf("\tNV Block: % 5d\n", syn_stream->nv_block.count);
+ for(i = 0; i < syn_stream->nv_block.count; i++) {
+ printf("\t\t%s: %s\n", syn_stream->nv_block.pairs[i].name,
+ syn_stream->nv_block.pairs[i].values);
+ }
+ break;
+ case SPDY_CTRL_SYN_REPLY:
+ syn_reply = (spdy_syn_reply *)&ctrl_frm->obj.syn_reply;
+ printf("\tStream-ID: % 5d\n", syn_reply->stream_id);
+ printf("\tNV Block: % 5d\n", syn_reply->nv_block.count);
+ for(i = 0; i < syn_reply->nv_block.count; i++) {
+ printf("\t\t%s: %s\n", syn_reply->nv_block.pairs[i].name,
+ syn_reply->nv_block.pairs[i].values);
+ }
+ break;
+ default:
+ printf("Unknown frame type.");
+ break;
}
}
-char *read_file(const char *filename, long *fsiz) {
+char *read_file(const char *filename, long *fsiz)
+{
FILE *f;
long siz;
char *buf;
size_t res;
f = fopen(filename, "rb");
- if (f == NULL) return NULL;
+ if(f == NULL)
+ return NULL;
fseek(f, 0, SEEK_END);
siz = ftell(f);
rewind(f);
- buf = (char *) malloc(sizeof(char)*siz);
- if (buf == NULL) return NULL;
+ buf = (char *)malloc(sizeof(char) * siz);
+ if(buf == NULL)
+ return NULL;
res = fread(buf, 1, siz, f);
- if (res != siz) {
+ if(res != siz) {
free(buf);
return NULL;
}
*fsiz = siz;
return buf;
}
-int main(int argc, char *argv[]) {
- if(argc != 2) {
- printf("Usage:\n%s [file]\n", argv[0]);
- return EXIT_FAILURE;
- }
+int main(int argc, char *argv[])
+{
+ if(argc != 2) {
+ printf("Usage:\n%s [file]\n", argv[0]);
+ return EXIT_FAILURE;
+ }
long fsiz;
char *fbuf = read_file(argv[1], &fsiz);
- if(fbuf == NULL) {
- printf("Failed to open file \"%s\".\n", argv[1]);
- return EXIT_FAILURE;
- }
- spdy_zlib_context zlib_ctx;
- spdy_frame frame;
- spdy_frame_init(&frame);
- spdy_data data;
- spdy_data_use(&data, fbuf, fsiz);
- spdy_zlib_inflate_init(&zlib_ctx);
+ if(fbuf == NULL) {
+ printf("Failed to open file \"%s\".\n", argv[1]);
+ return EXIT_FAILURE;
+ }
+ spdy_zlib_context zlib_ctx;
+ spdy_frame frame;
+ spdy_frame_init(&frame);
+ spdy_data data;
+ spdy_data_use(&data, fbuf, fsiz);
+ spdy_zlib_inflate_init(&zlib_ctx);
int ret = spdy_frame_parse(&frame, &data, &zlib_ctx);
if(ret == SPDY_ERROR_NONE) {
- switch(frame.type) {
- case SPDY_DATA_FRAME:
- handle_data_frame(&frame);
- break;
- case SPDY_CONTROL_FRAME:
- handle_control_frame(&frame);
- break;
+ switch (frame.type) {
+ case SPDY_DATA_FRAME:
+ handle_data_frame(&frame);
+ break;
+ case SPDY_CONTROL_FRAME:
+ handle_control_frame(&frame);
+ break;
}
}
spdy_frame_destroy(&frame);
spdy_zlib_inflate_end(&zlib_ctx);
free(fbuf);
return EXIT_SUCCESS;
}
-
Oops, something went wrong. Retry.

0 comments on commit 35e9877

Please sign in to comment.