00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <netdb.h>
00026 #include <Basics.H>
00027 #include "OS.H"
00028 #include "FS.H"
00029
00030 using std::cout;
00031 using std::endl;
00032
00033 int main()
00034 {
00035 static struct hostent *hp;
00036 char hostname[MAXHOSTNAMELEN+1];
00037 sockaddr_in hostsock;
00038
00039 if (gethostname(hostname, sizeof(hostname)-1) == SYSERROR)
00040 return errno;
00041
00042 cout << "My hostname is " << hostname << "\n";
00043
00044 if ((hp = gethostbyname(hostname)) == NULL)
00045 return errno;
00046
00047 bzero((char *)&hostsock, sizeof(hostsock));
00048 memcpy((char *)&(hostsock.sin_addr.s_addr), hp->h_addr, hp->h_length);
00049 endhostent();
00050
00051 cout << "My IP address is " << inet_ntoa_r(hostsock.sin_addr) << "\n";
00052
00053
00054
00055
00056 if(FS::IsDirectory("/"))
00057 {
00058 cout << "FS::IsDirectory seems to work" << endl;
00059 }
00060 else
00061 {
00062 cout << "FS::IsDirectory(\"/\") returned false" << endl;
00063 return errno || 1;
00064 }
00065
00066 if(FS::IsFile("/etc/passwd"))
00067 {
00068 cout << "FS::IsFile seems to work" << endl;
00069 }
00070 else
00071 {
00072 cout << "FS::IsFile(\"/etc/passwd\") returned false" << endl;
00073 return errno || 1;
00074 }
00075
00076 if(FS::Exists("/dev/null") && !FS::IsDirectory("/dev/null") && !FS::IsFile("/dev/null"))
00077 {
00078 cout << "FS::Exists seems to work" << endl;
00079 }
00080 else
00081 {
00082 cout << "Problem with FS::Exists/IsDirectory/IsFile test on /dev/null" << endl;
00083 return errno || 1;
00084 }
00085
00086 unsigned long total, resident;
00087 OS::GetProcessSize(total, resident);
00088 cout << "Total process size: " << total << endl
00089 << "Resident process size: " << resident << endl;
00090
00091 return 0;
00092 }
00093
00094