|
| |||||||||||||
#include "mit-copyright.h"#include "notice.h"#include "string_dictionary_aux.h"#include "variables.h"Go to the source code of this file.
Defines | |
| #define | is_number_variable(x) (isdigit(*(x)) && is_digits((x))) |
Functions | |
| void | var_clear_all_variables () |
| string | var_get_variable (string name) |
| void | var_set_variable (string name, string value) |
| void | var_set_variable_to_number (string name, int number) |
| void | var_set_variable_then_free_value (string name, string value) |
| void | var_set_number_variables_to_fields (char *data, int length) |
|
|
Definition at line 65 of file variables.c. Referenced by var_get_variable(), var_set_variable(), and var_set_variable_then_free_value(). |
|
|
Definition at line 76 of file variables.c. References string_dictionary_Create(), and string_dictionary_SafeDestroy(). 00077 {
00078 if (non_number_variable_dict) {
00079 string_dictionary_SafeDestroy(non_number_variable_dict);
00080 string_dictionary_SafeDestroy(number_variable_dict);
00081 }
00082
00083 non_number_variable_dict = string_dictionary_Create(101);
00084 number_variable_dict = string_dictionary_Create(11);
00085 fields_data_length = 0;
00086 }
|
|
|
Definition at line 98 of file variables.c. References get_field(), is_number_variable, string, and string_dictionary_Fetch(). Referenced by eval_expr(). 00100 {
00101 char *result;
00102 int field_to_get;
00103 static string last_get_field_call_result = NULL;
00104
00105 if (is_number_variable(name)) {
00106 if ((result = string_dictionary_Fetch(number_variable_dict, name)))
00107 return (result);
00108
00109 /*
00110 * Convert name to an integer avoiding overflow:
00111 */
00112 while (*name == '0')
00113 name++;
00114 if (strlen(name) > 12)
00115 field_to_get = 0; /* no way we'll have > 1
00116 * trillian fields... */
00117 else
00118 field_to_get = atoi(name);
00119
00120 if (!field_to_get)
00121 return ("");
00122 if (last_get_field_call_result)
00123 free(last_get_field_call_result);
00124 last_get_field_call_result = get_field(fields_data,
00125 fields_data_length,
00126 field_to_get);
00127 return (last_get_field_call_result);
00128 }
00129
00130 if (!(result = string_dictionary_Fetch(non_number_variable_dict, name)))
00131 result = "";
00132
00133 return (result);
00134 }
|
|
||||||||||||
|
Definition at line 223 of file variables.c. References string_dictionary_Create(), and string_dictionary_SafeDestroy(). 00226 {
00227 fields_data = data;
00228 fields_data_length = length;
00229
00230 string_dictionary_SafeDestroy(number_variable_dict);
00231 number_variable_dict = string_dictionary_Create(11);
00232 }
|
|
||||||||||||
|
Definition at line 146 of file variables.c. References is_number_variable, and string_dictionary_Set. 00149 {
00150 string_dictionary_Set(is_number_variable(name) ? number_variable_dict
00151 : non_number_variable_dict, name, value);
00152 }
|
|
||||||||||||
|
Definition at line 188 of file variables.c. References is_number_variable, string_dictionary_binding, string_dictionary_Define(), _string_dictionary_binding::value, and var_set_variable(). 00191 {
00192 string_dictionary_binding *binding;
00193 int exists;
00194
00195 if (is_number_variable(name)) {
00196 var_set_variable(name, value);
00197 free(value);
00198 return;
00199 }
00200
00201 binding = string_dictionary_Define(non_number_variable_dict, name,
00202 &exists);
00203 if (exists)
00204 free(binding->value);
00205 binding->value = value;
00206 }
|
|
||||||||||||
|
Definition at line 164 of file variables.c. References buffer, and var_set_variable(). 00167 {
00168 char buffer[20];
00169
00170 sprintf(buffer, "%d", number);
00171 var_set_variable(name, buffer);
00172 }
|
| Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |