Permalink
Browse files

windows build MINOR

  • Loading branch information...
1 parent 27f9aeb commit b6a5117e5bf615c3bbd60c2b3a9334eb29449b9b U-ACER-6E40E97492\Kristina Chodorow committed Jun 29, 2009
Showing with 42 additions and 29 deletions.
  1. +5 −7 bson.c
  2. +2 −1 config.w32
  3. +4 −1 db.c
  4. +9 −9 gridfs.c
  5. +14 −0 mongo.c
  6. +7 −10 mongo_types.c
  7. +1 −1 mongo_types.h
View
12 bson.c
@@ -57,12 +57,8 @@ static int prep_obj_for_db(buffer *buf, zval *array TSRMLS_DC) {
// serialize a zval
int zval_to_bson(buffer *buf, zval *zhash, int prep TSRMLS_DC) {
- zval **data;
- char *key, *field_name;
- uint key_len, start;
- ulong index;
- HashPosition pointer;
- int num = 0, key_type;
+ uint start;
+ int num = 0;
HashTable *arr_hash = Z_ARRVAL_P(zhash);
// check buf size
@@ -178,7 +174,9 @@ int serialize_element(char *name, zval **data, buffer *buf, int prep TSRMLS_DC)
set_type(buf, BSON_OID);
serialize_string(buf, name, name_len);
id = (mongo_id*)zend_object_store_get_object(*data TSRMLS_CC);
- MONGO_CHECK_INITIALIZED(id->id, MongoId);
+ if (!id->id) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
serialize_bytes(buf, id->id, OID_SIZE);
}
View
3 config.w32
@@ -4,8 +4,9 @@
ARG_ENABLE("mongo", "MongoDB support", "no");
if (PHP_MONGO != "no") {
- EXTENSION('mongo', 'mongo.c mongo_types.c bson.c cursor.c collection.c db.c util.c gridfs.c');
+ EXTENSION('mongo', 'mongo.c mongo_types.c bson.c cursor.c collection.c db.c gridfs.c');
AC_DEFINE('HAVE_MONGO', 1);
ADD_EXTENSION_DEP('mongo', 'spl', true);
+ ADD_EXTENSION_DEP('mongo', 'date', true);
}
View
5 db.c
@@ -429,6 +429,9 @@ PHP_METHOD(MongoDB, execute) {
code = obj;
}
+ else {
+ zval_add_ref(&code);
+ }
// create { $eval : code, args : [] }
MAKE_STD_ZVAL(zdata);
@@ -501,7 +504,7 @@ PHP_METHOD(MongoDB, command) {
// limit
Z_TYPE(limit) = IS_LONG;
- Z_LVAL(limit) = 1;
+ Z_LVAL(limit) = -1;
PUSH_PARAM(&limit); PUSH_PARAM((void*)1);
PUSH_EO_PARAM();
View
18 gridfs.c
@@ -225,7 +225,7 @@ PHP_METHOD(MongoGridFS, storeBytes) {
zval temp;
zval *extra = 0, *zid = 0, *zfile = 0, *chunks = 0;
- zval **zzid = 0, **zchunk_size;
+ zval **zzid = 0;
mongo_collection *c = (mongo_collection*)zend_object_store_get_object(getThis() TSRMLS_CC);
MONGO_CHECK_INITIALIZED(c->ns, MongoGridFS);
@@ -331,7 +331,7 @@ PHP_METHOD(MongoGridFS, storeFile) {
zval temp;
zval *extra = 0, *zid = 0, *zfile = 0, *chunks = 0, *upload_date = 0;
- zval **zzid = 0, **md5 = 0, **zchunk_size;
+ zval **zzid = 0, **md5 = 0;
mongo_collection *c = (mongo_collection*)zend_object_store_get_object(getThis() TSRMLS_CC);
MONGO_CHECK_INITIALIZED(c->ns, MongoGridFS);
@@ -483,11 +483,9 @@ PHP_METHOD(MongoGridFS, storeFile) {
// cleanup
if (created_id) {
zend_objects_store_del_ref(zid TSRMLS_CC);
- zval_ptr_dtor(&zid);
}
if (created_date) {
zend_objects_store_del_ref(upload_date TSRMLS_CC);
- zval_ptr_dtor(&upload_date);
}
zval_ptr_dtor(&zfile);
}
@@ -714,7 +712,7 @@ PHP_METHOD(MongoGridFSFile, getSize) {
PHP_METHOD(MongoGridFSFile, write) {
char *filename = 0;
int filename_len, total = 0;
- zval *gridfs, *file, *chunks, *n, *query, *cursor, *sort, *next;
+ zval *gridfs, *file, *chunks, *n, *query, *cursor, *sort;
zval **id;
FILE *fp;
@@ -794,7 +792,7 @@ PHP_METHOD(MongoGridFSFile, write) {
PHP_METHOD(MongoGridFSFile, getBytes) {
zval temp;
- zval *file, *gridfs, *chunks, *n, *query, *cursor, *sort, *next;
+ zval *file, *gridfs, *chunks, *n, *query, *cursor, *sort;
zval **id, **size;
char *str, *str_ptr;
int len;
@@ -848,7 +846,7 @@ PHP_METHOD(MongoGridFSFile, getBytes) {
POP_PARAM(); POP_PARAM();
if (Z_TYPE_PP(size) == IS_DOUBLE) {
- len = Z_DVAL_PP(size);
+ len = (int)Z_DVAL_PP(size);
}
else { // if Z_TYPE_PP(size) == IS_LONG
len = Z_LVAL_PP(size);
@@ -871,8 +869,10 @@ PHP_METHOD(MongoGridFSFile, getBytes) {
}
static int copy_bytes(void *to, char *from, int len) {
- memcpy(to, from, len);
- to += len;
+ char *winIsDumb = (char*)to;
+ memcpy(winIsDumb, from, len);
+ winIsDumb += len;
+ to = (void*)winIsDumb;
return len;
}
View
14 mongo.c
@@ -1084,7 +1084,11 @@ int get_reply(mongo_cursor *cursor TSRMLS_DC) {
// if this fails, we might be disconnected... but we're probably
// just out of results
+#ifdef WIN32
+ if (recv(sock, &cursor->header.length, INT_32, FLAGS) == FAILURE) {
+#else
if (read(sock, &cursor->header.length, INT_32) == FAILURE) {
+#endif
return FAILURE;
}
@@ -1095,13 +1099,23 @@ int get_reply(mongo_cursor *cursor TSRMLS_DC) {
return FAILURE;
}
+#ifdef WIN32
+ recv(sock, &cursor->header.request_id, INT_32, FLAGS);
+ recv(sock, &cursor->header.response_to, INT_32, FLAGS);
+ recv(sock, &cursor->header.op, INT_32, FLAGS);
+ recv(sock, &cursor->flag, INT_32, FLAGS);
+ recv(sock, &cursor->cursor_id, INT_64, FLAGS);
+ recv(sock, &cursor->start, INT_32, FLAGS);
+ recv(sock, &num_returned, INT_32, FLAGS);
+#else
read(sock, &cursor->header.request_id, INT_32);
read(sock, &cursor->header.response_to, INT_32);
read(sock, &cursor->header.op, INT_32);
read(sock, &cursor->flag, INT_32);
read(sock, &cursor->cursor_id, INT_64);
read(sock, &cursor->start, INT_32);
read(sock, &num_returned, INT_32);
+#endif
// create buf
cursor->header.length -= INT_32*9;
View
17 mongo_types.c
@@ -78,7 +78,7 @@ int mongo_mongo_id_serialize(zval *struc, unsigned char **serialized_data, zend_
return SUCCESS;
}
-int mongo_mongo_id_unserialize(zval **rval, zend_class_entry *ce, const unsigned char* p, long datalen, zend_unserialize_data* var_hash TSRMLS_DC) {
+int mongo_mongo_id_unserialize(zval **rval, zend_class_entry *ce, const unsigned char* p, zend_uint datalen, zend_unserialize_data* var_hash TSRMLS_DC) {
zval temp;
zval str;
@@ -223,25 +223,24 @@ PHP_METHOD(MongoId, __toString) {
*/
PHP_METHOD(MongoDate, __construct) {
zval *arg = 0;
- struct timeval time;
- int sec, usec = 0;
+ int usec = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zl", &arg, &usec) == FAILURE) {
return;
}
if (!arg) {
#ifdef WIN32
- SYSTEMTIME systime;
- GetSystemTime(&systime);
- time.tv_sec = systime.wSecond;
- time.tv_usec = systime.wMilliseconds * 1000;
+ time_t sec = time(0);
+ add_property_long(getThis(), "sec", sec);
+ add_property_long(getThis(), "usec", 0);
#else
+ struct timeval time;
gettimeofday(&time, NULL);
-#endif
add_property_long(getThis(), "sec", time.tv_sec);
add_property_long(getThis(), "usec", time.tv_usec);
+#endif
}
else if (Z_TYPE_P(arg) == IS_LONG) {
add_property_long(getThis(), "sec", Z_LVAL_P(arg));
@@ -537,8 +536,6 @@ PHP_METHOD(MongoDBRef, isRef) {
/* {{{ MongoDBRef::get()
*/
PHP_METHOD(MongoDBRef, get) {
- char *c_name;
- zval name;
zval *db, *ref, *collection, *query;
zval **ns, **id;
View
2 mongo_types.h
@@ -38,7 +38,7 @@ PHP_METHOD(MongoId, __construct);
PHP_METHOD(MongoId, __toString);
int mongo_mongo_id_serialize(zval*, unsigned char**, zend_uint*, zend_serialize_data* TSRMLS_DC);
-int mongo_mongo_id_unserialize(zval**, zend_class_entry*, const unsigned char*, long, zend_unserialize_data* TSRMLS_DC);
+int mongo_mongo_id_unserialize(zval**, zend_class_entry*, const unsigned char*, zend_uint, zend_unserialize_data* TSRMLS_DC);
PHP_METHOD(MongoRegex, __construct);
PHP_METHOD(MongoRegex, __toString);

0 comments on commit b6a5117

Please sign in to comment.