Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lyskom-server-ceder-1616-generations-topgit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
1d21aaee
Commit
1d21aaee
authored
Jul 08, 1998
by
Per Cederqvist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unused file removed.
parent
0fce2464
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
0 additions
and
4617 deletions
+0
-4617
src/libraries/libclient/.cvsignore
src/libraries/libclient/.cvsignore
+0
-0
src/libraries/libclient/Makefile.in
src/libraries/libclient/Makefile.in
+0
-109
src/libraries/libclient/async.c
src/libraries/libclient/async.c
+0
-524
src/libraries/libclient/async.h
src/libraries/libclient/async.h
+0
-57
src/libraries/libclient/client-Makefile.in
src/libraries/libclient/client-Makefile.in
+0
-109
src/libraries/libclient/client-malloc.h
src/libraries/libclient/client-malloc.h
+0
-28
src/libraries/libclient/client.c
src/libraries/libclient/client.c
+0
-203
src/libraries/libclient/client.h
src/libraries/libclient/client.h
+0
-82
src/libraries/libclient/input.c
src/libraries/libclient/input.c
+0
-283
src/libraries/libclient/input.h
src/libraries/libclient/input.h
+0
-104
src/libraries/libclient/kom-types.c
src/libraries/libclient/kom-types.c
+0
-88
src/libraries/libclient/output.c
src/libraries/libclient/output.c
+0
-675
src/libraries/libclient/output.h
src/libraries/libclient/output.h
+0
-299
src/libraries/libclient/parse.c
src/libraries/libclient/parse.c
+0
-1052
src/libraries/libclient/parse.h
src/libraries/libclient/parse.h
+0
-131
src/libraries/libclient/send.c
src/libraries/libclient/send.c
+0
-168
src/libraries/libclient/send.h
src/libraries/libclient/send.h
+0
-52
src/libraries/libclient/services.c
src/libraries/libclient/services.c
+0
-627
src/libraries/libclient/services.h
src/libraries/libclient/services.h
+0
-26
No files found.
src/libraries/libclient/.cvsignore
deleted
100644 → 0
View file @
0fce2464
src/libraries/libclient/Makefile.in
deleted
100644 → 0
View file @
0fce2464
AR
=
@AR@
RANLIB
=
@RANLIB@
srcdir
=
@srcdir@
VPATH
=
@srcdir@
CC
=
@CC@
-ansi
DEFS
=
@DEFS@
CFLAGS
=
-g
-Wall
${OPTFLAGS}
${DEFS}
\
-I
${srcdir}
/../../include
\
-I
${srcdir}
/../libmisc
../libclient-sup.a
:
input.o
\
async.o client.o send.o parse.o
\
kom-types.o output.o services.o
$(AR)
$(ARFLAGS)
$@
$?
$(RANLIB)
$@
# dependencies
async.o
:
async.c
\
../../include/kom-errno.h
\
../../include/kom-types.h
\
../../include/misc-types.h
\
../../include/services.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
\
async.h
\
client-malloc.h
\
client.h
\
parse.h
\
services.h
client.o
:
client.c
\
../../include/kom-types.h
\
../../include/misc-types.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
\
client-malloc.h
\
client.h
input.o
:
input.c
\
../../include/config.h
\
../../include/kom-errno.h
\
../../include/kom-types.h
\
../../include/m-config.h
\
../../include/misc-types.h
\
../../include/services.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
\
async.h
\
client.h
\
input.h
\
parse.h
kom-types.o
:
kom-types.c
\
../../include/config.h
\
../../include/kom-types.h
\
../../include/m-config.h
\
../../include/misc-types.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
output.o
:
output.c
\
../../include/com.h
\
../../include/config.h
\
../../include/kom-types.h
\
../../include/m-config.h
\
../../include/misc-types.h
\
../../include/services.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
\
client.h
\
output.h
\
send.h
\
services.h
parse.o
:
parse.c
\
../../include/kom-errno.h
\
../../include/kom-types.h
\
../../include/misc-types.h
\
../../include/services.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
\
async.h
\
client-malloc.h
\
parse.h
send.o
:
send.c
\
../../include/kom-types.h
\
../../include/misc-types.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
\
send.h
services.o
:
services.c
\
../../include/config.h
\
../../include/kom-errno.h
\
../../include/kom-types.h
\
../../include/m-config.h
\
../../include/misc-types.h
\
../../include/services.h
\
../libmisc/s-collat-tabs.h
\
../libmisc/s-string.h
\
client.h
\
input.h
\
output.h
\
parse.h
\
services.h
src/libraries/libclient/async.c
deleted
100644 → 0
View file @
0fce2464
/*
* $Id: async.c,v 1.3 1996/08/04 02:24:26 ceder Exp $
* Copyright (C) 1991, 1993, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
*
* LysKOM 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 1, or (at your option)
* any later version.
*
* LysKOM 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 LysKOM; see the file COPYING. If not, write to
* Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
* or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* async.c -- Receive asynchronous messages and call a handler.
*
* Written by Per Cederqvist 1990-07-24
*/
static
char
*
rcsid
=
"$Id: async.c,v 1.3 1996/08/04 02:24:26 ceder Exp $"
;
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/ioctl.h>
/* #include <sys/time.h> is included from kom-types.h */
#include <sys/types.h>
#if defined(__svr4__) && defined(__sparc__)
/* Solaris */
#include <stropts.h>
#include <sys/conf.h>
#define POLLINGREAD I_NREAD
#else
#define POLLINGREAD FIONREAD
#endif
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <kom-types.h>
#include <kom-errno.h>
#include <services.h>
#include "async.h"
#include "client-malloc.h"
#include "parse.h"
#include "client.h"
#include "services.h"
/*
* The handlers.
*/
static
void
(
*
new_text_handler
)(
Text_no
text_no
,
Text_stat
text_s
)
=
NULL
;
static
void
(
*
i_am_on_handler
)(
Who_info
info
)
=
NULL
;
static
void
(
*
i_am_off_handler
)(
Pers_no
pers_no
)
=
NULL
;
static
void
(
*
new_name_handler
)(
Conf_no
conf_no
,
String
old_name
,
String
new_name
)
=
NULL
;
static
void
(
*
directed_message_handler
)(
Conf_no
to
,
Conf_no
from
,
String
message
)
=
NULL
;
static
void
(
*
saving_handler
)(
void
)
=
NULL
;
/* Forward declarators for this file. */
static
Success
skip_one_token
(
FILE
*
fp
);
/*
* Functions that skip tokens. A token is:
* a number,
* a string or
* an array
*
* An array is
* the character '*' or
* the character '{' followed by any number of tokens followed by '}'
*/
/*
* skip_array is used when the first '{' of an array has been detected.
* It skips all tokens to the closing '}'.
*/
static
Success
skip_array
(
FILE
*
fp
)
{
int
c
;
while
(
skipwhite
(
fp
),
(
c
=
getc
(
fp
))
!=
'}'
)
{
ungetc
(
c
,
fp
);
if
(
skip_one_token
(
fp
)
!=
OK
)
return
FAILURE
;
}
return
OK
;
}
/*
* Skips the next token. Returns FAILURE if it isn't a token.
*/
static
Success
skip_one_token
(
FILE
*
fp
)
{
int
c
;
u_long
strlen
;
skipwhite
(
fp
);
switch
(
c
=
getc
(
fp
))
{
case
'{'
:
if
(
skip_array
(
fp
)
!=
OK
)
return
FAILURE
;
break
;
case
'*'
:
break
;
default:
if
(
!
isdigit
(
c
)
)
{
kom_errno
=
KOM_SERVER_IS_CRAZY
;
return
FAILURE
;
}
ungetc
(
c
,
fp
);
strlen
=
parse_long
(
fp
);
if
(
(
c
=
getc
(
fp
))
==
'H'
)
{
/* It was a string. Read it. */
while
(
strlen
--
>
0
)
getc
(
fp
);
}
else
{
/* It was a number. Ignore it. */
if
(
!
isspace
(
c
)
)
{
kom_errno
=
KOM_SERVER_IS_CRAZY
;
return
FAILURE
;
}
}
}
return
OK
;
}
/*
* Skip no_of_tokens token.
*/
static
Success
/* FIXME+++ - should this be exported? */
skip_token
(
FILE
*
fp
,
int
no_of_tokens
)
{
while
(
no_of_tokens
--
>
0
)
{
if
(
skip_one_token
(
fp
)
!=
OK
)
return
FAILURE
;
}
return
OK
;
}
/*
* Functions which gather the arguments for a handler and
* calls that handler.
*
* A handler is always responsible for free:ing everything
* which is given to it as a pointer. If no handler is registered
* these functions of course free everything they have malloced.
*/
static
Success
call_new_text
(
FILE
*
fp
)
{
Text_no
text_no
;
Text_stat
text
=
EMPTY_TEXT_STAT
;
text_no
=
parse_long
(
fp
);
if
(
parse_text_stat
(
fp
,
&
text
)
!=
OK
)
return
FAILURE
;
if
(
new_text_handler
==
NULL
)
{
if
(
text
.
misc_items
!=
NULL
)
isc_free
(
text
.
misc_items
);
}
else
new_text_handler
(
text_no
,
text
);
return
OK
;
}
static
Success
call_i_am_on
(
FILE
*
fp
)
{
Who_info
info
=
EMPTY_WHO_INFO
;
if
(
parse_who_info
(
fp
,
&
info
)
!=
OK
)
return
FAILURE
;
if
(
i_am_on_handler
==
NULL
)
{
s_clear
(
&
info
.
what_am_i_doing
);
s_clear
(
&
info
.
username
);
}
else
i_am_on_handler
(
info
);
return
OK
;
}
static
Success
call_i_am_off
(
FILE
*
fp
)
{
Pers_no
pers_no
;
pers_no
=
parse_long
(
fp
);
if
(
i_am_off_handler
!=
NULL
)
i_am_off_handler
(
pers_no
);
return
OK
;
}
static
Success
call_new_name
(
FILE
*
fp
)
{
Conf_no
conf_no
;
String
old_name
=
EMPTY_STRING
;
String
new_name
=
EMPTY_STRING
;
conf_no
=
parse_long
(
fp
);
if
(
parse_string
(
fp
,
&
old_name
)
!=
OK
||
parse_string
(
fp
,
&
new_name
)
!=
OK
)
{
return
FAILURE
;
}
if
(
new_name_handler
==
NULL
)
{
s_clear
(
&
old_name
);
s_clear
(
&
new_name
);
}
else
new_name_handler
(
conf_no
,
old_name
,
new_name
);
return
OK
;
}
static
Success
call_directed_message
(
FILE
*
fp
)
{
Conf_no
to
,
from
;
String
message
=
EMPTY_STRING
;
to
=
parse_long
(
fp
);
from
=
parse_long
(
fp
);
if
(
parse_string
(
fp
,
&
message
)
!=
OK
)
{
return
FAILURE
;
}
if
(
directed_message_handler
==
NULL
)
{
s_clear
(
&
message
);
}
else
directed_message_handler
(
to
,
from
,
message
);
return
OK
;
}
/*
* Call function telling that the server is syncing.
*/
static
Success
call_saving
(
FILE
*
fp
)
{
if
(
saving_handler
==
NULL
)
{
/* Do nothing */
}
else
{
saving_handler
();
}
return
OK
;
}
/*
* Parse an asynchronous message and call the appropriate function.
*/
Success
async
(
FILE
*
fp
)
{
int
tokens_to_skip
;
Async
fnc
;
tokens_to_skip
=
parse_long
(
fp
);
fnc
=
parse_long
(
fp
);
switch
(
fnc
)
{
case
ay_new_text
:
return
call_new_text
(
fp
);
case
ay_i_am_on
:
return
call_i_am_on
(
fp
);
case
ay_i_am_off
:
return
call_i_am_off
(
fp
);
case
ay_new_name
:
return
call_new_name
(
fp
);
case
ay_directed_message
:
return
call_directed_message
(
fp
);
case
ay_saving
:
return
call_saving
(
fp
);
default:
/*
* Messages that are not implemented. Since the server
* tells how long the message is it is possible to skip it.
*/
return
skip_token
(
fp
,
tokens_to_skip
);
}
}
/*
* Use the following functions to say that you want to catch a
* certain type of message. The default action is to ignore all
* messages.
*/
void
register_new_text
(
void
(
*
async_new_text
)(
Text_no
text_no
,
Text_stat
text_s
))
{
new_text_handler
=
async_new_text
;
}
void
register_i_am_on
(
void
(
*
async_i_am_on
)(
Who_info
info
))
{
i_am_on_handler
=
async_i_am_on
;
}
void
register_i_am_off
(
void
(
*
async_i_am_off
)(
Pers_no
pers_no
))
{
i_am_off_handler
=
async_i_am_off
;
}
void
register_new_name
(
void
(
*
async_new_name
)(
Conf_no
conf_no
,
String
old_name
,
String
new_name
))
{
new_name_handler
=
async_new_name
;
}
void
register_directed_message
(
void
(
*
async_message
)(
Conf_no
to
,
Conf_no
from
,
String
message
))
{
directed_message_handler
=
async_message
;
}
void
register_saving
(
void
(
*
saving_fun
)(
void
))
{
saving_handler
=
saving_fun
;
}
static
enum
{
poll_err
,
poll_got_msg
,
poll_no_msg
}
poll_server
(
void
)
{
int
c
;
long
nread
;
while
(
1
)
{
if
(
ioctl
(
kom_server
->
fd
,
POLLINGREAD
,
(
caddr_t
)
&
nread
)
!=
0
)
{
kom_errno
=
KOM_NO_CONNECT
;
return
poll_err
;
}
if
(
nread
==
0
)
return
poll_no_msg
;
if
(
(
c
=
getc
(
kom_server
->
in
))
==
':'
)
return
(
async
(
kom_server
->
in
)
==
OK
)
?
poll_got_msg
:
poll_err
;
if
(
!
isspace
(
c
)
)
{
kom_errno
=
KOM_SERVER_IS_CRAZY
;
return
poll_err
;
}
}
}
/*
* Wait for asynchronous message from client, or input on any of
* the file-descriptors in opt_set. Returns FAILURE if nothing
* happened in msec milliseconds or an error occurs. (kom_errno ==
* KOM_NO_ERR if the return was due to a timeout). Returns OK if
* there was an asynchronous message or input on any of the fd's in
* opt_set.
*
* Set opt_set to NULL if you don't want to wait on any other input
* than a message.
*
* To wait for a message or input on stdin the following code can be used:
*
* fd_set read_set;
*
* FD_ZERO(&read_set);
* FD_SET(fileno(stdin), &read_set);
* if ( kom_wait(read_set, 1000) == OK )
* {
* if ( FD_ISSET(fileno(stdio), &read_set) )
* handle_stdin_input();
* else
* handle_asynchronous_message();
* }
* else
* time_out();
*
* (The handler is called from kom_wait and not handle_asynchronous_message,
* but there might be more to do afterwards since a handler cannot call
* functions that communicate with the server.)
*/
extern
Success
kom_wait
(
fd_set
*
opt_set
,
int
msec
)
{
struct
timeval
wait
;
fd_set
read_set
;
int
nfds
;
kom_errno
=
KOM_NO_ERROR
;
switch
(
poll_server
())
{
case
poll_err
:
FD_ZERO
(
opt_set
);
return
FAILURE
;
case
poll_got_msg
:
FD_ZERO
(
opt_set
);
return
OK
;
case
poll_no_msg
:
break
;
}
/* No waiting message, so wait a while or two. */
/* Setup timeout structure */
wait
.
tv_sec
=
msec
/
1000
;
wait
.
tv_usec
=
(
msec
%
1000
)
*
1000
;
/* Setup file descriptor set */
if
(
opt_set
==
NULL
)
{
FD_ZERO
(
&
read_set
);
opt_set
=
&
read_set
;
}
FD_SET
(
kom_server
->
fd
,
opt_set
);
nfds
=
select
(
FD_SETSIZE
,
opt_set
,
(
fd_set
*
)
NULL
,
(
fd_set
*
)
NULL
,
&
wait
);
if
(
nfds
<
0
)
{
kom_errno
=
KOM_NO_CONNECT
;
return
FAILURE
;
}
if
(
FD_ISSET
(
kom_server
->
fd
,
opt_set
)
&&
poll_server
()
==
poll_err
)
{
return
FAILURE
;