head 1.2; access; symbols last-version-before-change-to-ossp-style:1.1.1.1 VAR_0_0_0:1.1.1.1 VENDOR:1.1.1; locks; strict; comment @ * @; 1.2 date 2001.11.13.12.08.32; author simons; state dead; branches; next 1.1; 1.1 date 2001.11.09.17.01.37; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.11.09.17.01.37; author rse; state Exp; branches; next ; desc @@ 1.2 log @- Moved all routines into a single source file var.c. - Renamed varexp.h to var.h. - Removed odin-based build system. - Moved test cases into var_test.c. - Adapted build system. @ text @#include "../internal.h" int dummy(void* context, const char* varname, size_t name_len, const char** data, size_t* data_len, size_t* buffer_size) { if (name_len != sizeof("test")-1) { printf("The the length of the variable name (%d) doesn't fit.\n", name_len); exit(1); } if (memcmp(varname, "test", sizeof("test")-1) != 0) { printf("Callback called for unknown variable.\n"); exit(1); } *data = "foobar"; *data_len = sizeof("foobar")-1; *buffer_size = 0; return 1; } int main(int argc, char** argv) { const char* input = "This is a $test!"; const char* output = "This is a foobar!"; char* tmp; size_t tmp_len; var_rc_t rc; rc = var_expand(input, strlen(input), &tmp, &tmp_len, &dummy, NULL, NULL, 0); if (rc != VAR_OK) { printf("var_expand() failed with error %d.\n", rc); return 1; } if (tmp_len != strlen(output)) { printf("The length of the output string is not what we expected: %d != %d.\n", tmp_len, strlen(output)); return 1; } if (memcmp(tmp, output, tmp_len) != 0) { printf("The buffer returned by var_expand() is not what we expected.\n"); return 1; } return 0; } @ 1.1 log @Initial revision @ text @@ 1.1.1.1 log @import first cut of OSSP var @ text @@