Back to index

courier  0.68.2
cgicheckbox.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2007 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 /*
00007 */
00008 
00009 #include      "cgi.h"
00010 #include      <stdio.h>
00011 #include      <string.h>
00012 #include      <stdlib.h>
00013 #include      <ctype.h>
00014 
00015 char *cgi_checkbox(const char *name,
00016                  const char *value,
00017                  const char *flags)
00018 {
00019        char *buf;
00020 
00021        if (!value)
00022               value="";
00023 
00024        buf=malloc(strlen(name)+strlen(flags)+200);
00025 
00026        if (!buf)
00027               return NULL;
00028 
00029        strcpy(buf, "<input type='checkbox' name='");
00030        strcat(buf, name);
00031        strcat(buf, "' value='");
00032        strcat(buf, value);
00033        strcat(buf, "'");
00034 
00035        if (strchr(flags, '*'))
00036               strcat(buf, " checked='checked'");
00037        if (strchr(flags, 'd'))
00038               strcat(buf, " disabled='disabled'");
00039        strcat(buf, " />");
00040        return buf;
00041 }