| 217 | | #endif |
| | 217 | |
| | 218 | } while(0); |
| | 219 | default: |
| | 220 | assert(0); |
| | 221 | } |
| | 222 | return 0; |
| | 223 | } |
| | 224 | /* }}} */ |
| | 225 | static inline int xc_entry_has_prefix_dmz(xc_entry_t *entry, zval *prefix) /* {{{ */ |
| | 226 | { |
| | 227 | /* this function isn't required but can be in dmz */ |
| | 228 | |
| | 229 | switch (entry->type) { |
| | 230 | case XC_TYPE_PHP: |
| | 231 | case XC_TYPE_VAR: |
| | 232 | do { |
| | 233 | #ifdef IS_UNICODE |
| | 234 | if (entry->name_type != prefix->type) { |
| | 235 | return 0; |
| | 236 | } |
| | 237 | |
| | 238 | if (entry->name_type == IS_UNICODE) { |
| | 239 | if (entry->name.ustr.len < Z_USTRLEN_P(prefix)) { |
| | 240 | return 0; |
| | 241 | } |
| | 242 | return memcmp(entry->name.ustr.val, Z_USTRVAL_P(prefix), Z_USTRLEN_P(prefix) * sizeof(UChar)) == 0; |
| | 243 | } |
| | 244 | #endif |
| | 245 | if (prefix->type != IS_STRING) { |
| | 246 | return 0; |
| | 247 | } |
| | 248 | |
| | 249 | if (entry->name.str.len < Z_STRLEN_P(prefix)) { |
| | 250 | return 0; |
| | 251 | } |
| | 252 | |
| | 253 | return memcmp(entry->name.str.val, Z_STRVAL_P(prefix), Z_STRLEN_P(prefix)) == 0; |
| | 2694 | /* {{{ proto bool xcache_unset_by_prefix(string prefix) |
| | 2695 | Unset existing data in cache by specified prefix */ |
| | 2696 | PHP_FUNCTION(xcache_unset_by_prefix) |
| | 2697 | { |
| | 2698 | zval *prefix; |
| | 2699 | int i, iend; |
| | 2700 | |
| | 2701 | if (!xc_var_caches) { |
| | 2702 | VAR_DISABLED_WARNING(); |
| | 2703 | RETURN_FALSE; |
| | 2704 | } |
| | 2705 | |
| | 2706 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &prefix) == FAILURE) { |
| | 2707 | return; |
| | 2708 | } |
| | 2709 | |
| | 2710 | for (i = 0, iend = xc_var_hcache.size; i < iend; i ++) { |
| | 2711 | xc_cache_t *cache = xc_var_caches[i]; |
| | 2712 | ENTER_LOCK(cache) { |
| | 2713 | int j, jend; |
| | 2714 | for (j = 0, jend = cache->hentry->size; j < jend; j ++) { |
| | 2715 | xc_entry_t *entry, *next; |
| | 2716 | for (entry = cache->entries[j]; entry; entry = next) { |
| | 2717 | next = entry->next; |
| | 2718 | if (xc_entry_has_prefix_dmz(entry, prefix)) { |
| | 2719 | xc_entry_remove_dmz(entry TSRMLS_CC); |
| | 2720 | } |
| | 2721 | } |
| | 2722 | } |
| | 2723 | } LEAVE_LOCK(cache); |
| | 2724 | } |
| | 2725 | } |
| | 2726 | /* }}} */ |