Skip to content

Commit

Permalink
Add deprecation warning and transition code for my-ip/my-hostname. Me…
Browse files Browse the repository at this point in the history
…rges #152.
  • Loading branch information
thommey committed Apr 18, 2016
2 parents 98bb0da + dc74cec commit 28b71d2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/net.c
Expand Up @@ -1474,3 +1474,27 @@ int findsock(int sock)
return -1;
return i;
}

/* Trace on my-ip and my-hostname variable to handle transition into vhost4/vhost6/listen-addr.
*/
char *traced_myiphostname(ClientData cd, Tcl_Interp *irp, EGG_CONST char *name1, EGG_CONST char *name2, int flags)
{
const char *value;

if (flags & TCL_INTERP_DESTROYED)
return NULL;
/* Recover trace in case of unset. */
if (flags & TCL_TRACE_DESTROYED) {
Tcl_TraceVar2(irp, name1, name2, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, traced_myiphostname, cd);
return NULL;
}

value = Tcl_GetVar2(irp, name1, name2, TCL_GLOBAL_ONLY);
strncpyz(vhost, value, sizeof vhost);
strncpyz(listen_ip, value, sizeof listen_ip);
putlog(LOG_MISC, "*", "WARNING: You are using the DEPRECATED variable '%s' in your config file.\n", name1);
putlog(LOG_MISC, "*", " To prevent future incompatibility, please use the vhost4/listen-addr variables instead.\n");
putlog(LOG_MISC, "*", " More information on this subject can be found in the eggdrop/doc/IPV6 file, or\n");
putlog(LOG_MISC, "*", " in the comments above those settings in the example eggdrop.conf that is included with Eggdrop.\n");
return NULL;
}
6 changes: 6 additions & 0 deletions src/tcl.c
Expand Up @@ -97,6 +97,8 @@ int handlen = HANDLEN;
int utftot = 0;
int clientdata_stuff = 0;

extern Tcl_VarTraceProc traced_myiphostname;

int expmem_tcl()
{
return strtot + utftot + clientdata_stuff;
Expand Down Expand Up @@ -472,13 +474,17 @@ static void init_traces()
add_tcl_coups(def_tcl_coups);
add_tcl_strings(def_tcl_strings);
add_tcl_ints(def_tcl_ints);
Tcl_TraceVar(interp, "my-ip", TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, traced_myiphostname, NULL);
Tcl_TraceVar(interp, "my-hostname", TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, traced_myiphostname, NULL);
}

void kill_tcl()
{
rem_tcl_coups(def_tcl_coups);
rem_tcl_strings(def_tcl_strings);
rem_tcl_ints(def_tcl_ints);
Tcl_UntraceVar(interp, "my-ip", TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, traced_myiphostname, NULL);
Tcl_UntraceVar(interp, "my-hostname", TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, traced_myiphostname, NULL);
kill_bind();
Tcl_DeleteInterp(interp);
}
Expand Down

0 comments on commit 28b71d2

Please sign in to comment.