root/sapi/phpdbg/phpdbg_utils.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. zend_hash_get_current_key_zval_ex

   1 /*
   2    +----------------------------------------------------------------------+
   3    | PHP Version 5                                                        |
   4    +----------------------------------------------------------------------+
   5    | Copyright (c) 1997-2016 The PHP Group                                |
   6    +----------------------------------------------------------------------+
   7    | This source file is subject to version 3.01 of the PHP license,      |
   8    | that is bundled with this package in the file LICENSE, and is        |
   9    | available through the world-wide-web at the following url:           |
  10    | http://www.php.net/license/3_01.txt                                  |
  11    | If you did not receive a copy of the PHP license and are unable to   |
  12    | obtain it through the world-wide-web, please send a note to          |
  13    | license@php.net so we can mail you a copy immediately.               |
  14    +----------------------------------------------------------------------+
  15    | Authors: Felipe Pena <felipe@php.net>                                |
  16    | Authors: Joe Watkins <joe.watkins@live.co.uk>                        |
  17    | Authors: Bob Weinand <bwoebi@php.net>                                |
  18    +----------------------------------------------------------------------+
  19 */
  20 
  21 #ifndef PHPDBG_UTILS_H
  22 #define PHPDBG_UTILS_H
  23 
  24 /**
  25  * Input scan functions
  26  */
  27 PHPDBG_API int phpdbg_is_numeric(const char*);
  28 PHPDBG_API int phpdbg_is_empty(const char*);
  29 PHPDBG_API int phpdbg_is_addr(const char*);
  30 PHPDBG_API int phpdbg_is_class_method(const char*, size_t, char**, char**);
  31 PHPDBG_API const char *phpdbg_current_file(TSRMLS_D);
  32 PHPDBG_API char *phpdbg_resolve_path(const char* TSRMLS_DC);
  33 PHPDBG_API char *phpdbg_trim(const char*, size_t, size_t*);
  34 PHPDBG_API const zend_function *phpdbg_get_function(const char*, const char* TSRMLS_DC);
  35 
  36 /**
  37  * Error/notice/formatting helpers
  38  */
  39 enum {
  40         P_ERROR  = 1,
  41         P_NOTICE,
  42         P_WRITELN,
  43         P_WRITE,
  44         P_LOG
  45 };
  46 
  47 #ifdef ZTS
  48 PHPDBG_API int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...) PHP_ATTRIBUTE_FORMAT(printf, 4, 5);
  49 #else
  50 PHPDBG_API int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
  51 #endif
  52 
  53 PHPDBG_API int phpdbg_rlog(FILE *stream, const char *fmt, ...);
  54 
  55 #define phpdbg_error(fmt, ...)              phpdbg_print(P_ERROR   TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__)
  56 #define phpdbg_notice(fmt, ...)             phpdbg_print(P_NOTICE  TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__)
  57 #define phpdbg_writeln(fmt, ...)            phpdbg_print(P_WRITELN TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__)
  58 #define phpdbg_write(fmt, ...)              phpdbg_print(P_WRITE   TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__)
  59 #define phpdbg_log(fmt, ...)                phpdbg_print(P_LOG     TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__)
  60 
  61 #define phpdbg_error_ex(out, fmt, ...)      phpdbg_print(P_ERROR   TSRMLS_CC, out, fmt, ##__VA_ARGS__)
  62 #define phpdbg_notice_ex(out, fmt, ...)     phpdbg_print(P_NOTICE  TSRMLS_CC, out, fmt, ##__VA_ARGS__)
  63 #define phpdbg_writeln_ex(out, fmt, ...)    phpdbg_print(P_WRITELN TSRMLS_CC, out, fmt, ##__VA_ARGS__)
  64 #define phpdbg_write_ex(out, fmt, ...)      phpdbg_print(P_WRITE   TSRMLS_CC, out, fmt, ##__VA_ARGS__)
  65 #define phpdbg_log_ex(out, fmt, ...)        phpdbg_print(P_LOG     TSRMLS_CC, out, fmt, ##__VA_ARGS__)
  66 
  67 #if PHPDBG_DEBUG
  68 #       define phpdbg_debug(fmt, ...) phpdbg_print(P_LOG   TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDERR], fmt, ##__VA_ARGS__)
  69 #else
  70 #       define phpdbg_debug(fmt, ...)
  71 #endif
  72 
  73 /* {{{ For writing blank lines */
  74 #define EMPTY NULL /* }}} */
  75 
  76 /* {{{ For prompt lines */
  77 #define PROMPT "phpdbg>" /* }}} */
  78 
  79 /* {{{ For separation */
  80 #define SEPARATE "------------------------------------------------" /* }}} */
  81 
  82 /* {{{ Color Management */
  83 #define PHPDBG_COLOR_LEN 12
  84 #define PHPDBG_COLOR_D(color, code) \
  85         {color, sizeof(color)-1, code}
  86 #define PHPDBG_COLOR_END \
  87         {NULL, 0L, {0}}
  88 #define PHPDBG_ELEMENT_LEN 3
  89 #define PHPDBG_ELEMENT_D(name, id) \
  90         {name, sizeof(name)-1, id}
  91 #define PHPDBG_ELEMENT_END \
  92         {NULL, 0L, 0}
  93 
  94 #define PHPDBG_COLOR_INVALID    -1
  95 #define PHPDBG_COLOR_PROMPT      0
  96 #define PHPDBG_COLOR_ERROR               1
  97 #define PHPDBG_COLOR_NOTICE              2
  98 #define PHPDBG_COLORS                    3
  99 
 100 typedef struct _phpdbg_color_t {
 101         char       *name;
 102         size_t      name_length;
 103         const char  code[PHPDBG_COLOR_LEN];
 104 } phpdbg_color_t;
 105 
 106 typedef struct _phpdbg_element_t {
 107         char            *name;
 108         size_t          name_length;
 109         int                     id;
 110 } phpdbg_element_t;
 111 
 112 PHPDBG_API const phpdbg_color_t *phpdbg_get_color(const char *name, size_t name_length TSRMLS_DC);
 113 PHPDBG_API void phpdbg_set_color(int element, const phpdbg_color_t *color TSRMLS_DC);
 114 PHPDBG_API void phpdbg_set_color_ex(int element, const char *name, size_t name_length TSRMLS_DC);
 115 PHPDBG_API const phpdbg_color_t* phpdbg_get_colors(TSRMLS_D); 
 116 PHPDBG_API int phpdbg_get_element(const char *name, size_t len TSRMLS_DC); /* }}} */
 117 
 118 /* {{{ Prompt Management */
 119 PHPDBG_API void phpdbg_set_prompt(const char* TSRMLS_DC);
 120 PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D); /* }}} */
 121 
 122 /* {{{ Console Width */
 123 PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */
 124 
 125 int phpdbg_rebuild_symtable(TSRMLS_D);
 126 
 127 #if PHP_VERSION_ID < 50500
 128 /* copy from zend_hash.c PHP 5.5 for 5.4 compatibility */
 129 static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) {
 130         Bucket *p;
 131 
 132         p = pos ? (*pos) : ht->pInternalPointer;
 133 
 134         if (!p) {
 135                 Z_TYPE_P(key) = IS_NULL;
 136         } else if (p->nKeyLength) {
 137                 Z_TYPE_P(key) = IS_STRING;
 138                 Z_STRVAL_P(key) = IS_INTERNED(p->arKey) ? (char*)p->arKey : estrndup(p->arKey, p->nKeyLength - 1);
 139                 Z_STRLEN_P(key) = p->nKeyLength - 1;
 140         } else {
 141                 Z_TYPE_P(key) = IS_LONG;
 142                 Z_LVAL_P(key) = p->h;
 143         }
 144 }
 145 #endif
 146 
 147 #endif /* PHPDBG_UTILS_H */

/* [<][>][^][v][top][bottom][index][help] */