From 6535366c633073db97a669ed671c1608383f9f1f Mon Sep 17 00:00:00 2001 From: nobody <nomail@example.com> Date: Tue, 23 Jun 1992 23:40:49 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'ceder.nanny.I'. --- db-crypt/db/ramkomd-data | Bin 621 -> 0 bytes db-crypt/db/ramkomd-texts | 0 doc/ADMINISTRATING | 46 - doc/INSTALL | 2 - doc/Makefile.template | 63 - doc/man/man5/ramkom.5 | 317 ---- doc/man/man8/ramkomd.8 | 118 -- doc/prot-A.bnf | 1067 ----------- doc/prot-A.slightly-obsolete | 230 --- doc/vad-aer-olaest.swe | 145 -- foo | 0 run-support/.cvsignore | 1 - run-support/updateLysKOM | 3 - scripts/import.make | 60 - src/include/dependencies | 0 src/include/server/dependencies | 0 src/libraries/libansi/config.h | 8 - src/libraries/libansi/dependencies | 1 - src/libraries/libansi/libansi.a | Bin 1280 -> 0 bytes src/libraries/libcommon/.cvsignore | 2 - src/libraries/libcommon/ChangeLog | 23 - src/libraries/libcommon/Makefile | 92 - src/libraries/libcommon/README | 5 - src/libraries/libcommon/dependencies | 26 - src/libraries/libcommon/kom-errno.c | 201 --- src/libraries/libcommon/misc-parser.c | 207 --- src/libraries/libcommon/misc-parser.h | 102 -- src/libraries/libcommon/parser.c | 449 ----- src/libraries/libcommon/parser.h | 173 -- src/libraries/libmisc/dependencies | 46 - src/libraries/libmisc/testnumlist | Bin 32768 -> 0 bytes src/server/.cvsignore | 11 - src/server/ChangeLog | 1295 -------------- src/server/FileList | 126 -- src/server/Magics | 15 - src/server/Makefile | 177 -- src/server/To-do | 32 - src/server/admin.c | 197 -- src/server/admin.h | 30 - src/server/async.h | 56 - src/server/cache-node.c | 237 --- src/server/cache-node.h | 117 -- src/server/cache.h | 260 --- src/server/call-switch.awk | 81 - src/server/com-h.awk | 46 - src/server/conference.c | 951 ---------- src/server/connections.c | 958 ---------- src/server/connections.h | 224 --- src/server/dbck-cache.c | 773 -------- src/server/dbck-cache.h | 36 - src/server/dbck.c | 1290 -------------- src/server/disk-cache.h | 32 - src/server/disk-end-of-atomic.c | 73 - src/server/end-of-atomic.h | 36 - src/server/exp.h | 30 - src/server/fnc-def-init.awk | 48 - src/server/fncdef.txt | 102 -- src/server/free.gdb | 10 - src/server/getopt.h | 113 -- src/server/handle-malloc-dump.el | 157 -- src/server/internal-connections.c | 276 --- src/server/internal-connections.h | 48 - src/server/internal-services.h | 60 - src/server/isc-interface.h | 32 - src/server/isc-malloc.c | 76 - src/server/isc-malloc.h | 46 - src/server/isc-parse.c | 59 - src/server/isc-parse.h | 37 - src/server/kom-types.c | 101 -- src/server/log.c | 67 - src/server/log.h | 48 - src/server/logII.c | 113 -- src/server/lyskomd.h | 45 - src/server/malloc.gdb | 11 - src/server/manipulate.h | 396 ---- src/server/membership.c | 1224 ------------- src/server/memory.c | 360 ---- src/server/memory.h | 83 - src/server/minmax.h | 32 - src/server/missing-ansi.c | 110 -- src/server/mux-parse.c | 281 --- src/server/mux-parse.h | 41 - src/server/mux.c | 435 ----- src/server/mux.h | 139 -- src/server/person.c | 824 --------- src/server/prot-a-output.c | 593 ------ src/server/prot-a-output.h | 137 -- src/server/prot-a-parse-arg-c.awk | 134 -- src/server/prot-a-parse-arg-h.awk | 37 - src/server/prot-a-parse.c | 350 ---- src/server/prot-a-parse.h | 52 - src/server/prot-a-send-async.c | 177 -- src/server/prot-a-send-async.h | 78 - src/server/prot-a.c | 368 ---- src/server/prot-a.h | 41 - src/server/ram-output.c | 410 ----- src/server/ram-output.h | 98 - src/server/ram-parse.c | 1201 ------------- src/server/ram-parse.h | 128 -- src/server/ram-smalloc.c | 257 --- src/server/ramkomd.c | 415 ----- src/server/realloc.gdb | 14 - src/server/rfc931.c | 57 - src/server/rfc931.h | 26 - src/server/send-async.c | 422 ----- src/server/send-async.h | 72 - src/server/server-config.c | 168 -- src/server/session.c | 660 ------- src/server/simple-cache.c | 2131 ---------------------- src/server/string-malloc.c | 76 - src/server/string-malloc.h | 46 - src/server/text-garb.c | 161 -- src/server/text-garb.h | 31 - src/server/text.c | 2380 ------------------------- src/server/tmp-limits.h | 30 - src/server/trace-mem.gdb | 20 - src/server/version.incl | 30 - 117 files changed, 26644 deletions(-) delete mode 100644 db-crypt/db/ramkomd-data delete mode 100644 db-crypt/db/ramkomd-texts delete mode 100644 doc/ADMINISTRATING delete mode 100644 doc/INSTALL delete mode 100644 doc/Makefile.template delete mode 100644 doc/man/man5/ramkom.5 delete mode 100644 doc/man/man8/ramkomd.8 delete mode 100644 doc/prot-A.bnf delete mode 100644 doc/prot-A.slightly-obsolete delete mode 100644 doc/vad-aer-olaest.swe delete mode 100644 foo delete mode 100644 run-support/.cvsignore delete mode 100644 run-support/updateLysKOM delete mode 100644 scripts/import.make delete mode 100644 src/include/dependencies delete mode 100644 src/include/server/dependencies delete mode 100644 src/libraries/libansi/config.h delete mode 100644 src/libraries/libansi/dependencies delete mode 100644 src/libraries/libansi/libansi.a delete mode 100644 src/libraries/libcommon/.cvsignore delete mode 100644 src/libraries/libcommon/ChangeLog delete mode 100644 src/libraries/libcommon/Makefile delete mode 100644 src/libraries/libcommon/README delete mode 100644 src/libraries/libcommon/dependencies delete mode 100644 src/libraries/libcommon/kom-errno.c delete mode 100644 src/libraries/libcommon/misc-parser.c delete mode 100644 src/libraries/libcommon/misc-parser.h delete mode 100644 src/libraries/libcommon/parser.c delete mode 100644 src/libraries/libcommon/parser.h delete mode 100644 src/libraries/libmisc/dependencies delete mode 100755 src/libraries/libmisc/testnumlist delete mode 100644 src/server/.cvsignore delete mode 100644 src/server/ChangeLog delete mode 100644 src/server/FileList delete mode 100644 src/server/Magics delete mode 100755 src/server/Makefile delete mode 100644 src/server/To-do delete mode 100644 src/server/admin.c delete mode 100644 src/server/admin.h delete mode 100644 src/server/async.h delete mode 100644 src/server/cache-node.c delete mode 100644 src/server/cache-node.h delete mode 100644 src/server/cache.h delete mode 100644 src/server/call-switch.awk delete mode 100644 src/server/com-h.awk delete mode 100644 src/server/conference.c delete mode 100644 src/server/connections.c delete mode 100644 src/server/connections.h delete mode 100644 src/server/dbck-cache.c delete mode 100644 src/server/dbck-cache.h delete mode 100644 src/server/dbck.c delete mode 100644 src/server/disk-cache.h delete mode 100644 src/server/disk-end-of-atomic.c delete mode 100644 src/server/end-of-atomic.h delete mode 100644 src/server/exp.h delete mode 100644 src/server/fnc-def-init.awk delete mode 100644 src/server/fncdef.txt delete mode 100644 src/server/free.gdb delete mode 100644 src/server/getopt.h delete mode 100644 src/server/handle-malloc-dump.el delete mode 100644 src/server/internal-connections.c delete mode 100644 src/server/internal-connections.h delete mode 100644 src/server/internal-services.h delete mode 100644 src/server/isc-interface.h delete mode 100644 src/server/isc-malloc.c delete mode 100644 src/server/isc-malloc.h delete mode 100644 src/server/isc-parse.c delete mode 100644 src/server/isc-parse.h delete mode 100644 src/server/kom-types.c delete mode 100644 src/server/log.c delete mode 100644 src/server/log.h delete mode 100644 src/server/logII.c delete mode 100644 src/server/lyskomd.h delete mode 100644 src/server/malloc.gdb delete mode 100644 src/server/manipulate.h delete mode 100644 src/server/membership.c delete mode 100644 src/server/memory.c delete mode 100644 src/server/memory.h delete mode 100644 src/server/minmax.h delete mode 100644 src/server/missing-ansi.c delete mode 100644 src/server/mux-parse.c delete mode 100644 src/server/mux-parse.h delete mode 100644 src/server/mux.c delete mode 100644 src/server/mux.h delete mode 100644 src/server/person.c delete mode 100644 src/server/prot-a-output.c delete mode 100644 src/server/prot-a-output.h delete mode 100644 src/server/prot-a-parse-arg-c.awk delete mode 100644 src/server/prot-a-parse-arg-h.awk delete mode 100644 src/server/prot-a-parse.c delete mode 100644 src/server/prot-a-parse.h delete mode 100644 src/server/prot-a-send-async.c delete mode 100644 src/server/prot-a-send-async.h delete mode 100644 src/server/prot-a.c delete mode 100644 src/server/prot-a.h delete mode 100644 src/server/ram-output.c delete mode 100644 src/server/ram-output.h delete mode 100644 src/server/ram-parse.c delete mode 100644 src/server/ram-parse.h delete mode 100644 src/server/ram-smalloc.c delete mode 100644 src/server/ramkomd.c delete mode 100644 src/server/realloc.gdb delete mode 100644 src/server/rfc931.c delete mode 100644 src/server/rfc931.h delete mode 100644 src/server/send-async.c delete mode 100644 src/server/send-async.h delete mode 100644 src/server/server-config.c delete mode 100644 src/server/session.c delete mode 100644 src/server/simple-cache.c delete mode 100644 src/server/string-malloc.c delete mode 100644 src/server/string-malloc.h delete mode 100644 src/server/text-garb.c delete mode 100644 src/server/text-garb.h delete mode 100644 src/server/text.c delete mode 100644 src/server/tmp-limits.h delete mode 100644 src/server/trace-mem.gdb delete mode 100644 src/server/version.incl diff --git a/db-crypt/db/ramkomd-data b/db-crypt/db/ramkomd-data deleted file mode 100644 index bf280601c0ddcd88ebd7e3190f6727734d78053d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 621 zcmZ?vadq_LGUL)#P%tw02q;P|PR%PxEXmBzQ_x5(Q^>1K)Kti=DM`&!Fi_A^Fa(nZ z1_lNSW)>#q<|gI_7Dy}u1q3uV2bpPXh|A2>l$_Mu+{7ZVi6onAXyM_LSWu8yq@Yny ztErGuQ&dE*6AjHh{3<h2OHzvz@^ck@DvQ1SeaUl_k(q~MN^WLeW^qYTV#&861&y?C zMVc@p4Hc>tOciROVQ6SzU<eI43kypmmZ^e)0tkab(%hWO0SdJh%uGBi(}T>@+#-Xr zva?Ex8At~TMiw5)sVS*NsyUU#i6!|(4p3SzC$m(qI90(A4Jd%38ib*)hNOXN6z3Y5 cLY%9mPzx2eG%`^zP%t)CFhWWX23&?*01A+WP5=M^ diff --git a/db-crypt/db/ramkomd-texts b/db-crypt/db/ramkomd-texts deleted file mode 100644 index e69de29bb..000000000 diff --git a/doc/ADMINISTRATING b/doc/ADMINISTRATING deleted file mode 100644 index d7e2d490d..000000000 --- a/doc/ADMINISTRATING +++ /dev/null @@ -1,46 +0,0 @@ - Administrating a LysKOM site - ============================ - - This document is a short description of how to administrate a LysKOM -database on your site. - - The first thing you will have to do is to follow the instructions in -the file INSTALL. This will set up the LysKOM system with a database -containing a few necessary conferences and one person - the -administrator. - - Once the LysKOM system is running, there is not much you will have -to do to keep it that way. One thing to remember is that the current -release of the server (0.32) has an incomplete handling of garbage -collection of the database. The database is split into two files, the -information file and the text file. Newly written texts are -concatenated to the text file and old texts are never removed. The -information file contains information about conferences, users and -where in the text file the texts are. This file is properly garbage -collected, but not the text file. - - There is a program called dbck (Data Base Check) which is used to -check the consistency of the LysKOM database. This program can also -be used to shrink the text file. To do this, just type `dbck -g' in -the database directory, or give additional switches to dbck to use the -correct directory. See further the manual page for dbck. When dbck -is to be run on the database, the LysKOM server *must* be stopped, or -unrepairable damage may result. See below for a description on how to -stop the server. - - There is a shell script called updateLysKOM which is used to insure -continuous operation. This script is run with certain intervals and -if the LysKOM server has died for some reason, updateLysKOM restarts -it. If the server is still running properly, updateLysKOM sends a -signal (SIGUSR1) to it, which causes the server to write call -statistics to a file named etc/lyskomd-log in the lyskom directory. - - Taking the server down cleanly can be done in two ways: through the -use of the LysKOM protocol on a socket, preferably through the use of -a suitable client, or to send the signal SIGHUP to it. This will -cause the server to save the database and close all client -connections. It will also create a file named etc/memory-usage in -which the memory usage of the server is reported. There is currently -a small memory leak in the server. We know about it, so there is no -need to send bug reports to us about that (unless you have found where -the leak is). diff --git a/doc/INSTALL b/doc/INSTALL deleted file mode 100644 index ec7b09e4a..000000000 --- a/doc/INSTALL +++ /dev/null @@ -1,2 +0,0 @@ -Edit src/server/config.c. Be careful to check - MAX_NO_OF_CONNECTIONS. \ No newline at end of file diff --git a/doc/Makefile.template b/doc/Makefile.template deleted file mode 100644 index f92cc4512..000000000 --- a/doc/Makefile.template +++ /dev/null @@ -1,63 +0,0 @@ -# -# $Id: Makefile.template,v 0.2 1991/09/15 09:54:15 linus Exp $ -# Copyright (C) 1991 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. -# -# Makefile for LysKOM -# -############################################################################### -# -# SPECIAL CONSIDERATIONS: -# -# - Requires GNU make. -# - CC, OPTIMIZE-FLAGS and other make variables are passed down -# in the environment. -# - C compiler must be ANSI conformant. -# -############################################################################### -# -# SPECIAL TARGETS: -############################################################################### - -# Directories that you might want to override via the environment. - -ifndef TOPDIR -TOPDIR := /usr/lyskom/src -endif - -ifndef SCRIPTDIR -SCRIPTDIR := $(TOPDIR)/scripts -endif - -include $(SCRIPTDIR)/import.make - - -# All directories that make should traverse to when doing clean etc. - -SUBDIRS = doc include junk lib scripts src - -all: - for i in $(SUBDIRS) ; \ - do \ - echo making all in directory $$i; \ - (cd $$i; $(MAKE) all) \ - done diff --git a/doc/man/man5/ramkom.5 b/doc/man/man5/ramkom.5 deleted file mode 100644 index fa0e2d1e1..000000000 --- a/doc/man/man5/ramkom.5 +++ /dev/null @@ -1,317 +0,0 @@ -.\" $Id: ramkom.5,v 1.4 1991/09/15 09:54:59 linus Exp $ -.\" Copyright (C) 1991 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. -.\" -.\" $Id: ramkom.5,v 1.4 1991/09/15 09:54:59 linus Exp $ -.\" $Date: 1991/09/15 09:54:59 $ -.TH ramkom 5 "August 24, 1991" -.SH NAME -ramkom - LysKOM -.I database -format -.SH SYNOPSIS -.B /usr/lyskom/db/ramkomd-* -.br -and -.br -.B /usr/lyskom/etc/pid -.PP -.B #include <lyskom/kom-types.h> -.SH DISCLAIMER -The -.I database -is not really a database but a sequential file where all data is saved -from the memory. -.SH DESCRIPTION -There are 2 files: One file with all the data -.RB ( ramkomd-data ). -And one with all texts -.RB ( ramkomd-texts ). -The texts file does not contain any information about where any text -starts of ends, all this is in the data file together with other infos -on the text. -.PP -If the first five chars of the data file is CLEAN then the -.I database -is considered clean. If its anything else the -.BR ramkomd (8) -program will try to find the backupfile instead. -.PP -Then there is a number telling the number of the next free conference -.RI ( next_free_num ). -.PP -Now follows a list of all conferences. One conference on each line. If -the conference is deleted the line consists of a -.B @ -otherwise it starts with a -.BR + . -.PP -Now follows a list of all person statuses. Here is also every person -on its own line and the deleted persons or the numbers that are not -persons but conferences are lines containing just a -.BR @ . -.PP -Both the conference status part and the person status part are exactly -.IR next_free_num -1 -lines long. -.PP -Now follows the number of the next text that is not used and a list of -text statuses. -Every text status has its own line just like the other statuses and -non-existent texts are represented by the -.BI @ . -.PP -The different statuses types are -.B conference -.BR statuses , -.B person statuses -and -.B text -.BR statuses . -These are in a struct in the include file but in this file they are -not saved as structs but every element is saved as a ascii string. -Strings are saved as holerith strings. The field of the struct is not -even saved in the same order as in the struct. -Their order in the database is followed below. -.PP -An array of things is represented in the database by a number telling -how many elements there are in the array and the either a -.B * -in the case no elements or a -.B { -followed by all the elements and a finishing -.BR } . -.SS Conference status -.LP -This contains all information for a conference. A conference is a -object that recieves texts. -.TP 15 -.I Name -Name of the conference saved as a holerith string. -.TP -.I Member list -An array of the members in that conference. -.TP -.I First local number -This is the local number of the first text in the conference. Its -saved here in order to save space in this file by not mentioning all -deleted texts in the beginning of the conference. -.TP -.I Texts -This is an array of recieved texts. The local number of the text is -determined by the position in this list and the value of the -.I first local -.IR number . -.TP -.I Type -This is the type of the conf, it contains the infomation that says if -the conference is read protected, original flagged conference, secret, -or if its a letter box. -.TP -.I Creation time -The time the conference was created. -.TP -.I Last written -The time the last text was sent to the conference. -.TP -.I Creator -The number of the person that has created the conference. This is 0 -for conferences that are created initially. -.TP -.I Presentation -This is the number of the text containing a presentation of the -conference. If there is no presentation this number is 0. -.TP -.I Supervisor -This is the number of the conference whose members are supervisors of -the conference. Initially this is set to be the number of the letter -box of the creator. -.TP -.I Permitted submitters -This is the number of the conference whose members are allowed to -submit texts to this conference. If this is 0 (the default) all -persons i -.B LysKOM -are allowed to submit. -.TP -.I Super conference -This is a number of a conference that comments to articles should be -sent to if this conference is original flagged. -.TP -.I Message of the day -This is the textnumber of the text containing a notice message about -the conference. Mostly used for letter boxes. If 0 then there is no -such message. -.TP -.I Garb nice -This is the number of days a text stays in the conference before it is -removed by the expiration routines. Its really the expiration rate. -.SS Person statuses -.LP -Person statuses contains all info about persons. -.TP 15 -.I Password -The password is stored as a string. The length of the string is 64 but -the length of the password itself is stored as the first char in the -string. Passwords longer that 63 chars are truncated. -.TP -.I Username -This is the username and machine from the last time the person logged in. -.TP -.I Privileges -The persons privileges are stored here. This is a bit array, length is -16 bits. It is not really welldetemined what bit does what. -.TP -.I Personal flags -The persons flags are stored here. -.TP -.I First local number -This is the local number of the first created text that still exists -in the database. Its local to this list. -.TP -.I Created text list -This is an array of all created texts beginning at the first local -number. -.TP -.I Marked texts -This is an array of all marked texts and their mark type. Every -element in the array is a text number and a mark number. -.TP -.I Membership -Here is the information about which conferences the person is member -in. Its an array where every element is of the type -.B Membership -(See below). -.TP -.I Last login -Time of the last login. -.TP -.I User area -Number of the text being the persons user area. If there is no user -area this is 0. -.TP -.I Total time present -Time in -.B LysKOM -in seconds. -.TP -.I Sessions -Number of logins made for that person. -.TP -.I Created lines -.TP -.I Created bytes -.TP -.I Read texts -Count of read marked texts. -.TP -.I No of fetches -This is the information about how many texts this person has fetched. -Using caching clients this number could increase well beyond -.I Read -.IR texts . -.TP -.I Created persons -Count of created persons. -.TP -.I Created conferences -Count of created conferences. -.SS Text statuses -This contains info about the texts. -.TP 15 -.I Created time -Time this text was created. -.TP -.I Author -Person that wrote this text. -.TP -.I Start -Start pointer for the text in the -.I ramkomd-texts -file. -.TP -.I Number of lines -Length of the text in lines. -.TP -.I Number of chars -Length of the text in chars. -.TP -.I Number of marks -Count of existing marks on this text. -.TP -.I Header list -An array containing info about -.IR recipients , -.I comments -.IR to -pointers -etc. Every element is a -.IR Misc_info . -.SS Membership -The membership type tells us about conferences we are member of and -how much we have already read of it. It is saved in this way: -.TP -.I Last time read -Updated when we mark a text as read in this conference. -.TP -.I Conference number -The number telling what conf. -.TP -.I Priority -Used by the client to determine reading order. -.TP -.I Last text read -Local number of the last text we have read. This is used to keep track -of which texts we have not yet read and calculate how many unread we -have in this conference. -.TP -.I Read texts -An array containing the texts that we have read after the -.I Last text -.IR read . -This is necessary because its possible to read in any order. -.SH FILES -.TP 20 -.IB database-directory /db/ramkomd-data -File with all the elements and pointers. -.TP -.IB database-directory /db/ramkomd-texts -File with the texts. -.TP -.IB database-directory /etc/pid -File with the pid of the lyskom-process. -.TP -.IB database-directory /db/ramkomd-backup -Backup file with all data. -.SH "SEE ALSO" -.BR ramkomd (8), -.BR dbck (8) -.SH BUGS -This is really a joke. Its not a database, not optimal in any way. But -it works. -.PP -The -.I message of the day -text number is not saved anywhere. This makes the -server forget what text that is when restarting. -.SH NOTES -This will soon disapear and be replaced by something more bazaarly -inexplicable. diff --git a/doc/man/man8/ramkomd.8 b/doc/man/man8/ramkomd.8 deleted file mode 100644 index 3f0646cdc..000000000 --- a/doc/man/man8/ramkomd.8 +++ /dev/null @@ -1,118 +0,0 @@ -.\" $Id: ramkomd.8,v 1.4 1991/09/15 09:54:39 linus Exp $ -.\" Copyright (C) 1991 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. -.\" -.\" $Id: ramkomd.8,v 1.4 1991/09/15 09:54:39 linus Exp $ -.\" $Date: 1991/09/15 09:54:39 $ -.TH ramkomd 8 "August 22, 1991" -.SH NAME -ramkomd - LysKOM server -.SH SYNOPSIS -.B /usr/lyskom/bin/ramkomd -[ -.B -d -] [ -.B -q -] [ -.BI -D database-directory -] [ -.BI -p clientportnumber -] [ -.BI -P muxportnumber -] [ -.B -a -] -.SH DESCRIPTION -This program runs a LysKOM server. -.PP -It listens for connections on the given portnumbers (defaults are 4894 -for the -.I clientportnumber -and 4787 for the -.IR muxportnumber ). -.SH OPTIONS -.TP -.B \-d -Adds one to the debug-level i.e. increases the amount of output on the -stderr from the process. - -Using one -.B \-d -make the process print a -.I > -for every timeout, a message for every person that is connecting or -disconnecting and a message for every succesful or unsuccessful -communication to the process. -.TP -.B \-q -Never save the database. -.TP -.BI \-D database-directory -Use the database in the -.I database-directory. -.br -Example: If your database is in -.B $HOME/lyskom/db -you should use the option -.B \-D$HOME/lyskom -.TP -.BI \-p clientportnumber -listens for clients on the port number -.I clientportnumber. -.TP -.BI \-P muxportnumber -listens for mux connections on the port number -.I muxportnumber. -A mux connection is a connection using a special protocoll to allow -several sessions within one connection. -.TP -.B \-a -Do not send any non-requested messages. This disables the sending of -messages about events in the server to all connections. -.SH FILES -.TP 20 -.B /usr/lyskom -Default database directory. -.TP -.IB database-directory /db/ramkomd-data -File with all the elements and pointers. -.TP -.IB database-directory /db/ramkomd-texts -File with the texts. -.TP -.IB database-directory /etc/pid -File with the pid of the lyskom-process. -.TP -.IB database-directory /db/ramkomd-backup -Backup file with all data. -.SH BUGS -Small memory leak. -.PP -There is no practical handling of security. -.PP -The choice of asynchronously issued messages is not very good. -.PP -The so called "data base" is a joke. -.SH AUTHOR -Per Cederqvist <ceder@lysator.liu.se> -.SH NOTE -Version 2.0 on its way. diff --git a/doc/prot-A.bnf b/doc/prot-A.bnf deleted file mode 100644 index 7f025bca7..000000000 --- a/doc/prot-A.bnf +++ /dev/null @@ -1,1067 +0,0 @@ - - LysKOM-Projektet - -------------------------------- - Specifikation av protokoll A mellan klient och server - -------------------------------- - av Lars Aronsson - <Aronsson@Lysator.LiU.SE> - 25 juni 1991 - - - - LysKOM - -LysKOM {r ett datakonferenssystem. Andra liknande system {r QZ-KOM och -PortaCOM. LysKOM {r Copyright (C) 1990 datorf|reningen Lysator vid -Universitetet och Tekniska H|gskolan i Link|ping. Var och en till}ts -fritt kopiera, {ndra och distribuera LysKOM dokument och program, -givet att mottagarna ges samma r{ttigheter. Varken Lysator eller dess -medlemmar tar n}got som helst ansvar f|r dokumentens eller programmens -riktighet eller f|ljderna av deras anv{ndande. - - - Den h{r texten - -Den h{r texten specificerar version A av det protokoll som anv{nds -mellan en klient (anv{ndarens program) och en server (databasen). Den -h{r texten {r t{nkt att inneh}lla allt du beh|ver veta f|r att skriva -en klient utan att veta n}got om servern, eller tv{rtom. - -Mitt syfte {r att den h{r texten skall vara s} fullst{ndig och korrekt -som m|jligt. Om du hittar n}gra fel, eller kommer p} n}got som saknas, -s} h|r g{rna av dig till mig. F|ljande {r de saker som jag vet saknas -i den h{r texten: - - Vad som lagras i en anv{ndares "user-area", och hur. - - - Filer - -Den h{r filen {r en mer systematisk sammanst{llning av nedan -uppr{knade filer. Det {r m|jligt att filerna har {ndrat namn, antal -och utseende n{r du l{ser detta. S} h{r hette de den 3 juni 1991: - - 2kom/doc/com-spec -- borta! - 2kom/doc/security-levels.txt - 2kom/include/kom-types.h - 2kom/include/kom-errno.h - 2kom/isc-client/com.h - 2kom/server/fncdef.txt -- borta? - 2kom/include/services.h - - - Underliggande protokoll - -LysKOM Protokoll A kan k|ras ovanp} vilken tillf|rlitlig dubbelriktad -8-bitars bytekanal som helst. I n|dfall kan det ocks} k|ras p} en -7-bitars bytekanal. Idag k|rs det ovanp} Telnet/TCP/IP. P} Lysator -anv{nds telnetport 4894 p} IP-host 130.236.254.12 (laila). Data i -protokoll A sker i ASCII klartext. I hollerithstr{ngar (se nedan) f}r -godtyckliga 8-bitars bytes f|rekomma, men tanken {r att man skall -kunna k|ra protokollet "r}tt" fr}n en textterminal. - - - Abstrakt syntaxnotation - -I den h{r specifikationen har en BNF-liknande grammatik anv{nts f|r -att beskriva protokollets dataelement. Det {r mycket vetenskapligt, -f|r s} g|r de som specar OSI-protokoll. Den h{r grammatiken borde -likna ASN.1 mer {n den g|r, men jag har inte ASN.1-specen h{r. -Dataf{lt har givits namn med liten begynnelsebokstav, datatyper med -stor. Operatorn "::=" definierar (som i BNF) och ":" ger typ (som i -Pascal). Kommentarer inleds med "!" och avslutas med radslut (som i -BLISS). Semikolon anv{nds som i C. De grundl{ggande typerna och deras -notation beskrivs h{rn{st. - - - Grundl{ggande datatyper - -Dataelementen som skickas med protokollet }tskiljs av (godtyckliga -sekvenser av) mellanslag, tab-tecken, line-feed, return, eller NULL. -Undvik att skicka NULL, men var beredd p} att tolka det som ett -mellanslag. - -INTEGER {r icke-negativa heltal som skall rymmas p} 32 bitar. De -skickas som text p} decimal form. - -HOLLERITH {r textstr{ngar. F|rst skickas str{ngens l{ngd som en -INTEGER, sedan bokstaven "H" och d{refter (utan }tskiljande -mellanslag!) texten. Texten f}r inneh}lla vilka byte-v{rden som helst -fr}n 0 till 255. - -BITSTRING skickas som text representerande ett heltal p} bin{r form. -Antal bitar i str{ngen framg}r alltid av sammanhanget. [ven inledande -nollor m}ste skickas. Siffran "1" representerar sant v{rde och "0" -falskt. Bitarna skickas i den ordning de st}r listade i den abstrakta -syntaxen. - - shape-of-world : BITSTRING ( - is-flat; is-round; is-3d; is-2d; ! e.g. "0110" - ) - -ARRAY {r en lista med ett visst antal element. Elementens typ noteras -omedelbart efter ordet ARRAY. F|rst skickas en INTEGER som ger antalet -element, sedan skickas tecknet "{", d{refter alla elementen i f|ljd -och slutligen tecknet "}". Tecknen "{" och "}" fyller egentligen ingen -funktion, men underl{ttar n{r man k|r protokollet "r}tt". Exempel: - - hackers : ARRAY HOLLERITH; - ! e.g. 4 { 8Haronsson 7Hbellman 4Hinge 5Hceder } - -SELECTION {r en INTEGER med efterf|ljande svans. Vilken typ svansen -har beror p} v{rdet av heltalet. F|r vissa v{rden kan svansen vara -tom. V{rdet anges i den abstrakta syntaxen med "nummer=namn". -Exempel: - - phrase : SELECTION ( - 1=hello name:HOLLERITH; ! e.g. "1 4HJohn" - 2=howdy ; ! e.g. "2" - ) - -RPC {r en mycket speciell notation som anv{nds f|r protokoll med -remote procedure calls, dvs fr}gor och svar. Notationen f|r RPC ser ut -som SELECTION, men varje alternativ har tv} svansar: fr}gan och -svaret. Selectornumret skickas bara tillsammans med fr}gan. Exempel: - - phrases : RPC ( - 1=cost inventory:INTEGER; price:INTEGER; - 2=time timezone:INTEGER; hours:INTEGER; - 3=name ; name:HOLLERITH; - ) - ! e.g. "1 23"->"498" "3"->"4HLars" "2 1"->"1430" - -Datastrukturen struct/record markeras i den abstrakta syntaxen bara -med omgivande "(" och ")". Detta inneb{r inte att n}gra extra tecken -skickas i protokollet. - - - Dialog - -En session b|rjar alltid med en uppkoppling, d{r klienten v{ljer -protokoll genom att skicka en - - uppkopplingsbeg{ran : ( "A"; loginnamn : HOLLERITH; ) - -vilken besvaras fr}n servern av en - - uppkopplingsbekr{ftelse : "LysKOM\n" - -D{refter har vi finns bara RPC-protokollet commands. Klienten f}r -skicka flera fr}gor innan den f}tt svar p} det f|rsta. F|r att h}lla -reda p} till vilket anrop ett visst svar h|r, v{ljer klienten ett -referensnummer att medf|lja och samma nummer }terfinns i svaret. Det -{r klientens sak att fritt v{lja och h}lla reda p} referensnumren. - - fr}ga : ( - ref-no : INTEGER; - commands-call; - ) - -som, om allt g}r som det skall, besvaras fr}n servern med - - ok-return : ( - "="; - ref-no : INTEGER; - commands-return; - ) - -eller, om n}got misslyckades, med - - error-return : ( - "%"; - ref-no : INTEGER; - error-no : Error-No; - error-status : INTEGER; - ) - -Det skall inte vara n}got tomrum mellan "=" respektive "%" och ref-no. -Observera att {ven f|r de funktioner d{r f-return {r inneh}llsl|st -svarar servern med "=" eller "%" och ref-number. - - - S{kerhetsniv}er och privilegiebittar - -S{kerhet och privilegier byggs i LysKOM med tv} komponenter: Varje -person har sig ett antal bittar tilldelad (man kan s{ga att personen -tillh|r ett antal grupper) och varje session har dessutom en -s{kerhetsniv} (ett tal). Varje r{ttighet kr{ver en viss bitt och en -viss minsta niv}. De senast aktuella kombinationerna -bitt-niv}-r{ttighet beskrivs i filen 2kom/doc/security-levels.txt, h{r -ges en vackrare tabell: - - Bitt Niv} R{ttighet - ------------------------------------------------------ - wheel Normalt ej tilldelad - 0 Alltid logga in, {ven vid "crowded" - 6 S{tta alla Priv_bits f|r alla personer - 7 S{tta password f|r alla personer - 8 Vara organisat|r (supervisor) f|r allt - 10 Kan l{sa alla texter - ------------------------------------------------------ - admin Normalt ej tilldelad - 1 St{nga av servern - 1 S{tta motd_of_kom - 1 L{sa last_login - 2 L{sa status f|r hemliga m|ten och - personer - 2 L{sa de skyddade delarna av statusen - 2 L{sa hela text_statusen, - {ven vid hemliga mottagare - 3 Byta namn p} alla - 4 Addera/subtrahera medlemmar - 4 Addera/subtrahera mottagare till texter - 5 S{tta superm|te - 5 Radera texter - 6 S{tta administrat|r - ------------------------------------------------------ - statistic Normalt ej tilldelad - 2 L{sa statistikdelarna av Person-structen, - {ven om de {r skyddade. - ------------------------------------------------------ - create_conf Normalt tilldelad - 0 Skapa m|ten - ------------------------------------------------------ - create_pers Normalt tilldelad - 0 Skapa personer - ------------------------------------------------------ - -Enligt Thomas Bellmans erfarenheter anv{nder en administrat|r i -praktiskt arbete bara niv}erna 0 och 255. I st{llet f|r -s{kerhetsniv}er borde de enskilda privilegiebittarna sl}s p} och av -individuellt. Detta kanske l|ses elegantare i kommande versioner av -protokollet. - - - Felkoder - -De felkoder som f|rekommer som svar p} RPC-anrop {r nedanst}ende. H{r -{r de f|rklarade i nummerordning. Det finns en kort lista i alfabetisk -ordning strax efter}t. - - Error-No : SELECTION ( - 0=no-error; ! No error has occured - 2=not-impl; ! Not implemented yet - 3=obsolete; ! No longer implemented - 4=pwd; ! Wrong or illegal password - 5=long-str; ! String too long - 6=login; ! Not logged in. - 7=login-disallowed; ! System is in 'singel-user mode' - 8=conf-zero; ! Attempt to use conference number 0. - 9=undef-conf; ! Undefined or secret conference - 10=undef-pers; ! Undefined or secret person - 11=access; ! No 'read/write permission' - 12=perm; ! No permission - 13=not-member; ! Not member in conf - 14=no-such-text; ! No such global text-no, or no access - 15=text-zero; ! Can't use text no 0 - 16=no-such-local-text;! No such local text-no - 17=local-text-zero; ! Can't use local text no 0 - 18=bad-name; ! Too short or too long - ! or contains illegal chars - 19=index-out-of-range; - 20=conf-exists; ! Already exists - 21=pers-exists; ! Already exists - 22=secret-public; ! Cannot be secret and !rd-prot - 23=letter-box; ! Cannot change letter-box flag - 24=ldb-err; ! Should never happen, - ! unless Willf|r makes a mistake. - 25=ill-misc; ! Illegal misc field. - ! err-stat holds field no - 26=illegal-info-type; ! Info-type parameter was illegal. - ! This means that there is a - ! bug in the client. - 27=already-recipient; ! Already recipient to this text. - 28=already-comment; ! Already comment to this text. - 29=already-footnote; ! Already footnote to this text. - 30=not-recipient; ! Not recipient - 31=not-comment; ! Not comment to this text. - 32=not-footnote; ! Not footnote to this text. - 33=recipient-limit; ! Too many recipients - 34=comm-limit; ! Too many comments - 35=foot-limit; ! Too many footnotes - 36=mark-limit; ! Too many marks. - 37=not-author; ! Only the author may add footnotes or - ! delete texts. - 38=no-connect; ! Can't connect to specified server - 39=out-of-memory; ! Couldn't get memory for result - 40=server-is-crazy; ! Client can't understand server - 41=client-is-crazy; ! Client thinks that server says it - ! can't understand client. - 42=undef-session; ! This session doesn't exist - ) - - - Nummer Felmeddelande Nummer Felmeddelande - ------------------------------------------------------ - 11 access 28 already-comment - 29 already-footnote 27 already-recipient - 18 bad-name 41 client-is-crazy - 34 comm-limit 20 conf-exists - 8 conf-zero 35 foot-limit - 25 ill-misc 26 illegal-info-type - 19 index-out-of-range 24 ldb-err - 23 letter-box 17 local-text-zero - 6 login 7 login-disallowed - 5 long-str 36 mark-limit - 38 no-connect 0 no-error - 16 no-such-local-text 14 no-such-text - 37 not-author 31 not-comment - 32 not-footnote 2 not-impl - 13 not-member 30 not-recipient - 3 obsolete 39 out-of-memory - 12 perm 21 pers-exists - 4 pwd 33 recipient-limit - 22 secret-public 40 server-is-crazy - 15 text-zero 9 undef-conf - 10 undef-pers 42 undef-session - ------------------------------------------------------ - - - Asynkrona anrop - -N{r som helst kan servern skicka ut ett asynkront anrop. En klient -beh|ver inte bry sig om dem. Det g}r bra att l{sa undan dem n{r ett -svar skall l{sas. Asynkrona meddelanden b|rjar alltid med ":" och ett -heltal som talar om hur m}nga parametrar som kommer. D{refter kommer -en selector och parametrarna. Precis som f|r ok- och error-return {r -d{r inget tomrum mellan ":" och f|rsta heltalet. I f|rklaringen nedan -listas de asynkrona anropen i nummerordning, men en alfabetiskt -sorterad lista f|ljer strax d{rp}. - - -asynk-meddelande ::= ( - ":"; - antal-params:INTEGER; - meddelande : SELECTION ( - 0=new-text ( text-no : Text-No; - text-stat : Text-stat ) - ! En ny text har skapats. - - 1=logout person : Pers-No; - ! G}r {ven under namnet "i-am-off" (i C-koden). - ! K{llkoden f|r Elispklienten g|r g{llande att - ! asynkrona anropet nummer 1 {r taget ur bruk. - ! Det {r ersatt av anrop 13 som anger sessionsnummer. - - 2=who-info ( person : Pers-No; - conference : Conf-No; - what-am-i-doing : HOLLERITH; ) - ! K{llkoden f|r Elispklienten g|r g{llande att - ! asynkrona anropet nummer 2 heter login, men att - ! det hur som helst {r taget ur bruk och ersatt av - ! asynkrona anropet nummer 9. - - 3=conf-deleted ! Anv ej av Elispklienten - ??? - 4=conf-created ! Anv ej av Elispklienten - ??? - 5=conf-changed-name - ( conf-no : Conf-No; - old-name : HOLLERITH; - new-name : HOLLERITH; ) - ! G}r {ven under namnet "new-name" (i C-koden). - - 6=i-am-on info : Who-Info; - 7=database-is-syncing - ; - 8=forced-leave-conf ! Anv ej av Elispklienten - ??? - 9=login ( pers-no : Pers-No; - session-no : Session-No; ) - - 10=broadcast-message - ( sender : Pers-No; - message : HOLLERITH; ) - ! Det vore estetiskt f|rdelaktigt om servern aldrig skickade - ! asynkrona anropet nummer 10 utan h|ll sig till nummer 12. - - 11=crowded ; - ! Asynkrona anropet nummer 11 betyder att n}gon har - ! misslyckats logga in, eftersom servern inte har fler - ! lediga f|rbindelser. Den ansvarsk{nnande anv{ndaren - ! kan nu v{lja att logga ut f|r att bereda plats. - - 12=directed-message - ( recipient : Pers-No; - sender : Pers-No; - message : HOLLERITH; ) - ! Om argumentet recipient {r noll (0) i asynkrona anropet - ! nummer 12, s} {r meddelandet riktat till alla inloggade. - ! Det {r {nnu inte m|jligt att rikta ett meddelande till - ! en viss session. - - 13=new-logout - ( pers-no : Pers-No; - session-no : Session-No; ) - ) -) - -En asterisk (*) efter numret i tabellen nedan anger att det asynkrona -anropet ersatts av n}got annat. Se ovan under respektive anrop f|r -n{rmare beskrivning. - - Nr Asynkront anrop Nr Asynkront anrop - ------------------------------------------------------ - 10 broadcast-message 5 conf-changed-name - 4 conf-created 3 conf-deleted - 11 crowded 7 database-is-syncing - 12 directed-message 8 forced-leave-conf - 6 i-am-on 9 login - 1* logout 13 new-logout - 0 new-text 2* who-info - ------------------------------------------------------ - - - RPC-anrop - -Klienten skickar RPC-anrop med parametrar till servern. Servern svarar -endera med ett felmeddelande (se ovan i avsnitten Dialog och Felkoder) -eller med ett returv{rde. Nedan ges BNF-grammatiken f|r de datatyper -som anv{nds i parametrar och returv{rden. RPC-anropen listas i -alfabetisk ordning, men en numeriskt sorterad lista f|ljer strax -efter}t. - - -commands : RPC ( - ! Anropsnummer och -namn - ! Datayp f|r anropsparameter - ! Datatyp f|r returv{rde - - 32=add-comment - params : ( comment : Text-No; - comment-to : Text-No; ) - ; - - - 37=add-footnote - params : ( footnote : Text-No; - footnote-to : Text-No; ) - ; - - 14=add-member - params : ( conf-no : Conf-No; - pers-no : Pers-No; - priority : INTEGER; - where : INTEGER; ) - ; - ! Addera angiven person som medlem i angivet m|te - ! Priority {r prioriteten p} l{slistan - ! Where {r placering p} listan, 0 (noll) eller st|rre - ! RPC-anropet nummer 14 anv{nds {ven senare f|r att {ndra - ! prioritet och plats p} listan. - - 30=add-recipient - ! The sequence "conf-no, type" is a reversed Misc-Info. - ! Type is recpt or cc_recpt. - add-recipient-params : ( text-no : Text-No; - conf-no : Conf-No; - type : INTEGER; ) - ; - - 45=broadcast - message : HOLLERITH; - ; - ! Ett privilegierat anrop. - ! Samma effekt kan n}s genom magisk parameter till anrop 53. - ! En gammal felaktig kommentar g|r g{llande att parametern - ! skulle vara ett text-no, men s} {r inte fallet. - - 3=change-name - change-name-params : ( conf-no : Conf-No; - new-name : HOLLERITH; ) - ; - ! Anropet nummer 3 byter namn p} angivet m|te eller person. - - 4=change-what-i-am-doing - what-am-i-doing : HOLLERITH; - ; - ! Den medskickade texten kommer att visas i vilka-listan, - ! se {ven anropet nummer 51. - - 10=create-conf - params : ( name : HOLLERITH; - type : Conf-Type; ) - result : Conf-No; - - 5=create-person - create-person-params : ( name : HOLLERITH; - passwd : HOLLERITH; ) - Pers-No; - ! En ny person skapas med angivet namn och l|senord. - ! Den skapade personens personnummer returneras. - - 28=create-text - ! create-text-return returns text number zero on error - ! NB! Only Misc-Infos 0,1,2,4 can be sent here. - params : ( text : HOLLERITH; - misc-info : ARRAY Misc-Info ) - result : Text-No; - - 11=delete-conf - conf : Conf-No; - ; - ! Utpl}na ett m|te eller en person. - - 29=delete-text - Text-No; - ; - - 55=disconnect - session-no : Session-No; - ; - ! Disconnect a session. You can disconnect your own session - ! (even if you are not logged in) and any session where you - ! are supervisor of the user that is logged in on that - ! session. - - 42=enable - ena-level : INTEGER; - ; - ! This is a privileged call. - ! Set ena-level. Zero means don't use any privileges. - - 50=get-conf-stat - conf-no : Conf-No; - result : Conference; - ! Returnera m|tesstatus f|r angivet m|te - - 13=get-conf-stat-old - params : ( conf-no : Conf-No; - mask : INTEGER; ) - result : Conference - ! Eftersom den mask som ing}r i params f|ga beaktas, - ! har anropet nummer 13 ersatts av anropet 50. - ! M|tesstatusen f|r det angivna m|tet returneras. - ! Om masken {r ett j{mnt tal, s} skickas ett tomt f{lt (0H) - ! name i svaret. Fr}n b|rjan var det t{nkt: - ! mask = name + members + texts + list-sizes -- just use 255 - - 47=get-created-texts - params : ( person : Pers-No; - first : Local-Text-No; - no-of-texts : INTEGER; ) - created-texts : Text-List; - ! NB! first is a text number local to the person who wrote it. - ! It is not a Local-Text-No in his mailbox. - - 34=get-map - params : ( conf-no : Conf-No; - first-local-no : Local-Text-No; - no-of-texts : INTEGER; ) - result : Text-List; - - 23=get-marks - ; - Mark-List; - - 48=get-members - params : ( conf : Conf-No; - first : INTEGER; - no-of-members : INTEGER; ) - members : Member-List; - ! first should perhaps be Local-Conf-No... - - 46=get-membership - params : ( person : Pers-No; - first : INTEGER; - no-of-confs : INTEGER; - mask : BITSTRING (want-read-texts); ) - memberships : Membership-List; - ! first should perhaps be Local-Conf-No... - - 49=get-person-stat - person : Pers-No; - result : Person; - ! Personstatusen f|r den angivna personen returneras. - - 6=get-person-stat-old - params : ( person : Pers-No; - mask : INTEGER; ) - result : Person; - ! Eftersom den mask som ing}r i params f|ga beaktas, - ! har anropet nummer 6 ersatts av anropet 49. - ! Personstatusen f|r den angivna personen returneras. - ! Om masken {r ett j{mnt tal, s} skickas ett tomt f{lt (0H) - ! username i svaret. - - 36=get-server-info - ; - result : Info; - ! Return various information about the server. - ! Anrop 36 hette tidigare get-info med samma semantik. - - 54=get-session-info - session-no : Session-No; - result : Session-Info; - - 25=get-text - params : ( text : Text-No; - start-char : INTEGER; - end-char : INTEGER; ) - result : HOLLERITH; - - 26=get-text-stat - params : Text-No; - result : Text-Stat; - - 35=get-time - ; - Time; - - 52=get-unread-confs - pers-no : Pers-No; - conf-no-list : ARRAY Conf-No; - - 0=login - login-params : ( person : Pers-No; - passwd : HOLLERITH; ) - ; - - 1=logout - ; - ; - ! Anropet nummer 1 misslyckas aldrig. - - 12=lookup-name - name : HOLLERITH; - result : Conf-List-Old; - ! Expandera ett f|rkortat namn och returnera en lista - ! med nummer p} de m|ten och personer som det kan vara. - ! Se kommentaren vid definitionen av Conf-List. - - 27=mark-as-read - params : ( conference : Conf-No; - texts : ARRAY Local-Text-No; ) - ; - - 24=mark-text - params : ( text : Text-No; - mark-type : INTEGER; ) - ! mark-type = permanently-marked -- just use 255 (?) - ! The server only stores (does not act upon) this value. - ; - - 2=pepsi - Conf-No; - ; - ! Anropet nummer 2 anv{nds f|r att g} till det angivna m|tet. - ! Det engelska namnet {r change conference. - ! Namnet "Pepsi" h|r till avdelningen mer krystade vitsar. - - 9=query-read-texts - params : ( pers-no : Pers-No; - conf-no : Conf-No; ) - result : Membership; - ! Man kan fr}ga efter ol{sta utan att logga in. - - 53=send-message - params : ( recipient : Pers-No; - message : HOLLERITH; ) - ; - ! Ett privilegierat anrop. - ! Om mottagaren {r nummer noll, skickas meddlandet till - ! samtliga inloggade personer. Detta kan ers{tta anrop 45. - - 17=set-conf-motd - params : ( conf-no : Conf-No; - text-no : Text-No; ) - ; - ! S{tt lappen text-no p} d|rren till conf-no. - ! Set-presentation och set-etc-motd trollar dessutom - ! med f{ltet no-of-marks i textstatusen f|r den gamla - ! och den nya presentationstexten. - ! Anrop 17 hette f|rr set-etc-motd med samma semantik. - - 21=set-conf-type - params : ( conf-no : Conf-No; - type : Conf-Type ) - ; - ! M|tet conf-no {r av typen type. - - 22=set-garb-nice - params : ( conf-no : Conf-No; - nice : Garb-Nice; ) - ; - ! Inl{gg i m|tet conf-no sparas i nice dagar innan de raderas. - - 41=set-motd-of-lyskom - motd : Text-No; - ; - ! This is a privileged call. - ! The text indicated by the parameter is set to be the message - ! of the day of LysKOM. - - 8=set-passwd - params : ( person : Pers-No; - old-pwd : HOLLERITH; - new-pwd : HOLLERITH; ) - ; - ! Ge personen ett nytt l|senord. Old-pwd {r det (gamla) - ! l|senordet f|r personen som g|r RPC-anropet (inte - ! n|dv{ndigt samma som anges av f|rsta argumentet). - - 19=set-permitted-submitters - params : ( conf-no : Conf-No; - perm-sub : Conf-No; ) - ; - ! M|tet conf-no {r skrivskyddat. - ! Endast medlemmar i perm-sub f}r skriva inl{gg i conf-no. - ! Om perm-sub {r 0 (noll) (???) {r m|tet inte skrivskyddat. - - 16=set-presentation - params : ( conf-no : Conf-No; - text-no : Text-No; ) - ; - ! [ndra presentationen f|r angivet m|te eller person. - ! Ange text-no 0 (noll) f|r att ta bort presentationen. - ! Set-presentation och set-etc-motd trollar dessutom - ! med f{ltet no-of-marks i textstatusen f|r den gamla - ! och den nya presentationstexten. - - 7=set-priv-bits - params : ( person : Pers-No; - privileges : Priv-Bits ) - ; - ! Ge eller ta n}gra bittar f|r den angivna personen. - - 20=set-super-conf - params : ( conf-no : Conf-No; - super-conf : Conf-No; ) - ; - ! G|r super-conf till superm|te (organisat|r?) f|r m|tet - ! conf-no. Om conf-no {r skrivskyddat, s} skickas eventuella - ! brev vidare till superm|tet. - - 18=set-supervisor - params : ( conf-no : Conf-No; - admin : Conf-No; ) - ; - ! G|r alla medlemmar i m|tet admin till administrat|rer (???) - ! f|r m|tet conf-no. Admin {r typiskt en persons brevl}da. - - 40=set-unread - params : ( conference : Conf-No; - no-of-unread : INTEGER; ) - ; - ! Endast l{sa no-of-unread senaste i angivet m|te. - - 57=set-user-area - params : ( pers-no : Pers-No; - user-area : Text-No; ) - ; - ! Angiven text anv{nds f|r att lagra angiven persons - ! variabler. Hur detta g}r till borde kanske behandlas - ! i ett separat kapitel. - - 44=shutdown - exit-val : INTEGER; - ; - ! This is a privileged call. - ! Shutdown server. - ! An old comment says exit-val is not used by the server. - ! Samma effekt n}s genom kill -HUP mot servern. - - 33=sub-comment - params : ( comment : Text-No; - comment-to : Text-No; ) - ; - - 38=sub-footnote - params : ( footnote : Text-No; - footnote-to : Text-No; ) - ; - - 15=sub-member - params : ( conf-no : Conf-No; - pers-no : Pers-No; ) - ; - ! Subtrahera angiven person som medlem i angivet m|te. - - 31=sub-recipient - params : ( text-no : Text-No; - conf-no : Conf-No; ) - ; - - - 43=sync - ; - ; - ! Make LysKOM sync its files. This is a privileged call. - ! Samma effekt n}s med kill -SIGUSR1 mot servern. - - 56=who-am-i - ; - sesson-no : Session-No; - - 39=who-is-on-old - ; - result : Who-Info-List-Old; - ! Anrop nummer 39 {r ersatt av anrop 51, vars svar ger - ! mer information. - - 51=who-is-on - ; - result : Who-Info-List; - ! Svaret {r en lista med information om nu aktiva sessioner. -) - -De anrop vars nummer i listan nedan f|ljs av en asterisk (*) {r -ersatta av modernare verianter i den nuvarande versionen (0.33) av -Elisp-klienten. - - Nummer RPC-Anrop Nummer RPC-Anrop - ------------------------------------------------------ - 0 login 1 logout - 2 pepsi 3 change-name - 4 change-what-i-am-doing - 5 create-person 6* get-person-stat-old - 7 set-priv-bits 8 set-passwd - 9 query-read-texts 10 create-conf - 11 delete-conf 12 lookup-name - 13* get-conf-stat-old 14 add-member - 15 sub-member 16 set-presentation - 17 set-conf-motd 18 set-supervisor - 19 set-permitted-submitters - 20 set-super-conf 21 set-conf-type - 22 set-garb-nice 23 get-marks - 24 mark-text 25 get-text - 26 get-text-stat 27 mark-as-read - 28 create-text 29 delete-text - 30 add-recipient 31 sub-recipient - 32 add-comment 33 sub-comment - 34 get-map 35 get-time - 36 get-server-info 37 add-footnote - 38 sub-footnote 39* who-is-on-old - 40 set-unread 41 set-motd-of-lyskom - 42 enable 43 sync - 44 shutdown 45* broadcast - 46 get-membership 47 get-created-texts - 48 get-members 49 get-person-stat - 50 get-conf-stat 51 who-is-on - 52 get-unread-confs 53 send-message - 54 get-session-info 55 disconnect - 56 who-am-i 57 set-user-area - ------------------------------------------------------ - - - Konstruerade datatyper - -H{r definieras de datatyper som sedan anv{nds i RPC-anrop fr}n -klienten till servern och i asynkrona anrop fr}n servern till -klienten. Datatyperna listas i bokstavsordning. - - -! Pers-no and Conf-no are u_shorts in the same domain. -Conf-No ::= INTEGER; -Conf-No-List ::= ARRAY Conf-No; ! Anv{nds var? - -Conf-List ::= ARRAY ( conference : Conf-No; - type : Conf-Type; ) - -! Som svar p} anrop 12 ges Conf-List-Old, som inte kan formuleras -! med den h{r BNF-grammatiken. Conf-List borde returneras, men d} -! vore inte LysKOM bak}tkompatibelt. -! Conf-List-Old: "3 { 3 45 62 } { 1001 0000 1001 }" -! Conf-List: "3 { 3 1001 45 0000 62 1001 }" - -Conf-Type ::= BITSTRING ( - rd_prot; ! Can anyone become a member? - original; ! Comments forbidden? - secret; ! Secret mailboxes cannot easily login by name - letterbox; ! Mailbox -) - -Conference ::= ( - name : HOLLERITH; - type : Conf-Type; - creation-time : Time; - last-written : Time; - creator : Pers-No; - presentation : Text-No; - supervisor : Conf-No; - permitted-submitters : Conf-No; ! Zero means anybody - super-conf : Conf-No; ! Zero means author - msg-of-day : Text-No; ! Every conf has one - nice : Garb-Nice; - no-of-members : INTEGER; - first-local-no : Local-Text-No; ! Oldest text still stored - no-of-texts : INTEGER; ! How many texts stored -) - -Garb-Nice ::= INTEGER; ! Number of days - -Info ::= ( - version : INTEGER; - conf-pres-conf : Conf-No; ! M|tet Pres (nya) m|ten - pers-pres-conf : Conf-No; ! M|tet Pres (nya) medlemmar - motd-conf : Conf-No; ! M|tet Lappar p} d|rren - kom-news-conf : Conf-No; ! M|tet Nyheter om LysKOM - motd-of-lyskom : Text-No; ! Visas vid login -) - -! kom-types.h defines Info-Datum as the tail in Misc-Info -! kom-types.h defines Info-Type as the selector in Misc-Info - -Local-Text-No ::= INTEGER; - -Mark ::= ( text-no : Text-No; type : INTEGER ) - ! Servern ger sig inte p} att tolka markeringstypen, - ! det {r helt upp till klienten. - -Mark-List ::= ARRAY Mark; - - -Member ::= Pers-No; -Member-List ::= ARRAY Member; -Membership ::= ( - last-time-read : Time; - conference : Conf-No; - priority : INTEGER; - last-text-read : Local-Text-No; - read-texts : ARRAY Local-Text-No; -) - -Membership-List ::= ARRAY Membership; - -Misc-Info ::= SELECTION ( - 0=recpt recipient : Conf-No; ! Mottagare - 1=cc-recpt cc-recipient : Conf-No; ! Extra kopia - 2=comm-to comment-to : Text-No; ! Kommentar till - 3=comm-in commented-in: Text-No; ! Kommentar i - 4=footn-to footnote-to : Text-No; ! Fotnot till - 5=footn-in footnoted-in : Text-No; ! Fotnot i - 6=loc-no local-no : Local-Text-No ! Lokalt textnummer - 7=rec-time received-at : Time; ! Mottaget tid - 8=sent-by sender : Pers-No; ! S{nt av - 9=sent-at sent-at : Time; ! S{nt n{r -! 10=...-recpt ??? ! F|r k{nnedom -) - -Pers-List ::= ARRAY Pers-No; - -Pers-No ::= Conf-no; - -Person ::= ( - username : HOLLERITH; ! E-mail adress - privileges : Priv-Bits; - flags : Personal-Flags; - last-login : Time; ! Eller logout? - user-area : Text-No; - total-time-present : INTEGER; ! I sekunder - sessions : INTEGER; - created-lines : INTEGER; - created-bytes : INTEGER; - read-texts : INTEGER; - no-of-text-fetches : INTEGER; - created-persons : INTEGER; - created-confs : INTEGER; - first-created-local-no : INTEGER; ! Well, local isn't really true but... - no-of-created-texts : INTEGER; ! Numbers of texts in the ARRAY, - ! i.e. not erased ones. - no-of-marks : INTEGER; - no-of-confs : INTEGER; -) ! /mo - -Personal-Flags ::= BITSTRING ( - unread-is-secret; - ! V{rdet 1 betyder att antalet ol{sta texter h}lls hemligt - flg2; flg3; flg4; flg5; flg6; flg7; flg8; -) - -! Se avsnittet ovan om s{kerhetsniv}er och privilegiebittar. -Priv-Bits ::= BITSTRING ( - wheel; admin; statistic; create_pers; create_conf; change_name; - flg7; flg8; flg9; flg10; flg11; flg12; flg13; flg14; flg15; flg16; -) - -! Session-Info {r v{ldigt likt Who-Info. -Session-Info ::= ( - person : Pers-No; - working-conference : Conf-No; - session : Session-No; - what-am-i-doing : HOLLERITH; - username : HOLLERITH; ! user@host - idle-time : INTEGER; ! Sekunder sedan senaste anrop - connection-time : Time; ! Tid och datum f|r uppkoppling - ! Detta {r ej detsamma som login-tid -) - -! Session numbers are unique to each session. A person can have -! more than one session running at the same time. Session numbers -! are assigned starting from 1 up. Session numbers are not reused -! during the lifetime of the server. See Who-Info-List -Session-No ::= INTEGER; - -Text-List ::= ( first-local-no : Local-Text-No; - texts : ARRAY Text-No; ) - -! Text-No is a u_long. -Text-No ::= INTEGER; - -Text-Stat ::= ( - creation-time : Time; - author : Pers-No; - no-of-lines : INTEGER; - no-of-chars : String-Size; - no-of-marks : INTEGER; - misc-info : ARRAY Misc-Info; -) - -! UNIX <time.h> struct tm. No time zone. -Time ::= ( - seconds : INTEGER; ! 0 ... 59 - minutes : INTEGER; ! 0 ... 59 - hours : INTEGER; ! 0 ... 23 - mday : INTEGER; ! 1 ... 31 - month : INTEGER; ! jan = 0 ... dec = 11 - year : INTEGER; ! Sedan 1900 - weekday : INTEGER; ! s|n = 0 ... SAT = 6 - yearday : INTEGER; ! 0 ... 365 - isdst : INTEGER; ! positivt = sommartid, 0 = normaltid -) - -Who-Info-Old ::= ( - person : Pers-No; - what-am-i-doing : HOLLERITH; - working-conference : Conf-No; -) -Who-Info-List-Old ::= ARRAY Who-Info-Old; - -Who-Info ::= ( - person : Pers-No; - working-conference : Conf-No; - session : Session-No; - what-am-i-doing : HOLLERITH; - username : HOLLERITH; ! user@hostname -) - -Who-Info-List ::= ARRAY Who-Info; - - - - Exempel - -Nedan ett exempel fr}n en verklig LysKOM-session. Kommentarer har jag -gett med "!" som i grammatiken. Exemplet {r gammalt och inneh}ller en -del detaljer som senare tagits ur bruk, men det ger {nd} en ide om hur -det r}a protokollet ser ut. - - $ telnet laila 4894 - Trying 130.236.254.12 ... - Connected to laila.lysator.liu.se. - Escape character is '^]'. - A8Haronsson ! Jag k|r protokoll A - LysKOM ! LysKOM svarar - 1 12 13HLars Aronsson ! lookup-name - =1 2 { 8 38 } { 1001 1001 } ! Person 8 eller Person 38 - :3 2 21 7 0H ! Person 21 gick till m|te 7 - :1 1 56 ! Person 56 loggade just ut - 2 0 8 8H******** ! login Person 8 med password - :3 2 8 0 0H ! Person 8 loggade just in - =2 ! login OK - 3 10 23HAntikommunistiskt Forum 0000 - ! Jag skapar ett |ppet m|te - =3 57 ! OK, m|te 57 skapat - 4 1 ! Jag loggar ut - :1 1 8 ! Person 8 loggade just ut - =4 ! logout OK diff --git a/doc/prot-A.slightly-obsolete b/doc/prot-A.slightly-obsolete deleted file mode 100644 index 7664414be..000000000 --- a/doc/prot-A.slightly-obsolete +++ /dev/null @@ -1,230 +0,0 @@ - - - LysKOM-Projektet - -------------------------------- - Beskrivning av server-klient-protokollet, - version A, i LysKOM - -------------------------------- - av Lars Aronsson - <aronsson@lysator.liu.se> - datum ok{nt - - - -Kommunikationen till servern sker i klartext. P} s} vis {r det m|jligt -att provk|ra utan att ha en klient ig}ng. Avlusningen blev ocks} -enklare. - - -UPPKOPPLING - -Vid uppkoppling s{nder klienten ett 'A' f|ljt av login-identiteten f|r -anv{ndaren (en str{ng, se nedan). Servern svarar med att skicka -"LysKOM\n". Sedan {r uppkopplingen gjord. - -FUNKTIONSANROP - -Vid ett funktionsanrop skickas f|ljande data fr}n klienten till -servern: - - ref-nr funktions-nr parametrar - -ref-nr {r ett heltal (unsigned, max 32 bitar) som klienten kan v{lja -fritt, t ex som ett l|pnummer. - -funktions-nr {r ett heltal som anger vilken funktion man vill anropa. -De definieras i isc/com.h. - -Om anropet lyckades ser svaret ut s} h{r: - - =ref-nr svar - -Om det misslyckas: - - %ref-nr kom_errno err_stat - - - -DATAFORMAT - -Allt som skickas (utom m|jligtvis innuti str{ngar) {r ASCII. Bortsett -fr}n innuti str{ngar skickas inga kontrolltecken. Whitespace anv{nds -f|r att skilja olika f{lt }t. Som whitespace r{knas ' ', \r, \n, \t -och \000. (Ett funktionsanrop beh|ver inte avslutas med \n, det g}r -lika bra med vilken whitespace som helst, men det m}ste finnas en -whitespace - det r{cker inte med att paketet tar slut). - -Alla tal, (t ex int, Pers_no, Conf_no) skickas i decimal form. - -Enumar skickas i decimal form. - -Str{ngar skickas som Hollerith-str{ngar, dvs f|rst ett heltal som -anger l{ngden, sen ett H, sen str{ngen. Innuti en str{ng kan vilka -tecken som helst komma. (0-255). - -Arrayer skickas inom m}svingar. T ex kan en Text_list som ser ut s} -h{r: -typedef struct { - Local_text_no first_local_no, - no_of_texts; - Text_no * texts; -} Text_list; - -skickas s} h{r: - 5 3 { 8 9 11 } - -eller, om texts==NULL: - 5 3 * - -Asterisk anv{nds allts} f|r att markera en tom array. (Till exempel om -man inte fr}gar efter Membership). Asterisk-notationen kan bara -anv{ndas i rikting fr}n servern till klienten. - - -EXEMPEL - -S} h{r kan en k|rning se ut. - -Klienten skickar Servern svarar F|rklaring -================ ============== ========== - -A5Hceder LysKOM\n Uppkoppling. -1 37 =1 100 1 2 3 4 5712 Get_info -69 27 5712 =69 {textstat} Get_text_stat -18 26 5712 =18 {textmassa} Get_text -2 1 334 5HaBcdE %2 3 0 0 0 Login, misslyckas. (KOM_PWD) -3 1 334 5HaBcDe =3 Login, lyckas. -... -9 2 =9 Logout (beh|vs eg. ej) - - -FELHANTERING - -Om servern tar emot text som inte st{mmer med det protokoll som f|r -tillf{llet {r implementerat (f|rhoppningsvis, men ej n|dv{ndigtvis, -det som {r beskrivet h{r) skriver den ut "%% LysKOM protocol error.\n" - -ASYNKRONA MEDDELANDEN - -Servern skickar ibland ut meddelanden som clienterna kanske tycker {r -intressanta. Formatet f|r dessa {r: - - :no_of_tokens function < tokens > - -De b|rjar allts} med ":" i st{llet f|r "=" eller "%". Genom att -antalet token alltid s{nds s} kan {ven gamla klienter "|verleva" en ny -klient med nya asynkrona meddelanden. Det {r bara att hoppa |ver r{tt -antal token. - -Termen "asynkrona meddelanden" {r lite oegentlig. Meddelanden {r -synkroniserade med allt annat som skickas ut fr}n servern. Ett -meddelanden kommer bara n{r ett svar skulle ha kommit. - -DATAFORMAT F\R SAMMANSATTA TYPER - -Person - username str{ng - privileges bitstr{ng - personal_flags bitstr{ng - created_texts: - first_local_no - no_of_texts - texts array - marks: - no_of_marks - marks array - conferences: - no_of_confs - confs: array - conf_no - priority - last_time_read - last_text_read - no_of_read - read_texts array - user_area - last_login - total_time_present - sessions - created_lines - created_bytes - read_texts - no_of_text_fetches - created_persons - created_confs - - - -Conference - - name str{ng - members: - no_of_members - members: array - member (Pers_no) - texts: - first_local_no - no_of_texts - texts array (Text_no) - conf_type bitstr{ng - creator - creation_time - presentation - supervisor - permitted_submitters - super_conf - last_written - msg_of_day - nice - - -Text_stat - - author - creation_time - no_of_lines - no_of_marks - no_of_misc - misc_info: array - type 0 recpt - 1 cc_recpt - 2 comm_to - 3 comm_in - 4 footn_to - 5 footn_in - 6 loc_no - 7 rec_time - 8 sent_by - 9 sent_at - datum - - - -Info - version - conf_pres_conf - pers_pres_conf - motd_conf - kom_news_conf - motd_of_lyskom - -Membership - - no_of_confs - confs: array - conf_no - priority - last_time_read - last_text_read - no_of_read - read_texts array - - -Text_list - first_local_no - no_of_texts - texts array - -str{ng - 12HTolv tecken. - diff --git a/doc/vad-aer-olaest.swe b/doc/vad-aer-olaest.swe deleted file mode 100644 index f56926256..000000000 --- a/doc/vad-aer-olaest.swe +++ /dev/null @@ -1,145 +0,0 @@ -This swedish text describes how the client knows which texts the user -has not yet read. It is extracted from the LysKOM-server that runs -at lysator.liu.se. -------------------------------------------------------------------- - - -102868 1991-09-07 20:40 /132 rader/ ceder (Per Cederqvist Lysator) -Kommentar till text 102846 av Jonas S Karlsson (@Link ping enl CSN) -Mottagare: LysKOM internals <1804> -Markerad av dig och 2 andra. -[rende: Hur man vet vad som {r ol{st. ------------------------------------------------------------- -Varje person har en lista |ver vilka m|ten han {r med i. F|r varje -m|te han {r med i lagras i en struct som vi kallar Membership: - - * m|tesnumret - * prioriteten p} m|tet - * n{r man senast l{ste en text i m|tet (markerade en text i - m|tet som l{st) - * vilka texter man har l{st (lokala m|tesnummer) - Just nu lagras det som - - Local_text_no last_text_read; - u_short no_of_read_texts; - Local_text_no *read_texts; - - vilket inneb{r att man har l{st alla texter fram till och - med last_text_read, och dessutom alla texter som finns i den - dynamiskt allokerade arrayen read_texts (som inneh}ller - no_of_read_texts texter). - -query_read_texts tar som argument en person och ett m|te (som -eventuellt kan vara en brevl}da) och returnerar den personens -Membership f|r just det m|tet. Till protokoll B kommer vi att d|pa om -funktionen till get_membership. - -> 102846 1991-09-07 17:05 /16 rader/ Jonas S Karlsson (@Link ping enl CSN) -> Mottagare: LysKOM internals <1801> -> [rende: Protokollet fr{ga... - -102846 {r ett globalt textnummer. Vi anv{nder typen Text_no f|r att -lagra och hantera s}dana nummer. 1801 {r ett lokalt nummer f|r m|tet -LysKOM internals. S}dana nummer lagras i en Local_text_no. (B}de -Text_no och Local_text_no {r 32 bittar just nu). - -F|r varje m|te finns en relation MAP : Local_text_no -> Text_no. Med -anropet get_map kan man h{mta en tabell med vars hj{lp man kan g|ra den -|vers{ttningen f|r ett visst m|te. - - -get_created_texts ger en lista som inneh}ller de texter som en viss -person har skrivit. - -F|r att ta reda p} vilka m|ten man har ol{sta inl{gg i g|r man s} h{r: - -1) get_unread_confs (ditt personnummer) - -Du f}r en lista med m|tesnummer. LysKOM garanterar att du inte har -n}got ol{st i n}got annat m|te, men det kan h{nda att den ger tillbaks -n}gra m|ten som du i verkligheten inte har n}got ol{st i. - -De m|ten man f}r tillbaks {r de d{r de existerar (eller har existerat) -en text med ett h|gre lokalt textnummer {n last_text_read i ditt -Membership i m|tet i fr}ga. - -2a) G|r query_read_texts f|r alla m|ten i listan du fick i steg 1. - -2b) Samtidigt h{mtar du m|tesstatusen f|r de m|tena (med -get_conf_stat). - -3) Samla ihop alla svaren och sortera dom s} att man f}r l{sa -inl{ggen i r{tt ordning. - -4) Ta det f|rsta m|tet. J{mf|r det h|gsta lokala numret som existerar -(det kan du f} fram ur m|tesstatusen) med last_text_read i ditt -Membership. Om det visar sig att det finns texter du inte har l{st -m}ste du g|ra ett get_map f|r att ta reda p} vilket globalt textnummer -de ol{sta texterna har. - -5) Sl} upp varje lokalt textnummer som du inte har l{st i mappen. Du -f}r ett Text_no. Om du f}r en nolla inneb{r det att den text som hade -det numret har raderats eller subtraherats fr}n m|tet. Ignorera det -lokala numret och tag n{sta. - -6) N{r du f}r ett textnummer som inte {r noll h{mtar du textstatusen -och textmassan (sj{lva texten) med get_text_stat och get_text, och -visar den p} sk{rmen. N{r anv{ndaren har l{st klart texten talar du om -det f|r servern med mark_as_read (som tar ett m|tesnummer och ett -Local_text_no som argument och uppdaterar ditt Membership f|r det -m|tet). Om texten har flera mottagare som du {r medlem i ska du anropa -mark_as_read en g}ng f|r varje mottagare. - -Repetera steg 5 och 6 tills du har l{st ut m|tet. Se till att du -f|ljer kommentartr{det, om anv{ndaren vill det. - -Repetera steg 4 tills allt {r utl{st. - -Visa alla markerade. - -Se tiden. -================================================================= - -S} g}r det till, grovt sett. Saker och ting kompliceras av att det -hela tiden skrivs nya texter. Servern skickar ut ett asynkront -meddelande n{r en ny text skapas (i ett m|te som man {r medlem i). I -meddelandet finns hela textstatusen (s} att man slipper h{mta den). - -En annan grej som g|r det hela komplicerat {r att man g{rna vill att -klienten ska h{mta saker i f|rv{g n{r man inte har n}got annat att -g|ra. Man vill att klienten inte ska h{mta samma information mer {n en -g}ng. Man vill f} upp den f|rsta texten s} snabbt som m|jligt. Man -vill kunna g|ra Lista Nyheter s} snabbt som m|jligt. Det finns m}nga -saker man kan optimera p} olika s{tt. - -Elispklienten g|r inte riktigt som jag har beskrivit det p} alla -st{llen, men resultatet blir i princip det samma. En del av anropen -(t ex get_unread_confs) har vi inf|rt i efterhand f|r att vi m{rkte -att det var n|dv{ndigt f|r att f} saker och ting att g} n}gorlunda -snabbt. - -Vi har medvetet valt att g|ra s} mycket jobb som m|jligt i klienten, -och s} lite jobb som m|jligt i servern. Nu, n{r det blev s} att -klienten {r skriven i elisp, s} skulle vi nog ha f}tt ett snabbare -system (s{rskilt uppstarten) om servern varit mer intelligent och valt -i vilken ordning texter ska visas. Systemet {r designat med m}let att -det inte ska bli l}ngsammare {ven om m}nga klienter kopplar upp sig -samtidigt, och det m}let har vi nog n}tt. (Att det kan g} l}ngsamt n{r -5-6 personer k|r sin elispklient p} lysator.liu.se beror inte p} -svarstiderna fr}n LysKOM-servern, utan p} att emacsarna blir -l}ngsamma. De som k|r fr}n en obelastad maskin samtidigt m{rker inte -att det g}r l}ngsamt (skryt, skryt:-)). (Nej, det finns inga m{tningar -som bekr{ftar det h{r - men jag t{nker m{ta lite responstider senare i -h|st). - -Med en smart klient skriven i c kommer LysKOM att bli snabbt. Om -c-klienterna k|rs p} varsin maskin (var och en har sin egen -arbetsstation) tror jag att systemet kommer att klara "tillr{ckligt" -m}nga anv{ndare. (LysKOM {r ju ett lokalt media. Om hela v{rlden k|rde -p} samma LysKOM-server i st{llet f|r att skriva news skulle det bli -olidligt att l{sa LysKOM {ven om man bortser fr}n responstider...) - -P}peka g{rna eventuella oklarheter i den h{r texten. Jag t{nker skicka -med den bland dokumentationen vi har i serverreleasen som vi snart -g|r, s} jag vill att texten ska vara begriplig... -(102868) ----------------------------------- diff --git a/foo b/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/run-support/.cvsignore b/run-support/.cvsignore deleted file mode 100644 index a12fc1f11..000000000 --- a/run-support/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Topdir.make diff --git a/run-support/updateLysKOM b/run-support/updateLysKOM deleted file mode 100644 index d071a5f74..000000000 --- a/run-support/updateLysKOM +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cd /usr/lyskom/cores -/bin/kill -USR1 `/bin/cat /usr/lyskom/etc/pid` 2>/dev/null >/dev/null || /usr/lyskom/bin/lyskomd >>/usr/lyskom/etc/stdout.log 2>>/usr/lyskom/etc/stderr.log & diff --git a/scripts/import.make b/scripts/import.make deleted file mode 100644 index 06f8c61c3..000000000 --- a/scripts/import.make +++ /dev/null @@ -1,60 +0,0 @@ -# This file is included by all Makefiles in the LysKOM hierarchy. -# It gives default values for all variables that is normally used. -# TOPDIR and SCRIPTDIR must be set before this file is included. -# If any of the variables are defined in the environment, that value -# will override the value that is set here. -# -# ceder is guilty. -# - -SHELL=/bin/sh -AWK = gawk -SED = /usr/bin/sed -CC = gcc -ansi -RM = /usr/gnu/bin/rm -vf - -INCLUDEDIR = $(TOPDIR)/include -LIBDIR = $(TOPDIR)/lib -ANSIDIR = $(INCLUDEDIR)/ansi - -INCLUDES = -I$(ANSIDIR) -I$(INCLUDEDIR) -OPTIMIZE-FLAGS = -O -MISC-CFLAGS = -g -Wall -PIPE = -pipe - -# -h flag makes NULL pointer references generate runtime errors -LDFLAGS = -h -L$(LIBDIR) - -CFLAGS = $(INCLUDES) $(OPTIMIZE-FLAGS) $(MISC-CFLAGS) $(PIPE) $(TARGET) - -# LysKOM executables that the typical user don't use go here. -# (The server, dbck, et c) - -LYSKOMSYSBIN = /usr/lyskom/bin - -# User executables (such as lyskom, kompost et c) - -LYSKOMUSRBIN = /usr/local/bin - - - -GENERIC-CLEAN = *~ *.o lib*.a dependencies core TAGS temp-Makefile \ - temp-?-Makefile - -# Too ugly... and it swells... -# -# EXPORTS = CC="${CC}" SHELL="${SHELL}" AWK="${AWK}" SED="${SED}" \ -# RM="${RM}" INCLUDEDIR="${INCLUDEDIR}" LIBDIR="${LIBDIR}" \ -# ANSIDIR="${ANSIDIR}" INCLUDES="${INCLUDES}" \ -# OPTIMIZE-FLAGS="${OPTIMIZE-FLAGS}" \ -# MISC-CFLAGS="${MISC-CFLAGS}" PIPE="${PIPE}" \ -# LDFLAGS="${LDFLAGS}" CFLAGS="${CFLAGS}" \ -# LYSKOMSYSBIN="${LYSKOMSYSBIN}" LYSKOMUSRBIN="${LYSKOMUSRBIN}" \ -# TOPDIR="${TOPDIR}" SCRIPTDIR="${SCRIPTDIR}" AR="${AR}" \ -# ARFLAGS="${ARFLAGS}" GENERIC-CLEAN="${GENERIC-CLEAN}" - -EXPORTS = - -# The Makefiles also dependes on the variables -# AR, ARFLAGS -# that are automatically set by GNU Make. diff --git a/src/include/dependencies b/src/include/dependencies deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/include/server/dependencies b/src/include/server/dependencies deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/libraries/libansi/config.h b/src/libraries/libansi/config.h deleted file mode 100644 index 80afad665..000000000 --- a/src/libraries/libansi/config.h +++ /dev/null @@ -1,8 +0,0 @@ -/* -** config.h -** -** System: SunOS 4.1.1 -*/ - - -/* #define HAVE_STRERROR */ diff --git a/src/libraries/libansi/dependencies b/src/libraries/libansi/dependencies deleted file mode 100644 index 00b32730b..000000000 --- a/src/libraries/libansi/dependencies +++ /dev/null @@ -1 +0,0 @@ -strerror.o : strerror.c config.h diff --git a/src/libraries/libansi/libansi.a b/src/libraries/libansi/libansi.a deleted file mode 100644 index da20a4f3e62e290cd2381b772fd4d11db21625e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1280 zcmY$iNi0gvu;VH&DM~FW$}iH(R{#Sub8`a&LsKIQ1qB5|BSQrR1!Gf?grR|fnVA__ z%m~C+P)OinWM*V%U|`5#fB*>w2F4{2CPNE|b_E%%pqc_=&wadq!jx$Y3~UVy?2HTy z49pA+3>O#@7#bEeaIiHnaDl`G85kHQ2q`cKGcYhXFfcGo5=vk&WME(rXkcL5Af~_o zlb@`$fawDh183v$2ONzrK&CUuFfg!mfLRO-3JeS^-B7jx0|N&K)Qu(#3>@50wgm$N z3rHNK%!Yx1sqO#&|3@I!vVhcp#9ff|`XK2IU|?W|*%iXTzznmCg$1Mwf`y=lgTh7< z<Tr>ggAx*3ABk<r3Q@qrz`)=P4loGcuK_}X$O0sG6B2tR68jJm`vDUBAA-#&fyA~# zV#gw}tB}~!kk~7b*t?O~ml13R1{VefkUu~e#O4P@A;<$R4B#j<fU<=cz)Hb{C<6mS z090Izfq@}`fr0V93P=EK7UO$RdSGB+;9_84{H6gB2Zb%e0SH?FL_yhL^B;f&pk_kZ z2@DKOJn6~F@yYqQ1(`XiDS8a?Nu_Ce1`P4V1x1;8C20)t#g)bJsYOLOnZ+d#PF`wJ z5kovImoUH>ddUo#c_mgQhPFk9*1AT9Cgvs<#%3lK)^Mh|HA8YnVv$vek!_KYwSl#v zk-0TPPJUjx0$8IlK8>Y$#hK}OsVNYpCLpB-*1CpJ{iw302-)I{{Gt+w9y5@ruCbB1 znT0iogxQU7fH_D7#8ikrRAVh5(q^Wn#->nv!Fo|uSwd8SoCb9<#LtEXAPHSVBMXSX z;kuyG;9xVbHZnD}W=PA)PXvXe5lD-PwShH5N`7flPO4RjAvlmMKtf=<;o{&B0gIRA zXQo({7@FD|n!@A8%FWQsR?CPXH80;Pz>p!SG|ei^(A+k$$Pg3_mexiLix)2j0Npg} Av;Y7A diff --git a/src/libraries/libcommon/.cvsignore b/src/libraries/libcommon/.cvsignore deleted file mode 100644 index 13dfd802d..000000000 --- a/src/libraries/libcommon/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Topdir.make -dependencies diff --git a/src/libraries/libcommon/ChangeLog b/src/libraries/libcommon/ChangeLog deleted file mode 100644 index 1d73a251b..000000000 --- a/src/libraries/libcommon/ChangeLog +++ /dev/null @@ -1,23 +0,0 @@ -Wed Feb 26 19:51:37 1992 Per Cederqvist (ceder@lysator) - - * kom-errno.c: Lint from gcc 2.0 removed. - -Sat Sep 21 11:01:47 1991 Per Cederqvist (ceder at lysator) - - * parser.c (parse): FREE (source_words) before returning. - -Sat Jul 6 06:15:40 1991 Per Cederqvist (ceder at lysator) - - * Fixade makefilen s} att den kan generera b}de liblyskom-server.a - och liblyskom-client.a. (Den ena kompilerad med SERVER - definierad, den andra med CLIENT definierad). "make depend" - kr{ver i nul{get manuella efterjusteringar. - - * misc-parser.h: "time_t" bytt mot "Time" (som {r "struct tm" i - klienten och "time_t" i servern). - - * [ndrade "typedef struct {...} Matching_info" till "typedef - struct matching_info {...} Matching_info". - - * parser.h: s-collat-tables.h -> s-collat-tabs.h. - diff --git a/src/libraries/libcommon/Makefile b/src/libraries/libcommon/Makefile deleted file mode 100644 index ee320b0b4..000000000 --- a/src/libraries/libcommon/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# -# $Id: Makefile,v 0.11 1992/04/14 15:43:14 ceder Exp $ -# Copyright (C) 1991 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. -# -include Topdir.make -SCRIPTDIR = $(TOPDIR)/scripts - -include $(SCRIPTDIR)/import.make - -TARGET = -DCLIENT - - -LIBOBJS = kom-errno.o misc-parser.o parser.o -INSTALL-HDRS = misc-parser.h parser.h -LIBRARIES = liblyskom-server$(PROFILE-LIB-SUFFIX).a \ - liblyskom-client$(PROFILE-LIB-SUFFIX).a - -all: $(LIBRARIES) - -client-dir: - $(MKDIR) client-dir - ln -s `echo $(LIBOBJS) $(INSTALL-HDRS) dependencies Topdir.make | \ - tr ' ' '\012' | sed 's/.o$$/.c/' | sed 's:^:\.\./:' ` client-dir/ - -server-dir: - $(MKDIR) server-dir - ln -s `echo $(LIBOBJS) $(INSTALL-HDRS) dependencies Topdir.make | \ - tr ' ' '\012' | sed 's/.o$$/.c/' | sed 's:^:\.\./:' ` server-dir/ - -.PHONY: liblyskom-server$(PROFILE-LIB-SUFFIX).a -liblyskom-server$(PROFILE-LIB-SUFFIX).a: server-dir - (cd server-dir;$(MAKE) $(EXPORTS) -f ../Makefile ../$@ TARGET=-DSERVER) - $(RANLIB) $@ - - -../liblyskom-server$(PROFILE-LIB-SUFFIX).a: $(LIBOBJS) - $(AR) $(ARFLAGS) $@ $? - -.PHONY: liblyskom-client$(PROFILE-LIB-SUFFIX).a -liblyskom-client$(PROFILE-LIB-SUFFIX).a: client-dir - (cd client-dir;$(MAKE) $(EXPORTS) -f ../Makefile ../$@ TARGET=-DCLIENT) - $(RANLIB) $@ - - -../liblyskom-client$(PROFILE-LIB-SUFFIX).a: $(LIBOBJS) - $(AR) $(ARFLAGS) $@ $? - - -clean: - $(RM) $(GENERIC-CLEAN) $(LIBRARIES) - -distclean: clean - $(RM) $(GENERIC-DIST-CLEAN) - $(RM) -r client-dir server-dir - -libraries: includes all - (cd $(LIBDIR); $(RM) $(LIBRARIES)) - cp $(LIBRARIES) $(LIBDIR) - (cd $(LIBDIR); $(TOUCHLIB) $(LIBRARIES)) - -include $(SCRIPTDIR)/install-includes.make - -binaries:; - -tags: - etags -t $(INCLUDEDIR)/*.h *.[hc] - -# Recreate the Makefile from Makefile - -include $(SCRIPTDIR)/Single-depend.make - -include dependencies diff --git a/src/libraries/libcommon/README b/src/libraries/libcommon/README deleted file mode 100644 index c55f3e5d4..000000000 --- a/src/libraries/libcommon/README +++ /dev/null @@ -1,5 +0,0 @@ -Functions for both the server and the clients to use. - -kom-errno.c - contains the kom_perror function -parser.c - routines for parsing the lyskom protocol -misc-parser.c - routines for parsing misc-info diff --git a/src/libraries/libcommon/dependencies b/src/libraries/libcommon/dependencies deleted file mode 100644 index dc0646a6b..000000000 --- a/src/libraries/libcommon/dependencies +++ /dev/null @@ -1,26 +0,0 @@ -kom-errno.o : kom-errno.c /users/ceder/lyskom/include/ansi/stdio.h \ - /users/ceder/lyskom/include/config.h \ - /users/ceder/lyskom/include/kom-errno.h \ - /users/ceder/lyskom/include/ansi/sys/types.h /usr/include/sys/types.h \ - /usr/gnu/lib/gcc-include/sys/stdtypes.h /usr/include/sys/stdtypes.h \ - /usr/include/sys/sysmacros.h -misc-parser.o : misc-parser.c misc-parser.h \ - /users/ceder/lyskom/include/kom-types.h \ - /users/ceder/lyskom/include/ansi/sys/types.h /usr/include/sys/types.h \ - /usr/gnu/lib/gcc-include/sys/stdtypes.h /usr/include/sys/stdtypes.h \ - /usr/include/sys/sysmacros.h /usr/gnu/lib/gcc-include/limits.h \ - /users/ceder/lyskom/include/ansi/time.h /usr/include/time.h \ - /users/ceder/lyskom/include/s-string.h \ - /users/ceder/lyskom/include/ansi/stdio.h \ - /users/ceder/lyskom/include/ansi/stddef.h \ - /users/ceder/lyskom/include/misc-types.h \ - /users/ceder/lyskom/include/s-collat-tabs.h -parser.o : parser.c /users/ceder/lyskom/include/ansi/stddef.h \ - /users/ceder/lyskom/include/ansi/sys/types.h /usr/include/sys/types.h \ - /usr/gnu/lib/gcc-include/sys/stdtypes.h /usr/include/sys/stdtypes.h \ - /usr/include/sys/sysmacros.h /users/ceder/lyskom/include/s-string.h \ - /usr/gnu/lib/gcc-include/limits.h /users/ceder/lyskom/include/ansi/stdio.h \ - /users/ceder/lyskom/include/misc-types.h \ - /users/ceder/lyskom/include/s-collat-tabs.h parser.h \ - /users/ceder/lyskom/include/zmalloc.h \ - /users/ceder/lyskom/include/compiler.h diff --git a/src/libraries/libcommon/kom-errno.c b/src/libraries/libcommon/kom-errno.c deleted file mode 100644 index 19525e388..000000000 --- a/src/libraries/libcommon/kom-errno.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * $Id: kom-errno.c,v 0.4 1992/02/26 18:46:19 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * kom_errno.c - * - * Created by ceder 1990-05-13 - * - */ - - -static char *rcsid = "$Id: kom-errno.c,v 0.4 1992/02/26 18:46:19 ceder Exp $"; - -#include <stdio.h> - -#include <config.h> - -#include <kom-errno.h> - - -Kom_err kom_errno = 0; - -/* Additional information about the error */ -u_long err_stat = 0; - -/* Note that kom_errout is defined in config.h */ - -void -kom_perror(void) -{ - switch (kom_errno) - { - case KOM_NO_ERROR: - fprintf (kom_errout, "Why am I called? There was no error!\n"); - break; - - case KOM_NOT_IMPL: - fprintf(kom_errout, "Not implemented yet\n"); - break; - - case KOM_PWD: - fprintf(kom_errout, "Wrong/illegal password\n"); - break; - - case KOM_LOGIN: - fprintf(kom_errout, "Not logged in.\n"); - break; - - case KOM_LOGIN_DISALLOWED: - fprintf(kom_errout, "System is in 'singel-user mode'\n"); - break; - - case KOM_CONF_ZERO: - fprintf(kom_errout, "Attempt to use conference number 0.\n"); - break; - - case KOM_UNDEF_CONF: - fprintf(kom_errout, "Undefined or secret conference\n"); - break; - - case KOM_UNDEF_PERS: - fprintf(kom_errout, "Undefined or secret person\n"); - break; - - case KOM_ACCESS: - fprintf(kom_errout, "No 'read/write permission'\n"); - break; - - case KOM_SECRET_PUBLIC: - fprintf(kom_errout, "Cannot be secret and !rd_prot\n"); - break; - - case KOM_LETTER_BOX: - fprintf(kom_errout, "Cannot change letter_box flag\n"); - break; - - case KOM_PERM: - fprintf(kom_errout, "No permission\n"); - break; - - case KOM_NOT_MEMBER: - fprintf(kom_errout, "Not member in conf\n"); - break; - - case KOM_NO_SUCH_TEXT: - fprintf(kom_errout, "No such global text as %ld or no access\n", - err_stat); - break; - - case KOM_NO_SUCH_LOCAL_TEXT: - fprintf(kom_errout, "No such local text as %ld\n", err_stat); - break; - - case KOM_INDEX_OUT_OF_RANGE: - fprintf(kom_errout, "Index out of range\n"); - break; - - case KOM_BAD_NAME: - fprintf(kom_errout, "To short/long or contains illegal chars\n"); - break; - - case KOM_CONF_EXISTS: - fprintf(kom_errout, "Already exists\n"); - break; - - case KOM_PERS_EXISTS: - fprintf(kom_errout, "Already exists\n"); - break; - - case KOM_LDB_ERR: - fprintf(kom_errout, "LDB_err\n"); - break; - - case KOM_ILL_MISC: - fprintf(kom_errout, "Illegal misc field at %ld.\n", err_stat); - break; - - case KOM_ILLEGAL_INFO_TYPE: - fprintf(kom_errout, "Info_type parameter illegal. Client is buggy.\n"); - break; - - case KOM_ALREADY_RECIPIENT: - fprintf(kom_errout, "Already recipient to this text.\n"); - break; - - case KOM_NOT_RECIPIENT: - fprintf(kom_errout, "Not recipient.\n"); - break; - - case KOM_RECIPIENT_LIMIT: - fprintf(kom_errout, "Too many recipients.\n"); - break; - - case KOM_COMM_LIMIT: - fprintf(kom_errout, "Too many comments.\n"); - break; - - case KOM_FOOT_LIMIT: - fprintf(kom_errout, "Too many footnotes.\n"); - break; - - case KOM_NOT_AUTHOR: - fprintf(kom_errout, "Only the author may add footnotes.\n"); - break; - - case KOM_OBSOLETE: - fprintf (kom_errout, "Servern {r inte kompatibel med mig.\n"); - break; - - case KOM_LONG_STR: - fprintf (kom_errout, "F|r l}ng str{ng.\n"); - break; - - case KOM_NO_CONNECT: - fprintf (kom_errout, "Kan ej f} kontakt med servern.\n"); - break; - - case KOM_OUT_OF_MEMORY: - fprintf (kom_errout, "Dumma Emacs! Fattar du inte att du inte ska " - "bryta en\nrad inuti en str{ng bara f|r att man anv{nder " - "} och {???\n"); - break; - - case KOM_SERVER_IS_CRAZY: - fprintf (kom_errout, "Hmm, jag tror servern har b|rjat tala i " - "tungom}l...\n"); - break; - - case KOM_CLIENT_IS_CRAZY: - fprintf (kom_errout, "Hoppschan. Jag har vischt b|rjat schluddra.\n"); - break; - -#ifndef COMPILE_CHECKS - default: - fprintf(kom_errout, "Unknown error %d\n", kom_errno); - break; -#endif - } -} - diff --git a/src/libraries/libcommon/misc-parser.c b/src/libraries/libcommon/misc-parser.c deleted file mode 100644 index 861555fa5..000000000 --- a/src/libraries/libcommon/misc-parser.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * $Id: misc-parser.c,v 0.3 1991/09/15 10:22:54 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * misc-parser.c - * Parse a list of misc-items for LysKOM texts. - * - * - * Copyright (C) 1990 Lysator Computer Club, - * Linkoping University, Sweden - * - * Everyone is granted permission to copy, modify and redistribute - * this code, provided the people they give it to can. - * - * - * Author: Thomas Bellman - * Lysator Computer Club - * Linkoping University - * Sweden - * - * email: Bellman@Lysator.LiU.SE - * - * - * Any opinions expressed in this code are the author's PERSONAL opinions, - * and does NOT, repeat NOT, represent any official standpoint of Lysator, - * even if so stated. - */ - -static char *rcsid = "$Id: misc-parser.c,v 0.3 1991/09/15 10:22:54 linus Exp $"; - - -#include "misc-parser.h" - -#define EXPORT - - -/* - * Return TRUE if the next misc-item exist, and it is of type - * MTYPE, FALSE otherwise. Can only be used within the function - * parse_next_misc(). - */ -#define NEXT_IS(mtype) \ - (*info < stop_pointer && (*info)->type == (mtype)) - - -#define BARF { result.type = m_error; return result; } - - -/* - * Parse out a "group" of misc-items from a list of them pointed - * to by *INFO. *STOP_POINTER must point to the item directly - * after the last in the list. **INFO will be incremented to - * point to the item after the recently parsed out group. The - * return value will have the TYPE field set to 'm_end_of_list' - * when the end of the list has been reached. - */ -EXPORT Misc_info_group -parse_next_misc (const Misc_info ** info, - const Misc_info * stop_pointer) - -{ - Misc_info_group result; - - - - /* Clear the 'result' struct */ - result.type = m_error; - result.recipient = 0; - result.cc_recipient = 0; - result.local_no = 0; - result.is_received = FALSE; - result.comment_to = 0; - result.commented_in = 0; - result.footnote_to = 0; - result.footnoted_in = 0; - result.sender = 0; - result.is_sent = 0; - - - if (*info >= stop_pointer) - { - result.type = m_end_of_list; - return result; - } - - - /* Now, do the real work... */ - switch ((*info)->type) - { - case recpt: /* These two are so similar that they can */ - case cc_recpt: /* Be handled in the same clause */ - if ((*info)->type == recpt) - { - result.type = m_recpt; - result.recipient = (*(*info)++).datum.recipient; - } - else - { - result.type = m_cc_recpt; - result.cc_recipient = (*(*info)++).datum.cc_recipient; - } - - /* There should follow a 'Local no', but check nevertheless */ - if (! NEXT_IS (loc_no)) - { BARF } - else - result.local_no = (*(*info)++).datum.local_no; - - if (NEXT_IS (rec_time)) - { - result.is_received = TRUE; - result.received_at = (*(*info)++).datum.received_at; - } - - if (NEXT_IS (sent_by)) - { - result.sender = (*(*info)++).datum.sender; - /* There _should_ be a 'sent_at' here... */ - if (! NEXT_IS (sent_at)) - { BARF } - /* Let the following if clause insert the 'sent_at' data. */ - } - if (NEXT_IS (sent_at)) - { - result.is_sent = TRUE; - result.sent_at = (*(*info)++).datum.sent_at; - } - - break; - - - case comm_to: - result.type = m_comm_to; - result.comment_to = (*(*info)++).datum.comment_to; - - if (NEXT_IS (sent_by)) - { - result.sender = (*(*info)++).datum.sender; - /* There _should_ be a 'sent_at' here. */ - if (! NEXT_IS (sent_at)) - { BARF } - /* Let the following if clause insert the 'sent_at' data. */ - } - if (NEXT_IS (sent_at)) - { - result.is_sent = TRUE; - result.sent_at = (*(*info)++).datum.sent_at; - } - - break; - - - case footn_to: - result.type = m_footn_to; - result.footnote_to = (*(*info)++).datum.footnote_to; - - if (NEXT_IS (sent_at)) - { - result.is_sent = TRUE; - result.sent_at = (*(*info)++).datum.sent_at; - } - - break; - - - case comm_in: - result.type = m_comm_in; - result.commented_in = (*(*info)++).datum.commented_in; - break; - - - case footn_in: - result.type = m_footn_in; - result.footnoted_in = (*(*info)++).datum.footnoted_in; - break; - - -#ifndef COMPILE_CHECKS - default: - result.type = m_error; - break; -#endif - } - - return result; -} diff --git a/src/libraries/libcommon/misc-parser.h b/src/libraries/libcommon/misc-parser.h deleted file mode 100644 index 413c44b74..000000000 --- a/src/libraries/libcommon/misc-parser.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * $Id: misc-parser.h,v 0.3 1991/09/15 10:22:49 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: misc-parser.h,v 0.3 1991/09/15 10:22:49 linus Exp $ - * - * misc-parser.h - * Parse a list of "misc-item":s for a text in LysKOM - * - * - * Copyright (C) 1990 Lysator Computer Club, - * Linkoping University, Sweden - * - * Everyone is granted permission to copy, modify and redistribute - * this code, provided the people they give it to can. - * - * - * Author: Thomas Bellman - * Lysator Computer Club - * Linkoping University - * Sweden - * - * email: Bellman@Lysator.LiU.SE - */ - - - -#include <kom-types.h> - - - -typedef enum { - m_recpt, - m_cc_recpt, - m_comm_to, - m_comm_in, - m_footn_to, - m_footn_in, - m_end_of_list, /* End of list reached */ - m_error /* Bad misc-items found */ -} Misc_struct_type; - - -typedef struct { - Misc_struct_type type; - Conf_no recipient; - Conf_no cc_recipient; - Local_text_no local_no; - Time received_at; - Text_no comment_to; - Text_no commented_in; - Text_no footnote_to; - Text_no footnoted_in; - Pers_no sender; - Time sent_at; - Bool is_received; - Bool is_sent; -} Misc_info_group; - - - -#define is_received(mstruct) ((mstruct).is_received != FALSE) -#define is_sent_by(mstruct) ((mstruct).sender != 0) -#define is_sent(mstruct) ((mstruct).is_sent != FALSE) - - -/* - * Parse out a "group" of misc-items from a list of them pointed - * to by *INFO. *STOP_POINTER must point to the item directly - * after the last in the list. **INFO will be incremented to - * point to the item after the recently parsed out group. The - * return value will have the TYPE field set to 'm_end_of_list' - * when the end of the list has been reached. - * - * If the has a bad format, the TYPE field will be 'm_error', - * and **INFO_POINTER will point to the item before the bad (or - * missing) item. - */ -extern Misc_info_group -parse_next_misc (const Misc_info ** info_pointer, - const Misc_info * stop_pointer); diff --git a/src/libraries/libcommon/parser.c b/src/libraries/libcommon/parser.c deleted file mode 100644 index 0a8e74ddd..000000000 --- a/src/libraries/libcommon/parser.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * $Id: parser.c,v 0.4 1991/09/21 12:04:23 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * client/parser.c -- Routines to parse commands - * - * - * Copyright (C) 1990 Lysator Computer Club, - * Linkoping University, Sweden - * - * Everyone is granted permission to copy, modify and redistribute - * this code, provided the people they give it to can. - * - * - * Author: Thomas Bellman - * Lysator Computer Club - * Linkoping University - * Sweden - * - * email: Bellman@Lysator.LiU.SE - * - * - * Any opinions expressed in this code are the author's PERSONAL opinions, - * and does NOT, repeat NOT, represent any official standpoint of Lysator, - * even if so stated. - */ - - -static char *rcsid = "$Id: parser.c,v 0.4 1991/09/21 12:04:23 ceder Exp $"; - -#include <stddef.h> - -#include <s-string.h> -#include <s-collat-tabs.h> - -#include <misc-types.h> - -#include "parser.h" - - -#define EXPORT /* To emphasize export of objects */ -#define PRIVATE static - - -#if defined (SERVER) -# include <server/smalloc.h> -# define MALLOC smalloc -# define REALLOC srealloc -# define FREE sfree -#elif defined (CLIENT) -# include <zmalloc.h> -# define MALLOC zmalloc -# define REALLOC zrealloc -# define FREE zfree -#else -# include <malloc.h> -# define MALLOC malloc -# define REALLOC realloc -# define FREE free -#endif - - - -/* - * Remove paranthesized "expressions" from the string STR. - * E g if STR is "Foo (Bar (vfslck)) Gazonk", then it is reduced - * to "Foo _ Gazonk", where '_' is the character in SEPARATOR. - * Superflous close paranthesis are disregarded. - */ -EXPORT void -remove_parenthesis (String * str, - char blanker) - -{ - String_size i; /* Index in loop */ - int nesting_depth; - - - /* Match parantheses. Remove text inside parantheses. */ - nesting_depth = 0; - for ( i = 0 ; i < s_strlen(*str) ; i++ ) - { - if (str->string[i] == '(') - nesting_depth++; - - if (str->string[i] == ')') - { - nesting_depth--; - str->string[i] = blanker; /* Don't forget that... */ - if (nesting_depth < 0) - nesting_depth = 0; - } - - if (nesting_depth > 0) - str->string[i] = blanker; - } - - return; -} - - - - -/* - * Convert a String to a list of tokens (words). This list is - * easier to parse than a string (since the string would have to - * be tokenized first anyway). The last entry is EMPTY_STRING. - * Returns NULL if any error occured (couldn't allocate memory). - * The result from this function should be freed when it is no longer - * used by a FREE(Parse_token *). Note that String (Parse_token *)[X].word - * points into source, and should thus not be freed. - */ -EXPORT Parse_token * -tokenize (const String source, - const String separators) - -{ - Parse_token * tokens = NULL; - Parse_token * temp_list; /* Temporary */ - String work_string = EMPTY_STRING; - String a_token; - String a_temp_token; /* More temporaries... */ - int no_of_tokens; - int list_size; - String_size pos_in_string; - const int chunk_size = 10; - - - - /* Copy string to working area */ - if (s_strcpy(&work_string, source) == FAILURE) - { - /* Couldn't allocate space for temporary string. */ - return NULL; - } - - remove_parenthesis (&work_string, separators.string[0]); - - no_of_tokens = 0; - list_size = 0; - pos_in_string = 0; - - while ( ! s_empty(a_token - = s_strtok (work_string, &pos_in_string, - separators))) - { - /* Make the token point into the original source string - * instead of the working string */ - a_temp_token = s_fsubstr (source, - pos_in_string - s_strlen (a_token), - pos_in_string - 1); -#if 0 -// * /* Get a real copy of the word */ -// * a_temp_token = EMPTY_STRING; -// * if (s_strcpy(&a_temp_token, a_token) == FAILURE) -// * { -// * /* Grumble... */ -// * free_tokens (tokens); -// * s_clear(&work_string); -// * return NULL; -// * } -#endif - - /* Is the allocated list large enough? */ - if (no_of_tokens++ >= list_size) - { - /* No, allocate more */ - temp_list = REALLOC (tokens, (list_size += chunk_size) - * sizeof(Parse_token)); - if (temp_list == NULL) - { - /* Sigh. Out of memory. */ - free_tokens (tokens); - s_clear (&work_string); - return NULL; - } - else - { - /* OK, we got what we asked for */ - tokens = temp_list; - } - } - - /* Insert the new token in the list */ - tokens [no_of_tokens-1].word = a_temp_token; - tokens [no_of_tokens-1].start_in_string = - pos_in_string - s_strlen(a_temp_token); - } - - s_clear (&work_string); - - /* Is there room in the list for the 'stop' element? */ - if (list_size <= no_of_tokens) - { - /* No, get some more memory */ - temp_list = REALLOC (tokens, (++list_size) * sizeof(Parse_token)); - if (temp_list == NULL) - { - /* Sigh. Out of memory. */ - free_tokens (tokens); - return NULL; - } - else - { - /* OK, we got what we asked for */ - tokens = temp_list; - } - } - - /* OK, insert the 'stop' element. */ - tokens [no_of_tokens].word = EMPTY_STRING; - tokens [no_of_tokens].start_in_string = END_OF_STRING; - - return tokens; -} - - - - -/* - * Count the number of tokens (words) in TOKEN_LIST. Used to - * set the NUMBER_OF_WORDS field in a 'Matching_info' object. - */ -extern int -count_words (const Parse_token * token_list) - -{ - int no_of_words; - - no_of_words = 0; - while (! s_empty(token_list++ -> word)) - no_of_words++; - - return no_of_words; -} - - - - -/* - * Free the list of tokens (// and the strings they are pointing to //). - * Free:ing NULL is a no-op. - */ -EXPORT void -free_tokens (Parse_token * token_list) - -{ - if (token_list != NULL) - { - FREE (token_list); - } -} - - - - -/* - * Returns the number of the first word of SOURCE that does - * not match PATTERN. A word "foo" in SOURCE matches "foobar" - * in PATTERN, but not vice versa. - */ -EXPORT int -match (Parse_token * source, - Parse_token * pattern, - char collat_tab [ COLLAT_TAB_SIZE ] ) - -{ - int word_no; - - word_no = 0; - while ( (! s_streq (pattern[word_no].word, EMPTY_STRING)) - && (! s_streq (source[word_no].word, EMPTY_STRING)) - && (s_usr_strhead (source[word_no].word, - pattern[word_no].word, - collat_tab))) - { - word_no++; - } - - return word_no; -} - - - - -/* - * Searches for a matching string in the table 'match_table'. - * Some weird pattern matching is done. - * parse().no_of_matches is -1 if an error occured (out of - * memory). - * - * What? You want a description of how it matches? Forget it! BUG! - * Try for yourself, and you'll find out! - */ - -EXPORT Parse_info -parse (String source_string, - Matching_info * match_table, - Bool allow_trailing_words, - Bool number_of_words_must_match, - String separators, - char collat_tab [ COLLAT_TAB_SIZE ] ) - -{ - Parse_info answer; - int * temp_indexes; - int index; - int size_of_index_list; - Parse_token * source_words; - int no_of_source_words; - int first_non_matching; - int best_match; - int highest_priority; - - const int chunk_size = 20; - - - - source_words = tokenize(source_string, separators); - if (source_words == NULL) - { - answer.no_of_matches = -1; - return answer; - } - - no_of_source_words = count_words(source_words); - - /* Check if SOURCE_STRING was empty of words */ - if (no_of_source_words == 0) - { - FREE (source_words); - answer.indexes = MALLOC (1 * sizeof(int)); - if (answer.indexes == NULL) - { - /* Gahh! Someone eats memory! */ - answer.no_of_matches = -1; - return answer; - } - answer.indexes[0] = -1; - answer.no_of_matches = 1; - return answer; - } - - - answer.no_of_matches = 0; - answer.indexes = NULL; - size_of_index_list = 0; - index = -1; - best_match = 1; /* At least one word */ - highest_priority = 1; - while (! s_empty (match_table[++index].name)) - { - first_non_matching = match (source_words, match_table[index].tokens, - collat_tab); - - if ( ( ! allow_trailing_words - && first_non_matching < no_of_source_words) - || ( number_of_words_must_match - && first_non_matching != count_words (match_table[index].tokens))) - { - continue; /* Try next entry in table */ - } - - if (first_non_matching < best_match) - continue; /* Try next entry in table */ - - if ( first_non_matching == best_match - && highest_priority > match_table[index].priority) - continue; - - /* If we reach this far, then we have a match that should be - * inserted in the table. But if it is a better match than any - * before, then we clear the table first. */ - if ( first_non_matching > best_match - || match_table[index].priority > highest_priority) - { - highest_priority = match_table[index].priority; - best_match = first_non_matching; - answer.no_of_matches = 0; - } - - /* Insert the match in the table */ - - /* Increase the size if necessary */ - if (answer.no_of_matches >= size_of_index_list) - { - temp_indexes = REALLOC (answer.indexes, - (size_of_index_list += chunk_size) - * sizeof(answer.indexes)); - if (temp_indexes == NULL) - { - /* Grumble! Out of memory. */ - FREE (source_words); - FREE (answer.indexes); - answer.no_of_matches = -1; - return answer; - } - - answer.indexes = temp_indexes; - } - - highest_priority = match_table [index].priority; - answer.indexes[answer.no_of_matches] = index; - /* Find out where the arguments start. - * This value should not be used if more than one match is found. - */ - /* Special hack needed if no parameters */ - if (s_empty (source_words [first_non_matching].word)) - answer.arguments = EMPTY_STRING; - else - answer.arguments = - s_fsubstr(source_string, - source_words[first_non_matching]. - start_in_string, - END_OF_STRING); - answer.no_of_matches++; - } - - /* All matches found by now */ - - /* Strip trailing blanks from the argument */ - if (answer.no_of_matches == 1) - answer.arguments = s_strip_trailing (answer.arguments, separators); - - FREE (source_words); - return answer; - -} /* END: parse() */ diff --git a/src/libraries/libcommon/parser.h b/src/libraries/libcommon/parser.h deleted file mode 100644 index fcac305d4..000000000 --- a/src/libraries/libcommon/parser.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * $Id: parser.h,v 0.3 1991/09/15 10:22:42 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: parser.h,v 0.3 1991/09/15 10:22:42 linus Exp $ - * - * client/parser.h -- Header file for LysKOM command parsing routines - * - * - * Copyright (C) 1990 Lysator Computer Club, - * Linkoping University, Sweden - * - * Everyone is granted permission to copy, modify and redistribute - * this code, provided the people they give it to can. - * - * - * Author: Thomas Bellman - * Lysator Computer Club - * Linkoping University - * Sweden - * - * e-mail: Bellman@Lysator.LiU.SE - */ - - -#ifndef PARSER_H_ALREADY_INCLUDED__ -#define PARSER_H_ALREADY_INCLUDED__ - - -#include <misc-types.h> -#include <s-string.h> -#include <s-collat-tabs.h> - - - -/* - * Information about one word. If the field 'word' is - * EMPTY_STRING, then the struct is considered to be the last - * in an "array". BUG: "array" is wrong word - */ -typedef struct { - String word; - String_size start_in_string; -} Parse_token; - - -/* - * Information about one string to match against during parse(). - * A list of these should be passed to parse() as the CMD_TABLE - * parameter. The 'tokens' field is set by doing - * I.tokens = tokenize(I.name, Separators); - */ -typedef struct matching_info { - String name; /* Name to match against */ - Parse_token * tokens; /* Tokenized version of name */ - int priority; /* Normally in interval 1..15 */ -} Matching_info; - - - -/* - * Remove paranthesized "expressions" from the string STR by - * replacing them with the character SEPARATOR. - * Superflous close paranthesis are disregarded. - */ -extern void -remove_parenthesis (String * str, - char separator); - - - -/* - * Convert a String to a list of tokens (words). This list is - * easier to parse than a string (since the string would have to - * be tokenized first anyway). - * Returns NULL if any error occured (couldn't allocate memory). - */ -extern Parse_token * -tokenize (const String source, - const String separators); - - - -/* - * Count the number of tokens (words) in TOKEN_LIST. Used to - * set the NUMBER_OF_WORDS field in a 'Matching_info' object. - */ -extern int -count_words (const Parse_token * token_list); - - - -/* - * Free the list of tokens (// and the strings they are pointing to //). - * Free:ing NULL is a no-op. - */ -extern void -free_tokens (Parse_token * token_list); - - - -/* - * Returns the number of the first word of SOURCE that does - * not match PATTERN. A word "foo" in SOURCE matches "foobar" - * in PATTERN, but not vice versa. - */ -extern int -match (Parse_token * source, - Parse_token * pattern, - char collat_tab [ COLLAT_TAB_SIZE ] ); - - - -/* - * Contains the result of a parse(). - */ -typedef struct { - int no_of_matches; /* Number of found matches */ - int * indexes; /* List of indexes */ - String arguments; /* The arguments... */ -} Parse_info; - - -/* - * Searches for a matching string in the table 'match_table'. - * Some weird pattern matching is done. The 'ARGUMENTS' field of - * the result is not a separate String, but points into - * SOURCE_STRING. - * If ALLOW_TRAILING_WORDS is false, then SOURCE_STRING may not - * contain any trailing words. - * If NUMBER_OF_WORDS_MUST_MATCH is true, then all the words - * in from the entry in MATCH_TABLE must be present (possibly - * abbrevated) in SOURCE_STRING. - * parse().no_of_matches is -1 if an error occured (out of - * memory). - * If SOURCE_STRING is empty, i e does not contain any words, - * the 'no_of_matches' field is 1, and indexes[0] is -1. - * - * What? You want a description of how it matches? Forget it! BUG! - * Try for yourself, and you'll find out! - */ - -extern Parse_info -parse (String source_string, - Matching_info * match_table, - Bool allow_trailing_words, - Bool number_of_words_must_match, - String separators, - char collat_tab [ COLLAT_TAB_SIZE ] ); - - -#endif /* PARSER_H_ALREADY_INCLUDED__ */ diff --git a/src/libraries/libmisc/dependencies b/src/libraries/libmisc/dependencies deleted file mode 100644 index 123b2966a..000000000 --- a/src/libraries/libmisc/dependencies +++ /dev/null @@ -1,46 +0,0 @@ -numlist.o : numlist.c /users/ceder/lyskom/include/ansi/stdio.h \ - /users/ceder/lyskom/include/ansi/stdlib.h \ - /users/ceder/lyskom/include/ansi/stddef.h \ - /users/ceder/lyskom/include/ansi/sys/types.h /usr/include/sys/types.h \ - /usr/gnu/lib/gcc-include/sys/stdtypes.h /usr/include/sys/stdtypes.h \ - /usr/include/sys/sysmacros.h /users/ceder/lyskom/include/misc-types.h \ - numlist.h -testnumlist.o : testnumlist.c /users/ceder/lyskom/include/ansi/stdio.h \ - /users/ceder/lyskom/include/ansi/stdlib.h \ - /users/ceder/lyskom/include/ansi/stddef.h \ - /users/ceder/lyskom/include/ansi/sys/types.h /usr/include/sys/types.h \ - /usr/gnu/lib/gcc-include/sys/stdtypes.h /usr/include/sys/stdtypes.h \ - /usr/include/sys/sysmacros.h /users/ceder/lyskom/include/misc-types.h \ - numlist.h -numlist2.o : numlist2.c /users/ceder/lyskom/include/ansi/stdio.h \ - /users/ceder/lyskom/include/ansi/stdlib.h \ - /users/ceder/lyskom/include/ansi/stddef.h \ - /users/ceder/lyskom/include/ansi/sys/types.h /usr/include/sys/types.h \ - /usr/gnu/lib/gcc-include/sys/stdtypes.h /usr/include/sys/stdtypes.h \ - /usr/include/sys/sysmacros.h /users/ceder/lyskom/include/misc-types.h \ - numlist2.h -zmalloc.o : zmalloc.c /users/ceder/lyskom/include/ansi/stddef.h \ - /users/ceder/lyskom/include/ansi/sys/types.h /usr/include/sys/types.h \ - /usr/gnu/lib/gcc-include/sys/stdtypes.h /usr/include/sys/stdtypes.h \ - /usr/include/sys/sysmacros.h /users/ceder/lyskom/include/ansi/malloc.h \ - /users/ceder/lyskom/include/ansi/string.h \ - /users/ceder/lyskom/include/compiler.h zmalloc.h -pom.o : pom.c /users/ceder/lyskom/include/ansi/sys/types.h \ - /usr/include/sys/types.h /usr/gnu/lib/gcc-include/sys/stdtypes.h \ - /usr/include/sys/stdtypes.h /usr/include/sys/sysmacros.h \ - /users/ceder/lyskom/include/ansi/time.h /usr/include/time.h \ - /users/ceder/lyskom/include/ansi/math.h /usr/include/math.h \ - /usr/include/floatingpoint.h /usr/include/sys/ieeefp.h \ - /users/ceder/lyskom/include/ansi/stdio.h pom.h -s-collat-tabs.o : s-collat-tabs.c s-collat-tabs.h \ - /usr/gnu/lib/gcc-include/limits.h -s-string.o : s-string.c /users/ceder/lyskom/include/ansi/sys/types.h \ - /usr/include/sys/types.h /usr/gnu/lib/gcc-include/sys/stdtypes.h \ - /usr/include/sys/stdtypes.h /usr/include/sys/sysmacros.h \ - /users/ceder/lyskom/include/ansi/stdio.h \ - /users/ceder/lyskom/include/ansi/string.h \ - /users/ceder/lyskom/include/ansi/ctype.h /usr/include/ctype.h \ - /users/ceder/lyskom/include/ansi/stdlib.h \ - /users/ceder/lyskom/include/ansi/stddef.h /usr/gnu/lib/gcc-include/assert.h \ - /users/ceder/lyskom/include/misc-types.h s-collat-tabs.h \ - /usr/gnu/lib/gcc-include/limits.h s-string.h diff --git a/src/libraries/libmisc/testnumlist b/src/libraries/libmisc/testnumlist deleted file mode 100755 index 103245d0a3816fd38dda3481d15c1add2871998a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmZo*V&rCEP+)*y1_lNONe%`E1&{!U!{Gaafk8#w{XGMV64TR0&(9Jp%4Zmu7!G*t zWMEKYOJ`tUOJrcs@(A$=)@SkqiOm3!Y8LnYF!1Oz`0Zq1V#tW-hq4O%!v3G|cy7Sp zQN_5%qk;iMclqsNG`s(Yfq{WT*Wv#Mj|v6_kG%gU^cnniG1`E|1$Y`j&P(TT{KZ(7 zz`$t2lgG&Y|5Vxs6&nTy`Ttke{XfIh^#30N16vaV69a<+(}i{aFI-sn|B6QyV-m;~ zeZBu5^sN|Y=vy%^&}RUN`0Zji12$Vi*Wv#QeZBu@plT}gtr#ox_5NP~oALtW3Wh}x zm1+!A*8M-D&!nLD|HTCmi@|Rf!vwG#k4F`w63ASSDu$DOyBN{}`gI-tzwui4|4JH5 zM1KNUPM<;FictcL_5NSEw(kE0eP+L13@%_3WE_9}JE80G|Br4ZD0Kh-(5+&~`TxZu z@Ba&r3I;}ny#FsQzWaa2Z$d!7&wU0Szc{~Ag?t7cj|v9X1Q~^V1{seE2KNLZsF-I0 zheAGsfJX%bv!6pMlV7R6ghzl!1p^b<jTH<meh&II3=9nQ3@jki{Tx8yre9iIq@R<S zq@R<bSDeqFpORXpUzJ*v4^9RW$wegwRtkCf3aHAs7#J8-A#$h^3b}~|1(|v23TcU% zIi*FZAcYLV5S1WPV5W01G%zqQH83y;F)%Q&GcYi)g6(7Q`^mt>PysSr)ihK!S%*OZ z0(2Ps!v6mV-pRnk$m0bjbA=Qt8JHLa1okjQ2Z2Nc5^@YI8JHMlm>d`yyd2U!6hJ&4 zmxc`>S&1AAgnF=y092P;fe2dz0~5m!eFlgMrv?E5eTKyU42*Y60{j!i5b_=s4AEfm zm;isjLZ@~A{}i!oTKE4?Zk<9N1Ba5{|38~1<ivs43VQ$l=oav>{Qse#_x}e|!vO{c z2A&271_p*SmIAv3rUC_h28fLP|NsACY=|mQvQJ|vuz{%ZsQUK>Wapg=_x>;lB=C4t z{d)`MABgY|TKE4?0>l3r9N`iR^&zq05=(5j+=;;mmsqfyTmt-YxP=SqmOPX=@&en4 zh$AaV3<&ID;7Z^F%MlSvx6fg?h707H+uH*CK{+NTvA85YuQXRdLBUo*HI$11ERdO( zl3D>3@C*C@2NY}i8VnpBRsS!5btgbY1U#z#p9hQhfkboz{{I2Rgx9+Nf6~SD_5S}! zWcZt+koW(OZU%$I|34A_2~X%B2DeUO4})8qAYtH|TToJ|kXM?UlUZD1#lWSStQyLo z8mf?)SDac@lA6K=;-sYJq=MO@c}1zo`RRF?RjDZo$@#gtiFqkj3aZImpj`MN@jn9t z(+gdP|9?EH{;vRq%q<s4IQ-k;wC?|p0DrG_|9_-0FdQoQbfHh5q2N1+^r-sZ4OS}v zsv`vS{(t9TU`R>#0g-upJPZt6=|wyY3<~Kv2{}9r44LU1JPZtl>0t?R`g;FAfzAKV zz`%A6#Pg{7?+P;O<{q#(!#{_6e;7m(d_Zzwk^c+~Ts<J3N7a7~u*ykbafW|lV3kTm zjJl5he<VmHNPt}8c|f1Rqv}66)!fVo@K0c1U`k;4Z{^egVu8|7SY}a4X=08-Zfb6R zQKdp^MMh$2aY<?l11LoPcvLXRfNhBZg-Qg-|9{eCJgWYmD$szHEns;QFsT;c4@xgi z6TsvO1_@AU0ka8|7WJ9@3SntYMeqNgE$bL~@?}6GAeBm>vWDSlqvA#h1|F7RP#JIw zBFDg^xQ;=9hXuq7nxLZh{|CtJAQM5guV0~V9)k!trSm8V1UGD0_y146f<hhx57<;a z1|AiLr%jidlpF&*6({nrfJ>K4Ao<`4Aku3>TA0^527xp=koig=eJdFxKy0rGX&fNh zX$1pIf|^1eg8)cYF_S?8BCn>wz_M)}15X+kNR?t9g8&1Iz8(V)C^T*uMELu>W8nG! z1?tux`b>!o|5kxQ5)?itCh;id{r|%tp_|7b@c#$MO&~vRnUEs~QmMc+VI9O~CB6SY z6gSGSfc@|z;TlL5WR8m9lywXO3QZuL3LsV<1BZ$R0}Cj8VQ%~Xhk->!5AGUJ+=_tQ zdA$MTB1GK&eTN#i*CW8HywKv71!Q;8e?><I4p1l~Vwr&f6c%0+!VeTN9%xixK*;?6 zqR*tS$H0-uz?h@!@c&1If64zX>;C^p=TXsP-~q9cm=f5)Y4Z)p3{Z&#E{zx%pg#To zM?vsugMtAE15*R2e%Y{&fhU!LVU^Rm|6f4v0r_vsgd7Hj86cj5-v2KO20SbXwaF0E z`%q<(Y9|L&8JHbON+3Tf>HYumwDCftf<u6Zf&jwQRF(q91dE_`|Gy-N!St&b@IXQz zBqsxwWB4Bjl7*C}2@L<$z&>SC(fj`annM0SLg(Ke1%?QJuZDECg8vCN309!6PzX@c zU|?Zt1i47p5uDaJz-b1YK0!H0F_3`=q|#{xg8<02NZ}4MHwDRDwFDKAYTXP57LaNG z|0w05hc1!{U-X$ks=@KJf`KEAff3Bt&0ydG>1N>2&48rb|9?QWKP1$V!qo=kB2enZ z7JkW6FtdZ26rDiniGe4mA%TH$LjowT{s>wJ$`k+pK=XtFNHy5CdjEf@81k?%HGx6} ztTT@R6e>R$1VCyOG#EG%7#On<p$<w-X+j{mlK&v}1^*Km7`+lqKq4R$RWuneP5Xls zu6Ya`P*X)fdO#^OXdMF&$lP=WhF>6?K;~dgrROkG=^l`J%v73c0WuqGj^6(-SbYd} zlVaZgFGzl^Lp2X6{5_!Ik3Ic@N;VF~JO&;HaB2dlD{xwZny<&elb{5Si!acWYz49j zo|2hB;mClTlHWkm3nY{wsrqk)uEYN?5&m1&{r{3)1Wrlo{(niz0QnUZj^Hqi0+|c; zIc7dLa$5KQ14tf}W427lQ3A0Q^!|T<q&83*0G9_W2@H%8LF@j1NVo)20d?g9usxvE z{sUZ#8zeIPlv4ngRiNCXz@Y5Fz@pFqQl$`3!U!%)ITQlGp#n0INg?n552d{SKTzXV zNsoaixN%cM8Yo22<RRe?ZX3%W>jwFq;}C<KViO0bbX)<FD`D9(AvX=gg4qEzc>@PS zngyn~3M0oM26>PPAURN;Q*uxcM3~IO5;QSE1X)gT9Rm+o)GU$VhYG~!iXcCO{l&nc zn90BbsnrxR7+ByTkiozL3j-z&P<Ud7csj^;pnMOF3537XnG!%@cL7x&L>}B5FhP|8 z#UaSwL7)(ofXP99C9l}T12V17Yu*13`5`b_SbYF76&%{2@B+IBCI>SY98*#VolujZ zF~O(;k^#pA0|Pjv=?46NqoVi!%@&Z2Fkij_rB5Z~cFLQCTVOZ2f%JpI=V=4T7r~92 zK(S|lE{YO&V0R+i!NZaOF0Y{Nm=F1W(46}LUUKSzO2-Wo(%@kS)eR0G?5b55K<Q1P zDS;2>7D#FUsa9|ZnvkFY9xu@Q53MP_2SL^S0i`O4+MtP`_ARJRP|^GU0$O9e@OW+y z&O^vK{bwIiPKVX)Uy{ISfdx|Q1pNO4YEgspJOjfykZqt)Ma^5_+|0l*2QA+-Fm!>` zgTfi)^DP^ASkePvB9O8Gk`}-z44xJsGN6<IGB-&9qytn+fXqRaOJPc2O0WURW6CA7 zBrq^1fb=CW{Lj(N`~L@0H$h7ohW~mA49u`r1X6zRYDklThVc(jiycxXezgPjxDptc z;qij%k~BzK(EI-(cmt^Q3$9(Erh<F|a-)*o{|`?al?)^pAgzN<4QU3LHhsAQiEB{V z8Qi4n^#29Z29OClED#qk^?=L*`4>6QfI=!Q10fT%frA0YL%0+qg2fd&SX=>4%?b`` zARjeDTwnup0T;*|bQeJLQ9~L$Zz1dj$$?7>Er{PVK&G}pO!Z-bh-vBl{{Rt*0hJxg zV0J)Efus{~nE~o=fb)C_^OgxYE+vehJfABCa!*KuJ_91ozL<gYffCer&>ZsxoSq=5 z0F+)qYEbP0g*M2=;4%nHss!8d0c1}i!zXBL>FE9c5Y!g3AqNyjJP8a8&p^I{gf(hA z6l5|uESzwu0FT9dfcYhn;Zp%frGkSV$d2~V4K*-3nn3PW5eNdMk~a|lZ&>&LO&+Yi zeFGW~0`;hroGx`LIYxr}RKe^1ze%_RG7-gfpxUtkR{9{zmhfC@P;gQJmt|mid4(pB zyn;i>1fO>dfBs(pl`sqp3``7J3=AwH3``6~3=A9~x{85;3q&_DFz|!uE(Qi+5Iu>3 zK?p?8Vqo9{(Tf-uBtY~k1_p5uy@`QA3`Fl@V2~66n+zGD0}bU#LPqHr_!t-%c%f|2 z=p7FO0|N^K0|Pe$0|O%i0|O@m0|PT?Y!^DR2hz*Nz`!656$5DnsR5Y*(jy2O9%Eo& z;Ada}n=Jrk3o|e<fY>q&3=AMOpwU7Q7Gq#w0Lg*e2g0HZ3=AMF%fP?@l9PbiCC$LV z0Afpl2Dm|%GB7ZJ*dQiI4n%{@mSbRG0O<wsL2MAsz{<eh!@yt#($CJ$!1j=ViMayg zK28SKGf=iLD+4PZblhB$k%4&uSR(_2JUausC1`Y&fq_Ajm4UgAfkDlJfq_Avm4P{l zfk9~o0|SFKBLmwbsCp-M2G%0b2rvT!gEu1s3n;6Bq=H!)n3q7+$FnjpK4M@{+Qh)X zP|VK2tOpviWME*ZWMp7U11V-;U}$1w-~hQ7#O-2bU{PRTPzA-+OjZWAjSLK$Y77hv zD;XJBKyd_8v!0QG9b_Jey^WQDeGdbJZVLkg!!cF{Hctiy!yE<%hHH!rY^y;E7#JAt zF*2|&fwG@7GO*o%vfnW>Fjqp^UsxH~y%`uZ8yFZESy>s_Ll_t|XE87^in1~=_AoGL z3o$S-Dzh>$r!g>S?P6eHG-737+{VD59TJ~fl3G#15TBZoSdz#PpPHA#P+XE&1QMyp zEMbU`cZu|K^!0RRh|f*T%!A0qr{&})g5*-cN>cO6GK=!_7<`M%GfR>)7}CrvEG!J; zON&!e7(hdSpwX}Ry!@2Z_=2L$JdnQ3{3M3>__Unjq|!77h-ex@DO447+$=u1C^fMp zl_9>Mw4|6JzBoBC4@oU#C=H<(GMWZ*Y)(#oGDCbC*swH)_{5}qkf+j$Qd1GCGmBF} zLv#p%+|=Bp)FK2wC$YE$!Ar|5Lgway0uDYB5Aii9$$tUW?a;i$kPMBWQED^<MnhmU z1V%$(M27$~0}}%e0~3P^{!oy7!oVPTg@K77hJgt*3?q7hfk8}zfk7O$R)C#>L1GF6 z1ET|UEkOdP-Q)KYVrt_5|NsAgV_*Q&?-&@t^fLw~Fny1K8BAYeU;)$T7+AsdF$Oj; zy^nz%OmAc00MqLjIKlKX22gtvY=MJ@vZilxQHh~mv4WwVnSzCdzJZaxfrWx|enDlC zf}y2_sX}mRo`P>?GIUBCtPMfHT0#gB1_mZ9f^1C4Dn{9(Aut*OqaiRF0;3@?8Umvs zFd71*Aut*OqaiRF0;3@?8UmvsFd71*Aut*OqaiRF0;3@?8UmvsFd71*Aut*OqaiRF z0;3@?SVDjWv>+2SR}Wg#2wJ=eUB@U2VT0Ew%0k(ob&c9cY|9j|FO)#y?$9-6AdyTY zb~O@v5fXbh68k0+`#XZoD2T*1Mq-B{v5S$|{YdPENbD_0>@!I08wfTN8xq?LiS35O z4nktbBC(PD%T$CUj^uZyRwVHWNbK22?4?NTO-SthNbIvn?CVJEM@a0qNbDa7HZvm< zn;VHOio}*hVml+T{gBv^NbC$Gb|DhG3W?o}#O^_2Peo$SLt?K)Vk5;J^8+OD*9bNX zQrxkqA&DcWNd^}N25IQJSrA*Efk9~-D6zVL7py3|K-r2649Wpewh{w_atxHM!oZ-M z1!b!-FevYWvK1H@l#fB#nhXre=b&sY1_qTVC|jF>LFEMl14|r|+mO;K%SnVdD<2YD z9<nG0wAPo^43x<r>!w-lKx+Q~|Nn=9fz=7h{=vY&>H%7z4_W)n>iGa<IRldih;m_I zFodoF2Kn8Dfk73tej3C!WnfSRTjRpOV8+0pY6ewr&cL8*2W49@FsQ=Jv1DLSg@unb z1A}TDRE-S-gX$Xw239YyVc_+~tT9M#PKUY^<mNnxJDG|Y7+CWm?qv3Xn&SjrBMow! z8v}!y4OHBnfkDj;%JyJjP=mR_i-AEc0xIs!z@P?;FMkFGHSl_97Y2p^1_m|Ii5DO< zgBTdp)<D$<Gcc&Z;xUAQLG1)oJd}Y!?E;h?!N8z)4a$yWU{HGkWk)eEsC|O6qZt^~ zenHuB3=HZZCdjUM1_pI-@#?|=T6U|>0g`ZGU`S(NPzSGFa$#UdXJAkVtvv^+&t_my z2d&Kpv2z$0)O8pbSPLNG30gPKT7eXXbx<}a-n$^-$vlUFfwdbd{+)q=6`a5R|NsAq zfq`{4RLwC42G%){FlT9EU|^jKW%n>Ju+D>&?dk>$46G}V*xMlGJXrhy$b67L7#LWQ z${beM8e;|q1~zGg8a5LoHd6V?R)8elg~VQi#6FM2euH4Mb0D#$kl4CNY*!?9AQHPC ziM<|)ja0_6pGFeDhQvnlFFR8C!;a*4_J0WV9GpmO5hS)85?dRIZGpr_s&_a7ki?^r z*l9>?q_UR-sqE!wK~mF)#GZ!4-h;$Gj>Nu%#D0jxeuc#TjKuzfU~{q}v60F&PH`l0 zB_uXd+;Jk+FPtezYLMcNb3T$dQkvwv4o$aSpfu_N&W!3XwiW|}x*t?rn}I<cR#xaR zFsOr*xC;Y=E(3!)XnzMN4;nBqsDrJ6l%MKtP`$<s4C;MQwh04+`ZNXxPNek7g;a-f zg@X+MDQ4iBgT!77$=4vaaUBJTL&|fmGmw1BAjiPKbrzC0LFEP4IjFy8fsArtU~pn! zP=~Qy85q<TLB-t|7}U2w*&y*#P_{b*gF38C^I%|5zXuifWMEK#!oa}w9O|A~3=G_` z4J;fC4BXt%GMtBjfm;O17GPlD2Ip~zo4MtoZZ2S8;8uXTc?$yrw<6TdZ=iNXGBBva z*s%-@>ffN^aSRL^u<|gLfk6Z86c+}Dcm@UyEvT9#1_liSC_9;fK?Agp1{6mr3=A5u zdMcHHK?4@oX$%Y+K~VJ>3=A5uxXxr?(16wBSquysu(-})V9;oSs?TF!(CA}e;5G+4 z1ng$+0I1(VVG<2xgTf>Q$_9l=5tJ>$z`zY|`$5B}9vVJJ7#O%4AmPIp$H2hd2ninz z&^{oLUuqZ_;Oqtl290@8_cSsvXe@)Wn-~~0VDa0+z@V`YD&ES#paF|tkoXIzcsm1w z#ycpxgMmTgAC%q2z@Q1Mo4OeoG(r2PKyK(^V9=CfVBnq#@jJ*p+-soz0{MM2lnwIx z9w-~+cce7TeG!_Te=sm`UxoOcF^_?P`x?~mF!#)a?nMIGJBNWm6BgHV85lHS@jH)! zK@+?W%7uYpJ_Cbh2-N+H7#K8Rak`j+K{E*|zJ!566BfVA7#K85pyJCJ7&L1b7`U%P z`~}(r#SJdUpmFp8>ds#b4BQ_f?qq_sNkDt1Kwbj5a}xuDCTMRIh`pJCL30`d1NSGW znGFmKJZ#V~fz|c<Ap4#eK<bY$Fld6MT^JaSGB9Yu+9Agn7&H$--Fbq6K@-*vImy7F z35(NH3=Ep!eO4|E45t|wG+}w?90P+E%&zkc3|ipz*e(nVmlzndU~P#j3=CSZFucmZ zpj8I7>ly=tRuz<egMmQ{=Es{13|f<*;-?uHw5CDX_ZS$oU}^FJ1A`XK{SO%!v^Fs? z@bE&zVHN`ej{?}E3=A9$3_R*kHV*>>j~>VpNSO1OLfJnU7<g=;>@N%qJPwe!U@Bl> z;Bkb+1v4yfet_&31Bd5l1_muy`v1bfpapAte`8?Kx&n3ccLoM6SYG(Sz@P<dv;AaX z(1PWK-wX`eu)Oe>fkB&(fq};f;up}~G@f9n`$2w*g1Yk$0|QSI#GTB23=BNUP<KMh zRnWP5pgnFNcQW!ZFldWG+{4Jvz@QC{7e+w_25lXvxDW$_Hni={D8j&?9l*fAlLB!A z$Q+&$BsU<HEj-OoH#}ot;Aw%l0kq!_Y_9@nKONM3bp{4)Xn%xJgMmRCnnxHl85p#o zd4y4mfkC?ts$Q3YK^s~wG3qfeXhZu-jQR`=+DD*j3>g@-q3M&+lz~AT8s>~<3=G=P zw907Cz@QCnGc#H+Fla-=oY9hjK?j;{8SNMtbfD!AqdfzI4tVdS3wSSq4mb#07#JNH z7<BZY_Bt~#=)l6tg@Hi_nok*B85nfJplaM17<8b06Gk5f1|67xeHj>ZilA!z7#MV* zd4bWNfk6l6_W%Y4ojFi7K@1E!>!9pl1_m8yUym__fk6ix+%61^p$rT<ub^te7#MWE zK-p0Y3_39XMl&$zg7;*)Ffhh2FzCYEAIrd?3(cFLIzbm&e=#O7Fz7<dI>sah23=@b z#~8rCpql_SKb?U=Hv`JfVqnmP`6ZiyLAQp1fu|K5cnsPh3=BL|k<!l`C>xX?7bB(T zRZuo4KZ3^}{{R0E%8%P1X^cgSfq`c`*wYMburM!!?iFQlVPLFfV9@P?x~HCjL3aw2 z-N3-03%1gQfw7T+K^MH&)P;euiGe{E+W%r~W?;|-TjRpO*uub|dk3nwm4QJQ+Gb#E zV_?t&SD6qsda(4<$-tlo+TRLtLq7w99(ZrB3j^Z>1_nKF5V$ZfPG(@xgVryMQy3WZ zU|~L$fk6)z<}(-=^k8{p76XGGEd9@6V9<lsxs3A|81$fJ4&wp_20duskZ~acgC4YO zVO-3>pbvA;3I+y!m>X6yFz6dW{k4jLK_BLZ)eH>!u<%^Vz@QIv!&U|ceOMaa#=xKt zEt45{F)-*u%VfsA3=H~bpk^LnV9<x<wc`v71~7Y1GB6lG+enOO7#Iv-{yodUU;s;3 zAaPi}ILE+X0BsjBo@Zb%fW_kl1_lFIUbw`-U;rxzE;BF~z~bl%c&LE^T>e~RU@(N% zM~pWa7z|<g_W=WgA+&yHe8|9H2pwBse8#|F2us_~85j&x7#MhVfIR`;kIZu#oQNQG z$|Wcpl!n3MhtN6&JVx~Y|9?;#egRF-pfn8br~Lo_{{sU94|t66|NsAQ7#MhdgA*MC zTNDEW&mTzI<}!hX=O^giXHdHO$-rO;D<^+5Fc`whia!hthOjjMmw~|$T0b)WXJ9ad zw#h+zh74Ch%mi&JGK7X96B7f2A+%g&VrF14gqEL7><kQs&!Fl#7#NJ8;lsqkz+eQ8 zJ0@NR1|w*j2c*{sI@ZA?z`$UX2h}Ucz+eP*Gm|g_gAue2Ws+iGFoO1Fm}D3jjG$#5 zlL7;S(GI9yB?bl~XxYxB!oXkz&5ulK3=GE5x{^tqfx#G>*O;^z7>uo;dUY5WjG<*0 zlO6+uG0dF?3=GCSP&I}O494InbYWmJWneJg0~I%CU@(TZZI~<=7)+r30wx;<1`}vn zVzOmmFoD_Sz`$SvP1{V43=Af)uyST#FoBK{F}X7^m_W;a(0G^$w9Uih$-rO&ZObwF zGccII+!n;ZV6p=0o?r$B6KH#kDU^Z11e`=%7?>g%7)(JC%izMm6ve<`3a!VP;u#oB zp<{_m2@DLT(EJ4!hvq4!L<R;^X!>DFVqh?Zg?};wgDET=(is>`k1#Os{Dq`{&>nnV z0dRnU(?72`l+DAyzzZHvfTVw3@c1Vr{qw@wT3;9#crBrM;R6E$uPv1QhJk_C5t9D7 zTo@R5oxq-B;G4q0!0QYyXc<f|Ffj0XBF;eI4M3cMz#EP@1A#XNaRvf!65^}_-VDT9 z2fQVS^9^`w5oa3kb|TI+;GK&&(|~s|;_L$6O^CA#cn=}YDB!(>IHQ2~5#r1N-p`0L z2l$u~XAbZQBF-G(Q-Ga0z`($#hd5XObWW{aJ_BS!VLn4iYH<m4>%U$;Lwa&@d~$wn zL1s>BiXMtwGDBuwiB*ZAZIPk1u92aMxrv3bnTdrpoM~>&kercNWL08hTV!NyU~On* zZq1OBpO>xx)@Y1RV`*M-W_n&~3Ph<1NU4Fft|3%Es;ntOwm2ids05<N3?!;+Y-Da` zVGSZ-b|V~M4pIRz6`~K-SPO`>nW?F<Db!xDUQ|_<5LF<jL0t^-v!MY<Lf6p90^)DD zE~qp(*bJ<VOiisBz^6G_l^7a<w3t{MSTm&LmnP+;T9p`r1IYp;1hyM44h|8pcv*gC zidBiBsjZ<YLwsg_QfZo1h@qKnv5`T1a$bp*p^kx$v5|FrK}nI7p}DP=p`nhk5lAG4 zAwDUwIMvF~T*u4=BoLoenpT`yWo4*iX$Iz}<s_zCndulBS?Cy=S;sKMr)B1(S{dmW znwaQVSX(m`XQmgYmc)b707G#>YHA9IX~IyF4AKZ<n=&LPgJ?rThJsA6tRX`#=opF; zs}c)_yqwIuY>>1WLvl`jGMH)1P?DLO3KBGCh>wpi&a47+3>gYaic&Ju(m*nXAenMd zFoJj%3@}Be3~)hXhSGSD0;>{3Lx$3LaO{GtER6@JJQIe}cu;U!m6$S=A|#=5@r9*{ zAjgInTG$p_lqKd^8Cu#V78!z4u(h#{fsUDpwKW4&QHh}iLrP*wN)gB{#tg|YrjdcI zmJvf{UOq_Nlp!Ux48$;F$cOmBn4uIBAQlYiFh+K2B}k1i1Huf3w3PVV#NuqL5@Qgv zIJLwo#K_RL*w`p7r8qt*v!vL{$O!5-bFkZtOwFvVVQNc^3>lpA^K-09jErql-5h;_ zU9AjsLV`kFtqgUn8G=iblT(X}txAkcY*YQctqe_d+#Ef9LW5jEiNcz}4{~lU_~a0) z5+hUFiehNF01<*IuqrV!L&#Y%Kowbq7=e=^_|Oh3BXe6VBU4CX1Rd&OWn>Odh#)@b zoDwTjXi|g-<fo*9R6$ZBSSS;8da;!uI7u2CSzE)bg19Hd$kevj$Re*a7i3scYEdyP z_2-p>P8BJ(GO~aMmWj0~$aX_B1M3(D&@mz)iwrHn83WZ+$l)kfZic1|c{zDj1xDr! znO24%i>*u<7(g`mbQSO^Cs0*Z1xA*(T1IAI4Mye+3=E)?Tddp+8S-+hj4T<_GV?Nv zGg4EmjEor=VCM`Qfs6th31WcE#3+2B;i@-U@Pg`{(Smoh;DwcxqXjScd~;B-2P!$h z#Ubq2CTOWKOiE+OSyWbOM&^jp71i621F1k_u!0m490+l%G~~h@T%{C1O7sF#aN*8? zIB^PmYF0{W4yJifL8xJfG9OfHfoh3@qSP|5&5$|+W(}zFKsUd*ASbf~)wN(DB(oVn z4nZ|3FSQ(EKD0_gR7TK1ax=1o);I_$=z&{SZbrr+xdM<9Xf+QxdJ9d)ssK{&8JUCc z53qs-5HwZALn?PSkRnhJFhKaoH6y6vwn8WXbHSA&%m{Gxi%^hPnu}y9w8n=<3rq_n zE|IERP~aiyf>{EhK{01#2sR+g$`Gl_hMZJ}-4H`7NCGng(O6B%%umwGXTW`U8>q@h zJ**9ON*m;yGJ>bG!TbttSs)T5ByJIWNKhd75MLqq&<IBeK%yDJ2l)=c1IHhN3yK@i zz`!UT4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@R7!85Z Q5Eu=C(GVC7fk7Gq0IWWazW@LL diff --git a/src/server/.cvsignore b/src/server/.cvsignore deleted file mode 100644 index d6013570f..000000000 --- a/src/server/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -Topdir.make -dependencies -com.h -fncdef-no-str-limit.txt -fnc-def-init.incl -prot-a-parse-arg.h -.gdbinit -prot-a-parse-arg.c -call-switch.incl -dbck -lyskomd diff --git a/src/server/ChangeLog b/src/server/ChangeLog deleted file mode 100644 index c0a03bd53..000000000 --- a/src/server/ChangeLog +++ /dev/null @@ -1,1295 +0,0 @@ -Thu Jun 11 16:28:39 1992 Per Cederqvist (ceder@lysator) - - * vercion.incl: Version 1.2.3. - - * server-config.c: Timeout set to two minutes. Cache size - increased to 20 elements. - * simple-cache.c (dump_cache_stats): Also report the cache sizes. - - * missing-ansi.c (strerror): Return a const char *,not a char *. - - * connections.c (login_request): Don't dump core when we can't get - the name of the originating host. - -Wed Jun 10 03:36:30 1992 Per Cederqvist (ceder@robin) - - * ramkomd.c (main): Log version number and pid when starting a new - server. - -Sun May 31 03:08:31 1992 Per Cederqvist (ceder@lysator) - - * version.incl: Version 1.2.2 (not released). (Note: a bug in - isc-0.97 has been fixed since 1.2.1: malloc() was used instead of - isc_malloc_wrapper to allocate the kom_server_mcb). - - * lyskomd.h (kom_server_mcb): Removed duplicate declaration (it - was (and still is) also declared in connections.h). - - * handle-malloc-dump.el: Added (require 'elib-dll). - -Mon May 25 22:56:38 1992 Per Cederqvist (ceder@lysator) - - * ram-smalloc.c (tmp_alloc): Don't log the size of the internal - table anymore. - - * version.incl: Version 1.2.1 (not released). - - * server-config.c (TIMEOUT): Increased from 100 ms to 5 seconds. - With isc 0.97 that should be no problem! - - * connections.c (toploop): The timeout is initially zero, so that - the garbing starts right away. - - * connections.c (login_request): Fix so that the server can tell - the difference between a mux and a client (using num_ip_*_port) - (The bug was introduced with the isc upgrade). - * lyskomd.h (listen_client, listen_mux): No longer exported. - * ramkomd.c (listen_client, listen_mux): Now static. - * ramkomd.c, lyskomd.h (num_ip_client_port, num_ip_mux_port): New - variables. - * ramkomd.c (server_init): Really use the IscConfig struct. - * ramkomd.c (server_init): Log which ports lyskomd listens to for - clients and servers, and set num_ip_*_port. - -Sat May 23 19:57:17 1992 Per Cederqvist (ceder@robin) - - * text.c (add_comment, add_footnote): Disallow texts to be - comments/footnotes to themselves, since that would trigger a bug - (the misc-list that is created would be erronous. A proper - misc-info-list handling package should be written instead. - -Tue May 19 01:06:50 1992 Per Cederqvist (ceder@lysator) - - * Makefile (tags): Search libraries/libisc-new. - -Mon May 18 23:27:04 1992 Per Cederqvist (ceder@lysator) - - * connections.h (Connection): Added the boolean field - username_valid. - * internal-connections.c (new_client, EMPTY_CONNECTION): - Initialize it. - * prot-a.c (prot_a_parse_packet): Use it to test if username is - set or not (instead of just assuming that an empty username is - unset). - -Thu Apr 16 00:46:50 1992 Per Cederqvist (ceder@lysator) - - * Use isc-0.97: - * Makefile (LIBS): -lisc-new instead of -lold-isc. - * Makefile (GENOBJS, GEN_SRCS): Include isc-malloc.[oc]. - * isc-malloc.[hc]: New files. (Compare string-malloc.[hc]). - * Various namechanges: - ISCMCB -> IscMaster - ISCECB -> IscEvent - ISCSCB -> IscSession - - * Use isc_destroy() instead of isc_close(). - * isc-interfacs.h: Include <isc-new.h> instead of <isc.h>. - * lyskomd.h (listen_client, listen_mux): Now (IscSession *). - Updated all references. - * lyskomd.h (kom_server_mcb): Now declared here. - * ramkomd.c ("isc-malloc.h"): Include instead of <isc-dump.h>. - * ramkomd.c (server_init): Use the new configuration scheme. - (Needs som further investigation). - * ramkomd.c (dump_exit_statistics): Don't - dump_isc_message_counts() since it doesn't exist. - -Wed Apr 15 19:52:20 1992 Per Cederqvist (ceder@lysator) - - * connections.c (add_to_kill_list): Check if the connection - already was on the kill-list. If so, print a diagnostic and - return. - -Tue Apr 14 17:21:26 1992 Per Cederqvist (ceder@lysator) - - * Version 1.1.2 (not released). - - * 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 - sfree when the kill_list is empty. - -Fri Apr 10 13:46:41 1992 Per Cederqvist (ceder@lysator) - - * Since lyskomd spended 25% of the time in check_kill_flag it was - rewritten. Instead of having a flag in the Connection that is - checked once after every atomic call a linked list of connections - that shall be killed is created. - * connections.h (Connection): The field kill_me deleted. - * connections.[hc] (add_to_kill_list): New function. - * connections.c (kill_list_size): New variables. - * connections.c (check_kill_flg): Rewritten to use the kill_list. - * internal-connections.c (EMPTY_CONNECTION, new_client): Don't try - to initialize kill_me. - * session.c (disconnect): Use add_to_kill_list() instead of kill_me. - -Thu Apr 9 00:15:33 1992 Per Cederqvist (ceder@lysator) - - * Version 1.1.1 (not released). - - * Lyskom used to spend 60% of the time in limit_text_stat. With - the changes of today it has dropped to 0.1%. - - * disk-end-of-atomic.c (end_of_atomic): Call limit_cache_size only - every 100 rounds. - - * conference.c (unique_name): Fixed bug. It was previously - possible to create a conference with the same name as an already - existing conference. - - * simple-cache.c (throwable_p): New function. - * simple-cache.c (limit_pers, limit_conf, limit_text_stat): Use - throwable_p, and get the condition right. - -Tue Apr 7 16:48:54 1992 Per Cederqvist (ceder@robin) - - * session.c (login_old, login): Handle visibility flag correctly - when an implicit logout is performed. - - * prot-a-output.c (prot_a_output_who_info): Removed erroneous - bugfix. - -Mon Apr 6 23:11:29 1992 Per Cederqvist (ceder@ruben) - - * session.c (who_is_on_ident): Fix malloc bug. - - * session.c (who_is_on, who_is_on_ident, who_is_on_old): Don't - return invisible sessions. - -Sat Apr 4 19:24:27 1992 Per Cederqvist (ceder@lysator) - - * person.c (get_person_stat): It is allowed to get the person - status before logging in so that it is possible to print a "last - login from:" message. - - * ramkomd.c: Include "getopt.h", not <getopt.h>. - - * person.c (create_person): The newly created person always logs in - visibly. - - * kom-types.c (EMPTY_SESSION_INFO_IDENT, EMPTY_WHO_INFO_IDENT): - New constants. - - * Makefile (LIBS): Use LIBRESOLV and LIBIDENT. - -Wed Apr 1 22:02:55 1992 Per Cederqvist (ceder@lysator) - - * Code to allow invisible sessions: - * connections.h (Connection): New field: invisible. - * session.c, fncdef.txt (login_old): New name for the function - login(). - * fncdef.txt (login): New function with a parameter for invisible - use. - * session.c, fncdef.txt (login): New function with invisibility - support. - * session.c (logout, pepsi, change_what_i_am_doing): Don't send - asynchronous messages if the session is invisible. - - * Code to allow user identification using the Ident protocol (as - defined in RFC 931): - * connections.h (Connection): New field: ident_user. - * connections.h (Res_type): New types: rt_session_info_ident and - rt_who_info_ident_list. - * connections.c (login_request): Set ident_user. - * fncdef.txt (who_is_on_ident, get_session_info_ident): New - functions that behaves like who_is_on and get_session_info, but - also returns the ident name. - * internal_conections.c (EMPTY_CONNECTION, new_client, - kill_client): Set/free ident_user and invisible. - * prot_a_output.c (prot_a_output_who_info_ident, - prot_a_output_who_info_ident_list, - prot_a_output_session_info_ident): New functions. - * prot-a.c (reply): rt_who_info_ident_list and - rt_session_info_ident: New reply types. - * session.c (login_old): Generate the a proper (but not - 1.1.0-compatible) string in username. - * session.c (who_is_on, get_session_info): Generate username. - * session.c (who_is_on_ident, get_session_info_ident): New functions. - - * prot-a.c (prot_a_reply): Free username when returning a - session_info. It is allocated in get_session_info() in session.c. - * prot-a-output.c (prot_a_output_who_info_list): Free username - when returning a who_info_list. It is allocated in who_is_on() in - session.c. - -Tue Mar 31 23:48:47 1992 Per Cederqvist (ceder@robert) - - * rfc931.[hc]: New file. - * Makefile: (GEN_OBJS, GEN_SRCS): Use it. - -Tue Mar 24 18:05:18 1992 Per Cederqvist (ceder@robert) - - * simple-cache.c (save_one_text): Check that the entire file made - it to the disk (compare wath ftell() says after fclose() and - fopen()). - -Mon Mar 23 08:51:13 1992 Per Cederqvist (ceder@robin) - - * dbck.c (truncated_texts): New variable. - * dbck.c (main): Increase modifications if truncated_texts is set. - * dbck-cache.c (init_cache): If the database is truncated or - severely damaged in the text-status part, just ignore the remaining - texts (and don't fail miserably). - -Thu Mar 12 04:30:17 1992 Per Cederqvist (ceder@lysator) - - * membership.c (get_unread_confs): You must be logged in to use - this call. - -Mon Mar 9 16:33:45 1992 Per Cederqvist (ceder@robin) - - * DATAFILE_NAME (server-config.c): Added a comment. - -Wed Feb 26 19:49:21 1992 Per Cederqvist (ceder@lysator) - - * various: Lint from gcc 2.0 deleted. - -Fri Feb 21 01:45:35 1992 Per Cederqvist (ceder@robin) - - * server-config.c (SYNC_TIMEOUT): Decreased from 10 millisec to 0. - It takes some 2 hours for the server at Lysator to save the - entire data base, and that is a bit too long... - - * dbck.c (main): New flag: -s. Prints some extra statistics. - - * dbck.c (print_statistics): New function that prints statistics - about the lengths of texts. - - * prot-a-parse-arg-c.awk: Fixed a syntax error. (gawk could - handle the file, but awk could not). - -Sun Jan 12 02:30:34 1992 Per Cederqvist (ceder at lysator) - - * prot-a-parse.[ch] (prot_a_get_token): Then function is now static. - -Sun Jan 5 19:10:20 1992 Per Cederqvist (ceder at lysator) - - * dbck.c (main): Tell the user why no compression was done if he - specifies -g and there is an error in the files. - - * dbck.c, ramkomd.c (main): Better usage messages. - - * simple-cache.c (init_cache): Slightly better log error message - when the text file can not be found. - -Wed Dec 18 00:05:43 1991 Per Cederqvist (ceder at lysator) - - * Version 1.0.4 was never used. Version is now 1.1.0. - - * fncdef.txt, prot-a.c, text.c (find_next_text_no, - find_previous_text_no): New functions. - -Tue Dec 17 00:52:11 1991 Per Cederqvist (ceder at lysator) - - * prot-a-parse-arg-c.awk: Fixed bogus parsing of argument to - get_last_text. - - * prot-a-parse.h, prot-a-parse.c (prot_a_parse_time_date): New - function for get_last_text. - - * text.c (get_last_text): Rewrote it. - -Mon Dec 16 15:32:57 1991 Per Cederqvist (ceder at ruben) - - * conference.c (is_supervisor): New arguments: viewer and viewer_p. - - * membership.c (access_perm): New parameters: viewer and viewer_p. - - * admin.c (broadcast, send_message): Don't forget to check the - length of the message. - - * text.c (create_text, create_anonymous_text): Fixed error in max - length comparison. - - * All the changes below fixes one single bug. When a text is - created that has both a secret and a public conference as - recipient the asynchronous messages that were sent out did not - filter away the secret conference. This has how been fixed. - - * membership.c manipulate.h (fast_access_perm): New arguments: - viewer and viewer_p. - - * send-async.c, text.c (is_member_in_recpt): Moved from - send-async.c to text.c. - - * send-async.h, send-async.c (async_new_text): Sends to a - specified connection. - - * text.c (create_text, create_anonymous_text): Use - send_async_new_text. - - * text.c (send_async_new_text): New function. - - * text.c (get_text_stat): Use filter_secret_info. - - * text.c (filter_secret_info): New function that given a text-stat - and a person number yields a new text-stat that only contains - tha recipients that the viewer is allowed to know about. - -Mon Nov 11 01:08:09 1991 Per Cederqvist (ceder at ruben) - - * fncdef.txt, prot-a.c, text.c: Added create_anonymous_text. - -Mon Nov 10 20:00:00 1991 Linus Tolke T (linus at ruben) - - * fncdef.txt, prot-a.c, text.c, call-switch.awk, cache.h, - connections.h : Added get_last_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 - (Priv_bits): The flg7 field has change name to extern_gw. - -Tue Oct 29 03:52:34 1991 Per Cederqvist (ceder at robert) - - * Makefile (tags): tags does not depend on anything now. - - * Makefile (HDRS): isc.h should be isc-interface.h. See note from - Sat Sep 21. - - * Version is now 1.0.4. - - * internal-connections.c (no_of_connection_attempts): Now a global - variable, so that dump_allocated_connections can write it to the - log files. - - * ramkomd.c (dump_exit_statistics): This function, which is only - run when the server is brought down nicely, writes some - statistics to a log file. The log file is now open in append - mode (and not overwrite mode...) - -Mon Oct 21 23:14:22 1991 Per Cederqvist (ceder at robin) - - * text.c (create_text): Check that the length of the text is no - greater than TEXT_LEN. - -Wed Sep 25 11:44:17 1991 Per Cederqvist (ceder at lysator) - - * person.c (do_set_passwd, chk_passwd), - ram-parse.c (fparse_conference): - Use string_free and not sfree to free strings that was - created with s_crea_c_string. - - * person.c (do_set_passwd): Fixed serious bug in salt generation. - -Mon Sep 23 19:39:55 1991 Per Cederqvist (ceder at lysator) - - * text.c (sender): handle a sent_at correctly. - -Sat Sep 21 02:12:24 1991 Per Cederqvist (ceder at lysator) - - * "isc.h" is now known as "isc-interface.h" to avoid confusion - with <isc.h>. - - * version.incl: Go 1.0.2. - - * ram-smalloc.c: Added support for memory leak finding. - - * trace-mem.gdb, handle-malloc-dump.el: Useful for finding memory - leaks in the server. Compile ram-smalloc.c with DEBUG_MALLOC - defined. - - * mux.c (mux_close): Fixed memory leak. - - * ramkomd.c (main): Print how many blocks isc allocates. - - * ramkomd.c: ip_client_port and ip_mux_port are local to ramkomd.c. - -Tue Sep 17 23:04:39 1991 Per Cederqvist (ceder at lysator) - - * .gdbinit: Now created by "make .gdbinit". - - * Removed smalloc.c that is never used. - -Mon Sep 16 19:27:04 1991 Per Cederqvist (ceder at lysator) - - * version.incl: Version 1.0! - -Fri Sep 13 22:20:59 1991 Per Cederqvist (ceder at lysator) - - * server-config.c: Det heter lyskomd-data, inte ramkomd-data - (osv). F|rb{ttrade n}gra kommentarer. - -Thu Sep 12 01:00:13 1991 Per Cederqvist (ceder at lysator) - - * ramkomd.c (main): Anropa srand() om ENCRYPT_PASSWORDS {r satt, - s} att vi f}r ett slumpm{ssigt fr|. - - * person.c (do_set_passwd, chk_passwd) Kryptera l|senord om - ENCRYPT_PASSWORDS {r satt. (Inkompatibelt med gamla - databasformatet). - -Tue Sep 10 21:58:18 1991 Per Cederqvist (ceder at robert) - - * conference.c (delete_conf): Om det {r en brevl}da som tas bort - s} ska personen som tas bort loggas ut f|rst (inte n|dv{ndigtvis - personen som tar bort en person...) - -Thu Sep 5 10:14:40 1991 Per Cederqvist (ceder at lysator) - - * cache.h, simple-cache.c, dbck-cache.c (cached_set_conf_type): - borttagen. - - * conference.c, person.c: alla anrop till cached_set_conf_type - borttagna. (Funktionen anropades bara precis efter - mark_conference_as_changed. - - * simple-cache.c: Fixade lite stavfel. La till lite nya defensiva - kontroller. - - * simple-cache.c (mark_conference_as_changed): Uppdatera inte bara - first_local_no, utan {ven nice och type i small_conf_array varje - g}ng som mark_conference_as_changed anropas. Namnet uppdateras - dock inte. Det kostar nog mer {n det smakar (man m}ste - reallokera en str{ng n{r man {ndrar namnet). - - * simple-cache.c (get_text_node, get_pers_node, get_conf_node): - Returnera NULL om det s|kta numret {r st|rre {n next_free_num - eller next_text_num. Defensivt ska det vara! - -Wed Sep 4 22:03:47 1991 Per Cederqvist (ceder at lysator) - - * text-garb.c (garb_text): Nollst{ll deleted_texts n{r garbningen - {r klar. - -Sat Aug 31 22:14:30 1991 Per Cederqvist (ceder at lysator) - - * ramkomd.c: Inkludera alltid <locale.h> - gcc -M f|rs|ker - inkludera den {ven om HAVE_LOCALE inte {r satt. Skicka med en - tom locale.h i include/ansi f|r de som inte har locale. - -Fri Aug 30 05:32:13 1991 Per Cederqvist (ceder at lysator) - - * config.c ramkomd.c (MAX_NO_OF_CONNECTIONS): S{tt fr}n - getdtablesize om det anropet finns. - - * limits.h heter numera tmp-limits.h (f|r att inte f|rv{xla den - med ANSI-filen <limits.h>. - -Wed Aug 28 03:21:27 1991 Per Cederqvist (ceder at lysator) - - * dbck.c (post_check_persons): Uppdatera modifications {ven n{r - man reparerar antalet skapade m|ten f|r en person. - - * La till RCS-Id i alla k{llkodsfiler. - - * prot-a-parse-arc-c.awk: "smalloc.h" heter <server/smalloc.h>. - - * dbck-cache2.c heter nu dbck-cache.c. - - * cache.c, end-of-atomic.c, lyskomd.c, ram-cache.c: Borttagna. - -Mon Aug 26 04:13:34 1991 Per Cederqvist (ceder at lysator) - - * simple-cache.c: Anv{nde BUFSIZ i st{llet f|r FILENAME_MAX. - - * #include "smalloc.h" heter nu #include <server/smalloc.h> - -Sat Aug 24 17:36:43 1991 Per Cederqvist (ceder at lysator) - - * simple-cache.c: Anv{nde FILENAME_MAX i st{llet f|r 1024. - - * limits.h (MAX_TEXT) |kade till 200003. - -Wed Aug 14 02:11:17 1991 Per Cederqvist (ceder at lysator) - - * Makefile(LIBS): La till -lresolv. - - * config.c(WHITESPACE): La till \r. Det g}r inte att koppla upp en - telnet till server version 0.31.6. - -Sat May 18 04:22:06 1991 Per Cederqvist (ceder at nanny) - - * Installerade och startade diskomd 0.29.1. - - * Div. bugfixar i diskomd och simple-cache.c. - -Fri May 17 06:00:00 1991 Per Cederqvist (ceder at nanny) - - * Installerade diskomd 0.29 som ramkomd. - -Wed May 8 04:43:50 1991 Thomas Bellman (Bellman@nanny) - - * conference.c (set_super_conf): Fixed bug that made it impossible - to set the super-conf to zero. - - -Mon May 6 09:34:00 1991 Per Cederqvist (ceder at nanny) - - * Anv{nder funktionerna i memory.h s} l}ng m|jligt i st{llet f|r - smalloc/sfree. - - * Nu har servern tv} kopior av namnet p} varje m|te. Dels en som - alltid ligger i minnet (name_list i ramkomd, small_conf_arr i - diskomd), dels en som bara {r inladdad ibland (i diskomd), - conf_arr. - -Fri May 3 14:49:19 1991 Per Cederqvist (ceder at nanny) - - * 0.28 installerad. - - * Anv{nder traverse_connections |verallt d{r man g}r igenom alla - uppkopplingar. - - * Ny fil: internal-connections.[hc] (i brist p} b{ttre namn). - Inneh}ller new_client(), kill_client(), get_conn_by_number() och - traverse_connections(). I forts{ttningen skall man inte anv{nda - sig av f{ltet (Connection *)->next, utan i st{llet anv{nda - traverse_connections() och get_conn_by_number(). - - * Nytt anrop: who_am_i som ger en Session_no. - -Thu May 2 17:24:50 1991 Per Cederqvist (ceder at nanny) - - * St{ngde av TIME_SYNC i ram-cache.c. Nu kanske n}gon orkar l{sa - log-filerna igen... - - * Nu kollas flaggan kill_me i Connection i _alla_ uppkopplingar - efter varje anrop, s} nu b|r disconnect fungera. - -Mon Apr 29 19:02:12 1991 Per Cederqvist (ceder at nanny) - - * Namnbyte i Who_info och Connection: session resp. client_no - heter numera session_no. - - * Ett nytt asynkront meddelande: logout. (Pers_no & Session_no). - - * Tv} nya anrop: get_session_info och disconnect. - -Mon Apr 22 14:32:19 1991 Per Cederqvist (ceder at nanny) - - * version 0.27.2 installerad. - - * Nu skickas sessionsnummer med n{r man g|r 'pepsi' och - 'change_what_i_am_doing'. - -Sat Apr 6 11:47:47 1991 Per Cederqvist (ceder at nanny) - - * version 0.27.1 installerad. - -Sun Mar 24 18:49:56 1991 Per Cederqvist (ceder at nanny) - - * parser.c: lookup_name(): Nu tas alla '-' bort - |kad - QZ-kom-kompatibilitet! F|r tillf{llet g|rs det bara om SERVER {r - definierad (f|r att inte riskera att f|rst|ra kod i klienten). - -Tue Mar 19 20:27:45 1991 Peter Eriksson (pen at nanny) - - * connections.c: logout_client() om CONN_MAGIC_FREE, skriver - nu i logfilen, och g|r return omeddelbart - snabbfix f|r - att servern inte ska krascha s} ofta.. - - * version 0.26 installerad - -Mon Mar 18 11:28:46 1991 Peter Eriksson (pen at nanny) - - * config.c: DEFAULT_CLIENT_SERVICE_NAME = lyskom-client - IN_CLIENT_PORT = 4896 - - * version 0.24 installerad - -Mon Mar 18 09:12:59 1991 Peter Eriksson (pen at nanny) - - * connections.c: mux_handle_packet(): mux->parse.string nollst{lls - nu efter att den har tilldelats till cp->hostname... - - * version 0.23 installerad - -Mon Mar 18 01:56:50 1991 Per Cederqvist (ceder at nanny) - - * send_message: ny funktion och asynkront meddelande. Ers{tter - broadcast. Broadcast finns kvar f|r bak}tkompatibilitet. - -Sun Mar 17 23:49:28 1991 Per Cederqvist (ceder at nanny) - - * mux.c: mux_flush(): om uppkopplingen var av typ MUX_TYPE_CLIENT - s} gjordes inte isc_flush. - -Sun Mar 17 03:50:23 1991 Peter Eriksson (pen at nanny) - - * connections.c: logout_client(), snabb fix f|r ett - problem som medf|rde att mux_close() anropas tv} - g}nger n}nstans (tror jag), och cp->mux var d} - NULL andra g}ngen... - - * Version 0.21 installerad - -Sat Mar 16 00:03:29 1991 Per Cederqvist (ceder at nanny) - - * Simpelt mux-protokoll implementerat. - - * change_name(): Nu kan man byta namn fr}n "foo" till "foo". - - * Version 0.20 installerad - -Tue Mar 12 02:16:12 1991 Peter Eriksson (pen at nanny) - - * server version 0.19 installerad.... BUG fixad i ISCLIB - som har medf|rt att en buffert vart |verskriven... - - * server version 0.18 installerad. (magiska nummer inf|rda - {ven i Connection och Mux strukturerna) - -Mon Mar 11 21:23:02 1991 Peter Eriksson (pen at nanny) - - * ram-smalloc.c/smalloc.c: Magiskt nummer inf|rt... - -Mon Mar 11 19:49:10 1991 Per Cederqvist (ceder at nanny) - - * dbck anpassat till nya formatet. "dbck -g" garbar i text-filen. - -Mon Mar 11 01:48:34 1991 Peter Eriksson (pen at nanny) - - * 0.17 installerad och ig}ngsatt. - -Sun Mar 10 21:23:50 1991 Peter Eriksson (pen at nanny) - - * connections.c: bugfix i new_client():setup av all_conn...-listan - -Sat Mar 9 15:25:09 1991 Peter Eriksson (pen at nanny) - - * Buffring av meddelanden g|rs nu i Mux-rutinerna. - -Sat Mar 9 05:52:34 1991 Per Cederqvist (ceder at nanny) - - * 0.16 installerad och ig}ngsatt. - -Sat Mar 9 03:25:25 1991 Peter Eriksson (pen at nanny) - - * Allt f{rdigt f|r MUX-hantering. Nu fattas bara ett - riktigt protokoll, samt buffring av utdata i Mux_client - strukturen. Major rewrite av det mesta som hade med - isc_ att g|ra. - -Thu Mar 7 03:16:00 1991 Peter Eriksson (pen at nanny) - - * Nu g}r servern genom kompilatorn, med allt fixat till - ISC. Jag har dock inte provk|rt... - -Wed Mar 6 23:08:16 1991 Per Cederqvist (ceder at nanny) - - * P} grund av Isc-ombyggnaden har jag inte kunnat provk|ra. - - * prot-a.c: prot_a_parse_packet(): Om man skrev n}got som matchade - regexpen "A[ \t\n]*\([0-9]+\)[^H].*" n{r man loggade in s} sattes - username till "\1H\{\}\1". - - * text.c: get_text(): Nu kan man (troligtvis) h{mta en "tom" text - utan att f} felet KOM_INDEX_OUT_OF_RANGE. - -Tue Mar 5 19:17:50 1991 Per Cederqvist (ceder at nanny) - - * ram-smalloc.c: rewrote tmp_alloc and free_tmp. Reason: a spurios - "rm ram-smalloc.c"... - -Sun Mar 3 22:16:34 1991 Per Cederqvist (ceder at nanny) - - * isc-serverinfo.[hc]: Uppsnyggad. Anv{nder inte l{ngre n}got som - {r lyskom-specifikt. F|ljd{ndringar i connections.c, dit en del - saker blev flyttade. Inge hj{lpte mig v{lja vad som skulle bort. - - * N{r n}gon f|rs|ker logga in, men servern {r full, sker nu - f|ljande: - - * Den som kopplar upp f}r texten "%% No connections left.\n". - - * Alla andra f}r det asynkrona meddelandet 11 - (ay_rejected_connection) (inga argument). - -Sat Mar 2 18:47:37 1991 Per Cederqvist (ceder at nanny) - - * i_am_on_obsolete skickas inte l{ngre. - - * broadcast tar nu en str{ng, inte ett textnummer. Skrev broadcast - och funktioner f|r det asynkrona meddelandet broadcast. - -Sat Mar 2 01:13:29 1991 Lars Willf|r (willfor at nanny) - - * Fixade en bug i set_permitted_submitters som gjorde att man inte - kunde s{tta till}tna inl{ggsskrivare till 0 (vem som helst). - -Tue Feb 19 00:52:03 1991 Per Cederqvist (ceder at nanny) - - * Bytte versionsnummer till 0.13. - - * conference.c: set_etc_motd(): Ett |verfl|digt semikolon gjorde - att det inte gick att s{tta etc_motd. - -Sun Feb 17 06:44:46 1991 Thomas Bellman (bellman at nanny) - - * isc-server.c: isc_flush(): Provar att stoppa redan n{r man n}tt - upp till maxgr{nsen MAXQUEUEDSIZE, och inte v{nta tills man - |verskrider den. - -Fri Feb 15 23:39:46 1991 Per Cederqvist (ceder at nanny) - - * De tv} {ndringarna nedan fungerade inte, s} jag }terst{llde allt. - - * Om /etc/nologin existerar skickar servern str{ngen - "%% No logins allowed." vid uppkoppling. Om fildeskriptorerna {r - slut skickas str{ngen "%% No connections left." - - * isc_getnextevent(): Nu returneras en ny uppkoppling {ven i - fallet ISC_EVENT_REJECT. Anroparen m}ste nu anropa - isc_logoutclient p} en s}dan uppkoppling innan isc_getnextevent - anropas n{sta g}ng. - -Sun Feb 10 10:04:24 1991 Per Cederqvist (ceder at nanny) - - * convert.c och convert-cache.c konverterade databasen. Filerna - f}r vara kvar ett tag till, tills vi ser att allt verkligen - fungerar. - - * Inge och jag skrev om ram-cache.c, ram-output.c och ram-parse.c. - Nu sparas textmassan i en s{rskild fil. Dessutom sparas - klockslag som time_t, inte som struct tm. Dessa tv} }tg{rder - ledde till _stora_ hastighetsvinster - ca en faktor 2. - - [ndringar i cached_delete_text(), cached_get_text(), - cached_create_text(), init_cache(), fparse_text_stat(), - foutput_text_stat(), foutput_time() och fparse_time(). - - * server/ram-output2.c heter numera server/ram-output.c - - * server/services.h heter numera server/internal-services.h - (include/services.h {r of|r{ndrad). - -Fri Feb 8 20:24:59 1991 Per Cederqvist (ceder at nanny) - - * cache.h: Ny funktion: cached_conf_exist(Conf_no). - - * cache.h: cached_get_name anv{nds inte! Det {r nu borttaget. - -Tue Feb 5 21:17:42 1991 Per Cederqvist (ceder at nanny) - - * Info om hur l}ng tid de olika delarna av synkningen tog lagras - om TIME_SYNC {r definierad i ram-cache.c. - - * Nu kan man l{sa motd_of_lyskom {ven om man inte {r inloggad. - -Tue Feb 5 02:58:34 1991 Peter Eriksson (pen at nanny) - - * isc-server.c/iscserver.h: Max queue size implementerad. - Statistik / client lagras i Isc_clientinfo. - -Tue Feb 5 00:51:44 1991 Per Cederqvist (ceder at nanny) - - * db/ramkomd-logg flyttad till etc/ramkomd-logg. - - * etc/pid: process-id skrivs i denna fil. - -Fri Feb 1 23:19:04 1991 Per Cederqvist (ceder at nanny) - - * 0.10 installerad och startad. - - * get_map fungerade inte om man f|rs|kte h{mta en delmap d{r alla - texter man ville ha var raderaded. 90-120 == 547689541. - (unsigned). R{ttat, men fr}gan {r hur m}nga liknande buggar det - finns... - -Tue Jan 22 10:14:28 1991 Lars Willf|r (willfor at nanny) - - * [ndrade lite #include-rader s} att make depend ska fungera. - Kommenterade bort '#include "CloseFileDescriptors"' ur logII.c. - -Fri Jan 18 10:33:58 1991 Per Cederqvist (ceder at nanny) - - * Nytt asynkront meddelande: ay_login. S{nds n{r n}gon loggar in. - Nu s{nds inte ay_i_am_on n{r man loggar in l{ngre. - -Thu Jan 17 14:43:14 1991 Per Cederqvist (ceder at nanny) - - * 0.09 installerad. - - * ram-cache.c: Om TIME_SYNC {r definierad loggas information om - hur l}ng tid varje syncning tar. - - * Inge:s funktioner f|r att spara databasen n{stan dubbelt s} - snabbt som vanligt testade och inlagda. - -Mon Jan 14 11:45:26 1991 Per Cederqvist (ceder at nanny) - - * forced_leave_conf(): Ny funktion som anropas n{r n}gon uttr{der - ur ett m|te (av n}gon orsak). Den skickar ett asynkront - meddelande till alla uppkopplingar d{r personen i fr}ga {r - inloggad och ber{ttar att han inte l{ngre {r med i m|tet. Det - asynkrona meddelandet heter "ay_leave_conf". - -Sun Jan 13 20:26:29 1991 Inge Wallin (inge at nanny) - - * Stoppat ner filerna ../*.h i det nyskapade directoryt ../include - samt fixat samtliga h- och c-filer i serverdirectoryt att - inkludera <foo.h> i st{llet f|r "../foo.h". Dessutom lagt till - -I../include i Makefile. - -Sun Jan 13 11:27:31 1991 Per Cederqvist (ceder at nanny) - - * membership.c: get_memberhip(): Om n}gon f|rs|ker h{mta en - medlemsskapslista f|r en person den {r organisat|r f|r utan att - h{mta de l{sta texterna s} s{tts read_texts till NULL. Bug! Fixat. - - * do_delete_text(): L{nken fr}n f|rfattaren till texten - (created_texts) s{tts till noll n{r texten tas bort. - -Fri Jan 11 13:37:00 1991 Per Cederqvist (ceder at nanny) - - * create_text(): Nu kan en text inte vara kommentar/fotnot till - samma text mer {n en g}ng. - -Thu Jan 10 21:42:16 1991 Thomas Bellman (bellman at nanny) - - * connections.c: call_function(): Variabeln 'status' tilldelades - v{rdet FALSE, fast den var av typen Success. - -Thu Jan 10 20:40:46 1991 Peter Eriksson (pen at nanny) - - * Added feature: rwhod support. (rwhod.c / connections.c) - -Thu Jan 10 12:40:33 1991 Per Cederqvist (ceder at nanny) - - * ram-output.c: foutput_membership() och ram-parse.c: - fparse_membership(): Om no_of_read != 0 och read_texts == NULL s} - s{tts no_of_read till 0 och ett meddelande loggas. - - * ram-parse.c: fparse_person(): en liten minnesl{cka tillt{ppt. - L|senordet lagrades dubbelt i servern. Eftersom fparse_person - bara anv{nds vid uppstart s} p}verkas inte storleken s} - mycket... - -Wed Jan 9 16:53:56 1991 Per Cederqvist (ceder at nanny) - - * mark_as_read(): adjust_read anropas alltid. F|rut kunde det - h{nda att read_texts blev o{ndlig om en text raderades innan man - l{ste den. Nu ska det inte bli s}. (Men det finns fortfarande - minst en bugg kvar n}gonstans i mark_as_read). - -Mon Jan 7 11:00:37 1991 Per Cederqvist (ceder at nanny) - - * mark_as_read(): Nu protesterar servern om man f|rs|ker markera - en text med lokalt nummer 0. - -Mon Jan 7 09:05:24 1991 Peter Eriksson (pen at nanny) - - * connections.c&isc-server.c: ISC_EVENT_REJECT - -Sun Jan 6 16:13:49 1991 Per Cederqvist (ceder at nanny) - - * text-garb.c: garb_text() loggar nu hur m}nga texter - den har tagit bort efter varje runda. - -Sun Jan 6 16:20:59 1991 Peter Eriksson (pen at nanny) - - * missing-ansi.c: skapade 'strerror()' - connections.c: {ndrade i toploop() s} fel skrivs ut som - text ist{llet f|r som siffror. - isc-server.c: ditto i isc_flush(). - -Sat Jan 5 16:20:04 1991 Peter Eriksson (pen at nanny) - - * connections.c: fexists(): nollst{llning av 'errno'. - skriv ut event->msg om den {r satt vid - ISC_EVENT_ERROR. - isc-server.c: isc_getnextevent(): s{tt isc_ei->msg till - en beskrivande text vid ISC_EVENT_ERROR. - -Sat Jan 5 04:13:01 1991 Per Cederqvist (ceder at nanny) - - * La in en close i isc_logoutclient. Nu ska v{l f|rbindelserna - kopplas ner ordentligt, hoppas jag. - -Fri Jan 4 21:14:36 1991 Per Cederqvist (ceder at nanny) - - * Version 0.07 tagen i drift. - -Fri Jan 4 20:13:40 1991 Peter Eriksson (pen at nanny) - - * isc-server.c: non-blocking writes och transmit queue funkar nu. - -Fri Jan 4 12:02:03 1991 Per Cederqvist (ceder at nanny) - - * create_text returnerar numera KOM_ILL_MISC om man f|rs|ker med - samma mottagare mer {n en g}ng. - - * add_recipient klarar nu {ven av att addera en cc_recpt. - -Fri Jan 4 11:57:48 1991 Peter Eriksson (pen at nanny) - - * printf.c: Ansifikation... - isc-server.c: isc_printf(), isc_putc(), isc_write() & isc_flush() - anv{nder nu alla en per-klient s{ndbuffer. - Dock anv{nds blocking-writes fortfarande... - prot-a-*.c & ram-*.c: Anv{nder nu isc-rutinerna f|r utmatning - ist{llet f|r stdio. - - -Sun Dec 16 21:55:19 1990 Thomas Bellman (bellman at nanny) - - * services.c: pepsi(), change_what_i_am_doing(): Man b|r nog s{tta - alla f{lt till n}got vettigt i infostrukturen som man skickar - till async_i_am_on()... Speciellt str{ngar som anv{ndarnamnet. - -Sat Dec 15 11:04:45 1990 Per Cederqvist (ceder at nanny) - - * prot-a-send-async.c, async.h: i_am_on skall naturligtvis skicka - en hel Who_info. Nu g|rs det. F|r att inte elisp-klienten skall - sluta fungera har numera i_am_on nummer 6. Gamla i_am_on, nummer - 2, finns fortfarande kvar, men kommer att tas bort om n}gon - m}nad eller s} n{r alla elisp-klienter som anv{nder gamla - i_am_on har f|rsvunnit. - -Fri Dec 14 22:15:11 1990 Per Cederqvist (ceder at nanny) - - * send-async.c: Nu t}l servern att det finns klienter som inte har - hunnit ber{tta vilket protokoll de anv{nder. Denna bugg har - orsakat ett antal omstarter... - -Mon Dec 10 05:32:01 1990 Thomas Bellman (bellman at nanny) - - * ramkomdc: chdir() till /usr/lyskom/etc innan man dumpar core. - Kommer antagligen inte att funka... - -Mon Dec 10 05:31:33 1990 Peter Eriksson (pen at nanny) - - * isc-server.c: non-blocking writes. (FNDELAY). - -Wed Dec 5 17:44:27 1990 Per Cederqvist (ceder at nanny) - - * ram-cache.c: {ndrade konstanten MAX_TEXT fr}n 9999 till 15000. - R{ttade en bugg i cached_create_text(). F|rut s} kollade den om - next_text_num var == MAX_TEXT, och sa i s} fall ifr}n, MEN - r{knade upp next_text_num. Text nummer (MAX_TEXT+1) kunde allts} - skapas... - -Sun Dec 2 18:06:01 1990 Per Cederqvist (ceder at nanny) - - * ram-output.c: foutput_time() - ram-parse.c: fparse_time() - Tidpunkter sparas numera i GMT. P} s} s{tt slipper man ta reda - p} vilken tidszon man k|r i. - -Thu Nov 29 14:43:27 1990 Per Cederqvist (ceder at nanny) - - * Jag {ndrade i typen Isc_clientinfo och tog bort en hel del som - jag i st{llet la i Connection (som jag skapade). Protokoll A - isolerat till typen Prot_a. Nu tror jag att allt som {r - protokoll-specifikt {r isolerat, s} l}ngt det g}r. Arbetet med - att implementera protokoll B b|rjar nu... - -Wed Nov 28 07:57:48 1990 Per Cederqvist (ceder at nanny) - - * [ven f|r de asynkrona meddelandena {r nu protokoll A isolerat. - -Tue Nov 27 14:39:12 1990 Peter Eriksson (pen at nanny) - - * kill -USR2 g|r fork()&abort() s} man kan f} ut en core av en - exekverande server utan att d|da den. - - * ramkomd.c - sighandler_quit - exit(1) -> abort(). - -Mon Nov 26 21:15:13 1990 Per Cederqvist (ceder at nanny) - - * Isc_clientinfo-structuren har ett nytt f{lt: u_char protocol. - - * F|rberedde f|r protokoll B genom att isolera protokoll A. Nu - ligger allt protkoll-A-specifikt i filerna prot-a-output.[hc], - prot-a-parse-arg-[hc].awk, prot-a-parse.[hc] och prot-a.[hc]. - Observera dock att jag inte {r helt klar {n: jag har inte gjort - n}got }t asynkrona meddelanden. - -Sun Nov 25 14:17:47 1990 Peter Eriksson (pen at nanny) - - * isc-cache.c&prot-a-output.c: fflush()+write(fileno()) -> fwrite(). - Borde snabba upp lite. - -Sun Nov 25 03:08:24 1990 Per Cederqvist (ceder at nanny) - - * services.c: mark_text(): Nu g}r det att markera texter! - [ndringar i manipulate.c:text_read_access - man f}r alltid l{sa - texter som man har markerat. Dessutom n}gra nya funktioner i - manipulate.c f|r att hantera markeringar. - - * services.c: set_conf_type(): Det {r inte till}tet att ha ett - m|te/en person som {r secret men inte rd_prot. - -Sat Nov 24 14:19:53 1990 Per Cederqvist (ceder at nanny) - - * kom_get_unread_confs ger vilka m|ten en viss person har ol{sta - inl{gg i. - -Sat Nov 24 09:33:32 1990 Peter Eriksson (pen at nanny) - - * MAX_NO_CONNECTIONS satt till 14 om __sequent__. - [14(max_no_clients)+1(portnum)+3(stdio)+1(databas)+1(reject)] - - * Nya kommandoradsoptioner: -D{databas-path}, -p{portnum}. - - * DATAFILE, BACKUPFILE -> datafile, backupfile (variabla pga - support av olika databasdir). - -Thu Nov 22 08:06:06 1990 Peter Eriksson (pen at nanny) - - * Hackade in -SIGUSR1/-SIGHUP/-SIGQUIT (sync, sync&die, sync&die-fast) - - * MAX_NO_OF_CONNECTIONS - funktionalitet - - * Check av /etc/nologin f|r utesp{rr av anv{ndare - -Wed Nov 21 10:16:28 1990 Per Cederqvist (ceder at nanny) - - * end-of-atomic: Nu anropas garb-text() om servern {r idle. - - * ram-cache.c: traverse_text och cached_get_garb_nice skrivna. - - * isc-server.c: Nu anv{nds SO_DONTLINGER, SO_REUSEADDR och - SO_KEEPALIVE p} socketen. - - * MAX_NO_OF_CONNECTIONS {r 15 om __sequent__ {r definierat, annars - 32. - - * config.c: USERNAME_LEN {ndard fr}n 32 till 128 f|r att f} plats - med ett maskinnamn ocks}. - - * Makefile: /bin/sed fattar inte heller \{n\}, precis som GNU-sed, - s} jag skrev om Makefilen utan den. - -Sun Nov 11 15:36:51 1990 Per Cederqvist (ceder at nanny) - - * cached_set_garb_nice och cached_get_garb_nice. - -Fri Nov 9 14:58:54 1990 Per Cederqvist (ceder at nanny) - - * server/cache.c och server/flurp.c (vad {r det?): - '#include "../ldb/ldb.h"' bortkommenterat f|r att kunna g|ra - make depend. - - * Makefilen: -L bortkommenterad fr}n LIBS. - -Fri Nov 2 00:55:32 1990 Peter Eriksson (pen at lave) - - * isc_server.c: isc_gethostname() - fixade s} att den returnerade - IP-nummret (som en String) som de ska enligt specen... - -Thu Nov 1 01:38:44 1990 Per Cederqvist (ceder at lave) - - * manipulate.c: do_sub_comment() och do_sub_foootnote klarade inte - av att f} NULL som text-status. Det fick dom fr}n do_delete_text... - - * manipulate.c: do_sub_recpt(): om conf_c var NULL s} gick det }t - skogen. Om conf_no inte existerade gick det }t samma h}ll. - -Sat Oct 20 14:35:59 1990 Per Cederqvist (ceder at lave) - - * Efter ett gott r}d fr}n Lars Aronsson s} har jag lagt till - funktionerna get_person_stat_old, get_conf_stat_old och - who_is_on_old. De har samma nummer som de gamla get_person_stat - et c. P} s} s{tt {r den nya servern kompatibel med gamla - klienter. - - * Who_info inneh}ller nu tv} nya f{lt: connection, som {r ett - l|pnummer som r{knas upp med ett f|r varje ny connection till - klienten, och username, som {r userid@host f|r just den h{r - uppkopplingen. (Om personen samtidigt {r inloggad fr}n en annan - maskin kan man inte se det med Who_info_old). - - * get_person_stat och get_conf_stat skall numera inte ha n}gon - mask. De skickar alltid med namnet. - -Fri Oct 19 20:42:32 1990 Per Cederqvist (ceder at lave) - - * L{nkning sker nu med -lresolv, s} att servern fr}gar nameservers - om namnet p} maskiner n{r den bara lyckas f} ip-nummret. - -Sun Oct 14 05:00:23 1990 Per Cederqvist (ceder at lave) - - * isc-server.c: isc_readmsg(): Det inl{sta meddelandet avslutades - med ett '\0', som aldrig anv{nds i servern. Det {r ju i och f|r - sig inte s} farligt, men problemet var att nollan lades utanf|r - det allokerade utrymmet om det kom f|r mycket data p} en g}ng... - Nu l{ggs aldrig n}gon '\0':a in. - -Thu Sep 13 20:38:22 1990 Per Cederqvist (ceder at laila) - - * isc-output.c: output_conference(): - [ven conf-type |verf|rs nu. Det var aldrig meningen att ta bort - den... - -Sat Sep 1 01:22:53 1990 Per Cederqvist (ceder at lave) - - * Nu fungerar {ndringarna, i alla fall delvis. - -Tue Aug 28 14:08:33 1990 Per Cederqvist (ceder at lave) - - * [ndringen av formaten f|r Text_status och tider ska vara klara nu. - -Sun Aug 26 16:23:40 1990 Per Cederqvist (ceder at lage) - - * P}b|rjade {ndring av formatet f|r |verf|ring av Text_status. I - forts{ttningen kommer {ven no_of_chars att |verf|ras. - - * P}b|rjade {ndring av formatet f|r en time_t. I forts{ttningen - kommer alla klockslag att |verf|ras som en struct tm. Serverns - lokala tid kommer att |verf|ras. Just nu {r {ndringen genomf|rd - p} n}gra, men inte alla st{llen. - -Tue Aug 21 19:46:50 1990 Per Cederqvist (ceder at lave) - - * get_text() tar nu h{nsyn till first_char och end_char. - - * get_members() testad. - - * Tog bort Template f|r att f|rhindra att n}gon {ndrar i den av - misstag. - -Sun Aug 12 17:17:44 1990 Per Cederqvist (ceder at lave) - - * get_members() tittar ox}, men den {r inte testad. T}get g}r - snart, och jag vill hinna {ta middag f|rst... Vi ses om 14 dar! - - * get_created_texts() tittar p} 'first' och 'len'. - - * En hel massa sm}buggar, bl a i mark_as_read(), r{ttade. - - * get_created_texts() och get_members() skrivna. Dom tittar _inte_ - p} 'first' och 'no_of_*' {n. - - * get_membership() tittar nu p} 'first' och 'no_of_confs'. - -Sat Aug 11 02:13:15 1990 Per Cederqvist (ceder at lave) - - * services.c: create_text(): Det {r nu till}tet att ha ett loc_no - som misc_item. Det ignoreras, oberoende av var det tr{ffas p}. - -Thu Aug 9 05:13:44 1990 Thomas Bellman (bellman at laila) - - * Make depend utg}r fr}n Makefile och inte fr}n Template. Man kan - allts} {ndra direkt i Makefile. - - * get_membership() skriven, men gl|mmer titta p} parametrarna - 'first' och 'no_of_confs'. Det {r inte testat heller... - -Sat Aug 4 01:41:41 1990 Thomas Bellman (bellman at lave) - - * manipulate.c: text_read_access(): Nu kan man inte l{sa - texter utan att vara inloggad. ]t minstone enligt - k{llkoden. Den server som k|r har fortfarande det gapande - s{kerhetsh}let. - -Tue Jul 24 04:40:32 1990 Per Cederqvist (ceder at lave) - - * F|rb{ttrad felhantering n{r f|r l}nga str{ngar kommer till - servern. Nu trunkerar isc-parse.c str{ngen till den maximala - l{nged +1 och l}ter services.c uppt{cka att str{ngen {r f|r l}ng - och protestera. F|rut skrev isc-parse.c '%% LysKOM protocol - error.' och det var nog lite v{l h}rt... - -Mon Jul 23 23:44:49 1990 Per Cederqvist (ceder at lave) - - * En b{ttre version av unique_name(), som inte alltid svara TRUE, - {r implementerad. - - * Asynkrona meddelanden {r implementerade. - -Fri Jul 13 00:11:48 1990 Per Cederqvist (ceder at lave) - - * services.h kan inte sl{ngas l{ngre. Fast nuf|rtiden s} {r den - ganska liten... - -Wed Jun 27 07:42:59 1990 Thomas Bellman (bellman at lave) - - * services.h kan sl{ngas. Filen har ersatts av - kom:/services.h, som numera kan anv{ndas b}de i serverdelen - och klientdelen. Filerna 'services.c' och 'manipulate.c' {r - {ndrade till att inkludera "../services.h" i st{llet. - Flaggan SERVER definieras i Makefilen. - -Wed Jun 6 04:31:02 1990 Per Cederqvist (ceder at laila) - - * end-of-atomic.[hc]: Funktion som skall anropas efter varje - atomiskt anrop. - -Wed May 30 18:47:42 1990 Linus Tolke (linus at lave) - - * cache.c rivet lite (cached_create_person, - mark_conferens_as_changed.) - - * cache.[hc] {ndrade i definitionen av cached_lookup_name s} att - den skall st{mma med -----------------------------------------\ - dvs char * -> String | - | -Fri May 25 07:32:18 1990 Per Cederqvist (ceder at lave) | - | - * manipulate.[hc]: Ny fil som inneh}ller hj{lpfunktioner till | - services.c. Skall endast anv{ndas av services.c. | - | - * log.[hc]: Funktioner f|r att skriva till log-fil. | - | -Wed May 23 18:30:26 1990 Per Cederqvist (ceder at lave) | - | - * cache.[hc], services.[hc]: Nu anv{nds String |verallt, och <--/ - char * inte alls. Det {r nog mycket i cache.[hc] som inte funkar - l{ngre... - - -Tue May 22 22:01:19 1990 Per Cederqvist (ceder at laila) - - * 2kom/server/services.h skapad. H{r ligger saker som t ex cachen m}ste - komma }t, men som klienterna inte ska komma }t. Det som bara - klienterna ska komma }t ligger fortfarande i 2kom/services.h - -Wed May 9 21:25:13 1990 Linus Tolke (linus at laila) - - * Rev infinitesimalt i cache.[hc]. mark_person_as changed fungerar - kanske. - -Tue May 8 23:19:37 1990 Per Cederqvist (ceder at lage) - - * Slog ihop cache.[ch] och unprot.[ch] till cache.[ch]. - unprot.[ch] finns kvar ett tag till, men inneh}ller bara skr{p. - -Mon May 7 16:23:28 1990 Per Cederqvist (ceder at lage) - - * server.[hc] heter numera lyskomd.[hc] i god UNIX-anda. - -Sat May 5 20:53:21 1990 Per Cederqvist (ceder at lave) - - * unprot.[hc]: Tog bort en massa funktionsstubbar som aldrig - kommer att avn{ndas. S}g till att .h och .c inneh}ller samma - funktioner. unprot.c g}r nu igenom kompilatorn! - -Thu May 3 18:54:46 1990 Per Cederqvist (ceder at lage) - - * unprot.c: Jag skriver in en kommentar "/****/" f|re - de funktioner som jag verkligen anv{nder. - -Tue Apr 24 03:34:14 1990 Per Cederqvist (ceder at lage) - - * smalloc.[hc]: Ny fkn srealloc. - - * server.h: Nytt f{lt i Connection: Person * person. - -Sat Apr 21 13:22:26 1990 Per Cederqvist (ceder at lave) - - * Ny Makefile, som regenerar sig sj{lv automagiskt. (make depend) - - * server.h: La till f{ltet ena_level i typen Connection. - -Wed Apr 18 01:35:49 1990 Per Cederqvist (ceder at lage) - - * services.c: get_marks har nu ingen parameter. Man kan bara titta - p} sina egna markeringar. - - * unprot.c: Tog bort unprot_change_what_i_am_doing - - * Flyttade minneshanteringen till smalloc.c - - * cache.c: La till ett anrop: get_name. - -Tue Apr 17 23:54:52 1990 Per Cederqvist (ceder at lage) - - * services.{ch}: {ndrade anropet av create_text - diff --git a/src/server/FileList b/src/server/FileList deleted file mode 100644 index d08e0d917..000000000 --- a/src/server/FileList +++ /dev/null @@ -1,126 +0,0 @@ -This is a list of all files in the server directory. - -Atomic calls ------------- -* services.h -* manipulate.h -* admin.c -* admin.h -* conference.c -* membership.c -* person.c -* session.c -* text.c - -* version.incl - Inkluderas av admin.c. Inneh}ller versionsnummret multiplicerat med 100. - I b-server blir det en str{ng. - -* parser.c@ -* parser.h@ - Matchar namn. Samma fil som anv{nds i tty-klienten. Ska bort till b-server. - - -Data cache ----------- -* cache.c -* cache.h - H{r skulle det ha legat en fungerande cache om inte mud funnits... - -Highest level of I/O --------------------- -* async.h -* send-async.c -* send-async.h -* call-switch.incl -* com-h.awk -* com.h -* connections.c -* connections.h -* end-of-atomic.c -* end-of-atomic.h -* fnc-def-init.awk -* fnc-def-init.incl -* fncdef-no-str-limit.txt -* fncdef.txt -* isc-parse.c -* isc-parse.h - -Low-level I/O -------------- -* isc-server.c -* isc-server.h -* printf.c - -Awk scripts ------------ -* call-switch.awk - -Misc ----- -* config.c -* kom-types.c -* kom-errno.c@ -* log.c -* log.h -* minmax.h -* missing-ansi.c -* smalloc.c -* smalloc.h -* std-disclaimer.h - -Dbck ----- -* dbck -* dbck-cache.c -* dbck.c -* misc-parser.c@ -* misc-parser.h@ - -Non-sources ------------ -* ChangeLog -* FileList -* Makefile -* TAGS -* To-do - -Main ----- -* lyskomd.c -* lyskomd.h -* text-garb.c -* text-garb.h - -Protocol A ----------- -* prot-a-output.c -* prot-a-output.h -* prot-a-parse-arg-c.awk -* prot-a-parse-arg-h.awk -* prot-a-parse-arg.c -* prot-a-parse-arg.h -* prot-a-parse.c -* prot-a-parse.h -* prot-a-send-async.c -* prot-a-send-async.h -* prot-a.c -* prot-a.h - -String packet -------------- -* s-collat-tables.c@ -* s-string.c@ - -Ramkomd -------- -* ram-cache.c -* ram-output.c -* ram-output.h -* ram-output2.c -* ram-parse.c -* ram-parse.h -* ram-smalloc.c -* ramkomd -* ramkomd.c - diff --git a/src/server/Magics b/src/server/Magics deleted file mode 100644 index 8eda7faeb..000000000 --- a/src/server/Magics +++ /dev/null @@ -1,15 +0,0 @@ -SMALLOC: - alloc = 0x12FE56A0 - free = 0xCA348E63 - -Connection: - alloc = 0x18F4AE74 - free = 0x67A7B144 - -Mux: - alloc = 0x56AE17DB - free = 0xF24A6BE7 - -ISC: - alloc = 0x12F54ACE - free = 0xEE47A37F diff --git a/src/server/Makefile b/src/server/Makefile deleted file mode 100755 index 9f9769c63..000000000 --- a/src/server/Makefile +++ /dev/null @@ -1,177 +0,0 @@ -# -# $Id: Makefile,v 0.26 1992/05/18 23:12:43 ceder Exp $ -# Copyright (C) 1991 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. -# -# $Id: Makefile,v 0.26 1992/05/18 23:12:43 ceder Exp $ - -include Topdir.make -SCRIPTDIR = $(TOPDIR)/scripts - -include $(SCRIPTDIR)/import.make - -HDRS = admin.h isc-parse.h prot-a-output.h async.h isc-interface.h \ - prot-a-parse.h cache.h tmp-limits.h prot-a-send-async.h connections.h \ - log.h prot-a.h dbck-cache.h lyskomd.h ram-output.h disk-cache.h \ - manipulate.h ram-parse.h end-of-atomic.h memory.h send-async.h exp.h \ - minmax.h internal-connections.h mux-parse.h \ - internal-services.h mux.h text-garb.h \ - version.incl cache-node.h - -# See config/sun4os4-defs.make about LIBRESOLV if you are running SunOS 4.1.1. - -LIBS = -lisc-new$(PROFILE-LIB-SUFFIX) -lmisc$(PROFILE-LIB-SUFFIX) \ - -llyskom-server$(PROFILE-LIB-SUFFIX) -lansi$(PROFILE-LIB-SUFFIX) \ - $(LIBRESOLV) $(LIBIDENT) - -TARGET = -DSERVER - - -# Files that implements protocol A. -PROTA = prot-a-output.o prot-a-parse-arg.o prot-a-parse.o prot-a.o \ - prot-a-send-async.o - -PROTA_SRCS = prot-a-output.c prot-a-parse-arg.c prot-a-parse.c prot-a.c \ - prot-a-send-async.c - -MUX = mux.o mux-parse.o - -MUX_SRCS = mux.c mux-parse.c -# Implementations of the atomic calls. - -ATOMS = text.o membership.o person.o conference.o session.o admin.o -ATOMS_SRCS = text.c membership.c person.c conference.c session.c admin.c - -# These files are needed by all versions of the LysKOM server. -GENOBJS = connections.o log.o $(ATOMS) \ - kom-types.o \ - send-async.o server-config.o text-garb.o \ - missing-ansi.o isc-parse.o memory.o $(PROTA) $(MUX) \ - internal-connections.o rfc931.o isc-malloc.o - -GEN_SRCS = connections.c log.c $(ATOMS_SRCS) \ - kom-types.c \ - send-async.c server-config.c text-garb.c \ - missing-ansi.c isc-parse.c memory.c $(PROTA_SRCS) $(MUX_SRCS) \ - internal-connections.c rfc931.c isc-malloc.c - -# Files for lyskomd. - -DISKOBJS = ramkomd.o ram-smalloc.o simple-cache.o ram-parse.o ram-output.o \ - disk-end-of-atomic.o cache-node.o string-malloc.o - -DISK_SRCS = ramkomd.c ram-smalloc.c simple-cache.c ram-parse.c ram-output.c \ - disk-end-of-atomic.c cache-node.c string-malloc.c - - -DBCK = dbck.o dbck-cache.o ram-smalloc.o ram-parse.o server-config.o\ - kom-types.o\ - missing-ansi.o ram-output.o memory.o - -DBCK_SRCS = dbck.c dbck-cache.c ram-smalloc.c ram-parse.c server-config.c\ - kom-types.c\ - missing-ansi.c ram-output.c memory.c - -ENCRYPT = encrypt-passwd.o dbck-cache.o ram-smalloc.o ram-parse.o server-config.o\ - kom-types.o\ - missing-ansi.o ram-output.o memory.o - -SPECIALS = call-switch.incl com.h fnc-def-init.incl prot-a-parse-arg.c\ - prot-a-parse-arg.h fncdef-no-str-limit.txt .gdbinit - -SRCS = $(GEN_SRCS) $(RAM_SRCS) $(DISK_SRCS) $(LYS_SRCS) $(DBCK_SRCS) - -PROGRAMS = lyskomd dbck - - -all binaries: $(PROGRAMS) - -includes: com.h - cp com.h $(INCLUDEDIR) - -libraries:; - -lyskomd: $(DISKOBJS) $(GENOBJS) - $(CC) $(LDFLAGS) -o lyskomd $(DISKOBJS) $(GENOBJS) $(LIBS) - -encrypt: $(ENCRYPT) - $(CC) $(LDFLAGS) -o enrypt $(ENCRYPT) $(LIBS) - -dbck: $(DBCK) - $(CC) $(LDFLAGS) -o dbck $(DBCK) $(LIBS) - -call-switch.incl: call-switch.awk fncdef-no-str-limit.txt - $(AWK) -f call-switch.awk fncdef-no-str-limit.txt > call-switch.incl - -com.h: com-h.awk fncdef-no-str-limit.txt - $(AWK) -f com-h.awk fncdef-no-str-limit.txt > com.h - -fnc-def-init.incl: fnc-def-init.awk fncdef-no-str-limit.txt - $(AWK) -f fnc-def-init.awk fncdef-no-str-limit.txt > fnc-def-init.incl - -prot-a-parse-arg.c: prot-a-parse-arg-c.awk fncdef.txt prot-a-parse-arg.h - $(AWK) -f prot-a-parse-arg-c.awk fncdef.txt > prot-a-parse-arg.c - -prot-a-parse-arg.h: prot-a-parse-arg-h.awk fncdef-no-str-limit.txt - $(AWK) -f prot-a-parse-arg-h.awk fncdef-no-str-limit.txt > \ - prot-a-parse-arg.h - -fncdef-no-str-limit.txt: fncdef.txt - (echo \# Do not edit this file! It is generated from fncdef.txt.;\ - cat fncdef.txt) | sed 's/([^)]*)//g' > fncdef-no-str-limit.txt - -.gdbinit: Topdir.make - $(RM) -f .gdbinit - echo handle 13 nostop noprint >.gdbinit - echo dir $(TOPDIR)/src/libraries/libcommon >>.gdbinit - echo dir $(TOPDIR)/src/libraries/libansi >>.gdbinit - echo dir $(TOPDIR)/src/libraries/libisc >>.gdbinit - echo dir $(TOPDIR)/src/libraries/libmisc >>.gdbinit - - -install: $(PROGRAMS) - echo Server not installed. -# cp lyskomd $(DESTDIR)/ramkomd # The utilites wants ramkomd. -# cp dbck $(DESTDIR)/ -# strip $(DESTDIR)/dbck -# Don't strip ramkomd - we want debugging info! - -clean: - $(RM) $(GENERIC-CLEAN) $(PROGRAMS) - -distclean: clean - $(RM) $(GENERIC-DIST-CLEAN) $(SPECIALS) - -specials: $(SPECIALS) - -tags: - $(RM) TAGS - etags -t $(INCLUDEDIR)/*.h *.h \ - $(TOPDIR)/src/libraries/libisc-new/src/*.h \ - $(TOPDIR)/src/libraries/lib*/*.h \ - *.c \ - $(TOPDIR)/src/libraries/libisc-new/src/*.c \ - $(TOPDIR)/src/libraries/lib*/*.c - -include $(SCRIPTDIR)/Parallell-depend.make - -include dependencies diff --git a/src/server/To-do b/src/server/To-do deleted file mode 100644 index e77030ad9..000000000 --- a/src/server/To-do +++ /dev/null @@ -1,32 +0,0 @@ -Borde ha en skedjuler f|r sync&garb. Sync&garb borde returnera antalet -millisekunder tills de skall bli anropade igen. Det minsta av dessa -v{rden borde vara timeout till isc_getnextevent. - ------------------ - -membership.c : adjust_read() har l|ss. (Suck. Vilka l|ss? Jag minns -inte nu. D{remot s} b|rjar det ju dyka upp rapporter om att folk f}r -l{sa samma inl{gg flera g}nger, s} det st{mmer nog... /ceder) - ------------------ - -log() borde se ut s} h{r: - -void -log ( Severity sev - char *format; - ...) - -enum severity { - MSG, - ERR, - FATAL -} - -typedef enum severity Severity; - -Om log() f}r FATAL s} {r det samma sak som restart_lyskom(). Om log f}r f|r m}nga ERR f|r snabbt (eller f|r m}nga likadana?) s} startas lyskom om. - -------------------------- -Om diskomd misslyckas med att spara borde den ha en alternativ -disk att spara p}. diff --git a/src/server/admin.c b/src/server/admin.c deleted file mode 100644 index 797078adc..000000000 --- a/src/server/admin.c +++ /dev/null @@ -1,197 +0,0 @@ -/* - * $Id: admin.c,v 0.6 1991/12/16 17:44:22 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * admin.c - * - * Administrative calls. - */ - -static char *rcsid = "$Id: admin.c,v 0.6 1991/12/16 17:44:22 ceder Exp $"; - -#include <stdlib.h> -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "manipulate.h" -#include <server/smalloc.h> -#include "cache.h" -#include "log.h" -#include "admin.h" -#include <kom-errno.h> -#include "com.h" -#include "connections.h" -#include "send-async.h" -#include "config.h" - -Info kom_info = -{ -#include "version.incl" - , /* version */ - 1, /* conf_pres_conf */ - 2, /* pers_pres_conf */ - 3, /* motd_conf */ - 4, /* kom_news_conf */ - 0 /* motd_of_lyskom */ -}; - -/* - * Return info about this server. This can (and should) be done - * before logging in. modt_of_lyskom should be displayed before - * prompting for username if it isn't 0. - */ -extern Success -get_info( Info *result ) -{ - *result = kom_info; - return OK; -} - -/* /// */ -extern Success -set_motd_of_lyskom (Text_no motd) -{ - Text_stat *old_motd = NULL; - Text_stat *new_motd = NULL; - - CHK_LOGIN(FAILURE); - - if ( !ENA(admin, 1) ) - { - kom_errno = KOM_PERM; - return FAILURE; - } - - /* Check that the new motd exists before deleting the old*/ - - if ( motd != 0 ) - { - GET_T_STAT(new_motd, motd, FAILURE); - if ( new_motd->no_of_marks >= MAX_MARKS_TEXT ) - { - log("LIMIT: set_motd_of_lyskom(%d): New motd has %d marks.\n", - motd, new_motd->no_of_marks); - kom_errno = KOM_MARK_LIMIT; - return FAILURE; - } - } - - /* Unmark the previous motd if it exists. */ - - if ( kom_info.motd_of_lyskom != 0 - && (old_motd = cached_get_text_stat(kom_info.motd_of_lyskom)) != NULL) - { - if ( old_motd->no_of_marks > 0 ) - { - --old_motd->no_of_marks; - mark_text_as_changed( kom_info.motd_of_lyskom ); - } - else - { - log("ERROR: do_set_motd(): Old motd not marked\n"); - } - } - - /* Mark the new motd */ - - if ( motd != 0 ) - { - ++new_motd->no_of_marks; - mark_text_as_changed( motd ); - } - - kom_info.motd_of_lyskom = motd; - - return OK; -} - - - - -/* - * Force all clients to read a message. - * Sends an asynchronous message. This is obsoleted by send_message. - */ -extern Success -broadcast (String message) -{ - CHK_LOGIN(FAILURE); - - if (s_strlen(message) > BROADCAST_LEN) - { - kom_errno = KOM_LONG_STR; - return FAILURE; - } - - async_broadcast(ACTPERS, message); - return OK; -} - -/* - * Send a message - */ -extern Success -send_message (Pers_no recipient, - const String message) -{ - CHK_LOGIN(FAILURE); - - if (s_strlen(message) > BROADCAST_LEN) - { - kom_errno = KOM_LONG_STR; - return FAILURE; - } - - return async_send_message(recipient, ACTPERS, message); -} - - - -/* - * Make LysKOM sync its files. - */ -extern Success -sync (void) -{ - cache_sync_all(); - dump_statistics(); - return OK; -} - -/* - * Close LysKOM. exit_val is (currently) not used. The database is synced. - */ -extern Success -shutdown (int exit_val) -{ - CHK_LOGIN(FAILURE); - if ( !ENA(admin, 1) ) - { - kom_errno = KOM_PERM; - return FAILURE; - } - - go_and_die = TRUE; - return OK; -} diff --git a/src/server/admin.h b/src/server/admin.h deleted file mode 100644 index 0d164140a..000000000 --- a/src/server/admin.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * $Id: admin.h,v 0.3 1991/09/15 10:33:21 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: admin.h,v 0.3 1991/09/15 10:33:21 linus Exp $ - * - * admin.h - */ -extern Info kom_info; diff --git a/src/server/async.h b/src/server/async.h deleted file mode 100644 index 23c5213a5..000000000 --- a/src/server/async.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * $Id: async.h,v 0.3 1991/09/15 10:33:18 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: async.h,v 0.3 1991/09/15 10:33:18 linus Exp $ - * - * This file contains the parts of the async protocol that are common - * to the server and the client. - */ - - -/* - * What does this packet contain? (See doc/com-spec) - */ -typedef enum { - ay_new_text = 0, - ay_i_am_off = 1, /* Obsoleted by ay_logout */ - ay_i_am_on_obsolete = 2, /* Sends a Who_info_old. */ - ay_conf_deleted = 3, - ay_conf_created = 4, - ay_new_name = 5, - ay_i_am_on = 6, /* Sends a Who_info when changeinge - conference or what-am-i-doing. */ - ay_sync_db = 7, /* Database is syncing. */ - ay_leave_conf = 8, - ay_login = 9, /* Sends a Pers_no and connection - when someone logs in. */ - ay_broadcast = 10, /* Sends Pers_no of sender and a string. */ - ay_rejected_connection = 11, - /* A connection attempt was rejected - because LysKOM is full. */ - ay_send_message = 12, /* A message is sent. */ - ay_logout = 13 /* Someone logs out. */ -} Async; - diff --git a/src/server/cache-node.c b/src/server/cache-node.c deleted file mode 100644 index 2c358c01c..000000000 --- a/src/server/cache-node.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * $Id: cache-node.c,v 0.7 1991/09/15 10:33:13 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * cache-node.c - * - * Used in diskomd. - */ - -static char *rcsid = "$Id: cache-node.c,v 0.7 1991/09/15 10:33:13 linus Exp $"; - - -#include <stdio.h> -#include <kom-types.h> -#include "exp.h" -#include "cache-node.h" -#include <server/smalloc.h> -#include "lyskomd.h" - -EXPORT const Cache_node EMPTY_CACHE_NODE = - ((Cache_node){{ 0, 0, 0}, NULL, NULL, 0, 0, 0, 0, NULL, NULL, 0}); - -EXPORT const Cache_node_block EMPTY_CACHE_NODE_BLOCK = - ((Cache_node_block){ 0, NULL, NULL}); - -EXPORT const Cache_node_mcb EMPTY_CACHE_NODE_MCB = - ((Cache_node_mcb){ 0, NULL, 0, 0, NULL, NULL, 0, NULL }); - - -EXPORT void -unlink_lru(Cache_node *node, - Cache_node **lru, - Cache_node **mru) -{ - Cache_node *link; - - link = node->next; - - if ( node->next != NULL ) - node->next->prev = node->prev; - else if (*lru == node) - *lru = node->prev; - - if ( node->prev != NULL ) - node->prev->next = link; - else if (*mru == node) - *mru = link; - - node->next = NULL; - node->prev = NULL; -} - -EXPORT void -insert_mru(Cache_node *node, - Cache_node **lru, - Cache_node **mru) -{ - node->prev = NULL; - node->next = *mru; - *mru = node; - if ( *lru == NULL ) - *lru = node; - - if ( node->next != NULL ) - node->next->prev = node; -} - -static Cache_node_mcb * -alloc_cache_node_mcb(void) -{ - Cache_node_mcb *t; - - t = smalloc(sizeof(Cache_node_mcb)); - *t = EMPTY_CACHE_NODE_MCB; - return t; -} - -static Cache_node_block * -alloc_cache_node_block(int table_size) -{ - Cache_node_block *t; - - t = smalloc(sizeof(Cache_node_block)); - *t = EMPTY_CACHE_NODE_BLOCK; - t->nodes = smalloc (table_size * sizeof (Cache_node)); - t->next_free = 0; - t->link = NULL; - - return t; -} - - -EXPORT Cache_node_mcb * -create_cache_node_mcb(int mcb_size, - int table_size) -{ - Cache_node_mcb *tmp; - - tmp = alloc_cache_node_mcb(); - *tmp = EMPTY_CACHE_NODE_MCB; - tmp->lookup_table = smalloc(sizeof(Cache_node *) * table_size); - tmp->lookup_table_size = table_size; - tmp->mcb_size = mcb_size; - tmp->last_block = NULL; - - return tmp; -} - -/* +++ No check is done that it is initialized. */ -EXPORT Cache_node * -get_cache_node (Cache_node_mcb *control, - u_long key) -{ - if ( key >= control->lookup_table_size ) - return NULL; - - return control->lookup_table[ key ]; -} - -static Cache_node * -alloc_cache_node (Cache_node_mcb *control) -{ - Cache_node *c; - Cache_node_block *new_block; - - if ( control->last_block == NULL - || control->last_block->next_free >= control->mcb_size ) - { - new_block = alloc_cache_node_block (control->mcb_size); - new_block->link = control->last_block; - control->last_block = new_block; - } - - c = &control->last_block->nodes[ control->last_block->next_free++ ]; - - *c = EMPTY_CACHE_NODE; - return c; -} - -EXPORT void -destruct_cache_node(Cache_node_mcb *control, - u_long key) -{ - if ( key >= control->lookup_table_size ) - return; - - control->lookup_table[ key ] = NULL; -} - -EXPORT void -create_cache_node (Cache_node_mcb *control, - u_long key) -{ - if ( key >= control->lookup_table_size ) - restart_kom("ERROR: create_cache_node(%lu, %lu): " - "lookup_table_size = %lu\n", - (u_long) control, key, - control->lookup_table_size); - - control->lookup_table[ key ] = alloc_cache_node(control); -} - -EXPORT void -zero_init_cache_node (Cache_node_mcb *control, - u_long key) -{ - if ( key >= control->lookup_table_size ) - restart_kom("ERROR: zero_init_cache_node(%lu, %lu): " - "lookup_table_size = %lu\n", - (u_long)control, key, - control->lookup_table_size); - - control->lookup_table[ key ] = NULL; -} - - - -EXPORT void -set_mru(Cache_node_mcb *mcb, - u_long key) -{ - Cache_node *node; - - node = get_cache_node(mcb, key); - - if (node == NULL) - restart_kom("set_mru(%d): nonexistent.\n", key); - - unlink_lru(node, &mcb->lru, &mcb->mru); - insert_mru(node, &mcb->lru, &mcb->mru); -} - -static void -free_cache_node_block (Cache_node_block *block) -{ - sfree(block->nodes); - sfree(block); -} - -extern void -free_cache_node_mcb(Cache_node_mcb *control) -{ - Cache_node_block *block; - - while ( control->last_block != NULL ) - { - block = control->last_block; - control->last_block = block->link; - free_cache_node_block (block); - } - - sfree(control->lookup_table); - sfree(control); -} - - diff --git a/src/server/cache-node.h b/src/server/cache-node.h deleted file mode 100644 index bdafbebcf..000000000 --- a/src/server/cache-node.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * $Id: cache-node.h,v 0.5 1991/09/15 10:33:09 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: cache-node.h,v 0.5 1991/09/15 10:33:09 linus Exp $ - * - * cache-node.h - */ - -typedef struct cache_node { - struct { - u_int exists : 1; - u_int exists_b : 1; - u_int dirty : 1; /* [r *ptr modifierad? */ - } s; - void *snap_shot; /* Dirty data to be written to file B. */ - /* (Dirty relative to file A). */ - void *ptr; /* In-core data. */ - long pos; /* Position to element in file A. */ - long size; /* Size on disk. */ - long pos_b; /* Position to element in file B. */ - long size_b; /* Size in file B. */ - struct cache_node *prev; /* Points towards most recently used. */ - struct cache_node *next; /* Points towards least recently used. */ - int lock_cnt; -} Cache_node; - -extern const Cache_node EMPTY_CACHE_NODE; - - -typedef struct cache_node_block { - int next_free; - Cache_node *nodes; /* Pointer to an array with - mcb_size elements. */ - struct cache_node_block *link; /* Points to previous block. */ -} Cache_node_block; - -extern const Cache_node_block EMPTY_CACHE_NODE_BLOCK; - - -typedef struct cache_node_mcb { - int mcb_size; /* Number of cache_nodes in each block. */ - Cache_node_block *last_block; /* The block where new cache_nodes - * can be allocated. */ - u_long hits; - u_long misses; - Cache_node *mru; - Cache_node *lru; - u_long lookup_table_size; - Cache_node **lookup_table; /* Easy to implement, but memory expensive. */ -} Cache_node_mcb; - - -extern const Cache_node_mcb EMPTY_CACHE_NODE_MCB; - -extern void -unlink_lru(Cache_node *node, - Cache_node **lru, - Cache_node **mru); - -extern void -insert_mru(Cache_node *node, - Cache_node **lru, - Cache_node **mru); - - -extern Cache_node_mcb * -create_cache_node_mcb(int mcb_size, - int table_size); - - -extern void -destruct_cache_node(Cache_node_mcb *control, - u_long key); - -extern Cache_node * -get_cache_node (Cache_node_mcb *control, - u_long key); - - -extern void -create_cache_node (Cache_node_mcb *control, - u_long key); - - -extern void -zero_init_cache_node (Cache_node_mcb *control, - u_long key); - -extern void -set_mru(Cache_node_mcb *mcb, - u_long key); - - -extern void -free_cache_node_mcb(Cache_node_mcb *control); diff --git a/src/server/cache.h b/src/server/cache.h deleted file mode 100644 index 24391e243..000000000 --- a/src/server/cache.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - * $Id: cache.h,v 0.8 1991/11/10 19:02:48 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: cache.h,v 0.8 1991/11/10 19:02:48 linus Exp $ - * - * This file contains the cached data that the server stores. - * .h file created by ceder 1990-04-18 - */ - -/* cache_sync_all only returns when everything is written to disk. */ -extern void -cache_sync_all(void); - - -/* First, some things which I want here. /ceder */ - -extern struct matching_info *match_table; - -extern void -cached_lock_conf(Conf_no conf_no); - -extern Success -init_cache(void); - -extern void -cached_unlock_conf(Conf_no conf); - -extern void -cached_lock_person(Pers_no pers); - -extern void -cached_unlock_person(Pers_no pers); - -extern Success -cached_delete_person(Pers_no pres); - -extern Success -cached_delete_text(Text_no text); - -extern Success -build_matching_info(void); - -extern void /* Write out everything. */ -cache_sync(void); - -/* S}d{r ja. Tack f|r mig. /ceder */ - -#define MAX_CACHED_PERSONS 5 /* To be increased after debugging */ -#define MAX_CACHED_WHATEVER /* To be added */ - - -/* - * Name caching routines - */ - -/* - * change_name changes the cached conference name. It is only called when - * a conference name is changed or a conference is deleted. - * - * cached_change_name(foo, EMPTY_STRING); should be used when a conference - * is deleted. (Eller ska det vara annorlunda? S} g|r jag nu... /ceder) - */ -extern void -cached_change_name(Conf_no name_num, - String new_name ); - - -/* add_name adds a name to the list of cached conference names. It is only - * used when a new conference is created. - */ -extern void -cached_add_name( char * new_name ); - -/* load all the conference names from disk and store them in memory */ -extern void -cached_load_names( void ); - -#if 0 -/* get one name (I want this call! /ceder) */ -/* I no longer want it. */ -extern String -cached_get_name( Conf_no conf_no ); /* Returns NULL if the conference */ - /* doesn't exist. */ -#endif - -extern Bool -cached_conf_exists( Conf_no conf_no ); - -/* - * Calls for the cacheing of conf_type: - * cached_get_conf_type() returns the type. - * The type is set when mark_conference_as_changed is called. - */ - -/* Get conference type */ -/* Undefined result if the conf doesn't exist. */ - -extern Conf_type -cached_get_conf_type (Conf_no conf_no); - -/* - * Get garb_nice for a certain conference. - * It is set when mark_conference_as_changed is called. - */ -extern Garb_nice -cached_get_garb_nice (Conf_no conf_no); - -extern Local_text_no -cached_get_highest_local_no (Conf_no conf_no); - - - -/* - * Person caching routines - */ -#if 0 -extern Person * -cached_read_person( Pers_no pers_no ); -#endif -/* - * Various function calls to tell the cache that something is changed. - */ - -void -mark_person_as_changed(Pers_no pers_no); - - -void -mark_conference_as_changed(Conf_no conf_no); - - -void -mark_text_as_changed(Text_no text_no); - - - - -/* - * Person-related calls - */ - -extern Success -cached_create_person( Pers_no person ); - - - -extern Person * -cached_get_person_stat( Pers_no person ); /* Returns NULL if person - doesn't exist */ - - - -/* - * Conference-related calls - */ -extern Conf_no -cached_create_conf( String name ); - - -extern Success -cached_delete_conf( Conf_no conf ); - -extern Success -cached_lookup_name(const String name, - Conf_list_old *result); - -extern Conference * -cached_get_conf_stat( Conf_no conf_no ); - - -/* - * Calls to handle texts - */ - -extern String -cached_get_text( Text_no text );/* The string should be free'd by the caller */ - -extern Text_stat * -cached_get_text_stat( Text_no text ); - - -extern Text_no -cached_create_text( String message); - -/* - * traverse_text can be used to cycle through all existing texts. 0 will - * be returned once in the "cycle". - */ -extern Text_no -traverse_text(Text_no seed); - -/* - * traverse_person can be used to cycle through all existing persons. 0 will - * be returned once in the "cycle". - */ -extern Pers_no -traverse_person(Pers_no seed); - -/* - * traverse_conference can be used to cycle through all existing conferences. - * 0 will be returned once in the "cycle". - */ -extern Conf_no -traverse_conference(Conf_no seed); - -/* - * Free all memory used by the cache. This should only be done - * as part of the shutdown sequence. The purpose of this is to - * make it possible to see if there are any memory leaks. - */ - -void -free_all_cache(void); - -/* - * Limit the number of 'clean' cache entries. - */ -void -cache_limit_size(void); - -/* - * Dump cache statistics. - */ - -void -dump_cache_stats(FILE *stat_file); - -/* - * Dump memory usage. - */ -void -dump_cache_mem_usage(FILE *stat_file); - -/* - * Export the highest text_no for searching. - */ -int -query_next_text_num(void); diff --git a/src/server/call-switch.awk b/src/server/call-switch.awk deleted file mode 100644 index 46cdbb5f3..000000000 --- a/src/server/call-switch.awk +++ /dev/null @@ -1,81 +0,0 @@ -# -# $Id: call-switch.awk,v 0.4 1991/11/10 19:02:43 linus Exp $ -# Copyright (C) 1991 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. -# -# $Id: call-switch.awk,v 0.4 1991/11/10 19:02:43 linus Exp $ -BEGIN { - printf("/* Don't edit this file - it is generated automatically"); - printf(" from\n call-switch.awk and fncdef.txt */\n"); - printf("\tswitch(client->function)\n\t{\n"); -} -$1 != "#" { - printf("\tcase call_fnc_%s:\n\t ", $2); - if ( $1 == "success" ) - printf("status = %s(", $2); - else - printf("res->number = %s(", $2); - - num=0; - string=0; - c_string=0; - for ( i = 3; i <= NF; i++) - { - if ( i != 3 ) - printf(", "); - if ( $i == ":" ) - { - printf("&res->%s", $(i+1)); - break; - } - if ( $i == "num" ) - printf("client->num%d", num++); - else if ( $i == "string" ) - printf("client->string%d", string++); - else if ( $i == "c_string" ) - printf("client->c_string%d", c_string++); - else if ( $i == "priv_bits" ) - printf("client->priv_bits"); - else if ( $i == "conf_type" ) - printf("client->conf_type"); - else if ( $i == "c_local_text_no_p" ) - printf("client->c_local_text_no_p"); - else if ( $i == "c_misc_info_p" ) - printf("client->c_misc_info_p"); - else if ( $i == "time_date" ) - printf("timelocal(&(client->time))"); - else - printf("\n#error in file server/fncdef.txt\n"); - } - - printf(");\n"); - if ( $1 == "number" ) - { - if ( $2 == "get_time" ) - printf("\t status = OK;\n"); - else - printf("\t status = (res->number != 0) ? OK : FAILURE;\n"); - } - - printf("\t break;\n\n"); -} -END { printf("\t}\n"); } diff --git a/src/server/com-h.awk b/src/server/com-h.awk deleted file mode 100644 index 4c332ec56..000000000 --- a/src/server/com-h.awk +++ /dev/null @@ -1,46 +0,0 @@ -# -# $Id: com-h.awk,v 0.3 1991/09/15 10:32:58 linus Exp $ -# Copyright (C) 1991 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. -# -# $Id: com-h.awk,v 0.3 1991/09/15 10:32:58 linus Exp $ -BEGIN { - printf("/*\n"); - printf(" * Don't edit this file! It is generated from fncdef.txt\n"); - printf(" * and com-h.awk.\n"); - printf(" */\n\n"); - printf("enum call_header {"); - cnt = 0; -} -$1 == "#" { - next; -} -cnt > 0 { - printf(","); -} -{ - printf("\n call_fnc_%-20s = %d", $2, cnt++); -} -END { printf("\n};\n\n"); - printf("typedef enum call_header Call_header;\n"); -} - diff --git a/src/server/conference.c b/src/server/conference.c deleted file mode 100644 index d58181a53..000000000 --- a/src/server/conference.c +++ /dev/null @@ -1,951 +0,0 @@ -/* - * $Id: conference.c,v 0.17 1992/04/09 09:17:44 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * conference.c - * - * All atomic calls that deals with conferences. - */ - -static char *rcsid = "$Id: conference.c,v 0.17 1992/04/09 09:17:44 ceder Exp $"; - - -#include <time.h> -#include <ctype.h> -#include <stdlib.h> -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "manipulate.h" -#include <kom-errno.h> -#include <server/smalloc.h> -#include "cache.h" -#include "log.h" -#include <config.h> -#include "com.h" -#include "connections.h" -#include "send-async.h" -#include <debug.h> -#include <parser.h> -#include "internal-connections.h" -#include "internal-services.h" - -/* - * Defined in conference.c. This will go away when we use regexp-matching. - * This is only temporary. +++*** - */ -extern Conf_no *conf_table; - -/* - * Static functions - */ - -/* - * Delete a conference. Delete all references to this conf. - */ - -static void -do_delete_conf (Conf_no conf_no, - Conference * conf_c) /* Not NULL */ -{ - int i; - - if ( do_set_presentation(conf_no, conf_c, 0) != OK ) - { - log("ERROR: do_delete_conf() - couldn't unmark presentation.\n"); - } - - if ( do_set_etc_motd(conf_no, conf_c, 0) != OK ) - { - log("ERROR: do_delete_conf() - couldn't unmark motd.\n"); - } - - /* Delete all members */ - /* Note that because of the way do_sub_member is written it is important */ - /* that the loop is executed this way. */ - for ( i = conf_c->members.no_of_members - 1; i >= 0; i-- ) - { - do_sub_member( conf_no, conf_c, conf_c->members.members + i, - conf_c->members.members[ i ].member, NULL, NULL); - } - - sfree( conf_c->members.members ); - conf_c->members.members = NULL; - - /* Delete the name */ - - s_clear( &conf_c->name ); - cached_change_name( conf_no, EMPTY_STRING); - - /* texts */ - - /* - * The texts are not deleted at once, but since they now have no recipient - * they will not live long. - */ - - /* ??? Note that there will still be a recipient in the texts, but it - will not exist in reality. This might cause problems. A do_sub_recpt() - should maybe be used. */ - /* Yes, do! Also, send out asynchronous message about deleted conf. */ - - sfree( conf_c->texts.texts ); - conf_c->texts.texts = NULL; - - cached_delete_conf( conf_no ); - - return; -} - -/* - * Functions that are exported to the server. - */ - -/* - * Return TRUE if NAME is not already used. - */ - -Bool -legal_name( String name ) -{ - if (name.len == 0 || name.len > CONF_NAME_LEN ) - { - return FALSE; - } - - while( name.len-- ) - { - if ( /* !isascii(*name.string) && */ - !isprint( *name.string ) ) - { - return FALSE; - } - name.string++; - } - - return TRUE; -} - -/* - * Return TRUE if name is unique, or if the only match is conf_no. Use 0 - * as conf_no if it should not be allowed to be changed. - */ -Bool -unique_name( const String name, Conf_no conf_no ) -{ - Parse_info parse_info; - Parse_token *name_token; - Parse_token *existing_token; - Bool exact_match_found; - Bool diff_found; - int i; - int n; - - parse_info = parse(name, match_table, FALSE, TRUE, - s_fcrea_str(WHITESPACE), - DEFAULT_COLLAT_TAB); - - if ( parse_info.no_of_matches == 0 ) /* Doesn't match any name. */ - { - sfree(parse_info.indexes); - return TRUE; - } - - if ( parse_info.no_of_matches == -1 ) /* Error. */ - { - log("unique_name(): parse returned error.\n"); - sfree(parse_info.indexes); - return FALSE; - } - - if ( parse_info.no_of_matches == 1 && parse_info.indexes[ 0 ] == -1 ) - { - /* Empty name is not allowed. */ - sfree(parse_info.indexes); - return FALSE; - } - - /* The name matches some conference. Check if they are equal. */ - - name_token = tokenize(name, s_fcrea_str(WHITESPACE)); - - exact_match_found = FALSE; - - for ( i = 0; !exact_match_found && i < parse_info.no_of_matches; i++ ) - { - existing_token = match_table[ parse_info.indexes[ i ] ].tokens; - diff_found = FALSE; - - for ( n = 0; - (!diff_found && !s_empty(existing_token[ n ].word) - && !s_empty(name_token[ n ].word)); - ++n) - { - if ( !s_usr_streq(existing_token[ n ].word, - name_token[ n ].word, - DEFAULT_COLLAT_TAB) ) - { - diff_found = TRUE; - } - } - - if (! s_empty(existing_token[ n ].word) - || ! s_empty(name_token[ n ].word) ) - { - /* The length (number of words) differed. */ - diff_found = TRUE; - } - - if ( !diff_found && conf_table[ parse_info.indexes[ i ] ] != conf_no ) - exact_match_found = TRUE; - } - - sfree(parse_info.indexes); - free_tokens(name_token); - return exact_match_found ? FALSE : TRUE; -} - -/* - * Create a conference. - */ -Conf_no -do_create_conf(String name, - Pers_no creator, - Conf_no supervisor, - Conf_no super_conf, - Conf_type type) -{ - Conf_no conf_no; - Conference * conf_c; - - /* Allocate memory for conf_c */ - - conf_no = cached_create_conf( name ); - - if ( (conf_c = cached_get_conf_stat( conf_no ) ) == NULL) - { - restart_kom("create_conf() - can't get conf_stat"); - } - - conf_c->creator = creator; - conf_c->creation_time = time(NULL); - conf_c->presentation= 0; /* No presentation yet */ - conf_c->supervisor = supervisor; - conf_c->permitted_submitters = 0; - conf_c->super_conf = super_conf; - conf_c->type = type; - conf_c->last_written= conf_c->creation_time; - conf_c->msg_of_day = 0; - conf_c->nice = DEFAULT_NICE; - conf_c->members = EMPTY_MEMBER_LIST; - conf_c->texts = EMPTY_TEXT_LIST; - - mark_conference_as_changed (conf_no); - - return conf_no; -} - - -/* - * Return TRUE if viewer is a supervisor to CONF. - */ - -Bool -is_supervisor(Conf_no conf, - Conference * conf_c, /* May be NULL */ - Pers_no viewer, - Person * viewer_p) /* May be NULL */ -{ - if (viewer == 0) /* Not yet logged in. */ - return FALSE; - - if (ENA(wheel, 8)) - return TRUE; - - if (viewer == conf) /* A person is ALWAYS supervisor to */ - return TRUE; /* his/her own mailbox! */ - - - if ( conf_c == NULL ) /* Get conference if unknown to the caller */ - GET_C_STAT( conf_c, conf, FALSE ); - - if ( !conf_c->supervisor ) - return FALSE; - - if (viewer == conf_c->supervisor) - return TRUE; - - if ( viewer_p == NULL ) - GET_P_STAT(viewer_p, viewer, FALSE); - - if ( locate_membership(conf_c->supervisor, viewer_p) != NULL) - return TRUE; - - return FALSE; -} - - -/* - * Atomic functions - */ - -/* - * Change name of a person or conference. You must be supervisor - * of the conference to use this call. - */ -extern Success -change_name (Conf_no conf_no, - String new_name) -{ - Conference * conf_c; - Access acc; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc <= none ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - if ( !ACT_P->privileges.change_name - || (acc != unlimited && !ENA(admin, 3))) - { - kom_errno = KOM_PERM; - return FAILURE; - } - - if ( !legal_name( new_name ) ) - { - kom_errno = KOM_BAD_NAME; - return FAILURE; - } - - if ( !unique_name( new_name, conf_no ) ) - { - kom_errno = KOM_CONF_EXISTS; - return FAILURE; - } - - async_new_name(conf_no, conf_c->name, new_name); - - s_strcpy(&conf_c->name, new_name); - mark_conference_as_changed(conf_no); - - cached_change_name(conf_no, new_name); - - return OK; -} - -/* - * Create a conference: Default modes: - * ACTPERS becomes supervisor and super_conf. - * Anyone can submitt texts. - * Noone (not even the creator) is a member in the conf. - * - * If ANYONE_CAN_CREATE_NEW_CONFS (#defined in config.h) is not true - * you must have the 'create_conf' capability. - * - * It is currently not allowed to have a conference that is secret - * and not rd_prot. This restriction might be lifted in the future - * (but I don't understand the use of such a conference...) - */ - -extern Conf_no -create_conf(String name, - Conf_type type) -{ - Conf_no conf_no; - - CHK_LOGIN(0); - - if (!ANYONE_CAN_CREATE_NEW_CONFS && !ENA(create_conf, 0) ) - { - kom_errno = KOM_PERM; - return 0; - } - - if ( !legal_name( name ) ) - { - kom_errno = KOM_BAD_NAME; - return 0; - } - - if ( !unique_name( name, 0 ) ) - { - kom_errno = KOM_CONF_EXISTS; - return 0; - } - - if ( type.letter_box ) /* A letter_box can only be created via */ - { /* create_person. */ - kom_errno = KOM_PERM; - return 0; - } - - if ( type.secret && !type.rd_prot ) - { - kom_errno = KOM_SECRET_PUBLIC; - return 0; - } - - conf_no = do_create_conf(name, ACTPERS, ACTPERS, ACTPERS, type); - - if ( conf_no != 0) - { - ACT_P->created_confs++; - mark_person_as_changed( ACTPERS ); - } - - return conf_no; -} - -/* - * Log out a person from any connection he might be logged on to. - */ -static void -logout_person(Pers_no pers_no) -{ - Session_no i = 0; - Connection *real_active_connection; - - real_active_connection = active_connection; - - while ( (i = traverse_connections(i)) != 0) - { - active_connection = get_conn_by_number(i); - - if ( active_connection->pers_no == pers_no ) - logout(); - } - - active_connection = real_active_connection; -} - -/* - * Delete a conference or person. You must be supervisor of the - * conference to be allowed to delete it. - */ -extern Success -delete_conf (Conf_no conf_no ) -{ - Conference * conf_c; - Access acc; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc != unlimited ) - { - kom_errno = (acc <= none) ? KOM_UNDEF_CONF : KOM_PERM ; - return FAILURE; - } - - if ( conf_c->type.letter_box ) - { - /* Make sure the person that is deleted is not logged in. */ - - logout_person (conf_no); - - if ( do_delete_pers (conf_no) != OK ) - { - log("ERROR: delete_conf(): can't delete person.\n"); - } - } - - do_delete_conf (conf_no, conf_c); - - return OK; -} - -/* - * Map conference name to number. Can be done without logging in. - * Secret conferences will not be returned unless ACTPERS is supervisor - * of, or member in, that conference. - */ -extern Success -lookup_name (const String name, - Conf_list_old * result) -{ - Conf_no * no, * no_copy; - Conf_type * type, *type_copy; - int i; - - if ( cached_lookup_name( name, result ) != OK ) - return FAILURE; - - no = no_copy = result->conf_nos; - type = type_copy = result->type_of_conf; - - for ( i = result->no_of_conf_nos; i > 0; i-- ) - { - if ( fast_access_perm (*no, ACTPERS, ACT_P) <= none ) - --result->no_of_conf_nos; - else - { - *no_copy++ = *no; - *type_copy++ = *type; - } - - ++no; - ++type; - } - return OK; -} - - -/* - * Get status for a conference. - */ -extern Success -get_conf_stat (Conf_no conf_no, - Conference * result ) -{ - Conference * conf_c; - Access acc; - - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc == error ) - return FAILURE; - - if ( acc == none ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - *result = *conf_c; - - return OK; -} - -extern Success -get_conf_stat_old (Conf_no conf_no, - int mask, - Conference * result ) -{ - Conference * conf_c; - Access acc; - - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc == error ) - return FAILURE; - - if ( acc == none ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - *result = *conf_c; - - if ( !(mask & 1) ) - result->name = EMPTY_STRING; - - return OK; -} - - - -/* - * Set or delete the presentation of a conference. If text_no == 0 there - * will be no presentation. - * - * The text's mark-count will be increased so that it will not be deleted - * when it gets old. - * - * BUGS: This should probably be a Info_type 'presentation to conf no #' - * for at least two reasons: - * 1) Given the text, there is no way to know that it - * is a presentation unless what the user writes - * tells you so. - * 2) Presentations should always be readable by everyone. - * But to be readable an open conference needs to be - * recipient of the text. Since all presentations should - * go to the presentation-confs (that is the clients - * responsibility!) this is no big problem, but it depends - * somewhat on how the text-garber is implemented. - */ - -extern Success -set_presentation (Conf_no conf_no, - Text_no text_no ) -{ - Conference * conf_c; - Access acc; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm(conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc < unlimited ) - { - kom_errno = (acc <= none) ? KOM_UNDEF_CONF : KOM_PERM; - return FAILURE; - } - - return do_set_presentation(conf_no, conf_c, text_no); -} - -/* - * Set a message-of-the-day for a conference. There should normally - * be no motd unless something extraordinary happens. If there is - * a motd the client should show it as soon as possible. - * - * Only the supervisor can change the motd. - * - * BUG: +++ There is no asynchronous message that reports new motds. - */ -extern Success -set_etc_motd( Conf_no conf_no, - Text_no text_no ) -{ - Conference * conf_c; - Access acc; - BUGDECL; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - if ( (acc = access_perm(conf_no, conf_c, ACTPERS, ACT_P)) < unlimited ) - { - kom_errno = (acc <= none ) ? KOM_UNDEF_CONF : KOM_PERM; - BUG(("set_etc_motd failed. Conf %ld Text %ld Acc %ld < %ld (%d).\n", - (u_long)conf_no, (u_long)text_no, (u_long)acc, - (u_long)unlimited, acc < unlimited)); - return FAILURE; - } - - return do_set_etc_motd(conf_no, conf_c, text_no); -} - -/* - * Set a new supervisor for a conference. May only be used by - * the old supervisor. - * - * NEW_SUPER is either a person or a conference number. If it is a - * conference number it means that all the members in NEW_SUPER become - * supervisors to CONF_NO. (NEW_SUPER should normally be rd_prot to - * prevent anyone from makeing themselves supervisors). - */ -extern Success -set_supervisor( Conf_no conf_no, - Conf_no new_super ) -{ - Conference * conf_c; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - if (new_super != 0) - CHK_EXIST(new_super, FAILURE); - - if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) - && !ENA(admin, 6) ) - { - kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; - return FAILURE; - } - - conf_c->supervisor = new_super; - mark_conference_as_changed( conf_no ); - - return OK; -} - -/* - * Allow certain users to submit texts to CONF_NO. - * - * If NEW_PERM_SUB == 0 anyone may submit texts. - * If it is a person only that person can submit texts to CONF_NO. - * If it is a conference only the members in that conference can - * submit texts. - * - * If anyone tries to submit a text to a conference he is not allowed - * to submit texts to the text will silently be redirected to the - * superconf. If he is not allowed to submit to that conference either - * it will be redirected again and so forth, but there is a limit - * (MAX_SUPER_CONF_LOOP) on how many redirections will be done. - * - * It is possible to have a secret conference as super_conf. Users - * will then be able to send texts to it, but they will not see - * where the text went... - */ -extern Success -set_permitted_submitters (Conf_no conf_no, - Conf_no new_perm_sub ) -{ - Conference * conf_c; - - CHK_LOGIN(FAILURE); - if (new_perm_sub != 0) - CHK_EXIST(new_perm_sub, FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) - && !ENA(admin, 6) ) - { - kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; - return FAILURE; - } - - conf_c->permitted_submitters = new_perm_sub; - mark_conference_as_changed( conf_no ); - - return OK; -} - -/* - * Set the super_conf of CONF_NO. This call may only be used of a - * supervisor of CONF_NO. - * - * See documentation for set_permitted_submitters(). - */ -extern Success -set_super_conf (Conf_no conf_no, - Conf_no new_super_conf ) -{ - Conference * conf_c; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - if (new_super_conf != 0) - CHK_EXIST(new_super_conf, FAILURE); - - if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) - && !ENA(admin, 5) ) - { - kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; - return FAILURE; - } - - conf_c->super_conf = new_super_conf; - mark_conference_as_changed( conf_no ); - - return OK; -} - -/* - * Set the type of a conference. Only the supervisor of a conference can - * set the conf_type. The letter_box flag can not be changed. - * - * BUG: It is allowed to set the type to 'secret' for persons. I don't - * think we want it to be that way. - */ -extern Success -set_conf_type (Conf_no conf_no, - Conf_type type ) -{ - Conference * conf_c; - Access acc; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - if ( type.secret && !type.rd_prot ) - { - kom_errno = KOM_SECRET_PUBLIC; - return 0; - } - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P) ; - - if ( acc < unlimited ) - { - kom_errno = ( acc <= none ) ? KOM_UNDEF_CONF : KOM_PERM ; - return FAILURE; - } - - if ( type.letter_box != conf_c->type.letter_box ) - { - kom_errno = KOM_LETTER_BOX; - return FAILURE; - } - - conf_c->type = type; - mark_conference_as_changed (conf_no); - - return OK; -} - - -/* - * Set garb_nice for a conference. This controls how long messages - * to a conference will live. The argument is probably the number of - * days a message will live. Only the supervisor of the conference - * may change the garb_nice. - */ -extern Success -set_garb_nice( Conf_no conf_no, - Garb_nice nice ) /* number of days */ -{ - Conference * conf_c; - Access acc; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc < unlimited ) - { - kom_errno = (acc <= none) ? KOM_UNDEF_CONF : KOM_PERM; - return FAILURE; - } - - conf_c->nice = nice; - mark_conference_as_changed( conf_no ); - - return OK; -} - -/* - * Change presentation of a conference. If text_no is 0, there will be - * no presentation. - */ - -Success -do_set_presentation(Conf_no conf_no, - Conference * conf_c, - Text_no text_no) -{ - Text_stat * old_pres; - Text_stat * new_pres = NULL; /* Initialized to stop gcc complaining - * about this being used uninitialized. - * This initialization is in fact not needed - * since it would not be used uninitialized.*/ - - /* Check that the new presentation exists before deleting the old*/ - - if ( text_no != 0 ) - { - GET_T_STAT(new_pres, text_no, FAILURE); - if ( new_pres->no_of_marks >= MAX_MARKS_TEXT ) - { - log("LIMIT: do_set_presentation(%d, ptr, %d): New presentation" - " has %d marks.\n", conf_no, text_no, new_pres->no_of_marks); - kom_errno = KOM_MARK_LIMIT; - return FAILURE; - } - } - - /* Unmark the previous presentation if it exists. */ - - if ( conf_c->presentation != 0 - && (old_pres = cached_get_text_stat(conf_c->presentation)) != NULL) - { - if ( old_pres->no_of_marks > 0 ) - { - --old_pres->no_of_marks; - mark_text_as_changed( conf_c->presentation ); - } - else - { - log("ERROR: do_set_presentation(): Old presentation not marked\n"); - } - } - - /* Mark the new presentation */ - - if ( text_no != 0 ) - { - ++new_pres->no_of_marks; - mark_text_as_changed( text_no ); - } - - conf_c->presentation = text_no; - mark_conference_as_changed( conf_no ); - - return OK; -} - -/* - * Change motd of a conference. If text_no is 0, there will be - * no motd. - */ - -Success -do_set_etc_motd(Conf_no conf_no, - Conference * conf_c, - Text_no text_no) -{ - Text_stat * old_motd; - Text_stat * new_motd = NULL; /* To stop gcc complaining. */ - - /* Check that the new motd exists before deleting the old*/ - - if ( text_no != 0 ) - { - GET_T_STAT(new_motd, text_no, FAILURE); - if ( new_motd->no_of_marks >= MAX_MARKS_TEXT ) - { - log("LIMIT: do_set_motd(%d, ptr, %d): New motd has %d marks.\n", - conf_no, text_no, new_motd->no_of_marks); - kom_errno = KOM_MARK_LIMIT; - return FAILURE; - } - } - - /* Unmark the previous motd if it exists. */ - - if ( conf_c->msg_of_day != 0 - && (old_motd = cached_get_text_stat(conf_c->msg_of_day)) != NULL) - { - if ( old_motd->no_of_marks > 0 ) - { - --old_motd->no_of_marks; - mark_text_as_changed( conf_c->msg_of_day ); - } - else - { - log("ERROR: do_set_motd(): Old motd not marked\n"); - } - } - - /* Mark the new motd */ - - if ( text_no != 0 ) - { - ++new_motd->no_of_marks; - mark_text_as_changed( text_no ); - } - - conf_c->msg_of_day = text_no; - mark_conference_as_changed( conf_no ); - - return OK; -} - - diff --git a/src/server/connections.c b/src/server/connections.c deleted file mode 100644 index e7929fc2f..000000000 --- a/src/server/connections.c +++ /dev/null @@ -1,958 +0,0 @@ -/* - * $Id: connections.c,v 0.19 1992/06/11 14:32:54 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * connections.c - * - * Denna fil inneh}ller niv}n ovanf|r isc. - * - * Created by Willf|r 31/3-90. Mostly written by ceder. - */ - -static char *rcsid = "$Id: connections.c,v 0.19 1992/06/11 14:32:54 ceder Exp $"; - - -#include <errno.h> -#include <setjmp.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/stat.h> -#include <time.h> -#include <sys/time.h> -#include <string.h> - -#include "s-string.h" -#include <kom-types.h> -#include "lyskomd.h" -#include <config.h> -#include <debug.h> -#include "end-of-atomic.h" -#include "log.h" -#include <services.h> -#include "isc-interface.h" -#include <kom-errno.h> -#include "com.h" -#include "connections.h" -#include "prot-a-parse.h" -#include "prot-a-output.h" -#include "prot-a.h" -#include <server/smalloc.h> -#include "prot-a-parse-arg.h" -#include "isc-parse.h" -#include "cache.h" -#include "send-async.h" -#include "mux.h" -#include "mux-parse.h" -#include "internal-connections.h" -#include "rfc931.h" - -IscMaster * kom_server_mcb = NULL; -Connection * active_connection = NULL; - -/* - * This is set TRUE when the server should be closed. It is checked - * each time around the main loop. It is set if someone with enough - * privileges issues a `shutdown', or of lyskomd receives a SIGHUP. - * This not an abort: all data is saved before we exit. - */ -volatile Bool go_and_die = FALSE; - -/* - * Once upon a time the entire database was always held in core, and - * saved to disk when we got a SIGUSR1 signal. Nowadays the server - * keeps track of the time itself and saves at appropriate intervalls. - * It does still write some statistics when it get a SIGUSR1 signal. - * The signal handler sets do_sync_db. The name is retained for - * historical reasons. - */ -volatile Bool do_sync_db = FALSE; - -jmp_buf parse_env; - - -const Fnc_descriptor fnc_defs[]={ -#include "fnc-def-init.incl" -}; - -u_long service_statistics[sizeof (fnc_defs) / sizeof (Fnc_descriptor)]; - -BUGDECL; - - - -static void -logout_client(Connection *cp) -{ - Connection *real_active_connection; - - if ( active_connection != NULL ) - { - log("BUGCHK: logout_client(%d): connection %d is active.\n", - cp->session_no, active_connection->session_no); - } - - switch (cp->magic) - { - case CONN_MAGIC_ALLOC: - break; - - case CONN_MAGIC_FREE: - log("LOGOUT_CLIENT: Trying to free freed Connection - ignored!\n"); - return; - - default: - restart_kom("LOGOUT_CLIENT: Bad magic number\n"); - } - - if ( cp->pers_no != 0 ) - { - real_active_connection = active_connection; /* Shouldn't be needed +++ */ - active_connection = cp; - logout(); - active_connection = real_active_connection; - } - - switch(cp->protocol) - { - case 0: /* Hasn't yet allocated any protocol. */ - break; - - case 'A': - prot_a_destruct(cp); - break; - - default: - restart_kom("logout_client(): Bad protocol.\n"); - } - - mux_close(cp); /* Close fd's. Clear mux and isc structures. */ - - kill_client(cp); /* Free the Connection */ -} - -/* - * This function is part of the shutdown tidy-up sequence. - */ -void -logout_all_clients(void) -{ - Session_no sess = 0; - Connection *conn; - - while ( (sess = traverse_connections (sess)) != 0) - { - conn = get_conn_by_number (sess); - - if ( conn == NULL ) - restart_kom("logout_all_clients(): cant get session %d.\n", - sess); - else - logout_client (conn); - } - - if ( traverse_connections (0) != 0) - restart_kom("logout_all_clients(): traverse_connections(0) == %d.\n", - traverse_connections(0)); -} - - - - - -/* - * Call a function in services.c. A pointer to the result is returned. - * The pointer points to static data which is overwritten on each call. - */ -static Success -call_function (Connection * client, - Result_holder * res) /* This is a union. */ -{ - Success status=FAILURE; /* OK if the call was successful. */ - - if ( active_connection != NULL ) - { - log("call_function(%d): active_connection = %d", - client->session_no, active_connection->session_no); - } - - active_connection = client; - - service_statistics[client->function]++; - -#include "call-switch.incl" - - active_connection = NULL; - - return status; -} - - -static void -parse_packet(Connection *client) -{ - if ( client->protocol == '\0' ) /* Not known yet. */ - { - client->protocol = parse_char(client); - switch(client->protocol) - { - case 'A': - prot_a_init(client); - break; - - default: - client->protocol = '\0'; - mux_printf(client, - "%%%%LysKOM unsupported protocol.\n"); - mux_flush(client); - BUG(("%%%%Unsupported protocol.\n")); - longjmp(parse_env, ISC_LOGOUT); - } - } - - switch(client->protocol) - { - case 'A': - prot_a_parse_packet(client); - break; - - default: - restart_kom("parse_packet(): Bad protocol.\n"); - break; - } -} - -/* - * Free all parsed areas which are no longer needed. Re-initialize all - * parse_pos fields so that the parse will expect a new function. - * - * This function is called - * when a parse error occurs - * when a parse is complete and the function has executed. - */ -static void -free_parsed(Connection *client) -{ - s_clear(&client->c_string0); - s_clear(&client->c_string1); - client->string0 = EMPTY_STRING; /* So that no one frees it. */ - sfree( client->c_misc_info_p); - client->c_misc_info_p = NULL; - sfree( client->c_local_text_no_p); - client->c_local_text_no_p = NULL; - client->parse_pos = 0; - client->fnc_parse_pos = 0; - client->array_parse_pos = 0; - client->struct_parse_pos = 0; - client->string_parse_pos = 0; -} - -/* - * Send a reply to a call. - */ -static void -reply(Connection *client, - Success status, - Result_holder *result) -{ - switch(client->protocol) - { - case 'A': - prot_a_reply(client, status, result); - break; - - default: - restart_kom("reply(): Bad protocol.\n"); - break; - } -} - - -/* - * Try to parse enough data from client->unparsed to call a function. - * If more data is needed set client->more_to_parse to FALSE. - */ -static void -parse_unparsed(Connection *client) -{ - String tmp_str = EMPTY_STRING; - Success status; - Result_holder result; - - switch ( setjmp(parse_env) ) - { - case 0 : - /* Parse message. If message is complete call function and reply. */ - parse_packet(client); - client->last_request = time(NULL); - status = call_function(client, &result); - reply(client, status, &result); - free_parsed(client); - end_of_atomic(FALSE); - break; - - case ISC_PROTOCOL_ERR: - s_clear(&client->string0); - free_parsed(client); - mux_printf(client, "%% LysKOM protocol error.\n"); - mux_flush(client); - BUG(("%%%% Protocol error.\n")); - s_clear(&client->unparsed); - client->first_to_parse = 0; - client->more_to_parse = FALSE; - end_of_atomic(FALSE); - break; - - case ISC_MSG_INCOMPLETE: - client->more_to_parse = FALSE; - break; - - case ISC_LOGOUT: - add_to_kill_list(client); - break; - } - - /* Delete the parsed part of 'unparsed' */ - - if ( s_substr(&tmp_str, client->unparsed, - client->first_to_parse, END_OF_STRING) != OK ) - restart_kom("parse_unparsed: s_substr\n"); - - s_clear(&client->unparsed); - client->unparsed = tmp_str; - client->first_to_parse = 0; -} - - -/* - * There is a message in the event. Parse it. - */ -static void -parse_message(Connection *cp, String tmp_str) -{ - VBUGSTR(tmp_str); - - cp->more_to_parse = TRUE; - - if ( s_strcat(&cp->unparsed, tmp_str) != OK ) - restart_kom("parse_message(): s_strcat\n"); - - tmp_str = EMPTY_STRING; - - /* Parse this packet, but leave the last token if it isn't complete. */ - - parse_unparsed(cp); - - return; -} - -static void -mux_handle_packet(Mux *mux) -{ - Mux_client *mcp = NULL; - Connection *cp = NULL; - - switch(mux->parse.function) - { - case 0: /* ping */ - isc_printf(mux->scb, "0\n"); - isc_flush(mux->scb); - break; - - case 1: /* login */ - - mcp = mux_getclientbyid(mux, mux->parse.num); - if (mcp) - { /* ERROR %d: Already logged in\n */ - isc_printf(mux->scb, "4\n"); - isc_flush(mux->scb); - return; - } - - cp = new_client(); - cp->mux = mux; - cp->hostname = mux->parse.string; - mux->parse.string = EMPTY_STRING; - - mux_addclient(mux, mux->parse.num, cp); - - - BUG(("\n[Client %d from %.*s via MUX %s", - cp->session_no, - (int)cp->hostname.len, - cp->hostname.string, - isc_gethostname(mux->scb->info.tcp.raddr, NULL, 0))); - BUG((" is connecting]\n")); - - break; - - case 2: /* logout */ - mcp = mux_getclientbyid(mux, mux->parse.num); - if (!mcp) - { /* ERROR %d: No such mux-session */ - isc_printf(mux->scb, "4\n"); - isc_flush(mux->scb); - return; - } - - cp = mcp->conn; - - BUG(("\n[Client %d via MUX(%s)", - cp->session_no, - isc_gethostname(mux->scb->info.tcp.raddr, NULL, 0))); - BUG((" is logging out by request]\n")); - - add_to_kill_list(cp); - break; - - case 3: /* msg */ - mcp = mux_getclientbyid(mux, mux->parse.num); - if (!mcp) - { /* ERROR %d: No such mux-session */ - isc_printf(mux->scb, "4\n"); - isc_flush(mux->scb); - return; - } - - cp = mcp->conn; - - VBUG(("\n[Message client %d via MUX #%d]\n", - cp->session_no, (int)mux->scb)); - - parse_message(cp, mux->parse.string); - break; - - default: - - VBUG(("\nMUX Protocol error from MUX #%d]\n", - (int)mux->scb)); - - isc_printf(mux->scb, "5\n"); - isc_flush(mux->scb); - break; - - } -} - -static void -mux_logout(Mux *mp) -{ - int i; - - for (i = 0; i < mp->client_c; i++) - if (mp->client_v[i].conn) - { - BUG(("\n[Client %d via MUX(%s)", - mp->client_v[i].conn->session_no, - isc_gethostname(mp->scb->info.tcp.raddr, NULL, 0))); - BUG((" is logging out by MUX shutdown]\n")); - logout_client(mp->client_v[i].conn); - end_of_atomic(FALSE); - } - - isc_destroy(kom_server_mcb, mp->scb); - mux_destruct(mp); -} - - -static void -mux_parse_unparsed(Mux *mux) -{ - String tmp_str; - - while ( mux->parse.more_to_parse ) - { - switch ( setjmp(mux_parse_env) ) - { - case 0 : - /* Parse message. Take apropriate action if message is complete. */ - mux_parse_packet(mux); - mux_handle_packet(mux); - mux_free_parsed(mux); - break; - - case MUX_PROTOCOL_ERR: - s_clear(&mux->parse.string); - mux_free_parsed(mux); - isc_printf(mux->scb, "5\n"); - isc_flush(mux->scb); - BUG(("%%%% Mux protocol error.\n")); - s_clear(&mux->parse.unparsed); - mux->parse.first_to_parse = 0; - mux->parse.more_to_parse = FALSE; - break; - - case MUX_MSG_INCOMPLETE: - mux->parse.more_to_parse = FALSE; - break; - - case MUX_LOGOUT: - mux_logout(mux); - return; - } - - /* Delete the parsed part of 'unparsed' */ - - tmp_str = EMPTY_STRING; - - if ( s_substr(&tmp_str, mux->parse.unparsed, - mux->parse.first_to_parse, END_OF_STRING) != OK ) - restart_kom("mux_parse_unparsed: s_substr\n"); - - s_clear(&mux->parse.unparsed); - mux->parse.unparsed = tmp_str; - mux->parse.first_to_parse = 0; - } -} - - -static void -mux_parse_message(Mux *mp, String tmp_str) -{ - VBUGSTR(tmp_str); - - BUG(("mux_parse_message(): mp->parse.unparsed = { len = %d, " - "string = %p }\n", mp->parse.unparsed.len, - (void *)mp->parse.unparsed.string)); - - if ( s_strcat(&mp->parse.unparsed, tmp_str) != OK ) - restart_kom("mux_parse_message(): s_strcat\n"); - - tmp_str = EMPTY_STRING; - - /* Parse this packet, but leave the last token if it isn't complete. */ - - mux_parse_unparsed(mp); - - return; -} - -/* - * parse data in client->unparsed and mux->unparsed if there - * is data that has not yet been taken care of. Return TRUE - * if there was no data to take care of. - */ -static Bool -parse_forgotten(void) -{ - Bool flg = FALSE; /* Was there anything? */ - Connection *ci; - Session_no session_no = 0; - - if ( traverse_connections(0) == 0 ) - return TRUE; - - while ( ( session_no = traverse_connections( session_no ) ) != 0 ) - { - ci = get_conn_by_number (session_no); - - if ( ci->more_to_parse ) - { - parse_unparsed(ci); - flg = TRUE; - } - } - - return !flg; -} - - -/* Return 1 if the named file exists, 0 otherwise */ -static int -fexists(const char *filename) -{ - struct stat buf; - int code; - - code = !stat(filename, &buf); - errno = 0; - - return code; -} - - -void -dump_statistics(void) -{ - static time_t last_dump = NO_TIME; - int i; - time_t now; - FILE *fp; - extern char statisticfile[1024]; /* Defined in ramkomd.c */ - - if ( (fp = fopen(statisticfile, "a")) == NULL ) - { - log(__FILE__ ": dump_statistics(): can't open file %s\n", - statisticfile); - return; - } - - time(&now); - - if (last_dump == NO_TIME) - { - fprintf(fp, "RESTART\n"); - last_dump = now; - } - - fprintf(fp, "TIME: %s", ctime(&now)); - fprintf(fp, "SECONDS: %d\n", (int)difftime(now, last_dump)); - fprintf(fp, "STATISTICS:"); - for ( i = 0; i < sizeof(service_statistics) / sizeof(u_long); i++) - { - fprintf(fp, " %lu", service_statistics[i]); - service_statistics[i]=0; - } - - fprintf(fp, "\n"); - fclose(fp); - - last_dump = now; -} - -/* List of connections to kill. */ - -Session_no *kill_list = NULL; -int kill_list_size = 0; - -/* Schedule this client for termination. */ -void -add_to_kill_list(Connection *conn) -{ - int i; - - for (i = 0; i < kill_list_size; i++) - if (kill_list[kill_list_size] == conn->session_no) - { - log("add_to_kill_list(%d): already present as %d of %d.\n", - conn->session_no, i, kill_list_size); - return; - } - - if (kill_list == NULL) - { - if (kill_list_size != 0) - restart_kom("add_to_kill_list(): size = %d\n", kill_list_size); - - kill_list_size = 1; - kill_list = smalloc(sizeof(Session_no)); - } - else - { - kill_list_size++; - kill_list = srealloc(kill_list, kill_list_size * sizeof(Session_no)); - } - - kill_list[kill_list_size-1] = conn->session_no; -} - -/* - * check_kill_flg must NEVER be called inside an atomic call! - */ -static void -check_kill_flg(void) -{ - Connection *conn; - - if ( active_connection != NULL ) - { - restart_kom("check_kill_flg: active_connection == %d", - active_connection->session_no); - } - - while (kill_list_size > 0) - { - --kill_list_size; - conn = get_conn_by_number (kill_list[kill_list_size]); - if (conn == NULL) - { - log("check_kill_flg(): Connection %d doesn't exist.\n", - kill_list[kill_list_size]); - } - else - { - logout_client (conn); - end_of_atomic (FALSE); - } - } - - if (kill_list != NULL) - { - sfree (kill_list); - kill_list = NULL; - } -} - -static void -login_request(IscEvent *event) -{ - Connection * cp; - char *realuser; - int localport; - IscAddress *isc_adr; - char *hostname = NULL; - - if (isc_sessions(kom_server_mcb) >= MAX_NO_OF_CONNECTIONS) - { - BUG(("Connection attempt rejected.\n")); - isc_printf(event->session, "%s", "%% No connections left.\n"); - isc_flush(event->session); - isc_destroy(kom_server_mcb, event->session); - - async_rejected_connection(); - return; - } - - /* Supress logins if /etc/nologin exists */ - if (fexists("/etc/nologin")) - { - isc_printf(event->session, "%s", "%% No logins allowed.\n"); - isc_flush(event->session); - isc_destroy(kom_server_mcb, event->session); - return; - } - - /* Find out if it is a mux or a client that tries to connect to - us. Do it by getting the local port number. */ - - isc_adr = isc_getladdress (event->session); - if (isc_adr == NULL) - restart_kom("login_request(): can't isc_getladdress (%lu)\n", - event->session); - - localport = isc_getportnum (isc_adr); - isc_freeaddress (isc_adr); - - if (localport == num_ip_mux_port) - { - /* Multiplexer requesting connection */ - - /* - ** Create, and setup the MUX for the MUX case - */ - event->session->udg = mux_create(MUX_TYPE_MUX, event->session); - - BUG(("MUX #%d at %s connecting.\n", - (int)event->session, - isc_gethostname(event->session->info.tcp.raddr, NULL, 0))); - } - else if (localport == num_ip_client_port) - { - /* Client requesting connection */ - - /* - ** Create, and setup the MUX for the CLIENT case - */ - event->session->udg = mux_create(MUX_TYPE_CLIENT, - event->session); - - cp = new_client(); - cp->mux = event->session->udg; - hostname = isc_gethostname(event->session->info.tcp.raddr, NULL, 0); - if (hostname == NULL) - hostname = isc_getipnum(event->session->info.tcp.raddr, NULL, 0); - if (hostname == NULL) - { - log("WNG: login_request(): unknown hostid.\n"); - s_crea_str(&cp->hostname, "unknown"); - } - else - s_crea_str(&cp->hostname, hostname); - - /* Get the real user name, as returned by the Ident protocol - (rfc 931). */ - realuser = get_real_username(event->session); - if (realuser != NULL) - s_crea_str(&cp->ident_user, realuser); - - mux_addclient(event->session->udg, 0, cp); - - BUG(("\n[Client %d from %s", cp->session_no, - isc_gethostname(event->session->info.tcp.raddr, NULL, 0))); - BUG((" is connecting]\n")); - } - else - { - /* Help! It was neither a client, nor a mux. */ - restart_kom("login_request(): Neither client, nor mux.\n"); - } -} - -static void -logout_request(IscEvent *event) -{ - Connection * cp; - - if (event->session->udg->type == MUX_TYPE_MUX) - { - BUG(("\n[MUX #%d at %s", (int)event->session, - isc_gethostname(event->session->info.tcp.raddr, NULL, 0))); - BUG((" is logging out]\n")); - - /* - ** Logout any remaining clients - */ - mux_logout(event->session->udg); - } - else - { - cp = event->session->udg->client_v[0].conn; - - BUG(("\n[Client %d from %s", cp->session_no, - isc_gethostname(event->session->info.tcp.raddr, NULL, 0))); - BUG((" is logging out]\n")); - - add_to_kill_list(cp); - } -} - - -static void -message_request(IscEvent *event) -{ - Connection *cp; - String tmp_str; - - if (event->session->udg->type == MUX_TYPE_MUX) - { - event->session->udg->parse.more_to_parse = TRUE; - tmp_str.string = (unsigned char *)event->msg->buffer; - tmp_str.len = event->msg->length; - mux_parse_message(event->session->udg, tmp_str); - } - else - { - cp = event->session->udg->client_v[0].conn; - VBUG(("\n[Message from client %d]\n", - cp->session_no)); - /* - ** Pass the message on to the parser - */ - tmp_str.string = (unsigned char *)event->msg->buffer; - tmp_str.len = event->msg->length; - parse_message(cp, tmp_str); - } -} - -static long -timevaldiff(struct timeval a, - struct timeval b) -{ - return 1000000 * (a.tv_sec - b.tv_sec) + a.tv_usec - b.tv_usec; -} - -void -toploop(void) -{ - IscEvent * event; - Bool pending_input = TRUE; /* Should be TRUE whenever there - is or might be pending input - from any client in the unparsed - buffer. */ - long timeout = 0; /* In milliseconds. Start with a - small value since we should - start garbing right away. */ - struct timeval before, after; - - while ( !go_and_die ) - { - if (do_sync_db) - { - /* - * do_sync_db used to save the entire database. Nowadays - * all it does is to print some statistics. - */ - cache_sync(); /* A noop in lyskomd. Actually - stops the server and dumps - everything in ramkomd. */ - dump_statistics(); - do_sync_db = FALSE; - } - - gettimeofday(&before, NULL); - event = isc_getnextevent(kom_server_mcb, - pending_input ? 0 : timeout ); - gettimeofday(&after, NULL); - - timeout -= timevaldiff(after, before) / 1000; - - if ( timeout < 0 ) - timeout = 0; - - if ( event == NULL ) - restart_kom("toploop(): Got NULL event - shouldn't happen...\n"); - - switch ( event->event ) - { - case ISC_EVENT_ERROR: - if (errno != EINTR) - { - log("toploop: ISC_EVENT_ERROR (error = '%s'):\n '%s'\n", - strerror(errno), event->msg ? event->msg->buffer - : "(unknown)"); - } - break; - - case ISC_EVENT_TIMEOUT: - BUG((">")); -#ifdef DEBUG - fflush(stdout); -#endif - if ( pending_input == FALSE ) - timeout = end_of_atomic(TRUE); /* Idle. Do some cleaning up. */ - else - { - if ( timeout == 0 ) - end_of_atomic(FALSE); - pending_input = !parse_forgotten(); - } - - - break; - - case ISC_EVENT_LOGIN: - pending_input = TRUE; - login_request(event); - break; - - case ISC_EVENT_LOGOUT: - pending_input = TRUE; - logout_request(event); - break; - - case ISC_EVENT_MESSAGE: - pending_input = TRUE; - message_request(event); - break; - - default: - pending_input = TRUE; - log("ERROR: toploop(): Unknown ISC_EVENT\n"); - break; - } - - isc_dispose(event); - - check_kill_flg(); - } -} diff --git a/src/server/connections.h b/src/server/connections.h deleted file mode 100644 index 94a7fd215..000000000 --- a/src/server/connections.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * $Id: connections.h,v 0.11 1992/05/18 23:09:19 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: connections.h,v 0.11 1992/05/18 23:09:19 ceder Exp $ - * - * connections.h -- The top level of the communication packet. - * - * Requires kom-types.h, com.h - */ - - -extern volatile Bool go_and_die; /* Set this to TRUE to kill the server. */ -extern volatile Bool do_sync_db; /* Set this to TRUE to force a sync via - signal. */ - -#define CONN_MAGIC_ALLOC 0x18F4AE74 -#define CONN_MAGIC_FREE 0x67A7B144 - -typedef struct connection { - unsigned long magic; /* Hey, this is like magic! */ - - struct connection * prev; - struct connection * next; - - /* The following are used by services.c (which has been split - into many files such as conference.c and person.c). */ - - Pers_no pers_no; /* 0 if not yet logged in. */ - Person * person; /* NULL if not yet logged in. */ - time_t session_start; /* the time when the current session - was started */ - Conf_no cwc; /* Current working conference */ - String what_am_i_doing; - u_char ena_level; /* Enable level */ - String username; /* Given userid. */ - String hostname; /* Real hostname */ - String ident_user; /* Real username */ - Bool invisible; /* Is this session invisible? */ - Bool username_valid; /* Set once username is set. */ - - /* The following are used by server/connections.c */ - - struct mux *mux; - u_char protocol; - - int parse_pos; - int fnc_parse_pos; - int array_parse_pos; - int struct_parse_pos; - int string_parse_pos; - - int ref_no; - Call_header function; /* Function to call. */ - - /* Gather data in these variables. */ - - long num0; - long num1; - long num2; - long num3; - String c_string0; /* These strings are used for strings - * that are *NOT* freed by services.c. - * They are freed by free_parsed() in - * connections.c */ - String c_string1; - String string0; /* This string is used for strings that - * are freed by the routines in services.c */ - Misc_info *c_misc_info_p; /* Freead by free_parsed(). */ - Local_text_no *c_local_text_no_p; /* Freead by free_parsed(). */ - Priv_bits priv_bits; - Conf_type conf_type; - struct tm time; - - /* Protocol independent things. */ - - String unparsed; - String_size first_to_parse; /* Index into unparsed. */ - Bool more_to_parse; /* Any chance that there is anything - left in unparsed? */ - time_t last_request; /* Set every time a packet is - received from the client. */ - - Session_no session_no; /* A unique number. */ -} Connection; -/* - * It is guaranteed that in the Connection struct the pers_no and person - * fields are either both 0/NULL, or both non-0/non-NULL. - */ - - -/* - * Data for the isc-server. - */ -extern struct isc_mcb *kom_server_mcb; - -/* - * active_connection points to the info about the client who initiated this - * call. This is set by connectins.c whenever a complete message is parsed - * and a function in services.c is called. - */ -Connection * active_connection; - - -/* - * This enum describes the result of a function in services.c. - */ -typedef enum { - rt_number, /* E.g. Pers_no, Conf_no, Text_no. - This is somewhat special in that the - function indicates an error by returning - 0 and not FAILURE. */ - rt_success, /* Only return a Success. */ - /* Functions of the following types returns a Success _and_ data - of the indicated type. The corresponding types are found in - kom-types.h */ - rt_person, - rt_membership, - rt_conf_list, - rt_conf_no_list, - rt_conference, - rt_string, - rt_mark_list, - rt_text_stat, - rt_text_list, - rt_who_info_list, - rt_who_info_list_old, - rt_info, - rt_membership_list, - rt_member_list, - rt_time_date, - rt_session_info, - rt_session_no, - rt_text_no, - rt_session_info_ident, - rt_who_info_ident_list -} Res_type; - -/* - * The result from a call is stored in this union. - * - * The pointers in these structures are normally set to point into - * data from the cache, and should thus not be free()d. In those cases - * where this actually contains newly allocated memory (and it is not - * allocated via tmp_alloc()) it should be free()d in prot_a_reply() in - * prot-a.c. - */ -typedef union { - u_long number; - Person person; - Membership membership; - Conf_list_old conf_list; - Conf_no_list conf_no_list; - Conference conference; - Mark_list mark_list; - String string; - Text_stat text_stat; - Text_list text_list; - Info info; - Who_info_list who_info_list; - Who_info_list_old who_info_list_old; - Membership_list membership_list; - Member_list member_list; - time_t time_date; - Session_info session_info; - Session_no session_no; - Text_no text_no; - Who_info_ident_list who_info_ident_list; - Session_info_ident session_info_ident; -} Result_holder; - - -typedef struct { - Res_type result; - /* The function that is used to parse args for this function: */ - void (*parser)(Connection *client); -} Fnc_descriptor; - -extern const Fnc_descriptor fnc_defs[]; - -/* - * This array holds number of calls to each service. It is dumped to the - * log file every time the server syncs. - */ -extern u_long service_statistics[]; - - -#ifdef _JBLEN -extern jmp_buf parse_env; -#endif - -extern void -toploop(void); - -extern void -dump_statistics(void); - -extern void -logout_all_clients(void); - -extern void -add_to_kill_list(Connection *conn); - diff --git a/src/server/dbck-cache.c b/src/server/dbck-cache.c deleted file mode 100644 index e269e252c..000000000 --- a/src/server/dbck-cache.c +++ /dev/null @@ -1,773 +0,0 @@ -/* - * $Id: dbck-cache.c,v 0.10 1992/03/23 08:02:50 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * This module contains some very simple simulations of the routines in - * cache.c. - * - * Extracted from ram-cache.c and rewritten by ceder. - * - * New database format with texts in their own file by Inge Wallin. - * Also save time as a time_t instead of a struct tm. - */ - -static char *rcsid = "$Id: dbck-cache.c,v 0.10 1992/03/23 08:02:50 ceder Exp $"; - - -/* - * All functions that can fail sets kom_errno to a suitable value - * if they fail. - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <sys/file.h> -#include <unistd.h> -#include <errno.h> - -#include <kom-errno.h> -#include <kom-types.h> -#include "s-collat-tabs.h" -#include <server/smalloc.h> -#include "cache.h" -#include <debug.h> -#include "lyskomd.h" -#include <parser.h> -#include "ram-parse.h" -#include "log.h" -#include "ram-output.h" -#include "com.h" -#include "connections.h" -#include "send-async.h" -#include "memory.h" -#include "dbck-cache.h" - -#ifdef TIME_SYNC -# include <sys/resource.h> -#endif - -#define EXPORT - -#include "tmp-limits.h" - -Person * pers_arr[ MAX_CONF ]; -Conference * conf_arr[ MAX_CONF ]; -Conf_type conf_type_arr[ MAX_CONF ]; -String name_list [ MAX_CONF ]; /* "cache" list */ - /* Global var auto init to NULL */ -int next_free_num = 1; - -Text_stat * text_arr[ MAX_TEXT ]; -int next_text_num = 1; - -/* Defined in ramkomd.c */ -extern char datafilename[]; -extern char backupfilename[]; -extern char textfilename[]; - - -static FILE *text_file = NULL; -static FILE *new_text_file = NULL; /* Used when garbage collecting. */ - -BUGDECL; - - -/* Macros */ - -#define TRACE2(format, arg) if ( buglevel > 2 ) printf(format, arg) -#define TRACE1(format) if ( buglevel > 2 ) printf(format) -#define TRACESTR(str) if ( buglevel > 2 ) s_puts(str) -#define INRANGE(str, num, retval) if ( num == 0 || num >= next_free_num ) \ -{ \ - return retval; \ - printf("%s: conf_no %d out of range 1 ... %d ", str, num, next_free_num); \ - fflush(stdout); \ - fflush(stderr); \ - abort(); \ -} - -#define TEXT_RANGE(str, num, retval) if ( num == 0 || num >= next_text_num ) \ -{ \ - return retval;\ - printf("Text_no out of range 1 ... %d ", next_text_num); \ - printf(str); \ - fflush(stdout); \ - fflush(stderr); \ - abort(); \ -} - - -extern Conf_type -cached_get_conf_type (Conf_no conf_no) -{ - return conf_arr [ conf_no ]->type; -} - - - -#define IMPL(retval) if (1) { fflush(stderr); fflush(stdout); abort(); } - - -/* - * Various function calls to tell the cache that something is changed. - */ - -void -mark_person_as_changed(Pers_no pers_no) -{ - TRACE2("Person %d is changed\n", pers_no); - return; -} - - -void -mark_conference_as_changed(Conf_no conf_no) -{ - TRACE2("Conf. %d is changed\n", conf_no); - return; -} - -void -mark_text_as_changed( Text_no text_no ) -{ - TRACE2("Text %d is changed.\n", text_no); - TEXT_RANGE("mark_text_as_changed\n", text_no, (void)0); -} - - -/* - * Person-related calls - */ - - -extern Success -cached_create_person( Pers_no person ) -{ - TRACE2("Person %d is being created.\n", person); - INRANGE("cached_create_person\n", person, FAILURE); - - if ( pers_arr[ person ] != NULL ) - { - TRACE1("pers_arr not NULL"); - fflush(stdout); - fflush(stderr); - abort(); - } - - pers_arr[ person ] = alloc_person(); - return OK; -} - - -extern Person * -cached_get_person_stat( Pers_no person ) -{ - INRANGE("cached_get_person_stat\n", person, NULL); - TRACE2("cached_get_person_stat %d\n", person); - kom_errno = KOM_UNDEF_PERS; - - return pers_arr[ person ]; -} - - - -/* - * Conference-related calls - */ -extern Conf_no /* Also cache the name */ -cached_create_conf (String name) -{ - Conference * conf_c; - Conf_no conf_no; - - TRACE1("cached_create_conf( "); - TRACESTR(name); - TRACE1(" )\n"); - - if ( next_free_num >= MAX_CONF ) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - return 0; - } - - conf_no = next_free_num++; - conf_c = alloc_conference(); - - conf_c->name = EMPTY_STRING; - s_strcpy(&conf_c->name, name); - - TRACE2(" number %d\n", conf_no); - - conf_arr[ conf_no ] = conf_c; - pers_arr[ conf_no ] = NULL; - - return conf_no; -} - -extern Success -cached_delete_conf( Conf_no conf ) -{ - INRANGE("cached_delete_conf()", conf, FAILURE); - if ( conf_arr[ conf ] == NULL ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - free_conference(conf_arr[ conf ]); - conf_arr[ conf ] = NULL; - return OK; -} - -Success -cached_delete_person(Pers_no pers) -{ - INRANGE("cached_delete_person()", pers, FAILURE); - if ( pers_arr[ pers ] == NULL ) - { - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - pers_arr[ pers ] = NULL; - return OK; -} - -Success -cached_delete_text(Text_no text) -{ - TEXT_RANGE("cached_delete_text()", text, FAILURE); - if ( text_arr[ text ] == NULL ) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - free_text_stat(text_arr[ text ]); - text_arr[ text ] = NULL; - return OK; - -} - - -extern Conference * -cached_get_conf_stat( Conf_no conf_no ) -{ - INRANGE("cached_get_conf_stat\n", conf_no, NULL); - TRACE2("cached_get_conf_stat %d\n", conf_no); - kom_errno = KOM_UNDEF_CONF; - - return conf_arr[ conf_no ]; -} - -/* - * Return TRUE if conf_no exists. - */ -Bool -cached_conf_exists(Conf_no conf_no) -{ - return conf_arr[ conf_no ] != NULL ? TRUE : FALSE; -} - - -/* - * Calls to handle texts - */ - -extern String -cached_get_text( Text_no text ) -{ - String the_string; - - TEXT_RANGE("cached_get_text\n", text, EMPTY_STRING); - TRACE2("cached_get_text %d\n", text); - - if ( text_arr[ text ] == NULL ) - return EMPTY_STRING; - else - { - the_string.string = tmp_alloc( text_arr[text]->no_of_chars ); - the_string.len = text_arr[text]->no_of_chars; - fseek(text_file, text_arr[ text ]->file_pos, SEEK_SET); - if ( fread(the_string.string, sizeof(char), the_string.len, text_file) - != the_string.len ) - { - log("WARNING: cached_get_text: " - "couldn't read enough characters of text %d\n", - text); - } - - return the_string; - } -} - -extern Text_stat * /* NULL on error */ -cached_get_text_stat( Text_no text ) -{ - kom_errno = KOM_NO_SUCH_TEXT; - TEXT_RANGE("cached_get_text_stat\n", text, NULL); - TRACE2("cached_get_text_stat %d\n", text); - - return text_arr[ text ]; -} - - - -/* - * The text is set up with an empty misc-field. The misc field is - * later initialized by create_text. - */ - -#if 0 -extern Text_no -cached_create_text( String message) -{ - Text_no tno; - - tno = next_text_num++; - - TRACE2("cached_create_text (len=%d)\n", message.len); - - if ( tno >= MAX_TEXT ) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - next_text_num = MAX_TEXT; - - return 0; - } - - text_arr[ tno ] = alloc_text_stat(); - text_arr[ tno ]->no_of_misc = 0; - text_arr[ tno ]->misc_items = NULL; - text_arr[ tno ]->no_of_marks = 0; - text_arr[ tno ]->no_of_lines = 0; - text_arr[ tno ]->no_of_chars = 0; - fseek(text_file, 0, SEEK_END); - text_arr[ tno ]->file_pos = ftell(text_file); - - if ( fwrite(message.string, sizeof(char), message.len, text_file) - != message.len ) { - log("WARNING: cached_create_text: Couldn't write the text %d\n", - tno); - } - - fflush(text_file); - - TRACE2("cached_create_text -> %d\n", tno); - - return tno; -} -#endif - -void -cached_flush_text(Text_no text_no, - String message) -{ - if ( text_no >= next_text_num ) - { - log("cached_flush_text(%lu, string): only text %lu exists.", - (u_long) text_no, (u_long) next_text_num); - return; - } - - fseek(new_text_file, 0, SEEK_END); - text_arr[ text_no ]->file_pos = ftell(new_text_file); - - if ( fwrite(message.string, sizeof(char), message.len, new_text_file) - != message.len ) - { - log("WARNING: cached_flush_text: Couldn't write the text %d\n", - text_no); - } - - fflush(new_text_file); -} - -Text_no -traverse_text(Text_no seed) -{ - seed++; - - while ( seed < next_text_num && text_arr[ seed ] == NULL ) - seed++; - - return (seed == next_text_num) ? 0 : seed ; -} - -Pers_no -traverse_person(Pers_no seed) -{ - seed++; - - while ( seed < next_free_num && pers_arr[ seed ] == NULL ) - seed++; - - return (seed == next_free_num) ? 0 : seed ; -} - -Conf_no -traverse_conference(Conf_no seed) -{ - seed++; - - while ( seed < next_free_num && conf_arr[ seed ] == NULL ) - seed++; - - return (seed == next_free_num) ? 0 : seed ; -} - -extern Garb_nice -cached_get_garb_nice (Conf_no conf_no) -{ - return conf_arr [ conf_no ]->nice; -} - -extern Local_text_no -cached_get_highest_local_no (Conf_no conf_no) -{ - return ( conf_arr [ conf_no ]->texts.first_local_no - - 1 + conf_arr [ conf_no ]->texts.no_of_texts ); -} - -/* Lock a person struct in memory. Increase a referenc count. */ -void -cached_lock_person(Pers_no pers_no) -{} - -/* Decrease reference count. If zero, unlock person. */ -void -cached_unlock_person(Pers_no pers_no) -{} - -/* Lock a conf struct in memory. Increase a referenc count. */ -void -cached_lock_conf(Conf_no conf_no) -{} - -/* Decrease reference count. If zero, unlock conf. */ -void -cached_unlock_conf(Conf_no conf_no) -{} - - - - -static Bool -is_clean(const char *fn) -{ - FILE *fp; - - if ( (fp = fopen(fn, "rb")) == NULL ) - return FALSE; - - if ( getc(fp) == 'C' && getc(fp) == 'L' && getc(fp) == 'E' - && getc(fp) == 'A' && getc(fp) == 'N' ) - { - fclose(fp); - return TRUE; - } - else - { - fclose(fp); - return FALSE; - } -} - -#ifdef TIME_SYNC -static long -timerdiff(struct timeval a, - struct timeval b) -{ - return a.tv_sec - b.tv_sec; -} -#endif - -extern void /* Write out everything. */ -cache_sync(void) -{ - FILE *fp; - int i; - -#ifdef TIME_SYNC - struct rusage start, after_confs, after_persons, after_text_stats, - after_text_masses; - time_t st, ac, ap, ats, atm; - void getrusage(int who, struct rusage *rusage); -#endif - -#ifdef TIME_SYNC - getrusage(0, &start); - time(&st); -#endif - - if ( is_clean(datafilename) ) - { - if ( rename(datafilename, backupfilename) != 0 ) - log("WARNING: cache_sync: can't backup.\n"); - } - else - log("cache_sync: datafile not clean. No backup taken.\n"); - - if ( (fp=fopen(datafilename, "w") ) == NULL ) - { - log("WARNING: cache_sync: can't open file to save in.\n"); - return; - } - - fprintf(fp, "DIRTY\n"); /* DIRTY-FLAG */ - - fprintf(fp, "%d\n", next_free_num); /* NEXT_FREE_NUM */ - - for ( i = 1; i < next_free_num; i++ ) /* CONFS */ - { - if ( conf_arr[ i ] == NULL ) - fprintf(fp, "@"); - else - { - fprintf(fp, "+ "); - foutput_conference(fp, conf_arr[ i ]); - } - putc('\n', fp); - } -#ifdef TIME_SYNC - getrusage(0, &after_confs); - time(&ac); -#endif - - for ( i = 1; i < next_free_num; i++ ) /* PERSONS */ - { - if ( pers_arr[ i ] == NULL ) - fprintf(fp, "@"); - else - { - fprintf(fp, "+ %dH", PASSWD_LEN); - fwrite(pers_arr[ i ]->pwd, PASSWD_LEN, 1, fp); - foutput_person(fp, pers_arr[ i ]); - } - putc('\n', fp); - } -#ifdef TIME_SYNC - getrusage(0, &after_persons); - time(&ap); -#endif - - fprintf(fp, "%d\n", next_text_num); /* NEXT_TEXT_NUM */ - - for ( i = 1; i < next_text_num; i++ ) /* TEXT_STATS */ - { - if ( text_arr[ i ] == NULL ) - fprintf(fp, "@"); - else - { - fprintf(fp, "+ "); - foutput_text_stat(fp, text_arr[ i ]); - } - putc('\n', fp); - } - -#ifdef TIME_SYNC - getrusage(0, &after_text_stats); - time(&ats); - - getrusage(0, &after_text_masses); - time(&atm); -#endif - - rewind(fp); - fprintf(fp, "CLEAN"); - fclose(fp); - -#ifdef TIME_SYNC - log("Sync ready.\n" - "User: %4ld sec (%4ld conf, %4ld pers, %4ld stat, %4ld text)\n" - "Sys: %4ld sec (%4ld conf, %4ld pers, %4ld stat, %4ld text)\n" - "Real: %4ld sec (%4ld conf, %4ld pers, %4ld stat, %4ld text)\n" - "Page faults: %4ld. Swapped: %4ld. Outblocked: %4ld.\n", - - timerdiff(after_text_masses.ru_utime, start.ru_utime), - timerdiff(after_confs.ru_utime, start.ru_utime), - timerdiff(after_persons.ru_utime, after_confs.ru_utime), - timerdiff(after_text_stats.ru_utime, after_persons.ru_utime), - timerdiff(after_text_masses.ru_utime, after_text_stats.ru_utime), - - timerdiff(after_text_masses.ru_stime, start.ru_stime), - timerdiff(after_confs.ru_stime, start.ru_stime), - timerdiff(after_persons.ru_stime, after_confs.ru_stime), - timerdiff(after_text_stats.ru_stime, after_persons.ru_stime), - timerdiff(after_text_masses.ru_stime, after_text_stats.ru_stime), - - (u_long)difftime(atm, st), - (u_long)difftime(ac, st), - (u_long)difftime(ap, ac), - (u_long)difftime(ats, ap), - (u_long)difftime(atm, ats), - - after_text_masses.ru_majflt - start.ru_majflt, - after_text_masses.ru_nswap - start.ru_nswap, - after_text_masses.ru_oublock - start.ru_oublock); -#endif -} - -void -cache_open_new_text_file(void) -{ - if ( ( new_text_file = fopen(textfilename, "w")) == NULL ) - { - log("Can't open file to save new texts. Goodbye.\n"); - exit(1); - } -} - -extern Success -init_cache(void) -{ - FILE *fp = NULL; - int i; - extern int vflag; /* from dbck.c */ - extern Bool truncated_texts; /* from dbck.c */ - - new_text_file = NULL; - - if ( (text_file = fopen(textfilename, "rb")) == NULL ) - { - perror(textfilename); - restart_kom("ERROR: init_cache: can't open text file %s.\n", - textfilename); - } - - if ( is_clean(datafilename) ) - { - if ( (fp = fopen(datafilename, "rb")) == NULL ) - { - log("WARNING: init_cache: can't open datafile.\n"); - return FAILURE; - } - log("MSG: init_cache: using datafile.\n"); - } - else if ( is_clean(backupfilename) ) - { - if ( (fp = fopen(backupfilename, "rb")) == NULL ) - { - log("WARNING: init_cache: can't open backupfile.\n"); - return FAILURE; - } - log("MSG: init_cache: using backup file.\n"); - } - else - { - log("WARNING: init_cache: can't find old data base.\n"); - return FAILURE; - } - - fseek(fp, 6, SEEK_SET); /* skip clean/dirty flag. */ - - next_free_num = fparse_long(fp); /* NEXT_FREE_NUM */ - - if ( vflag ) - log("Reading %d conferences, starting at pos %d.\n", - next_free_num-1, ftell(fp)); - - for ( i = 1; i < next_free_num; i++ ) /* CONFS */ - { - fskipwhite(fp); - switch(getc(fp)) - { - case '@': - conf_arr[ i ] = NULL; - break; - - case '+': - conf_arr[ i ] = alloc_conference(); - if ( fparse_conference(fp, conf_arr[ i ]) != OK ) - restart_kom("init_cache(): fparse_conference failed. " - "i == %d\n", i); - - name_list[i] = EMPTY_STRING; - s_strcpy(&name_list[i], conf_arr[ i ]->name); - - break; - } - } - - if ( vflag ) - log("Reading %d persons, starting at pos %d.\n", - next_free_num-1, ftell(fp)); - - for ( i = 1; i < next_free_num; i++ ) /* PERSONS */ - { - fskipwhite(fp); - switch(getc(fp)) - { - case '@': - pers_arr[ i ] = NULL; - break; - - case '+': - pers_arr[ i ] = alloc_person(); - if ( fparse_person(fp, pers_arr[ i ]) != OK ) - restart_kom("init_cache: fparse_person failed. i == %d\n", i); - - break; - } - } - - next_text_num = fparse_long(fp); /* NEXT_TEXT_NUM */ - - if ( vflag ) - log("Reading %d texts, starting at pos %d.\n", - next_text_num-1, ftell(fp)); - - for ( i = 1; i < next_text_num; i++ ) /* TEXT_STATS */ - { - fskipwhite(fp); - switch(getc(fp)) - { - case '@': - text_arr[ i ] = NULL; - break; - - case '+': - text_arr[ i ] = alloc_text_stat(); - if ( fparse_text_stat(fp, text_arr[ i ]) != OK ) - { - /* Simply ignore the following texts. The cause of this - error might be that the file has been truncated (maybe - due to an overfull disk). */ - - log("init_cache(): fparse_text_stat failed for text %d.\n" - "All remaining texts are lost.\n", i); - next_text_num = i; - truncated_texts = TRUE; - } - - break; - } - } - - log("Read %d confs/persons and %d texts, eof at %d\n", - next_free_num-1, next_text_num-1, ftell(fp)); - - fclose(fp); - - return OK; -} diff --git a/src/server/dbck-cache.h b/src/server/dbck-cache.h deleted file mode 100644 index 0e14af4a1..000000000 --- a/src/server/dbck-cache.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * $Id: dbck-cache.h,v 0.3 1991/09/15 10:32:35 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: dbck-cache.h,v 0.3 1991/09/15 10:32:35 linus Exp $ - * - */ -extern void -cached_flush_text(Text_no text_no, - String message); - -extern void -cache_open_new_text_file(void); - - diff --git a/src/server/dbck.c b/src/server/dbck.c deleted file mode 100644 index fd0bdaa47..000000000 --- a/src/server/dbck.c +++ /dev/null @@ -1,1290 +0,0 @@ -/* - * $Id: dbck.c,v 0.10 1992/03/23 08:02:42 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * dbck.c - A simple database checker and corrector. - * - * Author: Per Cederqvist. - */ - -static char *rcsid = "$Id: dbck.c,v 0.10 1992/03/23 08:02:42 ceder Exp $"; - - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> - -#include <kom-types.h> -#include <config.h> -#include "cache.h" -#include "log.h" -#include "lyskomd.h" -#include "misc-parser.h" -#include <server/smalloc.h> -#include <debug.h> -#include "dbck-cache.h" - -/* This is set to TRUE if init_cache finds out that the last part of the - database is missing. */ -Bool truncated_texts = FALSE; - -char datafilename[1024]; /* Full pathname to the database file */ -char backupfilename[1024]; /* Full pathname to the backup file */ -char textfilename[1024]; -char textbackupfilename[1024]; /* unshrinked text-file. */ -static const char *dbase_dir = NULL; /* Directory where database resides */ - -#define TEXTBACKUPFILE_NAME "db/backup-texts" - -int vflag=0; /* Verbose - list statistics also. */ -int iflag=0; /* Interactive - prompt user and repair. */ -int rflag=0; /* Repair simple error without confirmation. */ -int gflag=0; /* Garbage collect text-file. */ -int sflag=0; /* Statistic flag. */ - -int modifications = 0; - -typedef struct { - int created_confs; -} Person_scratchpad; - -static const Person_scratchpad EMPTY_PERSON_SCRATCHPAD = { 0 }; - -#include "tmp-limits.h" - -static Person_scratchpad *person_scratchpad[MAX_CONF]; - -#ifdef DEBUG -int buglevel = 0; -#endif - -extern void -log (const char * format, ...) -{ - va_list AP; - - va_start(AP, format); - - vfprintf(stdout, format, AP); - - va_end(AP); -} - -extern void -restart_kom (const char * format, ...) -{ - va_list AP; - - va_start(AP, format); - - vfprintf(stdout, format, AP); - - va_end(AP); - exit(1); -} - -static Person_scratchpad * -alloc_person_scratchpad(void) -{ - Person_scratchpad *p; - - p = smalloc(sizeof(Person_scratchpad)); - *p = EMPTY_PERSON_SCRATCHPAD; - return p; -} - - -static Bool -is_comment_to(Text_no comment, - Text_stat *parent) -{ - int i; - - for ( i = 0; i < parent->no_of_misc; i++ ) - { - switch( parent->misc_items[ i ].type ) - { - case comm_in: - if ( parent->misc_items[ i ].datum.commented_in == comment ) - return TRUE; - break; - default: - break; - } - } - - return FALSE; -} - -static Bool -is_commented_in(Text_no parent, - Text_stat *child) -{ - int i; - - for ( i = 0; i < child->no_of_misc; i++ ) - { - switch( child->misc_items[ i ].type ) - { - case comm_to: - if ( child->misc_items[ i ].datum.comment_to == parent ) - return TRUE; - break; - default: - break; - } - } - - return FALSE; -} - -static Bool -is_footnote_to(Text_no footnote, - Text_stat *parent) -{ - int i; - - for ( i = 0; i < parent->no_of_misc; i++ ) - { - switch( parent->misc_items[ i ].type ) - { - case footn_in: - if ( parent->misc_items[ i ].datum.footnoted_in == footnote ) - return TRUE; - break; - default: - break; - } - } - - return FALSE; -} - -static Bool -is_footnoted_in(Text_no parent, - Text_stat *child) -{ - int i; - - for ( i = 0; i < child->no_of_misc; i++ ) - { - switch( child->misc_items[ i ].type ) - { - case footn_to: - if ( child->misc_items[ i ].datum.footnote_to == parent ) - return TRUE; - break; - default: - break; - } - } - - return FALSE; -} - -static Member * -locate_member(Pers_no pers_no, - Conference * conf_c) -{ - Member * member; - int i; - - for(member = conf_c->members.members, i = conf_c->members.no_of_members; - i > 0; i--, member++) - { - if ( member->member == pers_no ) - { - return member; - } - } - - return NULL; -} - -/* - * Delete a misc_info. - * If it is a recpt, cc_recpt, comm_to or footn_to delete any - * loc_no, rec_time, sent_by or sent_at that might follow it. - * - * Note that the Misc_info is not reallocated. - */ - -static void -delete_misc (Text_stat *tstat, - Misc_info *misc) /* Pointer to first misc_item to delete. */ -{ - int del = 1; /* Number of items to delete. */ - /* Always delete at least one item. */ - Bool ready; - - /* Check range of misc */ - - if (misc < tstat->misc_items - || misc >= tstat->misc_items + tstat->no_of_misc ) - { - restart_kom("delete_misc() - misc out of range"); - } - - ready = FALSE; - - while (ready == FALSE - && misc + del < tstat->misc_items + tstat->no_of_misc ) - { - switch ( misc[ del ].type ) - { - case loc_no: - case rec_time: - case sent_by: - case sent_at: - del++; - break; - - case recpt: - case cc_recpt: - case footn_to: - case footn_in: - case comm_to: - case comm_in: - ready = TRUE; - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("delete_misc() - illegal misc found.\n"); -#endif - } - } - - tstat->no_of_misc -= del; - - /* Move items beyond the deleted ones. */ - - while ( misc < tstat->misc_items + tstat->no_of_misc ) - { - misc[ 0 ] = misc[ del ]; - misc++; - } -} - -static int -confirm(char *question) -{ - if ( iflag ) - { - fputs(question, stdout); - fputs(" (y/n) ", stdout); - while(1) - switch(getchar()) - { - case 'y': - case 'Y': - return 1; - case 'n': - case 'N': - case EOF: - return 0; - default: - break; - } - } - else - return 0; -} - - -static long -check_misc_infos(Text_no tno, - Text_stat *tstat) -{ - const Misc_info * misc = tstat->misc_items; - Misc_info * previous; - Misc_info_group group; - Conference *c; - Text_stat *t; - - long error=0; - - while (previous = (Misc_info *)misc, - group = parse_next_misc(&misc, - tstat->misc_items + tstat->no_of_misc), - group.type != m_end_of_list && group.type != m_error ) - { - switch ( group.type ) - { - case m_recpt: - c = cached_get_conf_stat (group.recipient); - if ( c == NULL && group.recipient == 0 ) - { - log ("Conference 0 is recipient to text %lu.\n", (u_long)tno); - if (rflag || confirm("Repair by deleting misc_item? ")) - { - delete_misc(tstat, previous); - mark_text_as_changed(tno); - modifications++; - log("Repaired: Conference 0 is no longer a recipient.\n"); - misc = previous; - } - else - error++; - - break; - } - - if ( c == NULL ) - break; - - /* Check loc_no */ - if ( group.local_no < c->texts.first_local_no ) - { - log("Text %lu: Recipient %lu<%lu> loc_no is less than %lu\n", - (u_long)tno, (u_long)group.recipient, - (u_long)group.local_no, - (u_long)c->texts.first_local_no); - error++; - } - else if ( c->texts.first_local_no + c->texts.no_of_texts - 1 - < group.local_no ) - { - log("Text %lu: Recipient %lu<%lu> loc_no" - " is greater than %lu\n", - (u_long)tno, (u_long)group.recipient, - (u_long)group.local_no, - (u_long)(c->texts.first_local_no - + c->texts.no_of_texts - 1)); - error++; - } - else if ( c->texts.texts[group.local_no - - c->texts.first_local_no] != tno ) - { - log("Text %lu: Recipient %lu<%lu>: that local number " - "is mapped to %lu.\n", - (u_long)tno, (u_long)group.recipient, - (u_long)group.local_no, - (u_long)c->texts.texts[group.local_no - - c->texts.first_local_no]); - error++; - } - - break; - - case m_cc_recpt: - c = cached_get_conf_stat (group.cc_recipient); - if ( c == NULL && group.cc_recipient == 0 ) - { - log ("Conference 0 is cc_recipient to text %lu.\n", - (u_long)tno); - if (rflag || confirm("Repair by deleting misc_item? ")) - { - delete_misc(tstat, previous); - mark_text_as_changed(tno); - modifications++; - log("Repaired: Conference 0 is no longer " - "a cc_recipient.\n"); - misc = previous; - } - else - error++; - - break; - } - - if ( c == NULL ) - break; - - /* Check loc_no */ - if ( group.local_no < c->texts.first_local_no ) - { - log("Text %lu: CC_Recipient %lu<%lu> is less than %lu\n", - (u_long)tno, (u_long)group.cc_recipient, - (u_long)group.local_no, - (u_long)c->texts.first_local_no); - error++; - } - else if ( c->texts.first_local_no + c->texts.no_of_texts - 1 - < group.local_no ) - { - log("Text %lu: CC_Recipient %lu<%lu> loc_no is " - "greater than %lu\n", - (u_long)tno, (u_long)group.cc_recipient, - (u_long)group.local_no, - (u_long)(c->texts.first_local_no - + c->texts.no_of_texts - 1)); - error++; - } - else if ( c->texts.texts[group.local_no - - c->texts.first_local_no] != tno ) - { - log("Text %lu: CC_Recipient %lu<%lu>: that local " - "number is mapped to %lu.\n", - (u_long)tno, (u_long)group.cc_recipient, - (u_long)group.local_no, - (u_long)c->texts.texts[group.local_no - - c->texts.first_local_no]); - error++; - } - - break; - - case m_comm_to: - t = cached_get_text_stat(group.comment_to); - - if ( t == NULL ) - { - log("Text %lu is a comment to %lu, which doesn't exist.\n", - (u_long)tno, (u_long)group.comment_to); - - if (rflag || confirm("Repair by deleting misc_item? ")) - { - delete_misc(tstat, previous); - mark_text_as_changed(tno); - modifications++; - log("Repaired: Comment-link deleted.\n"); - misc = previous; - } - else - error++; - - error++; - } - else if (!is_comment_to(tno, t)) - { - log("Text %lu is a comment to %lu, but not the reverse.\n", - (u_long)tno, (u_long)group.comment_to); - error++; - } - - break; - - case m_comm_in: - t = cached_get_text_stat(group.commented_in); - - if ( t == NULL ) - { - log("Text %lu is commented in %lu, which doesn't exist.\n", - (u_long)tno, (u_long)group.commented_in); - - if (rflag || confirm("Repair by deleting misc_item? ")) - { - delete_misc(tstat, previous); - mark_text_as_changed(tno); - modifications++; - log("Repaired: Comment-link deleted.\n"); - misc = previous; - } - else - error++; - } - else if (!is_commented_in(tno, t)) - { - log("Text %lu is a comment to %lu, but not the reverse.\n", - (u_long)tno, (u_long)group.commented_in); - error++; - } - - break; - - case m_footn_to: - t = cached_get_text_stat(group.footnote_to); - - if ( t == NULL ) - { - log("Text %lu is a footnote to %lu, which doesn't exist.\n", - (u_long)tno, (u_long)group.footnote_to); - - if (rflag || confirm("Repair by deleting misc_item? ")) - { - delete_misc(tstat, previous); - mark_text_as_changed(tno); - modifications++; - log("Repaired: Footnote-link deleted.\n"); - misc = previous; - } - else - error++; - } - else if (!is_footnote_to(tno, t)) - { - log("Text %lu is a footnote to %lu, but not the reverse.\n", - (u_long)tno, (u_long)group.footnote_to); - error++; - } - - break; - - case m_footn_in: - t = cached_get_text_stat(group.footnoted_in); - - if ( t == NULL ) - { - log("Text %lu is footnoted in %lu, which doesn't exist.\n", - (u_long)tno, (u_long)group.footnoted_in); - - if (rflag || confirm("Repair by deleting misc_item? ")) - { - delete_misc(tstat, previous); - mark_text_as_changed(tno); - modifications++; - log("Repaired: Footnote-link deleted.\n"); - misc = previous; - } - else - error++; - } - else if (!is_footnoted_in(tno, t)) - { - log("Text %lu is a footnot to %lu, but not the reverse.\n", - (u_long)tno, (u_long)group.footnoted_in); - error++; - } - - break; - - default: - log("check_misc_infos(): parse_next_misc returned type %lu\n", - (u_long)group.type); - break; - } - } - - if ( group.type == m_error ) - { - log("Text %lu has a bad misc_info_list.\n", (u_long)tno); - error++; - } - - return error; -} - - - - -static long -check_texts(void) -{ - Text_no ct = 0; - Text_stat *ctp=NULL; - long errors = 0; - Text_no number_of_texts = 0; - u_long bytes=0; - u_long max_bytes=0; - Text_no max_text=0; - - while ( ct = traverse_text(ct) ) - { - number_of_texts++; - - ctp = cached_get_text_stat( ct ); - if ( ctp == NULL ) - { - log("Text %lu nonexistent.\n", ct); - errors++; - } - else - { - bytes += ctp->no_of_chars; - if ( ctp->no_of_chars > max_bytes ) - { - max_bytes = ctp->no_of_chars; - max_text = ct; - } - - /* no_of_marks is not yet checked. */ - errors += check_misc_infos(ct, ctp); - } - } - - if (vflag) - { - if ( number_of_texts == 0 ) - log("WARNING: No texts found.\n"); - else - { - log("Total of %lu texts (total %lu bytes, " - "average %lu bytes/text).\n", - (u_long)number_of_texts, - (u_long)bytes, - (u_long)(bytes/number_of_texts)); - log("Longest text is %lu (%lu bytes).\n", - (u_long)max_text, (u_long)max_bytes); - } - } - - return errors; -} - -static Bool -adjust_text_list(Text_list *text_list) -{ - u_long zeroes; - u_long i; - - for (zeroes = 0; - zeroes < text_list->no_of_texts && text_list->texts[ zeroes ] == 0; - zeroes++) - ; - - if ( zeroes > 0 ) - { - text_list->no_of_texts -= zeroes; - text_list->first_local_no += zeroes; - - for ( i = 0; i < text_list->no_of_texts; i++) - text_list->texts[ i ] = text_list->texts[ i + zeroes ]; - - text_list->texts = srealloc(text_list->texts, - (text_list->no_of_texts - * sizeof(Text_no))); - } - - return zeroes > 0; -} - -static int -check_created_texts(Pers_no pno, - Text_list *created) -{ - u_long i; - Text_stat *t; - int error=0; - - for ( i=0; i < created->no_of_texts; i++ ) - { - if (created->texts[i] != 0) - { - t = cached_get_text_stat(created->texts[i]); - if ( t != NULL && t->author != pno) - { - log("Person %lu is author of text %lu whose author is %lu.\n", - (u_long)pno, (u_long)created->texts[i], - (u_long)t->author); - error++; - } - - if ( t == NULL ) - { - log("Person %lu is author of text %lu, which doesn't exist.\n", - (u_long)pno, (u_long)created->texts[i]); - if ( rflag || - confirm("Repair by setting to text_no to 0 in local map")) - { - created->texts[i] = 0; - mark_person_as_changed(pno); - modifications++; - log("Repaired: created_texts corrected.\n"); - } - else - error++; - } - } - } - - if ( created->no_of_texts > 0 && created->texts[0] == 0 ) - { - log("Person %lu has a bad created_texts array. Starts with a 0.\n", - (u_long)pno); - if ( rflag || confirm ("Repair by adjusting created_texts")) - { - adjust_text_list(created); - mark_person_as_changed(pno); - modifications++; - log("Repaired: created_texts adjusted.\n"); - } - else - error++; - } - - return error; -} - -static int -check_membership(Pers_no pno, - const Membership *mship) -{ - int error=0; - Conference *conf; - int i; - Local_text_no last=0; - - conf = cached_get_conf_stat(mship->conf_no); - if ( conf == NULL ) - { - log("Person %lu is a member in the non-existing conference %lu.\n", - (u_long)pno, (u_long)mship->conf_no); - error++; - } - else - { - /* Check read texts */ - if ( mship->last_text_read > - conf->texts.first_local_no + conf->texts.no_of_texts - 1) - { - log("Person %lu has read text %lu in conf %lu, " - "which only has %lu texts.\n", - (u_long)pno, - (u_long)mship->last_text_read, - (u_long)mship->conf_no, - (u_long)(conf->texts.first_local_no - + conf->texts.no_of_texts - 1)); - error++; - } - - for ( last = i = 0; i < mship->no_of_read; i++) - { - if ( mship->read_texts[i] <= last ) - { - log("Person %lu's membership in %lu is corrupt:" - " read text number %lu<%lu> <= %lu.\n", - (u_long)pno, (u_long)mship->conf_no, - (u_long)mship->read_texts[i], (u_long)i, (u_long)last); - error++; - } - - last = mship->read_texts[i]; - } - - /* Check that he is a member */ - if ( locate_member(pno, conf) == NULL ) - { - log("Person %lu is a member in %lu in which he isn't a member.\n", - (u_long)pno, (u_long)mship->conf_no); - error++; - } - } - - return error; -} - - - -static int -check_membership_list(Pers_no pno, - const Membership_list *mlist) -{ - int errors=0; - int i; - - for (i = 0; i < mlist->no_of_confs; i++) - errors += check_membership(pno, &mlist->confs[i]); - - return errors; -} - - -static int -check_persons(void) -{ - Pers_no cp = 0; - Person *pstat=NULL; - Conference *cstat=NULL; - long errors = 0; - Pers_no number_of_persons=0; - - while ( cp = traverse_person(cp) ) - { - number_of_persons++; - pstat = cached_get_person_stat (cp); - cstat = cached_get_conf_stat (cp); - - if ( pstat == NULL ) - { - log("Person %lu nonexistent.\n", (u_long)cp); - errors++; - } - else if (cstat == NULL) - { - log("Person %lu has no conference.\n", (u_long)cp); - errors++; - } - else if (!cstat->type.letter_box) - { - log("Person %lu's conference is not a letter_box.\n", - (u_long)cp); - errors++; - } - else - { - errors += (check_created_texts(cp, &pstat->created_texts) - + check_membership_list(cp, &pstat->conferences)); - } - } - - if (vflag) - log("Total of %lu persons.\n", number_of_persons); - - return errors; -} - -static Bool -is_recipient(Conf_no conf_no, - Text_stat * t_stat) -{ - int i; - - for ( i = 0; i < t_stat->no_of_misc; i++ ) - { - switch( t_stat->misc_items[ i ].type ) - { - case recpt: - if ( t_stat->misc_items[ i ].datum.recipient == conf_no ) - { - return TRUE; - } - break; - - case cc_recpt: - if ( t_stat->misc_items[ i ].datum.cc_recipient == conf_no ) - { - return TRUE; - } - break; - - case rec_time: - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case sent_by: - case sent_at: - case loc_no: - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("is_recipient(): illegal misc_item\n"); -#endif - } - } - - return FALSE; -} - -static int -check_texts_in_conf(Conf_no cc, - Text_list *tlist) -{ - u_long i; - Text_stat *t; - int error=0; - - for ( i=0; i < tlist->no_of_texts; i++ ) - { - if (tlist->texts[i] != 0) - { - t = cached_get_text_stat(tlist->texts[i]); - if ( t == NULL ) - { - log("Text %lu<%lu> in conference %lu is non-existent.\n", - (u_long)tlist->texts[i], - (u_long)i + tlist->first_local_no, - (u_long)cc); - - if (rflag - || confirm("Repair by setting Text_no to 0 in the map?") ) - { - tlist->texts[i]=0; - mark_conference_as_changed(cc); - modifications++; - log("Repaired: %lu is no longer a recipient.\n", - (u_long)cc); - } - else - error++; - } - else - { - if ( !is_recipient(cc, t) ) - { - log("Text %lu<%lu> in conference %lu doesn't " - "have the conference as recipient.\n", - (u_long)tlist->texts[i], - (u_long)i + tlist->first_local_no, - (u_long)cc); - - if (confirm("Repair by setting Text_no to 0 in the map?") ) - { - tlist->texts[i]=0; - mark_conference_as_changed(cc); - modifications++; - log("Repaired: %lu is no longer a recipient.\n", - (u_long)cc); - } - else - error++; - } - } - } - } - - if ( tlist->no_of_texts > 0 && tlist->texts[0] == 0 ) - { - log("Conference %lu has a bad Text_list. Starts with a 0.\n", - (u_long)cc); - if ( rflag || confirm ("Repair by adjusting text_list")) - { - adjust_text_list(tlist); - mark_conference_as_changed(cc); - modifications++; - log("Repaired: text_list adjusted.\n"); - } - else - error++; - } - - return error; -} - -static Membership * -locate_membership(Conf_no conf_no, - Person * pers_p) -{ - Membership * confp; - int i; - - for(confp = pers_p->conferences.confs, i = pers_p->conferences.no_of_confs; - i > 0; i--, confp++) - { - if ( confp->conf_no == conf_no ) - { - return confp; - } - } - - return NULL; -} - -static int -check_member(Conf_no cc, - Member *memb) -{ - Person *pp; - int error=0; - - pp = cached_get_person_stat(memb->member); - if ( pp == NULL ) - { - log("Person %lu, who is supposed to be a member in conf %lu, " - "is nonexistent.\n", - (u_long)memb->member, (u_long)cc); - error++; - } - else - { - if ( locate_membership(cc, pp) == NULL ) - { - log("Person %lu is not a member in conf %lu.\n", - (u_long)memb->member, - (u_long)cc); - error++; - } - } - - return error; -} - -static int -check_member_list(Conf_no cc, - const Member_list *mlist) -{ - int errors=0; - int i; - - for (i = 0; i < mlist->no_of_members; i++) - errors += check_member(cc, &mlist->members[i]); - - return errors; -} - - -static int -check_confs(void) -{ - Conf_no cc = 0; - Person *pstat=NULL; - Conference *cstat=NULL; - long errors = 0; - Conf_no number_of_confs = 0; - - while ( (cc = traverse_conference(cc)) != 0 ) - { - number_of_confs++; - cstat = cached_get_conf_stat (cc); - - if ( cstat == NULL ) - { - log("Conference %lu nonexistent.\n", (u_long)cc); - errors++; - } - else - { - if (cstat->type.letter_box) - { - pstat = cached_get_person_stat(cc); - if (pstat == NULL) - { - log("Mailbox %lu has no person.\n", (u_long)cc); - errors++; - } - } - else /* not letter_box */ - { - /* Remember that the creator might no longer exist. */ - if ( person_scratchpad[ cstat->creator ] != NULL ) - ++person_scratchpad[ cstat->creator ]->created_confs; - } - - errors += (check_texts_in_conf(cc, &cstat->texts) - + check_member_list(cc, &cstat->members)); - } - } - - if ( vflag ) - log("Total of %lu conferences.\n", (u_long)number_of_confs); - - return errors; -} - -static void -init_person_scratch(void) -{ - Pers_no pno = 0; - - while( (pno = traverse_person(pno)) != 0 ) - { - person_scratchpad[pno] = alloc_person_scratchpad(); - } -} - -static long -post_check_persons(void) -{ - long errors = 0; - - Pers_no pers_no = 0; - Person *pstat; - - while ( (pers_no = traverse_person(pers_no)) != 0 ) - { - if ( (pstat = cached_get_person_stat(pers_no)) == NULL ) - { - log("INTERNAL DBCK ERROR: post_check_persons(): can't " - "cached_get_person_stat(%d).\n", pers_no); - } - } - - return errors; -} - - -/* - * Returns 0 if the database seems to be correct. - */ -static long -check_data_base(void) -{ - long errors; - - init_person_scratch(); - errors = check_texts() + check_persons() + check_confs(); - return errors + post_check_persons(); -} - -static void -init_data_base(void) -{ - if (dbase_dir == NULL) - dbase_dir = DEFAULT_DBASE_DIR; - - sprintf(datafilename, "%s/%s", dbase_dir, DATAFILE_NAME); - sprintf(backupfilename, "%s/%s", dbase_dir, BACKUPFILE_NAME); - sprintf(textfilename, "%s/%s", dbase_dir, TEXTFILE_NAME); - sprintf(textbackupfilename, "%s/%s", dbase_dir, TEXTBACKUPFILE_NAME); - - if ( vflag ) - { - log("Database = %s\n", datafilename); - log("Backup = %s\n", backupfilename); - log("Text = %s\n", textfilename); - log("Textback = %s\n", textbackupfilename); - } - - if ( init_cache() == FAILURE ) - restart_kom("Can't find database.\n"); -} - -static void -garb_text_file(void) -{ - Text_no tno = 0; - String text; - - log("Renaming %s to %s\n", textfilename, textbackupfilename); - rename(textfilename, textbackupfilename); - log("Writing texts to (new) %s\n", textfilename); - fflush(stdout); - fflush(stderr); - cache_open_new_text_file(); - - while ( (tno = traverse_text(tno)) != 0 ) - { - text = cached_get_text(tno); - cached_flush_text(tno, text); - free_tmp(); - } - log("Writing datafile with new indexes.\n"); - fflush(stdout); - fflush(stderr); - cache_sync(); - log("Ready."); -} - - - -static void -print_statistics(void) -{ - Text_stat *ts; - Text_no t; - int *hist; - int i; - - hist = calloc(TEXT_LEN, sizeof(int)); - - if (hist == NULL) - { - perror("dbck: print_statistics(): can't calloc()"); - return; - } - - for (t=0; (t=traverse_text(t)) != 0;) - { - ts = cached_get_text_stat(t); - if (ts == NULL) - { - log("print_statistics(): Can't get text_stat.\n"); - return; - } - - hist[ts->no_of_chars]++; - } - - log("Length Frequency\n"); - for(i=0; i<TEXT_LEN; i++) - if(hist[i] != 0) - log("%8d %d\n", i, hist[i]); -} - -/* Stop "no previous prototype" warning from gcc 2.0 */ -int main(int, char**); - -int -main (int argc, - char **argv) -{ - int i; - int errors; - BUGDECL; - - for (i = 1; i < argc && argv[i][0] == '-'; i++) - { - switch (argv[i][1]) - { -#ifdef DEBUG - case 'd': - buglevel++; - break; -#endif - - case 'D': /* Database directory */ - dbase_dir = argv[i]+2; - break; - - case 'i': /* Running interactively. */ - iflag++; /* Will ask user and try to repair. */ - break; - - case 'r': /* Repair simple errors wihtout asking. */ - rflag++; - break; - - case 'v': /* Verbose: report more than errors. */ - vflag++; - break; - - case 'g': /* Garbage collect: compress text-file. */ - gflag++; - break; - - case 's': /* Statistics: text length et c. */ - sflag++; - break; - - default: - restart_kom("usage: %s [-d] [-Ddir] [-i] [-r] [-v] [-g]\n", - argv[0]); - } - } - - s_set_storage_management(smalloc, srealloc, sfree); - - init_data_base(); - errors = check_data_base(); - - if (truncated_texts == TRUE) - modifications++; - - if ( iflag ) - log("Total of %d error%s remains.\n", errors, errors == 1 ? "" : "s"); - else if ( vflag && errors > 0 ) - log("%d error%s found.\n", errors, errors == 1 ? "" : "s"); - - if ( modifications > 0 ) - { - log("%d modification%s made. Syncing...\n", - modifications, modifications == 1 ? "" : "s"); - fflush(stdout); - fflush(stderr); - cache_sync(); - log("ready.\n"); - } - - if ( sflag ) - print_statistics(); - - if ( gflag ) - { - if ( modifications == 0 && errors == 0 ) - { - log("No errors found. Compressing textfile.\n"); - fflush(stdout); - fflush(stderr); - garb_text_file(); - log("ready.\n"); - } - else - log("Compression not done since errors was found.\n"); - } - - return errors != 0; -} diff --git a/src/server/disk-cache.h b/src/server/disk-cache.h deleted file mode 100644 index 70f20adcb..000000000 --- a/src/server/disk-cache.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * $Id: disk-cache.h,v 0.3 1991/09/15 10:32:26 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: disk-cache.h,v 0.3 1991/09/15 10:32:26 linus Exp $ - * - */ -/* Returns TRUE when the sync is ready. */ -Bool -sync_part(void); - diff --git a/src/server/disk-end-of-atomic.c b/src/server/disk-end-of-atomic.c deleted file mode 100644 index 4ff3588c0..000000000 --- a/src/server/disk-end-of-atomic.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * $Id: disk-end-of-atomic.c,v 0.7 1992/04/09 09:19:43 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * end-of-atomic.c - * - * This is the magic function which is called at the end of every atomic - * call to the server. It is responisble for - * Free:ing all tmp_alloc:ated memory - * Throw out some cached data if necessary - * Forget some old texts if necessary - * Save some items to disk if saving - * - * idle is TRUE if the server has no pending calls. That might be a good time - * to forget old texts. - */ - -static char *rcsid = "$Id: disk-end-of-atomic.c,v 0.7 1992/04/09 09:19:43 ceder Exp $"; - - -#include <kom-types.h> -#include <server/smalloc.h> -#include "text-garb.h" -#include "config.h" -#include "disk-cache.h" -#include "cache.h" -#include "end-of-atomic.h" - -long -end_of_atomic( Bool idle ) -{ - int timeout = TIMEOUT; - static int limit = 0; - - free_tmp(); - - /* FIXME-- make limit_text_stat smarter instead. */ - if (limit++ > 100) - { - cache_limit_size(); - limit = 0; - } - - if ( idle ) - if ( garb_text() == FALSE ) - timeout = GARBTIMEOUT; - - if ( sync_part() == FALSE ) - timeout = SYNCTIMEOUT; - - return timeout; -} diff --git a/src/server/end-of-atomic.h b/src/server/end-of-atomic.h deleted file mode 100644 index c3e01b1c9..000000000 --- a/src/server/end-of-atomic.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * $Id: end-of-atomic.h,v 0.3 1991/09/15 10:32:18 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: end-of-atomic.h,v 0.3 1991/09/15 10:32:18 linus Exp $ - * - * end-of-atomic.c - */ - -/* - * Return value X: end_of_atomic() should be called again within the - * next X milliseconds. - */ -long -end_of_atomic( Bool idle ); diff --git a/src/server/exp.h b/src/server/exp.h deleted file mode 100644 index 2db7bd056..000000000 --- a/src/server/exp.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * $Id: exp.h,v 0.3 1991/09/15 10:32:14 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: exp.h,v 0.3 1991/09/15 10:32:14 linus Exp $ - * - */ -#define EXPORT -#define INTERNAL static diff --git a/src/server/fnc-def-init.awk b/src/server/fnc-def-init.awk deleted file mode 100644 index f626b248d..000000000 --- a/src/server/fnc-def-init.awk +++ /dev/null @@ -1,48 +0,0 @@ -# -# $Id: fnc-def-init.awk,v 0.4 1991/09/15 10:32:10 linus Exp $ -# Copyright (C) 1991 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. -# -# $Id: fnc-def-init.awk,v 0.4 1991/09/15 10:32:10 linus Exp $ -BEGIN { - printf("/* Don't edit this file - it is generated automatically"); - printf(" from\n fnc-def-init.awk and fncdef.txt */\n\n"); - printed_flg=0; -} -printed_flg==1 { - printf(",\n"); -} -$1 != "#" { - printf(" {"); - - if ( $(NF-1) == ":" ) - printf("%7s,", "rt_" $NF); - else - printf("%7s,", "rt_" $1); - - printf("prot_a_parse_arg_%s}", $2); - - printed_flg=1; -} -END { - printf("\n"); -} diff --git a/src/server/fncdef.txt b/src/server/fncdef.txt deleted file mode 100644 index c1116858d..000000000 --- a/src/server/fncdef.txt +++ /dev/null @@ -1,102 +0,0 @@ -# -# $Id: fncdef.txt,v 0.9 1992/04/01 20:46:37 ceder Exp $ -# Copyright (C) 1991 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. -# -# $Id: fncdef.txt,v 0.9 1992/04/01 20:46:37 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 -# with their argument and return types. -# -# NEVER alter any functions that have been in use for a while! Add -# new/modified functions last on this list! -# -# Functions that are reachable when using protocal A: -# -# (Functions whose name end in _old are obsolete and should not be used.) -# -success login_old num c_string (PWD_LEN) -success logout -success pepsi num -success change_name num c_string (CONF_NAME_LEN) -success change_what_i_am_doing string (WHAT_DO_LEN) -number create_person c_string (CONF_NAME_LEN) c_string (PWD_LEN) -success get_person_stat_old num num : person -success set_priv_bits num priv_bits -success set_passwd num c_string (PWD_LEN) c_string (PWD_LEN) -success query_read_texts num num : membership -number create_conf c_string (CONF_NAME_LEN) conf_type -success delete_conf num -success lookup_name c_string (CONF_NAME_LEN) : conf_list -success get_conf_stat_old num num : conference -success add_member num num num num -success sub_member num num -success set_presentation num num -success set_etc_motd num num -success set_supervisor num num -success set_permitted_submitters num num -success set_super_conf num num -success set_conf_type num conf_type -success set_garb_nice num num -success get_marks : mark_list -success mark_text num num -success get_text num num num : string -success get_text_stat num : text_stat -success mark_as_read num num c_local_text_no_p -number create_text c_string (TEXT_LEN) num c_misc_info_p -success delete_text num -success add_recipient num num num -success sub_recipient num num -success add_comment num num -success sub_comment num num -success get_map num num num : text_list -success get_time : time_date -success get_info : info -success add_footnote num num -success sub_footnote num num -success who_is_on_old : who_info_list_old -success set_unread num num -success set_motd_of_lyskom num -success enable num -success sync -success shutdown num -success broadcast c_string (BROADCAST_LEN) -success get_membership num num num num : membership_list -success get_created_texts num num num : text_list -success get_members num num num : member_list -success get_person_stat num : person -success get_conf_stat num : conference -success who_is_on : who_info_list -success get_unread_confs num : conf_no_list -success send_message num c_string (BROADCAST_LEN) -success get_session_info num : session_info -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 -success find_next_text_no num : text_no -success find_previous_text_no num : text_no -success login num c_string (PWD_LEN) num -success who_is_on_ident : who_info_ident_list -success get_session_info_ident num : session_info_ident diff --git a/src/server/free.gdb b/src/server/free.gdb deleted file mode 100644 index c60b06d60..000000000 --- a/src/server/free.gdb +++ /dev/null @@ -1,10 +0,0 @@ -break sfree if ptr != 0 -commands -silent -echo --- sfree ---\n -echo Arg: -print ptr -bt -echo =========\n -cont -end diff --git a/src/server/getopt.h b/src/server/getopt.h deleted file mode 100644 index 0157e8da6..000000000 --- a/src/server/getopt.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. - - 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, 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. */ - -#ifndef _GETOPT_H_ -#define _GETOPT_H_ - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option -{ -#ifdef __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -#ifdef __STDC__ -extern int getopt (int argc, char *const *argv, const char *shortopts); -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* not __STDC__ */ - -#endif /* _GETOPT_H_ */ diff --git a/src/server/handle-malloc-dump.el b/src/server/handle-malloc-dump.el deleted file mode 100644 index a05792a8a..000000000 --- a/src/server/handle-malloc-dump.el +++ /dev/null @@ -1,157 +0,0 @@ -;;;; -;;;; $Id: handle-malloc-dump.el,v 1.2 1992/05/31 01:10:43 ceder Exp $ -;;;; Copyright (C) 1991 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. -;;;; - -(require 'elib-dll) - -;;; block - each block that is active is stored on a dll. The dll -;;; contains blocks. Each block consists of 'addr' - the base addr of -;;; the block - and 'marker' - a marker that points to the backtrace. - -;;; Constructor: - -(defun create-block (addr - marker) - "Create a block from ADDR and MARKER." - (cons - 'BLOCK - (vector addr marker ))) - - -;;; Selectors: - -(defun block->addr (block) - "Get addr from BLOCK." - (elt (cdr block) 0)) - -(defun block->marker (block) - "Get marker from BLOCK." - (elt (cdr block) 1)) - - -;;; Modifiers: - -(defun set-block->addr (block newval) - "Set addr in BLOCK to NEWVAL." - (aset (cdr block) 0 newval)) - -(defun set-block->marker (block newval) - "Set marker in BLOCK to NEWVAL." - (aset (cdr block) 1 newval)) - - - -;;; Predicate: - -(defun block-p (object) - "Return t if OBJECT is a block." - (eq (car-safe object) 'BLOCK)) - - - -(defvar mstack nil - "A dll that holds all currently active memory blocks.") - -(defvar illegal-free nil - "A dll that holds all illegal free attempts.") - -(defun resolve-trace () - "Search the current buffer, and output any erroneous -mallocs/reallocs/frees to *Result*." - (interactive) - (setq mstack (dll-create)) - (setq illegal-free (dll-create)) - (goto-char (point-min)) - (while (re-search-forward "^--- \\(.*\\) ---$" nil 'foo) - (let* ((fn (buffer-substring (match-beginning 1) (match-end 1))) - (btstart (match-end 0)) - (btend (progn (re-search-forward "^==== end ====") - (match-beginning 0)))) - - (message fn) - (cond - ((string= fn "malloc") - (beginning-of-line 0) - (allocate)) - ((string= fn "free") - (beginning-of-line 0) - (free)) - ((string= fn "realloc") - (beginning-of-line -1) - (free) - (beginning-of-line 2) - (allocate))))) - (report-stacks)) - -(defun get-number () - "Get the last hex-string on this line, as a string." - (re-search-forward "0x[0-9a-f]*$") - (buffer-substring (match-beginning 0) (match-end 0))) - -(defun allocate () - "Add an unresolved allocation to mstack." - (dll-enter-first mstack - (create-block (get-number) - (point)))) - -(defun free () - "Resolve an allocation from mstack." - (let ((addr (get-number)) - (node (dll-nth mstack 0))) - (while (and node - (not (string= addr - (block->addr (dll-element mstack node))))) - (setq node (dll-next mstack node))) - (if node - (dll-delete mstack node) - (dll-enter-first illegal-free (create-block addr (point)))))) - -(defun report-stacks () - (save-window-excursion - (pop-to-buffer "*Result*" t) - (erase-buffer) - (insert "Forgotten mallocs:\n\n")) - (report-stack mstack) - (save-window-excursion - (pop-to-buffer "*Result*" t) - (insert "\n\nIllegal frees:\n\n")) - (report-stack illegal-free)) - - - -(defun report-stack (stack) - (let ((gdb-buf (current-buffer)) - (node (dll-nth stack 0))) - (while node - (goto-char (block->marker (dll-element stack node))) - (re-search-backward "^---") - (let* ((b (point)) - (e (progn - (re-search-forward "====$") - (point)))) - (save-excursion - (set-buffer "*Result*") - (insert (format "From char %d:\n" b)) - (insert-buffer-substring gdb-buf (1- b) (1+ e)))) - (setq node (dll-next stack node))))) diff --git a/src/server/internal-connections.c b/src/server/internal-connections.c deleted file mode 100644 index 0bcea8fd5..000000000 --- a/src/server/internal-connections.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * $Id: internal-connections.c,v 0.10 1992/05/18 23:09:21 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * internal-connections.c - * - * Abstract routines on the data type Connection. - */ - -static char *rcsid = "$Id: internal-connections.c,v 0.10 1992/05/18 23:09:21 ceder Exp $"; - - -#include "exp.h" -#include <kom-types.h> -#include <server/smalloc.h> -#include "com.h" -#include "connections.h" -#include "internal-connections.h" -#include "lyskomd.h" -#include "config.h" -#include "log.h" - -INTERNAL Connection *all_connections = NULL; -INTERNAL Session_no no_of_connection_attempts = 0; - -/* Used in get_conn_by_number to speed things up. */ - -INTERNAL Connection *last_conn = NULL; - -INTERNAL const Connection EMPTY_CONNECTION = - ((Connection){0, NULL, NULL, - /* Things used by services.c */ - 0, NULL, NO_TIME, 0, - EMPTY_STRING_i, 0, - EMPTY_STRING_i, EMPTY_STRING_i, EMPTY_STRING_i, - FALSE, FALSE, - /* Used by server/connections.c */ - NULL, '\0', - 0, 0, 0, 0, 0, 0, 0, - /* Gather data... */ - 0, 0, 0, 0, EMPTY_STRING_i, EMPTY_STRING_i, - EMPTY_STRING_i, NULL, NULL, DEFAULT_PRIV_BITS_i, - NULL_CONF_TYPE_i, EMPTY_tm_i, - /* Protocol independent... */ - EMPTY_STRING_i, 0, FALSE, - NO_TIME, 0}); - -static int no_of_allocated_connections = 0; - -INTERNAL Connection * -alloc_connection(void) -{ - Connection *res; - - res = smalloc ( sizeof(Connection) ); - *res = EMPTY_CONNECTION; - ++no_of_allocated_connections; - return res; -} - -EXPORT Connection * -new_client(void) -{ - Connection *c; - - c = alloc_connection(); - - c->magic = CONN_MAGIC_ALLOC; - - if (all_connections != NULL) - { - all_connections->prev->next = c; - c->prev = all_connections->prev; - all_connections->prev = c; - c->next = all_connections; - } - else - { - c->prev = c; - c->next = c; - } - - all_connections = c; - - c->session_no = ++no_of_connection_attempts; - c->protocol = '\0'; /* Reserved to mean 'no protocol specified yet' */ - c->unparsed = EMPTY_STRING; - c->first_to_parse = 0; - c->more_to_parse = TRUE; - c->last_request = NO_TIME; - c->pers_no = 0; - c->person = NULL; - time( & c->session_start ); - c->cwc = 0; - c->what_am_i_doing = EMPTY_STRING; - c->ena_level = 0; - c->username = EMPTY_STRING; - c->ident_user = EMPTY_STRING; - c->invisible = FALSE; - c->username_valid = FALSE; - - return c; -} - -/* - * Only used from logout_client - */ -EXPORT void -kill_client(Connection *cp) -{ - if ( all_connections == NULL ) - restart_kom("kill_client(): No clients in all_connections list\n"); - - if (all_connections == all_connections->next) - { - if (all_connections->prev != all_connections) - restart_kom("kill_client(): all_connections corrupt (LINK)\n"); - - if (all_connections != cp) - restart_kom("kill_client(): all_connections corrupt (SINGLE)\n"); - - all_connections = NULL; - } - else - { - if (cp->prev == NULL || cp->next == NULL) - restart_kom("kill_client(): all_connections corrupt (NULL)\n"); - - cp->prev->next = cp->next; - cp->next->prev = cp->prev; - - if (all_connections == cp) - all_connections = cp->next; - } - - if ( last_conn == cp ) - last_conn = NULL; - - cp->magic = CONN_MAGIC_FREE; - - s_clear(&cp->unparsed); - s_clear(&cp->what_am_i_doing); - s_clear(&cp->username); - s_clear(&cp->hostname); - s_clear(&cp->ident_user); - - if ( cp->mux != NULL ) - { - log("kill_client(): client %d has mux != NULL.\n", - cp->session_no); - } - - if ( !s_empty(cp->c_string0) || !s_empty(cp->c_string1) - || !s_empty(cp->string0) ) - { - log("kill_client(): unexpected string remains.\n"); - } - - if ( cp->c_misc_info_p != NULL || cp->c_local_text_no_p != NULL ) - log("kill_client(): unexpected remaining data.\n"); - - sfree(cp); - --no_of_allocated_connections; -} - -#ifdef DEFENSIVE_CHECKS - -INTERNAL void -check_conn_exists(Connection *foo) -{ - /* Check that foo really is active. */ - - Connection *c = all_connections; - Bool found = FALSE; - - do - { - if ( c == foo ) - found = TRUE; - - c = c->next; - } - while ( c != all_connections && found == FALSE ); - - if ( found == FALSE ) - restart_kom("get_conn_by_number: foo == %d not found in" - " all_connections.\n", last_conn->session_no); -} - -#endif - -/* - * Session_nos must NOT be recycled, or this code might break! - */ -EXPORT Connection * -get_conn_by_number (Session_no session_no) -{ - Connection *end; - - if ( last_conn == NULL ) - last_conn = all_connections; - else if ( all_connections == NULL ) - { - restart_kom("get_conn_by_number(%d): last_conn = %d and " - "all_connections == NULL", session_no, - last_conn->session_no); - } -#ifdef DEFENSIVE_CHECKS - else - check_conn_exists(last_conn); -#endif - - end = last_conn; - - do - { - if ( last_conn->session_no == session_no ) - return last_conn; - - last_conn = last_conn->next; - } - while ( last_conn != end); - - return NULL; -} - - -EXPORT Session_no -traverse_connections (Session_no session_no) -{ - Connection *prev = NULL; - - if ( all_connections == NULL ) - return 0; - - prev = get_conn_by_number ( session_no ); - - /* prev is NULL if session_no is 0, or if session_no was logged out. */ - - if ( prev == NULL ) - return all_connections->session_no; - else if ( prev->next == all_connections ) - return 0; /* Full circle. */ - else - return prev->next->session_no; -} - -void -dump_allocated_connections(FILE *fp) -{ - fprintf(fp, "---" __FILE__ ":\n\tConnections: %d\n", - no_of_allocated_connections); - fprintf(fp, "\tConnection attempts: %d\n", - no_of_connection_attempts); -} diff --git a/src/server/internal-connections.h b/src/server/internal-connections.h deleted file mode 100644 index d8d1e91a3..000000000 --- a/src/server/internal-connections.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id: internal-connections.h,v 0.4 1991/09/15 10:31:59 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: internal-connections.h,v 0.4 1991/09/15 10:31:59 linus Exp $ - * - * internal-connections.c - * - * Abstract routines on the data type Connection. - */ - -extern Connection * -new_client(void); - -extern void -kill_client(Connection *cp); - - -extern Connection * -get_conn_by_number (Session_no session_no); - - -extern Session_no -traverse_connections (Session_no session_no); - -extern void -dump_allocated_connections(FILE *fp); diff --git a/src/server/internal-services.h b/src/server/internal-services.h deleted file mode 100644 index 7d62cb860..000000000 --- a/src/server/internal-services.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * $Id: internal-services.h,v 0.4 1992/02/26 18:45:10 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: internal-services.h,v 0.4 1992/02/26 18:45:10 ceder Exp $ - * - * server/services.h - * - * F|rv{xla inte denna fil med services.h! - * - * I denna fil ligger en del funktioner typ do_delete_text som anropas - * b}de av servern (n{r en text blir f|r gammal) och av klienten (n{r - * en av{ndare kom p} att han inte ville ha texten kvar) - * - * Funktionerna i denna fil har kontrollerar inte att ACTPERS har r{tt att - * g|ra det som g|rs. +++FIXME--translate to english - */ - - -extern Bool logins_allowed; /* Defined in server/services.c */ - -/* - * Create a conference. - * - * Returns (Conf_no) 0 if there is an error. - */ - -extern Conf_no -do_create_conf(String name, - Pers_no creator, - Conf_no supervisor, - Conf_no super_conf, - Conf_type type); - - - -extern Success -do_delete_text(Text_no text_no, - Text_stat *text_s); diff --git a/src/server/isc-interface.h b/src/server/isc-interface.h deleted file mode 100644 index 200864460..000000000 --- a/src/server/isc-interface.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * $Id: isc-interface.h,v 0.4 1992/04/15 22:59:18 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: isc-interface.h,v 0.4 1992/04/15 22:59:18 ceder Exp $ - * - * Wrapper around <isc.h> to ensure that ISC_UDGTYPE is always correct. - */ - -#define ISC_UDGTYPE struct mux -#include <isc-new.h> diff --git a/src/server/isc-malloc.c b/src/server/isc-malloc.c deleted file mode 100644 index 5829c7b3c..000000000 --- a/src/server/isc-malloc.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * $Id: isc-malloc.c,v 1.1 1992/04/15 22:45:57 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * Malloc wrappers for the isc package. - * - * These functions call smalloc and also counts - * how many allocated blocks there are. - */ - -static char *rcsid = "$Id: isc-malloc.c,v 1.1 1992/04/15 22:45:57 ceder Exp $"; - - -#include <stdio.h> -#include <stddef.h> -#include <server/smalloc.h> -#include "log.h" -#include "exp.h" -#include "isc-malloc.h" - -static int no_of_allocated_blocks = 0; - -EXPORT void * -isc_malloc_wrapper(size_t size) -{ - ++no_of_allocated_blocks; - return smalloc (size); -} - - -EXPORT void -isc_free_wrapper(void * ptr) -{ - --no_of_allocated_blocks; - sfree(ptr); -} - -EXPORT void * -isc_realloc_wrapper (void * ptr, - size_t size) -{ - if ( ptr == NULL ) - return isc_malloc_wrapper (size); - - return srealloc (ptr, size); -} - - -EXPORT void -dump_isc_alloc_counts(FILE *stat_file) -{ - fprintf(stat_file, "---" __FILE__ ":\n" - "\tAllocated blocks by isc: %d\n", - no_of_allocated_blocks); -} diff --git a/src/server/isc-malloc.h b/src/server/isc-malloc.h deleted file mode 100644 index c80e6f8c7..000000000 --- a/src/server/isc-malloc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * $Id: isc-malloc.h,v 1.1 1992/04/15 22:45:54 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: isc-malloc.h,v 1.1 1992/04/15 22:45:54 ceder Exp $ - * - * Malloc wrappers for the string package. - * - * These functions call smalloc and also counts - * how many allocated strings there are. - */ - -extern void * -isc_malloc_wrapper (size_t size); - - -extern void -isc_free_wrapper (void * ptr); - -extern void * -isc_realloc_wrapper (void * ptr, - size_t size); - -extern void -dump_isc_alloc_counts(FILE *stat_file); diff --git a/src/server/isc-parse.c b/src/server/isc-parse.c deleted file mode 100644 index c99ca1708..000000000 --- a/src/server/isc-parse.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * $Id: isc-parse.c,v 0.3 1991/09/15 10:31:51 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * Generic parse routines. - */ - -static char *rcsid = "$Id: isc-parse.c,v 0.3 1991/09/15 10:31:51 linus Exp $"; - - -#include <setjmp.h> -#include <string.h> -#include <stdio.h> -#include "lyskomd.h" -#include <kom-types.h> -#include "com.h" -#include "connections.h" -#include "isc-parse.h" - -int -parse_char(Connection *client) -{ - if ( client->unparsed.len <= client->first_to_parse ) - longjmp(parse_env, ISC_MSG_INCOMPLETE); - - return client->unparsed.string[ client->first_to_parse++ ]; -} - - -int -parse_nonwhite_char(Connection *client) -{ - int c; - - while ( strchr(" \t\n\r", c=parse_char(client) ) != NULL ) - ; - return c; -} diff --git a/src/server/isc-parse.h b/src/server/isc-parse.h deleted file mode 100644 index 671f94bc0..000000000 --- a/src/server/isc-parse.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * $Id: isc-parse.h,v 0.3 1991/09/15 10:31:48 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: isc-parse.h,v 0.3 1991/09/15 10:31:48 linus Exp $ - * - */ -#define ISC_PROTOCOL_ERR 1 -#define ISC_MSG_INCOMPLETE 2 -#define ISC_LOGOUT 3 - -int -parse_char(Connection *client); - -int -parse_nonwhite_char(Connection *client); diff --git a/src/server/kom-types.c b/src/server/kom-types.c deleted file mode 100644 index 080ede36a..000000000 --- a/src/server/kom-types.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * $Id: kom-types.c,v 0.4 1992/04/04 17:27:55 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * kom-types.c - * Definition of constants and other thing that - * can't or shouldn't be defined in header files. - * - * - * Copyright (C) 1990 Lysator Computer Club - * Linkoping University, Sweden - * - * Everyone is granted permission to copy, modify and redistribute - * this code, provided the people they give it to can. - * - * - * Author: Thomas Bellman - * Lysator Computer Club - * Linkoping University - * Sweden - * - * email: bellman@Lysator.LiU.SE - */ - -static char *rcsid = "$Id: kom-types.c,v 0.4 1992/04/04 17:27:55 ceder Exp $"; - - - -#include <stdio.h> - -#include <kom-types.h> -#include <config.h> - -#define EXPORT - - -EXPORT const Conf_list_old EMPTY_CONF_LIST_OLD = EMPTY_CONF_LIST_OLD_i; - -EXPORT const Pers_list EMPTY_PERS_LIST = EMPTY_PERS_LIST_i; - -EXPORT const Mark_list EMPTY_MARK_LIST = EMPTY_MARK_LIST_i; - -EXPORT const Conf_type NULL_CONF_TYPE = NULL_CONF_TYPE_i; - -EXPORT const Membership EMPTY_MEMBERSHIP = EMPTY_MEMBERSHIP_i; - -EXPORT const Membership_list EMPTY_MEMBERSHIP_LIST = EMPTY_MEMBERSHIP_LIST_i; - -EXPORT const Text_list EMPTY_TEXT_LIST = EMPTY_TEXT_LIST_i; - -EXPORT const Member_list EMPTY_MEMBER_LIST = EMPTY_MEMBER_LIST_i; - -EXPORT const Session_info EMPTY_SESSION_INFO = EMPTY_SESSION_INFO_i; - -EXPORT const Session_info_ident EMPTY_SESSION_INFO_IDENT - = EMPTY_SESSION_INFO_IDENT_i; - -EXPORT const Who_info_old EMPTY_WHO_INFO_OLD = EMPTY_WHO_INFO_OLD_i; - -EXPORT const Who_info_list_old EMPTY_WHO_INFO_LIST_OLD = - EMPTY_WHO_INFO_LIST_OLD_i; - -EXPORT const Who_info EMPTY_WHO_INFO = EMPTY_WHO_INFO_i; - -EXPORT const Who_info_ident EMPTY_WHO_INFO_IDENT = EMPTY_WHO_INFO_IDENT_i; - -EXPORT const Who_info_list EMPTY_WHO_INFO_LIST = EMPTY_WHO_INFO_LIST_i; - -EXPORT const Priv_bits DEFAULT_PRIV_BITS = DEFAULT_PRIV_BITS_i; - -EXPORT const Personal_flags DEFAULT_PERSONAL_FLAGS = DEFAULT_PERSONAL_FLAGS_i; - - -EXPORT const Person EMPTY_PERSON = EMPTY_PERSON_i; - -EXPORT const Conference EMPTY_CONFERENCE = EMPTY_CONFERENCE_i; - -EXPORT const Small_conf EMPTY_SMALL_CONF = EMPTY_SMALL_CONF_i; - -EXPORT const Text_stat EMPTY_TEXT_STAT = EMPTY_TEXT_STAT_i; diff --git a/src/server/log.c b/src/server/log.c deleted file mode 100644 index 23e0a7a5d..000000000 --- a/src/server/log.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * $Id: log.c,v 0.3 1991/09/15 10:31:36 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * log.c - * - * File created by ceder 1990-05-25. - */ - -static char *rcsid = "$Id: log.c,v 0.3 1991/09/15 10:31:36 linus Exp $"; - - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include "log.h" - -/* - * Add a string to the log file. - */ - -extern void -log (const char * format, ...) -{ - va_list AP; - - va_start(AP, format); - logv(format, AP); - va_end(AP); -} - - -extern void -logv (const char *format, va_list AP) -{ - time_t clock; - - - time(&clock); - - fprintf(stderr, "--LOGG-> %s: ", ctime(&clock)); - vfprintf(stderr, format, AP); - - fflush(stderr); -} diff --git a/src/server/log.h b/src/server/log.h deleted file mode 100644 index 24d0844de..000000000 --- a/src/server/log.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * $Id: log.h,v 0.3 1991/09/15 10:31:32 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: log.h,v 0.3 1991/09/15 10:31:32 linus Exp $ - * - * log.h - * - * File created by ceder 1990-05-25. - */ - -#ifndef __LYSKOM__LOG_H__ -#define __LYSKOM__LOG_H__ - -/* - * Add a string to the log file. - */ - -extern void -log (const char * format, ...); - -#ifdef _STDARG_H - extern void - logv (const char * format, va_list AP); -#endif - -#endif diff --git a/src/server/logII.c b/src/server/logII.c deleted file mode 100644 index b463100d8..000000000 --- a/src/server/logII.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * $Id: logII.c,v 0.2 1991/09/15 10:31:29 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * log.c - * - * File created by ceder 1990-05-25. - */ - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> - -enum -{ - MESSAGE, /* No action when message_counter is 0. */ - WARNING, /* Sync&Restart when message_counter is 0. */ - RESTART, /* Sync&Restart immediately. */ - CRASH /* Don't sync, but restart immediately. */ - } log_class; - -typedef enum log_class Log_class; - - -extern void -log (Log_class class, - const char *file, - const char *function, - int *message_counter, - const char *format, ...) -{ - va_list AP; - time_t clock; - Bool log_it = TRUE; - Bool restart = FALSE; - - va_start(AP, format); - time(&clock); - - switch(log_class) - { - case MESSAGE: - if ( message_counter != NULL && message_counter > 0 ) - message_counter--; - else - log_it = FALSE; - break; - case WARNING: - if ( message_counter != NULL ) - if ( *message_counter > 0 ) - message_counter--; - else - restart = TRUE; - break; - case RESTART: - case CRASH: - break; -#ifndef COMPILE_CHECKS - default: - fprintf(stderr, "Deep Internal Error: log() called" - "with log_class %d.\n", log_class); -#endif - } - - if ( log_it == TRUE ) - { - fprintf(stderr, "--> %-19s %-29s %s", ctime(&clock)); - vfprintf(stderr, format, AP); - } - - if ( log_class == RESTART || (log_class == WARNING - && message_counter != NULL - && *message_counter <= 0)) - { - fprintf(stderr, "++> Syncing.\n"); - cache_sync(); - } - - if ( restart == TRUE || log_class == RESTART || log_class == CRASH ) - { - fprintf(stderr, "+++> Restarting LysKOM.\n"); -/* #include "CloseFileDescriptors" */ - execl("/usr/lyskom/bin/ramkomd", "ramkomd", NULL); - fprintf(stderr, "+++> execl() failed.\n"); - exit(1); - } - - va_end(AP); -} - - diff --git a/src/server/lyskomd.h b/src/server/lyskomd.h deleted file mode 100644 index e2f6884a2..000000000 --- a/src/server/lyskomd.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * $Id: lyskomd.h,v 0.6 1992/05/31 01:14:35 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: lyskomd.h,v 0.6 1992/05/31 01:14:35 ceder Exp $ - */ - - -/* Defined in ramkomd.c */ -extern int num_ip_client_port; -extern int num_ip_mux_port; - -/* - * restart_kom is used to try to recover from an impossible error. - * This function is in fact never called, unless some cosmic radiation - * changes some pointers or suchlike. - * - * The msg string is sent as a mail to kom@lysator.liu.se - * (At least one member in that group should not read his mail using kom...) - */ - - -extern void -restart_kom(const char * format, ...); diff --git a/src/server/malloc.gdb b/src/server/malloc.gdb deleted file mode 100644 index 37579b132..000000000 --- a/src/server/malloc.gdb +++ /dev/null @@ -1,11 +0,0 @@ -commands -silent -echo --- smalloc ---\n -echo Arg: -print size -echo Val: -print p -bt -echo =========\n -cont -end diff --git a/src/server/manipulate.h b/src/server/manipulate.h deleted file mode 100644 index 51e6a7478..000000000 --- a/src/server/manipulate.h +++ /dev/null @@ -1,396 +0,0 @@ -/* - * $Id: manipulate.h,v 0.6 1992/02/26 18:45:08 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: manipulate.h,v 0.6 1992/02/26 18:45:08 ceder Exp $ - * - * manipulate.h - * - * Skapad av ceder n}gon g}ng efter 1990-05-25, men f|re 1990-07-05. - */ - -/* - * Definition of macros used in services.c and manipulate.c - */ - -/* pers_no of the connected person. (0 if not logged in) */ -#define ACTPERS (active_connection->pers_no) - -/* person of the connected person. (NULL if not logged in) */ -#define ACT_P (active_connection->person) - -/* many functions can only be used if ACTPERS is logged in */ - -#define CHK_LOGIN(errortype) \ -{ \ - if ( ! ACTPERS ) \ - { \ - kom_errno = KOM_LOGIN; \ - return errortype; \ - } \ -} - - -/* Conference 0 does never exist. */ - -#define CONF_ZERO(conf, errortype) \ -{ \ - if ( (conf) == 0 ) \ - { \ - kom_errno = KOM_CONF_ZERO; \ - return errortype; \ - } \ -} - - -/* Check that a conference exists */ - -#define CHK_EXIST(conf, errortype) \ -{ \ - CONF_ZERO(conf, errortype); \ - if ( !cached_conf_exists( conf )) \ - { \ - kom_errno = KOM_UNDEF_CONF; \ - return errortype; \ - } \ -} - - -/* do a cached_get_person_stat */ - -#define GET_P_STAT(p_stat_p, pers_no, failure) \ -{ \ - if ( ((p_stat_p) = cached_get_person_stat( pers_no )) == NULL) \ - { \ - return (failure); \ - } \ -} - -/* do a cached_get_conf_stat */ - -#define GET_C_STAT(c_stat_p, conf_no, failure) \ -{ \ - if ( ((c_stat_p) = cached_get_conf_stat( conf_no )) == NULL) \ - { \ - return (failure); \ - } \ -} - -/* do a cached_get_text_stat */ - -#define GET_T_STAT(t_stat_p, text_no, failure) \ -{ \ - if ( ((t_stat_p) = cached_get_text_stat( text_no )) == NULL) \ - { \ - return (failure); \ - } \ -} - - -/* - * ENA returns TRUE if ACTPERS has his privtype bit set, and has - * enabled to at least req_lev. - */ - -#define ENA(privtype, req_lev) \ -(active_connection->ena_level >=(req_lev) && (ACT_P)->privileges.privtype) - - - -/* - * Add a misc item to a text_status. - * The item is put last on the list. Thus this macro should not be used - * to add rec_time. - * - * Text_stat * text_stat_pointer Textstatus to modify - * Info_type type_of_misc Type om misc_item to add - * tag_name Tagname in Info_datum - * value_of_misc Value to set tag_name to. - */ -#define ADD_MISC(text_stat_pointer, type_of_misc, tag_name, value_of_misc) \ -{ \ - /* Allocate space */ \ - text_stat_pointer->misc_items \ - = srealloc(text_stat_pointer->misc_items, \ - (++(text_stat_pointer->no_of_misc)) * sizeof(Misc_info));\ - \ - /* Set type */ \ - text_stat_pointer->misc_items[ text_stat_pointer->no_of_misc-1 ] \ - .type = type_of_misc; \ - \ - /* Set value */ \ - text_stat_pointer->misc_items[ text_stat_pointer->no_of_misc-1 ] \ - .datum.tag_name = value_of_misc; \ -} - - -/* - * IMPL - returns with error "not implemented yet" - */ - -#define IMPL(code) \ -{ \ - kom_errno = KOM_NOT_IMPL; \ - return code; \ -} - -/* - * A value of the following type are returned from access_perm() and - * fast_access_perm(). They are used to see how much viewer is allowed to - * read/modify the data of a given conference. - * - * access_perm() alway returns the "highest" from this list. - * fast_access_perm() avoids reading the conference struct. It will only - * return "unlimited" if the conference is secret and ACTPERS - * is not a member of the conference. fast_access_perm() is used - * in lookup_name() which sometimes have to check the access - * permissions of _all_ conferences. If access_perm() was used - * _all_ conference statuses would have to be read in into the - * cache in a single atomic call, and that would mean that the - * cache would overflow if there are many conferences. - * Now only the conference statuses for secret conferences of - * which ACTPERS is not a member have to be read in. - */ - -typedef enum { - error, /* The conf doesn't exist or other error. */ - none, /* A secret conference. */ - read_protected, /* An rd_prot conference. */ - limited, /* An open conference. */ - member, /* ACTPERS is a member of the conference. */ - unlimited /* ACTPERS is supervisor of the conference. */ -} Access; - - - -/* - * Functions which manipulate the CONFERENCE struct. - */ - -extern Success -chk_passwd( Password pwd, - const String s ); - - -/* - * Locate the Member struct in CONF_C for person PERS_NO - */ - -extern Member * -locate_member(Pers_no pers_no, - Conference * conf_c); - - -/* - * Return TRUE if viewer is a supervisor to CONF. - */ - -extern Bool -is_supervisor(Conf_no conf, - Conference * conf_c, /* May be NULL */ - Pers_no viewer, - Person * viewer_p); /* May be NULL */ - - - -/* - * This function is called whenever a person leaves a conf, - * i e when he pepsi():s or logout():s. - */ - -extern void -leave_conf(void); - - -/* - * Change presentation of a conference. If text_no is 0, there will be - * no presentation. - */ - -extern Success -do_set_presentation(Conf_no conf_no, - Conference * conf_c, - Text_no text_no); - - -/* - * Change motd of a conference. If text_no is 0, there will be - * no motd. - */ - -extern Success -do_set_etc_motd(Conf_no conf_no, - Conference * conf_c, - Text_no text_no); - - - - -/* - * Functions that manupulate the PERSON struct - */ - -/* - * Find the data about PERS_P:s membership in CONF_NO. - * Return NULL if not found - */ - -extern Membership * -locate_membership(Conf_no conf_no, - Person * pers_p); - - - -/* - * Delete a person. (The mailbox is not deleted);. - */ - -extern Success -do_delete_pers (Pers_no pers_no); - - -/* - * Functions which work on CONFERENCES and/or PERSONS. - */ - -/* - * Add a member to a conference. All errorchecking should already - * be done when this function is called. The person must not already - * be a member of the conference. It is _not_ an error to make WHERE bigger - * than the number of conferences the person is a member in. - */ - -extern void -do_add_member(Conf_no conf_no, /* Conference to add a new member to. */ - Conference * conf_c, /* Conf. status. Must NOT be NULL. */ - Pers_no pers_no, /* Person to be added. */ - Person * pers_p, /* Pers. status. Must NOT be NULL. */ - u_char priority, /* Prioritylevel to assign to this conf */ - u_short where); /* Sequence number in the list */ - -/* - * Return TRUE if ACTPERS has enough privileges to access VICTIM's data. - * VICTIM is a person or a conference. - * Meaning of return values: - * unlimited: ACTPERS is supervisor of VICTIM, or ACTPERS is admin, - * or ACTPERS is VICTIM - * none: VICTIM is secret, and ACTPERS is not a member - * member: ACTPERS is a member in VICTIM, but doesn't have unlimited - * access. - * limited: otherwise. - * error: see kom_errno - */ - -extern Access -access_perm(Conf_no victim, - Conference * victim_c, /* May be NULL */ - Pers_no viewer, - Person * viewer_p); /* May be NULL */ - -/* - * Fast version of access_perm. This function does not check if ATCPERS is a - * supervisor of the conference. This function should be used i calls where - * a lot of conferences are checked to avoid readin in conferences from the - * cache. - * - * BUG: If a person is supervisor of a secret conf he is not member in the - * result will be 'none'. - * - * unlimited: ACTPERS is admin, or ACTPERS is VICTIM - * none: VICTIM is secret, and ACTPERS is not a member - * member: ACTPERS is a member in VICTIM, but doesn't have unlimited - * access. - * limited: otherwise. - * error: see kom_errno - */ -Access -fast_access_perm(Conf_no victim, - Pers_no viewer, - Person *viewer_p); - - -/* - * Return TRUE if NAME is a legal name - */ - -extern Bool -legal_name( String name ); - - -/* - * Return TRUE if NAME is not already used - */ - -extern Bool -unique_name( const String name, Conf_no conf_no ); - - - - -/* - * Delete a member from a conference. - * No checks are made on the parameters. - * The dynamically allocated areas conf_c->members.members and - * pers_p->confs are NOT reallocated since they will anyhow sooner or later - * be flushed from core. - */ - -extern Success -do_sub_member(Conf_no conf_no, /* Conf to delete member from. */ - Conference * conf_c, /* May be NULL */ - Member * member, /* May be NULL */ - Pers_no pers_no, /* Person to be deleted. */ - Person * pers_p, /* May be NULL */ - Membership * mship); /* Pointer to the persons membership in - conf., or NULL if not known. */ - - -/* - * Functions which deal with TEXTS - */ - -/* - * Check if ACTPERS is allowed to read this text. - * Returns TRUE if he is allowed to read it. - */ - -extern Bool -text_read_access(Text_no text_no, - Text_stat * text_stat); - - - - -/* - * Check if ACTPERS has sent this text as a footnote to parent. - */ -extern Bool -is_footn_sender(Text_stat * text_s, - Text_no parent); - - -extern void -forced_leave_conf(Pers_no pers_no, - Conf_no conf_no); - diff --git a/src/server/membership.c b/src/server/membership.c deleted file mode 100644 index 2cd8ec224..000000000 --- a/src/server/membership.c +++ /dev/null @@ -1,1224 +0,0 @@ -/* - * $Id: membership.c,v 0.10 1992/04/04 17:28:16 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * membership.c - * - * All atomic calls that controlls who is a member in what. - * (The person/conf relation). - */ - -static char *rcsid = "$Id: membership.c,v 0.10 1992/04/04 17:28:16 ceder Exp $"; - -#include <time.h> -#include <stdlib.h> -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "manipulate.h" -#include <server/smalloc.h> -#include "cache.h" -#include "log.h" -#include "minmax.h" -#include "com.h" -#include "isc-interface.h" -#include "connections.h" -#include "send-async.h" -#include <kom-errno.h> -#include "internal-connections.h" - -#define DEBUG_MARK_AS_READ - -#ifdef DEBUG_MARK_AS_READ -# include <stdio.h> -# include <string.h> -# include "ram-output.h" -#endif - - - - - -/* - * Copy all information that ACTPERS is authorized to know about ORIG_P's - * membership in all conferences to CENSOR_P. - * - * This function is used in get_membership(). - */ -static void -copy_public_confs (Person * censor_p, /* The censored Person-struct */ - Person * orig_p, /* The uncensored Person-struct */ - Bool want_read) /* Does ACTPERS want to know - * which texts are read?*/ -{ - int i; /* Number of mships lefte in ORIG_P */ - Membership * censor_m; /* Pointer in CENSOR_P */ - Membership * orig_m; /* Pointer in ORIG_P */ - - - /* Copy all information except the secret. */ - - censor_p->conferences.confs - = tmp_alloc( orig_p->conferences.no_of_confs * sizeof(Membership)); - censor_p->conferences.no_of_confs = 0; - - censor_m = censor_p->conferences.confs; - orig_m = orig_p->conferences.confs; - - for ( i = 0; i < orig_p->conferences.no_of_confs; i++, orig_m++ ) - { - if ( fast_access_perm (orig_m->conf_no, ACTPERS, ACT_P) > none ) - { - *censor_m = *orig_m; - - if ( orig_p->flags.unread_is_secret || !want_read ) - { - censor_m->no_of_read = 0; - censor_m->read_texts = NULL; - } - - if ( orig_p->flags.unread_is_secret ) - { - censor_m->last_time_read = NO_TIME; - censor_m->last_text_read = 0; - } - - ++censor_m; - ++censor_p->conferences.no_of_confs; - } - } -} - -/* - * Change the priority of a certain conference in a person. - */ -static void -do_change_priority (Membership * mship, - u_char priority, - u_short where, - Pers_no pers_no, - Person * pers_p) -{ - Membership tmp_conf; - - mship->priority = priority; - - /* Check range of where */ - - if ( where >= pers_p->conferences.no_of_confs ) - { - where = pers_p->conferences.no_of_confs - 1; - } - - /* And now move the conference to slot number 'where' */ - - if ( mship < pers_p->conferences.confs + where ) - { - tmp_conf = *mship; - while ( mship < pers_p->conferences.confs + where) - { - *mship = *(mship + 1); - mship++; - } - *mship = tmp_conf; - } - else - { - tmp_conf = *mship; - while ( mship > pers_p->conferences.confs + where) - { - *mship = *(mship - 1); - mship--; - } - *mship = tmp_conf; - } - - mark_person_as_changed( pers_no ); -} - - -/* - * Insert a rec_time misc item to a text_status. - * The item is put at position POS on the list. (0 == first) - * Take no action if the misc_item at POS is a rec_time. - * This function is only used when a person marks his letters as read. - * - * Text_stat * text_stat_pointer Textstatus to modify - * int pos Where to insert rec_time - */ - -static void -do_add_rec_time (Text_stat * text_stat_ptr, - int pos) -{ - int i; - - /* Defensive checks */ - if ( pos < 0 || pos > text_stat_ptr->no_of_misc ) - { - restart_kom("do_add_rec_time() - illegal pos\n"); - } - - /* Check that no rec_time exists */ - - if ( pos < text_stat_ptr->no_of_misc - && text_stat_ptr->misc_items[ pos ].type == rec_time ) - { - return; - } - - /* Allocate space */ - text_stat_ptr->misc_items - = srealloc(text_stat_ptr->misc_items, - (++(text_stat_ptr->no_of_misc)) * sizeof(Misc_info)); - - /* Move items. */ - - for ( i = text_stat_ptr->no_of_misc - 1; i > pos; i-- ) - { - text_stat_ptr->misc_items[ i ] = text_stat_ptr->misc_items[ i - 1 ]; - } - - /* Set type */ - text_stat_ptr->misc_items[ pos ].type = rec_time; - - /* Set value */ - time( & text_stat_ptr->misc_items[ pos ].datum.received_at); -} - -/* - * add_rec_time adds a 'rec_time' misc_item to text number LOC_NO in - * conference CONF_NO. The item will follow a recpt or cc_recpt to ACTPERS. - * No action is taken if ACTPERS is not a recipient of the text, or the text - * no longer exists, or the text has already been received. - */ -static void -add_rec_time(Conf_no conf_no, - Conference * conf_c, /* The structure for conf_no */ - Local_text_no local_no) -{ - Bool found; - Text_no text_no; - Text_stat * t_stat; - int i; - - if ( local_no >= conf_c->texts.first_local_no + conf_c->texts.no_of_texts - || local_no < conf_c->texts.first_local_no ) - { - return; /* No longer exists in conf. */ - } - - text_no = conf_c->texts.texts[ local_no - conf_c->texts.first_local_no ]; - - if ( text_no == 0 ) - { - return; /* Text is deleted. */ - } - - GET_T_STAT(t_stat, text_no, (void)0); - - /* locate the misc_item which says that ACTPERS is a recipient */ - - for ( found = FALSE, i = 0; !found && i < t_stat->no_of_misc; i++ ) - { - switch ( t_stat->misc_items[ i ].type ) - { - case recpt: - if ( t_stat->misc_items[ i ].datum.recipient == ACTPERS ) - { - do_add_rec_time( t_stat, i + 2 ); /* Add after loc_no */ - found = TRUE; - } - break; - - case cc_recpt: - if ( t_stat->misc_items[ i ].datum.cc_recipient == ACTPERS ) - { - do_add_rec_time( t_stat, i + 2 ); - found = TRUE; - } - break; - - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case loc_no: - case rec_time: - case sent_by: - case sent_at: - break; - } - } - - if( found == FALSE ) - { - log("ERROR: add_rec_time(): found==FALSE\n"); - } - - mark_text_as_changed( text_no); - return; -} - -/* - * Check if there are some texts immediately following last_text_read - * that are read or deleted. If so, update last_text_read and delete them - * from read_texts. - * - * This is only used from mark_as_read(). - */ -static void -adjust_read( Membership * m, - const Conference * conf) -{ - u_short i; - Local_text_no * locp; - Local_text_no conf_max; /* Highest used local_text_no in conf */ - Local_text_no conf_min; /* Lowest used local_text_no in conf */ - Bool ready; -#ifdef DEFENSIVE_CHECKS - Local_text_no prev; -#endif - - i = 0; /* Number of texts in read_texts in Membership which are - included in last_text_read. */ - - /* (conf_min <= x <= conf_max) if x is an existing local_text_no */ - conf_max = conf->texts.first_local_no + conf->texts.no_of_texts - 1; - conf_min = conf->texts.first_local_no; - - do - { - ready = TRUE; - - /* Increase m->last_text_read if - * * the user has read the text (last_text_read+1) - * * text (last_text_read+1) is deleted. - */ - - if ( m->last_text_read < conf_max) /* Does (last_text_read+1) exist? */ - { - if ( m->no_of_read > i /* Read? */ - && m->read_texts[ i ] == m->last_text_read + 1 ) - { - i++; - m->last_text_read++; - ready = FALSE; - } - else - { - /* Is the text deleted? */ - if ( m->last_text_read + 1 < conf_min /* Deleted and older - than any text that - exists in the - conference. */ - || (conf->texts.texts /* Deleted? */ - [ m->last_text_read + 1 - conf_min ] - == 0 ) ) - { - m->last_text_read++; - ready = FALSE; - } - } - } - } while ( ready == FALSE ); - - /* Delete the first i entries in read_texts */ - if ( i > 0 ) - { - m->no_of_read -= i; - - for (locp = m->read_texts; - locp < m->read_texts + m->no_of_read; - locp++) - { - *locp = *(locp + i); - } - } - -#ifdef DEFENSIVE_CHECKS - - /* Check that the items in read_texts really ARE sorted in ascending order. - If not, there is probably a bug in this routine or in mark_as_read */ - - prev = m->last_text_read; - - for ( i = 0; i < m->no_of_read; i++) - { - if ( prev >= m->read_texts[ i ] ) - { - log("Bug in adjust_read. Conference %lu, Priority %lu\n" - "\tprev = %lu, i = %lu, m->read_texts[i] = %lu\n", - (u_long)m->conf_no, (u_long)m->priority, - (u_long)prev, (u_long)i, (u_long)m->read_texts[i]); - } - - prev = m->read_texts[ i ]; - } -#endif -} - -/* - * insert TEXT in the list of read_texts in M. The texts are sorted. - * m->no_of_read is updated. m->read_texts is never reallocated, and must - * thus be big enough to hold the new number. - * - * Returns FAILURE if the text is already read. - * - * This is only used from mark_as_read(). - */ - -static Success -insert_loc_no(Local_text_no text, - Membership * m) -{ - Local_text_no * seek, * move; - - - if ( text <= m->last_text_read ) - { - return FAILURE; /* This text was already read. */ - } - - for ( seek = m->read_texts; seek < m->read_texts + m->no_of_read; seek++) - { - if ( text == *seek ) - { - return FAILURE; /* This text was already read. */ - } - - if ( text < *seek ) - { /* The text should be entered here. */ - for ( move = m->read_texts + m->no_of_read; move > seek; move--) - { - *move = *(move - 1); - } - - *seek = text; - ++(m->no_of_read); - - return OK; - } - } - - *seek = text; /* The text had a higher number than any */ - ++(m->no_of_read); /* previously read text. */ - - return OK; -} - -/* - * End of static functions - */ - -/* - * Functions that are exported to the server. - */ - -/* - * Add a member to a conference. All errorchecking should already - * be done when this function is called. The person must not already - * be a member of the conference. It is _not_ an error to make WHERE bigger - * than the number of conferences the person is a member in. - */ - -void -do_add_member(Conf_no conf_no, /* Conference to add a new member to. */ - Conference * conf_c, /* Conf. status. Must NOT be NULL. */ - Pers_no pers_no, /* Person to be added. */ - Person * pers_p, /* Pers. status. Must NOT be NULL. */ - u_char priority, /* Prioritylevel to assign to this conf */ - u_short where) /* Sequence number in the list */ -{ - Membership * mship; - Member * member; - - /* First add the conference in the person-struct. - * Make room for it. - */ - - pers_p->conferences.confs = srealloc( pers_p->conferences.confs, - ++(pers_p->conferences.no_of_confs) - * sizeof(Membership)); - - /* Fill in the room */ - - /* Find last slot */ - mship = pers_p->conferences.confs + pers_p->conferences.no_of_confs - 1 ; - - /* Move all data beyond WHERE */ - while ( mship > pers_p->conferences.confs + where ) - { - *mship = *(mship - 1); - mship--; - } - - *mship = EMPTY_MEMBERSHIP; - - mship->conf_no = conf_no; - mship->priority = priority; - mship->last_time_read = time(NULL); - mship->last_text_read = 0; - mship->no_of_read = 0; - mship->read_texts = NULL; - - /* Make room for the person in the conference */ - - conf_c->members.members = srealloc( conf_c->members.members, - ++(conf_c->members.no_of_members) - * sizeof(Member)); - - /* New members go to the end of the list */ - - member = (conf_c->members.members - + conf_c->members.no_of_members - 1); - member->member = pers_no; - - mark_conference_as_changed( conf_no ); - mark_person_as_changed( pers_no ); - - return; -} - -/* - * Send an asynchronous message to person pers_no (if he is logged on) - * and tell him that he is no longer a member of conf_no. Also calls - * leave_conf(). - */ -extern void -forced_leave_conf(Pers_no pers_no, - Conf_no conf_no) -{ - Connection *real_active_connection; - Session_no i = 0; - - real_active_connection = active_connection; - - while ( (i = traverse_connections(i)) != 0 ) - { - active_connection = get_conn_by_number(i); - - if ( active_connection->pers_no == pers_no ) - { - async_forced_leave_conf(active_connection, conf_no); - - if ( active_connection->cwc == conf_no ) - leave_conf(); - } - } - - active_connection = real_active_connection; -} - -/* - * Delete a member from a conference. - * No checks are made on the parameters. - * The dynamically allocated areas conf_c->members.members and - * pers_p->confs are NOT reallocated since they will anyhow sooner or later - * be flushed from core. - */ - -Success -do_sub_member(Conf_no conf_no, /* Conf to delete member from. */ - Conference * conf_c, /* May be NULL */ - Member * member, /* May be NULL */ - Pers_no pers_no, /* Person to be deleted. */ - Person * pers_p, /* May be NULL */ - Membership * mship) /* Pointer to the persons membership in - conf., or NULL if not known. */ -{ - if ( conf_c == NULL ) - GET_C_STAT(conf_c, conf_no, FAILURE); - - if ( pers_p == NULL ) - GET_P_STAT(pers_p, pers_no, FAILURE); - - if ( mship == NULL && (mship = locate_membership(conf_no, pers_p)) == NULL) - restart_kom("do_sub_member() - can't find mship\n"); - - if ( member == NULL && (member = locate_member(pers_no, conf_c)) == NULL) - restart_kom("do_sub_member() - can't find member.\n"); - - forced_leave_conf(pers_no, conf_no); - - /* Delete from Person */ - - sfree( mship->read_texts ); - --pers_p->conferences.no_of_confs; - while ( mship - < pers_p->conferences.confs + pers_p->conferences.no_of_confs ) - { - *mship = *(mship + 1); - ++mship; - } - - /* Delete from Conference */ - - --conf_c->members.no_of_members; - while ( member < conf_c->members.members + conf_c->members.no_of_members ) - { - *member = *(member + 1); - ++member; - } - - mark_person_as_changed( pers_no ); - mark_conference_as_changed( conf_no ); - - return OK; -} - - -/* - * VICTIM is a person or a conference. - * Meaning of return values: - * unlimited: ACTPERS is supervisor of VICTIM, or ACTPERS is admin, - * or ACTPERS is VICTIM - * none: VICTIM is secret, and ACTPERS is not a member - * member: ACTPERS is a member in VICTIM, but doesn't have unlimited - * access. - * read_protected: The conference is rd_prot and ACTPERS is not a member. - * limited: otherwise. - * error: see kom_errno - */ - -Access -access_perm(Conf_no victim, - Conference * victim_c, /* May be NULL */ - Pers_no viewer, - Person * viewer_p) /* May be NULL */ -{ - if (victim == viewer) - return unlimited; - - if (victim_c == NULL) - GET_C_STAT(victim_c, victim, error); - - if ( viewer != 0 && ENA(admin, 2) ) - return unlimited; - - if ( is_supervisor(victim, victim_c, viewer, viewer_p)) - return unlimited; - - if ( viewer != 0 ) - { - if ( viewer_p == NULL ) - GET_P_STAT(viewer_p, viewer, error); - - if ( locate_membership( victim, viewer_p ) != NULL ) - return member; - } - - if ( victim_c->type.secret ) - return none; - - if ( victim_c->type.rd_prot ) - return read_protected; - - return limited; -} - - -/* - * Fast version of access_perm. See comment in file server/manipulate.h - * where Access is defined. - * - * Check if viewer is allowed to look at victiom. viewer_p, if - * supplied, should be a pointer to the pers-stat of viewer. - */ -Access -fast_access_perm(Conf_no victim, - Pers_no viewer, - Person *viewer_p) /* May be NULL. */ -{ - Conf_type conf_type; - - if ( !cached_conf_exists(victim) ) - return error; - - if ( viewer != 0 && (ENA(admin, 2) || ENA(wheel,8) || viewer == victim) ) - return unlimited; - - if ( viewer != 0 ) - { - if ( viewer_p == NULL ) - GET_P_STAT(viewer_p, viewer, error); - - if ( locate_membership( victim, viewer_p ) != NULL ) - return member; - } - - /* Only read in conference struct when really necessary. */ - conf_type = cached_get_conf_type (victim); - if ( conf_type.secret ) - return access_perm(victim, NULL, viewer, viewer_p); - - if ( conf_type.rd_prot ) - return read_protected; - - return limited; -} - -/* - * Locate the Member struct in CONF_C for person PERS_NO - */ - -Member * -locate_member(Pers_no pers_no, - Conference * conf_c) -{ - Member * member; - int i; - - for(member = conf_c->members.members, i = conf_c->members.no_of_members; - i > 0; i--, member++) - { - if ( member->member == pers_no ) - { - return member; - } - } - - return NULL; -} - - -/* - * Find the data about PERS_P:s membership in CONF_NO. - * Return NULL if not found - */ - -Membership * -locate_membership(Conf_no conf_no, - Person * pers_p) -{ - Membership * confp; - int i; - - for(confp = pers_p->conferences.confs, i = pers_p->conferences.no_of_confs; - i > 0; i--, confp++) - { - if ( confp->conf_no == conf_no ) - { - return confp; - } - } - - return NULL; -} - -/* - * Atomic functions. - */ - -/* - * Unsubscribe from a conference. - * - * You must be supervisor of either conf_no or pers_no to be allowed to - * do this. - * - * BUGS: There is no passive membership. - */ -extern Success -sub_member( Conf_no conf_no, - Pers_no pers_no ) -{ - Conference * conf_c; - Membership * mship; - Person * pers_p; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - GET_P_STAT(pers_p, pers_no, FAILURE); - - if( (mship = locate_membership(conf_no, pers_p) ) == NULL) - { - kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_NOT_MEMBER; - return FAILURE; - } - - if ( !is_supervisor(conf_no, conf_c, ACTPERS, ACT_P) - && !is_supervisor(pers_no, NULL, ACTPERS, ACT_P) - && !ENA(admin, 4) ) - { - kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_PERM; - return FAILURE; - } - - return do_sub_member(conf_no, conf_c, NULL, pers_no, pers_p, mship); -} - - -/* - * Add a member to a conference (join a conference) or - * Change the priority of a conference. - * - * Anyone may add anyone as a member as long as the new member is not - * secret and the conference is not rd_prot. This might be a bug. - * - * PRIORITY is the assigned priority for the conference. WHERE says - * where on the list the person wants the conference. 0 is first. WHERE - * is automatically set to the number of conferences that PERS_NO is member - * in if WHERE is too big, so it is not an error to give WHERE == ~0 as - * a parameter. - * - * You can only re-prioritize if you are supervisor of pers_no. - */ -extern Success -add_member(Conf_no conf_no, - Pers_no pers_no, - u_char priority, - u_short where) /* Range of where is [0..] */ -{ - Conference * conf_c, * pers_c; - Person * pers_p; - Membership * mship; - - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - GET_P_STAT(pers_p, pers_no, FAILURE); - - if ( access_perm(conf_no, conf_c, ACTPERS, ACT_P) < limited - && !ENA(admin, 4) ) - { - kom_errno = conf_c->type.secret ? KOM_UNDEF_CONF : KOM_ACCESS; - return FAILURE; - } - - /* Is he already a member? */ - - if ( (mship = locate_membership( conf_no, pers_p )) != NULL) - { - /* He is already a member. Only change the priority. */ - - GET_C_STAT(pers_c, pers_no, FAILURE); - if( !is_supervisor (pers_no, pers_c , ACTPERS, ACT_P) ) - { - /* Noone else can change one's priorities. */ - kom_errno = KOM_PERM; - return FAILURE; - } - - do_change_priority( mship, priority, where, pers_no, pers_p); - } - else - { - do_add_member(conf_no, conf_c, pers_no, pers_p, priority, where); - } - - return OK; -} - -#ifdef DEBUG_MARK_AS_READ -static int -check_membership(Pers_no pno, - const Conference *conf, - const Membership *mship) -{ - int error=0; - int i; - Local_text_no last=0; - int log_no=0; - - /* Check read texts */ - if ( mship->last_text_read > - conf->texts.first_local_no + conf->texts.no_of_texts - 1) - { - if ( log_no++ < 80 ) - log("membership.c: check_membership():" - "(%d) Person %lu has read text %lu in conf %lu," - "which only has %lu texts.\n", - log_no, - (u_long)pno, - (u_long)mship->last_text_read, - (u_long)mship->conf_no, - (u_long)(conf->texts.first_local_no - + conf->texts.no_of_texts - 1)); - error++; - } - - last = mship->last_text_read; - - for ( i = 0; i < mship->no_of_read; i++) - { - if ( mship->read_texts[i] <= last ) - { - error++; - } - - last = mship->read_texts[i]; - } - - return error; -} -#endif - -/* - * mark_as_read() is used to tell LysKOM which texts you have read. - * You can mark several texts in one chunk, but the chunk should not - * be too big to prevent users from having to re-read texts in case of - * a [server/client/network]-crash. - * - * The texts are marked per conference. If there are several recipients - * to a text it should be mark_as_read() in all the recipients. - * - * If conference is ACTPERS mailbox it will add a rec_time item in the - * misc_items field. - * - * It is only possible to mark texts as read in a conference you are - * member in. - * - * Attempts to mark non-existing texts as read are ignored if the text - * has existed. If the text has not yet been created KOM_NO_SUCH_LOCAL_TEXT - * will be returned in kom_errno. - * - * If CONFERENCE is the current working conference of ACTPERS, and the text - * has not previously been marked as read, ACT_P->read_texts will be - * increased. If the client cooperates this will be correct. If the - * client pepsi()s to all recipients of a text before marking it as read - * the read_texts field will be too big. (If anyone cares about that, - * feel free to rewrite this code as long as it doen't get too CPU- - * intensive.) - */ -extern Success -mark_as_read (Conf_no conference, - int no_of_texts, - const Local_text_no * text_arr ) -{ - int i; - Membership * m; - int allocflg = 0; /* read_texts is not re-allocated yet */ - Conference * conf_c; - Success retval = OK; -#ifdef DEBUG_MARK_AS_READ - const Local_text_no * const text_arr_start = text_arr; - Membership original; - int loop; - static int log_no = 0; -#endif - - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conference, FAILURE); - - if ( (m = locate_membership( conference, ACT_P)) == NULL) - { - kom_errno = KOM_NOT_MEMBER; - return FAILURE; - } - -#ifdef DEBUG_MARK_AS_READ - if ( m->read_texts == NULL && m->no_of_read != 0 ) - { - log("mark_as_read(): m->read_texts == NULL && m->no_of_read == %lu (corrected).", - (u_long)m->no_of_read); - m->no_of_read = 0; - } - - original = *m; - original.read_texts = smalloc(m->no_of_read * sizeof(Local_text_no)); - memcpy(original.read_texts, m->read_texts, - m->no_of_read * sizeof(Local_text_no)); -#endif - - for( i = no_of_texts; i > 0; i--, text_arr++ ) - { - if ( *text_arr >= ( conf_c->texts.first_local_no - + conf_c->texts.no_of_texts )) - { - kom_errno = KOM_NO_SUCH_LOCAL_TEXT; - err_stat = no_of_texts - i; - retval = FAILURE; - break; /* Exit for-loop */ - } - - if ( *text_arr == 0 ) - { - kom_errno = KOM_LOCAL_TEXT_ZERO; - err_stat = no_of_texts - i; - retval = FAILURE; - break; /* Exit for-loop */ - } - - /* Is it a letter to ACTPERS? If so, add a rec_time item. */ - - if ( conference == ACTPERS ) - add_rec_time( conference, conf_c, *text_arr ); - - /* Update the Membership struct */ - - if ( *text_arr == m->last_text_read + 1 ) - { - ++m->last_text_read; - if ( active_connection->cwc == conference ) - ++ACT_P->read_texts; - } - else - { - if ( allocflg == 0 ) - { - /* Realloc as much as is needed, and probably more. */ - /* Better than to execute srealloc 100 times... */ - - m->read_texts = srealloc( m->read_texts, - (m->no_of_read + i) - * sizeof(Local_text_no)); - allocflg = 1; - } - - if ( insert_loc_no( *text_arr, m ) == OK - && active_connection->cwc == conference ) - { - ++ACT_P->read_texts; - } - } - } - - adjust_read( m, conf_c ); /* Delete initial part - of read_texts in the membership. */ - /* Realloc to correct size */ - - m->read_texts = srealloc( m->read_texts, - (m->no_of_read) * sizeof(Local_text_no)); - - mark_conference_as_changed ( conference ); - - if ( active_connection->cwc == conference ) - mark_person_as_changed( ACTPERS ); -#ifdef DEBUG_MARK_AS_READ - /* Check that the membership is correct. Otherwise log all info. */ - if ( check_membership(ACTPERS, conf_c, m) > 0 && log_no++ < 40 ) - { - log("mark_as_read(): (Msg no %d) Person %lu " - "has a corrupt membership:\n", - log_no, (u_long)ACTPERS); - log("Dump of data follows: <original membership>" - " <updated membership> <texts to mark>\n"); - foutput_membership(stderr, &original); - putc('\n', stderr); - foutput_membership(stderr, m); - fprintf(stderr, "\n%lu { ", (u_long)no_of_texts); - for ( loop = 0; loop < no_of_texts; loop++ ) - { - fprintf(stderr, "\n%lu ", (u_long)text_arr_start[loop]); - } - fprintf(stderr, "}\n"); - } - - sfree(original.read_texts); -#endif - return retval; -} - -/* - * Ask what conferences a person is a member of. - * - * /// The following might be slightly misleading: /// /ceder - * Only ask for information about at most NO_OF_CONFS conferences - * starting with conferece FIRST. WANT_READ_TEXTS has the same - * function as GETP_READ_TEXTS in the get_person_stat call. - * /// - */ -extern Success -get_membership (Pers_no pers_no, - u_short first, - u_short no_of_confs, - Bool want_read_texts, - Membership_list * memberships ) -{ - Person * p_orig; - Person temp_pers; - Conference * pers_c; - Access acc; - int i; - - CHK_LOGIN (FAILURE); - - GET_P_STAT (p_orig, pers_no, FAILURE); - GET_C_STAT (pers_c, pers_no, FAILURE); - - acc = access_perm (pers_no, pers_c, ACTPERS, ACT_P); - - if (acc == error) - return FAILURE; - - if (acc == none) - { - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - /* Make a copy of the struct. */ - - temp_pers = *p_orig; - - /* Delete all secret information. */ - - if ( acc != unlimited ) - copy_public_confs (&temp_pers, p_orig, want_read_texts); - else if ( !want_read_texts ) - { - /* Delete info about read texts. */ - temp_pers.conferences.confs - = tmp_alloc(temp_pers.conferences.no_of_confs - * sizeof(Membership)); - - memcpy(temp_pers.conferences.confs, - p_orig->conferences.confs, - (temp_pers.conferences.no_of_confs - * sizeof(Membership) )); - - for ( i = 0; i < temp_pers.conferences.no_of_confs; i++ ) - temp_pers.conferences.confs[ i ].read_texts = NULL; - } - - - *memberships = temp_pers.conferences; - - if ( first >= memberships->no_of_confs ) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - return FAILURE; - } - - memberships->confs += first; - memberships->no_of_confs = min( memberships->no_of_confs - first, - no_of_confs); - - return OK; -} - -/* - * +++/// - * - * first starts at 0. - */ -extern Success -get_members (Conf_no conf_no, - u_short first, - u_short no_of_members, - Member_list * members ) -{ - Conference * conf_c; - Access acc; - - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc == error ) - return FAILURE; - - if ( acc == none ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - *members = conf_c->members; - - if ( first >= members->no_of_members ) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - return FAILURE; - } - - members->members += first; - members->no_of_members = min (no_of_members, - members->no_of_members - first); - - return OK; -} - -/* - * Get a list of all conferences where it is possible that a person has - * unread articles. - */ - -Success -get_unread_confs(Pers_no pers_no, - Conf_no_list *result) -{ - Person *pers_p; - Membership *confs; - u_short n; - - CHK_LOGIN(FAILURE); - GET_P_STAT(pers_p, pers_no, FAILURE); - - result->conf_nos = tmp_alloc (pers_p->conferences.no_of_confs - * sizeof(Conf_no)); - result->no_of_confs = 0; - - for ( n = 0, confs = pers_p->conferences.confs; - n < pers_p->conferences.no_of_confs; - n++, confs++ ) - { - if ((confs->last_text_read - < cached_get_highest_local_no (confs->conf_no)) - && (fast_access_perm(confs->conf_no, ACTPERS, ACT_P) - > read_protected)) - { - result->conf_nos[ result->no_of_confs++ ] = confs->conf_no; - } - } - return OK; -} - - -/* - * Tell the server that I want to mark/unmark texts as read so that I - * get (approximately) no_of_unread unread texts in conf_no. - */ -extern Success -set_unread (Conf_no conf_no, - Text_no no_of_unread) -{ - Membership *mship; - Conference *conf_c; - Local_text_no highest; - - CHK_LOGIN(FAILURE); - - GET_C_STAT(conf_c, conf_no, FAILURE); - - if ( (mship = locate_membership(conf_no, ACT_P)) == NULL ) - { - kom_errno = KOM_NOT_MEMBER; - return FAILURE; - } - - highest = conf_c->texts.first_local_no + conf_c->texts.no_of_texts - 1; - - mship->last_text_read = ((highest > no_of_unread) - ? (highest - no_of_unread) : 0); - - sfree(mship->read_texts); - mship->read_texts = NULL; - mship->no_of_read = 0; - - mark_person_as_changed(ACTPERS); - return OK; -} - diff --git a/src/server/memory.c b/src/server/memory.c deleted file mode 100644 index c82e7153c..000000000 --- a/src/server/memory.c +++ /dev/null @@ -1,360 +0,0 @@ -/* - * $Id: memory.c,v 0.8 1992/02/26 18:45:07 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * Memory allocators/deallocators. - * - * These functions should be used instead of smalloc/srealloc. - */ - -static char *rcsid = "$Id: memory.c,v 0.8 1992/02/26 18:45:07 ceder Exp $"; - - -#include <kom-types.h> -#include <string.h> -#include <server/smalloc.h> -#include "memory.h" -#include "exp.h" -#include "lyskomd.h" -#include "log.h" - -static int person_cnt = 0; -static int conference_cnt = 0; -static int text_stat_cnt = 0; - - - -EXPORT Person * -alloc_person(void) -{ - Person *p; - - person_cnt++; - - p = smalloc(sizeof(Person)); - *p = EMPTY_PERSON; - return p; -} - - -EXPORT Conference * -alloc_conference(void) -{ - Conference *c; - - conference_cnt++; - - c = smalloc(sizeof(Conference)); - *c = EMPTY_CONFERENCE; - return c; -} - -EXPORT Text_stat * -alloc_text_stat(void) -{ - Text_stat *t; - - text_stat_cnt++; - - t = smalloc(sizeof(Text_stat)); - *t = EMPTY_TEXT_STAT; - return t; -} - -static void -clear_text_list(Text_list *text_list) -{ - if ( text_list == NULL ) - { - log("clear_text_list(): text_list == NULL.\n"); - return; - } - - sfree(text_list->texts); - *text_list = EMPTY_TEXT_LIST; -} - - -static void -clear_mark_list(Mark_list *mark_list) -{ - if ( mark_list == NULL ) - { - log("clear_mark_list(): mark_list == NULL.\n"); - return; - } - - sfree(mark_list->marks); - *mark_list = EMPTY_MARK_LIST; -} - - -static void -clear_membership(Membership *mship) -{ - if ( mship == NULL ) - { - log("clear_membership(): mship == NULL.\n"); - return; - } - - sfree(mship->read_texts); - *mship = EMPTY_MEMBERSHIP; -} - -static void -clear_membership_list(Membership_list *mlist) -{ - int i; - - if ( mlist == NULL ) - { - log("clear_membership_list(): membership_list == NULL.\n"); - return; - } - - for ( i = 0; i < mlist->no_of_confs; i++ ) - { - clear_membership(&mlist->confs[i]); - } - - sfree(mlist->confs); - *mlist = EMPTY_MEMBERSHIP_LIST; -} - - -EXPORT void -clear_person(Person *person) -{ - s_clear(&person->username); - clear_text_list(&person->created_texts); - clear_mark_list(&person->marks); - clear_membership_list(&person->conferences); - *person = EMPTY_PERSON; -} - -EXPORT void -free_person(Person *person) -{ - if ( person == NULL ) - return; - - person_cnt--; - clear_person(person); - sfree(person); -} - - -static void -clear_member_list(Member_list *m) -{ - if ( m == NULL ) - return; - - sfree(m->members); - *m = EMPTY_MEMBER_LIST; -} - -EXPORT void -clear_conference(Conference *confp) -{ - s_clear(&confp->name); - clear_member_list(&confp->members); - clear_text_list(&confp->texts); - *confp = EMPTY_CONFERENCE; -} - -EXPORT void -free_conference(Conference *confp) -{ - if ( confp == NULL ) - return; - - conference_cnt--; - clear_conference(confp); - sfree(confp); -} - -EXPORT void -clear_text_stat(Text_stat *t) -{ - int i; - - for ( i = 0; i < t->no_of_misc; i++ ) - { - switch ( t->misc_items[ i ].type ) - { - case recpt: - case cc_recpt: - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case loc_no: - case rec_time: - case sent_by: - case sent_at: - /* No need to free anything for these. */ - break; - - default: - restart_kom(__FILE__ ": free_text_stat: unknown Info_type %d.", - t->misc_items[ i ].type ); - } - } - - sfree(t->misc_items); - *t = EMPTY_TEXT_STAT; -} - -EXPORT void -free_text_stat(Text_stat *t) -{ - if ( t == NULL ) - return; - - text_stat_cnt--; - clear_text_stat(t); - sfree(t); -} - -static Text_list -copy_text_list(Text_list tl) -{ - Text_list r; - - r = tl; - r.texts = smalloc(r.no_of_texts * sizeof(Text_no)); - memcpy(r.texts, tl.texts, r.no_of_texts * sizeof(Text_no)); - - return r; -} - -static Mark_list -copy_mark_list(Mark_list ml) -{ - Mark_list r; - - r.no_of_marks = ml.no_of_marks; - r.marks = smalloc(r.no_of_marks * sizeof(Mark)); - memcpy(r.marks, ml.marks, r.no_of_marks * sizeof(Mark)); - return r; -} - - -static Membership -copy_membership(Membership m) -{ - Membership res; - - res = m; - res.read_texts = smalloc(m.no_of_read * sizeof(Local_text_no)); - memcpy(res.read_texts, m.read_texts, m.no_of_read * sizeof(Local_text_no)); - return res; -} - - -static Membership_list -copy_membership_list(Membership_list ml) -{ - Membership_list r; - int i; - - r.no_of_confs = ml.no_of_confs; - r.confs = smalloc(ml.no_of_confs * sizeof(Membership)); - - for ( i = 0; i < r.no_of_confs; i++ ) - { - r.confs[i] = copy_membership(ml.confs[i]); - } - - return r; -} - - -EXPORT Person * -copy_person(Person *p) -{ - Person *c; - - c = alloc_person(); - *c = *p; - c->username = EMPTY_STRING; - s_strcpy(&c->username, p->username); - - c->created_texts = copy_text_list(p->created_texts); - c->marks = copy_mark_list(p->marks); - c->conferences = copy_membership_list(p->conferences); - return c; -} - -static Member_list -copy_member_list(Member_list ml) -{ - Member_list res; - - res.no_of_members = ml.no_of_members; - res.members = smalloc(res.no_of_members * sizeof ( Member )); - memcpy(res.members, ml.members, res.no_of_members * sizeof ( Member )); - return res; -} - -EXPORT Conference * -copy_conf(Conference *o) -{ - Conference *c; - - c = alloc_conference(); - *c = *o; - c->name = EMPTY_STRING; - s_strcpy(&c->name, o->name); - c->members = copy_member_list(o->members); - c->texts = copy_text_list(o->texts); - return c; -} - -EXPORT Text_stat * -copy_text_stat(Text_stat *t) -{ - Text_stat *c; - - c = alloc_text_stat(); - *c = *t; - c->misc_items = smalloc(c->no_of_misc * sizeof(Misc_info)); - memcpy(c->misc_items, t->misc_items, c->no_of_misc * sizeof(Misc_info)); - return c; -} - - -EXPORT void -dump_alloc_counts(FILE *fp) -{ - fprintf(fp, "---memory.c:\n" - "\tperson: %d\n" - "\tconference: %d\n" - "\ttext_stat: %d\n", - person_cnt, - conference_cnt, - text_stat_cnt); -} diff --git a/src/server/memory.h b/src/server/memory.h deleted file mode 100644 index a495495c2..000000000 --- a/src/server/memory.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * $Id: memory.h,v 0.6 1991/09/15 10:31:06 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: memory.h,v 0.6 1991/09/15 10:31:06 linus Exp $ - * - * The time has come to get some order into this mess. - * - * From now on the following terminology is used: - * - * alloc_ smalloc() the object. Increase _cnt. - * free_ sfree() the object. Decrease _cnt. - * clear_ free_() any objects contained in the object, - * but not the object itself. - * copy_ smalloc() a new object and also smalloc() - * any objects contained in it. - */ - - - -extern Person * -alloc_person(void); - -extern Conference * -alloc_conference(void); - -extern Text_stat * -alloc_text_stat(void); - -extern void -free_person(Person *person); - -extern void -free_conference(Conference *confp); - -extern void -free_text_stat(Text_stat *t); - -extern Person * -copy_person(Person *p); - -extern Conference * -copy_conf(Conference *c); - -extern Text_stat * -copy_text_stat(Text_stat *c); - -extern void -clear_conference(Conference *c); - -extern void -clear_person(Person *p); - -extern void -clear_text_stat(Text_stat *t); - -#ifdef FILE - -extern void -dump_alloc_counts(FILE *stat_file); - -#endif diff --git a/src/server/minmax.h b/src/server/minmax.h deleted file mode 100644 index 938024a6c..000000000 --- a/src/server/minmax.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * $Id: minmax.h,v 0.3 1991/09/15 10:31:02 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: minmax.h,v 0.3 1991/09/15 10:31:02 linus Exp $ - * - * I can't believe that this really doesn't exist in a standard library! - */ - -#define min(a, b) ((a) > (b) ? (b) : (a)) -#define max(a, b) ((a) > (b) ? (a) : (b)) diff --git a/src/server/missing-ansi.c b/src/server/missing-ansi.c deleted file mode 100644 index 61ad890a4..000000000 --- a/src/server/missing-ansi.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * $Id: missing-ansi.c,v 0.7 1992/06/11 14:34:18 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * Some missing functions that are needed. - * - * Written by ceder. - */ - -static char *rcsid = "$Id: missing-ansi.c,v 0.7 1992/06/11 14:34:18 ceder Exp $"; - - -#include <string.h> -#include <time.h> - -#if defined(__sequent__) && !defined(DEBUG_MALLOC) - -void * -memcpy (void * s1, const void * s2, size_t n) -{ - extern bcopy(const char *b1, char *b2, unsigned int length); - - /* bcopy takes the parameters the other way round. */ - - bcopy(s2, s1, n); - return s1; /* Since ANSI says so */ -} - -#endif - -#if defined(__sequent__) || defined(__sun__) || defined(__vax__) - -extern double -difftime(time_t t1, time_t t2) -{ - return (double) t1 - (double) t2; -} - -#endif - -#ifdef __sequent__ - -/* - * This version in NOT 100 % ANSI-conformant, but it is enough to run LysKOM - * (I hope) /ceder - */ - -extern time_t -mktime (const struct tm * temeptr ) -{ - int nyears; - int nleaps; - int ndays; - - nyears = temeptr->tm_year - 70; - nleaps = (nyears+2) / 4; - - ndays = 365 * nyears + nleaps + temeptr->tm_yday; - - return (time_t) ( temeptr->tm_sec - + 60 * ( temeptr->tm_min - + 60 * ( temeptr->tm_hour - + 24 * ndays ))); -} - -#endif - - -#if defined(__sequent__) || defined(__sun__) -#include <errno.h> -#include <stdio.h> - -extern char *sys_errlist[]; -extern int sys_nerr; - -const char *strerror(int eno) -{ - static char buf[200]; - - - if (eno < 0 || eno >= sys_nerr) - { - sprintf(buf, "error #%d", eno); - return buf; - } - else - return sys_errlist[eno]; -} -#endif diff --git a/src/server/mux-parse.c b/src/server/mux-parse.c deleted file mode 100644 index d84e74bc3..000000000 --- a/src/server/mux-parse.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * $Id: mux-parse.c,v 0.8 1991/09/21 13:07:00 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - ** mux-parse.c Handle the MUX protocol - * This is a hack. Clean this mess up with lacgen. - */ - -static char *rcsid = "$Id: mux-parse.c,v 0.8 1991/09/21 13:07:00 ceder Exp $"; - - -#include <stddef.h> -#include <stdarg.h> -#include <string.h> -#include "lyskomd.h" -#include "s-string.h" -#include <kom-types.h> -#include "com.h" -#include "connections.h" -#include "isc-interface.h" -#include "mux.h" -#include <server/smalloc.h> -#include <setjmp.h> -#include <string.h> -#include <stdio.h> -#include "mux-parse.h" -#include "minmax.h" -#include "config.h" -#include "log.h" - -jmp_buf mux_parse_env; - -static String -mux_get_token(Mux *mux) -{ - String result; - String_size old_first; - - old_first = mux->parse.first_to_parse; - - result = s_strtok(mux->parse.unparsed, &mux->parse.first_to_parse, - s_fcrea_str(WHITESPACE)); - - /* Check that there was at least one trailing blank. */ - - if ( mux->parse.first_to_parse >= s_strlen(mux->parse.unparsed) ) - { - mux->parse.first_to_parse = old_first; - longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); - } - - return result; -} - -static long -mux_parse_long(Mux *mux) -{ - String token; - String_size end; - long res; - - token = mux_get_token(mux); - res = s_strtol(token, &end, PROTOCOL_NUMBER_BASE); - if (end != s_strlen(token)) - longjmp(mux_parse_env, MUX_PROTOCOL_ERR); - - return res; -} - - -/* - * Parse a string. At most 'maxlen' characters are allowed. If the - * mux sends a longer string only the first 'maxlen+1' characters - * are read. Any remaining characters are discarded. - * - * longjmp if not enough characters are available or if there - * is an error. Result is used to save state in that case. - * +++ Result should not be used to save state. - */ -static void -mux_parse_string(Mux *mux, - String *result, - int maxlen) -{ - String_size hptr; /* Pointer to 'H' */ - String_size mux_len; /* The len the mux is sending. */ - String_size truncated_len; /* How much the server will receive. */ - String_size to_skip; - static u_long err_cnt = 0; - - switch ( mux->parse.string_parse_pos ) - { - case 0: - if ( ( result->len != 0 || result->string != NULL) && err_cnt++ < 20 ) - { - log ("mux_parse_string(): result->len == %lu, " - "result->string == %lu. This memory will not be free()'d.\n", - (u_long)result->len, (u_long)result->string); - *result = EMPTY_STRING; - if ( err_cnt == 20 ) - log("Won't log the above warning no more."); - } - - /* Get number and discard trailing 'H' */ - mux_len = s_strtol(s_fsubstr(mux->parse.unparsed, - mux->parse.first_to_parse, - END_OF_STRING), - &hptr, PROTOCOL_NUMBER_BASE); - - if ( hptr == -1 - || mux->parse.first_to_parse + hptr - >= s_strlen(mux->parse.unparsed) ) - { - longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); - } - - /* Check that - a) there is a trailing H - b) there was at least one digit before the H */ - - /* +++ Use s-string.c to extract the char. */ - /* +++ Fix prot_a_parse_string also. */ - if ( mux->parse.unparsed.string[ mux->parse.first_to_parse - + hptr ] != 'H' - || hptr <= 0 ) - { - longjmp(mux_parse_env, MUX_PROTOCOL_ERR); - } - - mux->parse.first_to_parse += 1 + hptr; - mux->parse.string_parse_pos = 1; - result->len = mux_len; /* +++ Transfer mux_len. */ - /* Fall through */ - case 1: - mux_len = result->len; - /* Check that the entire string is transmitted. */ - /* (Don't care about the trailing part that will be skipped if the - * string is longer than maxlen) */ - truncated_len = min(maxlen + 1, mux_len); - - if ( mux->parse.first_to_parse + truncated_len - > s_strlen(mux->parse.unparsed) ) - { - longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); - } - - *result = EMPTY_STRING; - - s_mem_crea_str(result, - mux->parse.unparsed.string + mux->parse.first_to_parse, - truncated_len); - - mux->parse.first_to_parse += truncated_len; - mux->parse.string_parse_pos = 2; - result->len = mux_len; /* Can't transfer the local mux_len across - * call boundary. +++ There should be room - * for mux_len in the per-connection - * protocol data. - */ - /* Fall through */ - case 2: - /* Was the string too long? If so, skip the truncated data. */ - - mux_len = result->len; /* +++ shouldn't modify ->len */ - truncated_len = min(maxlen+1, mux_len); - - if ( mux_len > truncated_len ) - { - to_skip = min(mux_len - truncated_len, - mux->parse.unparsed.len - mux->parse.first_to_parse); - /* From now on, mux_len is length of result + numer of - chars to skip. Clean up this! +++ - */ - mux_len -= to_skip; - mux->parse.first_to_parse += to_skip; - } - - result->len = mux_len; - - if ( mux_len > truncated_len ) - { - /* +++ mux_len is transferred in result->len. */ - longjmp(mux_parse_env, MUX_MSG_INCOMPLETE); - } - - /* Fall through */ - default: - mux->parse.string_parse_pos = 0; - } -} - - - - - -static Bool -mux_is_legal_fnc(int fnc) -{ - switch(fnc) - { - case 0: - case 1: - case 2: - case 3: - return TRUE; - - default: - return FALSE; - } -} - -static void -mux_parse_client_message(Mux *mux) -{ - switch(mux->parse.parse_pos_2) - { - case 0: - mux->parse.num = mux_parse_long(mux); - mux->parse.parse_pos_2 = 1; - /* Fall through */ - case 1: - mux_parse_string(mux, &mux->parse.string, 10000); - /* Fall through */ - default: - mux->parse.parse_pos_2 = 0; - } -} - -void -mux_parse_packet(Mux *mux) -{ - switch(mux->parse.parse_pos) - { - case 0: /* Get fnc_no */ - mux->parse.function = mux_parse_long(mux); - if ( !mux_is_legal_fnc(mux->parse.function) ) - longjmp(mux_parse_env, MUX_PROTOCOL_ERR); - mux->parse.parse_pos = 1; - /* Fall through */ - case 1: - /* Call the function that parses the arguments for this call. */ - switch(mux->parse.function) - { - case 0: - break; - - case 2: - mux->parse.num = mux_parse_long(mux); - break; - - case 1: - case 3: - mux_parse_client_message(mux); - break; - } - /* Fall through */ - default: - mux->parse.parse_pos = 0; - } -} diff --git a/src/server/mux-parse.h b/src/server/mux-parse.h deleted file mode 100644 index 6d4ab0ab6..000000000 --- a/src/server/mux-parse.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * $Id: mux-parse.h,v 0.4 1992/02/26 18:45:04 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: mux-parse.h,v 0.4 1992/02/26 18:45:04 ceder Exp $ - * - ** mux-parse.c Handle the MUX protocol - * This is a hack. - */ - -#ifdef _JBLEN -extern jmp_buf mux_parse_env; -#endif - -#define MUX_PROTOCOL_ERR 1 -#define MUX_MSG_INCOMPLETE 2 -#define MUX_LOGOUT 3 - -extern void -mux_parse_packet(Mux *mux); diff --git a/src/server/mux.c b/src/server/mux.c deleted file mode 100644 index b85544fc1..000000000 --- a/src/server/mux.c +++ /dev/null @@ -1,435 +0,0 @@ -/* - * $Id: mux.c,v 0.8 1992/04/15 22:59:22 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* -** mux.c -*/ - -static char *rcsid = "$Id: mux.c,v 0.8 1992/04/15 22:59:22 ceder Exp $"; - - -#include <stddef.h> -#include <stdarg.h> -#include <string.h> -#include "s-string.h" -#include "lyskomd.h" -#include <kom-types.h> -#include "com.h" -#include "connections.h" -#include "isc-interface.h" -#include "mux.h" -#include <server/smalloc.h> - - -extern _printf( int (*sputc)(int chr), const char *fmt, va_list AP); - - -/* -** MUX support functions -*/ - -Mux * -mux_create(Mux_type type, IscSession *scb) -{ - Mux *mp; - - - mp = (Mux *) smalloc(sizeof(Mux)); - - mp->magic = MUX_MAGIC_ALLOC; - mp->type = type; - mp->scb = scb; - mp->client_c = 0; - mp->client_v = NULL; - - mp->parse.parse_pos = 0; - mp->parse.parse_pos_2 = 0; - mp->parse.string_parse_pos = 0; - mp->parse.first_to_parse = 0; - mp->parse.more_to_parse = TRUE; - mp->parse.function = 0; - mp->parse.string = EMPTY_STRING; - mp->parse.unparsed = EMPTY_STRING; - - return mp; -} - -void -mux_free_parsed(Mux *mp) -{ - s_clear(&mp->parse.string); - mp->parse.parse_pos = 0; - mp->parse.parse_pos_2 = 0; - mp->parse.string_parse_pos = 0; -} - -void -mux_destruct(Mux *mp) -{ - switch (mp->magic) - { - case MUX_MAGIC_ALLOC: - break; - - case MUX_MAGIC_FREE: - restart_kom("MUX_DESTRUCT: Trying to destruct freed Mux block\n"); - - default: - restart_kom("MUX_DESTRUCT: Bad magic number\n"); - } - - mp->magic = MUX_MAGIC_FREE; - - mux_free_parsed(mp); - s_clear(&mp->parse.unparsed); - - sfree(mp->client_v); - sfree(mp); -} - - - -int -mux_clients(Mux *mp) -{ - int i; - int c; - - - switch (mp->magic) - { - case MUX_MAGIC_ALLOC: - break; - - case MUX_MAGIC_FREE: - restart_kom("MUX_CLIENTS: Trying to work on freed Mux block\n"); - - default: - restart_kom("MUX_CLIENTS: Bad magic number\n"); - } - - for (i = 0, c = 0; i < mp->client_c; i++) - if (mp->client_v[i].id != -1) - c++; - - return c; -} - - -void -mux_addclient(Mux *mp, int id, Connection *cp) -{ - int i; - - - switch (mp->magic) - { - case MUX_MAGIC_ALLOC: - break; - - case MUX_MAGIC_FREE: - restart_kom("MUX_ADDCLIENT: Trying to work on freed Mux block\n"); - - default: - restart_kom("MUX_ADDCLIENT: Bad magic number\n"); - } - - for (i = 0; i < mp->client_c; i++) - if (mp->client_v[i].id == -1) - break; - - if (i == mp->client_c) - { - mp->client_c++; - if (mp->client_v == NULL) - mp->client_v = (Mux_client *) smalloc(sizeof(Mux_client)); - else - mp->client_v = (Mux_client *) srealloc(mp->client_v, - sizeof(Mux_client) * - (mp->client_c)); - } - - mp->client_v[i].conn = cp; - mp->client_v[i].id = id; - mp->client_v[i].outmsg = isc_allocmsg(MUX_OUTMSGSIZE); -} - - - -void -mux_delclient(Mux *mp, int id) -{ - int i; - - - switch (mp->magic) - { - case MUX_MAGIC_ALLOC: - break; - - case MUX_MAGIC_FREE: - restart_kom("MUX_DELCLIENT: Trying to work on freed Mux block\n"); - - default: - restart_kom("MUX_DELCLIENT: Bad magic number\n"); - } - - for (i = 0; i < mp->client_c; i++) - if (mp->client_v[i].id == id) - { - mp->client_v[i].id = -1; - mp->client_v[i].conn = NULL; - isc_freemsg(mp->client_v[i].outmsg); - return; - } -} - - -Mux_client * -mux_getclientbyid(Mux *mp, int id) -{ - int i; - - - switch (mp->magic) - { - case MUX_MAGIC_ALLOC: - break; - - case MUX_MAGIC_FREE: - restart_kom("MUX_GETCLIENTBYID: Trying to work on freed Mux block\n"); - - default: - restart_kom("MUX_GETCLIENTBYID: Bad magic number\n"); - } - - - for (i = 0; i < mp->client_c; i++) - if (mp->client_v[i].id == id) - return &mp->client_v[i]; - - return NULL; -} - - - -Mux_client * -mux_getclientbyconn(Mux *mp, Connection *cp) -{ - int i; - - - switch (mp->magic) - { - case MUX_MAGIC_ALLOC: - break; - - case MUX_MAGIC_FREE: - restart_kom("MUX_GETCLIENTBYCONN: Trying to work on freed Mux block\n"); - - default: - restart_kom("MUX_GETCLIENTBYCONN: Bad magic number\n"); - } - - for (i = 0; i < mp->client_c; i++) - if (mp->client_v[i].conn == cp) - return &mp->client_v[i]; - - return NULL; -} - - -/* -** MUX output functions -*/ - - -int -mux_write(Connection * cp, - const unsigned char * buf, - size_t size) -{ - Mux * mp = cp->mux; - Mux_client * mcp; - size_t osize; - size_t wlen; - size_t clen; - - - mcp = mux_getclientbyconn(mp, cp); - if (mcp == NULL) - /* BETTER ERROR HANDLING SHOULD GO HERE */ - restart_kom("mux_write: STALE CLIENT ID\n"); - - osize = size; - while (size > 0) - { - while ((wlen = mcp->outmsg->size - mcp->outmsg->length) == 0) - mux_flush(cp); - - clen = size > wlen ? wlen : size; - memcpy(mcp->outmsg->buffer + mcp->outmsg->length, buf, clen); - mcp->outmsg->length += clen; - size -= clen; - buf += clen; - } - - return osize; -} - - - - -int -mux_putc(int chr, - Connection * cp) -{ - Mux * mp = cp->mux; - Mux_client * mcp; - - - mcp = mux_getclientbyconn(mp, cp); - if (mcp == NULL) - /* BETTER ERROR HANDLING SHOULD GO HERE */ - restart_kom("mux_putc: STALE CLIENT ID\n"); - - while (mcp->outmsg->length == mcp->outmsg->size) - mux_flush(cp); - - mcp->outmsg->buffer[mcp->outmsg->length++] = chr; - - return chr; -} - - - -static Connection *send_cp; - -static int -send_putc(int chr) -{ - return mux_putc(chr, send_cp); -} - - - -int -mux_printf(Connection * cp, - const char * format, - ...) -{ - va_list AP; - int retval = -1; - - - va_start(AP, format); - - send_cp = cp; - retval = _printf(&send_putc, format, AP); - - va_end(AP); - - return retval; -} - - -void -mux_flush(Connection * cp) -{ - Mux * mp = cp->mux; - Mux_client * mcp; - - - mcp = mux_getclientbyconn(mp, cp); - if (mcp == NULL) - /* BETTER ERROR HANDLING SHOULD GO HERE */ - restart_kom("mux_flush: STALE CLIENT ID\n"); - - if (mcp->outmsg->length == 0) - return; - - switch (mp->type) - { - case MUX_TYPE_CLIENT: - isc_send(mp->scb, mcp->outmsg); - isc_flush(mp->scb); - mcp->outmsg = isc_allocmsg(MUX_OUTMSGSIZE); - break; - - case MUX_TYPE_MUX: - isc_printf(mp->scb, "3 %d %dH", - mcp->id, mcp->outmsg->length); - isc_write(mp->scb, mcp->outmsg->buffer, mcp->outmsg->length); - isc_printf(mp->scb, "\n"); - isc_flush(mp->scb); - mcp->outmsg->length = 0; - break; - - default: - restart_kom("mux_flush: ILLEGAL MUX TYPE: %d\n", mp->type); - } -} - - -void -mux_close(Connection * cp) -{ - Mux * mp = cp->mux; - Mux_client * mcp; - - - mcp = mux_getclientbyconn(mp, cp); - if (mcp == NULL) - /* BETTER ERROR HANDLING SHOULD GO HERE */ - restart_kom("mux_close: STALE CLIENT ID\n"); - - mux_flush(cp); - - switch (mp->type) - { - case MUX_TYPE_CLIENT: - isc_destroy(kom_server_mcb, mp->scb); - - if (mp->client_c != 1) - restart_kom("ERROR: mux_close(): client_c == %d\n", mp->client_c); - - isc_freemsg(mp->client_v[0].outmsg); - - mux_destruct(mp); - cp->mux = NULL; - break; - - case MUX_TYPE_MUX: - isc_printf(mp->scb, "2 %d\n", mcp->id); - isc_flush(mp->scb); - - mux_delclient(mp, mcp->id); - cp->mux = NULL; - break; - - default: - restart_kom("mux_close: ILLEGAL MUX TYPE: %d\n", mp->type); - } -} - diff --git a/src/server/mux.h b/src/server/mux.h deleted file mode 100644 index b02700e2c..000000000 --- a/src/server/mux.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * $Id: mux.h,v 0.4 1991/09/15 10:30:43 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: mux.h,v 0.4 1991/09/15 10:30:43 linus Exp $ - * -** mux.h -*/ - -#ifndef __LYSKOM__MUX_H__ -#define __LYSKOM__MUX_H__ - -#define MUX_OUTMSGSIZE 1024 - -#define MUX_MAGIC_ALLOC 0x56AE17DB -#define MUX_MAGIC_FREE 0xF24A6BE7 - -typedef enum -{ - MUX_TYPE_CLIENT, - MUX_TYPE_MUX -} Mux_type; - - - -typedef struct -{ - int id; /* MUX client id */ - Connection * conn; /* LysKOM virtual Connection */ - - struct isc_msg * outmsg; -} Mux_client; - -typedef struct -{ - int parse_pos; - int parse_pos_2; - int string_parse_pos; - int function; /* Function to call. */ - - /* Gather data in these variables. */ - - long num; - String string; - String unparsed; - String_size first_to_parse; /* Index into unparsed. */ - Bool more_to_parse; /* Any chance that there is anything - left in unparsed? */ -} Mux_parse; - -typedef struct mux -{ - unsigned long magic; /* Magic number :-) */ - Mux_type type; - struct isc_scb * scb; - - Mux_parse parse; - - int client_c; - Mux_client * client_v; -} Mux; - - -/* -** MUX support functions -*/ - -extern Mux * -mux_create(Mux_type type, IscSession *scb); - -extern void -mux_destruct(Mux *mp); - -extern int -mux_clients(Mux *mp); - -extern void -mux_addclient(Mux *mp, int id, Connection *cp); - -extern void -mux_delclient(Mux *mp, int id); - -extern Mux_client * -mux_getclientbyid(Mux *mp, int id); - -extern Mux_client * -mux_getclientbyconn(Mux *mp, Connection *cp); - - - -/* -** MUX output functions -*/ - -extern int -mux_write(Connection * cp, - const unsigned char * buf, - size_t size); - -extern int -mux_printf(Connection * cp, - const char * format, - ...); - -extern int -mux_putc(int chr, - Connection * cp); - -extern void -mux_flush(Connection * cp); - -extern void -mux_close(Connection * cp); - -extern void -mux_free_parsed(Mux *mp); - -#endif diff --git a/src/server/person.c b/src/server/person.c deleted file mode 100644 index 32c39abaf..000000000 --- a/src/server/person.c +++ /dev/null @@ -1,824 +0,0 @@ -/* - * $Id: person.c,v 0.17 1992/04/04 17:49:08 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * person.c - * - * All atomic calls that deals with persons. - */ - -static char *rcsid = "$Id: person.c,v 0.17 1992/04/04 17:49:08 ceder Exp $"; - -#include <m-config.h> -#include <time.h> -#include <string.h> -#include <stdlib.h> -#include <crypt.h> - -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "manipulate.h" -#include <kom-errno.h> -#include <server/smalloc.h> -#include "string-malloc.h" -#include "cache.h" -#include "log.h" -#include "minmax.h" -#include <config.h> -#include <parser.h> -#include "com.h" -#include "connections.h" -#include "send-async.h" -#include <debug.h> - -/* - * Static functions. - */ - -static Bool -legal_passwd(const String pwd) -{ - int i; - - for (i = 0; i < s_strlen(pwd); i++) - if (pwd.string[i] == '\0') - return FALSE; - - return TRUE; -} - -static Success -do_set_passwd( Password pwd, - const String new_pwd) -{ -#ifdef ENCRYPT_PASSWORDS - char salt[3]; - static char crypt_seed[] = ("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"); - char *password; - - if ( !legal_passwd(new_pwd) ) - return FAILURE; - - salt[0] = crypt_seed [rand() % (sizeof (crypt_seed) - 1)]; - salt[1] = crypt_seed [rand() % (sizeof (crypt_seed) - 1)]; - salt[2] = '\0'; - - password = s_crea_c_str(new_pwd); - if (password == NULL) - return FAILURE; - else - { - strcpy((char *)pwd, (const char *)crypt(password, salt)); - string_free(password); - return OK; - } - -#else - - /* Compatibility mode... */ - if ( !legal_passwd(new_pwd) ) - return FAILURE; - - *pwd++ = new_pwd.len; /* Indeed too easy crypt... */ - strncpy(pwd, (const char *)new_pwd.string, - min( PASSWD_LEN-1, new_pwd.len )); - - return OK; - -#endif -} - - - -/* - * Mark a text. No check is done if pers_p is really allowed to mark it. - * Use mark_type==0 to unmark the text. - */ - -static Success -do_mark_text(Pers_no pers_no, - Person *pers_p, /* May be NULL */ - Text_no text_no, - Text_stat *text_s, /* May be NULL */ - u_char mark_type) -{ - Mark *markp; - Mark *old_mark = NULL; - int i; - BUGDECL; - - if ( pers_p == NULL ) - GET_P_STAT(pers_p, pers_no, FAILURE); - - /* Locate the mark. */ - - for ( i = pers_p->marks.no_of_marks, markp = pers_p->marks.marks; - i > 0 && old_mark == NULL; - i--, markp++ ) - { - if ( markp->text_no == text_no ) - old_mark = markp; - } - - if (old_mark != NULL && mark_type != 0) - { - /* Change marktype of an already marked text. (No need to check - that the text exists). */ - BUG(("do_mark_text(): Change type of mark.\n")); - - old_mark->mark_type = mark_type; - mark_person_as_changed(pers_no); - } - else if (old_mark != NULL) - { - /* Delete this mark. */ - BUG(("do_mark_text(): Delete mark.\n")); - - while ( old_mark < ( pers_p->marks.marks - + pers_p->marks.no_of_marks - 1 )) - { - *old_mark = *(old_mark + 1); - old_mark++; - } - - pers_p->marks.no_of_marks--; - mark_person_as_changed(pers_no); - - /* ...and don't forget to decrease the ref_cnt in the text_stat... */ - - if ( (text_s = cached_get_text_stat(text_no)) != NULL ) - { - if ( text_s->no_of_marks == 0 ) - { - log("WNG: do_mark_text(): Text %d has no_of_marks==0,\ - but person %d had marked the text.", - text_no, pers_no); - } - else - { - text_s->no_of_marks--; - mark_text_as_changed(text_no); - } - } - /* ...but it is not an error if someone has deleted the text. */ - } - else if ( mark_type != 0 ) - { - /* A new mark. Check that the text exists. */ - BUG(("do_mark_text(): new mark.\n")); - - if ( text_s == NULL ) - GET_T_STAT(text_s, text_no, FAILURE); - - if (text_s->no_of_marks >= MAX_MARKS_TEXT - || pers_p->marks.no_of_marks >= MAX_MARKS_PERSON) - { - kom_errno = KOM_MARK_LIMIT; - return FAILURE; - } - - text_s->no_of_marks++; - mark_text_as_changed(text_no); - - pers_p->marks.marks = srealloc(pers_p->marks.marks, - ++pers_p->marks.no_of_marks * sizeof(Mark)); - pers_p->marks.marks[pers_p->marks.no_of_marks - 1].text_no = text_no; - pers_p->marks.marks[pers_p->marks.no_of_marks - 1].mark_type - = mark_type; - mark_person_as_changed(pers_no); - } - else - { - /* An attempt to delete a non-existent mark. This is a noop. */ - BUG(("do_mark_text(): delete non-existent mark.\n")); - } - - return OK; -} - - -/* - * Change user_area of a person. If text_no is 0, there will be - * no user_area. - */ - -static Success -do_set_user_area(Pers_no pers_no, - Person * pers_p, /* May be NULL */ - Text_no user_area) -{ - Text_stat * old_user_area; - Text_stat * new_user_area = NULL; /* To stop gcc complaining. */ - - /* Check that the new user_area exists before deleting the old*/ - - if ( user_area != 0 ) - { - GET_T_STAT(new_user_area, user_area, FAILURE); - if ( new_user_area->no_of_marks >= MAX_MARKS_TEXT ) - { - log("LIMIT: set_user_area(%d, %d): New user_area's " - "mark count (%d) > %d.\n", - pers_no, user_area, new_user_area->no_of_marks, - MAX_MARKS_TEXT); - kom_errno = KOM_MARK_LIMIT; - return FAILURE; - } - } - - if ( pers_p == NULL ) - GET_P_STAT(pers_p, pers_no, FAILURE); - - /* Unmark the previous user_area if it exists. */ - - if ( pers_p->user_area != 0 - && (old_user_area = cached_get_text_stat(pers_p->user_area)) != NULL) - { - if ( old_user_area->no_of_marks > 0 ) - { - --old_user_area->no_of_marks; - mark_text_as_changed( pers_p->user_area ); - } - else - { - log("ERROR: set_user_area(%d, %d): Old user_area %d not marked\n", - pers_no, user_area, pers_p->user_area); - } - } - - /* Mark the new user_area */ - - if ( user_area != 0 ) - { - ++new_user_area->no_of_marks; - mark_text_as_changed( user_area ); - } - - pers_p->user_area = user_area; - mark_person_as_changed (pers_no); - - return OK; -} -/* - * End of static functions. - */ - -/* - * Functions that are exported to the server. - */ - -/* - * Delete a person. (The mailbox is not deleted). - */ - -Success -do_delete_pers (Pers_no pers_no) -{ - Person * pers_p; - int i; - - GET_P_STAT(pers_p, pers_no, FAILURE); - - /* Cancel membership in all confs. */ - /* Note that because of the way do_sub_member is written the */ - /* loop must be executed this way. */ - for ( i = pers_p->conferences.no_of_confs - 1; i >= 0; i-- ) - { - if ( do_sub_member( pers_p->conferences.confs[ i ].conf_no, NULL, NULL, - pers_no, pers_p, - pers_p->conferences.confs + i) != OK) - { - log("ERROR: do_delete_pers(): can't sub_member\n"); - } - } - - for ( i = pers_p->marks.no_of_marks; i > 0; i-- ) - { - if ( do_mark_text(pers_no, pers_p, - pers_p->marks.marks[0].text_no, NULL, 0) != OK ) - { - log("WNG: do_delete_pers(): can't unmark text %d (i == %d)\n", - pers_p->marks.marks[0].text_no, i); - } - } - - if ( do_set_user_area(pers_no, pers_p, 0) != OK ) - { - log("WNG: do_delete_pers(): can't unmark user_area\n"); - } - - s_clear( &pers_p->username ); - sfree( pers_p->created_texts.texts ); - pers_p->created_texts.texts = NULL; - pers_p->created_texts.no_of_texts = 0; - - cached_delete_person(pers_no); - /* ??? Eller r{cker det med cached_delete_conf() ??? */ - - /* ASYNC */ - return OK; -} - -/* - * Check a password - */ -Success -chk_passwd (Password pwd, - const String try) -{ -#ifdef ENCRYPT_PASSWORDS - char *c_try; - - c_try = s_crea_c_str(try); - if (c_try == NULL) - return FAILURE; - - if (strcmp ((const char *)pwd, - (const char *)crypt(c_try, (const char *)pwd)) != 0) - { - string_free(c_try); - return FAILURE; - } - else - { - string_free(c_try); - return OK; - } - -#else - - int i; - - if ( try.len != *pwd ) - return FAILURE; - - for ( i = 0; i < try.len; i++ ) - if ( pwd[ i + 1 ] != try.string[ i ] ) - return FAILURE; - - return OK; - -#endif -} - - -/* - * Mark a text. - * - * If the you already have marked the text the mark-type will be changed. - * If mark_type == 0 the mark will be deleted. You can only mark texts - * that you are allowed to read. You are always allowed to read all - * texts that you have marked even if you are no longer a recipient - * of the text. - */ - -extern Success -mark_text( Text_no text_no, /* Will fail if the user is not */ - u_char mark_type ) /* allowed to read the text. */ -{ - Text_stat *text_s = NULL; - BUGDECL; - - CHK_LOGIN(FAILURE); - - if ( mark_type != 0 ) - { - /* Check that the user is allowed to read the text. */ - GET_T_STAT(text_s, text_no, FAILURE); - if ( !text_read_access(text_no, text_s) ) - { - kom_errno = KOM_PERM; - return FAILURE; - } - } - - BUG(("Person %d markerar text %d med typ %d\n", - ACTPERS, text_no, mark_type)); - - return do_mark_text(ACTPERS, ACT_P, text_no, text_s, mark_type); -} - -/* - * Create a new person. - * - * If CREATE_PERSON_BEFORE_LOGIN (#define'd in config.h) is true - * anyone can create themself. Otherwise you must be logged in to - * create a new person. - * - * If you are not logged in an auto-login as the created person is - * performed. (This is so that it is impossible to create a million - * persons (and so destroy the database) anonymously. This way it will - * at least be possible to see from which machine the attack came). - * - * If you are logged in you will be supervisor and creator of the new - * person, otherwise the new person will be supervisor and creator. - * - * The new person will be rd_prot, but not secret. His privileges will - * be as defined in DEFAULT_PRIV_BITS in kom-types.c. - * - * This function returns the Pers_no of the new person, or 0 if an error - * occured. (0 is an illegal Pers_no). - */ -extern Pers_no -create_person (String name, - const String passwd ) -{ - Pers_no new_user; - Conference * mailbox; - Person * pers_p; - - - if (!CREATE_PERSON_BEFORE_LOGIN && ACTPERS == 0 ) - { - kom_errno = KOM_LOGIN; - return 0; - } - -#if 0 - if ( !logins_allowed && !ACTPERS ) /* A new user can't create himself */ - { /* if he isn't allowed to login. */ - kom_errno = KOM_LOGIN_DISALLOWED; - return 0; - } -#endif - - if ( !legal_name( name ) ) - { - kom_errno = KOM_BAD_NAME; - return 0; - } - - if ( !unique_name( name, 0 ) ) - { - kom_errno = KOM_CONF_EXISTS; - return 0; - } - - if ( !legal_passwd( passwd ) ) - { - kom_errno = KOM_PWD; - return 0; - } - - new_user = cached_create_conf( name ); - - if ( (mailbox = cached_get_conf_stat( new_user ) ) == NULL) - { - restart_kom("create_person() - can't get conf_stat"); - } - - - mailbox->creator = ACTPERS ? ACTPERS : new_user; - mailbox->creation_time = time(NULL); - mailbox->presentation = 0; /* No presentation yet */ - mailbox->supervisor = ACTPERS ? ACTPERS : new_user; - mailbox->permitted_submitters = 0; - mailbox->super_conf = ACTPERS; - mailbox->type.rd_prot = 1; - mailbox->type.original = 0; - mailbox->type.secret = 0; - mailbox->type.letter_box = 1; - mailbox->last_written = mailbox->creation_time; - mailbox->msg_of_day = 0; - mailbox->nice = DEFAULT_NICE; - mailbox->members = EMPTY_MEMBER_LIST; - mailbox->texts = EMPTY_TEXT_LIST; - - mark_conference_as_changed (new_user); - - /* allocate Person */ - - if ( cached_create_person( new_user ) == FAILURE ) - { - cached_delete_conf( new_user ); - mark_conference_as_changed( new_user ); /*&*/ - return 0; - } - - if ( ( pers_p = cached_get_person_stat( new_user )) == NULL ) - { - cached_delete_conf( new_user ); - mark_conference_as_changed( new_user ); /*&*/ - restart_kom("create_person() - can't get pers_stat"); - } - - - /* Fill in Person */ - *pers_p = EMPTY_PERSON; - if ( do_set_passwd( pers_p->pwd, passwd) != OK ) - restart_kom("create_person(): can't set passwd\n"); - - mark_person_as_changed( new_user ); - - do_add_member( new_user, mailbox, new_user, pers_p, UCHAR_MAX, 0 ); - - if ( ACTPERS ) - { - ACT_P->created_persons++; - mark_person_as_changed( ACTPERS ); - } - else - { - /* Auto login, always visible */ - login (new_user, passwd, FALSE); - } - - return new_user; -} - - -/* - * Get the person status of PERSON. - */ -extern Success -get_person_stat (Pers_no person, - Person * result) -{ - Person *p_orig; - Conference *pers_c; - Access acc; - - GET_P_STAT(p_orig, person, FAILURE); - GET_C_STAT(pers_c, person, FAILURE); - - acc = access_perm (person, pers_c, ACTPERS, ACT_P); - - if ( acc == error ) - return FAILURE; - - if ( acc == none ) - { - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - *result = *p_orig; /* Make a copy of the struct. */ - - /* The user area is normally secret. */ - - if( acc != unlimited ) - result->user_area = 0; - - return OK; -} - -/* As get_person_stat, but only return the name if bit 0 in mask is set. */ - -extern Success -get_person_stat_old (Pers_no person, - int mask, - Person * result) -{ - Person *p_orig; - Conference *pers_c; - Access acc; - - CHK_LOGIN(FAILURE); - - GET_P_STAT(p_orig, person, FAILURE); - GET_C_STAT(pers_c, person, FAILURE); - - acc = access_perm (person, pers_c, ACTPERS, ACT_P); - - if ( acc == error ) - return FAILURE; - - if ( acc == none ) - { - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - *result = *p_orig; /* Make a copy of the struct. */ - - /* The user area is normally secret. */ - - if( acc != unlimited ) - result->user_area = 0; - - if ( !(mask & 1 ) ) - result->username = EMPTY_STRING; - - return OK; -} - - -/* /// */ -extern Success -get_created_texts(Pers_no pers_no, - Local_text_no first, - u_long len, - Text_list * result) -{ - Person *pers_p; - Access acc; - Local_text_no new_first; - - CHK_LOGIN(FAILURE); - - GET_P_STAT(pers_p, pers_no, FAILURE); - - acc = access_perm(pers_no, NULL, ACTPERS, ACT_P); - - if ( acc == error ) - return FAILURE; - - if ( acc == none ) - { - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - *result = pers_p->created_texts; - new_first = max(result->first_local_no, first); - - if ( new_first >= result->first_local_no + result->no_of_texts) - { - kom_errno = KOM_NO_SUCH_LOCAL_TEXT; - return FAILURE; - } - - result->texts += new_first - result->first_local_no; - result->no_of_texts = min(len, (result->no_of_texts - - (new_first - result->first_local_no))); - result->first_local_no = new_first; - - return OK; -} - - - -/* - * Set privilege bits of a person. You must have the wheel bit set - * to be allowed to do this. - */ -extern Success -set_priv_bits( Pers_no person, - Priv_bits privileges ) -{ - Person *p; - - CHK_LOGIN(FAILURE); - - GET_P_STAT(p, person, FAILURE); - - if ( ENA(wheel, 6) ) - { - p->privileges = privileges; - mark_person_as_changed( person ); - return OK; - } - else - { - kom_errno = KOM_PERM; - return FAILURE; - } -} - -/* - * Set password. You may set the password of yourself and all persons that - * you are supervisor of. OLD_PWD is your password. - */ -extern Success -set_passwd (Pers_no person, - const String old_pwd, /* of the one who is changing the pwd, - not necessarily the person whose pwd - is changed. */ - const String new_pwd) /* of person */ -{ - Person *p; - - CHK_LOGIN(FAILURE); - - GET_P_STAT(p, person, FAILURE); - - if ( person != ACTPERS && !ENA(wheel, 7) - && !is_supervisor (person, NULL, ACTPERS, ACT_P) ) - { - kom_errno = KOM_PERM; - return FAILURE; /* Not allowed to change the other persons pwd */ - } - - if ( chk_passwd( ACT_P->pwd, old_pwd ) == FAILURE ) - { - kom_errno = KOM_PWD; - return FAILURE; - } - - if ( do_set_passwd( p->pwd, new_pwd ) != OK) - { - kom_errno = KOM_PWD; - return FAILURE; - } - - mark_person_as_changed( person ); - - return OK; -} - -/* - * Ask which texts a person has read in a certain conference. - * Can be done before loggin. Will return EMPTY_MEMBERSHIP if VICTIM - * has his unread_is_secret-flag set. This can not be distinguished - * from the case when VICTIM has not read any texts in CONF_NO. This - * is a feature, not a bug. (At least I think so. /ceder+++) - * - * (*** Well, I've changed my mind. This call is full of security holes. - * /ceder) - * - * Will fail if VICTIM is not a member of CONF_NO. - */ -extern Success -query_read_texts(Pers_no victim, - Conf_no conf_no, - Membership * result) /* Points to area to store result in */ -{ - Person * victim_p; - Membership * membp; - Access victim_acc; - - GET_P_STAT( victim_p, victim, FAILURE); - - victim_acc = access_perm(victim, NULL, ACTPERS, ACT_P); - if ( victim_acc <= none ) - { - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - if ( access_perm(conf_no, NULL, ACTPERS, ACT_P) <= none ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - if ( (membp = locate_membership (conf_no, victim_p)) == NULL) - { - kom_errno = KOM_NOT_MEMBER; - return FAILURE; - } - - *result = *membp; - - if ( victim_p->flags.unread_is_secret && - victim_acc != unlimited) - { - result->last_time_read = NO_TIME; - result->last_text_read = 0; - result->no_of_read = 0; - result->read_texts = NULL; - } - - return OK; -} - - -/* - * Set user_area. The text is a text which has previously been created - * with create_text(). It typically contains option-settings for the - * clients, e. g. if you want to be interrupted when new mail arrives. - * The format of this text is not yet defined. - * - * set_user_area(0) to clear the user area. - */ - -extern Success -set_user_area(Pers_no pers_no, - Text_no user_area) -{ - Person *pers_p; - - CHK_LOGIN(FAILURE); - GET_P_STAT(pers_p, pers_no, FAILURE); - - if ( access_perm(pers_no, NULL, ACTPERS, ACT_P) != unlimited ) - { - kom_errno = KOM_PERM; - return FAILURE; - } - - return do_set_user_area (pers_no, pers_p, user_area); -} diff --git a/src/server/prot-a-output.c b/src/server/prot-a-output.c deleted file mode 100644 index 867582420..000000000 --- a/src/server/prot-a-output.c +++ /dev/null @@ -1,593 +0,0 @@ -/* - * $Id: prot-a-output.c,v 0.11 1992/04/08 18:18:59 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * prot-a-output.c - write objects through a mux connection. - * - * Written by ceder 1990-07-13 - */ - -static char *rcsid = "$Id: prot-a-output.c,v 0.11 1992/04/08 18:18:59 ceder Exp $"; - - -#include <kom-types.h> -#include <stdio.h> -#include <sys/file.h> -#include <time.h> -#include "lyskomd.h" -#include "com.h" -#include "connections.h" -#include "prot-a-output.h" -#include "isc-interface.h" -#include "mux.h" - -void -prot_a_output_person (Connection *fp, - Person *person) -{ - prot_a_output_string (fp, person->username); - prot_a_output_priv_bits (fp, person->privileges); - prot_a_output_personal_flags (fp, person->flags); - - prot_a_output_time(fp, person->last_login); - - mux_printf (fp, " %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", - (u_long) person -> user_area, - (u_long) person -> total_time_present, /* This is not a time, - * but a number of seconds. - */ - (u_long) person -> sessions, - (u_long) person -> created_lines, - (u_long) person -> created_bytes, - (u_long) person -> read_texts, - (u_long) person -> no_of_text_fetches, - (u_long) person -> created_persons, - (u_long) person -> created_confs, - (u_long) person -> created_texts.first_local_no, - (u_long) person -> created_texts.no_of_texts, - (u_long) person -> marks.no_of_marks, - (u_long) person -> conferences.no_of_confs); -} - -void -prot_a_output_membership(Connection *fp, - const Membership *mship) -{ - int i; - - prot_a_output_time(fp, mship->last_time_read ); - - mux_printf(fp, " %lu %lu %lu %lu", - (u_long)mship->conf_no, - (u_long)mship->priority, - (u_long)mship->last_text_read, - (u_long)mship->no_of_read); - - if ( mship->read_texts != NULL && mship->no_of_read > 0) - { - mux_printf(fp, " {"); - for ( i = 0; i < mship->no_of_read; i++) - mux_printf(fp, " %lu", (u_long)mship->read_texts[ i ]); - - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - - -void -prot_a_output_membership_list (Connection * fp, - Membership_list mlist) -{ - int i; - - mux_printf(fp, " %lu", (u_long)mlist.no_of_confs); - - if ( mlist.confs != NULL && mlist.no_of_confs > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < mlist.no_of_confs; i++) - prot_a_output_membership(fp, mlist.confs + i); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - - -void -prot_a_output_conf_list(Connection *fp, - Conf_list_old conf_list) -{ - int i; - - mux_printf(fp, " %lu", (u_long)conf_list.no_of_conf_nos); - if ( conf_list.conf_nos != NULL && conf_list.no_of_conf_nos > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < conf_list.no_of_conf_nos; i++ ) - mux_printf(fp, " %lu", (u_long)conf_list.conf_nos[ i ]); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); - - if ( conf_list.type_of_conf != NULL && conf_list.no_of_conf_nos > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < conf_list.no_of_conf_nos; i++ ) - prot_a_output_conf_type(fp, conf_list.type_of_conf[ i ]); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - -void -prot_a_output_conf_no_list(Connection *fp, - Conf_no_list conf_no_list) -{ - int i; - - mux_printf(fp, " %lu", (u_long)conf_no_list.no_of_confs); - if ( conf_no_list.conf_nos != NULL && conf_no_list.no_of_confs > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < conf_no_list.no_of_confs; i++ ) - mux_printf(fp, " %lu", (u_long)conf_no_list.conf_nos[ i ]); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - - -void -prot_a_output_conference (Connection *fp, - Conference *conf_c) -{ - prot_a_output_string(fp, conf_c->name); - - prot_a_output_conf_type(fp, conf_c->type); - - prot_a_output_time(fp, conf_c -> creation_time ); - prot_a_output_time(fp, conf_c -> last_written ); - - mux_printf (fp, " %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", - (u_long) conf_c -> creator, - (u_long) conf_c -> presentation, - (u_long) conf_c -> supervisor, - (u_long) conf_c -> permitted_submitters, - (u_long) conf_c -> super_conf, - (u_long) conf_c -> msg_of_day, - (u_long) conf_c -> nice, - (u_long) conf_c -> members.no_of_members, - (u_long) conf_c -> texts.first_local_no, - (u_long) conf_c -> texts.no_of_texts); -} - - -void -prot_a_output_mark_list(Connection *fp, - Mark_list mark_list) -{ - int i; - - mux_printf(fp, " %lu", (u_long)mark_list.no_of_marks); - - if ( mark_list.marks != NULL && mark_list.no_of_marks > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < mark_list.no_of_marks; i++ ) - prot_a_output_mark(fp, mark_list.marks[ i ]); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); - -} - - -void -prot_a_output_text_stat(Connection *fp, - Text_stat *t_stat) -{ - int i; - - prot_a_output_time(fp, t_stat->creation_time); - - mux_printf(fp, " %lu %lu %lu %lu %lu", - (u_long)t_stat->author, - (u_long)t_stat->no_of_lines, - (u_long)t_stat->no_of_chars, - (u_long)t_stat->no_of_marks, - (u_long)t_stat->no_of_misc); - - if ( t_stat->misc_items != NULL && t_stat->no_of_misc > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < t_stat->no_of_misc; i++ ) - prot_a_output_misc_info(fp, t_stat->misc_items[ i ]); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - - -void -prot_a_output_text_list(Connection *fp, - Text_list text_list) -{ - int i; - - mux_printf(fp, " %lu %lu", - (u_long)text_list.first_local_no, - (u_long)text_list.no_of_texts); - - if ( text_list.texts != NULL && text_list.no_of_texts > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < text_list.no_of_texts; i++ ) - mux_printf(fp, " %lu", (u_long)text_list.texts[ i ]); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - -static void -prot_a_output_who_info_ident(Connection *fp, - Who_info_ident *info) -{ - mux_printf(fp, " %lu %lu %lu", - (u_long)info->person, - (u_long)info->working_conference, - (u_long)info->session_no); - - prot_a_output_string(fp, info->what_am_i_doing); - prot_a_output_string(fp, info->username); - prot_a_output_string(fp, info->hostname); - prot_a_output_string(fp, info->ident_user); -} - - -void -prot_a_output_who_info(Connection *fp, - Who_info *info) -{ - mux_printf(fp, " %lu %lu %lu", - (u_long)info->person, - (u_long)info->working_conference, - (u_long)info->session_no); - - prot_a_output_string(fp, info->what_am_i_doing); - prot_a_output_string(fp, info->username); -} - - -void -prot_a_output_who_info_list(Connection *fp, - Who_info_list info) -{ - int i; - - mux_printf(fp, " %lu", (u_long)info.no_of_persons); - - if ( info.info != NULL && info.no_of_persons > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < info.no_of_persons; i++ ) - { - prot_a_output_who_info(fp, &info.info[ i ]); - /* The username is specially alloced in who_is_on() in - session.c. */ - s_clear(&info.info[i].username); - } - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - -void -prot_a_output_who_info_ident_list(Connection *fp, - Who_info_ident_list info) -{ - int i; - - mux_printf(fp, " %lu", (u_long)info.no_of_persons); - - if ( info.info != NULL && info.no_of_persons > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < info.no_of_persons; i++ ) - { - prot_a_output_who_info_ident(fp, &info.info[ i ]); - } - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - -void -prot_a_output_who_info_list_old(Connection *fp, - Who_info_list_old info) -{ - int i; - - mux_printf(fp, " %lu", (u_long)info.no_of_persons); - - if ( info.info != NULL && info.no_of_persons > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < info.no_of_persons; i++ ) - { - mux_printf(fp, " %lu %lu", - (u_long)info.info[ i ].person, - (u_long)info.info[ i ].working_conference); - - prot_a_output_string(fp, info.info[ i ].what_am_i_doing); - } - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - -void -prot_a_output_session_info(Connection *fp, - Session_info *info) -{ - mux_printf(fp, " %lu %lu %lu", - (u_long)info->person, - (u_long)info->working_conference, - (u_long)info->session); - - prot_a_output_string(fp, info->what_am_i_doing); - prot_a_output_string(fp, info->username); - - mux_printf(fp, " %lu", (u_long)info->idle_time); - prot_a_output_time(fp, info->connection_time); -} - -void -prot_a_output_session_info_ident(Connection *fp, - Session_info_ident *info) -{ - mux_printf(fp, " %lu %lu %lu", - (u_long)info->person, - (u_long)info->working_conference, - (u_long)info->session); - - prot_a_output_string(fp, info->what_am_i_doing); - prot_a_output_string(fp, info->username); - prot_a_output_string(fp, info->hostname); - prot_a_output_string(fp, info->ident_user); - - mux_printf(fp, " %lu", (u_long)info->idle_time); - prot_a_output_time(fp, info->connection_time); -} - -void -prot_a_output_info(Connection *fp, - Info *info) -{ - mux_printf(fp, " %lu %lu %lu %lu %lu %lu", - (u_long)info->version, - (u_long)info->conf_pres_conf, - (u_long)info->pers_pres_conf, - (u_long)info->motd_conf, - (u_long)info->kom_news_conf, - (u_long)info->motd_of_lyskom); -} - - -extern void -prot_a_output_string(Connection *fp, - String str) -{ - mux_printf(fp, " %luH", (u_long)str.len); - mux_write(fp, str.string, str.len); -} - - -extern void -prot_a_output_priv_bits(Connection *fp, - Priv_bits bits) -{ - mux_putc(' ', fp); - mux_putc(bits.wheel + '0', fp); - mux_putc(bits.admin + '0', fp); - mux_putc(bits.statistic + '0', fp); - mux_putc(bits.create_pers + '0', fp); - mux_putc(bits.create_conf + '0', fp); - mux_putc(bits.change_name + '0', fp); - mux_putc(bits.extern_gw + '0', fp); - mux_putc(bits.flg8 + '0', fp); - mux_putc(bits.flg9 + '0', fp); - mux_putc(bits.flg10 + '0', fp); - mux_putc(bits.flg11 + '0', fp); - mux_putc(bits.flg12 + '0', fp); - mux_putc(bits.flg13 + '0', fp); - mux_putc(bits.flg14 + '0', fp); - mux_putc(bits.flg15 + '0', fp); - mux_putc(bits.flg16 + '0', fp); -} - - -extern void -prot_a_output_personal_flags(Connection *fp, - Personal_flags flags) -{ - mux_putc(' ', fp); - mux_putc(flags.unread_is_secret + '0', fp); - mux_putc(flags.flg2 + '0', fp); - mux_putc(flags.flg3 + '0', fp); - mux_putc(flags.flg4 + '0', fp); - mux_putc(flags.flg5 + '0', fp); - mux_putc(flags.flg6 + '0', fp); - mux_putc(flags.flg7 + '0', fp); - mux_putc(flags.flg8 + '0', fp); -} - -extern void -prot_a_output_conf_type(Connection *fp, - Conf_type type) -{ - mux_putc(' ', fp); - mux_putc(type.rd_prot + '0', fp); - mux_putc(type.original + '0', fp); - mux_putc(type.secret + '0', fp); - mux_putc(type.letter_box + '0', fp); -} - - -extern void -prot_a_output_member_list(Connection *fp, - Member_list m_list) -{ - int i; - - mux_printf(fp, " %lu", (u_long)m_list.no_of_members); - if ( m_list.members != NULL && m_list.no_of_members > 0 ) - { - mux_printf(fp, " {"); - for ( i = 0; i < m_list.no_of_members; i++ ) - prot_a_output_member(fp, m_list.members[ i ]); - mux_printf(fp, " }"); - } - else - mux_printf(fp, " *"); -} - - -void -prot_a_output_member(Connection *fp, - Member member) -{ - mux_printf(fp, " %lu", (u_long)member.member); -} - - -extern void -prot_a_output_mark(Connection *fp, - Mark mark) -{ - mux_printf(fp, " %lu %lu", (u_long)mark.text_no, (u_long)mark.mark_type); -} - - -extern void -prot_a_output_misc_info(Connection *fp, - Misc_info misc) -{ - mux_printf(fp, " %lu", (u_long)misc.type); - - switch(misc.type) - { - case recpt: - mux_printf(fp, " %lu", (u_long)misc.datum.recipient); - break; - - case cc_recpt: - mux_printf(fp, " %lu", (u_long)misc.datum.cc_recipient); - break; - - case loc_no: - mux_printf(fp, " %lu", (u_long)misc.datum.local_no); - break; - - case rec_time: - prot_a_output_time(fp, misc.datum.received_at); - break; - - case comm_to: - mux_printf(fp, " %lu", (u_long)misc.datum.comment_to); - break; - - case comm_in: - mux_printf(fp, " %lu", (u_long)misc.datum.commented_in); - break; - - case footn_to: - mux_printf(fp, " %lu", (u_long)misc.datum.footnote_to); - break; - - case footn_in: - mux_printf(fp, " %lu", (u_long)misc.datum.footnoted_in); - break; - - case sent_by: - mux_printf(fp, " %lu", (u_long)misc.datum.sender); - break; - - case sent_at: - prot_a_output_time(fp, misc.datum.sent_at); - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("prot_a_output_misc_info: Illegal misc\n"); -#endif - } -} - - -void -prot_a_output_time(Connection *fp, - time_t clock) -{ - struct tm *time; - - time = localtime( &clock ); - - mux_printf(fp, " %lu %lu %lu %lu %lu %lu %lu %lu %lu", - (u_long) time -> tm_sec, - (u_long) time -> tm_min, - (u_long) time -> tm_hour, - (u_long) time -> tm_mday, - (u_long) time -> tm_mon, - (u_long) time -> tm_year, - (u_long) time -> tm_wday, - (u_long) time -> tm_yday, - (u_long) time -> tm_isdst); -} - - -void -prot_a_output_session_no(Connection *fp, - Session_no session_no) -{ - mux_printf(fp, " %lu", (u_long) session_no); -} - -void -prot_a_output_text_no(Connection *fp, - Text_no text) -{ - mux_printf(fp, " %lu", (u_long) text); -} diff --git a/src/server/prot-a-output.h b/src/server/prot-a-output.h deleted file mode 100644 index 468d5b00b..000000000 --- a/src/server/prot-a-output.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * $Id: prot-a-output.h,v 0.6 1992/04/04 17:30:55 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: prot-a-output.h,v 0.6 1992/04/04 17:30:55 ceder Exp $ - * - */ -extern void -prot_a_output_person(Connection *fp, - Person *person); - - -extern void -prot_a_output_membership(Connection *fp, - const Membership *mship); - -extern void -prot_a_output_membership_list(Connection *fp, - Membership_list mlist); - -extern void -prot_a_output_conf_list(Connection *fp, - Conf_list_old conf_list); - -extern void -prot_a_output_conf_no_list(Connection *fp, - Conf_no_list conf_no_list); - -extern void -prot_a_output_conference(Connection *fp, - Conference *conf_c); - -extern void -prot_a_output_mark_list(Connection *fp, - Mark_list mark_list); - -extern void -prot_a_output_text_stat(Connection *fp, - Text_stat *t_stat); - -extern void -prot_a_output_text_list(Connection *fp, - Text_list text_list); - -extern void -prot_a_output_info(Connection *fp, - Info *info); - -void -prot_a_output_who_info(Connection *fp, - Who_info *info); - -extern void -prot_a_output_who_info_list(Connection *fp, - Who_info_list info); - -extern void -prot_a_output_who_info_ident_list(Connection *fp, - Who_info_ident_list info); - -extern void -prot_a_output_who_info_list_old(Connection *fp, - Who_info_list_old info); - -void -prot_a_output_session_info(Connection *fp, - Session_info *info); - -void -prot_a_output_session_info_ident(Connection *fp, - Session_info_ident *info); - -extern void -prot_a_output_string(Connection *fp, - String str); - -extern void -prot_a_output_priv_bits(Connection *fp, - Priv_bits bits); - -extern void -prot_a_output_personal_flags(Connection *fp, - Personal_flags flags); - - -extern void -prot_a_output_conf_type(Connection *fp, - Conf_type type); - -extern void -prot_a_output_member_list(Connection *fp, - Member_list m_list); - -extern void -prot_a_output_mark(Connection *fp, - Mark mark); - -extern void -prot_a_output_misc_info(Connection *fp, - Misc_info misc); - -extern void -prot_a_output_member(Connection *fp, - Member member); - -void -prot_a_output_time(Connection *fp, - time_t clock); - -void -prot_a_output_session_no(Connection *fp, - Session_no session_no); - -void -prot_a_output_text_no(Connection *fp, - Text_no text); diff --git a/src/server/prot-a-parse-arg-c.awk b/src/server/prot-a-parse-arg-c.awk deleted file mode 100644 index 744542aeb..000000000 --- a/src/server/prot-a-parse-arg-c.awk +++ /dev/null @@ -1,134 +0,0 @@ -# -# $Id: prot-a-parse-arg-c.awk,v 0.6 1992/02/21 00:51:06 ceder Exp $ -# Copyright (C) 1991 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. -# -# $Id: prot-a-parse-arg-c.awk,v 0.6 1992/02/21 00:51:06 ceder Exp $ -BEGIN { - printf("/* Don't edit this file - it is generated automatically"); - printf(" from\n prot-a-parse-arg-c.awk and fncdef.txt */\n\n"); - printf("#include <setjmp.h>\n"); - printf("#include <kom-types.h>\n"); - printf("#include \"com.h\"\n"); - printf("#include \"isc-interface.h\"\n"); - printf("#include \"connections.h\"\n"); - printf("#include \"isc-parse.h\"\n"); - printf("#include <server/smalloc.h>\n"); - printf("#include \"prot-a.h\"\n"); - printf("#include \"prot-a-parse.h\"\n"); - printf("#include \"prot-a-parse-arg.h\"\n"); - printf("#include <config.h>\n\n"); -} -$1 != "#" { - printf("void\nprot_a_parse_arg_%s(Connection *client)\n{\n", $2); - printf(" switch( client->fnc_parse_pos )\n"); - printf(" {\n"); - num=0; - string=0; - c_string=0; - for ( i = 3; i <= NF; i++) - { - if ( $i == ":" ) - break; - - printf(" case %d:\n", i - 3); - if ( $i == "num" ) - printf("\tclient->num%d = prot_a_parse_long(client);\n", num++); - else if ( $i == "c_string" ) - printf("\tprot_a_parse_string(client, &client->c_string%d, %s);\n",\ - c_string++, $(++i)); - else if ( $i == "string" ) - printf("\tprot_a_parse_string(client, &client->string%d, %s);\n",\ - string++, $(++i)); - else if ( $i == "priv_bits" ) - printf("\tprot_a_parse_priv_bits(client, &client->priv_bits);\n"); - else if ( $i == "conf_type" ) - printf("\tprot_a_parse_conf_type(client, &client->conf_type);\n"); - else if ( $i == "c_local_text_no_p" ) - { - printf("\tif ( parse_nonwhite_char(client) != '{' )\n"); - printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n"); - printf("\tif ( client->num%d > MARK_AS_READ_CHUNK )\n", num-1); - printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n"); - printf("\n"); - printf("\tclient->c_local_text_no_p = "); - printf("smalloc(client->num%d\n", num-1); - printf("\t\t\t\t\t * sizeof(Local_text_no));\n\n"); - printf("\tclient->array_parse_pos = 0;\n"); - printf("\tclient->fnc_parse_pos = %d;\n", i - 2); - printf(" case %d:\n", i - 2); - printf("\twhile( client->array_parse_pos < "); - printf("client->num%d )\n", num-1); - printf("\t{\n"); - printf("\t client->c_local_text_no_p[ client->"); - printf("array_parse_pos ]\n"); - printf("\t\t= prot_a_parse_long(client);\n"); - printf("\t ++client->array_parse_pos;\n"); - printf("\t}\n"); - printf("\tclient->fnc_parse_pos = %d;", i - 1); - printf(" case %d:\n", i - 1); - printf("\tif ( parse_nonwhite_char(client) != '}' )\n"); - printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n"); - } - else if ( $i == "c_misc_info_p" ) - { - printf("\tif ( parse_nonwhite_char(client) != '{' )\n"); - printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n"); - printf("\tif ( client->num%d > MAX_CREA_MISC )\n", num-1); - printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n"); - printf("\n"); - printf("\tclient->c_misc_info_p = "); - printf("smalloc(client->num%d\n", num-1); - printf("\t\t\t\t\t* sizeof(Misc_info));\n"); - printf("\tclient->array_parse_pos = 0;\n"); - printf("\tclient->fnc_parse_pos = %d;\n", i - 2); - printf(" case %d:\n", i - 2); - printf("\twhile( client->array_parse_pos < "); - printf("client->num%d )\n", num-1); - printf("\t{\n"); - printf("\t prot_a_parse_misc_info(client,"); - printf(" &client->c_misc_info_p"); - printf("[ client->array_parse_pos ]);\n"); - printf("\t ++client->array_parse_pos;\n"); - printf("\t}\n"); - printf("\tclient->fnc_parse_pos = %d;\n", i - 1); - printf(" case %d:\n", i - 1); - printf("\tif ( parse_nonwhite_char(client) != '}' )\n"); - printf("\t longjmp(parse_env, ISC_PROTOCOL_ERR);\n"); - } - else if ( $i == "time_date" ) - printf("\tprot_a_parse_time_date(client, &client->time);\n"); - else - printf("#error in prot-a-parse-arg-c.awk: not ready yet.\n"); - - if ( i != NF && $(i+1) != ":") - printf("\tclient->fnc_parse_pos = %d;\n", i - 2); - } - - printf(" default:\n"); - printf("\tclient->fnc_parse_pos = 0;\n"); - printf(" }\n"); - printf("}\n\n"); -} -END { - printf("/* end of this auto generated file. */\n"); -} diff --git a/src/server/prot-a-parse-arg-h.awk b/src/server/prot-a-parse-arg-h.awk deleted file mode 100644 index f101d2ca6..000000000 --- a/src/server/prot-a-parse-arg-h.awk +++ /dev/null @@ -1,37 +0,0 @@ -# -# $Id: prot-a-parse-arg-h.awk,v 0.3 1991/09/15 10:30:16 linus Exp $ -# Copyright (C) 1991 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. -# -# $Id: prot-a-parse-arg-h.awk,v 0.3 1991/09/15 10:30:16 linus Exp $ -BEGIN { - printf("/* Don't edit this file - it is generated automatically"); - printf(" from\n prot-a-parse-arg-h.awk and fncdef.txt */\n\n"); -} -$1 != "#" { - printf("void prot_a_parse_arg_%s(Connection *client);\n", $2); -} - -END { printf("/* end of this auto generated file. */\n"); -} - - diff --git a/src/server/prot-a-parse.c b/src/server/prot-a-parse.c deleted file mode 100644 index e8ce8bdab..000000000 --- a/src/server/prot-a-parse.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * $Id: prot-a-parse.c,v 0.10 1992/01/12 01:32:34 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * prot-a-parse.c - parse protocol-A messages. - * - * BUG: Not all functions are used, I think. /ceder - */ - -static char *rcsid = "$Id: prot-a-parse.c,v 0.10 1992/01/12 01:32:34 ceder Exp $"; - - -#include <setjmp.h> -#include <string.h> - -#include "s-string.h" -#include <kom-types.h> -#include "lyskomd.h" -#include "com.h" -#include "connections.h" -#include "prot-a-parse.h" -#include "isc-parse.h" -#include <server/smalloc.h> -#include "minmax.h" -#include "prot-a.h" -#include "config.h" -#include "log.h" - - -/* - * Return next token from the input stream. Note that the String returned - * by this call points into data that might be freed by the next call to - * get_token or any function which reads from the stream. - */ - -static String -prot_a_get_token(Connection *client) -{ - String result; - String_size old_first; - - old_first = client->first_to_parse; - - result = s_strtok(client->unparsed, &client->first_to_parse, - s_fcrea_str(WHITESPACE)); - - /* Check that there was at least one trailing blank. */ - - if ( client->first_to_parse >= s_strlen(client->unparsed) ) - { - client->first_to_parse = old_first; - longjmp(parse_env, ISC_MSG_INCOMPLETE); - } - - return result; -} - - -long -prot_a_parse_long(Connection *client) -{ - String token; - String_size end; - long res; - - token = prot_a_get_token(client); - res = s_strtol(token, &end, PROTOCOL_NUMBER_BASE); - if (end != s_strlen(token)) - longjmp(parse_env, ISC_PROTOCOL_ERR); - - return res; -} - -void -prot_a_parse_priv_bits(Connection *client, - Priv_bits *res) -{ - String token; - - token = prot_a_get_token(client); - - if ( s_strlen(token) != 16 ) - longjmp(parse_env, ISC_PROTOCOL_ERR); - - res->wheel = token.string[ 0 ] != '0'; - res->admin = token.string[ 1 ] != '0'; - res->statistic = token.string[ 2 ] != '0'; - res->create_pers = token.string[ 3 ] != '0'; - res->create_conf = token.string[ 4 ] != '0'; - res->change_name = token.string[ 5 ] != '0'; - res->extern_gw = token.string[ 6 ] != '0'; - res->flg8 = token.string[ 7 ] != '0'; - res->flg9 = token.string[ 8 ] != '0'; - res->flg10 = token.string[ 9 ] != '0'; - res->flg11 = token.string[ 10 ] != '0'; - res->flg12 = token.string[ 11 ] != '0'; - res->flg13 = token.string[ 12 ] != '0'; - res->flg14 = token.string[ 13 ] != '0'; - res->flg15 = token.string[ 14 ] != '0'; - res->flg16 = token.string[ 15 ] != '0'; -} - -void -prot_a_parse_conf_type(Connection *client, - Conf_type *res) -{ - String token; - - token = prot_a_get_token(client); - - if ( s_strlen(token) != 4 ) - longjmp(parse_env, ISC_PROTOCOL_ERR); - - res->rd_prot = token.string[ 0 ] != '0'; - res->original = token.string[ 1 ] != '0'; - res->secret = token.string[ 2 ] != '0'; - res->letter_box = token.string[ 3 ] != '0'; -} - -/* - * Parse a string. At most 'maxlen' characters are allowed. If the - * client sends a longer string only the first 'maxlen+1' characters - * are read. Any remaining characters are discarded. - */ -/* - * +++ This needs cleaning up. See comments in and above mux_parse_string. - */ -void -prot_a_parse_string(Connection *client, - String *result, - int maxlen) -{ - String_size hptr; /* Pointer to 'H' */ - String_size client_len; /* The len the client is sending. */ - String_size truncated_len; /* How much the server will receive. */ - String_size to_skip; - static u_long err_cnt = 0; - - switch ( client->string_parse_pos ) - { - case 0: - if ( (result->len != 0 || result->string != NULL) && err_cnt++ < 20 ) - { - log ("prot_a_parse_string(): result->len == %lu, " - "result->string == %lu. This memory will not be free()'d.\n", - (u_long)result->len, (u_long)result->string); - *result = EMPTY_STRING; - if ( err_cnt == 20 ) - log("Won't log the above warning no more."); - } - - /* Get number and discard trailing 'H' */ - client_len = s_strtol(s_fsubstr(client->unparsed, - client->first_to_parse, - END_OF_STRING), - &hptr, PROTOCOL_NUMBER_BASE); - - if ( hptr == -1 - || client->first_to_parse + hptr - >= s_strlen(client->unparsed) ) - { - longjmp(parse_env, ISC_MSG_INCOMPLETE); - } - - /* Check that - a) there is a trailing H - b) there was at least one digit before the H */ - - if ( client->unparsed.string[ client->first_to_parse - + hptr ] != 'H' - || hptr <= 0 ) - { - longjmp(parse_env, ISC_PROTOCOL_ERR); - } - - client->first_to_parse += 1 + hptr; - client->string_parse_pos = 1; - result->len = client_len; /* +++ Transfer */ - /* Fall through */ - case 1: - client_len = result->len; - /* Check that the entire string is transmitted. */ - /* (Don't care about the trailing part that will be skipped if the - * string is longer than maxlen) */ - truncated_len = min(maxlen + 1, client_len); - - if ( client->first_to_parse + truncated_len - > s_strlen(client->unparsed) ) - { - longjmp(parse_env, ISC_MSG_INCOMPLETE); - } - - *result = EMPTY_STRING; - - s_mem_crea_str(result, - client->unparsed.string + client->first_to_parse, - truncated_len); - result->len = client_len; /* Ugly! +++ */ - - client->first_to_parse += truncated_len; - client->string_parse_pos = 2; - /* Fall through */ - case 2: - /* Was the string too long? If so, skip the truncated data. */ - - client_len = result->len; - truncated_len = min(maxlen+1, client_len); - - if ( client_len > truncated_len ) - { - to_skip = min(client_len - truncated_len, - client->unparsed.len - client->first_to_parse); - client_len -= to_skip; - client->first_to_parse += to_skip; - } - - result->len = client_len; - - if ( client_len > truncated_len ) - longjmp(parse_env, ISC_MSG_INCOMPLETE); - /* Fall through */ - default: - client->string_parse_pos = 0; - } -} - - -extern void -prot_a_parse_misc_info(Connection *client, - Misc_info *result) -{ - switch ( client->struct_parse_pos ) - { - case 0: - result->type = prot_a_parse_long(client); - client->struct_parse_pos = 1; - /* Fall through */ - case 1: - switch( result->type ) - { - case recpt: - result->datum.recipient = prot_a_parse_long(client); - break; - - case cc_recpt: - result->datum.cc_recipient = prot_a_parse_long(client); - break; - - case loc_no: - result->datum.local_no = prot_a_parse_long(client); - break; - - case comm_to: - result->datum.comment_to = prot_a_parse_long(client); - break; - - case footn_to: - result->datum.footnote_to = prot_a_parse_long(client); - break; - - case comm_in: - case footn_in: - case rec_time: - case sent_by: - case sent_at: - /* Fall through */ - -#ifndef COMPILE_CHECKS - default: -#endif - longjmp(parse_env, ISC_PROTOCOL_ERR); - } - default: - client->struct_parse_pos = 0; - } -} - - -void -prot_a_parse_time_date(Connection *client, - struct tm *result) -{ - /* A time never occur inside a string, and a string never occur - inside a time. Thus I use string_parse_pos here instead of - inventing a new variable. Lacgen will allocate variables as - needed... */ - - switch( client->string_parse_pos ) - { - case 0: - result->tm_sec = prot_a_parse_long(client); - client->string_parse_pos = 1; - /* Fall through */ - case 1: - result->tm_min = prot_a_parse_long(client); - client->string_parse_pos = 2; - /* Fall through */ - case 2: - result->tm_hour = prot_a_parse_long(client); - client->string_parse_pos = 3; - /* Fall through */ - case 3: - result->tm_mday = prot_a_parse_long(client); - client->string_parse_pos = 4; - /* Fall through */ - case 4: - result->tm_mon = prot_a_parse_long(client); - client->string_parse_pos = 5; - /* Fall through */ - case 5: - result->tm_year = prot_a_parse_long(client); - client->string_parse_pos = 6; - /* Fall through */ - case 6: - result->tm_wday = prot_a_parse_long(client); - client->string_parse_pos = 7; - /* Fall through */ - case 7: - result->tm_yday = prot_a_parse_long(client); - client->string_parse_pos = 8; - /* Fall through */ - case 8: - result->tm_isdst = prot_a_parse_long(client); - /* Fall through */ - default: - client->string_parse_pos = 0; - } -} - diff --git a/src/server/prot-a-parse.h b/src/server/prot-a-parse.h deleted file mode 100644 index a6ef44da2..000000000 --- a/src/server/prot-a-parse.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * $Id: prot-a-parse.h,v 0.5 1992/01/12 01:32:32 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: prot-a-parse.h,v 0.5 1992/01/12 01:32:32 ceder Exp $ - * - */ -extern long -prot_a_parse_long(Connection *client); - -extern void -prot_a_parse_priv_bits(Connection *client, - Priv_bits *result); - -extern void -prot_a_parse_conf_type(Connection *client, - Conf_type *result); - - -extern void -prot_a_parse_string(Connection *client, - String *result, - int maxlen); - -extern void -prot_a_parse_misc_info(Connection *client, - Misc_info *result); - -extern void -prot_a_parse_time_date(Connection *client, - struct tm *result); diff --git a/src/server/prot-a-send-async.c b/src/server/prot-a-send-async.c deleted file mode 100644 index 7da522445..000000000 --- a/src/server/prot-a-send-async.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * $Id: prot-a-send-async.c,v 0.5 1991/09/21 13:06:55 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * Asynchronous messages in protocol A. - */ - -static char *rcsid = "$Id: prot-a-send-async.c,v 0.5 1991/09/21 13:06:55 ceder Exp $"; - - -#include <stdio.h> -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "async.h" -#include "com.h" -#include "connections.h" -#include "prot-a-send-async.h" -#include "prot-a-output.h" -#include "manipulate.h" -#include "log.h" -#include "isc-interface.h" -#include "mux.h" - -static void -async_header(Connection *fp, - int no_of_tokens, - Async fnc) -{ - mux_printf(fp, ":%lu %lu", (u_long)no_of_tokens, (u_long)fnc); -} - - - - -static void -async_trailer(Connection *fp) -{ - mux_putc('\n', fp); - mux_flush(fp); -} - - -void -prot_a_async_new_text(Connection *cptr, - Text_no text_no, - Text_stat *text_s) -{ - async_header(cptr, 16, ay_new_text); - mux_printf(cptr, " %lu", text_no); - prot_a_output_text_stat(cptr, text_s); - async_trailer(cptr); -} - - -void -prot_a_async_i_am_on(Connection *cptr, - Who_info info) -{ - async_header(cptr, 5, ay_i_am_on); - prot_a_output_who_info(cptr, &info); - async_trailer(cptr); -} - -void -prot_a_async_i_am_off(Connection *cptr, - Pers_no pers_no) -{ - async_header(cptr, 1, ay_i_am_off); - mux_printf(cptr, " %lu", pers_no); - async_trailer(cptr); -} - - -void -prot_a_async_logout(Connection *cptr, - Pers_no pers_no, - Session_no session_no) -{ - async_header(cptr, 2, ay_logout); - mux_printf(cptr, " %lu %lu", (u_long)pers_no, (u_long)session_no); - async_trailer(cptr); -} - -void -prot_a_async_new_name(Connection *cptr, - Conf_no conf_no, - String old_name, - String new_name) -{ - async_header(cptr, 3, ay_new_name); - mux_printf(cptr, " %lu", (u_long)conf_no); - prot_a_output_string(cptr, old_name); - prot_a_output_string(cptr, new_name); - async_trailer(cptr); -} - -void -prot_a_async_sync_db(Connection *cptr) -{ - async_header(cptr, 0, ay_sync_db); - async_trailer(cptr); -} - -void -prot_a_async_forced_leave_conf(Connection *cptr, - Conf_no conf_no) -{ - async_header(cptr, 1, ay_leave_conf); - mux_printf(cptr, " %lu", (u_long)conf_no); - async_trailer(cptr); -} - -void -prot_a_async_login(Connection *cptr, - Pers_no pers_no, - int session_no) -{ - async_header(cptr, 2, ay_login); - mux_printf(cptr, " %lu %lu", (u_long)pers_no, (u_long)session_no); - async_trailer(cptr); -} - - -void -prot_a_async_broadcast(Connection *cptr, - Pers_no pers_no, - String message) -{ - prot_a_async_send_message(cptr, 0, pers_no, message); -#if 0 - async_header(cptr, 2, ay_broadcast); - mux_printf(cptr, " %lu", (u_long)pers_no); - prot_a_output_string(cptr, message); - async_trailer(cptr); -#endif -} - -void -prot_a_async_rejected_connection(Connection *cptr) -{ - async_header(cptr, 0, ay_rejected_connection); - async_trailer(cptr); -} - -void -prot_a_async_send_message(Connection *cptr, - Pers_no recipient, - Pers_no sender, - String message) -{ - async_header(cptr, 3, ay_send_message); - mux_printf(cptr, " %lu %lu", (u_long)recipient, (u_long)sender); - prot_a_output_string(cptr, message); - async_trailer(cptr); -} diff --git a/src/server/prot-a-send-async.h b/src/server/prot-a-send-async.h deleted file mode 100644 index 871fa60e2..000000000 --- a/src/server/prot-a-send-async.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * $Id: prot-a-send-async.h,v 0.3 1991/09/15 10:30:00 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: prot-a-send-async.h,v 0.3 1991/09/15 10:30:00 linus Exp $ - * - * Asynchronous messages in protocol A. - */ - -void -prot_a_async_new_text(Connection *cptr, - Text_no text_no, - Text_stat *text_s); - -void -prot_a_async_i_am_on(Connection *cptr, - Who_info info); -void -prot_a_async_i_am_off(Connection *cptr, - Pers_no pers_no); -void -prot_a_async_logout(Connection *cptr, - Pers_no pers_no, - Session_no session_no); - -void -prot_a_async_new_name(Connection *cptr, - Conf_no conf_no, - String old_name, - String new_name); - -void -prot_a_async_sync_db(Connection *cptr); - -void -prot_a_async_forced_leave_conf(Connection *cptr, - Conf_no conf_no); - -void -prot_a_async_login(Connection *cptr, - Pers_no pers_no, - int session_no); - - -void -prot_a_async_broadcast(Connection *cptr, - Pers_no pers_no, - String message); - -void -prot_a_async_rejected_connection(Connection *cptr); - -void -prot_a_async_send_message(Connection *cptr, - Pers_no recipient, - Pers_no sender, - String message); diff --git a/src/server/prot-a.c b/src/server/prot-a.c deleted file mode 100644 index 0b4010398..000000000 --- a/src/server/prot-a.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * $Id: prot-a.c,v 0.15 1992/05/18 23:09:23 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * Protocol A. - */ - -static char *rcsid = "$Id: prot-a.c,v 0.15 1992/05/18 23:09:23 ceder Exp $"; - - -#include <stdio.h> -#include <setjmp.h> - -#include <kom-errno.h> -#include <kom-types.h> -#include <server/smalloc.h> -#include "lyskomd.h" -#include "com.h" -#include "connections.h" -#include "isc-parse.h" -#include "prot-a.h" -#include "prot-a-output.h" -#include "prot-a-parse.h" -#include <debug.h> -#include "isc-interface.h" -#include "mux.h" - -BUGDECL; - -void -prot_a_reply(Connection *client, - Bool status, - Result_holder *res) -{ - /* - * The function is called. Now return the answer. - */ - - if ( status == OK ) - { - mux_printf(client, "=%d", client->ref_no); - - switch ( fnc_defs[ client->function ].result ) - { - case rt_number: - mux_printf(client, " %ld", (u_long)res->number); - BUG(("=%d\n", res->number)); - break; - - case rt_success: - BUG(("=Success\n")); - break; - - case rt_person: - prot_a_output_person(client, &res->person); - BUG(("={Person struct not listed}\n")); - break; - - case rt_membership: - prot_a_output_membership(client, &res->membership); - BUG(("={Membership struct not listed}\n")); - break; - - case rt_conf_list: - prot_a_output_conf_list(client, res->conf_list); - BUG(("={Conf_list not listed}\n")); - break; - - case rt_conf_no_list: - prot_a_output_conf_no_list(client, res->conf_no_list); - BUG(("={Conf_no_list not listed}\n")); - break; - - case rt_conference: - prot_a_output_conference(client, &res->conference); - BUG(("={Conference struct not listed}\n")); - break; - - case rt_string: - prot_a_output_string(client, res->string); - BUG(("={%dH", res->string.len)); - BUGSTR(res->string); - BUG(("}\n")); - break; - - case rt_mark_list: - prot_a_output_mark_list(client, res->mark_list); - BUG(("={Mark_list not listed}\n")); - break; - - case rt_text_stat: - prot_a_output_text_stat(client, &res->text_stat); - BUG(("={Text_stat struct not listed}\n")); - break; - - case rt_text_list: - prot_a_output_text_list(client, res->text_list); - BUG(("={Text_list not listed}\n")); - break; - - case rt_who_info_list: - prot_a_output_who_info_list(client, res->who_info_list); - BUG(("={Who_info_list not listed}\n")); - break; - - case rt_who_info_list_old: - prot_a_output_who_info_list_old(client, - res->who_info_list_old); - BUG(("={Old who_info_list not listed}\n")); - break; - - case rt_session_info: - prot_a_output_session_info(client, - &res->session_info); - /* Clear username, since it is allocated (in get_session_info() - in session.c). See comment abover the definition of - typedef Result_holder in connections.h. */ - s_clear(&res->session_info.username); - BUG(("={Session_info not listed}\n")); - break; - - case rt_info: - prot_a_output_info(client, &res->info); - BUG(("={Who_info struct not listed}\n")); - break; - - case rt_membership_list: - prot_a_output_membership_list (client, res->membership_list); - BUG (("={Membership_list not listed}\n")); - break; - - case rt_member_list: - prot_a_output_member_list (client, res->member_list); - BUG(("={Member_list not listed}\n")); - break; - - case rt_time_date: - prot_a_output_time (client, res->time_date); - BUG(("=(time_t)%d\n", res->time_date)); - break; - - case rt_session_no: - prot_a_output_session_no (client, res->session_no); - BUG(("=(Session_no)%d\n", res->session_no)); - break; - - case rt_text_no: - prot_a_output_text_no (client, res->text_no); - BUG(("=(Text_no)%d\n", res->text_no)); - break; - - case rt_who_info_ident_list: - prot_a_output_who_info_ident_list(client, - res->who_info_ident_list); - BUG(("={Who_info_ident_list not listed}\n")); - break; - - case rt_session_info_ident: - prot_a_output_session_info_ident(client, - &res->session_info_ident); - BUG(("={Session_info_ident not listed}\n")); - break; - } - mux_putc('\n', client); - } - else - { - /* Failure. Give a reply with the error message. */ - mux_printf(client, "%%%d %d %d\n", - client->ref_no, kom_errno, err_stat); - BUG(("%%Err %d\n", kom_errno)); - } - - mux_flush(client); -} - -/* - * Check if it is a legal function. - * - * BUG: This should be generated from fncdef.txt. - */ - - -/* - * Set up all data structures that are private to protocol A. This - * function is called from connections.c whenever a connection says - * that it is of type A. - */ -void -prot_a_init(Connection *conn) -{ - conn->parse_pos = 0; - conn->fnc_parse_pos = 0; - conn->array_parse_pos = 0; - conn->struct_parse_pos = 0; - conn->string_parse_pos = 0; - conn->ref_no = 0; - conn->function = 0; - conn->num0 = 0; - conn->num1 = 0; - conn->num2 = 0; - conn->num3 = 0; - conn->c_string0 = EMPTY_STRING; - conn->c_string1 = EMPTY_STRING; - conn->string0 = EMPTY_STRING; - conn->c_misc_info_p = NULL; - conn->c_local_text_no_p = NULL; - conn->priv_bits = DEFAULT_PRIV_BITS; - conn->conf_type = NULL_CONF_TYPE; -} - -void -prot_a_destruct(Connection *conn) -{ - - /* - * All strings et c should already by free:d - that is done at the - * end of each atomic call. But free them anyhow, just in case - * this client is forced of. - */ - - s_clear(&conn->string0); - s_clear(&conn->c_string0); - s_clear(&conn->c_string1); - sfree(conn->c_misc_info_p); - sfree(conn->c_local_text_no_p); -} - - -static Bool -prot_a_is_legal_fnc(Call_header fnc) -{ - switch(fnc) - { - case call_fnc_login_old: - case call_fnc_logout: - case call_fnc_pepsi: - case call_fnc_change_name: - case call_fnc_change_what_i_am_doing: - case call_fnc_create_person: - case call_fnc_get_person_stat_old: - case call_fnc_set_priv_bits: - case call_fnc_set_passwd: - case call_fnc_query_read_texts: - case call_fnc_create_conf: - case call_fnc_delete_conf: - case call_fnc_lookup_name: - case call_fnc_get_conf_stat_old: - case call_fnc_add_member: - case call_fnc_sub_member: - case call_fnc_set_presentation: - case call_fnc_set_etc_motd: - case call_fnc_set_supervisor: - case call_fnc_set_permitted_submitters: - case call_fnc_set_super_conf: - case call_fnc_set_conf_type: - case call_fnc_set_garb_nice: - case call_fnc_get_marks: - case call_fnc_mark_text: - case call_fnc_get_text: - case call_fnc_get_text_stat: - case call_fnc_mark_as_read: - case call_fnc_create_text: - case call_fnc_delete_text: - case call_fnc_add_recipient: - case call_fnc_sub_recipient: - case call_fnc_add_comment: - case call_fnc_sub_comment: - case call_fnc_get_map: - case call_fnc_get_time: - case call_fnc_get_info: - case call_fnc_add_footnote: - case call_fnc_sub_footnote: - case call_fnc_who_is_on_old: - case call_fnc_set_unread: - case call_fnc_set_motd_of_lyskom: - case call_fnc_enable: - case call_fnc_sync: - case call_fnc_shutdown: - case call_fnc_broadcast: - case call_fnc_get_membership: - case call_fnc_get_created_texts: - case call_fnc_get_members: - case call_fnc_get_person_stat: - case call_fnc_get_conf_stat: - case call_fnc_who_is_on: - case call_fnc_get_unread_confs: - case call_fnc_send_message: - case call_fnc_get_session_info: - case call_fnc_disconnect: - case call_fnc_who_am_i: - case call_fnc_set_user_area: - case call_fnc_get_last_text: - case call_fnc_create_anonymous_text: - case call_fnc_find_next_text_no: - case call_fnc_find_previous_text_no: - case call_fnc_who_is_on_ident: - case call_fnc_get_session_info_ident: - case call_fnc_login: - return TRUE; - - default: - return FALSE; - } -} - - -void -prot_a_parse_packet(Connection *client) -{ - if ( client->username_valid == FALSE ) - { - /* Connection not established yet */ - - prot_a_parse_string(client, &client->c_string0, USERNAME_LEN); - - client->username = client->c_string0; /* Kludge to deal with */ - client->c_string0 = EMPTY_STRING; /* "A5B" as first input. */ - /* Protokoll B will not suffer from this... */ - - client->username_valid = TRUE; - mux_printf(client, "LysKOM\n"); - mux_flush(client); - BUG(("[Client %d is logged on]\n", client->session_no)); - } - - switch(client->parse_pos) - { - case 0: /* Get ref_no */ - client->ref_no = prot_a_parse_long(client); - client->parse_pos = 1; - /* Fall through */ - case 1: /* Get fnc_no */ - client->function = prot_a_parse_long(client); - if ( !prot_a_is_legal_fnc(client->function) ) - longjmp(parse_env, ISC_PROTOCOL_ERR); - client->parse_pos = 2; - /* Fall through */ - case 2: - /* Call the function that parses the arguments for this call. */ - fnc_defs[client->function].parser(client); - /* Fall through */ - default: - client->parse_pos = 0; - } - -} diff --git a/src/server/prot-a.h b/src/server/prot-a.h deleted file mode 100644 index dd2678c8c..000000000 --- a/src/server/prot-a.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * $Id: prot-a.h,v 0.3 1991/09/15 10:29:52 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: prot-a.h,v 0.3 1991/09/15 10:29:52 linus Exp $ - * - */ -void -prot_a_init(Connection *conn); - -void -prot_a_destruct(Connection *conn); - -void -prot_a_reply(Connection *client, - Bool status, - Result_holder *result); - -void -prot_a_parse_packet(Connection *client); diff --git a/src/server/ram-output.c b/src/server/ram-output.c deleted file mode 100644 index aa30b0208..000000000 --- a/src/server/ram-output.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * $Id: ram-output.c,v 0.5 1991/10/29 14:52:15 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * ram-output.c - write objects to disk. - * - * This is a hack. It shouldn't be used except for debugging and as a - * temporary substitute for what Willf|r is (or should:-) be doing. - * - * Written by ceder 1990-07-13. Rewritten 1990-08-31. - * Some functions rewritten for speed by Inge Wallin. - * (It worked - now saving is twice as fast.) - */ - -static char *rcsid = "$Id: ram-output.c,v 0.5 1991/10/29 14:52:15 linus Exp $"; - - -#include <kom-types.h> -#include <stdio.h> -#include <sys/file.h> -#include <time.h> -#include "lyskomd.h" -#include "ram-output.h" -#include "com.h" -#include "isc-interface.h" -#include "connections.h" -#include "prot-a-output.h" -#include "log.h" - -void -foutput_person (FILE *fp, - Person *person) -{ - foutput_string (fp, person->username); - foutput_priv_bits (fp, person->privileges); - foutput_personal_flags (fp, person->flags); - - foutput_text_list (fp, person->created_texts); - foutput_mark_list (fp, person->marks); - foutput_membership_list (fp, person->conferences); - - foutput_time(fp, person->last_login); - - fprintf (fp, " %lu %lu %lu %lu %lu %lu %lu %lu %lu", - (u_long) person -> user_area, - (u_long) person -> total_time_present, /* This is not a time, - * but a number of seconds. - */ - (u_long) person -> sessions, - (u_long) person -> created_lines, - (u_long) person -> created_bytes, - (u_long) person -> read_texts, - (u_long) person -> no_of_text_fetches, - (u_long) person -> created_persons, - (u_long) person -> created_confs); -} - - - -void -foutput_conference (FILE *fp, - Conference *conf_c) -{ - foutput_string(fp, conf_c->name); - foutput_member_list(fp, conf_c->members); - foutput_text_list(fp, conf_c->texts); - foutput_conf_type(fp, conf_c->type); - - foutput_time(fp, conf_c -> creation_time ); - foutput_time(fp, conf_c -> last_written ); - - fprintf (fp, " %lu %lu %lu %lu %lu %lu %lu", - (u_long) conf_c -> creator, - (u_long) conf_c -> presentation, - (u_long) conf_c -> supervisor, - (u_long) conf_c -> permitted_submitters, - (u_long) conf_c -> super_conf, - (u_long) conf_c -> msg_of_day, - (u_long) conf_c -> nice); -} - - -void -foutput_text_stat(FILE *fp, - Text_stat *t_stat) -{ - int i; - - foutput_time(fp, t_stat->creation_time); - - foutput_ulong((u_long) t_stat->author, fp); - foutput_ulong((u_long) t_stat->file_pos, fp); - foutput_ulong((u_long) t_stat->no_of_lines, fp); - foutput_ulong((u_long) t_stat->no_of_chars, fp); - foutput_ulong((u_long) t_stat->no_of_marks, fp); - foutput_ulong((u_long) t_stat->no_of_misc, fp); - - if ( t_stat->misc_items != NULL && t_stat->no_of_misc > 0 ) - { - fputs(" {", fp); - for ( i = 0; i < t_stat->no_of_misc; i++ ) - foutput_misc_info(fp, t_stat->misc_items[ i ]); - fputs(" }", fp); - } - else - fputs(" *", fp); -} - - -extern void -foutput_string(FILE *fp, - String str) -{ - foutput_ulong((u_long)str.len, fp); - putc('H', fp); - - if (str.len) - fwrite(str.string, str.len, 1, fp); -} - -extern void -foutput_priv_bits(FILE *fp, - Priv_bits bits) -{ - putc(' ', fp); - putc(bits.wheel + '0', fp); - putc(bits.admin + '0', fp); - putc(bits.statistic + '0', fp); - putc(bits.create_pers + '0', fp); - putc(bits.create_conf + '0', fp); - putc(bits.change_name + '0', fp); - putc(bits.extern_gw + '0', fp); - putc(bits.flg8 + '0', fp); - putc(bits.flg9 + '0', fp); - putc(bits.flg10 + '0', fp); - putc(bits.flg11 + '0', fp); - putc(bits.flg12 + '0', fp); - putc(bits.flg13 + '0', fp); - putc(bits.flg14 + '0', fp); - putc(bits.flg15 + '0', fp); - putc(bits.flg16 + '0', fp); -} - -extern void -foutput_personal_flags(FILE *fp, - Personal_flags flags) -{ - putc(' ', fp); - putc(flags.unread_is_secret + '0', fp); - putc(flags.flg2 + '0', fp); - putc(flags.flg3 + '0', fp); - putc(flags.flg4 + '0', fp); - putc(flags.flg5 + '0', fp); - putc(flags.flg6 + '0', fp); - putc(flags.flg7 + '0', fp); - putc(flags.flg8 + '0', fp); -} - - -void -foutput_text_list(FILE *fp, - Text_list text_list) -{ - int i; - - foutput_ulong((u_long)text_list.first_local_no, fp); - foutput_ulong((u_long)text_list.no_of_texts, fp); - - if ( text_list.texts != NULL && text_list.no_of_texts > 0 ) - { - fputs(" {", fp); - for ( i = 0; i < text_list.no_of_texts; i++ ) - foutput_ulong((u_long)text_list.texts[ i ], fp); - fputs(" }", fp); - } - else - fprintf(fp, " *"); -} - - -void -foutput_mark_list(FILE *fp, - Mark_list mark_list) -{ - int i; - - fprintf(fp, " %lu", (u_long)mark_list.no_of_marks); - - if ( mark_list.marks != NULL && mark_list.no_of_marks > 0 ) - { - fprintf(fp, " {"); - for ( i = 0; i < mark_list.no_of_marks; i++ ) - foutput_mark(fp, mark_list.marks[ i ]); - fprintf(fp, " }"); - } - else - fprintf(fp, " *"); - -} - - -extern void -foutput_mark(FILE *fp, - Mark mark) -{ - fprintf(fp, " %lu %lu", (u_long)mark.text_no, (u_long)mark.mark_type); -} - -void -foutput_membership_list (FILE * fp, - Membership_list mlist) -{ - int i; - - fprintf(fp, " %lu", (u_long)mlist.no_of_confs); - - if ( mlist.confs != NULL && mlist.no_of_confs > 0 ) - { - fprintf(fp, " {"); - for ( i = 0; i < mlist.no_of_confs; i++) - foutput_membership(fp, mlist.confs + i); - fprintf(fp, " }"); - } - else - fprintf(fp, " *"); -} - - - -void -foutput_membership(FILE *fp, - Membership *mship) -{ - int i; - - foutput_time(fp, mship->last_time_read ); - - if ( mship->read_texts == NULL && mship->no_of_read != 0 ) - { - log("foutput_membership(): no_of_read forced to 0" - " in someones membership in %lu.\n", - mship->conf_no); - mship->no_of_read = 0; - } - - fprintf(fp, " %lu %lu %lu %lu", - (u_long)mship->conf_no, - (u_long)mship->priority, - (u_long)mship->last_text_read, - (u_long)mship->no_of_read); - - if ( mship->read_texts != NULL && mship->no_of_read > 0) - { - fprintf(fp, " {"); - for ( i = 0; i < mship->no_of_read; i++) - fprintf(fp, " %lu", (u_long)mship->read_texts[ i ]); - - fprintf(fp, " }"); - } - else - fprintf(fp, " *"); -} - -void -foutput_time(FILE *fp, - time_t clock) -{ - foutput_ulong((u_long) clock, fp); -} - - -extern void -foutput_member_list(FILE *fp, - Member_list m_list) -{ - int i; - - fprintf(fp, " %lu", (u_long)m_list.no_of_members); - if ( m_list.members != NULL && m_list.no_of_members > 0 ) - { - fprintf(fp, " {"); - for ( i = 0; i < m_list.no_of_members; i++ ) - foutput_member(fp, m_list.members[ i ]); - fprintf(fp, " }"); - } - else - fprintf(fp, " *"); -} - - -void -foutput_member(FILE *fp, - Member member) -{ - fprintf(fp, " %lu", (u_long)member.member); -} - -extern void -foutput_conf_type(FILE *fp, - Conf_type type) -{ - putc(' ', fp); - putc(type.rd_prot + '0', fp); - putc(type.original + '0', fp); - putc(type.secret + '0', fp); - putc(type.letter_box + '0', fp); -} - - -extern void -foutput_misc_info(FILE *fp, - Misc_info misc) -{ - foutput_ulong((u_long)misc.type, fp); - - switch(misc.type) - { - case recpt: - foutput_ulong((u_long)misc.datum.recipient, fp); - break; - - case cc_recpt: - foutput_ulong((u_long)misc.datum.cc_recipient, fp); - break; - - case loc_no: - foutput_ulong((u_long)misc.datum.local_no, fp); - break; - - case rec_time: - foutput_time(fp, misc.datum.received_at); - break; - - case comm_to: - foutput_ulong((u_long)misc.datum.comment_to, fp); - break; - - case comm_in: - foutput_ulong((u_long)misc.datum.commented_in, fp); - break; - - case footn_to: - foutput_ulong((u_long)misc.datum.footnote_to, fp); - break; - - case footn_in: - foutput_ulong((u_long)misc.datum.footnoted_in, fp); - break; - - case sent_by: - foutput_ulong((u_long)misc.datum.sender, fp); - break; - - case sent_at: - foutput_time(fp, misc.datum.sent_at); - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("prot_a_output_misc_info: Illegal misc\n"); -#endif - } -} - - -/* - * Output the unsigned long L in the fastest way possible to the file - * FP. Ok, it's ugly, but it's fast (or is it?). - */ - -void -foutput_ulong (u_long l, - FILE *fp) -{ - static char buf[20]; - char *cp; - - putc(' ', fp); - if (l < 10) - putc("0123456789"[l], fp); - else { - cp = buf + 19; - while (l > 0) { - *cp-- = (l % 10) + '0'; - l /= 10; - } - fwrite(cp + 1, buf + 19 - cp, 1, fp); - } -} diff --git a/src/server/ram-output.h b/src/server/ram-output.h deleted file mode 100644 index 06635db7a..000000000 --- a/src/server/ram-output.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * $Id: ram-output.h,v 0.3 1991/09/15 10:29:44 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: ram-output.h,v 0.3 1991/09/15 10:29:44 linus Exp $ - * - * ram-output.c - write objects to disk. - * - * This is a hack. It shouldn't be used except for debugging and as a - * temporary substitute for what Willf|r is (or should:-) be doing. - * - * Written by ceder 1990-07-13. Rewritten 1990-08-31. - */ - -void -foutput_person (FILE *fp, - Person *person); - - -void -foutput_conference (FILE *fp, - Conference *conf_c); - -void -foutput_text_stat(FILE *fp, - Text_stat *t_stat); - -extern void -foutput_string(FILE *fp, - String str); -extern void -foutput_priv_bits(FILE *fp, - Priv_bits bits); -extern void -foutput_personal_flags(FILE *fp, - Personal_flags flags); - -void -foutput_text_list(FILE *fp, - Text_list text_list); - -void -foutput_mark_list(FILE *fp, - Mark_list mark_list); - -extern void -foutput_mark(FILE *fp, - Mark mark); -void -foutput_membership_list (FILE * fp, - Membership_list mlist); - -void -foutput_membership(FILE *fp, - Membership *mship); -void -foutput_time(FILE *fp, - time_t clock); - -extern void -foutput_member_list(FILE *fp, - Member_list m_list); - -void -foutput_member(FILE *fp, - Member member); -extern void -foutput_conf_type(FILE *fp, - Conf_type type); - -extern void -foutput_misc_info(FILE *fp, - Misc_info misc); - -extern void -foutput_ulong (u_long l, - FILE *fp); diff --git a/src/server/ram-parse.c b/src/server/ram-parse.c deleted file mode 100644 index 90115496e..000000000 --- a/src/server/ram-parse.c +++ /dev/null @@ -1,1201 +0,0 @@ -/* - * $Id: ram-parse.c,v 0.9 1991/10/29 14:52:07 linus Exp $ - * Copyright (C) 1991 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. - */ -/*#define DISKERR*/ /* Some corrections - that are needed by diskomd 0.29. - */ -/* - * ram-parse.c -- parse objects from disk file. - */ - -static char *rcsid = "$Id: ram-parse.c,v 0.9 1991/10/29 14:52:07 linus Exp $"; - - -/* - * BUGS: Not all functions are needed. - * The method for checking errors in fparse_long is ugly. - * Errors in fparse_long are not always checked for. - */ -#include <stdio.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/file.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include "lyskomd.h" -#include "s-string.h" -#include <kom-types.h> -#include <kom-errno.h> -#include <services.h> -#include "ram-parse.h" -#include "log.h" -#include <server/smalloc.h> -#include "com.h" -#include "connections.h" -#ifdef DISKERR -#include "string-malloc.h" -#endif - -#define REALLOC(ptr, size) srealloc(ptr, size) - -static int fparse_long_errors = 0; - -void -fskipwhite(FILE *fp) -{ - int c; - - while ( (c = getc(fp)) != EOF && /* isascii(c) && */ isspace(c) ) - ; - - ungetc(c, fp); -} - -extern u_long -fparse_long(FILE *fp) -{ - u_long res = 0; - int foo = 0; - int c; - - fskipwhite(fp); - while ( (c = getc(fp)) != EOF && /* isascii(c) && */ isdigit(c)) - { - foo = 1; - res = 10 * res + c - '0'; - } - - if ( foo == 0 ) - { - log("fparse_long() failed at pos %d.\n", ftell(fp)); - ++fparse_long_errors; - } - - ungetc(c, fp); - - return res; -} - -extern time_t -fparse_time(FILE *fp) -{ - return fparse_long(fp); -} - - - -extern Success -fparse_conference(FILE *fp, - Conference *result) -{ - if ( fparse_long_errors != 0 ) - { - log("fparse_conference(): fparse_long_errors == %d on entry. Reset.\n", - fparse_long_errors); - fparse_long_errors = 0; - } - - if ( fparse_string(fp, &result->name) != OK ) - { - log("fparse_conference(): Can't parse name.\n"); - return FAILURE; - } - - if ( fparse_member_list(fp, &result->members) != OK - || fparse_text_list(fp, &result->texts) != OK - || fparse_conf_type(fp, &result->type) != OK ) - { - log("fparse_conference: file is corrupt.\n"); - return FAILURE; - } - - result->creation_time = fparse_time(fp); - result->last_written = fparse_time(fp); - - result->creator = fparse_long(fp); - result->presentation = fparse_long(fp); - result->supervisor = fparse_long(fp); - result->permitted_submitters = fparse_long(fp); - result->super_conf = fparse_long(fp); - result->msg_of_day = fparse_long(fp); - - if ( fparse_long_errors != 0 ) - { - log("fparse_conference(): %d fparse_long_errors before 'nice'. " - "Reset.\n", - fparse_long_errors); - fparse_long_errors = 0; - return FAILURE; - } - - result->nice = fparse_long(fp); - -#ifdef DISKERR - if ( fparse_long_errors != 0 ) - { - log("fparse_conference(): Error parsing 'nice' at pos %d. " - "nice set to 77 and error ignored.\n", ftell(fp)); - fparse_long_errors = 0; - result->nice = 77; - } - - if ( result->nice < 10 ) - { - char *name; - int new_nice; - - name = s_crea_c_str(result->name); - new_nice = 10 * result->nice + 7; - - if ( name == NULL ) - { - log("fparse_conference(): nice in (null) was %d, set to %d.\n", - result->nice, new_nice); - } - else - { - log("fparse_conference(): nice in %s was %d, set to %d.\n", - name, result->nice, new_nice); - string_free(name); - } - - result->nice = new_nice; - } -#endif - - fskipwhite(fp); - - return OK; -} - - -Success -fparse_person(FILE *fp, - Person *person) -{ - String pwd = EMPTY_STRING; - - if ( fparse_long_errors != 0 ) - { - log("fparse_person(): fparse_long_errors == %d on entry. Reset.\n", - fparse_long_errors); - fparse_long_errors = 0; - } - - if ( fparse_string(fp, &pwd) != OK ) - { - log("fparse_person(): Failed to parse password.\n"); - return FAILURE; - } - - memcpy(person->pwd, pwd.string, PASSWD_LEN); - s_clear(&pwd); - - if ( fparse_string(fp, &person->username) != OK - || fparse_priv_bits(fp, &person->privileges) != OK - || fparse_personal_flags(fp, &person->flags) != OK - || fparse_text_list(fp, &person->created_texts) != OK - || fparse_mark_list(fp, &person->marks) != OK - || fparse_membership_list(fp, &person->conferences) != OK ) - { - log("fparse_person(): parse error.\n"); - return FAILURE; - } - - person->last_login = fparse_time(fp); - - person->user_area = fparse_long(fp); - person->total_time_present = fparse_long(fp); - person->sessions = fparse_long(fp); - person->created_lines = fparse_long(fp); - person->created_bytes = fparse_long(fp); - person->read_texts = fparse_long(fp); - person->no_of_text_fetches = fparse_long(fp); - person->created_persons = fparse_long(fp); - - if ( fparse_long_errors != 0 ) - { - log("fparse_person(): %d fparse_long_errors before 'created_" - "confs'. Reset.\n", - fparse_long_errors); - fparse_long_errors = 0; - return FAILURE; - } - - person->created_confs = fparse_long(fp); - -#ifdef DISKERR - if ( fparse_long_errors != 0 ) - { - log("fparse_person(): Error parsing 'created_confs' at pos %d. " - "created_confs set to 0 and error ignored.\n", ftell(fp)); - fparse_long_errors = 0; - person->created_confs = 0; - } -#endif - - fskipwhite(fp); - - return OK; -} - -Success -fparse_membership(FILE *fp, - Membership *mship) -{ - int i; - - mship->last_time_read = fparse_time(fp); - - mship->conf_no = fparse_long(fp); - mship->priority = fparse_long(fp); - mship->last_text_read = fparse_long(fp); - mship->no_of_read = fparse_long(fp); - - if ( mship->no_of_read > 0) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - mship->read_texts - = REALLOC(mship->read_texts, (mship->no_of_read - * sizeof(Local_text_no))); - if ( mship->read_texts == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < mship->no_of_read; i++) - mship->read_texts[ i ] = fparse_long(fp); - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - kom_errno = KOM_SERVER_IS_CRAZY; - log("fparse_membership(): expected '}' at pos %d.\n", - ftell(fp)); - return FAILURE; - } - break; - - case '*': - if ( mship->read_texts != NULL ) - { - sfree(mship->read_texts); - mship->read_texts = NULL; - } - log("fparse_membership(): empty read_texts " - "with %lu elements (corrected)\n", - mship->no_of_read); - mship->no_of_read = 0; - break; - default: - log("fparse_membership(): expected '*' or '{' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_membership(): expected '*' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - if ( mship->read_texts != NULL ) - { - sfree(mship->read_texts); - mship->read_texts = NULL; - } - } - - return OK; -} - - -extern Success -fparse_membership_list(FILE *fp, - Membership_list *result) -{ - int i; - - /* First free all the read_texts. */ - - if ( result->confs != NULL ) - { - for ( i = 0; i < result->no_of_confs; i++) - sfree(result->confs[ i ].read_texts); - } - - result->no_of_confs = fparse_long(fp); - - if ( result->no_of_confs > 0 ) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - result->confs = REALLOC(result->confs, - (result->no_of_confs - * sizeof(Membership))); - if ( result->confs == NULL && result->no_of_confs > 0 ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_confs; i++) - { - result->confs[ i ] = EMPTY_MEMBERSHIP; - if ( fparse_membership(fp, &result->confs[i]) != OK ) - return FAILURE; - } - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - log("fparse_membership_list(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - break; - case '*': - if ( result->confs != NULL ) - { - sfree(result->confs); - result->confs = NULL; - } - log("fparse_membership_list(): empty list with %lu " - "elements (corrected).\n", - (u_long)result->no_of_confs); - - result->no_of_confs = 0; - break; - default: - log("fparse_membership_list(): expected '*' or '{' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_membership_list(): expected '*' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - if ( result->confs != NULL ) - { - sfree(result->confs); - result->confs = NULL; - } - } - return OK; -} - - -extern Success -fparse_conf_list(FILE *fp, - Conf_list_old *result) -{ - int i; - - result->no_of_conf_nos = fparse_long(fp); - if ( result->no_of_conf_nos > 0 ) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - result->conf_nos = REALLOC(result->conf_nos, - (result->no_of_conf_nos - * sizeof(Conf_no))); - if ( result->conf_nos == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_conf_nos; i++) - result->conf_nos[ i ] = fparse_long(fp); - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - log("fparse_conf_list(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - break; - case '*': - if ( result->conf_nos != NULL ) - { - sfree(result->conf_nos); - result->conf_nos = NULL; - } - break; - default: - log("fparse_conf_list(): expected '*' or '{' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_conf_list(): expected '*' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - if ( result->conf_nos != NULL ) - { - sfree(result->conf_nos); - result->conf_nos = NULL; - } - } - - if ( result->no_of_conf_nos > 0 ) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - result->type_of_conf = REALLOC(result->type_of_conf, - (result->no_of_conf_nos - * sizeof(Conf_type))); - - if ( result->type_of_conf == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_conf_nos; i++) - if ( fparse_conf_type(fp, &result->type_of_conf[i]) != OK ) - { - return FAILURE; - } - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - log("fparse_conf_list(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - break; - case '*': - if ( result->type_of_conf != NULL ) - { - sfree(result->type_of_conf); - result->type_of_conf = NULL; - } - break; - default: - log("fparse_conf_list(): expected '*' or '+' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_conf_list(): expected '*' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - if ( result->type_of_conf != NULL ) - { - sfree(result->type_of_conf); - result->type_of_conf = NULL; - } - } - return OK; -} - - -extern Success -fparse_mark_list(FILE *fp, - Mark_list *result) -{ - int i; - - result->no_of_marks = fparse_long(fp); - - if ( result->no_of_marks > 0 ) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - result->marks = REALLOC(result->marks, - (result->no_of_marks - * sizeof(Mark))); - - if ( result->marks == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_marks; i++) - if ( fparse_mark(fp, &result->marks[ i ] ) != OK ) - { - return FAILURE; - } - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - log("fparse_mark_list(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - break; - - case '*': - if ( result->marks != NULL ) - { - sfree(result->marks); - result->marks = NULL; - } - break; - - default: - log("fparse_mark_list(): expected '*' or '{' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_mark_list(): expected '*' at pos %d.\n", ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - if ( result->marks != NULL ) - { - sfree(result->marks); - result->marks = NULL; - } - } - return OK; -} - - -extern Success -fparse_text_stat(FILE *fp, - Text_stat *result) -{ - int i; - int c; - - if ( fparse_long_errors != 0 ) - { - log("fparse_text_stat(): fparse_long_errors == %d on entry. Reset.\n", - fparse_long_errors); - fparse_long_errors = 0; - } - - result->creation_time = fparse_time(fp); - - result->author = fparse_long(fp); - result->file_pos = fparse_long(fp); - result->no_of_lines = fparse_long(fp); - result->no_of_chars = fparse_long(fp); - result->no_of_marks = fparse_long(fp); - result->no_of_misc = fparse_long(fp); - - if ( fparse_long_errors != 0 ) - { - log("fparse_text_stat(): %d fparse_long_errors before 'misc_items'. " - "Reset.\n", - fparse_long_errors); - fparse_long_errors = 0; - return FAILURE; - } - - if ( result->no_of_misc > 0 ) - { - fskipwhite(fp); - switch( c = getc(fp) ) - { - case '{': - result->misc_items = REALLOC(result->misc_items, - (result->no_of_misc - * sizeof(Misc_info))); - - if ( result->misc_items == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_misc; i++) - if ( fparse_misc_info(fp, &result->misc_items[ i ]) != OK ) - return FAILURE; - - fskipwhite(fp); - if ( (c = getc(fp)) != '}' ) - { -#ifdef DISKERR - if ( c == '@' || c == '+' ) - { - ungetc(c, fp); - log("fparse_text_stat(): got '%c' when expecting '}'.\n." - "Character ungetc'd and interpreted as a '}'." - " (pos %d).\n", c, ftell(fp)); - } - else -#endif - { - log("fparse_text_stat(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - - break; - - case '@': - case '+': - ungetc(c, fp); - log("fparse_text_stat(): got '%c' when expecting '{' or '*'\n." - "Character ungetc'd and interpreted as a '*'. (pos %d).\n", - c, ftell(fp)); - /* Fall through */ - case '*': - if ( result->misc_items != NULL ) - { - sfree(result->misc_items); - result->misc_items = NULL; - } - break; - - default: - log("fparse_text_stat(): expected '*' or '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( (c = getc(fp)) != '*' ) - { -#ifdef DISKERR - if ( c == '@' || c == '+' ) - { - ungetc(c, fp); - log("fparse_text_stat(): got '%c' when expecting '*'.\n." - "Character ungetc'd and interpreted as a '*'." - " (pos %d).\n", c, ftell(fp)); - } - else -#endif - { - log("fparse_text_stat(): expected '*' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - - if ( result->misc_items != NULL ) - { - sfree(result->misc_items); - result->misc_items = NULL; - } - } - - fskipwhite(fp); - - return OK; -} - - -extern Success -fparse_text_list(FILE *fp, - Text_list *result) -{ - int i; - - result->first_local_no = fparse_long(fp); - result->no_of_texts = fparse_long(fp); - - if ( result->no_of_texts > 0 ) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - result->texts = REALLOC(result->texts, - (result->no_of_texts - * sizeof(Text_no))); - - if ( result->texts == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_texts; i++) - result->texts[ i ] = fparse_long(fp); - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - log("fparse_text_list(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - break; - - case '*': - if ( result->texts != NULL ) - { - sfree(result->texts); - result->texts = NULL; - } - break; - - default: - log("fparse_text_list(): expected '*' or '{' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_text_list(): expected '*' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - if ( result->texts != NULL ) - { - sfree(result->texts); - result->texts = NULL; - } - } - return OK; -} - - -extern Success -fparse_info(FILE *fp, - Info *result) -{ - result->version = fparse_long(fp); - result->conf_pres_conf = fparse_long(fp); - result->pers_pres_conf = fparse_long(fp); - result->motd_conf = fparse_long(fp); - result->kom_news_conf = fparse_long(fp); - result->motd_of_lyskom = fparse_long(fp); - return OK; -} - - -extern Success -fparse_string(FILE *fp, - String *result) -{ - String_size length; - - length = fparse_long(fp); - - if ( getc(fp) != 'H' ) - { - log("fparse_string(): expected 'H' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - s_size_crea_str(result, length); - - if ( result->string == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - if ( fread(result->string, sizeof(char), result->len, fp) - != result->len ) - { - log("fparse_string(): unexpected eof at pos %d.\n", ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - return OK; -} - -extern Success -fparse_member_list(FILE *fp, - Member_list *result) -{ - int i; - - result->no_of_members = fparse_long(fp); - if ( result->no_of_members > 0 ) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - result->members = REALLOC(result->members, - (result->no_of_members - * sizeof(Member))); - - if ( result->members == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_members; i++) - if ( fparse_member(fp, &result->members[ i ]) != OK ) - { - return FAILURE; - } - - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - log("fparse_member_list(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - break; - - case '*': - if ( result->members != NULL ) - { - sfree(result->members); - result->members = NULL; - } - break; - - default: - log("fparse_member_list(): expected '*' or '{' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_member_list(): expected '*' at pos %d.\n", ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - if ( result->members != NULL ) - { - sfree(result->members); - result->members = NULL; - } - } - return OK; -} - - -extern Success -fparse_member(FILE *fp, - Member *result) -{ - result->member = fparse_long(fp); - return OK; -} - -extern Success -fparse_mark(FILE *fp, - Mark *result) -{ - result->text_no = fparse_long(fp); - result->mark_type = fparse_long(fp); - return OK; -} - - -extern Success -fparse_priv_bits(FILE *fp, - Priv_bits *result) -{ - fskipwhite(fp); - - result->wheel = getc(fp) != '0'; - result->admin = getc(fp) != '0'; - result->statistic = getc(fp) != '0'; - result->create_pers = getc(fp) != '0'; - result->create_conf = getc(fp) != '0'; - result->change_name = getc(fp) != '0'; - result->extern_gw = getc(fp) != '0'; - result->flg8 = getc(fp) != '0'; - result->flg9 = getc(fp) != '0'; - result->flg10 = getc(fp) != '0'; - result->flg11 = getc(fp) != '0'; - result->flg12 = getc(fp) != '0'; - result->flg13 = getc(fp) != '0'; - result->flg14 = getc(fp) != '0'; - result->flg15 = getc(fp) != '0'; - result->flg16 = getc(fp) != '0'; - - return OK; -} - - -extern Success -fparse_personal_flags(FILE *fp, - Personal_flags *result) -{ - fskipwhite(fp); - - result->unread_is_secret = getc(fp) != '0'; - result->flg2 = getc(fp) != '0'; - result->flg3 = getc(fp) != '0'; - result->flg4 = getc(fp) != '0'; - result->flg5 = getc(fp) != '0'; - result->flg6 = getc(fp) != '0'; - result->flg7 = getc(fp) != '0'; - result->flg8 = getc(fp) != '0'; - - return OK; -} - -extern Success -fparse_conf_type(FILE *fp, - Conf_type *result) -{ - fskipwhite(fp); - - result->rd_prot = getc(fp) != '0'; - result->original = getc(fp) != '0'; - result->secret = getc(fp) != '0'; - result->letter_box = getc(fp) != '0'; - - return OK; -} - - -extern Success -fparse_who_info(FILE *fp, - Who_info *result) -{ - result->person = fparse_long(fp); - result->working_conference = fparse_long(fp); - if ( fparse_string(fp, &result->what_am_i_doing) != OK ) - { - log("fparse_who_info(): parse error.\n"); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - return OK; -} - - -extern Success -fparse_who_info_list(FILE *fp, - Who_info_list *result) -{ - int i; - - fskipwhite(fp); - - result->no_of_persons = fparse_long(fp); - - if ( result->no_of_persons > 0 ) - { - fskipwhite(fp); - switch(getc(fp)) - { - case '{': - result->info = REALLOC(result->info, - (result->no_of_persons - * sizeof(Who_info))); - - if ( result->info == NULL ) - { - kom_errno = KOM_OUT_OF_MEMORY; - return FAILURE; - } - - for ( i = 0; i < result->no_of_persons; i++) - { - result->info[ i ] = EMPTY_WHO_INFO; - if ( fparse_who_info(fp, &result->info[ i ]) != OK ) - return FAILURE; - } - - - fskipwhite(fp); - if ( getc(fp) != '}' ) - { - log("fparse_who_info_list(): expected '}' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - break; - - case '*': - if ( result->info != NULL ) - { - sfree(result->info); - result->info = NULL; - } - break; - - default: - log("fparse_who_info_list(): expected '*' or '{' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - } - else - { - fskipwhite(fp); - if ( getc(fp) != '*' ) - { - log("fparse_who_info_list(): expected '*' at pos %d.\n", - ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - if ( result->info != NULL ) - { - sfree(result->info); - result->info = NULL; - } - } - return OK; -} - -extern Success -fparse_misc_info(FILE *fp, - Misc_info *result) -{ - result->type = fparse_long(fp); - - switch(result->type) - { - case recpt: - result->datum.recipient = fparse_long(fp); - break; - - case cc_recpt: - result->datum.cc_recipient = fparse_long(fp); - break; - - case loc_no: - result->datum.local_no = fparse_long(fp); - break; - - case rec_time: - result->datum.received_at = fparse_time(fp); - break; - - case comm_to: - result->datum.comment_to = fparse_long(fp); - break; - - case comm_in: - result->datum.commented_in = fparse_long(fp); - break; - - case footn_to: - result->datum.footnote_to = fparse_long(fp); - break; - - case footn_in: - result->datum.footnoted_in = fparse_long(fp); - break; - - case sent_by: - result->datum.sender = fparse_long(fp); - break; - - case sent_at: - result->datum.sent_at = fparse_time(fp); - break; - - default: - log("fparse_misc_info(): illegal info_type %d at pos %d.\n", - result->type, ftell(fp)); - kom_errno = KOM_SERVER_IS_CRAZY; - return FAILURE; - } - - return OK; -} diff --git a/src/server/ram-parse.h b/src/server/ram-parse.h deleted file mode 100644 index 9e4403c4c..000000000 --- a/src/server/ram-parse.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * $Id: ram-parse.h,v 0.3 1991/09/15 10:29:35 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: ram-parse.h,v 0.3 1991/09/15 10:29:35 linus Exp $ - * - * ram-parse.h -- parse objects from disk file. - */ - -extern u_long -fparse_long(FILE *fp); - -extern void -fskipwhite(FILE *fp); - -extern time_t -fparse_time(FILE *fp); - -extern Success -fparse_conference(FILE *fp, - Conference *result); - - -Success -fparse_person(FILE *fp, - Person *person); - -Success -fparse_membership(FILE *fp, - Membership *mship); - - -extern Success -fparse_membership_list(FILE *fp, - Membership_list *result); - - -extern Success -fparse_conf_list(FILE *fp, - Conf_list_old *result); - - -extern Success -fparse_mark_list(FILE *fp, - Mark_list *result); - - -extern Success -fparse_text_stat(FILE *fp, - Text_stat *result); - - -extern Success -fparse_text_list(FILE *fp, - Text_list *result); - - -extern Success -fparse_info(FILE *fp, - Info *result); - - -extern Success -fparse_string(FILE *fp, - String *result); - -extern Success -fparse_member_list(FILE *fp, - Member_list *result); - - -extern Success -fparse_member(FILE *fp, - Member *result); - -extern Success -fparse_mark(FILE *fp, - Mark *result); - - -extern Success -fparse_priv_bits(FILE *fp, - Priv_bits *result); - - -extern Success -fparse_personal_flags(FILE *fp, - Personal_flags *result); - -extern Success -fparse_conf_type(FILE *fp, - Conf_type *result); - - -extern Success -fparse_who_info(FILE *fp, - Who_info *result); - - -extern Success -fparse_who_info_list(FILE *fp, - Who_info_list *result); - -extern Success -fparse_misc_info(FILE *fp, - Misc_info *result); - diff --git a/src/server/ram-smalloc.c b/src/server/ram-smalloc.c deleted file mode 100644 index 0c3f92fef..000000000 --- a/src/server/ram-smalloc.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * $Id: ram-smalloc.c,v 0.9 1992/05/31 01:19:48 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * smalloc.c - * - * Contains memory allocator routines - * - * TEST VERSION by ceder - */ - -/* - * Define DEBUG_MALLOC to get traces from smalloc, srealloc and sfree. - * Run the resulting lyskomd under gdb. Source trace-mem.gdb. Run - * M-x resolve-trace (from handle-malloc-dump.el) on the resulting output. - */ -/* #define DEBUG_MALLOC */ - -static char *rcsid = "$Id: ram-smalloc.c,v 0.9 1992/05/31 01:19:48 ceder Exp $"; - - -#include <stdio.h> -#include <stdarg.h> -#include <sys/types.h> -#include <malloc.h> -#include <stdlib.h> -#include <server/smalloc.h> -#include "lyskomd.h" -#include "log.h" -#include "exp.h" - -static int no_of_allocated_blocks = 0; - -#ifdef DEBUG_MALLOC -static void -trace_smalloc(size_t size, - void *result) -{ - printf("smalloc:\nArg: 0x%lx\nRes: 0x%lx\n", (long)size, (long)result); - printf("==== end ====\n"); -} -#endif - -/* - * "safe" malloc. Handles the case when malloc returns NULL. - * smalloc cannot fail. - */ -EXPORT void * -smalloc(size_t size) -{ - unsigned int *p; - - p = (unsigned int *) malloc(size + 2*sizeof(unsigned int) + 2); - if (p == NULL) - restart_kom("Can't allocate %lu bytes.\n", (u_long)size); - - ++no_of_allocated_blocks; - - *p++ = SMALLOC_MAGIC_ALLOC; - *p++ = size; - ((unsigned char *) p)[size] = 0x89; - ((unsigned char *) p)[size+1] = 0xA7; - -#ifdef DEBUG_MALLOC - trace_smalloc(size, p); -#endif - - return (void *) p; -} - -#ifdef DEBUG_MALLOC -static void -trace_free(void *block) -{ - printf("sfree:\nArg: 0x%lx\n", (long)block); - printf("==== end ====\n"); -} -#endif - -EXPORT void -sfree(void * ptr) /* it is legal to sfree a NULL pointer */ -{ - unsigned int *ip; - -#if 0 - if ( ptr == NULL) - log("SFREE: Freeing a NULL pointer - should be bad! /pen\n"); -#endif - - if ( ptr != NULL ) - { -#ifdef DEBUG_MALLOC - trace_free(ptr); -#endif - ip = (unsigned int *) ptr; - ip -= 2; - switch (*ip) - { - case SMALLOC_MAGIC_ALLOC: - if (((unsigned char *) (ip+2))[ip[1]] != 0x89 || - ((unsigned char *) (ip+2))[ip[1]+1] != 0xA7) - restart_kom("SFREE: Buffer overflow, bsize = %ul\n", ip[1]); - --no_of_allocated_blocks; - *ip = SMALLOC_MAGIC_FREE; - free( ip ); - break; - - case SMALLOC_MAGIC_FREE: - restart_kom("SFREE: Trying to free already freed block\n"); - - default: - restart_kom("SFREE: Illegal magic number\n"); - } - } -} - -#ifdef DEBUG_MALLOC -static void -trace_srealloc(size_t size, - void *arg, - void *result) -{ - printf("srealloc:\nSize: 0x%lx\nArg: 0x%lx\nRes: 0x%lx\n", - (long)size, (long)arg, (long)result); - printf("==== end ====\n"); -} -#endif -EXPORT void * -srealloc(void * ptr, size_t size) /* Never fails. It is legal to */ -{ /* realloc the NULL ptr. */ - unsigned int * ip; - unsigned int * new_ptr; - - if ( ptr == NULL ) - return smalloc(size); - - ip = (unsigned int *) ptr; - ip -= 2; - switch (*ip) - { - case SMALLOC_MAGIC_ALLOC: - break; - - case SMALLOC_MAGIC_FREE: - restart_kom("SREALLOC: Trying to realloc freed block\n"); - - default: - restart_kom("SREALLOC: Illegal magic number\n"); - } - - if (((unsigned char *) (ip+2))[ip[1]] != 0x89 || - ((unsigned char *) (ip+2))[ip[1]+1] != 0xA7) - restart_kom("SREALLOC: Buffer overflow, osize = %ul, nsize = %ul\n", - ip[1], size); - - *ip = SMALLOC_MAGIC_FREE; - if ( (new_ptr = (unsigned int *) realloc((void *) ip, - size+2*sizeof(unsigned int)+2) ) == NULL ) - { - restart_kom("Out of memory - can't realloc. ptr = %d size = %d. ", - (int)ptr, size); - } - - *new_ptr++ = SMALLOC_MAGIC_ALLOC; - *new_ptr++ = size; - - ((unsigned char *) new_ptr)[size] = 0x89; - ((unsigned char *) new_ptr)[size+1] = 0xA7; - -#ifdef DEBUG_MALLOC - trace_srealloc(size, ptr, new_ptr); -#endif - - return (void *) new_ptr; -} - - -/* - * Allocate temporary memory, which is automatically freed after this - * atomic call. - */ - -static void **tmp_alloc_table = NULL; -static int tmp_alloc_table_size = 0; /* Size */ -static int tmp_alloc_table_use = 0; /* Used size */ - -EXPORT void * -tmp_alloc(u_long size) -{ - if ( tmp_alloc_table_size <= tmp_alloc_table_use ) - { - /* Need to increas table. */ - tmp_alloc_table = srealloc (tmp_alloc_table, - ((++tmp_alloc_table_size) - * sizeof (void *))); - } - - return (tmp_alloc_table[ tmp_alloc_table_use++ ] - = smalloc (size)); -} - - -/* - * Free all core which is allocated with tmp_alloc(). This is called from - * end_of_atomic(). - */ -EXPORT void -free_tmp(void) -{ - int i; - - for ( i = 0; i < tmp_alloc_table_use; i++ ) - { - sfree ( tmp_alloc_table[ i ] ); - tmp_alloc_table[ i ] = NULL; - } - - tmp_alloc_table_use = 0; -} - -EXPORT void -free_all_tmp(void) -{ - free_tmp(); - sfree( tmp_alloc_table ); - tmp_alloc_table = NULL; - tmp_alloc_table_size = 0; -} - -EXPORT void -dump_smalloc_counts(FILE *stat_file) -{ - fprintf(stat_file, "---ram-smalloc.c:\n" - "\tAllocated blocks (grand total): %d\n", - no_of_allocated_blocks); -} diff --git a/src/server/ramkomd.c b/src/server/ramkomd.c deleted file mode 100644 index f3a0c40d0..000000000 --- a/src/server/ramkomd.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * $Id: ramkomd.c,v 0.30 1992/06/10 01:37:39 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * Detta {r serverns huvudprogram. Det kommer f|rhoppningsvis bli st|rre - * {n det {r just nu... - * - * Created by Willf|r 31/3-90 - * - * It has grown! /ceder - */ - -static char *rcsid = "$Id: ramkomd.c,v 0.30 1992/06/10 01:37:39 ceder Exp $"; - - -#include <m-config.h> -#include "getopt.h" -#include <stdlib.h> -#include <signal.h> -#include <stdio.h> -#include <ctype.h> -#include <netdb.h> -#include <string.h> -#include <locale.h> /* Not all machines have locale.h - for those - that don't have it we supply an empty - <locale.h>. gcc -M tries to include files, - even if they are #ifdef'd out. */ -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/param.h> -#include <time.h> -#include <sys/resource.h> -#include <netinet/in.h> -#include <unistd.h> -#include <errno.h> - -#include "s-string.h" -#include <kom-types.h> -#include "string-malloc.h" -#include "isc-malloc.h" -#include <kom-errno.h> -#include "internal-services.h" -#include "lyskomd.h" -#include "isc-interface.h" -#include <server/smalloc.h> -#include "cache.h" -#include "log.h" -#include "com.h" -#include "connections.h" -#include "config.h" -#include "exp.h" -#include "memory.h" -#include "internal-connections.h" - -Kom_err kom_errno; -u_long err_stat; -Bool send_async_messages = TRUE; - - -#ifdef DEBUG -int buglevel = 0; -Bool never_save = FALSE; -#endif - - - -EXPORT char datafilename[BUFSIZ]; /* Full pathname to the database file */ -EXPORT char backupfilename[BUFSIZ]; /* Full pathname to the backup file */ -EXPORT char textfilename[BUFSIZ]; /* Full pathname to the text file. */ -EXPORT char statisticfile[BUFSIZ]; /* Dito to statistics file. */ -EXPORT char pidfile[BUFSIZ]; /* Dito pid-file. */ -INTERNAL char memusefile[BUFSIZ]; /* Memory usage file. */ - -static char ip_client_port[80]; /* Port to listen to for clients */ -static char ip_mux_port[80]; /* Port to listen to for mux:es */ - -int num_ip_client_port=0; /* Numeric representation of the above. */ -int num_ip_mux_port=0; /* -"- */ - -static IscSession *listen_client = NULL; /* ISC listen identifier */ -static IscSession *listen_mux = NULL; /* -"- */ - - -static char *dbase_dir = NULL; /* Directory where database resides */ - -static void -dump_exit_statistics(void); - -static void -server_init( char * client_port, char * mux_port) -{ - IscConfig config; - IscAddress *isc_adr = NULL; - - /* - ** Setup some parameters here - */ - config.version = 1005; - config.master.version = 1001; - config.master.memfn.alloc = &isc_malloc_wrapper; - config.master.memfn.realloc = &isc_realloc_wrapper; - config.master.memfn.free = &isc_free_wrapper; - config.master.abortfn = NULL; /* Use default abort function. */ - config.session.version = 1001; - config.session.max.msgsize = -1; /* Use default sizes. */ - config.session.max.queuedsize = -1; - config.session.max.dequeuelen = -1; - config.session.max.openretries = -1; - config.session.max.backlog = -1; - - kom_server_mcb = isc_initialize(&config); - if ( kom_server_mcb == NULL ) - restart_kom("server_init: can't isc_initialize()\n"); - - listen_client = isc_listentcp(kom_server_mcb, NULL, client_port); - if (listen_client == NULL) - restart_kom("server_init: can't isc_listentcp(CLIENT)\n"); - - isc_adr = isc_getladdress (listen_client); - if (isc_adr == NULL) - restart_kom("server_init(): can't isc_getladdress (listen_client)\n"); - - num_ip_client_port = isc_getportnum (isc_adr); - isc_freeaddress (isc_adr); - - listen_mux = isc_listentcp (kom_server_mcb, NULL, mux_port); - if (listen_mux == NULL) - restart_kom("server_init: can't isc_listentcp(MUX)\n"); - - isc_adr = isc_getladdress (listen_mux); - if (isc_adr == NULL) - restart_kom("server_init(): can't isc_getladdress (listen_mux)\n"); - - num_ip_mux_port = isc_getportnum (isc_adr); - isc_freeaddress (isc_adr); - - log("Listening for clients on %d and muxes on %d.\n", - num_ip_client_port, num_ip_mux_port); - - /* - * Ignore SIGPIPE, which the server gets if it tries to write to a - * socket and the client has died. The server will anyhow handle - * this situation correct. - */ - signal(SIGPIPE, SIG_IGN); -} - -static void -init_data_base(const char *dbase_dir) -{ - String a = EMPTY_STRING, b = EMPTY_STRING, c = EMPTY_STRING, - d = EMPTY_STRING; - - if (dbase_dir == NULL) - dbase_dir = DEFAULT_DBASE_DIR; - - sprintf(datafilename, "%s/%s", dbase_dir, DATAFILE_NAME); - sprintf(backupfilename, "%s/%s", dbase_dir, BACKUPFILE_NAME); - sprintf(textfilename, "%s/%s", dbase_dir, TEXTFILE_NAME); - sprintf(statisticfile, "%s/%s", dbase_dir, STATISTIC_NAME); - sprintf(pidfile, "%s/%s", dbase_dir, PID_NAME); - sprintf(memusefile, "%s/%s", dbase_dir, MEMUSE_NAME); - - log("Database = %s\n", datafilename); - log("Backup = %s\n", backupfilename); - - if ( init_cache() == FAILURE ) - { - log ( "Setting up first four conferences.\n"); - - if ( s_crea_str(&a, "Presentation (av nya) m|ten") != OK - || s_crea_str(&b, "Presentation (av nya) medlemmar") != OK - || s_crea_str(&c, "Lappar (p}) d|rren") != OK - || s_crea_str(&d, "Nyheter om LysKOM") != OK) - { - restart_kom("init_data_base: can't create strings\n"); - } - - if ( ! ( do_create_conf(a, 0, 0, 0, NULL_CONF_TYPE) - && do_create_conf(b, 0, 0, 0, NULL_CONF_TYPE) - && do_create_conf(c, 0, 0, 0, NULL_CONF_TYPE) - && do_create_conf(d, 0, 0, 0, NULL_CONF_TYPE))) - { - restart_kom("init_data_base: Kan ej skapa m|ten\n"); - } - - s_clear(&a); - s_clear(&b); - s_clear(&c); - s_clear(&d); - } -} - -static void -sighandler_hup (int sig) -{ - log ("Signal HUP received. Shutting down server.\n"); - go_and_die = TRUE; -} - -static void -sighandler_quit (int sig) -{ - log ("Signal QUIT received - syncing...\n"); - cache_sync_all(); - log ("Dumping core now.\n"); - abort(); -} - -static void -sighandler_usr1 (int sig) -{ - do_sync_db = TRUE; -} - -static void -sighandler_usr2 (int sig) -{ - int child; - extern int fork(void); - - log ("Signal USR2 received - will dump core now. (Check that child dies.)\n"); - if ((child = fork()) == 0) - { - abort(); - log ("Abort() failed!!!"); - exit(1); - } - else if (child < 0) - { - log ("Couldn't fork.\n"); - } - else - { - wait (NULL); - } -} - -static void -save_pid(void) -{ - FILE *fp; - - if ( (fp = fopen(pidfile, "w")) == NULL ) - return; - - fprintf(fp, "%d", getpid()); - fclose(fp); -} - -/* Stop complaint from gcc 2.0 about "no previous prototype for `main'". */ -int main(int argc, char **argv); - -int -main (int argc, - char **argv) -{ - int i; - - log("*** Version %d (process %d) started.\n", -#include "version.incl" - , getpid()); - -#ifdef HAVE_LOCALE - if (setlocale(LC_CTYPE, "iso_8859_1") == NULL) - { - perror("setlocale"); - exit(1); - } -#endif - -#ifdef HAVE_GETDTABLESIZE - MAX_NO_OF_CONNECTIONS = getdtablesize() - PROTECTED_FDS; -#endif - /* If we don't have getdtablesize MAX_NO_OF_CONNECTIONS is - set at compile time. */ - -#ifdef ENCRYPT_PASSWORDS - srand(time(NULL) + getpid()); -#endif - - s_set_storage_management(string_malloc, string_realloc, string_free); - - - strcpy(ip_client_port, DEFAULT_CLIENT_SERVICE); - strcpy(ip_mux_port, DEFAULT_MUX_SERVICE); - - for (i = 1; i < argc && argv[i][0] == '-'; i++) - switch (argv[i][1]) - { - case 'd': - buglevel++; - break; - - case 'q': - never_save = TRUE; - break; - - case 'D': /* Database directory */ - dbase_dir = argv[i]+2; - break; - - case 'p': /* TCP/IP port number for clients */ - strcpy(ip_client_port, argv[i]+2); - break; - - case 'P': /* TCP/IP port number for MUXes */ - strcpy(ip_mux_port, argv[i]+2); - break; - - case 'a': - send_async_messages = FALSE; - break; - - default: - restart_kom("usage: %s [-d] [-q] [-Ddir] [-pport] [-Pmuxport]" - " [-a]\n", argv[0]); - } - - if (i < argc) - { - restart_kom("usage: %s [-d] [-q] [-Ddir] [-pport] [-Pmuxport]" - " [-a]\n", argv[0]); - } - - signal(SIGHUP, sighandler_hup); - signal(SIGQUIT, sighandler_quit); - signal(SIGUSR1, sighandler_usr1); - signal(SIGUSR2, sighandler_usr2); - - server_init(ip_client_port, ip_mux_port); - init_data_base(dbase_dir); - save_pid(); - - toploop(); - - logout_all_clients(); - isc_shutdown(kom_server_mcb); - cache_sync_all(); - - dump_exit_statistics(); - - log("%s terminated normally.\n", argv[0]); - - return 0; -} - -static void -dump_exit_statistics(void) -{ - FILE *stat_file; - time_t now; - - time(&now); - stat_file = fopen(memusefile, "a"); - - if ( stat_file == NULL ) - restart_kom("Can't open file to save memory usage to.\n"); - - fprintf(stat_file, "\nLysKOM Server going down at %s\n", ctime(&now)); - - dump_cache_stats (stat_file); - - free_all_tmp(); - free_all_cache(); - - dump_smalloc_counts(stat_file); - dump_alloc_counts(stat_file); - dump_cache_mem_usage(stat_file); - dump_string_alloc_counts(stat_file); - dump_allocated_connections(stat_file); - dump_isc_alloc_counts(stat_file); - fclose (stat_file); -} - -void -restart_kom(const char * format, ...) -{ - va_list AP; - char pathname[MAXPATHLEN]; - char *getwd(char *pathname); /* +++ should be in sys/param.h */ - - va_start(AP, format); - logv(format, AP); - va_end(AP); - - log("Previous message is fatal. Will dump core now.\n"); - if ( getwd(pathname) == NULL ) - log("getwd failed: %s\n", pathname); - else - log("Search for the core in %s\n", pathname); - - abort(); -} diff --git a/src/server/realloc.gdb b/src/server/realloc.gdb deleted file mode 100644 index 8dcf250d3..000000000 --- a/src/server/realloc.gdb +++ /dev/null @@ -1,14 +0,0 @@ -commands -silent -echo --- srealloc ---\n -echo Arg: -print size -echo Val: -print new_ptr -echo Old: -print ptr -echo \n -bt -echo =========\n -cont -end diff --git a/src/server/rfc931.c b/src/server/rfc931.c deleted file mode 100644 index 63e103c07..000000000 --- a/src/server/rfc931.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * $Id: rfc931.c,v 1.2 1992/04/01 20:32:03 ceder Exp $ - * Copyright (C) 1991 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. - */ - -/* - * This function retrieves the real user that owns the TCP/IP link - * that is connecting via the IscSession "scb". The returned string - * points to static data which is overwritten on the next call. - * - * Link with "-lauthuser". - */ - -#include <stddef.h> -#include "isc-interface.h" -#include <m-config.h> -#include "rfc931.h" -#include <authuser.h> - -#ifdef RFC_931 - -char * -get_real_username(IscSession *scb) -{ - unsigned long inlocal; - unsigned long inremote; - unsigned short local; - unsigned short remote; - - - if (auth_fd2(scb->fd, &inlocal, &inremote, - &local, &remote) == -1) - return NULL; - - return auth_tcpuser2(inlocal, inremote, local, remote); -} -#endif diff --git a/src/server/rfc931.h b/src/server/rfc931.h deleted file mode 100644 index 5e1380430..000000000 --- a/src/server/rfc931.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * $Id: rfc931.h,v 1.1 1992/03/31 21:51:34 ceder Exp $ - * Copyright (C) 1991 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. - */ - -char *get_real_username(IscSession *scb); diff --git a/src/server/send-async.c b/src/server/send-async.c deleted file mode 100644 index d2c1293b3..000000000 --- a/src/server/send-async.c +++ /dev/null @@ -1,422 +0,0 @@ -/* - * $Id: send-async.c,v 0.4 1991/12/16 16:43:56 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * send-async.c -- Send messages about events to all connected clients. - * - * Written by Per Cederqvist 1990-07-22--23 - */ - -static char *rcsid = "$Id: send-async.c,v 0.4 1991/12/16 16:43:56 ceder Exp $"; - - -#include <stdio.h> -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "async.h" -#include "manipulate.h" -#include "com.h" -#include "connections.h" -#include "send-async.h" -#include "prot-a-send-async.h" -#include "prot-a-output.h" -#include "log.h" -#include "internal-connections.h" - - -extern Bool send_async_messages; - - -void -async_new_text(struct connection *cptr, - Text_no text_no, - Text_stat *text_s) -{ - if (!send_async_messages) - return; - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_new_text(cptr, text_no, text_s); - break; - default: - restart_kom("async_new_text(): bad protocol.\n"); - break; - } -} - - - - -void -async_i_am_on(Who_info info) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0 ) - { - cptr = get_conn_by_number(i); - - switch(cptr->protocol) - { - case 0: /* Not yet logged on. */ - break; - case 'A': - prot_a_async_i_am_on(cptr, info); - break; - default: - restart_kom("async_i_am_on(): bad protocol.\n"); - break; - } - } -} - - -void -async_i_am_off(Pers_no pers_no) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0 ) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_i_am_off(): cptr == NULL\n"); - return; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_i_am_off(cptr, pers_no); - break; - default: - restart_kom("async_i_am_off(): bad protocol.\n"); - break; - } - } -} - -void -async_logout(Pers_no pers_no, - Session_no session_no) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_logout(): cptr == NULL\n"); - return; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_logout(cptr, pers_no, session_no); - break; - default: - restart_kom("async_logout(): bad protocol.\n"); - break; - } - } -} - - - -void -async_new_name(Conf_no conf_no, - const String old_name, - const String new_name) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_new_name(): cptr == NULL\n"); - return; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_new_name(cptr, conf_no, old_name, new_name); - break; - - default: - restart_kom("async_new_name(): bad protocol.\n"); - break; - } - } -} - - - - -#if 0 -conf_deleted -conf_created -#endif - -void -async_sync_db(void) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0 ) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_sync_db(): cptr == NULL\n"); - return; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_sync_db(cptr); - break; - default: - restart_kom("async_sync_db(): bad protocol.\n"); - break; - } - } -} - - -extern void -async_forced_leave_conf (struct connection *cptr, - Conf_no conf_no) -{ - if (!send_async_messages) - return; - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_forced_leave_conf(cptr, conf_no); - break; - default: - restart_kom("async_forced_leave_conf(): bad protocol.\n"); - break; - } -} - -void -async_login(Pers_no pers_no, - int client_no) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_login(): cptr == NULL\n"); - return; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_login(cptr, pers_no, client_no); - break; - - default: - restart_kom("async_login(): bad protocol.\n"); - break; - } - } -} - -void -async_broadcast(Pers_no pers_no, - String message) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_broadcast(): cptr == NULL\n"); - return; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_broadcast(cptr, pers_no, message); - break; - - default: - restart_kom("async_broadcast(): bad protocol.\n"); - break; - } - } -} - - -void -async_rejected_connection(void) -{ - Connection *cptr; - Session_no i = 0; - - if (!send_async_messages) - return; - - while ( (i = traverse_connections(i)) != 0) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_rejected_connections(): cptr == NULL\n"); - return; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - prot_a_async_rejected_connection(cptr); - break; - - default: - restart_kom("async_rejected_connection(): bad protocol.\n"); - break; - } - } -} - - -/* - * Returns failure if no message was sent. - */ -Success -async_send_message(Pers_no recipient, - Pers_no sender, - String message) -{ - Connection *cptr; - Session_no i = 0; - Success retval = FAILURE; - - if (!send_async_messages) - return FAILURE; - - while ( (i = traverse_connections(i)) != 0) - { - cptr = get_conn_by_number(i); - - if ( cptr == NULL ) - { - log("async_send_message(): cptr == NULL\n"); - return FAILURE; - } - - switch(cptr->protocol) - { - case 0: - break; - case 'A': - if ( recipient == 0 || - (recipient == cptr->pers_no && recipient != 0 )) - { - prot_a_async_send_message(cptr, recipient, sender, message); - retval = OK; - } - break; - - default: - restart_kom("async_send_message(): bad protocol.\n"); - break; - } - } - - return retval; -} diff --git a/src/server/send-async.h b/src/server/send-async.h deleted file mode 100644 index 1233bd0df..000000000 --- a/src/server/send-async.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * $Id: send-async.h,v 0.4 1991/12/16 16:43:54 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: send-async.h,v 0.4 1991/12/16 16:43:54 ceder Exp $ - * - */ -extern void -async_new_text(Connection *cptr, - Text_no text_no, - Text_stat *text_s); - -extern void -async_i_am_on(Who_info info); - -extern void -async_i_am_off(Pers_no person); - -extern void -async_logout(Pers_no pers_no, - Session_no session_no); - -extern void -async_new_name(Conf_no conf_no, - const String old_name, - const String new_name); - -extern void -async_sync_db(void); - - -extern void -async_forced_leave_conf (Connection *cptr, - Conf_no conf_no); - - -extern void -async_login(Pers_no pers_no, - int client_no); - -extern void -async_broadcast(Pers_no pers_no, - String message); - -extern void -async_rejected_connection(void); - -extern Success -async_send_message(Pers_no recipient, - Pers_no sender, - String message); diff --git a/src/server/server-config.c b/src/server/server-config.c deleted file mode 100644 index dbe7ca3cc..000000000 --- a/src/server/server-config.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * $Id: server-config.c,v 0.18 1992/06/11 19:16:16 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * config.c - * - * This is in a .c file to make it possible to change a value without having - * to recompile the entire server. - */ - -#include <config.h> -#include <m-config.h> - -static char *rcsid = "$Id: server-config.c,v 0.18 1992/06/11 19:16:16 ceder Exp $"; - - - -/* Where to save things. These are used by lyskomd and dbck. */ - -/* - * DEFAULT_DBASE_DIR can be overriden by giving -Ddir to lyskomd or dbck. - */ - -const char * DEFAULT_DBASE_DIR = "/usr/lyskom"; - -/* - * Note: if you change any of the following three names you will have - * to change the name of the real files in db-nocrypt/db/ also. - */ -const char *DATAFILE_NAME = "db/lyskomd-data"; -const char *BACKUPFILE_NAME = "db/lyskomd-backup"; -const char *TEXTFILE_NAME = "db/lyskomd-texts"; - -const char *STATISTIC_NAME = "etc/lyskomd-log"; -const char *PID_NAME = "etc/pid"; -const char *MEMUSE_NAME = "etc/memory-usage"; - -/* Communications */ - -const char * DEFAULT_CLIENT_SERVICE = "lyskom"; /* Can be number! */ -const char * DEFAULT_MUX_SERVICE = "lyskom-mux"; /* Can be number! */ - -/* - * The following should always be true: - * 0 <= SYNCTIMEOUT <= GARBTIMEOUT <= TIMEOUT - * Times in milliseconds. - */ -const int TIMEOUT = 120000; /* Timeout to select() when totally idle. - This shouldn't be too small, since - the various intervals below are - currently only checked this often. +++ */ -const int GARBTIMEOUT = 100; /* Timeout to select() when garbing texts - but not syncing. */ -const int SYNCTIMEOUT = 0; /* Timeout to select() when syncing. */ - -/* Times in minutes. */ -const int GARB_INTERVAL = 60*24; /* Minutes between deletion of - expired texts. */ -const int SYNC_INTERVAL = 30; /* Minutes between sync. */ -const int SYNC_RETRY_INTERVAL = 5; /* 5 = Wait 5 minutes and retry after - an error while writing to disk. */ - -/* String limits */ - -const int CONF_NAME_LEN = 60; /* Conference (and Person) name */ -const int PWD_LEN = 128; /* Password. It is not guaranteed that all - chars are significant. */ -const int WHAT_DO_LEN = 60; /* what_am_i_doing */ -const int USERNAME_LEN = 128; /* Max login-id from clients */ -const int TEXT_LEN =131072;/* Max len of a text. */ -const int BROADCAST_LEN = 1024; /* Max len of a broadcast message */ - -/* Text_stat limits */ - -const int MAX_MARKS_PERSON = 2048; /* Max marks per person */ -const int MAX_MARKS_TEXT = 1024; /* Max marks per text */ -const int MAX_RECIPIENTS = 256; /* Max recipients/cc_recipients per text */ -const int MAX_COMM = 128; /* Max number of comments to a text */ -const int MAX_FOOT = 32; /* Max number of footnotes to a text */ -const int MAX_CREA_MISC = 512; /* Sum of recipients, cc_recipients, comm_to - * and footn_to must not exceed MAX_CREA_MISC - * when the text is created. */ - -/* - * Size of the cache. This tells us how many clean objects of each - * type to hold. Since all dirty items are also held in core, the - * actual size of the cache is bigger. - */ - -const int CACHE_CONFERENCES = 20; -const int CACHE_PERSONS = 20; -const int CACHE_TEXT_STATS = 20; - -/* - * Some other limits - */ - -/* - * MAX_NO_OF_CONNECTIONS must be small enough. Each connection takes one - * file descriptor, and it is important that there are a few descriptors - * left so that it is possible to save the data base. lyskomd might crash - * if this number is too big and that many connectionattempts are made - * simultaneously. - * - * The following descriptors are open by LysKOM: - * stdin, stdout, stderr (stdin and stdout could probably be closed. - * The log() function prints to stderr.) - * TEXTFILE_NAME (always open) - * DATAFILE_NAME (often open) - * STATISTIC_NAME (open after a SIGUSR1) - * Thus, the max number of connections is the number of available file - * descriptors minus six. This has not been fully tested for a long - * while, so we subtract eight just to be on the safe side. That still - * gives 56 simultaneous users on a sun4, and that is enough for the - * time beeing. (If you need more connections you can ran a mux. Send - * mail to kom@lysator.liu.se for more info.) - */ - -#ifdef HAVE_GETDTABLESIZE -int MAX_NO_OF_CONNECTIONS = 0; /* Initialized by main(). */ -#else -const int MAX_NO_OF_CONNECTIONS = (MAX_OPEN_FD - PROTECTED_FDS); -#endif - - -const int MARK_AS_READ_CHUNK = 128; /* You can't mark more than this many - * texts as read in one call. */ - -/* - * Max number of nested super_confs a message will be forwarded before - * the server gives up. - */ -const int MAX_SUPER_CONF_LOOP = 17; - - -const int DEFAULT_NICE = 77; /* Number of days a text normally lives. */ - - - -/* Max entries in the per-client transmit queue */ -const int MAXQUEUEDSIZE = 300; - -/* Max entries in the per-client transmit queue to send at any one time */ -const int MAXDEQUEUELEN = 10; - -/* What is whitespace? */ -const unsigned char *WHITESPACE = (const unsigned char *)" \t\f\n\r"; diff --git a/src/server/session.c b/src/server/session.c deleted file mode 100644 index 7529e7fbb..000000000 --- a/src/server/session.c +++ /dev/null @@ -1,660 +0,0 @@ -/* - * $Id: session.c,v 0.12 1992/04/14 17:18:33 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * session.c - * - * Session control and miscellaneous. - */ - -static char *rcsid = "$Id: session.c,v 0.12 1992/04/14 17:18:33 ceder Exp $"; - - -#include <time.h> -#include <stdlib.h> -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "manipulate.h" -#include "cache.h" -#include "com.h" -#include "connections.h" -#include "send-async.h" -#include <server/smalloc.h> -#include "log.h" -#include <kom-errno.h> -#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, connection->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, connection->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. - */ - -extern void -leave_conf(void) -{ - Membership * mship; - - if (active_connection->cwc != 0 ) - { - if ((mship = locate_membership( active_connection->cwc, ACT_P )) - != NULL ) - { - time(&mship->last_time_read); - mark_person_as_changed (active_connection->pers_no); - } - else - { - log("ERROR: leave_conf(): Can't find membership of cwc.\n"); - } - - cached_unlock_conf( active_connection->cwc ); - active_connection->cwc = 0; - } -} - -/* - * Log in as user pers_no. If ACTPERS is a supervisor of pers_no the login - * will succeed regardless of the passwd. An logout() will automatically - * be performed if ACTPERS is logged in. - */ -extern Success -login_old (Pers_no pers_no, - const String passwd) -{ - Person *pers_p; - - GET_P_STAT(pers_p, pers_no, FAILURE); - -#if 0 - if ( !logins_allowed && !pers_p->privileges.wheel) - { - kom_errno = KOM_LOGIN_DISALLOWED; - return FAILURE; - } -#endif - - if ( !is_supervisor(pers_no, NULL, ACTPERS, ACT_P) - && chk_passwd(pers_p->pwd, passwd) == FAILURE ) - { - kom_errno = KOM_PWD; - return FAILURE; - } - - logout(); /*+++ How many tries are allowed before disconnection? */ - - active_connection->invisible = FALSE; - - ACTPERS = pers_no; - ACT_P = pers_p; - - cached_lock_person(pers_no); - - pers_p->last_login = time(&active_connection->session_start); - ++pers_p->sessions; - - s_strcpy(&pers_p->username, active_connection->username); - - /* A Person should have separate fields for ident_user and hostname. - But for now, we use the syntax username(ident_user)@hostname. */ - - if (!s_empty(active_connection->ident_user)) - { - if ( s_strcat(&pers_p->username, - s_fcrea_str((const unsigned char *)"(")) != OK ) - restart_kom("login: s_strcat (\n"); - - if ( s_strcat(&pers_p->username, active_connection->ident_user) != OK ) - restart_kom("login: s_strcat ident_user\n"); - - if ( s_strcat(&pers_p->username, - s_fcrea_str((const unsigned char *)")")) != OK ) - restart_kom("login: s_strcat )\n"); - } - - if ( s_strcat(&pers_p->username, - s_fcrea_str((const unsigned char *)"@")) != OK ) - restart_kom("prot_a_parse_packet: s_strcat\n"); - - if ( s_strcat(&pers_p->username, active_connection->hostname) != OK ) - restart_kom("prot_a_parse_packet: s_strcat II\n"); - - mark_person_as_changed( pers_no ); - - async_login(ACTPERS, active_connection->session_no); - - return OK; -} - -/* - * Log in as user pers_no. If ACTPERS is a supervisor of pers_no the login - * will succeed regardless of the passwd. An logout() will automatically - * be performed if ACTPERS is logged in. - */ -extern Success -login (Pers_no pers_no, - const String passwd, - Bool invisible) -{ - Person *pers_p; - - GET_P_STAT(pers_p, pers_no, FAILURE); - -#if 0 - if ( !logins_allowed && !pers_p->privileges.wheel) - { - kom_errno = KOM_LOGIN_DISALLOWED; - return FAILURE; - } -#endif - - if ( !is_supervisor(pers_no, NULL, ACTPERS, ACT_P) - && chk_passwd(pers_p->pwd, passwd) == FAILURE ) - { - kom_errno = KOM_PWD; - return FAILURE; - } - - logout(); /*+++ How many tries are allowed before disconnection? */ - - active_connection->invisible = !!invisible; /* Normalize 17. */ - - ACTPERS = pers_no; - ACT_P = pers_p; - - cached_lock_person(pers_no); - - pers_p->last_login = time(&active_connection->session_start); - ++pers_p->sessions; - - s_strcpy(&pers_p->username, active_connection->username); - - /* A Person should have separate fields for ident_user and hostname. - But for now, we use the syntax username(ident_user)@hostname. */ - - if (!s_empty(active_connection->ident_user)) - { - if ( s_strcat(&pers_p->username, - s_fcrea_str((const unsigned char *)"(")) != OK ) - restart_kom("login: s_strcat (\n"); - - if ( s_strcat(&pers_p->username, active_connection->ident_user) != OK ) - restart_kom("login: s_strcat ident_user\n"); - - if ( s_strcat(&pers_p->username, - s_fcrea_str((const unsigned char *)")")) != OK ) - restart_kom("login: s_strcat )\n"); - } - - if ( s_strcat(&pers_p->username, - s_fcrea_str((const unsigned char *)"@")) != OK ) - restart_kom("prot_a_parse_packet: s_strcat\n"); - - if ( s_strcat(&pers_p->username, active_connection->hostname) != OK ) - restart_kom("prot_a_parse_packet: s_strcat II\n"); - - mark_person_as_changed( pers_no ); - - if (!active_connection->invisible) - async_login(ACTPERS, active_connection->session_no); - - return OK; -} - - -/* - * Log out. Does not disconnect the client. The person is also automatically - * logged out if the connection is closed. Takes no action if noone is logged - * in on this line. Never fails. - */ -extern Success -logout( void ) -{ - if ( ACTPERS != 0 ) /* Is he logged in? Then log him out. */ - { - if (!active_connection->invisible) - { - async_i_am_off( ACTPERS ); - async_logout( ACTPERS, active_connection->session_no ); - } - - leave_conf(); - ACT_P->total_time_present += - difftime(time(&ACT_P->last_login), - active_connection->session_start); - - cached_unlock_person( ACTPERS ); - mark_person_as_changed( ACTPERS ); - } - - - s_clear(&active_connection -> what_am_i_doing); - - active_connection->person = NULL; - active_connection->cwc = 0; - active_connection->pers_no = 0; - active_connection->ena_level = 0; - - return OK; -} - - -/* - * Change Conference. - * - * You are not allowed to change to a conference unless you are a - * member in the conference. - * - * You can pepsi(0) to indicate that you are no longer in a certain - * conference. - * - * There are two reasons to use this call: - * 1) Other persons want to know what you are doing. - * 2) When the server checks that you have permission to - * read a certain text it first checks if you current working - * conference is a recipient of the text, since that is a - * cheap test. If that test fails it will have to read in the - * conference structs for the recipients of the text until it - * finds an open one. - * - * In the future the server might read in the conference in advance when - * someone pepsi's to it to allow faster response times. - */ -extern Success -pepsi (Conf_no conference) -{ - Who_info info = EMPTY_WHO_INFO; - - CHK_LOGIN(FAILURE); - if ( conference != 0 ) - { - CHK_EXIST(conference, FAILURE); - - if ( locate_membership( conference, ACT_P) == NULL ) - { - kom_errno = KOM_NOT_MEMBER; - return FAILURE; - } - } - - leave_conf(); - - active_connection->cwc = conference; - if ( conference != 0 ) - cached_lock_conf( conference ); - - if (!active_connection->invisible) - { - info.person = ACTPERS; - info.what_am_i_doing = active_connection->what_am_i_doing; - 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; -} - - -/* - * Tell the server what you are doing. This string is sent to anyone - * who does a 'who_is_on()'. - */ -extern Success -change_what_i_am_doing (String what_am_i_doing) -{ - Who_info info = EMPTY_WHO_INFO; - - if ( s_strlen( what_am_i_doing ) > WHAT_DO_LEN ) - { - s_clear ( &what_am_i_doing ); - kom_errno = KOM_LONG_STR; - return FAILURE; - } - - s_clear ( &active_connection->what_am_i_doing ); - active_connection->what_am_i_doing = what_am_i_doing; - - if (!active_connection->invisible) - { - info.person = ACTPERS; - info.what_am_i_doing = active_connection->what_am_i_doing; - 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. - */ -extern Success -who_is_on( Who_info_list *result ) -{ - Connection *cptr; - int no_of_clients = 0; - int i; - Session_no session; - - cptr = active_connection; - - for ( session = 0; (session = traverse_connections(session)) != 0; ) - { - cptr = get_conn_by_number(session); - - if ( cptr->person != NULL && cptr->invisible == FALSE ) - ++no_of_clients; - } - - result->no_of_persons = no_of_clients; - result->info = tmp_alloc ( no_of_clients * sizeof(Who_info)); - - for ( session = 0, i = 0; - i < no_of_clients && (session = traverse_connections(session)) != 0; ) - { - cptr = get_conn_by_number(session); - - if ( cptr->person != NULL && cptr->invisible == FALSE ) - { - result->info[ i ] = EMPTY_WHO_INFO; - result->info[ i ].person = cptr->pers_no; - result->info[ i ].what_am_i_doing = cptr->what_am_i_doing; - - /* 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. */ - create_oldstyle_username(&result->info[i].username, cptr); - - result->info[ i ].working_conference = cptr->cwc; - result->info[ i ].session_no = cptr->session_no; - ++i; - } - } - - if ( i != no_of_clients ) - log("who_is_on: i == %d, no_of_clients == %d\n", - i, no_of_clients); - - return OK; -} - -/* - * Get info about what all the currently logged in persons are doing. - */ -extern Success -who_is_on_ident( Who_info_ident_list *result ) -{ - Connection *cptr; - int no_of_clients = 0; - int i; - Session_no session; - - cptr = active_connection; - - for ( session = 0; (session = traverse_connections(session)) != 0; ) - { - cptr = get_conn_by_number(session); - - if ( cptr->person != NULL && cptr->invisible == FALSE ) - ++no_of_clients; - } - - result->no_of_persons = no_of_clients; - result->info = tmp_alloc ( no_of_clients * sizeof(Who_info_ident)); - - for ( session = 0, i = 0; - i < no_of_clients && (session = traverse_connections(session)) != 0; ) - { - cptr = get_conn_by_number(session); - - if ( cptr->person != NULL && cptr->invisible == FALSE ) - { - result->info[i] = EMPTY_WHO_INFO_IDENT; - result->info[i].person = cptr->pers_no; - result->info[i].what_am_i_doing = cptr->what_am_i_doing; - result->info[i].username = cptr->username; - result->info[i].hostname = cptr->hostname; - result->info[i].ident_user = cptr->ident_user; - result->info[i].working_conference = cptr->cwc; - result->info[i].session_no = cptr->session_no; - ++i; - } - } - - if ( i != no_of_clients ) - log("who_is_on_ident: i == %d, no_of_clients == %d\n", - i, no_of_clients); - - return OK; -} - - -extern Success -get_session_info (Session_no session_no, - Session_info *result) -{ - Connection *cptr; - - CHK_LOGIN(FAILURE); - - cptr = get_conn_by_number(session_no); - - if ( cptr != NULL ) - { - *result = EMPTY_SESSION_INFO; - result->person = cptr->pers_no; - result->what_am_i_doing = cptr->what_am_i_doing; - result->working_conference = cptr->cwc; - result->session = cptr->session_no; - result->connection_time = cptr->session_start; - result->idle_time = difftime(time(NULL), - cptr->last_request); - - /* Backward compatibility. result->username is free()d in - prot_a_reply() prot-a.c. */ - create_oldstyle_username(&result->username, cptr); - - return OK; - } - else - { - kom_errno = KOM_UNDEF_SESSION; - return FAILURE; - } -} - -extern Success -get_session_info_ident (Session_no session_no, - Session_info_ident *result) -{ - Connection *cptr; - - CHK_LOGIN(FAILURE); - - cptr = get_conn_by_number(session_no); - - if ( cptr != NULL ) - { - *result = EMPTY_SESSION_INFO_IDENT; - result->person = cptr->pers_no; - result->what_am_i_doing = cptr->what_am_i_doing; - result->working_conference = cptr->cwc; - result->session = cptr->session_no; - result->connection_time = cptr->session_start; - result->idle_time = difftime(time(NULL), - cptr->last_request); - result->username = cptr->username; - result->hostname = cptr->hostname; - result->ident_user = cptr->ident_user; - - return OK; - } - else - { - kom_errno = KOM_UNDEF_SESSION; - return FAILURE; - } -} - -extern Success -who_am_i (Session_no *session_no) -{ - *session_no = active_connection->session_no; - return OK; -} - - - -extern Success -disconnect (Session_no session_no) -{ - Connection *cptr; - - if ( session_no != active_connection->session_no ) - CHK_LOGIN(FAILURE); - - cptr = get_conn_by_number(session_no); - - if ( cptr != NULL ) - { - if ( is_supervisor(cptr->pers_no, NULL, ACTPERS, ACT_P) - || session_no == active_connection->session_no ) - { - add_to_kill_list(cptr); - return OK; - } - else - { - kom_errno = KOM_PERM; - return FAILURE; - } - } - else - { - kom_errno = KOM_UNDEF_SESSION; - return FAILURE; - } -} - - -/* Get less info */ -extern Success -who_is_on_old( Who_info_list_old *result ) -{ - Connection *cptr; - int no_of_clients = 0; - int i; - Session_no session = 0; - - - while ( (session = traverse_connections(session)) != 0) - { - cptr = get_conn_by_number(session); - - if ( cptr->person != NULL && cptr->invisible == FALSE ) - ++no_of_clients; - } - - result->no_of_persons = no_of_clients; - result->info = tmp_alloc ( no_of_clients * sizeof(Who_info)); - - for (session = 0, i = 0; - i < no_of_clients && (session = traverse_connections(session)) != 0;) - { - cptr = get_conn_by_number(session); - - if ( cptr->person != NULL && cptr->invisible == FALSE ) - { - result->info[ i ] = EMPTY_WHO_INFO_OLD; - result->info[ i ].person = cptr->pers_no; - result->info[ i ].what_am_i_doing = cptr->what_am_i_doing; - result->info[ i ].working_conference = cptr->cwc; - ++i; - } - } - - if ( i != no_of_clients ) - log("who_is_on_old: i == %d, no_of_clients == %d\n", - i, no_of_clients); - - return OK; -} - -/* - * Ask the server what it thinks the time is. - */ -extern Success -get_time( time_t *clock ) -{ - time(clock); - - return OK; -} - - - -/* - * Set ena_level. 0 means don't use any privileges. /// - */ -extern Success -enable (u_char ena_level) -{ - CHK_LOGIN(FAILURE); - active_connection->ena_level = ena_level; - return OK; -} diff --git a/src/server/simple-cache.c b/src/server/simple-cache.c deleted file mode 100644 index 48f49960b..000000000 --- a/src/server/simple-cache.c +++ /dev/null @@ -1,2131 +0,0 @@ -/* - * $Id: simple-cache.c,v 0.23 1992/06/11 19:16:47 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * This module contains some simple simulations of the routines in - * cache.c. - * - * Extracted from ram-cache.c and rewritten by ceder. - * - * New database format with texts in their own file by Inge Wallin. - * - * New save algorithm by ceder. - */ - -static char *rcsid = "$Id: simple-cache.c,v 0.23 1992/06/11 19:16:47 ceder Exp $"; - - - -/* - * Possible improvements: +++ - * When there are consecutive items in file A that shall be copied - * to file B, copy them in one transfer (up to a certain limit). - * - * In pre_sync: compute size of, and allocate disk space for file B. - */ - -/* - * All functions that can fail sets kom_errno to a suitable value - * if they fail. - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <sys/file.h> -#include <unistd.h> -#include <errno.h> - -#include <kom-errno.h> -#include <kom-types.h> -#include "s-collat-tabs.h" -#include <server/smalloc.h> -#include <parser.h> -#include "cache.h" -#include <debug.h> -#include "lyskomd.h" -#include "ram-parse.h" -#include "log.h" -#include "com.h" -#include "isc-interface.h" -#include "ram-output.h" -#include "connections.h" -#include "prot-a-output.h" -#include "send-async.h" -#include "memory.h" -#include "exp.h" - -#include "tmp-limits.h" -#include "cache-node.h" -#include "disk-cache.h" -static Small_conf * small_conf_arr[ MAX_CONF ]; -static Cache_node_mcb * pers_mcb; -static Cache_node_mcb * conf_mcb; -static int next_free_num = 1; - -static Cache_node_mcb * text_mcb; -static int next_text_num = 1; - -/* Defined in ramkomd.c */ -extern char datafilename[BUFSIZ]; -extern char backupfilename[BUFSIZ]; -extern char textfilename[BUFSIZ]; - -/* - * The elements in the following lists with same index refers to the same - * conference. - */ -static int no_of_match_info; -EXPORT Matching_info *match_table = NULL; -EXPORT Conf_no *conf_table = NULL; /* Used in conference.c. */ - - -static FILE *text_file= NULL; -static FILE *file_a = NULL; /* Current file. */ -static FILE *file_b = NULL; /* File under construction. */ - -/* - * Four state variables for the background save. - */ -static enum { - sync_save_conf, - sync_save_pers, - sync_save_text, - sync_error, - sync_wait, - sync_ready -} sync_state; - -static long sync_next; - -static Conf_no highest_conf_no; -static Text_no highest_text_no; - -BUGDECL; - - -/* Macros */ - -#define TRACE2(format, arg) if ( buglevel > 2 ) printf(format, arg) -#define TRACE1(format) if ( buglevel > 2 ) printf(format) -#define TRACESTR(str) if ( buglevel > 2 ) s_puts(str) - - -static Person * -read_person(FILE *fp, - long pos, - long size) -{ - Person *p; - - p = alloc_person(); - fseek(fp, pos+1, SEEK_SET); /* Skip '+' */ - if ( fparse_person(fp, p) != OK ) - { - free_person(p); - return NULL; - } - else - return p; -} - - - -static Conference * -read_conference(FILE *fp, - long pos, - long size) -{ - Conference *c; - - c = alloc_conference(); - fseek(fp, pos+1, SEEK_SET); /* Skip '+' */ - if ( fparse_conference(fp, c) != OK ) - { - free_conference(c); - return NULL; - } - else - return c; -} - - -static Text_stat * -read_text_stat(FILE *fp, - long pos, - long size) -{ - Text_stat *t; - - t = alloc_text_stat(); - fseek(fp, pos+1, SEEK_SET); /* Skip '+' */ - if ( fparse_text_stat(fp, t) != OK ) - { - free_text_stat(t); - return NULL; - } - else - return t; -} - -static void -pers_set_mru(Pers_no pers_no) -{ - set_mru(pers_mcb, pers_no); -} - -static void -text_set_mru(Text_no text_no) -{ - set_mru(text_mcb, text_no); -} - -static void -conf_set_mru(Conf_no conf_no) -{ - set_mru(conf_mcb, conf_no); -} - -static Cache_node * -get_pers_node(Pers_no pers_no) -{ - if ( pers_no >= next_free_num ) - return NULL; - - return get_cache_node(pers_mcb, pers_no); -} - -static void -unlink_text_lru (Cache_node *node) -{ - unlink_lru (node, &text_mcb->lru, &text_mcb->mru); -} - -static void -unlink_conf_lru (Cache_node *node) -{ - unlink_lru (node, &conf_mcb->lru, &conf_mcb->mru); -} - -static void -unlink_pers_lru (Cache_node *node) -{ - unlink_lru (node, &pers_mcb->lru, &pers_mcb->mru); -} - -static Cache_node * -get_conf_node(Conf_no conf_no) -{ - if ( conf_no >= next_free_num ) - return NULL; - - return get_cache_node(conf_mcb, conf_no); -} - -static Cache_node * -get_text_node(Text_no text_no) -{ - if ( text_no >= next_text_num ) - return NULL; - - return get_cache_node(text_mcb, text_no); -} - - -/* - * Name caching routines - */ - -/* - * change_name changes the cached conference name. It is only called when - * a conference name is changed or a conference is deleted. - */ -void -cached_change_name( Conf_no name_num, - String new_name ) -{ - if ( name_num < 1 || name_num >= next_free_num ) - restart_kom("cached_change_name(%d, ----): next_free_num==%d", - name_num, next_free_num); - - s_clear( &small_conf_arr[name_num]->name ); - s_strcpy( &small_conf_arr[name_num]->name, new_name); - build_matching_info(); -} - - -extern Conf_type -cached_get_conf_type (Conf_no conf_no) -{ - if ( conf_no < 1 || conf_no >= next_free_num ) - restart_kom("cached_get_conf_type(%d): next_free_num==%d", - conf_no, next_free_num); - - if ( small_conf_arr [ conf_no ] == NULL ) - restart_kom("cached_get_conf_type(%d): conference does not exist.\n", - conf_no); - - return small_conf_arr [ conf_no ]->type; -} - - - -/* - * Various function calls to tell the cache that something is changed. - */ - -void -mark_person_as_changed(Pers_no pers_no) -{ - Cache_node *node; - - node = get_pers_node(pers_no); - - TRACE2("Person %d is changed\n", pers_no); - if ( node == NULL || node->s.exists == 0) - restart_kom("mark_person_as_changed(%d): nonexistent.\n", pers_no); - - node->s.dirty = 1; - pers_set_mru( pers_no ); -} - -/* - * Mark the conference as dirty, so that it will be written to - * the disk. - * - * Also update all fields in the Small_conf except then name, so that - * they are always current. - * - * NOTE: You must call cached_change_name when the name changes. - * It is not necessary to call cached_change_name after - * cached_create_conf. - */ - -void -mark_conference_as_changed(Conf_no conf_no) -{ - Cache_node *node; - Conference *conf_c; - - node = get_conf_node (conf_no); - - TRACE2("Conf. %d is changed\n", conf_no); - if ( node == NULL || node->s.exists == 0) - restart_kom("mark_conference_as_changed(%d): nonexistent.\n", conf_no); - - node->s.dirty = 1; - conf_set_mru( conf_no ); - - conf_c = (Conference *) node->ptr; - - small_conf_arr[ conf_no ]->highest_local_no - = (conf_c->texts.first_local_no - 1 + conf_c->texts.no_of_texts ); - - small_conf_arr[ conf_no ]->nice = conf_c->nice; - small_conf_arr[ conf_no ]->type = conf_c->type; -} - -void -mark_text_as_changed( Text_no text_no ) -{ - Cache_node *node; - - node = get_text_node (text_no); - - TRACE2("Text %d is changed.\n", text_no); - if ( text_no < 1 || text_no >= next_text_num - || node == NULL || node->s.exists == 0) - { - restart_kom("mark_text_as_changed(%d): nonexistent.\n", text_no); - } - - node->s.dirty = 1; - text_set_mru (text_no); -} - - - -/* - * Person-related calls - */ - - -extern Success -cached_create_person( Pers_no person ) -{ - Cache_node *node; - - TRACE2("Person %d is being created.\n", person); - - if ( person < 1 || person >= next_free_num ) - { - restart_kom("cached_create_person(%d): next_free_num == %d.\n", - person, next_free_num); - } - - if ( get_pers_node(person) != NULL ) - { - restart_kom("cached_create_person(%d): Person existed.\n", - person); - } - - create_cache_node (pers_mcb, person); - node = get_pers_node (person); - - if ( node == NULL ) - restart_kom("cached_create_person(): couldn't get cache_node.\n"); - - node->ptr = alloc_person(); - node->s.dirty = 1; - node->s.exists = 1; - pers_set_mru( person ); - return OK; -} - - -extern Person * -cached_get_person_stat( Pers_no person ) -{ - Cache_node *node; - - TRACE2("cached_get_person_stat %d\n", person); - - if ( person == 0 ) - { - kom_errno = KOM_CONF_ZERO; - return NULL; - } - - if ( person >= next_free_num ) - { - kom_errno = KOM_UNDEF_PERS; - return NULL; - } - - node = get_pers_node (person); - - if ( node == NULL || node->s.exists == 0 ) - { - kom_errno = KOM_UNDEF_PERS; - return NULL; - } - - if ( node->ptr != NULL ) - { - pers_set_mru( person ); - ++pers_mcb->hits; - return node->ptr; - } - - if ( node->snap_shot != NULL ) - { - node->ptr = copy_person (node->snap_shot); - pers_set_mru (person); - ++pers_mcb->hits; - return node->ptr; - } - - node->ptr = read_person(file_a, node->pos, node->size); - - ++pers_mcb->misses; - pers_set_mru (person); - return node->ptr; -} - - -/* - * Conference-related calls - */ - - -static int no_of_allocated_small_confs = 0; - -static void -free_small_conf (Small_conf *sc) -{ - if ( sc != NULL ) - { - --no_of_allocated_small_confs; - s_clear ( &sc->name ); - sfree (sc); - } -} - - -static Small_conf * -alloc_small_conf(void) -{ - Small_conf *s; - s = smalloc(sizeof(Small_conf)); - *s = EMPTY_SMALL_CONF; - ++no_of_allocated_small_confs; - - return s; -} - - -/* - * Create a conference. - * - * Set up a Conference and cache the name in the small_conf_array. - */ -extern Conf_no -cached_create_conf (String name) -{ - Conference * conf_c; - Conf_no conf_no; - Cache_node *node; - - TRACE1("cached_create_conf( "); - TRACESTR(name); - TRACE1(" )\n"); - - if ( next_free_num >= MAX_CONF ) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - return 0; - } - - conf_no = next_free_num++; - - create_cache_node (conf_mcb, conf_no); - node = get_conf_node (conf_no); - - if ( node == NULL ) - restart_kom("cached_create_conf(): failed to allocate cache_node.\n"); - - node->s.exists = 1; - node->s.dirty = 1; - node->ptr = conf_c = alloc_conference(); - conf_set_mru(conf_no); - - zero_init_cache_node (pers_mcb, conf_no); - small_conf_arr[ conf_no ] = alloc_small_conf(); - - conf_c->name = EMPTY_STRING; - s_strcpy(&conf_c->name, name); - cached_change_name( conf_no, name); - - TRACE2("Created conference number %d\n", conf_no); - - return conf_no; -} - - -extern Success -cached_delete_conf( Conf_no conf ) -{ - Cache_node *node; - - if ( conf == 0 ) - { - kom_errno = KOM_CONF_ZERO; - return FAILURE; - } - - if ( conf >= next_free_num ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - node = get_conf_node (conf); - - if ( node == NULL || node->s.exists == 0 ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - if ( node->lock_cnt > 0 ) - log("WNG: cached_delete_conf(%d): lock_cnt === %d\n", - conf, node->lock_cnt); - - free_conference(node->ptr); - node->ptr = NULL; - node->s.exists = 0; - - return OK; -} - -Success -cached_delete_person(Pers_no pers) -{ - Cache_node *node; - - if ( pers == 0 ) - { - kom_errno = KOM_CONF_ZERO; - return FAILURE; - } - - if ( pers >= next_free_num ) - { - log("cached_delete_person(%lu): next_free_num == %lu\n", - (u_long)pers, (u_long)next_free_num); - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - node = get_pers_node (pers); - - if ( pers >= next_free_num || node == NULL || node->s.exists == 0 ) - { - log("cached_delete_person(): attempt to" - " delete non-existing person.\n"); - kom_errno = KOM_UNDEF_PERS; - return FAILURE; - } - - if ( node->lock_cnt > 0 ) - log("cached_delete_pers(%lu): lock_cnt === %lu\n", - (u_long)pers, (u_long)node->lock_cnt); - - free_person (node->ptr); - node->ptr = NULL; - node->s.exists = 0; - return OK; -} - -Success -cached_delete_text(Text_no text) -{ - Cache_node *node; - - if ( text == 0 ) - { - kom_errno = KOM_TEXT_ZERO; - return FAILURE; - } - - node = get_text_node (text); - - if ( text >= next_text_num || node == NULL - || node->s.exists == 0 ) - { - log("cached_delete_text(): attempt to" - " delete non-existing text %d.\n", text); - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( node->lock_cnt > 0 ) - log("cached_delete_text(%d): lock_cnt === %d\n", - text, node->lock_cnt); - - - free_text_stat(node->ptr); - node->ptr = NULL; - node->s.exists = 0; - - return OK; -} - - -extern Conference * -cached_get_conf_stat (Conf_no conf_no) -{ - Cache_node *node; - - TRACE2("cached_get_conf_stat %d\n", conf_no); - - if ( conf_no == 0 ) - { - kom_errno = KOM_CONF_ZERO; - return NULL; - } - - node = get_conf_node (conf_no); - - if ( conf_no >= next_free_num || node == NULL || node->s.exists == 0 ) - { - kom_errno = KOM_UNDEF_CONF; - return NULL; - } - - if ( node->ptr != NULL ) - { - conf_set_mru (conf_no); - ++conf_mcb->hits; - return node->ptr; - } - - if ( node->snap_shot != NULL ) - { - node->ptr = copy_conf (node->snap_shot); - conf_set_mru (conf_no); - ++conf_mcb->hits; - return node->ptr; - } - - node->ptr = read_conference(file_a, node->pos, node->size); - ++conf_mcb->misses; - - conf_set_mru (conf_no); - return node->ptr; -} - -/* - * Return TRUE if conf_no exists. - */ -Bool -cached_conf_exists(Conf_no conf_no) -{ - Cache_node *node; - - if (conf_no == 0 || conf_no >= next_free_num ) - return FALSE; - - node = get_conf_node (conf_no); - - return node != NULL && node->s.exists != 0; -} - - -/* - * Calls to handle texts - */ - -/* - * +++ Should return Success. - */ -extern String -cached_get_text( Text_no text ) -{ - String the_string; - Text_stat *t_stat; - - TRACE2("cached_get_text %d\n", text); - - if ( (t_stat = cached_get_text_stat (text)) == NULL ) - return EMPTY_STRING; - else - { - the_string.string = tmp_alloc( t_stat->no_of_chars ); - the_string.len = t_stat->no_of_chars; - fseek(text_file, t_stat->file_pos, SEEK_SET); - - if ( fread(the_string.string, sizeof(char), the_string.len, text_file) - != the_string.len ) - { - log("WARNING: cached_get_text: " - "couldn't read enough characters of text %d\n", - text); - return EMPTY_STRING; - } - - return the_string; - } -} - - -extern Text_stat * /* NULL on error */ -cached_get_text_stat( Text_no text ) -{ - Cache_node *node; - - TRACE2("cached_get_text_stat(%d); next_text_num == ", text); - TRACE2("%d\n", next_text_num); - - if ( text == 0 ) - { - kom_errno = KOM_TEXT_ZERO; - return NULL; - } - - node = get_text_node (text); - - if ( text >= next_text_num || node == NULL || node->s.exists == 0 ) - { - TRACE1("cached_get_text_stat: no such text.\n"); - kom_errno = KOM_NO_SUCH_TEXT; - return NULL; - } - - if ( node->ptr != NULL ) - { - TRACE1("Found in ptr.\n"); - text_set_mru( text ); - ++text_mcb->hits; - return node->ptr; - } - - if ( node->snap_shot != NULL ) - { - TRACE1("Found in snap_shot\n"); - node->ptr = copy_text_stat(node->snap_shot); - text_set_mru (text); - ++text_mcb->hits; - return node->ptr; - } - - TRACE1("Found in file A.\n"); - node->ptr = read_text_stat(file_a, node->pos, node->size); - - text_set_mru (text); - ++text_mcb->misses; - return node->ptr; -} - - - -/* - * The text is set up with an empty misc-field. The misc field is - * then initialized by create_text. - */ - -extern Text_no -cached_create_text( String message) -{ - Text_no tno; - Cache_node *node; - - tno = next_text_num++; - - TRACE2("cached_create_text (len=%d)\n", message.len); - - if ( tno >= MAX_TEXT ) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - next_text_num = MAX_TEXT; - - return 0; - } - - create_cache_node(text_mcb, tno); - node = get_text_node (tno); - - if ( node == NULL ) - restart_kom("cached_create_text(): could'nt create cache-node.\n"); - - node->s.exists = 1; - node->s.dirty = 1; - node->ptr = alloc_text_stat(); - ((Text_stat *)node->ptr)->no_of_misc = 0; - ((Text_stat *)node->ptr)->misc_items = NULL; - ((Text_stat *)node->ptr)->no_of_marks = 0; - ((Text_stat *)node->ptr)->no_of_lines = 0; - ((Text_stat *)node->ptr)->no_of_chars = 0; - fseek(text_file, 0, SEEK_END); - ((Text_stat *)node->ptr)->file_pos = ftell(text_file); - - text_set_mru( tno ); - - if ( fwrite(message.string, sizeof(char), message.len, text_file) - != message.len ) { - log("WARNING: cached_create_text: Couldn't write the text %d\n", - tno); - } - - fflush(text_file); - - TRACE2("cached_create_text -> %d\n", tno); - - return tno; -} - - -EXPORT Text_no -traverse_text(Text_no seed) -{ - Cache_node *node; - - seed++; - - while ( seed < next_text_num ) - { - node = get_text_node (seed); - if ( node != NULL && node->s.exists != 0 ) - break; - - seed++; - } - - return (seed >= next_text_num) ? 0 : seed ; -} - -Pers_no -traverse_person(Pers_no seed) -{ - Cache_node *node; - - seed++; - - while ( seed < next_free_num ) - { - node = get_pers_node (seed); - if (node != NULL && node->s.exists != 0 ) - break; - - seed++; - } - - return (seed >= next_free_num) ? 0 : seed ; -} - -Conf_no -traverse_conference(Conf_no seed) -{ - Cache_node *node; - - seed++; - - while ( seed < next_free_num ) - { - node = get_conf_node (seed); - if (node != NULL && node->s.exists != 0 ) - break; - - seed++; - } - - return (seed >= next_free_num) ? 0 : seed ; -} - -extern Garb_nice -cached_get_garb_nice (Conf_no conf_no) -{ - return small_conf_arr [ conf_no ]->nice; -} - - -extern Local_text_no -cached_get_highest_local_no (Conf_no conf_no) -{ - return small_conf_arr[ conf_no ]->highest_local_no; -} - -/* Lock a person struct in memory. Increase a referenc count. */ -void -cached_lock_person(Pers_no pers_no) -{ - Cache_node *node; - - node = get_pers_node(pers_no); - - if ( node == NULL || node->s.exists == 0 ) - restart_kom("cached_lock_person(%d): nonexistent.\n", pers_no); - - if ( node->ptr == NULL ) - { - Person *pers_stat_ptr; - - pers_stat_ptr = cached_get_person_stat( pers_no ); - - if ( pers_stat_ptr == NULL ) - restart_kom("cached_lock_person(%d): couldn't read in person.\n", - pers_no); - - if ( pers_stat_ptr != node->ptr ) - restart_kom("cached_lock_person(%d): pers_stat_ptr == %d, node" - "->ptr == %d.\n", pers_no, pers_stat_ptr, - node->ptr); - } - - node->lock_cnt++; -} - -/* Decrease reference count. If zero, unlock person. */ -void -cached_unlock_person(Pers_no pers_no) -{ - Cache_node *node; - - node = get_pers_node (pers_no); - - if ( node == NULL ) - restart_kom("cached_unlock_person(): couldn't get cache-node.\n"); - - if ( node->lock_cnt <= 0 ) - { - log("cached_unlock_person(%d): lock_cnt == %d.\n", - pers_no, node->lock_cnt); - - node->lock_cnt = 0; - } - else - node->lock_cnt--; -} - - -/* Lock a conf struct in memory. Increase a reference count. */ -void -cached_lock_conf(Conf_no conf_no) -{ - Cache_node *node; - - node = get_conf_node(conf_no); - - if ( node == NULL) - restart_kom("cached_lock_conf(): can't get cache-node.\n"); - - if ( node->s.exists == 0 ) - restart_kom("cached_lock_conf(%d): nonexistent.\n", conf_no); - - if ( node->ptr == NULL ) - { - Conference *conference_ptr; - - conference_ptr = cached_get_conf_stat( conf_no ); - - if ( conference_ptr == NULL ) - restart_kom("cached_lock_conf(%d): couldn't read in conf.\n", - conf_no); - - if ( conference_ptr != node->ptr ) - restart_kom("cached_lock_conf(%d): conference_ptr == %d, node" - "->ptr == %d.\n", conf_no, conference_ptr, - node->ptr); - } - - node->lock_cnt++; -} - -/* Decrease reference count. If zero, unlock conf. */ -void -cached_unlock_conf(Conf_no conf_no) -{ - Cache_node *node; - - node = get_conf_node(conf_no); - if ( node == NULL ) - restart_kom("cached_unlock_conf(): can't get node.\n"); - - if ( node->lock_cnt <= 0 ) - { - log("cached_unlock_conf(%d): lock_cnt == %d.\n", - conf_no, node->lock_cnt); - - node->lock_cnt = 0; - } - else - node->lock_cnt--; -} - - - -/* - * And here comes some functions to deal with lookup_names. - */ - -/* Free the _contents_ of a match_table. The table itself i _not_ freed. */ - -static void -free_match_table(Matching_info *match) -{ - if ( match == NULL ) - return; - - while ( ! s_empty( match->name )) - { - free_tokens( match->tokens ); - /* match->name is not freed since it points into conf_arr[]. */ - - ++match; - } -} - -extern Success -build_matching_info(void) -{ - Conf_no i; - Matching_info *match; - Conf_no *conf; - - free_match_table(match_table); - - match_table = srealloc(match_table, next_free_num * sizeof(Matching_info)); - conf_table = srealloc(conf_table, next_free_num * sizeof(Conf_no)); - - no_of_match_info = 0; - - match = match_table; - conf = conf_table; - - for ( i = 1; i < next_free_num; i++ ) - { - if ( small_conf_arr[ i ] != NULL - && ! s_empty ( small_conf_arr[ i ]->name ) ) - { - match->name = small_conf_arr[ i ]->name; - match->tokens = tokenize(match->name, s_fcrea_str(WHITESPACE)); - match->priority = 7; - *conf = i; - ++match; - ++conf; - ++no_of_match_info; - } - } - - match->name = EMPTY_STRING; - match->tokens = NULL; - match->priority = 0; - *conf = 0; - - return OK; -} - - - -/* Map conference name to number */ -extern Success -cached_lookup_name(const String name, - Conf_list_old *result) -{ - Parse_info tmp; - int i; - - tmp = parse(name, match_table, FALSE, FALSE, - s_fcrea_str(WHITESPACE), DEFAULT_COLLAT_TAB); - - if ( tmp.no_of_matches == -1 ) - return FAILURE; - - if ( tmp.no_of_matches == 1 && tmp.indexes[ 0 ] == -1 ) - { - /* Return the entire list. */ - result->no_of_conf_nos = no_of_match_info; - result->conf_nos = tmp_alloc(no_of_match_info * sizeof(Conf_no)); - result->type_of_conf = tmp_alloc(no_of_match_info * sizeof(Conf_type)); - - for ( i = 0; i < no_of_match_info; i++ ) - { - result->conf_nos[ i ] = conf_table[ i ]; - result->type_of_conf[ i ] = small_conf_arr[ conf_table[i] ]->type; - } - } - else - { - /* Return the conferences whose conf_nos are in indexes[]. */ - result->no_of_conf_nos = tmp.no_of_matches; - result->conf_nos = tmp_alloc(tmp.no_of_matches * sizeof(Conf_no)); - result->type_of_conf = tmp_alloc(tmp.no_of_matches - * sizeof(Conf_type)); - - for ( i = 0; i < tmp.no_of_matches; i++ ) - { - result->conf_nos[ i ] = conf_table[ tmp.indexes[ i ] ]; - result->type_of_conf[ i ] - = small_conf_arr[ conf_table[ tmp.indexes[ i ] ] ]->type; - } - } - sfree(tmp.indexes); - return OK; -} - - -static Bool -is_clean(const char *fn) -{ - FILE *fp; - - if ( (fp = fopen(fn, "rb")) == NULL ) - return FALSE; - - if ( getc(fp) == 'C' && getc(fp) == 'L' && getc(fp) == 'E' - && getc(fp) == 'A' && getc(fp) == 'N' ) - { - fclose(fp); - return TRUE; - } - else - { - fclose(fp); - return FALSE; - } -} - - -static void -pre_sync(void) -{ - long i; - Cache_node *node; - - async_sync_db(); - - /* Mark up what to save.*/ - - BUG(("Sync starting\n")); - - highest_text_no = next_text_num; - highest_conf_no = next_free_num; - - for ( i = 1; i < highest_conf_no; i++ ) - { - node = get_conf_node(i); - - if ( node != NULL ) - { - node->s.exists_b = node->s.exists; - - if ( node->s.dirty != 0 && node->s.exists != 0) - { - free_conference(node->snap_shot); - - if ( node->lock_cnt == 0 ) - { - unlink_conf_lru(node); - node->snap_shot = node->ptr; - node->ptr = NULL; - } - else - { - node->snap_shot = copy_conf(node->ptr); - } - - node->s.dirty = 0; - } - } - } - - for ( i = 1; i < highest_conf_no; i++ ) - { - node = get_pers_node(i); - - if ( node != NULL ) - { - node->s.exists_b = node->s.exists; - - if ( node->s.dirty != 0 && node->s.exists != 0) - { - free_person(node->snap_shot); - - if ( node->lock_cnt == 0 ) - { - unlink_pers_lru(node); - node->snap_shot = node->ptr; - node->ptr = NULL; - } - else - { - node->snap_shot - = copy_person(node->ptr); - } - - node->s.dirty = 0; - } - } - } - - for ( i = 1; i < highest_text_no; i++ ) - { - node = get_text_node(i); - - if ( node != NULL ) - { - node->s.exists_b = node->s.exists; - - if ( node->s.dirty != 0 && node->s.exists != 0) - { - free_text_stat(node->snap_shot); - - if ( node->lock_cnt == 0 ) - { - unlink_text_lru(node); - node->snap_shot = node->ptr; - node->ptr = NULL; - } - else - { - node->snap_shot - = copy_text_stat(node->ptr); - } - - node->s.dirty = 0; - } - } - } - - /* All marking is done. Now open file B. */ - - if ( is_clean(datafilename) ) - { - if ( rename(datafilename, backupfilename) != 0 ) - restart_kom("pre_sync: can't backup.\n"); - } - else - log("pre_sync: datafile not clean. No backup taken.\n"); - - if ( file_b != NULL ) - { - log("pre_sync: Save in progress aborted.\n"); - fclose(file_b); - } - - if ( (file_b=fopen(datafilename, "wb") ) == NULL ) - { - log("WARNING: pre_sync: can't open file to save in.\n"); - sync_state = sync_wait; - - return; - } - - fprintf(file_b, "DIRTY\n"); /* DIRTY-FLAG */ - - fprintf(file_b, "%d\n", highest_conf_no); /* NEXT_FREE_NUM */ - sync_state = sync_save_conf; - sync_next = 1; -} - -static void -copy_file(FILE *from, - FILE *to, - long from_pos, - long len) -{ - char *buf; - long result; - - buf = smalloc(len); - if ( fseek(from, from_pos, SEEK_SET) == -1 ) - { - sync_state = sync_error; - log("sync: copy_file(): fseek failed.\n"); - sfree(buf); - return; - } - - if ( (result = fread(buf, 1, len, from)) != len ) - { - log("sync: copy_file(): fread failed.\n" - "from_pos = %d, len = %d, result = %d\n", - from_pos, len, result); - - sync_state = sync_error; - sfree(buf); - return; - } - - if ( fseek(to, 0, SEEK_END) == -1 ) - { - sync_state = sync_error; - log("sync: copy_file(): second fseek failed.\n"); - sfree(buf); - return; - } - - if ( fwrite(buf, 1, len, to) != len ) - { - sync_state = sync_error; - log("sync: copy_file(): fwrite failed.\n"); - sfree(buf); - return; - } - - sfree(buf); -} - -static void -save_one_conf(void) -{ - Cache_node *cn; - - if (sync_next < highest_conf_no) - { - cn = get_conf_node (sync_next); - - if ( cn == NULL ) - { - putc('@', file_b); - putc('\n', file_b); - } - else - { - cn->pos_b = ftell(file_b); - - if ( cn->s.exists_b == 0 ) - putc('@', file_b); - else if ( cn->snap_shot != NULL ) - { - fprintf(file_b, "+ "); - foutput_conference(file_b, cn->snap_shot); - } - else if ( cn->s.dirty == 0 && cn->ptr != NULL ) - { - fprintf(file_b, "+ "); - foutput_conference(file_b, cn->ptr); - } - else - { - copy_file(file_a, file_b, cn->pos, cn->size - 1); - } - - putc('\n', file_b); - cn->size_b = ftell(file_b) - cn->pos_b; - } - sync_next++; - } - else /* All conferences are written. */ - { - sync_next = 1; - sync_state = sync_save_pers; - } -} - -static void -write_pers(FILE *fp, - Person *p) -{ - fprintf(fp, "+ %dH", PASSWD_LEN); - fwrite(p->pwd, PASSWD_LEN, 1, fp); - foutput_person(fp, p); -} - -static void -save_one_pers(void) -{ - Cache_node *cn; - - if (sync_next < highest_conf_no) - { - cn = get_pers_node (sync_next); - - if ( cn == NULL ) - { - putc('@', file_b); - putc('\n', file_b); - } - else - { - cn->pos_b = ftell(file_b); - - if ( cn->s.exists_b == 0 ) - putc('@', file_b); - else if ( cn->snap_shot != NULL ) - { - write_pers(file_b, cn->snap_shot); - } - else if ( cn->s.dirty == 0 && cn->ptr != NULL ) - { - write_pers(file_b, cn->ptr); - } - else - { - copy_file(file_a, file_b, cn->pos, cn->size - 1); - } - - putc('\n', file_b); - cn->size_b = ftell(file_b) - cn->pos_b; - } - sync_next++; - } - else /* All persons are written. */ - { - fprintf(file_b, "%d\n", highest_text_no); /* NEXT_TEXT_NUM */ - sync_next = 1; - sync_state = sync_save_text; - } -} - -static void -post_sync(void) -{ - int i; - Cache_node *node; - - async_sync_db(); - - if ( file_a == NULL ) - log("WARNING: post_sync(): file_a == NULL. This is only normal " - "if this is the first sync ever on this data file.\n"); - else - fclose(file_a); - - if ( ( file_a = fopen(datafilename, "rb") ) == NULL ) - { - log("post_sync: can't open the file I just saved.\n"); - sync_state = sync_wait; - return; - } - - for ( i = 1; i < highest_conf_no; i++ ) - { - node = get_conf_node(i); - if ( node != NULL ) - { - node->pos = node->pos_b; - node->size = node->size_b; - free_conference(node->snap_shot); - node->snap_shot = NULL; - /* +++ Delete if it no longer exists. */ - } - } - - for ( i = 1; i < highest_conf_no; i++ ) - { - node = get_pers_node(i); - if ( node != NULL ) - { - node->pos = node->pos_b; - node->size = node->size_b; - free_person(node->snap_shot); - node->snap_shot = NULL; - /* +++ Delete if it no longer exists. */ - } - } - - for ( i = 1; i < highest_text_no; i++ ) - { - node = get_text_node(i); - if ( node != NULL ) - { - node->pos = node->pos_b; - node->size = node->size_b; - free_text_stat(node->snap_shot); - node->snap_shot = NULL; - /* +++ Delete if it no longer exists. */ - } - } -} - - - -static void -save_one_text(void) -{ - Cache_node *cn; - long offset; - long offset2; - - if (sync_next < highest_text_no) - { - cn = get_text_node(sync_next); - - if ( cn == NULL ) - { - putc('@', file_b); - putc('\n', file_b); - } - else - { - cn->pos_b = ftell(file_b); - - if ( cn->s.exists_b == 0 ) - putc('@', file_b); - else if ( cn->snap_shot != NULL ) - { - fprintf(file_b, "+ "); - foutput_text_stat(file_b, cn->snap_shot); - } - else if ( cn->s.dirty == 0 && cn->ptr != NULL ) - { - fprintf(file_b, "+ "); - foutput_text_stat(file_b, cn->ptr); - } - else - { - copy_file(file_a, file_b, cn->pos, cn->size - 1); - } - - putc('\n', file_b); - cn->size_b = ftell(file_b) - cn->pos_b; - } - sync_next++; - } - else /* All texts are written. */ - { - if ( ferror(file_b) != 0 ) - { - log ("save_one_text(): ferror() detected.\n"); - sync_state = sync_error; - return; - } - - offset = ftell(file_b); /* Make sure that the entire file resides - on disk. This test seems to be necessary. - The data file has been corrupted at least - once. */ - - if (offset == -1) - { - log ("save_one_text(): ftell returned -1.\n"); - sync_state = sync_error; - return; - } - - rewind(file_b); - if ( ferror(file_b) != 0 ) - { - log ("save_one_text(): rewind failed.\n"); - sync_state = sync_error; - return; - } - - fprintf(file_b, "CLEAN"); - - if ( ferror(file_b) != 0 ) - { - log ("save_one_text(): fprintf(CLEAN) failed.\n"); - sync_state = sync_error; - return; - } - - if (fflush(file_b) != 0) - { - log ("save_one_text(): fflush failed.\n"); - sync_state = sync_error; - return; - } - - if ( ferror(file_b) != 0 ) - { - log ("save_one_text(): ferror after fflush failed.\n"); - sync_state = sync_error; - return; - } - - if ( fclose(file_b) != 0 ) - { - file_b = NULL; - - log("Sync: fclose() failed in save_one_text. Deleting " - "file and retrying.\n"); - remove(datafilename); - sync_state = sync_wait; - return; - } - - file_b = fopen(datafilename, "rb"); - if (file_b == NULL) - { - log("save_one_text(): failed to reopen file.\n"); - remove (datafilename); - sync_state = sync_wait; - return; - } - - if (fseek(file_b, 0, SEEK_END) != 0) - { - log("save_one_text(): fseek failed.\n"); - sync_state = sync_error; - return; - } - - offset2 = ftell (file_b); - if ( offset2 != offset ) - { - log ("save_one_text(): ftell returns different offsets" - "(%l and %l).\n", offset, offset2); - sync_state = sync_error; - return; - } - - fclose (file_b); - file_b = NULL; - - sync_state = sync_ready; - - BUG(("Sync ready\n")); - post_sync(); - } -} - -/* - * Sync_part() should be called often as long as it returns FALSE. - * Sync_part() returns TRUE when everything is written to a file. - * Sync_part() should be called once in a while even when it returns - * TRUE (because sync() checks to see if it is time to start yet - * another save.) - */ -Bool -sync_part(void) -{ - static time_t last_sync_start = NO_TIME; - - if ( last_sync_start == NO_TIME ) - { - last_sync_start = time(NULL); - sync_state = sync_ready; - } - - switch(sync_state) - { - case sync_save_conf: - save_one_conf(); - break; - - case sync_save_pers: - save_one_pers(); - break; - - case sync_save_text: - save_one_text(); - break; - - case sync_ready: - if ( difftime(time(NULL), last_sync_start) < 60 * SYNC_INTERVAL ) - return TRUE; - - last_sync_start = time(NULL); - - pre_sync(); - break; - - case sync_wait: - if ( difftime(time(NULL), last_sync_start) < 60 * SYNC_RETRY_INTERVAL ) - return TRUE; - - last_sync_start = time(NULL); - - pre_sync(); - break; - - case sync_error: - log("sync: Error saving new file. Discarding file and " - "trying again.\n"); - fclose(file_b); - file_b = NULL; - remove(datafilename); - sync_state = sync_wait; - break; - - default: - restart_kom("sync(): sync_state==%d", sync_state); - } - - if ( file_b != NULL && ferror(file_b) != 0) - sync_state = sync_error; - - return FALSE; -} - - -static void -setup_small_conf(Conf_no conf_no, - Conference *conf_c) -{ - small_conf_arr[ conf_no ] = alloc_small_conf(); - s_strcpy(&small_conf_arr[ conf_no ]->name, conf_c->name); - small_conf_arr[ conf_no ]->type = conf_c->type; - small_conf_arr[ conf_no ]->highest_local_no - = (conf_c->texts.first_local_no - 1 - + conf_c->texts.no_of_texts ); - small_conf_arr[ conf_no ]->nice = conf_c->nice; -} - - - -extern Success -init_cache(void) -{ - int i; - Cache_node *node; - Conference tmp_conf = EMPTY_CONFERENCE; - Person tmp_pers = EMPTY_PERSON; - Text_stat tmp_text = EMPTY_TEXT_STAT; - - pers_mcb = create_cache_node_mcb(100, MAX_CONF); - conf_mcb = create_cache_node_mcb(100, MAX_CONF); - text_mcb = create_cache_node_mcb(100, MAX_TEXT); - - - - if ( (text_file = fopen(textfilename, "a+b")) == NULL ) - { - restart_kom("ERROR: init_cache: can't open text file \"%s\"." - " errno = %d\n", - textfilename, errno); - } - - if ( is_clean(datafilename) ) - { - if ( (file_a = fopen(datafilename, "rb")) == NULL ) - { - log("WARNING: init_cache: can't open datafile.\n"); - return FAILURE; - } - log("MSG: init_cache: using datafile.\n"); - } - else if ( is_clean(backupfilename) ) - { - if ( (file_a = fopen(backupfilename, "rb")) == NULL ) - { - log("WARNING: init_cache: can't open backupfile.\n"); - return FAILURE; - } - log("MSG: init_cache: using backup file.\n"); - } - else - { - log("WARNING: init_cache: can't find old data base.\n"); - return FAILURE; - } - - fseek(file_a, 6, SEEK_SET); /* skip clean/dirty flag. */ - - next_free_num = fparse_long(file_a); /* NEXT_FREE_NUM */ - - for ( i = 1; i < next_free_num; i++ ) /* CONFS */ - { - fskipwhite(file_a); - switch(getc(file_a)) - { - case '@': - zero_init_cache_node(conf_mcb, i); - break; - - case '+': - create_cache_node(conf_mcb, i); - node = get_conf_node(i); - node->s.exists = 1; - - node->pos = ftell(file_a) - 1; /* Don't forget the '+' */ - - if ( fparse_conference(file_a, &tmp_conf) != OK ) - restart_kom("init_cache(): fparse_conference failed. " - "i == %d\n", i); - - node->size = ftell(file_a) - node->pos; - setup_small_conf(i, &tmp_conf); - clear_conference(&tmp_conf); - - break; - } - } - - build_matching_info(); - - for ( i = 1; i < next_free_num; i++ ) /* PERSONS */ - { - fskipwhite(file_a); - switch(getc(file_a)) - { - case '@': - zero_init_cache_node(pers_mcb, i); - break; - - case '+': - create_cache_node(pers_mcb, i); - node = get_pers_node(i); - node->s.exists = 1; - node->pos = ftell(file_a) - 1; /* Don't forget the '+' */ - if ( fparse_person(file_a, &tmp_pers) != OK ) - restart_kom("init_cache: fparse_person failed. i == %d\n", i); - - node->size = ftell(file_a) - node->pos; - clear_person(&tmp_pers); - - break; - } - } - - next_text_num = fparse_long(file_a); /* NEXT_TEXT_NUM */ - - for ( i = 1; i < next_text_num; i++ ) /* TEXT_STATS */ - { - fskipwhite(file_a); - switch(getc(file_a)) - { - case '@': - zero_init_cache_node(text_mcb, i); - break; - - case '+': - create_cache_node(text_mcb, i); - node = get_text_node(i); - node->s.exists = 1; - - node->pos = ftell(file_a) - 1; /* Don't forget the '+' */ - - if ( fparse_text_stat(file_a, &tmp_text) != OK ) - restart_kom("init_cache(): fparse_text_stat failed. i == %d\n", - i); - - node->size = ftell(file_a) - node->pos; - clear_text_stat(&tmp_text); - - break; - } - } - - log("Read %d confs/persons and %d texts\n", - next_free_num, next_text_num); - - return OK; -} - -/* ramkomd compatibility: */ -extern void -cache_sync(void) -{ -} - -extern void -cache_sync_all(void) -{ - pre_sync(); - while ( sync_part() != TRUE ) - ; -} - -void -free_all_cache (void) -{ - int i; - Cache_node *node; - - for ( i = 0; i < next_free_num; i++ ) - { - node = get_conf_node(i); - if ( node != NULL ) - { - if ( node->snap_shot != NULL ) - { - free_conference (node->snap_shot); - node->snap_shot = NULL; - } - - if ( node->ptr != NULL ) - { - free_conference (node->ptr); - node->ptr = NULL; - } - } - - destruct_cache_node (conf_mcb, i); - - node = get_pers_node(i); - if ( node != NULL ) - { - if ( node->snap_shot != NULL ) - { - free_person (node->snap_shot); - node->snap_shot = NULL; - } - - if ( node->ptr != NULL ) - { - free_person (node->ptr); - node->ptr = NULL; - } - } - - destruct_cache_node (pers_mcb, i); - - if ( small_conf_arr[i] != NULL ) - { - free_small_conf (small_conf_arr[i]); - small_conf_arr[i] = NULL; - } - } - - for ( i = 0; i < next_text_num; i++ ) - { - node = get_text_node(i); - if ( node != NULL ) - { - if ( node->snap_shot != NULL ) - { - free_text_stat (node->snap_shot); - node->snap_shot = NULL; - } - - if ( node->ptr != NULL ) - { - free_text_stat (node->ptr); - node->ptr = NULL; - } - } - - destruct_cache_node (text_mcb, i); - } - - free_match_table(match_table); - - free_cache_node_mcb(conf_mcb); - free_cache_node_mcb(text_mcb); - free_cache_node_mcb(pers_mcb); - - sfree (match_table); - sfree (conf_table); -} - - -/* Is it allowed to delete this node from the cache? It is, unless - the node is locked, dirty, or contains a snap-shot. */ - -static Bool -throwable_p(Cache_node *node) -{ - return (node->s.dirty == 0 - && node->snap_shot == NULL - && node->lock_cnt == 0); -} - -static void -limit_pers(void) -{ - Cache_node *node; - int i; - - node = pers_mcb->mru; - - /* Skip first CACHE_PERSONS clean persons. */ - for ( i = 0; node != NULL && i < CACHE_PERSONS; i++ ) - { - while (node != NULL && !throwable_p(node)) - node = node->next; - - if ( node != NULL ) - node = node->next; - } - - /* Delete any remaining clean persons */ - while ( node != NULL ) - { - if (throwable_p(node)) - { - unlink_pers_lru(node); - free_person (node->ptr); - node->ptr = NULL; - /* +++ delete cache-node if non-existent. */ - } - - node = node->next; - } -} - -static void -limit_conf(void) -{ - Cache_node *node; - int i; - - node = conf_mcb->mru; - - /* Skip first CACHE_CONFERENCES clean confs. */ - for ( i = 0; node != NULL && i < CACHE_CONFERENCES; i++ ) - { - while (node != NULL && !throwable_p(node)) - node = node->next; - - if ( node != NULL ) - node = node->next; - } - - /* Delete any remaining clean confs. */ - while ( node != NULL ) - { - if (throwable_p(node)) - { - unlink_conf_lru(node); - free_conference (node->ptr); - node->ptr = NULL; - /* +++ delete if non-existent. */ - } - - node = node->next; - } -} - - -static void -limit_text_stat(void) -{ - Cache_node *node; - int i; - - node = text_mcb->mru; - - /* Skip first CACHE_TEXT_STATS clean text_stats. */ - for ( i = 0; node != NULL && i < CACHE_TEXT_STATS; i++ ) - { - while (node != NULL && !throwable_p(node)) - node = node->next; - - if (node != NULL) - node = node->next; - } - - /* Delete any remaining clean text_stats. */ - while ( node != NULL ) - { - if (throwable_p(node)) - { - unlink_text_lru(node); - free_text_stat (node->ptr); - node->ptr = NULL; - /* +++ delete if non-existent. */ - } - - node = node->next; - } -} - - - -/* - * Limit the number of 'clean' cache entries. - */ -EXPORT void -cache_limit_size(void) -{ - limit_pers(); - limit_conf(); - limit_text_stat(); -} - -EXPORT void -dump_cache_mem_usage(FILE *fp) -{ - fprintf(fp, "---simple-cache.c:\n" - "\tSmall_confs: %d\n", - no_of_allocated_small_confs); -} - - -EXPORT void -dump_cache_stats(FILE *fp) -{ - fprintf(fp, "---simple-cache.c:\n"); - fprintf(fp, - "\tPersons (cache size: %d):\n" - "\t hits: %lu\n" - "\t miss: %lu\n", - CACHE_PERSONS, - pers_mcb->hits, - pers_mcb->misses); - fprintf(fp, - "\tConferences (cache size: %d):\n" - "\t hits: %lu\n" - "\t miss: %lu\n", - CACHE_CONFERENCES, - conf_mcb->hits, - conf_mcb->misses); - fprintf(fp, - "\tText_stats (cache size: %d):\n" - "\t hits: %lu\n" - "\t miss: %lu\n", - CACHE_TEXT_STATS, - text_mcb->hits, - text_mcb->misses); -} - - -EXPORT int -query_next_text_num(void) -{ - return next_text_num; -} diff --git a/src/server/string-malloc.c b/src/server/string-malloc.c deleted file mode 100644 index de3637d20..000000000 --- a/src/server/string-malloc.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * $Id: string-malloc.c,v 0.5 1991/09/15 10:28:55 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * Malloc wrappers for the string package. - * - * These functions call smalloc and also counts - * how many allocated strings there are. - */ - -static char *rcsid = "$Id: string-malloc.c,v 0.5 1991/09/15 10:28:55 linus Exp $"; - - -#include <stdio.h> -#include <stddef.h> -#include <server/smalloc.h> -#include "log.h" -#include "exp.h" -#include "string-malloc.h" - -static int no_of_allocated_blocks = 0; - -EXPORT void * -string_malloc(size_t size) -{ - ++no_of_allocated_blocks; - return smalloc (size); -} - - -EXPORT void -string_free(void * ptr) -{ - --no_of_allocated_blocks; - sfree(ptr); -} - -EXPORT void * -string_realloc (void * ptr, - size_t size) -{ - if ( ptr == NULL ) - return string_malloc (size); - - return srealloc (ptr, size); -} - - -EXPORT void -dump_string_alloc_counts(FILE *stat_file) -{ - fprintf(stat_file, "---" __FILE__ ":\n" - "\tAllocated strings: %d\n", - no_of_allocated_blocks); -} diff --git a/src/server/string-malloc.h b/src/server/string-malloc.h deleted file mode 100644 index c747729c9..000000000 --- a/src/server/string-malloc.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * $Id: string-malloc.h,v 0.3 1991/09/15 10:28:51 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: string-malloc.h,v 0.3 1991/09/15 10:28:51 linus Exp $ - * - * Malloc wrappers for the string package. - * - * These functions call smalloc and also counts - * how many allocated strings there are. - */ - -extern void * -string_malloc(size_t size); - - -extern void -string_free(void * ptr); - -extern void * -string_realloc (void * ptr, - size_t size); - -extern void -dump_string_alloc_counts(FILE *stat_file); diff --git a/src/server/text-garb.c b/src/server/text-garb.c deleted file mode 100644 index fbcdc1c9a..000000000 --- a/src/server/text-garb.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * $Id: text-garb.c,v 0.6 1992/02/26 18:44:57 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * This file contains the functions that deletes old texts. - * - * Author: Per Cederqvist. - */ - -static char *rcsid = "$Id: text-garb.c,v 0.6 1992/02/26 18:44:57 ceder Exp $"; - - -#include <time.h> -#include <kom-types.h> -#include "cache.h" -#include "log.h" -#include "internal-services.h" -#include "lyskomd.h" -#include "text-garb.h" -#include <debug.h> - - -/* - * Delete old texts. - * - * Return value is TRUE if there is nothing more to do right now, - * FALSE if this function should be called again as soon as the - * server has some time over. - */ - -Bool -garb_text(void) -{ - static Text_no last_checked = 0; - static time_t last_start = NO_TIME; - static long deleted_texts = 0; - BUGDECL; - - Text_stat *text_s; - Misc_info *misc; - u_short nmisc; - double age; /* How many seconds is this text? */ - double limit = 24 * 3600; - - if ( last_checked == 0 ) - { - if ( last_start != NO_TIME - && difftime(time(NULL), last_start) < GARB_INTERVAL * 60 ) - { - return TRUE; - } - - log("MSG: garb started.\n"); - time( &last_start ); - } - - last_checked = traverse_text( last_checked ); - - if ( last_checked == 0 ) - { - log("MSG: garb ready. %lu texts deleted.\n", (u_long)deleted_texts); - deleted_texts = 0; - return FALSE; - } - - if ( (text_s = cached_get_text_stat( last_checked )) == NULL ) - { - log("ERROR: garb_text(): Can't get text-stat.\n"); - return FALSE; - } - - age = difftime( time(NULL), text_s->creation_time ); - - if ( text_s->no_of_marks > 0 || age < 24 * 3600 ) - { - return FALSE; - } - - for (nmisc = text_s->no_of_misc, misc = text_s->misc_items; - nmisc > 0; - --nmisc, ++misc ) - { - switch ( misc->type ) - { - case recpt: - if ( cached_conf_exists( misc->datum.recipient ) ) - { - limit = (24 * 3600 * - cached_get_garb_nice( misc->datum.recipient )); - if ( age < limit ) - return FALSE; - } - - break; - - case cc_recpt: - if ( cached_conf_exists( misc->datum.cc_recipient )) - { - limit = ( 24 * 3600 - * cached_get_garb_nice( misc->datum.cc_recipient )); - if ( age < limit ) - return FALSE; - } - - break; - - case comm_to: - case comm_in: - case footn_to: - case footn_in: - limit = 24 * 3600; - break; - - case loc_no: - case rec_time: - case sent_by: - break; - - case sent_at: - if ( difftime ( time(NULL), misc->datum.sent_at ) - < limit ) - { - return FALSE; - } - - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("garb_text(): Illegal misc-item.\n"); -#endif - } - } - - VBUG(("garb_text: deleting %d\n", last_checked)); - do_delete_text ( last_checked, text_s ); - deleted_texts++; - return FALSE; -} - diff --git a/src/server/text-garb.h b/src/server/text-garb.h deleted file mode 100644 index 1ff9da7ef..000000000 --- a/src/server/text-garb.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * $Id: text-garb.h,v 0.3 1991/09/15 10:28:43 linus Exp $ - * Copyright (C) 1991 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. - */ -/* - * $Id: text-garb.h,v 0.3 1991/09/15 10:28:43 linus Exp $ - * - */ -extern Bool -garb_text(void); - diff --git a/src/server/text.c b/src/server/text.c deleted file mode 100644 index 180571a11..000000000 --- a/src/server/text.c +++ /dev/null @@ -1,2380 +0,0 @@ -/* - * $Id: text.c,v 0.17 1992/05/23 18:03:35 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * text.c - * - * All atomic calls that deals with texts. - */ - -static char *rcsid = "$Id: text.c,v 0.17 1992/05/23 18:03:35 ceder Exp $"; - -#include <time.h> -#include <stdlib.h> -#include "lyskomd.h" -#include <kom-types.h> -#include <services.h> -#include "manipulate.h" -#include <kom-errno.h> -#include <server/smalloc.h> -#include "cache.h" -#include "log.h" -#include "minmax.h" -#include <config.h> -#include "com.h" -#include "isc-interface.h" -#include "connections.h" -#include "send-async.h" -#include "admin.h" -#include "internal-connections.h" -#include "internal-services.h" - -/* - * Static functions - */ - - -/* - * Add text_no to the list of texts in a conference. Return the local number - * the text gets in this conference. - */ - -static Local_text_no -add_text_in_conf(Conference * conf_c, - Text_no text_no) -{ - Text_list * t; - - time( & conf_c->last_written ); - - /* Add number last on the text_list */ - t = &(conf_c->texts); - t->texts = srealloc(t->texts, ++(t->no_of_texts) * sizeof(Text_no)); - t->texts[ t->no_of_texts - 1 ] = text_no; - - return t->first_local_no + t->no_of_texts - 1; -} - - -/* - * Set the global text_no of a certain local text_no if that local text_no - * exists in the conf. No action is taken if the local text_no doesn't exist. - * This function is probably only used to set the number to zero when a text - * is deleted. - */ - -static void -set_loc_no (Conference * conf_c, - Local_text_no loc_no, - Text_no text_no) -{ - if ( loc_no < conf_c->texts.first_local_no - || loc_no > conf_c->texts.first_local_no + conf_c->texts.no_of_texts ) - { - return; /* Doesn't exist in conf.stat. */ - } - - conf_c->texts.texts[ loc_no - conf_c->texts.first_local_no ] = text_no; - - return; -} -/* - * Count how many recipients and cc_recipients a text has. - */ - -static int -count_recipients( Text_stat *t_stat ) -{ - int n = 0; - Misc_info * misc; - - for ( misc = t_stat->misc_items; - misc < t_stat->misc_items + t_stat->no_of_misc; misc++ ) - { - if ( misc->type == recpt || misc->type == cc_recpt ) - { - n++; - } - } - - return n; -} - -/* - * Count how many footnotes a text has. - */ - -static int -count_footn( Text_stat *t_stat ) -{ - int n = 0; - Misc_info * misc; - - for ( misc = t_stat->misc_items; - misc < t_stat->misc_items + t_stat->no_of_misc; misc++ ) - { - if ( misc->type == footn_in ) - { - n++; - } - } - - return n; -} - -/* - * Count how many commments a text has. - */ - -static int -count_comment( Text_stat *t_stat ) -{ - int n = 0; - Misc_info * misc; - - for ( misc = t_stat->misc_items; - misc < t_stat->misc_items + t_stat->no_of_misc; misc++ ) - { - if ( misc->type == comm_in ) - { - n++; - } - } - - return n; -} - -/* - * Check if ACTPERS is allowed to read this text. - * Returns TRUE if he is allowed to read it. - */ - - -/* - * Check if CONF_NO is a recipient of the text whose text_stat is given. - */ - -static Bool -is_recipient(Conf_no conf_no, - Text_stat * t_stat) -{ - int i; - - for ( i = 0; i < t_stat->no_of_misc; i++ ) - { - switch( t_stat->misc_items[ i ].type ) - { - case recpt: - if ( t_stat->misc_items[ i ].datum.recipient == conf_no ) - { - return TRUE; - } - break; - - case cc_recpt: - if ( t_stat->misc_items[ i ].datum.cc_recipient == conf_no ) - { - return TRUE; - } - break; - - case rec_time: - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case sent_by: - case sent_at: - case loc_no: - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("is_recipient(): illegal misc_item\n"); -#endif - } - } - - return FALSE; -} - - -/* - * Check if comment is a comment to parent. - */ -static Bool -is_comment_to(Text_no comment, - Text_stat *parent) -{ - int i; - - for ( i = 0; i < parent->no_of_misc; i++ ) - { - switch( parent->misc_items[ i ].type ) - { - case comm_in: - if ( parent->misc_items[ i ].datum.commented_in == comment ) - return TRUE; - break; - default: - break; - } - } - - return FALSE; -} - -/* - * Check if footnote is a footnote to parent. - */ -static Bool -is_footnote_to(Text_no footnote, - Text_stat *parent) -{ - int i; - - for ( i = 0; i < parent->no_of_misc; i++ ) - { - switch( parent->misc_items[ i ].type ) - { - case footn_in: - if ( parent->misc_items[ i ].datum.footnoted_in == footnote ) - return TRUE; - break; - default: - break; - } - } - - return FALSE; -} -/* - * Return the conference which the text goes to. This is normally conf_no, but - * it may be a super_conf. If ACTPERS is not allowed to submit a text to - * conf_no or a super_conf, return 0. - */ -static Conf_no -submit_to(Conf_no conf_no, /* The conference the user is trying to */ - /* submit a text to. */ - Conference * conf_c) /* May be NULL */ -{ - int i; - Access acc; - - CHK_LOGIN(0); - - if ( conf_c == NULL ) - GET_C_STAT(conf_c, conf_no, 0); - - for ( i=0; i < MAX_SUPER_CONF_LOOP; i++) - { - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc <= none ) - return 0; - - if (conf_c->permitted_submitters == 0 - || acc == unlimited - || locate_membership( conf_c->permitted_submitters, ACT_P) != NULL) - { - return conf_no; - } - - - if ((conf_no = conf_c->super_conf) == 0) - return 0; - - GET_C_STAT(conf_c, conf_no, 0); - } - - return 0; -} - - -/* - * Say that FOOTNOTE is a footnote to TEXT. - */ - -static Success -do_add_footnote(Text_no footnote, - Text_no text) -{ - Text_stat *foot_s, *text_s; - - GET_T_STAT(foot_s, footnote, FAILURE); - GET_T_STAT(text_s, text, FAILURE); - - ADD_MISC(foot_s, footn_to, footnote_to, text); - ADD_MISC(text_s, footn_in, footnoted_in, footnote); - - mark_text_as_changed( footnote ); - mark_text_as_changed( text ); - - return OK; -} - - -/* - * Say that COMMENT is a comment to TEXT. - */ - -static Success -do_add_comment(Text_no comment, - Text_no text) -{ - Text_stat *comm_s, *text_s; - - GET_T_STAT(comm_s, comment, FAILURE); - GET_T_STAT(text_s, text, FAILURE); - - ADD_MISC(comm_s, comm_to, comment_to, text); - ADD_MISC(text_s, comm_in, commented_in, comment); - - mark_text_as_changed( comment ); - mark_text_as_changed( text ); - - return OK; -} - - -/* - * Say that RECEIVER is a recipient of TEXT. - */ -static Success -do_add_recpt(Text_no text, - Text_stat * text_s, /* May be NULL */ - Conf_no receiver) -{ - Conference *rece_c; - - if ( text_s == NULL ) - { - GET_T_STAT(text_s, text, FAILURE); - } - - GET_C_STAT(rece_c, receiver, FAILURE); - - ADD_MISC(text_s, recpt, recipient, receiver); - ADD_MISC(text_s, loc_no, local_no, add_text_in_conf(rece_c, text)); - - mark_text_as_changed(text); - mark_conference_as_changed(receiver); - - return OK; -} - - -static Success -do_add_cc_recpt(Text_no new_text, - Text_stat *text_s, /* May be NULL */ - Conf_no receiver) -{ - Conference *rece_c; - - if ( text_s == NULL ) - GET_T_STAT(text_s, new_text, FAILURE); - - GET_C_STAT(rece_c, receiver, FAILURE); - - ADD_MISC(text_s, cc_recpt, cc_recipient, receiver); - ADD_MISC(text_s, loc_no, local_no, add_text_in_conf(rece_c, new_text)); - - mark_text_as_changed( new_text ); - mark_conference_as_changed( receiver ); - - return OK; -} - - -/* - * Return number of lines in a text - */ - -static u_short -count_lines( String str ) -{ - u_short l = 0; - - while ( str.len-- > 0 ) - { - if( *str.string++ == '\n' ) - { - l++; - } - } - - return l; -} - - -/* - * Delete misc_info at location loc. - * If it is a recpt, cc_recpt, comm_to or footn_to delete any - * loc_no, rec_time, sent_by or sent_at that might follow it. - * - * Note that the Misc_info is not reallocated. - */ - -static void -do_delete_misc (u_short * no_of_misc, - Misc_info * misc, - int loc) -{ - int del = 1; /* Number of items to delete. */ - /* Always delete at least one item. */ - Bool ready; - - /* Check range of loc */ - - if ( loc < 0 || loc >= *no_of_misc ) - { - restart_kom("do_delete_misc() - loc out of range"); - } - - ready = FALSE; - - while ( ready == FALSE && loc + del < *no_of_misc ) - { - switch ( misc[ loc + del ].type ) - { - case loc_no: - case rec_time: - case sent_by: - case sent_at: - del++; - break; - - case recpt: - case cc_recpt: - case footn_to: - case footn_in: - case comm_to: - case comm_in: - ready = TRUE; - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("do_delete_misc() - illegal misc"); -#endif - } - } - - *no_of_misc -= del; - - /* Move items beyond the deleted ones. */ - - while ( loc < *no_of_misc ) - { - misc[ loc ] = misc[ loc + del ]; - loc++; - } -} - -/* - * Delete leading zeroes from the text_list. - * Returns TRUE if some zeroes was deleted. - */ -static Bool -adjust_text_list(Text_list *text_list) -{ - u_long zeroes; - u_long i; - - for (zeroes = 0; - zeroes < text_list->no_of_texts && text_list->texts[ zeroes ] == 0; - zeroes++) - ; - - if ( zeroes > 0 ) - { - text_list->no_of_texts -= zeroes; - text_list->first_local_no += zeroes; - - for ( i = 0; i < text_list->no_of_texts; i++) - text_list->texts[ i ] = text_list->texts[ i + zeroes ]; - - text_list->texts = srealloc(text_list->texts, - (text_list->no_of_texts - * sizeof(Text_no))); - } - - return zeroes > 0; -} - - -/* - * Delete a recipient from a text. Does not fail if the recipient doesn't - * exist - that is not an error. - */ -static Success -do_sub_recpt (Text_no text_no, - Text_stat * text_s, /* May be NULL */ - Conf_no conf_no, - Conference * conf_s ) /* May be NULL */ -{ - int i; - - if ( text_s == NULL ) - GET_T_STAT(text_s, text_no, FAILURE); - - if ( conf_s == NULL ) - { - conf_s = cached_get_conf_stat( conf_no ); /* Might still be NULL. */ - } - - for ( i = 0; i < text_s->no_of_misc; i++ ) - { - switch ( text_s->misc_items[ i ].type) - { - case recpt: - if ( text_s->misc_items[ i ].datum.recipient == conf_no ) - { - if ( conf_s != NULL ) - { - /* Only if the conference exists: */ - set_loc_no( conf_s, - text_s->misc_items[ i+1 ].datum.local_no, 0 ); - adjust_text_list (&conf_s->texts); - mark_conference_as_changed (conf_no); - } - - do_delete_misc ( &text_s->no_of_misc, text_s->misc_items, i ); - mark_text_as_changed (text_no); - - return OK; - } - break; - - case cc_recpt: - if ( text_s->misc_items[ i ].datum.cc_recipient == conf_no ) - { - if ( conf_s != NULL ) - { - set_loc_no( conf_s, - text_s->misc_items[ i+1 ].datum.local_no, 0 ); - mark_conference_as_changed( conf_no ); - } - - do_delete_misc( &text_s->no_of_misc, text_s->misc_items, i ); - mark_text_as_changed( text_no ); - - return OK; - } - break; - - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case loc_no: - case rec_time: - case sent_by: - case sent_at: - break; - -#ifndef COMPILE_CHECKS - default: - log(__FILE__ ": do_sub_recpt(): bad misc_item.\n"); - break; -#endif - } - } - - kom_errno = KOM_NOT_RECIPIENT; - return FAILURE; -} - -/* - * Delete the link between comment and comment_to. - */ -static void -do_sub_comment (Text_no comment, /* The comment. */ - Text_stat * text_s, - Text_no comment_to, /* The commented. */ - Text_stat * parent_s ) -{ - int i; - Bool ready; - - if ( text_s == NULL ) - GET_T_STAT(text_s, comment, (void)0); - - if ( parent_s == NULL ) - GET_T_STAT(parent_s, comment_to, (void)0); - - for ( ready = FALSE, i = 0; !ready && i < text_s->no_of_misc; i++ ) - { - switch ( text_s->misc_items[ i ].type) - { - case comm_to: - if ( text_s->misc_items[ i ].datum.comment_to == comment_to ) - { - do_delete_misc( &text_s->no_of_misc, text_s->misc_items, i ); - mark_text_as_changed( comment ); - ready = TRUE; - } - break; - - default: - break; - } - } - - if ( !ready ) - restart_kom("do_sub_comment(): part 1 failed.\n"); - - - for ( ready = FALSE, i = 0; !ready && i < parent_s->no_of_misc; i++ ) - { - switch ( parent_s->misc_items[ i ].type) - { - case comm_in: - if ( parent_s->misc_items[ i ].datum.commented_in == comment ) - { - do_delete_misc (&parent_s->no_of_misc, - parent_s->misc_items, i ); - mark_text_as_changed( comment_to ); - ready = TRUE; - } - break; - - default: - break; - } - } - - if ( !ready ) - restart_kom("do_sub_comment(): part 2 failed.\n"); - - return; -} - - -/* - * Delete the link between footnote and footnote_to. - */ -static void -do_sub_footnote (Text_no footnote, - Text_stat * text_s, - Text_no footnote_to, - Text_stat * parent_s ) -{ - int i; - Bool ready; - - if ( text_s == NULL ) - GET_T_STAT(text_s, footnote, (void)0); - - if ( parent_s == NULL ) - GET_T_STAT(parent_s, footnote_to, (void)0); - - for ( ready = FALSE, i = 0; !ready && i < text_s->no_of_misc; i++ ) - { - switch ( text_s->misc_items[ i ].type) - { - case footn_to: - if ( text_s->misc_items[ i ].datum.footnote_to == footnote_to ) - { - do_delete_misc( &text_s->no_of_misc, text_s->misc_items, i ); - mark_text_as_changed( footnote ); - ready = TRUE; - } - break; - - default: - break; - } - } - - if ( !ready ) - restart_kom("do_sub_footnote(): part 1 failed.\n"); - - - for ( ready = FALSE, i = 0; !ready && i < parent_s->no_of_misc; i++ ) - { - switch ( parent_s->misc_items[ i ].type) - { - case footn_in: - if ( parent_s->misc_items[ i ].datum.footnoted_in == footnote ) - { - do_delete_misc (&parent_s->no_of_misc, - parent_s->misc_items, i ); - mark_text_as_changed( footnote_to ); - ready = TRUE; - } - break; - - default: - break; - } - } - - if ( !ready ) - restart_kom("do_sub_footnote(): part 2 failed.\n"); - - return; -} - - -/* - * Who is sender of misc_item I? Returns 0 if there is no sent_by misc_item. - */ -static Pers_no -sender(Text_stat * t_stat, - int i) -{ - for (i++ ; i < t_stat->no_of_misc; i++) - { - switch ( t_stat->misc_items[ i ].type ) - { - case sent_by: - return t_stat->misc_items[ i ].datum.sender; - - case recpt: - case cc_recpt: - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case sent_at: - return 0; /* No sender. */ - - case loc_no: - case rec_time: - break; /* These may come before a sent_by. */ - -#ifndef COMPILE_CHECKS - default: - log("ERROR: sender(): Illegal misc_item found.\n"); - return 0; -#endif - } - } - return 0; /* No sender. */ -} - - -/* - * Check if ACTPERS has sent this text to conference CONF_NO - */ -static Bool -is_sender(Text_stat * text_s, - Conf_no conf_no) -{ - int i; - - if ( !ACTPERS ) - { - return FALSE; - } - - for ( i = 0; i < text_s->no_of_misc; i++ ) - { - switch( text_s->misc_items[ i ].type ) - { - case recpt: - if ( text_s->misc_items[ i ].datum.recipient == conf_no - && sender ( text_s, i ) == ACTPERS ) - { - return TRUE; - } - break; - - case cc_recpt: - if ( text_s->misc_items[ i ].datum.cc_recipient == conf_no - && sender ( text_s, i ) == ACTPERS ) - { - return TRUE; - } - break; - - case loc_no: - case rec_time: - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case sent_by: - case sent_at: - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("is_sender(): Illegal misc_item found.\n"); -#endif - } - } - - return FALSE; -} - - -/* - * Check if ACTPERS has sent this text as a comment to parent. - */ -static Bool -is_comm_sender(Text_stat * text_s, - Text_no parent) -{ - int i; - - if ( !ACTPERS ) - { - return FALSE; - } - - for ( i = 0; i < text_s->no_of_misc; i++ ) - { - switch( text_s->misc_items[ i ].type ) - { - case comm_to: - if ( text_s->misc_items[ i ].datum.comment_to == parent - && sender ( text_s, i ) == ACTPERS ) - { - return TRUE; - } - break; - - - case recpt: - case cc_recpt: - case loc_no: - case rec_time: - case comm_in: - case footn_to: - case footn_in: - case sent_by: - case sent_at: - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("is_comm_sender(): Illegal misc_item found.\n"); -#endif - } - } - - return FALSE; -} - - -/* - * Check if ACTPERS is allowed to add a footnote to a text. Sets errno if - * there is an error. - */ - -static Success -check_footn(Text_stat * t_stat) -{ - if ( t_stat->author != ACTPERS ) - { - kom_errno = KOM_NOT_AUTHOR; - return FAILURE; - } - - if ( count_footn( t_stat ) >= MAX_FOOT ) - { - kom_errno = KOM_FOOT_LIMIT; - return FAILURE; - } - - return OK; -} - -/* - * Check if ACTPERS is allowed to add a comment to a text. Sets errno if - * there is an error. Note that it is allowed to comment a text even if - * you are not allowed to read it. - */ - -static Success -check_comm(Text_stat * t_stat) -{ - if ( count_comment( t_stat ) >= MAX_COMM ) - { - kom_errno = KOM_COMM_LIMIT; - return FAILURE; - } - - return OK; -} - - -/* - * Return a pointer to a Mark if pers_no has marked the text text_no. - * Otherwise, return NULL. - */ -static Mark * -locate_mark(Pers_no pers_no, - Person *pers_p, /* May be NULL. */ - Text_no text_no) -{ - Mark *mp; - Mark *result = NULL; - int i; - Mark_list mlist; - - if ( pers_p == NULL ) - GET_P_STAT(pers_p, pers_no, NULL); - - mlist = pers_p->marks; - - for ( i = mlist.no_of_marks, mp = mlist.marks; - i > 0 && result == NULL; - i--, mp++ ) - { - if ( mp->text_no == text_no ) - result = mp; - } - - return result; -} - -/* - * Skip one misc-item with all additional data. - * - * This is only used from get_text_stat. - */ -static void -skip_recp (Misc_info ** misc, - Text_stat * text_stat ) -{ - Bool ready = FALSE; - - ++(*misc); - while ( !ready && *misc < text_stat->misc_items + text_stat->no_of_misc ) - { - switch ( (*misc)->type ) - { - case loc_no: - case rec_time: - case sent_by: - case sent_at: - ++(*misc); - break; - - case recpt: - case cc_recpt: - case comm_to: - case comm_in: - case footn_to: - case footn_in: - ready = TRUE; - break; -#ifndef COMPILE_CHECKS - default: - restart_kom("skip_recp() - illegal misc\n"); -#endif - } - } -} - -/* - * End of static functions. - */ - -/* - * Functions that are exported to the rest of the server. - */ - -/* - * Check if ACTPERS is allowed to read this text. - * Returns TRUE if he is allowed to read it. - */ -Bool -text_read_access(Text_no text_no, - Text_stat * text_stat) -{ - int i; - Misc_info *misc; - Conference *recipient; - - /* - * Nope, people who aren't logged in, should NOT be - * allowed to read any texts but motd_of_lyskom! - */ - if ( text_no == kom_info.motd_of_lyskom ) - return TRUE; - - CHK_LOGIN(FALSE); - - if ( text_stat == NULL ) - GET_T_STAT(text_stat, text_no, FALSE); - - if ( ENA(wheel, 10)) - return TRUE; - - if ( ACTPERS ) - { - if ( text_stat->author == ACTPERS ) - return TRUE; - - /* Check if ACTPERS or current working conference is a recipient */ - - for (i = text_stat->no_of_misc, misc = text_stat->misc_items; - i; i--, misc++) - { - if ( misc->type == recpt - && (misc->datum.recipient == active_connection->cwc - || misc->datum.recipient == ACTPERS )) - { - return TRUE; - } - - if ( misc->type == cc_recpt - && (misc->datum.cc_recipient == active_connection->cwc - || misc->datum.cc_recipient == ACTPERS )) - { - return TRUE; - } - } - - /* Check if ACTPERS is member in any of the recipients */ - - for (i = text_stat->no_of_misc, misc = text_stat->misc_items; - i; i--, misc++) - { - if ( misc->type == recpt - && locate_membership( misc->datum.recipient, ACT_P) != NULL) - { - return TRUE; - } - - if ( misc->type == cc_recpt - && locate_membership( misc->datum.cc_recipient, ACT_P) != NULL) - { - return TRUE; - } - } - - if ( locate_mark(ACTPERS, ACT_P, text_no) != NULL ) - { - return TRUE; - } - } - - /* Check if any of the recipients is an open conference, */ - /* or if ACTPERS is a supervisor. (Note: ACTPERS is not */ - /* supervisor of anything if he isn't logged in.) */ - - for (i = text_stat->no_of_misc, misc = text_stat->misc_items; - i; i--, misc++) - { - if ( misc->type == recpt - && (recipient = - cached_get_conf_stat( misc->datum.recipient )) != NULL ) - { - if ( !recipient->type.rd_prot - || is_supervisor(misc->datum.recipient, recipient, - ACTPERS, ACT_P)) - { - return TRUE; - } - } - - if ( misc->type == cc_recpt - && (recipient = - cached_get_conf_stat( misc->datum.cc_recipient )) != NULL ) - { - if ( !recipient->type.rd_prot - || is_supervisor(misc->datum.cc_recipient, recipient, - ACTPERS, ACT_P)) - { - return TRUE; - } - } - } - - return FALSE; -} - - -/* - * Delete a text from the database. Deletes all "links" to/from other - * texts/persons/conferences. (e. g. comm_to/comm_in) - */ -Success -do_delete_text(Text_no text_no, - Text_stat *text_s) -{ - Person *author; - Bool found = FALSE; - u_long i; - - if ( text_s == NULL ) - GET_T_STAT(text_s, text_no, FAILURE); - - if ((author = cached_get_person_stat (text_s->author)) != NULL) - { - /* Delete this text from created_texts. */ - - for ( i = 0; i < author->created_texts.no_of_texts; i++ ) - if ( author->created_texts.texts[ i ] == text_no ) - { - author->created_texts.texts[ i ] = 0; - adjust_text_list (&author->created_texts); - mark_person_as_changed (text_s->author); - found = TRUE; - break; - } - - if ( !found ) - log("ERROR: " __FILE__ ": do_delete_text(): text not found " - "in authors created_texts."); - } - - while ( text_s->no_of_misc > 0 ) - { - switch ( text_s->misc_items[ 0 ].type ) - { - case recpt: - if ( do_sub_recpt(text_no, text_s, - text_s->misc_items[ 0 ].datum.recipient, NULL) - != OK ) - restart_kom("do_delete_text(): error pos 1.\n"); - break; - - case cc_recpt: - if ( do_sub_recpt(text_no, text_s, - text_s->misc_items[ 0 ].datum.cc_recipient, NULL) - != OK ) - restart_kom("do_delete_text(): error pos 2.\n"); - break; - - case comm_to: - do_sub_comment(text_no, text_s, - text_s->misc_items[ 0 ].datum.comment_to, NULL); - break; - - case comm_in: - do_sub_comment(text_s->misc_items[ 0 ].datum.commented_in, NULL, - text_no, text_s); - break; - - case footn_to: - do_sub_footnote(text_no, text_s, - text_s->misc_items[ 0 ].datum.footnote_to, NULL); - break; - - case footn_in: - do_sub_footnote(text_s->misc_items[ 0 ].datum.footnoted_in, NULL, - text_no, text_s); - break; - - - case loc_no: - case rec_time: - case sent_by: - case sent_at: - restart_kom("do_delete_text(): Illegal misc-item syntax.\n"); -#ifndef COMPILE_CHECKS - default: - restart_kom("do_delete_text(): Illegal misc-item.\n"); -#endif - } - } - - cached_delete_text(text_no); - return OK; -} - -/* - * Atomic calls. - */ - -/* - * Calls to handle marks. - * - * Marks are secret. No else can know what you have marked. - */ - -/* - * Get text_nos of all marked texts. - */ -extern Success -get_marks( Mark_list *result ) -{ - CHK_LOGIN(FAILURE); - *result = ACT_P->marks; - return OK; -} - - - - -/* - * Get the text. The text will not be marked as read until you - * explicitly mark_as_read() it. start_char = 0 && end_char = END_OF_STRING - * gives the entire text. - */ -extern Success -get_text (Text_no text_no, - String_size start_char, - String_size end_char, - String * result) -{ - Text_stat * text_s; - - GET_T_STAT(text_s, text_no, FAILURE); - - /* Check if ACTPERS has read acess to the text */ - - if ( text_read_access( text_no, text_s ) != TRUE ) - { - kom_errno = KOM_NO_SUCH_TEXT; - err_stat = text_no; - - return FAILURE; - } - - *result = cached_get_text( text_no ); - - if ( start_char > result->len ) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - return FAILURE; - } - - /* Should use something in s-string.c to do this. +++ */ - result->string += start_char; - result->len = min ( result->len - 1, end_char ) + 1 - start_char; - - if ( ACTPERS ) - { - ++ACT_P->no_of_text_fetches; - mark_person_as_changed( ACTPERS ); - } - - return OK; -} - - - -/* - * Check if person is a member in any of the recipients or cc_recipients - * of text_s - */ -static Bool -is_member_in_recpt(Person *person, - Text_stat *text_s) -{ - int i; - - for ( i = 0; i < text_s->no_of_misc; i++ ) - { - switch(text_s->misc_items[ i ].type) - { - case recpt: - if ( locate_membership(text_s->misc_items[ i ].datum.recipient, - person) != NULL ) - { - return TRUE; - } - break; - - case cc_recpt: - if ( locate_membership(text_s->misc_items[ i ].datum.cc_recipient, - person) != NULL ) - { - return TRUE; - } - break; - - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case loc_no: - case rec_time: - case sent_by: - case sent_at: - break; - -#ifndef COMPILE_CHECKS - default: - log(__FILE__ ": is_member_in_recpt(): bad misc_item.\n"); - break; -#endif - } - } - - return FALSE; -} - - -/* - * Copy the text_stat original into result, but only those part - * that viewer is allowed to see. (Censor away information about - * conferences that viewer is not allowed to know about). - * - * All memory is allocated via tmp_alloc(). - */ -static void -filter_secret_info(Text_stat *result, - Text_stat *original, - Pers_no viewer, - Person *viewer_p) /* May be NULL. */ -{ - Misc_info * orig; - Misc_info * copy; /* Censored Misc_infos */ - - /* ^^^ Possible optimisation: - No need to copy unless there is a secret conf among the recipients. */ - - *result = *original; - - result->misc_items = tmp_alloc(result->no_of_misc * sizeof ( Misc_info)); - result->no_of_misc = 0; - copy = result->misc_items; - orig = original->misc_items; - - while ( orig < original->misc_items + original->no_of_misc ) - { - switch( orig->type ) - { - case recpt: - if ( (fast_access_perm (orig->datum.recipient, viewer, viewer_p) - <= none ) - && !ENA(admin, 4)) - { - skip_recp ( &orig, original ); - } - else - { - *copy++ = *orig++; - ++result->no_of_misc; - } - break; - - case cc_recpt: - if ( (fast_access_perm (orig->datum.cc_recipient, viewer, viewer_p) - <= none) - && !ENA(admin, 4)) - { - skip_recp ( &orig, original ); - } - else - { - *copy++ = *orig++; - ++result->no_of_misc; - } - break; - - case loc_no: - case rec_time: - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case sent_by: - case sent_at: - *copy++ = *orig++; - ++result->no_of_misc; - break; - -#ifndef COMPILE_CHECKS - default: - restart_kom("filter_secret_info() - illegal misc_item!\n"); -#endif - } - } -} - -/* - * Get text status. - * - * If there are recipients of the text that are secret confs - * those misc-items will be censored. - */ -extern Success -get_text_stat (Text_no text_no, - Text_stat *result ) -{ - Text_stat * text_stat; - - GET_T_STAT(text_stat, text_no, FAILURE); - - if ( !text_read_access(text_no, text_stat) && !ENA(admin, 2)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - filter_secret_info(result, text_stat, ACTPERS, ACT_P); - return OK; -} - -/* - * Functions local to create_text: - */ - -/* - * Check that the recipient or cc_recipient at LOC is not already a - * recipient or cc_recipient of this text. - */ -static Success -check_double_subm (Misc_info * misc, - int loc, - Conf_no addressee) -{ - int j; - - for ( j = 0; j < loc; j++) - { - switch ( misc[ j ].type ) - { - case recpt: - if ( misc[ j ].datum.recipient == addressee ) - return FAILURE; - - break; - - case cc_recpt: - if ( misc[ j ].datum.cc_recipient == addressee ) - return FAILURE; - - break; - - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case loc_no: - case rec_time: - case sent_by: - case sent_at: - break; - -#ifndef COMPILE_CHECKS - default: - log(__FILE__, ": check_double_subm(): bad misc_item.\n"); - break; -#endif - } - } - return OK; -} - -/* - * Check that none of the first 'pos' misc_items pointed to by misc - * is a comment or footnote to text forbidden. - */ -static Success -check_double_comm (Misc_info *misc, - int pos, - Text_no forbidden) -{ - for(;pos > 0; pos--, misc++) - { - switch(misc->type) - { - case comm_to: - if ( misc->datum.comment_to == forbidden ) - return FAILURE; - break; - - case footn_to: - if ( misc->datum.footnote_to == forbidden ) - return FAILURE; - break; - - case recpt: - case cc_recpt: - case comm_in: - case footn_in: - case loc_no: - case rec_time: - case sent_by: - case sent_at: - break; - -#ifndef COMPILE_CHECKS - default: - log(__FILE__ "check_double_subm(): bad misc_item.\n"); - break; -#endif - } - } - - return OK; -} - - - -/* - * Check that all misc_items are legal. Return OK / FAILURE. - * Update recpt & cc_recpt fields if the text goes to a super_conf. - * Signal an error if a conference is recipient more than once, or if - * a text is a comment to the same text more than once. - */ -static Success -create_text_check_misc (u_short * no_of_misc, - Misc_info * misc ) -{ - int i; - Text_stat * parent; - Conf_no addressee; - - for ( i = 0; i < *no_of_misc; i++) - { - err_stat = i; /* In case of an error, err_stat indicates which - misc_item caused the error. */ - - switch( misc[ i ].type ) - { - case footn_to: - /* Check that ACTPERS is the author to the text. */ - - GET_T_STAT( parent, misc[ i ].datum.footnote_to, FAILURE); - - if ( check_footn(parent) == FAILURE ) - return FAILURE; - - if ( check_double_comm(misc, i, misc[ i ].datum.footnote_to) - != OK ) - { - kom_errno = KOM_ILL_MISC; - return FAILURE; - } - - break; - - case comm_to: - /* Check that the text exists. */ - - GET_T_STAT( parent, misc[ i ].datum.comment_to, FAILURE); - - if ( check_comm(parent) == FAILURE ) - return FAILURE; - - if ( check_double_comm(misc, i, misc[ i ].datum.comment_to) - != OK ) - { - kom_errno = KOM_ILL_MISC; - return FAILURE; - } - - break; - - case recpt: - /* Check that ACTPERS has write access to the conference or a - superconference. */ - /* Superconfs are recursive */ - - addressee = submit_to( misc[ i ].datum.recipient, NULL); - - /* Update in case of super_conf */ - - if ((misc[ i ].datum.recipient = addressee) == 0) - { - kom_errno = KOM_ACCESS; - return FAILURE; - } - - /* Check that this recipient is not already a recipient. */ - - if ( check_double_subm(misc, i, addressee) != OK ) - { - kom_errno = KOM_ILL_MISC; - return FAILURE; - } - - break; - - case cc_recpt: - /* Check that ACTPERS has write access to the conference or a - superconference. */ - /* Superconfs are recursive */ - - addressee = submit_to( misc[ i ].datum.cc_recipient, NULL); - - /* Update in case of super_conf */ - - if ((misc[ i ].datum.cc_recipient = addressee) == 0) - { - kom_errno = KOM_ACCESS; - return FAILURE; - } - - /* Check that this recipient is not already a recipient. */ - - if (check_double_subm(misc, i, addressee) != OK) - { - kom_errno = KOM_ILL_MISC; - return FAILURE; - } - - break; - - case loc_no: /* Ignore loc_no */ - break; - - case comm_in: - case footn_in: - case rec_time: - case sent_by: - case sent_at: - /* Fall through */ -#ifndef COMPILE_CHECKS - default: -#endif - kom_errno = KOM_ILL_MISC; - return FAILURE; - } - } - - return OK; -} - -/* - * Fix all double references. Eg if misc contains comm_to, add a comm_in field. - * No access-permission checking is done. - */ -static Success -create_text_add_miscs(Text_no new_text, - int no_of_misc, - Misc_info * misc) -{ - int i; - - for ( i = 0; i < no_of_misc; i++) - { - err_stat = i; /* In case of an error, err_stat indicates which - misc_item caused the error. */ - - switch( misc[ i ].type ) - { - case footn_to: - if ( do_add_footnote(new_text, misc[ i ].datum.footnote_to) != OK) - return FAILURE; - - break; - - case comm_to: - if ( do_add_comment(new_text, misc[ i ].datum.comment_to) != OK ) - return FAILURE; - - break; - - case recpt: - if ( do_add_recpt(new_text, NULL, misc[ i ].datum.recipient) != OK) - return FAILURE; - - break; - - case cc_recpt: - if ( do_add_cc_recpt(new_text, NULL, - misc[ i ].datum.cc_recipient) !=OK ) - return FAILURE; - - break; - - case loc_no: /* Ignore loc_no. */ - break; - - case comm_in: - case footn_in: - case rec_time: - case sent_by: - case sent_at: - /* Fall through */ -#ifndef COMPILE_CHECKS - default: -#endif - restart_kom("create_text_add_misc() - illegal Info_type"); - } - } - return OK; -} - -/* - * Send an asynchronous message, but filter any secret information. - */ - -static void -send_async_new_text (Text_no text_no, - Text_stat *text_s) -{ - Connection *cptr; - Session_no i = 0; - Text_stat filtered = EMPTY_TEXT_STAT; - - while ( (i = traverse_connections(i)) != 0 ) - { - cptr = get_conn_by_number(i); - - /* - * filter_secret_info copies the text-stat to filtered, but - * since it is allocated with tmp_alloc we do not need to free - * the memory now. - */ - filter_secret_info(&filtered, text_s, - cptr->pers_no, cptr->person); - - if ( cptr->person != NULL - && is_member_in_recpt (cptr->person, &filtered) ) - { - async_new_text (cptr, text_no, &filtered); - } - } -} - - -/* - * Create a text. - * - * The recipients may change. See doc for set_permitted_submitters. - * - * The only allowed Misc_items are recpt, cc_recpt, comm_to and footn_to. - * loc_no are allowed, but ignored. - * - * Returns text_no of the created text, or 0 if there was an error. - */ -extern Text_no -create_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_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 = ACTPERS; - 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; - } - - ACT_P->created_texts.texts - = srealloc(ACT_P->created_texts.texts, - ++(ACT_P->created_texts.no_of_texts) * sizeof(Text_no)); - ACT_P->created_texts.texts[ ACT_P->created_texts.no_of_texts - 1 ] = text; - ACT_P->created_lines += t_stat->no_of_lines; - ACT_P->created_bytes += t_stat->no_of_chars; - - mark_person_as_changed (ACTPERS); - mark_text_as_changed (text); - - send_async_new_text (text, t_stat); /* Send asynchronous 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! */ - - send_async_new_text (text, t_stat); - - return text; -} - -/* - * Delete a text. - * - * Only a supervisor of the author may delete a text. - */ -extern Success -delete_text( Text_no text_no ) -{ - Text_stat *text_s; - - CHK_LOGIN(FAILURE); - GET_T_STAT(text_s, text_no, FAILURE); - - if ( !is_supervisor(text_s->author, NULL, ACTPERS, ACT_P) - && !ENA(admin, 5) ) - { - kom_errno = (text_read_access(text_no, text_s) - ? KOM_NOT_AUTHOR : KOM_NO_SUCH_TEXT); - return FAILURE; - } - - return do_delete_text(text_no, text_s); -} - -/* - * Lookup a text according to creation-time. - * The text-no of the text created closest before TIME is returned. - * The text text-no might not be readable. - */ -extern Success -get_last_text(time_t time, - Text_no *result) -{ - Text_no lower = 0; - Text_no higher = query_next_text_num() - 1; - Text_stat *text_stat = NULL; - Text_no try; - Text_no middle; - - /* - * We search for the text in the interval [lower, higher] - * (inclusive). Middle is set to the middle (rounded towards - * infinity), and we search from there and upward until we find a - * text. - */ - - while (lower < higher) - { - middle = (lower + higher)/2 + 1; /* Binary search */ - try = middle; - text_stat = NULL; - - while (text_stat == NULL && try <= higher) - text_stat = cached_get_text_stat (try++); - - if ( text_stat == NULL ) - higher = middle - 1; - else - { - if (time > text_stat->creation_time) - lower = try - 1; - else /* The intervall is "halved" */ - higher = middle - 1; - } - } - - *result = lower; - - return OK; -} - - -/* - * Return next existing text-no. - */ - -extern Success -find_next_text_no (Text_no start, - Text_no *result) -{ - Text_no highest = query_next_text_num(); - Text_stat *text_s; - - while (++start < highest) - { - text_s = cached_get_text_stat(start); - if (text_s != NULL && text_read_access(start, text_s) == TRUE) - { - *result = start; - return OK; - } - } - - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; -} - - -/* - * Return next/previous existing text-no. - */ - -extern Success -find_previous_text_no (Text_no start, - Text_no *result) -{ - Text_stat *text_s; - - while (start-- > 0) - { - text_s = cached_get_text_stat(start); - if (text_s != NULL && text_read_access(start, text_s) == TRUE) - { - *result = start; - return OK; - } - } - - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; -} - -/* - * Add a recipient to a text. - */ -extern Success -add_recipient( Text_no text_no, - Conf_no conf_no, - Info_type type ) /* recpt or cc_recpt */ -{ - Text_stat * t_stat; - Conference * conf_c; - - CHK_LOGIN(FAILURE); - GET_T_STAT(t_stat, text_no, FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - if ( !text_read_access(text_no, t_stat ) && !ENA(admin, 4)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( is_recipient(conf_no, t_stat) ) - { - kom_errno = KOM_ALREADY_RECIPIENT; - return FAILURE; - } - - if ( count_recipients( t_stat ) >= MAX_RECIPIENTS ) - { - kom_errno = KOM_RECIPIENT_LIMIT; - return FAILURE; - } - - switch ( type ) - { - case recpt: - if ( do_add_recpt(text_no, t_stat, conf_no) != OK) - return FAILURE; - break; - - case cc_recpt: - if ( do_add_cc_recpt(text_no, t_stat, conf_no) != OK) - return FAILURE; - break; - - case comm_to: - case comm_in: - case footn_to: - case footn_in: - case loc_no: - case rec_time: - case sent_by: - case sent_at: - /* Fall through */ -#ifndef COMPILE_CHECKS - default: -#endif - kom_errno = KOM_ILLEGAL_INFO_TYPE; - return FAILURE; - } - - if ( t_stat->author != ACTPERS ) - ADD_MISC(t_stat, sent_by, sender, ACTPERS); - - ADD_MISC(t_stat, sent_at, sent_at, time(NULL)); - - mark_text_as_changed( text_no ); - return OK; -} - - -/* - * Subtract a recipient from a text. - * - * This may be done by - * a) a supervisor of the author. - * b) a supervisor of the recipient. - * c) the sender of the text to the recipient - */ -extern Success -sub_recipient( Text_no text_no, - Conf_no conf_no) -{ - Text_stat * text_s; - Conference * conf_c; - - CHK_LOGIN(FAILURE); - GET_T_STAT(text_s, text_no, FAILURE); - - if ( !text_read_access(text_no, text_s ) && !ENA(admin, 4)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( !is_recipient( conf_no, text_s ) ) - { - kom_errno = KOM_NOT_RECIPIENT; - return FAILURE; - } - - GET_C_STAT(conf_c, conf_no, FAILURE); - - - if ( !is_supervisor (text_s->author, NULL, ACTPERS, ACT_P) - && !is_supervisor (conf_no, conf_c, ACTPERS, ACT_P) - && !is_sender (text_s, conf_no) ) - { - kom_errno = KOM_PERM; - return FAILURE; - } - - return do_sub_recpt( text_no, text_s, conf_no, conf_c ); -} - -/* - * Add a comment-link between two existing texts. - */ -extern Success -add_comment(Text_no comment, - Text_no comment_to) -{ - Text_stat *child_s, *parent_s; - - CHK_LOGIN(FAILURE); - - /* The following code can not cope with a text that is a comment - to itself. That is considered to be a bug. Work around it for - now, until a proper misc-info-list handling package is written. - FIXME +++ /// */ - if (comment == comment_to) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - return FAILURE; - } - - GET_T_STAT(child_s, comment, FAILURE); - GET_T_STAT(parent_s, comment_to, FAILURE); - - if ( check_comm(parent_s) != OK ) - return FAILURE; - - if ( !text_read_access(comment, child_s) ) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - /* Check if already comment */ - if ( is_comment_to(comment, parent_s) ) - { - kom_errno = KOM_ALREADY_COMMENT; - return FAILURE; - } - - if ( do_add_comment(comment, comment_to) != OK) - return FAILURE; - - if ( child_s->author != ACTPERS ) - ADD_MISC(child_s, sent_by, sender, ACTPERS); - - ADD_MISC(child_s, sent_at, sent_at, time(NULL)); - - mark_text_as_changed (comment); - return OK; -} - -/* - * Delete a comment-link between two texts. - * - * This can be done by: - * a) a supervisor of any of the authors. - * b) the sender of the comment. - */ -extern Success -sub_comment( Text_no comment, /* 'comment' is no longer a comment */ - Text_no parent ) /* to 'parent' */ -{ - Text_stat * text_s; - Text_stat * parent_s; - - - CHK_LOGIN(FAILURE); - - GET_T_STAT(text_s, comment, FAILURE); - GET_T_STAT(parent_s, parent, FAILURE); - - if ( !text_read_access(comment, text_s ) && !ENA(admin, 4)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( !text_read_access(parent, parent_s ) && !ENA(admin, 4)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( !is_comment_to( comment, parent_s ) ) - { - kom_errno = KOM_NOT_COMMENT; - return FAILURE; - } - - - if ( !is_supervisor (text_s->author, NULL, ACTPERS, ACT_P) - && !is_supervisor (parent_s->author, NULL, ACTPERS, ACT_P) - && !is_comm_sender (text_s, parent) ) - { - kom_errno = KOM_PERM; - return FAILURE; - } - - do_sub_comment( comment, text_s, parent, parent_s ); - return OK; -} - -/* - * Add a footnote-link between two existing texts. Only the author - * may do this. The texts must have the same author. - */ -extern Success -add_footnote( Text_no footnote, - Text_no footnote_to ) -{ - Text_stat *text_s, *parent_s; - - CHK_LOGIN(FAILURE); - GET_T_STAT(text_s, footnote, FAILURE); - GET_T_STAT(parent_s, footnote_to, FAILURE); - - /* The following code can not cope with a text that is a footnote - to itself. That is considered to be a bug. Work around it for - now, until a proper misc-info-list handling package is written. - FIXME /// +++ */ - if (footnote == footnote_to) - { - kom_errno = KOM_INDEX_OUT_OF_RANGE; - return FAILURE; - } - - if ( !text_read_access(footnote, text_s) - || !text_read_access(footnote_to, parent_s) ) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( check_footn(parent_s) != OK ) - return FAILURE; - - if ( text_s->author != parent_s->author ) - { - kom_errno = KOM_NOT_AUTHOR; - return FAILURE; - } - - /* Check if already footnote */ - if ( is_footnote_to(footnote, parent_s) ) - { - kom_errno = KOM_ALREADY_FOOTNOTE; - return FAILURE; - } - - if ( do_add_footnote(footnote, footnote_to) != OK) - return FAILURE; - - ADD_MISC(text_s, sent_at, sent_at, time(NULL)); - - mark_text_as_changed( footnote ); - return OK; -} - -/* - * Delete a footnote-link between two texts. - * Only the author may do this. - */ -extern Success -sub_footnote( Text_no footnote, /* 'footnote' is no longer a */ - Text_no parent ) /* footnote to 'parent' */ -{ - Text_stat * text_s; - Text_stat * parent_s; - - - CHK_LOGIN(FAILURE); - - GET_T_STAT(text_s, footnote, FAILURE); - GET_T_STAT(parent_s, parent, FAILURE); - - if ( !text_read_access(footnote, text_s ) && !ENA(admin, 4)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( !text_read_access(parent, parent_s ) && !ENA(admin, 4)) - { - kom_errno = KOM_NO_SUCH_TEXT; - return FAILURE; - } - - if ( !is_footnote_to( footnote, parent_s ) ) - { - kom_errno = KOM_NOT_FOOTNOTE; - return FAILURE; - } - - - if ( text_s->author != ACTPERS && parent_s->author != ACTPERS ) - { - kom_errno = KOM_PERM; - return FAILURE; - } - - do_sub_footnote( footnote, text_s, parent, parent_s ); - return OK; -} - - -/* - * Get mapping from Local_text_no to (global) Text_no for part of - * a conference. - * - * BUG: You should be allowed to get the mapping if it is a letterbox - * which is not unread_is_secret. +++ (Really? I don't think so. /ceder) - */ -extern Success -get_map (Conf_no conf_no, - Local_text_no first_local_no, - Local_text_no no_of_texts, - Text_list * result) -{ - Conference * conf_c; - Local_text_no highest_wanted_no, highest; - Access acc; - - CHK_LOGIN(FAILURE); - GET_C_STAT(conf_c, conf_no, FAILURE); - - acc = access_perm (conf_no, conf_c, ACTPERS, ACT_P); - - if ( acc <= none ) - { - kom_errno = KOM_UNDEF_CONF; - return FAILURE; - } - - if ( acc == read_protected ) - { - kom_errno = KOM_ACCESS; - return FAILURE; - } - - highest = conf_c->texts.first_local_no + conf_c->texts.no_of_texts; - - if ( first_local_no >= highest ) - { - kom_errno = KOM_NO_SUCH_LOCAL_TEXT; - return FAILURE; - } - - result->first_local_no = max(conf_c->texts.first_local_no, - first_local_no); - highest_wanted_no = min(highest, first_local_no + no_of_texts); - - if ( highest_wanted_no >= result->first_local_no ) - result->no_of_texts = highest_wanted_no - result->first_local_no; - else - result->no_of_texts = 0; - - result->texts = &conf_c->texts.texts[ result->first_local_no - - conf_c->texts.first_local_no ]; - - return OK; -} diff --git a/src/server/tmp-limits.h b/src/server/tmp-limits.h deleted file mode 100644 index f0b8f25a3..000000000 --- a/src/server/tmp-limits.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * $Id: tmp-limits.h,v 0.8 1992/04/08 18:07:03 ceder Exp $ - * Copyright (C) 1991 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. - */ -/* - * These arbitrary limits should be lifted in future versions. - */ - -#define MAX_CONF 1999 -#define MAX_TEXT 249997 diff --git a/src/server/trace-mem.gdb b/src/server/trace-mem.gdb deleted file mode 100644 index e6767e7dc..000000000 --- a/src/server/trace-mem.gdb +++ /dev/null @@ -1,20 +0,0 @@ -break trace_smalloc -commands -echo --- malloc ---\n -bt -cont -end - -break trace_free -commands -echo --- free ---\n -bt -cont -end - -break trace_srealloc -commands -echo --- realloc ---\n -bt -cont -end diff --git a/src/server/version.incl b/src/server/version.incl deleted file mode 100644 index c4e78d605..000000000 --- a/src/server/version.incl +++ /dev/null @@ -1,30 +0,0 @@ -/* - * $Id: version.incl,v 0.30 1992/06/11 18:47:30 ceder Exp $ - * Copyright (C) 1991 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. - */ - -/* - * The version number is encoded in a long. It shall be printed as - * in sed s/\(.*\)\(..\)\(..\)/\1.\2.\3/ - */ -10203 -- GitLab