Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cuebreakpoints.c 2.1 KiB

20 anos atrás
20 anos atrás
20 anos atrás
20 anos atrás
20 anos atrás
20 anos atrás
20 anos atrás
20 anos atrás
20 anos atrás
20 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * cuebreakpoints.c -- print track break points
  3. *
  4. * Copyright (C) 2004 Svend Sorensen
  5. * For license terms, see the file COPYING in this distribution.
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <getopt.h>
  11. #include "cuefile.h"
  12. #include "time.h"
  13. char *progname;
  14. void usage (int status)
  15. {
  16. if (0 == status) {
  17. fprintf(stdout, "%s: usage: cuebreakpoints [option...] [file...]\n", progname);
  18. fputs("\
  19. \n\
  20. OPTIONS\n\
  21. -h, --help print usage\n\
  22. -i, --input-format cue|toc set format of file(s)\n\
  23. ", stdout);
  24. } else {
  25. fprintf(stderr, "run `%s --help' for usage\n", progname);
  26. }
  27. exit (status);
  28. }
  29. void print_m_ss_ff (long frame)
  30. {
  31. int m, s, f;
  32. time_frame_to_msf(frame, &m, &s, &f);
  33. printf ("%d:%02d.%02d\n", m, s, f);
  34. }
  35. void print_breaks (Cd *cd)
  36. {
  37. int i;
  38. long b;
  39. Track *track;
  40. for (i = 1; i <= cd_get_ntrack(cd); i++) {
  41. track = cd_get_track(cd, i);
  42. /* don't print zero indexes */
  43. b = track_get_start(track) + track_get_index(track, 1) - track_get_zero_pre(track);
  44. if (0 != b)
  45. print_m_ss_ff(b);
  46. }
  47. }
  48. int breaks (char *name, int format)
  49. {
  50. Cd *cd = NULL;
  51. if (NULL == (cd = cf_parse(name, &format))) {
  52. fprintf(stderr, "%s: input file error\n", name);
  53. return -1;
  54. }
  55. print_breaks(cd);
  56. return 0;
  57. }
  58. int main (int argc, char **argv)
  59. {
  60. int format = UNKNOWN;
  61. /* option variables */
  62. char c;
  63. /* getopt_long() variables */
  64. extern char *optarg;
  65. extern int optind;
  66. static struct option longopts[] = {
  67. {"help", no_argument, NULL, 'h'},
  68. {"input-format", required_argument, NULL, 'i'},
  69. {NULL, 0, NULL, 0}
  70. };
  71. progname = *argv;
  72. while (-1 != (c = getopt_long(argc, argv, "hi:", longopts, NULL))) {
  73. switch (c) {
  74. case 'h':
  75. usage(0);
  76. break;
  77. case 'i':
  78. if (0 == strcmp("cue", optarg))
  79. format = CUE;
  80. else if (0 == strcmp("toc", optarg))
  81. format = TOC;
  82. else
  83. fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
  84. usage(1);
  85. break;
  86. default:
  87. usage(1);
  88. break;
  89. }
  90. }
  91. if (optind == argc) {
  92. breaks("-", format);
  93. } else {
  94. for (; optind < argc; optind++)
  95. breaks(argv[optind], format);
  96. }
  97. return 0;
  98. }