CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/vncdll/winvnc/ParseHost.h
Views: 11780
1
// Copyright (C) 2006 Constantin Kaplinsky. All Rights Reserved.
2
//
3
// TightVNC is free software; you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation; either version 2 of the License, or
6
// (at your option) any later version.
7
//
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16
// USA.
17
//
18
// TightVNC distribution homepage on the Web: http://www.tightvnc.com/
19
20
//
21
// The ParseHostPort function parses a VNC host name which can be specified
22
// in one of these formats:
23
// (1) hostname
24
// (2) hostname:display (display < 100)
25
// (3) hostname:port (port >= 100)
26
// (4) hostname::port
27
// The function determines and returns the port number, and modifies str[]
28
// by inserting a zero byte in place of the first colon found in the string.
29
// The algorithm of determining the port number is as follows:
30
// (1) if there are no colons in the string, base_port is used;
31
// (2) if there is one colon and the following number is less than 100,
32
// then the port number is calculated by adding this number (display
33
// number) to base_port;
34
// (3) if there is one colon and the following number is 100 or greater,
35
// then this number is interpreted as a port number;
36
// (4) if there are two colons, the following number is always treated as
37
// a port number.
38
//
39
40
int ParseHostPort(char *str, int base_port);
41
42