From: Wilfried Goesgens Date: Wed, 18 Jul 2012 14:24:09 +0000 (+0200) Subject: client-move: edits to finish this. X-Git-Tag: v8.20~313 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=e5b0ab22468d49791f864e1648ded8d0173a6b2e client-move: edits to finish this. --- diff --git a/citadel/citadel.h b/citadel/citadel.h index 0d1897220..87224168a 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -61,12 +61,7 @@ extern "C" { /* Various length constants */ -#define UGLISTLEN 100 /* you get a ungoto list of this size */ #define ROOMNAMELEN 128 /* The size of a roomname string */ -#define NONCE_SIZE 128 /* Added by to allow for APOP auth - * it is BIG becuase there is a hostname - * in the nonce, as per the APOP RFC. - */ #define USERNAME_SIZE 64 /* The size of a username string */ #define MAX_EDITORS 5 /* # of external editors supported */ @@ -202,50 +197,9 @@ struct floor { #define NEWREGISTER 0 /* new user to register */ #define REREGISTER 1 /* existing user reregistering */ -#define READ_HEADER 2 -#define READ_MSGBODY 3 - -/* commands we can send to the stty_ctdl() routine */ -#define SB_NO_INTR 0 /* set to Citadel client mode, i/q disabled */ -#define SB_YES_INTR 1 /* set to Citadel client mode, i/q enabled */ -#define SB_SAVE 2 /* save settings */ -#define SB_RESTORE 3 /* restore settings */ -#define SB_LAST 4 /* redo the last command sent */ - -#define NEXT_KEY 15 -#define STOP_KEY 3 - -/* citadel.rc stuff */ -#define RC_NO 0 /* always no */ -#define RC_YES 1 /* always yes */ -#define RC_DEFAULT 2 /* setting depends on user config */ - -/* keepalives */ -enum { - KA_NO, /* no keepalives */ - KA_YES, /* full keepalives */ - KA_HALF /* half keepalives */ -}; - -/* for <;G>oto and <;S>kip commands */ -#define GF_GOTO 0 /* <;G>oto floor mode */ -#define GF_SKIP 1 /* <;S>kip floor mode */ -#define GF_ZAP 2 /* <;Z>ap floor mode */ - /* number of items which may be handled by the CONF command */ #define NUM_CONFIGS 70 -/* - * MIME types used in Citadel for configuration stuff - */ -#define SPOOLMIME "application/x-citadel-delivery-list" -#define INTERNETCFG "application/x-citadel-internet-config" -#define IGNETCFG "application/x-citadel-ignet-config" -#define IGNETMAP "application/x-citadel-ignet-map" -#define FILTERLIST "application/x-citadel-filter-list" -#define SIEVECONFIG "application/x-citadel-sieve-config" -#define XMPPMORTUARY "application/x-citadel-xmpp-mortuary" - #define TRACE syslog(LOG_DEBUG, "Checkpoint: %s, %d\n", __FILE__, __LINE__) #ifndef LONG_MAX diff --git a/citadel/configure.ac b/citadel/configure.ac index 943a84571..41c00e0d9 100644 --- a/citadel/configure.ac +++ b/citadel/configure.ac @@ -247,11 +247,6 @@ fi AC_CHECK_LIB(intl, libintl_bindtextdomain, [LDFLAGS="$LDFLAGS -lintl"]) - - -AC_ARG_ENABLE(threaded-client, [ --disable-threaded-client - disable multithreaded client]) - AC_ARG_ENABLE(pie, [ --enable-pie build position-independent executables]) AC_ARG_WITH(pam, [ --with-pam use PAM if present (see PAM.txt before you try this)]) @@ -284,10 +279,6 @@ else test -d /usr/local/BerkeleyDB.4.5 && db_dir=/usr/local/BerkeleyDB.4.5 fi -dnl By default, we only build the client (citadel and whobbs) unless we can -dnl figure out how to build with POSIX threads. -TARGETS=client - AC_CANONICAL_HOST PTHREAD_DEFS=-D_REENTRANT AC_MSG_CHECKING([how to compile with POSIX threads]) @@ -996,10 +987,7 @@ AC_CACHE_CHECK([for pthread_create], ac_cv_func_pthread_create, #endif], ac_cv_func_pthread_create=yes, ac_cv_func_pthread_create=no)]) if test "$ac_cv_func_pthread_create" = yes; then - test "$DATABASE" && TARGETS="client server utils" - if test "x$enable_threaded_client" != xno; then - AC_DEFINE(THREADED_CLIENT, [], [define this if you want to enable the multithreaded client]) - fi + test "$DATABASE" && TARGETS="server utils" fi AC_REPLACE_FUNCS(snprintf getutline) @@ -1084,7 +1072,6 @@ if test "$abs_srcdir" != "$abs_builddir"; then fi mkdir -p $abs_builddir/utils mkdir -p $abs_builddir/utillib - mkdir -p $abs_builddir/textclient fi if test -n "$srcdir"; then diff --git a/citadel/include/citadel_dirs.h b/citadel/include/citadel_dirs.h index 51929cc63..3a0b6d86e 100644 --- a/citadel/include/citadel_dirs.h +++ b/citadel/include/citadel_dirs.h @@ -37,7 +37,6 @@ extern char ctdl_utilbin_dir[PATH_MAX]; /* some of the frequently used files */ extern char file_citadel_control[PATH_MAX]; -extern char file_citadel_rc[PATH_MAX]; extern char file_citadel_config[PATH_MAX]; extern char file_citadel_urlshorteners[PATH_MAX]; extern char file_lmtp_socket[PATH_MAX]; diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index 97ecc1dff..a2a00f52b 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -11,14 +11,6 @@ */ #define CHATLOG "/dev/null" -/* - * S_KEEPALIVE is a watchdog timer. It is used to send "keep - * alive" messages to the server to prevent the server from assuming the - * client is dead and terminating the session. 30 seconds is the recommended - * value; I can't think of any good reason to change it. - */ -#define S_KEEPALIVE 30 - /* * Logging level to use if none is specified on the command line. * Note that this will suppress messages before they even get to syslog(). diff --git a/citadel/utillib/citadel_dirs.c b/citadel/utillib/citadel_dirs.c index a88417954..ff6247074 100644 --- a/citadel/utillib/citadel_dirs.c +++ b/citadel/utillib/citadel_dirs.c @@ -65,7 +65,6 @@ char ctdl_bin_dir[PATH_MAX]=""; /* some of our files, that are needed in several places */ char file_citadel_control[PATH_MAX]=""; -char file_citadel_rc[PATH_MAX]=""; char file_citadel_config[PATH_MAX]=""; char file_citadel_urlshorteners[PATH_MAX]=""; char file_lmtp_socket[PATH_MAX]=""; @@ -233,11 +232,6 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, "%scitadel.config", ctdl_autoetc_dir); StripSlashes(file_citadel_config, 0); - snprintf(file_citadel_rc, - sizeof file_citadel_rc, - "%scitadel.rc", - ctdl_etc_dir); - StripSlashes(file_citadel_rc, 0); snprintf(file_citadel_urlshorteners, sizeof file_citadel_urlshorteners, "%scitadel_urlshorteners.rc", @@ -356,7 +350,6 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, DBG_PRINT(ctdl_bin_dir); DBG_PRINT(ctdl_utilbin_dir); DBG_PRINT(file_citadel_control); - DBG_PRINT(file_citadel_rc); DBG_PRINT(file_citadel_config); DBG_PRINT(file_lmtp_socket); DBG_PRINT(file_lmtp_unfiltered_socket); diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 296d1cee5..46b103e41 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -655,5 +655,108 @@ extern ConstStr RoomNetCfgStrs[maxRoomNetCfg]; /* a nice consistent place to define how we turn a message id into a thread id hash */ #define ThreadIdHash(Buf) abs(HashLittle(ChrPtr(Buf), StrLength(Buf))) +#ifdef __cplusplus +extern "C" { +#endif + +/* + * MIME types used in Citadel for configuration stuff + */ +#define SPOOLMIME "application/x-citadel-delivery-list" +#define INTERNETCFG "application/x-citadel-internet-config" +#define IGNETCFG "application/x-citadel-ignet-config" +#define IGNETMAP "application/x-citadel-ignet-map" +#define FILTERLIST "application/x-citadel-filter-list" +#define SIEVECONFIG "application/x-citadel-sieve-config" +#define XMPPMORTUARY "application/x-citadel-xmpp-mortuary" +#define INTERNETCFG "application/x-citadel-internet-config" + +#define LISTING_FOLLOWS 100 +#define CIT_OK 200 +#define MORE_DATA 300 +#define SEND_LISTING 400 +#define ERROR 500 +#define BINARY_FOLLOWS 600 +#define SEND_BINARY 700 +#define START_CHAT_MODE 800 + +#define INTERNAL_ERROR 10 +#define TOO_BIG 11 +#define ILLEGAL_VALUE 12 +#define NOT_LOGGED_IN 20 +#define CMD_NOT_SUPPORTED 30 +#define SERVER_SHUTTING_DOWN 31 +#define PASSWORD_REQUIRED 40 +#define ALREADY_LOGGED_IN 41 +#define USERNAME_REQUIRED 42 +#define HIGHER_ACCESS_REQUIRED 50 +#define MAX_SESSIONS_EXCEEDED 51 +#define RESOURCE_BUSY 52 +#define RESOURCE_NOT_OPEN 53 +#define NOT_HERE 60 +#define INVALID_FLOOR_OPERATION 61 +#define NO_SUCH_USER 70 +#define FILE_NOT_FOUND 71 +#define ROOM_NOT_FOUND 72 +#define NO_SUCH_SYSTEM 73 +#define ALREADY_EXISTS 74 +#define MESSAGE_NOT_FOUND 75 + +#define ASYNC_MSG 900 +#define ASYNC_GEXP 02 + +#define QR_PERMANENT 1 /* Room does not purge */ +#define QR_INUSE 2 /* Set if in use, clear if avail */ +#define QR_PRIVATE 4 /* Set for any type of private room */ +#define QR_PASSWORDED 8 /* Set if there's a password too */ +#define QR_GUESSNAME 16 /* Set if it's a guessname room */ +#define QR_DIRECTORY 32 /* Directory room */ +#define QR_UPLOAD 64 /* Allowed to upload */ +#define QR_DOWNLOAD 128 /* Allowed to download */ +#define QR_VISDIR 256 /* Visible directory */ +#define QR_ANONONLY 512 /* Anonymous-Only room */ +#define QR_ANONOPT 1024 /* Anonymous-Option room */ +#define QR_NETWORK 2048 /* Shared network room */ +#define QR_PREFONLY 4096 /* Preferred status needed to enter */ +#define QR_READONLY 8192 /* Aide status required to post */ +#define QR_MAILBOX 16384 /* Set if this is a private mailbox */ + +#define QR2_SYSTEM 1 /* System room; hide by default */ +#define QR2_SELFLIST 2 /* Self-service mailing list mgmt */ +#define QR2_COLLABDEL 4 /* Anyone who can post can delete */ +#define QR2_SUBJECTREQ 8 /* Subject strongly recommended */ +#define QR2_SMTP_PUBLIC 16 /* Listservice Subscribers may post */ +#define QR2_MODERATED 32 /* Listservice aide has to permit posts */ + +#define US_NEEDVALID 1 /* User needs to be validated */ +#define US_EXTEDIT 2 /* Always use external editor */ +#define US_PERM 4 /* Permanent user */ +#define US_LASTOLD 16 /* Print last old message with new */ +#define US_EXPERT 32 /* Experienced user */ +#define US_UNLISTED 64 /* Unlisted userlog entry */ +#define US_NOPROMPT 128 /* Don't prompt after each message */ +#define US_PROMPTCTL 256 /* ext & top work at prompt */ +#define US_DISAPPEAR 512 /* Use "disappearing msg prompts" */ +#define US_REGIS 1024 /* Registered user */ +#define US_PAGINATOR 2048 /* Pause after each screen of text */ +#define US_INTERNET 4096 /* Internet mail privileges */ +#define US_FLOORS 8192 /* User wants to see floors */ +#define US_COLOR 16384 /* User wants ANSI color support */ +#define US_USER_SET (US_LASTOLD | US_EXPERT | US_UNLISTED | \ + US_NOPROMPT | US_DISAPPEAR | US_PAGINATOR | \ + US_FLOORS | US_COLOR | US_PROMPTCTL | US_EXTEDIT) + +#define UA_KNOWN 2 /* Room appears in a 'known rooms' list */ +#define UA_GOTOALLOWED 4 /* User may goto this room if specified by exact name */ +#define UA_HASNEWMSGS 8 /* Unread messages exist in this room */ +#define UA_ZAPPED 16 /* User has forgotten (zapped) this room */ +#define UA_POSTALLOWED 32 /* User may post top-level messages here */ +#define UA_ADMINALLOWED 64 /* Aide or Room Aide rights exist here */ +#define UA_DELETEALLOWED 128 /* User is allowed to delete messages from this room */ +#define UA_REPLYALLOWED 256 /* User is allowed to reply to existing messages here */ + +#ifdef __cplusplus +} +#endif #endif // LIBCITADEL_H diff --git a/textclient/Makefile.in b/textclient/Makefile.in index 54203aae4..a10ed3fd4 100644 --- a/textclient/Makefile.in +++ b/textclient/Makefile.in @@ -37,7 +37,7 @@ AUTOCONF=@AUTOCONF@ chkpwd_LIBS=@chkpwd_LIBS@ CC=@CC@ CFLAGS=@CFLAGS@ -I ./include/ -CPPFLAGS=@CPPFLAGS@ -I. -I ./include/ +CPPFLAGS=@CPPFLAGS@ -I. -I ./src/include/ DATABASE=@DATABASE@ DEFS=@DEFS@ -DDIFF=\"@DIFF@\" -DPATCH=\"@PATCH@\" LDFLAGS=@LDFLAGS@ @@ -70,6 +70,7 @@ SOURCES=src/client_chat.c \ src/tuiconfig.c \ src/citadel.c \ src/citadel_ipc.c \ + src/ecrash.c \ src/ipc_c_tcp.c \ src/screen.c @@ -93,10 +94,11 @@ citadel$(EXEEXT): src/citadel.o \ src/routines2.o \ src/tuiconfig.o \ src/screen.o \ + src/ecrash.o \ src/citadel_ipc.o \ src/ipc_c_tcp.o \ $(LIBOBJS) - $(CC) citadel.o \ + $(CC) src/citadel.o \ src/client_chat.o \ src/client_passwords.o \ src/commands.o \ @@ -107,6 +109,7 @@ citadel$(EXEEXT): src/citadel.o \ src/routines2.o \ src/tuiconfig.o \ src/screen.o \ + src/ecrash.o \ src/citadel_ipc.o \ src/ipc_c_tcp.o \ $(LIBOBJS) \ diff --git a/textclient/aclocal.m4 b/textclient/aclocal.m4 index 56e89469e..899da07b8 100644 --- a/textclient/aclocal.m4 +++ b/textclient/aclocal.m4 @@ -110,3 +110,4 @@ else fi ]) +m4_include([acinclude.m4]) diff --git a/textclient/bootstrap b/textclient/bootstrap index 636a4b168..9f4f84643 100755 --- a/textclient/bootstrap +++ b/textclient/bootstrap @@ -22,9 +22,6 @@ autoheader echo ... running mk_svn_revision.sh ... ./scripts/mk_svn_revision.sh -echo ... running mk_module_init.sh ... -./scripts/mk_module_init.sh - echo echo This script has been tested with autoconf 2.53 and echo automake 1.5. Other versions may work, but we recommend diff --git a/textclient/debian/rules b/textclient/debian/rules index 7e8178d20..7cb8f65d9 100755 --- a/textclient/debian/rules +++ b/textclient/debian/rules @@ -125,15 +125,6 @@ install-arch: build-arch $(MAKE) install-locale DESTDIR=$(DEB_DESTDIR) $(MAKE) DESTDIR=$(DEB_DESTDIR) install-exec-new install-data-new - install -D -p -m0755 database_cleanup.sh \ - $(DEB_DESTDIR)/usr/share/doc/citadel-server/examples/database_cleanup.sh - - install -D -p -m0644 docs/welcomemail.html \ - $(DEB_DESTDIR)/usr/share/doc/citadel-server/welcomemail.html - - install -D -p -m0644 docs/welcomemail.txt \ - $(DEB_DESTDIR)/usr/share/doc/citadel-server/welcomemail.txt - dh_install -s --sourcedir=debian/tmp binary-common: diff --git a/textclient/src/citadel.c b/textclient/src/citadel.c index 5821df404..3b958891e 100644 --- a/textclient/src/citadel.c +++ b/textclient/src/citadel.c @@ -41,9 +41,9 @@ #include #include #include -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" -#include "axdefs.h" +//#include "axdefs.h" #include "routines.h" #include "routines2.h" #include "tuiconfig.h" @@ -58,7 +58,7 @@ #include "snprintf.h" #endif #include "screen.h" -#include "citadel_dirs.h" +///#include "citadel_dirs.h" #include "ecrash.h" #include "md5.h" @@ -1005,8 +1005,8 @@ void system_info(CtdlIPC *ipc) CtdlIPCServerInfo(ipc, buf); scr_printf("You are connected to %s (%s) @%s\n", ipc->ServInfo.nodename, ipc->ServInfo.humannode, ipc->ServInfo.fqdn); - scr_printf("running %s with text client v%.2f,\n", ipc->ServInfo.software, (float)REV_LEVEL/100); - scr_printf("server build %s,\n", ipc->ServInfo.svn_revision, (float)REV_LEVEL/100); + scr_printf("running %s with text client v%.2f,\n", ipc->ServInfo.software, (float)CLIENT_VERSION/100); + scr_printf("server build %s,\n", ipc->ServInfo.svn_revision, (float)CLIENT_VERSION/100); scr_printf("and located in %s.\n", ipc->ServInfo.site_location); scr_printf("Connected users %d / Active users %d / Highest message #%ld\n", mrtg_users, mrtg_active_users, mrtg_himessage); scr_printf("Server uptime: %s\n", mrtg_server_uptime); @@ -1101,8 +1101,8 @@ void get_serv_info(CtdlIPC *ipc, char *supplied_hostname) moreprompt = ipc->ServInfo.moreprompt; /* be nice and identify ourself to the server */ - CtdlIPCIdentifySoftware(ipc, SERVER_TYPE, 0, REV_LEVEL, - (ipc->isLocal ? "local" : CITADEL), + CtdlIPCIdentifySoftware(ipc, CLIENT_TYPE, 0, CLIENT_VERSION, + (ipc->isLocal ? "local" : PACKAGE_STRING), (supplied_hostname) ? supplied_hostname : /* Look up the , in the bible if you're confused */ (locate_host(ipc, buf), buf), buf); @@ -1419,9 +1419,9 @@ int main(int argc, char **argv) #ifdef HAVE_BACKTRACE bzero(¶ms, sizeof(params)); - params.filename = file_pid_paniclog; +// params.filename = file_pid_paniclog; // panic_fd=open(file_pid_paniclog, O_APPEND|O_CREAT|O_DIRECT); - params.filep = fopen(file_pid_paniclog, "a+"); +/// params.filep = fopen(file_pid_paniclog, "a+"); params.debugLevel = ECRASH_DEBUG_VERBOSE; params.dumpAllThreads = TRUE; params.useBacktraceSymbols = 1; @@ -1432,7 +1432,7 @@ int main(int argc, char **argv) params.signals[2]=SIGBUS; params.signals[3]=SIGABRT; - eCrash_Init(¶ms); +/// eCrash_Init(¶ms); #endif setIPCErrorPrintf(scr_printf); setCryptoStatusHook(statusHook); diff --git a/textclient/src/citadel_ipc.c b/textclient/src/citadel_ipc.c index 15e860a4b..8a65f85d9 100644 --- a/textclient/src/citadel_ipc.c +++ b/textclient/src/citadel_ipc.c @@ -40,10 +40,10 @@ #include #endif #include -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" -#include "citadel_decls.h" -#include "citadel_dirs.h" +//#include "citadel_decls.h" +//#include "citadel_dirs.h" #ifdef THREADED_CLIENT pthread_mutex_t rwlock; #endif @@ -63,6 +63,135 @@ pthread_mutex_t **Critters; /* Things that need locking */ #endif static void (*status_hook)(char *s) = NULL; +char ctdl_autoetc_dir[PATH_MAX]=""; +char file_citadel_rc[PATH_MAX]=""; +char ctdl_run_dir[PATH_MAX]=""; +char ctdl_etc_dir[PATH_MAX]=""; +char ctdl_home_directory[PATH_MAX] = ""; +char file_citadel_socket[PATH_MAX]=""; +char file_citadel_config[PATH_MAX]=""; + + +char *viewdefs[]={ + "Messages", + "Summary", + "Address book", + "Calendar", + "Tasks" +}; + +char *axdefs[]={ + "Deleted", + "New User", + "Problem User", + "Local User", + "Network User", + "Preferred User", + "Aide", + "Sysop" + }; + + +INLINE void CtdlIPC_lock(CtdlIPC *ipc) +{ + if (ipc->network_status_cb) ipc->network_status_cb(1); +#ifdef THREADED_CLIENT + pthread_mutex_lock(&(ipc->mutex)); +#endif +} + + +INLINE void CtdlIPC_unlock(CtdlIPC *ipc) +{ +#ifdef THREADED_CLIENT + pthread_mutex_unlock(&(ipc->mutex)); +#endif + if (ipc->network_status_cb) ipc->network_status_cb(0); +} + +#ifdef __cplusplus +} +#endif + + +char *libcitadelclient_version_string(void) { + return "libcitadelclient(unnumbered)"; +} + + + + +#define COMPUTE_DIRECTORY(SUBDIR) memcpy(dirbuffer,SUBDIR, sizeof dirbuffer);\ + snprintf(SUBDIR,sizeof SUBDIR, "%s%s%s%s%s%s%s", \ + (home&!relh)?ctdl_home_directory:basedir, \ + ((basedir!=ctdldir)&(home&!relh))?basedir:"/", \ + ((basedir!=ctdldir)&(home&!relh))?"/":"", \ + relhome, \ + (relhome[0]!='\0')?"/":"",\ + dirbuffer,\ + (dirbuffer[0]!='\0')?"/":""); + +#define DBG_PRINT(A) if (dbg==1) fprintf (stderr,"%s : %s \n", #A, A) + + +void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg) +{ + const char* basedir = ""; + char dirbuffer[PATH_MAX] = ""; + + StripSlashes(ctdldir, 1); + +#ifndef HAVE_RUN_DIR + basedir=ctdldir; +#else + basedir=RUN_DIR; +#endif + COMPUTE_DIRECTORY(ctdl_run_dir); + StripSlashes(ctdl_run_dir, 1); + + +#ifndef HAVE_AUTO_ETC_DIR + basedir=ctdldir; +#else + basedir=AUTO_ETC_DIR; +#endif + COMPUTE_DIRECTORY(ctdl_autoetc_dir); + StripSlashes(ctdl_autoetc_dir, 1); + + +#ifndef HAVE_ETC_DIR + basedir=ctdldir; +#else + basedir=ETC_DIR; +#endif + COMPUTE_DIRECTORY(ctdl_etc_dir); + StripSlashes(ctdl_etc_dir, 1); + + + + snprintf(file_citadel_rc, + sizeof file_citadel_rc, + "%scitadel.rc", + ctdl_etc_dir); + StripSlashes(file_citadel_rc, 0); + + snprintf(file_citadel_socket, + sizeof file_citadel_socket, + "%scitadel.socket", + ctdl_run_dir); + StripSlashes(file_citadel_socket, 0); + + snprintf(file_citadel_config, + sizeof file_citadel_config, + "%scitadel.config", + ctdl_autoetc_dir); + StripSlashes(file_citadel_config, 0); + + DBG_PRINT(ctdl_run_dir); + DBG_PRINT(file_citadel_socket); + DBG_PRINT(ctdl_etc_dir); + DBG_PRINT(file_citadel_rc); +} void setCryptoStatusHook(void (*hook)(char *s)) { status_hook = hook; @@ -1545,7 +1674,7 @@ int CtdlIPCIdentifySoftware(CtdlIPC *ipc, int developerid, int clientid, !software_name) { developerid = 8; clientid = 0; - revision = REV_LEVEL - 600; + revision = CLIENT_VERSION - 600; software_name = "Citadel (libcitadel)"; } if (!hostname) return -2; diff --git a/textclient/src/client_chat.c b/textclient/src/client_chat.c index 760ce5934..29f3e267d 100644 --- a/textclient/src/client_chat.c +++ b/textclient/src/client_chat.c @@ -39,7 +39,7 @@ #endif #include #include -#include "citadel.h" +//#include "citadel.h" #include "citadel_ipc.h" #include "client_chat.h" #include "commands.h" @@ -47,9 +47,9 @@ #include "citadel_decls.h" #include "rooms.h" #include "messages.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +//#ifndef HAVE_SNPRINTF +//#include "snprintf.h" +//#endif #include "screen.h" #define MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/textclient/src/client_passwords.c b/textclient/src/client_passwords.c index aabb7d918..3e864a41a 100644 --- a/textclient/src/client_passwords.c +++ b/textclient/src/client_passwords.c @@ -24,7 +24,7 @@ #include #include #include -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" #include "commands.h" #include "client_passwords.h" diff --git a/textclient/src/commands.c b/textclient/src/commands.c index 426849a95..4fe088316 100644 --- a/textclient/src/commands.c +++ b/textclient/src/commands.c @@ -51,7 +51,7 @@ #include #include #include -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" #include "commands.h" #include "messages.h" @@ -60,11 +60,11 @@ #include "routines2.h" #include "rooms.h" #include "client_chat.h" -#include "citadel_dirs.h" +////#include "citadel_dirs.h" #include "tuiconfig.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +//#ifndef HAVE_SNPRINTF +//#include "snprintf.h" +///#endif #include "screen.h" #include "ecrash.h" diff --git a/textclient/src/include/citadel_ipc.h b/textclient/src/include/citadel_ipc.h index c67cfd310..1236743b2 100644 --- a/textclient/src/include/citadel_ipc.h +++ b/textclient/src/include/citadel_ipc.h @@ -1,3 +1,8 @@ +#ifdef __GNUC__ +#define INLINE __inline__ +#else +#define INLINE +#endif #define UDS "_UDS_" #ifdef __CYGWIN__ @@ -7,7 +12,9 @@ #endif #define DEFAULT_PORT "504" -#include "sysdep.h" +#include +#include +////#include "sysdep.h" #ifdef HAVE_PTHREAD_H #include #endif @@ -17,7 +24,108 @@ #include #endif -#include "server.h" +#define CLIENT_VERSION 811 +#define CLIENT_TYPE 0 +//copycat of: /#include "server.h" + +#define ROOMNAMELEN 128 /* The size of a roomname string */ + +// copycat of citadel_dirs.h +void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg); + +//copycat of: /#include "citadel.h" +/* commands we can send to the stty_ctdl() routine */ +#define SB_NO_INTR 0 /* set to Citadel client mode, i/q disabled */ +#define SB_YES_INTR 1 /* set to Citadel client mode, i/q enabled */ +#define SB_SAVE 2 /* save settings */ +#define SB_RESTORE 3 /* restore settings */ +#define SB_LAST 4 /* redo the last command sent */ + +#define UGLISTLEN 100 /* you get a ungoto list of this size */ + +#define USERNAME_SIZE 64 /* The size of a username string */ +#define MAX_EDITORS 5 /* # of external editors supported */ + /* MUST be at least 1 */ + +#define NONCE_SIZE 128 /* Added by to allow for APOP auth + * it is BIG becuase there is a hostname + * in the nonce, as per the APOP RFC. + */ + +/* + * S_KEEPALIVE is a watchdog timer. It is used to send "keep + * alive" messages to the server to prevent the server from assuming the + * client is dead and terminating the session. 30 seconds is the recommended + * value; I can't think of any good reason to change it. + */ +#define S_KEEPALIVE 30 + +#define READ_HEADER 2 +#define READ_MSGBODY 3 + +#define NUM_CONFIGS 70 + + + +/* + * This struct stores a list of rooms with new messages which the client + * fetches from the server. This allows the client to "march" through + * relevant rooms without having to ask the server each time where to go next. + */ +typedef struct ExpirePolicy ExpirePolicy; +struct ExpirePolicy { + int expire_mode; + int expire_value; +}; + +typedef struct march march; +struct march { + struct march *next; + char march_name[ROOMNAMELEN]; + unsigned int march_flags; + char march_floor; + char march_order; + unsigned int march_flags2; + int march_access; +}; +/* + * User records. + */ +typedef struct ctdluser ctdluser; +struct ctdluser { /* User record */ + int version; /* Cit vers. which created this rec */ + uid_t uid; /* Associate with a unix account? */ + char password[32]; /* password */ + unsigned flags; /* See US_ flags below */ + long timescalled; /* Total number of logins */ + long posted; /* Number of messages ever submitted */ + uint8_t axlevel; /* Access level */ + long usernum; /* User number (never recycled) */ + time_t lastcall; /* Date/time of most recent login */ + int USuserpurge; /* Purge time (in days) for user */ + char fullname[64]; /* Display name (primary identifier) */ +}; +typedef struct ctdlroom ctdlroom; +struct ctdlroom { + char QRname[ROOMNAMELEN]; /* Name of room */ + char QRpasswd[10]; /* Only valid if it's a private rm */ + long QRroomaide; /* User number of room aide */ + long QRhighest; /* Highest message NUMBER in room */ + time_t QRgen; /* Generation number of room */ + unsigned QRflags; /* See flag values below */ + char QRdirname[15]; /* Directory name, if applicable */ + long QRinfo; /* Info file update relative to msgs*/ + char QRfloor; /* Which floor this room is on */ + time_t QRmtime; /* Date/time of last post */ + struct ExpirePolicy QRep; /* Message expiration policy */ + long QRnumber; /* Globally unique room number */ + char QRorder; /* Sort key for room listing order */ + unsigned QRflags2; /* Additional flags */ + int QRdefaultview; /* How to display the contents */ +}; + + +///////////// #ifdef __cplusplus extern "C" { @@ -190,6 +298,8 @@ enum MessageDirection { ReadReverse = -1, ReadForward = 1 }; +extern char file_citadel_rc[PATH_MAX]; +extern char file_citadel_config[PATH_MAX]; /* Shared Diffie-Hellman parameters */ #define DH_P "F6E33BD70D475906ABCFB368DA2D1E5611D57DFDAC6A10CD78F406D6952519C74E21FFDCC5A780B9359722AACC8036E4CD24D5F5165EAC9EF226DBD9BBCF678F8DDEE86386F1BC20E291A9854A513A2CA326B411DC92E38F2ED2FEB6A3B792F13DB6550371FDBAC5ECA373BE5050CA4905431CA86088737D52B36C8D13CE9CB4EEF4C910285035E8329DD07551A80B87775676DD1067395CCEE9040C9B8BF998C528B3772B4C590A2CF18C5E58929BFCB538A62638B7437A9C68572D15287E97692B0B1EC5444D9DAB6EB062D20B79CA005EC5035065567AFD1FEF9B251D74747C6065D8C8B6B0862D1EE03F3A244C429EADE0CCC5C3A4196F5CBF5AA01A9026EFB20AA90E462BD64620278F271905EB604F38E6CFAE412EAA6C468E3B58170909BC18662FE2053224F30BE4FDB93BF9FBF969D91A5427A0665AC7BD1C43701B991094C92F7A935063055617142164F02973EB4ED86DD74D2BBAB3CD3B28F7BBD8D9F925B0FE92F7F7D0568D783F9ECE7AF96FB5AF274B586924B64639733A73ACA8F2BD1E970DF51ADDD983F7F6361A2B0DC4F086DE26D8656EC8813DE4B74D6D57BC1E690AC2FF1682B7E16938565A41D1DC64C75ADB81DA4582613FC68C0FDD327D35E2CDF20D009465303773EF3870FBDB0985EE7002A95D7912BBCC78187C29DB046763B7FABFF44EABE820F8ED0D7230AA0AF24F428F82448345BC099B" @@ -366,23 +476,43 @@ char CtdlIPC_get(CtdlIPC* ipc); -static INLINE void CtdlIPC_lock(CtdlIPC *ipc) -{ - if (ipc->network_status_cb) ipc->network_status_cb(1); -#ifdef THREADED_CLIENT - pthread_mutex_lock(&(ipc->mutex)); -#endif -} +INLINE void CtdlIPC_lock(CtdlIPC *ipc); +INLINE void CtdlIPC_unlock(CtdlIPC *ipc); -static INLINE void CtdlIPC_unlock(CtdlIPC *ipc) -{ -#ifdef THREADED_CLIENT - pthread_mutex_unlock(&(ipc->mutex)); -#endif - if (ipc->network_status_cb) ipc->network_status_cb(0); -} +char *libcitadelclient_version_string(void); -#ifdef __cplusplus -} +/* commands we can send to the stty_ctdl() routine */ +#define SB_NO_INTR 0 /* set to Citadel client mode, i/q disabled */ +#define SB_YES_INTR 1 /* set to Citadel client mode, i/q enabled */ +#define SB_SAVE 2 /* save settings */ +#define SB_RESTORE 3 /* restore settings */ +#define SB_LAST 4 /* redo the last command sent */ + +#define NEXT_KEY 15 +#define STOP_KEY 3 + +/* citadel.rc stuff */ +#define RC_NO 0 /* always no */ +#define RC_YES 1 /* always yes */ +#define RC_DEFAULT 2 /* setting depends on user config */ + +/* keepalives */ +enum { + KA_NO, /* no keepalives */ + KA_YES, /* full keepalives */ + KA_HALF /* half keepalives */ +}; + +/* for <;G>oto and <;S>kip commands */ +#define GF_GOTO 0 /* <;G>oto floor mode */ +#define GF_SKIP 1 /* <;S>kip floor mode */ +#define GF_ZAP 2 /* <;Z>ap floor mode */ + + +#ifndef AXDEFS + +extern char *axdefs[]; + +extern char *viewdefs[]; #endif diff --git a/textclient/src/ipc_c_tcp.c b/textclient/src/ipc_c_tcp.c index a6cae96c7..d87cdf5b7 100644 --- a/textclient/src/ipc_c_tcp.c +++ b/textclient/src/ipc_c_tcp.c @@ -21,13 +21,41 @@ #include #include #include -#include "citadel.h" +//#include "citadel.h" #include "citadel_ipc.h" -#include "citadel_decls.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +//#include "citadel_decls.h" +//#ifndef HAVE_SNPRINTF +//#include "snprintf.h" +//#endif #include "commands.h" +#include +#include +#include +#include +#include +#include +#include + +#if TIME_WITH_SYS_TIME +# include +# include +#else +# if HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#ifdef HAVE_TERMIOS_H +#include +#else +#include +#endif + +#ifdef HAVE_SYS_SELECT_H +#include +#endif /* Note that some of these functions may not work with multiple instances. */ diff --git a/textclient/src/messages.c b/textclient/src/messages.c index 6cc8f6a6f..66299f30b 100644 --- a/textclient/src/messages.c +++ b/textclient/src/messages.c @@ -43,16 +43,16 @@ #include #include -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" #include "citadel_decls.h" #include "messages.h" #include "commands.h" #include "tuiconfig.h" #include "rooms.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +//#ifndef HAVE_SNPRINTF +///#include "snprintf.h" +//#endif #include "screen.h" #define MAXWORDBUF SIZ diff --git a/textclient/src/rooms.c b/textclient/src/rooms.c index 6dcc99bb6..732661e57 100644 --- a/textclient/src/rooms.c +++ b/textclient/src/rooms.c @@ -26,18 +26,18 @@ #include #include #include -#include "citadel.h" +//#include "citadel.h" #include "citadel_ipc.h" #include "citadel_decls.h" #include "rooms.h" #include "commands.h" #include "messages.h" #include "tuiconfig.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +//#ifndef HAVE_SNPRINTF +//#include "snprintf.h" +//#endif #include "screen.h" -#include "citadel_dirs.h" +//#include "citadel_dirs.h" #define IFNEXPERT if ((userflags&US_EXPERT)==0) diff --git a/textclient/src/routines.c b/textclient/src/routines.c index f7261ee2d..33e05c81a 100644 --- a/textclient/src/routines.c +++ b/textclient/src/routines.c @@ -48,7 +48,7 @@ #endif #include -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" #include "screen.h" @@ -58,7 +58,7 @@ struct utmp *getutline(struct utmp *ut); #define ROUTINES_C -#include "citadel.h" +///#include "citadel.h" #include "routines.h" #include "commands.h" #include "citadel_decls.h" diff --git a/textclient/src/routines2.c b/textclient/src/routines2.c index afe38dbb9..32ec9fc01 100644 --- a/textclient/src/routines2.c +++ b/textclient/src/routines2.c @@ -40,16 +40,16 @@ #include #include #include "sysdep.h" -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" #include "citadel_decls.h" #include "routines2.h" #include "routines.h" #include "commands.h" -#include "messages.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +//#include "messages.h" +//#ifndef HAVE_SNPRINTF +//#include "snprintf.h" +//#endif #include "screen.h" /* work around solaris include files */ diff --git a/textclient/src/screen.c b/textclient/src/screen.c index 6bcc4b5f8..4144c2404 100644 --- a/textclient/src/screen.c +++ b/textclient/src/screen.c @@ -23,11 +23,11 @@ #include #include #include "sysdep.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +///#ifndef HAVE_SNPRINTF +///#include "snprintf.h" +///#endif #include -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" #include "citadel_decls.h" #include "commands.h" diff --git a/textclient/src/tuiconfig.c b/textclient/src/tuiconfig.c index 3ec778329..254f4e6bc 100644 --- a/textclient/src/tuiconfig.c +++ b/textclient/src/tuiconfig.c @@ -39,16 +39,16 @@ #include #include #include "sysdep.h" -#include "citadel.h" +///#include "citadel.h" #include "citadel_ipc.h" #include "citadel_decls.h" #include "tuiconfig.h" #include "messages.h" #include "routines.h" #include "commands.h" -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif +///#ifndef HAVE_SNPRINTF +///#include "snprintf.h" +///#endif #include "screen.h" /* work around solaris include files */