#include <signal.h>
#endif
+/*
+ * internet resource value
+ */
+#define HTTP_PROXY "" /* Default proxy url */
+#define HTTP_PROXY_PORT 0 /* Default proxy port */
+#define HTTP_TIMEOUT 20 /* Timeout length (second) */
+#define SCORE_SERVER "www.kmc.gr.jp" /* Default score server url */
+#define SCORE_PORT 80 /* Default score server port */
+
#ifdef JP
#define SCORE_PATH "http://www.kmc.gr.jp/~habu/local/hengscore/score.cgi"
#else
static int Vasprintf(char **buf, const char *fmt, va_list ap)
{
int ret;
+ static char static_buf[8192];
- *buf = malloc(1024);
+ *buf = static_buf;
#if defined(HAVE_VSNPRINTF)
- ret = vsnprintf(*buf, 1024, fmt, ap);
+ ret = vsnprintf(*buf, sizeof(static_buf), fmt, ap);
#else
ret = vsprintf(*buf, fmt, ap);
#endif
va_list ap;
va_start(ap, fmt);
- vasprintf(&tmpbuf, fmt, ap);
+ ret = vasprintf(&tmpbuf, fmt, ap);
va_end(ap);
- if(!tmpbuf) return -1;
+ if (ret < 0) return -1;
-#ifdef MAC_MPW
+#if ('\r' == 0x0a && '\n' == 0x0d)
{
- /* '\n' is 0x0D and '\r' is 0x0A in MPW. Swap back these. */
+ /*
+ * Originally '\r'= CR (= 0x0d) and '\n'= LF (= 0x0a)
+ * But for MPW (Macintosh Programers Workbench), these
+ * are reversed so that '\r'=LF and '\n'=CR unless the
+ * -noMapCR option is not defined.
+ *
+ * We need to swap back these here since the score
+ * dump text should be written using LF as the end of
+ * line.
+ */
char *ptr;
for (ptr = tmpbuf; *ptr; ptr++)
- if ('\n' == *ptr) *ptr = '\r';
+ {
+ if (0x0d == *ptr) *ptr = 0x0a;
+ }
}
#endif
#endif
Term_fresh();
- sd = connect_scoreserver();
+ /* ¥×¥í¥¥·¤òÀßÄꤹ¤ë */
+ set_proxy(HTTP_PROXY, HTTP_PROXY_PORT);
+
+ /* Connect to the score server */
+ sd = connect_server(HTTP_TIMEOUT, SCORE_SERVER, SCORE_PORT);
+
+
if (!(sd < 0)) break;
#ifdef JP
sprintf(buff, "¥¹¥³¥¢¡¦¥µ¡¼¥Ð¤Ø¤ÎÀܳ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£(%s)", soc_err());