Print this page
7558 libscf.h should provide constants for scf_type_to_string return values


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2013, Joyent, Inc. All rights reserved.

  25  */
  26 
  27 /*
  28  * This is the main implementation file for the low-level repository
  29  * interface.
  30  */
  31 
  32 #include "lowlevel_impl.h"
  33 
  34 #include "repcache_protocol.h"
  35 #include "scf_type.h"
  36 
  37 #include <assert.h>
  38 #include <alloca.h>
  39 #include <door.h>
  40 #include <errno.h>
  41 #include <fcntl.h>
  42 #include <fnmatch.h>
  43 #include <libuutil.h>
  44 #include <poll.h>


 275                 }
 276 
 277                 if (!scf_setup_error()) {
 278                         lowlevel_inited = -1;
 279                         goto end;
 280                 }
 281                 lowlevel_inited = 1;
 282         }
 283 end:
 284         (void) pthread_mutex_unlock(&lowlevel_init_lock);
 285         if (lowlevel_inited > 0)
 286                 return (1);
 287         return (0);
 288 }
 289 
 290 static const struct {
 291         scf_type_t ti_type;
 292         rep_protocol_value_type_t ti_proto_type;
 293         const char *ti_name;
 294 } scf_type_info[] = {
 295         {SCF_TYPE_BOOLEAN,      REP_PROTOCOL_TYPE_BOOLEAN,      "boolean"},
 296         {SCF_TYPE_COUNT,        REP_PROTOCOL_TYPE_COUNT,        "count"},
 297         {SCF_TYPE_INTEGER,      REP_PROTOCOL_TYPE_INTEGER,      "integer"},
 298         {SCF_TYPE_TIME,         REP_PROTOCOL_TYPE_TIME,         "time"},
 299         {SCF_TYPE_ASTRING,      REP_PROTOCOL_TYPE_STRING,       "astring"},
 300         {SCF_TYPE_OPAQUE,       REP_PROTOCOL_TYPE_OPAQUE,       "opaque"},
 301         {SCF_TYPE_USTRING,      REP_PROTOCOL_SUBTYPE_USTRING,   "ustring"},
 302         {SCF_TYPE_URI,          REP_PROTOCOL_SUBTYPE_URI,       "uri"},
 303         {SCF_TYPE_FMRI,         REP_PROTOCOL_SUBTYPE_FMRI,      "fmri"},
 304         {SCF_TYPE_HOST,         REP_PROTOCOL_SUBTYPE_HOST,      "host"},
 305         {SCF_TYPE_HOSTNAME,     REP_PROTOCOL_SUBTYPE_HOSTNAME,  "hostname"},
 306         {SCF_TYPE_NET_ADDR,     REP_PROTOCOL_SUBTYPE_NETADDR,   "net_address"},












 307         {SCF_TYPE_NET_ADDR_V4,  REP_PROTOCOL_SUBTYPE_NETADDR_V4,
 308             "net_address_v4"},
 309         {SCF_TYPE_NET_ADDR_V6,  REP_PROTOCOL_SUBTYPE_NETADDR_V6,
 310             "net_address_v6"}
 311 };
 312 
 313 #define SCF_TYPE_INFO_COUNT (sizeof (scf_type_info) / sizeof (*scf_type_info))
 314 static rep_protocol_value_type_t
 315 scf_type_to_protocol_type(scf_type_t t)
 316 {
 317         int i;
 318 
 319         for (i = 0; i < SCF_TYPE_INFO_COUNT; i++)
 320                 if (scf_type_info[i].ti_type == t)
 321                         return (scf_type_info[i].ti_proto_type);
 322 
 323         return (REP_PROTOCOL_TYPE_INVALID);
 324 }
 325 
 326 static scf_type_t
 327 scf_protocol_type_to_type(rep_protocol_value_type_t t)
 328 {
 329         int i;
 330 




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2013, Joyent, Inc. All rights reserved.
  25  * Copyright 2016 RackTop Systems.
  26  */
  27 
  28 /*
  29  * This is the main implementation file for the low-level repository
  30  * interface.
  31  */
  32 
  33 #include "lowlevel_impl.h"
  34 
  35 #include "repcache_protocol.h"
  36 #include "scf_type.h"
  37 
  38 #include <assert.h>
  39 #include <alloca.h>
  40 #include <door.h>
  41 #include <errno.h>
  42 #include <fcntl.h>
  43 #include <fnmatch.h>
  44 #include <libuutil.h>
  45 #include <poll.h>


 276                 }
 277 
 278                 if (!scf_setup_error()) {
 279                         lowlevel_inited = -1;
 280                         goto end;
 281                 }
 282                 lowlevel_inited = 1;
 283         }
 284 end:
 285         (void) pthread_mutex_unlock(&lowlevel_init_lock);
 286         if (lowlevel_inited > 0)
 287                 return (1);
 288         return (0);
 289 }
 290 
 291 static const struct {
 292         scf_type_t ti_type;
 293         rep_protocol_value_type_t ti_proto_type;
 294         const char *ti_name;
 295 } scf_type_info[] = {
 296         {SCF_TYPE_BOOLEAN,      REP_PROTOCOL_TYPE_BOOLEAN,
 297             SCF_TYPE_STRING_BOOLEAN},
 298         {SCF_TYPE_COUNT,        REP_PROTOCOL_TYPE_COUNT,
 299             SCF_TYPE_STRING_COUNT},
 300         {SCF_TYPE_INTEGER,      REP_PROTOCOL_TYPE_INTEGER,
 301             SCF_TYPE_STRING_INTEGER},
 302         {SCF_TYPE_TIME,         REP_PROTOCOL_TYPE_TIME,
 303             SCF_TYPE_STRING_TIME},
 304         {SCF_TYPE_ASTRING,      REP_PROTOCOL_TYPE_STRING,
 305             SCF_TYPE_STRING_ASTRING},
 306         {SCF_TYPE_OPAQUE,       REP_PROTOCOL_TYPE_OPAQUE,
 307             SCF_TYPE_STRING_OPAQUE},
 308         {SCF_TYPE_USTRING,      REP_PROTOCOL_SUBTYPE_USTRING,
 309             SCF_TYPE_STRING_USTRING},
 310         {SCF_TYPE_URI,          REP_PROTOCOL_SUBTYPE_URI,
 311             SCF_TYPE_STRING_URI},
 312         {SCF_TYPE_FMRI,         REP_PROTOCOL_SUBTYPE_FMRI,
 313             SCF_TYPE_STRING_FMRI},
 314         {SCF_TYPE_HOST,         REP_PROTOCOL_SUBTYPE_HOST,
 315             SCF_TYPE_STRING_HOST},
 316         {SCF_TYPE_HOSTNAME,     REP_PROTOCOL_SUBTYPE_HOSTNAME,
 317             SCF_TYPE_STRING_HOSTNAME},
 318         {SCF_TYPE_NET_ADDR,     REP_PROTOCOL_SUBTYPE_NETADDR,
 319             SCF_TYPE_STRING_NET_ADDR},
 320         {SCF_TYPE_NET_ADDR_V4,  REP_PROTOCOL_SUBTYPE_NETADDR_V4,
 321             SCF_TYPE_STRING_NET_ADDR_V4},
 322         {SCF_TYPE_NET_ADDR_V6,  REP_PROTOCOL_SUBTYPE_NETADDR_V6,
 323             SCF_TYPE_STRING_NET_ADDR_V6}
 324 };
 325 
 326 #define SCF_TYPE_INFO_COUNT (sizeof (scf_type_info) / sizeof (*scf_type_info))
 327 static rep_protocol_value_type_t
 328 scf_type_to_protocol_type(scf_type_t t)
 329 {
 330         int i;
 331 
 332         for (i = 0; i < SCF_TYPE_INFO_COUNT; i++)
 333                 if (scf_type_info[i].ti_type == t)
 334                         return (scf_type_info[i].ti_proto_type);
 335 
 336         return (REP_PROTOCOL_TYPE_INVALID);
 337 }
 338 
 339 static scf_type_t
 340 scf_protocol_type_to_type(rep_protocol_value_type_t t)
 341 {
 342         int i;
 343