00001 /* 00002 * Hamlib Interface - toolbox header 00003 * Copyright (c) 2000-2004 by Stephane Fillod 00004 * 00005 * $Id: misc.h,v 1.18 2005/01/24 23:03:25 fillods Exp $ 00006 * 00007 * This library is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU Library General Public License as 00009 * published by the Free Software Foundation; either version 2 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 * 00021 */ 00022 00023 #ifndef _MISC_H 00024 #define _MISC_H 1 00025 00026 #include <hamlib/rig.h> 00027 00028 00029 /* 00030 * Carefull!! These marcos are NOT reentrant! 00031 * ie. they may not be executed atomically, 00032 * thus not ensure mutual exclusion. 00033 * Fix it when making Hamlib reentrant! --SF 00034 */ 00035 #define Hold_Decode(rig) {(rig)->state.hold_decode = 1;} 00036 #define Unhold_Decode(rig) {(rig)->state.hold_decode = 0;} 00037 00038 __BEGIN_DECLS 00039 00040 /* 00041 * Do a hex dump of the unsigned char array. 00042 */ 00043 00044 void dump_hex(const unsigned char ptr[], size_t size); 00045 00046 /* 00047 * BCD conversion routines. 00048 * to_bcd converts a long long int to a little endian BCD array, 00049 * and return a pointer to this array. 00050 * from_bcd converts a little endian BCD array to long long int 00051 * reprensentation, and return it. 00052 * bcd_len is the number of digits in the BCD array. 00053 */ 00054 extern HAMLIB_EXPORT(unsigned char *) to_bcd(unsigned char bcd_data[], unsigned long long freq, unsigned bcd_len); 00055 extern HAMLIB_EXPORT(unsigned long long) from_bcd(const unsigned char bcd_data[], unsigned bcd_len); 00056 00057 /* 00058 * same as to_bcd and from_bcd, but in Big Endian mode 00059 */ 00060 extern HAMLIB_EXPORT(unsigned char *) to_bcd_be(unsigned char bcd_data[], unsigned long long freq, unsigned bcd_len); 00061 extern HAMLIB_EXPORT(unsigned long long) from_bcd_be(const unsigned char bcd_data[], unsigned bcd_len); 00062 00063 extern HAMLIB_EXPORT(int) sprintf_freq(char *str, freq_t); 00064 00065 00066 /* check if it's any of CR or LF */ 00067 #define isreturn(c) ((c) == 10 || (c) == 13) 00068 00069 00070 /* needs config.h included beforehand in .c file */ 00071 #ifdef HAVE_INTTYPES_H 00072 #include <inttypes.h> 00073 #endif 00074 00075 #ifdef PRId64 00076 00077 #define PRIll PRId64 00078 #else 00079 #ifdef FBSD4 00080 #define PRIll "qd" 00081 #else 00082 #define PRIll "lld" 00083 #endif 00084 #endif 00085 00086 #ifdef SCNd64 00087 00088 #define SCNll SCNd64 00089 #else 00090 #ifdef FBSD4 00091 #define SCNll "qd" 00092 #else 00093 #define SCNll "lld" 00094 #endif 00095 #endif 00096 00097 00098 00099 __END_DECLS 00100 00101 #endif /* _MISC_H */
Hamlib documentation for version 1.2.7 -- Tue Aug 26 21:43:29 2008
Project page: http://hamlib.org