summaryrefslogtreecommitdiffstats
path: root/raptorsmiface/libraptorsmiface.h
blob: 46aa1c9cce8ef1544ad52cfaee78c45875c8e3b0 (plain)
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
/*
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

   (c) 2012 Timothy Pearson
   (c) 2012 Raptor Engineering
*/

#include <unistd.h>

#include <sys/types.h>

typedef unsigned char bool;
#define true 1
#define false 0

// SM_STATUS_ALLOCATED: Server is not yet started
// SM_STATUS_RUNNING: Server is up, but client is not connected
// SM_STATUS_CONNECTED: Server is up and client is connected
enum raptor_sm_status {
	SM_STATUS_ALLOCATED,
	SM_STATUS_RUNNING,
	SM_STATUS_CONNECTED,
	SM_STATUS_FORCEKILL
};

#define RAPTOR_SM_SERVER_PID_FIELD "server_pid"
#define RAPTOR_SM_WM_PID_FIELD "wm_pid"

#define RAPTOR_SM_BASE_PULSEAUDIO_PORT 2000
#define RAPTOR_SM_MANAGEMENT_SERVER_IP_NETRANGE "10.0.0.0/8"

char* raptor_sm_get_ip_for_hostname(char* hostname, char* err);
char* raptor_sm_get_hostname_for_username(char* username, bool create);

char* raptor_sm_get_ip_for_username(char* username, bool create);
pid_t raptor_sm_run_remote_server(char* username, char *const argv[], char* dbfield, int display);
pid_t raptor_sm_get_pid_for_username(char* username, char* dbfield);
char* raptor_sm_server_started(char* username, pid_t pid, int display, char* dbfield);
char* raptor_sm_wm_started(char* username, pid_t pid, char* dbfield);
int   raptor_sm_get_display_for_username(char* username);
void  raptor_sm_wait_for_pid_exit(char* username, pid_t pid);
char* raptor_sm_get_username_for_display_and_hostname(int display, char* hostname);
void  raptor_sm_session_terminated(char* username);
void  raptor_sm_wm_terminated(char* username);
int   raptor_sm_get_new_unique_display(int mindisplay, int maxdisplay);
bool  raptor_sm_sesslimit_reached(char* username);
char  raptor_sm_set_session_state(int display, int state);
void  raptor_sm_run_remote_desktop(char* username, int display, char* executable);
void  raptor_sm_terminate_server(char* username);
char* raptor_sm_get_hostname_for_display(int display);
void  raptor_sm_stats_report_server_start(char* hostname);
void  raptor_sm_stats_report_server_stop(char* hostname);