OSDN Git Service

Add new option -- show_ammo_detail / show_ammo_no_crit
[hengband/hengband.git] / src / report.c
index 78b209c..9829bd7 100644 (file)
 #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
@@ -49,25 +58,6 @@ typedef struct {
 
 #define        BUFSIZE (65536)
 
-#ifndef HAVE_VASPRINTF
-#define vasprintf      Vasprintf
-
-static int Vasprintf(char **buf, const char *fmt, va_list ap)
-{
-       int ret;
-
-       *buf = malloc(1024);
-
-#if defined(HAVE_VSNPRINTF)
-       ret = vsnprintf(*buf, 1024, fmt, ap);
-#else
-       ret = vsprintf(*buf, fmt, ap);
-#endif
-       return ret;
-}
-
-#endif /* ifndef HAVE_VASPRINTF */ 
-
 static BUF* buf_new(void)
 {
        BUF *p;
@@ -114,14 +104,18 @@ static int buf_append(BUF *buf, const char *data, size_t size)
 static int buf_sprintf(BUF *buf, const char *fmt, ...)
 {
        int             ret;
-       char    *tmpbuf;
+       char    tmpbuf[8192];
        va_list ap;
 
        va_start(ap, fmt);
-       vasprintf(&tmpbuf, fmt, ap);
+#if defined(HAVE_VSNPRINTF)
+       ret = vsnprintf(tmpbuf, sizeof(tmpbuf), fmt, ap);
+#else
+       ret = vsprintf(tmpbuf, fmt, ap);
+#endif
        va_end(ap);
 
-       if(!tmpbuf) return -1;
+       if (ret < 0) return -1;
 
 #if ('\r' == 0x0a && '\n' == 0x0d)
        {
@@ -145,8 +139,6 @@ static int buf_sprintf(BUF *buf, const char *fmt, ...)
 
        ret = buf_append(buf, tmpbuf, strlen(tmpbuf));
 
-       free(tmpbuf);
-
        return ret;
 }
 
@@ -486,7 +478,13 @@ errr report_score(void)
 #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());