modified: src1/input.c
[GalaxyCodeBases.git] / c_cpp / etc / calc / custom / c_pzasusb8.c
blob929cf968d76f1ec65ad329936afc2521c366e3b4
1 /*
2 * c_pzasusb8 - print numereator as a string of USB8s
4 * Copyright (C) 1999-2004 Ernest Bowen
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: c_pzasusb8.c,v 30.1 2007/03/16 11:10:04 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/custom/RCS/c_pzasusb8.c,v $
24 * Under source code control: 1999/10/06 03:12:25
25 * File existed as early as: 1999
27 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 #if defined(CUSTOM)
33 #include <stdio.h>
35 #include "have_const.h"
36 #include "value.h"
37 #include "custom.h"
38 #include "zmath.h"
40 #include "have_unused.h"
43 * c_pzasusb8 - print numereator as a string of USB8s
45 * given:
46 * count = 1;
47 * vals[0] real number;
49 * returns:
50 * null
52 /*ARGSUSED*/
53 VALUE
54 c_pzasusb8(char UNUSED *name, int UNUSED count, VALUE **vals)
56 VALUE result; /* what we will return */
57 ZVALUE z; /* numerator of the value */
58 long half_cnt; /* number of HALFs in the numerator */
59 USB8 *h; /* octet pointer */
60 long half_len; /* length of a half in octets */
61 long i;
62 long j;
65 * arg check
67 result.v_type = V_NULL;
68 if (vals[0]->v_type != V_NUM) {
69 math_error("Non-real argument for pzasusb8");
70 /*NOTREACHED*/
74 * look at the numerator
76 z = vals[0]->v_num->num;
77 half_len = sizeof(HALF);
78 half_cnt = z.len;
81 * print the octets
83 h = (USB8 *) z.v;
84 for (i=0; i < half_cnt; ++i) {
85 printf("%ld:\t", i);
86 for (j=0; j < half_len; ++j) {
87 printf("%02x", (int)(*h++));
89 putchar('\n');
91 return result;
94 #endif /* CUSTOM */