| 1 | /* Structures and equates used for version 1 and 2 Igor Pro variable records. |
| 2 | See Igor Pro Technical Note PTN003 for details. |
| 3 | */ |
| 4 | |
| 5 | #ifdef __cplusplus |
| 6 | extern "C" { |
| 7 | #endif |
| 8 | |
| 9 | // All structures written to disk are 2-byte-aligned. |
| 10 | #if GENERATINGPOWERPC |
| 11 | #pragma options align=mac68k |
| 12 | #endif |
| 13 | #ifdef WIN32 |
| 14 | #pragma pack(2) |
| 15 | #endif |
| 16 | |
| 17 | /* VarHeader1 |
| 18 | This is the header written at the start of the version 1 variables record, |
| 19 | before the actual variable data. |
| 20 | |
| 21 | The entire variables record on disk consists of: |
| 22 | PackedFileRecordHeader of type kVariablesRecord |
| 23 | |
| 24 | numSysVars system variables written as floats in order (K0, K1 . . . K19). |
| 25 | |
| 26 | numUserVars user numeric variables, each written as a UserNumVarRec record. |
| 27 | |
| 28 | numUserStrs user string variables, each consisting of a UserStrVarRec record. |
| 29 | */ |
| 30 | typedef struct VarHeader1 { |
| 31 | short version; // Version number is 1 for this header. |
| 32 | short numSysVars; // Number of system variables (K0, K1 . . .). |
| 33 | short numUserVars; // Number of user numeric variables -- may be zero./ |
| 34 | short numUserStrs; // Number of user string variables -- may be zero. |
| 35 | } VarHeader1; |
| 36 | |
| 37 | /* UserStrVarRec1 |
| 38 | This header precedes each user string variable in a version 2 variables record. |
| 39 | */ |
| 40 | typedef struct UserStrVarRec1 { |
| 41 | char name[31+1]; // Name of the string variable. |
| 42 | short strLen; // The real size of the following array. |
| 43 | char data[1]; |
| 44 | } UserStrVarRec1; |
| 45 | |
| 46 | |
| 47 | /* VarHeader2 |
| 48 | This is the header written at the start of the version 2 variables record, |
| 49 | before the actual variable data. |
| 50 | |
| 51 | The entire variables record on disk consists of: |
| 52 | PackedFileRecordHeader of type kVariablesRecord |
| 53 | |
| 54 | numSysVars system variables written as floats in order (K0, K1 . . . K19). |
| 55 | |
| 56 | numUserVars user numeric variables, each written as a UserNumVarRec record. |
| 57 | |
| 58 | numUserStrs user string variables, each consisting of a UserStrVarRec record. |
| 59 | |
| 60 | numDependentVars user dependent numeric variables, each consisting of a UserDependentVarRec record. |
| 61 | |
| 62 | numDependentStrs user dependent string variables, each consisting of a UserDependentVarRec record. |
| 63 | */ |
| 64 | typedef struct VarHeader2 { |
| 65 | short version; // Version number is 2 for this header. |
| 66 | short numSysVars; // Number of system variables (K0, K1 . . .). |
| 67 | short numUserVars; // Number of user numeric variables -- may be zero. |
| 68 | short numUserStrs; // Number of user string variables -- may be zero. |
| 69 | short numDependentVars; // Number of dependent numeric variables -- may be zero. |
| 70 | short numDependentStrs; // Number of dependent string variables -- may be zero. |
| 71 | } VarHeader2; |
| 72 | |
| 73 | |
| 74 | /* UserStrVarRec2 |
| 75 | This header precedes each user string variable in a version 2 variables record. |
| 76 | */ |
| 77 | typedef struct UserStrVarRec2 { |
| 78 | char name[31+1]; // Name of the string variable. |
| 79 | long strLen; // Number of bytes in the string. |
| 80 | char data[1]; // Start of string data. This is not a C string - no null terminator. |
| 81 | } UserStrVarRec2; |
| 82 | |
| 83 | struct VarNumRec { |
| 84 | short numType; // Type from IgorMath.h. |
| 85 | double realPart; // The real part of the number. |
| 86 | double imagPart; // The imag part if the number is complex. |
| 87 | long reserved; // Reserved - set to zero. |
| 88 | }; |
| 89 | typedef struct VarNumRec VarNumRec; |
| 90 | |
| 91 | |
| 92 | /* UserNumVarRec |
| 93 | This header precedes each user numeric variable. |
| 94 | */ |
| 95 | typedef struct UserNumVarRec { |
| 96 | char name[31+1]; // Name of the variable as a C string including null terminator. |
| 97 | short type; // Must be 1, signifying numeric. |
| 98 | VarNumRec num; // Type and value of the variable if it is numeric. |
| 99 | } UserNumVarRec; |
| 100 | |
| 101 | /* UserDependentVarRec |
| 102 | This header precedes each user dependent numeric or string variable. |
| 103 | A dependent variable is one controlled by a dependency formula, |
| 104 | such as: |
| 105 | numVar0 := 2*numVar1 |
| 106 | */ |
| 107 | typedef struct UserDependentVarRec { |
| 108 | char name[31+1]; // Name of the variable. |
| 109 | short type; // 0 = string, 1 = numeric. |
| 110 | VarNumRec num; // Type and value of the variable if it is numeric. Not used for string. |
| 111 | short formulaLen; // The length of the dependency formula. |
| 112 | char formula[1]; // Start of the dependency formula. A C string including null terminator. |
| 113 | } UserDependentVarRec; |
| 114 | |
| 115 | |
| 116 | #if GENERATINGPOWERPC |
| 117 | #pragma options align=reset |
| 118 | #endif |
| 119 | #ifdef WIN32 |
| 120 | #pragma pack() |
| 121 | #endif |
| 122 | // All structures written to disk are 2-byte-aligned. |
| 123 | |
| 124 | #ifdef __cplusplus |
| 125 | } |
| 126 | #endif |