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