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


C++ savestring函数代码示例

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


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

示例1: tilde_expand_word

static char *
tilde_expand_word (char *filename)
{
  char *dirname, *expansion, *username;
  int user_len;
  struct passwd *user_entry;

  if (filename == 0)
    return ((char *)NULL);

  if (*filename != '~')
    return (savestring (filename));

  /* A leading `~/' or a bare `~' is *always* translated to the value of
     $HOME or the home directory of the current user, regardless of any
     preexpansion hook. */
  if (filename[1] == '\0' || filename[1] == '/')
    {
      /* Prefix $HOME to the rest of the string. */
      expansion = (char *) getenv ("HOME");

      /* If there is no HOME variable, look up the directory in
     the password database. */
      if (expansion == 0)
        expansion = get_home_dir ();

      return (glue_prefix_and_suffix (expansion, filename, 1));
    }

  username = isolate_tilde_prefix (filename, &user_len);

  /* No preexpansion hook, or the preexpansion hook failed.  Look in the
     password database. */
  dirname = (char *)NULL;
  user_entry = getpwnam (username);
  if (user_entry == 0)
    {
      free (username);
      /* If we don't have a failure hook, or if the failure hook did not
     expand the tilde, return a copy of what we were passed. */
      if (dirname == 0)
    dirname = savestring (filename);
    }
  else
    {
      free (username);
      dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len);
    }

#if HAVE_ENDPWENT
  endpwent ();
#endif
  return (dirname);
}
开发者ID:tylerberry,项目名称:newts,代码行数:54,代码来源:which.c

示例2: convert_suffix_rule

static void
convert_suffix_rule (char *target, char *source, struct commands *cmds)
{
  char *targname, *targpercent, *depname;
  char **names, **percents;
  struct dep *deps;
  unsigned int len;

  if (target == 0)
    /* Special case: TARGET being nil means we are defining a
       `.X.a' suffix rule; the target pattern is always `(%.o)'.  */
    {
#ifdef VMS
      targname = savestring ("(%.obj)", 7);
#else
      targname = savestring ("(%.o)", 5);
#endif
      targpercent = targname + 1;
    }
  else
    {
      /* Construct the target name.  */
      len = strlen (target);
      targname = xmalloc (1 + len + 1);
      targname[0] = '%';
      bcopy (target, targname + 1, len + 1);
      targpercent = targname;
    }

  names = (char **) xmalloc (2 * sizeof (char *));
  percents = (char **) alloca (2 * sizeof (char *));
  names[0] = targname;
  percents[0] = targpercent;
  names[1] = percents[1] = 0;

  if (source == 0)
    deps = 0;
  else
    {
      /* Construct the dependency name.  */
      len = strlen (source);
      depname = xmalloc (1 + len + 1);
      depname[0] = '%';
      bcopy (source, depname + 1, len + 1);
      deps = (struct dep *) xmalloc (sizeof (struct dep));
      deps->next = 0;
      deps->name = depname;
      deps->ignore_mtime = 0;
      deps->need_2nd_expansion = 0;
    }

  create_pattern_rule (names, percents, 0, deps, cmds, 0);
}
开发者ID:OS2World,项目名称:DEV-UTIL-gnumake,代码行数:53,代码来源:rule.c

示例3: initdefines

void initdefines()
/*
 * Initialize the built-in #define's.  There are two flavors:
 *      #define decus   1               (static definitions)
 *      #define __FILE__ ??             (dynamic, evaluated by magic)
 * Called only on cpp startup.
 *
 * Note: the built-in static definitions are supressed by the -N option.
 * __LINE__, __FILE__, and __DATE__ are always present.
 */
{
        register char           **pp;
        register char           *tp;
        register DEFBUF         *dp;
        int                     i;
        time_t                  tvec;

#if !defined( WNT ) && !defined(G3)
        extern char             *ctime();
#endif

        /*
         * Predefine the built-in symbols.  Allow the
         * implementor to pre-define a symbol as "" to
         * eliminate it.
         */
        if (nflag == 0) {
            for (pp = preset; *pp != NULL; pp++) {
                if (*pp[0] != EOS) {
                    dp = defendel(*pp, FALSE);
                    dp->repl = savestring("1");
                    dp->nargs = DEF_NOARGS;
                }
            }
        }
        /*
         * The magic pre-defines (__FILE__ and __LINE__ are
         * initialized with negative argument counts.  expand()
         * notices this and calls the appropriate routine.
         * DEF_NOARGS is one greater than the first "magic" definition.
         */
        if (nflag < 2) {
            for (pp = magic, i = DEF_NOARGS; *pp != NULL; pp++) {
                dp = defendel(*pp, FALSE);
                dp->nargs = --i;
            }
#if OK_DATE
            /*
             * Define __DATE__ as today's date.
             */
            dp = defendel("__DATE__", FALSE);
            dp->repl = tp = getmem(27);
            dp->nargs = DEF_NOARGS;
            time( &tvec);
            *tp++ = '"';
            strcpy(tp, ctime(&tvec));
            tp[24] = '"';                       /* Overwrite newline    */
#endif
        }
}
开发者ID:cjapes,项目名称:core,代码行数:60,代码来源:cpp3.c

示例4: setwindow

static void
setwindow(char *list)
    /* corners of window into the matrix */
{
    static char	*templist = NULL;	/* a working copy of the window list */
    char	*ptr;			/* next window coordinate in *templist */
    int		i = 0;			/* assigned to this region in wlist[] */

/*
 *
 * Sets up an optional window into the matrix.
 *
 */


    wlist[0] = wlist[1] = 1;
    wlist[2] = wlist[3] = 0;

    if ( list != NULL )  {
	if ( templist != NULL )
	    free(templist);
	templist = savestring(list);

	ptr = strtok(templist, ",/ \t\n");
	while ( ptr != NULL )  {
	    wlist[i++] = atoi(ptr);
	    ptr = strtok(NULL, ",/ \t\n");
	}   /* End while */
    }	/* End if */

}   /* End of setwindow */
开发者ID:andreiw,项目名称:polaris,代码行数:31,代码来源:postmd.c

示例5: initialize

/* Inicializacion del cliente */
void initialize()
{
    gethostname(my_host,HOSTNAME_SIZE);
    my_host[HOSTNAME_SIZE] = '\0';
    
    if ((local_host = gethostbyname(my_host)) == NULL)
    {
	printf("Local server not found.\n");
    	return;
    }
    
    list.nfiles = 0;
    list.lfiles = 0;
    list.files = (char *)NULL;
    
    
    bzero((char *) &cli_addr, sizeof(cli_addr));

    cli_addr.sin_family = AF_INET;
    bcopy((char *)local_host->h_addr_list[0],(char *)&cli_addr.sin_addr.s_addr,local_host->h_length);
    cli_addr.sin_port = htons(0);

    my_ident = (char *)savestring(getenv("LOGNAME"));

}
开发者ID:plineo,项目名称:scf,代码行数:26,代码来源:scf_client.c

示例6: scan_filename_with_cleanup

/* FIXME: add comment: */
char *
scan_filename_with_cleanup(const char **cmd, const char *defname)
{
  char *filename;
  char *fullname;

  /* FIXME: Need to get the ``/a(ppend)'' flag from somewhere.  */

  /* File: */
  if ((*cmd) == NULL)
    {
      if (defname == NULL)
	error(_("Missing filename."));
      filename = xstrdup(defname);
      make_cleanup(xfree, filename);
    }
  else
    {
      /* FIXME: should parse a possibly quoted string: */
      const char *end;

      (*cmd) = skip_spaces(*cmd);
      end = (*cmd + strcspn(*cmd, " \t"));
      filename = savestring((*cmd), end - (*cmd));
      make_cleanup(xfree, filename);
      (*cmd) = skip_spaces(end);
    }
  gdb_assert(filename != NULL);

  fullname = tilde_expand(filename);
  make_cleanup(xfree, fullname);

  return fullname;
}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:35,代码来源:cli-dump.c

示例7: push_prompt

/* Pushes a new prompt on the prompt stack. Each prompt has three
   parts: prefix, prompt, suffix. Usually prefix and suffix are empty
   strings, except when the annotation level is 2. Memory is allocated
   within savestring for the new prompt. */
void
push_prompt (char *prefix, char *prompt, char *suffix)
{
  the_prompts.top++;
  PREFIX (0) = savestring (prefix, strlen (prefix));

  /* Note that this function is used by the set annotate 2
     command. This is why we take care of saving the old prompt
     in case a new one is not specified. */
  if (prompt)
    PROMPT (0) = savestring (prompt, strlen (prompt));
  else
    PROMPT (0) = savestring (PROMPT (-1), strlen (PROMPT (-1)));

  SUFFIX (0) = savestring (suffix, strlen (suffix));
}
开发者ID:HoMeCracKeR,项目名称:gdb-ng,代码行数:20,代码来源:event-top.c

示例8: hpux_has_execd

int
hpux_has_execd (int pid, char **execd_pathname)
{
  /* This request is only available on HPUX 10.0 and later.  */
#if !defined(PT_GET_PROCESS_STATE)
  *execd_pathname = NULL;
  return 0;

#else
  int pt_status;
  ptrace_state_t ptrace_state;

  errno = 0;
  pt_status = call_ptrace (PT_GET_PROCESS_STATE,
			   pid,
			   (PTRACE_ARG3_TYPE) & ptrace_state,
			   sizeof (ptrace_state));
  if (errno)
    perror_with_name ("ptrace");
  if (pt_status < 0)
    return 0;

  if (ptrace_state.pe_report_event & PTRACE_EXEC)
    {
      char *exec_file = target_pid_to_exec_file (pid);
      *execd_pathname = savestring (exec_file, strlen (exec_file));
      return 1;
    }

  return 0;
#endif
}
开发者ID:sjohnston-adventiumlabs,项目名称:xen-micart-scheduler,代码行数:32,代码来源:hppah-nat.c

示例9: addcolormap

static void
addcolormap(char *list)
    /* use this color map */
{
    static char	*templist = NULL;	/* a working copy of the color list */
    char	*ptr;			/* next color in *templist */
    int		i = 0;			/* assigned to this region in ilist[] */

/*
 *
 * Assigns the integers in *list to the color field for the regions defined in
 * ilist[]. Assumes ilist[] has already been setup.
 *
 */


    if ( list != NULL )  {
	if ( templist != NULL )
	    free(templist);
	templist = savestring(list);

	ptr = strtok(templist, ",/ \t\n");
	while ( ptr != NULL )  {
	    ilist[i++].color = atoi(ptr) % 256;
	    ptr = strtok(NULL, ",/ \t\n");
	}   /* End while */
    }	/* End if */

}   /* End of addcolormap */
开发者ID:andreiw,项目名称:polaris,代码行数:29,代码来源:postmd.c

示例10: set_gnutarget

/* Set the gnutarget: */
void
set_gnutarget(char *newtarget)
{
  if (gnutarget_string != NULL)
    xfree(gnutarget_string);
  gnutarget_string = savestring(newtarget, strlen(newtarget));
  set_gnutarget_command(NULL, 0, NULL);
}
开发者ID:dougmencken,项目名称:apple-gdb-1824,代码行数:9,代码来源:corefile.c

示例11: main

/* Set default values for LC_CTYPE, LC_COLLATE, and LC_MESSAGES if they
   are not specified in the environment, but LANG or LC_ALL is.  This
   should be called from main() after parsing the environment. */
void
set_default_locale_vars ()
{
  char *val;

#if defined (HAVE_SETLOCALE)
  val = get_string_value ("LC_CTYPE");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_CTYPE, lc_all);

#  if defined (LC_COLLATE)
  val = get_string_value ("LC_COLLATE");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_COLLATE, lc_all);
#  endif /* LC_COLLATE */

#  if defined (LC_MESSAGES)
  val = get_string_value ("LC_MESSAGES");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_MESSAGES, lc_all);
#  endif /* LC_MESSAGES */

#  if defined (LC_NUMERIC)
  val = get_string_value ("LC_NUMERIC");
  if (val == 0 && lc_all && *lc_all)
    setlocale (LC_NUMERIC, lc_all);
#  endif /* LC_NUMERIC */

#endif /* HAVE_SETLOCALE */

  val = get_string_value ("TEXTDOMAIN");
  if (val && *val)
    {
      FREE (default_domain);
      default_domain = savestring (val);
      textdomain (default_domain);
    }

  val = get_string_value ("TEXTDOMAINDIR");
  if (val && *val)
    {
      FREE (default_dir);
      default_dir = savestring (val);
      bindtextdomain (default_domain, default_dir);
    }
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:49,代码来源:locale.c

示例12: AddCommandLine

static FieldSpec *
AddCommandLine(FieldList    *list,
	       char	    *line)
{
    FieldSpec	*field;


    if (line == NULL)
	return NULL;

    field = FindField(*list, "commandLine");

    if (field == NULL)
    {
	field = NewFieldSpec(ECHAR, 1);
	if (field == NULL)
	{
	    DebugMsg(1, "AddCommandLine: Couldn't create field spec.");
	    return NULL;
	}

	field->dim[0] = strlen(line);
	field->name = savestring("commandLine");
	field->occurrence = GLOBAL;

	if (!AddField(list, field))
	{
	    DebugMsg(1, "AddCommandLine: Couldn't add field spec.");
	    return NULL;
	}
    }
    else			/* field != NULL */
    {
	if (field->occurrence != GLOBAL)
	{
	    DebugMsg(1, "AddCommandLine: non-GLOBAL field \'commandLine\".");
	    return NULL;
	}

	field->type = ECHAR;
	field->rank = 1;
	field->dim = (long *) ((field->dim == NULL)
				? malloc(sizeof(long))
				: realloc(field->dim, sizeof(long)));

	if (field->dim == NULL)
	{
	    DebugMsg(1, "AddCommandLine: couldn't (re)allocate dimension.");
	    return NULL;
	}

	field->dim[0] = 1 + strlen(line);
    }

    field->data = line;

    return field;
}
开发者ID:rsprouse,项目名称:espsfree,代码行数:58,代码来源:fea2esig.c

示例13: buildilist

static void
buildilist(char *list)
    /* use this as the interval list */
{
    static char	*templist = NULL;	/* a working copy of the list */
    char	*ptr;			/* next number in *templist */
    int		i;			/* loop index - for checking the list */


/*
 *
 * Reads string *list and builds up the ilist[] that will be used in the next
 * matrix. Since strtok() modifies the string it's parsing we make a copy first.
 * The format of the interval list is described in detail in the comments at the
 * beginning of this program. Basically consists of a comma or space separated
 * list of floating point numbers that must be given in increasing numerical order.
 * The list determines how floating point numbers are mapped into integers in the
 * range 0 to 254.
 *
 */


    if ( templist != NULL )		/* free the space used by the last list */
	free(templist);

    while ( isascii(*list) && isspace(*list) )
	list++;

    for ( ptr = list, regions = 3; *ptr != '\0'; ptr++ )  {
	if ( *ptr == ',' || *ptr == '/' || isspace(*ptr) )
	    regions += 2;
	while ( isascii(*ptr) && isspace(*ptr) ) ptr++;
    }	/* End for */

    next = 0;
    templist = savestring(list);

    ptr = strtok(templist, ",/ \t\n");
    while ( ptr != NULL )  {
	ilist[next].count = 0;
	ilist[next++].color = 254 * (regions - 1 - next) / (regions - 1);
	ilist[next].val = atof(ptr);
	ilist[next].count = 0;
	ilist[next++].color = 254 * (regions - 1 - next) / (regions - 1);
	ptr = strtok(NULL, ",/ \t\n");
    }	/* End while */

    ilist[next].count = 0;
    ilist[next].color = 254 * (regions - 1 - next) / (regions - 1);

    if ( next == 0 )			/* make sure we have a list */
	error(FATAL, "missing interval list");

    for ( i = 3; i < next; i += 2 )	/* that's in increasing numerical order */
	if ( ilist[i].val <= ilist[i-2].val )
	    error(FATAL, "bad interval list");

}   /* End of buildilist */
开发者ID:andreiw,项目名称:polaris,代码行数:58,代码来源:postmd.c

示例14: get_current_user_info

/* From bash-3.2 */
static void
get_current_user_info ()
{
  struct passwd *entry;

  /* Don't fetch this more than once. */
  if (current_user.user_name == 0)
    {
      entry = getpwuid (current_user.uid);
      if (entry)
        {
          current_user.user_name = savestring (entry->pw_name);
          current_user.shell = (entry->pw_shell && entry->pw_shell[0])
                                ? savestring (entry->pw_shell)
                                : savestring ("/bin/sh");
          current_user.home_dir = savestring (entry->pw_dir);
        }
      else
        {
          current_user.user_name = "I have no name!";
          current_user.user_name = savestring (current_user.user_name);
          current_user.shell = savestring ("/bin/sh");
          current_user.home_dir = savestring ("/");
        }
      endpwent ();
    }
}
开发者ID:Distrotech,项目名称:which,代码行数:28,代码来源:bash.c

示例15: _rl_revert_all_lines

/* Process and free undo lists attached to each history entry prior to the
   current entry, inclusive, reverting each line to its saved state.  This 
   is destructive, and state about the current line is lost.  This is not
   intended to be called while actively editing, and the current line is
   not assumed to have been added to the history list. */
void
_rl_revert_all_lines (void)
{
  int hpos;
  HIST_ENTRY *entry;
  UNDO_LIST *ul, *saved_undo_list;
  char *lbuf;

  lbuf = savestring (rl_line_buffer);
  saved_undo_list = rl_undo_list;
  hpos = where_history ();

  entry = (hpos == history_length) ? previous_history () : current_history ();
  while (entry)
    {
      if (ul = (UNDO_LIST *)entry->data)
	{
	  if (ul == saved_undo_list)
	    saved_undo_list = 0;
	  /* Set up rl_line_buffer and other variables from history entry */
	  rl_replace_from_history (entry, 0);	/* entry->line is now current */
	  entry->data = 0;			/* entry->data is now current undo list */
	  /* Undo all changes to this history entry */
	  while (rl_undo_list)
	    rl_do_undo ();
	  /* And copy the reverted line back to the history entry, preserving
	     the timestamp. */
	  FREE (entry->line);
	  entry->line = savestring (rl_line_buffer);
	}
      entry = previous_history ();
    }

  /* Restore history state */
  rl_undo_list = saved_undo_list;	/* may have been set to null */
  history_set_pos (hpos);
  
  /* reset the line buffer */
  rl_replace_line (lbuf, 0);
  _rl_set_the_line ();

  /* and clean up */
  xfree (lbuf);
}  
开发者ID:bminor,项目名称:bash,代码行数:49,代码来源:misc.c


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