• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
3  * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
4  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
5  */
6 
7 /*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/gsm2cod.c,v 1.1 1994/10/21 20:52:11 jutta Exp $*/
8 
9 #include <stdio.h>
10 #include <assert.h>
11 
12 #include	"gsm.h"
13 #include	"proto.h"
14 
15 char  * pname;
16 
17 int	debug      = 0;
18 int	verbosity  = 0;
19 int	error      = 0;
20 
P0()21 usage P0()
22 {
23 	fprintf(stderr, "Usage: %s [files...]\n", pname);
24 	exit(1);
25 }
26 
27 void process P2((f, filename), FILE * f, char * filename)
28 {
29 	gsm_frame	buf;
30 	gsm_signal	source[76];
31 
32 	int		cc;
33 	gsm		r;
34 	int		nr=0;
35 
36 	(void)memset(source, 0, sizeof(source));
37 
38 	if (!(r = gsm_create())) {
39 		perror("gsm_create");
40 		error = 1;
41 		return ;
42 	}
43 	gsm_option(r, GSM_OPT_VERBOSE, &verbosity);
44 	for (;;) {
45 		cc = fread((char *)buf, sizeof(buf), 1, f);
46 		if (cc == 0) {
47 			gsm_destroy(r);
48 			return;
49 		}
50 		if (cc != 1) {
51 			error = 1;
52 			fprintf(stderr,
53 				"%s: %s -- trailing bytes ignored\n",
54 				pname, filename);
55 			gsm_destroy(r);
56 			return;
57 		}
58 
59 		gsm_explode(r, buf, source);
60 		if (write(1, (char *)source, sizeof(source))!= sizeof(source)) {
61 
62 			perror("write");
63 			error = 1;
64 			gsm_destroy(r);
65 			return;
66 		}
67 	}
68 }
69 
70 main P2((ac, av), int ac, char ** av)
71 {
72 	int 		opt;
73 	extern char   * optarg;
74 	extern int	optind;
75 
76 	FILE		* f;
77 
78 	if (!(pname = av[0])) pname = "gsm2cod";
79 
80 	ac--;
81 	av++;
82 
83 	if (!ac) process(stdin, "*stdin*");
84 	else for (; *av; av++) {
85 		if (!(f = fopen(*av, "r"))) perror(*av);
86 		else {
87 			process(f, *av);
88 			fclose(f);
89 		}
90 	}
91 
92 	exit(error);
93 }
94