// fill cmsg_info struct static void CMsgInfo( cmsg_info *info, int parmno, msg_codes msgnum, va_list args ) { char *fname; unsigned line; char const *msgstr; int prefix_len; info->msgnum = msgnum; // CMsgSetClass( info, msgnum ); info->col = 0; switch( msgnum ) { case ERR_INVALID_MEMORY_MODEL: case ERR_INVALID_OPTION: case ERR_INVALID_OPTIMIZATION: /* no location for error message */ line = 0; fname = NULL; break; default: if( error_fname != NULL ) { fname = error_fname; line = error_line; } else { fname = FileIndexToCorrectName( TokenLoc.fno ); line = TokenLoc.line; } } prefix_len = 0; if( parmno ) { msgstr = CGetMsgStr( PHRASE_PARAM ); prefix_len = sprintf( info->msgtxt, msgstr, parmno ); info->msgtxt[prefix_len++] = ' '; } msgstr = CGetMsgStr( msgnum ); _vsnprintf( info->msgtxt + prefix_len, MAX_MSG_LEN - prefix_len, msgstr, args ); info->msgtxt[MAX_MSG_LEN - 1] = '\0'; info->line = line; info->fname = fname; }
void CGetMsg( char *msgbuf, msg_codes msgcode ) { char const *p = CGetMsgStr( msgcode ); while( (*msgbuf++ = *p++) ) /* empty */; }