MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / fb_msg_format

Function fb_msg_format

src/common/classes/MsgPrint.cpp:359–399  ·  view source on GitHub ↗

Lookup and format message. Return as much of formatted string as fits in caller's buffer.

Source from the content-addressed store, hash-verified

357
358// Lookup and format message. Return as much of formatted string as fits in caller's buffer.
359int fb_msg_format(void* handle, USHORT facility, USHORT number, unsigned int bsize, TEXT* buffer,
360 const MsgFormat::SafeArg& arg)
361{
362 int total_msg = 0;
363 char msg[BUFFER_SMALL] = "";
364 const int n = gds__msg_lookup(handle, facility, number, sizeof(msg), msg, NULL);
365
366 if (n > 0 && unsigned(n) < sizeof(msg))
367 {
368 // Shameful bridge, gds__msg_format emulation for old format messages.
369 if (strchr(msg, '%'))
370 {
371 const TEXT* rep[5];
372 arg.dump(rep, 5);
373 total_msg = fb_utils::snprintf(buffer, bsize, msg, rep[0], rep[1], rep[2], rep[3], rep[4]);
374 }
375 else
376 total_msg = MsgPrint(buffer, bsize, msg, arg);
377 }
378 else
379 {
380 Firebird::string s;
381 s.printf("can't format message %d:%d -- ", facility, number);
382 if (n == -1)
383 s += "message text not found";
384 else if (n == -2)
385 {
386 s += "message file ";
387 s += fb_utils::getPrefix(Firebird::IConfigManager::DIR_MSG, MSG_FILE).ToString();
388 s += " not found";
389 }
390 else
391 {
392 fb_utils::snprintf(buffer, bsize, "message system code %d", n);
393 s += buffer;
394 }
395 total_msg = s.copyTo(buffer, bsize);
396 }
397
398 return (n > 0 ? total_msg : -total_msg);
399}

Callers 15

ALICE_printFunction · 0.85
ALICE_errorFunction · 0.85
IUTILS_msg_getFunction · 0.85
BURP_msg_partialFunction · 0.85
BURP_msg_putFunction · 0.85
BURP_msg_getFunction · 0.85
bad_attributeFunction · 0.85
printMsgFunction · 0.85
GSEC_printFunction · 0.85
GSEC_messageFunction · 0.85
GSEC_print_partialFunction · 0.85
msg_getFunction · 0.85

Calls 7

MsgPrintFunction · 0.85
getPrefixFunction · 0.85
snprintfFunction · 0.50
dumpMethod · 0.45
printfMethod · 0.45
ToStringMethod · 0.45
copyToMethod · 0.45

Tested by

no test coverage detected