本文整理汇总了C++中PrintErrorMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ PrintErrorMessage函数的具体用法?C++ PrintErrorMessage怎么用?C++ PrintErrorMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PrintErrorMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddIPv4ToFilter
TApiStatus AddIPv4ToFilter(TFilterData* filter,
TIPAddressType addr_type, char* ip_addr, int mask)
{
// Convert IPv4 string address to struct
if(strlen(ip_addr) >= INET_ADDRSTRLEN)
{
PrintErrorMessage("AddIPv4ToFilter", "IP address is too long");
return API_ERROR;
}
// Check mask
if(mask < 0 || mask > 32)
{
PrintErrorMessage("AddIPv4ToFilter", "Mask is out of {0,1,...,32}");
return API_ERROR;
}
// Save to data structure
switch(addr_type)
{
case SRC:
filter->src_ip = ip_addr;
filter->src_mask = mask;
break;
case DST:
filter->dst_ip = ip_addr;
filter->dst_mask = mask;
break;
default:
PrintErrorMessage("AddIPv4ToFilter", "Wrong address type");
return API_ERROR;
}
return API_OK;
}
示例2: Call
bool LuaManager::ProtectedCall(int narg, int nresults)
{
try
{
Call(narg, nresults);
}
catch (luabind::error e)
{
m_bSuccess = false;
if (lua->IsString())
{
PrintErrorMessage(lua->GetString(), true, true);
lua->Pop();
}
else
PrintErrorMessage("LuaManager::ProtectedCall failed - luabind::error thrown, but not error message in stack!", true, false);
}
catch (...)
{
PrintErrorMessage("LuaManager::ProtectedCall failed - Unhandled Exception", true, true);
m_bSuccess = false;
}
return m_bSuccess;
}
示例3: AddPortToFilter
TApiStatus AddPortToFilter(TFilterData* filter,
TIPAddressType addr_type, int port)
{
// Check port
if(port < 0 || port > 65535)
{
PrintErrorMessage("AddPortToFilter", "Port is out of {0,1,...,65535}");
return API_ERROR;
}
// Save to data structure
switch(addr_type)
{
case SRC:
filter->src_port = port;
break;
case DST:
filter->dst_port = port;
break;
default:
PrintErrorMessage("AddPortToFilter", "Wrong port type");
return API_ERROR;
}
return API_OK;
}
示例4: SetInterfaceOnNetworkElement
TApiStatus SetInterfaceOnNetworkElement(TNetworkElement* element,
char* interface)
{
onep_status_t rc;
// Discover active interfaces if needed
if(element->interfaces == NULL)
{
TApiStatus s = GetInterfacesOnNetworkElement(element);
if(s != API_OK)
{
PrintErrorMessage("SetInterfaceOnNetworkElement", "get interfaces");
return API_ERROR;
}
}
// Set interface
TInterfaceItem* intf_item = (TInterfaceItem*)(malloc(sizeof(TInterfaceItem)));
rc = onep_element_get_interface_by_name(element->ne, interface, &(intf_item->interface));
if (rc != ONEP_OK) {
PrintErrorMessage("SetInterfaceOnNetworkElement", onep_strerror(rc));
return API_ERROR;
}
// Add it to list
intf_item->next = element->interface_list;
element->interface_list = intf_item;
return API_OK;
}
示例5: ADCSendCommand
/* ===================================================================*/
LDD_TError ADCSendCommand(byte* cmd, uint8 len)
{
LDD_TError err;
/* Check the command. */
err = CheckCommand(*cmd, len);
if(err != ERR_OK)
{
PrintErrorMessage(err);
return err;
}
/* Prepare the buffer of command transmitted to ADC. */
err = SPI1Send(cmd, len);
if(err != ERR_OK)
{
PrintErrorMessage(err); /* If error occurred, print the error message, */
return err; /* then return error type. */
}
/* Enable the SPI transmission interrupt to transmit. */
SPI1EnableTxInterrupt();
return err;
}
示例6: PrintErrorMessage
void Preprocessor::ParsePragma( LexemList& args )
{
args.pop_front();
if( args.empty() )
{
PrintErrorMessage( "Pragmas need arguments." );
return;
}
std::string p_name = args.begin()->Value;
args.pop_front();
std::string p_args;
if( !args.empty() )
{
if( args.begin()->Type != Lexem::STRING )
PrintErrorMessage( "Pragma parameter should be a string literal." );
p_args = RemoveQuotes( args.begin()->Value );
args.pop_front();
}
if( !args.empty() )
PrintErrorMessage( "Too many parameters to pragma." );
Pragmas.push_back( p_name );
Pragmas.push_back( p_args );
Pragma::Instance pi;
pi.Text = p_args;
pi.CurrentFile = CurrentFile;
pi.CurrentFileLine = LinesThisFile;
pi.RootFile = RootFile;
pi.GlobalLine = CurrentLine;
if( CurPragmaCallback )
CurPragmaCallback->CallPragma( p_name, pi );
}
示例7: NPTSolverExecute
INT NPTSolverExecute (NP_BASE *theNP, INT argc , char **argv)
{
NP_T_SOLVER *np;
INT result,level;
np = (NP_T_SOLVER *) theNP;
level = CURRENTLEVEL(theNP->mg);
if (np->y == NULL) {
PrintErrorMessage('E',"NPTSolverExecute","no vector y");
return (1);
}
if (np->tass == NULL) {
PrintErrorMessage('E',"NPTSolverExecute","no assemble num proc");
return (1);
}
if (np->nlsolve == NULL) {
PrintErrorMessage('E',"NPTSolverExecute","no solver num proc");
return (1);
}
if (ReadArgvOption("i",argc,argv)) {
if (*np->TimePreProcess != NULL)
if ((*np->TimePreProcess)(np,level,&result)) {
UserWriteF("NPTSolverExecute: TimePreProcess failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("0",argc,argv)) {
if (*np->TimeInit != NULL)
if ((*np->TimeInit)(np,level,&result)) {
UserWriteF("NPTSolverExecute: TimeInit failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("s",argc,argv)) {
if (*np->TimeStep != NULL)
if ((*np->TimeStep)(np,level,&result)) {
UserWriteF("NPTSolverExecute: TimeStep failed, error code %d\n",
result);
return (1);
}
}
if (ReadArgvOption("p",argc,argv)) {
if (*np->TimePostProcess != NULL)
if ((*np->TimePostProcess)(np,level,&result)) {
UserWriteF("NPTSolverExecute: TimePostProcess failed, error code %d\n",
result);
return (1);
}
}
return(0);
}
示例8: OpenAndMergeVHD
BOOL OpenAndMergeVHD(PCWSTR pszVhdPath)
{
BOOL bRet = FALSE;
DWORD ret;
HANDLE hVhd;
MERGE_VIRTUAL_DISK_PARAMETERS mparms;
OPEN_VIRTUAL_DISK_PARAMETERS oparms;
MERGE_VIRTUAL_DISK_FLAG flags = MERGE_VIRTUAL_DISK_FLAG_NONE;
VIRTUAL_STORAGE_TYPE vst =
{
VIRTUAL_STORAGE_TYPE_DEVICE_VHD,
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT
};
wprintf(L"OpenAndMergeVHD %s\n", pszVhdPath);
oparms.Version = OPEN_VIRTUAL_DISK_VERSION_1;
oparms.Version1.RWDepth = 2;
ret = OpenVirtualDisk(&vst, pszVhdPath,
VIRTUAL_DISK_ACCESS_METAOPS | VIRTUAL_DISK_ACCESS_GET_INFO,
OPEN_VIRTUAL_DISK_FLAG_NONE, &oparms, &hVhd);
if (ERROR_SUCCESS == ret)
{
printf("success opening vdisk...\n");
mparms.Version = MERGE_VIRTUAL_DISK_VERSION_1;
mparms.Version1.MergeDepth = oparms.Version1.RWDepth - 1; //MERGE_VIRTUAL_DISK_DEFAULT_MERGE_DEPTH;
ret = MergeVirtualDisk(hVhd, flags, &mparms, NULL);
if (ERROR_SUCCESS == ret)
{
printf("success merging vdisk...\n");
bRet = TRUE;
}
else
{
printf("failed to expand vdisk... %d\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
}
else
{
printf("failed to open vdisk...err %d\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
if (INVALID_HANDLE_VALUE != hVhd)
{
CloseHandle(hVhd);
}
return bRet;
}
示例9: PrintErrorMessage
GLboolean FWindow::Linux_Initialize()
{
Attributes = new GLint[12]{GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, DepthBits, GLX_STENCIL_SIZE, StencilBits,
GLX_RED_SIZE, ColourBits, GLX_GREEN_SIZE, ColourBits, GLX_BLUE_SIZE, ColourBits, None};
Decorators = 1;
CurrentWindowStyle |= LINUX_DECORATOR_CLOSE | LINUX_DECORATOR_MAXIMIZE | LINUX_DECORATOR_MINIMIZE | LINUX_DECORATOR_MOVE;
if (!WindowManager::GetDisplay())
{
PrintErrorMessage(ERROR_LINUX_CANNOTCONNECTXSERVER);
exit(0);
}
VisualInfo = glXGetVisualFromFBConfig(WindowManager::GetDisplay(), GetBestFrameBufferConfig());
//VisualInfo = glXChooseVisual(WindowManager::GetDisplay(), 0, Attributes);
if (!VisualInfo)
{
PrintErrorMessage(ERROR_LINUX_INVALIDVISUALINFO);
exit(0);
}
SetAttributes.colormap = XCreateColormap(WindowManager::GetDisplay(),
DefaultRootWindow(WindowManager::GetDisplay()),
VisualInfo->visual, AllocNone);
SetAttributes.event_mask = ExposureMask | KeyPressMask
| KeyReleaseMask | MotionNotify | ButtonPressMask | ButtonReleaseMask
| FocusIn | FocusOut | Button1MotionMask | Button2MotionMask | Button3MotionMask |
Button4MotionMask | Button5MotionMask | PointerMotionMask | FocusChangeMask
| VisibilityChangeMask | PropertyChangeMask | SubstructureNotifyMask;
WindowHandle = XCreateWindow(WindowManager::GetInstance()->m_Display,
XDefaultRootWindow(WindowManager::GetInstance()->m_Display), 0, 0,
Resolution[0], Resolution[1],
0, VisualInfo->depth, InputOutput,
VisualInfo->visual, CWColormap | CWEventMask,
&SetAttributes);
if(!WindowHandle)
{
PrintErrorMessage(ERROR_LINUX_CANNOTCREATEWINDOW);
exit(0);
}
XMapWindow(WindowManager::GetDisplay(), WindowHandle);
XStoreName(WindowManager::GetDisplay(), WindowHandle,
Name);
InitializeAtomics();
XSetWMProtocols(WindowManager::GetDisplay(), WindowHandle, &AtomClose, GL_TRUE);
return Linux_InitializeGL();
}
示例10: OpenAndGetPhysVHD
BOOL OpenAndGetPhysVHD(PCWSTR pszVhdPath, PWSTR pszPhysicalDiskPath)
{
BOOL bRet = FALSE;
HANDLE hVhd = INVALID_HANDLE_VALUE;
DWORD ret;
OPEN_VIRTUAL_DISK_PARAMETERS oparams;
ATTACH_VIRTUAL_DISK_PARAMETERS iparams;
VIRTUAL_STORAGE_TYPE vst =
{
VIRTUAL_STORAGE_TYPE_DEVICE_VHD,
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT
};
wprintf(L"OpenAndGetPhysVHD %s\n", pszVhdPath);
oparams.Version = OPEN_VIRTUAL_DISK_VERSION_1;
oparams.Version1.RWDepth = OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT;
iparams.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
ret = OpenVirtualDisk(&vst, pszVhdPath,
VIRTUAL_DISK_ACCESS_ATTACH_RW | VIRTUAL_DISK_ACCESS_GET_INFO | VIRTUAL_DISK_ACCESS_DETACH,
OPEN_VIRTUAL_DISK_FLAG_NONE, &oparams, &hVhd);
if (ERROR_SUCCESS == ret)
{
ULONG sizePhysicalDisk;
printf("success opening vdisk...\n");
memset(pszPhysicalDiskPath, 0, sizeof (wchar_t) * PHYS_PATH_LEN);
sizePhysicalDisk = (PHYS_PATH_LEN * sizeof(wchar_t)) * 256;
ret = GetVirtualDiskPhysicalPath(hVhd, &sizePhysicalDisk, pszPhysicalDiskPath);
if (ERROR_SUCCESS == ret)
{
wprintf(L"success getting physical path %s vhdname\n", pszPhysicalDiskPath);
bRet = TRUE;
}
else
{
printf("failed to get vhd physical info %d\n", ret);
PrintErrorMessage(GetLastError());
}
}
else
{
printf("failed to open vdisk...err 0x%x\n", ret);
PrintErrorMessage(GetLastError());
}
if (INVALID_HANDLE_VALUE != hVhd)
{
CloseHandle(hVhd);
}
return bRet;
}
示例11: OpenAndAttachVHD
BOOL OpenAndAttachVHD(PCWSTR pszVhdPath)
{
BOOL bRet = FALSE;
HANDLE hVhd = INVALID_HANDLE_VALUE;
DWORD ret;
OPEN_VIRTUAL_DISK_PARAMETERS oparams;
ATTACH_VIRTUAL_DISK_PARAMETERS iparams;
VIRTUAL_STORAGE_TYPE vst =
{
VIRTUAL_STORAGE_TYPE_DEVICE_VHD,
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT
};
wprintf(L"OpenAndAttachVHD %s\n", pszVhdPath);
oparams.Version = OPEN_VIRTUAL_DISK_VERSION_1;
oparams.Version1.RWDepth = OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT;
iparams.Version = ATTACH_VIRTUAL_DISK_VERSION_1;
ret = OpenVirtualDisk(&vst, pszVhdPath,
VIRTUAL_DISK_ACCESS_ATTACH_RW | VIRTUAL_DISK_ACCESS_GET_INFO | VIRTUAL_DISK_ACCESS_DETACH,
OPEN_VIRTUAL_DISK_FLAG_NONE, &oparams, &hVhd);
if (ERROR_SUCCESS == ret)
{
printf("success opening vdisk...\n");
ret = AttachVirtualDisk(hVhd, NULL,
ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME, 0, &iparams, NULL);
if (ERROR_SUCCESS == ret)
{
printf("success attaching vdisk...\n");
}
else
{
printf("failed to attach vdisk...err 0x%x\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
}
else
{
printf("failed to open vdisk...err 0x%x\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
if (INVALID_HANDLE_VALUE != hVhd)
{
CloseHandle(hVhd);
}
return bRet;
}
示例12: OpenAndDetachVHD
BOOL OpenAndDetachVHD(PCWSTR pszVhdPath)
{
BOOL bRet = FALSE;
DWORD ret;
DETACH_VIRTUAL_DISK_FLAG Flags;
HANDLE hVhd = INVALID_HANDLE_VALUE;
OPEN_VIRTUAL_DISK_PARAMETERS oparams;
VIRTUAL_STORAGE_TYPE vst =
{
VIRTUAL_STORAGE_TYPE_DEVICE_VHD,
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT
};
wprintf(L"OpenAndDetachVHD %s\n", pszVhdPath);
oparams.Version = OPEN_VIRTUAL_DISK_VERSION_1;
oparams.Version1.RWDepth = OPEN_VIRTUAL_DISK_RW_DEPTH_DEFAULT;
ret = OpenVirtualDisk(&vst, pszVhdPath,
VIRTUAL_DISK_ACCESS_DETACH,
OPEN_VIRTUAL_DISK_FLAG_NONE, NULL /*&oparams*/, &hVhd);
if (ERROR_SUCCESS == ret)
{
printf("success opening vdisk...\n");
Flags = DETACH_VIRTUAL_DISK_FLAG_NONE;
ret = DetachVirtualDisk(hVhd, Flags, 0);
if (ERROR_SUCCESS == ret)
{
printf("success detaching vdisk...\n");
}
else
{
printf("failed to detach vdisk... %d\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
}
else
{
printf("failed to open vdisk...err %d\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
if (INVALID_HANDLE_VALUE != hVhd)
{
CloseHandle(hVhd);
}
return bRet;
}
示例13: OpenAndSetVHDInfo
int OpenAndSetVHDInfo(PCWSTR pszVhdPath, PCWSTR pszGuid, GUID *Guid)
{
BOOL bRet = FALSE;
DWORD ret;
HANDLE hVhd;
ULONG InfoSize;
SET_VIRTUAL_DISK_INFO SetInfo;
VIRTUAL_STORAGE_TYPE vst =
{
VIRTUAL_STORAGE_TYPE_DEVICE_VHD,
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT
};
wprintf(L"OpenAndSetVHDInfo %s GUID %s\n", pszVhdPath, pszGuid);
ret = OpenVirtualDisk(&vst, pszVhdPath,
VIRTUAL_DISK_ACCESS_ALL, OPEN_VIRTUAL_DISK_FLAG_NONE,
NULL, &hVhd);
if (ERROR_SUCCESS == ret)
{
printf("success opening vdisk...\n");
SetInfo.Version = SET_VIRTUAL_DISK_INFO_IDENTIFIER;
InfoSize = sizeof(SetInfo);
SetInfo.UniqueIdentifier = zGuid; //*Guid;
ret = SetVirtualDiskInformation(hVhd, &SetInfo);
if (ret == ERROR_SUCCESS)
{
printf("success setting vhd info\n");
}
else
{
printf("failed to set vhd info %d\n", ret);
PrintErrorMessage(GetLastError());
}
}
else
{
printf("failed to open vdisk...err %d\n", ret);
PrintErrorMessage(GetLastError());
}
if (INVALID_HANDLE_VALUE != hVhd)
{
CloseHandle(hVhd);
}
return bRet;
}
示例14: OpenAndExpandVHD
// Expanding a virtual disk requires that the virtual disk be detached during
// the operation.
BOOL OpenAndExpandVHD(PCWSTR pszVhdPath, ULONG newSizeMB)
{
BOOL bRet = FALSE;
DWORD ret;
HANDLE hVhd = INVALID_HANDLE_VALUE;
EXPAND_VIRTUAL_DISK_PARAMETERS xparams;
VIRTUAL_STORAGE_TYPE vst =
{
VIRTUAL_STORAGE_TYPE_DEVICE_VHD,
VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT
};
wprintf(L"OpenAndExpandVHD %s, new size (MB) %d\n", pszVhdPath, newSizeMB);
ret = OpenVirtualDisk(&vst, pszVhdPath,
VIRTUAL_DISK_ACCESS_METAOPS,
OPEN_VIRTUAL_DISK_FLAG_NONE, NULL, &hVhd);
if (ERROR_SUCCESS == ret)
{
printf("success opening vdisk...\n");
xparams.Version = EXPAND_VIRTUAL_DISK_VERSION_1;
xparams.Version1.NewSize = newSizeMB * 1024 * 1024;
ret = ExpandVirtualDisk(hVhd, EXPAND_VIRTUAL_DISK_FLAG_NONE, &xparams, 0);
if (ERROR_SUCCESS == ret)
{
printf("success expanding vdisk...\n");
}
else
{
printf("failed to expand vdisk... %d\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
}
else
{
printf("failed to open vdisk...err %d\n", ret);
PrintErrorMessage(GetLastError());
bRet = FALSE;
}
if (INVALID_HANDLE_VALUE != hVhd)
{
CloseHandle(hVhd);
}
return bRet;
}
示例15: WriteFile
static void WriteFile( char* fileName, void* data, int dataToWrite ) {
HANDLE fileHandle;
//TODO: look into other options, such as: Overlapped, No_Bufffering, and Random_Access
fileHandle = CreateFile(
fileName,
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
0
);
if( fileHandle == INVALID_HANDLE_VALUE ) {
fileHandle = CreateFile(
fileName,
GENERIC_WRITE,
FILE_SHARE_WRITE,
0,
TRUNCATE_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0
);
if( fileHandle == INVALID_HANDLE_VALUE ) {
PrintErrorMessage( GetLastError() );
printf("Did not write to file %s\n", fileName );
return;
}
}
DWORD bytesWritten = 0;
DWORD writeSuccess = WriteFile(
fileHandle,
data,
dataToWrite,
&bytesWritten,
NULL //NOT NULL if i ever do overlapped stuff according to msdn
);
if( writeSuccess != 1 ) {
PrintErrorMessage( GetLastError() );
printf("Did not write to file %s\n", fileName );
return;
}
//Close
BOOL closeReturnValue = CloseHandle( fileHandle );
assert( closeReturnValue );
}