1
0

acd.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <bio.h>
  12. #include <disk.h>
  13. #include <auth.h>
  14. #include <fcall.h>
  15. #include <thread.h>
  16. #include <9p.h>
  17. /* acme */
  18. typedef struct Event Event;
  19. typedef struct Window Window;
  20. enum
  21. {
  22. STACK = 16384,
  23. EVENTSIZE = 256,
  24. NEVENT = 5,
  25. };
  26. struct Event
  27. {
  28. int c1;
  29. int c2;
  30. int q0;
  31. int q1;
  32. int flag;
  33. int nb;
  34. int nr;
  35. char b[EVENTSIZE*UTFmax+1];
  36. Rune r[EVENTSIZE+1];
  37. };
  38. struct Window
  39. {
  40. /* file descriptors */
  41. int ctl;
  42. int event;
  43. int addr;
  44. int data;
  45. Biobuf *body;
  46. /* event input */
  47. char buf[512];
  48. char *bufp;
  49. int nbuf;
  50. Event e[NEVENT];
  51. int id;
  52. int open;
  53. Channel *cevent; /* chan(Event*) */
  54. };
  55. extern Window* newwindow(void);
  56. extern int winopenfile(Window*, char*);
  57. extern void winopenbody(Window*, int);
  58. extern void winclosebody(Window*);
  59. extern void wintagwrite(Window*, char*, int);
  60. extern void winname(Window*, char*);
  61. extern void winwriteevent(Window*, Event*);
  62. extern void winread(Window*, uint, uint, char*);
  63. extern int windel(Window*, int);
  64. extern void wingetevent(Window*, Event*);
  65. extern void wineventproc(void*);
  66. extern void winwritebody(Window*, char*, int);
  67. extern void winclean(Window*);
  68. extern int winselect(Window*, char*, int);
  69. extern int winsetaddr(Window*, char*, int);
  70. extern char* winreadbody(Window*, int*);
  71. extern void windormant(Window*);
  72. extern void winsetdump(Window*, char*, char*);
  73. extern char* readfile(char*, char*, int*);
  74. extern void ctlprint(int, char*, ...);
  75. extern void* emalloc(uint);
  76. extern char* estrdup(char*);
  77. extern char* estrstrdup(char*, char*);
  78. extern char* egrow(char*, char*, char*);
  79. extern char* eappend(char*, char*, char*);
  80. extern void error(char*, ...);
  81. extern int tokenizec(char*, char**, int, char*);
  82. /* cd stuff */
  83. typedef struct Msf Msf; /* minute, second, frame */
  84. struct Msf {
  85. int m;
  86. int s;
  87. int f;
  88. };
  89. typedef struct Track Track;
  90. struct Track {
  91. Msf start;
  92. Msf end;
  93. uint32_t bstart;
  94. uint32_t bend;
  95. char *title;
  96. };
  97. enum {
  98. MTRACK = 64,
  99. };
  100. typedef struct Toc Toc;
  101. struct Toc {
  102. int ntrack;
  103. int nchange;
  104. int changetime;
  105. int track0;
  106. Track track[MTRACK];
  107. char *title;
  108. };
  109. extern int msfconv(Fmt*);
  110. #pragma varargck argpos error 1
  111. #pragma varargck argpos ctlprint 2
  112. #pragma varargck type "M" Msf
  113. enum { /* state */
  114. Sunknown,
  115. Splaying,
  116. Spaused,
  117. Scompleted,
  118. Serror,
  119. };
  120. typedef struct Cdstatus Cdstatus;
  121. struct Cdstatus {
  122. int state;
  123. int track;
  124. int index;
  125. Msf abs;
  126. Msf rel;
  127. };
  128. typedef struct Drive Drive;
  129. struct Drive {
  130. Window *w;
  131. Channel *cstatus; /* chan(Cdstatus) */
  132. Channel *ctocdisp; /* chan(Toc) */
  133. Channel *cdbreq; /* chan(Toc) */
  134. Channel *cdbreply; /* chan(Toc) */
  135. Scsi *scsi;
  136. Toc toc;
  137. Cdstatus status;
  138. };
  139. int gettoc(Scsi*, Toc*);
  140. void drawtoc(Window*, Drive*, Toc*);
  141. void redrawtoc(Window*, Toc*);
  142. void tocproc(void*); /* Drive* */
  143. void cddbproc(void*); /* Drive* */
  144. void cdstatusproc(void*); /* Drive* */
  145. extern int debug;
  146. #define DPRINT if(debug)fprint
  147. void acmeevent(Drive*, Window*, Event*);
  148. int playtrack(Drive*, int, int);
  149. int pause(Drive*);
  150. int resume(Drive*);
  151. int stop(Drive*);
  152. int eject(Drive*);
  153. int ingest(Drive*);
  154. int markplay(Window*, uint32_t);
  155. int setplaytime(Window*, char*);
  156. void advancetrack(Drive*, Window*);