btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / kits / textencoding / CharacterSetRoster.cpp
blob7c5f044477968bf482664898bcd51ac8284cac77
1 #include <string.h>
2 #include <strings.h>
3 #include <CharacterSet.h>
4 #include <CharacterSetRoster.h>
5 #include "character_sets.h"
7 namespace BPrivate {
9 BCharacterSetRoster::BCharacterSetRoster()
11 index = 0;
14 BCharacterSetRoster::~BCharacterSetRoster()
16 // nothing to do
19 status_t
20 BCharacterSetRoster::GetNextCharacterSet(BCharacterSet * charset)
22 if (charset == 0) {
23 return B_BAD_VALUE;
25 if (index >= character_sets_by_id_count) {
26 return B_BAD_VALUE;
28 *charset = *character_sets_by_id[index++];
29 return B_NO_ERROR;
32 status_t
33 BCharacterSetRoster::RewindCharacterSets()
35 index = 0;
36 if (index >= character_sets_by_id_count) {
37 return B_BAD_VALUE;
39 return B_NO_ERROR;
42 status_t
43 BCharacterSetRoster::StartWatching(BMessenger target)
45 // TODO: implement it
46 return B_ERROR;
49 status_t
50 BCharacterSetRoster::StopWatching(BMessenger target)
52 // TODO: implement it
53 return B_ERROR;
56 const BCharacterSet *
57 BCharacterSetRoster::GetCharacterSetByFontID(uint32 id)
59 if ((id < 0) || (id >= character_sets_by_id_count)) {
60 return NULL;
62 return character_sets_by_id[id];
65 const BCharacterSet *
66 BCharacterSetRoster::GetCharacterSetByConversionID(uint32 id)
68 if ((id+1 < 0) || (id+1 >= character_sets_by_id_count)) {
69 return NULL;
71 return character_sets_by_id[id+1];
74 const BCharacterSet *
75 BCharacterSetRoster::GetCharacterSetByMIBenum(uint32 MIBenum)
77 if ((MIBenum < 0) || (MIBenum > maximum_valid_MIBenum)) {
78 return NULL;
80 return character_sets_by_MIBenum[MIBenum];
83 const BCharacterSet *
84 BCharacterSetRoster::FindCharacterSetByPrintName(const char * name)
86 for (uint id = 0 ; (id < character_sets_by_id_count) ; id++) {
87 if (strcmp(character_sets_by_id[id]->GetPrintName(),name) == 0) {
88 return character_sets_by_id[id];
91 return 0;
94 const BCharacterSet *
95 BCharacterSetRoster::FindCharacterSetByName(const char * name)
97 // first search standard names and mime names
98 for (uint id = 0 ; (id < character_sets_by_id_count) ; id++) {
99 if (strcasecmp(character_sets_by_id[id]->GetName(),name) == 0) {
100 return character_sets_by_id[id];
102 const char * mime = character_sets_by_id[id]->GetMIMEName();
103 if ((mime != NULL) && (strcasecmp(mime,name) == 0)) {
104 return character_sets_by_id[id];
107 // only after searching all the above names do we look at aliases
108 for (uint id = 0 ; (id < character_sets_by_id_count) ; id++) {
109 for (int alias = 0 ; (alias < character_sets_by_id[id]->CountAliases()) ; alias++) {
110 if (strcasecmp(character_sets_by_id[id]->AliasAt(alias),name) == 0) {
111 return character_sets_by_id[id];
115 return 0;