File: test69.c

package info (click to toggle)
libtpl 1.6.1-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,028 kB
  • sloc: ansic: 5,669; perl: 1,062; makefile: 101; cpp: 32; sh: 18
file content (39 lines) | stat: -rw-r--r-- 971 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdlib.h>
#include "tpl.h"

#define TEST_LEN1 10
#define TEST_LEN2 5

extern tpl_hook_t tpl_hook;

int main() {
    tpl_node *tn;
    int i[TEST_LEN1] = {1,2,3,4,5,6,7,8,9,10};
    int j[TEST_LEN2] = {5,4,3,2,1};
    int i2[TEST_LEN1];
    int j2[TEST_LEN2];
    int x,y;

    tpl_hook.oops = printf;  /* errors to printf */

    tn = tpl_map("A(i#i#)", i, TEST_LEN1, j, TEST_LEN2);
    for(y=0; y < 2; y++) {
        for(x=0; x < TEST_LEN1; x++) i[x] += 1;
        for(x=0; x < TEST_LEN2; x++) j[x] -= 1;
        tpl_pack(tn,1);
    }
    tpl_dump(tn,TPL_FILE,"/tmp/test69.tpl");
    tpl_free(tn);

    tn = tpl_map("A(i#i#)", i2, TEST_LEN1, j2, TEST_LEN2);
    tpl_load(tn,TPL_FILE,"/tmp/test69.tpl");
    while (tpl_unpack(tn,1) > 0) {
        for(x=0; x < TEST_LEN1; x++) printf("%d ", i2[x]);
        printf("\n");
        for(x=0; x < TEST_LEN2; x++) printf("%d ", j2[x]);
        printf("\n");
    }
    tpl_free(tn);
    return(0);
}