Re: Problem with EMail Registration Code

From: RK (rlkm4@YAHOO.COM)
Date: 01/09/02


grep buf db.h
/* global buffering system */
char    buf[MAX_STRING_LENGTH];
char    buf1[MAX_STRING_LENGTH];
char    buf2[MAX_STRING_LENGTH];

I'm still using global buffers so that in db.h is buf, buf1, buf2..etc
and the whole family of "hated" globals. I've pulled out all of the
mail things to the following function:

void send_email(int code, char *arg)
{
  FILE *fl;
  char filename[MAX_STRING_LENGTH];

  sprintf(buf, "%s%i", register_body, code);
  sprintf(filename, "reg.txt");

  log(buf);

  if (!(fl = fopen(filename, "w")))
  {
     log("Error opening registration file.");
     return;
  }

  if (!fl) {
     log("Error opening registration file.");
     return;
  }

  if (fclose(fl)) {
     log("Error closing registration file.");
     return;
  }
  log ("Done opening file");
  log (buf);
  fprintf(fl, "%s", buf);
  fclose(fl);

  sprintf(buf, "elm -s %s %s < reg.txt", register_subject, arg);
  system(buf);

 //  unlink("reg.txt");
   log("DONE SENDING EMAIL");

}

"code" is the numeric random password generated.
"arg" is the argument/email given

I made an ingame command that takes 1 argument and passes it to this
function and uses an arbitrary "code" value just to test to see if the
function works.

ACMD(do_test)
{
  send_email(54321, argument);
}

I type (ingame): test myemail@addr.com

I goto my email box and find my email in my box, but its blank.
I go to check the reg.txt, and its blank too. I then try any command
in game and it crashes (not if I just hit enter repeatedly, I get the
prompt again and again).

I tried to make a new character using this same function, but it
crashes before anything happens.

Suggestions? Does anyone know any similar snippets that do work or
have less problems?

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT