1 /*
2 	WARNING: This file was generated by the dkct program (see
3 	http://dktools.sourceforge.net/ for details).
4 	Changes you make here will be lost if dkct is run again!
5 	You should modify the original source and run dkct on it.
6 	Original source: test-dk4path8.ctr
7 */
8 
9 /**	@file test-dk4path8.c The test-dk4path8 module.
10 */
11 
12 
13 #include <stdio.h>
14 
15 #include <libdk4c/dk4path8.h>
16 #include <libdk4base/dk4mem.h>
17 #include <libdk4base/dk4str8.h>
18 
19 #include "string.h"
20 
21 static const char * const	p1[] = {
22 "/usr/local",
23 "my/file"
24 };
25 
26 static const char * const	p2[] = {
27 "../erwin.txt",
28 "../../bla.blubb",
29 "../../../test.was.passiert",
30 "ganz-langer-test-was-nun-wohl-passiert"
31 };
32 
33 
34 static const char * const p3[] = {
35 "/var",
36 "/usr/local/var/test/nocheins/undimmernocheins",
37 "test.dat"
38 };
39 
main(void)40 int main(void)
41 {
42   char buf[256];
43   char minbuf[16];
44   char *resptr;
45   dk4_er_t	er;
46   const size_t szp1 = sizeof(p1)/sizeof(DK4_PCHAR);
47   const size_t szp2 = sizeof(p2)/sizeof(DK4_PCHAR);
48   const size_t szmb = sizeof(minbuf);
49   size_t i;
50   size_t j;
51 
52 #if 0
53   for (i = 0; i < szp1; i++) {
54     for (j = 0; j < szp2; j++) {
55       strcpy(buf, p1[i]);
56       dk4error_init(&er);
57       if (dk4path8_append(buf, sizeof(buf), p2[j], &er)) {
58         printf("%u %u = \"%s\"\n", (unsigned)i, (unsigned)j, buf);
59       } else {
60         printf("%u %u ERROR %d\n", (unsigned)i, (unsigned)j, er.ec);
61       }
62     }
63   }
64 #endif
65 
66   if (0 != dk4path8_concatenate_buffer(minbuf, szmb, p3[0], p3[2], NULL)) {
67     fputs(minbuf, stdout);
68     fputc('\n', stdout);
69   }
70   else {
71     printf("ERROR: Not concatenated!\n");
72   }
73   resptr = dk4path8_concatenate_new(p3[0], p3[2], NULL);
74   if (NULL != resptr) {
75     fputs(resptr, stdout);
76     fputc('\n', stdout);
77     dk4mem_free(resptr);
78   }
79   else {
80     printf("ERROR: Function failed!\n");
81   }
82 
83   if (0 != dk4path8_concatenate_buffer(minbuf, szmb, p3[1], p3[2], NULL)) {
84     fputs(minbuf, stdout);
85     fputc('\n', stdout);
86   }
87   else {
88     printf("ERROR: Not concatenated!\n");
89   }
90   resptr = dk4path8_concatenate_new(p3[1], p3[2], NULL);
91   if (NULL != resptr) {
92     fputs(resptr, stdout);
93     fputc('\n', stdout);
94     dk4mem_free(resptr);
95   }
96   else {
97     printf("ERROR: Function failed!\n");
98   }
99 
100   return 0;
101 }
102 
103 
104