comment.c
来自「speech signal process tools」· C语言 代码 · 共 88 行
C
88 行
/* comment - read/write comment field from an SPS file. This material contains proprietary software of Entropic Processing, Inc. Any reproduction, distribution, or publication without the the prior written permission of Entropic Processing, Inc. is strictly prohibited. Any public distribution of copies of this work authorized in writing by Entropic Processing, Inc. must bear the notice "Copyright 1986 Entropic Processing, Inc."*/ #ifdef SCCS static char *sccs_id = "@(#)comment.c 1.3 10/12/86 EPI"; #endif#include <stdio.h>#include <sps/sps.h>#define SYNTAX USAGE ("comment: [-a comfile] spsfile\n")main (argc, argv)char **argv;int argc;{ int getopt (), c, aflag = 0, i; extern optind; extern char *optarg, *mktemp(), *ctime(); long time(), tloc; FILE *in, *out, *tstrm, *comment, *fopen(); struct header *ih; char *template = "/usr/tmp/cmtXXXXXX", buf[1000], *comfile; void com_err(); while ((c = getopt (argc, argv, "a:")) != EOF) { switch (c) { case 'a': aflag++; comfile = optarg; break; } } if (argc - optind < 1) SYNTAX; TRYOPEN (argv[0], argv[optind], "r", in); if (!(ih = read_header (in))) NOTSPS (argv[0], argv[optind]); tloc = time(0); if (aflag) { if (strcmp (comfile, "-") == 0) { (void) printf ("%s: enter comment, end with EOF\n", argv[0]); comment = stdin; } else TRYOPEN (argv[0], comfile, "r", comment); if ((tstrm = fopen (mktemp (template), "w")) == NULL) CANTOPEN (argv[0], template); if(!add_comment(ih,"comment added: ")) com_err(argv[0]); if(!add_comment(ih,ctime(&tloc))) com_err(argv[0]); while (fgets (buf, sizeof buf, comment) != NULL) if (!add_comment (ih, buf)) com_err(argv[0]); (void) write_header (ih, tstrm); while ((c = getc (in)) != EOF) putc (c, tstrm); (void) fclose (tstrm); (void) fclose (in); tstrm=fopen(template,"r"); (void) unlink(template); out=fopen(argv[optind],"w"); while ((c = getc(tstrm)) != EOF) putc (c, out); (void) unlink(tstrm); exit(0); } for (i = 0; ih -> variable.comment[i] != NULL; (void) putchar(ih -> variable.comment[i++])); if((ih->variable.comment != NULL) && ih->variable.comment[strlen(ih->variable.comment)-1] != '\n') (void) putchar('\n'); exit(0);}voidcom_err(name)char *name;{ fprintf(stderr,"%s: error adding comment, probably too large.",name); exit(1);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?