extern void main(void) { OSStatus err; OSStatus junk; err = InitOpenTransportInContext(kInitOTForApplicationMask, NULL); if (err == noErr) { err = OTRegisterAsClientInContext("\pOTClassicContextTest", DummyNotifier, NULL); if (err == noErr) { err = TransferTest(); if (err == noErr) { err = MemTest(); } if (err == noErr) { err = OpenTest(); } if (err == noErr) { err = TaskTest(); } if (err == noErr) { err = StreamTest(); } junk = OTUnregisterAsClientInContext(NULL); assert(junk == noErr); } CloseOpenTransportInContext(NULL); }
NMErr NetworkShutdown( void ) { NMErr err = kNMNoError; /*if we have a client connection to someone, close it*/ if (_ourClientEndpoint) { if (!_clientClosing) /*so we don't somehow close twice*/ ProtocolCloseEndpoint(_ourClientEndpoint,true); /*specify an orderly disconnect*/ _clientClosing = true; } /*if we're the server, close all our endpoints and then ourself we could probably get away with just closing ourself, but just to be safe...*/ if (_ourHostEndpoint) { clientPlayer *thePlayer = _clientList; while (thePlayer) { ProtocolCloseEndpoint(thePlayer->endpoint,true);/*specifies an "orderly" disconnect*/ thePlayer = thePlayer->next; } if (!_hostClosing) /*so we don't somehow close twice*/ ProtocolCloseEndpoint(_ourHostEndpoint,true); /*specifies an "orderly" disconnect*/ _hostClosing = true; } /* Here we wait for all of our endpoints to finish closing. Otherwise our callback might be called while our app is shutting down*/ printf("\n-closing all endpoints-\n"); fflush(stdout); { while ((_clientList) || _ourHostEndpoint || _ourClientEndpoint) { NetworkHandleMessage(); } } printf("-done-\n"); fflush(stdout); #if (OP_PLATFORM_MAC_CFM) #if TARGET_API_MAC_CARBON CloseOpenTransportInContext(theOTContext); #else CloseOpenTransport(); #endif #endif return err; }
void GSocket_Cleanup() { if ( gOTInited != 0 ) { if ( gInetSvcRef != NULL ) OTCloseProvider( gInetSvcRef ); #if TARGET_CARBON CloseOpenTransportInContext( NULL ) ; #else CloseOpenTransport() ; #endif if ( gOTNotifierUPP ) DisposeOTNotifyUPP( gOTNotifierUPP ) ; } }
errr report_score(void) { #ifdef MACINTOSH OSStatus err; #else errr err = 0; #endif #ifdef WINDOWS WSADATA wsaData; WORD wVersionRequested =(WORD) (( 1) | ( 1 << 8)); #endif BUF *score; int sd; char seikakutmp[128]; score = buf_new(); sprintf(seikakutmp, "%s ", ap_ptr->title); buf_sprintf(score, "name: %s\n", player_name); buf_sprintf(score, "version: Hengband %d.%d.%d\n", FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH); buf_sprintf(score, "score: %d\n", total_points()); buf_sprintf(score, "level: %d\n", p_ptr->lev); buf_sprintf(score, "depth: %d\n", dun_level); buf_sprintf(score, "maxlv: %d\n", p_ptr->max_plv); buf_sprintf(score, "maxdp: %d\n", max_dlv[DUNGEON_ANGBAND]); buf_sprintf(score, "au: %d\n", p_ptr->au); buf_sprintf(score, "turns: %d\n", turn_real(turn)); buf_sprintf(score, "sex: %d\n", p_ptr->psex); buf_sprintf(score, "race: %s\n", rp_ptr->title); buf_sprintf(score, "class: %s\n", cp_ptr->title); buf_sprintf(score, "seikaku: %s\n", seikakutmp); buf_sprintf(score, "realm1: %s\n", realm_names[p_ptr->realm1]); buf_sprintf(score, "realm2: %s\n", realm_names[p_ptr->realm2]); buf_sprintf(score, "killer: %s\n", p_ptr->died_from); buf_sprintf(score, "-----charcter dump-----\n"); make_dump(score); if (screen_dump) { buf_sprintf(score, "-----screen shot-----\n"); buf_append(score, screen_dump, strlen(screen_dump)); } #ifdef WINDOWS if (WSAStartup(wVersionRequested, &wsaData)) { msg_print("Report: WSAStartup failed."); goto report_end; } #endif #ifdef MACINTOSH #if TARGET_API_MAC_CARBON err = InitOpenTransportInContext(kInitOTForApplicationMask, NULL); #else err = InitOpenTransport(); #endif if (err != noErr) { msg_print("Report: OpenTransport failed."); return 1; } #endif Term_clear(); while (1) { char buff[160]; prt("connecting...", 0, 0); Term_fresh(); /* プロキシを設定する */ 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; sprintf(buff, "Failed to connect to the score server.(%s)", soc_err()); prt(buff, 0, 0); (void)inkey(); if (!get_check_strict("Try again? ", CHECK_NO_HISTORY)) { err = 1; goto report_end; } } prt("Sending the score...", 0, 0); Term_fresh(); http_post(sd, SCORE_PATH, score); disconnect_server(sd); report_end: #ifdef WINDOWS WSACleanup(); #endif #ifdef MACINTOSH #if TARGET_API_MAC_CARBON CloseOpenTransportInContext(NULL); #else CloseOpenTransport(); #endif #endif return err; }