mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
6.1 KiB

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