Skip to content

Commit

Permalink
Remove dependence of compress module on share module
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Nov 11, 2022
1 parent 55595ab commit b99e37d
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 40 deletions.
8 changes: 4 additions & 4 deletions doc/MODULES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Eggdrop Module Information Last revised: Jul 25, 2016
Eggdrop Module Information Last revised: Nov 10, 2022

Eggdrop Module Information

Expand Down Expand Up @@ -60,9 +60,9 @@ MODULES INCLUDED WITH EGGDROP

compress

This module provides support for file compression. This allows the
bot to transfer compressed user files and, therefore, save a
significant amount of bandwidth.
This module provides support for file compression. With share module
loaded this allows the bot to transfer compressed user files and,
therefore, save a significant amount of bandwidth.

console

Expand Down
4 changes: 2 additions & 2 deletions doc/modules/MODULES
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ channels

compress

This module provides support for file compression. This allows the
bot to transfer compressed user files and, therefore, save a
This module provides support for file compression. With share module loaded
this allows the bot to transfer compressed user files and, therefore, save a
significant amount of bandwidth.

console
Expand Down
6 changes: 3 additions & 3 deletions doc/sphinx_source/modules/included.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Modules included with Eggdrop
or save channel specific userfile information.

:ref:`compress`
This module provides support for file compression. This
allows the bot to transfer compressed user files and, therefore,
save a significant amount of bandwidth.
This module provides support for file compression. With share module loaded
this allows the bot to transfer compressed user files and, therefore, save a
significant amount of bandwidth.

:ref:`console`
This module provides storage of console settings when you exit
Expand Down
10 changes: 4 additions & 6 deletions doc/sphinx_source/modules/mod/compress.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
Last revised: May 27, 2004
Last revised: Nov 10, 2022

.. _compress:

===============
Compress Module
===============

This module provides support for file compression. It can be used
to compress files via Tcl or to transfer the userfile compressed during the
share process, saving bandwidth.

This module requires: share
This module provides support for file compression. It can be used to compress
files via Tcl or, with share module loaded, to transfer the userfile compressed
during the share process, saving bandwidth.

Put this line into your Eggdrop configuration file to load the compress
module::
Expand Down
8 changes: 4 additions & 4 deletions eggdrop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1510,10 +1510,10 @@ set xfer-timeout 30

#### COMPRESS MODULE ####

# This module provides support for file compression. This allows the
# bot to transfer compressed user files and therefore save a significant amount
# of bandwidth. The share module must be loaded to load this module. Un-comment
# the following line to the compress module.
# This module provides support for file compression. With share module loaded
# this allows the bot to transfer compressed user files and therefore save a
# significant amount of bandwidth. Un-comment the following line to the compress
# module.
#loadmodule compress

# Allow compressed sending of user files? The user files are compressed with
Expand Down
23 changes: 15 additions & 8 deletions src/mod/compress.mod/compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,25 @@ static char *compress_close()
rem_help_reference("compress.help");
rem_tcl_commands(my_tcl_cmds);
rem_tcl_ints(my_tcl_ints);
uff_deltable(compress_uff_table);

if (module_find("share", 2, 5))
uff_deltable(compress_uff_table);

module_undepend(MODULE_NAME);
return NULL;
}

EXPORT_SCOPE char *compress_start();

static void compress_start_share() {
module_entry *me = module_find("share", 2, 5);
if (me) {
share_funcs = me->funcs;
uff_addtable(compress_uff_table);
}
debug0("added compression mod funcs to share mod");
}

static Function compress_table[] = {
/* 0 - 3 */
(Function) compress_start,
Expand All @@ -433,6 +444,7 @@ static Function compress_table[] = {
(Function) uncompress_file,
/* 8 - 11 */
(Function) is_compressedfile,
(Function) compress_start_share,
};

char *compress_start(Function *global_funcs)
Expand All @@ -444,19 +456,14 @@ char *compress_start(Function *global_funcs)
share_compressed = 0;
compress_level = 9;

module_register(MODULE_NAME, compress_table, 1, 2);
module_register(MODULE_NAME, compress_table, 1, 3);
if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.8.0 or later.";
}

share_funcs = module_depend(MODULE_NAME, "share", 2, 3);
if (!share_funcs) {
module_undepend(MODULE_NAME);
return "This module requires share module 2.3 or later.";
}
compress_start_share();

uff_addtable(compress_uff_table);
add_tcl_ints(my_tcl_ints);
add_tcl_commands(my_tcl_cmds);
add_help_reference("compress.help");
Expand Down
11 changes: 6 additions & 5 deletions src/mod/compress.mod/compress.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ typedef enum {

#ifndef MAKING_COMPRESS
/* 4 - 7 */
# define compress_to_file ((int (*)(char *, char *, int))(compress_funcs[4]))
# define compress_file ((int (*)(char *, int))(compress_funcs[5]))
# define uncompress_to_file ((int (*)(char *, char *))(uncompress_funcs[6]))
# define uncompress_file ((int (*)(char *))(uncompress_funcs[7]))
# define compress_to_file ((int (*)(char *, char *, int))(compress_funcs[4]))
# define compress_file ((int (*)(char *, int))(compress_funcs[5]))
# define uncompress_to_file ((int (*)(char *, char *))(uncompress_funcs[6]))
# define uncompress_file ((int (*)(char *))(uncompress_funcs[7]))
/* 8 - 11 */
# define is_compressedfile ((int (*)(char *))(uncompress_funcs[8]))
# define is_compressedfile ((int (*)(char *))(uncompress_funcs[8]))
# define compress_start_share ((void (*)(void))(compress_funcs[9]))
#endif /* !MAKING_COMPRESS */

#endif /* !_EGG_MOD_COMPRESS_COMPRESS_H */
4 changes: 2 additions & 2 deletions src/mod/compress.mod/help/compress.help
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%{help=compress module}%{+n}
### %bcompress module%b
This module provides support for file compression. It can be used
to compress files via Tcl or to transfer the userfile compressed during the
share process, saving bandwidth.
to compress files via Tcl or, with share module loaded, to transfer the
userfile compressed during the share process, saving bandwidth.

Config file variables for configuring the compress module:
%bcompress-level share-compressed%b
Expand Down
8 changes: 4 additions & 4 deletions src/mod/compress.mod/modinfo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DESC:The compress module provides support for file compression. This
DESC:allows the bot to transfer compressed user files and therefore
DESC:saves a significant amount of bandwidth, especially on very active
DESC:hubs. The module depends on the zlib library.
DESC:The compress module provides support for file compression. With share
DESC:module loaded this allows the bot to transfer compressed user files and
DESC:therefore saves a significant amount of bandwidth, especially on very
DESC:active hubs. The module depends on the zlib library.
DESC:
DESC:You will want to ENABLE this module if you have enough CPU time
DESC:to spare.
Expand Down
14 changes: 12 additions & 2 deletions src/mod/share.mod/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "src/users.h"
#include "transfer.mod/transfer.h"
#include "channels.mod/channels.h"
#include "compress.mod/compress.h"

/* Minimum version I will share with. */
static const int min_share = 1029900;
Expand All @@ -44,7 +45,8 @@ static const int min_exemptinvite = 1032800;
/* Minimum version that supports userfile features. */
static const int min_uffeature = 1050200;

static Function *global = NULL, *transfer_funcs = NULL, *channels_funcs = NULL;
static Function *global = NULL, *transfer_funcs = NULL, *channels_funcs = NULL,
*compress_funcs = NULL;

static int private_global = 0;
static int private_user = 0;
Expand Down Expand Up @@ -2349,10 +2351,11 @@ static Function share_table[] = {

char *share_start(Function *global_funcs)
{
module_entry *me;

global = global_funcs;

module_register(MODULE_NAME, share_table, 2, 4);
module_register(MODULE_NAME, share_table, 2, 5);
if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.8.0 or later.";
Expand All @@ -2378,6 +2381,13 @@ char *share_start(Function *global_funcs)
add_builtins(H_dcc, my_cmds);
uff_init();
uff_addtable(internal_uff_table);

me = module_find("compress", 1, 3);
if (me) {
compress_funcs = me->funcs;
compress_start_share();
}

return NULL;
}

Expand Down

0 comments on commit b99e37d

Please sign in to comment.