[X2serv-cvs] [CVS] Module x3: Change committed
Brought to you by:
sirvulcan
From: Alex S. <ru...@us...> - 2005-03-17 20:18:49
|
Committer : Alex Schumann <ru...@us...> CVSROOT : /cvsroot/x2serv Module : x3 Commit time: 2005-03-17 20:18:39 UTC Modified files: ChangeLog.X3 src/chanserv.c src/helpfile.c src/opserv.c Log message: Made some stuff pretty.. including USERS, STATS NETWORK, and TRACE PRINT. ---------------------- diff included ---------------------- Index: x3/ChangeLog.X3 diff -u x3/ChangeLog.X3:1.9 x3/ChangeLog.X3:1.10 --- x3/ChangeLog.X3:1.9 Tue Mar 15 21:29:08 2005 +++ x3/ChangeLog.X3 Thu Mar 17 12:18:28 2005 @@ -1,6 +1,16 @@ /*********************************************************************** X3 ChangeLog +2005-03-17 Alex Schumann <ru...@af...> + + * src/opserv.c: Improved readability of trace print output + + * src/chanserv.c: Improved cmd_list_users output & cleaned it up + a little. + + * src/helpfile.c: Improved table_send readability (used in lots + of listings including users and stats network etc) + 2005-03-15 Alex Schumann <ru...@af...> * src/chanserv.c: Improved some syntax error reporting for commands @@ -45,5 +55,5 @@ ***********************************************************************/ -#define CVS_VERSION "$Revision: 1.9 $" +#define CVS_VERSION "$Revision: 1.10 $" Index: x3/src/chanserv.c diff -u x3/src/chanserv.c:1.16 x3/src/chanserv.c:1.17 --- x3/src/chanserv.c:1.16 Tue Mar 15 21:16:50 2005 +++ x3/src/chanserv.c Thu Mar 17 12:18:29 2005 @@ -319,8 +319,8 @@ { "CSMSG_BANS_REMOVED", "Removed all channel bans from $b%s$b." }, /* Channel userlist */ - { "CSMSG_ACCESS_ALL_HEADER", "%s users from level %d to %d:" }, - { "CSMSG_ACCESS_SEARCH_HEADER", "%s users from level %d to %d matching %s:" }, + { "CSMSG_ACCESS_ALL_HEADER", "=---- %s users from level %d to %d ----=" }, + { "CSMSG_ACCESS_SEARCH_HEADER", "=-- %s users from level %d to %d matching %s --=" }, { "CSMSG_INVALID_ACCESS", "$b%s$b is an invalid access level." }, { "CSMSG_CHANGED_ACCESS", "%s now has access $b%d$b in %s." }, @@ -670,6 +670,17 @@ return level; } +char * +user_level_name_from_level(int level) +{ + unsigned int ii; + for(ii = 0; (ii < ArrayLength(accessLevels)); ii++) + if(level == accessLevels[ii].level) + return accessLevels[ii].title; + return("UNKNOWN"); +} + + int parse_level_range(unsigned short *minl, unsigned short *maxl, const char *arg) { @@ -3461,6 +3472,7 @@ return 1; } +/* This is never used... */ static void zoot_list(struct listData *list) { @@ -3556,8 +3568,10 @@ lData.highest = highest; lData.search = (argc > 1) ? argv[1] : NULL; send_list = def_list; + /* What does the following line do exactly?? */ (void)zoot_list; /* since it doesn't show user levels */ + /* this does nothing!! -rubin if(user->handle_info) { switch(user->handle_info->userlist_style) @@ -3566,6 +3580,7 @@ case HI_STYLE_ZOOT: send_list = def_list; break; } } + */ lData.users = alloca(channel->channel_info->userCount * sizeof(struct userData *)); matches = 0; @@ -3596,7 +3611,10 @@ ary = malloc(lData.table.width*sizeof(**lData.table.contents)); lData.table.contents[matches] = ary; - ary[0] = strtab(uData->access); + /* ary[0] = strtab(uData->access);*/ + ary[0] = user_level_name_from_level(uData->access); + /* TODO: replace above with func that returns static string + * of userlevel for that level. eg OP/MANAGER etc. -rubin */ ary[1] = uData->handle->handle; if(uData->present) ary[2] = "Here"; Index: x3/src/helpfile.c diff -u x3/src/helpfile.c:1.4 x3/src/helpfile.c:1.5 --- x3/src/helpfile.c:1.4 Tue Mar 15 21:16:51 2005 +++ x3/src/helpfile.c Thu Mar 17 12:18:29 2005 @@ -261,11 +261,22 @@ return NULL; } +int strlen_vis(char *str) +{ + int count; + for(count=0;*str;str++) + if(!iscntrl(*str)) + count++; + return count; +} + void table_send(struct userNode *from, const char *to, unsigned int size, irc_send_func irc_send, struct helpfile_table table) { unsigned int ii, jj, len, nreps, reps, tot_width, pos, spaces, *max_width; char line[MAX_LINE_SIZE+1]; struct handle_info *hi; + char *sepstr = NULL; + int sepsize = 0; if (IsChannelName(to) || *to == '$') { message_dest = NULL; @@ -334,6 +345,7 @@ for (pos=ii=0; ii<((table.flags & TABLE_REPEAT_HEADERS)?nreps:1); ii++) { for (jj=0; 1; ) { len = strlen(table.contents[0][jj]); + line[pos++] = '\02'; /* bold header */ spaces = max_width[jj] - len; if (table.flags & TABLE_PAD_LEFT) while (spaces--) @@ -346,10 +358,16 @@ while (spaces--) line[pos++] = ' '; line[pos++] = ' '; + line[pos++] = '\02'; /* end bold header */ } } line[pos] = 0; irc_send(from, to, line); + sepsize = strlen_vis(line); + sepstr = malloc(sepsize + 1); + memset(sepstr, '-', sepsize); + sepstr[sepsize] = 0; + irc_send(from, to, sepstr); ii = 1; } /* Send the table. */ @@ -376,6 +394,18 @@ line[pos++] = ' '; } } + if (!(table.flags & TABLE_NO_HEADERS)) { + /* Send end bar & free its memory */ + if(sepsize > 5) + { + sepstr[sepsize/2-1] = 'E'; + sepstr[sepsize/2] = 'n'; + sepstr[sepsize/2+1]= 'd'; + } + irc_send(from, to, sepstr); + free(sepstr); + } + if (!(table.flags & TABLE_NO_FREE)) { /* Deallocate table memory (but not the string memory). */ for (ii=0; ii<table.length; ii++) @@ -704,6 +734,7 @@ } +/* int _send_help_breef(struct userNode *dest, struct userNode *src, expand_func_t expand, const char *format, ...) { @@ -713,16 +744,16 @@ va_list ap; buf = (char *) malloc(strlen(format) +1); - sprintf(buf, format); + strcpy(buf, format); ptr = strchr(buf, '\n'); *ptr = '\0'; - printf("buf is: %s", buf); va_start(ap, buf); res = vsend_message(dest->nick, src, dest->handle_info, 12, expand, buf, ap); va_end(ap); free(buf); return res; } +*/ int @@ -777,7 +808,18 @@ continue; rec = dict_find(lang_hf->db, topic, NULL); if (rec && rec->type == RECDB_QSTRING) - return _send_help_breef(dest, src, hf->expand, rec->d.qstring); + { + char* buf; + int res; + + buf = malloc(strlen(rec->d.qstring) + 1); + strcpy(buf, rec->d.qstring); + *strchr(buf, '\n') = 0; + + res = _send_help(dest, src, hf->expand, buf); + free(buf); + return res; + } } rec = dict_find(hf->db, "<missing>", NULL); if (!rec) Index: x3/src/opserv.c diff -u x3/src/opserv.c:1.13 x3/src/opserv.c:1.14 --- x3/src/opserv.c:1.13 Tue Mar 15 15:31:01 2005 +++ x3/src/opserv.c Thu Mar 17 12:18:29 2005 @@ -3343,9 +3343,9 @@ { struct discrim_and_source *das = extra; if (match->handle_info) { - send_message_type(4, das->source, opserv, "%s!%s@%s %s", match->nick, match->ident, match->hostname, match->handle_info->handle); + send_message_type(4, das->source, opserv, "%-15s\002!\002%15s\002@\002%s %s", match->nick, match->ident, match->hostname, match->handle_info->handle); } else { - send_message_type(4, das->source, opserv, "%s!%s@%s", match->nick, match->ident, match->hostname); + send_message_type(4, das->source, opserv, "%-15s\002!\002%15s\002@\002%s", match->nick, match->ident, match->hostname); } return 0; } ----------------------- End of diff ----------------------- |