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