1 /* valnode.h 2 * 3 * =========================================================================== 4 * 5 * PUBLIC DOMAIN NOTICE 6 * National Center for Biotechnology Information 7 * 8 * This software/database is a "United States Government Work" under the 9 * terms of the United States Copyright Act. It was written as part of 10 * the author's official duties as a United States Government employee and 11 * thus cannot be copyrighted. This software/database is freely available 12 * to the public for use. The National Library of Medicine and the U.S. 13 * Government have not placed any restriction on its use or reproduction. 14 * 15 * Although all reasonable efforts have been taken to ensure the accuracy 16 * and reliability of the software and data, the NLM and the U.S. 17 * Government do not and cannot warrant the performance or results that 18 * may be obtained by using this software or data. The NLM and the U.S. 19 * Government disclaim all warranties, express or implied, including 20 * warranties of performance, merchantability or fitness for any particular 21 * purpose. 22 * 23 * Please cite the author in any work or product based on this material. 24 * 25 * =========================================================================== 26 * 27 * File Name: valnode.h 28 * 29 * Author: Alexey Dobronadezhdin 30 * 31 * File Description: 32 * ----------------- 33 * ValNode functionality from C-toolkit. 34 */ 35 36 #ifndef VALNODE_H 37 #define VALNODE_H 38 39 /***************************************************************************** 40 * 41 * DataVal = a universal data type 42 * ValNode = a linked list of DataVal 43 * 44 *****************************************************************************/ 45 46 BEGIN_NCBI_SCOPE 47 48 typedef union dataval { 49 void* ptrvalue; 50 int intvalue; 51 double realvalue; 52 bool boolvalue; 53 int (*funcvalue)(); 54 Int8 bigintvalue; 55 } DataVal, *DataValPtr; 56 57 typedef struct valnode { 58 unsigned char choice; /* to pick a choice */ 59 unsigned char extended; /* extra fields reserved to NCBI allocated in structure */ 60 DataVal data; /* attached data */ 61 bool fatal; 62 struct valnode *next; /* next in linked list */ 63 } ValNode, *ValNodePtr; 64 65 typedef union _IntPnt_ { 66 int intvalue; 67 void* ptrvalue; 68 } IntPnt; 69 70 typedef struct _Choice_ { 71 unsigned char choice; 72 IntPnt value; 73 } Choice, *ChoicePtr; 74 75 /* convenience structure for holding head and tail of ValNode list for efficient tail insertion */ 76 typedef struct valnodeblock { 77 ValNodePtr head; 78 ValNodePtr tail; 79 } ValNodeBlock, *ValNodeBlockPtr; 80 81 ValNodePtr ValNodeNew(ValNodePtr vnp); 82 ValNodePtr ValNodeFree(ValNodePtr vnp); 83 ValNodePtr ValNodeFreeData(ValNodePtr vnp); 84 ValNodePtr ValNodeLink(ValNodePtr* head, ValNodePtr newnode); 85 86 ValNodePtr ValNodeCopyStrEx(ValNodePtr* head, ValNodePtr* tail, short choice, const char* str); 87 char* ValNodeMergeStrsEx(ValNodePtr list, char* separator); 88 89 END_NCBI_SCOPE 90 91 #endif 92