This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

99
getpage/ENTRY.HPP Normal file
View File

@@ -0,0 +1,99 @@
#ifndef _HTTP_ENTRYITEM_HPP_
#define _HTTP_ENTRYITEM_HPP_
#ifndef _COMMON_STRING_HPP_
#include <common/string.hpp>
#endif
#ifndef _COMMON_BLOCK_HPP_
#include <common/block.hpp>
#endif
class EntryItem
{
public:
EntryItem(void);
EntryItem(const EntryItem &entryItem);
EntryItem(const String &hostName,const String &pageName,const String &saveAs);
EntryItem &operator=(const EntryItem &entryItem);
BOOL operator==(const EntryItem &entryItem)const;
const String &hostName(void)const;
void hostName(const String &hostName);
const String &pageName(void)const;
void pageName(const String &pageName);
const String &saveAs(void)const;
void saveAs(const String &saveAs);
private:
String mHostName;
String mPageName;
String mSaveAs;
};
inline
EntryItem::EntryItem(void)
{
}
inline
EntryItem::EntryItem(const EntryItem &entryItem)
: mHostName(entryItem.hostName()), mPageName(entryItem.pageName()), mSaveAs(entryItem.saveAs())
{
}
inline
EntryItem::EntryItem(const String &hostName,const String &pageName,const String &saveAs)
: mHostName(hostName), mPageName(pageName), mSaveAs(saveAs)
{
}
inline
EntryItem &EntryItem::operator=(const EntryItem &entryItem)
{
hostName(entryItem.hostName());
pageName(entryItem.pageName());
saveAs(entryItem.saveAs());
return *this;
}
inline
BOOL EntryItem::operator==(const EntryItem &entryItem)const
{
return (hostName()==entryItem.hostName()&&
pageName()==entryItem.pageName()&&
saveAs()==entryItem.saveAs());
}
inline
const String &EntryItem::hostName(void)const
{
return mHostName;
}
inline
void EntryItem::hostName(const String &hostName)
{
mHostName=hostName;
}
inline
const String &EntryItem::pageName(void)const
{
return mPageName;
}
inline
void EntryItem::pageName(const String &pageName)
{
mPageName=pageName;
}
inline
const String &EntryItem::saveAs(void)const
{
return mSaveAs;
}
inline
void EntryItem::saveAs(const String &saveAs)
{
mSaveAs=saveAs;
}
#endif

108
getpage/getpage.dsp Normal file
View File

@@ -0,0 +1,108 @@
# Microsoft Developer Studio Project File - Name="getpage" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=getpage - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "getpage.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "getpage.mak" CFG="getpage - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "getpage - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "getpage - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "getpage - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "getpage - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "msvcobj"
# PROP Intermediate_Dir "msvcobj"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS.STRICT" /D "__FLAT__" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "getpage - Win32 Release"
# Name "getpage - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\mainpage.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

74
getpage/getpage.dsw Normal file
View File

@@ -0,0 +1,74 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "common"=..\common\common.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "fileio"=..\fileio\fileio.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "getpage"=.\getpage.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name common
End Project Dependency
Begin Project Dependency
Project_Dep_Name fileio
End Project Dependency
Begin Project Dependency
Project_Dep_Name socket
End Project Dependency
}}}
###############################################################################
Project: "socket"=..\socket\socket.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

BIN
getpage/getpage.ncb Normal file

Binary file not shown.

BIN
getpage/getpage.opt Normal file

Binary file not shown.

36
getpage/getpage.plg Normal file
View File

@@ -0,0 +1,36 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: getpage - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\sean\LOCALS~1\Temp\RSPC.tmp" with contents
[
/nologo /Gz /MTd /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS.STRICT" /D "__FLAT__" /Fo"msvcobj/" /Fd"msvcobj/" /FD /GZ /c
"D:\work\getpage\mainpage.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\sean\LOCALS~1\Temp\RSPC.tmp"
Creating temporary file "C:\DOCUME~1\sean\LOCALS~1\Temp\RSPD.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib wsock32.lib /nologo /subsystem:console /incremental:yes /pdb:"msvcobj/getpage.pdb" /debug /machine:I386 /out:"msvcobj/getpage.exe" /pdbtype:sept
.\msvcobj\mainpage.obj
\work\exe\mscommon.lib
\work\exe\msfileio.lib
\work\exe\mssocket.lib
]
Creating command line "link.exe @C:\DOCUME~1\sean\LOCALS~1\Temp\RSPD.tmp"
<h3>Output Window</h3>
Compiling...
mainpage.cpp
Linking...
LINK : LNK6004: msvcobj/getpage.exe not found or not built by the last incremental link; performing full link
<h3>Results</h3>
getpage.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

7
getpage/jazz001.mid Normal file
View File

@@ -0,0 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>302 Found</TITLE>
</HEAD><BODY>
<H1>Found</H1>
The document has moved <A HREF="http://www.classicalmidiconnection.com/cgibin/x.cgi?mid/jaz/jazz001.mid">here</A>.<P>
</BODY></HTML>

262
getpage/mainpage.cpp Normal file
View File

@@ -0,0 +1,262 @@
#include <common/mdifrm.hpp>
#include <getpage/entry.hpp>
#include <common/string.hpp>
#include <common/openfile.hpp>
#include <common/filemap.hpp>
#include <common/pview.hpp>
#include <common/openfile.hpp>
#include <common/profile.hpp>
#include <common/file.hpp>
#include <common/stdio.hpp>
#include <socket/hostent.hpp>
#include <socket/servent.hpp>
#include <socket/intsaddr.hpp>
#include <socket/socket.hpp>
#include <fileio/fileio.hpp>
WORD open(const String &hostName,const String &nameFile);
WORD open(const String &hostName,const String &nameString,const String &saveAs);
WORD makeFileName(String &pathFileName);
BOOL getEntryItems(const String &pathFileName,Block<EntryItem> &entryItems);
void replaceSpace(String &string);
class Console
{
public:
Console();
void writeLine(const String &string);
void read();
};
Console::Console()
{
}
void Console::writeLine(const String &string)
{
printf("%s\n",string.str());
}
void Console::read()
{
char buffer[32];
sscanf("%s",buffer);
}
Console winConsole;
// for when i do a post request
//POST /cgi-bin/phone_book.cgi HTTP/1.0
//
//Referer: http://www.somedomain.com/Direcory/file.html
//
//User-Agent: Mozilla/1.22 (Windows: I: 32bit)
//
//Accept */*
//
//Content-type: application/x-www-form-urlencoded
//
//Content-length: 29
//
//
//
//name=Selena+Sol&phone=7700404
//
//
int main(int argc,char **argv)
{
String pathFileName(argv[1]);
Block<EntryItem> entryItems;
if(pathFileName.isNull())
{
winConsole.writeLine("GETPAGE <inputfile>");
winConsole.writeLine("Input file is a text file that contains entries in the following format...");
winConsole.writeLine("<hostname> <pagename> <saveas>");
winConsole.writeLine("for example...");
winConsole.writeLine("\"www.developer.com\" \"http://www.developer.com/reference/foo.htm\" \"c:\\developer\\docs\\foo.html\"");
winConsole.writeLine("a '#' character located in the first position of any line indicates a comment, the line is ignored.");
winConsole.writeLine("Press ENTER to exit.");
winConsole.read();
return FALSE;
}
if(!getEntryItems(pathFileName,entryItems))
{
winConsole.writeLine("Failed to read input file");
winConsole.writeLine("Press ENTER to exit");
winConsole.read();
return FALSE;
}
for(int itemIndex=0;itemIndex<entryItems.size();itemIndex++)
{
EntryItem &entryItem=entryItems[itemIndex];
open(entryItem.hostName(),entryItem.pageName(),entryItem.saveAs());
}
winConsole.writeLine("Done...");
winConsole.writeLine("Press ENTER to exit.");
winConsole.read();
return FALSE;
}
WORD open(const String &hostName,const String &nameString)
{
INETSocketAddress internetSocketAddress;
String getRequest;
HostEnt hostEntry;
ServEnt serverEntry;
WSASystem wsaSystem;
Socket httpControl;
getRequest="GET ";
winConsole.writeLine(String("trying ")+hostName+String("..."));
if(!wsaSystem.isInitialized()){winConsole.writeLine("WINSOCK initialization failure.");return FALSE;}
InternetAddress internetAddress(hostName);
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){return FALSE;}}
else if(!hostEntry.hostByName(hostName)){return FALSE;}
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){winConsole.writeLine(String("no DNS entry for ")+hostName);return FALSE;}}
else if(!hostEntry.hostByName(hostName)){winConsole.writeLine(String("no DNS entry for ")+hostName);return FALSE;}
winConsole.writeLine(String("connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")"));
internetSocketAddress.internetAddress((hostEntry.addresses())[0]);
if(serverEntry.serviceByName("http","tcp"))
{
if(!httpControl.create()){winConsole.writeLine("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(serverEntry.port());
}
else
{
if(!httpControl.create()){winConsole.writeLine("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(htons(80));
}
if(!httpControl.connect(internetSocketAddress)){winConsole.writeLine("unable to connect to http daemon");return FALSE;}
httpControl.getSocketName(internetSocketAddress);
getRequest+=nameString;
winConsole.writeLine(getRequest);
getRequest+="\n";
httpControl.send(getRequest);
TimeInfo timeInfo;
String saveFile(nameString);
makeFileName(saveFile);
winConsole.writeLine(String("'")+saveFile+String("'"));
httpControl.receiveBinary(saveFile,25000000,timeInfo);
return httpControl.isConnected();
}
WORD open(const String &hostName,const String &nameString,const String &saveAs)
{
INETSocketAddress internetSocketAddress;
String getRequest;
HostEnt hostEntry;
ServEnt serverEntry;
WSASystem wsaSystem;
Socket httpControl;
getRequest="GET ";
winConsole.writeLine(String("trying ")+hostName+String("..."));
if(!wsaSystem.isInitialized()){winConsole.writeLine("WINSOCK initialization failure.");return FALSE;}
InternetAddress internetAddress(hostName);
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){return FALSE;}}
else if(!hostEntry.hostByName(hostName)){winConsole.writeLine(String("unable to contact host '")+hostName+String("'"));return FALSE;}
if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){winConsole.writeLine(String("no DNS entry for ")+hostName);return FALSE;}}
else if(!hostEntry.hostByName(hostName)){winConsole.writeLine(String("no DNS entry for ")+hostName);return FALSE;}
winConsole.writeLine(String("connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")"));
internetSocketAddress.internetAddress((hostEntry.addresses())[0]);
if(serverEntry.serviceByName("http","tcp"))
{
if(!httpControl.create()){winConsole.writeLine("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(serverEntry.port());
}
else
{
if(!httpControl.create()){winConsole.writeLine("unable to create socket.");return FALSE;}
internetSocketAddress.family(PF_INET);
internetSocketAddress.port(80);
}
if(!httpControl.connect(internetSocketAddress)){winConsole.writeLine("unable to connect to http daemon");return FALSE;}
httpControl.getSocketName(internetSocketAddress);
getRequest+=nameString;
getRequest+=" HTTP/1.0\n";
winConsole.writeLine(getRequest);
httpControl.send(getRequest);
TimeInfo timeInfo;
winConsole.writeLine(String("'")+saveAs+String("'"));
// char ch;
// int count=1;
// while(httpControl.receive(&ch,1,true))printf("%c",ch);
/* Block<String> receiveStrings;
httpControl.receivePage(receiveStrings);
for(int index=0;index<receiveStrings.size();index++)
{
winConsole.writeLine(receiveStrings[index]);
}
*/
httpControl.receiveImage(saveAs,timeInfo);
httpControl.receiveBinary(saveAs,25000000,timeInfo);
return httpControl.isConnected();
}
WORD makeFileName(String &pathFileName)
{
String tempString(pathFileName);
char *ptr;
ptr=::strchr(tempString,'.');
if(!ptr)return FALSE;
while(*ptr!='\\'&&*ptr!='/'&&*ptr!=':'&&ptr>=(char*)tempString)ptr--;
pathFileName=(++ptr);
return TRUE;
}
BOOL getEntryItems(const String &pathFileName,Block<EntryItem> &entryItems)
{
File inFile;
String strLine;
entryItems.remove();
inFile.open(pathFileName,"rb");
if(!inFile.isOkay())return FALSE;
strLine.reserve(512);
while(inFile.readLine(strLine))
{
if('#'==*(char*)strLine)continue;
String host=strLine.betweenString('\"','\"');
host=host.trimLeft().trimRight();
String page=strLine.betweenString('\"',0).betweenString('\"',0).betweenString('\"','\"');
replaceSpace(page);
page=page.trimLeft().trimRight();
String saveAs=strLine.betweenString('\"',0).betweenString('\"',0).betweenString('\"',0).betweenString('\"',0).betweenString('\"','\"');
saveAs=saveAs.trimLeft().trimRight();
entryItems.insert(&EntryItem(host,page,saveAs));
}
return entryItems.size()?TRUE:FALSE;
}
void replaceSpace(String &string)
{
int position;
String replace="%20";
while(-1!=(position=string.strchr(' ')))
{
String tmp=string.substr(0,position-1);
String tmp2=string.substr(position+1,string.length());
winConsole.writeLine(String("'")+tmp+String("'"));
winConsole.writeLine(String("'")+tmp2+String("'"));
string=tmp+replace+tmp2;
winConsole.writeLine(String("'")+string+String("'"));
}
}