Forum Discussion
Altera_Forum
Honored Contributor
19 years agohi zzh
don't give up, try this simple example : ************* html code : index.html****************** <FORM method="get" ACTION="mult.cgi" > Please specify the multiplicands: <INPUT NAME="m" SIZE="5"> <INPUT NAME="n" SIZE="5"> <INPUT TYPE="SUBMIT" VALUE="Multiply!"> </FORM> **************************************** ************** cgi code : mult.c****************** # include <stdio.h># include <stdlib.h> int main(void) { char *data; long m,n; printf("%s%c%c\n", "Content-Type:text/html;charset=iso-8859-1",13,10); printf("<TITLE>Multiplication results</TITLE>\n"); printf("<H3>Multiplication results</H3>\n"); data = getenv("QUERY_STRING"); if(data == NULL) printf(" Error! Error in passing data from form to script."); else if(sscanf(data,"m=%ld&n=%ld",&m,&n)!=2) printf(" Error! Invalid data. Data must be numeric."); else printf(" The product of %ld and %ld is %ld.",m,n,m*n); return 0; } ****************************************************** ******************** Makefile : Makefile***********************# # configurable options# - set DEBUG = 1 to turn on debugging support# DEBUG = 1 PROJ_NAME = mult INSTALL_DIR = PROGS := $(PROJ_NAME).exe CFLAGS += # # You should not need to modify anything beyond this point# TOPDIR = . include ./Rules.mak ifeq '$(DEBUG)' '1' PROGS += $(PROGS:.exe=.gdb) endif all: $(PROGS) .PHONY: clean clean: -rm -f *.[oad] *.elf *.gdb *.bin *.exe .PHONY: install install: all ifeq "$(INSTALL_DIR)" "" $(error No installation directory specified) endif mkdir -p $(INSTALL_DIR)/bin install -v $(filter %.exe, $(PROGS)) $(INSTALL_DIR)/bin *************************************************************** steps to follow : --> create a new uclinux application --> add "mult.c" and "Makefile" to project --> right click on project : -- creat make target --> yes -- build make target --> if compilation success it will create a multi.exe --> add "index.html" and "mult.exe" to httpd derictory on file system --> rename "mult.exe" by "mult.cgi" and go ! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif