03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync/** @file
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * IPRT - Message Formatting.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync */
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync/*
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2009-2011 Oracle Corporation
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync *
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * available from http://www.virtualbox.org. This file is free software;
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * you can redistribute it and/or modify it under the terms of the GNU
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * General Public License (GPL) as published by the Free Software
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync *
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * The contents of this file may alternatively be used under the terms
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * of the Common Development and Distribution License Version 1.0
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * VirtualBox OSE distribution, in which case the provisions of the
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * CDDL are applicable instead of those of the GPL.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync *
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * You may elect to license modified versions of this file under the
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * terms and conditions of either the GPL or the CDDL or both.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync */
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync#ifndef ___iprt_msg_h
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync#define ___iprt_msg_h
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync#include <iprt/cdefs.h>
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync#include <iprt/types.h>
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync#include <iprt/stdarg.h>
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsyncRT_C_DECLS_BEGIN
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync/** @defgroup grp_rt_msg RTMsg - Message Formatting
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @ingroup grp_rt
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @{
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync */
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync/**
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync * Sets the program name to use.
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync *
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync * @returns IPRT status code.
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync * @param pszFormat The program name format string.
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync * @param ... Format arguments.
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync */
bb933ee4eb48572fc6f1541d945c81141e233561vboxsyncRTDECL(int) RTMsgSetProgName(const char *pszFormat, ...);
bb933ee4eb48572fc6f1541d945c81141e233561vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync/**
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * Print error message to standard error.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync *
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * The message will be prefixed with the file name part of process image name
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * (i.e. no path) and "error: ". If the message doesn't end with a new line,
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * one will be added. The caller should call this with an empty string if
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * unsure whether the cursor is currently position at the start of a new line.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync *
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @returns IPRT status code.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @param pszFormat The message format string.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @param ... Format arguments.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync */
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsyncRTDECL(int) RTMsgError(const char *pszFormat, ...);
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync/**
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * Print error message to standard error.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync *
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * The message will be prefixed with the file name part of process image name
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * (i.e. no path) and "error: ". If the message doesn't end with a new line,
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * one will be added. The caller should call this with an empty string if
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * unsure whether the cursor is currently position at the start of a new line.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync *
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @returns IPRT status code.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @param pszFormat The message format string.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync * @param va Format arguments.
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync */
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsyncRTDECL(int) RTMsgErrorV(const char *pszFormat, va_list va);
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync/**
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * Same as RTMsgError() except for the return value.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync *
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @returns @a enmExitCode
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @param enmExitCode What to exit code to return. This is mainly for
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * saving some vertical space in the source file.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @param pszFormat The message format string.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @param ... Format arguments.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync */
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsyncRTDECL(RTEXITCODE) RTMsgErrorExit(RTEXITCODE enmExitcode, const char *pszFormat, ...);
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync/**
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * Same as RTMsgErrorV() except for the return value.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync *
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @returns @a enmExitCode
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @param enmExitCode What to exit code to return. This is mainly for
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * saving some vertical space in the source file.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @param pszFormat The message format string.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync * @param va Format arguments.
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync */
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsyncRTDECL(RTEXITCODE) RTMsgErrorExitV(RTEXITCODE enmExitCode, const char *pszFormat, va_list va);
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsync
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync/**
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * Same as RTMsgError() except for the return value.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync *
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @returns @a rcRet
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @param rcRet What IPRT status to return. This is mainly for
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * saving some vertical space in the source file.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @param pszFormat The message format string.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @param ... Format arguments.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync */
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsyncRTDECL(int) RTMsgErrorRc(int rc, const char *pszFormat, ...);
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync/**
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * Same as RTMsgErrorV() except for the return value.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync *
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @returns @a rcRet
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @param rcRet What IPRT status to return. This is mainly for
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * saving some vertical space in the source file.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @param pszFormat The message format string.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync * @param va Format arguments.
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync */
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsyncRTDECL(int) RTMsgErrorRcV(int rc, const char *pszFormat, va_list va);
8f9ee2e23790d5b9a9a5102b5874a67f73f9180evboxsync
4245f019939e8870b3cc5266d803669f36f58441vboxsync/**
4245f019939e8870b3cc5266d803669f36f58441vboxsync * Print an error message for a RTR3Init failure and suggest an exit code.
4245f019939e8870b3cc5266d803669f36f58441vboxsync *
4245f019939e8870b3cc5266d803669f36f58441vboxsync * @code
4245f019939e8870b3cc5266d803669f36f58441vboxsync *
4245f019939e8870b3cc5266d803669f36f58441vboxsync * int rc = RTR3Init();
4245f019939e8870b3cc5266d803669f36f58441vboxsync * if (RT_FAILURE(rc))
4245f019939e8870b3cc5266d803669f36f58441vboxsync * return RTMsgInitFailure(rc);
4245f019939e8870b3cc5266d803669f36f58441vboxsync *
4245f019939e8870b3cc5266d803669f36f58441vboxsync * @endcode
4245f019939e8870b3cc5266d803669f36f58441vboxsync *
4245f019939e8870b3cc5266d803669f36f58441vboxsync * @returns Appropriate exit code.
4245f019939e8870b3cc5266d803669f36f58441vboxsync * @param rcRTR3Init The status code returned by RTR3Init.
4245f019939e8870b3cc5266d803669f36f58441vboxsync */
9c77b083e2ca3a9b509faa9789072f2527422e22vboxsyncRTDECL(RTEXITCODE) RTMsgInitFailure(int rcRTR3Init);
4245f019939e8870b3cc5266d803669f36f58441vboxsync
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync/**
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * Print informational message to standard error.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * The message will be prefixed with the file name part of process image name
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * (i.e. no path) and "warning: ". If the message doesn't end with a new line,
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * one will be added. The caller should call this with an empty string if
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * unsure whether the cursor is currently position at the start of a new line.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @returns IPRT status code.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param pszFormat The message format string.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param ... Format arguments.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync */
08636936a7f38868de256341b720ae78fbd0b4b4vboxsyncRTDECL(int) RTMsgWarning(const char *pszFormat, ...);
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync/**
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * Print informational message to standard error.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * The message will be prefixed with the file name part of process image name
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * (i.e. no path) and "warning: ". If the message doesn't end with a new line,
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * one will be added. The caller should call this with an empty string if
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * unsure whether the cursor is currently position at the start of a new line.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @returns IPRT status code.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param pszFormat The message format string.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param va Format arguments.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync */
08636936a7f38868de256341b720ae78fbd0b4b4vboxsyncRTDECL(int) RTMsgWarningV(const char *pszFormat, va_list va);
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync/**
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * Print informational message to standard output.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * The message will be prefixed with the file name part of process image name
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * (i.e. no path) and "info: ". If the message doesn't end with a new line,
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * one will be added. The caller should call this with an empty string if
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * unsure whether the cursor is currently position at the start of a new line.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @returns IPRT status code.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param pszFormat The message format string.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param ... Format arguments.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync */
08636936a7f38868de256341b720ae78fbd0b4b4vboxsyncRTDECL(int) RTMsgInfo(const char *pszFormat, ...);
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync/**
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * Print informational message to standard output.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * The message will be prefixed with the file name part of process image name
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * (i.e. no path) and "info: ". If the message doesn't end with a new line,
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * one will be added. The caller should call this with an empty string if
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * unsure whether the cursor is currently position at the start of a new line.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync *
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @returns IPRT status code.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param pszFormat The message format string.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync * @param va Format arguments.
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync */
08636936a7f38868de256341b720ae78fbd0b4b4vboxsyncRTDECL(int) RTMsgInfoV(const char *pszFormat, va_list va);
08636936a7f38868de256341b720ae78fbd0b4b4vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync/** @} */
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsyncRT_C_DECLS_END
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync#endif
03c2683d4e59cc500217b1d5d76fdf9b8cdfefa5vboxsync