From c4e1f97a62ecd44855b65d6bced9f4789744ffd7 Mon Sep 17 00:00:00 2001
From: "Zed A. Shaw"
Date: Sun, 12 Jun 2011 12:03:31 -0700
Subject: [PATCH 01/15] Fix up some formatting and add licenses to most .c
files.
---
src/adt/darray.c | 34 ++
src/adt/dict.c | 812 ++++++++++++++++----------------
src/adt/hash.c | 6 +-
src/cache.c | 34 ++
src/config/module.c | 34 ++
src/connection.c | 1 -
src/control.c | 34 ++
src/dbg.c | 34 ++
src/dir.c | 1 +
src/filter.c | 34 ++
src/io.c | 34 ++
src/log.c | 34 ++
src/upload.c | 34 ++
tools/config_modules/null.c | 34 ++
tools/config_modules/zmq.c | 34 ++
tools/filters/null.c | 34 ++
tools/m2sh/src/ast.c | 34 ++
tools/m2sh/src/cli.c | 80 +++-
tools/m2sh/src/cli.rl | 34 ++
tools/m2sh/src/commands.c | 34 ++
tools/m2sh/src/config_file.c | 34 ++
tools/m2sh/src/constants.c | 34 ++
tools/m2sh/src/lexer.c | 106 +++--
tools/m2sh/src/lexer.rl | 34 ++
tools/m2sh/src/m2sh.c | 34 ++
tools/m2sh/src/token.c | 34 ++
tools/m2sh/tests/cli_tests.c | 34 ++
tools/m2sh/tests/parser_tests.c | 34 ++
28 files changed, 1285 insertions(+), 469 deletions(-)
diff --git a/src/adt/darray.c b/src/adt/darray.c
index e33b5514..0d4f30ca 100644
--- a/src/adt/darray.c
+++ b/src/adt/darray.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "adt/darray.h"
#include "mem/halloc.h"
#include
diff --git a/src/adt/dict.c b/src/adt/dict.c
index f7cc0a69..6c89634f 100644
--- a/src/adt/dict.c
+++ b/src/adt/dict.c
@@ -86,10 +86,10 @@ static void rotate_left(dnode_t *upper)
the sentinel nil node, and root->parent->left points back to root */
if (upper == upparent->left) {
- upparent->left = lower;
+ upparent->left = lower;
} else {
- assert (upper == upparent->right);
- upparent->right = lower;
+ assert (upper == upparent->right);
+ upparent->right = lower;
}
lower->left = upper;
@@ -112,10 +112,10 @@ static void rotate_right(dnode_t *upper)
lower->parent = upparent = upper->parent;
if (upper == upparent->right) {
- upparent->right = lower;
+ upparent->right = lower;
} else {
- assert (upper == upparent->left);
- upparent->left = lower;
+ assert (upper == upparent->left);
+ upparent->left = lower;
}
lower->right = upper;
@@ -130,7 +130,7 @@ static void rotate_right(dnode_t *upper)
static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
{
if (node == nil)
- return;
+ return;
free_nodes(dict, node->left, nil);
free_nodes(dict, node->right, nil);
dict->freenode(node, dict->context);
@@ -152,17 +152,17 @@ static int verify_bintree(dict_t *dict)
first = dict_first(dict);
if (dict->dupes) {
- while (first && (next = dict_next(dict, first))) {
- if (dict->compare(first->key, next->key) > 0)
- return 0;
- first = next;
- }
+ while (first && (next = dict_next(dict, first))) {
+ if (dict->compare(first->key, next->key) > 0)
+ return 0;
+ first = next;
+ }
} else {
- while (first && (next = dict_next(dict, first))) {
- if (dict->compare(first->key, next->key) >= 0)
- return 0;
- first = next;
- }
+ while (first && (next = dict_next(dict, first))) {
+ if (dict->compare(first->key, next->key) >= 0)
+ return 0;
+ first = next;
+ }
}
return 1;
}
@@ -186,22 +186,22 @@ static unsigned int verify_redblack(dnode_t *nil, dnode_t *root)
unsigned height_left, height_right;
if (root != nil) {
- height_left = verify_redblack(nil, root->left);
- height_right = verify_redblack(nil, root->right);
- if (height_left == 0 || height_right == 0)
- return 0;
- if (height_left != height_right)
- return 0;
- if (root->color == dnode_red) {
- if (root->left->color != dnode_black)
- return 0;
- if (root->right->color != dnode_black)
- return 0;
- return height_left;
- }
- if (root->color != dnode_black)
- return 0;
- return height_left + 1;
+ height_left = verify_redblack(nil, root->left);
+ height_right = verify_redblack(nil, root->right);
+ if (height_left == 0 || height_right == 0)
+ return 0;
+ if (height_left != height_right)
+ return 0;
+ if (root->color == dnode_red) {
+ if (root->left->color != dnode_black)
+ return 0;
+ if (root->right->color != dnode_black)
+ return 0;
+ return height_left;
+ }
+ if (root->color != dnode_black)
+ return 0;
+ return height_left + 1;
}
return 1;
}
@@ -215,10 +215,10 @@ static unsigned int verify_redblack(dnode_t *nil, dnode_t *root)
static dictcount_t verify_node_count(dnode_t *nil, dnode_t *root)
{
if (root == nil)
- return 0;
+ return 0;
else
- return 1 + verify_node_count(nil, root->left)
- + verify_node_count(nil, root->right);
+ return 1 + verify_node_count(nil, root->left)
+ + verify_node_count(nil, root->right);
}
/*
@@ -231,9 +231,9 @@ static dictcount_t verify_node_count(dnode_t *nil, dnode_t *root)
static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node)
{
if (root != nil) {
- return root == node
- || verify_dict_has_node(nil, root->left, node)
- || verify_dict_has_node(nil, root->right, node);
+ return root == node
+ || verify_dict_has_node(nil, root->left, node)
+ || verify_dict_has_node(nil, root->right, node);
}
return 0;
}
@@ -248,17 +248,17 @@ dict_t *dict_create(dictcount_t maxcount, dict_comp_t comp)
dict_t *new = malloc(sizeof *new);
if (new) {
- new->compare = comp;
- new->allocnode = dnode_alloc;
- new->freenode = dnode_free;
- new->context = NULL;
- new->nodecount = 0;
- new->maxcount = maxcount;
- new->nilnode.left = &new->nilnode;
- new->nilnode.right = &new->nilnode;
- new->nilnode.parent = &new->nilnode;
- new->nilnode.color = dnode_black;
- new->dupes = 0;
+ new->compare = comp;
+ new->allocnode = dnode_alloc;
+ new->freenode = dnode_free;
+ new->context = NULL;
+ new->nodecount = 0;
+ new->maxcount = maxcount;
+ new->nilnode.left = &new->nilnode;
+ new->nilnode.right = &new->nilnode;
+ new->nilnode.parent = &new->nilnode;
+ new->nilnode.color = dnode_black;
+ new->dupes = 0;
}
return new;
}
@@ -268,7 +268,7 @@ dict_t *dict_create(dictcount_t maxcount, dict_comp_t comp)
*/
void dict_set_allocator(dict_t *dict, dnode_alloc_t al,
- dnode_free_t fr, void *context)
+ dnode_free_t fr, void *context)
{
assert (dict_count(dict) == 0);
assert ((al == NULL && fr == NULL) || (al != NULL && fr != NULL));
@@ -383,22 +383,22 @@ int dict_verify(dict_t *dict)
/* check that the sentinel node and root node are black */
if (root->color != dnode_black)
- return 0;
+ return 0;
if (nil->color != dnode_black)
- return 0;
+ return 0;
if (nil->right != nil)
- return 0;
+ return 0;
/* nil->left is the root node; check that its parent pointer is nil */
if (nil->left->parent != nil)
- return 0;
+ return 0;
/* perform a weak test that the tree is a binary search tree */
if (!verify_bintree(dict))
- return 0;
+ return 0;
/* verify that the tree is a red-black tree */
if (!verify_redblack(nil, root))
- return 0;
+ return 0;
if (verify_node_count(nil, root) != dict_count(dict))
- return 0;
+ return 0;
return 1;
}
@@ -410,19 +410,19 @@ int dict_verify(dict_t *dict)
int dict_similar(const dict_t *left, const dict_t *right)
{
if (left->compare != right->compare)
- return 0;
+ return 0;
if (left->allocnode != right->allocnode)
- return 0;
+ return 0;
if (left->freenode != right->freenode)
- return 0;
+ return 0;
if (left->context != right->context)
- return 0;
+ return 0;
if (left->dupes != right->dupes)
- return 0;
+ return 0;
return 1;
}
@@ -444,24 +444,24 @@ dnode_t *dict_lookup(dict_t *dict, const void *key)
/* simple binary search adapted for trees that contain duplicate keys */
while (root != nil) {
- result = dict->compare(key, root->key);
- if (result < 0)
- root = root->left;
- else if (result > 0)
- root = root->right;
- else {
- if (!dict->dupes) { /* no duplicates, return match */
- return root;
- } else { /* could be dupes, find leftmost one */
- do {
- saved = root;
- root = root->left;
- while (root != nil && dict->compare(key, root->key))
- root = root->right;
- } while (root != nil);
- return saved;
- }
- }
+ result = dict->compare(key, root->key);
+ if (result < 0)
+ root = root->left;
+ else if (result > 0)
+ root = root->right;
+ else {
+ if (!dict->dupes) { /* no duplicates, return match */
+ return root;
+ } else { /* could be dupes, find leftmost one */
+ do {
+ saved = root;
+ root = root->left;
+ while (root != nil && dict->compare(key, root->key))
+ root = root->right;
+ } while (root != nil);
+ return saved;
+ }
+ }
}
return NULL;
@@ -479,23 +479,23 @@ dnode_t *dict_lower_bound(dict_t *dict, const void *key)
dnode_t *tentative = 0;
while (root != nil) {
- int result = dict->compare(key, root->key);
-
- if (result > 0) {
- root = root->right;
- } else if (result < 0) {
- tentative = root;
- root = root->left;
- } else {
- if (!dict->dupes) {
- return root;
- } else {
- tentative = root;
- root = root->left;
- }
- }
+ int result = dict->compare(key, root->key);
+
+ if (result > 0) {
+ root = root->right;
+ } else if (result < 0) {
+ tentative = root;
+ root = root->left;
+ } else {
+ if (!dict->dupes) {
+ return root;
+ } else {
+ tentative = root;
+ root = root->left;
+ }
+ }
}
-
+
return tentative;
}
@@ -511,23 +511,23 @@ dnode_t *dict_upper_bound(dict_t *dict, const void *key)
dnode_t *tentative = 0;
while (root != nil) {
- int result = dict->compare(key, root->key);
-
- if (result < 0) {
- root = root->left;
- } else if (result > 0) {
- tentative = root;
- root = root->right;
- } else {
- if (!dict->dupes) {
- return root;
- } else {
- tentative = root;
- root = root->right;
- }
- }
+ int result = dict->compare(key, root->key);
+
+ if (result < 0) {
+ root = root->left;
+ } else if (result > 0) {
+ tentative = root;
+ root = root->right;
+ } else {
+ if (!dict->dupes) {
+ return root;
+ } else {
+ tentative = root;
+ root = root->right;
+ }
+ }
}
-
+
return tentative;
}
@@ -554,22 +554,22 @@ void dict_insert(dict_t *dict, dnode_t *node, const void *key)
/* basic binary tree insert */
while (where != nil) {
- parent = where;
- result = dict->compare(key, where->key);
- /* trap attempts at duplicate key insertion unless it's explicitly allowed */
- assert (dict->dupes || result != 0);
- if (result < 0)
- where = where->left;
- else
- where = where->right;
+ parent = where;
+ result = dict->compare(key, where->key);
+ /* trap attempts at duplicate key insertion unless it's explicitly allowed */
+ assert (dict->dupes || result != 0);
+ if (result < 0)
+ where = where->left;
+ else
+ where = where->right;
}
assert (where == nil);
if (result < 0)
- parent->left = node;
+ parent->left = node;
else
- parent->right = node;
+ parent->right = node;
node->parent = parent;
node->left = nil;
@@ -582,47 +582,47 @@ void dict_insert(dict_t *dict, dnode_t *node, const void *key)
node->color = dnode_red;
while (parent->color == dnode_red) {
- grandpa = parent->parent;
- if (parent == grandpa->left) {
- uncle = grandpa->right;
- if (uncle->color == dnode_red) { /* red parent, red uncle */
- parent->color = dnode_black;
- uncle->color = dnode_black;
- grandpa->color = dnode_red;
- node = grandpa;
- parent = grandpa->parent;
- } else { /* red parent, black uncle */
- if (node == parent->right) {
- rotate_left(parent);
- parent = node;
- assert (grandpa == parent->parent);
- /* rotation between parent and child preserves grandpa */
- }
- parent->color = dnode_black;
- grandpa->color = dnode_red;
- rotate_right(grandpa);
- break;
- }
- } else { /* symmetric cases: parent == parent->parent->right */
- uncle = grandpa->left;
- if (uncle->color == dnode_red) {
- parent->color = dnode_black;
- uncle->color = dnode_black;
- grandpa->color = dnode_red;
- node = grandpa;
- parent = grandpa->parent;
- } else {
- if (node == parent->left) {
- rotate_right(parent);
- parent = node;
- assert (grandpa == parent->parent);
- }
- parent->color = dnode_black;
- grandpa->color = dnode_red;
- rotate_left(grandpa);
- break;
- }
- }
+ grandpa = parent->parent;
+ if (parent == grandpa->left) {
+ uncle = grandpa->right;
+ if (uncle->color == dnode_red) { /* red parent, red uncle */
+ parent->color = dnode_black;
+ uncle->color = dnode_black;
+ grandpa->color = dnode_red;
+ node = grandpa;
+ parent = grandpa->parent;
+ } else { /* red parent, black uncle */
+ if (node == parent->right) {
+ rotate_left(parent);
+ parent = node;
+ assert (grandpa == parent->parent);
+ /* rotation between parent and child preserves grandpa */
+ }
+ parent->color = dnode_black;
+ grandpa->color = dnode_red;
+ rotate_right(grandpa);
+ break;
+ }
+ } else { /* symmetric cases: parent == parent->parent->right */
+ uncle = grandpa->left;
+ if (uncle->color == dnode_red) {
+ parent->color = dnode_black;
+ uncle->color = dnode_black;
+ grandpa->color = dnode_red;
+ node = grandpa;
+ parent = grandpa->parent;
+ } else {
+ if (node == parent->left) {
+ rotate_right(parent);
+ parent = node;
+ assert (grandpa == parent->parent);
+ }
+ parent->color = dnode_black;
+ grandpa->color = dnode_red;
+ rotate_left(grandpa);
+ break;
+ }
+ }
}
dict_root(dict)->color = dnode_black;
@@ -658,63 +658,63 @@ dnode_t *dict_delete(dict_t *dict, dnode_t *delete)
*/
if (delete->left != nil && delete->right != nil) {
- dnode_t *next = dict_next(dict, delete);
- dnode_t *nextparent = next->parent;
- dnode_color_t nextcolor = next->color;
-
- assert (next != nil);
- assert (next->parent != nil);
- assert (next->left == nil);
-
- /*
- * First, splice out the successor from the tree completely, by
- * moving up its right child into its place.
- */
-
- child = next->right;
- child->parent = nextparent;
-
- if (nextparent->left == next) {
- nextparent->left = child;
- } else {
- assert (nextparent->right == next);
- nextparent->right = child;
- }
-
- /*
- * Now that the successor has been extricated from the tree, install it
- * in place of the node that we want deleted.
- */
-
- next->parent = delparent;
- next->left = delete->left;
- next->right = delete->right;
- next->left->parent = next;
- next->right->parent = next;
- next->color = delete->color;
- delete->color = nextcolor;
-
- if (delparent->left == delete) {
- delparent->left = next;
- } else {
- assert (delparent->right == delete);
- delparent->right = next;
- }
+ dnode_t *next = dict_next(dict, delete);
+ dnode_t *nextparent = next->parent;
+ dnode_color_t nextcolor = next->color;
+
+ assert (next != nil);
+ assert (next->parent != nil);
+ assert (next->left == nil);
+
+ /*
+ * First, splice out the successor from the tree completely, by
+ * moving up its right child into its place.
+ */
+
+ child = next->right;
+ child->parent = nextparent;
+
+ if (nextparent->left == next) {
+ nextparent->left = child;
+ } else {
+ assert (nextparent->right == next);
+ nextparent->right = child;
+ }
+
+ /*
+ * Now that the successor has been extricated from the tree, install it
+ * in place of the node that we want deleted.
+ */
+
+ next->parent = delparent;
+ next->left = delete->left;
+ next->right = delete->right;
+ next->left->parent = next;
+ next->right->parent = next;
+ next->color = delete->color;
+ delete->color = nextcolor;
+
+ if (delparent->left == delete) {
+ delparent->left = next;
+ } else {
+ assert (delparent->right == delete);
+ delparent->right = next;
+ }
} else {
- assert (delete != nil);
- assert (delete->left == nil || delete->right == nil);
+ assert (delete != nil);
+ assert (delete->left == nil || delete->right == nil);
- child = (delete->left != nil) ? delete->left : delete->right;
+ child = (delete->left != nil) ? delete->left : delete->right;
- child->parent = delparent = delete->parent;
+ child->parent = delparent = delete->parent;
- if (delete == delparent->left) {
- delparent->left = child;
- } else {
- assert (delete == delparent->right);
- delparent->right = child;
- }
+ if (delete == delparent->left) {
+ delparent->left = child;
+ } else {
+ assert (delete == delparent->right);
+ delparent->right = child;
+ }
}
delete->parent = NULL;
@@ -728,76 +728,76 @@ dnode_t *dict_delete(dict_t *dict, dnode_t *delete)
/* red-black adjustments */
if (delete->color == dnode_black) {
- dnode_t *parent, *sister;
-
- dict_root(dict)->color = dnode_red;
-
- while (child->color == dnode_black) {
- parent = child->parent;
- if (child == parent->left) {
- sister = parent->right;
- assert (sister != nil);
- if (sister->color == dnode_red) {
- sister->color = dnode_black;
- parent->color = dnode_red;
- rotate_left(parent);
- sister = parent->right;
- assert (sister != nil);
- }
- if (sister->left->color == dnode_black
- && sister->right->color == dnode_black) {
- sister->color = dnode_red;
- child = parent;
- } else {
- if (sister->right->color == dnode_black) {
- assert (sister->left->color == dnode_red);
- sister->left->color = dnode_black;
- sister->color = dnode_red;
- rotate_right(sister);
- sister = parent->right;
- assert (sister != nil);
- }
- sister->color = parent->color;
- sister->right->color = dnode_black;
- parent->color = dnode_black;
- rotate_left(parent);
- break;
- }
- } else { /* symmetric case: child == child->parent->right */
- assert (child == parent->right);
- sister = parent->left;
- assert (sister != nil);
- if (sister->color == dnode_red) {
- sister->color = dnode_black;
- parent->color = dnode_red;
- rotate_right(parent);
- sister = parent->left;
- assert (sister != nil);
- }
- if (sister->right->color == dnode_black
- && sister->left->color == dnode_black) {
- sister->color = dnode_red;
- child = parent;
- } else {
- if (sister->left->color == dnode_black) {
- assert (sister->right->color == dnode_red);
- sister->right->color = dnode_black;
- sister->color = dnode_red;
- rotate_left(sister);
- sister = parent->left;
- assert (sister != nil);
- }
- sister->color = parent->color;
- sister->left->color = dnode_black;
- parent->color = dnode_black;
- rotate_right(parent);
- break;
- }
- }
- }
-
- child->color = dnode_black;
- dict_root(dict)->color = dnode_black;
+ dnode_t *parent, *sister;
+
+ dict_root(dict)->color = dnode_red;
+
+ while (child->color == dnode_black) {
+ parent = child->parent;
+ if (child == parent->left) {
+ sister = parent->right;
+ assert (sister != nil);
+ if (sister->color == dnode_red) {
+ sister->color = dnode_black;
+ parent->color = dnode_red;
+ rotate_left(parent);
+ sister = parent->right;
+ assert (sister != nil);
+ }
+ if (sister->left->color == dnode_black
+ && sister->right->color == dnode_black) {
+ sister->color = dnode_red;
+ child = parent;
+ } else {
+ if (sister->right->color == dnode_black) {
+ assert (sister->left->color == dnode_red);
+ sister->left->color = dnode_black;
+ sister->color = dnode_red;
+ rotate_right(sister);
+ sister = parent->right;
+ assert (sister != nil);
+ }
+ sister->color = parent->color;
+ sister->right->color = dnode_black;
+ parent->color = dnode_black;
+ rotate_left(parent);
+ break;
+ }
+ } else { /* symmetric case: child == child->parent->right */
+ assert (child == parent->right);
+ sister = parent->left;
+ assert (sister != nil);
+ if (sister->color == dnode_red) {
+ sister->color = dnode_black;
+ parent->color = dnode_red;
+ rotate_right(parent);
+ sister = parent->left;
+ assert (sister != nil);
+ }
+ if (sister->right->color == dnode_black
+ && sister->left->color == dnode_black) {
+ sister->color = dnode_red;
+ child = parent;
+ } else {
+ if (sister->left->color == dnode_black) {
+ assert (sister->right->color == dnode_red);
+ sister->right->color = dnode_black;
+ sister->color = dnode_red;
+ rotate_left(sister);
+ sister = parent->left;
+ assert (sister != nil);
+ }
+ sister->color = parent->color;
+ sister->left->color = dnode_black;
+ parent->color = dnode_black;
+ rotate_right(parent);
+ break;
+ }
+ }
+ }
+
+ child->color = dnode_black;
+ dict_root(dict)->color = dnode_black;
}
assert (dict_verify(dict));
@@ -815,9 +815,9 @@ int dict_alloc_insert(dict_t *dict, const void *key, void *data)
dnode_t *node = dict->allocnode(dict->context);
if (node) {
- dnode_init(node, data);
- dict_insert(dict, node, key);
- return 1;
+ dnode_init(node, data);
+ dict_insert(dict, node, key);
+ return 1;
}
return 0;
}
@@ -838,8 +838,8 @@ dnode_t *dict_first(dict_t *dict)
dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left;
if (root != nil)
- while ((left = root->left) != nil)
- root = left;
+ while ((left = root->left) != nil)
+ root = left;
return (root == nil) ? NULL : root;
}
@@ -854,8 +854,8 @@ dnode_t *dict_last(dict_t *dict)
dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *right;
if (root != nil)
- while ((right = root->right) != nil)
- root = right;
+ while ((right = root->right) != nil)
+ root = right;
return (root == nil) ? NULL : root;
}
@@ -872,17 +872,17 @@ dnode_t *dict_next(dict_t *dict, dnode_t *curr)
dnode_t *nil = dict_nil(dict), *parent, *left;
if (curr->right != nil) {
- curr = curr->right;
- while ((left = curr->left) != nil)
- curr = left;
- return curr;
+ curr = curr->right;
+ while ((left = curr->left) != nil)
+ curr = left;
+ return curr;
}
parent = curr->parent;
while (parent != nil && curr == parent->right) {
- curr = parent;
- parent = curr->parent;
+ curr = parent;
+ parent = curr->parent;
}
return (parent == nil) ? NULL : parent;
@@ -898,17 +898,17 @@ dnode_t *dict_prev(dict_t *dict, dnode_t *curr)
dnode_t *nil = dict_nil(dict), *parent, *right;
if (curr->left != nil) {
- curr = curr->left;
- while ((right = curr->right) != nil)
- curr = right;
- return curr;
+ curr = curr->left;
+ while ((right = curr->right) != nil)
+ curr = right;
+ return curr;
}
parent = curr->parent;
while (parent != nil && curr == parent->left) {
- curr = parent;
- parent = curr->parent;
+ curr = parent;
+ parent = curr->parent;
}
return (parent == nil) ? NULL : parent;
@@ -960,10 +960,10 @@ dnode_t *dnode_create(void *data)
{
dnode_t *new = malloc(sizeof *new);
if (new) {
- new->data = data;
- new->parent = NULL;
- new->left = NULL;
- new->right = NULL;
+ new->data = data;
+ new->parent = NULL;
+ new->left = NULL;
+ new->right = NULL;
}
return new;
}
@@ -1008,12 +1008,12 @@ void dict_process(dict_t *dict, void *context, dnode_process_t function)
dnode_t *node = dict_first(dict), *next;
while (node != NULL) {
- /* check for callback function deleting */
- /* the next node from under us */
- assert (dict_contains(dict, node));
- next = dict_next(dict, node);
- function(dict, node, context);
- node = next;
+ /* check for callback function deleting */
+ /* the next node from under us */
+ assert (dict_contains(dict, node));
+ next = dict_next(dict, node);
+ function(dict, node, context);
+ node = next;
}
}
@@ -1034,18 +1034,18 @@ void dict_load_next(dict_load_t *load, dnode_t *newnode, const void *key)
{
dict_t *dict = load->dictptr;
dnode_t *nil = &load->nilnode;
-
+
assert (!dnode_is_in_a_dict(newnode));
assert (dict->nodecount < dict->maxcount);
- #ifndef NDEBUG
+#ifndef NDEBUG
if (dict->nodecount > 0) {
- if (dict->dupes)
- assert (dict->compare(nil->left->key, key) <= 0);
- else
- assert (dict->compare(nil->left->key, key) < 0);
+ if (dict->dupes)
+ assert (dict->compare(nil->left->key, key) <= 0);
+ else
+ assert (dict->compare(nil->left->key, key) < 0);
}
- #endif
+#endif
newnode->key = key;
nil->right->left = newnode;
@@ -1067,63 +1067,63 @@ void dict_load_end(dict_load_t *load)
assert (dnode_red == 0 && dnode_black == 1);
while (fullcount >= nodecount && fullcount)
- fullcount >>= 1;
+ fullcount >>= 1;
botrowcount = nodecount - fullcount;
for (curr = loadnil->left; curr != loadnil; curr = next) {
- next = curr->left;
-
- if (complete == NULL && botrowcount-- == 0) {
- assert (baselevel == 0);
- assert (level == 0);
- baselevel = level = 1;
- complete = tree[0];
-
- if (complete != 0) {
- tree[0] = 0;
- complete->right = dictnil;
- while (tree[level] != 0) {
- tree[level]->right = complete;
- complete->parent = tree[level];
- complete = tree[level];
- tree[level++] = 0;
- }
- }
- }
-
- if (complete == NULL) {
- curr->left = dictnil;
- curr->right = dictnil;
- curr->color = level % 2;
- complete = curr;
-
- assert (level == baselevel);
- while (tree[level] != 0) {
- tree[level]->right = complete;
- complete->parent = tree[level];
- complete = tree[level];
- tree[level++] = 0;
- }
- } else {
- curr->left = complete;
- curr->color = (level + 1) % 2;
- complete->parent = curr;
- tree[level] = curr;
- complete = 0;
- level = baselevel;
- }
+ next = curr->left;
+
+ if (complete == NULL && botrowcount-- == 0) {
+ assert (baselevel == 0);
+ assert (level == 0);
+ baselevel = level = 1;
+ complete = tree[0];
+
+ if (complete != 0) {
+ tree[0] = 0;
+ complete->right = dictnil;
+ while (tree[level] != 0) {
+ tree[level]->right = complete;
+ complete->parent = tree[level];
+ complete = tree[level];
+ tree[level++] = 0;
+ }
+ }
+ }
+
+ if (complete == NULL) {
+ curr->left = dictnil;
+ curr->right = dictnil;
+ curr->color = level % 2;
+ complete = curr;
+
+ assert (level == baselevel);
+ while (tree[level] != 0) {
+ tree[level]->right = complete;
+ complete->parent = tree[level];
+ complete = tree[level];
+ tree[level++] = 0;
+ }
+ } else {
+ curr->left = complete;
+ curr->color = (level + 1) % 2;
+ complete->parent = curr;
+ tree[level] = curr;
+ complete = 0;
+ level = baselevel;
+ }
}
if (complete == NULL)
- complete = dictnil;
+ complete = dictnil;
for (i = 0; i < DICT_DEPTH_MAX; i++) {
- if (tree[i] != 0) {
- tree[i]->right = complete;
- complete->parent = tree[i];
- complete = tree[i];
- }
+ if (tree[i] != 0) {
+ tree[i]->right = complete;
+ complete->parent = tree[i];
+ complete = tree[i];
+ }
}
dictnil->color = dnode_black;
@@ -1143,47 +1143,47 @@ void dict_merge(dict_t *dest, dict_t *source)
assert (dict_similar(dest, source));
if (source == dest)
- return;
+ return;
dest->nodecount = 0;
load_begin_internal(&load, dest);
for (;;) {
- if (leftnode != NULL && rightnode != NULL) {
- if (dest->compare(leftnode->key, rightnode->key) < 0)
- goto copyleft;
- else
- goto copyright;
- } else if (leftnode != NULL) {
- goto copyleft;
- } else if (rightnode != NULL) {
- goto copyright;
- } else {
- assert (leftnode == NULL && rightnode == NULL);
- break;
- }
-
- copyleft:
- {
- dnode_t *next = dict_next(dest, leftnode);
- #ifndef NDEBUG
- leftnode->left = NULL; /* suppress assertion in dict_load_next */
- #endif
- dict_load_next(&load, leftnode, leftnode->key);
- leftnode = next;
- continue;
- }
-
- copyright:
- {
- dnode_t *next = dict_next(source, rightnode);
- #ifndef NDEBUG
- rightnode->left = NULL;
- #endif
- dict_load_next(&load, rightnode, rightnode->key);
- rightnode = next;
- continue;
- }
+ if (leftnode != NULL && rightnode != NULL) {
+ if (dest->compare(leftnode->key, rightnode->key) < 0)
+ goto copyleft;
+ else
+ goto copyright;
+ } else if (leftnode != NULL) {
+ goto copyleft;
+ } else if (rightnode != NULL) {
+ goto copyright;
+ } else {
+ assert (leftnode == NULL && rightnode == NULL);
+ break;
+ }
+
+copyleft:
+ {
+ dnode_t *next = dict_next(dest, leftnode);
+#ifndef NDEBUG
+ leftnode->left = NULL; /* suppress assertion in dict_load_next */
+#endif
+ dict_load_next(&load, leftnode, leftnode->key);
+ leftnode = next;
+ continue;
+ }
+
+copyright:
+ {
+ dnode_t *next = dict_next(source, rightnode);
+#ifndef NDEBUG
+ rightnode->left = NULL;
+#endif
+ dict_load_next(&load, rightnode, rightnode->key);
+ rightnode = next;
+ continue;
+ }
}
dict_clear(source);
diff --git a/src/adt/hash.c b/src/adt/hash.c
index 567f96cf..4890e714 100644
--- a/src/adt/hash.c
+++ b/src/adt/hash.c
@@ -77,7 +77,7 @@ static int hash_comp_default(const void *key1, const void *key2);
*/
#if 0
-Fixed for our usage -josh
+ Fixed for our usage -josh
static void compute_bits(void)
{
hash_val_t val = HASH_VAL_T_MAX; /* 1 */
@@ -299,7 +299,7 @@ hash_t *hash_create(hashcount_t maxcount, hash_comp_t compfun,
// Fixed size for our usage
//if (hash_val_t_bit == 0) /* 1 */
- //compute_bits();
+ //compute_bits();
hash = malloc(sizeof *hash); /* 2 */
@@ -406,7 +406,7 @@ hash_t *hash_init(hash_t *hash, hashcount_t maxcount,
{
// Fixed size for our usage.
//if (hash_val_t_bit == 0) /* 1 */
- //compute_bits();
+ //compute_bits();
assert (is_power_of_two(nchains));
diff --git a/src/cache.c b/src/cache.c
index 892e3f0f..37d55ab2 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "cache.h"
#include
diff --git a/src/config/module.c b/src/config/module.c
index 1473adba..8b9d13d9 100644
--- a/src/config/module.c
+++ b/src/config/module.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "config/module.h"
#include "config/db.h"
diff --git a/src/connection.c b/src/connection.c
index 1fba1506..f887aee7 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1,4 +1,3 @@
-#undef DEBUG
/**
*
* Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
diff --git a/src/control.c b/src/control.c
index 4aa58632..3dc718a3 100644
--- a/src/control.c
+++ b/src/control.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "control.h"
#include "bstring.h"
#include "task/task.h"
diff --git a/src/dbg.c b/src/dbg.c
index 74633b78..8a7d17ee 100644
--- a/src/dbg.c
+++ b/src/dbg.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "dbg.h"
FILE *LOG_FILE = NULL;
diff --git a/src/dir.c b/src/dir.c
index 2e6dd590..d8bb9a79 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -31,6 +31,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define _FILE_OFFSET_BITS 64
#include
#include
diff --git a/src/filter.c b/src/filter.c
index 5da03851..d087ec4b 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "filter.h"
#include "adt/darray.h"
#include "mem/halloc.h"
diff --git a/src/io.c b/src/io.c
index 25f0dd1d..05095dbf 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#define _XOPEN_SOURCE 500
#define _FILE_OFFSET_BITS 64
diff --git a/src/log.c b/src/log.c
index 0e6641b6..31b10e5e 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "log.h"
#include "dbg.h"
#include "request.h"
diff --git a/src/upload.c b/src/upload.c
index 0fb5fd55..6becd7da 100644
--- a/src/upload.c
+++ b/src/upload.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include "upload.h"
#include "dbg.h"
diff --git a/tools/config_modules/null.c b/tools/config_modules/null.c
index 6fdef0be..c69c910c 100644
--- a/tools/config_modules/null.c
+++ b/tools/config_modules/null.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include
#include
diff --git a/tools/config_modules/zmq.c b/tools/config_modules/zmq.c
index 615465c0..21a4e9f3 100644
--- a/tools/config_modules/zmq.c
+++ b/tools/config_modules/zmq.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include
#include
diff --git a/tools/filters/null.c b/tools/filters/null.c
index 11854987..b99b922f 100644
--- a/tools/filters/null.c
+++ b/tools/filters/null.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include
diff --git a/tools/m2sh/src/ast.c b/tools/m2sh/src/ast.c
index 8c3509da..5eebc884 100644
--- a/tools/m2sh/src/ast.c
+++ b/tools/m2sh/src/ast.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "ast.h"
#include
#include
diff --git a/tools/m2sh/src/cli.c b/tools/m2sh/src/cli.c
index 34512602..da8cfbce 100644
--- a/tools/m2sh/src/cli.c
+++ b/tools/m2sh/src/cli.c
@@ -1,5 +1,39 @@
#line 1 "src/cli.rl"
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
/*
* Parse command line arguments.
@@ -20,11 +54,11 @@
#define TKOPT(C) TKBASE(OPTION, fsm->ts+(C), fsm->te-(C*2))
-#line 42 "src/cli.rl"
+#line 76 "src/cli.rl"
-#line 28 "src/cli.c"
+#line 62 "src/cli.c"
static const int params_start = 4;
static const int params_first_final = 4;
static const int params_error = -1;
@@ -32,7 +66,7 @@ static const int params_error = -1;
static const int params_en_main = 4;
-#line 45 "src/cli.rl"
+#line 79 "src/cli.rl"
void cli_params_init( struct params *fsm )
{
@@ -40,7 +74,7 @@ void cli_params_init( struct params *fsm )
fsm->token_count = 0;
fsm->curtk = 0;
-#line 44 "src/cli.c"
+#line 78 "src/cli.c"
{
fsm->cs = params_start;
fsm->ts = 0;
@@ -48,7 +82,7 @@ void cli_params_init( struct params *fsm )
fsm->act = 0;
}
-#line 52 "src/cli.rl"
+#line 86 "src/cli.rl"
}
void cli_params_execute( struct params *fsm, bstring data)
@@ -59,22 +93,22 @@ void cli_params_execute( struct params *fsm, bstring data)
Token *temp = NULL;
-#line 63 "src/cli.c"
+#line 97 "src/cli.c"
{
if ( p == pe )
goto _test_eof;
switch ( fsm->cs )
{
tr0:
-#line 39 "src/cli.rl"
+#line 73 "src/cli.rl"
{{p = (( fsm->te))-1;}{ TK(BLOB); }}
goto st4;
tr2:
-#line 33 "src/cli.rl"
+#line 67 "src/cli.rl"
{ fsm->te = p+1;{ TKSTR(QSTRING); }}
goto st4;
tr7:
-#line 36 "src/cli.rl"
+#line 70 "src/cli.rl"
{ fsm->te = p+1;}
goto st4;
tr13:
@@ -90,23 +124,23 @@ void cli_params_execute( struct params *fsm, bstring data)
}
goto st4;
tr14:
-#line 39 "src/cli.rl"
+#line 73 "src/cli.rl"
{ fsm->te = p;p--;{ TK(BLOB); }}
goto st4;
tr21:
-#line 32 "src/cli.rl"
+#line 66 "src/cli.rl"
{ fsm->te = p;p--;{ TKOPT(2); }}
goto st4;
tr22:
-#line 31 "src/cli.rl"
+#line 65 "src/cli.rl"
{ fsm->te = p;p--;{ TKOPT(1); }}
goto st4;
tr23:
-#line 35 "src/cli.rl"
+#line 69 "src/cli.rl"
{ fsm->te = p;p--;{ TK(IDENT); }}
goto st4;
tr24:
-#line 34 "src/cli.rl"
+#line 68 "src/cli.rl"
{ fsm->te = p;p--;{ TK(NUMBER); }}
goto st4;
st4:
@@ -117,7 +151,7 @@ void cli_params_execute( struct params *fsm, bstring data)
case 4:
#line 1 "NONE"
{ fsm->ts = p;}
-#line 121 "src/cli.c"
+#line 155 "src/cli.c"
switch( (*p) ) {
case 32: goto tr7;
case 34: goto tr8;
@@ -141,20 +175,20 @@ case 4:
tr6:
#line 1 "NONE"
{ fsm->te = p+1;}
-#line 39 "src/cli.rl"
+#line 73 "src/cli.rl"
{ fsm->act = 7;}
goto st5;
tr15:
#line 1 "NONE"
{ fsm->te = p+1;}
-#line 33 "src/cli.rl"
+#line 67 "src/cli.rl"
{ fsm->act = 3;}
goto st5;
st5:
if ( ++p == pe )
goto _test_eof5;
case 5:
-#line 158 "src/cli.c"
+#line 192 "src/cli.c"
if ( (*p) == 32 )
goto tr13;
if ( 9 <= (*p) && (*p) <= 13 )
@@ -168,7 +202,7 @@ case 5:
if ( ++p == pe )
goto _test_eof6;
case 6:
-#line 172 "src/cli.c"
+#line 206 "src/cli.c"
switch( (*p) ) {
case 32: goto st0;
case 34: goto tr15;
@@ -199,7 +233,7 @@ case 1:
if ( ++p == pe )
goto _test_eof7;
case 7:
-#line 203 "src/cli.c"
+#line 237 "src/cli.c"
if ( (*p) == 32 )
goto st0;
if ( 9 <= (*p) && (*p) <= 13 )
@@ -213,7 +247,7 @@ case 7:
if ( ++p == pe )
goto _test_eof8;
case 8:
-#line 217 "src/cli.c"
+#line 251 "src/cli.c"
switch( (*p) ) {
case 32: goto st2;
case 39: goto tr15;
@@ -244,7 +278,7 @@ case 3:
if ( ++p == pe )
goto _test_eof9;
case 9:
-#line 248 "src/cli.c"
+#line 282 "src/cli.c"
if ( (*p) == 32 )
goto st2;
if ( 9 <= (*p) && (*p) <= 13 )
@@ -404,7 +438,7 @@ case 15:
}
-#line 62 "src/cli.rl"
+#line 96 "src/cli.rl"
}
int cli_params_finish( struct params *fsm )
diff --git a/tools/m2sh/src/cli.rl b/tools/m2sh/src/cli.rl
index 5dcc8666..0eb17d44 100644
--- a/tools/m2sh/src/cli.rl
+++ b/tools/m2sh/src/cli.rl
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
/*
* Parse command line arguments.
diff --git a/tools/m2sh/src/commands.c b/tools/m2sh/src/commands.c
index 2b0d9461..b2279c64 100644
--- a/tools/m2sh/src/commands.c
+++ b/tools/m2sh/src/commands.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "config_file.h"
#include "cli.h"
#include "commands.h"
diff --git a/tools/m2sh/src/config_file.c b/tools/m2sh/src/config_file.c
index a48d4849..60f8b8a8 100644
--- a/tools/m2sh/src/config_file.c
+++ b/tools/m2sh/src/config_file.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include "constants.h"
#include
diff --git a/tools/m2sh/src/constants.c b/tools/m2sh/src/constants.c
index 84f541be..904f7ab7 100644
--- a/tools/m2sh/src/constants.c
+++ b/tools/m2sh/src/constants.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "constants.h"
struct tagbstring CONFIG_SCHEMA = bsStatic(
diff --git a/tools/m2sh/src/lexer.c b/tools/m2sh/src/lexer.c
index 9522a847..20a99f82 100644
--- a/tools/m2sh/src/lexer.c
+++ b/tools/m2sh/src/lexer.c
@@ -1,5 +1,39 @@
#line 1 "src/lexer.rl"
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "config_file.h"
#include "parser.h"
@@ -28,11 +62,11 @@ void Parse(
#define TKSTR(N) TKBASE(N, ts+1, te-3)
-#line 65 "src/lexer.rl"
+#line 99 "src/lexer.rl"
-#line 36 "src/lexer.c"
+#line 70 "src/lexer.c"
static const int m2sh_lexer_start = 8;
static const int m2sh_lexer_first_final = 8;
static const int m2sh_lexer_error = 0;
@@ -40,7 +74,7 @@ static const int m2sh_lexer_error = 0;
static const int m2sh_lexer_en_main = 8;
-#line 68 "src/lexer.rl"
+#line 102 "src/lexer.rl"
void Parse_print_error(const char *message, bstring content, int at, int line_number)
{
@@ -76,7 +110,7 @@ tst_t *Parse_config_string(bstring content)
char *te = NULL;
-#line 80 "src/lexer.c"
+#line 114 "src/lexer.c"
{
cs = m2sh_lexer_start;
ts = 0;
@@ -84,76 +118,76 @@ tst_t *Parse_config_string(bstring content)
act = 0;
}
-#line 103 "src/lexer.rl"
+#line 137 "src/lexer.rl"
-#line 90 "src/lexer.c"
+#line 124 "src/lexer.c"
{
if ( p == pe )
goto _test_eof;
switch ( cs )
{
tr1:
-#line 44 "src/lexer.rl"
+#line 78 "src/lexer.rl"
{te = p+1;{ TKSTR(QSTRING) }}
goto st8;
tr4:
-#line 59 "src/lexer.rl"
+#line 93 "src/lexer.rl"
{te = p+1;}
goto st8;
tr9:
-#line 45 "src/lexer.rl"
+#line 79 "src/lexer.rl"
{te = p+1;{ TKSTR(PATTERN) }}
goto st8;
tr10:
-#line 57 "src/lexer.rl"
+#line 91 "src/lexer.rl"
{te = p+1;}
goto st8;
tr12:
-#line 56 "src/lexer.rl"
+#line 90 "src/lexer.rl"
{te = p+1;{ state.line_number++; }}
goto st8;
tr13:
-#line 51 "src/lexer.rl"
+#line 85 "src/lexer.rl"
{te = p+1;{ TK(LPAREN) }}
goto st8;
tr14:
-#line 52 "src/lexer.rl"
+#line 86 "src/lexer.rl"
{te = p+1;{ TK(RPAREN) }}
goto st8;
tr15:
-#line 53 "src/lexer.rl"
+#line 87 "src/lexer.rl"
{te = p+1;{ TK(COMMA) }}
goto st8;
tr17:
-#line 54 "src/lexer.rl"
+#line 88 "src/lexer.rl"
{te = p+1;{ TK(COLON) }}
goto st8;
tr18:
-#line 46 "src/lexer.rl"
+#line 80 "src/lexer.rl"
{te = p+1;{ TK(EQ) }}
goto st8;
tr20:
-#line 49 "src/lexer.rl"
+#line 83 "src/lexer.rl"
{te = p+1;{ TK(LBRACE) }}
goto st8;
tr21:
-#line 50 "src/lexer.rl"
+#line 84 "src/lexer.rl"
{te = p+1;{ TK(RBRACE) }}
goto st8;
tr23:
-#line 47 "src/lexer.rl"
+#line 81 "src/lexer.rl"
{te = p+1;{ TK(LBRACKET) }}
goto st8;
tr24:
-#line 48 "src/lexer.rl"
+#line 82 "src/lexer.rl"
{te = p+1;{ TK(RBRACKET) }}
goto st8;
tr25:
-#line 61 "src/lexer.rl"
+#line 95 "src/lexer.rl"
{te = p;p--;{ TK(NUMBER) }}
goto st8;
tr26:
-#line 1 "src/lexer.rl"
+#line 1 "NONE"
{ switch( act ) {
case 16:
{{p = ((te))-1;} TK(CLASS) }
@@ -165,18 +199,18 @@ tst_t *Parse_config_string(bstring content)
}
goto st8;
tr28:
-#line 63 "src/lexer.rl"
+#line 97 "src/lexer.rl"
{te = p;p--;{ TK(IDENT) }}
goto st8;
st8:
-#line 1 "src/lexer.rl"
+#line 1 "NONE"
{ts = 0;}
if ( ++p == pe )
goto _test_eof8;
case 8:
-#line 1 "src/lexer.rl"
+#line 1 "NONE"
{ts = p;}
-#line 180 "src/lexer.c"
+#line 214 "src/lexer.c"
switch( (*p) ) {
case 10: goto tr12;
case 32: goto tr10;
@@ -252,22 +286,22 @@ case 9:
goto st9;
goto tr25;
tr19:
-#line 1 "src/lexer.rl"
+#line 1 "NONE"
{te = p+1;}
-#line 63 "src/lexer.rl"
+#line 97 "src/lexer.rl"
{act = 17;}
goto st10;
tr27:
-#line 1 "src/lexer.rl"
+#line 1 "NONE"
{te = p+1;}
-#line 62 "src/lexer.rl"
+#line 96 "src/lexer.rl"
{act = 16;}
goto st10;
st10:
if ( ++p == pe )
goto _test_eof10;
case 10:
-#line 271 "src/lexer.c"
+#line 305 "src/lexer.c"
if ( (*p) == 95 )
goto st11;
if ( (*p) < 65 ) {
@@ -334,23 +368,23 @@ case 7:
_out: {}
}
-#line 104 "src/lexer.rl"
+#line 138 "src/lexer.rl"
if(state.error) {
Parse_print_error("SYNTAX ERROR", content,
(int)(ts - bdata(content)), ++state.line_number);
} else if( cs ==
-#line 345 "src/lexer.c"
+#line 379 "src/lexer.c"
0
-#line 109 "src/lexer.rl"
+#line 143 "src/lexer.rl"
) {
Parse_print_error("INVALID CHARACTER", content,
(int)(ts - bdata(content)), ++state.line_number);
} else if( cs >=
-#line 352 "src/lexer.c"
+#line 386 "src/lexer.c"
8
-#line 112 "src/lexer.rl"
+#line 146 "src/lexer.rl"
) {
Parse(parser, TKEOF, NULL, &state);
} else {
diff --git a/tools/m2sh/src/lexer.rl b/tools/m2sh/src/lexer.rl
index 03c7bf0e..7dd18d08 100644
--- a/tools/m2sh/src/lexer.rl
+++ b/tools/m2sh/src/lexer.rl
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "config_file.h"
#include "parser.h"
diff --git a/tools/m2sh/src/m2sh.c b/tools/m2sh/src/m2sh.c
index 2242bfbc..0432bf45 100644
--- a/tools/m2sh/src/m2sh.c
+++ b/tools/m2sh/src/m2sh.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include
#include
diff --git a/tools/m2sh/src/token.c b/tools/m2sh/src/token.c
index 491c2610..91d99461 100644
--- a/tools/m2sh/src/token.c
+++ b/tools/m2sh/src/token.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include
#include "config_file.h"
diff --git a/tools/m2sh/tests/cli_tests.c b/tools/m2sh/tests/cli_tests.c
index c8a576fe..0282849c 100644
--- a/tools/m2sh/tests/cli_tests.c
+++ b/tools/m2sh/tests/cli_tests.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "minunit.h"
#include "cli.h"
#include
diff --git a/tools/m2sh/tests/parser_tests.c b/tools/m2sh/tests/parser_tests.c
index 09a5fdde..4e3969ab 100644
--- a/tools/m2sh/tests/parser_tests.c
+++ b/tools/m2sh/tests/parser_tests.c
@@ -1,3 +1,37 @@
+/**
+ *
+ * Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the Mongrel2 Project, Zed A. Shaw, nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "minunit.h"
#include "config_file.h"
#include "parser.h"
From ed74c183dac25bdf974774299cd731eddd745f10 Mon Sep 17 00:00:00 2001
From: "Guillermo O. Freschi"
Date: Sun, 12 Jun 2011 20:55:17 -0300
Subject: [PATCH 02/15] Fix to output the request method correctly in the log.
---
src/log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/log.c b/src/log.c
index 31b10e5e..64185af7 100644
--- a/src/log.c
+++ b/src/log.c
@@ -215,7 +215,7 @@ static inline bstring make_log_message(Request *req, const char *remote_addr,
remote_addr,
remote_port,
(int)time(NULL),
- request_method,
+ bdata(request_method),
bdata(Request_path(req)),
Request_is_json(req) ? "" : bdata(req->version),
status,
From 137dbcd5d4e0915a32c95ca40564fb734b93f9d7 Mon Sep 17 00:00:00 2001
From: "Guillermo O. Freschi"
Date: Sun, 12 Jun 2011 23:48:46 -0300
Subject: [PATCH 03/15] Logs are now written in tnetstring format.
---
src/log.c | 48 ++++++++++++++++++++++++++++++++++-------------
src/tnetstrings.c | 28 +++++++++++++++++++++++++++
src/tnetstrings.h | 7 +++++++
3 files changed, 70 insertions(+), 13 deletions(-)
diff --git a/src/log.c b/src/log.c
index 64185af7..1af30fc0 100644
--- a/src/log.c
+++ b/src/log.c
@@ -37,6 +37,7 @@
#include "request.h"
#include "headers.h"
#include "setting.h"
+#include "tnetstrings.h"
#include
#include
#include
@@ -196,12 +197,12 @@ int Log_poison_workers()
return -1;
}
-static inline bstring make_log_message(Request *req, const char *remote_addr,
+static inline bstring make_log_message(Request *req, const char *remote_addr,
int remote_port, int status, int size)
{
bstring request_method = NULL;
- if(Request_is_json(req)) {
+ if (Request_is_json(req)) {
request_method = &JSON_METHOD;
} else if (Request_is_xml(req)) {
request_method = &XML_METHOD;
@@ -209,19 +210,40 @@ static inline bstring make_log_message(Request *req, const char *remote_addr,
request_method = req->request_method;
}
- bstring log_data = bformat("%s,%.*s,%d,%d,%s,%s,%s,%d,%d\n",
- bdata(req->target_host->name),
- IPADDR_SIZE,
- remote_addr,
- remote_port,
- (int)time(NULL),
- bdata(request_method),
- bdata(Request_path(req)),
- Request_is_json(req) ? "" : bdata(req->version),
- status,
- size);
+ tns_outbuf outbuf = {.buffer = NULL};
+ bstring b_temp;
+
+ check(tns_render_log_start(&outbuf), "Could not initialize buffer");
+
+ tns_render_number_prepend(&outbuf, size);
+ tns_render_number_prepend(&outbuf, status);
+
+ b_temp = bfromcstr(Request_is_json(req) ? "" : bdata(req->version));
+ tns_render_string_prepend(&outbuf, b_temp);
+ bdestroy(b_temp);
+
+ tns_render_string_prepend(&outbuf, Request_path(req));
+ tns_render_string_prepend(&outbuf, request_method);
+ tns_render_number_prepend(&outbuf, (int) time(NULL));
+ tns_render_number_prepend(&outbuf, remote_port);
+
+ b_temp = bfromcstr(remote_addr);
+ tns_render_string_prepend(&outbuf, b_temp);
+ bdestroy(b_temp);
+
+ tns_render_string_prepend(&outbuf, req->target_host->name);
+
+ tns_render_log_end(&outbuf);
+
+ // log_data now owns the outbuf buffer
+ bstring log_data = tns_outbuf_to_bstring(&outbuf);
+ bconchar(log_data, '\n');
return log_data;
+
+error:
+
+ return NULL;
}
static void free_log_msg(void *data, void *hint)
diff --git a/src/tnetstrings.c b/src/tnetstrings.c
index 480b5f54..18911d33 100644
--- a/src/tnetstrings.c
+++ b/src/tnetstrings.c
@@ -290,6 +290,18 @@ void tns_render_hash_pair(tns_outbuf *outbuf, bstring key, bstring value)
tns_render_value(&val, outbuf);
}
+void tns_render_number_prepend(tns_outbuf *outbuf, long value)
+{
+ tns_value_t val = {.type = tns_tag_number, .value.number = value};
+ tns_render_value(&val, outbuf);
+}
+
+void tns_render_string_prepend(tns_outbuf *outbuf, bstring value)
+{
+ tns_value_t val = {.type = tns_tag_string, .value.string = value};
+ tns_render_value(&val, outbuf);
+}
+
int tns_render_request_start(tns_outbuf *outbuf)
{
check(tns_outbuf_init(outbuf) != -1, "Failed to init buffer.");
@@ -321,6 +333,22 @@ int tns_render_request_end(tns_outbuf *outbuf, int header_start, bstring uuid, i
return -1;
}
+int tns_render_log_start(tns_outbuf *outbuf)
+{
+ check(tns_outbuf_init(outbuf) != -1, "Failed to init buffer.");
+
+ check(tns_outbuf_putc(outbuf, ']') != -1, "Failed ending request.");
+
+ return outbuf->used_size;
+error:
+ return -1;
+}
+
+void tns_render_log_end(tns_outbuf *outbuf)
+{
+ tns_outbuf_clamp(outbuf, 1);
+}
+
int tns_render_request_headers(tns_outbuf *outbuf, hash_t *headers)
{
hscan_t scan;
diff --git a/src/tnetstrings.h b/src/tnetstrings.h
index 2177137f..ed85c1d5 100644
--- a/src/tnetstrings.h
+++ b/src/tnetstrings.h
@@ -88,6 +88,13 @@ int tns_render_request_start(tns_outbuf *outbuf);
int tns_render_request_end(tns_outbuf *outbuf, int header_start, bstring uuid, int id, bstring path);
+int tns_render_log_start(tns_outbuf *outbuf);
+
+void tns_render_log_end(tns_outbuf *outbuf);
+
+void tns_render_string_prepend(tns_outbuf *outbuf, bstring value);
+void tns_render_number_prepend(tns_outbuf *outbuf, long value);
+
tns_value_t *tns_standard_table(bstring header_data, tns_value_t *rows);
#define tns_get_type(T) (((tns_value_t *)(T)) == NULL ? tns_tag_invalid : ((tns_value_t *)(T))->type)
From c26da18a9ee54c64b7a285bd02044e4e27f7b851 Mon Sep 17 00:00:00 2001
From: "Guillermo O. Freschi"
Date: Mon, 13 Jun 2011 01:48:21 -0300
Subject: [PATCH 04/15] Speedup when rendering numbers in a tnetstring.
Added null terminator sometimes missing when rendering tnetstrings.
---
src/tnetstrings.c | 30 +++++++++++++++++++++++-------
tests/tnetstrings_tests.c | 19 +++++++++++++++++++
2 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/src/tnetstrings.c b/src/tnetstrings.c
index 18911d33..1a7d5229 100644
--- a/src/tnetstrings.c
+++ b/src/tnetstrings.c
@@ -4,6 +4,7 @@
#include
#include "mem/halloc.h"
+#define MAX_NUM_LEN 22 // ceil(log_10 2^64) + 2
static inline int
tns_parse_dict(void *dict, const char *data, size_t len);
@@ -45,20 +46,33 @@ static inline int tns_render_string(void *val, tns_outbuf *outbuf)
return tns_outbuf_rputs(outbuf, bdata(t->value.string), blength(t->value.string));
}
-
static inline int tns_render_number(void *val, tns_outbuf *outbuf)
{
tns_value_t *t = (tns_value_t *)val;
- char out[120] = {0};
-
assert(t->type == tns_tag_number && "Value is not a number.");
- int rc = snprintf(out, 119, "%ld", t->value.number);
- check(rc != -1 && rc <= 119, "Failed to generate number.");
+ long number = t->value.number;
+ int negative = number < 0;
+
+ while (outbuf->alloc_size < outbuf->used_size + MAX_NUM_LEN) {
+ check(tns_outbuf_extend(outbuf) != -1, "Failed to extend buffer.");
+ }
+
+ if (negative) {
+ outbuf->buffer[outbuf->used_size++] = '0' - (number%10);
+ number /= 10;
+ number = -number;
+ }
- out[119] = '\0'; // safety since snprintf might not do this
+ do {
+ outbuf->buffer[outbuf->used_size++] = '0' + (number%10);
+ } while (number /= 10);
- return tns_outbuf_rputs(outbuf, out, rc);
+ if (negative) {
+ outbuf->buffer[outbuf->used_size++] = '-';
+ }
+
+ return 0;
error:
return -1;
@@ -258,6 +272,8 @@ char *tns_render(void *val, size_t *len)
tns_inplace_reverse(output, *len);
+ output[*len] = '\0';
+
return output;
error:
diff --git a/tests/tnetstrings_tests.c b/tests/tnetstrings_tests.c
index ec862409..b828135e 100644
--- a/tests/tnetstrings_tests.c
+++ b/tests/tnetstrings_tests.c
@@ -1,8 +1,26 @@
#include "minunit.h"
#include
#include
+#include
#include
+
+char *test_tnetstring_numbers()
+{
+ char *result;
+ size_t len;
+
+ tns_value_t max = {.type = tns_tag_number, .value.number = LONG_MAX};
+ result = tns_render(&max, &len);
+ mu_assert(len == 23, "Wrong length on LONG_MAX");
+ free(result);
+
+ tns_value_t min = {.type = tns_tag_number, .value.number = LONG_MIN};
+ result = tns_render(&min, &len);
+ mu_assert(len == 24, "Wrong length on LONG_MIN");
+ free(result);
+}
+
char *test_tnetstring_encode()
{
size_t len = 0;
@@ -133,6 +151,7 @@ char * all_tests() {
mu_run_test(test_tnetstring_encode);
mu_run_test(test_tnetstring_decode);
+ mu_run_test(test_tnetstring_numbers);
mu_run_test(test_complex_types);
return NULL;
From 3acfd057199063369e52b12e4846e58df03e16c8 Mon Sep 17 00:00:00 2001
From: "Guillermo O. Freschi"
Date: Mon, 13 Jun 2011 02:13:59 -0300
Subject: [PATCH 05/15] Removed incorrect edge case handling. Disabled handling
of LONG_MIN.
---
src/tnetstrings.c | 4 ++--
tests/tnetstrings_tests.c | 14 +++++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/tnetstrings.c b/src/tnetstrings.c
index 1a7d5229..860edc16 100644
--- a/src/tnetstrings.c
+++ b/src/tnetstrings.c
@@ -54,13 +54,13 @@ static inline int tns_render_number(void *val, tns_outbuf *outbuf)
long number = t->value.number;
int negative = number < 0;
+ assert(number != LONG_MIN && "LONG_MIN cannot be handled");
+
while (outbuf->alloc_size < outbuf->used_size + MAX_NUM_LEN) {
check(tns_outbuf_extend(outbuf) != -1, "Failed to extend buffer.");
}
if (negative) {
- outbuf->buffer[outbuf->used_size++] = '0' - (number%10);
- number /= 10;
number = -number;
}
diff --git a/tests/tnetstrings_tests.c b/tests/tnetstrings_tests.c
index b828135e..3ddd3615 100644
--- a/tests/tnetstrings_tests.c
+++ b/tests/tnetstrings_tests.c
@@ -15,10 +15,18 @@ char *test_tnetstring_numbers()
mu_assert(len == 23, "Wrong length on LONG_MAX");
free(result);
- tns_value_t min = {.type = tns_tag_number, .value.number = LONG_MIN};
- result = tns_render(&min, &len);
- mu_assert(len == 24, "Wrong length on LONG_MIN");
+ // WARNING: LONG_MIN is an edge case
+ //tns_value_t min = {.type = tns_tag_number, .value.number = LONG_MIN};
+ //result = tns_render(&min, &len);
+ //mu_assert(len == 24, "Wrong length on LONG_MIN");
+ //free(result);
+
+ tns_value_t minus_one = {.type = tns_tag_number, .value.number = -1};
+ result = tns_render(&minus_one, &len);
+ mu_assert(len == 5, "Wrong length on -1");
free(result);
+
+ return NULL;
}
char *test_tnetstring_encode()
From c71266e6ce7f1698bd43470c621088bcccc1aa12 Mon Sep 17 00:00:00 2001
From: "Guillermo O. Freschi"
Date: Mon, 13 Jun 2011 03:35:44 -0300
Subject: [PATCH 06/15] m2sh is now able to read tnetstring access logs.
---
tools/m2sh/src/commands.c | 42 +++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/tools/m2sh/src/commands.c b/tools/m2sh/src/commands.c
index b2279c64..0988c4f0 100644
--- a/tools/m2sh/src/commands.c
+++ b/tools/m2sh/src/commands.c
@@ -300,6 +300,46 @@ static int Command_hosts(Command *cmd)
}
+static int Command_access_logs(Command *cmd)
+{
+ bstring log_filename = option(cmd, "log", "logs/access.log");
+
+ FILE *log_file = fopen(bdata(log_filename), "r");
+
+ bstring line;
+ while (line = bgets((bNgetc) fgetc, log_file, '\n')) {
+ tns_value_t *log_item = tns_parse(bdata(line), blength(line), NULL);
+
+ assert(log_item.type == tns_tag_list && "Malformed log line.");
+
+ darray_t *entries = log_item->value.list;
+
+ bstring hostname = ((tns_value_t *)darray_get(entries, 0))->value.string;
+ bstring remote_addr = ((tns_value_t *)darray_get(entries, 1))->value.string;
+ long remote_port = ((tns_value_t *)darray_get(entries, 2))->value.number;
+ long timestamp = ((tns_value_t *)darray_get(entries, 3))->value.string;
+ bstring request_method = ((tns_value_t *)darray_get(entries, 4))->value.string;
+ bstring request_path = ((tns_value_t *)darray_get(entries, 5))->value.string;
+ bstring version = ((tns_value_t *)darray_get(entries, 6))->value.string;
+ long status = ((tns_value_t *)darray_get(entries, 7))->value.number;
+ long size = ((tns_value_t *)darray_get(entries, 8))->value.number;
+
+ printf("[%ld] %s:%ld %s %s %s%s %ld %ld\n",
+ timestamp,
+ bdata(remote_addr),
+ remote_port,
+ bdata(version),
+ bdata(request_method),
+ bdata(hostname),
+ bdata(request_path),
+ status,
+ size);
+ }
+
+ return 0;
+}
+
+
static int Command_routes(Command *cmd)
{
bstring db_file = option(cmd, "db", "config.sqlite");
@@ -912,6 +952,8 @@ static CommandHandler COMMAND_MAPPING[] = {
.help = "Alias for load." },
{.name = "shell", .cb = Command_shell,
.help = "Starts an interactive shell." },
+ {.name = "access", .cb = Command_access_logs,
+ .help = "Prints the access log."},
{.name = "servers", .cb = Command_servers,
.help = "Lists the servers in a config database." },
{.name = "hosts", .cb = Command_hosts,
From da4990887910558250e2ec9138432eaa6074033a Mon Sep 17 00:00:00 2001
From: "Zed A. Shaw"
Date: Mon, 13 Jun 2011 00:34:07 -0700
Subject: [PATCH 07/15] Fix a buffer overflow when the buffer is the exact
size.
---
src/tnetstrings.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/tnetstrings.c b/src/tnetstrings.c
index 860edc16..9854d056 100644
--- a/src/tnetstrings.c
+++ b/src/tnetstrings.c
@@ -271,7 +271,6 @@ char *tns_render(void *val, size_t *len)
check(output != NULL, "Failed to render tnetstring.");
tns_inplace_reverse(output, *len);
-
output[*len] = '\0';
return output;
@@ -413,6 +412,12 @@ char *tns_render_reversed(void *val, size_t *len)
check(tns_render_value(val, &outbuf) != -1, "Failed to render value.");
*len = outbuf.used_size;
+ if(outbuf.used_size == outbuf.alloc_size) {
+ // need to extend it just a bit for the \0 terminator
+ outbuf.buffer = realloc(outbuf.buffer, outbuf.used_size + 1);
+ check_mem(outbuf.buffer);
+ }
+
return outbuf.buffer;
error:
From a47d7601be0c1e28e1cf3d29e99f429bae8bc1ab Mon Sep 17 00:00:00 2001
From: "Guillermo O. Freschi"
Date: Wed, 15 Jun 2011 03:50:20 -0300
Subject: [PATCH 08/15] Do not quit on error; print message and skip line.
---
tools/m2sh/src/commands.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/tools/m2sh/src/commands.c b/tools/m2sh/src/commands.c
index 0988c4f0..be3d28ee 100644
--- a/tools/m2sh/src/commands.c
+++ b/tools/m2sh/src/commands.c
@@ -305,12 +305,18 @@ static int Command_access_logs(Command *cmd)
bstring log_filename = option(cmd, "log", "logs/access.log");
FILE *log_file = fopen(bdata(log_filename), "r");
-
+ int line_number = 0;
bstring line;
- while (line = bgets((bNgetc) fgetc, log_file, '\n')) {
+
+ while ((line = bgets((bNgetc) fgetc, log_file, '\n')) != NULL) {
+ line_number++;
+
tns_value_t *log_item = tns_parse(bdata(line), blength(line), NULL);
- assert(log_item.type == tns_tag_list && "Malformed log line.");
+ if (!log_item || log_item->type != tns_tag_list) {
+ fprintf(stderr, "Malformed log line: %d.\n", line_number);
+ continue;
+ }
darray_t *entries = log_item->value.list;
@@ -334,6 +340,8 @@ static int Command_access_logs(Command *cmd)
bdata(request_path),
status,
size);
+
+ tns_value_destroy(log_item);
}
return 0;
From b08288fc213aa29b0095e03a9870f74aebefc9cd Mon Sep 17 00:00:00 2001
From: "Guillermo O. Freschi"
Date: Wed, 15 Jun 2011 03:51:33 -0300
Subject: [PATCH 09/15] Toying with log formatting.
---
tools/m2sh/src/commands.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/m2sh/src/commands.c b/tools/m2sh/src/commands.c
index be3d28ee..0bacc2c0 100644
--- a/tools/m2sh/src/commands.c
+++ b/tools/m2sh/src/commands.c
@@ -330,14 +330,14 @@ static int Command_access_logs(Command *cmd)
long status = ((tns_value_t *)darray_get(entries, 7))->value.number;
long size = ((tns_value_t *)darray_get(entries, 8))->value.number;
- printf("[%ld] %s:%ld %s %s %s%s %ld %ld\n",
+ printf("[%ld] %s:%ld %s \"%s %s %s\" %ld %ld\n",
timestamp,
bdata(remote_addr),
remote_port,
- bdata(version),
- bdata(request_method),
bdata(hostname),
+ bdata(request_method),
bdata(request_path),
+ bdata(version),
status,
size);
From 645aabd88297bb2d5d8e9290a37465e286945f38 Mon Sep 17 00:00:00 2001
From: "Zed A. Shaw"
Date: Wed, 15 Jun 2011 11:35:09 -0700
Subject: [PATCH 10/15] Have reload copy handlers over from the previous server
config if they haven't changed. Debugging output on temporarily.
---
src/connection.c | 2 +-
src/handler.c | 13 +++++++---
src/mongrel2.c | 19 +++++++-------
src/server.c | 67 +++++++++++++++++++++++++++++++++++++++++++-----
src/server.h | 2 +-
src/task/task.c | 1 +
6 files changed, 83 insertions(+), 21 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index f887aee7..54318042 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -625,7 +625,7 @@ void Connection_task(void *v)
error: // fallthrough
State_exec(&conn->state, CLOSE, (void *)conn);
Connection_destroy(conn);
- return;
+ taskexit(0);
}
int Connection_deliver_raw(Connection *conn, bstring buf)
diff --git a/src/handler.c b/src/handler.c
index 74f5ceb4..4f880320 100644
--- a/src/handler.c
+++ b/src/handler.c
@@ -1,3 +1,5 @@
+#undef NDEBUG
+
/**
*
* Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
@@ -178,7 +180,7 @@ static inline int handler_recv_parse(Handler *handler, HandlerParser *parser)
rc = mqrecv(handler->recv_socket, inmsg, 0);
check(rc == 0, "Receive on handler socket failed.");
- check(handler->running, "Received shutdown notification, goodbye.");
+ check(handler->running, "Handler marked as not running.");
rc = HandlerParser_execute(parser, zmq_msg_data(inmsg), zmq_msg_size(inmsg));
check(rc == 1, "Failed to parse message from handler.");
@@ -236,13 +238,18 @@ void Handler_task(void *v)
HandlerParser_reset(parser);
}
+ debug("############################### HANDLER EXITED: %p, running: %d, task: %p",
+ handler, handler->running, handler->task);
+ handler->running = 0;
+ handler->task = NULL;
HandlerParser_destroy(parser);
- debug("HANDLER EXITED.");
taskexit(0);
error:
+ handler->running = 0;
+ handler->task = NULL;
HandlerParser_destroy(parser);
- log_err("HANDLER TASK DIED");
+ log_err("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! HANDLER TASK DIED");
taskexit(1);
}
diff --git a/src/mongrel2.c b/src/mongrel2.c
index 5e8800ad..746ae969 100644
--- a/src/mongrel2.c
+++ b/src/mongrel2.c
@@ -112,7 +112,7 @@ void start_terminator()
}
-Server *load_server(const char *db_file, const char *server_uuid, int reuse_fd)
+Server *load_server(const char *db_file, const char *server_uuid, Server *old_srv)
{
int rc = 0;
Server *srv = NULL;
@@ -130,17 +130,17 @@ Server *load_server(const char *db_file, const char *server_uuid, int reuse_fd)
check(srv, "Failed to load server %s from %s", server_uuid, db_file);
check(srv->default_host, "No default_host set for server: %s, you need one host named: %s", server_uuid, bdata(srv->default_hostname));
- if(reuse_fd == -1) {
+ if(old_srv == NULL || old_srv->listen_fd == -1) {
srv->listen_fd = netannounce(TCP, bdata(srv->bind_addr), srv->port);
check(srv->listen_fd >= 0, "Can't announce on TCP port %d", srv->port);
check(fdnoblock(srv->listen_fd) == 0, "Failed to set listening port %d nonblocking.", srv->port);
} else {
- srv->listen_fd = dup(reuse_fd);
+ srv->listen_fd = dup(old_srv->listen_fd);
check(srv->listen_fd != -1, "Failed to dup the socket from the running server.");
- fdclose(reuse_fd);
+ fdclose(old_srv->listen_fd);
}
- check(Server_start_handlers(srv) == 0, "Failed to start handlers.");
+ check(Server_start_handlers(srv, old_srv) == 0, "Failed to start handlers.");
Config_close_db();
return srv;
@@ -253,14 +253,15 @@ Server *reload_server(Server *old_srv, const char *db_file, const char *server_u
{
RUNNING = 1;
- Server_stop_handlers(old_srv);
-
+ log_info("------------------------ RELOAD %s -----------------------------------", server_uuid);
MIME_destroy();
Setting_destroy();
- Server *srv = load_server(db_file, server_uuid, old_srv->listen_fd);
+ Server *srv = load_server(db_file, server_uuid, old_srv);
check(srv != NULL, "Failed to load new server config.");
+ Server_stop_handlers(old_srv);
+
RELOAD = 0;
return srv;
@@ -322,7 +323,7 @@ void taskmain(int argc, char **argv)
check(rc != -1, "Failed to load the config module: %s", argv[3]);
}
- SERVER = load_server(argv[1], argv[2], -1);
+ SERVER = load_server(argv[1], argv[2], NULL);
check(SERVER, "Aborting since can't load server.");
SuperPoll_get_max_fd();
diff --git a/src/server.c b/src/server.c
index 27fba22e..0f83cbb7 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1,3 +1,4 @@
+#undef NDEBUG
/**
*
* Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
@@ -339,11 +340,57 @@ Host *Server_match_backend(Server *srv, bstring target)
return NULL;
}
-int Server_start_handlers(Server *srv)
+static inline int Server_copy_active_handlers(Server *srv, Server *copy_from)
+{
+ debug("Copying handlers from %p to %p.", copy_from, srv);
+ int i = 0;
+
+ for(i = 0; i < darray_end(copy_from->handlers); i++) {
+ Handler *from = darray_get(copy_from->handlers, i);
+
+ int j = 0;
+ for(j = 0; j < darray_end(srv->handlers); j++) {
+ Handler *to = darray_get(srv->handlers, j);
+
+ debug("Comparing %s=%s, %s=%s, %s=%s, %s=%s",
+ bdata(from->send_ident),
+ bdata(to->send_ident),
+ bdata(from->recv_ident),
+ bdata(to->recv_ident),
+ bdata(from->recv_spec),
+ bdata(to->recv_spec),
+ bdata(from->send_spec),
+ bdata(to->send_spec));
+
+ if(biseq(from->send_ident, to->send_ident) &&
+ biseq(from->recv_ident, to->recv_ident) &&
+ biseq(from->recv_spec, to->recv_spec) &&
+ biseq(from->send_spec, to->send_spec)
+ )
+ {
+ debug("Handler is the same, copying over: %p to %p", from, to);
+ darray_set(srv->handlers, j, from);
+ // swap them around so that the darrays stay full
+ darray_set(copy_from->handlers, i, to);
+ to->running = 0;
+ break;
+ }
+ }
+ }
+
+ return 0;
+}
+
+int Server_start_handlers(Server *srv, Server *copy_from)
{
int i = 0;
int rc = 0;
+ if(copy_from != NULL) {
+ rc = Server_copy_active_handlers(srv, copy_from);
+ check(rc != -1, "Failed to copy old handlers to new server config.");
+ }
+
for(i = 0; i < darray_end(srv->handlers); i++) {
Handler *handler = darray_get(srv->handlers, i);
check(handler != NULL, "Invalid handler, can't be NULL.");
@@ -369,15 +416,21 @@ int Server_stop_handlers(Server *srv)
Handler *handler = darray_get(srv->handlers, i);
check(handler != NULL, "Invalid handler, can't be NULL.");
+ debug("############################### HANDLER SHUTDOWN: %p, running: %d, task: %p",
+ handler, handler->running, handler->task);
if(handler->running) {
log_info("STOPPING HANDLER %s", bdata(handler->send_spec));
- tasksignal(handler->task, SIGINT);
- handler->running = 0;
- taskdelay(1);
-
- if(handler->recv_socket) zmq_close(handler->recv_socket);
- if(handler->send_socket) zmq_close(handler->send_socket);
+ if(handler->task != NULL) {
+ tasksignal(handler->task, SIGINT);
+ handler->running = 0;
+ taskdelay(1);
+ }
}
+
+ if(handler->recv_socket) zmq_close(handler->recv_socket);
+ if(handler->send_socket) zmq_close(handler->send_socket);
+ handler->recv_socket = NULL;
+ handler->send_socket = NULL;
}
return 0;
diff --git a/src/server.h b/src/server.h
index 0b66e8f8..ce88cc81 100644
--- a/src/server.h
+++ b/src/server.h
@@ -85,7 +85,7 @@ void Server_set_default_host(Server *srv, Host *host);
Host *Server_match_backend(Server *srv, bstring target);
-int Server_start_handlers(Server *srv);
+int Server_start_handlers(Server *srv, Server *copy_from);
int Server_stop_handlers(Server *srv);
diff --git a/src/task/task.c b/src/task/task.c
index 62a4176e..3d19dddf 100644
--- a/src/task/task.c
+++ b/src/task/task.c
@@ -224,6 +224,7 @@ static void taskscheduler(void)
i = t->alltaskslot;
alltask[i] = alltask[--nalltask];
alltask[i]->alltaskslot = i;
+ debug("FREEING TASK: %p", t);
free(t);
}
}
From f17d251a33c35ff66efcb7377f7715554dbed044 Mon Sep 17 00:00:00 2001
From: "Zed A. Shaw"
Date: Wed, 15 Jun 2011 23:47:39 -0700
Subject: [PATCH 11/15] Update the routes with copied handlers as well.
---
src/connection.c | 3 +--
src/server.c | 54 ++++++++++++++++++++++++++++++++----------------
2 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index 54318042..12365133 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -189,13 +189,12 @@ int Connection_send_to_handler(Connection *conn, Handler *handler, char *body, i
}
debug("SENT: %s", bdata(payload));
-
check(payload, "Failed to create payload for request.");
debug("HTTP TO HANDLER: %.*s", blength(payload) - content_len, bdata(payload));
rc = Handler_deliver(handler->send_socket, bdata(payload), blength(payload));
- free(payload);
+ free(payload); payload = NULL;
error_unless(rc != -1, conn, 502, "Failed to deliver to handler: %s",
bdata(Request_path(conn->req)));
diff --git a/src/server.c b/src/server.c
index 0f83cbb7..1cc219b3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -340,11 +340,40 @@ Host *Server_match_backend(Server *srv, bstring target)
return NULL;
}
+static inline int same_handler(Handler *from, Handler *to)
+{
+ return biseq(from->send_ident, to->send_ident) &&
+ biseq(from->recv_ident, to->recv_ident) &&
+ biseq(from->recv_spec, to->recv_spec) &&
+ biseq(from->send_spec, to->send_spec);
+}
+
+typedef struct RouteUpdater {
+ Handler *original;
+ Handler *replacement;
+} RouteUpdater;
+
+static void update_routes(void *value, void *data)
+{
+ RouteUpdater *update = data;
+ Backend *backend = ((Route *)value)->data;
+
+ if(backend->type == BACKEND_HANDLER && backend->target.handler == update->original) {
+ debug("Found backend that needs replacing: %p replaced with %p",
+ update->original, update->replacement);
+ backend->target.handler = update->replacement;
+ }
+}
+
+static void update_host_routes(void *value, void *data)
+{
+ Host *host = ((Route *)value)->data;
+ tst_traverse(host->routes->routes, update_routes, data);
+}
+
static inline int Server_copy_active_handlers(Server *srv, Server *copy_from)
{
- debug("Copying handlers from %p to %p.", copy_from, srv);
int i = 0;
-
for(i = 0; i < darray_end(copy_from->handlers); i++) {
Handler *from = darray_get(copy_from->handlers, i);
@@ -352,23 +381,12 @@ static inline int Server_copy_active_handlers(Server *srv, Server *copy_from)
for(j = 0; j < darray_end(srv->handlers); j++) {
Handler *to = darray_get(srv->handlers, j);
- debug("Comparing %s=%s, %s=%s, %s=%s, %s=%s",
- bdata(from->send_ident),
- bdata(to->send_ident),
- bdata(from->recv_ident),
- bdata(to->recv_ident),
- bdata(from->recv_spec),
- bdata(to->recv_spec),
- bdata(from->send_spec),
- bdata(to->send_spec));
-
- if(biseq(from->send_ident, to->send_ident) &&
- biseq(from->recv_ident, to->recv_ident) &&
- biseq(from->recv_spec, to->recv_spec) &&
- biseq(from->send_spec, to->send_spec)
- )
+ if(same_handler(from, to))
{
- debug("Handler is the same, copying over: %p to %p", from, to);
+ debug("Swapping %p original for %p replacement", to, from);
+ RouteUpdater update = {.original = to, .replacement = from};
+ tst_traverse(srv->hosts->routes, update_host_routes, &update);
+
darray_set(srv->handlers, j, from);
// swap them around so that the darrays stay full
darray_set(copy_from->handlers, i, to);
From 09d8dd1fa8617601d04491e63dadb0b606d0f868 Mon Sep 17 00:00:00 2001
From: Duane Griffin
Date: Sat, 18 Jun 2011 12:29:51 +0100
Subject: [PATCH 12/15] Add explicit dependency on libm2 to each test that
needs it.
Without this a -j4 build reliably fails on my machine.
---
Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index bfcdc410..49d42e99 100644
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,7 @@ pristine: clean
${MAKE} -C tools/m2sh pristine
.PHONY: tests
-tests: build/libm2.a tests/config.sqlite ${TESTS} test_filters filters config_modules
+tests: tests/config.sqlite ${TESTS} test_filters filters config_modules
sh ./tests/runtests.sh
tests/config.sqlite: src/config/config.sql src/config/example.sql src/config/mimetypes.sql
@@ -84,13 +84,13 @@ check:
m2sh:
${MAKE} ${MAKEOPTS} -C tools/m2sh all
-test_filters:
+test_filters: build/libm2.a
${MAKE} ${MAKEOPTS} -C tests/filters all
-filters:
+filters: build/libm2.a
${MAKE} ${MAKEOPTS} -C tools/filters all
-config_modules:
+config_modules: build/libm2.a
${MAKE} ${MAKEOPTS} -C tools/config_modules all
install: all
From 8944853bfc9d093f5daacd883cc9ea44132ccad9 Mon Sep 17 00:00:00 2001
From: "Zed A. Shaw"
Date: Sat, 18 Jun 2011 15:59:08 -0700
Subject: [PATCH 13/15] Use CFLAGS instead of OPTFLAGS for the -fPIC build.
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index bfcdc410..2848febb 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ ${OBJECTS_NOEXT}: CFLAGS += ${NOEXTCFLAGS}
bin/mongrel2: build/libm2.a src/mongrel2.o
$(CC) $(CFLAGS) src/mongrel2.o -o $@ $< $(LIBS)
-build/libm2.a: OPTFLAGS += -fPIC
+build/libm2.a: CFLAGS += -fPIC
build/libm2.a: build ${LIB_OBJ}
ar rcs $@ ${LIB_OBJ}
ranlib $@
From 78331f74c30596cd6e48f76f3455941f6f6c5b2c Mon Sep 17 00:00:00 2001
From: Juba Borgohain
Date: Sat, 18 Jun 2011 18:11:17 -0500
Subject: [PATCH 14/15] Display a hint to the user that they may be missing a
')' in their config file if there is a syntax error when the end of file is
reached.
---
tools/m2sh/src/parser.c | 109 +++++++++++++++++++++-------------------
tools/m2sh/src/parser.y | 3 ++
2 files changed, 59 insertions(+), 53 deletions(-)
diff --git a/tools/m2sh/src/parser.c b/tools/m2sh/src/parser.c
index c7be2206..c584eaa4 100644
--- a/tools/m2sh/src/parser.c
+++ b/tools/m2sh/src/parser.c
@@ -157,40 +157,40 @@ static const YYMINORTYPE yyzerominor = { 0 };
** yy_default[] Default action for each state.
*/
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 20, 21, 22, 26, 14, 15, 37, 18, 3, 12,
- /* 10 */ 31, 13, 20, 21, 22, 26, 30, 15, 67, 7,
- /* 20 */ 39, 12, 34, 13, 38, 23, 24, 25, 1, 27,
- /* 30 */ 23, 24, 25, 32, 23, 24, 25, 6, 35, 23,
- /* 40 */ 24, 25, 36, 23, 24, 25, 16, 17, 40, 19,
- /* 50 */ 29, 14, 8, 14, 9, 28, 10, 2, 33, 16,
- /* 60 */ 17, 11, 4, 68, 5,
+ /* 0 */ 26, 27, 28, 32, 15, 14, 6, 1, 3, 13,
+ /* 10 */ 37, 12, 26, 27, 28, 32, 11, 14, 67, 7,
+ /* 20 */ 23, 13, 4, 12, 33, 29, 30, 31, 5, 19,
+ /* 30 */ 29, 30, 31, 16, 17, 20, 29, 30, 31, 40,
+ /* 40 */ 25, 9, 16, 17, 15, 39, 22, 29, 30, 31,
+ /* 50 */ 38, 29, 30, 31, 15, 21, 2, 24, 34, 10,
+ /* 60 */ 18, 36, 35, 68, 68, 68, 68, 68, 8,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 2, 3, 4, 5, 5, 7, 27, 19, 10, 11,
- /* 10 */ 12, 13, 2, 3, 4, 5, 19, 7, 17, 18,
- /* 20 */ 19, 11, 27, 13, 20, 21, 22, 23, 25, 20,
- /* 30 */ 21, 22, 23, 20, 21, 22, 23, 26, 20, 21,
- /* 40 */ 22, 23, 20, 21, 22, 23, 2, 3, 0, 1,
- /* 50 */ 19, 5, 24, 5, 10, 9, 10, 6, 14, 2,
- /* 60 */ 3, 8, 15, 28, 15,
+ /* 0 */ 2, 3, 4, 5, 5, 7, 26, 25, 10, 11,
+ /* 10 */ 12, 13, 2, 3, 4, 5, 8, 7, 17, 18,
+ /* 20 */ 19, 11, 6, 13, 20, 21, 22, 23, 15, 20,
+ /* 30 */ 21, 22, 23, 2, 3, 20, 21, 22, 23, 0,
+ /* 40 */ 1, 10, 2, 3, 5, 14, 20, 21, 22, 23,
+ /* 50 */ 20, 21, 22, 23, 5, 27, 15, 19, 9, 10,
+ /* 60 */ 27, 19, 19, 28, 28, 28, 28, 28, 24,
};
#define YY_SHIFT_USE_DFLT (-3)
#define YY_SHIFT_MAX 17
static const signed char yy_shift_ofst[] = {
- /* 0 */ -1, -2, 10, 10, 10, 10, 44, 48, 46, 57,
- /* 10 */ -1, -3, -3, -3, 51, 53, 47, 49,
+ /* 0 */ -1, -2, 10, 10, 10, 10, 31, 39, 49, 40,
+ /* 10 */ -1, -3, -3, -3, 8, 16, 13, 41,
};
-#define YY_REDUCE_USE_DFLT (-22)
+#define YY_REDUCE_USE_DFLT (-21)
#define YY_REDUCE_MAX 13
static const signed char yy_reduce_ofst[] = {
- /* 0 */ 1, 4, 9, 13, 18, 22, -21, -12, -3, -5,
- /* 10 */ 31, 28, 3, 11,
+ /* 0 */ 1, 26, 15, 30, 4, 9, 28, 38, 42, 33,
+ /* 10 */ 43, 44, -20, -18,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- /* 10 */ 66, 55, 59, 63, 66, 66, 66, 66, 41, 43,
- /* 20 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 30 */ 54, 56, 57, 60, 61, 64, 65, 62, 58, 42,
+ /* 10 */ 66, 55, 63, 59, 66, 66, 66, 66, 61, 64,
+ /* 20 */ 65, 62, 58, 42, 41, 43, 44, 45, 46, 47,
+ /* 30 */ 48, 49, 50, 51, 52, 53, 54, 56, 57, 60,
};
#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
@@ -419,28 +419,28 @@ static void yy_destructor(
case 14: /* RBRACKET */
case 15: /* COLON */
{
-#line 26 "src/parser.y"
+#line 29 "src/parser.y"
Token_destroy((yypminor->yy0));
#line 425 "src/parser.c"
}
break;
case 19: /* assignment */
{
-#line 55 "src/parser.y"
+#line 58 "src/parser.y"
free((yypminor->yy35));
#line 432 "src/parser.c"
}
break;
case 24: /* parameters */
{
-#line 66 "src/parser.y"
+#line 69 "src/parser.y"
AST_destroy((yypminor->yy9));
#line 439 "src/parser.c"
}
break;
case 27: /* hash_pair */
{
-#line 106 "src/parser.y"
+#line 109 "src/parser.y"
free((yypminor->yy27));
#line 446 "src/parser.c"
}
@@ -615,7 +615,7 @@ static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){
while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser);
/* Here code is inserted which will execute if the parser
** stack every overflows */
-#line 22 "src/parser.y"
+#line 25 "src/parser.y"
log_err("There was a stack overflow at line: %d", state->line_number);
#line 622 "src/parser.c"
@@ -756,67 +756,67 @@ static void yy_reduce(
** break;
*/
case 0: /* config ::= vars */
-#line 28 "src/parser.y"
+#line 31 "src/parser.y"
{ state->settings = yymsp[0].minor.yy9; }
#line 762 "src/parser.c"
break;
case 1: /* vars ::= vars assignment */
-#line 32 "src/parser.y"
+#line 35 "src/parser.y"
{
yygotominor.yy9 = tst_insert(yymsp[-1].minor.yy9, bdata(yymsp[0].minor.yy35->key->data), blength(yymsp[0].minor.yy35->key->data), yymsp[0].minor.yy35);
}
#line 769 "src/parser.c"
break;
case 2: /* vars ::= assignment */
-#line 37 "src/parser.y"
+#line 40 "src/parser.y"
{
yygotominor.yy9 = tst_insert(yygotominor.yy9, bdata(yymsp[0].minor.yy35->key->data), blength(yymsp[0].minor.yy35->key->data), yymsp[0].minor.yy35);
}
#line 776 "src/parser.c"
break;
case 3: /* vars ::= vars EOF */
-#line 41 "src/parser.y"
+#line 44 "src/parser.y"
{ yygotominor.yy9 = yymsp[-1].minor.yy9; yy_destructor(yypParser,1,&yymsp[0].minor);
}
#line 782 "src/parser.c"
break;
case 4: /* expr ::= QSTRING */
-#line 45 "src/parser.y"
+#line 48 "src/parser.y"
{ yygotominor.yy48 = Value_create(VAL_QSTRING, yymsp[0].minor.yy0); }
#line 787 "src/parser.c"
break;
case 5: /* expr ::= PATTERN */
-#line 46 "src/parser.y"
+#line 49 "src/parser.y"
{ yygotominor.yy48 = Value_create(VAL_PATTERN, yymsp[0].minor.yy0); }
#line 792 "src/parser.c"
break;
case 6: /* expr ::= NUMBER */
-#line 47 "src/parser.y"
+#line 50 "src/parser.y"
{ yygotominor.yy48 = Value_create(VAL_NUMBER, yymsp[0].minor.yy0); }
#line 797 "src/parser.c"
break;
case 7: /* expr ::= class */
-#line 48 "src/parser.y"
+#line 51 "src/parser.y"
{ yygotominor.yy48 = Value_create(VAL_CLASS, yymsp[0].minor.yy29); }
#line 802 "src/parser.c"
break;
case 8: /* expr ::= list */
-#line 49 "src/parser.y"
+#line 52 "src/parser.y"
{ yygotominor.yy48 = Value_create(VAL_LIST, yymsp[0].minor.yy18); }
#line 807 "src/parser.c"
break;
case 9: /* expr ::= hash */
-#line 50 "src/parser.y"
+#line 53 "src/parser.y"
{ yygotominor.yy48 = Value_create(VAL_HASH, yymsp[0].minor.yy9); }
#line 812 "src/parser.c"
break;
case 10: /* expr ::= IDENT */
-#line 51 "src/parser.y"
+#line 54 "src/parser.y"
{ yygotominor.yy48 = Value_create(VAL_REF, yymsp[0].minor.yy0); }
#line 817 "src/parser.c"
break;
case 11: /* assignment ::= IDENT EQ expr */
-#line 56 "src/parser.y"
+#line 59 "src/parser.y"
{
yygotominor.yy35 = malloc(sizeof(Pair)); yygotominor.yy35->key = yymsp[-2].minor.yy0; yygotominor.yy35->value = yymsp[0].minor.yy48;
yy_destructor(yypParser,6,&yymsp[-1].minor);
@@ -824,72 +824,72 @@ static void yy_reduce(
#line 825 "src/parser.c"
break;
case 12: /* class ::= CLASS LPAREN parameters RPAREN */
-#line 63 "src/parser.y"
+#line 66 "src/parser.y"
{ yygotominor.yy29 = calloc(sizeof(Class), 1); yygotominor.yy29->id = -1; yygotominor.yy29->ident = yymsp[-3].minor.yy0; yygotominor.yy29->params = yymsp[-1].minor.yy9; yy_destructor(yypParser,8,&yymsp[-2].minor);
yy_destructor(yypParser,9,&yymsp[0].minor);
}
#line 832 "src/parser.c"
break;
case 13: /* parameters ::= parameters COMMA assignment */
-#line 68 "src/parser.y"
+#line 71 "src/parser.y"
{ yygotominor.yy9 = tst_insert(yymsp[-2].minor.yy9, bdata(yymsp[0].minor.yy35->key->data), blength(yymsp[0].minor.yy35->key->data), yymsp[0].minor.yy35); yy_destructor(yypParser,10,&yymsp[-1].minor);
}
#line 838 "src/parser.c"
break;
case 14: /* parameters ::= parameters assignment */
-#line 71 "src/parser.y"
+#line 74 "src/parser.y"
{ yygotominor.yy9 = tst_insert(yymsp[-1].minor.yy9, bdata(yymsp[0].minor.yy35->key->data), blength(yymsp[0].minor.yy35->key->data), yymsp[0].minor.yy35); }
#line 843 "src/parser.c"
break;
case 15: /* parameters ::= */
case 23: /* hash_elements ::= */ yytestcase(yyruleno==23);
-#line 74 "src/parser.y"
+#line 77 "src/parser.y"
{ yygotominor.yy9 = NULL; }
#line 849 "src/parser.c"
break;
case 16: /* list ::= LBRACE list_elements RBRACE */
-#line 78 "src/parser.y"
+#line 81 "src/parser.y"
{ yygotominor.yy18 = yymsp[-1].minor.yy18; yy_destructor(yypParser,11,&yymsp[-2].minor);
yy_destructor(yypParser,12,&yymsp[0].minor);
}
#line 856 "src/parser.c"
break;
case 17: /* list_elements ::= list_elements COMMA expr */
-#line 82 "src/parser.y"
+#line 85 "src/parser.y"
{ yygotominor.yy18 = yymsp[-2].minor.yy18; list_append(yygotominor.yy18, lnode_create(yymsp[0].minor.yy48)); yy_destructor(yypParser,10,&yymsp[-1].minor);
}
#line 862 "src/parser.c"
break;
case 18: /* list_elements ::= list_elements expr */
-#line 85 "src/parser.y"
+#line 88 "src/parser.y"
{ yygotominor.yy18 = yymsp[-1].minor.yy18; list_append(yygotominor.yy18, lnode_create(yymsp[0].minor.yy48)); }
#line 867 "src/parser.c"
break;
case 19: /* list_elements ::= */
-#line 88 "src/parser.y"
+#line 91 "src/parser.y"
{ yygotominor.yy18 = list_create(LISTCOUNT_T_MAX); }
#line 872 "src/parser.c"
break;
case 20: /* hash ::= LBRACKET hash_elements RBRACKET */
-#line 92 "src/parser.y"
+#line 95 "src/parser.y"
{ yygotominor.yy9 = yymsp[-1].minor.yy9; yy_destructor(yypParser,13,&yymsp[-2].minor);
yy_destructor(yypParser,14,&yymsp[0].minor);
}
#line 879 "src/parser.c"
break;
case 21: /* hash_elements ::= hash_elements COMMA hash_pair */
-#line 96 "src/parser.y"
+#line 99 "src/parser.y"
{ yygotominor.yy9 = tst_insert(yymsp[-2].minor.yy9, bdata(yymsp[0].minor.yy27->key->data), blength(yymsp[0].minor.yy27->key->data), yymsp[0].minor.yy27); yy_destructor(yypParser,10,&yymsp[-1].minor);
}
#line 885 "src/parser.c"
break;
case 22: /* hash_elements ::= hash_elements hash_pair */
-#line 99 "src/parser.y"
+#line 102 "src/parser.y"
{ yygotominor.yy9 = tst_insert(yymsp[-1].minor.yy9, bdata(yymsp[0].minor.yy27->key->data), blength(yymsp[0].minor.yy27->key->data), yymsp[0].minor.yy27); }
#line 890 "src/parser.c"
break;
case 24: /* hash_pair ::= QSTRING COLON expr */
-#line 107 "src/parser.y"
+#line 110 "src/parser.y"
{
yygotominor.yy27 = malloc(sizeof(Pair)); yygotominor.yy27->key = yymsp[-2].minor.yy0; yygotominor.yy27->value = yymsp[0].minor.yy48;
yy_destructor(yypParser,15,&yymsp[-1].minor);
@@ -897,7 +897,7 @@ static void yy_reduce(
#line 898 "src/parser.c"
break;
case 25: /* hash_pair ::= PATTERN COLON expr */
-#line 110 "src/parser.y"
+#line 113 "src/parser.y"
{
yygotominor.yy27 = malloc(sizeof(Pair)); yygotominor.yy27->key = yymsp[-2].minor.yy0; yygotominor.yy27->value = yymsp[0].minor.yy48;
yy_destructor(yypParser,15,&yymsp[-1].minor);
@@ -966,8 +966,11 @@ static void yy_syntax_error(
#define TOKEN (yyminor.yy0)
#line 18 "src/parser.y"
+ if( !TOKEN ) {
+ log_err("Reached the end of file so it seems like you are missing a ')'");
+ }
state->error = 1;
-#line 971 "src/parser.c"
+#line 974 "src/parser.c"
ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */
}
diff --git a/tools/m2sh/src/parser.y b/tools/m2sh/src/parser.y
index 971eb896..3a01907a 100644
--- a/tools/m2sh/src/parser.y
+++ b/tools/m2sh/src/parser.y
@@ -16,6 +16,9 @@
%extra_argument {ParserState *state}
%syntax_error {
+ if( !TOKEN ) {
+ log_err("Reached the end of file so it seems like you are missing a ')'");
+ }
state->error = 1;
}
From 79a792c3556f6eaf2c9ef1d7ef63a0c212798e43 Mon Sep 17 00:00:00 2001
From: "Zed A. Shaw"
Date: Tue, 21 Jun 2011 09:23:57 -0700
Subject: [PATCH 15/15] Release 1.7.4.
---
README.md | 7 ++++---
docs/manual/Makefile | 2 +-
docs/wiki/mongrel2.wiki | 4 ++--
examples/python/mongrel2/config/commands.py | 2 +-
examples/python/setup.py | 2 +-
src/version.h | 2 +-
6 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 7358e921..e33c6534 100644
--- a/README.md
+++ b/README.md
@@ -32,13 +32,14 @@ Features
Download
--------
-Mongrel2 is now 1.7.3 as of *Sat Jun 11 22:13:23 PDT 2011*:
+Mongrel2 is now 1.7.4 as of *Tue Jun 21 09:16:15 PDT 2011*:
-* [mongrel2-1.7.3.tar.bz2](http://mongrel2.org/static/downloads/mongrel2-1.7.3.tar.bz2) MD5: bb0f85fdd2bc7c83286be5335a10c743
+* [mongrel2-1.7.4.tar.bz2](http://mongrel2.org/static/downloads/mongrel2-1.7.4.tar.bz2) MD5:
Documentation
-------------
-You can get documentation and read more about it at [mongrel2.org](http://mongrel2.org).
+There is a full manual available at [mongrel2.org](http://mongrel2.org/static/mongrel2-manual.html)
+covering every aspect of Mongrel2, with more as we write features.
diff --git a/docs/manual/Makefile b/docs/manual/Makefile
index 72e62b4e..d16fa6e5 100644
--- a/docs/manual/Makefile
+++ b/docs/manual/Makefile
@@ -1,6 +1,6 @@
JUNK_FILES=book-final.* *.aux *.log styles/*.aux
SOURCE=book
-WEBSITE=$(USER)@mongrel2.org:deployment/files/static
+WEBSITE=$(USER)@mongrel2.org:/var/www/mongrel2.org/static/
FINAL=book-final
draft: book-final.dvi
diff --git a/docs/wiki/mongrel2.wiki b/docs/wiki/mongrel2.wiki
index bd6ec42e..f23b3f1d 100644
--- a/docs/wiki/mongrel2.wiki
+++ b/docs/wiki/mongrel2.wiki
@@ -28,10 +28,10 @@ technologies.
-Mongrel2 is now 1.7.2 as of Fri Jun 10 08:36:14 PDT 2011
+Mongrel2 is now 1.7.4:
diff --git a/examples/python/mongrel2/config/commands.py b/examples/python/mongrel2/config/commands.py
index a663175f..7775f226 100644
--- a/examples/python/mongrel2/config/commands.py
+++ b/examples/python/mongrel2/config/commands.py
@@ -502,7 +502,7 @@ def version_command():
Prints out the version of your mongrel2 binary."
"""
- print "Mongrel2/1.7.3"
+ print "Mongrel2/1.7.4"
diff --git a/examples/python/setup.py b/examples/python/setup.py
index 5823e6b6..8beeedf5 100644
--- a/examples/python/setup.py
+++ b/examples/python/setup.py
@@ -10,7 +10,7 @@
'url': 'http://pypi.python.org/pypi/mongrel2-python',
'download_url': 'http://pypi.python.org/pypi/mongrel2-python',
'author_email': 'zedshaw@zedshaw.com',
- 'version': '1.7.3',
+ 'version': '1.7.4',
'install_requires': ['nose', 'simplejson', 'pyrepl', 'storm'],
'packages': ['mongrel2', 'mongrel2.config'],
'package_data': {'mongrel2': ['sql/config.sql']},
diff --git a/src/version.h b/src/version.h
index bdf3f411..5a14b306 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,3 +1,3 @@
-#define VERSION "Mongrel2/1.7.3"
+#define VERSION "Mongrel2/1.7.4"