commit version 0.1
This commit is contained in:
54
inc/attribute.h
Normal file
54
inc/attribute.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* attribute.h
|
||||
*
|
||||
* Created on: 08.08.2017
|
||||
* Author: julian
|
||||
*/
|
||||
|
||||
#ifndef ATTRIBUTE_H_
|
||||
#define ATTRIBUTE_H_
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "nhtml_string.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
string_t name, value;
|
||||
} attr_t;
|
||||
|
||||
/**
|
||||
* \brief copy the give attribute
|
||||
* \return a copy of attr
|
||||
*/
|
||||
attr_t attr_copy(attr_t * attr);
|
||||
/**
|
||||
* \brief reset the attribute
|
||||
* Deletes all strings
|
||||
*/
|
||||
void attr_destroy(attr_t * attr);
|
||||
|
||||
|
||||
typedef struct {
|
||||
attr_t * arr;
|
||||
size_t len;
|
||||
} attr_set_t;
|
||||
|
||||
/**
|
||||
* \brief search in attribute set for key
|
||||
* \param set The Attribute set
|
||||
* \param key The Key to search
|
||||
* \return the pointer to the attribute in the set mathching the key
|
||||
* \return NULL if there is no matching attribute
|
||||
*/
|
||||
attr_t * attr_set_find(attr_set_t *set, const char * key);
|
||||
// Append new Attribute to set
|
||||
/**
|
||||
* \brief Append new attribute pair to set
|
||||
* \return 0 on success
|
||||
* \return -1 on failure (error can be found to errno)
|
||||
*/
|
||||
int attr_set_append(attr_set_t * set, attr_t *new_entry);
|
||||
|
||||
|
||||
#endif /* ATTRIBUTE_H_ */
|
||||
37
inc/html.h
Normal file
37
inc/html.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* html.h
|
||||
*
|
||||
* Created on: 07.08.2017
|
||||
* Author: julian
|
||||
*/
|
||||
|
||||
#ifndef HTML_H_
|
||||
#define HTML_H_
|
||||
|
||||
#include <stdio.h> // needs FILE
|
||||
#include "nhtml_string.h"
|
||||
#include "attribute.h"
|
||||
|
||||
extern int html_escape(int c, FILE* output);
|
||||
|
||||
typedef struct node {
|
||||
string_t name;
|
||||
attr_set_t attributes;
|
||||
} node_t;
|
||||
|
||||
|
||||
/**
|
||||
* \brief emit html opening tag for \node
|
||||
* \param node the Node to create the opening tag for
|
||||
* \param output the File to write to
|
||||
*/
|
||||
void open_node(node_t * node, FILE * output);
|
||||
|
||||
/**
|
||||
* \brief emit html closing tag for \node
|
||||
* \param node the Node to create the closing tag for
|
||||
* \param output the File to write to
|
||||
*/
|
||||
void close_node(node_t * node, FILE * output);
|
||||
|
||||
#endif /* HTML_H_ */
|
||||
18
inc/includes.h
Normal file
18
inc/includes.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* includes.h
|
||||
*
|
||||
* Created on: 08.08.2017
|
||||
* Author: julian
|
||||
*/
|
||||
|
||||
#ifndef INC_INCLUDES_H_
|
||||
#define INC_INCLUDES_H_
|
||||
|
||||
#include <nhtml_string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void include_add_path(const char * path);
|
||||
|
||||
int include_file(string_t *filename, FILE * output);
|
||||
|
||||
#endif /* INC_INCLUDES_H_ */
|
||||
53
inc/nhtml_string.h
Normal file
53
inc/nhtml_string.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* nhtml_string.h
|
||||
*
|
||||
* Created on: 08.08.2017
|
||||
* Author: julian
|
||||
*/
|
||||
|
||||
#ifndef NHTML_STRING_H_
|
||||
#define NHTML_STRING_H_
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
#include <errno.h> // errno
|
||||
|
||||
typedef struct {
|
||||
char * c_str;
|
||||
size_t len;
|
||||
} string_t;
|
||||
|
||||
/**\brief append the char @c to @str
|
||||
* \param str to the String to append to
|
||||
* \param c the char to append
|
||||
* \return -1 on error, errno will be set to errorcode
|
||||
* \return 0 on success
|
||||
*/
|
||||
int string_append(string_t *str, char c);
|
||||
|
||||
/**
|
||||
* \brief append src to dest
|
||||
* will enlarge dest to accommodate src
|
||||
* \return -1 on failure (check errno)
|
||||
* \return 0 on success
|
||||
*/
|
||||
int string_concat(string_t * dest, string_t * src);
|
||||
|
||||
/**
|
||||
* \brief Erase the String from memory
|
||||
*/
|
||||
void string_destroy(string_t *s);
|
||||
|
||||
/**
|
||||
* \brief copy the contents of a string
|
||||
* \param old The String to copy
|
||||
* \return returns the new string
|
||||
*/
|
||||
string_t string_copy(string_t old);
|
||||
|
||||
/**
|
||||
* \brief creates copy of str
|
||||
* \return a copy of str
|
||||
*/
|
||||
string_t string_from_cstr(const char * str);
|
||||
|
||||
#endif /* NHTML_STRING_H_ */
|
||||
17
inc/parser.h
Normal file
17
inc/parser.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* parser.h
|
||||
*
|
||||
* Created on: 08.08.2017
|
||||
* Author: julian
|
||||
*/
|
||||
|
||||
#ifndef INC_PARSER_H_
|
||||
#define INC_PARSER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int strip(FILE * input);
|
||||
int parse_node(int current, FILE * stream, FILE * output);
|
||||
|
||||
|
||||
#endif /* INC_PARSER_H_ */
|
||||
Reference in New Issue
Block a user