//---------------------------------------------------------------------------- // // Copyright (C) 2004 Intel Corporation // // File: CommonDefinitions.h // // Contents: Sample code for an Intel� AMT Network client. // // Notes: This file contains type, function and constant definitions // used throughout the code of the all sample applications. // //---------------------------------------------------------------------------- #ifndef COMMON_DEFINITIONS_H #define COMMON_DEFINITIONS_H #include "StatusCodeDefinitions.h" #if defined (_WIN32) || defined (_WIN64) #include "StatusStrings.h" #include #else /* * httpDigest.h for gSoap HTTP Digest support */ //#include "httpDigest.h" #endif #include /* * Function prototypes */ void PrintAuthenticationNote(); bool CheckReturnStatus(unsigned int res, unsigned long status,const char *message); bool ValidateIP(const char *uri); void GetString(char *msg, char *s, bool hidden); bool DisplayWarning(const char *msg); bool GetNumber(int *number); void ReplaceSubstring(const char *oldString,const char *oldSubstr, const char *newSubstr, char *newString); void SetIPAddress(unsigned long &address, unsigned long bytes[]); void NumberToIP(unsigned long address, unsigned long bytes[]); void NumberToString(unsigned long number, char *string); void IpToString(unsigned long address, char *string); void StringToIP(const char *string, unsigned long &address); void GuidToString(const unsigned char* guid, char* string); bool ExtractIPFromUri(const char *uri, char *baseUrl); void IsEmulator(const char *targetUrl, int *isEmulator); bool GetOption(int *commandLineLength, char *argv[], int numOfArgs, char **option, char ***commandLine); void PrintSuccess(bool print = true); void FunctionCall(const char *message); // struct that allow to compare two version struct Version { //compare the string version to int members Version(std::string versionStr) { sscanf(versionStr.c_str(), "%d.%d.%d.%d", &major, &minor, &revision, &build); } bool operator<(const Version &otherVersion) { if(major < otherVersion.major) return true; if(major > otherVersion.major) return false; // major equal if(minor < otherVersion.minor) return true; if(minor > otherVersion.minor) return false; // minor equal if(revision < otherVersion.revision) return true; if(revision > otherVersion.revision) return false; //revision equal if(build < otherVersion.build) return true; return false; } bool operator==(const Version &otherVersion) { if(major == otherVersion.major && minor == otherVersion.minor && revision == otherVersion.revision && build == otherVersion.build) return true; return false; } bool operator>(const Version &otherVersion) { if(major > otherVersion.major) return true; if(major < otherVersion.major) return false; // major equal if(minor > otherVersion.minor) return true; if(minor < otherVersion.minor) return false; // minor equal if(revision > otherVersion.revision) return true; if(revision < otherVersion.revision) return false; //revision equal if(build > otherVersion.build) return true; return false; } int major, minor, revision, build; }; #if defined (_WIN32) || defined (_WIN64) bool ParseCommandLine(int commandLineLength,char* commandLine[],char **target, char **certName, bool *local, bool *krb,bool *verbose = NULL, char **username = NULL, char **password = NULL,char **proxy = NULL, char **proxyUserName = NULL ,char **proxyPassWord = NULL); #define CHAR _TCHAR #else bool ParseCommandLine(int commandLineLength,char* commandLine[],char **target, char **certName = NULL,char **certPass = NULL, bool *verbose = NULL, char **username = NULL, char **password = NULL, char **proxy = NULL, char **proxyUserName = NULL ,char **proxyPassWord = NULL); #define CHAR char #endif /* * Constants for the common use */ static const int MAX_LINE_LEN = 1024; static const int TIMEOUT = 80; //static const int AMT_SECURE_PORT = 16993; //static const int AMT_UNSECURE_PORT = 16992; static const char *DEFAULT_USERNAME = "admin"; static const char *DEFAULT_PASSWORD = "admin"; static const char *CERT_NAME = "-cert"; static const char *PROXY = "-proxy"; static const char *USER = "-user"; static const char *PASS = "-pass"; static const char* HOST = "-host"; static const char* COMMON_NAME = "-commonName"; static const char *VERBOSE = "-verbose"; static const char *PROXY_USER_NAME = "-proxyUserName"; static const char *PROXY_PASSWORD = "-proxyPassword"; static const char *PROXY_SOCKS = "-proxySocks"; static const char* PROXY_SOCKS_USER_NAME = "-proxySocksUserName"; static const char* PROXY_SOCKS_PASSWORD = "-proxySocksPass"; #if defined (_WIN32) || defined (_WIN64) static const char *LOCAL = "-local"; static const char *KRB = "-krb"; #else static const char *CERT_PASS = "-certPass"; #endif #define OID_LOCAL "2.16.840.1.113741.1.2.2" #define OID_REMOTE "2.16.840.1.113741.1.2.1" #endif