示例#1
0
DWORD
CTAllocateStringPrintf(
    PSTR* result,
    PCSTR format,
    ...
    )
{
    DWORD ceError;

    va_list args;
    va_start(args, format);
    ceError = CTAllocateStringPrintfV(result, format, args);
    va_end(args);

    return ceError;
}
示例#2
0
void
LWRaiseEx(
    LWException** dest,
    DWORD code,
    const char* file,
    unsigned int line,
    const char* _shortMsg,
    const char* fmt,
    ...
    )
{
    if (dest)
    {
	DWORD ceError;
	char* shortMsg;
	char* longMsg;
	va_list ap;
	
	va_start(ap, fmt);
	
	if (!_shortMsg)
	{
	    _shortMsg = LwWin32ExtErrorToName(code);
	}
        if (!_shortMsg)
        {
            _shortMsg = "Undocumented exception";
        }

	if (!fmt)
	{
	    fmt = LwWin32ExtErrorToDescription(code);
	}
        if (!fmt)
        {
            fmt = "An undocumented exception has occurred. Please contact Likewise technical support and use the error code to identify this exception.";
        }

	if (_shortMsg)
	{
	    if ((ceError = CTAllocateString(_shortMsg, &shortMsg)))
	    {
		*dest = CreateException(ceError, __FILE__, __LINE__, NULL, NULL);
		return;
	    }
	}
	else
	{
	    shortMsg = NULL;
	}
	    
	if (fmt)
	{
	    if ((ceError = CTAllocateStringPrintfV(&longMsg, fmt, ap)))
	    {
		CTFreeString(shortMsg);
		*dest = CreateException(ceError, __FILE__, __LINE__, NULL, NULL);
		return;
	    }
	}
	else
	{
	    longMsg = NULL;
	}

	*dest = CreateException(code, file, line, shortMsg, longMsg);
    }
}