📄 tag.c
字号:
/************************************************** * * id3tag.c * * CVS ID: $Id: tag.c,v 1.9 2007/09/10 17:57:21 trubac Exp $ * Author: Jiri Sedmik [JS], Leos Longauer [LL] - STM * Date: $Date: 2007/09/10 17:57:21 $ * Revision: $Revision: 1.9 $ * * Description: * * *************************************************** * * COPYRIGHT (C) ST Microelectronics 2005 * All Rights Reserved * **************************************************** * * STM CVS Log: * * $Log: tag.c,v $ * Revision 1.9 2007/09/10 17:57:21 trubac * using another macro name * * Revision 1.8 2007/04/04 07:52:41 trubac * limit max length of ID3v1 to 30 characters * * Revision 1.7 2006/11/25 08:13:03 belardi * Ununsed function removal to free code space * * Revision 1.6 2006/09/27 19:49:32 belardi * Removed (global) unused variables * * Revision 1.5 2006/09/18 09:55:21 belardi * Corrected CVS keyword usage * * Revision 1.4 2006/09/18 09:23:02 belardi * Added Log CVS keyword into file header * * ***************************************************///#include <stdio.h>//#include <stdlib.h>#include <string.h>#include "accordoptypes.h"#include "apdevsys.h"#include "tag.h"// uint8 tag_length = 64; // [RB] unused__align(4) uint8 tag_buf[TAG_BUFFER_LENGTH];void estrcpy(uint8 *dest,uint8 *src,uint16 size){ uint8 i;#ifdef STATIC size = wmin (size,ID3V1_MAX_TEXT_SIZE);#endif for(i = 0; i < size; i++) { dest[i] = (*src++); }}void str_convert_byte2int(uint8 *buffer, uint8 size) //inside buffer expand text8bit encoded to 16bit encoded big endian { uint8 i; for(i = size; i>0; i--) { buffer[(i - 1) * 2 + 1] = buffer[i - 1]; buffer[(i - 1) * 2] = 0x0; } } #if 0 // [RB] unusedvoid str_convert2lsb(uint8 *buffer,uint16 *length) //exchange text to big endian (remove BOM sequences){ uint8 exchange_bytes = 0; //big endian by default uint8 rd_ptr = 0; uint8 wr_ptr = 0; uint8 tmp; //Length is reduced by BOM (FFFE or FEFF) while(1) { if (rd_ptr>=((*length) - 1)) break; if ((buffer[rd_ptr] == 0xFE) && (buffer[rd_ptr+1] == 0xFF)) //BOM Big endian { exchange_bytes = 0; rd_ptr +=2; } if ((buffer[rd_ptr] == 0xFF) && (buffer[rd_ptr+1] == 0xFE)) //BOM Little endian { rd_ptr +=2; exchange_bytes = 1; } if (exchange_bytes) { tmp = buffer[rd_ptr]; buffer[wr_ptr] = buffer[rd_ptr+1]; buffer[wr_ptr+1] = tmp; } else if (wr_ptr!=rd_ptr) { buffer[wr_ptr] = buffer[rd_ptr]; buffer[wr_ptr+1] = buffer[rd_ptr+1]; } rd_ptr+=2; wr_ptr+=2; } if (wr_ptr != rd_ptr) *length = *length - (rd_ptr - wr_ptr); //decrease by BOM length inside text }#endif // 0/* Calulates the length of text. Maximum parameter is maxsize. If maxsize is zero, max is set to limit of variable */uint16 id3_v1_len(uint8 * buffer, uint16 maxsize) { uint16 i=0; if (0 == maxsize) maxsize = 30; for (;i<maxsize;i++) { if (buffer[i]==0) break; } return (i); // return length, which can have maximum value of maxsize }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -