OSDN Git Service

bow of accuracy have now higher to_h than to_d.
[hengband/hengband.git] / src / inet.c
index eb75548..f82a195 100644 (file)
@@ -100,7 +100,7 @@ int soc_read(int sd, char *buf, size_t sz)
 #endif /* if 0 */
 
 /* ¥×¥í¥­¥·¥µ¡¼¥Ð¤Î¥¢¥É¥ì¥¹¤ò¤ò¥Õ¥¡¥¤¥ë¤«¤éÆɤó¤ÇÀßÄꤹ¤ë */
-static void set_proxy(void)
+void set_proxy(char *default_url, int default_port)
 {
        char buf[1024];
        size_t len;
@@ -119,9 +119,9 @@ static void set_proxy(void)
 
        if (!fp)
        {
-               /* ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ïdefine.hÆâ¤Î¥Ç¥Õ¥©¥ë¥È¤òÀßÄê */
-               proxy = (char *)HTTP_PROXY;
-               proxy_port = HTTP_PROXY_PORT;
+               /* ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï¥Ç¥Õ¥©¥ë¥È¤òÀßÄê */
+               proxy = default_url;
+               proxy_port = default_port;
                return;
        }
 
@@ -176,7 +176,7 @@ static void set_proxy(void)
        else
        {
                strcpy(proxy, s);
-               proxy_port = HTTP_PROXY_PORT;
+               proxy_port = default_port;
        }
 
        /* ¥×¥í¥­¥·¤Î¥¢¥É¥ì¥¹¤òproxy¤Ë¥³¥Ô¡¼ */
@@ -190,11 +190,8 @@ static void set_proxy(void)
 int soc_write(int sd, char *buf, size_t sz)
 {
 #ifndef MACINTOSH
-#ifndef WINDOWS
-       write(sd, buf, sz);
-#else
        int nleft, nwritten;
-       
+
        nleft = sz;
 
        while (nleft > 0) {
@@ -204,7 +201,6 @@ int soc_write(int sd, char *buf, size_t sz)
                nleft -= nwritten;
                buf += nwritten;
        }
-#endif
 #else /* !MACINTOSH */
 
        OTResult bytesSent;
@@ -223,7 +219,7 @@ int soc_write_str(int sd, char *buf)
 #endif
 
 #if !defined(WINDOWS) && !defined(MACINTOSH)
-static jmp_buf env;
+static sigjmp_buf      env;
 static void (*sig_int_saved)(int);
 static void (*sig_alm_saved)(int);
 #endif
@@ -256,9 +252,9 @@ static void interrupt_report(int sig)
 #endif
 
 
+/* ¥µ¡¼¥Ð¤Ë¥³¥Í¥¯¥È¤¹¤ë´Ø¿ô¡£ */
+int connect_server(int timeout, const char *host, int port)
 #ifndef MACINTOSH
-/* ¥µ¡¼¥Ð¤Ë¥³¥Í¥¯¥È¤¹¤ë´Ø¿ô¡£ Win, unix */
-static int connect_server(int timeout, const char *host, int port)
 {
        int                     sd;
        struct sockaddr_in      to;
@@ -292,9 +288,12 @@ static int connect_server(int timeout, const char *host, int port)
        }
        sig_int_saved = signal(SIGINT, interrupt_report);
        sig_alm_saved = signal(SIGALRM, interrupt_report);
-    
+
        /* ¥¿¥¤¥à¥¢¥¦¥È¤Î»þ´Ö¤òÀßÄê */
        setitimer(ITIMER_REAL, &val, NULL);
+#else
+       /* Unused in Windows */
+       (void)timeout;
 #endif
 
        /* ¥×¥í¥­¥·¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ì¤Ð¥×¥í¥­¥·¤Ë·Ò¤° */
@@ -338,17 +337,9 @@ static int connect_server(int timeout, const char *host, int port)
 
 #ifndef WINDOWS
        if ((sd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
-       {
-#ifdef JP
-               errstr = "¥¨¥é¡¼: ¥½¥±¥Ã¥È¤òÀ¸À®¤Ç¤­¤Þ¤»¤ó";
-#else
-               errstr = "Error : cannot create socket.";
-#endif
-               restore_signal();
-               return -1;
-       }
 #else
        if  ((sd = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
+#endif
        {
 #ifdef JP
                errstr = "¥¨¥é¡¼: ¥½¥±¥Ã¥È¤òÀ¸À®¤Ç¤­¤Þ¤»¤ó";
@@ -358,7 +349,6 @@ static int connect_server(int timeout, const char *host, int port)
                restore_signal();
                return -1;
        }
-#endif
 
        if (connect(sd, (struct sockaddr *)&to, sizeof(to)) < 0)
        {
@@ -383,8 +373,7 @@ static int connect_server(int timeout, const char *host, int port)
 
 #else /* !MACINTOSH */
 
-/* ¥µ¡¼¥Ð¤Ë¥³¥Í¥¯¥È¤¹¤ë´Ø¿ô¡£ Mac */
-static int connect_server(int timeout, const char *host, int port)
+        /* ¥µ¡¼¥Ð¤Ë¥³¥Í¥¯¥È¤¹¤ë´Ø¿ô¡£ Mac */
 {
        OSStatus err;
        InetHostInfo    response;
@@ -481,13 +470,6 @@ static int connect_server(int timeout, const char *host, int port)
 }
 #endif
 
-int connect_scoreserver(void)
-{
-       /* ¥×¥í¥­¥·¤òÀßÄꤹ¤ë */
-       set_proxy();
-
-       return connect_server(HTTP_TIMEOUT, SCORE_SERVER, SCORE_PORT);
-}
 
 int disconnect_server(int sd)
 {