Before we start with the grand string tidy up, its a good idea to remove any code from PGPlus that we don’t need.

The first item in the crosshairs is history.c. Nothing within PGPlus currently uses those functions, and when we later come to needing history like functionality we can do a better job with a somewhat different algorithm. Removal is relatively simple, first we delete the file from the src directory. Next we delete these lines from proto.h:
/* historee externs */
extern history *init_hist ( int );
extern void add_to_hist ( history *, char * );
extern int stack_hist ( history *, int, char * );
extern void clean_hist ( history * );
extern void free_hist ( history * );
extern void init_global_histories ( void );

And finally we delete this line from glue.c:
init_global_histories(); /* history logging */

Our next target is ident. Historically ident was used to provide the name of a user connected to a specific port, which was somewhat useful in the early days of telnet talkers. However these days ident servers are rare, Windows for example has no ident service and most Linux distro’s either don’t include one or have it disabled by default.  Removing ident is a little more complicated than history, but far more worthwhile from a time perspective.

Our first task is to remove it from the list of files that are compiled every time we compile the talker. To do that we need to edit src/configure/makefile.template and remove the following line:
IDENT = ident_server
Next we edit these lines to remove $(IDENT) from the list:
ifdef STRIP
all: $(TALKER) $(ANGEL) $(IDENT) $(INTERCOM) strip
else
all: $(TALKER) $(ANGEL) $(IDENT) $(INTERCOM)
endif
else
all: $(TALKER) $(ANGEL) $(IDENT) $(INTERCOM)
endif

We now completely delete this section:
$(IDENT): ident_server.c include/ident.h Makefile
@echo "Now compiling .... ident server"
@$(CC) $(CFLAGS) $(DEFS) -o $(IDENT) ident_server.c $(LIBS)

Followed by deleting these 2 lines:
@echo "Now stripping .... $(IDENT) binary"
@strip $(IDENT)

And then these 3 lines:
@echo "Now installing ... $(IDENT) binary"
@mv $(IDENT) $(BIN)/$(IDENT)
@chmod $(PERMS) $(BIN)/$(IDENT)

Finally we remove $(IDENT) from this line:
@-rm -f $(TALKER) $(ANGEL) $(IDENT) $(INTERCOM) $(OBJECTS) ../junk/*
And save that file. Next we need to edit Configure.options in the same folder, removing this line from the file:
bool 'Include ident server lookup code' IDENT
After closing that file, we need to edit Configure.help to remove these lines:
Include ident server lookup code
IDENT
Allows the admin to see what account name a user is connecting with
provided the server they are connecting from uses an ident server.

Now that the configure and makefiles have been edited, we can start removing the code. So we begin by deleting ident_server.c and ident_client.c. Next we need to track down any ident code in the talker itself. typing ./qs 'def IDENT' in our src directory will list every file we need to edit. As the first 2 edits in glue.c are non intuitive I’ll show them here, the rest are just simple deletes.
#ifndef IDENT
if (q == NULL || p == q)
#else
if (q == NULL) /* residents don't see their own ident lookup */
#endif

Becomes:
if (q == NULL || p == q)
Likewise:
#ifndef IDENT
if (can_get_addy)
return (p->inet_addr);return 0;
}
#else
#ifdef ROBOTS
if (!can_get_addy || (!strcasecmp(p->remote_user, "<") && !strcasecmp(p->remote_user, ">")) || p->residency & ROBOT_PRIV)
#else
if (!can_get_addy || (!strcasecmp(p->remote_user, "<") && !strcasecmp(p->remote_user, ">")))
#endif
{
sprintf(retstr, "%s", p->inet_addr);
while (*retstr)
retstr++;
}
else
{
sprintf(retstr, "%s@%s", p->remote_user, p->inet_addr);
while (*retstr)
retstr++;
}
*retstr++ = 0;return addy;
}
#endif

Becomes:
if (can_get_addy)
return (p->inet_addr);return 0;
}

And with that (and the edits I’m leaving to you) the old ident code is purged from the talker.

The next item to remove is the robots code. Sadly there are very few robots for PGPlus, with those that exist tending to connect to the talker via a normal login. Purging this code is a little less complicated than ident, but just as fiddly.
Just for kicks, I’ll do this one backwards. Start by deleting robot_plist.c and robot_int.c from the src directory, along with the 2 header files robot_player.h and robot_proto.h.
Next we search in our src folder for “def ROBOTS” and “def INTELLIBOTS”, as before we delete any code found. Finally we move into the configure directory, and remove the references to ROBOTS from both Configure.options and Configure.help.

With all of that done, we can now “make newos” to update our makefile, “make configure” to update our configuration, and finally “make install” to enjoy the fruits of our labours.

Advertisements