« third_party/modest/source/mycss/values/image.c
↑ Summary
third_party/modest/source/mycss/values/values.c »
| 1 | /* | ||||||||||
| 2 | Copyright (C) 2016-2017 Alexander Borisov | ||||||||||
| 3 | |||||||||||
| 4 | This library is free software; you can redistribute it and/or | ||||||||||
| 5 | modify it under the terms of the GNU Lesser General Public | ||||||||||
| 6 | License as published by the Free Software Foundation; either | ||||||||||
| 7 | version 2.1 of the License, or (at your option) any later version. | ||||||||||
| 8 | |||||||||||
| 9 | This library is distributed in the hope that it will be useful, | ||||||||||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||
| 12 | Lesser General Public License for more details. | ||||||||||
| 13 | |||||||||||
| 14 | You should have received a copy of the GNU Lesser General Public | ||||||||||
| 15 | License along with this library; if not, write to the Free Software | ||||||||||
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||||||||
| 17 | |||||||||||
| 18 | Author: lex.borisov@gmail.com (Alexander Borisov) | ||||||||||
| 19 | */ | ||||||||||
| 20 | |||||||||||
| 21 | #include "mycss/values/units.h" | ||||||||||
| 22 | #include "mycss/values/units_resources.h" | ||||||||||
| 23 | #include "mycore/utils/resources.h" | ||||||||||
| 24 | |||||||||||
| 25 | 0 | const mycss_units_index_static_entry_t * mycss_units_index_entry_by_name(const char* name, size_t length) | |||||||||
| 26 | { | ||||||||||
| 27 | 0 | ▶ | if(length == 0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | return NULL; | |||||||||
| 29 | |||||||||||
| 30 | 0 | size_t idx = ((mycore_string_chars_lowercase_map[ (const unsigned char)name[0] ] * | |||||||||
| 31 | 0 | mycore_string_chars_lowercase_map[ (const unsigned char)name[(length - 1)] ] * | |||||||||
| 32 | length) | ||||||||||
| 33 | 0 | % MyCSS_UNITS_STATIC_INDEX_FOR_SEARCH_SIZE) + 1; | |||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | while (mycss_units_index_static_for_search[idx].name) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | { | ||||||||||
| 37 | 0 | ▶ | if(mycss_units_index_static_for_search[idx].name_length == length) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | ▶ | if(mycore_strncasecmp(mycss_units_index_static_for_search[idx].name, name, length) == 0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | return &mycss_units_index_static_for_search[idx]; | |||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | if(mycss_units_index_static_for_search[idx].next) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | idx = mycss_units_index_static_for_search[idx].next; | |||||||||
| 43 | else | ||||||||||
| 44 | 0 | return NULL; | |||||||||
| 45 | } | ||||||||||
| 46 | 0 | ▶ | else if(mycss_units_index_static_for_search[idx].name_length > length) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | return NULL; | |||||||||
| 48 | } | ||||||||||
| 49 | else { | ||||||||||
| 50 | 0 | idx = mycss_units_index_static_for_search[idx].next; | |||||||||
| 51 | } | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 0 | return NULL; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 0 | mycss_units_type_t mycss_units_type_by_name(const char *name, size_t length) | |||||||||
| 58 | { | ||||||||||
| 59 | 0 | const mycss_units_index_static_entry_t *entry = mycss_units_index_entry_by_name(name, length); | |||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | if(entry) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | return entry->unit_type; | |||||||||
| 63 | |||||||||||
| 64 | 0 | return MyCSS_UNIT_TYPE_UNDEF; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 0 | const char * mycss_units_name_by_type(mycss_units_type_t unit_type) | |||||||||
| 68 | { | ||||||||||
| 69 | 0 | ▶ | if(unit_type >= MyCSS_UNIT_TYPE_LAST_ENTRY) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | return NULL; | |||||||||
| 71 | |||||||||||
| 72 | 0 | return mycss_units_index_name[unit_type]; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||