示例#1
0
static ftRequest_t* FTP_DLRequest(const char* url)
{
	char address[MAX_OSPATH];
	char ftppath[MAX_OSPATH];
	char* charloc;
	ftRequest_t* request;

	/* Strip away trailing spaces */
	
	
	while(*url == ' ')
		url++;
	
	Com_DPrintf("FTPDLRequest: Open URL: ftp://%s\n", url);
	
	Q_strncpyz(address, url, sizeof(address));
	Q_strncpyz(ftppath, url, sizeof(ftppath));
	
	charloc = strchr(address, '/');
	if(charloc)
	{
		charloc[0] = '\0';
	}
	
	if (strchr(address, ':') == NULL) {
		Q_strcat(address, sizeof(address), ":21");
	}
	
	charloc = strchr(ftppath, '/');
	if(charloc && charloc != ftppath)
	{
		Q_bstrcpy(ftppath, charloc);
	}else{
		ftppath[0] = '/';
		ftppath[1] = '\0';
	}
		
	if(strlen(address) < 2)
		return NULL;
	
	request = FT_CreateRequest(address, ftppath);
	
	if(request == NULL)
		return NULL;
	
	request->protocol = FT_PROTO_FTP;
	request->active = qtrue;
	request->stage = 0;
	return request;	
}
void  GScr_GetCvar()
{
  const char *stringval;
  const char *querystr;
  char promod_fool_names[1024];
  char promod_fool_sums[1024];

  if(Scr_GetNumParam() != 1)
  {
	Scr_Error("Usage: getcvar <cvarname>");
  }

  querystr = Scr_GetString(0);

  stringval = Cvar_GetVariantString(querystr);

  if( !Q_stricmpn( querystr, "sv_iwd" , 6) )
  {
    Cvar_VariableStringBuffer("sv_iwdNames", promod_fool_names, sizeof( promod_fool_names ));
    Cvar_VariableStringBuffer("sv_iwds", promod_fool_sums, sizeof( promod_fool_sums ));

    char* ptr_names = promod_fool_names;
    char* ptr_sums = promod_fool_sums;
    int len;
    /* 1st get the number of IWDs */
    while(*ptr_names && *ptr_sums)
    {
        if(*ptr_names == ' ' && *ptr_sums == ' ')
        {
            ptr_names++;
            ptr_sums++;

            if(!Q_stricmpn(ptr_names, "xiceops_", 8))
            {
                len = Q_strichr(ptr_names, ' ');
                if(len == -1)
                {
                    Scr_AddString(stringval);
                    return;
                }
                Q_bstrcpy(ptr_names, &ptr_names[len +1]);

                len = Q_strichr(ptr_sums, ' ');
                if(len == -1)
                {
                    Scr_AddString(stringval);
                    return;
                }
                Q_bstrcpy(ptr_sums, &ptr_sums[len +1]);
            }
        }
        if(*ptr_names != ' ')
            ptr_names++;

        if(*ptr_sums != ' ')
            ptr_sums++;
    }

    if(!Q_stricmp( querystr, "sv_iwdNames") )
    {
        Scr_AddString(promod_fool_names);
        return;
    }
    if(!Q_stricmp( querystr, "sv_iwds") )
    {
        Scr_AddString(promod_fool_sums);
        return;
    }
  }

  Scr_AddString(stringval);
}
示例#3
0
static ftRequest_t* HTTPGetRequest(const char* url)
{
	char address[MAX_OSPATH];
	char wwwpath[MAX_OSPATH];
	char getbuffer[MAX_STRING_CHARS];
	char* charloc;
	ftRequest_t* request;
	
	
	/* Strip away trailing spaces */
	
	while(*url == ' ')
		url++;
	
	Com_DPrintf("HTTPGetRequest: Open URL: http://%s\n", url);
	
	Q_strncpyz(address, url, sizeof(address));
	Q_strncpyz(wwwpath, url, sizeof(wwwpath));
	
	charloc = strchr(address, '/');
	if(charloc)
	{
		charloc[0] = '\0';
	}
	
	if (strchr(address, ':') == NULL) {
		Q_strcat(address, sizeof(address), ":80");
	}
	
	charloc = strchr(wwwpath, '/');
	if(charloc && charloc != wwwpath)
	{
		Q_bstrcpy(wwwpath, charloc);
	}else{
		wwwpath[0] = '/';
		wwwpath[1] = '\0';
	}
	
	
	if(strlen(address) < 2)
		return NULL;
	
	request = FT_CreateRequest(address, wwwpath);
	
	if(request == NULL)
		return NULL;
	
	request->protocol = FT_PROTO_HTTP;
	request->active = qtrue;
	
	
	Com_sprintf(getbuffer, sizeof(getbuffer),
				"GET %s HTTP/1.1 \r\n"
				"Host: %s \r\n"
				"User-Agent: %s \r\n"
				"Accept-Encoding: \r\n"
				"Connection: Close\r\n"
				"\r\n", wwwpath, address, "CoD4X HTTP Downloader");
	
	FT_AddData(request, getbuffer, strlen(getbuffer));
	
	return request;
	
}