3 * Parse field descriptions
5 * (c) 2004 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 /*----- Header files ------------------------------------------------------*/
32 /*----- Main code ---------------------------------------------------------*/
34 /* --- @field_parse@ --- *
36 * Arguments: @qd_parse *qd@ = parser context
38 * Returns: Field pointer if OK, or null.
40 * Use: Parses a field description, which has the form
42 * * `prime', `niceprime' or `binpoly'
47 field *field_parse(qd_parse *qd)
50 mp *m = MP_NEW, *b = MP_NEW;
52 switch (qd_enum(qd, "prime,niceprime,binpoly,binnorm")) {
55 if ((m = qd_getmp(qd)) == 0) goto done;
60 if ((m = qd_getmp(qd)) == 0) goto done;
61 f = field_niceprime(m);
65 if ((m = qd_getmp(qd)) == 0) goto done;
70 if ((m = qd_getmp(qd)) == 0) goto done;
72 if ((b = qd_getmp(qd)) == 0) goto done;
73 f = field_binnorm(m, b);
78 if (!f) qd->e = "bad field parameters";
85 /*----- That's all, folks -------------------------------------------------*/