adding SCP_SESSION and SCP_CONNECTION handling code

ulab-original
ilsimo 17 years ago
parent 38ec8c903c
commit 8c3d20c3d5

@ -2,6 +2,7 @@
LIBSCPOBJ = libscp_vX.o libscp_v0.o \ LIBSCPOBJ = libscp_vX.o libscp_v0.o \
libscp_v1s.o libscp_v1c.o \ libscp_v1s.o libscp_v1c.o \
libscp_init.o libscp_lock.o libscp_tcp.o \ libscp_init.o libscp_lock.o libscp_tcp.o \
libscp_session.o libscp_connection.o \
os_calls.o os_calls.o
DESTDIR = /usr/local/xrdp DESTDIR = /usr/local/xrdp

@ -30,6 +30,8 @@
#include "libscp_types.h" #include "libscp_types.h"
#include "libscp_connection.h"
#include "libscp_session.h"
#include "libscp_init.h" #include "libscp_init.h"
#include "libscp_tcp.h" #include "libscp_tcp.h"
#include "libscp_lock.h" #include "libscp_lock.h"

@ -0,0 +1,57 @@
/*
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.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_connection.c
* @brief SCP_CONNECTION handling code
* @author Simone Fedele
*
*/
#include "libscp_connection.h"
struct SCP_CONNECTION*
scp_connection_create(int sck)
{
struct SCP_CONNECTION* conn;
conn = g_malloc(sizeof(struct SCP_CONNECTION), 0);
if (0 == conn)
{
return 0;
}
conn->in_sck=sck;
make_stream(conn->in_s);
init_stream(conn->in_s, 8196);
make_stream(conn->out_s);
init_stream(conn->out_s, 8196);
return conn;
}
void
scp_connection_destroy(struct SCP_CONNECTION* c)
{
free_stream(c->in_s);
free_stream(c->out_s);
g_free(c);
}

@ -0,0 +1,54 @@
/*
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.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_connection.h
* @brief SCP_CONNECTION handling code
* @author Simone Fedele
*
*/
#ifndef LIBSCP_CONNECTION_H
#define LIBSCP_CONNECTION_H
#include "libscp.h"
/**
*
* @brief creates a new connection
* @param sck the connection socket
*
* @return a struct SCP_CONNECTION* object on success, NULL otherwise
*
*/
struct SCP_CONNECTION*
scp_connection_create(int sck);
/**
*
* @brief destroys a struct SCP_CONNECTION* object
* @param c the object to be destroyed
*
*/
void
scp_connection_destroy(struct SCP_CONNECTION* c);
#endif

@ -56,4 +56,3 @@ scp_make_connection(int sck)
return conn; return conn;
} }

@ -0,0 +1,228 @@
/*
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.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_session.c
* @brief SCP_SESSION handling code
* @author Simone Fedele
*
*/
#include "libscp_session.h"
struct SCP_SESSION*
scp_session_create()
{
struct SCP_SESSION* s;
s = g_malloc(sizeof(struct SCP_SESSION), 0);
if (0 == s)
{
return 0;
}
s->username=0;
s->password=0;
s->hostname=0;
s->errstr=0;
#warning usare scp_session_set* per inizializzare la sessione!!!!!!
return s;
}
/*******************************************************************/
int
scp_session_set_type(struct SCP_SESSION* s, tui8 type)
{
switch (type)
{
case SCP_SESSION_TYPE_XVNC:
s->type = SCP_SESSION_TYPE_XVNC;
break;
case SCP_SESSION_TYPE_XRDP:
s->type = SCP_SESSION_TYPE_XRDP;
break;
default:
return 1;
}
return 0;
}
/*******************************************************************/
int
scp_session_set_version(struct SCP_SESSION* s, tui32 version)
{
switch (version)
{
case 0:
s->version = 0;
break;
case 1:
s->version = 1;
break;
default:
return 1;
}
return 0;
}
/*******************************************************************/
int
scp_session_set_height(struct SCP_SESSION* s, tui16 h)
{
s->height = h;
return 0;
}
/*******************************************************************/
int
scp_session_set_width(struct SCP_SESSION* s, tui16 w)
{
s->width = w;
return 0;
}
/*******************************************************************/
int
scp_session_set_bpp(struct SCP_SESSION* s, tui8 bpp)
{
switch (bpp)
{
case 8:
case 16:
case 24:
s->bpp = bpp;
default:
return 1;
}
return 0;
}
/*******************************************************************/
int
scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr)
{
if (s->rsr)
{
s->rsr = 1;
}
else
{
s->rsr = 0;
}
return 0;
}
/*******************************************************************/
int
scp_session_set_locale(struct SCP_SESSION* s, char* str)
{
if (0 == str) return 1;
g_strncpy(s->locale, str, 17);
s->locale[17]='\0';
return 0;
}
/*******************************************************************/
int
scp_session_set_username(struct SCP_SESSION* s, char* str)
{
if (0 == str) return 1;
if (0 != s->username) g_free(s->username);
s->username = g_strdup(str);
return 0;
}
/*******************************************************************/
int
scp_session_set_password(struct SCP_SESSION* s, char* str)
{
if (0 == str) return 1;
if (0 != s->password) g_free(s->password);
s->password = g_strdup(str);
return 0;
}
/*******************************************************************/
int
scp_session_set_hostname(struct SCP_SESSION* s, char* str)
{
if (0 == str) return 1;
if (0 != s->hostname) g_free(s->hostname);
s->hostname = g_strdup(str);
return 0;
}
/*******************************************************************/
int
scp_session_set_errstr(struct SCP_SESSION* s, char* str)
{
if (0 == str) return 1;
if (0 != s->errstr) g_free(s->errstr);
s->errstr = g_strdup(str);
return 0;
}
/*******************************************************************/
int
scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display)
{
s->display=display;
return 0;
}
/*******************************************************************/
int
scp_session_set_addr(struct SCP_SESSION* s, int type, char* addr)
{
}
/*******************************************************************/
void
scp_session_destroy(struct SCP_SESSION* s)
{
if (s->username)
{
g_free(s->username);
s->username=0;
}
if (s->password)
{
g_free(s->password);
s->password=0;
}
if (s->hostname)
{
g_free(s->hostname);
s->hostname=0;
}
if (s->errstr)
{
g_free(s->errstr);
s->errstr=0;
}
g_free(s);
}

@ -0,0 +1,92 @@
/*
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.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005-2007
*/
/**
*
* @file libscp_session.h
* @brief SCP_SESSION handling code
* @author Simone Fedele
*
*/
#ifndef LIBSCP_SESSION_H
#define LIBSCP_SESSION_H
#include "libscp.h"
/**
*
* @brief creates a new connection
* @param sck the connection socket
*
* @return a struct SCP_SESSION* object on success, NULL otherwise
*
*/
struct SCP_SESSION*
scp_session_create();
int
scp_session_set_type(struct SCP_SESSION* s, tui8 type);
int
scp_session_set_version(struct SCP_SESSION* s, tui32 version);
int
scp_session_set_height(struct SCP_SESSION* s, tui16 h);
int
scp_session_set_width(struct SCP_SESSION* s, tui16 w);
int
scp_session_set_bpp(struct SCP_SESSION* s, tui8 bpp);
int
scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr);
int
scp_session_set_locale(struct SCP_SESSION* s, char* str);
int
scp_session_set_username(struct SCP_SESSION* s, char* str);
int
scp_session_set_password(struct SCP_SESSION* s, char* str);
int
scp_session_set_hostname(struct SCP_SESSION* s, char* str);
int
scp_session_set_addr(struct SCP_SESSION* s, int type, char* addr);
int
scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display);
int
scp_session_set_errstr(struct SCP_SESSION* s, char* str);
/**
*
* @brief destroys a session object
* @param s the object to be destroyed
*
*/
void
scp_session_destroy(struct SCP_SESSION* s);
#endif
Loading…
Cancel
Save