gsm2cod.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. /*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/gsm2cod.c,v 1.1 1994/10/21 20:52:11 jutta Exp $*/
  7. #include <stdio.h>
  8. #include <assert.h>
  9. #include "gsm.h"
  10. #include "proto.h"
  11. char * pname;
  12. int debug = 0;
  13. int verbosity = 0;
  14. int error = 0;
  15. usage P0()
  16. {
  17. fprintf(stderr, "Usage: %s [files...]\n", pname);
  18. exit(1);
  19. }
  20. void process P2((f, filename), FILE * f, char * filename)
  21. {
  22. gsm_frame buf;
  23. gsm_signal source[76];
  24. int cc;
  25. gsm r;
  26. int nr=0;
  27. (void)memset(source, 0, sizeof(source));
  28. if (!(r = gsm_create())) {
  29. perror("gsm_create");
  30. error = 1;
  31. return ;
  32. }
  33. gsm_option(r, GSM_OPT_VERBOSE, &verbosity);
  34. for (;;) {
  35. cc = fread((char *)buf, sizeof(buf), 1, f);
  36. if (cc == 0) {
  37. gsm_destroy(r);
  38. return;
  39. }
  40. if (cc != 1) {
  41. error = 1;
  42. fprintf(stderr,
  43. "%s: %s -- trailing bytes ignored\n",
  44. pname, filename);
  45. gsm_destroy(r);
  46. return;
  47. }
  48. gsm_explode(r, buf, source);
  49. if (write(1, (char *)source, sizeof(source))!= sizeof(source)) {
  50. perror("write");
  51. error = 1;
  52. gsm_destroy(r);
  53. return;
  54. }
  55. }
  56. }
  57. main P2((ac, av), int ac, char ** av)
  58. {
  59. int opt;
  60. extern char * optarg;
  61. extern int optind;
  62. FILE * f;
  63. if (!(pname = av[0])) pname = "gsm2cod";
  64. ac--;
  65. av++;
  66. if (!ac) process(stdin, "*stdin*");
  67. else for (; *av; av++) {
  68. if (!(f = fopen(*av, "r"))) perror(*av);
  69. else {
  70. process(f, *av);
  71. fclose(f);
  72. }
  73. }
  74. exit(error);
  75. }