1m4_ignore([dnl
2#include <sys/types.h>
3#include <string.h>
4
5#include <db.h>
6
7int foo(void);
8
9DB *job_db, *name_db, *pers_db;
10DB_TXN *txn;
11
12int
13main() {
14	foo();
15	return (0);
16}
17
18int
19foo()
20{])
21m4_indent([dnl
22DBC *name_curs, *job_curs, *join_curs;
23DBC *carray__LB__3__RB__;
24DBT key, data;
25int ret, tret;
26m4_blank
27name_curs = NULL;
28job_curs = NULL;
29memset(&key, 0, sizeof(key));
30memset(&data, 0, sizeof(data));
31m4_blank
32if ((ret =
33    name_db-__GT__cursor(name_db, txn, &name_curs, 0)) != 0)
34	goto err;
35key.data = "smith";
36key.size = sizeof("smith");
37if ((ret =
38    name_curs-__GT__c_get(name_curs, &key, &data, DB_SET)) != 0)
39	goto err;
40m4_blank
41if ((ret = job_db-__GT__cursor(job_db, txn, &job_curs, 0)) != 0)
42	goto err;
43key.data = "manager";
44key.size = sizeof("manager");
45if ((ret =
46    job_curs-__GT__c_get(job_curs, &key, &data, DB_SET)) != 0)
47	goto err;
48m4_blank
49carray__LB__0__RB__ = name_curs;
50carray__LB__1__RB__ = job_curs;
51carray__LB__2__RB__ = NULL;
52m4_blank
53if ((ret =
54    pers_db-__GT__join(pers_db, carray, &join_curs, 0)) != 0)
55	goto err;
56while ((ret =
57    join_curs-__GT__c_get(join_curs, &key, &data, 0)) == 0) {
58	/* Process record returned in key/data. */
59}
60m4_blank
61/*
62 * If we exited the loop because we ran out of records,
63 * then it has completed successfully.
64 */
65if (ret == DB_NOTFOUND)
66	ret = 0;
67m4_blank
68err:
69if (join_curs != NULL &&
70    (tret = join_curs-__GT__c_close(join_curs)) != 0 && ret == 0)
71	ret = tret;
72if (name_curs != NULL &&
73    (tret = name_curs-__GT__c_close(name_curs)) != 0 && ret == 0)
74	ret = tret;
75if (job_curs != NULL &&
76    (tret = job_curs-__GT__c_close(job_curs)) != 0 && ret == 0)
77	ret = tret;
78m4_blank
79return (ret);
80])
81m4_ignore([dnl
82}])
83