-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_Net_Send_Session.c
187 lines (145 loc) · 3.96 KB
/
_Net_Send_Session.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
** SPDX-License-Identifier: GPL-3.0-or-later
** Copyright (c) 2023-2024 Rene W. Olsen <[email protected]>
*/
// --
#include "RVNCd.h"
// --
void myInitSessionInfo( struct Config *cfg, int a, int b, int c, int d )
{
//struct CommandSession *msg;
memset( & cfg->SessionStatus, 0, sizeof( cfg->SessionStatus ));
LogTime_Init( & cfg->SessionStatus.si_LogTime );
cfg->SessionStatus.si_IPAddr[0] = a;
cfg->SessionStatus.si_IPAddr[1] = b;
cfg->SessionStatus.si_IPAddr[2] = c;
cfg->SessionStatus.si_IPAddr[3] = d;
cfg->cfg_ServerPrintSession = TRUE;
cfg->cfg_SessionUsed = TRUE;
// --
// msg = myCalloc( sizeof( struct CommandSession ) );
//
// if ( msg )
// {
// msg->cs_Command = CMD_Session;
// msg->cs_Starting = 1;
//
// IExec->PutMsg( CmdMsgPort, & msg->cs_Message );
// }
}
// --
void myPrintSessionInfo( struct Config *cfg )
{
//struct CommandSession *msg;
// --
LogTime_Stop( & cfg->SessionStatus.si_LogTime );
// --
// msg = myCalloc( sizeof( struct CommandSession ));
//
// if ( msg )
// {
// msg->cs_Command = CMD_Session;
// msg->cs_Starting = 0;
//
// IExec->PutMsg( CmdMsgPort, & msg->cs_Message );
// }
// --
if ( ! cfg->cfg_ServerPrintSession )
{
goto bailout;
}
cfg->cfg_ServerPrintSession = FALSE;
if ( ! DoVerbose )
{
goto bailout;
}
static char Buf_Tiles_Total[32];
static char Buf_Tiles_ZLib[32];
static char Buf_Tiles_Raw[32];
static char Buf_Duration[64];
static char Buf_Connect[64];
static char Buf_Read[32];
static char Buf_Send[32];
LogTime_GetConnectTime( & cfg->SessionStatus.si_LogTime, Buf_Connect, sizeof( Buf_Connect ));
LogTime_GetDurationTime( & cfg->SessionStatus.si_LogTime, Buf_Duration, sizeof( Buf_Duration ));
Session_GetProcent( Buf_Tiles_Total, sizeof( Buf_Tiles_Total ), cfg->SessionStatus.si_Tiles_Total, cfg->SessionStatus.si_Tiles_Total );
Session_GetProcent( Buf_Tiles_ZLib, sizeof( Buf_Tiles_ZLib ), cfg->SessionStatus.si_Tiles_Total, cfg->SessionStatus.si_Tiles_ZLib );
Session_GetProcent( Buf_Tiles_Raw, sizeof( Buf_Tiles_Raw ), cfg->SessionStatus.si_Tiles_Total, cfg->SessionStatus.si_Tiles_Raw );
Session_GetBytes( Buf_Read, sizeof( Buf_Read ), cfg->SessionStatus.si_Read_Bytes );
Session_GetBytes( Buf_Send, sizeof( Buf_Send ), cfg->SessionStatus.si_Send_Bytes );
printf( "\n" );
printf( "Session Infomation\n" );
printf( "\n" );
printf( "IP Address ..... : %d.%d.%d.%d\n", cfg->SessionStatus.si_IPAddr[0], cfg->SessionStatus.si_IPAddr[1], cfg->SessionStatus.si_IPAddr[2], cfg->SessionStatus.si_IPAddr[3] );
printf( "Connected at ... : %s\n", Buf_Connect );
printf( "Duration ....... : %s\n", Buf_Duration );
printf( "\n" );
printf( "Bytes Read ..... : %s\n", Buf_Read );
printf( "Bytes Send ..... : %s\n", Buf_Send );
printf( "\n" );
printf( "Tiles .......... : %s\n", Buf_Tiles_Total );
printf( "Raw Tiles ...... : %s\n", Buf_Tiles_Raw );
printf( "ZLib Tiles ..... : %s\n", Buf_Tiles_ZLib );
printf( "\n" );
bailout:
return;
}
// --
void Session_GetBytes( char *buf, int len, uint64 val )
{
uint64 v4;
uint64 v2;
uint64 v3;
uint64 tmp;
if ( val < 1024LL )
{
snprintf( buf, len, "%lld B", val );
return;
}
v2 = 512LL;
v3 = 1024LL;
v4 = 1024LL * 1024LL;
if ( val < v4 )
{
snprintf( buf, len, "%lld KB", ( val + v2 ) / ( v3 ));
return;
}
v2 *= 1024LL;
v3 *= 1024LL;
v4 *= 1024LL;
if ( val < v4 )
{
tmp = ( val + v2 ) * 10 / v3;
snprintf( buf, len, "%lld.%lld MB", tmp / 10, tmp % 10 );
return;
}
v2 *= 1024LL;
v3 *= 1024LL;
v4 *= 1024LL;
if ( val < v4 )
{
tmp = ( val + v2 ) * 10 / v3;
snprintf( buf, len, "%lld.%lld GB", tmp / 10, tmp % 10 );
return;
}
v2 *= 1024LL;
v3 *= 1024LL;
// v4 *= 1024LL;
tmp = ( val + v2 ) * 10 / v3;
snprintf( buf, len, "%lld.%lld TB", tmp / 10, tmp % 10 );
}
// --
void Session_GetProcent( char *buf, int len, uint64 total, uint64 val )
{
uint64 v;
if ( total )
{
v = (( val * 100LL ) / total );
snprintf( buf, len, "%lld (%lld%%)", val, v );
}
else
{
snprintf( buf, len, "0 (--%%)" );
}
}
// --