Exemple #1
0
int main(int argc, char *argv[]) {

#ifdef __SWITCH_DEBUG__
	socketInitializeDefault();
	nxlinkStdio();
#endif

	// Create our OSystem instance
	g_system = new OSystem_Switch();
	assert(g_system);

	// Pre initialize the backend
	((OSystem_Switch *)g_system)->init();

#ifdef DYNAMIC_MODULES
	PluginManager::instance().addPluginProvider(new SDLPluginProvider());
#endif

	// Invoke the actual ScummVM main entry point:
	int res = scummvm_main(argc, argv);

	// Free OSystem
	g_system->destroy();

#ifdef __SWITCH_DEBUG__
	socketExit();
#endif

	return res;
}
Exemple #2
0
 void RetrieveToFile(std::string URL, std::string Path, std::function<void(double Done, double Total)> Callback)
 {
     socketInitializeDefault();
     FILE *f = fopen(Path.c_str(), "wb");
     if(f)
     {
         tmpcb = Callback;
         CURL *curl = curl_easy_init();
         curl_easy_setopt(curl, CURLOPT_URL, URL.c_str());
         curl_easy_setopt(curl, CURLOPT_USERAGENT, "Goldleaf");
         curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
         curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlFileWrite);
         curl_easy_setopt(curl, CURLOPT_WRITEDATA, f);
         curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
         curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, CurlProgress);
         curl_easy_perform(curl);
         curl_easy_cleanup(curl);
     }
     fclose(f);
     socketExit();
 }
Exemple #3
0
 std::string RetrieveContent(std::string URL, std::string MIMEType)
 {
     socketInitializeDefault();
     std::string cnt;
     CURL *curl = curl_easy_init();
     if(!MIMEType.empty())
     {
         curl_slist *headerdata = NULL;
         headerdata = curl_slist_append(headerdata, ("Content-Type: " + MIMEType).c_str());
         headerdata = curl_slist_append(headerdata, ("Accept: " + MIMEType).c_str());
         curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerdata);
     }
     curl_easy_setopt(curl, CURLOPT_URL, URL.c_str());
     curl_easy_setopt(curl, CURLOPT_USERAGENT, "Goldleaf");
     curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
     curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
     curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlStrWrite);
     curl_easy_setopt(curl, CURLOPT_WRITEDATA, &cnt);
     curl_easy_perform(curl);
     curl_easy_cleanup(curl);
     socketExit();
     return cnt;
 }
Exemple #4
0
Result socketInitialize(const SocketInitConfig *config) {
    Result ret = 0;
    BsdInitConfig bcfg = {
        .version = config->bsdsockets_version,

        .tcp_tx_buf_size        = config->tcp_tx_buf_size,
        .tcp_rx_buf_size        = config->tcp_rx_buf_size,
        .tcp_tx_buf_max_size    = config->tcp_tx_buf_max_size,
        .tcp_rx_buf_max_size    = config->tcp_rx_buf_max_size,

        .udp_tx_buf_size = config->udp_tx_buf_size,
        .udp_rx_buf_size = config->udp_rx_buf_size,

        .sb_efficiency = config->sb_efficiency,
    };

    SfdnsresConfig sfdnsresConfig = {
        .serialized_out_addrinfos_max_size  = config->serialized_out_addrinfos_max_size,
        .serialized_out_hostent_max_size    = config->serialized_out_hostent_max_size,
        .bypass_nsd                         = config->bypass_nsd,
        .timeout                            = config->dns_timeout,
    };

    int dev = FindDevice("soc:");
    if(dev != -1)
        return MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);

    ret = bsdInitialize(&bcfg);
    if(R_SUCCEEDED(ret))
        dev = AddDevice(&g_socketDevoptab);
    else {
        socketExit();
        return ret;
    }

    if(dev == -1) {
        socketExit();
        return MAKERESULT(Module_Libnx, LibnxError_TooManyDevOpTabs);
    }
    else {
        g_bsdResult = 0;
        g_bsdErrno = 0;

        g_sfdnsresConfig = sfdnsresConfig;
        g_sfdnsresResult = 0;
    }

    return ret;
}

void socketExit(void) {
    RemoveDevice("soc:");
    bsdExit();
}

Result socketGetLastBsdResult(void) {
    return g_bsdResult;
}

Result socketGetLastSfdnsresResult(void) {
    return g_sfdnsresResult;
}

/***********************************************************************************************************************/

static int _socketGetFd(int fd) {
    __handle *handle = __get_handle(fd);
    if(handle == NULL) {
        errno = EBADF;
        return -1;
    }
    if(strcmp(devoptab_list[handle->device]->name, "soc") != 0) {
        errno = ENOTSOCK;
        return -1;
    }
    return *(int *)handle->fileStruct;
}