src/server/object.h

Sun, 13 Nov 2011 13:43:01 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 13 Nov 2011 13:43:01 +0100
changeset 4
998844b5ed25
parent 3
137197831306
child 5
dbc01588686e
permissions
-rw-r--r--

Added some protocol functions

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2011 Olaf Wintermann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. 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.
 *
 * 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.
 */

#ifndef OBJECT_H
#define	OBJECT_H

#include "nsapi.h"

#ifdef	__cplusplus
extern "C" {
#endif

// TODO: Enum auslagern in andere Datei?
enum RequestPhase {
    NSAPIAuthTrans = 0,
    NSAPINameTrans,
    NSAPIPathCheck,
    NSAPIService,
    REQ_FINISH,
    NUM_NSAPI_TYPES
};
typedef enum RequestPhase RequestPhase;

struct directive {
    FuncStruct *func;
    pblock     *param;
};

struct dtable {
    directive **directive;
    int ndir;
};

struct httpd_object {
    char  *name;

    dtable *dt;
    int    nd;
};

struct httpd_objset {
    httpd_object **obj;
    int pos;
};


/*
 * create a new httpd_object
 */
httpd_object* object_new(char *name);

/*
 * frees an httpd_object
 */
void object_free(httpd_object *obj);

/*
 * adds a directive to the object with the type dt (enum DirectiveType)
 */
void object_add_directive(httpd_object *obj, directive *dir, int dt);

/*
 * get a list of all directives with a specific type
 */
#define object_get_dtable(obj,type) &obj->dt[type];



httpd_objset* create_test_objset();


#ifdef	__cplusplus
}
#endif

#endif	/* OBJECT_H */

mercurial