/*

                                   _JNJ`                        
                               .JNMH`                           
                              JMMF`       `;.                   
                            .NMM)          `MN.                 
                            MMM)            (MML                
                           (MMM`             MMML               
                     M  I  D  N  I  G  H  T    C  o  D  E       
                           (NMMF             MHNH               
                            NMML            .MMM                
                             NMML          .NMH                 
                              4MMNL       .#F                   
                               `4HNNL_   `                      
                                   `"""`                        

                          Copyright (C) 2004-2007
       "Ian (Larry) Latter" <ian dot latter at midnightcode dot org>

    Midnight Code is a registered trademark of Ian Latter.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, and mirrored at the Midnight Code web
    site; as at version 2 of the License only.
  
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
  
    You should have received a copy of the GNU General Public License
    (version 2) along with this program; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA, or see http://midnightcode.org/gplv2.txt

*/


/* midnightcode-webint.h :: Midnight Code web interface library		*/


#ifndef __MIDNIGHTCODE_WEBINT_H
#define __MIDNIGHTCODE_WEBINT_H 1


#define MIDNIGHTCODE_WEBINT_MESSAGE_MINSIZE 16
#define MIDNIGHTCODE_WEBINT_PORT 98

enum midnightcode_webint_layout_t
{
  MIDNIGHTCODE_WEBINT_LAYOUT_NONE = 0,
  MIDNIGHTCODE_WEBINT_LAYOUT_DOCUMENT_HEAD = 1,
  MIDNIGHTCODE_WEBINT_LAYOUT_DOCUMENT_TAIL = 2,
  MIDNIGHTCODE_WEBINT_LAYOUT_FORM_HEAD = 4,
  MIDNIGHTCODE_WEBINT_LAYOUT_FORM_TAIL = 8,
  MIDNIGHTCODE_WEBINT_LAYOUT_HEAD = 16,
  MIDNIGHTCODE_WEBINT_LAYOUT_TAIL = 32,
  MIDNIGHTCODE_WEBINT_LAYOUT_MENU = 64,
  MIDNIGHTCODE_WEBINT_LAYOUT_CONTENT = 128,
  MIDNIGHTCODE_WEBINT_LAYOUT_ALL = 255
};

#define MIDNIGHTCODE_WEBINT_LAYOUT_PRECONTENT			\
		MIDNIGHTCODE_WEBINT_LAYOUT_DOCUMENT_HEAD |	\
		MIDNIGHTCODE_WEBINT_LAYOUT_FORM_HEAD |		\
		MIDNIGHTCODE_WEBINT_LAYOUT_HEAD |		\
		MIDNIGHTCODE_WEBINT_LAYOUT_MENU
#define MIDNIGHTCODE_WEBINT_LAYOUT_POSTCONTENT			\
		MIDNIGHTCODE_WEBINT_LAYOUT_TAIL |		\
		MIDNIGHTCODE_WEBINT_LAYOUT_FORM_TAIL |		\
		MIDNIGHTCODE_WEBINT_LAYOUT_DOCUMENT_TAIL

enum midnightcode_webint_membrane_t
{
  MIDNIGHTCODE_WEBINT_MEMBRANE_ENCODE = 0,
  MIDNIGHTCODE_WEBINT_MEMBRANE_DECODE = 1
};

enum midnightcode_webint_query_t
{
  MIDNIGHTCODE_WEBINT_QUERY_ACK = 0,
  MIDNIGHTCODE_WEBINT_QUERY_GET = 1,
  MIDNIGHTCODE_WEBINT_QUERY_SET = 2
};

struct midnightcode_webint_menu_t
{
  int active;
  char * url_s;
  char * descript_s;
};

struct midnightcode_webint_page_t
{
  char * label_s;
  char * title_s;
};

struct midnightcode_webint_content_t
{
  char * label_s;
  char * content_s;
};

struct midnightcode_webint_message_t
{
  int query;
  int type;
  int buffer_size;
  char * buffer;
};

int midnightcode_webint_membrane(int direction,
                     char ** buffer, int * buffer_size,
                     struct midnightcode_webint_message_t ** message);
int midnightcode_webint_buffer(char ** buffer,
                     char * title,
                     struct midnightcode_webint_menu_t * menu_items,
                     struct midnightcode_webint_page_t * page_items,
                     struct midnightcode_webint_content_t * content_items,
                     int padding, int sections);
void midnightcode_webint(char * title,
                     struct midnightcode_webint_menu_t * menu_items,
                     struct midnightcode_webint_page_t * page_items,
                     struct midnightcode_webint_content_t * content_items,
                     int padding, int sections);


#endif
