RemoteDrawingEngine: Reduce RP_READ_BITMAP result timeout.
[haiku.git] / src / kits / shared / StringForRate.cpp
bloba2d3f57a6f84f035667d9abae3e59b72a4fac838
1 /*
2 * Copyright 2012 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "StringForRate.h"
8 #include <stdio.h>
10 #include <SystemCatalog.h>
12 using BPrivate::gSystemCatalog;
15 #undef B_TRANSLATION_CONTEXT
16 #define B_TRANSLATION_CONTEXT "StringForRate"
19 namespace BPrivate {
22 const char*
23 string_for_rate(double rate, char* string, size_t stringSize, double base)
25 double kbps = rate / base;
26 if (kbps < 10.0) {
27 const char* trKey = B_TRANSLATE_MARK("%d bps");
28 snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
29 B_TRANSLATION_CONTEXT), (int)rate);
30 return string;
32 double mbps = kbps / base;
33 if (mbps < 10.0) {
34 const char* trKey = B_TRANSLATE_MARK("%.0f Kbps");
35 snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
36 B_TRANSLATION_CONTEXT), kbps);
37 return string;
39 double gbps = mbps / base;
40 if (gbps < 10.0) {
41 const char* trKey = B_TRANSLATE_MARK("%.0f Mbps");
42 snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
43 B_TRANSLATION_CONTEXT), mbps);
44 return string;
46 double tbps = gbps / base;
47 if (tbps < 10.0) {
48 const char* trKey = B_TRANSLATE_MARK("%.0f Gbps");
49 snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
50 B_TRANSLATION_CONTEXT), gbps);
51 return string;
53 const char* trKey = B_TRANSLATE_MARK("%.0f Tbps");
54 snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
55 B_TRANSLATION_CONTEXT), tbps);
56 return string;
60 } // namespace BPrivate