1*5306Sgm209912 /* 2*5306Sgm209912 * CDDL HEADER START 3*5306Sgm209912 * 4*5306Sgm209912 * The contents of this file are subject to the terms of the 5*5306Sgm209912 * Common Development and Distribution License (the "License"). 6*5306Sgm209912 * You may not use this file except in compliance with the License. 7*5306Sgm209912 * 8*5306Sgm209912 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5306Sgm209912 * or http://www.opensolaris.org/os/licensing. 10*5306Sgm209912 * See the License for the specific language governing permissions 11*5306Sgm209912 * and limitations under the License. 12*5306Sgm209912 * 13*5306Sgm209912 * When distributing Covered Code, include this CDDL HEADER in each 14*5306Sgm209912 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5306Sgm209912 * If applicable, add the following below this CDDL HEADER, with the 16*5306Sgm209912 * fields enclosed by brackets "[]" replaced with your own identifying 17*5306Sgm209912 * information: Portions Copyright [yyyy] [name of copyright owner] 18*5306Sgm209912 * 19*5306Sgm209912 * CDDL HEADER END 20*5306Sgm209912 */ 21*5306Sgm209912 22*5306Sgm209912 /* 23*5306Sgm209912 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*5306Sgm209912 * Use is subject to license terms. 25*5306Sgm209912 */ 26*5306Sgm209912 27*5306Sgm209912 #ifndef _COMMP_UTIL_H 28*5306Sgm209912 #define _COMMP_UTIL_H 29*5306Sgm209912 30*5306Sgm209912 #pragma ident "%Z%%M% %I% %E% SMI" 31*5306Sgm209912 32*5306Sgm209912 #ifdef __cplusplus 33*5306Sgm209912 extern "C" { 34*5306Sgm209912 #endif 35*5306Sgm209912 36*5306Sgm209912 #include <sys/types.h> 37*5306Sgm209912 38*5306Sgm209912 #define COMMP_CRLF "\r\n" 39*5306Sgm209912 #define COMMP_LF "\n" 40*5306Sgm209912 #define COMMP_SKIP_CRLF(msg_ptr) ((msg_ptr) = (msg_ptr) + 2) 41*5306Sgm209912 #define COMMP_SKIP_LF(msg_ptr) ((msg_ptr) = (msg_ptr) + 1) 42*5306Sgm209912 43*5306Sgm209912 #define COMMP_SECS_IN_DAY 86400 44*5306Sgm209912 #define COMMP_SECS_IN_HOUR 3600 45*5306Sgm209912 #define COMMP_SECS_IN_MIN 60 46*5306Sgm209912 47*5306Sgm209912 #define COMMP_SP ' ' 48*5306Sgm209912 #define COMMP_CR '\r' 49*5306Sgm209912 #define COMMP_COLON ':' 50*5306Sgm209912 #define COMMP_SLASH '/' 51*5306Sgm209912 #define COMMP_EQUALS '=' 52*5306Sgm209912 #define COMMP_ADDRTYPE_IP4 "IP4" 53*5306Sgm209912 #define COMMP_ADDRTYPE_IP6 "IP6" 54*5306Sgm209912 55*5306Sgm209912 #define COMMP_COPY_STR(dst, src, len) { \ 56*5306Sgm209912 (dst) = calloc(1, (len) + 1); \ 57*5306Sgm209912 if ((dst) != NULL) { \ 58*5306Sgm209912 (void) strncpy((dst), (src), (len)); \ 59*5306Sgm209912 } \ 60*5306Sgm209912 } 61*5306Sgm209912 62*5306Sgm209912 extern int commp_skip_white_space(const char **, const char *); 63*5306Sgm209912 extern int commp_find_token(const char **, const char **, const char *, 64*5306Sgm209912 char, boolean_t); 65*5306Sgm209912 extern int commp_atoi(const char *, const char *, int *); 66*5306Sgm209912 extern int commp_strtoull(const char *, const char *, uint64_t *); 67*5306Sgm209912 extern int commp_strtoub(const char *, const char *, uint8_t *); 68*5306Sgm209912 extern int commp_atoui(const char *, const char *, uint_t *); 69*5306Sgm209912 extern int commp_time_to_secs(const char *, const char *, uint64_t *); 70*5306Sgm209912 extern int commp_add_str(char **, const char *, int); 71*5306Sgm209912 72*5306Sgm209912 #ifdef __cplusplus 73*5306Sgm209912 } 74*5306Sgm209912 #endif 75*5306Sgm209912 76*5306Sgm209912 #endif /* _COMMP_UTIL_H */ 77