Coverage Report

Created: 2026-01-16 06:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libvncserver/src/libvncserver/stats.c
Line
Count
Source
1
/*
2
 * stats.c
3
 */
4
5
/*
6
 *  Copyright (C) 2002 RealVNC Ltd.
7
 *  OSXvnc Copyright (C) 2001 Dan McGuirk <mcguirk@incompleteness.net>.
8
 *  Original Xvnc code Copyright (C) 1999 AT&T Laboratories Cambridge.  
9
 *  All Rights Reserved.
10
 *
11
 *  This is free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 2 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  This software is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU General Public License for more details.
20
 *
21
 *  You should have received a copy of the GNU General Public License
22
 *  along with this software; if not, write to the Free Software
23
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
24
 *  USA.
25
 */
26
27
#include <rfb/rfb.h>
28
29
char *messageNameServer2Client(uint32_t type, char *buf, int len);
30
char *messageNameClient2Server(uint32_t type, char *buf, int len);
31
char *encodingName(uint32_t enc, char *buf, int len);
32
33
rfbStatList *rfbStatLookupEncoding(rfbClientPtr cl, uint32_t type);
34
rfbStatList *rfbStatLookupMessage(rfbClientPtr cl, uint32_t type);
35
36
void  rfbStatRecordEncodingSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
37
void  rfbStatRecordEncodingRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
38
void  rfbStatRecordMessageSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
39
void  rfbStatRecordMessageRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw);
40
void rfbResetStats(rfbClientPtr cl);
41
void rfbPrintStats(rfbClientPtr cl);
42
43
44
45
46
2.51k
char *messageNameServer2Client(uint32_t type, char *buf, int len) {
47
2.51k
    if (buf==NULL) return "error";
48
2.51k
    switch (type) {
49
321
    case rfbFramebufferUpdate:        snprintf(buf, len, "FramebufferUpdate"); break;
50
3
    case rfbSetColourMapEntries:      snprintf(buf, len, "SetColourMapEntries"); break;
51
948
    case rfbBell:                     snprintf(buf, len, "Bell"); break;
52
455
    case rfbServerCutText:            snprintf(buf, len, "ServerCutText"); break;
53
21
    case rfbResizeFrameBuffer:        snprintf(buf, len, "ResizeFrameBuffer"); break;
54
0
    case rfbFileTransfer:             snprintf(buf, len, "FileTransfer"); break;
55
17
    case rfbTextChat:                 snprintf(buf, len, "TextChat"); break;
56
195
    case rfbPalmVNCReSizeFrameBuffer: snprintf(buf, len, "PalmVNCReSize"); break;
57
69
    case rfbXvp:                      snprintf(buf, len, "XvpServerMessage"); break;
58
482
    default:
59
482
        snprintf(buf, len, "svr2cli-0x%08X", 0xFF);
60
2.51k
    }
61
2.51k
    return buf;
62
2.51k
}
63
64
2.51k
char *messageNameClient2Server(uint32_t type, char *buf, int len) {
65
2.51k
    if (buf==NULL) return "error";
66
2.51k
    switch (type) {
67
321
    case rfbSetPixelFormat:           snprintf(buf, len, "SetPixelFormat"); break;
68
3
    case rfbFixColourMapEntries:      snprintf(buf, len, "FixColourMapEntries"); break;
69
948
    case rfbSetEncodings:             snprintf(buf, len, "SetEncodings"); break;
70
455
    case rfbFramebufferUpdateRequest: snprintf(buf, len, "FramebufferUpdate"); break;
71
21
    case rfbKeyEvent:                 snprintf(buf, len, "KeyEvent"); break;
72
194
    case rfbPointerEvent:             snprintf(buf, len, "PointerEvent"); break;
73
22
    case rfbClientCutText:            snprintf(buf, len, "ClientCutText"); break;
74
0
    case rfbFileTransfer:             snprintf(buf, len, "FileTransfer"); break;
75
174
    case rfbSetScale:                 snprintf(buf, len, "SetScale"); break;
76
37
    case rfbSetServerInput:           snprintf(buf, len, "SetServerInput"); break;
77
24
    case rfbSetSW:                    snprintf(buf, len, "SetSingleWindow"); break;
78
17
    case rfbTextChat:                 snprintf(buf, len, "TextChat"); break;
79
195
    case rfbPalmVNCSetScaleFactor:    snprintf(buf, len, "PalmVNCSetScale"); break;
80
69
    case rfbXvp:                      snprintf(buf, len, "XvpClientMessage"); break;
81
31
    case rfbSetDesktopSize:           snprintf(buf, len, "SetDesktopSize"); break;
82
0
    default:
83
0
        snprintf(buf, len, "cli2svr-0x%08X", type);
84
85
86
2.51k
    }
87
2.51k
    return buf;
88
2.51k
}
89
90
/* Encoding name must be <=16 characters to fit nicely on the status output in
91
 * an 80 column terminal window
92
 */
93
26.3k
char *encodingName(uint32_t type, char *buf, int len) {
94
26.3k
    if (buf==NULL) return "error";
95
    
96
26.3k
    switch (type) {
97
4.08k
    case rfbEncodingRaw:                snprintf(buf, len, "raw");         break;
98
0
    case rfbEncodingCopyRect:           snprintf(buf, len, "copyRect");    break;
99
348
    case rfbEncodingRRE:                snprintf(buf, len, "RRE");         break;
100
795
    case rfbEncodingCoRRE:              snprintf(buf, len, "CoRRE");       break;
101
301
    case rfbEncodingHextile:            snprintf(buf, len, "hextile");     break;
102
211
    case rfbEncodingZlib:               snprintf(buf, len, "zlib");        break;
103
201
    case rfbEncodingTight:              snprintf(buf, len, "tight");       break;
104
196
    case rfbEncodingTightPng:           snprintf(buf, len, "tightPng");    break;
105
196
    case rfbEncodingZlibHex:            snprintf(buf, len, "zlibhex");     break;
106
211
    case rfbEncodingUltra:              snprintf(buf, len, "ultra");       break;
107
486
    case rfbEncodingZRLE:               snprintf(buf, len, "ZRLE");        break;
108
274
    case rfbEncodingZYWRLE:             snprintf(buf, len, "ZYWRLE");      break;
109
197
    case rfbEncodingCache:              snprintf(buf, len, "cache");       break;
110
200
    case rfbEncodingCacheEnable:        snprintf(buf, len, "cacheEnable"); break;
111
194
    case rfbEncodingXOR_Zlib:           snprintf(buf, len, "xorZlib");     break;
112
194
    case rfbEncodingXORMonoColor_Zlib:  snprintf(buf, len, "xorMonoZlib");  break;
113
199
    case rfbEncodingXORMultiColor_Zlib: snprintf(buf, len, "xorColorZlib"); break;
114
194
    case rfbEncodingSolidColor:         snprintf(buf, len, "solidColor");  break;
115
270
    case rfbEncodingXOREnable:          snprintf(buf, len, "xorEnable");   break;
116
195
    case rfbEncodingCacheZip:           snprintf(buf, len, "cacheZip");    break;
117
198
    case rfbEncodingSolMonoZip:         snprintf(buf, len, "monoZip");     break;
118
195
    case rfbEncodingUltraZip:           snprintf(buf, len, "ultraZip");    break;
119
120
0
    case rfbEncodingXCursor:            snprintf(buf, len, "Xcursor");     break;
121
0
    case rfbEncodingRichCursor:         snprintf(buf, len, "RichCursor");  break;
122
0
    case rfbEncodingPointerPos:         snprintf(buf, len, "PointerPos");  break;
123
124
0
    case rfbEncodingLastRect:           snprintf(buf, len, "LastRect");    break;
125
0
    case rfbEncodingNewFBSize:          snprintf(buf, len, "NewFBSize");   break;
126
0
    case rfbEncodingExtDesktopSize:     snprintf(buf, len, "ExtendedDesktopSize"); break;
127
0
    case rfbEncodingKeyboardLedState:   snprintf(buf, len, "LedState");    break;
128
0
    case rfbEncodingSupportedMessages:  snprintf(buf, len, "SupportedMessage");  break;
129
0
    case rfbEncodingSupportedEncodings: snprintf(buf, len, "SupportedEncoding"); break;
130
0
    case rfbEncodingServerIdentity:     snprintf(buf, len, "ServerIdentify");    break;
131
132
    /* The following lookups do not report in stats */
133
0
    case rfbEncodingCompressLevel0: snprintf(buf, len, "CompressLevel0");  break;
134
0
    case rfbEncodingCompressLevel1: snprintf(buf, len, "CompressLevel1");  break;
135
0
    case rfbEncodingCompressLevel2: snprintf(buf, len, "CompressLevel2");  break;
136
0
    case rfbEncodingCompressLevel3: snprintf(buf, len, "CompressLevel3");  break;
137
0
    case rfbEncodingCompressLevel4: snprintf(buf, len, "CompressLevel4");  break;
138
0
    case rfbEncodingCompressLevel5: snprintf(buf, len, "CompressLevel5");  break;
139
0
    case rfbEncodingCompressLevel6: snprintf(buf, len, "CompressLevel6");  break;
140
0
    case rfbEncodingCompressLevel7: snprintf(buf, len, "CompressLevel7");  break;
141
0
    case rfbEncodingCompressLevel8: snprintf(buf, len, "CompressLevel8");  break;
142
0
    case rfbEncodingCompressLevel9: snprintf(buf, len, "CompressLevel9");  break;
143
    
144
0
    case rfbEncodingQualityLevel0:  snprintf(buf, len, "QualityLevel0");   break;
145
0
    case rfbEncodingQualityLevel1:  snprintf(buf, len, "QualityLevel1");   break;
146
0
    case rfbEncodingQualityLevel2:  snprintf(buf, len, "QualityLevel2");   break;
147
0
    case rfbEncodingQualityLevel3:  snprintf(buf, len, "QualityLevel3");   break;
148
0
    case rfbEncodingQualityLevel4:  snprintf(buf, len, "QualityLevel4");   break;
149
0
    case rfbEncodingQualityLevel5:  snprintf(buf, len, "QualityLevel5");   break;
150
0
    case rfbEncodingQualityLevel6:  snprintf(buf, len, "QualityLevel6");   break;
151
0
    case rfbEncodingQualityLevel7:  snprintf(buf, len, "QualityLevel7");   break;
152
0
    case rfbEncodingQualityLevel8:  snprintf(buf, len, "QualityLevel8");   break;
153
0
    case rfbEncodingQualityLevel9:  snprintf(buf, len, "QualityLevel9");   break;
154
155
156
17.0k
    default:
157
17.0k
        snprintf(buf, len, "Enc(0x%08X)", type);
158
26.3k
    }
159
160
26.3k
    return buf;
161
26.3k
}
162
163
164
165
166
167
rfbStatList *rfbStatLookupEncoding(rfbClientPtr cl, uint32_t type)
168
0
{
169
0
    rfbStatList *ptr;
170
0
    if (cl==NULL) return NULL;
171
0
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
172
0
    {
173
0
        if (ptr->type==type) return ptr;
174
0
    }
175
    /* Well, we are here... need to *CREATE* an entry */
176
0
    ptr = (rfbStatList *)malloc(sizeof(rfbStatList));
177
0
    if (ptr!=NULL)
178
0
    {
179
0
        memset((char *)ptr, 0, sizeof(rfbStatList));
180
0
        ptr->type = type;
181
        /* add to the top of the list */
182
0
        ptr->Next = cl->statEncList;
183
0
        cl->statEncList = ptr;
184
0
    }
185
0
    return ptr;
186
0
}
187
188
189
rfbStatList *rfbStatLookupMessage(rfbClientPtr cl, uint32_t type)
190
105k
{
191
105k
    rfbStatList *ptr;
192
105k
    if (cl==NULL) return NULL;
193
345k
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
194
343k
    {
195
343k
        if (ptr->type==type) return ptr;
196
343k
    }
197
    /* Well, we are here... need to *CREATE* an entry */
198
2.51k
    ptr = (rfbStatList *)malloc(sizeof(rfbStatList));
199
2.51k
    if (ptr!=NULL)
200
2.51k
    {
201
2.51k
        memset((char *)ptr, 0, sizeof(rfbStatList));
202
2.51k
        ptr->type = type;
203
        /* add to the top of the list */
204
2.51k
        ptr->Next = cl->statMsgList;
205
2.51k
        cl->statMsgList = ptr;
206
2.51k
    }
207
2.51k
    return ptr;
208
105k
}
209
210
void rfbStatRecordEncodingSentAdd(rfbClientPtr cl, uint32_t type, int byteCount) /* Specifically for tight encoding */
211
0
{
212
0
    rfbStatList *ptr;
213
214
0
    ptr = rfbStatLookupEncoding(cl, type);
215
0
    if (ptr!=NULL)
216
0
        ptr->bytesSent      += byteCount;
217
0
}
218
219
220
void  rfbStatRecordEncodingSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
221
0
{
222
0
    rfbStatList *ptr;
223
224
0
    ptr = rfbStatLookupEncoding(cl, type);
225
0
    if (ptr!=NULL)
226
0
    {
227
0
        ptr->sentCount++;
228
0
        ptr->bytesSent      += byteCount;
229
0
        ptr->bytesSentIfRaw += byteIfRaw;
230
0
    }
231
0
}
232
233
void  rfbStatRecordEncodingRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
234
0
{
235
0
    rfbStatList *ptr;
236
237
0
    ptr = rfbStatLookupEncoding(cl, type);
238
0
    if (ptr!=NULL)
239
0
    {
240
0
        ptr->rcvdCount++;
241
0
        ptr->bytesRcvd      += byteCount;
242
0
        ptr->bytesRcvdIfRaw += byteIfRaw;
243
0
    }
244
0
}
245
246
void  rfbStatRecordMessageSent(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
247
33.6k
{
248
33.6k
    rfbStatList *ptr;
249
250
33.6k
    ptr = rfbStatLookupMessage(cl, type);
251
33.6k
    if (ptr!=NULL)
252
33.6k
    {
253
33.6k
        ptr->sentCount++;
254
33.6k
        ptr->bytesSent      += byteCount;
255
33.6k
        ptr->bytesSentIfRaw += byteIfRaw;
256
33.6k
    }
257
33.6k
}
258
259
void  rfbStatRecordMessageRcvd(rfbClientPtr cl, uint32_t type, int byteCount, int byteIfRaw)
260
71.7k
{
261
71.7k
    rfbStatList *ptr;
262
263
71.7k
    ptr = rfbStatLookupMessage(cl, type);
264
71.7k
    if (ptr!=NULL)
265
71.7k
    {
266
71.7k
        ptr->rcvdCount++;
267
71.7k
        ptr->bytesRcvd      += byteCount;
268
71.7k
        ptr->bytesRcvdIfRaw += byteIfRaw;
269
71.7k
    }
270
71.7k
}
271
272
273
int rfbStatGetSentBytes(rfbClientPtr cl)
274
0
{
275
0
    rfbStatList *ptr=NULL;
276
0
    int bytes=0;
277
0
    if (cl==NULL) return 0;
278
0
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
279
0
        bytes += ptr->bytesSent;
280
0
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
281
0
        bytes += ptr->bytesSent;
282
0
    return bytes;
283
0
}
284
285
int rfbStatGetSentBytesIfRaw(rfbClientPtr cl)
286
0
{
287
0
    rfbStatList *ptr=NULL;
288
0
    int bytes=0;
289
0
    if (cl==NULL) return 0;
290
0
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
291
0
        bytes += ptr->bytesSentIfRaw;
292
0
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
293
0
        bytes += ptr->bytesSentIfRaw;
294
0
    return bytes;
295
0
}
296
297
int rfbStatGetRcvdBytes(rfbClientPtr cl)
298
0
{
299
0
    rfbStatList *ptr=NULL;
300
0
    int bytes=0;
301
0
    if (cl==NULL) return 0;
302
0
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
303
0
        bytes += ptr->bytesRcvd;
304
0
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
305
0
        bytes += ptr->bytesRcvd;
306
0
    return bytes;
307
0
}
308
309
int rfbStatGetRcvdBytesIfRaw(rfbClientPtr cl)
310
0
{
311
0
    rfbStatList *ptr=NULL;
312
0
    int bytes=0;
313
0
    if (cl==NULL) return 0;
314
0
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
315
0
        bytes += ptr->bytesRcvdIfRaw;
316
0
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
317
0
        bytes += ptr->bytesRcvdIfRaw;
318
0
    return bytes;
319
0
}
320
321
int rfbStatGetMessageCountSent(rfbClientPtr cl, uint32_t type)
322
0
{
323
0
  rfbStatList *ptr=NULL;
324
0
    if (cl==NULL) return 0;
325
0
  for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
326
0
      if (ptr->type==type) return ptr->sentCount;
327
0
  return 0;
328
0
}
329
int rfbStatGetMessageCountRcvd(rfbClientPtr cl, uint32_t type)
330
0
{
331
0
  rfbStatList *ptr=NULL;
332
0
    if (cl==NULL) return 0;
333
0
  for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
334
0
      if (ptr->type==type) return ptr->rcvdCount;
335
0
  return 0;
336
0
}
337
338
int rfbStatGetEncodingCountSent(rfbClientPtr cl, uint32_t type)
339
0
{
340
0
  rfbStatList *ptr=NULL;
341
0
    if (cl==NULL) return 0;
342
0
  for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
343
0
      if (ptr->type==type) return ptr->sentCount;
344
0
  return 0;
345
0
}
346
int rfbStatGetEncodingCountRcvd(rfbClientPtr cl, uint32_t type)
347
0
{
348
0
  rfbStatList *ptr=NULL;
349
0
    if (cl==NULL) return 0;
350
0
  for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
351
0
      if (ptr->type==type) return ptr->rcvdCount;
352
0
  return 0;
353
0
}
354
355
356
357
358
void rfbResetStats(rfbClientPtr cl)
359
4.77k
{
360
4.77k
    rfbStatList *ptr;
361
4.77k
    if (cl==NULL) return;
362
4.77k
    while (cl->statEncList!=NULL)
363
0
    {
364
0
        ptr = cl->statEncList;
365
0
        cl->statEncList = ptr->Next;
366
0
        free(ptr);
367
0
    }
368
7.28k
    while (cl->statMsgList!=NULL)
369
2.51k
    {
370
2.51k
        ptr = cl->statMsgList;
371
2.51k
        cl->statMsgList = ptr->Next;
372
2.51k
        free(ptr);
373
2.51k
    }
374
4.77k
}
375
376
377
void rfbPrintStats(rfbClientPtr cl)
378
2.38k
{
379
2.38k
    rfbStatList *ptr=NULL;
380
2.38k
    char encBuf[64];
381
2.38k
    double savings=0.0;
382
2.38k
    int    totalRects=0;
383
2.38k
    double totalBytes=0.0;
384
2.38k
    double totalBytesIfRaw=0.0;
385
386
2.38k
    char *name=NULL;
387
2.38k
    int bytes=0;
388
2.38k
    int bytesIfRaw=0;
389
2.38k
    int count=0;
390
391
2.38k
    if (cl==NULL) return;
392
    
393
2.38k
    rfbLog("%-21.21s  %-6.6s   %9.9s/%9.9s (%6.6s)\n", "Statistics", "events", "Transmit","RawEquiv","saved");
394
4.89k
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
395
2.51k
    {
396
2.51k
        name       = messageNameServer2Client(ptr->type, encBuf, sizeof(encBuf));
397
2.51k
        count      = ptr->sentCount;
398
2.51k
        bytes      = ptr->bytesSent;
399
2.51k
        bytesIfRaw = ptr->bytesSentIfRaw;
400
        
401
2.51k
        savings = 0.0;
402
2.51k
        if (bytesIfRaw>0.0)
403
59
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
404
2.51k
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
405
59
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
406
59
          name, count, bytes, bytesIfRaw, savings);
407
2.51k
        totalRects += count;
408
2.51k
        totalBytes += bytes;
409
2.51k
        totalBytesIfRaw += bytesIfRaw;
410
2.51k
    }
411
412
2.38k
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
413
0
    {
414
0
        name       = encodingName(ptr->type, encBuf, sizeof(encBuf));
415
0
        count      = ptr->sentCount;
416
0
        bytes      = ptr->bytesSent;
417
0
        bytesIfRaw = ptr->bytesSentIfRaw;
418
0
        savings    = 0.0;
419
420
0
        if (bytesIfRaw>0.0)
421
0
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
422
0
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
423
0
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
424
0
          name, count, bytes, bytesIfRaw, savings);
425
0
        totalRects += count;
426
0
        totalBytes += bytes;
427
0
        totalBytesIfRaw += bytesIfRaw;
428
0
    }
429
2.38k
    savings=0.0;
430
2.38k
    if (totalBytesIfRaw>0.0)
431
59
        savings = 100.0 - ((totalBytes/totalBytesIfRaw)*100.0);
432
2.38k
    rfbLog(" %-20.20s: %6d | %9.0f/%9.0f (%5.1f%%)\n",
433
2.38k
            "TOTALS", totalRects, totalBytes,totalBytesIfRaw, savings);
434
435
2.38k
    totalRects=0.0;
436
2.38k
    totalBytes=0.0;
437
2.38k
    totalBytesIfRaw=0.0;
438
439
2.38k
    rfbLog("%-21.21s  %-6.6s   %9.9s/%9.9s (%6.6s)\n", "Statistics", "events", "Received","RawEquiv","saved");
440
4.89k
    for (ptr = cl->statMsgList; ptr!=NULL; ptr=ptr->Next)
441
2.51k
    {
442
2.51k
        name       = messageNameClient2Server(ptr->type, encBuf, sizeof(encBuf));
443
2.51k
        count      = ptr->rcvdCount;
444
2.51k
        bytes      = ptr->bytesRcvd;
445
2.51k
        bytesIfRaw = ptr->bytesRcvdIfRaw;
446
2.51k
        savings    = 0.0;
447
448
2.51k
        if (bytesIfRaw>0.0)
449
2.51k
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
450
2.51k
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
451
2.51k
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
452
2.51k
          name, count, bytes, bytesIfRaw, savings);
453
2.51k
        totalRects += count;
454
2.51k
        totalBytes += bytes;
455
2.51k
        totalBytesIfRaw += bytesIfRaw;
456
2.51k
    }
457
2.38k
    for (ptr = cl->statEncList; ptr!=NULL; ptr=ptr->Next)
458
0
    {
459
0
        name       = encodingName(ptr->type, encBuf, sizeof(encBuf));
460
0
        count      = ptr->rcvdCount;
461
0
        bytes      = ptr->bytesRcvd;
462
0
        bytesIfRaw = ptr->bytesRcvdIfRaw;
463
0
        savings    = 0.0;
464
465
0
        if (bytesIfRaw>0.0)
466
0
            savings = 100.0 - (((double)bytes / (double)bytesIfRaw) * 100.0);
467
0
        if ((bytes>0) || (count>0) || (bytesIfRaw>0))
468
0
            rfbLog(" %-20.20s: %6d | %9d/%9d (%5.1f%%)\n",
469
0
          name, count, bytes, bytesIfRaw, savings);
470
0
        totalRects += count;
471
0
        totalBytes += bytes;
472
0
        totalBytesIfRaw += bytesIfRaw;
473
0
    }
474
2.38k
    savings=0.0;
475
2.38k
    if (totalBytesIfRaw>0.0)
476
2.13k
        savings = 100.0 - ((totalBytes/totalBytesIfRaw)*100.0);
477
2.38k
    rfbLog(" %-20.20s: %6d | %9.0f/%9.0f (%5.1f%%)\n",
478
2.38k
            "TOTALS", totalRects, totalBytes,totalBytesIfRaw, savings);
479
      
480
2.38k
} 
481