void MsgList_VAppend(MsgList **list, // IN reference to existing list const char *idFmt, // IN message ID and English message va_list args) // IN args { ASSERT(idFmt != NULL); if (!Msg_HasMsgID(idFmt)) { ASSERT(Err_String2Errno(idFmt) != ERR_INVALID); /* On release builds, tolerate other messages that lack MSGIDs. */ MsgList_Append(list, MSGID(literal) "%s", idFmt); return; } /* * In silent mode, skip processing in release builds. Debug * builds can afford the speed cost to verify message is constructable. */ if (list != NULL || vmx86_debug) { MsgList *m = MsgId2MsgList(idFmt); Bool status; char *error; status = MsgFmt_GetArgs(m->format, args, &m->args, &m->numArgs, &error); if (!status) { Log("%s error: %s\nformat <%s>\n", __FUNCTION__, error, m->format); PANIC(); } if (list != NULL) { m->next = *list; *list = m; } else { /* Silent mode, but constructed as a sanity test. Clean up. */ ASSERT(vmx86_debug); MsgList_Free(m); } } }
void MsgList_AppendStr(MsgList **list, // IN reference to existing list const char *id) // IN message ID and English message { ASSERT(id != NULL); /* Silently upgrade system errors to real MSGIDs. */ if (!Msg_HasMsgID(id)) { ASSERT(Err_String2Errno(id) != ERR_INVALID); /* On release builds, tolerate other messages that lack MSGIDs. */ MsgList_Append(list, MSGID(literal) "%s", id); return; } /* * The MsgList_AppendStr variant does not accept format strings. This * check disallows some legitimate strings, but it's probably easier * on the msgconv parser to just disallow all format-string-like things. */ ASSERT(strchr(id, '%') == NULL); /* * In silent mode, skip processing in release builds. Debug * builds can afford the speed cost to verify message is constructable. */ if (list != NULL || vmx86_debug) { MsgList *m = MsgId2MsgList(id); if (list != NULL) { m->next = *list; *list = m; } else { /* Silent mode, but constructed as a sanity test. Clean up. */ ASSERT(vmx86_debug); MsgList_Free(m); } } }
const char * FileIO_MsgError(FileIOResult status) // IN { const char *result = NULL; switch (status) { case FILEIO_SUCCESS: /* * Most of the time, you don't call this function with this value * because there is no error */ result = MSGID(fileio.success) "Success"; break; case FILEIO_CANCELLED: /* * Most of the time, you don't call this function with this value * because you don't want to display error messages after a user has * cancelled an operation. */ result = MSGID(fileio.cancel) "The operation was canceled by the user"; break; case FILEIO_ERROR: /* * Most of the time, you don't call this function with this value * because you can call your native function to retrieve a more * accurate message. */ result = MSGID(fileio.generic) "Error"; break; case FILEIO_OPEN_ERROR_EXIST: result = MSGID(fileio.exists) "The file already exists"; break; case FILEIO_LOCK_FAILED: result = MSGID(fileio.lock) "Failed to lock the file"; break; case FILEIO_READ_ERROR_EOF: result = MSGID(fileio.eof) "Tried to read beyond the end of the file"; break; case FILEIO_FILE_NOT_FOUND: result = MSGID(fileio.notfound) "Could not find the file"; break; case FILEIO_NO_PERMISSION: result = MSGID(fileio.noPerm) "Insufficient permission to access the file"; break; case FILEIO_FILE_NAME_TOO_LONG: result = MSGID(fileio.namelong) "The file name is too long"; break; case FILEIO_WRITE_ERROR_FBIG: result = MSGID(fileio.fBig) "The file is too large"; break; case FILEIO_WRITE_ERROR_NOSPC: result = MSGID(fileio.noSpc) "There is no space left on the device"; break; case FILEIO_WRITE_ERROR_DQUOT: result = MSGID(fileio.dQuot) "There is no space left on the device"; break; case FILEIO_ERROR_LAST: NOT_IMPLEMENTED(); break; /* * We do not provide a default case on purpose, so that the compiler can * detect changes in the error set and reminds us to implement the * associated messages --hpreg */ } if (!result) { Warning("%s: bad code %d\n", __FUNCTION__, status); ASSERT(0); result = MSGID(fileio.unknown) "Unknown error"; } return result; }