summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sesman/libscp/Makefile1
-rw-r--r--sesman/libscp/libscp.h2
-rw-r--r--sesman/libscp/libscp_connection.c57
-rw-r--r--sesman/libscp/libscp_connection.h54
-rw-r--r--sesman/libscp/libscp_init.c9
-rw-r--r--sesman/libscp/libscp_session.c228
-rw-r--r--sesman/libscp/libscp_session.h92
7 files changed, 438 insertions, 5 deletions
diff --git a/sesman/libscp/Makefile b/sesman/libscp/Makefile
index 804734c0..fa2d594d 100644
--- a/sesman/libscp/Makefile
+++ b/sesman/libscp/Makefile
@@ -2,6 +2,7 @@
LIBSCPOBJ = libscp_vX.o libscp_v0.o \
libscp_v1s.o libscp_v1c.o \
libscp_init.o libscp_lock.o libscp_tcp.o \
+ libscp_session.o libscp_connection.o \
os_calls.o
DESTDIR = /usr/local/xrdp
diff --git a/sesman/libscp/libscp.h b/sesman/libscp/libscp.h
index 31aa367f..59e6f173 100644
--- a/sesman/libscp/libscp.h
+++ b/sesman/libscp/libscp.h
@@ -30,6 +30,8 @@
#include "libscp_types.h"
+#include "libscp_connection.h"
+#include "libscp_session.h"
#include "libscp_init.h"
#include "libscp_tcp.h"
#include "libscp_lock.h"
diff --git a/sesman/libscp/libscp_connection.c b/sesman/libscp/libscp_connection.c
new file mode 100644
index 00000000..40b947e2
--- /dev/null
+++ b/sesman/libscp/libscp_connection.c
@@ -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);
+}
diff --git a/sesman/libscp/libscp_connection.h b/sesman/libscp/libscp_connection.h
new file mode 100644
index 00000000..2db3fa1c
--- /dev/null
+++ b/sesman/libscp/libscp_connection.h
@@ -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
+
diff --git a/sesman/libscp/libscp_init.c b/sesman/libscp/libscp_init.c
index 48c6b2c3..768c69f9 100644
--- a/sesman/libscp/libscp_init.c
+++ b/sesman/libscp/libscp_init.c
@@ -28,7 +28,7 @@
#include "libscp_init.h"
/* server API */
-int DEFAULT_CC
+int DEFAULT_CC
scp_init(void)
{
scp_lock_init();
@@ -40,15 +40,15 @@ struct SCP_CONNECTION*
scp_make_connection(int sck)
{
struct SCP_CONNECTION* conn;
-
+
conn = g_malloc(sizeof(struct SCP_CONNECTION), 0);
if (0 == conn)
{
return 0;
}
-
- conn->in_sck=sck;
+
+ conn->in_sck = sck;
make_stream(conn->in_s);
init_stream(conn->in_s, 8196);
make_stream(conn->out_s);
@@ -56,4 +56,3 @@ scp_make_connection(int sck)
return conn;
}
-
diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c
new file mode 100644
index 00000000..2027a019
--- /dev/null
+++ b/sesman/libscp/libscp_session.c
@@ -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);
+}
diff --git a/sesman/libscp/libscp_session.h b/sesman/libscp/libscp_session.h
new file mode 100644
index 00000000..8a4e0364
--- /dev/null
+++ b/sesman/libscp/libscp_session.h
@@ -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