Пример #1
0
static int handle_token_colon( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;

	if( parser->empty_line
	    && !push_indent( parser->indent, out ))
		return 0;

	if( parser->in_branch
	    && !parser->parens_closed
	    && parser->empty_line ) 
	{
		int i;
		for( i = 4; i > 0; --i )
			putc( ' ', out );
	}

	if( !push_token( tk, out ) )
		return 0;

	parser->empty_line = 0;
	parser->un_op = 0;
	return 1;
}
Пример #2
0
static int handle_token_assign_op( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;

	if( parser->empty_line ) {

		if( !push_indent( parser->indent, out ) )
			return 0;
		int i;
		for( i = 4; i > 0; --i )
			putc( ' ', out );
	}
	else {
		putc( ' ', out );
	}
	    
	if( !push_token( tk, out ) )
		return 0;

	parser->empty_line = 0;
	parser->un_op = 0;

	return 1;
}
Пример #3
0
static int handle_token_rbrace( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;

	int lbi = parser->brace_indent[parser->last_brace_indent];

	if( !parser->empty_line ) {
		putc( '\n', out );
		parser->empty_line = 1;
	}
	
	parser->indent = lbi;

	if( !push_indent( parser->indent, out ) )
	{
		return 0;
	}

	if( !push_token( tk, out ) )
	{
		return 0;
	}

	--parser->last_brace_indent;

	if( parser->last_brace_indent > 0
	    && parser->last_brace_indent < parser->stack_size - 10
	    && !shrink_stack( &(parser->brace_indent),
	                       &(parser->stack_size) ) )
	{
		return 0;
	}

	lbi = parser->brace_indent[parser->last_brace_indent];

	if( !parser->last_brace_indent )
	{
		parser->indent = lbi;
	}
	else
	{
		parser->indent = lbi + 1;
	}

	parser->empty_line = 0;
	parser->un_op = 0;
	return 1;
}
Пример #4
0
static int handle_token_comment( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;
	if( !parser->empty_line ) { 
		putc( '\t', out );
	}
	if( parser->empty_line
	    && !push_indent( parser->indent, out ))
		return 0;
	if( !push_token( tk, out ) )
		return 0;
	parser->empty_line = 0;
	parser->un_op = 0;
	return 1;
}
Пример #5
0
static int handle_token_lbrace( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;

	++parser->last_brace_indent;

	if( parser->last_brace_indent >= parser->stack_size
	    && !enlarge_stack( &(parser->brace_indent),
		                &(parser->stack_size)  ) )
	{
		return 0;	
	}

	parser->brace_indent[parser->last_brace_indent]
		= parser->indent;

	if( !parser->empty_line 
	    && parser->prev_tk.type != ASSIGN_OP )
	{
		putc( '\n', out );
		parser->empty_line = 1;
	}

	// insert a space after '=' in array initialization
	if( parser->prev_tk.type == ASSIGN_OP )
	{
		putc( ' ', out );
	}

	if( !push_indent( parser->indent, out ) )
		return 0;

	if( !push_token( tk, out ) )
		return 0;

	parser->empty_line = 0;
	parser->in_branch = 0;
	++parser->indent;
	parser->un_op = 0;
	return 1;
}
Пример #6
0
static int handle_token_semicolon( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;

	if( parser->empty_line
	    && !push_indent( parser->indent, out ) )
		return 0;

	if( parser->in_branch )	
	{
		if( parser->parens_closed ) {
			parser->in_branch = 0;
		}
		else if( parser->empty_line ) {
			int i;
			for( i = 4; i > 0; --i )
				putc( ' ', out );
		}
	}

	if( !push_token( tk, out ) )
		return 0;

	if( !parser->in_branch )
	{
		if( parser->last_brace_indent )
			parser->indent = parser->brace_indent[parser
				->last_brace_indent] + 1;
		else
			parser->indent = 0;
	}

	parser->empty_line = 0;
	parser->un_op = 0;

	return 1;
}
Пример #7
0
static int handle_token_case_kw( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;
	if( !parser->empty_line ) {
		putc( '\n', out );
		parser->empty_line = 1;
	}

	parser->indent = parser->brace_indent[parser->last_brace_indent];

	if( parser->empty_line
	    && !push_indent( parser->indent, out ))
		return 0;

	if( !push_token( tk, out ) )
		return 0;

	parser->empty_line = 0;
	++parser->indent;
	parser->un_op = 0;
	return 1;
}
Пример #8
0
static int handle_token_cond( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;
	if( tk->type == IF_KW && parser->prev_tk.type == ELSE_KW ) {
		putc( ' ', out );	
	}
	else if( !parser->empty_line ) {
		putc( '\n', out );
		parser->empty_line = 1;
	}
	if( parser->in_branch
	    && parser->prev_tk.type != ELSE_KW )
	{
		++parser->indent;
	}
	else {
		parser->in_branch = 1;
	}
	if( tk->type != ELSE_KW )
		parser->parens_closed = 0;
	else {
		parser->parens_closed = 1;
	}
	
	if( parser->prev_tk.type != ELSE_KW
	    && parser->empty_line
	    && !push_indent( parser->indent, out ) )
		return 0;

	if( !push_token( tk, out ) )
		return 0;

	parser->empty_line = 0;
	parser->un_op = 0;
	return 1;
}
Пример #9
0
Error RichTextLabel::append_bbcode(const String& p_bbcode) {

	int pos = 0;

	List<String> tag_stack;
	Ref<Font> normal_font=get_font("normal_font");
	Ref<Font> bold_font=get_font("bold_font");
	Ref<Font> italics_font=get_font("italics_font");
	Ref<Font> bold_italics_font=get_font("bold_italics_font");
	Ref<Font> mono_font=get_font("mono_font");

	Color base_color=get_color("default_color");

	int indent_level=0;

	bool in_bold=false;
	bool in_italics=false;

	while(pos < p_bbcode.length()) {


		int brk_pos = p_bbcode.find("[",pos);

		if (brk_pos<0)
			brk_pos=p_bbcode.length();

		if (brk_pos > pos) {
			add_text(p_bbcode.substr(pos,brk_pos-pos));
		}

		if (brk_pos==p_bbcode.length())
			break; //nothing else o add

		int brk_end = p_bbcode.find("]",brk_pos+1);

		if (brk_end==-1) {
			//no close, add the rest
			add_text(p_bbcode.substr(brk_pos,p_bbcode.length()-brk_pos));
			break;
		}


		String tag = p_bbcode.substr(brk_pos+1,brk_end-brk_pos-1);


		if (tag.begins_with("/") && tag_stack.size()) {

			bool tag_ok = tag_stack.size() && tag_stack.front()->get()==tag.substr(1,tag.length());



			if (tag_stack.front()->get()=="b")
				in_bold=false;
			if (tag_stack.front()->get()=="i")
				in_italics=false;
			if (tag_stack.front()->get()=="indent")
				indent_level--;


			if (!tag_ok) {

				add_text("[");
				pos++;
				continue;
			}

			tag_stack.pop_front();
			pos=brk_end+1;
			if (tag!="/img")
				pop();

		} else if (tag=="b") {

			//use bold font
			in_bold=true;
			if (in_italics)
				push_font(bold_italics_font);
			else
				push_font(bold_font);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="i") {

			//use italics font
			in_italics=true;
			if (in_bold)
				push_font(bold_italics_font);
			else
				push_font(italics_font);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="code") {

			//use monospace font
			push_font(mono_font);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag.begins_with("table=")) {

			int columns = tag.substr(6,tag.length()).to_int();
			if (columns<1)
				columns=1;
			//use monospace font
			push_table(columns);
			pos=brk_end+1;
			tag_stack.push_front("table");
		} else if (tag=="cell") {

			push_cell();
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag.begins_with("cell=")) {

			int ratio = tag.substr(6,tag.length()).to_int();
			if (ratio<1)
				ratio=1;
			//use monospace font
			set_table_column_expand(get_current_table_column(),true,ratio);
			push_cell();
			pos=brk_end+1;
			tag_stack.push_front("cell");
		} else if (tag=="u") {

			//use underline
			push_underline();
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="s") {

			//use strikethrough (not supported underline instead)
			push_underline();
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="center") {

			//use underline
			push_align(ALIGN_CENTER);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="fill") {

			//use underline
			push_align(ALIGN_FILL);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="right") {

			//use underline
			push_align(ALIGN_RIGHT);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="ul") {

			//use underline
			push_list(LIST_DOTS);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="ol") {

			//use underline
			push_list(LIST_NUMBERS);
			pos=brk_end+1;
			tag_stack.push_front(tag);
		} else if (tag=="indent") {

			//use underline
			indent_level++;
			push_indent(indent_level);
			pos=brk_end+1;
			tag_stack.push_front(tag);

		} else if (tag=="url") {

			//use strikethrough (not supported underline instead)
			int end=p_bbcode.find("[",brk_end);
			if (end==-1)
				end=p_bbcode.length();
			String url = p_bbcode.substr(brk_end+1,end-brk_end-1);
			push_meta(url);

			pos=brk_end+1;
			tag_stack.push_front(tag);

		} else if (tag.begins_with("url=")) {

			String url = tag.substr(4,tag.length());
			push_meta(url);
			pos=brk_end+1;
			tag_stack.push_front("url");
		} else if (tag=="img") {

			//use strikethrough (not supported underline instead)
			int end=p_bbcode.find("[",brk_end);
			if (end==-1)
				end=p_bbcode.length();
			String image = p_bbcode.substr(brk_end+1,end-brk_end-1);

			Ref<Texture> texture = ResourceLoader::load(image,"Texture");
			if (texture.is_valid())
				add_image(texture);

			pos=end;
			tag_stack.push_front(tag);
		} else if (tag.begins_with("color=")) {

			String col = tag.substr(6,tag.length());
			Color color;

			if (col.begins_with("#"))
				color=Color::html(col);
			else if (col=="aqua")
				color=Color::html("#00FFFF");
			else if (col=="black")
				color=Color::html("#000000");
			else if (col=="blue")
				color=Color::html("#0000FF");
			else if (col=="fuchsia")
				color=Color::html("#FF00FF");
			else if (col=="gray" || col=="grey")
				color=Color::html("#808080");
			else if (col=="green")
				color=Color::html("#008000");
			else if (col=="lime")
				color=Color::html("#00FF00");
			else if (col=="maroon")
				color=Color::html("#800000");
			else if (col=="navy")
				color=Color::html("#000080");
			else if (col=="olive")
				color=Color::html("#808000");
			else if (col=="purple")
				color=Color::html("#800080");
			else if (col=="red")
				color=Color::html("#FF0000");
			else if (col=="silver")
				color=Color::html("#C0C0C0");
			else if (col=="teal")
				color=Color::html("#008008");
			else if (col=="white")
				color=Color::html("#FFFFFF");
			else if (col=="yellow")
				color=Color::html("#FFFF00");
			else
				color=base_color;



			push_color(color);
			pos=brk_end+1;
			tag_stack.push_front("color");

		} else if (tag.begins_with("font=")) {

			String fnt = tag.substr(5,tag.length());


			Ref<Font> font = ResourceLoader::load(fnt,"Font");
			if (font.is_valid())
				push_font(font);
			else
				push_font(normal_font);

			pos=brk_end+1;
			tag_stack.push_front("font");


		} else {

			add_text("["); //ignore
			pos=brk_pos+1;

		}
	}

	return OK;
}
Пример #10
0
static int handle_token_op( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;

	if( !parser->empty_line 
	    && (!parser->in_branch || !parser->parens_closed) )
	{
		if( is_incr_or_decr( tk ) ) {

			if( !parser->un_op
			    && parser->prev_tk.type != LPAREN
			    && parser->prev_tk.type != RPAREN
			    && parser->prev_tk.type != LBRACKET
			    && parser->prev_tk.type != RBRACKET
			    && parser->prev_tk.type != IDENT
			    && parser->prev_tk.type != NUM_CONST
			    && parser->prev_tk.type != CHR_LIT
			    && parser->prev_tk.type != STR_LIT )
			{
				putc( ' ', out );
			}
		}
		else if( is_unary_op( tk ) ) {

			if( is_incr_or_decr( &(parser->prev_tk ) ) ) {
				putc( ' ', out );
			}
			else if( !parser->un_op
			         && parser->prev_tk.type != LPAREN
			         && parser->prev_tk.type != LBRACKET
			         && !(parser->prev_tk.start[0] == '*'
			              && tk->start[0] == '*') )
			{
				putc( ' ', out );
			}
		}
		else if( parser->un_op
		         || parser->prev_tk.type == RPAREN
		         || parser->prev_tk.type == RBRACKET
		         || parser->prev_tk.type == IDENT
		         || parser->prev_tk.type == NUM_CONST
		         || parser->prev_tk.type == CHR_LIT
		         || parser->prev_tk.type == STR_LIT)
		{
			putc( ' ', out );
		}
	}

	/* find out if this is an unary op */
	if( is_incr_or_decr( tk ) ) {
		parser->un_op = 1;
	}
	else if( is_unary_op( tk )
	         && !is_incr_or_decr( &(parser->prev_tk) )
	         && parser->prev_tk.type != IDENT
	         && parser->prev_tk.type != NUM_CONST
	         && parser->prev_tk.type != CHR_LIT
	         && parser->prev_tk.type != STR_LIT
	         && parser->prev_tk.type != RBRACKET )
	{
		if( parser->prev_tk.type != RPAREN ) {
			parser->un_op = 1;
		}
		else if( parser->in_branch ) {
			parser->un_op = 1;
		}
	}
	else {
		parser->un_op = 0;
	}

	if( parser->in_branch ) {

		if( parser->parens_closed )
		{
			if( !parser->empty_line )
			{
				putc( '\n', out );
				parser->empty_line = 1;
			}

			parser->in_branch = 0;
			++parser->indent;
		}
	}
	else if( parser->prev_tk.type == SEMICOLON ) {
		putc( '\n', out );
		parser->empty_line = 1;
	}

	if( parser->empty_line
	    && !push_indent( parser->indent, out ))
		return 0;

	if( parser->in_branch
	    && !parser->parens_closed
	    && parser->empty_line ) 
	{
		int i;
		for( i = 4; i > 0; --i )
			putc( ' ', out );
	}
	if( !push_token( tk, out ) )
		return 0;
	parser->empty_line = 0;
	return 1;
}
Пример #11
0
static int handle_token_lparen( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;
	
	if( parser->in_branch ) {

		if( parser->parens_closed ) {

			if( !parser->empty_line ) {
				putc( '\n', out );
				parser->empty_line = 1;
			}
			++parser->indent;

			if( !push_indent( parser->indent, out ) )
				return 0;
			parser->in_branch = 0;
		}
		else {
			++parser->paren_depth;

			if( parser->empty_line ) {

				if( !push_indent( parser->indent, out ) )
					return 0;

				int i;
				for( i = 4; i > 0; --i )
					putc( ' ', out );
			}
		}
	}
	else
	{
		if( !parser->empty_line ) {

			if( parser->prev_tk.type == LBRACE
			    || parser->prev_tk.type == RBRACE
			    || parser->prev_tk.type == SEMICOLON )
			{
				putc('\n', out );
				parser->empty_line = 1;
			}
		}

		if( parser->empty_line
		    && !push_indent( parser->indent, out ) )
			return 0;
	}
	
	/* putting space before token if needed */
	if( !parser->empty_line
	    && parser->prev_tk.type != LPAREN
	    && parser->prev_tk.type != LBRACKET
	    && parser->prev_tk.type != SEMICOLON
	    && !parser->un_op )
	{
		putc( ' ', out );
	}

	if( !push_token( tk, out ) )
		return 0;

	parser->empty_line = 0;
	parser->un_op = 0;
	return 1;
}
Пример #12
0
static int handle_token_ident( Token * tk, Parser * parser, FILE * out )
{
	if( !tk || !parser || !out )
		return 0;

	if( !parser->in_branch ) {

		if( !parser->empty_line ) {

			if( parser->prev_tk.type == LBRACE
			    || parser->prev_tk.type == SEMICOLON )
			{
				putc( '\n', out );
				parser->empty_line = 1;
			}
			else if( parser->prev_tk.type != LPAREN
			         && parser->prev_tk.type != LBRACKET
			         && parser->prev_tk.type != STRUCT_SEP
			         && !parser->un_op )
			{
				putc( ' ', out );
			}
		}
	}
	else if( parser->parens_closed ) {

		if( parser->prev_tk.type == RPAREN
		    && !parser->empty_line )
		{
			putc( '\n', out );
			parser->empty_line = 1;
		}
		parser->in_branch = 0;
		++parser->indent;
	}


	if( parser->empty_line
	    && !push_indent( parser->indent, out ) )
	{
		return 0;
	}


	if( parser->in_branch
	    && !parser->parens_closed
	    && parser->empty_line ) 
	{
		int i;
		for( i = 4; i > 0; --i )
			putc( ' ', out );
	}
		

	if( !push_token( tk, out ) )
		return 0;

	parser->empty_line = 0;
	parser->un_op = 0;
	return 1;
}
Пример #13
0
int  tbc_mod_gen_compile ()
{
	axlDtd   * dtd;
	axlDoc   * doc;
	axlError * error;
	axlNode  * node;
	axlNode  * moddef;
	char     * mod_name;
	char     * tolower;
	char     * toupper;
	char     * description;

	/* parse DTD document */
	dtd = axl_dtd_parse (TBC_MOD_GEN_DTD, -1, &error);
	if (dtd == NULL) {
		/* report error and dealloc resources */
		error ("Failed to parse DTD, error found: %s", axl_error_get (error));
		axl_error_free (error);

		return axl_false;
	} /* end if */
	
	/* nice, now parse the xml file */
	doc = axl_doc_parse_from_file (exarg_get_string ("compile"), &error);
	if (doc == NULL) {
		/* report error and dealloc resources */
		error ("unable to parse file: %s, error found: %s", 
		       exarg_get_string ("compile"),
		       axl_error_get (error));
		axl_error_free (error);
		axl_dtd_free (dtd);
	} /* end if */

	/* nice, now validate content */
	if (! axl_dtd_validate (doc, dtd, &error)) {
		/* report error and dealloc */
		error ("failed to validate module description provided: %s, error found: %s",
		       exarg_get_string ("compile"),
		       axl_error_get (error));
		axl_error_free (error);
		axl_doc_free (doc);
		axl_dtd_free (dtd);
		return axl_false;
	} /* end if */

	/* ok, now produce source code  */
	axl_dtd_free (dtd);

	/* open file */
	moddef   = axl_doc_get_root (doc);
	node     = axl_doc_get (doc, "/mod-def/name");
	mod_name = (char *) axl_node_get_content (node, NULL);
	mod_name = support_clean_name (mod_name);
	tolower  = support_to_lower (mod_name);
	toupper  = support_to_upper (mod_name);

	/* out dir */
	support_open_file (ctx, "%s%s.c", get_out_dir (), mod_name);

	/* place copyright if found */
	node     = axl_doc_get (doc, "/mod-def/copyright");
	if (node != NULL) {
		/* place the copyright */
	}  /* end if */
	
	write ("/* %s implementation */\n", mod_name);
	write ("#include <turbulence.h>\n\n");

	write ("/* use this declarations to avoid c++ compilers to mangle exported\n");
	write (" * names. */\n");
	write ("BEGIN_C_DECLS\n\n");

	write ("/* global turbulence context reference */\n");
	write ("TurbulenceCtx * ctx = NULL;\n\n");

	/* place here additional content */
	node    = axl_doc_get (doc, "/mod-def/source-code/additional-content");
	if (node != NULL) {
		write ("%s\n", axl_node_get_content (node, NULL));
	} /* end if */

	/* init handler */
	write ("/* %s init handler */\n", mod_name);
	write ("static int  %s_init (TurbulenceCtx * _ctx) {\n", tolower);

	push_indent ();
	write ("/* configure the module */\n");
	write ("TBC_MOD_PREPARE (_ctx);\n\n");
	pop_indent ();

	node = axl_doc_get (doc, "/mod-def/source-code/init");
	if (axl_node_get_content (node, NULL)) {
		/* write the content defined */
		write ("%s\n", axl_node_get_content (node, NULL));
	}
	write ("} /* end %s_init */\n\n", tolower);

	/* close handler */
	write ("/* %s close handler */\n", mod_name);
	write ("static void %s_close (TurbulenceCtx * _ctx) {\n", tolower);
	node = axl_doc_get (doc, "/mod-def/source-code/close");
	if (axl_node_get_content (node, NULL)) {
		/* write the content defined */
		write ("%s\n", axl_node_get_content (node, NULL));
	}
	write ("} /* end %s_close */\n\n", tolower);

	/* reconf handler */
	write ("/* %s reconf handler */\n", mod_name);
	write ("static void %s_reconf (TurbulenceCtx * _ctx) {\n", tolower);
	node = axl_doc_get (doc, "/mod-def/source-code/reconf");
	if (axl_node_get_content (node, NULL)) {
		/* write the content defined */
		write ("%s\n", axl_node_get_content (node, NULL));
	}
	write ("} /* end %s_reconf */\n\n", tolower);

	/* unload handler */
	write ("/* %s unload handler */\n", mod_name);
	write ("static void %s_unload (TurbulenceCtx * _ctx) {\n", tolower);
	node = axl_doc_get (doc, "/mod-def/source-code/unload");
	if (axl_node_get_content (node, NULL)) {
		/* write the content defined */
		write ("%s\n", axl_node_get_content (node, NULL));
	}
	write ("} /* end %s_unload */\n\n", tolower);

	/* ppath_selected handler */
	write ("/* %s ppath-selected handler */\n", mod_name);
	write ("static axl_bool %s_ppath_selected (TurbulenceCtx * _ctx, TurbulencePPathDef * ppath_selected, VortexConnection * conn) {\n", tolower);
	node = axl_doc_get (doc, "/mod-def/source-code/ppath-selected");
	if (axl_node_get_content (node, NULL)) {
		/* write the content defined */
		write ("%s\n", axl_node_get_content (node, NULL));
	}
	write ("} /* end %s_ppath_selected */\n\n", tolower);

	/* write handler description */
	write ("/* Entry point definition for all handlers included in this module */\n");
	write ("TurbulenceModDef module_def = {\n");

	push_indent ();

	write ("\"%s\",\n", mod_name);
	node        = axl_doc_get (doc, "/mod-def/description");
	description = (char *) axl_node_get_content (node, NULL);
	write ("\"%s\",\n", description ? description : "");
	write ("%s_init,\n", tolower);
	write ("%s_close,\n", tolower);
	write ("%s_reconf,\n", tolower);
	write ("%s_unload,\n", tolower);
	write ("%s_ppath_selected\n", tolower);
	pop_indent ();

	write ("};\n\n");

	write ("END_C_DECLS\n\n");
	
	/* close content */
	support_close_file (ctx);

	/* create the makefile required */
	support_open_file (ctx, "%sMakefile.am", get_out_dir ());
	
	write ("# Module definition\n");
	write ("EXTRA_DIST = %s\n\n", exarg_get_string ("compile"));
	
	       
	write ("INCLUDES = -Wall -g -ansi $(TURBULENCE_CFLAGS) -I../../src -DCOMPILATION_DATE=`date +%%s` \\\n");
	push_indent ();
	
	write ("-DVERSION=\\\"$(VERSION)\\\" \\\n");
	write ("$(AXL_CFLAGS) $(VORTEX_CFLAGS) $(EXARG_CFLAGS)\n\n");
	pop_indent ();
	
	write ("# configure module binary\n");
	write ("lib_LTLIBRARIES      = %s.la\n", mod_name);
	write ("%s_la_SOURCES  = %s.c %s\n", mod_name, mod_name,
	       HAS_ATTR (moddef, "sources") ? ATTR_VALUE (moddef, "sources") : "");
	write ("%s_la_LDFLAGS  = -module -ldl\n\n", mod_name);
	
	write ("# reconfigure module installation directory\n");
	write ("libdir = `turbulence-config --mod-dir`\n\n");
	
	write ("# configure site module installation\n");
	write ("modconfdir   = `turbulence-config --mod-xml`\n");
	write ("modconf_DATA = %s.xml %s.win32.xml\n\n", mod_name, mod_name);
	
	write ("%s.xml %s.win32.xml:\n", mod_name, mod_name);
	push_indent ();
	write ("echo \"<mod-turbulence location=\\\"`turbulence-config --mod-dir`/%s.so\\\"/>\" > %s.xml\n", mod_name, mod_name);
	write ("echo \"<mod-turbulence location=\\\"../modules/%s.dll\\\"/>\" > %s.win32.xml\n", mod_name, mod_name);
	pop_indent ();

	support_close_file (ctx);

	/* create autoconf if defined */
	if (exarg_is_defined ("enable-autoconf")) {

		msg ("found autoconf support files request..");
		
		/* create the autogen.sh */
		support_open_file (ctx, "%sautogen.sh", get_out_dir ());

		write ("# autogen.sh file created by tbc-mod-gen\n");
		write ("PACKAGE=\"%s: %s\"\n\n", mod_name, description);

		write ("(automake --version) < /dev/null > /dev/null 2>&1 || {\n");

		push_indent ();
		write ("echo;\n");
		write ("echo \"You must have automake installed to compile $PACKAGE\";\n");
		write ("echo;\n");
		write ("exit;\n");
		pop_indent ();

		write ("}\n\n");

		write ("(autoconf --version) < /dev/null > /dev/null 2>&1 || {\n");
		push_indent ();
		write ("echo;\n");
		write ("echo \"You must have autoconf installed to compile $PACKAGE\";\n");
		write ("echo;\n");
		write ("exit;\n");
		pop_indent ();
		write ("}\n\n");

		write ("echo \"Generating configuration files for $PACKAGE, please wait....\"\n");
		write ("echo;\n\n");

		write ("touch NEWS README AUTHORS ChangeLog\n");
		write ("libtoolize --force;\n");
		write ("aclocal $ACLOCAL_FLAGS;\n");
		write ("autoheader;\n");
		write ("automake --add-missing;\n");
		write ("autoconf;\n\n");

		write ("./configure $@ --enable-maintainer-mode --enable-compile-warnings\n");

		support_close_file (ctx);

		support_make_executable (ctx, "%sautogen.sh", get_out_dir ());

		/* now create the configure.ac file */

		support_open_file (ctx, "%sconfigure.ac", get_out_dir ());

		write ("dnl configure.ac template file created by tbc-mod-gen\n");
		write ("AC_INIT(%s.c)\n\n", mod_name);

		write ("dnl declare a global version value\n");
		write ("%s_VERSION=\"0.0.1\"\n", toupper);
		write ("AC_SUBST(%s_VERSION)\n\n", toupper);

		write ("AC_CONFIG_AUX_DIR(.)\n");
		write ("AM_INIT_AUTOMAKE(%s, $%s_VERSION)\n\n", mod_name, toupper);

		write ("AC_CONFIG_HEADER(config.h)\n");
		write ("AM_MAINTAINER_MODE\n");
		write ("AC_PROG_CC\n");
		write ("AC_ISC_POSIX\n");
		write ("AC_HEADER_STDC\n");
		write ("AM_PROG_LIBTOOL\n\n");

		write ("dnl external dependencies\n");
		write ("PKG_CHECK_MODULES(AXL, axl >= %s)\n\n", AXL_VERSION);

		write ("dnl general libries subsitution\n");
		write ("AC_SUBST(AXL_CFLAGS)\n");
		write ("AC_SUBST(AXL_LIBS)\n\n");

		write ("dnl external dependencies\n");
		write ("PKG_CHECK_MODULES(VORTEX, vortex >= %s) \n\n", VORTEX_VERSION);

		write ("dnl general libries subsitution\n");
		write ("AC_SUBST(VORTEX_CFLAGS)\n");
		write ("AC_SUBST(VORTEX_LIBS)\n\n");

		write ("dnl external dependencies\n");
		write ("PKG_CHECK_MODULES(EXARG, exarg)\n\n");

		write ("dnl general libries subsitution\n");
		write ("AC_SUBST(EXARG_CFLAGS)\n");
		write ("AC_SUBST(EXARG_LIBS)\n\n");
		
		write ("dnl external dependencies\n");
		write ("PKG_CHECK_MODULES(TURBULENCE, turbulence >= %s)\n\n", VERSION);

		write ("dnl general libries subsitution\n");
		write ("AC_SUBST(TURBULENCE_CFLAGS)\n");
		write ("AC_SUBST(TURBULENCE_LIBS)\n\n");

		write ("AC_OUTPUT([\n");
		write ("Makefile\n");
		write ("])\n\n");

		write ("echo \"------------------------------------------\"\n");
		write ("echo \"--       mod_template Settings          --\"\n");
		write ("echo \"------------------------------------------\"\n");
		write ("echo \"------------------------------------------\"\n");
		write ("echo \"--            Let it BEEP!              --\"\n");
		write ("echo \"--                                      --\"\n");
		write ("echo \"--     NOW TYPE: make; make install     --\"\n");
		write ("echo \"------------------------------------------\"\n");

		support_close_file (ctx);
		
	} /* end if */

	/* dealloc */
	axl_free (tolower);
	axl_free (toupper);
	axl_doc_free (doc);

	/* create the script file */
	support_open_file (ctx, "%sgen-code", get_out_dir ());

	write ("#!/bin/sh\n\n");

	/* write the mod gen */
	write ("tbc-mod-gen --compile %s --out-dir %s\n", exarg_get_string ("compile"), exarg_get_string ("out-dir"));
	
	support_close_file (ctx);

	support_make_executable (ctx, "%sgen-code", get_out_dir ());

	msg ("%s created!", mod_name);
	axl_free (mod_name);

	return axl_true;
}