当前位置: 首页>>代码示例>>C++>>正文


C++ write_string函数代码示例

本文整理汇总了C++中write_string函数的典型用法代码示例。如果您正苦于以下问题:C++ write_string函数的具体用法?C++ write_string怎么用?C++ write_string使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了write_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: command_find_frame_props_cache_client

static void command_find_frame_props_cache_client(void * x) {
    CommandFindFrameInfo * args = (CommandFindFrameInfo *)x;
    Channel * c = cache_channel();
    Context * ctx = NULL;
    StackTracingInfo * info = NULL;
    int err = 0;

    ctx = id2ctx(args->id);
    if (ctx == NULL) err = ERR_INV_CONTEXT;
    else if (get_stack_tracing_info(ctx, args->addr, &info) < 0) err = errno;

    cache_exit();

    write_stringz(&c->out, "R");
    write_stringz(&c->out, args->token);
    write_errno(&c->out, err);

    if (args->props) {
        unsigned cnt = 0;
        write_stream(&c->out, '{');

        if (info != NULL && info->size) {
            json_write_string(&c->out, "CodeAddr");
            write_stream(&c->out, ':');
            json_write_uint64(&c->out, info->addr);
            write_stream(&c->out, ',');
            json_write_string(&c->out, "CodeSize");
            write_stream(&c->out, ':');
            json_write_uint64(&c->out, info->size);
            cnt++;
        }

        if (info != NULL && info->fp != NULL) {
            if (cnt++ > 0) write_stream(&c->out, ',');
            json_write_string(&c->out, "FP");
            write_stream(&c->out, ':');
            write_commands(&c->out, ctx, info->fp->cmds, info->fp->cmds_cnt);
        }

        if (info != NULL && info->regs != NULL) {
            int i;
            if (cnt++ > 0) write_stream(&c->out, ',');
            json_write_string(&c->out, "Regs");
            write_stream(&c->out, ':');
            write_stream(&c->out, '{');
            for (i = 0; i < info->reg_cnt; i++) {
                if (i > 0) write_stream(&c->out, ',');
                json_write_string(&c->out, register2id(ctx, STACK_NO_FRAME, info->regs[i]->reg));
                write_stream(&c->out, ':');
                write_commands(&c->out, ctx, info->regs[i]->cmds, info->regs[i]->cmds_cnt);
            }
            write_stream(&c->out, '}');
        }

        if (info != NULL && info->subs != NULL) {
            int i;
            if (cnt++ > 0) write_stream(&c->out, ',');
            json_write_string(&c->out, "Inlined");
            write_stream(&c->out, ':');
            write_stream(&c->out, '[');
            for (i = 0; i < info->sub_cnt; i++) {
                if (i > 0) write_stream(&c->out, ',');
                write_inlined_subroutine_info(&c->out, info->subs[i]);
            }
            write_stream(&c->out, ']');
        }

        write_stream(&c->out, '}');
        write_stream(&c->out, 0);
    }
    else {
        /* Deprecated, use findFrameProps */

        json_write_uint64(&c->out, info ? info->addr : 0);
        write_stream(&c->out, 0);
        json_write_uint64(&c->out, info ? info->size : 0);
        write_stream(&c->out, 0);

        if (info == NULL || info->fp == NULL) write_string(&c->out, "null");
        else write_commands(&c->out, ctx, info->fp->cmds, info->fp->cmds_cnt);
        write_stream(&c->out, 0);

        if (info != NULL && info->regs != NULL) {
            int i;
            write_stream(&c->out, '{');
            for (i = 0; i < info->reg_cnt; i++) {
                if (i > 0) write_stream(&c->out, ',');
                json_write_string(&c->out, register2id(ctx, STACK_NO_FRAME, info->regs[i]->reg));
                write_stream(&c->out, ':');
                write_commands(&c->out, ctx, info->regs[i]->cmds, info->regs[i]->cmds_cnt);
            }
            write_stream(&c->out, '}');
        }
        else {
            write_string(&c->out, "null");
        }
        write_stream(&c->out, 0);
    }

    write_stream(&c->out, MARKER_EOM);
//.........这里部分代码省略.........
开发者ID:tom3333,项目名称:tcf.agent,代码行数:101,代码来源:symbols.c

示例2: write_sref

static void 
write_sref(FILE *fob, mxArray *data, double uu_to_dbu)
{
   mxArray *internal, *propfield, *pxy;
   double *pdxy=NULL;
   int32_t xy[2];
   int mxy=0;
   int k,nlen;
   element_t sref;


   /* internal structure */
   if ( !get_field_ptr(data, "internal", &internal) )
      mexErrMsgTxt("gds_write_element (sref) :  missing internal data field.");
   memcpy(&sref, (int32_t *)mxGetData(internal), sizeof(element_t));

   /* number of sref locations contained in compound element */
   if ( get_field_ptr(data, "xy", &pxy) ) {
      mxy = mxGetM(pxy);
      pdxy = (double *)mxGetData(pxy);
   }
   else   
      mexErrMsgTxt("gds_write_element (sref) :  missing or empty xy field.");

   /* 
    * write out the individual sref elements 
    */
   for (k=0; k<mxy; k++) {

      /* SREF */
      write_record_hdr(fob, SREF, 0);

      /* ELFLAGS */
      if ( sref.has & HAS_ELFLAGS ) {
	 write_record_hdr(fob, ELFLAGS, sizeof(uint16_t));
	 write_word(fob, sref.elflags);
      }

      /* PLEX */
      if ( sref.has & HAS_PLEX ) {
	 write_record_hdr(fob, PLEX, sizeof(int32_t));
	 write_int(fob, sref.plex);
      }

      /* SNAME */
      nlen = strlen(sref.sname);
      if ( !nlen )
	 mexErrMsgTxt("gds_write_element (sref) :  name of referenced structure missing.");
      if (nlen % 2)
	 nlen += 1;
      if (nlen > 32)
	 mexErrMsgTxt("gds_write_element (sref) :  structure name must have <= 32 chars.");
      write_record_hdr(fob, SNAME, nlen);
      write_string(fob, sref.sname, nlen);

      /* STRANS */
      if ( sref.has & HAS_STRANS ) {
	 write_record_hdr(fob, STRANS, sizeof(uint16_t));
	 write_word(fob, sref.strans.flags);
	 if ( sref.has & HAS_MAG && sref.strans.mag != 1.0) {
	    write_record_hdr(fob, MAG, 8);
	    write_real8(fob, sref.strans.mag);
	 }
	 if ( sref.has & HAS_ANGLE && sref.strans.angle != 0.0) {
	    write_record_hdr(fob, ANGLE, 8);
	    write_real8(fob, sref.strans.angle);
	 }
      }

      /* XY */
      xy[0] = floor(0.5 + pdxy[k]     * uu_to_dbu);
      xy[1] = floor(0.5 + pdxy[k+mxy] * uu_to_dbu);
      write_record_hdr(fob, XY, 2*sizeof(int32_t));
      write_int_n(fob, xy, 2);
   
      /* Property */
      if ( get_field_ptr(data, "prop", &propfield) )
	 write_property(fob, propfield);

      /* ENDEL */
      write_record_hdr(fob, ENDEL, 0);
   }
} 
开发者ID:huihui7987,项目名称:matlab_hui,代码行数:83,代码来源:gds_write_element.c

示例3: write_aref

static void 
write_aref(FILE *fob, mxArray *data, double uu_to_dbu)
{
   mxArray *field, *propfield, *internal;
   double *pd;
   int32_t xy[6];
   int mxy,nxy=0,nlen;
   element_t aref;


   /* internal structure */
   if ( !get_field_ptr(data, "internal", &internal) )
      mexErrMsgTxt("gds_write_element (aref) :  missing internal data field.");
   memcpy(&aref, (int32_t *)mxGetData(internal), sizeof(element_t));

   /* AREF */
   write_record_hdr(fob, AREF, 0);

   /* ELFLAGS */
   if ( aref.has & HAS_ELFLAGS ) {
      write_record_hdr(fob, ELFLAGS, sizeof(uint16_t));
      write_word(fob, aref.elflags);
   }

   /* PLEX */
   if ( aref.has & HAS_PLEX ) {
      write_record_hdr(fob, PLEX, sizeof(int32_t));
      write_int(fob, aref.plex);
   }

   /* SNAME */   
   nlen = strlen(aref.sname);
   if ( !nlen )
      mexErrMsgTxt("gds_write_element (aref) :  name of referenced structure missing.");
   if (nlen % 2)
      nlen += 1;
   if (nlen > 32)
      mexErrMsgTxt("gds_write_element (aref) :  structure name must have <= 32 chars.");
   write_record_hdr(fob, SNAME, nlen);
   write_string(fob, aref.sname, nlen);

   /* STRANS */
   if ( aref.has & HAS_STRANS ) {
      write_record_hdr(fob, STRANS, sizeof(uint16_t));
      write_word(fob, aref.strans.flags);
      if ( aref.has & HAS_MAG && aref.strans.mag != 1.0) {
	 write_record_hdr(fob, MAG, 8);
	 write_real8(fob, aref.strans.mag);
      }
      if ( aref.has & HAS_ANGLE && aref.strans.angle != 0.0) {
	 write_record_hdr(fob, ANGLE, 8);
	 write_real8(fob, aref.strans.angle);
      }
   }

   /* COLROW */
   if ( !aref.nrow )
      mexErrMsgTxt("gds_write_element (aref) :  number of rows is 0; must be > 0.");
   if ( !aref.ncol )
      mexErrMsgTxt("gds_write_element (aref) :  number of columns is 0; must be > 0.");
   write_record_hdr(fob, COLROW, 2*sizeof(uint16_t));
   write_word(fob, aref.ncol);
   write_word(fob, aref.nrow);
   
   /* XY */
   if ( get_field_ptr(data, "xy", &field) ) {
      pd = (double *)mxGetData(field);
      mxy = mxGetM(field);
      nxy = mxGetN(field);
      if ( (mxy != 3) || (nxy != 2) )
	 mexErrMsgTxt("gds_write_element (aref) :  xy must be 3x2 matrix.");
      scale_trans(pd, xy, mxy, uu_to_dbu);
      write_record_hdr(fob, XY, mxy*nxy*sizeof(int32_t));
      write_int_n(fob, xy, 6);
   }
   else   
      mexErrMsgTxt("gds_write_element (aref) :  missing or empty xy field.");

   /* Property */
   if ( get_field_ptr(data, "prop", &propfield) )
      write_property(fob, propfield);

   /* ENDEL */
   write_record_hdr(fob, ENDEL, 0);
} 
开发者ID:huihui7987,项目名称:matlab_hui,代码行数:85,代码来源:gds_write_element.c

示例4: write_string

std::wstring json_spirit::write_formatted( const wmValue&  value )
{
    return write_string( value, true );
}
开发者ID:ya3-old-c-coder,项目名称:yacoin,代码行数:4,代码来源:json_spirit_writer.cpp

示例5: prefix

pfs::error_code ubjson_ostream<OStreamType, JsonType>::write_object (json_type const & j)
{
    _os << UBJSON_CHAR_OBJECT_BEGIN;

    bool use_count_optimization = ((_flags & count_optimized) && !j.empty());
    bool is_special_case = false;

    // If a type is specified, a count must also be specified.
    // A type cannot be specified by itself.
    bool use_type_optimization  = ((_flags & type_optimized) && use_count_optimization);

    // Additional checks for type optimization
    if (use_type_optimization) {

        // This call is safe. Array is not empty as checked before
        int8_t first_prefix = prefix(*j.cbegin());
        use_type_optimization = pfs::all_of(j.cbegin(), j.cend(), compare_prefix(first_prefix));

        if (use_type_optimization) {
            _os << UBJSON_CHAR_TYPE;
            _os << first_prefix;

            // Check special cases
            if (first_prefix == UBJSON_CHAR_NOOP
                    || first_prefix == UBJSON_CHAR_NULL
                    || first_prefix == UBJSON_CHAR_TRUE
                    || first_prefix == UBJSON_CHAR_FALSE) {
                is_special_case = true;
            }
        }
    }

    if (use_count_optimization) {
        _os << UBJSON_CHAR_SIZE;
        write_integer(static_cast<typename json_type::integer_type>(j.size()), true);
    }

    typename json_type::const_iterator first = j.cbegin();
    typename json_type::const_iterator last = j.cend();

    if (is_special_case) {
        for (; first != last; ++first) {
            // The [S] (string) marker is omitted from each of the names in the
            // name/value pairings inside the object. The JSON specification does
            // not allow non-string name values, therefore the [S] marker
            // is redundant and must not be used.
           write_string(first.key(), false);
        }
    } else {
        for (; first != last; ++first) {
            write_string(first.key(), false);
            write_json(*first, !use_type_optimization);
        }
    }

    // If a count is specified the container must not specify an end-marker.
    if (!use_count_optimization)
        _os << UBJSON_CHAR_OBJECT_END;

    return pfs::error_code();
}
开发者ID:semenovf,项目名称:pfs,代码行数:61,代码来源:ubjson_ostream.hpp

示例6: append_key

static inline void
append_key(struct bson *bs, int type, const char *key, size_t sz) {
	write_byte(bs, type);
	write_string(bs, key, sz);
}
开发者ID:yangxgkem,项目名称:server,代码行数:5,代码来源:lua-bson.c

示例7: content_handler

/* ====================================================================
 * Here's the real content handler.
 * ==================================================================== */
static int content_handler(request_rec *r)
{
    long length;
    wkcfg *cfg;
    WFILE* env_dict = NULL;
    int i;
    char msgbuf[MAX_STRING_LEN];
    int conn_attempt = 0;
    WFILE* whole_dict = NULL;
    WFILE* int_dict = NULL;
    const char *value;
    const char *key;
    array_header *hdr_arr;
    table_entry *elts;

    cfg = ap_get_module_config(r->per_dir_config, &webkit_module);
    if (cfg == NULL) {
        log_debug("No cfg", r);
        cfg = (wkcfg*)wk_create_dir_config(r->pool, "/");
    }

    env_dict = setup_WFILE(r);
    whole_dict = setup_WFILE(r);
    int_dict = setup_WFILE(r);

    if (env_dict == NULL || whole_dict == NULL) {
        log_error("Couldn't allocate Python data structures", r->server);
        return HTTP_INTERNAL_SERVER_ERROR;
    }

    ap_add_common_vars(r);
    ap_add_cgi_vars(r); /* not included in the common_vars above */

    /* Build the environment dictionary */

    hdr_arr = ap_table_elts(r->subprocess_env);
    elts = (table_entry *)hdr_arr->elts;

    /* start dictionary */
    w_byte(TYPE_DICT, env_dict);

    for (i = 0; i < hdr_arr->nelts; ++i) {
        if (!elts[i].key)
            continue;
        key = elts[i].key;
        value = ap_table_get(r->subprocess_env, elts[i].key);
        write_string(key, env_dict);
        if (value != NULL)
            write_string(value, env_dict);
        else
            w_byte(TYPE_NONE, env_dict);
    }
    hdr_arr = cfg->passheaders;
    if (hdr_arr) {
        char **headers = (char **)hdr_arr->elts;
        for (i = 0; i < hdr_arr->nelts; i++) {
            key = headers[i];
            value = ap_table_get(r->headers_in, key);
            if (value && *value) {
                write_string(key, env_dict);
                write_string(value, env_dict);
            }
        }
    }

#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
    /* Ordinarily Apache only makes the username available to CGI scripts,
    keeping the password secret. It can be configured to make the complete
    credential details available, but only by completely rebuilding the
    server with SECURITY_HOLE_PASS_AUTHORIZATION set (enabling this feature
    is considered a security risk). By setting the same constant, you can
    have mod_webkit pass the authorization information to WebKit instead.
    (suggested by Maximillian Dornseif 2003-10-27) */
    key = "Authorization";
    value = ap_table_get(r->headers_in, key);
    if (value && *value) {
      write_string("X-HTTP_AUTHORIZATION", env_dict);
      write_string(value, env_dict);
    }
#endif

    w_byte(TYPE_NULL, env_dict);
    /* end dictionary */
    log_debug("Built env dictionary", r);

    /* We can start building the full dictionary now */
    w_byte(TYPE_DICT, whole_dict);
    write_string("format", whole_dict); /* key */
    write_string("CGI", whole_dict); /* value */
    write_string("time", whole_dict); /* key */
    w_byte(TYPE_INT, whole_dict); /* value */
    /* patch from Ken Lalonde to make the time entry useful */
    w_long((long)r->request_time, whole_dict); /* value */

    write_string("environ", whole_dict); /* key */

    /* copy env_dict into whole_dict */
//.........这里部分代码省略.........
开发者ID:Cito,项目名称:w4py-olde-docs,代码行数:101,代码来源:mod_webkit.c

示例8: write_string

void Core::handleMessage(const Message& msg, MessageSession* session){
	write_string(session->target().bare() + " -> " + msg.body());
	// to debug
	//print_session_id(session->target().bare());
}
开发者ID:ratsy,项目名称:Cptalk-,代码行数:5,代码来源:XMPP.cpp

示例9: serialize_tree


//.........这里部分代码省略.........
                    // increment data pointer if node is a union
                    if (node_is_union)
                        *data = (char*)initial_data + largest_child_data_field;
                }
                // indent to current level using tab
                chars = add_indent(&target_buffer, &target_size, &target_offset, level);
                if (chars < 0)
                    return chars;
                // write node end
                if (level == 0 || (*desc)[1].type == KOW_BRANCH_END)
                    node_end_str = "]}\n";
                else
                    node_end_str = "]},\n";
                chars = add_string(&target_buffer, &target_size, &target_offset, node_end_str);
                if (chars < 0)
                    return chars;
                break;
            }
            default:
            {
                int value_size = kowhai_get_node_type_size(node->type);
                // write header
                chars = add_header(&target_buffer, &target_size, &target_offset, node, get_name_param, get_name);
                if (chars < 0)
                    return chars;
                // write value identifier
                chars = add_string(&target_buffer, &target_size, &target_offset, ", \""VALUE"\": ");
                if (chars < 0)
                    return chars;
                // write value/s
                if (node->type == KOW_CHAR && node->count > 1 && str_printable((char *)*data, node->count))
                {
                    // special string case
                    chars = write_string(target_buffer, target_size, "\"%.*s\"", node->count, (char*)*data);
                    if (chars >= 0)
                    {
                        target_buffer += chars;
                        target_size -= chars;
                        target_offset += chars;
                    }
                    else
                        return chars;
                    // increment data pointer
                    if (!in_union)
                        *data = (char*)*data + value_size * node->count;
                    else if (value_size * node->count > *largest_data_field)
                        *largest_data_field = value_size * node->count;
                }
                else if (node->count > 1)
                {
                    // write start bracket
                    chars = add_string(&target_buffer, &target_size, &target_offset, "[");
                    if (chars < 0)
                        return chars;
                    for (i = 0; i < node->count; i++)
                    {
                        // write leaf node array item value
                        chars = add_value(&target_buffer, &target_size, &target_offset, node->type, (char*)*data + i * value_size);
                        if (chars < 0)
                            return chars;
                        // write comma if there is another array item
                        if (i < node->count - 1)
                        {
                            chars = add_string(&target_buffer, &target_size, &target_offset, ", ");
                            if (chars < 0)
                                return chars;
开发者ID:othane,项目名称:kowhai,代码行数:67,代码来源:kowhai_serialize.c

示例10: filecache_update

void filecache_update(TARGET *t)
{
	MD5SUM blobmd5sum;
	int haveblobmd5sum = 0;
	const char *cachedname;
	const char *blobname;
	int cacheerror;

	if (!t->filecache_generate)
		return;

	/* If the buildmd5sum is empty, then the file doesn't exist. */
	cacheerror = ismd5empty(t->buildmd5sum);
	if (cacheerror)
		return;

	haveblobmd5sum = 0;
	cachedname = filecache_getfilename(t, t->buildmd5sum, NULL);
	if (!cachedname)
		return;

	/* Search for the appropriate .link file that matches the target. */
	haveblobmd5sum = filecache_findlink(cachedname, blobmd5sum);

	/* If we weren't able to determine the target md5sum, do it now. */
	if (!haveblobmd5sum)
	{
#ifdef OPT_BUILTIN_LUA_SUPPORT_EXT
		LIST *md5callback;

		pushsettings( t->settings );
		md5callback = var_get( "MD5CALLBACK" );
		popsettings( t->settings );

		if ( md5callback )
		{
			luahelper_md5callback(t->boundname, blobmd5sum, md5callback->string);
		}
		else
		{
#endif
			md5file(t->boundname, blobmd5sum);
#ifdef OPT_BUILTIN_LUA_SUPPORT_EXT
		}
#endif
		memcpy(t->contentmd5sum, blobmd5sum, sizeof(MD5SUM));
		if (ismd5empty(t->contentmd5sum))
			return;
	}

	{
		/* Is the blob already there? */
		time_t blobtime;
		blobname = filecache_getfilename(t, blobmd5sum, ".blob");
		if (file_time(blobname, &blobtime) == -1)
		{
			time_t blobpartialtime;
			const char *blobpartialname;

			if(DEBUG_MD5HASH)
				printf("Caching %s as %s\n", t->name, cachedname);
			else
				printf("Caching %s\n", t->name);

			/* Write the new .blob to the cache. */
			blobpartialname = filecache_getfilename(t, blobmd5sum, ".blob.partial");
			if (file_time(blobpartialname, &blobpartialtime) == -1)
			{
				if (copyfile(blobpartialname, t->boundname, &blobmd5sum) == 0  ||
					rename(blobpartialname, blobname) != 0)
				{
					printf("** Unable to write %s to cache.\n", t->name, cachedname);
					filecache_disable(t);
					return;
				}
			}
		}
	}

	/* Write the new .link file to the cache. */
	{
		FILE *file;
		BUFFER linknamebuff;
		buffer_init(&linknamebuff);
		buffer_addstring(&linknamebuff, cachedname, strlen(cachedname));
		buffer_addchar(&linknamebuff, '-');
		buffer_addstring(&linknamebuff, md5tostring(blobmd5sum), 32);
		buffer_addstring(&linknamebuff, ".link", 5);
		buffer_addchar(&linknamebuff, 0);

		file_mkdir(buffer_ptr(&linknamebuff));
		file = fopen(buffer_ptr(&linknamebuff), "wb");
		if (file)
		{
			write_md5sum(file, blobmd5sum);
			write_string(file, t->name);
			fclose(file);
		}

		buffer_free(&linknamebuff);
//.........这里部分代码省略.........
开发者ID:0xb1dd1e,项目名称:jamplus,代码行数:101,代码来源:hcache.c

示例11: add_value

int add_value(char** dest, size_t* dest_size, int* current_offset, uint16_t node_type, void* data)
{
    int chars;
    union any_type_t val;

    // on some systems vsnprintf requires the src buffer to be aligned
    // properly, since data is possibly packed to make the tree tidier
    // the memcpy below gets our data into an aligned var
    memcpy(&val, data, kowhai_get_node_type_size(node_type));

    switch (node_type)
    {
        case KOW_CHAR:
            if (val.c < 32 || val.c >= 127)
                chars = write_string(*dest, *dest_size, "%d", val.c);
            else
                chars = write_string(*dest, *dest_size, "%c", val.c);
            break;
        case KOW_INT8:
            chars = write_string(*dest, *dest_size, "%d", val.i8);
            break;
        case KOW_INT16:
            chars = write_string(*dest, *dest_size, "%d", val.i16);
            break;
        case KOW_INT32:
            chars = write_string(*dest, *dest_size, "%d", val.i32);
            break;
        case KOW_INT64:
            chars = write_string(*dest, *dest_size, "%ld", val.i64);
            break;
        case KOW_UINT8:
            chars = write_string(*dest, *dest_size, "%d", val.ui8);
            break;
        case KOW_UINT16:
            chars = write_string(*dest, *dest_size, "%d", val.ui16);
            break;
        case KOW_UINT32:
            chars = write_string(*dest, *dest_size, "%d", val.ui32);
            break;
        case KOW_UINT64:
            chars = write_string(*dest, *dest_size, "%ld", val.ui64);
            break;
        case KOW_FLOAT:
            chars = write_string(*dest, *dest_size, "%.17g", val.f);
            break;
        case KOW_DOUBLE:
            chars = write_string(*dest, *dest_size, "%.17lg", val.d);
            break;
        default:
            return -1;
    }
    if (chars >= 0)
    {
        *dest += chars;
        *dest_size -= chars;
        *current_offset += chars;
    }
    return chars;
}
开发者ID:othane,项目名称:kowhai,代码行数:59,代码来源:kowhai_serialize.c

示例12: hcache_writefile

void
	hcache_writefile(HCACHEFILE *file)
{
	FILE	*f;
	HCACHEDATA	*c;
	int		header_count = 0;
	int		maxage;

	if( !file  ||  !file->dirty  ||  !file->cachefilename )
		return;

	file_mkdir(file->cachefilename);

	if( ! (f = fopen( file->cachefilename, "wb" ) ) )
		return;

	maxage = cache_maxage();

	/* print out the version */
	fprintf( f, "@%[email protected]\n", CACHE_FILE_VERSION );

	for( c = file->hcachelist; c; c = c->next ) {
		LIST	*l;

		if( maxage == 0 )
			c->age = 0;
		else if( c->age > maxage )
			continue;

		write_string( f, c->boundname );
		write_int( f, (int)c->time );
		write_int( f, c->age );

#ifdef OPT_BUILTIN_MD5CACHE_EXT
		write_int( f, (int)c->mtime );
		write_md5sum( f, c->rulemd5sum );
		write_md5sum( f, c->contentmd5sum );
#endif

		write_int( f, list_length( c->includes ) );
		for( l = c->includes; l; l = list_next( l ) ) {
			write_string( f, l->string );
		}

		write_int( f, list_length( c->hdrscan ) );
		for( l = c->hdrscan; l; l = list_next( l ) ) {
			write_string( f, l->string );
		}

		fputc( '!', f );
		fputc( '\n', f );
		++header_count;
	}

	if( DEBUG_HEADER )
		printf( "hcache written to %s.	 %d dependencies, %.0f%% hit rate\n",
		file->cachefilename, header_count,
		queries ? 100.0 * hits / queries : 0 );

	fclose( f );
}
开发者ID:0xb1dd1e,项目名称:jamplus,代码行数:61,代码来源:hcache.c

示例13: write_string

void
SExprFileWriter::write_path(const char* name, const Pathname& path)
{
  write_string(name, path.get_raw_path());
}
开发者ID:jcs12311,项目名称:pingus,代码行数:5,代码来源:sexpr_file_writer.cpp

示例14: save_game

int save_game (char* s, char* d)
{
	SINT16 i;
	struct image_stack_element* ptr = image_stack;
	FILE* f = fopen (s, "wb");

	if(!f)
		return err_BadFileOpen;

#ifdef DREAMCAST
	write_vmu_header(f, d);
#endif

	write_bytes (f, strSig, 8);
	write_string (f, d);

	write_uint8 (f, (UINT8)SAVEGAME_VERSION);
	write_uint8 (f, (UINT8)game.state);
	/* game.name */
	write_string (f, game.id);
	/* game.crc */

	for (i = 0; i < MAX_FLAGS; i++)
		write_uint8 (f, game.flags[i]);
	for (i = 0; i < MAX_VARS; i++)
		write_uint8 (f, game.vars[i]);

	write_sint16 (f, (SINT8)game.horizon);
	write_sint16 (f, (SINT16)game.line_status);
	write_sint16 (f, (SINT16)game.line_user_input);
	write_sint16 (f, (SINT16)game.line_min_print);
	/* game.cursor_pos */
	/* game.input_buffer */
	/* game.echo_buffer */
	/* game.keypress */
	write_sint16 (f, (SINT16)game.input_mode);
	write_sint16 (f, (SINT16)game.lognum);

	write_sint16 (f, (SINT16)game.player_control);
	write_sint16 (f, (SINT16)game.quit_prog_now);
	write_sint16 (f, (SINT16)game.status_line);
	write_sint16 (f, (SINT16)game.clock_enabled);
	write_sint16 (f, (SINT16)game.exit_all_logics);
	write_sint16 (f, (SINT16)game.picture_shown);
	write_sint16 (f, (SINT16)game.has_prompt);
	write_sint16 (f, (SINT16)game.game_flags);

	/* Reversed to keep compatibility with old savegames */
	write_sint16 (f, (SINT16)!game.input_enabled);

	for (i = 0; i < _HEIGHT; i++)
		write_uint8 (f, game.pri_table[i]);

	/* game.msg_box_ticks */
	/* game.block */
	/* game.window */
	/* game.has_window */

	write_sint16 (f, (SINT16)game.gfx_mode);
	write_uint8 (f, game.cursor_char);
	write_sint16 (f, (SINT16)game.color_fg);
	write_sint16 (f, (SINT16)game.color_bg);

	/* game.hires (#ifdef USE_HIRES) */
	/* game.sbuf */
	/* game.ego_words */
	/* game.num_ego_words */

	write_sint16 (f, (SINT16)game.num_objects);
	for (i = 0; i < (SINT16)game.num_objects; i++)
		write_sint16 (f, (SINT16)object_get_location(i));

	/* game.ev_keyp */
	for (i = 0; i < MAX_STRINGS; i++)
		write_string (f, game.strings[i]);

	/* record info about loaded resources */
	for (i = 0; i < MAX_DIRS; i++) {
		write_uint8 (f, game.dir_logic[i].flags);
		write_sint16 (f, (SINT16)game.logics[i].sIP);
		write_sint16 (f, (SINT16)game.logics[i].cIP);
	}
	for (i = 0; i < MAX_DIRS; i++)
		write_uint8(f, game.dir_pic[i].flags);
	for (i = 0; i < MAX_DIRS; i++)
		write_uint8(f, game.dir_view[i].flags);
	for (i = 0; i < MAX_DIRS; i++)
		write_uint8(f, game.dir_sound[i].flags);

	/* game.pictures */
	/* game.logics */
	/* game.views */
	/* game.sounds */

	for(i = 0; i < MAX_VIEWTABLE; i++) {
		struct vt_entry* v = &game.view_table[i];

		write_uint8(f, v->step_time);
		write_uint8(f, v->step_time_count);
		write_uint8(f, v->entry);
//.........这里部分代码省略.........
开发者ID:SimonKagstrom,项目名称:sarien-j2me,代码行数:101,代码来源:savegame.c

示例15: add_pool_entry

static void
add_pool_entry (MonoCompile *cfg, ConstantPoolEntry *entry)
{
	int *cp_id= (int *) mono_mempool_alloc0 (cfg->mempool, sizeof (int));
	*cp_id = cfg->gdump_ctx->next_cp_id;
	g_hash_table_insert (cfg->gdump_ctx->constant_pool, entry, cp_id);
	write_byte (cfg, POOL_NEW);
	write_short (cfg, cfg->gdump_ctx->next_cp_id++);
	switch (entry->pt) {
		case PT_STRING:
			write_byte (cfg, POOL_STRING);
			write_string (cfg, (char *) entry->data);
			break;
		case PT_METHOD: {
			MonoMethod *method = (MonoMethod *) entry->data;
			write_byte (cfg, POOL_METHOD);
			write_pool (cfg, create_cp_entry (cfg, (void *) method->klass, PT_KLASS));
			write_pool (cfg, create_cp_entry (cfg, (void *) method->name, PT_STRING));
			write_pool (cfg, create_cp_entry (cfg, (void *) method->signature, PT_SIGNATURE));
			write_int (cfg, (int) method->flags);
			write_int (cfg, -1); // don't transmit bytecode.
			break;
		}
		case PT_KLASS: {
			MonoClass *klass = (MonoClass *) entry->data;
			write_byte (cfg, POOL_KLASS);
			write_string (cfg, klass->name);
			write_byte (cfg, KLASS);
			break;
		}
		case PT_SIGNATURE: {
			write_byte (cfg, POOL_SIGNATURE);
			MonoMethodSignature *sig = (MonoMethodSignature *) entry->data;
			write_short (cfg, sig->param_count);
			for (int i = 0; i < sig->param_count; i++) {
				GString *sbuf = g_string_new (NULL);
				mono_type_get_desc (sbuf, sig->params [i], TRUE);
				write_pool (cfg, create_cp_entry (cfg, (void *) sbuf->str, PT_STRING));
				g_string_free (sbuf, TRUE);
			}
			GString *sbuf = g_string_new (NULL);
			mono_type_get_desc (sbuf, sig->ret, TRUE);
			write_pool (cfg, create_cp_entry (cfg, (void *) sbuf->str, PT_STRING));
			g_string_free (sbuf, TRUE);
			break;
		}
		case PT_OPTYPE: {
			MonoInst *insn = (MonoInst *) entry->data;
			write_byte (cfg, POOL_NODE_CLASS);

			write_string (cfg, mono_inst_name (insn->opcode));
			GString *insndesc = mono_print_ins_index_strbuf (-1, insn);
			int len = strnlen (insndesc->str, 0x2000);
#define CUTOFF 40
			if (len > CUTOFF) {
				insndesc->str[CUTOFF] = '\0';
				insndesc->str[CUTOFF - 1] = '.';
				insndesc->str[CUTOFF - 2] = '.';
			}
			write_string (cfg, insndesc->str);
			if (len > CUTOFF)
				insndesc->str[CUTOFF] = ' ';
			g_string_free (insndesc, TRUE);

			// one predecessor
			write_short (cfg, 1);
			write_byte (cfg, 0);
			write_pool (cfg, create_cp_entry (cfg, (void *) "predecessor", PT_STRING));
			write_pool (cfg, create_cp_entry (cfg, (void *) NULL, PT_INPUTTYPE));

			// make NUM_SUCCESSOR successor edges, not everyone will be used.
#define NUM_SUCCESSOR 5
			write_short (cfg, NUM_SUCCESSOR);
			for (int i = 0; i < NUM_SUCCESSOR; i++) {
				char *str = g_strdup ("successor1");
				str[9] = '0' + i;
				write_byte (cfg, 0);
				write_pool (cfg, create_cp_entry (cfg, (void *) str, PT_STRING));
			}

			break;
		}
		case PT_INPUTTYPE: {
			write_byte (cfg, POOL_ENUM);
			write_pool (cfg, create_cp_entry (cfg, (void *) NULL, PT_ENUMKLASS));
			write_int (cfg, 0);
			break;
		}
		case PT_ENUMKLASS: {
			write_byte (cfg, POOL_KLASS);
			write_string (cfg, "InputType");
			write_byte (cfg, ENUM_KLASS);
			write_int (cfg, 1);
			write_pool (cfg, create_cp_entry (cfg, (void *) "fixed", PT_STRING));
			break;
		}
	}
}
开发者ID:0ostreamo0,项目名称:mono,代码行数:98,代码来源:cfgdump.c


注:本文中的write_string函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。