diff --git a/src/server/ChangeLog b/src/server/ChangeLog index d9b1b038657fc95dc33e0a2f6240d55d3b3b96b8..37c59437969254e4ec7e698a305534532aa1cd7a 100644 --- a/src/server/ChangeLog +++ b/src/server/ChangeLog @@ -1,3 +1,10 @@ +Tue Apr 14 17:21:26 1992 Per Cederqvist (ceder@lysator) + + * session.c (create_oldstyle_username): New function. + * session.c (pepsi, change_what_am_i_doing, who_is_on, + get_session_info): Use it. (pepsi and change_what_am_i_doing used + to got the username wrong in 1.1.1). + Sat Apr 11 22:00:27 1992 Per Cederqvist (ceder@robin) * connections.c (check_kill_flag): Small optimization: don't call diff --git a/src/server/session.c b/src/server/session.c index 56a9c898d3122d41e6385c65ced47b57216f4e52..aab19da8023f52071d318394682790128c50081b 100644 --- a/src/server/session.c +++ b/src/server/session.c @@ -1,5 +1,5 @@ /* - * $Id: session.c,v 0.10 1992/04/10 11:56:36 ceder Exp $ + * $Id: session.c,v 0.11 1992/04/14 15:28:10 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -28,7 +28,7 @@ * Session control and miscellaneous. */ -static char *rcsid = "$Id: session.c,v 0.10 1992/04/10 11:56:36 ceder Exp $"; +static char *rcsid = "$Id: session.c,v 0.11 1992/04/14 15:28:10 ceder Exp $"; #include <time.h> @@ -47,6 +47,26 @@ static char *rcsid = "$Id: session.c,v 0.10 1992/04/10 11:56:36 ceder Exp $"; #include "config.h" #include "internal-connections.h" + +/* + * Create an oldstyle username, user%host.domain@host.domain. + * The RESULT must be initialized to a string (such as EMPTY_STRING). + * A new string will be allocated in RESULT. (The old will be freed). + */ +static void +create_oldstyle_username(String *result, + Connection *connection) +{ + if ( s_strcpy(result, cptr->username) != OK ) + restart_kom("create_oldstyle_username(): strcpy\n"); + + if ( s_strcat(result, s_fcrea_str((const unsigned char *)"@")) != OK ) + restart_kom("create_oldstyle_username: s_strcat\n"); + + if ( s_strcat(result, cptr->hostname) != OK ) + restart_kom("prot_a_parse_packet: s_strcat II\n"); +} + /* * This function is called whenever a person leaves a conf, * i e when he pepsi():s or logout():s. @@ -309,11 +329,15 @@ pepsi (Conf_no conference) { info.person = ACTPERS; info.what_am_i_doing = active_connection->what_am_i_doing; - info.username = active_connection->username; info.working_conference = conference; info.session_no = active_connection->session_no; - + + /* Bug compatibility. */ + create_oldstyle_username(&info.username, active_connection); + async_i_am_on(info); + + s_clear(&info.username); } return OK; @@ -343,16 +367,19 @@ change_what_i_am_doing (String what_am_i_doing) { info.person = ACTPERS; info.what_am_i_doing = active_connection->what_am_i_doing; - info.username = active_connection->username; + create_oldstyle_username(&info.username, active_connection); info.working_conference = active_connection->cwc; info.session_no = active_connection->session_no; async_i_am_on(info); + + s_clear(&info.username); } return OK; } + /* * Get info about what all the currently logged in persons are doing. */ @@ -391,15 +418,7 @@ who_is_on( Who_info_list *result ) /* Backward compatibility: Old clients want the username to be user%host@host. result->info[i].username is free()d in prot_a_output_who_info_list() in prot-a-output.c. */ - if ( s_strcpy(&result->info[i].username, cptr->username) != OK ) - restart_kom("who_is_on(): strcpy\n"); - - if ( s_strcat(&result->info[i].username, - s_fcrea_str((const unsigned char *)"@")) != OK ) - restart_kom("who_is_on: s_strcat\n"); - - if ( s_strcat(&result->info[i].username, cptr->hostname) != OK ) - restart_kom("prot_a_parse_packet: s_strcat II\n"); + create_oldstyle_username(&result->info[i].username, cptr); result->info[ i ].working_conference = cptr->cwc; result->info[ i ].session_no = cptr->session_no; @@ -488,15 +507,7 @@ get_session_info (Session_no session_no, /* Backward compatibility. result->username is free()d in prot_a_reply() prot-a.c. */ - if (s_strcpy(&result->username ,cptr->username) != OK) - restart_kom("get_session_info(): strcpy.\n"); - - if ( s_strcat(&result->username, - s_fcrea_str((const unsigned char *)"@")) != OK ) - restart_kom("get_session_info: s_strcat\n"); - - if ( s_strcat(&result->username, cptr->hostname) != OK ) - restart_kom("get_session_infot: s_strcat II\n"); + create_oldstyle_username(&result->username, cptr); return OK; }