Print this page
OS-2444 richmond hardware maps need to support ivy bridge

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/fm/topo/libtopo/common/topo_string.c
          +++ new/usr/src/lib/fm/topo/libtopo/common/topo_string.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26      -
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
       26 +/*
       27 + * Copyright (c) 2013, Joyent, Inc. All rights reserved.
       28 + */
  28   29  
  29   30  #include <strings.h>
  30   31  #include <ctype.h>
  31   32  #include <fm/libtopo.h>
  32   33  #include <fm/topo_mod.h>
  33   34  #include <topo_alloc.h>
  34   35  
  35   36  char *
  36   37  topo_hdl_strdup(topo_hdl_t *thp, const char *s)
  37   38  {
↓ open down ↓ 11 lines elided ↑ open up ↑
  49   50  }
  50   51  
  51   52  void
  52   53  topo_hdl_strfree(topo_hdl_t *thp, char *s)
  53   54  {
  54   55          if (s != NULL)
  55   56                  topo_hdl_free(thp, s, strlen(s) + 1);
  56   57  }
  57   58  
  58   59  char *
       60 +topo_hdl_strsplit(topo_hdl_t *hdl, const char *input, const char *sep,
       61 +    char **lastp)
       62 +{
       63 +        size_t seplen = strlen(sep);
       64 +        const char *scanstart;
       65 +        char *token;
       66 +        char *ret;
       67 +
       68 +        if (input != NULL) {
       69 +                /*
       70 +                 * Start scanning at beginning of input:
       71 +                 */
       72 +                scanstart = input;
       73 +        } else {
       74 +                /*
       75 +                 * If we have already finished scanning, return NULL.
       76 +                 */
       77 +                if (*lastp == NULL)
       78 +                        return (NULL);
       79 +
       80 +                /*
       81 +                 * Otherwise, start scanning where we left off:
       82 +                 */
       83 +                scanstart = *lastp;
       84 +        }
       85 +
       86 +        token = strstr(scanstart, sep);
       87 +        if (token != NULL) {
       88 +                /*
       89 +                 * We still have a separator, so advance the next-start
       90 +                 * pointer past it:
       91 +                 */
       92 +                *lastp = token + seplen;
       93 +                /*
       94 +                 * Copy out this element:
       95 +                 */
       96 +                ret = topo_hdl_alloc(hdl, token - scanstart + 1);
       97 +                (void) strncpy(ret, scanstart, token - scanstart);
       98 +                ret[token - scanstart] = '\0';
       99 +        } else {
      100 +                /*
      101 +                 * We have no separator, so this is the last element:
      102 +                 */
      103 +                *lastp = NULL;
      104 +                ret = topo_hdl_strdup(hdl, scanstart);
      105 +        }
      106 +
      107 +        return (ret);
      108 +}
      109 +
      110 +char *
  59  111  topo_mod_strdup(topo_mod_t *mod, const char *s)
  60  112  {
  61  113          return (topo_hdl_strdup(mod->tm_hdl, s));
  62  114  }
  63  115  
  64  116  void
  65  117  topo_mod_strfree(topo_mod_t *mod, char *s)
  66  118  {
  67  119          topo_hdl_strfree(mod->tm_hdl, s);
  68  120  }
  69  121  
      122 +char *
      123 +topo_mod_strsplit(topo_mod_t *mod, const char *input, const char *sep,
      124 +    char **lastp)
      125 +{
      126 +        return (topo_hdl_strsplit(mod->tm_hdl, input, sep, lastp));
      127 +}
      128 +
  70  129  const char *
  71  130  topo_strbasename(const char *s)
  72  131  {
  73  132          const char *p = strrchr(s, '/');
  74  133  
  75  134          if (p == NULL)
  76  135                  return (s);
  77  136  
  78  137          return (++p);
  79  138  }
↓ open down ↓ 177 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX