📄 extract.c
字号:
/* EXTRACT.C - Extract message bits from coded blocks. *//* Copyright (c) 2000 by Radford M. Neal * * Permission is granted for anyone to copy, use, or modify this program * for purposes of research or education, provided this copyright notice * is retained, and note is made of any changes that have been made. * * This program is distributed without any warranty, express or implied. * As this program was written for research purposes only, it has not been * tested to the degree that would be advisable in any important application. * All use of this program is entirely at the user's own risk. */#include <stdio.h>#include <stdlib.h>#include <math.h>#include "alloc.h"#include "blockio.h"#include "mod2sparse.h"#include "mod2dense.h"#include "mod2convert.h"#include "rcode.h"void usage(void);/* MAIN PROGRAM. */int main( int argc, char **argv){ char *gen_file, *coded_file, *ext_file; FILE *codef, *extf; char *cblk; int i; /* Look at arguments. */ if (!(gen_file = argv[1]) || !(coded_file = argv[2]) || !(ext_file = argv[3]) || argv[4]) { usage(); } /* Read generator matrix file, up to the point of finding out which are the message bits. */ read_gen(gen_file,1,1); /* Open decoded file. */ codef = fopen(coded_file,"r"); if (codef==NULL) { fprintf(stderr,"Can't open coded file: %s\n",coded_file); exit(1); } /* Open file to write extracted message bits to. */ extf = fopen(ext_file,"w"); if (extf==NULL) { fprintf(stderr,"Can't create file for extracted bits: %s\n",ext_file); exit(1); } cblk = chk_alloc (N, sizeof *cblk); for (;;) { /* Read block from coded file. */ if (blockio_read(codef,cblk,N)==EOF) break; /* Extract message bits and write to file, followed by newline to mark block boundary. */ for (i = M; i<N; i++) { putc("01"[cblk[cols[i]]],extf); } putc('\n',extf); } if (ferror(extf) || fclose(extf)!=0) { fprintf(stderr,"Error writing extracted data to %s\n",ext_file); exit(1); } return 0;}/* PRINT USAGE MESSAGE AND EXIT. */void usage(void){ fprintf(stderr, "Usage: extract gen-file decoded-file extracted-file\n"); exit(1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -