all repos — cgit @ 6ec5f36f279a85f59db2851ab476d9acd0015770

a hyperfast web frontend for git written in c

Add html_option() function

This is a generic function used to output html "option" tags.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Lars Hjemli hjemli@gmail.com
Sun, 28 Oct 2007 12:08:45 +0100
commit

6ec5f36f279a85f59db2851ab476d9acd0015770

parent

0c8dd9c4bcc7a1a7a49f4eca1f3eb869d0995ea2

2 files changed, 13 insertions(+), 0 deletions(-)

jump to
M cgit.hcgit.h

@@ -204,6 +204,7 @@ extern void html_txt(char *txt);

extern void html_ntxt(int len, char *txt); extern void html_attr(char *txt); extern void html_hidden(char *name, char *value); +extern void html_option(char *value, char *text, char *selected_value); extern void html_link_open(char *url, char *title, char *class); extern void html_link_close(void); extern void html_filemode(unsigned short mode);
M html.chtml.c

@@ -126,6 +126,18 @@ html_attr(value);

html("'/>"); } +void html_option(char *value, char *text, char *selected_value) +{ + html("<option value='"); + html_attr(value); + html("'"); + if (selected_value && !strcmp(selected_value, value)) + html(" selected"); + html(">"); + html_txt(text); + html("</option>\n"); +} + void html_link_open(char *url, char *title, char *class) { html("<a href='");