Ejemplo n.º 1
0
ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, char **str_index, uint *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos) {
  HashPosition hp = ht->getPosition();
  if (pos) {
    hp = *pos;
  }
  if (hp == ht->invalid_index) {
    return HASH_KEY_NON_EXISTENT;
  }

  HPHP::Variant key = ht->getKey(hp);
  if (key.isString()) {
    HPHP::String keyStr = key.toString();
    if (duplicate) {
      *str_index = estrndup(keyStr.data(), keyStr.size());
    } else {
      *str_index = const_cast<char*>(keyStr.data());
    }
    if (str_length) {
      *str_length = keyStr.size();
    }
    return HASH_KEY_IS_STRING;
  }

  assert(key.isInteger());
  *num_index = key.toInt64();
  return HASH_KEY_IS_LONG;
}
Ejemplo n.º 2
0
PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, int persistent STREAMS_DC TSRMLS_DC) {
    HPHP::String s;
    if (maxlen == PHP_STREAM_COPY_ALL) {
      HPHP::StringBuffer sb;
      sb.read(src);
      s = sb.detach();
    } else {
      s = src->read(maxlen);
    }
    *buf = const_cast<char*>(s->data());
    return s->size();
}
Ejemplo n.º 3
0
PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen, int persistent STREAMS_DC TSRMLS_DC) {
    HPHP::String s;
    if (maxlen == PHP_STREAM_COPY_ALL) {
      HPHP::StringBuffer sb;
      sb.read(src->hphp_file);
      s = sb.detach();
    } else {
      s = src->hphp_file->read(maxlen);
    }
    *buf = (char*) emalloc(s->size());
    memcpy(*buf, s->data(), s->size());
    return s->size();
}
Ejemplo n.º 4
0
 static bool dateTimezoneIniCallback(const HPHP::String& value, void *p) {
   assert(p == nullptr);
   if (value.empty()) {
     return false;
   }
   return f_date_default_timezone_set(value);
 }
Ejemplo n.º 5
0
int64_t PG_memory_limit() {
  HPHP::String ret;
  HPHP::IniSetting::Get("memory_limit", ret);
  return ret->toInt64();
}
Ejemplo n.º 6
0
Archivo: var.cpp Proyecto: 191919/hhvm
/* {{{ includes
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "php.h"
#include "php_string.h"
#include "php_var.h"
#include "php_smart_str.h"
#include "basic_functions.h"

#include "ext/standard/php_smart_str.h"
#include "hphp/runtime/ext/std/ext_std_variable.h"

#define COMMON (Z_ISREF_PP(struc) ? "&" : "")
/* }}} */

PHPAPI void php_var_serialize(smart_str *buf, zval **struc, php_serialize_data_t *var_hash TSRMLS_DC) {
  HPHP::String s = HPHP::f_serialize(HPHP::tvAsVariant((*struc)->tv()));
  smart_str_appendl(buf, s.data(), s.size());
}
PHPAPI int php_var_unserialize(zval **rval, const unsigned char **p, const unsigned char *max, php_unserialize_data_t *var_hash TSRMLS_DC) {
  HPHP::Variant ret = HPHP::f_unserialize(HPHP::String((const char*) *p, max - *p, HPHP::CopyString));
  MAKE_STD_ZVAL(*rval);
  HPHP::cellDup(*ret.asCell(), *(*rval)->tv());
  return !ret.isBoolean() || ret.toBoolean();
}
PHPAPI void var_destroy(php_unserialize_data_t *var_hash) {
  not_implemented();
}
Ejemplo n.º 7
0
static bool bool_ini_get(const char* str) {
  HPHP::String ret;
  HPHP::IniSetting::Get(str, ret);
  return ret.toBoolean();
}