Move lib to the root.
[libradsec.git] / radius / examples / nr_vp_create.c
1 /*
2  * The person or persons who have associated work with this document
3  * (the "Dedicator" or "Certifier") hereby either (a) certifies that,
4  * to the best of his knowledge, the work of authorship identified is
5  * in the public domain of the country from which the work is
6  * published, or (b) hereby dedicates whatever copyright the
7  * dedicators holds in the work of authorship identified below (the
8  * "Work") to the public domain. A certifier, moreover, dedicates any
9  * copyright interest he may have in the associated work, and for
10  * these purposes, is described as a "dedicator" below.
11  *
12  * A certifier has taken reasonable steps to verify the copyright
13  * status of this work. Certifier recognizes that his good faith
14  * efforts may not shield him from liability if in fact the work
15  * certified is not in the public domain.
16  *
17  * Dedicator makes this dedication for the benefit of the public at
18  * large and to the detriment of the Dedicator's heirs and
19  * successors. Dedicator intends this dedication to be an overt act of
20  * relinquishment in perpetuity of all present and future rights under
21  * copyright law, whether vested or contingent, in the Work. Dedicator
22  * understands that such relinquishment of all rights includes the
23  * relinquishment of all rights to enforce (by lawsuit or otherwise)
24  * those copyrights in the Work.
25  *
26  * Dedicator recognizes that, once placed in the public domain, the
27  * Work may be freely reproduced, distributed, transmitted, used,
28  * modified, built upon, or otherwise exploited by anyone for any
29  * purpose, commercial or non-commercial, and in any way, including by
30  * methods that have not yet been invented or conceived.
31  */
32
33 static VALUE_PAIR *example_nr_vp_create(void)
34 {
35         VALUE_PAIR *vp;
36         VALUE_PAIR *head = NULL;
37
38         /*
39          *      Create the request contents.
40          */
41         vp = nr_vp_create(PW_USER_NAME, 0, "bob", 4);
42         if (!vp) {
43                 fprintf(stderr, "User-Name: %s\n", nr_strerror(0));
44                 exit(1);
45         }
46         nr_vps_append(&head, vp);
47
48         /*
49          *      The User-Password attribute is automatically encrypted
50          *      when being placed in the packet.  This version stays
51          *      untouched, and should be "plain text".
52          */
53         vp = nr_vp_create(PW_USER_PASSWORD, 0, "hello", 6);
54         if (!vp) {
55                 fprintf(stderr, "User-Password: %s\n", nr_strerror(0));
56                 exit(1);
57         }
58         nr_vps_append(&head, vp);
59
60         return head;
61 }