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


C++ safe_str函数代码示例

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


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

示例1: menus

std::vector<IMenu*> LayoutManager::findAllMenus(IWindow& window, const char* path)
{
	// create a collection of all menus associated with this window.
	auto& windowMenus = window.menus();
	std::vector<IMenu*> menus(windowMenus.size() + dynamicMenus_.size());

	// copy all the menus owned by the window
	auto it = std::transform(windowMenus.begin(), windowMenus.end(), menus.begin(),
	                         [](const std::unique_ptr<IMenu>& menu) { return menu.get(); });

	// copy all the menus dynamically registered for this window
	auto windowId = safe_str(window.id());
	it = std::copy_if(dynamicMenus_.begin(), dynamicMenus_.end(), it, [&](IMenu* menu) {
		auto menuWindowId = safe_str(menu->windowId());
		return strcmp(windowId, menuWindowId) == 0;
	});

	// resize the collection to the actual number of menus that were collected
	menus.erase(it, menus.end());

	for (auto it = menus.begin(); it != menus.end();)
	{
		if (matchMenu(**it, path))
		{
			++it;
			continue;
		}

		it = menus.erase(it);
	}

	return menus;
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:33,代码来源:layout_manager.cpp

示例2: addNewNebula

void addNewNebula(dbref executor, int index, const char* name, double radius, double x, double y, double z, char *buff, char **bp)
{
	aspace_borders* newNebula;
	newNebula = im_find(nebula_map, index);
	
	if (newNebula != NULL) {
		safe_str("#-1 NEBULA # ALREADY IN USE", buff, bp);
		return;
	}
		
	newNebula = mush_malloc(sizeof(aspace_borders), "nebula_info");
	
	newNebula->name = mush_strdup(name, "spacenebula_name");
	newNebula->empire_id = 0;
	newNebula->radius = radius;
	newNebula->x = x;
	newNebula->y = y;
	newNebula->z = z;
	
	if( im_insert(nebula_map, index, newNebula )) {
		safe_str("New nebula Created.", buff, bp);
		write_spacelog(executor, executor, tprintf("Nebula Created: %s", newNebula->name));
	} else
		safe_str("#-1 NEBULA NOT CREATED.", buff, bp);
}
开发者ID:DieterKoblenz,项目名称:aspace,代码行数:25,代码来源:space_nebula.c

示例3: list_attribs

/** Return a list of standard attributes.
 * This functions returns the list of standard attributes, separated by
 * spaces, in a statically allocated buffer.
 */
char *
list_attribs(void)
{
  ATTR *ap;
  const char *ptrs[BUFFER_LEN / 2];
  static char buff[BUFFER_LEN];
  char *bp;
  const char *name;
  int nptrs = -1, i;

  for (ap = ptab_firstentry_new(&ptab_attrib, &name);
       ap; ap = ptab_nextentry_new(&ptab_attrib, &name)) {
    if (strcmp(name, AL_NAME(ap)))
      continue;
    ptrs[++nptrs] = AL_NAME(ap);
  }
  bp = buff;
  if (nptrs >= 0)
    safe_str(ptrs[0], buff, &bp);
  for (i = 1; i < nptrs; i++) {
    safe_chr(' ', buff, &bp);
    safe_str(ptrs[i], buff, &bp);
  }
  *bp = '\0';
  return buff;
}
开发者ID:HarryCordewener,项目名称:pennmush,代码行数:30,代码来源:atr_tab.c

示例4: display_flagtab

void display_flagtab(dbref player)
{
    UTF8 *buf, *bp;
    FLAGNAMEENT *fp;

    bp = buf = alloc_lbuf("display_flagtab");
    safe_str(T("Flags:"), buf, &bp);
    for (fp = gen_flag_names; fp->flagname; fp++)
    {
        FLAGBITENT *fbe = fp->fbe;
        if (  (  (fbe->listperm & CA_WIZARD)
              && !Wizard(player))
           || (  (fbe->listperm & CA_GOD)
              && !God(player)))
        {
            continue;
        }
        safe_chr(' ', buf, &bp);
        safe_str(fp->flagname, buf, &bp);
        if (fbe->flaglett != ' ')
        {
            safe_chr('(', buf, &bp);
            if (!fp->bPositive)
            {
                safe_chr('!', buf, &bp);
            }
            safe_chr(fbe->flaglett, buf, &bp);
            safe_chr(')', buf, &bp);
        }
    }
    *bp = '\0';
    notify(player, buf);
    free_lbuf(buf);
}
开发者ID:sanjayui,项目名称:tinymux,代码行数:34,代码来源:flags.cpp

示例5: help_helper

void help_helper(dbref executor, int iHelpfile, UTF8 *topic_arg,
    UTF8 *buff, UTF8 **bufc)
{
    if (!ValidateHelpFileIndex(iHelpfile))
    {
        return;
    }

    size_t nTopic;
    const UTF8 *topic = MakeCanonicalTopicName(topic_arg, nTopic);

    CHashTable *htab = mudstate.aHelpDesc[iHelpfile].ht;
    struct help_entry *htab_entry =
        (struct help_entry *)hashfindLEN(topic, nTopic, htab);

    if (htab_entry)
    {
        UTF8 *result = alloc_lbuf("help_helper");
        if (ReportTopic(executor, htab_entry, iHelpfile, result))
        {
            safe_str(result, buff, bufc);
        }
        else
        {
            safe_str(T("#-1 ERROR"), buff, bufc);
        }
        free_lbuf(result);
    }
    else
    {
        safe_str(T("#-1 TOPIC DOES NOT EXIST"), buff, bufc);
    }
}
开发者ID:sanjayui,项目名称:tinymux,代码行数:33,代码来源:help.cpp

示例6: read_request

static cachemgr_request *
read_request(void)
{
    char *buf;
    cachemgr_request *req;
    char *s;
    char *t;
    char *q;
    if ((buf = read_post_request()) != NULL)
	(void) 0;
    else if ((buf = read_get_request()) != NULL)
	(void) 0;
    else
	return NULL;
#ifdef _SQUID_MSWIN_
    if (strlen(buf) == 0 || strlen(buf) == 4000)
#else
    if (strlen(buf) == 0)
#endif
	return NULL;
    req = xcalloc(1, sizeof(cachemgr_request));
    for (s = strtok(buf, "&"); s != NULL; s = strtok(NULL, "&")) {
	t = xstrdup(s);
	if ((q = strchr(t, '=')) == NULL)
	    continue;
	*q++ = '\0';
	rfc1738_unescape(t);
	rfc1738_unescape(q);
	if (0 == strcasecmp(t, "server") && strlen(q))
	    req->server = xstrdup(q);
	else if (0 == strcasecmp(t, "host") && strlen(q))
	    req->hostname = xstrdup(q);
	else if (0 == strcasecmp(t, "port") && strlen(q))
	    req->port = atoi(q);
	else if (0 == strcasecmp(t, "user_name") && strlen(q))
	    req->user_name = xstrdup(q);
	else if (0 == strcasecmp(t, "passwd") && strlen(q))
	    req->passwd = xstrdup(q);
	else if (0 == strcasecmp(t, "auth") && strlen(q))
	    req->pub_auth = xstrdup(q), decode_pub_auth(req);
	else if (0 == strcasecmp(t, "operation"))
	    req->action = xstrdup(q);
    }
    if (req->server && !req->hostname) {
	char *p;
	req->hostname = strtok(req->server, ":");
	if ((p = strtok(NULL, ":")))
	    req->port = atoi(p);
    }
    make_pub_auth(req);
    debug(1) fprintf(stderr, "cmgr: got req: host: '%s' port: %d uname: '%s' passwd: '%s' auth: '%s' oper: '%s'\n",
	safe_str(req->hostname), req->port, safe_str(req->user_name), safe_str(req->passwd), safe_str(req->pub_auth), safe_str(req->action));
    return req;
}
开发者ID:CoolerVoid,项目名称:squid,代码行数:54,代码来源:cachemgr.c

示例7: list_borders

void list_borders(char *buff, char **bp)
{
	int first = 0;
	int index = 0;
        	
       for (index = 1; index <= im_count(border_map); index++) {
		if (first) {
			safe_str("~", buff, bp);
		}
		
		safe_str(border_line_bot(index, im_find(border_map, index)), buff, bp);
		++first;
        }
}
开发者ID:DieterKoblenz,项目名称:aspace,代码行数:14,代码来源:space_border.c

示例8: sass_parse_block

  static Block_Obj sass_parse_block(Sass_Compiler* compiler) throw()
  {

    // assert valid pointer
    if (compiler == 0) return 0;
    // The cpp context must be set by now
    Context* cpp_ctx = compiler->cpp_ctx;
    Sass_Context* c_ctx = compiler->c_ctx;
    // We will take care to wire up the rest
    compiler->cpp_ctx->c_compiler = compiler;
    compiler->state = SASS_COMPILER_PARSED;

    try {

      // get input/output path from options
      std::string input_path = safe_str(c_ctx->input_path);
      std::string output_path = safe_str(c_ctx->output_path);

      // maybe skip some entries of included files
      // we do not include stdin for data contexts
      bool skip = c_ctx->type == SASS_CONTEXT_DATA;

      // dispatch parse call
      Block_Obj root(cpp_ctx->parse());
      // abort on errors
      if (!root) return 0;

      // skip all prefixed files? (ToDo: check srcmap)
      // IMO source-maps should point to headers already
      // therefore don't skip it for now. re-enable or
      // remove completely once this is tested
      size_t headers = cpp_ctx->head_imports;

      // copy the included files on to the context (dont forget to free later)
      if (copy_strings(cpp_ctx->get_included_files(skip, headers), &c_ctx->included_files) == NULL)
        throw(std::bad_alloc());

      // return parsed block
      return root;

    }
    // pass errors to generic error handler
    catch (...) { handle_errors(c_ctx); }

    // error
    return 0;

  }
开发者ID:DealerDotCom,项目名称:libsass,代码行数:48,代码来源:sass_context.cpp

示例9: do_whichof

static void
do_whichof(char *args[], int nargs, enum whichof_t flag,
           char *buff, char **bp, dbref executor,
           dbref caller, dbref enactor, NEW_PE_INFO *pe_info, int eflags,
           int isbool)
{
  int j;
  char tbuf[BUFFER_LEN], *tp;
  char sep[BUFFER_LEN];
  char const *ap;
  int first = 1;
  tbuf[0] = '\0';

  if (eflags <= 0)
    eflags = PE_DEFAULT;

  if (flag == DO_ALLOF) {
    /* The last arg is a delimiter. Parse it in place. */
    char *sp = sep;
    const char *arglast = args[nargs - 1];
    if (process_expression(sep, &sp, &arglast, executor,
                           caller, enactor, eflags, PT_DEFAULT, pe_info))
      return;
    *sp = '\0';
    nargs--;
  } else
    sep[0] = '\0';

  for (j = 0; j < nargs; j++) {
    tp = tbuf;
    ap = args[j];
    if (process_expression(tbuf, &tp, &ap, executor, caller,
                           enactor, eflags, PT_DEFAULT, pe_info))
      return;
    *tp = '\0';
    if ((isbool && parse_boolean(tbuf)) || (!isbool && strlen(tbuf))) {
      if (!first && *sep) {
        safe_str(sep, buff, bp);
      } else
        first = 0;
      safe_str(tbuf, buff, bp);
      if (flag == DO_FIRSTOF)
        return;
    }
  }
  if (flag == DO_FIRSTOF)
    safe_str(tbuf, buff, bp);
}
开发者ID:ccubed,项目名称:MuDocker,代码行数:48,代码来源:funmisc.c

示例10: list_locks

/** Return a list of all available locks
 * \param buff the buffer
 * \param bp a pointer to the current position in the buffer.
 * \param name if not NULL, only show locks with this prefix
 */
void
list_locks(char *buff, char **bp, const char *name)
{
  lock_list **locks, *lk;
  bool first = 1;
  int nlocks = 0, n;

  locks = mush_calloc(htab_locks.entries, sizeof(lock_list), "lock.list");

  for (lk = hash_firstentry(&htab_locks); lk; lk = hash_nextentry(&htab_locks)) {
    /* Skip those that don't match */
    if (name && !string_prefix(lk->type, name))
      continue;
    locks[nlocks++] = lk;
  }

  qsort(locks, nlocks, sizeof lk, lock_compare);

  for (n = 0; n < nlocks; n += 1) {
    if (first) {
      first = 0;
    } else {
      safe_chr(' ', buff, bp);
    }
    safe_str(strupper(locks[n]->type), buff, bp);
  }

  mush_free(locks, "lock.list");
}
开发者ID:MrWigggles,项目名称:pennmush,代码行数:34,代码来源:lock.c

示例11: unparse_warnings

/** Given a warning bitmask, return a string of warnings on it.
 * \param warns the warnings.
 * \return pointer to statically allocated string listing warnings.
 */
const char *
unparse_warnings(warn_type warns)
{
    static char tbuf1[BUFFER_LEN];
    char *tp;
    int listsize, indexx;

    tp = tbuf1;

    /* Get the # of elements in checklist */
    listsize = sizeof(checklist) / sizeof(tcheck);

    /* Point c at last non-null in checklist, and go backwards */
    for (indexx = listsize - 2; warns && (indexx >= 0); indexx--) {
        warn_type the_flag = checklist[indexx].flag;
        if (!(the_flag & ~warns)) {
            /* Which is to say:
             * if the bits set on the_flag is a subset of the bits set on warns
             */
            safe_str(checklist[indexx].name, tbuf1, &tp);
            safe_chr(' ', tbuf1, &tp);
            /* If we've got a flag which subsumes smaller ones, don't
             * list the smaller ones
             */
            warns &= ~the_flag;
        }
    }
    *tp = '\0';
    return tbuf1;
}
开发者ID:tkrajcar,项目名称:pennjson,代码行数:34,代码来源:warnings.c

示例12: listq_walk

static void
listq_walk(const char *cur, int count __attribute__ ((__unused__)),
           void *userdata)
{
  struct st_qreg_data *st_data = (struct st_qreg_data *) userdata;
  char *name;

  name = (char *) cur + 1;

  if (!st_data->wild || quick_wild(st_data->wild, name)) {
    if (st_data->count++) {
      safe_str(st_data->osep, st_data->buff, st_data->bp);
    }
    safe_str(name, st_data->buff, st_data->bp);
  }
}
开发者ID:ccubed,项目名称:MuDocker,代码行数:16,代码来源:funmisc.c

示例13: cu5_pennpy_unparse

static int
cu5_pennpy_unparse(PyObject *value, char *buff, char **bp)
{
    char *value_str;

    if (value == Py_None) {
        /* No value. */
        return 1;
    }

    /* Coerce value to string. */
    if (!(value = PyObject_Str(value))) {
        /* Swallow exception. */
        PyErr_Clear();
        return 0;
    }

    /* Get string. */
    if (!(value_str = PyString_AsString(value))) {
        /* Swallow exception. */
        PyErr_Clear();
        Py_DECREF(value);
        return 0;
    }

    safe_str(value_str, buff, bp);
    Py_DECREF(value);
    return 1;
}
开发者ID:tkrajcar,项目名称:pypenn,代码行数:29,代码来源:pennpy.c

示例14: command_process_relay_cell

/** Process a 'relay' or 'relay_early' <b>cell</b> that just arrived from
 * <b>conn</b>. Make sure it came in with a recognized circ_id. Pass it on to
 * circuit_receive_relay_cell() for actual processing.
 */
static void
command_process_relay_cell(cell_t *cell, or_connection_t *conn)
{
  circuit_t *circ;
  int reason, direction;

  circ = circuit_get_by_circid_orconn(cell->circ_id, conn);

  if (!circ) {
    log_debug(LD_OR,
              "unknown circuit %d on connection from %s:%d. Dropping.",
              cell->circ_id, conn->_base.address, conn->_base.port);
    return;
  }

  if (circ->state == CIRCUIT_STATE_ONIONSKIN_PENDING) {
    log_fn(LOG_PROTOCOL_WARN,LD_PROTOCOL,"circuit in create_wait. Closing.");
    circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
    return;
  }

  if (CIRCUIT_IS_ORIGIN(circ)) {
    /* if we're a relay and treating connections with recent local
     * traffic better, then this is one of them. */
    conn->client_used = time(NULL);
  }

  if (!CIRCUIT_IS_ORIGIN(circ) &&
      cell->circ_id == TO_OR_CIRCUIT(circ)->p_circ_id)
    direction = CELL_DIRECTION_OUT;
  else
    direction = CELL_DIRECTION_IN;

  /* If we have a relay_early cell, make sure that it's outbound, and we've
   * gotten no more than MAX_RELAY_EARLY_CELLS_PER_CIRCUIT of them. */
  if (cell->command == CELL_RELAY_EARLY) {
    if (direction == CELL_DIRECTION_IN) {
      /* XXX Allow an unlimited number of inbound relay_early cells for
       * now, for hidden service compatibility. See bug 1038. -RD */
    } else {
      or_circuit_t *or_circ = TO_OR_CIRCUIT(circ);
      if (or_circ->remaining_relay_early_cells == 0) {
        log_fn(LOG_PROTOCOL_WARN, LD_OR,
               "Received too many RELAY_EARLY cells on circ %d from %s:%d."
               "  Closing circuit.",
               cell->circ_id, safe_str(conn->_base.address), conn->_base.port);
        circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
        return;
      }
      --or_circ->remaining_relay_early_cells;
    }
  }

  if ((reason = circuit_receive_relay_cell(cell, circ, direction)) < 0) {
    log_fn(LOG_PROTOCOL_WARN,LD_PROTOCOL,"circuit_receive_relay_cell "
           "(%s) failed. Closing.",
           direction==CELL_DIRECTION_OUT?"forward":"backward");
    circuit_mark_for_close(circ, -reason);
  }
}
开发者ID:kitsune-dsu,项目名称:kitsune-tor,代码行数:64,代码来源:command.c

示例15: getWindow

IWindow* LayoutManager::getWindow(const char* windowId)
{
	auto windowIt = windows_.find(safe_str(windowId));
	if (windowIt == windows_.end())
	{
		return nullptr;
	}
	return windowIt->second;
}
开发者ID:Aidanboneham,项目名称:wgtf,代码行数:9,代码来源:layout_manager.cpp


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