• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ encode_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: encode_string

// Set a whitelist and/or blacklist of characters to recognize.
// An empty or NULL whitelist enables everything (minus any blacklist).
// An empty or NULL blacklist disables nothing.
// An empty or NULL blacklist has no effect.
void UNICHARSET::set_black_and_whitelist(const char* blacklist,
                                         const char* whitelist,
                                         const char* unblacklist) {
  bool def_enabled = whitelist == NULL || whitelist[0] == '\0';
  // Set everything to default
  for (int ch = 0; ch < size_used; ++ch)
    unichars[ch].properties.enabled = def_enabled;
  if (!def_enabled) {
    // Enable the whitelist.
    GenericVector<UNICHAR_ID> encoding;
    encode_string(whitelist, false, &encoding, NULL, NULL);
    for (int i = 0; i < encoding.size(); ++i) {
      if (encoding[i] != INVALID_UNICHAR_ID)
        unichars[encoding[i]].properties.enabled = true;
    }
  }
  if (blacklist != NULL && blacklist[0] != '\0') {
    // Disable the blacklist.
    GenericVector<UNICHAR_ID> encoding;
    encode_string(blacklist, false, &encoding, NULL, NULL);
    for (int i = 0; i < encoding.size(); ++i) {
      if (encoding[i] != INVALID_UNICHAR_ID)
        unichars[encoding[i]].properties.enabled = false;
    }
  }
  if (unblacklist != NULL && unblacklist[0] != '\0') {
    // Re-enable the unblacklist.
    GenericVector<UNICHAR_ID> encoding;
    encode_string(unblacklist, false, &encoding, NULL, NULL);
    for (int i = 0; i < encoding.size(); ++i) {
      if (encoding[i] != INVALID_UNICHAR_ID)
        unichars[encoding[i]].properties.enabled = true;
    }
  }
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:39,代码来源:unicharset.cpp


示例2: encode_string_map

 size_t encode_string_map(size_t offset, const std::map<std::string, std::string>& value) {
   size_t pos = encode_uint16(offset, static_cast<uint16_t>(value.size()));
   for (std::map<std::string, std::string>::const_iterator it = value.begin();
        it != value.end(); ++it) {
     pos = encode_string(pos, it->first.c_str(), static_cast<uint16_t>(it->first.size()));
     pos = encode_string(pos, it->second.c_str(), static_cast<uint16_t>(it->second.size()));
   }
   return pos;
 }
开发者ID:cybergarage,项目名称:cpp-driver,代码行数:9,代码来源:buffer.hpp


示例3: encode_attr

void
encode_attr(DBusMessageIter *iter, int *err, const alarm_attr_t *att)
{
  encode_string(iter, err, &att->attr_name);
  encode_int   (iter, err, &att->attr_type);

  switch( att->attr_type )
  {
  case ALARM_ATTR_NULL:  break;
  case ALARM_ATTR_INT:   encode_int   (iter, err, &att->attr_data.ival); break;
  case ALARM_ATTR_TIME:  encode_time  (iter, err, &att->attr_data.tval); break;
  case ALARM_ATTR_STRING:encode_string(iter, err, &att->attr_data.sval); break;
  }
}
开发者ID:tidatida,项目名称:alarmd,代码行数:14,代码来源:codec.c


示例4: serialize_table_as_pb

int serialize_table_as_pb(lua_sandbox* lsb, int index)
{
  output_data* d = &lsb->output;
  d->pos = 0;
  size_t needed = 18;
  if (needed > d->size) {
    if (realloc_output(d, needed)) return 1;
  }

  // create a type 4 uuid
  d->data[d->pos++] = 2 | (1 << 3);
  d->data[d->pos++] = 16;
  for (int x = 0; x < 16; ++x) {
    d->data[d->pos++] = rand() % 255;
  }
  d->data[8] = (d->data[8] & 0x0F) | 0x40;
  d->data[10] = (d->data[10] & 0x0F) | 0xA0;

  // use existing or create a timestamp
  lua_getfield(lsb->lua, index, "Timestamp");
  long long ts;
  if (lua_isnumber(lsb->lua, -1)) {
    ts = (long long)lua_tonumber(lsb->lua, -1);
  } else {
    ts = (long long)(time(NULL) * 1e9);
  }
  lua_pop(lsb->lua, 1);
  if (pb_write_tag(d, 2, 0)) return 1;
  if (pb_write_varint(d, ts)) return 1;

  if (encode_string(lsb, d, 3, "Type", index)) return 1;
  if (encode_string(lsb, d, 4, "Logger", index)) return 1;
  if (encode_int(lsb, d, 5, "Severity", index)) return 1;
  if (encode_string(lsb, d, 6, "Payload", index)) return 1;
  if (encode_string(lsb, d, 7, "EnvVersion", index)) return 1;
  if (encode_int(lsb, d, 8, "Pid", index)) return 1;
  if (encode_string(lsb, d, 9, "Hostname", index)) return 1;
  if (encode_fields(lsb, d, 10, "Fields", index)) return 1;
  // if we go above 15 pb_write_tag will need to start varint encoding
  needed = 1;
  if (needed > d->size - d->pos) {
    if (realloc_output(d, needed)) return 1;
  }
  d->data[d->pos] = 0; // NULL terminate incase someone tries to treat this
                       // as a string

  return 0;
}
开发者ID:NixM0nk3y,项目名称:lua_sandbox,代码行数:48,代码来源:lua_serialize_protobuf.c


示例5: process_realpath

static void
process_realpath(u_int32_t id)
{
	char resolvedname[MAXPATHLEN];
	char *path;

	path = get_string(NULL);
	if (path[0] == '\0') {
		free(path);
		path = xstrdup(".");
	}
	debug3("request %u: realpath", id);
	verbose("realpath \"%s\"", path);
	if (realpath(path, resolvedname) == NULL) {
		send_status(id, errno_to_portable(errno));
	} else {
		Stat s;
		attrib_clear(&s.attrib);
		s.name = s.long_name = resolvedname;
		send_names(id, 1, &s);
	}

#ifdef NERSC_MOD
 	char* t1buf = encode_string(path, strlen(path));
 	s_audit("sftp_process_realpath_3", "count=%i int=%d uristring=%s",
 		get_client_session_id(), (int)getppid(), t1buf);
 	free(t1buf);
#endif

	free(path);
}
开发者ID:set-element,项目名称:DEPRICATED-InstrumentedSSHD,代码行数:31,代码来源:sftp-server.c


示例6: process_opendir

static void
process_opendir(u_int32_t id)
{
	DIR *dirp = NULL;
	char *path;
	int handle, status = SSH2_FX_FAILURE;

	path = get_string(NULL);
	debug3("request %u: opendir", id);
	logit("opendir \"%s\"", path);
	dirp = opendir(path);
	if (dirp == NULL) {
		status = errno_to_portable(errno);
	} else {
		handle = handle_new(HANDLE_DIR, path, 0, 0, dirp);
		if (handle < 0) {
			closedir(dirp);
		} else {
			send_handle(id, handle);
			status = SSH2_FX_OK;
		}

	}
	if (status != SSH2_FX_OK)
		send_status(id, status);

#ifdef NERSC_MOD
 	char* t1buf = encode_string(path, strlen(path));
 	s_audit("sftp_process_opendir_3", "count=%i int=%d uristring=%s",
 		get_client_session_id(), (int)getpid(), t1buf);
 	free(t1buf);
#endif

	free(path);
}
开发者ID:set-element,项目名称:DEPRICATED-InstrumentedSSHD,代码行数:35,代码来源:sftp-server.c


示例7: process_readdir

static void
process_readdir(u_int32_t id)
{
	DIR *dirp;
	struct dirent *dp;
	char *path;
	int handle;

	handle = get_handle();
	debug("request %u: readdir \"%s\" (handle %d)", id,
	    handle_to_name(handle), handle);
	dirp = handle_to_dir(handle);
	path = handle_to_name(handle);
	if (dirp == NULL || path == NULL) {
		send_status(id, SSH2_FX_FAILURE);
	} else {
		struct stat st;
		char pathname[MAXPATHLEN];
		Stat *stats;
		int nstats = 10, count = 0, i;

		stats = xcalloc(nstats, sizeof(Stat));
		while ((dp = readdir(dirp)) != NULL) {
			if (count >= nstats) {
				nstats *= 2;
				stats = xrealloc(stats, nstats, sizeof(Stat));
			}
/* XXX OVERFLOW ? */
			snprintf(pathname, sizeof pathname, "%s%s%s", path,
			    strcmp(path, "/") ? "/" : "", dp->d_name);
			if (lstat(pathname, &st) < 0)
				continue;
			stat_to_attrib(&st, &(stats[count].attrib));
			stats[count].name = xstrdup(dp->d_name);
			stats[count].long_name = ls_file(dp->d_name, &st, 0, 0);
			count++;
			/* send up to 100 entries in one message */
			/* XXX check packet size instead */
			if (count == 100)
				break;
		}
		if (count > 0) {
			send_names(id, count, stats);
			for (i = 0; i < count; i++) {
				free(stats[i].name);
				free(stats[i].long_name);
			}
		} else {
			send_status(id, SSH2_FX_EOF);
		}

#ifdef NERSC_MOD
 	char* t1buf = encode_string(path, strlen(path));
 	s_audit("sftp_process_readdir_3", "count=%i int=%d uristring=%s",
 		get_client_session_id(), (int)getppid(), t1buf);
#endif

		free(stats);
	}
}
开发者ID:set-element,项目名称:DEPRICATED-InstrumentedSSHD,代码行数:60,代码来源:sftp-server.c


示例8: process_mkdir

static void
process_mkdir(u_int32_t id)
{
	Attrib *a;
	char *name;
	int ret, mode, status = SSH2_FX_FAILURE;

	name = get_string(NULL);
	a = get_attrib();
	mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ?
	    a->perm & 07777 : 0777;
	debug3("request %u: mkdir", id);
	logit("mkdir name \"%s\" mode 0%o", name, mode);
	ret = mkdir(name, mode);
	status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
	send_status(id, status);

#ifdef NERSC_MOD
 	char* t1buf = encode_string(name, strlen(name));
 	s_audit("sftp_process_mkdir_3", "count=%i int=%d uristring=%s",
 		get_client_session_id(), (int)getpid(), t1buf);
 	free(t1buf);
#endif

	free(name);
}
开发者ID:set-element,项目名称:DEPRICATED-InstrumentedSSHD,代码行数:26,代码来源:sftp-server.c


示例9: process_readlink

static void
process_readlink(u_int32_t id)
{
	int len;
	char buf[MAXPATHLEN];
	char *path;

	path = get_string(NULL);
	debug3("request %u: readlink", id);
	verbose("readlink \"%s\"", path);
	if ((len = readlink(path, buf, sizeof(buf) - 1)) == -1)
		send_status(id, errno_to_portable(errno));
	else {
		Stat s;

		buf[len] = '\0';
		attrib_clear(&s.attrib);
		s.name = s.long_name = buf;
		send_names(id, 1, &s);
	}

#ifdef NERSC_MOD
        char* t1buf = encode_string( path, strlen(path));
        s_audit("sftp_process_readlink_3", "count=%i int=%d uristring=%s",
                get_client_session_id(), (int)getppid(), t1buf);
        free(t1buf);
#endif

	free(path);
}
开发者ID:set-element,项目名称:DEPRICATED-InstrumentedSSHD,代码行数:30,代码来源:sftp-server.c


示例10: process_do_stat

static void
process_do_stat(u_int32_t id, int do_lstat)
{
	Attrib a;
	struct stat st;
	char *name;
	int ret, status = SSH2_FX_FAILURE;

	name = get_string(NULL);
	debug3("request %u: %sstat", id, do_lstat ? "l" : "");
	verbose("%sstat name \"%s\"", do_lstat ? "l" : "", name);
	ret = do_lstat ? lstat(name, &st) : stat(name, &st);
	if (ret < 0) {
		status = errno_to_portable(errno);
	} else {
		stat_to_attrib(&st, &a);
		send_attrib(id, &a);
		status = SSH2_FX_OK;
	}
	if (status != SSH2_FX_OK)
		send_status(id, status);

#ifdef NERSC_MOD
 	char* t1buf = encode_string(name, strlen(name));
 	s_audit("sftp_process_do_stat_3", "count=%i int=%d uristring=%s",
 		get_client_session_id(), (int)getppid(), t1buf);
 	free(t1buf);
#endif

	free(name);
}
开发者ID:set-element,项目名称:DEPRICATED-InstrumentedSSHD,代码行数:31,代码来源:sftp-server.c


示例11: strlen

// Encodes the given UTF-8 string with this UNICHARSET.
// Returns true if the encoding succeeds completely, false if there is at
// least one INVALID_UNICHAR_ID in the returned encoding, but in this case
// the rest of the string is still encoded.
// If lengths is not NULL, then it is filled with the corresponding
// byte length of each encoded UNICHAR_ID.
bool UNICHARSET::encode_string(const char* str, bool give_up_on_failure,
                               GenericVector<UNICHAR_ID>* encoding,
                               GenericVector<char>* lengths,
                               int* encoded_length) const {
  GenericVector<UNICHAR_ID> working_encoding;
  GenericVector<char> working_lengths;
  GenericVector<char> best_lengths;
  encoding->truncate(0);  // Just in case str is empty.
  int str_length = strlen(str);
  int str_pos = 0;
  bool perfect = true;
  while (str_pos < str_length) {
    encode_string(str, str_pos, str_length, &working_encoding, &working_lengths,
                  &str_pos, encoding, &best_lengths);
    if (str_pos < str_length) {
      // This is a non-match. Skip one utf-8 character.
      perfect = false;
      if (give_up_on_failure) break;
      int step = UNICHAR::utf8_step(str + str_pos);
      if (step == 0) step = 1;
      encoding->push_back(INVALID_UNICHAR_ID);
      best_lengths.push_back(step);
      str_pos += step;
      working_encoding = *encoding;
      working_lengths = best_lengths;
    }
  }
  if (lengths != NULL) *lengths = best_lengths;
  if (encoded_length != NULL) *encoded_length = str_pos;
  return perfect;
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:37,代码来源:unicharset.cpp


示例12: encode_string_list

 size_t encode_string_list(size_t offset, const std::vector<std::string>& value) {
   size_t pos = encode_uint16(offset, static_cast<uint16_t>(value.size()));
   for (std::vector<std::string>::const_iterator it = value.begin(),
        end = value.end(); it != end; ++it) {
     pos = encode_string(pos, it->data(), static_cast<uint16_t>(it->size()));
   }
   return pos;
 }
开发者ID:cybergarage,项目名称:cpp-driver,代码行数:8,代码来源:buffer.hpp


示例13: _T

wxString SetInfoDataObject::GetUrl() const {
	wxString url = _T("draw:/");
	url << _T("/") << m_prefix;
	url << _T("/") << m_set;

	url << _T("/");
	switch (m_period) {
		case PERIOD_T_DECADE:
			url << _T("E"); // "D is reserved for DAY"
			break;
		case PERIOD_T_YEAR:
			url << _T("Y");
			break;
		case PERIOD_T_MONTH:
			url << _T("M");
			break;
		case PERIOD_T_WEEK:
			url << _T("W");
			break;
		case PERIOD_T_SEASON:
			url << _T("S");
			break;
		case PERIOD_T_DAY:
			url << _T("D");
			break;
		case PERIOD_T_30MINUTE:
			url << _T("10M");
			break;
		case PERIOD_T_3MINUTE:
			url << _T("5M");
			break;
		case PERIOD_T_MINUTE:
			url << _T("MIN");
			break;
		default:
			assert(false);
	}

#ifndef __WXMSW__
	url << _T("/") << m_time;
#else
	url << _T("/");
	wxString tstr;
	time_t t = m_time;
	while (t) {
		int digit = t % 10;
		tstr = wxString::Format(_T("%d"), digit) + tstr;
		t /= 10;
	}
	url << tstr;
#endif
	url << _T("/") << m_selected_draw;

	return encode_string(url, true);

}
开发者ID:wds315,项目名称:szarp,代码行数:56,代码来源:drawdnd.cpp


示例14: if

// Sets the normed_ids vector from the normed string. normed_ids is not
// stored in the file, and needs to be set when the UNICHARSET is loaded.
void UNICHARSET::set_normed_ids(UNICHAR_ID unichar_id) {
  unichars[unichar_id].properties.normed_ids.truncate(0);
  if (unichar_id == UNICHAR_SPACE && id_to_unichar(unichar_id)[0] == ' ') {
    unichars[unichar_id].properties.normed_ids.push_back(UNICHAR_SPACE);
  } else if (!encode_string(unichars[unichar_id].properties.normed.string(),
                            true, &unichars[unichar_id].properties.normed_ids,
                            NULL, NULL)) {
    unichars[unichar_id].properties.normed_ids.truncate(0);
    unichars[unichar_id].properties.normed_ids.push_back(unichar_id);
  }
}
开发者ID:bhanu475,项目名称:tesseract,代码行数:13,代码来源:unicharset.cpp


示例15: GetStrProperties

// Gets the properties for a grapheme string, combining properties for
// multiple characters in a meaningful way where possible.
// Returns false if no valid match was found in the unicharset.
// NOTE that script_id, mirror, and other_case refer to this unicharset on
// return and will need translation if the target unicharset is different.
bool UNICHARSET::GetStrProperties(const char* utf8_str,
                                  UNICHAR_PROPERTIES* props) const {
  props->Init();
  props->SetRangesEmpty();
  int total_unicodes = 0;
  GenericVector<UNICHAR_ID> encoding;
  if (!encode_string(utf8_str, true, &encoding, NULL, NULL))
    return false;  // Some part was invalid.
  for (int i = 0; i < encoding.size(); ++i) {
    int id = encoding[i];
    const UNICHAR_PROPERTIES& src_props = unichars[id].properties;
    // Logical OR all the bools.
    if (src_props.isalpha) props->isalpha = true;
    if (src_props.islower) props->islower = true;
    if (src_props.isupper) props->isupper = true;
    if (src_props.isdigit) props->isdigit = true;
    if (src_props.ispunctuation) props->ispunctuation = true;
    if (src_props.isngram) props->isngram = true;
    if (src_props.enabled) props->enabled = true;
    // Min/max the tops/bottoms.
    UpdateRange(src_props.min_bottom, &props->min_bottom, &props->max_bottom);
    UpdateRange(src_props.max_bottom, &props->min_bottom, &props->max_bottom);
    UpdateRange(src_props.min_top, &props->min_top, &props->max_top);
    UpdateRange(src_props.max_top, &props->min_top, &props->max_top);
    float bearing = props->advance + src_props.bearing;
    if (total_unicodes == 0 || bearing < props->bearing) {
      props->bearing = bearing;
      props->bearing_sd = props->advance_sd + src_props.bearing_sd;
    }
    props->advance += src_props.advance;
    props->advance_sd += src_props.advance_sd;
    // With a single width, just use the widths stored in the unicharset.
    props->width = src_props.width;
    props->width_sd = src_props.width_sd;
    // Use the first script id, other_case, mirror, direction.
    // Note that these will need translation, except direction.
    if (total_unicodes == 0) {
      props->script_id = src_props.script_id;
      props->other_case = src_props.other_case;
      props->mirror = src_props.mirror;
      props->direction = src_props.direction;
    }
    // The normed string for the compound character is the concatenation of
    // the normed versions of the individual characters.
    props->normed += src_props.normed;
    ++total_unicodes;
  }
  if (total_unicodes > 1) {
    // Estimate the total widths from the advance - bearing.
    props->width = props->advance - props->bearing;
    props->width_sd = props->advance_sd + props->bearing_sd;
  }
  return total_unicodes > 0;
}
开发者ID:bhanu475,项目名称:tesseract,代码行数:59,代码来源:unicharset.cpp


示例16: process_setstat

static void
process_setstat(u_int32_t id)
{
	Attrib *a;
	char *name;
	int status = SSH2_FX_OK, ret;

	name = get_string(NULL);
	a = get_attrib();
	debug("request %u: setstat name \"%s\"", id, name);
	if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
		logit("set \"%s\" size %llu",
		    name, (unsigned long long)a->size);
		ret = truncate(name, a->size);
		if (ret == -1)
			status = errno_to_portable(errno);
	}
	if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
		logit("set \"%s\" mode %04o", name, a->perm);
		ret = chmod(name, a->perm & 07777);
		if (ret == -1)
			status = errno_to_portable(errno);
	}
	if (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME) {
		char buf[64];
		time_t t = a->mtime;

		strftime(buf, sizeof(buf), "%Y%m%d-%H:%M:%S",
		    localtime(&t));
		logit("set \"%s\" modtime %s", name, buf);
		ret = utimes(name, attrib_to_tv(a));
		if (ret == -1)
			status = errno_to_portable(errno);
	}
	if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
		logit("set \"%s\" owner %lu group %lu", name,
		    (u_long)a->uid, (u_long)a->gid);
		ret = chown(name, a->uid, a->gid);
		if (ret == -1)
			status = errno_to_portable(errno);
	}
	send_status(id, status);

#ifdef NERSC_MOD
 	char* t1buf = encode_string( name, strlen(name));
 	s_audit("sftp_process_setstat_3", "count=%i int=%d int=%d uristring=%s",
 		get_client_session_id(), (int)getppid(), id, t1buf);
 	free(t1buf);
#endif

	free(name);
}
开发者ID:set-element,项目名称:DEPRICATED-InstrumentedSSHD,代码行数:52,代码来源:sftp-server.c


示例17: calloc

gchar *encoded_string(const gchar *string)
{
     /* FIXME: check whether this code is still used (it might have been dropped out with the GTK+1.2 removal) */
     char *ldap_string;

     if (!string) return NULL;

     ldap_string = calloc(2 * strlen(string) + 1, sizeof(char));
  
     encode_string(ldap_string, string, strlen(string));

     return ldap_string;
}
开发者ID:kallisti5,项目名称:gqclient,代码行数:13,代码来源:encode.c


示例18: heka_encode_message_table

lsb_err_value heka_encode_message_table(lsb_lua_sandbox *lsb, int idx)
{
  lsb_err_value ret = NULL;
  lsb_output_buffer *ob = &lsb->output;
  ob->pos = 0;

  // use existing or create a type 4 uuid
  lua_getfield(lsb->lua, idx, LSB_UUID);
  size_t len;
  const char *uuid = lua_tolstring(lsb->lua, -1, &len);
  ret = lsb_write_heka_uuid(ob, uuid, len);
  lua_pop(lsb->lua, 1); // remove uuid
  if (ret) return ret;

  // use existing or create a timestamp
  lua_getfield(lsb->lua, idx, LSB_TIMESTAMP);
  long long ts;
  if (lua_isnumber(lsb->lua, -1)) {
    ts = (long long)lua_tonumber(lsb->lua, -1);
  } else {
    ts = time(NULL) * 1000000000LL;
  }
  lua_pop(lsb->lua, 1); // remove timestamp

  ret = lsb_pb_write_key(ob, LSB_PB_TIMESTAMP, LSB_PB_WT_VARINT);
  if (!ret) ret = lsb_pb_write_varint(ob, ts);
  if (!ret) ret = encode_string(lsb, ob, LSB_PB_TYPE, LSB_TYPE, idx);
  if (!ret) ret = encode_string(lsb, ob, LSB_PB_LOGGER, LSB_LOGGER, idx);
  if (!ret) ret = encode_int(lsb, ob, LSB_PB_SEVERITY, LSB_SEVERITY, idx);
  if (!ret) ret = encode_string(lsb, ob, LSB_PB_PAYLOAD, LSB_PAYLOAD, idx);
  if (!ret) ret = encode_string(lsb, ob, LSB_PB_ENV_VERSION, LSB_ENV_VERSION,
                                idx);
  if (!ret) ret = encode_int(lsb, ob, LSB_PB_PID, LSB_PID, idx);
  if (!ret) ret = encode_string(lsb, ob, LSB_PB_HOSTNAME, LSB_HOSTNAME, idx);
  if (!ret) ret = encode_fields(lsb, ob, LSB_PB_FIELDS, LSB_FIELDS, idx);
  if (!ret) ret = lsb_expand_output_buffer(ob, 1);
  ob->buf[ob->pos] = 0; // prevent possible overrun if treated as a string
  return ret;
}
开发者ID:bbinet,项目名称:lua_sandbox,代码行数:39,代码来源:message.c


示例19: save_value

/* Returns LUAAMF_ESUCCESS on success, error code on failure */
static int save_value(
    luaamf_SaveBuffer * sb,
    lua_State * L,
    int index,
    int use_code
  )
{
  int result = LUAAMF_EFAILURE;

  switch (lua_type(L, index))
  {
  case LUA_TNIL:
    sb_writechar(sb, LUAAMF_NULL);
    result = LUAAMF_ESUCCESS;
    break;

  case LUA_TBOOLEAN:
    sb_writechar(sb, lua_toboolean(L, index) ? LUAAMF_TRUE : LUAAMF_FALSE);
    result = LUAAMF_ESUCCESS;
    break;

  case LUA_TNUMBER:
    result = encode_double(sb, lua_tonumber(L, index));
    break;

  case LUA_TSTRING:
    {
      size_t len;
      const char * buf = lua_tolstring(L, index, &len);
      if(use_code)
      {
        sb_writechar(sb, LUAAMF_STRING);
      }
      result = encode_string(sb, buf, len);
      break;
    }

  case LUA_TTABLE:
    result = save_table(L, sb, index);
    break;

  case LUA_TNONE:
  case LUA_TFUNCTION:
  case LUA_TTHREAD:
  case LUA_TUSERDATA:
  default:
    result = LUAAMF_EBADTYPE;
  }

  return result;
}
开发者ID:fantao963,项目名称:lua-amf,代码行数:52,代码来源:save.c


示例20: _T

void SelectDrawWidget::GoToWWWDocumentation(DrawInfo *d) {
	if (d->IsValid() == false)
		return;
	TParam *p = d->GetParam()->GetIPKParam();
	TSzarpConfig* sc = p->GetSzarpConfig();

	wxString link = sc->GetDocumentationBaseURL();

	if (link.IsEmpty())
		link = _T("http://www.szarp.com");

	link += _T("/cgi-bin/param_docs.py?");
	link << _T("prefix=") << d->GetBasePrefix().c_str();

	link << _T("&param=") << encode_string(p->GetName().c_str());

	TUnit* u;
	if ((u = p->GetParentUnit())) {
		TDevice* dev = u->GetDevice();
		link << _T("&path=") << encode_string(dev->GetPath().c_str());
	}

	int validity = 8 * 3600;
	std::wstringstream tss;
	tss << (wxDateTime::Now().GetTicks() / validity * validity);

	link << _T("&id=") << sz_md5(tss.str());

#if __WXMSW__
	if (wxLaunchDefaultBrowser(link) == false)
#else
	if (wxExecute(wxString::Format(_T("xdg-open %s"), link.c_str())) == 0)
#endif
		wxMessageBox(_("I was not able to start default browser"), _("Error"), wxICON_ERROR | wxOK, this);


}
开发者ID:cyclefusion,项目名称:szarp,代码行数:37,代码来源:seldraw.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ encoder函数代码示例发布时间:2022-05-30
下一篇:
C++ encode_ok_reply函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap