Asterisk - The Open Source Telephony Project GIT-master-a358458
ham84.c
Go to the documentation of this file.
1/*
2
3$Log$
4Revision 1.15 2004/06/26 03:50:14 markster
5Merge source cleanups (bug #1911)
6
7Revision 1.14 2003/02/12 13:59:15 matteo
8mer feb 12 14:56:57 CET 2003
9
10Revision 1.1.1.1 2003/02/12 13:59:15 matteo
11mer feb 12 14:56:57 CET 2003
12
13Revision 1.2 2000/01/05 08:20:39 markster
14Some OSS fixes and a few lpc changes to make it actually work
15
16 * Revision 1.1 1996/08/19 22:32:07 jaf
17 * Initial revision
18 *
19
20*/
21
22/* -- translated by f2c (version 19951025).
23 You must link the resulting object file with the libraries:
24 -lf2c -lm (in that order)
25*/
26
27#include "f2c.h"
28
29#ifdef P_R_O_T_O_T_Y_P_E_S
30extern int ham84_(integer *input, integer *output, integer *errcnt);
31#endif
32
33/* ***************************************************************** */
34
35/* HAM84 Version 45G */
36
37/* $Log$
38 * Revision 1.15 2004/06/26 03:50:14 markster
39 * Merge source cleanups (bug #1911)
40 *
41 * Revision 1.14 2003/02/12 13:59:15 matteo
42 * mer feb 12 14:56:57 CET 2003
43 *
44 * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
45 * mer feb 12 14:56:57 CET 2003
46 *
47 * Revision 1.2 2000/01/05 08:20:39 markster
48 * Some OSS fixes and a few lpc changes to make it actually work
49 *
50 * Revision 1.1 1996/08/19 22:32:07 jaf
51 * Initial revision
52 * */
53/* Revision 1.3 1996/03/21 15:26:00 jaf */
54/* Put comment header in standard form. */
55
56/* Revision 1.2 1996/03/13 22:00:13 jaf */
57/* Comments added explaining that none of the local variables of this */
58/* subroutine need to be saved from one invocation to the next. */
59
60/* Revision 1.1 1996/02/07 14:47:04 jaf */
61/* Initial revision */
62
63
64/* ***************************************************************** */
65
66/* Hamming 8,4 Decoder - can correct 1 out of seven bits */
67/* and can detect up to two errors. */
68
69/* Input: */
70/* INPUT - Seven bit data word, 4 bits parameter and */
71/* 4 bits parity information */
72/* Input/Output: */
73/* ERRCNT - Sums errors detected by Hamming code */
74/* Output: */
75/* OUTPUT - 4 corrected parameter bits */
76
77/* This subroutine is entered with an eight bit word in INPUT. The 8th */
78/* bit is parity and is stripped off. The remaining 7 bits address the */
79/* hamming 8,4 table and the output OUTPUT from the table gives the 4 */
80/* bits of corrected data. If bit 4 is set, no error was detected. */
81/* ERRCNT is the number of errors counted. */
82
83/* This subroutine has no local state. */
84
85/* Subroutine */ int ham84_(integer *input, integer *output, integer *errcnt)
86{
87 /* Initialized data */
88
89 static integer dactab[128] = { 16,0,0,3,0,5,14,7,0,9,14,11,14,13,30,14,0,
90 9,2,7,4,7,7,23,9,25,10,9,12,9,14,7,0,5,2,11,5,21,6,5,8,11,11,27,
91 12,5,14,11,2,1,18,2,12,5,2,7,12,9,2,11,28,12,12,15,0,3,3,19,4,13,
92 6,3,8,13,10,3,13,29,14,13,4,1,10,3,20,4,4,7,10,9,26,10,4,13,10,15,
93 8,1,6,3,6,5,22,6,24,8,8,11,8,13,6,15,1,17,2,1,4,1,6,15,8,1,10,15,
94 12,15,15,31 };
95
96 integer i__, j, parity;
97
98/* Arguments */
99/* Parameters/constants */
100/* Local variables that need not be saved */
101/* Determine parity of input word */
102 parity = *input & 255;
103 parity ^= parity / 16;
104 parity ^= parity / 4;
105 parity ^= parity / 2;
106 parity &= 1;
107 i__ = dactab[*input & 127];
108 *output = i__ & 15;
109 j = i__ & 16;
110 if (j != 0) {
111/* No errors detected in seven bits */
112 if (parity != 0) {
113 ++(*errcnt);
114 }
115 } else {
116/* One or two errors detected */
117 ++(*errcnt);
118 if (parity == 0) {
119/* Two errors detected */
120 ++(*errcnt);
121 *output = -1;
122 }
123 }
124 return 0;
125} /* ham84_ */
static int input(yyscan_t yyscanner)
Definition: ast_expr2f.c:1570
int ham84_(integer *input, integer *output, integer *errcnt)
Definition: ham84.c:85
INT32 integer
Definition: lpc10.h:80