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
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
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
00269
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
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
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