#!/bin/gawk -f # by Mike J Oropeza # Uses "POST" method of CGI invocation # # Variables E-Mail Format # ============= ============================== # [Issue Properties] # name Project Name=Call Tracking # title Title=Title of test bug report # type Type=NF (Feature Enhancement) # component Component=Documentation # version Version = 1.0 # platform Platform=Linux # OSVersion OS Version=2.6 # # [Issue Description] # Steps are here # Do this # Then do this # //Notice it does not work # # contact Contact=John Doe # company Company Name=Test Company # phone Phone=555-555-5555 # email Email=email@company BEGIN { printf "Content-type: text/html\n\n" # printf "\nCall Form Accepted\n" # printf "
\n"

	head["name"]="[Issue Properties]\nProject Name = "
	head["title"]="Title = "
	head["type"]="Type = "
	head["priority"]="Priority = 3-Medium"
	head["component"]="Component = " 
        head["version"]="Version = "
	head["platform"]="Platform = "
	head["OSVersion"]="OS Version = "
	head["desc"]="\n[Issue Description]\n"
	head["contact"]="\nContact = " 
	head["company"]="Company Name = "
	head["phone"]="Phone = "
	head["email"]="Email = "
	head["Submit"]=""

	getline callno < "callno"
	print ++callno > "callno"

	call="calls/"callno
}

function out( label ) {
	printf "%s%s\n", head[label], rvalue[label] > call
}
/^------------------------/ { next }

/^Content-Disposition: form-data;/ {
    if( length( line ) ) rvalue[lvalue]=line
	split($3,ref,"=")
	gsub("[\"\015]","",ref[2])

	lvalue=ref[2]
	getline
	getline line
	sub("\015","",line)
	next
}

{	line=sprintf( "%s\n%s", line, $0 ) }

END {
#	print "Call Reference Number: "callno

	out( "name" )
	out( "title" )
	out( "type" )
	out( "priority" )
	out( "component" )
        out( "version" )	
        out( "platform" )
	out( "OSVersion" )
	out( "desc" )
	out( "contact" )
	out( "company" )
	out( "phone" )
	out( "email" )

    system("mail -s \"[" callno "] " rvalue["title"] "\" support@synchronnetworks.com < "call )

	while( getline line < "ack.htm" == 1 ) {
		if( line ~ "copy body" ) {
			print "
"
			print "Call ID: "callno
			while( getline body < call == 1 )
				print body
			print "
" } else { print line } } # printf "
\n" }