Esempio n. 1
0
void device_opencl_info(vector<DeviceInfo>& devices)
{
	vector<OpenCLPlatformDevice> usable_devices;
	OpenCLInfo::get_usable_devices(&usable_devices);
	/* Devices are numbered consecutively across platforms. */
	int num_devices = 0;
	foreach(OpenCLPlatformDevice& platform_device, usable_devices) {
		const string& platform_name = platform_device.platform_name;
		const cl_device_type device_type = platform_device.device_type;
		const string& device_name = platform_device.device_name;
		string hardware_id = platform_device.hardware_id;
		if(hardware_id == "") {
			hardware_id = string_printf("ID_%d", num_devices);
		}

		DeviceInfo info;
		info.type = DEVICE_OPENCL;
		info.description = string_remove_trademark(string(device_name));
		info.num = num_devices;
		/* We don't know if it's used for display, but assume it is. */
		info.display_device = true;
		info.advanced_shading = OpenCLInfo::kernel_use_advanced_shading(platform_name);
		info.pack_images = true;
		info.use_split_kernel = OpenCLInfo::kernel_use_split(platform_name,
		                                                     device_type);
		info.id = string("OPENCL_") + platform_name + "_" + device_name + "_" + hardware_id;
		devices.push_back(info);
		num_devices++;
	}
}
Esempio n. 2
0
void RedScreen::set_name(const std::string& name)
{
    if (!name.empty()) {
        string_printf(_name, name.c_str(), _id);
    }
    _window.set_title(_name);
}
Esempio n. 3
0
char *uri2filename(UriUriA *uri)
{
	char *furi_str = uri2string(uri);
	char *newfilename = NULL;

	if (!furi_str)
		return NULL;

	string_replace_with_char(furi_str, "//", *DIR_SEPAR_STR);
	string_replace_with_char(furi_str, "/", *DIR_SEPAR_STR);

#ifdef _WIN32
	string_replace_with_char(furi_str, ":", '_');
#endif

	if (furi_str) {
		string_printf(&newfilename, "%s%s", option_values.file_output_directory, furi_str);

		if (newfilename[strlen(newfilename)-1] == *DIR_SEPAR_STR)
			string_cat(&newfilename, "index.html");
	}

	string_free(furi_str);

	return newfilename;
}
Esempio n. 4
0
	bool load_kernels(bool experimental)
	{
		/* check if cuda init succeeded */
		if(cuContext == 0)
			return false;

		if(!support_device(experimental))
			return false;

		/* get kernel */
		string cubin = compile_kernel();

		if(cubin == "")
			return false;

		/* open module */
		cuda_push_context();

		CUresult result = cuModuleLoad(&cuModule, cubin.c_str());
		if(cuda_error(result))
			cuda_error(string_printf("Failed loading CUDA kernel %s.", cubin.c_str()));

		cuda_pop_context();

		return (result == CUDA_SUCCESS);
	}
Esempio n. 5
0
char *get_host(UriUriA *uri)
{
	char *ret_str = NULL;
	int i, len = 0;

	if (uri->hostData.ip4)
		return *string_printf(&ret_str, "%d.%d.%d.%d", uri->hostData.ip4->data[0],
			uri->hostData.ip4->data[1], uri->hostData.ip4->data[2], uri->hostData.ip4->data[3]);
	
	if (uri->hostData.ip6) {
		ret_str = string_alloc(40);

		for (i = 0; i < 16; i++) {
			len += sprintf(ret_str + len, "%2.2x", uri->hostData.ip6->data[i]);
			if (i % 2 == 1 && i < 15)
				ret_str[len++] = ':';
		}
		return ret_str;
	}

	if (uri->hostData.ipFuture.first) 
		return string_nnew(uri->hostData.ipFuture.first,
			uri->hostData.ipFuture.afterLast - uri->hostData.ipFuture.first);

	if (uri->hostText.first) 
		return string_nnew(uri->hostText.first, uri->hostText.afterLast - uri->hostText.first);

	return NULL;
}
Esempio n. 6
0
extern
void add_aws_nodes ( KConfig *self )
{
    char home [ 4096 ] = "";

    size_t num_writ;
    char path [ 4096 ];
    rc_t rc;

    check_env ( self, home, sizeof home );
    /* if home environtment is found, create AWS root node */

    if ( home [ 0 ] != 0 )
    {
        rc = string_printf ( path, sizeof path, &num_writ, "%s/.aws", home );
        if ( rc == 0 && num_writ != 0 )
        {
            KConfigNode *aws_node;
            
            /* create aws node */
            rc = KConfigOpenNodeUpdate ( self, &aws_node, "AWS", NULL );
            if ( rc == 0 )
                rc = aws_find_nodes ( aws_node, path );
            
            rc = KConfigNodeRelease ( aws_node );
        }
    }
}
Esempio n. 7
0
static bool CC write_to_file_cb( stat_row * row, void * f_data )
{
    write_ctx * wctx = ( write_ctx * ) f_data;
    char buffer[ 256 ];
    size_t num_writ;

    rc_t rc = string_printf ( buffer, sizeof buffer, &num_writ,
                                "%s\t%u\t%u\t%s\t%u\t%u\t%u\t%u\t%u\t%u\n", 
                                row->spotgroup, 
                                row->base_pos,
                                row->n_read,
                                row->dimer,
                                row->gc_content,
                                row->hp_run,
                                row->max_qual_value,
                                row->quality,
                                row->count,
                                row->mismatch_count );

    if ( rc == 0 )
    {
        size_t f_writ;
        rc = KFileWrite ( wctx->out, wctx->pos, buffer, num_writ, &f_writ );
        if ( rc == 0 )
        {
            uint32_t percent = progressbar_percent( wctx->entries, ++wctx->lines, wctx->fract_digits );
            update_progressbar( wctx->progress, percent );
            wctx->pos += f_writ;
        }
    }
    return ( rc == 0 );
}
Esempio n. 8
0
void BlenderSession::update_status_progress()
{
	string timestatus, status, substatus;
	float progress;
	double total_time;
	char time_str[128];
	float mem_used = (float)session->stats.mem_used / 1024.0f / 1024.0f;
	float mem_peak = (float)session->stats.mem_peak / 1024.0f / 1024.0f;

	get_status(status, substatus);
	get_progress(progress, total_time);

	timestatus = string_printf("Mem: %.2fM, Peak: %.2fM | ", mem_used, mem_peak);

	timestatus += b_scene.name();
	if(b_rlay_name != "")
		timestatus += ", "  + b_rlay_name;
	timestatus += " | ";

	BLI_timestr(total_time, time_str, sizeof(time_str));
	timestatus += "Elapsed: " + string(time_str) + " | ";

	if(substatus.size() > 0)
		status += " | " + substatus;

	if(status != last_status) {
		b_engine.update_stats("", (timestatus + status).c_str());
		b_engine.update_memory_stats(mem_used, mem_peak);
		last_status = status;
	}
	if(progress != last_progress) {
		b_engine.update_progress(progress);
		last_progress = progress;
	}
}
Esempio n. 9
0
  GuessedTimeZone() {
    time_t the_time = time(0);
    struct tm tmbuf;
    struct tm *ta = localtime_r(&the_time, &tmbuf);
    const char *tzid = nullptr;
    if (ta) {
      tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff,
                                           ta->tm_isdst);
    }
    if (!tzid) {
      tzid = "UTC";
    }
    m_tzid = tzid;

#define DATE_TZ_ERRMSG \
  "It is not safe to rely on the system's timezone settings. Please use " \
  "the date.timezone setting, the TZ environment variable or the " \
  "date_default_timezone_set() function. In case you used any of those " \
  "methods and you are still getting this warning, you most likely " \
  "misspelled the timezone identifier. "

    string_printf(m_warning, DATE_TZ_ERRMSG
                  "We selected '%s' for '%s/%.1f/%s' instead",
                  tzid, ta ? ta->tm_zone : "Unknown",
                  ta ? (float) (ta->tm_gmtoff / 3600) : 0,
                  ta ? (ta->tm_isdst ? "DST" : "no DST") : "Unknown");
  }
Esempio n. 10
0
static void print_matchcount( char * buffer, size_t buf_len, size_t *buf_idx, int *match_count )
{
    size_t num_writ;
    string_printf( &buffer[ *buf_idx ], buf_len - *buf_idx, &num_writ,    "%d", *match_count );
    *match_count = 0;
    *buf_idx += num_writ;
}
Esempio n. 11
0
static ShaderOutput *node_find_output_by_name(ShaderNode *node,
                                              BL::Node& b_node,
                                              BL::NodeSocket& b_socket)
{
	string name = b_socket.name();

	if(node_use_modified_socket_name(node)) {
		BL::Node::outputs_iterator b_output;
		bool found = false;
		int counter = 0, total = 0;

		for(b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
			if(b_output->name() == name) {
				if(!found)
					counter++;
				total++;
			}

			if(b_output->ptr.data == b_socket.ptr.data)
				found = true;
		}

		/* rename if needed */
		if(name == "Shader")
			name = "Closure";

		if(total > 1)
			name = string_printf("%s%d", name.c_str(), counter);
	}

	return node->output(name.c_str());
}
Esempio n. 12
0
Variant HHVM_FUNCTION(vprintf, const Variant& vformat, const Variant& args) {
    String format = vformat.toString();
    String output = string_printf(format.data(), format.size(), args.toArray());
    if (output.isNull()) return false;
    g_context->write(output.data(), output.size());
    return output.size();
}
//=============================================================================
// y-func : Functions for Neutrino
//=============================================================================
//-------------------------------------------------------------------------
// y-func : mount_get_list
//-------------------------------------------------------------------------
std::string  CNeutrinoYParser::func_mount_get_list(CyhookHandler *, std::string)
{
	CConfigFile *Config = new CConfigFile(',');
	std::string ysel, ytype, yip, ylocal_dir, ydir, ynr, yresult;
	int yitype;

	Config->loadConfig(NEUTRINO_CONFIGFILE);
	for(unsigned int i=0; i <= 7; i++)
	{
		ynr=itoa(i);
		ysel = ((i==0) ? "checked=\"checked\"" : "");
		yitype = Config->getInt32("network_nfs_type_"+ynr,0);
		ytype = ( (yitype==0) ? "NFS" :((yitype==1) ? "CIFS" : "FTPFS") );
		yip = Config->getString("network_nfs_ip_"+ynr,"");
		ydir = Config->getString("network_nfs_dir_"+ynr,"");
		ylocal_dir = Config->getString("network_nfs_local_dir_"+ynr,"");
		if(!ydir.empty())
			ydir="("+ydir+")";

		yresult += string_printf("<input type='radio' name='R1' value='%d' %s />%d %s - %s %s %s<br/>",
			i,ysel.c_str(),i,ytype.c_str(),yip.c_str(),ylocal_dir.c_str(), ydir.c_str());
	}
	delete Config;
	return yresult;
}
Esempio n. 14
0
static
rc_t CC KStsDefaultFormatter( void* self, KWrtHandler* writer,
                              size_t argc, const wrt_nvp_t args[],
                              size_t envc, const wrt_nvp_t envs[] )
{
    rc_t rc = 0;
    size_t num_writ, nsize;
    uint32_t mlen;
    char buffer[8192], *nbuffer;
    const char* msg, *mend;

    /* if writer is null than silence */
    if( writer == NULL || writer->writer == NULL ) {
        return rc;
    }
    msg = wrt_nvp_find_value(envc, envs, "message");
    if( msg != NULL ) {
        mend = msg + strlen(msg);
        /* strip trailing newlines */
        while( mend != msg && (*mend == '\n' || *mend == '\r') ) {
            --mend;
        }
        mlen = ( uint32_t ) ( mend - msg );
    } else {
        mlen = 0;
    }

    nbuffer = buffer;
    nsize = sizeof(buffer);
    do {
        rc = string_printf(nbuffer, nsize, & num_writ, "%s %s.%s: %.*s\n",
                                 wrt_nvp_find_value(envc, envs, "timestamp"),
                                 wrt_nvp_find_value(envc, envs, "app"),
                                 wrt_nvp_find_value(envc, envs, "version"),
                                 ( uint32_t ) mlen, msg);
        if( num_writ > nsize ) {
            assert ( nbuffer == buffer );
            nbuffer = malloc(nsize = num_writ + 2);
            if( nbuffer == NULL ) {
                rc = RC(rcRuntime, rcLog, rcLogging, rcMemory, rcExhausted);
                break;
            }
            continue;
        }
        /* replace newlines with spaces, excluding last one */
        for(nsize = 0; nsize < num_writ - 1; nsize++) {
            if( nbuffer[nsize] == '\n' || nbuffer[nsize] == '\r' ) {
                nbuffer[nsize] = ' ';
            }
        }
        break;
    } while(true);
    if( rc == 0 ) {
        rc = LogFlush(writer, nbuffer, num_writ);
    }
    if( nbuffer != buffer ) {
        free(nbuffer);
    }
    return rc;
}
Esempio n. 15
0
/*
 * parse_SIZE
 *
 * %SIZE(structure-attribute)
 *
 * Returns the number of addressable units that would
 * be allocated for a data segment with the specified
 * structure attribute.
 */
static int
parse_SIZE (parse_ctx_t pctx, void *vctx, quotelevel_t ql, lextype_t lt)
{
    expr_ctx_t ctx = vctx;
    lexeme_t *lex;
    strudef_t *stru;
    unsigned int units;

    if (!parser_expect(pctx, QL_NORMAL, LEXTYPE_DELIM_LPAR, 0, 1)) {
        expr_signal(ctx, STC__DELIMEXP, "(");
        return 0;
    }
    units = 0;
    if (!parser_expect(pctx, QL_NORMAL, LEXTYPE_NAME_STRUCTURE, &lex, 1)) {
        expr_signal(ctx, STC__STRUNMEXP);
        return 1;
    }
    if (!structure_allocate(ctx, lexeme_ctx_get(lex), &stru, &units, 0, 0)) {
        expr_signal(ctx, STC__SYNTAXERR);
    }
    if (!parser_expect(pctx, QL_NORMAL, LEXTYPE_DELIM_RPAR, 0, 1)) {
        expr_signal(ctx, STC__DELIMEXP, ")");
    }

    parser_insert(pctx, parser_lexeme_create(pctx, LEXTYPE_NUMERIC,
                                             string_printf(expr_strctx(ctx), 0,
                                                           "%u", units)));

    return 1;

} /* expr_parse_SIZE */
Esempio n. 16
0
static void display_info(Progress& progress)
{
	static double latency = 0.0;
	static double last = 0;
	double elapsed = time_dt();
	string str, interactive;

	latency = (elapsed - last);
	last = elapsed;

	int sample, tile;
	double total_time, sample_time;
	string status, substatus;

	sample = progress.get_sample();
	progress.get_tile(tile, total_time, sample_time);
	progress.get_status(status, substatus);

	if(substatus != "")
		status += ": " + substatus;

	interactive = options.interactive? "On":"Off";

	str = string_printf("%s        Time: %.2f        Latency: %.4f        Sample: %d        Average: %.4f        Interactive: %s",
						status.c_str(), total_time, latency, sample, sample_time, interactive.c_str());

	view_display_info(str.c_str());

	if(options.show_help)
		view_display_help();
}
Esempio n. 17
0
static rc_t enter_vdbcopy_node( KMetadata *dst_meta, const bool show_meta )
{
    rc_t rc;
    KMDataNode *hist_node;

    if ( show_meta )
        KOutMsg( "--- entering Copy entry...\n" );

    rc = KMetadataOpenNodeUpdate ( dst_meta, &hist_node, "HISTORY" );
    DISP_RC( rc, "enter_vdbcopy_node:KMetadataOpenNodeUpdate('HISTORY') failed" );
    if ( rc == 0 )
    {
        char event_name[ 32 ];
        uint32_t index = get_child_count( hist_node ) + 1;
        rc = string_printf ( event_name, sizeof( event_name ), NULL, "EVENT_%u", index );
        DISP_RC( rc, "enter_vdbcopy_node:string_printf(EVENT_NR) failed" );
        if ( rc == 0 )
        {
            KMDataNode *event_node;
            rc = KMDataNodeOpenNodeUpdate ( hist_node, &event_node, event_name );
            DISP_RC( rc, "enter_vdbcopy_node:KMDataNodeOpenNodeUpdate('EVENT_NR') failed" );
            if ( rc == 0 )
            {
                rc = enter_date_name_vers( event_node );
                KMDataNodeRelease ( event_node );
            }
        }
        KMDataNodeRelease ( hist_node );
    }
    return rc;
}
Esempio n. 18
0
static void display_info(Progress& progress)
{
	static double latency = 0.0;
	static double last = 0;
	double elapsed = time_dt();
	string str;

	latency = (elapsed - last);
	last = elapsed;

	int sample, tile;
	double total_time, sample_time;
	string status, substatus;

	sample = progress.get_sample();
	progress.get_tile(tile, total_time, sample_time);
	progress.get_status(status, substatus);

	if(substatus != "")
		status += ": " + substatus;

	str = string_printf("latency: %.4f        sample: %d        total: %.4f        average: %.4f        %s",
		latency, sample, total_time, sample_time, status.c_str());

	view_display_info(str.c_str());
}
Esempio n. 19
0
static void _doc_process_var(doc_ptr doc, cptr name)
{
    if (strcmp(name, "version") == 0)
    {
        string_ptr s = string_alloc_format("%d.%d.%d", VER_MAJOR, VER_MINOR, VER_PATCH);
        doc_insert(doc, string_buffer(s));
        string_free(s);
    }
    else if (strlen(name) > 3 && strncmp(name, "FF_", 3) == 0)
    {
        char buf[100];
        int  f_idx;

        sprintf(buf, "%s", name + 3);
        f_idx = f_tag_to_index(buf);

        if (0 <= f_idx && f_idx < max_f_idx)
        {
            string_ptr s = string_alloc();
            feature_type *feat = &f_info[f_idx];

            string_printf(s, "<color:%c>%c</color>",
                attr_to_attr_char(feat->d_attr[F_LIT_STANDARD]),
                feat->d_char[F_LIT_STANDARD]);

            doc_insert(doc, string_buffer(s));
            string_free(s);
        }
    }
}
Esempio n. 20
0
static void get_string_cell( char * buffer, size_t buffer_size, const VTable * tab, int64_t row, const char * column )
{
    if ( has_col( tab, column ) )
    {
        const VCursor * cur;
        rc_t rc = VTableCreateCursorRead( tab, &cur );
        if ( rc == 0 )
        {
            uint32_t idx;
            rc = VCursorAddColumn( cur, &idx, column );
            if ( rc == 0 )
            {
                rc = VCursorOpen( cur );
                if ( rc == 0 )
                {
                    const char * src;
                    uint32_t row_len;
                    rc = VCursorCellDataDirect( cur, row, idx, NULL, (const void**)&src, NULL, &row_len );
                    if ( rc == 0 )
                    {
                        size_t num_writ;
                        string_printf( buffer, buffer_size, &num_writ, "%.*s", row_len, src );
                    }
                }
            }
            VCursorRelease( cur );
        }
    }
}
Esempio n. 21
0
//-----------------------------------------------------------------------------
// parse parameter string
//       parameter               = attribute "=" value
//       attribute               = token
//       value                   = token | quoted-string
//
// 	If parameter attribute is multiple times given, the values are stored like this:
// 		<attribute>=<value1>,<value2>,..,<value n>
//-----------------------------------------------------------------------------
bool CWebserverRequest::ParseParams(std::string param_string)
{
	bool ende = false;
	std::string param, name="", value, number;

	while(!ende)
	{
		if(!ySplitStringExact(param_string,"&",param,param_string))
			ende = true;
		if(ySplitStringExact(param,"=",name,value))
		{
			name = decodeString(name);
			value = trim(decodeString(value));
			if(ParameterList[name].empty())
				ParameterList[name] = value;
			else
			{
				ParameterList[name] += ",";
				ParameterList[name] += value;
			}
		}
		else
			name = trim(decodeString(name));
		number = string_printf("%d", ParameterList.size()+1);
		log_level_printf(7,"ParseParams: name: %s value: %s\n",name.c_str(), value.c_str());
		ParameterList[number] = name;
	}
	return true;
}
//-------------------------------------------------------------------------
// y-func : get_bouquets_as_dropdown [<bouquet>] <doshowhidden>
//-------------------------------------------------------------------------
std::string  CNeutrinoYParser::func_get_bouquets_as_dropdown(CyhookHandler *, std::string para)
{
	std::string yresult, sel, nr_str, do_show_hidden;
	int nr=1;

	ySplitString(para," ",nr_str, do_show_hidden);
	if(!nr_str.empty())
		nr = atoi(nr_str.c_str());

	int mode = NeutrinoAPI->Zapit->getMode();
	for (int i = 0; i < (int) g_bouquetManager->Bouquets.size(); i++) {
		//ZapitChannelList &channels = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->Bouquets[i]->radioChannels : g_bouquetManager->Bouquets[i]->tvChannels;
		ZapitChannelList channels;
		if (mode == CZapitClient::MODE_RADIO)
			g_bouquetManager->Bouquets[i]->getRadioChannels(channels);
		else
			g_bouquetManager->Bouquets[i]->getTvChannels(channels);
		sel=(nr==(i+1)) ? "selected=\"selected\"" : "";
		if(!channels.empty() && (!g_bouquetManager->Bouquets[i]->bHidden || do_show_hidden == "true"))
			yresult += string_printf("<option value=%u %s>%s</option>\n", i + 1, sel.c_str(),
				std::string(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) :g_bouquetManager->Bouquets[i]->Name.c_str()).c_str());
			//yresult += string_printf("<option value=%u %s>%s</option>\n", i + 1, sel.c_str(), (encodeString(std::string(g_bouquetManager->Bouquets[i]->Name.c_str()))).c_str());
	}
	return yresult;
}
Esempio n. 23
0
static void test_encrypted(string* x,string* y,string *pri) {
    string mess,messb,encrypted_mess,xx,yy,tag;
    INIT(mess);
    INIT(messb);
    INIT(encrypted_mess);
    INIT(xx);
    INIT(yy);
    INIT(tag);

    mess.len = 10;
    mess.buf = (u8*)malloc(10);
    mess.buf[0] = 'h';
    mess.buf[1] = 'e';
    mess.buf[2] = 'l';
    mess.buf[3] = 'l';
    mess.buf[4] = 'o';
    mess.buf[5] = 'w';
    mess.buf[6] = 'o';
    mess.buf[7] = 'r';
    mess.buf[8] = 'd';
    mess.buf[9] = '\0';
    int res;
    printf("%s %d\n",__FILE__,__LINE__);
    res = crypto_ECIES_encrypto_message(&mess,x,y,&xx,&yy,&encrypted_mess,&tag);
    string_printf("xx",&xx);
    string_printf("yy",&yy);
    string_printf("encryptd_mess",&encrypted_mess);
    string_printf("tag",&tag);

    FILE *fd;
    fd = fopen("encrypted_mess","w");
    fwrite(encrypted_mess.buf,1,encrypted_mess.len,fd);
    fd = fopen("xx","w");
    fwrite(xx.buf,1,xx.len,fd);
    fd = fopen("yy","w");
    fwrite(yy.buf,1,yy.len,fd);
    fd = fopen("tag","w");
    fwrite(tag.buf,1,tag.len,fd);


    if(res != 0) {
        error();
        return;
    }
    res = crypto_ECIES_decrypto_message(&encrypted_mess,&xx,&yy,&tag,pri,&messb);
    printf("res :%d\n",res);
}
Esempio n. 24
0
static void CC num_gen_as_string_cb( void *item, void *data )
{
    char temp[40];
    p_num_gen_node node = ( p_num_gen_node )item;
    long unsigned int start = node->start;
    long unsigned int end = ( start + node->count - 1 );
    switch( node->count )
    {
    case 0 : temp[0]=0;
             break;
    case 1 : string_printf ( temp, sizeof temp, NULL, "%lu,", start );
             break;
    default: string_printf ( temp, sizeof temp, NULL, "%lu-%lu,", start, end );
             break;
    }
    string_ctx_add( ( p_string_ctx )data, temp );
}
static SCM
ppscm_make_pp_type_error_exception (const char *message, SCM object)
{
  std::string msg = string_printf ("%s: ~S", message);
  return gdbscm_make_error (pp_type_error_symbol,
			    NULL /* func */, msg.c_str (),
			    scm_list_1 (object), scm_list_1 (object));
}
Esempio n. 26
0
static std::string
i386_windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
{
  if (ptid.lwp () != 0)
    return string_printf ("Thread 0x%lx", ptid.lwp ());

  return normal_pid_to_str (ptid);
}
Esempio n. 27
0
	lfl_string as_loadvars::create_request(const lfl_string& method, const lfl_string& uri, bool send_data)
	{
		lfl_string information;
		//create information in the form of name=value (urlencoded)
		string_hash<lfl_string>::iterator it = m_values.begin();
		for(bool first = true; it != m_values.end(); ++it)
		{
			lfl_string name, value;

			name = it->first;
			value = it->second;

			url_encode( &name );
			url_encode( &value );
			information += string_printf("%s%s=%s", first? "":"&",name.c_str(), value.c_str() );
			first = false;
		}

		if( method == "POST")
		{
			lfl_string request = string_printf( "POST %s HTTP/1.1\r\n", uri.c_str() );

			m_headers.set("Content-Length", string_printf( "%i", information.size()));

			request += create_header();
			request += "\r\n";
			request += information;

			return request;
		}
		else if(method == "GET")
		{
			lfl_string request = string_printf( "GET %s?%s HTTP/1.1\r\n", uri.c_str(), information.c_str() );
			request += create_header();
			request += "\r\n";

			return request;
		}
		else
		{
			assert(0 && "unsupported");
		}

		return "";
	}
Esempio n. 28
0
static string line_directive(const string& path, int line)
{
	string escaped_path = path;
	string_replace(escaped_path, "\"", "\\\"");
	string_replace(escaped_path, "\'", "\\\'");
	string_replace(escaped_path, "\?", "\\\?");
	string_replace(escaped_path, "\\", "\\\\");
	return string_printf("#line %d \"%s\"", line, escaped_path.c_str());
}
Esempio n. 29
0
string string_human_readable_size(size_t size)
{
	static const char suffixes[] = "BKMGTPEZY";

	const char* suffix = suffixes;
	size_t r = 0;

	while(size >= 1024) {
		r = size % 1024;
		size /= 1024;
		suffix++;
	}

	if(*suffix != 'B')
		return string_printf("%.2f%c", double(size*1024+r)/1024.0, *suffix);
	else
		return string_printf("%zu", size);
}
Esempio n. 30
0
string NamedSizeStats::full_report(int indent_level)
{
	const string indent(indent_level * kIndentNumSpaces, ' ');
	const string double_indent = indent + indent;
	string result = "";
	result += string_printf("%sTotal memory: %s (%s)\n",
	                        indent.c_str(),
	                        string_human_readable_size(total_size).c_str(),
	                        string_human_readable_number(total_size).c_str());
	sort(entries.begin(), entries.end(), namedSizeEntryComparator);
	foreach(const NamedSizeEntry& entry, entries) {
		result += string_printf(
		        "%s%-32s %s (%s)\n",
		        double_indent.c_str(),
		        entry.name.c_str(),
		        string_human_readable_size(entry.size).c_str(),
		        string_human_readable_number(entry.size).c_str());
	}