id3_dll_wrapper.cpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. // The authors have released ID3Lib as Public Domain (PD) and claim no copyright,
  2. // patent or other intellectual property protection in this work. This means that
  3. // it may be modified, redistributed and used in commercial and non-commercial
  4. // software and hardware without restrictions. ID3Lib is distributed on an "AS IS"
  5. // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
  6. //
  7. // The ID3Lib authors encourage improvements and optimisations to be sent to the
  8. // ID3Lib coordinator, currently Dirk Mahoney ([email protected]). Approved
  9. // submissions may be altered, and will be included and released under these terms.
  10. //
  11. // Mon Nov 23 18:34:01 1998
  12. #include "id3_tag.h"
  13. #ifdef __DLL
  14. #include <string.h>
  15. struct ID3_VerInfo
  16. {
  17. char name [ 30 ];
  18. luint version,
  19. revision;
  20. };
  21. // misc wrappers
  22. CDLLEXPORT
  23. void ID3_GetVersion ( ID3_VerInfo *info )
  24. {
  25. info->version = ID3LIB_VER;
  26. info->revision = ID3LIB_REV;
  27. strcpy ( info->name, ID3LIB_NAME );
  28. return;
  29. }
  30. // tag wrappers
  31. CDLLEXPORT
  32. ID3_Tag *ID3Tag_New ( void )
  33. {
  34. return new ID3_Tag;
  35. }
  36. CDLLEXPORT
  37. void ID3Tag_Delete ( ID3_Tag *tag )
  38. {
  39. if ( tag )
  40. delete tag;
  41. return;
  42. }
  43. CDLLEXPORT
  44. void ID3Tag_Clear ( ID3_Tag *tag )
  45. {
  46. if ( tag )
  47. tag->Clear();
  48. return;
  49. }
  50. CDLLEXPORT
  51. bool ID3Tag_HasChanged ( ID3_Tag *tag )
  52. {
  53. bool changed = false;
  54. if ( tag )
  55. changed = tag->HasChanged();
  56. return changed;
  57. }
  58. CDLLEXPORT
  59. void ID3Tag_SetUnsync ( ID3_Tag *tag, bool unsync )
  60. {
  61. if ( tag )
  62. tag->SetUnsync ( unsync );
  63. return;
  64. }
  65. CDLLEXPORT
  66. void ID3Tag_SetExtendedHeader ( ID3_Tag *tag, bool ext )
  67. {
  68. if ( tag )
  69. tag->SetExtendedHeader ( ext );
  70. return;
  71. }
  72. CDLLEXPORT
  73. void ID3Tag_SetCompression ( ID3_Tag *tag, bool comp )
  74. {
  75. if ( tag )
  76. tag->SetCompression ( comp );
  77. return;
  78. }
  79. CDLLEXPORT
  80. void ID3Tag_SetPadding ( ID3_Tag *tag, bool pad )
  81. {
  82. if ( tag )
  83. tag->SetPadding ( pad );
  84. return;
  85. }
  86. CDLLEXPORT
  87. void ID3Tag_AddFrame ( ID3_Tag *tag, ID3_Frame *frame )
  88. {
  89. if ( tag )
  90. tag->AddFrame ( frame );
  91. return;
  92. }
  93. CDLLEXPORT
  94. void ID3Tag_AddFrames ( ID3_Tag *tag, ID3_Frame *frames, luint num )
  95. {
  96. if ( tag )
  97. tag->AddFrames ( frames, num );
  98. return;
  99. }
  100. CDLLEXPORT
  101. void ID3Tag_RemoveFrame ( ID3_Tag *tag, ID3_Frame *frame )
  102. {
  103. if ( tag )
  104. tag->RemoveFrame ( frame );
  105. return;
  106. }
  107. CDLLEXPORT
  108. void ID3Tag_Parse ( ID3_Tag *tag, uchar header[ ID3_TAGHEADERSIZE ], uchar *buffer )
  109. {
  110. if ( tag )
  111. tag->Parse ( header, buffer );
  112. return;
  113. }
  114. CDLLEXPORT
  115. luint ID3Tag_Link ( ID3_Tag *tag, char *fileName )
  116. {
  117. luint offset = 0;
  118. if ( tag )
  119. offset = tag->Link ( fileName );
  120. return offset;
  121. }
  122. CDLLEXPORT
  123. void ID3Tag_Update ( ID3_Tag *tag )
  124. {
  125. if ( tag )
  126. tag->Update();
  127. return;
  128. }
  129. CDLLEXPORT
  130. void ID3Tag_Strip ( ID3_Tag *tag, bool v1Also )
  131. {
  132. if ( tag )
  133. tag->Strip ( v1Also );
  134. return;
  135. }
  136. CDLLEXPORT
  137. ID3_Frame *ID3Tag_FindFrameWithID ( ID3_Tag *tag, ID3_FrameID id )
  138. {
  139. ID3_Frame *frame = NULL;
  140. if ( tag )
  141. frame = tag->Find ( id );
  142. return frame;
  143. }
  144. CDLLEXPORT
  145. ID3_Frame *ID3Tag_FindFrameWithINT ( ID3_Tag *tag, ID3_FrameID id, ID3_FieldID fld, luint data )
  146. {
  147. ID3_Frame *frame = NULL;
  148. if ( tag )
  149. frame = tag->Find ( id, fld, data );
  150. return frame;
  151. }
  152. CDLLEXPORT
  153. ID3_Frame *ID3Tag_FindFrameWithASCII ( ID3_Tag *tag, ID3_FrameID id, ID3_FieldID fld, char *data )
  154. {
  155. ID3_Frame *frame = NULL;
  156. if ( tag )
  157. frame = tag->Find ( id, fld, data );
  158. return frame;
  159. }
  160. CDLLEXPORT
  161. ID3_Frame *ID3Tag_FindFrameWithUNICODE ( ID3_Tag *tag, ID3_FrameID id, ID3_FieldID fld, wchar_t *data )
  162. {
  163. ID3_Frame *frame = NULL;
  164. if ( tag )
  165. frame = tag->Find ( id, fld, data );
  166. return frame;
  167. }
  168. CDLLEXPORT
  169. luint ID3Tag_NumFrames ( ID3_Tag *tag )
  170. {
  171. luint num = 0;
  172. if ( tag )
  173. num = tag->NumFrames();
  174. return num;
  175. }
  176. CDLLEXPORT
  177. ID3_Frame *ID3Tag_GetFrameNum ( ID3_Tag *tag, luint num )
  178. {
  179. ID3_Frame *frame = NULL;
  180. if ( tag )
  181. frame = tag->GetFrameNum ( num );
  182. return frame;
  183. }
  184. // frame wrappers
  185. CDLLEXPORT
  186. void ID3Frame_Clear ( ID3_Frame *frame )
  187. {
  188. if ( frame )
  189. frame->Clear();
  190. return;
  191. }
  192. CDLLEXPORT
  193. void ID3Frame_SetID ( ID3_Frame *frame, ID3_FrameID id )
  194. {
  195. if ( frame )
  196. frame->SetID ( id );
  197. return;
  198. }
  199. CDLLEXPORT
  200. ID3_FrameID ID3Frame_GetID ( ID3_Frame *frame )
  201. {
  202. ID3_FrameID id = ID3FID_NOFRAME;
  203. if ( frame )
  204. id = frame->GetID();
  205. return id;
  206. }
  207. CDLLEXPORT
  208. ID3_Field *ID3Frame_GetField ( ID3_Frame *frame, ID3_FieldID name )
  209. {
  210. ID3_Field *field = NULL;
  211. if ( frame )
  212. field = &( frame->Field ( name ) );
  213. return field;
  214. }
  215. // field wrappers
  216. CDLLEXPORT
  217. void ID3Field_Clear ( ID3_Field *field )
  218. {
  219. if ( field )
  220. field->Clear();
  221. return;
  222. }
  223. CDLLEXPORT
  224. luint ID3Field_Size ( ID3_Field *field )
  225. {
  226. luint size = 0;
  227. if ( field )
  228. size = field->Size();
  229. return size;
  230. }
  231. CDLLEXPORT
  232. luint ID3Field_GetNumTextItems ( ID3_Field *field )
  233. {
  234. luint items = 0;
  235. if ( field )
  236. items = field->GetNumTextItems();
  237. return items;
  238. }
  239. CDLLEXPORT
  240. void ID3Field_SetINT ( ID3_Field *field, luint data )
  241. {
  242. if ( field )
  243. field->Set ( data );
  244. return;
  245. }
  246. CDLLEXPORT
  247. luint ID3Field_GetINT ( ID3_Field *field )
  248. {
  249. luint value = 0;
  250. if ( field )
  251. value = field->Get();
  252. return value;
  253. }
  254. CDLLEXPORT
  255. void ID3Field_SetUNICODE ( ID3_Field *field, wchar_t *string )
  256. {
  257. if ( field )
  258. field->Set ( string );
  259. return;
  260. }
  261. CDLLEXPORT
  262. luint ID3Field_GetUNICODE ( ID3_Field *field, wchar_t *buffer, luint maxChars, luint itemNum )
  263. {
  264. luint numChars = 0;
  265. if ( field )
  266. numChars = field->Get ( buffer, maxChars, itemNum );
  267. return numChars;
  268. }
  269. CDLLEXPORT
  270. void ID3Field_AddUNICODE ( ID3_Field *field, wchar_t *string )
  271. {
  272. if ( field )
  273. field->Add ( string );
  274. return;
  275. }
  276. CDLLEXPORT
  277. void ID3Field_SetASCII ( ID3_Field *field, char *string )
  278. {
  279. if ( field )
  280. field->Set ( string );
  281. return;
  282. }
  283. CDLLEXPORT
  284. luint ID3Field_GetASCII ( ID3_Field *field, char *buffer, luint maxChars, luint itemNum )
  285. {
  286. luint numChars = 0;
  287. if ( field )
  288. numChars = field->Get ( buffer, maxChars, itemNum );
  289. return numChars;
  290. }
  291. CDLLEXPORT
  292. void ID3Field_AddASCII ( ID3_Field *field, char *string )
  293. {
  294. if ( field )
  295. field->Add ( string );
  296. return;
  297. }
  298. CDLLEXPORT
  299. void ID3Field_SetBINARY ( ID3_Field *field, uchar *data, luint size )
  300. {
  301. if ( field )
  302. field->Set ( data, size );
  303. return;
  304. }
  305. CDLLEXPORT
  306. void ID3Field_GetBINARY ( ID3_Field *field, uchar *buffer, luint buffLength )
  307. {
  308. if ( field )
  309. field->Get ( buffer, buffLength );
  310. return;
  311. }
  312. CDLLEXPORT
  313. void ID3Field_FromFile ( ID3_Field *field, char *fileName )
  314. {
  315. if ( field )
  316. field->FromFile ( fileName );
  317. return;
  318. }
  319. CDLLEXPORT
  320. void ID3Field_ToFile ( ID3_Field *field, char *fileName )
  321. {
  322. if ( field )
  323. field->ToFile ( fileName );
  324. return;
  325. }
  326. #endif