Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

newboard.c

Go to the documentation of this file.
00001 #if defined(macintosh)
00002 #include <types.h>
00003 #else
00004 #include <sys/types.h>
00005 #endif
00006 #include <ctype.h>
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <string.h>
00010 #include <time.h>
00011 #include "merc.h"
00012 //#include "newboard.h"
00013 /*
00014 void load_spools(CHAR_DATA *ch);
00015 void load_spool_boot(CHAR_DATA *ch,SPOOL_DATA *pspool);
00016 SPOOL_DATA spool[NOTE_MAX_SPOOL] =
00017 {
00018 
00019     { "Note",    "General In-Character Notes", TRUE},
00020     { "OOCNote","Out of Character Notes",TRUE},
00021     { "News",   "Mud News", TRUE},
00022     { "Change", "Mud Changes", TRUE},
00023     { "poof",   "poof", FALSE }
00024 
00025 };
00026 
00027 void do_note (CHAR_DATA *ch, char *argument)
00028 {
00029 char buf[MAX_STRING_LENGTH];
00030 char arg[MAX_STRING_LENGTH];
00031 char arg2[MAX_STRING_LENGTH];
00032 argument = one_argument(argument, arg);
00033 argument = one_argument(argument, arg2);    
00034     sprintf(buf, "Spooldata: %s", spool[1].name);
00035     send_to_char(buf,ch);
00036     if (str_cmp(ch->name, "Tribul"))
00037     {
00038         send_to_char("Sorry...only Tribul can use this function.\n\rIt should be back up when he finishes the new note system.\n\r",ch);
00039         return;
00040     }
00041 
00042     if (arg[0] == '\0' && !IS_SET(ch->chann, IS_WRITING_NOTE))
00043     {
00044         send_to_char("You have no current notes in progress.\n\r",ch);
00045         return;
00046     }
00047 
00048     if (!str_cmp (arg,"to"))
00049     {
00050         if (!IS_SET(ch->chann, IS_WRITING_NOTE))
00051                 SET_BIT(ch->chann, IS_WRITING_NOTE);
00052         ch->note_to = str_dup(arg2);
00053         sprintf(buf, "Ok.\n\r");
00054         send_to_char(buf,ch);
00055         
00056     }
00057     if (!str_cmp (arg, "subject"))
00058     {
00059         strcat(arg2, " ");
00060         strcat(arg2, argument);
00061         ch->note_subject = str_dup(arg2);
00062         sprintf(buf, "Ok.\n\r");
00063         send_to_char(buf,ch);
00064 
00065     }
00066     if (!str_cmp(arg, "clear"))
00067     {
00068         if (!IS_SET(ch->chann, IS_WRITING_NOTE))
00069         {
00070             send_to_char("There are no notes in progress.\n\r",ch);
00071             return;
00072         }
00073 
00074         if (IS_SET(ch->chann,IS_WRITING_NOTE))
00075             REMOVE_BIT(ch->chann, IS_WRITING_NOTE);
00076         ch->note_to = NULL;
00077         ch->note_subject = NULL;
00078         ch->note_body = NULL;
00079         send_to_char("Note cleared.\n\r",ch);
00080         return;
00081     }
00082     if (!str_cmp(arg, "show"))
00083     {
00084         if (!IS_SET(ch->chann, IS_WRITING_NOTE))
00085         {
00086             send_to_char("You are not currently writing a note.\n\r",ch);
00087             return;
00088         }
00089 */  /*tribul - Keep that pesky (NULL) out of the strings*/
00090 /*      if (ch->note_to == NULL)
00091             ch->note_to = "";
00092         if (ch->note_subject == NULL)
00093             ch->note_subject = "";
00094         if (ch->note_body == NULL)
00095             ch->note_body = "";
00096               
00097         sprintf(buf, "sender: %s\n\r",ch->name);
00098         send_to_char(buf,ch);
00099         sprintf(buf, "note to: %s \n\r",ch->note_to);
00100         send_to_char(buf,ch);
00101         sprintf(buf, "note subject: %s\n\r",ch->note_subject);
00102         send_to_char(buf,ch);
00103         sprintf(buf, "Text -\n\r%s",ch->note_body);
00104         send_to_char(buf,ch);
00105     }
00106 
00107     if (!str_cmp(arg, "+"))
00108 
00109     {
00110     char buf2[4*MAX_STRING_LENGTH];
00111     if (ch->note_body == NULL)
00112     {
00113         ch->note_body = "";
00114     }
00115 
00116     strcat(arg2, " ");
00117     strcat(arg2, argument);
00118     strcpy(buf2, ch->note_body);
00119     free_string(ch->note_body);
00120     ch->note_body = NULL;
00121     strcat (buf2, arg2);
00122     strcat (buf2, "\n\r");
00123     ch->note_body = buf2;
00124     
00125     }
00126 
00127     if (!str_cmp(arg, "load"))
00128     {
00129         load_spools (ch);
00130     }
00131     if (!str_cmp(arg, "save"))
00132     {
00133         FILE *fp;
00134 //      char buf[4*MAX_STRING_LENGTH];
00135         if (ch->note_body == NULL)
00136             ch->note_body = "";
00137         if (ch->note_subject == NULL)
00138             ch->note_subject = "";
00139         if (ch->note_to == NULL)
00140             ch->note_to = ch->name;
00141         if ((fp = fopen (NOTE_FILE, "a")) == NULL)
00142         {
00143             send_to_char("Unable to open file: TEMP_FILE for write!",ch);
00144         }
00145         else
00146         {
00147             fprintf(fp, "sender %s\n", ch->name);
00148             fprintf(fp, "spool 1\n");*/ /* just for the sake
00149                                 of not screwing up 
00150                                 the spool *mutter**/
00151             /*
00152             fprintf(fp, "receive  %s\n", ch->note_to);
00153             fprintf(fp, "subject %s\n", ch->note_subject);
00154             fprintf(fp, "body %s\n", ch->note_body);
00155             fclose(fp);
00156             send_to_char("note written successfully\n\r",ch);
00157         }
00158         
00159 //      rename (TEMP_FILE, NOTE_FILE);
00160         fpReserve = fopen (NULL_FILE, "r");
00161         return;
00162     }
00163 }
00164 void load_spool_boot(CHAR_DATA *ch, SPOOL_DATA *pspool)
00165 {
00166         FILE *fp;
00167         NOTE_SPOOL *pnote;
00168         send_to_char(sizeof(*pnote),ch);
00169     //        SPOOL_DATA *pspool;
00170 
00171         *//* just to make sure.... Overkill? *smirk* */
00172 /*      pnote->sender = NULL;
00173         pnote->whom   = NULL;
00174         pnote->subject = NULL;
00175         pnote->body    = NULL;
00176         pnote->spool   = NULL;
00177 */
00178     /*  if ((fp = fopen (NOTE_FILE, "r")) == NULL)
00179         {
00180             send_to_char ("Unable to open notefile for read!",ch);
00181         return;
00182         }
00183         else
00184         {
00185             for ( ; ; )
00186             {
00187                 NOTE_SPOOL *pnote;
00188                 char letter;
00189             
00190                 do
00191                 {
00192                     letter = getc(fp);
00193                     if ( feof(fp))
00194                     {
00195                         fclose (fp);
00196                         send_to_char("fclose(fp);\n\r",ch);
00197                         return;
00198                     }
00199                 }
00200                 while (isspace(letter));
00201                 ungetc(letter,fp);
00202                 pnote = alloc_perm(sizeof(*pnote));
00203                 char sbuf[MAX_STRING_LENGTH];
00204                 sprintf(sbuf, fread_word(fp));
00205                 send_to_char(sbuf,ch);
00206                 if (str_cmp(fread_word(fp), "sender"))
00207                     break;
00208                 pnote->sender = fread_string(fp);
00209                 if (str_cmp( fread_word(fp), "spool"))
00210                     break;
00211                 //pnote->sender = fread_string(fp);
00212                 if (str_cmp( fread_word(fp), "receive"))
00213                     break;
00214                 pnote->whom = fread_string(fp);
00215                 if (str_cmp(fread_word(fp), "subject"))
00216                     break;
00217                 pnote->subject = fread_string(fp);
00218                 if (str_cmp(fread_word(fp), "body"))
00219                     break;
00220                 pnote->body = fread_string(fp);
00221                 pnote->next = NULL;
00222 
00223             //pspool->note_first = pnote;
00224             }
00225         }
00226     fclose(fp);
00227     char buf[MAX_STRING_LENGTH];
00228 //if (pnote->sender == NULL)
00229         pnote->sender = "";
00230     if (pnote->whom == NULL)
00231         pnote->whom = "";
00232     if (pnote->subject == NULL)
00233         pnote->subject = "";
00234     if (pnote->body == NULL)
00235         pnote->body = "";
00236 
00237     sprintf(buf, "note from: %s\n\rnote to: %s\n\rNote subject: %s\n\rNote body: %s\n\r",
00238             pnote->sender, pnote->whom, pnote->subject, pnote->body);
00239     send_to_char(buf,ch);
00240     
00241     
00242 
00243 }
00244 
00245 void load_spools(CHAR_DATA *ch)
00246 {
00247     int i;
00248     for (i = 0; i < NOTE_MAX_SPOOL; i++)
00249         load_spool_boot(ch,&spool[i]);
00250 }
00251 */
00252 void builder_note(CHAR_DATA *ch, char * argument)
00253 {
00254     char arg1[MAX_STRING_LENGTH];
00255     char arg2[MAX_STRING_LENGTH];
00256     char buf[MAX_STRING_LENGTH];
00257     argument = one_argument(argument, arg1);
00258     argument = one_argument(argument, arg2);
00259     FILE *fp;
00260     
00261     if ((!str_cmp(arg1, "post")) && arg2[0] == '\0')
00262     {
00263         send_to_char("Syntax - bnote post <who> <message>\n\r",ch);
00264         return;
00265     }
00266     if (!str_cmp(arg1, "read"))
00267     {
00268         //send_to_char("Working on it!!\n\r",ch);
00269         //return;
00270         if ((fp = fopen (BUILDER_FILE, "r")) == NULL)
00271         {
00272             send_to_char("Unable to open Builder-file.\n\rIf you get this error, then that probably means its empty.\n\r",ch);
00273             return;
00274         }
00275         for ( ; ; )
00276         {
00277             if ( feof (fp))
00278             {
00279                 fclose(fp);
00280                 send_to_char("\n\rEnd of file.\n\r",ch);
00281                 return;
00282             }
00283             while(fgets(buf, 10, fp)!=NULL)
00284                 send_to_char(buf,ch);
00285         }
00286             
00287     }
00288     if (!str_cmp(arg1, "post"))
00289     {
00290         if (arg2[0] == '\0')
00291         {
00292             send_to_char("You need a receipient.\n\r",ch);
00293             return;
00294         }
00295         if (argument[0] == '\0')
00296         {
00297             send_to_char("You need a message\n\r",ch);
00298             return;
00299         }
00300         
00301         sprintf (buf, "From: %s\n\rTo: %s\n\rmessage:\n\r%s\n\r", ch->name, arg2, argument);
00302 //  append_file2(ch, BUILDER_FILE, buf);
00303         send_to_char (buf, ch);
00304         send_to_char("logged.\n\r",ch);
00305         return;
00306     }
00307     if (!str_cmp(arg1, "purge"))
00308     {
00309         if (!str_cmp(ch->name, "Rhaeven") || !str_cmp(ch->name,"Tribul"))
00310         {
00311             send_to_char ("{R{!{*Deleting{x the build-note file.\n\r",ch);
00312             unlink (BUILDER_FILE);
00313             return;
00314         }
00315         send_to_char ("Syntax - bnote post <who> <message>\n\rSyntax - bnote read\n\r",ch);
00316         return;
00317     }
00318     
00319     send_to_char("Syntax - bnote post <who> <message>\n\rSyntax - bnote read\n\r",ch);
00320     return;
00321 }
00322 
00323 void code_note (CHAR_DATA *ch, char * argument)
00324 {
00325     char buf[MAX_STRING_LENGTH];
00326     char arg1[MAX_STRING_LENGTH];
00327     char arg2[MAX_STRING_LENGTH];
00328     char tempp[MAX_STRING_LENGTH];
00329     FILE *fp;
00330     argument = one_argument (argument, arg1);
00331     argument = one_argument (argument, arg2);
00332     
00333     if (!str_cmp(arg1, "post"))
00334     {
00335         if (arg2[0] == '\0')
00336         {
00337             send_to_char("You must have something to post!\n\r",ch);
00338             return;
00339         }
00340         strcat(arg2, argument);
00341         sprintf(buf, "From: %s\n\rMessage: \n\r%s\n\r", ch->name, arg2);
00342 //      append_file2(ch, CODE_FILE, buf);
00343         send_to_char(buf, ch);
00344         send_to_char("\n\rLogged.\n\r",ch);
00345         return;
00346     }
00347 
00348     if (!str_cmp(ch->name, "Tribul") && arg1[0] == '\0' && argument[0] == '\0' && arg2[0] == '\0')
00349     {
00350         if ((fp = fopen (CODE_FILE, "r")) == NULL)
00351         {
00352                send_to_char("Unable to open Code-file.\n\rIf you get this error, then that probably means its empty.\n\r",ch);
00353                return;
00354         }
00355         for ( ; ; )
00356         {
00357                if ( feof (fp))
00358                {
00359                       fclose(fp);
00360                       send_to_char("\n\rEnd of file.\n\r",ch);
00361                       return;
00362                }
00363             while(fgets(buf, 10, fp)!=NULL)
00364                        send_to_char(buf,ch);
00365              }
00366         
00367     
00368     }
00369      if (!str_cmp(arg1, "purge"))
00370      {
00371          if (!str_cmp(ch->name,"Tribul"))
00372          {
00373              send_to_char ("{R{!{*Deleting{x the Code-note file.\n\r",ch);
00374          unlink (CODE_FILE);
00375              return;
00376           }
00377           send_to_char ("Syntax - cnote post <message>\n\r",ch);
00378           return;
00379           }
00380          send_to_char("Syntax - cnote post <message>\n\r",ch);
00381          return;
00382 }
00383 
00384              
00385     

Generated on Thu Jan 13 21:48:13 2005 for Beyond the Shadows by  doxygen 1.4.0