c1.htm
     <html>
     <form action="/cgi-bin/c1.exe" method="get">
     <input type="submit" value="Click">
     </form>
     </html>
        
     #include <windows.h>
     #include <stdio.h>
     int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine, int nShow)
     {
     printf("Content-type: text/html\n\n\n");
     printf("Hello\n\n");
     return 0;
     }
     
     #include <windows.h>
     #include <stdio.h>
     int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine, int nShow)
     {
     printf("Content-type: text/html\n\n\n");
     printf("<b>Hello</b><p>");
     printf("<b>How are you</b><p>");
     return 0;
     }
     
     #include <windows.h>
     #include <stdio.h>
     char *p1,*p2,*p3,*p4;
     int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine, int nShow)
     {
     printf("Content-type: text/html\n\n\n");
     p1=getenv("SERVER_NAME") ;
     p2=getenv("SERVER_SOFTWARE");
     p3=getenv("SERVER_PROTOCOL");
     p4=getenv("SERVER_PORT");
     printf("Server :<p>");
     printf("SERVER_NAME: %s............SERVER_SOFTWARE: %s<p>",p1,p2);
     printf("SERVER_PROTOCOL: %s............SERVER_PORT: %s<p>",p3,p4);
     p1=getenv("REQUEST_METHOD") ;
     p2=getenv("SCRIPT_NAME");
     p3=getenv("DOCUMENT_ROOT") ;
     p4=getenv("QUERY_STRING");
     printf("REQUEST_METHOD : %s...............SCRIPT_NAME: %s<p>",p1,p2);
     printf("DOCUMENT_ROOT  : %s...............QUERY_STRING: %s<p>",p3,p4);
     p1=getenv("REMOTE_ADDR");
     p2=getenv("HTTP_ACCEPT");
     p3=getenv("HTTP_USER_AGENT");
     p4=getenv("HTTP_REFERER");
     printf("REMOTE_ADDR: %s<p>",p1);
     printf("HTTP_ACCEPT: %s<p>",p2);
     printf("HTTP_USER_AGENT: %s<p>",p3);
     printf("HTTP_REFERER: %s<p>",p4);
     return(0);
     }
     
     <html>
     <form action="/cgi-bin/c2.exe" method="get">
     <input type="text" name=a>
     <input type="text" name=b>
     <input type="submit" value="Click">
     </form>
     </html>
     
     #include <windows.h>
     #include <stdio.h>
     int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine, int nShow)
     {
     int i,j;
     char aa[100];
     char bb[100];
	 char *c;
     printf("Content-type: text/html\n\n\n");
     printf("lpszCmdLine..%s<p>",lpszCmdLine);
     c = getenv("QUERY_STRING");
     printf("QUERY_STRING %s<p>",getenv("QUERY_STRING"));
     for(i=0,j=0;c[i] != '&';i++,j++)
     aa[j]= c[i];
     aa[j]=0;
     i++;
     for(j=0;c[i] != '\0';i++,j++)
     bb[j]= c[i];
     bb[j]=0;
     printf("aa...... %s<p>",aa);
     printf("bb....... %s<p>",bb);
     return(0);
     }
     
     <HTML>
     <BODY>
     <h1> Ping </h1>
     <FORM action="/cgi-bin/c1.exe" method="GET">
     Enter the Name of the Server <br>
     <INPUT TYPE=TEXT NAME=a value="www.microsoft.com"><p>
     HOP No.<br>
     <INPUT TYPE=TEXT NAME=b value = "7">
     <INPUT type=submit value="Press me!">
     </FORM>
     </BODY>
     </HTML>
     
     #include <windows.h>
     #include <stdio.h>
     struct o
     {
	     unsigned char Ttl,Tos,Flags,OptionsSize,*OptionsData;
     };
     struct
     {
	     DWORD Address;
	     unsigned long  Status,RoundTripTime;
	     unsigned short DataSize,Reserved;
	     void *Data;
	     struct o  Options;
     } E;
     char *lp;
     HANDLE hIP;WSADATA wsa;HANDLE hIcmp;DWORD *dwIPAddr;struct hostent *phostent;
     DWORD d;char aa[100];struct o I;int i;int j;int k;
     HANDLE ( WINAPI *pIcmpCreateFile )( VOID );char p1[100],p2[100];
     BOOL ( WINAPI *pIcmpCloseHandle )( HANDLE );
     DWORD (WINAPI *pIcmpSendEcho)(HANDLE,DWORD,LPVOID,WORD,LPVOID,LPVOID,DWORD,DWORD);
	 char * ge;
     int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine, int nShow)
     {
     printf("Content-type: text/html\n\n\n");
	 ge = getenv("QUERY_STRING");
     lp=&ge[2];
     i=0;
     while ( *(lp+i) != '&')
     {
     p1[j]=*(lp+i);
     j++;i++;
     }
     i+=3;p1[j]=0;j=0;
     while ( *(lp+i) != '&'&& *(lp+i)!=0 )
     {
     p2[j]=*(lp+i);
     j++;i++;
     }
     p2[j]=0;
     k=atoi(p2);
     hIcmp = LoadLibrary( "ICMP.DLL" );
     d=WSAStartup( 0x0101, &wsa );
     pIcmpCreateFile=GetProcAddress( hIcmp,"IcmpCreateFile");
     pIcmpCloseHandle=GetProcAddress( hIcmp,"IcmpCloseHandle");
     pIcmpSendEcho =GetProcAddress( hIcmp,"IcmpSendEcho" );
     hIP = pIcmpCreateFile();
     I.Ttl=k;
     phostent = gethostbyname(p1);
     dwIPAddr = (DWORD *)( *phostent->h_addr_list );
     pIcmpSendEcho(hIP,*dwIPAddr,0,0,&I,&E,sizeof(E),8000 );
     d=E.Address;
     phostent = gethostbyaddr((char *)&d,4,PF_INET);
     printf("<center><h2>Result</h2></center><p>");
     printf("<hr><b>Host Computer :</b> %s <p>",p1);
     printf("<b>Hop no :</b> %s <p><hr>",p2);
     if ( phostent  != 0 )
     printf("%s <p>",phostent->h_name);
     else
     printf("No Name<p>");
     wsprintf(aa,"Round Trip Time : %dms,  Time To Live : %d",E.RoundTripTime,E.Options.Ttl );
     printf("%s <p>\n",aa);
     pIcmpCloseHandle( hIP );
     FreeLibrary( hIcmp );
     WSACleanup();
     return(0);
     }
     
     <HTML>
     <BODY>
     <h1> SMTP </h1>
     <FORM action="/cgi-bin/c1.exe" method="GET">
     Mail From:<br>
     <INPUT type=text name=a size=25 value="abc@aaa.com"><p>
     Mail To: <br>
     <INPUT type=text name=b size=25 value="vijay1@giasbm01.vsnl.net.in"><p>
     Text :<br>
     <textarea rows=4 cols=40 name=c>Enter your letter here</textarea><p>
     <INPUT type=submit value="Press me!">
     </FORM>
     </BODY>
     </HTML>
     
     #include <windows.h>
     #include <stdio.h>
     struct sockaddr_in A;WSADATA W;SOCKET S;char aa[100];int i;struct hostent *H;
     char R[10000],RR[10000];char aaa[100];
     void abc(char *p)
     {
     FILE * fp;
     fp = fopen("z.txt","a+");
     fprintf(fp,"%s",p);
     fclose(fp);
     }
     char p1[100],p2[100],p3[10000];char * lp;int i,j;char *ge;
     int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdLine, int nShow)
     {
     printf("Content-type: text/html \n\n\n");
     printf("<center><h1>Result</h1></center><hr>");
	 ge=getenv("QUERY_STRING");
     lp=&ge[2];
     i=0;
     while ( *(lp+i) != '&')
     {
     p1[j]=*(lp+i);
     j++;i++;
     }
     i+=3;p1[j]=0;j=0;
     while ( *(lp+i) != '&'&& *(lp+i)!=0 )
     {
     p2[j]=*(lp+i);
     j++;i++;
     }
     i+=3;p2[j]=0;j=0;
     while ( *(lp+i) != '&'&& *(lp+i)!=0 )
     {
     p3[j]=*(lp+i);
     j++;i++;
     }
     p3[j]=0;
     WSAStartup (0x101, &W);
     S = socket(AF_INET, SOCK_STREAM,0);
     A.sin_family=AF_INET;
     A.sin_port = htons(25);
     H=gethostbyname("giasbm01.vsnl.net.in");
     A.sin_addr.s_addr=*((unsigned long *) H->h_addr);
     i=connect(S,(struct sockaddr *) &A,sizeof(A));
     printf("connect %d <p>",i);
     i=recv(S,R,10000,0);
     printf("Recv: %d bytes <p> Data: %s<p> ",i,R);
     strcpy(R,"HELO vijay.com\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent: %s <p>",R);
     memset(&R,' ',10000);
     i=recv(S,R,10000,0);
     R[i]=0;
     printf("Recv :%d bytes<p> Data: %s<p>",i,R);
     strcpy(aa,"MAIL FROM:<");
     strcat(aa,p1);
     strcat(aa,">\r\n");
     strcpy(R,aa);
     i=send(S,R,strlen(R),0);
     strcpy(RR,"<b>Mail From:<br></b>");
     strcat(RR,p1);
     strcat(RR,"<p>");
     printf("%s",RR);
     memset(&R,' ',10000);
     i=recv(S,R,10000,0);
     R[i]=0;
     printf("Recv %d bytes<p> Data : %s<p>",i,R);
     strcpy(aa,"RCPT TO:<");
     strcat(aa,p2);
     strcat(aa,">\r\n");
     strcpy(R,aa);
     i=send(S,R,strlen(R),0);
     strcpy(RR,"<b>Mail To:<br></b>");
     strcat(RR,p2);
     strcat(RR,"<p>");
     printf("%s",RR);
     memset(&R,' ',10000);
     i=recv(S,R,10000,0);
     R[i]=0;
     printf("Recv: %d bytes <p> Data : %s<p>",i,R);
     strcpy(R,"DATA\r\n");
     i=send(S,R,strlen(R),0);
     strcpy(RR,"<b>DATA:<br></b>");
     for(j=0; p3[j]!=0;j++)
     {
             if(p3[j] == '+')
                     p3[j]=32;
     }
     strcat(RR,p3);
     strcat(RR,"<p>");
     printf("%s",RR);
     memset(&R,' ',10000);
     i=recv(S,R,10000,0);
     printf("Recv: %d bytes<p> Data : %s<p>",i,R);
     strcpy(R,"To:aaa.com\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent: %s<p> ",R);
     strcpy(R,"FROM:vijay1@giasbm01.vsnl.net.in\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent: %s <p>",R);
     strcpy(R,"DATE:15 Aug 96 09:24 IST\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent: %s<p> ",R);
     strcpy(R,"MESSAGE_ID:<123@e.com>\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent: %s<p> ",R);
     for(j=0; p3[j]!=0;j++)
     {
             if(p3[j] == '+')
                     p3[j]=32;
     }
     strncpy(R,p3,j);
     strcat(R,"\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent: %s  <p>",R);
     memset(&R,' ',10000);
     strcpy(R,".\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent : %s <p> ",R);
     i=recv(S,R,10000,0);
     printf("Recv: %d bytes <p> Data: %s<p>",i,R);
     strcpy(R,"QUIT\r\n");
     i=send(S,R,strlen(R),0);
     printf("Sent : %s<p> ",R);
     i=recv(S,R,10000,0);
     printf("Recv: %d bytes <p> Data: %s",i,R);
     return 0;
     }
     Move back to the Vijay Mukhi's Technology Cornucopia Page to learn more about the other new Internet Technologies.