/* (c) steve at steve dash parker dot org Released under GPL version 2 (http://www.gnu.org/copyleft/gpl.html) This program is free software; you can redistribute it and/or modify it under the terms of Version 2 of the the GNU General Public License as published by the Free Software Foundation. Any later versions of the GPL will be evaluated as they are released, and this software may or may not be re-released under those terms also. 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 along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA See the included file COPYING for more details. */ #include void virt_inc(char *filename) { FILE *f; char s[255]; f=fopen(filename, "r"); if (f) { while (fgets(s, 255, f)) printf("%s\n", s); fclose(f); } } void show_html_header() { printf("Content-type: text/html\n\nAlcCalc\n"); //printf("\n"); virt_inc("/path/to/leftframe.shtml"); } void show_form() { printf("
"); printf("
Volume: ml ... (1 pint=568ml, 1 litre=1000ml)
Quantity: ... how many cans, bottles, glasses, etc
ABV: %% ... The ABV rating (eg Boddingtons = 3.8%)
\n"); } void process_data(int vol, int qty, float abv) { int ml; float alc; float units; int min; ml=vol*qty; alc=ml*abv/100; units = alc/10; min=units*60; //printf("Total ml : %d
\n", ml); //printf("Total alc: %02.02f ml
\n", alc); //printf("Total units: %02.02f units
\n", units); //printf("Time: %02d h %02d m", min/60, min%60); printf("%d x %d ml at %01.01f% = %02.02f units, or %02dh %02dm
\n", qty, vol, abv, units, min/60, min%60); } int main() { int i; char qs[255]; int vol, qty; float abv; fgets(qs, 255, stdin); show_html_header(); for (i=0; i\n"); } show_form(); //printf("\n"); virt_inc("/path/to/bottom.html"); printf("\n"); return 0; }