Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix up some formatting and add licenses to most .c files.

  • Loading branch information...
commit c4e1f97a62ecd44855b65d6bced9f4789744ffd7 1 parent 5c29ed2
@zedshaw authored
View
34 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 <assert.h>
View
812 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);
View
6 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));
View
34 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 <stdio.h>
View
34 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"
View
1  src/connection.c
@@ -1,4 +1,3 @@
-#undef DEBUG
/**
*
* Copyright (c) 2010, Zed A. Shaw and Mongrel2 Project Contributors.
View
34 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"
View
34 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;
View
1  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 <dir.h>
#include <cache.h>
View
34 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"
View
34 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
View
34 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"
View
34 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 <sys/stat.h>
#include "upload.h"
#include "dbg.h"
View
34 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 <filter.h>
#include <dbg.h>
#include <config/module.h>
View
34 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 <filter.h>
#include <dbg.h>
#include <config/module.h>
View
34 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 <filter.h>
#include <dbg.h>
View
34 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 <stdlib.h>
#include <dbg.h>
View
80 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 )
View
34 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.
View
34 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"
View
34 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 <config/db.h>
#include "constants.h"
#include <bstring.h>
View
34 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(
View
106 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 {
View
34 tools/m2sh/src/lexer.rl