-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathr_util.cpp
More file actions
83 lines (70 loc) · 1.5 KB
/
Copy pathr_util.cpp
File metadata and controls
83 lines (70 loc) · 1.5 KB
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
#include "r_util.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <winuser.h>
#include <stdarg.h>
#include <stringapiset.h>
#include <string>
void SkipSpace(char*& p)
{
while(*p == ' ')
++p;
}
int SkipLine(char*& p)
{
char* pp = strstr(p, "\r\n");
if(pp)
{
p = pp + strlen("\r\n");
return 0;
}
return -1;
}
int get_rtsp_addr(r_string& url, r_string& host, int& port)
{
port = 554;
if(0 != memcmp(url.c_str(), "rtsp://", strlen("rtsp://")))
{
r_log("%s illegal\n", url.c_str());
return -1;
}
char* start = url.Data() + strlen("rtsp://");
char* p = strchr(start, ':');
if(p)
{
host.assign(start, p - start);
++p;
port = atoi(p);
}
else
{
p = strchr(start, '/');
if(p)
{
host.assign(start, p - start);
}
else
{
host.assign(start, url.Size() - (start - url.c_str()));
}
}
r_log("host:%s, port:%d\n", host.c_str(), port);
return 0;
}
void r_log(const char* pszFormat, ...)
{
va_list pArgs;
char szMessageBuffer[64]={0};
va_start( pArgs, pszFormat );
_vsnprintf( szMessageBuffer, 64, pszFormat, pArgs );
va_end( pArgs );
TCHAR buf[64] = {0};
#ifdef UNICODE
MultiByteToWideChar(CP_ACP, 0, szMessageBuffer, -1, buf, 64);
#else
strcpy(buf, strszMessageBufferUsr);
#endif
OutputDebugString(buf);
}