Back to index

wims  3.65+svn20090927
Defines | Functions | Variables
cyclicode.c File Reference
#include "../wims.h"

Go to the source code of this file.


#define MAX_DEGREE   256
#define MAX_LENGTH   1024000


void errorquit (char *msg)
char * find_word_end (char *p)
char * find_word_start (char *p)
int main (int argc, char *argv[])


int ch
int degree
int length
char poly [MAX_DEGREE]
char chain [MAX_DEGREE]

Define Documentation

#define MAX_DEGREE   256

Definition at line 30 of file cyclicode.c.

#define MAX_LENGTH   1024000

Definition at line 31 of file cyclicode.c.

Function Documentation

void errorquit ( char *  msg)

Definition at line 36 of file cyclicode.c.

    fprintf(stderr,"%s\n",msg); exit(1);

Here is the caller graph for this function:

char* find_word_end ( char *  p)

Definition at line 42 of file cyclicode.c.

    int i;
    for(i=0;!isspace(*p) && *p!=0 && i<MAX_LINELEN; p++,i++);
    return p;
char* find_word_start ( char *  p)

Definition at line 50 of file cyclicode.c.

    int i;
    for(i=0; isspace(*p) && i<MAX_LINELEN; p++,i++);
    return p;
int main ( int  argc,
char *  argv[] 

Definition at line 57 of file cyclicode.c.

    char *parm, *p1, *p2, c1, c2;
    char pbuf[1024];
    int i,j,k;
    double dt;
    if(parm==NULL || *parm==0) errorquit("no_parameter");
    p1=find_word_start(pbuf); p2=find_word_end(p1);
    if(*p2!=0) *p2++=0;
    ch=atoi(p1); p1=find_word_start(p2);
    if(ch!=2 && ch!=3 && ch!=5 && ch!=7) errorquit("bad_characteristics");
    p2=find_word_end(p1); if(*p2!=0) *p2++=0;
    p2=find_word_start(p2); *find_word_end(p2)=0;
    if(degree!=strlen(p2)) errorquit("unequal_degrees");
    if(degree>MAX_DEGREE) errorquit("degree_too_high");
    if(dt>=(double) MAX_LENGTH) errorquit("length_overflow");
    for(i=0;i<degree;i++) {
       c1=*(p1+i); c2=*(p2+i);
       if(!isdigit(c1) || c1>=ch+'0') errorquit("bad_polynomial");
       if(!isdigit(c2) || c2>=ch+'0') errorquit("bad_chain");
       poly[i]=ch-(c1-'0'); chain[i]=c2-'0';
    for(i=0;i<length;i++) {
       k%=ch; printf("%d",k);
       memmove(chain,chain+1,degree-1); chain[degree-1]=k;
    return 0;

Here is the call graph for this function:

Variable Documentation

int ch

Definition at line 33 of file cyclicode.c.

Definition at line 34 of file cyclicode.c.

int degree

Definition at line 33 of file cyclicode.c.

int length

Definition at line 33 of file cyclicode.c.

Definition at line 34 of file cyclicode.c.