00001 // $Id: spec.cpp,v 1.1 2000/04/26 03:43:06 eldamitri Exp $ 00002 00003 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags 00004 // Copyright 1999, 2000 Scott Thomas Haug 00005 00006 // This library is free software; you can redistribute it and/or modify it 00007 // under the terms of the GNU Library General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or (at your 00009 // option) any later version. 00010 // 00011 // This library is distributed in the hope that it will be useful, but WITHOUT 00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 // License for more details. 00015 // 00016 // You should have received a copy of the GNU Library General Public License 00017 // along with this library; if not, write to the Free Software Foundation, 00018 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 // The id3lib authors encourage improvements and optimisations to be sent to 00021 // the id3lib coordinator. Please see the README file for details on where to 00022 // send such submissions. See the AUTHORS file for a list of people who have 00023 // contributed to id3lib. See the ChangeLog file for a list of changes to 00024 // id3lib. These files are distributed with id3lib at 00025 // http://download.sourceforge.net/id3lib/ 00026 00027 #if defined HAVE_CONFIG_H 00028 #include <config.h> 00029 #endif 00030 00031 #include "spec.h" 00032 00033 ID3_V2Spec ID3_VerRevToV2Spec(uchar ver, uchar rev) 00034 { 00035 ID3_V2Spec spec = ID3V2_UNKNOWN; 00036 if (2 == ver) 00037 { 00038 if (0 == rev) 00039 { 00040 spec = ID3V2_2_0; 00041 } 00042 else if (1 == rev) 00043 { 00044 spec = ID3V2_2_1; 00045 } 00046 } 00047 else if (3 == ver) 00048 { 00049 if (0 == rev) 00050 { 00051 spec = ID3V2_3_0; 00052 } 00053 } 00054 00055 return spec; 00056 } 00057 00058 uchar ID3_V2SpecToVer(ID3_V2Spec spec) 00059 { 00060 uchar ver = 0; 00061 switch (spec) 00062 { 00063 case ID3V2_2_0: 00064 case ID3V2_2_1: 00065 ver = 2; 00066 break; 00067 case ID3V2_3_0: 00068 ver = 3; 00069 break; 00070 default: 00071 break; 00072 } 00073 return ver; 00074 } 00075 00076 uchar ID3_V2SpecToRev(ID3_V2Spec spec) 00077 { 00078 uchar rev = 0; 00079 switch (spec) 00080 { 00081 case ID3V2_2_0: 00082 case ID3V2_3_0: 00083 rev = 0; 00084 break; 00085 case ID3V2_2_1: 00086 rev = 1; 00087 break; 00088 default: 00089 break; 00090 } 00091 return rev; 00092 } 00093