1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 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 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _COMMP_UTIL_H 28 #define _COMMP_UTIL_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <sys/types.h> 35 36 #define COMMP_CRLF "\r\n" 37 #define COMMP_LF "\n" 38 #define COMMP_SKIP_CRLF(msg_ptr) ((msg_ptr) = (msg_ptr) + 2) 39 #define COMMP_SKIP_LF(msg_ptr) ((msg_ptr) = (msg_ptr) + 1) 40 41 #define COMMP_SECS_IN_DAY 86400 42 #define COMMP_SECS_IN_HOUR 3600 43 #define COMMP_SECS_IN_MIN 60 44 45 #define COMMP_SP ' ' 46 #define COMMP_CR '\r' 47 #define COMMP_COLON ':' 48 #define COMMP_SLASH '/' 49 #define COMMP_EQUALS '=' 50 #define COMMP_ADDRTYPE_IP4 "IP4" 51 #define COMMP_ADDRTYPE_IP6 "IP6" 52 53 #define COMMP_COPY_STR(dst, src, len) { \ 54 (dst) = calloc(1, (len) + 1); \ 55 if ((dst) != NULL) { \ 56 (void) strncpy((dst), (src), (len)); \ 57 } \ 58 } 59 60 extern int commp_skip_white_space(const char **, const char *); 61 extern int commp_find_token(const char **, const char **, const char *, 62 char, boolean_t); 63 extern int commp_atoi(const char *, const char *, int *); 64 extern int commp_strtoull(const char *, const char *, uint64_t *); 65 extern int commp_strtoub(const char *, const char *, uint8_t *); 66 extern int commp_atoui(const char *, const char *, uint_t *); 67 extern int commp_time_to_secs(const char *, const char *, uint64_t *); 68 extern int commp_add_str(char **, const char *, int); 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 #endif /* _COMMP_UTIL_H */ 75