TPRO01.MOD - Use macro for name display 2THE 1Programmer0 #1 @5920 Fri Feb 26 02:43:44 1993 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Mod Name: TPRO01.MOD Author: 2THE 1Programmer ³0 ³ Difficulty: Not the easiest Date: Feb 9, 1993 ³ ³ Version: 4.22 (Will work with others) ³ ³Description: Allows users to have a macro show their name. Lets sysops ³ ³ display just the users name. ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ This will take some time to install. 6Read the ENTIRE MOD FIRST0 to make sure that you can install it correctly. This mod has been tested as bug free. It has beed beta tested with several othere WWIV sysops and has been found as such. Please support bug free mods. Now for the disclaimer. It works just fine on my system. Don't blame me if you didn't back up your source. Now for a better description. What this does is allow you to use a macro to show your name. You can put WWIV color commands in it and IBM characters too. This way you can have like special casing of your name (look at mine). As a benefit. I added a function that would print out just the username without any numbers after it. Just call it like: s=name(thisuser); And you will have the name by itself. Included is a restriction so that you can set it up so that someone can not use it. I have it set to 'O'. You can change it to whatever you want to. Also, when creating the macro, it only allows for 30 characters. And it also only lets you enter in a ^P or ^C and of course printable text. But it only allows a number after the ^P or ^C. For those with the MERLIN9 MCI mod installed, this will keep your system from hanging, and also from users that would like to display userinfo in the name. A safety precaution. If your system uses some other color mod, and you can not figure out how to mod this mod to accept them, drop me a note as to what your system has for colors, and I will see what I can do. ------------------------------------------------------------------------------ STEP 1 Backup your source. ------------------------------------------------------------------------------ STEP 2 Add MODSTRIN.MOD. This mod does use the mod.str file. You don't need it, but it is used here in this mod. Included is the instructions if you don't have MODSTRIN.MOD installed. ------------------------------------------------------------------------------ STEP 3 FILE CONIO.C In the function void val_cur_user(void) Search for and add the following lines case 5: movecsr(wx+32,wy+3); editline(restrict,16,SET,&rc,rst); thisuser.restrict=0; for (i=0; i<=15; i++) if (restrict[i]!=32) thisuser.restrict |= (1 << i); if (thisuser.restrict & restrict_user_macro) /* add me */ thisuser.umacro[0]='\0'; /* add me */ break; case 6: In the function void topscreen(void) Search for and add the following lines sprintf(ol,"Users: %4u Total Calls: %5lu Calls Today: %4u P osted :%3u ", status.users,status.callernum1,status.callstoday,status.msgposttoday); outs(ol); movecsr(0,2); ts=1; /* add me */ sprintf(ol,"%-36s %-4u min / %2u%% E-mail sent :%3u ", nam(&thisuser,usernum),status.activetoday, (int) (10*status.activetoday/144),status.emailtoday); outs(ol); ts=0; /* add me */ movecsr(0,3); sprintf(ol,"SL=%3u DL=%3u FW=%3u Uploaded:%2u files  Feedback :%3u ", thisuser.sl,thisuser.dsl,fwaiting,status.uptoday,status.fbacktoday); outs(ol); break; Just a few lines further down you will find this. Add the lines indicated. if (strcmp(thisuser.laston,date())) strcpy(lo,thisuser.laston); else sprintf(lo,"Today:%2d",thisuser.ontoday); movecsr(0,0); ts=1; /* add me */ sprintf(ol,"%-36s W=%2u UL=%4u/%6lu SL=%3u LO=%5u PO=%4u", nam(&thisuser,usernum),thisuser.waiting,thisuser.uploaded, thisuser.uk,thisuser.sl,thisuser.logons,thisuser.msgpost); outs(ol); ts=0; /* add me */ movecsr(0,1); if (thisuser.wwiv_regnum) sprintf(calls,"%lu",thisuser.wwiv_regnum); else strcpy(calls,thisuser.callsign); sprintf(ol,"%-20s %12s %-6s DL=%4u/%6lu DL=%3u TO=%5.0lu ES=%4u", thisuser.realname,thisuser.phone,calls, thisuser.downloaded,thisuser.dk,thisuser.dsl, ((long) ((thisuser.timeon+timer()-timeon)/60.0)), thisuser.emailsent+thisuser.emailnet); ------------------------------------------------------------------------------ STEP 4 FILE DEFAULTS.C In the function void print_cur_stat(void) if (okansi()) { pl(get_string(397)); /* "8. Change colors" */ outstr(get_string(398)); npr("%s\r\n", /* "9. Full screen editor: " */ ((thisuser.defed) && (thisuser.defed<=numed))? editors[thisuser.defed-1].description:get_string(5)); /* "None." */ outstr(get_string(399)); npr("%s\r\n", /* "A. Extended colors : " */ (thisuser.sysstatus & sysstatus_funky_colors)?str_yes:str_no); } outstr(get_string(400)); npr("%d\r\n",thisuser.optional_val); /* "B. Optional lines : " */ outstr(modstring(THEPROGRAMMER01)); /* See note 1 below */ /* add me */ if (thisuser.umacro[0]) /* add me */ list_macro(thisuser.umacro); /* add me */ else /* add me */ if (thisuser.restrict & restrict_user_macro) /* add me */ pl( modstring(THEPROGRAMMER01+1)); /* See note 2 below */ /* add me */ else /* add me */ pl(get_string(402)); /* "" */ /* add me */ outstr(get_string(401)); /* "W. WWIV reg num : " */ if (thisuser.wwiv_regnum) npr("%ld\r\n",thisuser.wwiv_regnum); else pl(get_string(402)); /* "" */ -------------------------------- ** Note 1 ** -------------------------------- If you do not have the MODSTRIN.MOD installed. Then replace that line with: outstr("C. Username macro : "); -------------------------------- ** Note 2 ** -------------------------------- If you do not have the MODSTRIN.MOD installed. Then replace that line with: pl("Not allowed"); In the function void defaults(void) Change the 2 lines to add the 'C' command (or whatever is free on your system) if (hangup) return; nl(); helpl=4; if (okansi()) { prt(2,get_string(477)); /* "Defaults: (1-9,A-B,W,?,Q) : " */ ch=onek("Q?123456789ABCW"); /* change me */ } else { prt(2,get_string(478)); /* "Defaults: (1-7,B,W,?,Q) : " */ ch=onek("Q?1234567BCW"); /* change me */ } switch(ch) { case 'Q': done=1; break; Further in the switch add the following lines. You may need to change the case to a letter that is available. case 'B': optional_lines(); break; case 'C': /* add me */ input_user_macro(); /* add me */ break; /* add me */ case 'W': enter_regnum(); break; At the end of the file add the following function. void input_user_macro(void) { unsigned char s[ 31],tempmac[ 31],s1[ 81]; int i, done1; unsigned char ch1; if (thisuser.restrict & restrict_user_macro) return; strcpy(s,thisuser.umacro); thisuser.umacro[0]=0; done1=0; i=0; nl(); pl(get_string(449)); /* "Enter your macro now, hit ctrl-Z when done." */ nl(); okskey=0; do { ch1=getkey(); if (ch1==26) done1=1; else if (ch1==8) { if (i>0) { i--; backspace(); if (tempmac[i]<32) backspace(); } } else { if (ch1>=' ') { if ((tempmac[i-1]<' ') && (i)) { if ((ch1>='0') && (ch1<='9')) { tempmac[i++]=ch1; outchr(ch1); } } else { tempmac[i++]=ch1; outchr(ch1); } } else { if ((ch1==3) || (ch1==16)) { if (((tempmac[i-1]<' ') && (i)) || (!i)){ tempmac[i++]=ch1; outchr('^'); outchr(ch1+64); } } } } if (i>=28) done1=1; } while ((!done1) && (!hangup)); okskey=1; tempmac[i]=0; nl(); pl(get_string(450)); /* "You entered:" */ nl(); nl(); list_macro(tempmac); nl(); prt(5,get_string(438)); /* "Is this OK? " */ if (yn()) { sprintf(s1,get_stringx(1,THEPROGRAMMER01_LOG),tempmac); /* See note 3 below */ for (i=0; s1[i]; i++) if (s1[i]=='\x10') s1[i]='\x03'; sysoplog(s1); strcpy(thisuser.umacro,tempmac); nl(); pl(get_string(451)); /* "Macro saved." */ } else { nl(); strcpy(&(thisuser.umacro[0]),s); pl(get_string(452)); /* "Nothing saved." */ } } -------------------------------- ** Note 3 ** -------------------------------- This line is for the sysoplog, and I have put that string in the sysoplog.str file. I padded it out to 200 lines, and added the following line to it: Username macro changed to '%s' Now if you don't want to change the SYSOPLOG.STR file then just change it to: sprintf(s1,"Username macro changed to '%s'",tempmac); ------------------------------------------------------------------------------ STEP 5 FILE UEDIT.C In the function void uedit(int usern, int other) In the switch search for the case and add the lines indicated. case 'Z': nl(); npr(" %s\r\n",restrict_string); do { prt(2,get_string(279)); /* "Toggle? " */ s[0]=13; s[1]='?'; strcpy(&(s[2]),restrict_string); ch1=onek(s); if (ch1==32) ch1=13; if (ch1=='?') printmenu(10); if ((ch1!=13) && (ch1!='?')) { i=-1; for (i1=0; i1<16; i1++) if (ch1==s[i1+2]) i=i1; if (i>-1) { u.restrict ^= (1 << i); if (u.restrict & restrict_user_macro) /* add me */ u.umacro[0]='\0'; /* add me */ write_user(un,&u); } } } while ((!hangup) && (ch1=='?')); break; case 'A': ------------------------------------------------------------------------------ STEP 6 FILE UTILITY.C Add the following function char *name( userrec *u1) { static char o[81]; int i,f,p; userrec u; u=*u1; f=1; for (i=0; i<81; i++) o[ i]='\0'; if ((u.umacro[0]) && (!ts)){ strcpy( o, u.umacro); p=strlen(o); o[p++]='\x03'; o[p++]='0'; o[p]='\0'; for (i=0; o[i]; i++) if (o[i]=='\x10') o[i]='\x03'; } else { for (p=0; p='A') && (u.name[p]<='Z')) f=0; o[p]=u.name[p]; } else { if ((u.name[p]>='A') && (u.name[p]<='Z')) o[p]=u.name[p]-'A'+'a'; else { if ((u.name[p]>=' ') && (u.name[p]<='/')) f=1; o[p]=u.name[p]; } } } } return( o); } Replace the *nam function with the one provided here. char *nam(userrec *u1, unsigned int un) { char *o; int p; userrec u; u=*u1; o=name(&u); p=strlen(o); o[p++]=32; o[p++]='#'; itoa(un,&o[p],10); return(o); } ------------------------------------------------------------------------------ STEP 7 FILE VARDEC.H In userrec struct change this line: res_gp[100]; /* reserved for whatever */ To read as follows and add the one line: umacro[31], /* Macro to be used for the username */ /* add me */ res_gp[69]; /* reserved for whatever */ /* change me */ In the userrec.restrict defines add the one indicated. You might have to change the numbers if you have added your own. /* userrec.restrict */ #define restrict_logon 0x0001 #define restrict_chat 0x0002 #define restrict_validate 0x0004 #define restrict_automessage 0x0008 #define restrict_anony 0x0010 #define restrict_post 0x0020 #define restrict_email 0x0040 #define restrict_vote 0x0080 #define restrict_auto_msg_delete 0x0100 #define restrict_net 0x0200 #define restrict_upload 0x0400 #define restrict_user_macro 0x0800 /* add me */ The restrict_string macro will also be changed to add the macro restriction. Change this line: #define restrict_string "LCMA*PEVKNU " To: #define restrict_string "LCMA*PEVKNUO " Note: You may have to adjust the string for your needs. This is only based on stock WWIV source code. ------------------------------------------------------------------------------ STEP 8 FILE VARS.H You will need to add this variable anywhere in the defined area. I put it right before the version info. __EXTRN__ int ts; /* for the top of screen name */ ------------------------------------------------------------------------------ STEP 9 If you don't use a MOD.STR file then skip this step. You will need to add these 2 lines in the MOD.STR file. "C. Username macro : " "Not allowed" Next you will need to define a macro that points to what line number is the start for the two strings. I put the macro in a file called MODSTR.H. This is what mine looks like. #define THEPROGRAMMER01 1 It is at the start of the MOD.STR file, so it is number 1. Alternatively, you could also put them right into BBS.STR file. ------------------------------------------------------------------------------ STEP 10 If you decided to put that one string in the SYSOPLOG.STR file, then you will need to add another define that reads: #define THEPROGRAMMER01_LOG 200 Where the 200 is the string number that you used in the sysoplog file. ------------------------------------------------------------------------------ STEP 11 You will need to type "MAKE FCNS" from DOS so that the FCNS.H file can be updated. Or you can edit FCNS.H to add the functions yourself. The first one is preferrebly the easier one to do. ------------------------------------------------------------------------------ STEP 12 Edit BBS.STR to change the 2 lines that have the options in the defaults area. You will need to add the 'C' to both lines. They are line numbers 477 & 478. 6### IMPORTANT NOTE ###0 DO NOT EDIT BBS.STR, NOR ANY OTHER STRING FILE, WITH A TEXT EDITOR. USE ONLY A PROGRAM THAT IS CAPABLE OF EDITING STRING FILES, SUCH AS THE MINIESM THAT IS INCLUDED WITH THE BBS. YOU COULD (AND PROBABLY WOULD) END UP DAMAGING YOU BBS OTHERWISE. ------------------------------------------------------------------------------ STEP 13 Recompile! ------------------------6### ANOTHER IMPORTANT NOTE ###0------------------------ DO NOT CHANGE THE SIZE OF THE MACRO. IF YOU DO, YOUR EMAIL FILE WILL BECOME CORRUPTED. POSSIBLY OTHER THINGS WILL BECOME CORRUPTED TOO. Now that you done. Enjoy it! If you find this mod useful. Just drop a note saying that you are using it. I am curious to see how many systems would find it useful, and use it. If you have any suggestions for improvements or questions, again, drop a note with the suggestion. I can be reached at 1 @5903 on WWIVnet. 2THE 1Programmer0