[BACK]Return to nh343-simple_mail.diff CVS log [TXT][DIR] Up to [contributed] / dgamelaunch-openbsd

Annotation of dgamelaunch-openbsd/nh343-simple_mail.diff, Revision 1.1

1.1     ! rubenllo    1: diff -urN orig/nethack-3.4.3/include/decl.h nethack-3.4.3/include/decl.h
        !             2: --- orig/nethack-3.4.3/include/decl.h  2003-12-07 15:39:13.000000000 -0800
        !             3: +++ nethack-3.4.3/include/decl.h       2004-01-03 15:57:34.000000000 -0800
        !             4: @@ -385,6 +385,10 @@
        !             5:  };
        !             6:  #endif /* AUTOPICKUP_EXCEPTIONS */
        !             7:
        !             8: +#ifdef SIMPLE_MAIL
        !             9: +E int mailckfreq;
        !            10: +#endif
        !            11: +
        !            12:  #undef E
        !            13:
        !            14:  #endif /* DECL_H */
        !            15: diff -urN orig/nethack-3.4.3/include/flag.h nethack-3.4.3/include/flag.h
        !            16: --- orig/nethack-3.4.3/include/flag.h  2003-12-07 15:39:13.000000000 -0800
        !            17: +++ nethack-3.4.3/include/flag.h       2004-01-03 15:57:34.000000000 -0800
        !            18: @@ -175,6 +175,9 @@
        !            19:        uchar   bouldersym;     /* symbol for boulder display */
        !            20:        boolean travel1;        /* first travel step */
        !            21:        coord   travelcc;       /* coordinates for travel_cache */
        !            22: +#ifdef SIMPLE_MAIL
        !            23: +      boolean simplemail;     /* simple mail format $NAME:$MESSAGE */
        !            24: +#endif
        !            25:  #ifdef WIZARD
        !            26:        boolean  sanity_check;  /* run sanity checks */
        !            27:        boolean  mon_polycontrol;       /* debug: control monster polymorphs */
        !            28: diff -urN orig/nethack-3.4.3/include/unixconf.h nethack-3.4.3/include/unixconf.h
        !            29: --- orig/nethack-3.4.3/include/unixconf.h      2003-12-07 15:39:13.000000000 -0800
        !            30: +++ nethack-3.4.3/include/unixconf.h   2004-01-03 15:57:34.000000000 -0800
        !            31: @@ -193,7 +193,6 @@
        !            32:  # endif
        !            33:  #endif
        !            34:
        !            35: -#define MAILCKFREQ    50
        !            36:  #endif        /* MAIL */
        !            37:
        !            38:
        !            39: diff -urN orig/nethack-3.4.3/src/mail.c nethack-3.4.3/src/mail.c
        !            40: --- orig/nethack-3.4.3/src/mail.c      2003-12-07 15:39:13.000000000 -0800
        !            41: +++ nethack-3.4.3/src/mail.c   2004-01-03 16:07:21.000000000 -0800
        !            42: @@ -5,6 +5,8 @@
        !            43:  #include "hack.h"
        !            44:
        !            45:  #ifdef MAIL
        !            46: +#include <fcntl.h>
        !            47: +#include <errno.h>
        !            48:  #include "mail.h"
        !            49:
        !            50:  /*
        !            51: @@ -36,6 +38,8 @@
        !            52:  STATIC_DCL boolean FDECL(md_rush,(struct monst *,int,int));
        !            53:  STATIC_DCL void FDECL(newmail, (struct mail_info *));
        !            54:
        !            55: +int mailckfreq = 0;
        !            56: +
        !            57:  extern char *viz_rmin, *viz_rmax;     /* line-of-sight limits (vision.c) */
        !            58:
        !            59:  #ifdef OVL0
        !            60: @@ -464,11 +468,15 @@
        !            61:  void
        !            62:  ckmailstatus()
        !            63:  {
        !            64: +#ifdef SIMPLE_MAIL
        !            65: +      if (mailckfreq == 0)
        !            66: +        mailckfreq = (iflags.simplemail ? 5 : 10);
        !            67: +#else
        !            68: +      mailckfreq = 10;
        !            69: +#endif
        !            70: +
        !            71:        if(!mailbox || u.uswallow || !flags.biff
        !            72: -#  ifdef MAILCKFREQ
        !            73: -                  || moves < laststattime + MAILCKFREQ
        !            74: -#  endif
        !            75: -                                                      )
        !            76: +                  || moves < laststattime + mailckfreq)
        !            77:                return;
        !            78:
        !            79:        laststattime = moves;
        !            80: @@ -501,9 +509,68 @@
        !            81:  readmail(otmp)
        !            82:  struct obj *otmp;
        !            83:  {
        !            84: -#  ifdef DEF_MAILREADER                       /* This implies that UNIX is defined */
        !            85: +#ifdef DEF_MAILREADER
        !            86:        register const char *mr = 0;
        !            87: +#endif /* DEF_MAILREADER */
        !            88: +#ifdef SIMPLE_MAIL
        !            89: +      if (iflags.simplemail)
        !            90: +      {
        !            91: +              FILE* mb = fopen(mailbox, "r");
        !            92: +              char curline[102], *msg;
        !            93: +              boolean seen_one_already = FALSE;
        !            94: +              struct flock fl = { 0 };
        !            95: +
        !            96: +              fl.l_type = F_RDLCK;
        !            97: +              fl.l_whence = SEEK_SET;
        !            98: +              fl.l_start = 0;
        !            99: +              fl.l_len = 0;
        !           100: +
        !           101: +              if (!mb)
        !           102: +                      goto bail;
        !           103: +
        !           104: +              /* Allow this call to block. */
        !           105: +              if (fcntl (fileno (mb), F_SETLKW, &fl) == -1)
        !           106: +                goto bail;
        !           107: +
        !           108: +              errno = 0;
        !           109: +
        !           110: +              while (fgets(curline, 102, mb) != NULL)
        !           111: +              {
        !           112: +                fl.l_type = F_UNLCK;
        !           113: +                fcntl (fileno(mb), F_UNLCK, &fl);
        !           114: +
        !           115: +                pline("There is a%s message on this scroll.",
        !           116: +                    seen_one_already ? "nother" : "");
        !           117: +
        !           118: +                msg = strchr(curline, ':');
        !           119: +
        !           120: +                if (!msg)
        !           121: +                  goto bail;
        !           122: +
        !           123: +                *msg = '\0';
        !           124: +                msg++;
        !           125: +
        !           126: +                pline ("This message is from '%s'.", curline);
        !           127: +
        !           128: +                msg[strlen(msg) - 1] = '\0'; /* kill newline */
        !           129: +                pline ("It reads: \"%s\".", msg);
        !           130: +
        !           131: +                seen_one_already = TRUE;
        !           132: +                errno = 0;
        !           133: +
        !           134: +                fl.l_type = F_RDLCK;
        !           135: +                fcntl(fileno(mb), F_SETLKW, &fl);
        !           136: +              }
        !           137:
        !           138: +              fl.l_type = F_UNLCK;
        !           139: +              fcntl(fileno(mb), F_UNLCK, &fl);
        !           140: +
        !           141: +              fclose(mb);
        !           142: +              unlink(mailbox);
        !           143: +              return;
        !           144: +      }
        !           145: +# endif /* SIMPLE_MAIL */
        !           146: +# ifdef DEF_MAILREADER                        /* This implies that UNIX is defined */
        !           147:        display_nhwindow(WIN_MESSAGE, FALSE);
        !           148:        if(!(mr = nh_getenv("MAILREADER")))
        !           149:                mr = DEF_MAILREADER;
        !           150: @@ -512,15 +578,21 @@
        !           151:                (void) execl(mr, mr, (char *)0);
        !           152:                terminate(EXIT_FAILURE);
        !           153:        }
        !           154: -#  else
        !           155: -#   ifndef AMS                                /* AMS mailboxes are directories */
        !           156: +# else
        !           157: +#  ifndef AMS                         /* AMS mailboxes are directories */
        !           158:        display_file(mailbox, TRUE);
        !           159: -#   endif /* AMS */
        !           160: -#  endif /* DEF_MAILREADER */
        !           161: +#  endif /* AMS */
        !           162: +# endif /* DEF_MAILREADER */
        !           163:
        !           164:        /* get new stat; not entirely correct: there is a small time
        !           165:           window where we do not see new mail */
        !           166:        getmailstatus();
        !           167: +      return;
        !           168: +
        !           169: +#ifdef SIMPLE_MAIL
        !           170: +bail:
        !           171: +      pline("It appears to be all gibberish."); /* bail out _professionally_ */
        !           172: +#endif
        !           173:  }
        !           174:
        !           175:  # endif /* UNIX */
        !           176: @@ -587,10 +659,7 @@
        !           177:        static int laststattime = 0;
        !           178:
        !           179:        if(u.uswallow || !flags.biff
        !           180: -#  ifdef MAILCKFREQ
        !           181: -                  || moves < laststattime + MAILCKFREQ
        !           182: -#  endif
        !           183: -                                                      )
        !           184: +                  || moves < laststattime + mailckfreq)
        !           185:                return;
        !           186:
        !           187:        laststattime = moves;
        !           188: diff -urN orig/nethack-3.4.3/sys/unix/unixmain.c nethack-3.4.3/sys/unix/unixmain.c
        !           189: --- orig/nethack-3.4.3/sys/unix/unixmain.c     2003-12-07 15:39:13.000000000 -0800
        !           190: +++ nethack-3.4.3/sys/unix/unixmain.c  2004-01-03 15:57:34.000000000 -0800
        !           191: @@ -54,7 +54,9 @@
        !           192:        register char *dir;
        !           193:  #endif
        !           194:        boolean exact_username;
        !           195: -
        !           196: +#ifdef SIMPLE_MAIL
        !           197: +      char* e_simple = NULL;
        !           198: +#endif
        !           199:  #if defined(__APPLE__)
        !           200:        /* special hack to change working directory to a resource fork when
        !           201:           running from finder --sam */
        !           202: @@ -84,6 +86,12 @@
        !           203:        }
        !           204:  #endif
        !           205:
        !           206: +#ifdef SIMPLE_MAIL
        !           207: +      /* figure this out early */
        !           208: +      e_simple = nh_getenv("SIMPLEMAIL");
        !           209: +      iflags.simplemail = (e_simple ? 1 : 0);
        !           210: +#endif
        !           211: +
        !           212:        hname = argv[0];
        !           213:        hackpid = getpid();
        !           214:        (void) umask(0777 & ~FCMASK);

CVSweb