Skip to content

Commit

Permalink
Merge pull request #11 from gslin/master
Browse files Browse the repository at this point in the history
Support GET_PATHS pathcount arg (default to 2).
  • Loading branch information
lstrojny committed Aug 6, 2013
2 parents 83de5f7 + 7a591d0 commit 90852ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ make install
- ``bool MogileFs::close()``
- ``bool MogileFs::put(file, string $key, string $class[, bool $use_file])``
- ``array MogileFs::fileInfo(string $key)``
- ``array MogileFs::get(string $key)``
- ``array MogileFs::get(string $key[, integer $pathcount = 2])``
- ``bool MogileFs::delete(string $key)``
- ``bool MogileFs::rename(string $from_key, string $to_key)``
- ``array MogileFs::listKeys(string $prefix, string $after, integer $limit)``
Expand Down
9 changes: 5 additions & 4 deletions mogilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ ZEND_END_ARG_INFO()
MOGILEFS_ARG_INFO
ZEND_BEGIN_ARG_INFO(arginfo_MogileFs_get, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, pathcount)
ZEND_END_ARG_INFO()

MOGILEFS_ARG_INFO
Expand Down Expand Up @@ -816,26 +817,26 @@ PHP_METHOD(MogileFs, put)
}
/* }}} */

/* {{{ proto string MogileFs::get(string key)
/* {{{ proto string MogileFs::get(string key, integer pathcount)
Get MogileFs path */
PHP_METHOD(MogileFs, get)
{
zval *object;
MogilefsSock *mogilefs_sock;
char *key = NULL, *request, *response;
int key_len, request_len, response_len;
int key_len, pathcount = 2, request_len, response_len;

if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",
&object, mogilefs_ce,
&key, &key_len) == FAILURE) {
&key, &key_len, &pathcount) == FAILURE) {
return;
}

if (mogilefs_sock_get(object, &mogilefs_sock TSRMLS_CC) < 0) {
zend_throw_exception(mogilefs_exception_ce, "Could not connect to tracker", 0 TSRMLS_CC);
RETURN_FALSE;
}
request_len = spprintf(&request, 0, "GET_PATHS domain=%s&key=%s\r\n", mogilefs_sock->domain, key);
request_len = spprintf(&request, 0, "GET_PATHS domain=%s&key=%s&pathcount=%d\r\n", mogilefs_sock->domain, key, pathcount);
if (MOGILEFS_SOCK_WRITE_FREE(mogilefs_sock, request, request_len) < 0) {
RETURN_FALSE;
}
Expand Down

0 comments on commit 90852ad

Please sign in to comment.