acd.h 3.1 KB

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