package.xml 0000664 0001750 0001750 00000215776 12673034026 013060 0 ustar jmikola jmikola
mongodb
pecl.php.net
MongoDB driver for PHP
The purpose of this driver is to provide exceptionally thin glue between MongoDB
and PHP, implementing only fundemental and performance-critical components
necessary to build a fully-functional MongoDB driver.
Hannes Magnusson
bjori
bjori@php.net
yes
Jeremy Mikola
jmikola
jmikola@php.net
yes
Derick Rethans
derick
derick@php.net
yes
2016-03-18
1.1.5
1.1.5
stable
stable
Apache License
* PHPC-632: Define MONGOC_NO_AUTOMATIC_GLOBALS when bundling libmongoc
5.4.0
7.99.99
1.4.8
mongodb
mongodb-1.1.5/scripts/centos/ldap/Domain.ldif 0000664 0001750 0001750 00000000127 12673034026 020757 0 ustar jmikola jmikola dn: dc=10gen,dc=me
objectClass: dcObject
objectClass: organization
dc: 10gen
o : 10gen
mongodb-1.1.5/scripts/centos/ldap/Users.ldif 0000664 0001750 0001750 00000000106 12673034026 020646 0 ustar jmikola jmikola dn: ou=Users,dc=10gen,dc=me
ou: Users
objectClass: organizationalUnit
mongodb-1.1.5/scripts/centos/ldap/basics.ldif 0000664 0001750 0001750 00000000244 12673034026 021014 0 ustar jmikola jmikola dn: dc=10gen,dc=me
objectclass: dcObject
objectclass: organization
o: MongoDB
dc: 10gen
dn: cn=Manager,dc=10gen,dc=me
objectclass: organizationalRole
cn: Manager
mongodb-1.1.5/scripts/centos/ldap/install.sh 0000664 0001750 0001750 00000001141 12673034026 020707 0 ustar jmikola jmikola yum -y update
yum -y install openldap-servers openldap-clients openldap-devel python-devel gcc cyrus-sasl-plain xfsprogs net-snmp ps-misc wget python-ldap
service slapd stop
service slapd start
#just in case
sleep 10
ldapadd -Y EXTERNAL -H ldapi:/// -f /phongo/scripts/centos/ldap/pw.ldif
# Add our specifics
ldapadd -x -D "cn=Manager,dc=10gen,dc=me" -w password -f /phongo/scripts/centos/ldap/Domain.ldif
ldapadd -x -D "cn=Manager,dc=10gen,dc=me" -w password -f /phongo/scripts/centos/ldap/Users.ldif
# Add the users
python /phongo/scripts/centos/ldap/ldapconfig.py -f /phongo/scripts/centos/ldap/users
mongodb-1.1.5/scripts/centos/ldap/mongod.ldif 0000664 0001750 0001750 00000010272 12673034026 021035 0 ustar jmikola jmikola #
# See slapd-config(5) for details on configuration options.
# This file should NOT be world readable.
#
dn: cn=config
objectClass: olcGlobal
cn: config
olcArgsFile: /var/run/openldap/slapd.args
olcPidFile: /var/run/openldap/slapd.pid
#
# TLS settings
#
olcTLSCACertificatePath: /etc/openldap/certs
olcTLSCertificateFile: "OpenLDAP Server"
olcTLSCertificateKeyFile: /etc/openldap/certs/password
#
# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#
#olcReferral: ldap://root.openldap.org
#
# Sample security restrictions
# Require integrity protection (prevent hijacking)
# Require 112-bit (3DES or better) encryption for updates
# Require 64-bit encryption for simple bind
#
#olcSecurity: ssf=1 update_ssf=112 simple_bind=64
#
# Load dynamic backend modules:
# - modulepath is architecture dependent value (32/64-bit system)
# - back_sql.la backend requires openldap-servers-sql package
# - dyngroup.la and dynlist.la cannot be used at the same time
#
#dn: cn=module,cn=config
#objectClass: olcModuleList
#cn: module
#olcModulepath: /usr/lib/openldap
#olcModulepath: /usr/lib64/openldap
#olcModuleload: accesslog.la
#olcModuleload: auditlog.la
#olcModuleload: back_dnssrv.la
#olcModuleload: back_ldap.la
#olcModuleload: back_mdb.la
#olcModuleload: back_meta.la
#olcModuleload: back_null.la
#olcModuleload: back_passwd.la
#olcModuleload: back_relay.la
#olcModuleload: back_shell.la
#olcModuleload: back_sock.la
#olcModuleload: collect.la
#olcModuleload: constraint.la
#olcModuleload: dds.la
#olcModuleload: deref.la
#olcModuleload: dyngroup.la
#olcModuleload: dynlist.la
#olcModuleload: memberof.la
#olcModuleload: pcache.la
#olcModuleload: ppolicy.la
#olcModuleload: refint.la
#olcModuleload: retcode.la
#olcModuleload: rwm.la
#olcModuleload: seqmod.la
#olcModuleload: smbk5pwd.la
#olcModuleload: sssvlv.la
#olcModuleload: syncprov.la
#olcModuleload: translucent.la
#olcModuleload: unique.la
#olcModuleload: valsort.la
#
# Schema settings
#
dn: cn=schema,cn=config
objectClass: olcSchemaConfig
cn: schema
include: file:///etc/openldap/schema/core.ldif
include: file:///etc/openldap/schema/corba.schema
include: file:///etc/openldap/schema/cosine.ldif
include: file:///etc/openldap/schema/duaconf.schema
include: file:///etc/openldap/schema/dyngroup.schema
include: file:///etc/openldap/schema/inetorgperson.ldif
include: file:///etc/openldap/schema/java.schema
include: file:///etc/openldap/schema/misc.schema
include: file:///etc/openldap/schema/nis.ldif
include: file:///etc/openldap/schema/openldap.ldif
include: file:///etc/openldap/schema/ppolicy.schema
include: file:///etc/openldap/schema/collective.schema
#
# Frontend settings
#
dn: olcDatabase=frontend,cn=config
objectClass: olcDatabaseConfig
olcDatabase: frontend
#
# Sample global access control policy:
# Root DSE: allow anyone to read it
# Subschema (sub)entry DSE: allow anyone to read it
# Other DSEs:
# Allow self write access
# Allow authenticated users read access
# Allow anonymous users to authenticate
#
#olcAccess: to dn.base="" by * read
#olcAccess: to dn.base="cn=Subschema" by * read
#olcAccess: to *
# by self write
# by users read
# by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn. (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!
#
#
# Configuration database
#
dn: olcDatabase=config,cn=config
objectClass: olcDatabaseConfig
olcDatabase: config
olcAccess: to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,c
n=auth" manage by * none
#
# Server status monitoring
#
dn: olcDatabase=monitor,cn=config
objectClass: olcDatabaseConfig
olcDatabase: monitor
olcAccess: to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,c
n=auth" read by dn.base="cn=Manager,dc=10gen,dc=me" read by * none
#
# Backend database definitions
#
dn: olcDatabase=hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: hdb
olcSuffix: dc=10gen,dc=me
olcRootDN: cn=Manager,dc=10gen,dc=me
olcRootPW: {SSHA}t3hTZGC4FTOS6AnTa76aX7HRtt1IDqFM
olcDbDirectory: /var/lib/ldap
olcDbIndex: objectClass eq,pres
olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub
mongodb-1.1.5/scripts/centos/ldap/pw.ldif 0000664 0001750 0001750 00000001173 12673034026 020200 0 ustar jmikola jmikola dn: olcDatabase={0}config,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: {SSHA}t3hTZGC4FTOS6AnTa76aX7HRtt1IDqFM
-
replace: olcRootDN
olcRootDN: cn=Manager,dc=10gen,dc=me
dn: olcDatabase={2}bdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: {SSHA}t3hTZGC4FTOS6AnTa76aX7HRtt1IDqFM
-
replace: olcSuffix
olcSuffix: dc=10gen,dc=me
-
replace: olcRootDN
olcRootDN: cn=Manager,dc=10gen,dc=me
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=Manager,dc=10gen,dc=me" read by * none
mongodb-1.1.5/scripts/centos/ldap/saslauthd.conf 0000664 0001750 0001750 00000000143 12673034026 021545 0 ustar jmikola jmikola ldap_servers: ldap://localhost:389
ldap_search_base: ou=Users,dc=10gen,dc=me
ldap_filter: (uid=%u)
mongodb-1.1.5/scripts/centos/ldap/users 0000664 0001750 0001750 00000000026 12673034026 017772 0 ustar jmikola jmikola bugs
features
dbadmin
mongodb-1.1.5/scripts/centos/essentials.sh 0000664 0001750 0001750 00000000362 12673034026 020477 0 ustar jmikola jmikola # Tools you can't live without
sudo yum install -y git vim
# I can't stand emacs
echo 'set -o vi' | sudo tee /etc/profile.d/vishell.sh
# Who knows how to configure RHEL at all anyway?
sudo service iptables stop
sudo chkconfig iptables off
mongodb-1.1.5/scripts/freebsd/essentials.sh 0000664 0001750 0001750 00000000575 12673034026 020624 0 ustar jmikola jmikola # Update ports
sudo portsnap fetch extract update
# Minimum required PHP install + pecl
sudo pkg install -y pcre php56 php56-openssl php56-json php56-zlib pear autoconf pkgconf cyrus-sasl
# We need vim. git requires curl. mongoc requires libtool and automake
sudo pkg install -y vim git curl libtool automake
# I can't stand emacs
echo 'set -o vi' | sudo tee -a /etc/profile
mongodb-1.1.5/scripts/freebsd/phongo.sh 0000664 0001750 0001750 00000000473 12673034026 017741 0 ustar jmikola jmikola ls -1 /phongo/mongodb*.tgz | sort -n -r | xargs sudo pecl install -f 2>&1 > /phongo/.build
if test $? -eq 0; then
php -m | grep -q mongodb || echo "extension=mongodb.so" | sudo tee -a /usr/local/etc/php/extensions.ini
pecl run-tests -q -p mongodb 2>&1 > /phongo/.tests
else
tail -n50 /phongo/.build
exit 3
fi
mongodb-1.1.5/scripts/presets/replicaset-30.json 0000664 0001750 0001750 00000002665 12673034026 021441 0 ustar jmikola jmikola {
"id": "REPLICASET_30",
"name": "mongod",
"members": [
{
"procParams": {
"dbpath": "/tmp/REPLICASET/3100/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/REPLICASET/3100/mongod.log",
"nohttpinterface": true,
"journal": true,
"noprealloc": true,
"nssize": 1,
"port": 3100,
"smallfiles": true,
"setParameter": {"enableTestCommands": 1}
},
"rsParams": {
"priority": 99,
"tags": {
"ordinal": "one",
"dc": "pa"
}
},
"server_id": "RS-30-one"
},
{
"procParams": {
"dbpath": "/tmp/REPLICASET/3101/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/REPLICASET/3101/mongod.log",
"nohttpinterface": true,
"journal": true,
"noprealloc": true,
"nssize": 1,
"port": 3101,
"smallfiles": true,
"setParameter": {"enableTestCommands": 1}
},
"rsParams": {
"priority": 1.1,
"tags": {
"ordinal": "two",
"dc": "nyc"
}
},
"server_id": "RS-30-two"
},
{
"procParams": {
"dbpath": "/tmp/REPLICASET/3102/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/REPLICASET/3002/mongod.log",
"nohttpinterface": true,
"journal": true,
"noprealloc": true,
"nssize": 1,
"port": 3102,
"smallfiles": true,
"setParameter": {"enableTestCommands": 1}
},
"rsParams": {
"arbiterOnly": true
},
"server_id": "RS-30-arbiter"
}
],
"version": "30-release"
}
mongodb-1.1.5/scripts/presets/replicaset.json 0000664 0001750 0001750 00000002617 12673034026 021216 0 ustar jmikola jmikola {
"id": "REPLICASET",
"name": "mongod",
"members": [
{
"procParams": {
"dbpath": "/tmp/REPLICASET/3000/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/REPLICASET/3000/mongod.log",
"nohttpinterface": true,
"journal": true,
"noprealloc": true,
"nssize": 1,
"port": 3000,
"smallfiles": true,
"setParameter": {"enableTestCommands": 1}
},
"rsParams": {
"priority": 99,
"tags": {
"ordinal": "one",
"dc": "pa"
}
},
"server_id": "RS-one"
},
{
"procParams": {
"dbpath": "/tmp/REPLICASET/3001/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/REPLICASET/3001/mongod.log",
"nohttpinterface": true,
"journal": true,
"noprealloc": true,
"nssize": 1,
"port": 3001,
"smallfiles": true,
"setParameter": {"enableTestCommands": 1}
},
"rsParams": {
"priority": 1.1,
"tags": {
"ordinal": "two",
"dc": "nyc"
}
},
"server_id": "RS-two"
},
{
"procParams": {
"dbpath": "/tmp/REPLICASET/3002/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/REPLICASET/3002/mongod.log",
"nohttpinterface": true,
"journal": true,
"noprealloc": true,
"nssize": 1,
"port": 3002,
"smallfiles": true,
"setParameter": {"enableTestCommands": 1}
},
"rsParams": {
"arbiterOnly": true
},
"server_id": "RS-arbiter"
}
]
}
mongodb-1.1.5/scripts/presets/standalone-24.json 0000664 0001750 0001750 00000000535 12673034026 021433 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE_24",
"procParams": {
"dbpath": "/tmp/standalone-24/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone-24/mongod.log",
"journal": true,
"port": 2500,
"setParameter": {"enableTestCommands": 1}
},
"version": "24-release"
}
mongodb-1.1.5/scripts/presets/standalone-26.json 0000664 0001750 0001750 00000000535 12673034026 021435 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE_26",
"procParams": {
"dbpath": "/tmp/standalone-26/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone-26/mongod.log",
"journal": true,
"port": 2600,
"setParameter": {"enableTestCommands": 1}
},
"version": "26-release"
}
mongodb-1.1.5/scripts/presets/standalone-30.json 0000664 0001750 0001750 00000000535 12673034026 021430 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE_30",
"procParams": {
"dbpath": "/tmp/standalone-30/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone-30/mongod.log",
"journal": true,
"port": 2700,
"setParameter": {"enableTestCommands": 1}
},
"version": "30-release"
}
mongodb-1.1.5/scripts/presets/standalone-auth.json 0000664 0001750 0001750 00000000610 12673034026 022141 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE_AUTH",
"auth_key": "secret",
"login": "root",
"password": "toor",
"procParams": {
"dbpath": "/tmp/standalone-auth/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone-auth/m.log",
"journal": true,
"port": 2200,
"setParameter": {"enableTestCommands": 1}
}
}
mongodb-1.1.5/scripts/presets/standalone-plain.json 0000664 0001750 0001750 00000000746 12673034026 022315 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE_PLAIN",
"auth_key": "secret",
"login": "root",
"password": "toor",
"procParams": {
"dbpath": "/tmp/standalone-plain/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone-plain/m.log",
"journal": true,
"port": 2400,
"setParameter": {"enableTestCommands": 1, "saslauthdPath": "/var/run/saslauthd/mux", "authenticationMechanisms": "MONGODB-CR,PLAIN"}
}
}
mongodb-1.1.5/scripts/presets/standalone-ssl.json 0000664 0001750 0001750 00000001015 12673034026 022001 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE_SSL",
"procParams": {
"dbpath": "/tmp/standalone-ssl/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone-ssl/m.log",
"journal": true,
"port": 2100,
"setParameter": {"enableTestCommands": 1}
},
"sslParams": {
"sslMode": "requireSSL",
"sslCAFile": "/phongo/scripts/ssl/ca.pem",
"sslPEMKeyFile": "/phongo/scripts/ssl/server.pem",
"sslWeakCertificateValidation": true
}
}
mongodb-1.1.5/scripts/presets/standalone-x509.json 0000664 0001750 0001750 00000001256 12673034026 021714 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE_X509",
"authSource": "$external",
"login": "C=US,ST=New York,L=New York City,O=MongoDB,OU=KernelUser,CN=client",
"procParams": {
"dbpath": "/tmp/standalone-x509/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone-x509/m.log",
"journal": true,
"port": 2300,
"setParameter": {"enableTestCommands": 1, "authenticationMechanisms": "MONGODB-X509"}
},
"sslParams": {
"sslMode": "requireSSL",
"sslCAFile": "/phongo/scripts/ssl/ca.pem",
"sslPEMKeyFile": "/phongo/scripts/ssl/server.pem",
"sslWeakCertificateValidation": true
}
}
mongodb-1.1.5/scripts/presets/standalone.json 0000664 0001750 0001750 00000000467 12673034026 021214 0 ustar jmikola jmikola {
"name": "mongod",
"id" : "STANDALONE",
"procParams": {
"dbpath": "/tmp/standalone/",
"ipv6": true,
"logappend": true,
"logpath": "/tmp/standalone/mongod.log",
"journal": true,
"port": 2000,
"setParameter": {"enableTestCommands": 1}
}
}
mongodb-1.1.5/scripts/ssl/ca.pem 0000664 0001750 0001750 00000005641 12673034026 016372 0 ustar jmikola jmikola -----BEGIN CERTIFICATE-----
MIIDczCCAlugAwIBAgIBATANBgkqhkiG9w0BAQUFADB0MRcwFQYDVQQDEw5LZXJu
ZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYw
FAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UE
BhMCVVMwHhcNMTQwNzE3MTYwMDAwWhcNMjAwNzE3MTYwMDAwWjB0MRcwFQYDVQQD
Ew5LZXJuZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25n
b0RCMRYwFAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazEL
MAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCBxSXj
qA5y2EMQkcmvLDNikE88Og3+spJ3ex60HWVPk8EeXN68jyfbKLYsoCcBE2rBAE/N
shVBJa8irh0o/UTh1XNW4iGCsfMvYamXiHnaOjmGVKjfBoj6pzQH0uK0X5olm3Sa
zZPkLLCR81yxsK6woJZMFTvrlEjxj/SmDZ9tVXW692bC4i6nGvOCSpgv9kms85xO
Ed2xbuCLXFDXKafXZd5AK+iegkDs3ah7VXMEE8sbqGnlqC1nsy5bpCnb7aC+3af7
SV2XEFlSQT5kwTmk9CvTDzM9O78SO8nNhEOFBLQEdGDGd3BShE8dCdh2JTy3zKsb
WeE+mxy0mEwxNfGfAgMBAAGjEDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEF
BQADggEBAANwbvhM5K/Jcl6yzUSqAawvyAypT5aWBob7rt9KFq/aemjMN0gY2nsS
8WTGd9jiXlxGc/TzrK6MOsJ904UAFE1L9uR//G1gIBa9dNbYoiii2Fc8b1xDVJEP
b23rl/+GAT6UTSY+YgEjeA4Jk6H9zotO07lSw06rbCQam5SdA5UiMvuLHWCo3BHY
8WzqLiW/uHlb4K5prF9yuTUBEIgkRvvvyOKXlRvm1Ed5UopT2hmwA86mffAfgJc2
vSbm9/8Q00fYwO7mluB6mbEcnbquaqRLoB83k+WbwUAZ2yjWHXuXVMPwyaysazcp
nOjaLwQJQgKejY62PiNcw7xC/nIxBeI=
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAgcUl46gOcthDEJHJrywzYpBPPDoN/rKSd3setB1lT5PBHlze
vI8n2yi2LKAnARNqwQBPzbIVQSWvIq4dKP1E4dVzVuIhgrHzL2Gpl4h52jo5hlSo
3waI+qc0B9LitF+aJZt0ms2T5CywkfNcsbCusKCWTBU765RI8Y/0pg2fbVV1uvdm
wuIupxrzgkqYL/ZJrPOcThHdsW7gi1xQ1ymn12XeQCvonoJA7N2oe1VzBBPLG6hp
5agtZ7MuW6Qp2+2gvt2n+0ldlxBZUkE+ZME5pPQr0w8zPTu/EjvJzYRDhQS0BHRg
xndwUoRPHQnYdiU8t8yrG1nhPpsctJhMMTXxnwIDAQABAoIBAD5iGOnM800wO2Uu
wGbOd9FNEFoiinHDRHfdnw/1BavwmqjO+mBo7T8E3jarsrRosiwfyz1V+7O6uuuQ
CgKXZlKuOuksgfGDPCWt7EolWHaZAOhbsGaujJD6ah/MuCD/yGmFxtNYOl05QpSX
Cht9lSzhtf7TQl/og/xkOLbO27JB540ck/OCSOczXg9Z/O8AmIUyDn7AKb6G1Zhk
2IN//HQoAvDUMZLWrzy+L7YGbA8pBR3yiPsYBH0rX2Oc9INpiGA+B9Nf1HDDsxeZ
/o+5xLbRDDfIDtlYO0cekJ053W0zUQLrMEIn9991EpG2O/fPgs10NlKJtaFH8CmT
ExgVA9ECgYEA+6AjtUdxZ0BL3Wk773nmhesNH5/5unWFaGgWpMEaEM7Ou7i6QApL
KAbzOYItV3NNCbkcrejq7jsDGEmiwUOdXeQx6XN7/Gb2Byc/wezy5ALi0kcUwaur
6s9+Ah+T4vcU2AjfuCWXIpe46KLEbwORmCRQGwkCBCwRhHGt5sGGxTkCgYEAhAaw
voHI6Cb+4z3PNAKRnf2rExBYRyCz1KF16ksuwJyQSLzFleXRyRWFUEwLuVRL0+EZ
JXhMbtrILrc23dJGEsB8kOCFehSH/IuL5eB0QfKpDFA+e6pimsbVeggx/rZhcERB
WkcV3jN4O82gSL3EnIgvAT1/nwhmbmjvDhFJhZcCgYBaW4E3IbaZaz9S/O0m69Fa
GbQWvS3CRV1oxqgK9cTUcE9Qnd9UC949O3GwHw0FMERjz3N7B/8FGW/dEuQ9Hniu
NLmvqWbGlnqWywNcMihutJKbDCdp/Km5olUPkiNbB3sWsOkViXoiU/V0pK6BZvir
d67EZpGwydpogyH9kVVCEQKBgGHXc3Q7SmCBRbOyQrQQk0m6i+V8328W1S5m2bPg
M62aWXMOMn976ZRT1pBDSwz1Y5yJ3NDf7gTZLjEwpgCNrFCJRcc4HLL0NDL8V5js
VjvpUU5GyYdsJdb+M4ZUPHi/QEaqzqPQumwJSLlJEdfWirZWVj9dDA8XcpGwQjjy
psHRAoGBAJUTgeJYhjK7k5sgfh+PRqiRJP0msIH8FK7SenBGRUkelWrW6td2Riey
EcOCMFkRWBeDgnZN5xDyWLBgrzpw9iHQQIUyyBaFknQcRUYKHkCx+k+fr0KHHCUb
X2Kvf0rbeMucb4y/h7950HkBBq83AYKMAoI8Ql3cx7pKmyOLXRov
-----END RSA PRIVATE KEY----- mongodb-1.1.5/scripts/ssl/client.pem 0000664 0001750 0001750 00000005611 12673034026 017262 0 ustar jmikola jmikola -----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIBAzANBgkqhkiG9w0BAQUFADB0MRcwFQYDVQQDEw5LZXJu
ZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYw
FAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UE
BhMCVVMwHhcNMTQwNzE3MTYwMDAwWhcNMjAwNzE3MTYwMDAwWjBwMQ8wDQYDVQQD
EwZjbGllbnQxEzARBgNVBAsTCktlcm5lbFVzZXIxEDAOBgNVBAoTB01vbmdvREIx
FjAUBgNVBAcTDU5ldyBZb3JrIENpdHkxETAPBgNVBAgTCE5ldyBZb3JrMQswCQYD
VQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJIFboAk9Fdi
DY5Xld2iw36vB3IpHEfgWIimd+l1HX4jyp35i6xoqkZZHJUL/NMbUFJ6+44EfFJ5
biB1y1Twr6GqpYp/3R30jKQU4PowO7DSal38MR34yiRFYPG4ZPPXXfwPSuwKrSNo
bjqa0/DRJRVQlnGwzJkPsWxIgCjc8KNO/dSHv/CGymc9TjiFAI0VVOhMok1CBNvc
ifwWjGBg5V1s3ItMw9x5qk+b9ff5hiOAGxPiCrr8R0C7RoeXg7ZG8K/TqXbsOZEG
AOQPRGcrmqG3t4RNBJpZugarPWW6lr11zMpiPLFTrbq3ZNYB9akdsps4R43TKI4J
AOtGMJmK430CAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAA+nPgVT4addi13yB6mjW
+UhdUkFwtb1Wcg0sLtnNucopHZLlCj5FfDdp1RQxe3CyMonxyHTKkrWtQmVtUyvf
C/fjpIKt9A9kAmveMHBiu9FTNTc0sbiXcrEBeHF5cD7N+Uwfoc/4rJm0WjEGNkAd
pYLCCLVZXPVr3bnc3ZLY1dFZPsJrdH3nJGMjLgUmoNsKnaGozcjiKiXqm6doFzkg
0Le5yD4C/QTaie2ycFa1X5bJfrgoMP7NqKko05h4l0B0+DnjpoTJN+zRreNTMKvE
ETGvpUu0IYGxe8ZVAFnlEO/lUeMrPFvH+nDmJYsxO1Sjpds2hi1M1JoeyrTQPwXj
2Q==
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAkgVugCT0V2INjleV3aLDfq8HcikcR+BYiKZ36XUdfiPKnfmL
rGiqRlkclQv80xtQUnr7jgR8UnluIHXLVPCvoaqlin/dHfSMpBTg+jA7sNJqXfwx
HfjKJEVg8bhk89dd/A9K7AqtI2huOprT8NElFVCWcbDMmQ+xbEiAKNzwo0791Ie/
8IbKZz1OOIUAjRVU6EyiTUIE29yJ/BaMYGDlXWzci0zD3HmqT5v19/mGI4AbE+IK
uvxHQLtGh5eDtkbwr9Opduw5kQYA5A9EZyuaobe3hE0Emlm6Bqs9ZbqWvXXMymI8
sVOturdk1gH1qR2ymzhHjdMojgkA60YwmYrjfQIDAQABAoIBAB249VEoNIRE9TVw
JpVCuEBlKELYk2UeCWdnWykuKZ6vcmLNlNy3QVGoeeTs172w5ZykY+f4icXP6da5
o3XauCVUMvYKKNwcFzSe+1xxzPSlH/mZh/Xt2left6f8PLBVuk/AXSPG2I9Ihodv
VIzERaQdD0J9FmhhhV/hMhUfQ+w5rTCaDpq1KVGU61ks+JAtlQ46g+cvPF9c80cI
TEC875n2LqWKmLRN43JUnctV3uGTmolIqCRMHPAs/egl+lG2RXJjqXSQ2uFLOvC/
PXtBb597yadSs2BWPnTu/r7LbLGBAExzlQK1uFsTvuKsBPb3qrvUux0L68qwPuiv
W24N8BECgYEAydtAvVB7OymQEX3mck2j7ixDN01wc1ZaCLBDvYPYS/Pvzq4MBiAD
lHRtbIa6HPGA5jskbccPqQn8WGnJWCaYvCQryvgaA+BBgo1UTLfQJUo/7N5517vv
KvbUa6NF0nj3VwfDV1vvy+amoWi9NOVn6qOh0K84PF4gwagb1EVy9MsCgYEAuTAt
KCWdZ/aNcKgJc4NCUqBpLPF7EQypX14teixrbF/IRNS1YC9S20hpkG25HMBXjpBe
tVg/MJe8R8CKzYjCt3z5Ff1bUQ2bzivbAtgjcaO0Groo8WWjnamQlrIQcvWM7vBf
dnIflQ0slxbHfCi3XEe8tj2T69R7wJZ8L7PxR9cCgYEACgwNtt6Qo6s37obzt3DB
3hL57YC/Ph5oMNKFLKOpWm5z2zeyhYOGahc5cxNppBMpNUxwTb6AuwsyMjxhty+E
nqi2PU4IDXVWDWd3cLIdfB2r/OA99Ez4ZI0QmaLw0L8QoJZUVL7QurdqR9JsyHs6
puUqIrb195s/yiPR7sjeJe0CgYEAuJviKEd3JxCN52RcJ58OGrh2oKsJ9/EbV0rX
Ixfs7th9GMDDHuOOQbNqKOR4yMSlhCU/hKA4PgTFWPIEbOiM08XtuZIb2i0qyNjH
N4qnqr166bny3tJnzOAgl1ljNHa8y+UsBTO3cCr17Jh0vL0KLSAGa9XvBAWKaG6b
1iIXwXkCgYAVz+DA1yy0qfXdS1pgPiCJGlGZXpbBcFnqvbpGSclKWyUG4obYCbrb
p5VKVfoK7uU0ly60w9+PNIRsX/VN/6SVcoOzKx40qQBMuYfJ72DQrsPjPYvNg/Nb
4SK94Qhp9TlAyXbqKJ02DjtuDim44sGZ8g7b+k3FfoK4OtzNsqdVdQ==
-----END RSA PRIVATE KEY----- mongodb-1.1.5/scripts/ssl/crl.pem 0000664 0001750 0001750 00000003765 12673034026 016574 0 ustar jmikola jmikola Certificate Revocation List (CRL):
Version 2 (0x1)
Signature Algorithm: sha256WithRSAEncryption
Issuer: /CN=Kernel Test CA/OU=Kernel/O=MongoDB/L=New York City/ST=New York/C=US
Last Update: Aug 21 13:56:28 2014 GMT
Next Update: Aug 18 13:56:28 2024 GMT
CRL extensions:
X509v3 CRL Number:
4096
No Revoked Certificates.
Signature Algorithm: sha256WithRSAEncryption
48:1b:0b:b1:89:f5:6f:af:3c:dd:2a:a0:e5:55:04:80:16:b4:
23:98:39:bb:9f:16:c9:25:73:72:c6:a6:73:21:1d:1a:b6:99:
fc:47:5e:bc:af:64:29:02:9c:a5:db:15:8a:65:48:3c:4f:a6:
cd:35:47:aa:c6:c0:39:f5:a6:88:8f:1b:6c:26:61:4e:10:d7:
e2:b0:20:3a:64:92:c1:d3:2a:11:3e:03:e2:50:fd:4e:3c:de:
e2:e5:78:dc:8e:07:a5:69:55:13:2b:8f:ae:21:00:42:85:ff:
b6:b1:2b:69:08:40:5a:25:8c:fe:57:7f:b1:06:b0:72:ff:61:
de:21:59:05:a8:1b:9e:c7:8a:08:ab:f5:bc:51:b3:36:68:0f:
54:65:3c:8d:b7:80:d0:27:01:3e:43:97:89:19:89:0e:c5:01:
2c:55:9f:b6:e4:c8:0b:35:f8:52:45:d3:b4:09:ce:df:73:98:
f5:4c:e4:5a:06:ac:63:4c:f8:4d:9c:af:88:fc:19:f7:77:ea:
ee:56:18:49:16:ce:62:66:d1:1b:8d:66:33:b5:dc:b1:25:b3:
6c:81:e9:d0:8a:1d:83:61:49:0e:d9:94:6a:46:80:41:d6:b6:
59:a9:30:55:3d:5b:d3:5b:f1:37:ec:2b:76:d0:3a:ac:b2:c8:
7c:77:04:78
-----BEGIN X509 CRL-----
MIIBzjCBtwIBATANBgkqhkiG9w0BAQsFADB0MRcwFQYDVQQDEw5LZXJuZWwgVGVz
dCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYwFAYDVQQH
Ew1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UEBhMCVVMX
DTE0MDgyMTEzNTYyOFoXDTI0MDgxODEzNTYyOFqgDzANMAsGA1UdFAQEAgIQADAN
BgkqhkiG9w0BAQsFAAOCAQEASBsLsYn1b6883Sqg5VUEgBa0I5g5u58WySVzcsam
cyEdGraZ/EdevK9kKQKcpdsVimVIPE+mzTVHqsbAOfWmiI8bbCZhThDX4rAgOmSS
wdMqET4D4lD9Tjze4uV43I4HpWlVEyuPriEAQoX/trEraQhAWiWM/ld/sQawcv9h
3iFZBagbnseKCKv1vFGzNmgPVGU8jbeA0CcBPkOXiRmJDsUBLFWftuTICzX4UkXT
tAnO33OY9UzkWgasY0z4TZyviPwZ93fq7lYYSRbOYmbRG41mM7XcsSWzbIHp0Iod
g2FJDtmUakaAQda2WakwVT1b01vxN+wrdtA6rLLIfHcEeA==
-----END X509 CRL-----
mongodb-1.1.5/scripts/ssl/server.pem 0000664 0001750 0001750 00000005665 12673034026 017323 0 ustar jmikola jmikola -----BEGIN CERTIFICATE-----
MIIDfjCCAmagAwIBAgIBBzANBgkqhkiG9w0BAQUFADB0MRcwFQYDVQQDEw5LZXJu
ZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYw
FAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UE
BhMCVVMwHhcNMTQwNzE3MTYwMDAwWhcNMjAwNzE3MTYwMDAwWjBsMQ8wDQYDVQQD
EwZzZXJ2ZXIxDzANBgNVBAsTBktlcm5lbDEQMA4GA1UEChMHTW9uZ29EQjEWMBQG
A1UEBxMNTmV3IFlvcmsgQ2l0eTERMA8GA1UECBMITmV3IFlvcmsxCzAJBgNVBAYT
AlVTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp76KJeDczBqjSPJj
5f8DHdtrWpQDK9AWNDlslWpi6+pL8hMqwbX0D7hC2r3kAgccMyFoNIudPqIXfXVd
1LOh6vyY+jveRvqjKW/UZVzZeiL4Gy4bhke6R8JRC3O5aMKIAbaiQUAI1Nd8LxIt
LGvH+ia/DFza1whgB8ym/uzVQB6igOifJ1qHWJbTtIhDKaW8gvjOhv5R3jzjfLEb
R9r5Q0ZyE0lrO27kTkqgBnHKPmu54GSzU/r0HM3B+Sc/6UN+xNhNbuR+LZ+EvJHm
r4de8jhW8wivmjTIvte33jlLibQ5nYIHrlpDLEwlzvDGaIio+OfWcgs2WuPk98MU
tht0IQIDAQABoyMwITAfBgNVHREEGDAWgglsb2NhbGhvc3SCCTEyNy4wLjAuMTAN
BgkqhkiG9w0BAQUFAAOCAQEANoYxvVFsIol09BQA0fwryAye/Z4dYItvKhmwB9VS
t99DsmJcyx0P5meB3Ed8SnwkD0NGCm5TkUY/YLacPP9uJ4SkbPkNZ1fRISyShCCn
SGgQUJWHbCbcIEj+vssFb91c5RFJbvnenDkQokRvD2VJWspwioeLzuwtARUoMH3Y
qg0k0Mn7Bx1bW1Y6xQJHeVlnZtzxfeueoFO55ZRkZ0ceAD/q7q1ohTXi0vMydYgu
1CB6VkDuibGlv56NdjbttPJm2iQoPaez8tZGpBo76N/Z1ydan0ow2pVjDXVOR84Y
2HSZgbHOGBiycNw2W3vfw7uK0OmiPRTFpJCmewDjYwZ/6w==
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAp76KJeDczBqjSPJj5f8DHdtrWpQDK9AWNDlslWpi6+pL8hMq
wbX0D7hC2r3kAgccMyFoNIudPqIXfXVd1LOh6vyY+jveRvqjKW/UZVzZeiL4Gy4b
hke6R8JRC3O5aMKIAbaiQUAI1Nd8LxItLGvH+ia/DFza1whgB8ym/uzVQB6igOif
J1qHWJbTtIhDKaW8gvjOhv5R3jzjfLEbR9r5Q0ZyE0lrO27kTkqgBnHKPmu54GSz
U/r0HM3B+Sc/6UN+xNhNbuR+LZ+EvJHmr4de8jhW8wivmjTIvte33jlLibQ5nYIH
rlpDLEwlzvDGaIio+OfWcgs2WuPk98MUtht0IQIDAQABAoIBACgi1ilECXCouwMc
RDzm7Jb7Rk+Q9MVJ79YlG08Q+oRaNjvAzE03PSN5wj1WjDTUALJXPvi7oy82V4qE
R6Q6Kvbv46aUJpYzKFEk2dw7ACpSLa1LNfjGNtMusnecA/QF/8bxLReRu8s5mBQn
NDnZvCqllLbfjNlAvsF+/UIn5sqFZpAZPMtPwkTAeh5ge8H9JvrG8y8aXsiFGAhV
Z7tMZyn8wPCUrRi14NLvVB4hxM66G/tuTp8r9AmeTU+PV+qbCnKXd+v0IS52hvX9
z75OPfAc66nm4bbPCapb6Yx7WaewPXXU0HDxeaT0BeQ/YfoNa5OT+ZOX1KndSfHa
VhtmEsECgYEA3m86yYMsNOo+dkhqctNVRw2N+8gTO28GmWxNV9AC+fy1epW9+FNR
yTQXpBkRrR7qrd5mF7WBc7vAIiSfVs021RMofzn5B1x7jzkH34VZtlviNdE3TZhx
lPinqo0Yy3UEksgsCBJFIofuCmeTLk4ZtqoiZnXr35RYibaZoQdUT4kCgYEAwQ6Y
xsKFYFks1+HYl29kR0qUkXFlVbKOhQIlj/dPm0JjZ0xYkUxmzoXD68HrOWgz7hc2
hZaQTgWf+8cRaZNfh7oL+Iglczc2UXuwuUYguYssD/G6/ZPY15PhItgCghaU5Ewy
hMwIJ81NENY2EQTgk/Z1KZitXdVJfHl/IPMQgdkCgYASdqkqkPjaa5dDuj8byO8L
NtTSUYlHJbAmjBbfcyTMG230/vkF4+SmDuznci1FcYuJYyyWSzqzoKISM3gGfIJQ
rYZvCSDiu4qGGPXOWANaX8YnMXalukGzW/CO96dXPB9lD7iX8uxKMX5Q3sgYz+LS
hszUNHWf2XB//ehCtZkKAQKBgQCxL2luepeZHx82H9T+38BkYgHLHw0HQzLkxlyd
LjlE4QCEjSB4cmukvkZbuYXfEVEgAvQKVW6p/SWhGkpT4Gt8EXftKV9dyF21GVXQ
JZnhUOcm1xBsrWYGLXYi2agrpvgONBTlprERfq5tdnz2z8giZL+RZswu45Nnh8bz
AcKzuQKBgQCGOQvKvNL5XKKmws/KRkfJbXgsyRT2ubO6pVL9jGQG5wntkeIRaEpT
oxFtWMdPx3b3cxtgSP2ojllEiISk87SFIN1zEhHZy/JpTF0GlU1qg3VIaA78M1p2
ZdpUsuqJzYmc3dDbQMepIaqdW4xMoTtZFyenUJyoezz6eWy/NlZ/XQ==
-----END RSA PRIVATE KEY----- mongodb-1.1.5/scripts/ubuntu/ldap/install.sh 0000664 0001750 0001750 00000001006 12673034026 020736 0 ustar jmikola jmikola sudo apt-get -y install ldap-utils libsasl2-modules-ldap sasl2-bin
# setup saslauthd
sudo sed -i 's/MECHANISMS="pam"/MECHANISMS="ldap"/' /etc/default/saslauthd
sudo sed -i 's/START=no/START="yes"/' /etc/default/saslauthd
sudo cp /phongo/scripts/ubuntu/ldap/saslauthd.conf /etc/
sudo service saslauthd restart
testsaslauthd -u bugs -p password -s mongod -f /var/run/saslauthd/mux
#ldapsearch -x -LLL -b dc=10gen,dc=me -h 192.168.112.20
#ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts -h 192.168.112.20
mongodb-1.1.5/scripts/ubuntu/ldap/saslauthd.conf 0000664 0001750 0001750 00000000150 12673034026 021572 0 ustar jmikola jmikola ldap_servers: ldap://192.168.112.20:389
ldap_search_base: ou=Users,dc=10gen,dc=me
ldap_filter: (uid=%u)
mongodb-1.1.5/scripts/ubuntu/essentials.sh 0000664 0001750 0001750 00000000365 12673034026 020531 0 ustar jmikola jmikola if [ ! -e ".provisioned" ]; then
# Tools you can't live without
apt-get update
apt-get install -y build-essential git vim libtool autoconf
# I can't stand emacs
echo 'set -o vi' | sudo tee /etc/profile.d/vishell.sh
touch .provisioned
fi
mongodb-1.1.5/scripts/ubuntu/mongo-orchestration.sh 0000664 0001750 0001750 00000003277 12673034026 022365 0 ustar jmikola jmikola # Enable MongoDB Enterprise repo
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
# 3.2 key
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo 'deb http://repo.mongodb.com/apt/ubuntu precise/mongodb-enterprise/3.2 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-enterprise-3.2.list
echo 'deb http://repo.mongodb.com/apt/ubuntu precise/mongodb-enterprise/3.0 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-enterprise-3.0.list
echo 'deb http://repo.mongodb.com/apt/ubuntu precise/mongodb-enterprise/2.6 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-enterprise-2.6.list
echo 'deb http://repo.mongodb.com/apt/ubuntu precise/mongodb-enterprise/2.4 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-enterprise-2.4.list
apt-get update
apt-get install -y libsnmp15 libgsasl7
sudo apt-get download mongodb-enterprise-server=3.2.0
sudo apt-get download mongodb-enterprise-mongos=3.2.0
sudo apt-get download mongodb-enterprise-server=3.0.3
sudo apt-get download mongodb-enterprise-server=2.6.9
sudo apt-get download mongodb-10gen-enterprise=2.4.13
dpkg -x mongodb-10gen-enterprise_2.4.13_amd64.deb 2.4.13
dpkg -x mongodb-enterprise-server_2.6.9_amd64.deb 2.6.9
dpkg -x mongodb-enterprise-server_3.0.3_amd64.deb 3.0.3
dpkg -x mongodb-enterprise-server_3.2.0_amd64.deb 3.2.0
dpkg -x mongodb-enterprise-mongos_3.2.0_amd64.deb 3.2.0
# Python stuff for mongo-orchestration
apt-get install -y python python-dev python-pip
pip install --upgrade 'git+https://github.com/10gen/mongo-orchestration.git#egg=mongo_orchestration'
# Launch mongo-orchestration
mongo-orchestration -f mongo-orchestration-config.json -b 192.168.112.10 --enable-majority-read-concern start
mongodb-1.1.5/scripts/ubuntu/phongo.sh 0000664 0001750 0001750 00000000566 12673034026 017654 0 ustar jmikola jmikola apt-get install -y php-pear php5-dbg gdb
apt-get install -y libssl-dev libsasl2-dev libpcre3-dev pkg-config
ls -1 /phongo/mongodb*.tgz | sort -n -r | xargs sudo pecl install -f 2>&1 > /phongo/.build
php -m | grep -q mongodb || echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
pecl run-tests -q -p mongodb 2>&1 > /phongo/.tests
mongodb-1.1.5/scripts/vmware/kernel.sh 0000664 0001750 0001750 00000000466 12673034026 017620 0 ustar jmikola jmikola # Ensure that VMWare Tools recompiles kernel modules
# when we update the linux images
sed -i.bak 's/answer AUTO_KMODS_ENABLED_ANSWER no/answer AUTO_KMODS_ENABLED_ANSWER yes/g' /etc/vmware-tools/locations
sed -i.bak 's/answer AUTO_KMODS_ENABLED no/answer AUTO_KMODS_ENABLED yes/g' /etc/vmware-tools/locations
mongodb-1.1.5/scripts/convert-mo-tests.php 0000664 0001750 0001750 00000021305 12673034026 020440 0 ustar jmikola jmikola
--FILE--
array(
"method" => "DELETE",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
}
function mo_post($url, $body) {
global $KILLLIST;
$url = getMOUri() . $url;
$opts = array("http" =>
array(
"method" => "POST",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"content" => json_encode($body),
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
$array = json_decode($out, true);
if ($array && !empty($array["mongodb_uri"])) {
$KILLLIST[] = $array["id"];
return $array["mongodb_uri"];
}
}
$KILLLIST = array();
$INITCONFIG = %INITCONFIG%;
$dsn = "%DSN%";
if ($INITCONFIG) {
$dsn = mo_post("/%URLTYPE%", $INITCONFIG);
}
$manager = new MongoDB\Driver\Manager($dsn);
%TESTPLAN%;
foreach($KILLLIST as $id) {
mo_delete("/%URLTYPE%/$id");
}
?>
===DONE===
--EXPECTF--
%OUTPUT%
===DONE===
TEMPLATE;
?>getMessage() . "\n";
}
file_put_contents($phptfile, $phpt);
}
function convert($test, $template) {
$TESTPLAN = array();
$OUTPUT = "";
$test["phases"] = isset($test["phases"]) ? $test["phases"] : array();
foreach($test["phases"] as $phase) {
$TESTPLAN[] = phase($phase, $output);
if ($output) {
ob_start();
var_dump($output);
$OUTPUT .= ob_get_contents();
ob_end_clean();
$OUTPUT = str_replace('2) "%s"', '%d) "%s"', $OUTPUT);
}
}
foreach($test["tests"] as $phase) {
$TESTPLAN[] = phase($phase, $output);
if ($output) {
ob_start();
var_dump($output);
$OUTPUT .= ob_get_contents();
ob_end_clean();
$OUTPUT = str_replace('2) "%s"', '%d) "%s"', $OUTPUT);
}
}
$replacements = array(
"%DSN%" => clientSetup($test),
"%DESCRIPTION%" => description($test),
"%INITCONFIG%" => initConfig($test),
"%URLTYPE%" => $test["type"],
"%TESTPLAN%" => join("\n\n", $TESTPLAN),
"%OUTPUT%" => rtrim($OUTPUT),
);
return makeTest($replacements, $template);
}
function phase($phase, &$output) {
$output = null;
if (isset($phase["MOOperation"])) {
return MOOperation($phase["MOOperation"], $output);
}
if (isset($phase["clientHosts"])) {
return clientHosts($phase["clientHosts"], $output);
}
if (isset($phase["clientOperation"])) {
return clientOperation($phase["clientOperation"], $output);
}
if (isset($phase["wait"])) {
return 'sleep(' . $phase["wait"] . ');';
}
throw new UnexpectedValueException("Don't know how to deal with " . json_encode($phase));
}
function MOOperation($phase, &$output) {
$method = strtolower($phase["method"]);
switch($method) {
case "post":
return 'mo_post("' . $phase["uri"] . '", ' . var_export($phase["payload"], true) . ');';
case "delete":
return 'mo_delete("' . $phase["uri"] . '");';
default:
throw new UnexpectedValueException("Don't know the method $method");
}
}
function clientHosts($hosts, &$output) {
$output = array();
$retval = <<< CODE
\$clientHosts = array();
CODE;
if (!empty($hosts['primary'])) {
$primary = var_export($hosts['primary'], true);
$retval .= <<< CODE
\$found = array_filter(\$manager->getServers(), function(\$server) {
return \$server->getHost() == $primary && \$server->getType() == MongoDB\\Driver\\SERVERTYPE_RS_PRIMARY;
});
if (count(\$found) == 1) {
\$clientHosts['primary'] = $primary;
}
CODE;
$output['primary'] = $hosts['primary'];
}
if (!empty($hosts['secondaries'])) {
foreach ($hosts['secondaries'] as $secondaryHost) {
$secondary = var_export($secondaryHost, true);
$retval .= <<< CODE
\$found = array_filter(\$manager->getServers(), function(\$server) {
return \$server->getHost() == $secondary && \$server->getType() == MongoDB\\Driver\\SERVERTYPE_RS_SECONDARY;
});
if (count(\$found) == 1) {
\$clientHosts['secondaries'][] = $secondary;
}
CODE;
$output['secondaries'][] = $secondaryHost;
}
}
$retval .= <<< CODE
var_dump(\$clientHosts);
CODE;
return $retval;
}
function clientOperation($phase, &$output) {
switch($phase["operation"]) {
case "insertOne":
$output = !isset($phase["outcome"]) ? array("ok" => 1) : $phase["outcome"];
if (!$output["ok"]) {
$output["errmsg"] = "%s";
}
$wc = !isset($phase["writeConcern"]) ? 1 : $phase["writeConcern"]["w"];
$doc = var_export($phase["doc"], true);;
$doc = str_replace("\n", "\n ", $doc);
$retval = <<< CODE
try {
\$wc = new MongoDB\\Driver\\WriteConcern($wc);
\$bulk = new MongoDB\Driver\BulkWrite();
\$bulk->insert($doc);
\$result = \$manager->executeBulkWrite("databaseName.collectionName", \$bulk, \$wc);
if (\$result->getInsertedCount() == 1) {
var_dump(array("ok" => 1));
} else {
var_dump(array("ok" => 0, "errmsg" => "getInsertedCount => " . \$result->getInsertedCount()));
}
} catch(Exception \$e) {
var_dump(array("ok" => 0, "errmsg" => get_class(\$e) . ": " . \$e->getMessage()));
}
CODE;
return $retval;
break;
case "find":
$output = $phase["outcome"];
if (!$output["ok"]) {
$output["errmsg"] = "%s";
}
$retval = <<< CODE
try {
\$query = new MongoDB\\Driver\\Query(array());
\$result = \$manager->executeQuery("databaseName.collectionName", \$query)->toArray();
var_dump(array("ok" => 1));
} catch(Exception \$e) {
var_dump(array("ok" => 0, "errmsg" => get_class(\$e) . ": " . \$e->getMessage()));
}
CODE;
return $retval;
break;
default:
throw new UnexpectedValueException("IDK what to do about {$phase["operation"]}");
}
}
function clientSetUp($test) {
$setup = $test["clientSetUp"];
if (!$setup) {
throw new UnexpectedValueException("No 'clientSetUp' key provided");
}
$seedlist = join(",", $setup["hosts"]);
$options = array();
if (!empty($setup["options"])) {
$entries = array();
foreach($setup["options"] as $k => $v) {
switch($k) {
case "readPreference":
$entries[] = "$k={$v["mode"]}";
break;
case "heartbeatFrequency":
$entries[] = "$k=$v";
break;
default:
throw new Exception("Don't know how to handle '$k'");
}
}
$options = join("&", $entries);
}
if ($options) {
return sprintf("mongodb://%s/?%s", $seedlist, $options);
} else {
return sprintf("mongodb://%s", $seedlist);
}
}
function makeTest($replacements, $template) {
return str_replace(array_keys($replacements), array_values($replacements), $template);
}
function description($test) {
static $count = 0;
$desc = $test["description"];
return sprintf("Cluster Integration Test#%03d: %s", ++$count, $desc);
}
function initConfig($test) {
// The initConfig entry alone isn't valid MO post
$config = $test["initConfig"];
$config["name"] = "mongod";
return var_export($config, true);
}
mongodb-1.1.5/scripts/list-servers.php 0000664 0001750 0001750 00000000340 12673034026 017645 0 ustar jmikola jmikola $uri) {
printf("%-20s \t %s\n", $serverid, $uri);
}
mongodb-1.1.5/scripts/start-servers.php 0000664 0001750 0001750 00000020370 12673034026 020034 0 ustar jmikola jmikola [
"scripts/presets/standalone.json",
"scripts/presets/standalone-24.json",
"scripts/presets/standalone-26.json",
"scripts/presets/standalone-30.json",
"scripts/presets/standalone-ssl.json",
"scripts/presets/standalone-auth.json",
"scripts/presets/standalone-x509.json",
"scripts/presets/standalone-plain.json",
],
"replicasets" => [
"scripts/presets/replicaset.json",
"scripts/presets/replicaset-30.json",
],
];
function make_ctx($preset, $method = "POST") {
$opts = [
"http" => [
"timeout" => 60,
"method" => $method,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"content" => json_encode(array("preset" => $preset)),
"ignore_errors" => true,
],
];
$ctx = stream_context_create($opts);
return $ctx;
}
function failed($result) {
echo "\n\n";
echo join("\n", $result);
printf("Last operation took: %.2f secs\n", lap());
exit();
}
function mo_http_request($uri, $context) {
global $http_response_header;
$result = file_get_contents($uri, false, $context);
if ($result === false) {
failed($http_response_header);
}
return $result;
}
printf("Cleaning out previous processes, if any ");
lap();
/* Remove all pre-existing ReplicaSets */
$replicasets = mo_http_request(getMOUri() . "/replica_sets", make_ctx(getMOPresetBase(), "GET"));
$replicasets = json_decode($replicasets, true);
foreach($replicasets["replica_sets"] as $replicaset) {
$uri = getMOUri() . "/replica_sets/" . $replicaset["id"];
mo_http_request($uri, make_ctx(getMOPresetBase(), "DELETE"));
echo ".";
}
echo " ";
/* Remove all pre-existing servers */
$servers = mo_http_request(getMOUri() . "/servers", make_ctx(getMOPresetBase(), "GET"));
$servers = json_decode($servers, true);
foreach($servers["servers"] as $server) {
$uri = getMOUri() . "/servers/" . $server["id"];
mo_http_request($uri, make_ctx(getMOPresetBase(), "DELETE"));
echo ".";
}
printf("\t(took: %.2f secs)\n", lap());
foreach($PRESETS["standalone"] as $preset) {
lap();
$json = json_decode(file_get_contents($preset), true);
printf("Starting %-20s ... ", $json["id"]);
$result = mo_http_request(getMOUri() . "/servers", make_ctx(getMOPresetBase() . $preset));
$decode = json_decode($result, true);
if (!isset($decode["id"])) {
failed($decode);
}
$SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"];
printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap());
}
echo "---\n";
foreach($PRESETS["replicasets"] as $preset) {
lap();
$json = json_decode(file_get_contents($preset), true);
printf("Starting %-20s ... ", $json["id"]);
$result = mo_http_request(getMOUri() . "/replica_sets", make_ctx(getMOPresetBase() . $preset));
$decode = json_decode($result, true);
if (!isset($decode["id"])) {
failed($decode);
}
$SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"];
printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap());
}
file_put_contents($FILENAME, json_encode($SERVERS, JSON_PRETTY_PRINT));
/*
wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-AUTH
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-24
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-26
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/RS-two
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/RS-arbiter
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-PLAIN
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-X509
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/RS-one
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers/STANDALONE-SSL
wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/replica_sets
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/replica_sets/REPLICASET
wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/
wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/replica_sets
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/standalone.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/standalone-24.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/standalone-26.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/standalone-ssl.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/standalone-auth.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/standalone-x509.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/standalone-plain.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/servers
wget --body-data='{"preset":"\/phongo\/\/scripts\/presets\/replicaset.json"}' --method='POST' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded' http://192.168.112.10:8889/replica_sets
*/
mongodb-1.1.5/src/BSON/Binary.c 0000664 0001750 0001750 00000016700 12673034026 015732 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_binary_ce;
zend_object_handlers php_phongo_handler_binary;
/* {{{ proto BSON\Binary Binary::__construct(string $data, int $type)
Construct a new BSON Binary type */
PHP_METHOD(Binary, __construct)
{
php_phongo_binary_t *intern;
zend_error_handling error_handling;
char *data;
phongo_zpp_char_len data_len;
phongo_long type;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_BINARY_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &data, &data_len, &type) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (type < 0 || type > UINT8_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected type to be an unsigned 8-bit integer, %" PHONGO_LONG_FORMAT " given", type);
return;
}
intern->data = estrndup(data, data_len);
intern->data_len = data_len;
intern->type = (uint8_t) type;
}
/* }}} */
/* {{{ proto string Binary::getData()
*/
PHP_METHOD(Binary, getData)
{
php_phongo_binary_t *intern;
intern = Z_BINARY_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->data, intern->data_len);
}
/* }}} */
/* {{{ proto integer Binary::getType()
*/
PHP_METHOD(Binary, getType)
{
php_phongo_binary_t *intern;
intern = Z_BINARY_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->type);
}
/* }}} */
/* {{{ BSON\Binary */
ZEND_BEGIN_ARG_INFO_EX(ai_Binary___construct, 0, 0, 2)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, type)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Binary_getData, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Binary_getType, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_binary_me[] = {
PHP_ME(Binary, __construct, ai_Binary___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, getData, ai_Binary_getData, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Binary, getType, ai_Binary_getType, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_binary_t object handlers */
static void php_phongo_binary_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern = Z_OBJ_BINARY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->data) {
efree(intern->data);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_binary_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_binary_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_binary;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_binary_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_binary;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_binary_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_binary_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
intern = Z_BINARY_OBJ_P(object);
*is_temp = 1;
array_init_size(&retval, 2);
ADD_ASSOC_STRINGL(&retval, "data", intern->data, intern->data_len);
ADD_ASSOC_LONG_EX(&retval, "type", intern->type);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Binary)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Binary", php_phongo_binary_me);
php_phongo_binary_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_binary_ce->create_object = php_phongo_binary_create_object;
PHONGO_CE_INIT(php_phongo_binary_ce);
zend_class_implements(php_phongo_binary_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_binary, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_binary.get_debug_info = php_phongo_binary_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_binary.free_obj = php_phongo_binary_free_object;
php_phongo_handler_binary.offset = XtOffsetOf(php_phongo_binary_t, std);
#endif
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_GENERIC"), BSON_SUBTYPE_BINARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_FUNCTION"), BSON_SUBTYPE_FUNCTION TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_OLD_BINARY"), BSON_SUBTYPE_BINARY_DEPRECATED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_OLD_UUID"), BSON_SUBTYPE_UUID_DEPRECATED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_UUID"), BSON_SUBTYPE_UUID TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_MD5"), BSON_SUBTYPE_MD5 TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_binary_ce, ZEND_STRL("TYPE_USER_DEFINED"), BSON_SUBTYPE_USER TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/Javascript.c 0000664 0001750 0001750 00000015410 12673034026 016611 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_javascript_ce;
zend_object_handlers php_phongo_handler_javascript;
/* {{{ proto BSON\Javascript Javascript::__construct(string $javascript[, array|object $document])
* The string is JavaScript code. The document is a mapping from identifiers to values, representing the scope in which the string should be evaluated
* NOTE: eJSON does not support this type :( */
PHP_METHOD(Javascript, __construct)
{
php_phongo_javascript_t *intern;
zend_error_handling error_handling;
char *javascript;
phongo_zpp_char_len javascript_len;
zval *document = NULL;
bson_t scope = BSON_INITIALIZER;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_JAVASCRIPT_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|A!", &javascript, &javascript_len, &document) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (document) {
phongo_zval_to_bson(document, PHONGO_BSON_NONE, &scope, NULL TSRMLS_CC);
}
php_phongo_new_javascript_from_javascript_and_scope(0, getThis(), javascript, javascript_len, &scope TSRMLS_CC);
bson_destroy(&scope);
}
/* }}} */
/* {{{ BSON\Javascript */
ZEND_BEGIN_ARG_INFO_EX(ai_Javascript___construct, 0, 0, 1)
ZEND_ARG_INFO(0, javascript)
ZEND_ARG_INFO(0, scope)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_javascript_me[] = {
PHP_ME(Javascript, __construct, ai_Javascript___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_javascript_t object handlers */
static void php_phongo_javascript_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern = Z_OBJ_JAVASCRIPT(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->javascript) {
efree(intern->javascript);
}
if (intern->document) {
bson_destroy(intern->document);
intern->document = NULL;
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_javascript_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_javascript_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
intern->document = NULL;
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_javascript;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_javascript_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_javascript;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_javascript_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_javascript_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_JAVASCRIPT_OBJ_P(object);
array_init(&retval);
ADD_ASSOC_STRINGL(&retval, "javascript", intern->javascript, intern->javascript_len);
if (intern->document) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
if (phongo_bson_to_zval_ex(bson_get_data(intern->document), intern->document->len, &state)) {
#if PHP_VERSION_ID >= 70000
Z_ADDREF(state.zchild);
ADD_ASSOC_ZVAL_EX(&retval, "scope", &state.zchild);
#else
Z_ADDREF_P(state.zchild);
ADD_ASSOC_ZVAL_EX(&retval, "scope", state.zchild);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "scope");
}
zval_ptr_dtor(&state.zchild);
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Javascript)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Javascript", php_phongo_javascript_me);
php_phongo_javascript_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_javascript_ce->create_object = php_phongo_javascript_create_object;
PHONGO_CE_INIT(php_phongo_javascript_ce);
zend_class_implements(php_phongo_javascript_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_javascript, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_javascript.get_debug_info = php_phongo_javascript_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_javascript.free_obj = php_phongo_javascript_free_object;
php_phongo_handler_javascript.offset = XtOffsetOf(php_phongo_javascript_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/MaxKey.c 0000664 0001750 0001750 00000010004 12673034026 015673 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_maxkey_ce;
zend_object_handlers php_phongo_handler_maxkey;
/* {{{ BSON\MaxKey */
static zend_function_entry php_phongo_maxkey_me[] = {
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_maxkey_t object handlers */
static void php_phongo_maxkey_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_maxkey_t *intern = Z_OBJ_MAXKEY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_maxkey_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_maxkey_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_maxkey_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_maxkey;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_maxkey_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_maxkey;
return retval;
}
#endif
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(MaxKey)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MaxKey", php_phongo_maxkey_me);
php_phongo_maxkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_maxkey_ce->create_object = php_phongo_maxkey_create_object;
PHONGO_CE_INIT(php_phongo_maxkey_ce);
zend_class_implements(php_phongo_maxkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_maxkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
#if PHP_VERSION_ID >= 70000
php_phongo_handler_maxkey.free_obj = php_phongo_maxkey_free_object;
php_phongo_handler_maxkey.offset = XtOffsetOf(php_phongo_maxkey_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/MinKey.c 0000664 0001750 0001750 00000010005 12673034026 015672 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_minkey_ce;
zend_object_handlers php_phongo_handler_minkey;
/* {{{ BSON\MinKey */
static zend_function_entry php_phongo_minkey_me[] = {
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_minkey_t object handlers */
static void php_phongo_minkey_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_minkey_t *intern = Z_OBJ_MINKEY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_minkey_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_minkey_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_minkey_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_minkey;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_minkey_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_minkey;
return retval;
}
#endif
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(MinKey)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "MinKey", php_phongo_minkey_me);
php_phongo_minkey_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_minkey_ce->create_object = php_phongo_minkey_create_object;
PHONGO_CE_INIT(php_phongo_minkey_ce);
zend_class_implements(php_phongo_minkey_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_minkey, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
#if PHP_VERSION_ID >= 70000
php_phongo_handler_minkey.free_obj = php_phongo_minkey_free_object;
php_phongo_handler_minkey.offset = XtOffsetOf(php_phongo_minkey_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/ObjectID.c 0000664 0001750 0001750 00000015200 12673034026 016123 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_objectid_ce;
zend_object_handlers php_phongo_handler_objectid;
/* {{{ proto BSON\ObjectID ObjectID::__construct(string $id)
Constructs a new Object ID, optionally from a string */
PHP_METHOD(ObjectID, __construct)
{
php_phongo_objectid_t *intern;
zend_error_handling error_handling;
char *id = NULL;
phongo_zpp_char_len id_len;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_OBJECTID_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &id, &id_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (id) {
zend_str_tolower(id, id_len);
if (bson_oid_is_valid(id, id_len)) {
bson_oid_t oid;
bson_oid_init_from_string(&oid, id);
bson_oid_to_string(&oid, intern->oid);
} else {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "%s", "Invalid BSON ID provided");
}
} else {
bson_oid_t oid;
bson_oid_init(&oid, NULL);
bson_oid_to_string(&oid, intern->oid);
}
}
/* }}} */
/* {{{ proto void ObjectID::__toString()
*/
PHP_METHOD(ObjectID, __toString)
{
php_phongo_objectid_t *intern;
intern = Z_OBJECTID_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->oid, 24);
}
/* }}} */
/* {{{ BSON\ObjectID */
ZEND_BEGIN_ARG_INFO_EX(ai_ObjectID___construct, 0, 0, 0)
ZEND_ARG_INFO(0, id)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_ObjectID___toString, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_objectid_me[] = {
PHP_ME(ObjectID, __construct, ai_ObjectID___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ObjectID, __toString, ai_ObjectID___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_objectid_t object handlers */
static void php_phongo_objectid_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern = Z_OBJ_OBJECTID(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_objectid_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_objectid_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_objectid;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_objectid_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_objectid;
return retval;
}
#endif
} /* }}} */
static int php_phongo_objectid_compare_objects(zval *o1, zval *o2 TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern1;
php_phongo_objectid_t *intern2;
intern1 = Z_OBJECTID_OBJ_P(o1);
intern2 = Z_OBJECTID_OBJ_P(o2);
return strcmp(intern1->oid, intern2->oid);
} /* }}} */
HashTable *php_phongo_objectid_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_objectid_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_OBJECTID_OBJ_P(object);
array_init(&retval);
ADD_ASSOC_STRINGL(&retval, "oid", intern->oid, 24);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ObjectID)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "ObjectID", php_phongo_objectid_me);
php_phongo_objectid_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_objectid_ce->create_object = php_phongo_objectid_create_object;
PHONGO_CE_INIT(php_phongo_objectid_ce);
zend_class_implements(php_phongo_objectid_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_objectid, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_objectid.compare_objects = php_phongo_objectid_compare_objects;
php_phongo_handler_objectid.get_debug_info = php_phongo_objectid_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_objectid.free_obj = php_phongo_objectid_free_object;
php_phongo_handler_objectid.offset = XtOffsetOf(php_phongo_objectid_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/Persistable.c 0000664 0001750 0001750 00000005153 12673034026 016763 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_persistable_ce;
/* {{{ BSON\Persistable */
static zend_function_entry php_phongo_persistable_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Persistable)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Persistable", php_phongo_persistable_me);
php_phongo_persistable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
zend_class_implements(php_phongo_persistable_ce TSRMLS_CC, 2, php_phongo_unserializable_ce, php_phongo_serializable_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/Regex.c 0000664 0001750 0001750 00000016355 12673034026 015566 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_regex_ce;
zend_object_handlers php_phongo_handler_regex;
/* {{{ proto BSON\Regex Regex::__construct(string $pattern, string $flags)
Constructs a new regular expression. */
PHP_METHOD(Regex, __construct)
{
php_phongo_regex_t *intern;
zend_error_handling error_handling;
char *pattern;
phongo_zpp_char_len pattern_len;
char *flags;
phongo_zpp_char_len flags_len;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &pattern, &pattern_len, &flags, &flags_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
intern->pattern = estrndup(pattern, pattern_len);
intern->pattern_len = pattern_len;
intern->flags = estrndup(flags, flags_len);
intern->flags_len = flags_len;
}
/* }}} */
/* {{{ proto void Regex::getPattern()
*/
PHP_METHOD(Regex, getPattern)
{
php_phongo_regex_t *intern;
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->pattern, intern->pattern_len);
}
/* }}} */
/* {{{ proto void Regex::getFlags()
*/
PHP_METHOD(Regex, getFlags)
{
php_phongo_regex_t *intern;
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
PHONGO_RETURN_STRINGL(intern->flags, intern->flags_len);
}
/* }}} */
/* {{{ proto void Regex::__toString()
*/
PHP_METHOD(Regex, __toString)
{
php_phongo_regex_t *intern;
char *regex;
int regex_len;
intern = Z_REGEX_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
regex_len = spprintf(®ex, 0, "/%s/%s", intern->pattern, intern->flags);
PHONGO_RETVAL_STRINGL(regex, regex_len);
efree(regex);
}
/* }}} */
/* {{{ BSON\Regex */
ZEND_BEGIN_ARG_INFO_EX(ai_Regex___construct, 0, 0, 2)
ZEND_ARG_INFO(0, pattern)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Regex_getPattern, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Regex_getFlags, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Regex___toString, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_regex_me[] = {
PHP_ME(Regex, __construct, ai_Regex___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, getPattern, ai_Regex_getPattern, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, getFlags, ai_Regex_getFlags, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Regex, __toString, ai_Regex___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_regex_t object handlers */
static void php_phongo_regex_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern = Z_OBJ_REGEX(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->pattern) {
efree(intern->pattern);
}
if (intern->flags) {
efree(intern->flags);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_regex_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_regex_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_regex;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_regex_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_regex;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_regex_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_regex_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_REGEX_OBJ_P(object);
array_init(&retval);
ADD_ASSOC_STRINGL(&retval, "pattern", intern->pattern, intern->pattern_len);
ADD_ASSOC_STRINGL(&retval, "flags", intern->flags, intern->flags_len);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Regex)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Regex", php_phongo_regex_me);
php_phongo_regex_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_regex_ce->create_object = php_phongo_regex_create_object;
PHONGO_CE_INIT(php_phongo_regex_ce);
zend_class_implements(php_phongo_regex_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_regex, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_regex.get_debug_info = php_phongo_regex_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_regex.free_obj = php_phongo_regex_free_object;
php_phongo_handler_regex.offset = XtOffsetOf(php_phongo_regex_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/Serializable.c 0000664 0001750 0001750 00000005360 12673034026 017114 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_serializable_ce;
/* {{{ BSON\Serializable */
ZEND_BEGIN_ARG_INFO_EX(ai_serializable_bsonserialize, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_serializable_me[] = {
ZEND_ABSTRACT_ME(Serializable, bsonSerialize, ai_serializable_bsonserialize)
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Serializable)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Serializable", php_phongo_serializable_me);
php_phongo_serializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
zend_class_implements(php_phongo_serializable_ce TSRMLS_CC, 1, php_phongo_type_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/Timestamp.c 0000664 0001750 0001750 00000015452 12673034026 016454 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_timestamp_ce;
zend_object_handlers php_phongo_handler_timestamp;
/* {{{ proto BSON\Timestamp Timestamp::__construct(integer $increment, int $timestamp)
Construct a new BSON Timestamp (4bytes increment, 4bytes timestamp) */
PHP_METHOD(Timestamp, __construct)
{
php_phongo_timestamp_t *intern;
zend_error_handling error_handling;
phongo_long increment;
phongo_long timestamp;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_TIMESTAMP_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &increment, ×tamp) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (increment < 0 || increment > UINT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected increment to be an unsigned 32-bit integer, %" PHONGO_LONG_FORMAT " given", increment);
return;
}
if (timestamp < 0 || timestamp > UINT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected timestamp to be an unsigned 32-bit integer, %" PHONGO_LONG_FORMAT " given", timestamp);
return;
}
intern->increment = increment;
intern->timestamp = timestamp;
}
/* }}} */
/* {{{ proto string Timestamp::__toString()
Returns [increment:timestamp] */
PHP_METHOD(Timestamp, __toString)
{
php_phongo_timestamp_t *intern;
char *retval;
int retval_len;
intern = Z_TIMESTAMP_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
retval_len = spprintf(&retval, 0, "[%" PRIu32 ":%" PRIu32 "]", intern->increment, intern->timestamp);
PHONGO_RETVAL_STRINGL(retval, retval_len);
efree(retval);
}
/* }}} */
/* {{{ BSON\Timestamp */
ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp___construct, 0, 0, 2)
ZEND_ARG_INFO(0, increment)
ZEND_ARG_INFO(0, timestamp)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Timestamp___toString, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_timestamp_me[] = {
PHP_ME(Timestamp, __construct, ai_Timestamp___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Timestamp, __toString, ai_Timestamp___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_timestamp_t object handlers */
static void php_phongo_timestamp_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern = Z_OBJ_TIMESTAMP(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_timestamp_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_timestamp_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_timestamp;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_timestamp_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_timestamp;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_timestamp_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_timestamp_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_TIMESTAMP_OBJ_P(object);
array_init(&retval);
ADD_ASSOC_LONG_EX(&retval, "increment", intern->increment);
ADD_ASSOC_LONG_EX(&retval, "timestamp", intern->timestamp);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Timestamp)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Timestamp", php_phongo_timestamp_me);
php_phongo_timestamp_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_timestamp_ce->create_object = php_phongo_timestamp_create_object;
PHONGO_CE_INIT(php_phongo_timestamp_ce);
zend_class_implements(php_phongo_timestamp_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_timestamp, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_timestamp.get_debug_info = php_phongo_timestamp_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_timestamp.free_obj = php_phongo_timestamp_free_object;
php_phongo_handler_timestamp.offset = XtOffsetOf(php_phongo_timestamp_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/Type.c 0000664 0001750 0001750 00000004700 12673034026 015424 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_type_ce;
/* {{{ BSON\Type */
static zend_function_entry php_phongo_type_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Type)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Type", php_phongo_type_me);
php_phongo_type_ce = zend_register_internal_interface(&ce TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/UTCDateTime.c 0000664 0001750 0001750 00000016611 12673034026 016557 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_utcdatetime_ce;
zend_object_handlers php_phongo_handler_utcdatetime;
/* {{{ proto BSON\UTCDateTime UTCDateTime::__construct(integer $milliseconds)
Construct a new UTCDateTime */
PHP_METHOD(UTCDateTime, __construct)
{
php_phongo_utcdatetime_t *intern;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_UTCDATETIME_OBJ_P(getThis());
#if SIZEOF_PHONGO_LONG == 8
{
phongo_long milliseconds;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &milliseconds) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
intern->milliseconds = milliseconds;
}
#elif SIZEOF_PHONGO_LONG == 4
{
char *s_milliseconds;
phongo_zpp_char_len s_milliseconds_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &s_milliseconds, &s_milliseconds_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
intern->milliseconds = STRTOLL(s_milliseconds);
}
#else
# error Unsupported architecture (integers are neither 32-bit nor 64-bit)
#endif
zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
/* {{{ proto string UTCDateTime::__toString()
Returns the string representation of the UTCDateTime */
PHP_METHOD(UTCDateTime, __toString)
{
php_phongo_utcdatetime_t *intern;
char *tmp;
int tmp_len;
intern = Z_UTCDATETIME_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
tmp_len = spprintf(&tmp, 0, "%" PRId64, intern->milliseconds);
PHONGO_RETVAL_STRINGL(tmp, tmp_len);
efree(tmp);
}
/* }}} */
/* {{{ proto string UTCDateTime::toDateTime()
Returns DateTime object representing this UTCDateTime */
PHP_METHOD(UTCDateTime, toDateTime)
{
php_phongo_utcdatetime_t *intern;
intern = Z_UTCDATETIME_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
php_phongo_new_datetime_from_utcdatetime(return_value, intern->milliseconds TSRMLS_CC);
}
/* }}} */
/* {{{ BSON\UTCDateTime */
ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime___construct, 0, 0, 1)
ZEND_ARG_INFO(0, milliseconds)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime___toString, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_UTCDateTime_toDateTime, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_utcdatetime_me[] = {
PHP_ME(UTCDateTime, __construct, ai_UTCDateTime___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(UTCDateTime, __toString, ai_UTCDateTime___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(UTCDateTime, toDateTime, ai_UTCDateTime_toDateTime, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_utcdatetime_t object handlers */
static void php_phongo_utcdatetime_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern = Z_OBJ_UTCDATETIME(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_utcdatetime_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_utcdatetime_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_utcdatetime;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_utcdatetime_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_utcdatetime;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_utcdatetime_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_utcdatetime_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_UTCDATETIME_OBJ_P(object);
array_init(&retval);
#if SIZEOF_LONG == 4
{
char tmp[24];
int tmp_len;
tmp_len = snprintf(tmp, sizeof(tmp), "%" PRId64, intern->milliseconds);
ADD_ASSOC_STRINGL(&retval, "milliseconds", tmp, tmp_len);
}
#else
ADD_ASSOC_LONG_EX(&retval, "milliseconds", intern->milliseconds);
#endif
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(UTCDateTime)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "UTCDateTime", php_phongo_utcdatetime_me);
php_phongo_utcdatetime_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_utcdatetime_ce->create_object = php_phongo_utcdatetime_create_object;
PHONGO_CE_INIT(php_phongo_utcdatetime_ce);
zend_class_implements(php_phongo_utcdatetime_ce TSRMLS_CC, 1, php_phongo_type_ce);
memcpy(&php_phongo_handler_utcdatetime, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_utcdatetime.get_debug_info = php_phongo_utcdatetime_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_utcdatetime.free_obj = php_phongo_utcdatetime_free_object;
php_phongo_handler_utcdatetime.offset = XtOffsetOf(php_phongo_utcdatetime_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/BSON/Unserializable.c 0000664 0001750 0001750 00000005326 12673034026 017461 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_unserializable_ce;
/* {{{ BSON\Unserializable */
ZEND_BEGIN_ARG_INFO_EX(ai_unserializable_bsonunserialize, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, data, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_unserializable_me[] = {
ZEND_ABSTRACT_ME(Unserializable, bsonUnserialize, ai_unserializable_bsonunserialize)
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Unserializable)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, BSON_NAMESPACE, "Unserializable", php_phongo_unserializable_me);
php_phongo_unserializable_ce = zend_register_internal_interface(&ce TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/AuthenticationException.c 0000664 0001750 0001750 00000005507 12673034026 024031 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_authenticationexception_ce;
/* {{{ MongoDB\Driver\AuthenticationException */
static zend_function_entry php_phongo_authenticationexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(AuthenticationException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "AuthenticationException", php_phongo_authenticationexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_authenticationexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
#else
php_phongo_authenticationexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/BulkWriteException.c 0000664 0001750 0001750 00000005425 12673034026 022761 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_bulkwriteexception_ce;
/* {{{ MongoDB\Driver\BulkWriteException */
static zend_function_entry php_phongo_bulkwriteexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(BulkWriteException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "BulkWriteException", php_phongo_bulkwriteexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_bulkwriteexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce);
#else
php_phongo_bulkwriteexception_ce = zend_register_internal_class_ex(&ce, php_phongo_writeexception_ce, NULL TSRMLS_CC);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/ConnectionException.c 0000664 0001750 0001750 00000005441 12673034026 023146 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_connectionexception_ce;
/* {{{ MongoDB\Driver\ConnectionException */
static zend_function_entry php_phongo_connectionexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ConnectionException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionException", php_phongo_connectionexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_connectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
#else
php_phongo_connectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/ConnectionTimeoutException.c 0000664 0001750 0001750 00000005623 12673034026 024517 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_connectiontimeoutexception_ce;
/* {{{ MongoDB\Driver\ConnectionTimeoutException */
static zend_function_entry php_phongo_connectiontimeoutexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ConnectionTimeoutException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ConnectionTimeoutException", php_phongo_connectiontimeoutexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
#else
php_phongo_connectiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
#endif
PHONGO_CE_INIT(php_phongo_connectiontimeoutexception_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/Exception.c 0000664 0001750 0001750 00000005033 12673034026 021123 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_exception_ce;
/* {{{ MongoDB\Driver\Exception */
static zend_function_entry php_phongo_exception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Exception)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "Exception", php_phongo_exception_me);
php_phongo_exception_ce = zend_register_internal_interface(&ce TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/ExecutionTimeoutException.c 0000664 0001750 0001750 00000005604 12673034026 024362 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_executiontimeoutexception_ce;
/* {{{ MongoDB\Driver\ExecutionTimeoutException */
static zend_function_entry php_phongo_executiontimeoutexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ExecutionTimeoutException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "ExecutionTimeoutException", php_phongo_executiontimeoutexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
#else
php_phongo_executiontimeoutexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
#endif
PHONGO_CE_INIT(php_phongo_executiontimeoutexception_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/InvalidArgumentException.c 0000664 0001750 0001750 00000005661 12673034026 024144 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_invalidargumentexception_ce;
/* {{{ MongoDB\Driver\InvalidArgumentException */
static zend_function_entry php_phongo_invalidargumentexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(InvalidArgumentException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "InvalidArgumentException", php_phongo_invalidargumentexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_invalidargumentexception_ce = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException);
#else
php_phongo_invalidargumentexception_ce = zend_register_internal_class_ex(&ce, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
#endif
zend_class_implements(php_phongo_invalidargumentexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/LogicException.c 0000664 0001750 0001750 00000005503 12673034026 022103 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_logicexception_ce;
/* {{{ MongoDB\Driver\LogicException */
static zend_function_entry php_phongo_logicexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(LogicException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "LogicException", php_phongo_logicexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_logicexception_ce = zend_register_internal_class_ex(&ce, spl_ce_LogicException);
#else
php_phongo_logicexception_ce = zend_register_internal_class_ex(&ce, spl_ce_LogicException, NULL TSRMLS_CC);
#endif
zend_class_implements(php_phongo_logicexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/RuntimeException.c 0000664 0001750 0001750 00000005531 12673034026 022472 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_runtimeexception_ce;
/* {{{ MongoDB\Driver\RuntimeException */
static zend_function_entry php_phongo_runtimeexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(RuntimeException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "RuntimeException", php_phongo_runtimeexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_runtimeexception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException);
#else
php_phongo_runtimeexception_ce = zend_register_internal_class_ex(&ce, spl_ce_RuntimeException, NULL TSRMLS_CC);
#endif
zend_class_implements(php_phongo_runtimeexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/SSLConnectionException.c 0000664 0001750 0001750 00000005557 12673034026 023540 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_sslconnectionexception_ce;
/* {{{ MongoDB\Driver\SSLConnectionException */
static zend_function_entry php_phongo_sslconnectionexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(SSLConnectionException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "SSLConnectionException", php_phongo_sslconnectionexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce);
#else
php_phongo_sslconnectionexception_ce = zend_register_internal_class_ex(&ce, php_phongo_connectionexception_ce, NULL TSRMLS_CC);
#endif
PHONGO_CE_INIT(php_phongo_sslconnectionexception_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/UnexpectedValueException.c 0000664 0001750 0001750 00000005661 12673034026 024154 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_unexpectedvalueexception_ce;
/* {{{ MongoDB\Driver\UnexpectedValueException */
static zend_function_entry php_phongo_unexpectedvalueexception_me[] = {
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(UnexpectedValueException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "UnexpectedValueException", php_phongo_unexpectedvalueexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_unexpectedvalueexception_ce = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException);
#else
php_phongo_unexpectedvalueexception_ce = zend_register_internal_class_ex(&ce, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
#endif
zend_class_implements(php_phongo_unexpectedvalueexception_ce TSRMLS_CC, 1, php_phongo_exception_ce);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Exception/WriteException.c 0000664 0001750 0001750 00000007474 12673034026 022151 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#include
PHONGO_API zend_class_entry *php_phongo_writeexception_ce;
/* {{{ proto MongoDB\Driver\WriteResult WriteException::getWriteResult()
Returns the WriteResult from the failed write operation. */
PHP_METHOD(WriteException, getWriteResult)
{
zval *writeresult;
#if PHP_VERSION_ID >= 70000
zval rv;
#endif
if (zend_parse_parameters_none() == FAILURE) {
return;
}
#if PHP_VERSION_ID >= 70000
writeresult = zend_read_property(php_phongo_writeexception_ce, getThis(), ZEND_STRL("writeResult"), 0, &rv TSRMLS_CC);
#else
writeresult = zend_read_property(php_phongo_writeexception_ce, getThis(), ZEND_STRL("writeResult"), 0 TSRMLS_CC);
#endif
RETURN_ZVAL(writeresult, 1, 0);
}
/* }}} */
/**
* Value object for write concern used in issuing write operations.
*/
/* {{{ MongoDB\Driver\WriteException */
ZEND_BEGIN_ARG_INFO_EX(ai_WriteException_getWriteResult, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_writeexception_me[] = {
PHP_ME(WriteException, getWriteResult, ai_WriteException_getWriteResult, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(WriteException)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver\\Exception", "WriteException", php_phongo_writeexception_me);
#if PHP_VERSION_ID >= 70000
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce);
#else
php_phongo_writeexception_ce = zend_register_internal_class_ex(&ce, php_phongo_runtimeexception_ce, NULL TSRMLS_CC);
#endif
php_phongo_writeexception_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;
zend_declare_property_null(php_phongo_writeexception_ce, ZEND_STRL("writeResult"), ZEND_ACC_PROTECTED TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/BulkWrite.c 0000664 0001750 0001750 00000030162 12673034026 017140 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* We need to access the internal bulk structure to access the bulk op count */
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_bulkwrite_ce;
zend_object_handlers php_phongo_handler_bulkwrite;
/* {{{ proto MongoDB\Driver\BulkWrite BulkWrite::__construct([array $options = array()])
Constructs a new BulkWrite */
PHP_METHOD(BulkWrite, __construct)
{
php_phongo_bulkwrite_t *intern;
zend_error_handling error_handling;
zval *options = NULL;
zend_bool ordered = 1;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!", &options) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (options && php_array_exists(options, "ordered")) {
ordered = php_array_fetch_bool(options, "ordered");
}
intern->bulk = phongo_bulkwrite_init(ordered);
if (options && php_array_exists(options, "bypassDocumentValidation")) {
mongoc_bulk_operation_set_bypass_document_validation(intern->bulk, php_array_fetch_bool(options, "bypassDocumentValidation"));
}
}
/* }}} */
/* {{{ proto mixed BulkWrite::insert(array|object $document)
Adds an insert operation to the bulk */
PHP_METHOD(BulkWrite, insert)
{
php_phongo_bulkwrite_t *intern;
zval *document;
bson_t *bson;
bson_t *bson_out = NULL;
int bson_flags = PHONGO_BSON_ADD_ID;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A", &document) == FAILURE) {
return;
}
if (return_value_used) {
bson_flags |= PHONGO_BSON_RETURN_ID;
}
bson = bson_new();
phongo_zval_to_bson(document, bson_flags, bson, &bson_out TSRMLS_CC);
mongoc_bulk_operation_insert(intern->bulk, bson);
bson_clear(&bson);
if (bson_out && return_value_used) {
bson_iter_t iter;
if (bson_iter_init_find(&iter, bson_out, "_id")) {
php_phongo_objectid_new_from_oid(return_value, bson_iter_oid(&iter) TSRMLS_CC);
bson_clear(&bson_out);
return;
}
bson_clear(&bson_out);
}
}
/* }}} */
/* {{{ proto void BulkWrite::update(array|object $query, array|object $newObj[, array $updateOptions = array()])
Adds an update operation to bulk */
PHP_METHOD(BulkWrite, update)
{
php_phongo_bulkwrite_t *intern;
zval *query;
zval *newObj;
zval *updateOptions = NULL;
mongoc_update_flags_t flags = MONGOC_UPDATE_NONE;
bson_t *bquery;
bson_t *bupdate;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "AA|a!", &query, &newObj, &updateOptions) == FAILURE) {
return;
}
bquery = bson_new();
bupdate = bson_new();
phongo_zval_to_bson(query, PHONGO_BSON_NONE, bquery, NULL TSRMLS_CC);
phongo_zval_to_bson(newObj, PHONGO_BSON_NONE, bupdate, NULL TSRMLS_CC);
if (updateOptions) {
flags |= php_array_fetch_bool(updateOptions, "multi") ? MONGOC_UPDATE_MULTI_UPDATE : 0;
flags |= php_array_fetch_bool(updateOptions, "upsert") ? MONGOC_UPDATE_UPSERT : 0;
}
if (flags & MONGOC_UPDATE_MULTI_UPDATE) {
mongoc_bulk_operation_update(intern->bulk, bquery, bupdate, !!(flags & MONGOC_UPDATE_UPSERT));
} else {
bson_iter_t iter;
zend_bool replaced = 0;
if (bson_iter_init(&iter, bupdate)) {
while (bson_iter_next (&iter)) {
if (!strchr (bson_iter_key (&iter), '$')) {
mongoc_bulk_operation_replace_one(intern->bulk, bquery, bupdate, !!(flags & MONGOC_UPDATE_UPSERT));
replaced = 1;
break;
}
}
}
if (!replaced) {
mongoc_bulk_operation_update_one(intern->bulk, bquery, bupdate, !!(flags & MONGOC_UPDATE_UPSERT));
}
}
bson_clear(&bquery);
bson_clear(&bupdate);
}
/* }}} */
/* {{{ proto void BulkWrite::delete(array|object $query[, array $deleteOptions = array()])
Adds a delete operation to the bulk */
PHP_METHOD(BulkWrite, delete)
{
php_phongo_bulkwrite_t *intern;
zval *query;
zval *deleteOptions = NULL;
bson_t *bson;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A|a!", &query, &deleteOptions) == FAILURE) {
return;
}
bson = bson_new();
phongo_zval_to_bson(query, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
if (deleteOptions && php_array_fetch_bool(deleteOptions, "limit")) {
mongoc_bulk_operation_remove_one(intern->bulk, bson);
} else {
mongoc_bulk_operation_remove(intern->bulk, bson);
}
bson_clear(&bson);
}
/* }}} */
/* {{{ proto integer BulkWrite::count()
Returns the number of operations that have been added to the bulk */
PHP_METHOD(BulkWrite, count)
{
php_phongo_bulkwrite_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_BULKWRITE_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(intern->bulk->commands.len);
}
/* }}} */
/* {{{ MongoDB\Driver\BulkWrite */
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite___construct, 0, 0, 0)
ZEND_ARG_ARRAY_INFO(0, options, 1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_insert, 0, 0, 1)
ZEND_ARG_INFO(0, document)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_update, 0, 0, 2)
ZEND_ARG_INFO(0, query)
ZEND_ARG_INFO(0, newObj)
ZEND_ARG_ARRAY_INFO(0, updateOptions, 1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_delete, 0, 0, 1)
ZEND_ARG_INFO(0, query)
ZEND_ARG_ARRAY_INFO(0, deleteOptions, 1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_BulkWrite_count, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_bulkwrite_me[] = {
PHP_ME(BulkWrite, __construct, ai_BulkWrite___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, insert, ai_BulkWrite_insert, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, update, ai_BulkWrite_update, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, delete, ai_BulkWrite_delete, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(BulkWrite, count, ai_BulkWrite_count, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_bulkwrite_t object handlers */
static void php_phongo_bulkwrite_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_bulkwrite_t *intern = Z_OBJ_BULKWRITE(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->bulk) {
mongoc_bulk_operation_destroy(intern->bulk);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_bulkwrite_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_bulkwrite_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_bulkwrite_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_bulkwrite;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_bulkwrite_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_bulkwrite;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_bulkwrite_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
php_phongo_bulkwrite_t *intern = NULL;
*is_temp = 1;
intern = Z_BULKWRITE_OBJ_P(object);
array_init(&retval);
if (intern->bulk->database) {
ADD_ASSOC_STRING(&retval, "database", intern->bulk->database);
} else {
ADD_ASSOC_NULL_EX(&retval, "database");
}
if (intern->bulk->collection) {
ADD_ASSOC_STRING(&retval, "collection", intern->bulk->collection);
} else {
ADD_ASSOC_NULL_EX(&retval, "collection");
}
ADD_ASSOC_BOOL_EX(&retval, "ordered", intern->bulk->flags.ordered);
ADD_ASSOC_BOOL_EX(&retval, "executed", intern->bulk->executed);
ADD_ASSOC_LONG_EX(&retval, "server_id", intern->bulk->hint);
if (intern->bulk->write_concern) {
#if PHP_VERSION_ID >= 70000
zval write_concern;
php_phongo_write_concern_to_zval(&write_concern, intern->bulk->write_concern);
ADD_ASSOC_ZVAL_EX(&retval, "write_concern", &write_concern);
#else
zval *write_concern = NULL;
MAKE_STD_ZVAL(write_concern);
php_phongo_write_concern_to_zval(write_concern, intern->bulk->write_concern);
ADD_ASSOC_ZVAL_EX(&retval, "write_concern", write_concern);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "write_concern");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(BulkWrite)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "BulkWrite", php_phongo_bulkwrite_me);
php_phongo_bulkwrite_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_bulkwrite_ce->create_object = php_phongo_bulkwrite_create_object;
PHONGO_CE_INIT(php_phongo_bulkwrite_ce);
memcpy(&php_phongo_handler_bulkwrite, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_bulkwrite.get_debug_info = php_phongo_bulkwrite_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_bulkwrite.free_obj = php_phongo_bulkwrite_free_object;
php_phongo_handler_bulkwrite.offset = XtOffsetOf(php_phongo_bulkwrite_t, std);
#endif
zend_class_implements(php_phongo_bulkwrite_ce TSRMLS_CC, 1, spl_ce_Countable);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Command.c 0000664 0001750 0001750 00000013725 12673034026 016614 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_command_ce;
zend_object_handlers php_phongo_handler_command;
/* {{{ proto MongoDB\Driver\Command Command::__construct(array|object $document)
Constructs a new Command */
PHP_METHOD(Command, __construct)
{
php_phongo_command_t *intern;
zend_error_handling error_handling;
zval *document;
bson_t *bson = bson_new();
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_COMMAND_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A", &document) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
phongo_zval_to_bson(document, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
intern->bson = bson;
}
/* }}} */
/**
* Value object for a database command document.
*/
/* {{{ MongoDB\Driver\Command */
ZEND_BEGIN_ARG_INFO_EX(ai_Command___construct, 0, 0, 1)
ZEND_ARG_INFO(0, document)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_command_me[] = {
PHP_ME(Command, __construct, ai_Command___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_command_t object handlers */
static void php_phongo_command_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_command_t *intern = Z_OBJ_COMMAND(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->bson) {
bson_clear(&intern->bson);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_command_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_command_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_command_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_command;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_command_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_command;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_command_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_command_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_COMMAND_OBJ_P(object);
array_init_size(&retval, 1);
if (intern->bson) {
#if PHP_VERSION_ID >= 70000
zval zv;
#else
zval *zv;
#endif
phongo_bson_to_zval(bson_get_data(intern->bson), intern->bson->len, &zv);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "command", &zv);
#else
ADD_ASSOC_ZVAL_EX(&retval, "command", zv);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "command");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Command)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Command", php_phongo_command_me);
php_phongo_command_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_command_ce->create_object = php_phongo_command_create_object;
PHONGO_CE_INIT(php_phongo_command_ce);
memcpy(&php_phongo_handler_command, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_command.get_debug_info = php_phongo_command_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_command.free_obj = php_phongo_command_free_object;
php_phongo_handler_command.offset = XtOffsetOf(php_phongo_command_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Cursor.c 0000664 0001750 0001750 00000022122 12673034026 016502 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_cursor_ce;
zend_object_handlers php_phongo_handler_cursor;
/* {{{ proto void Cursor::setTypeMap(array $typemap)
Sets a type map to use for BSON unserialization */
PHP_METHOD(Cursor, setTypeMap)
{
php_phongo_cursor_t *intern;
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
zval *typemap = NULL;
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!", &typemap) == FAILURE) {
return;
}
phongo_bson_typemap_to_state(typemap, &state.map TSRMLS_CC);
intern->visitor_data = state;
}
/* }}} */
static int php_phongo_cursor_to_array_apply(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval *data;
zval *return_value = (zval*)puser;
data = iter->funcs->get_current_data(iter TSRMLS_CC);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
if (Z_ISUNDEF_P(data)) {
return ZEND_HASH_APPLY_STOP;
}
Z_TRY_ADDREF_P(data);
add_next_index_zval(return_value, data);
#else
zval **data;
zval *return_value = (zval*)puser;
iter->funcs->get_current_data(iter, &data TSRMLS_CC);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
if (data == NULL || *data == NULL) {
return ZEND_HASH_APPLY_STOP;
}
Z_ADDREF_PP(data);
add_next_index_zval(return_value, *data);
#endif
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
/* {{{ proto array Cursor::toArray()
Returns an array of all result documents for this cursor */
PHP_METHOD(Cursor, toArray)
{
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init(return_value);
if (spl_iterator_apply(getThis(), php_phongo_cursor_to_array_apply, (void*)return_value TSRMLS_CC) != SUCCESS) {
zval_dtor(return_value);
RETURN_NULL();
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\CursorId Cursor::getId()
Returns the CursorId for this cursor */
PHP_METHOD(Cursor, getId)
{
php_phongo_cursor_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
php_phongo_cursor_id_new_from_id(return_value, mongoc_cursor_get_id(intern->cursor) TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\Server Cursor::getServer()
Returns the Server object to which this cursor is attached */
PHP_METHOD(Cursor, getServer)
{
php_phongo_cursor_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
phongo_server_init(return_value, intern->cursor->client, intern->server_id TSRMLS_CC);
}
/* }}} */
/* {{{ proto boolean Cursor::isDead()
Checks if a cursor is still alive */
PHP_METHOD(Cursor, isDead)
{
php_phongo_cursor_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSOR_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_BOOL(!mongoc_cursor_is_alive(intern->cursor));
}
/* }}} */
/* {{{ MongoDB\Driver\Cursor */
ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_setTypeMap, 0, 0, 1)
ZEND_ARG_ARRAY_INFO(0, typemap, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_toArray, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_getId, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_getServer, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Cursor_isDead, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_cursor_me[] = {
PHP_ME(Server, __construct, NULL, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(Cursor, setTypeMap, ai_Cursor_setTypeMap, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, toArray, ai_Cursor_toArray, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, getId, ai_Cursor_getId, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, getServer, ai_Cursor_getServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Cursor, isDead, ai_Cursor_isDead, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_cursor_t object handlers */
static void php_phongo_cursor_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern = Z_OBJ_CURSOR(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
php_phongo_cursor_free(intern);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_cursor_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_cursor_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_cursor;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_cursor_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_cursor;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_cursor_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_cursor_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_CURSOR_OBJ_P(object);
array_init_size(&retval, 2);
if (intern->cursor) {
#if PHP_VERSION_ID >= 70000
zval zcursor;
php_phongo_cursor_to_zval(&zcursor, intern->cursor);
ADD_ASSOC_ZVAL_EX(&retval, "cursor", &zcursor);
#else
zval *zcursor = NULL;
MAKE_STD_ZVAL(zcursor);
php_phongo_cursor_to_zval(zcursor, intern->cursor);
ADD_ASSOC_ZVAL_EX(&retval, "cursor", zcursor);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "cursor");
}
ADD_ASSOC_LONG_EX(&retval, "server_id", intern->server_id);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Cursor)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Cursor", php_phongo_cursor_me);
php_phongo_cursor_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_cursor_ce->create_object = php_phongo_cursor_create_object;
PHONGO_CE_INIT(php_phongo_cursor_ce);
php_phongo_cursor_ce->get_iterator = php_phongo_cursor_get_iterator;
memcpy(&php_phongo_handler_cursor, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_cursor.get_debug_info = php_phongo_cursor_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_cursor.free_obj = php_phongo_cursor_free_object;
php_phongo_handler_cursor.offset = XtOffsetOf(php_phongo_cursor_t, std);
#endif
zend_class_implements(php_phongo_cursor_ce TSRMLS_CC, 1, zend_ce_traversable);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/CursorId.c 0000664 0001750 0001750 00000012206 12673034026 016761 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_cursorid_ce;
zend_object_handlers php_phongo_handler_cursorid;
/* {{{ proto string CursorId::__toString()
Returns the string representation of the CursorId */
PHP_METHOD(CursorId, __toString)
{
php_phongo_cursorid_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_CURSORID_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETVAL_LONG(intern->id);
convert_to_string(return_value);
}
/* }}} */
/* {{{ MongoDB\Driver\CursorId */
ZEND_BEGIN_ARG_INFO_EX(ai_CursorId___toString, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_cursorid_me[] = {
PHP_ME(Server, __construct, NULL, ZEND_ACC_FINAL|ZEND_ACC_PRIVATE)
PHP_ME(CursorId, __toString, ai_CursorId___toString, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_cursorid_t object handlers */
static void php_phongo_cursorid_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_cursorid_t *intern = Z_OBJ_CURSORID(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_cursorid_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_cursorid_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_cursorid_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_cursorid;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_cursorid_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_cursorid;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_cursorid_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_cursorid_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_CURSORID_OBJ_P(object);
array_init(&retval);
ADD_ASSOC_LONG_EX(&retval, "id", intern->id);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(CursorId)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "CursorId", php_phongo_cursorid_me);
php_phongo_cursorid_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_cursorid_ce->create_object = php_phongo_cursorid_create_object;
PHONGO_CE_INIT(php_phongo_cursorid_ce);
memcpy(&php_phongo_handler_cursorid, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_cursorid.get_debug_info = php_phongo_cursorid_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_cursorid.free_obj = php_phongo_cursorid_free_object;
php_phongo_handler_cursorid.offset = XtOffsetOf(php_phongo_cursorid_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Manager.c 0000664 0001750 0001750 00000041753 12673034026 016612 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
#include
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
#include
#include
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
#define PHONGO_MANAGER_URI_DEFAULT "mongodb://localhost:27017/"
PHONGO_API zend_class_entry *php_phongo_manager_ce;
zend_object_handlers php_phongo_handler_manager;
/* {{{ proto MongoDB\Driver\Manager Manager::__construct([string $uri = "mongodb://localhost:27017/"[, array $options = array()[, array $driverOptions = array()]]])
Constructs a new Manager */
PHP_METHOD(Manager, __construct)
{
php_phongo_manager_t *intern;
zend_error_handling error_handling;
char *uri_string = NULL;
phongo_zpp_char_len uri_string_len = 0;
zval *options = NULL;
bson_t bson_options = BSON_INITIALIZER;
zval *driverOptions = NULL;
SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!a!a!", &uri_string, &uri_string_len, &options, &driverOptions) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
if (options) {
phongo_zval_to_bson(options, PHONGO_BSON_NONE, &bson_options, NULL TSRMLS_CC);
}
phongo_manager_init(intern, uri_string, &bson_options, driverOptions TSRMLS_CC);
bson_destroy(&bson_options);
}
/* }}} */
/* {{{ proto MongoDB\Driver\Cursor Manager::executeCommand(string $db, MongoDB\Driver\Command $command[, MongoDB\Driver\ReadPreference $readPreference = null])
Execute a command */
PHP_METHOD(Manager, executeCommand)
{
php_phongo_manager_t *intern;
char *db;
phongo_zpp_char_len db_len;
zval *command;
zval *readPreference = NULL;
php_phongo_command_t *cmd;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &db, &db_len, &command, php_phongo_command_ce, &readPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
cmd = Z_COMMAND_OBJ_P(command);
phongo_execute_command(intern->client, db, cmd->bson, phongo_read_preference_from_zval(readPreference TSRMLS_CC), -1, return_value, return_value_used TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\Cursor Manager::executeQuery(string $namespace, MongoDB\Driver\Query $zquery[, MongoDB\Driver\ReadPreference $readPreference = null])
Execute a Query */
PHP_METHOD(Manager, executeQuery)
{
php_phongo_manager_t *intern;
char *namespace;
phongo_zpp_char_len namespace_len;
zval *zquery;
zval *readPreference = NULL;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &namespace, &namespace_len, &zquery, php_phongo_query_ce, &readPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
phongo_execute_query(intern->client, namespace, phongo_query_from_zval(zquery TSRMLS_CC), phongo_read_preference_from_zval(readPreference TSRMLS_CC), -1, return_value, return_value_used TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\WriteResult Manager::executeBulkWrite(string $namespace, MongoDB\Driver\BulkWrite $zbulk[, MongoDB\Driver\WriteConcern $writeConcern = null])
Executes a write operation bulk (e.g. insert, update, delete) */
PHP_METHOD(Manager, executeBulkWrite)
{
php_phongo_manager_t *intern;
char *namespace;
phongo_zpp_char_len namespace_len;
zval *zbulk;
zval *zwrite_concern = NULL;
php_phongo_bulkwrite_t *bulk;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO|O!", &namespace, &namespace_len, &zbulk, php_phongo_bulkwrite_ce, &zwrite_concern, php_phongo_writeconcern_ce) == FAILURE) {
return;
}
bulk = Z_BULKWRITE_OBJ_P(zbulk);
phongo_execute_write(intern->client, namespace, bulk->bulk, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), -1, return_value, return_value_used TSRMLS_CC);
}
/* }}} */
/* {{{ proto MongoDB\Driver\ReadConcern Manager::getReadConcern()
Returns the ReadConcern associated with this Manager */
PHP_METHOD(Manager, getReadConcern)
{
php_phongo_manager_t *intern;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (return_value_used) {
phongo_readconcern_init(return_value, mongoc_client_get_read_concern(intern->client) TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\ReadPreference Manager::getReadPreference()
Returns the ReadPreference associated with this Manager */
PHP_METHOD(Manager, getReadPreference)
{
php_phongo_manager_t *intern;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (return_value_used) {
phongo_readpreference_init(return_value, mongoc_client_get_read_prefs(intern->client) TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\Server[] Manager::getServers()
Returns the Servers associated with this Manager */
PHP_METHOD(Manager, getServers)
{
php_phongo_manager_t *intern;
mongoc_set_t *set;
size_t i;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
array_init(return_value);
set = intern->client->topology->description.servers;
for(i=0; iitems_len; i++) {
#if PHP_VERSION_ID >= 70000
zval obj;
#else
zval *obj = NULL;
#endif
mongoc_server_description_t *sd = (mongoc_server_description_t *) set->items[i].item;
if (sd->type == MONGOC_SERVER_UNKNOWN) {
continue;
}
#if PHP_VERSION_ID >= 70000
phongo_server_init(&obj, intern->client, ((mongoc_server_description_t *)set->items[i].item)->id TSRMLS_CC);
add_next_index_zval(return_value, &obj);
#else
MAKE_STD_ZVAL(obj);
phongo_server_init(obj, intern->client, sd->id TSRMLS_CC);
add_next_index_zval(return_value, obj);
#endif
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\WriteConcern Manager::getWriteConcern()
Returns the WriteConcern associated with this Manager */
PHP_METHOD(Manager, getWriteConcern)
{
php_phongo_manager_t *intern;
DECLARE_RETURN_VALUE_USED
SUPPRESS_UNUSED_WARNING(return_value_ptr)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (return_value_used) {
phongo_writeconcern_init(return_value, mongoc_client_get_write_concern(intern->client) TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto MongoDB\Driver\Server Manager::selectServers(MongoDB\Driver\ReadPreference $readPreference)
Returns a suitable Server for the given $readPreference */
PHP_METHOD(Manager, selectServer)
{
php_phongo_manager_t *intern;
zval *zreadPreference = NULL;
const mongoc_read_prefs_t *readPreference;
bson_error_t error;
mongoc_server_description_t *selected_server = NULL;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_MANAGER_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zreadPreference, php_phongo_readpreference_ce) == FAILURE) {
return;
}
readPreference = phongo_read_preference_from_zval(zreadPreference TSRMLS_CC);
selected_server = mongoc_topology_select(intern->client->topology, MONGOC_SS_READ, readPreference, MONGOC_SS_DEFAULT_LOCAL_THRESHOLD_MS, &error);
if (selected_server) {
phongo_server_init(return_value, intern->client, selected_server->id TSRMLS_CC);
mongoc_server_description_destroy(selected_server);
} else {
/* Check for connection related exceptions */
if (EG(exception)) {
return;
}
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto void MongoDB\Driver\Manager::__wakeUp()
* Throws MongoDB\Driver\RuntimeException as it cannot be serialized */
PHP_METHOD(Manager, __wakeUp)
{
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(this_ptr)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
phongo_throw_exception(PHONGO_ERROR_RUNTIME TSRMLS_CC, "%s", "MongoDB\\Driver objects cannot be serialized");
}
/* }}} */
/**
* Manager abstracts a cluster of Server objects (i.e. socket connections).
*
* Typically, users will connect to a cluster using a URI, and the Manager will
* perform tasks such as replica set discovery and create the necessary Server
* objects. That said, it is also possible to create a Manager with an arbitrary
* collection of Server objects using the static factory method (this can be
* useful for testing or administration).
*
* Operation methods do not take socket-level options (e.g. socketTimeoutMS).
* Those options should be specified during construction.
*/
/* {{{ MongoDB\Driver\Manager */
ZEND_BEGIN_ARG_INFO_EX(ai_Manager___construct, 0, 0, 0)
ZEND_ARG_INFO(0, uri)
ZEND_ARG_ARRAY_INFO(0, options, 0)
ZEND_ARG_ARRAY_INFO(0, driverOptions, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeCommand, 0, 0, 2)
ZEND_ARG_INFO(0, db)
ZEND_ARG_OBJ_INFO(0, command, MongoDB\\Driver\\Command, 0)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeQuery, 0, 0, 2)
ZEND_ARG_INFO(0, namespace)
ZEND_ARG_OBJ_INFO(0, zquery, MongoDB\\Driver\\Query, 0)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeBulkWrite, 0, 0, 2)
ZEND_ARG_INFO(0, namespace)
ZEND_ARG_OBJ_INFO(0, zbulk, MongoDB\\Driver\\BulkWrite, 0)
ZEND_ARG_OBJ_INFO(0, writeConcern, MongoDB\\Driver\\WriteConcern, 1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_getReadConcern, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_getReadPreference, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_getServers, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_getWriteConcern, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_selectServer, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, readPreference, MongoDB\\Driver\\ReadPreference, 1)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_manager_me[] = {
PHP_ME(Manager, __construct, ai_Manager___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, executeCommand, ai_Manager_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, executeQuery, ai_Manager_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, executeBulkWrite, ai_Manager_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getReadConcern, ai_Manager_getReadConcern, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getReadPreference, ai_Manager_getReadPreference, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getServers, ai_Manager_getServers, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, getWriteConcern, ai_Manager_getWriteConcern, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, selectServer, ai_Manager_selectServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_manager_t object handlers */
static void php_phongo_manager_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_manager_t *intern = Z_OBJ_MANAGER(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->client) {
mongoc_client_destroy(intern->client);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_manager_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_manager_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_manager_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_manager;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_manager_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_manager;
return retval;
}
#endif
} /* }}} */
bool phongo_add_server_debug(void *item, void *ctx) /* {{{ */
{
mongoc_server_description_t *server = item;
zval *retval = ctx;
#if PHP_VERSION_ID >= 70000
zval entry;
php_phongo_server_to_zval(&entry, server);
add_next_index_zval(retval, &entry);
#else
zval *entry = NULL;
MAKE_STD_ZVAL(entry);
php_phongo_server_to_zval(entry, server);
add_next_index_zval(retval, entry);
#endif
return true;
} /* }}} */
HashTable *php_phongo_manager_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_manager_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_MANAGER_OBJ_P(object);
array_init(&retval);
ADD_ASSOC_STRING(&retval, "uri", (char *)mongoc_uri_get_string(intern->client->uri));
{
#if PHP_VERSION_ID >= 70000
zval cluster;
array_init(&cluster);
mongoc_set_for_each(intern->client->topology->description.servers, phongo_add_server_debug, &cluster);
ADD_ASSOC_ZVAL_EX(&retval, "cluster", &cluster);
#else
zval *cluster = NULL;
MAKE_STD_ZVAL(cluster);
array_init(cluster);
mongoc_set_for_each(intern->client->topology->description.servers, phongo_add_server_debug, cluster);
ADD_ASSOC_ZVAL_EX(&retval, "cluster", cluster);
#endif
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Manager)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Manager", php_phongo_manager_me);
php_phongo_manager_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_manager_ce->create_object = php_phongo_manager_create_object;
PHONGO_CE_INIT(php_phongo_manager_ce);
memcpy(&php_phongo_handler_manager, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_manager.get_debug_info = php_phongo_manager_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_manager.free_obj = php_phongo_manager_free_object;
php_phongo_handler_manager.offset = XtOffsetOf(php_phongo_manager_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Query.c 0000664 0001750 0001750 00000021051 12673034026 016332 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* PHP array helpers */
#include "php_array_api.h"
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_query_ce;
zend_object_handlers php_phongo_handler_query;
/* {{{ proto MongoDB\Driver\Query Query::__construct(array|object $filter[, array $options = array()])
Constructs a new Query */
PHP_METHOD(Query, __construct)
{
php_phongo_query_t *intern;
zend_error_handling error_handling;
zval *zfilter;
zval *zoptions = NULL;
bson_t bfilter;
bson_t boptions = BSON_INITIALIZER;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_QUERY_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "A|a!", &zfilter, &zoptions) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
intern->query = bson_new();
bson_init(&bfilter);
phongo_zval_to_bson(zfilter, PHONGO_BSON_NONE, &bfilter, NULL TSRMLS_CC);
if (zoptions) {
if (php_array_exists(zoptions, "readConcern")) {
zval *zread_concern = php_array_fetchc(zoptions, "readConcern");
if (Z_TYPE_P(zread_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(zread_concern), php_phongo_readconcern_ce TSRMLS_CC)) {
#if PHP_VERSION_ID >= 70000
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"readConcern\" option to be %s, %s given", ZSTR_VAL(php_phongo_readconcern_ce->name), zend_get_type_by_const(Z_TYPE_P(zread_concern)));
#else
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"readConcern\" option to be %s, %s given", php_phongo_readconcern_ce->name, zend_get_type_by_const(Z_TYPE_P(zread_concern)));
#endif
bson_clear(&intern->query);
return;
}
intern->read_concern = mongoc_read_concern_copy(phongo_read_concern_from_zval(zread_concern TSRMLS_CC));
php_array_unsetc(zoptions, "readConcern");
}
phongo_zval_to_bson(zoptions, PHONGO_BSON_NONE, &boptions, NULL TSRMLS_CC);
}
if (!phongo_query_init(intern, &bfilter, &boptions TSRMLS_CC)) {
bson_clear(&intern->query);
}
bson_destroy(&bfilter);
bson_destroy(&boptions);
}
/* }}} */
/* {{{ MongoDB\Driver\Query */
ZEND_BEGIN_ARG_INFO_EX(ai_Query___construct, 0, 0, 1)
ZEND_ARG_INFO(0, filter)
ZEND_ARG_ARRAY_INFO(0, options, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_query_me[] = {
PHP_ME(Query, __construct, ai_Query___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(Manager, __wakeUp, NULL, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_query_t object handlers */
static void php_phongo_query_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_query_t *intern = Z_OBJ_QUERY(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->selector) {
bson_clear(&intern->selector);
}
if (intern->query) {
bson_clear(&intern->query);
}
if (intern->read_concern) {
mongoc_read_concern_destroy(intern->read_concern);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_query_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_query_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_query_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_query;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_query_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_query;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_query_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
php_phongo_query_t *intern;
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
*is_temp = 1;
intern = Z_QUERY_OBJ_P(object);
array_init_size(&retval, 6);
/* Avoid using PHONGO_TYPEMAP_NATIVE_ARRAY for decoding query and selector
* documents so that users can differentiate BSON arrays and documents. */
if (intern->query) {
#if PHP_VERSION_ID >= 70000
zval zv;
#else
zval *zv;
#endif
phongo_bson_to_zval(bson_get_data(intern->query), intern->query->len, &zv);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "query", &zv);
#else
ADD_ASSOC_ZVAL_EX(&retval, "query", zv);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "query");
}
if (intern->selector) {
#if PHP_VERSION_ID >= 70000
zval zv;
#else
zval *zv;
#endif
phongo_bson_to_zval(bson_get_data(intern->selector), intern->selector->len, &zv);
#if PHP_VERSION_ID >= 70000
ADD_ASSOC_ZVAL_EX(&retval, "selector", &zv);
#else
ADD_ASSOC_ZVAL_EX(&retval, "selector", zv);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "selector");
}
ADD_ASSOC_LONG_EX(&retval, "flags", intern->flags);
ADD_ASSOC_LONG_EX(&retval, "skip", intern->skip);
ADD_ASSOC_LONG_EX(&retval, "limit", intern->limit);
ADD_ASSOC_LONG_EX(&retval, "batch_size", intern->batch_size);
if (intern->read_concern) {
#if PHP_VERSION_ID >= 70000
zval read_concern;
php_phongo_read_concern_to_zval(&read_concern, intern->read_concern);
ADD_ASSOC_ZVAL_EX(&retval, "readConcern", &read_concern);
#else
zval *read_concern = NULL;
MAKE_STD_ZVAL(read_concern);
php_phongo_read_concern_to_zval(read_concern, intern->read_concern);
ADD_ASSOC_ZVAL_EX(&retval, "readConcern", read_concern);
#endif
} else {
ADD_ASSOC_NULL_EX(&retval, "readConcern");
}
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(Query)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "Query", php_phongo_query_me);
php_phongo_query_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_query_ce->create_object = php_phongo_query_create_object;
PHONGO_CE_INIT(php_phongo_query_ce);
memcpy(&php_phongo_handler_query, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_query.get_debug_info = php_phongo_query_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_query.free_obj = php_phongo_query_free_object;
php_phongo_handler_query.offset = XtOffsetOf(php_phongo_query_t, std);
#endif
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/ReadConcern.c 0000664 0001750 0001750 00000015462 12673034026 017421 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_readconcern_ce;
zend_object_handlers php_phongo_handler_readconcern;
/* {{{ proto MongoDB\Driver\ReadConcern ReadConcern::__construct([string $level])
Constructs a new ReadConcern */
PHP_METHOD(ReadConcern, __construct)
{
php_phongo_readconcern_t *intern;
zend_error_handling error_handling;
char *level = NULL;
phongo_zpp_char_len level_len = 0;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_READCONCERN_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &level, &level_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
intern->read_concern = mongoc_read_concern_new();
if (level) {
mongoc_read_concern_set_level(intern->read_concern, level);
}
}
/* }}} */
/* {{{ proto string|null ReadConcern::getLevel()
Returns the ReadConcern "level" option */
PHP_METHOD(ReadConcern, getLevel)
{
php_phongo_readconcern_t *intern;
const char *level;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_READCONCERN_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
level = mongoc_read_concern_get_level(intern->read_concern);
if (level) {
PHONGO_RETURN_STRING(level);
}
RETURN_NULL();
}
/* }}} */
/**
* Value object for read concern used in issuing read operations.
*/
/* {{{ MongoDB\Driver\ReadConcern */
ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern___construct, 0, 0, 0)
ZEND_ARG_INFO(0, level)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_ReadConcern_getLevel, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_readconcern_me[] = {
PHP_ME(ReadConcern, __construct, ai_ReadConcern___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadConcern, getLevel, ai_ReadConcern_getLevel, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_readconcern_t object handlers */
static void php_phongo_readconcern_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_readconcern_t *intern = Z_OBJ_READCONCERN(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->read_concern) {
mongoc_read_concern_destroy(intern->read_concern);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_readconcern_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_readconcern_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_readconcern_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_readconcern;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_readconcern_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_readconcern;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_readconcern_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
const mongoc_read_concern_t *read_concern = phongo_read_concern_from_zval(object TSRMLS_CC);
*is_temp = 1;
php_phongo_read_concern_to_zval(&retval, read_concern);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ReadConcern)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadConcern", php_phongo_readconcern_me);
php_phongo_readconcern_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_readconcern_ce->create_object = php_phongo_readconcern_create_object;
PHONGO_CE_INIT(php_phongo_readconcern_ce);
memcpy(&php_phongo_handler_readconcern, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_readconcern.get_debug_info = php_phongo_readconcern_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_readconcern.free_obj = php_phongo_readconcern_free_object;
php_phongo_handler_readconcern.offset = XtOffsetOf(php_phongo_readconcern_t, std);
#endif
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("LOCAL"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_LOCAL) TSRMLS_CC);
zend_declare_class_constant_stringl(php_phongo_readconcern_ce, ZEND_STRL("MAJORITY"), ZEND_STRL(MONGOC_READ_CONCERN_LEVEL_MAJORITY) TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/ReadPreference.c 0000664 0001750 0001750 00000021751 12673034026 020106 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include
/* Our Compatability header */
#include "phongo_compat.h"
/* Our stuffz */
#include "php_phongo.h"
#include "php_bson.h"
PHONGO_API zend_class_entry *php_phongo_readpreference_ce;
zend_object_handlers php_phongo_handler_readpreference;
/* {{{ proto MongoDB\Driver\ReadPreference ReadPreference::__construct(integer $mode[, array $tagSets = array()])
Constructs a new ReadPreference */
PHP_METHOD(ReadPreference, __construct)
{
php_phongo_readpreference_t *intern;
zend_error_handling error_handling;
long mode;
zval *tagSets = NULL;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value) SUPPRESS_UNUSED_WARNING(return_value_used)
zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);
intern = Z_READPREFERENCE_OBJ_P(getThis());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|a!", &mode, &tagSets) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
switch(mode) {
case MONGOC_READ_PRIMARY:
case MONGOC_READ_SECONDARY:
case MONGOC_READ_PRIMARY_PREFERRED:
case MONGOC_READ_SECONDARY_PREFERRED:
case MONGOC_READ_NEAREST:
intern->read_preference = mongoc_read_prefs_new(mode);
if (tagSets) {
bson_t *tags = bson_new();
phongo_zval_to_bson(tagSets, PHONGO_BSON_NONE, (bson_t *)tags, NULL TSRMLS_CC);
mongoc_read_prefs_set_tags(intern->read_preference, tags);
bson_destroy(tags);
if (!mongoc_read_prefs_is_valid(intern->read_preference)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Invalid tagSets");
return;
}
}
break;
default:
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Invalid mode: %ld", mode);
return;
}
}
/* }}} */
/* {{{ proto integer ReadPreference::getMode()
Returns the ReadPreference mode */
PHP_METHOD(ReadPreference, getMode)
{
php_phongo_readpreference_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_READPREFERENCE_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RETURN_LONG(mongoc_read_prefs_get_mode(intern->read_preference));
}
/* }}} */
/* {{{ proto array ReadPreference::getTagSets()
Returns the ReadPreference tag sets */
PHP_METHOD(ReadPreference, getTagSets)
{
php_phongo_readpreference_t *intern;
SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)
intern = Z_READPREFERENCE_OBJ_P(getThis());
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (intern->read_preference->tags.len) {
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
/* Use native arrays for debugging output */
state.map.root_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
state.map.document_type = PHONGO_TYPEMAP_NATIVE_ARRAY;
phongo_bson_to_zval_ex(bson_get_data(&intern->read_preference->tags), intern->read_preference->tags.len, &state);
#if PHP_VERSION_ID >= 70000
RETURN_ZVAL(&state.zchild, 0, 1);
#else
RETURN_ZVAL(state.zchild, 0, 1);
#endif
} else {
RETURN_NULL();
}
}
/* }}} */
/**
* Value object for read preferences used in issuing commands and queries.
*/
/* {{{ MongoDB\Driver\ReadPreference */
ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference___construct, 0, 0, 1)
ZEND_ARG_INFO(0, mode)
ZEND_ARG_ARRAY_INFO(0, tagSets, 1)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference_getMode, 0, 0, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(ai_ReadPreference_getTagSets, 0, 0, 0)
ZEND_END_ARG_INFO();
static zend_function_entry php_phongo_readpreference_me[] = {
PHP_ME(ReadPreference, __construct, ai_ReadPreference___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadPreference, getMode, ai_ReadPreference_getMode, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_ME(ReadPreference, getTagSets, ai_ReadPreference_getTagSets, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
PHP_FE_END
};
/* }}} */
/* {{{ php_phongo_readpreference_t object handlers */
static void php_phongo_readpreference_free_object(phongo_free_object_arg *object TSRMLS_DC) /* {{{ */
{
php_phongo_readpreference_t *intern = Z_OBJ_READPREFERENCE(object);
zend_object_std_dtor(&intern->std TSRMLS_CC);
if (intern->read_preference) {
mongoc_read_prefs_destroy(intern->read_preference);
}
#if PHP_VERSION_ID < 70000
efree(intern);
#endif
} /* }}} */
phongo_create_object_retval php_phongo_readpreference_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
{
php_phongo_readpreference_t *intern = NULL;
intern = PHONGO_ALLOC_OBJECT_T(php_phongo_readpreference_t, class_type);
zend_object_std_init(&intern->std, class_type TSRMLS_CC);
object_properties_init(&intern->std, class_type);
#if PHP_VERSION_ID >= 70000
intern->std.handlers = &php_phongo_handler_readpreference;
return &intern->std;
#else
{
zend_object_value retval;
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_readpreference_free_object, NULL TSRMLS_CC);
retval.handlers = &php_phongo_handler_readpreference;
return retval;
}
#endif
} /* }}} */
HashTable *php_phongo_readpreference_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
{
#if PHP_VERSION_ID >= 70000
zval retval;
#else
zval retval = zval_used_for_init;
#endif
const mongoc_read_prefs_t *read_prefs = phongo_read_preference_from_zval(object TSRMLS_CC);
*is_temp = 1;
php_phongo_read_preference_to_zval(&retval, read_prefs);
return Z_ARRVAL(retval);
} /* }}} */
/* }}} */
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(ReadPreference)
{
zend_class_entry ce;
(void)type;(void)module_number;
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "ReadPreference", php_phongo_readpreference_me);
php_phongo_readpreference_ce = zend_register_internal_class(&ce TSRMLS_CC);
php_phongo_readpreference_ce->create_object = php_phongo_readpreference_create_object;
PHONGO_CE_INIT(php_phongo_readpreference_ce);
memcpy(&php_phongo_handler_readpreference, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
php_phongo_handler_readpreference.get_debug_info = php_phongo_readpreference_get_debug_info;
#if PHP_VERSION_ID >= 70000
php_phongo_handler_readpreference.free_obj = php_phongo_readpreference_free_object;
php_phongo_handler_readpreference.offset = XtOffsetOf(php_phongo_readpreference_t, std);
#endif
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_PRIMARY"), MONGOC_READ_PRIMARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_PRIMARY_PREFERRED"), MONGOC_READ_PRIMARY_PREFERRED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY"), MONGOC_READ_SECONDARY TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_SECONDARY_PREFERRED"), MONGOC_READ_SECONDARY_PREFERRED TSRMLS_CC);
zend_declare_class_constant_long(php_phongo_readpreference_ce, ZEND_STRL("RP_NEAREST"), MONGOC_READ_NEAREST TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
mongodb-1.1.5/src/MongoDB/Server.c 0000664 0001750 0001750 00000053042 12673034026 016500 0 ustar jmikola jmikola /*
+---------------------------------------------------------------------------+
| PHP Driver for MongoDB |
+---------------------------------------------------------------------------+
| Copyright 2013-2015 MongoDB, Inc. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+---------------------------------------------------------------------------+
| Copyright (c) 2014-2015 MongoDB, Inc. |
+---------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/* External libs */
#include
#include
#include
/* PHP Core stuff */
#include
#include
#include
#include
#include