diff --git a/src/server/ChangeLog b/src/server/ChangeLog index 89f6a32bb70307733d6f8d4e129a359c1216fb34..d091fbc9e28a4f117770e6cad61451db79de0ca9 100644 --- a/src/server/ChangeLog +++ b/src/server/ChangeLog @@ -1,3 +1,7 @@ +Mon Nov 11 01:08:09 1991 Per Cederqvist (ceder at ruben) + + * fncdef.txt, prot-a.c, text.c: Added create_anonymous_text. + Tue Oct 29 15:48:15 1991 Linus Tolke Y (linus at ruben) * prot-a-output.c, prot-a-parse.c, ram-output.c, ram-parse.c diff --git a/src/server/fncdef.txt b/src/server/fncdef.txt index 51518237ad68980d9e46b57bca23555ae457ded5..b41e47c98a29eb611790f9db4c49d024c93a643a 100644 --- a/src/server/fncdef.txt +++ b/src/server/fncdef.txt @@ -1,5 +1,5 @@ # -# $Id: fncdef.txt,v 0.6 1991/11/10 19:02:35 linus Exp $ +# $Id: fncdef.txt,v 0.7 1991/11/11 00:27:41 ceder Exp $ # Copyright (C) 1991 Lysator Academic Computer Association. # # This file is part of the LysKOM server. @@ -22,7 +22,7 @@ # # Please mail bug reports to bug-lyskom@lysator.liu.se. # -# $Id: fncdef.txt,v 0.6 1991/11/10 19:02:35 linus Exp $ +# $Id: fncdef.txt,v 0.7 1991/11/11 00:27:41 ceder Exp $ # # This file is used to describe the functions in services.c. All # functions that are reachable from the clients are listed here, together @@ -94,3 +94,4 @@ success disconnect num success who_am_i : session_no success set_user_area num num success get_last_text time_date : text_no +number create_anonymous_text c_string (TEXT_LEN) num c_misc_info_p diff --git a/src/server/prot-a.c b/src/server/prot-a.c index a71f2f84a74c0c2009df24ee6b035c3f39063e54..5ebeb9c9bfac22875bbca7dcc922909bad183962 100644 --- a/src/server/prot-a.c +++ b/src/server/prot-a.c @@ -1,5 +1,5 @@ /* - * $Id: prot-a.c,v 0.9 1991/11/10 19:02:18 linus Exp $ + * $Id: prot-a.c,v 0.10 1991/11/11 00:27:32 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -26,7 +26,7 @@ * Protocol A. */ -static char *rcsid = "$Id: prot-a.c,v 0.9 1991/11/10 19:02:18 linus Exp $"; +static char *rcsid = "$Id: prot-a.c,v 0.10 1991/11/11 00:27:32 ceder Exp $"; #include <stdio.h> @@ -291,6 +291,7 @@ prot_a_is_legal_fnc(Call_header fnc) case call_fnc_who_am_i: case call_fnc_set_user_area: case call_fnc_get_last_text: + case call_fnc_create_anonymous_text: return TRUE; default: diff --git a/src/server/text.c b/src/server/text.c index 8363e7d266fe430e1e55cdeca77f0eb16c2df265..37bc0617d3e5a43fb0aabd9418a4cb98a15d82d6 100644 --- a/src/server/text.c +++ b/src/server/text.c @@ -1,5 +1,5 @@ /* - * $Id: text.c,v 0.9 1991/11/10 19:02:05 linus Exp $ + * $Id: text.c,v 0.10 1991/11/11 00:27:17 ceder Exp $ * Copyright (C) 1991 Lysator Academic Computer Association. * * This file is part of the LysKOM server. @@ -28,7 +28,7 @@ * All atomic calls that deals with texts. */ -static char *rcsid = "$Id: text.c,v 0.9 1991/11/10 19:02:05 linus Exp $"; +static char *rcsid = "$Id: text.c,v 0.10 1991/11/11 00:27:17 ceder Exp $"; #include <time.h> #include <stdlib.h> @@ -1705,6 +1705,72 @@ create_text(String message, return text; } +/* + * Create an anonymous text. + * + * This is just like create_text, but the author of the text is set to + * Pers_no 0, to guarantee that the author is anonymous. + * + * (This should really be called create_ftp_text (in analogy with + * change-conference which was truncated to CC, which was transmuted + * into pepsi) but public demand said NO!) + * + * Returns text_no of the created text, or 0 if there was an error. + */ +extern Text_no +create_anonymous_text(String message, + u_short no_of_misc, + Misc_info * misc ) +{ + Text_no text; + Text_stat * t_stat; + extern int errno; + + CHK_LOGIN(0); + + /* Check the length of the text. */ + + if ( s_strlen (message) >= TEXT_LEN ) + { + kom_errno = KOM_LONG_STR; + return 0; + } + + /* Check all misc-items */ + + if ( create_text_check_misc(&no_of_misc, misc) != OK + || (text = cached_create_text( message )) == 0) + { + return 0; + } + + if ( (t_stat = cached_get_text_stat( text )) == NULL ) + { + restart_kom("create_anonymous_text: can't get text-stat of " + "newly created text.\n" + "Text == %d, kom_errno == %d, errno == %d\n", + text, kom_errno, errno); + } + + t_stat->author = 0; + t_stat->creation_time = time(NULL); + t_stat->no_of_lines = count_lines( message ); + t_stat->no_of_chars = s_strlen( message ); + + if ( create_text_add_miscs(text, no_of_misc, misc) != OK ) + { + log("ERROR: create_text(): can't add miscs.\n"); + return 0; + } + + mark_text_as_changed( text ); + /* Don't add this person to create - we want true anonymity! */ + + async_new_text( text, t_stat ); /* Send asynchronous message. */ + + return text; +} + /* * Delete a text. *