本文整理汇总了C++中ONV函数的典型用法代码示例。如果您正苦于以下问题:C++ ONV函数的具体用法?C++ ONV怎么用?C++ ONV使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ONV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addr_peer
static int addr_peer(void)
{
ne_socket *sock = ne_sock_create();
ne_inet_addr *ia, *ia2;
unsigned int port = 9999, realport;
int ret;
ia = ne_iaddr_make(ne_iaddr_ipv4, raw_127);
ONN("ne_iaddr_make returned NULL", ia == NULL);
CALL(new_spawn_server(1, serve_close, NULL, &realport));
ONN("could not connect", ne_sock_connect(sock, ia, realport));
ia2 = ne_sock_peer(sock, &port);
ret = ne_iaddr_cmp(ia, ia2);
ONV(ret != 0,
("comparison of peer with server address was %d", ret));
ONV(port != realport, ("got peer port %u, expected %u", port, realport));
ne_sock_close(sock);
CALL(await_server());
ne_iaddr_free(ia);
ne_iaddr_free(ia2);
return OK;
}
示例2: blocking
static int blocking(void)
{
ne_socket *sock;
int ret;
CALL(begin(&sock, echo_server, NULL));
CALL(expect_block_timeout(sock, 1, "with non-zero timeout"));
WRITEL("Hello, world.\n");
/* poll for data */
do {
ret = ne_sock_block(sock, 1);
} while (ret == NE_SOCK_TIMEOUT);
ONV(ret != 0, ("ne_sock_block never got data: %d", ret));
PEEK("Hello,");
ret = ne_sock_block(sock, 1);
ONV(ret != 0, ("ne_sock_block failed after peek: %d", ret));
LINE("Hello, world.\n");
return finish(sock, 0);
}
示例3: copy_overwrite
static int copy_overwrite(void)
{
PRECOND(copy_ok);
/* Do it again with Overwrite: F to check that fails. */
ONN("COPY on existing resource with Overwrite: F should fail (RFC2518:S8.8.4)",
ne_copy(i_session, 0, NE_DEPTH_INFINITE, src, dest) != NE_ERROR);
if (STATUS(412)) {
t_warning("COPY-on-existing fails with 412");
}
ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, dest),
("COPY-on-existing with 'Overwrite: T' should succeed (RFC2518:S8.8.4): %s", ne_get_error(i_session)));
/* tricky one this, I didn't think it should work, but the spec
* makes it look like it should. */
ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, coll),
("COPY overwrites collection: %s", ne_get_error(i_session)));
if (STATUS(204)) {
t_warning("COPY to existing resource didn't give 204 (RFC2518:S8.8.5)");
}
return OK;
}
示例4: my_mkcol2_proppatch
void
my_mkcol2_proppatch(char* uri, int depth, const ne_propname pops[])
{
char tmp[256] = "/tmp/Davtest-XXXXXX";
char myuri[128];
int i, fd;
if ( (fd=mkstemp(tmp)) < 0){
perror("mkstemp() :");
return ;
}
for( i=0; i<4; i++)
write(fd, tmp, sizeof(tmp));
if ( depth > 1){
memset(myuri, 0, sizeof(myuri));
strcpy( myuri, uri);
sprintf( myuri, "%ssub/", myuri);
ONV(ne_mkcol(i_session, myuri),
("MKCOL %s: %s", myuri, ne_get_error(i_session)));
ONMREQ("PROPPATCH",myuri, ne_proppatch(i_session, myuri, pops));
my_mkcol2( myuri, depth-1);
}else if ( depth == 1)
for ( i=0; i<pget_option.width; i++){
memset(myuri, 0, sizeof(myuri));
strcpy( myuri, uri);
sprintf( myuri, "%sfile%d", myuri, i);
ONV(ne_put(i_session, myuri, fd),
("PUT of %s: %s", myuri, ne_get_error(i_session)));
}
return;
}
示例5: expect_close
/* Exect a read() to return EOF */
static int expect_close(ne_socket *sock)
{
ssize_t n = ne_sock_read(sock, buffer, 1);
ONV(n > 0, ("read got %" NE_FMT_SSIZE_T " bytes not closure", n));
ONV(n < 0 && n != NE_SOCK_CLOSED,
("read got error not closure: `%s'", ne_sock_error(sock)));
return OK;
}
示例6: fullread_expect
/* do a sock_read() on sock for 'len' bytes, and expect 'str'. */
static int fullread_expect(ne_socket *sock, const char *str, size_t len)
{
ssize_t ret = ne_sock_fullread(sock, buffer, len);
ONV(ret, ("fullread failed (%" NE_FMT_SSIZE_T "): %s",
ret, ne_sock_error(sock)));
ONV(memcmp(str, buffer, len),
("fullread mismatch: `%.*s' not `%.*s'",
(int)len, buffer, (int)len, str));
return OK;
}
示例7: read_expect
/* do a sock_read() on sock for 'len' bytes, and expect 'str'. */
static int read_expect(ne_socket *sock, const char *str, size_t len)
{
ssize_t ret = ne_sock_read(sock, buffer, len);
ONV((ssize_t)len != ret,
("read got %" NE_FMT_SSIZE_T " bytes not %" NE_FMT_SIZE_T, ret, len));
ONV(memcmp(str, buffer, len),
("read mismatch: `%.*s' not `%.*s'",
(int)len, buffer, (int)len, str));
return OK;
}
示例8: addr_make_v6
static int addr_make_v6(void)
{
#ifdef TEST_IPV6
struct {
const unsigned char *addr;
const char *rep;
} as[] = {
{ raw6_cafe, "feed::cafe" },
{ raw6_babe, "cafe:babe::" },
{ raw6_nuls, "::" },
{ NULL, NULL }
};
int n;
for (n = 0; as[n].rep != NULL; n++) {
ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv6, as[n].addr);
char pr[128];
unsigned char raw[17];
ONV(ia == NULL, ("could not make address for '%s'",
as[n].rep));
ne_iaddr_print(ia, pr, sizeof pr);
ONV(strcmp(pr, as[n].rep),
("address %d was '%s' not '%s'", n, pr, as[n].rep));
ONN("bogus ne_iaddr_typeof return", ne_iaddr_typeof(ia) != ne_iaddr_ipv6);
raw[16] = 'Z';
ONN("ne_iaddr_raw gave bad retval", ne_iaddr_raw(ia, raw) != raw);
ONN("raw address mismatch", memcmp(raw, as[n].addr, 4) != 0);
ONN("ne_iaddr_raw buffer overflow", raw[16] != 'Z');
ne_iaddr_free(ia);
ia = ne_iaddr_parse(as[n].rep, ne_iaddr_ipv6);
ONV(ia == NULL, ("ne_iaddr_parse failed for %s", as[n].rep));
ONN("bogus ne_iaddr_typeof return", ne_iaddr_typeof(ia) != ne_iaddr_ipv6);
ONN("ne_iaddr_raw gave bad retval", ne_iaddr_raw(ia, raw) != raw);
ONN("raw address mismatch", memcmp(raw, as[n].addr, 4) != 0);
ONN("ne_iaddr_raw buffer overflow", raw[16] != 'Z');
ne_iaddr_free(ia);
}
return OK;
#else
/* should fail when lacking IPv6 support. */
ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv6, raw6_nuls);
ONN("ne_iaddr_make did not return NULL", ia != NULL);
ONN("ne_iaddr_parse did not return NULL", ne_iaddr_parse("127.0.0.1", ne_iaddr_ipv6));
#endif
return OK;
}
示例9: line_expect
static int line_expect(ne_socket *sock, const char *line)
{
ssize_t ret = ne_sock_readline(sock, buffer, BUFSIZ);
size_t len = strlen(line);
NE_DEBUG(NE_DBG_SOCKET, " -> expected=%s -> actual=%s", line, buffer);
ONV(ret == NE_SOCK_CLOSED, ("socket closed, expecting `%s'", line));
ONV(ret < 0, ("socket error `%s', expecting `%s'",
ne_sock_error(sock), line));
ONV((size_t)ret != len || strcmp(line, buffer),
("readline mismatch: `%s' not `%s'", buffer, line));
return OK;
}
示例10: strnzcpy
static int strnzcpy(void)
{
char buf[5];
ne_strnzcpy(buf, "abcdefghi", sizeof buf);
ONV(strcmp(buf, "abcd"), ("result was `%s' not `abcd'", buf));
ne_strnzcpy(buf, "ab", sizeof buf);
ONV(strcmp(buf, "ab"), ("result was `%s' not `ab'", buf));
return OK;
}
示例11: resolve_numeric
static int resolve_numeric(void)
{
ne_sock_addr *addr = ne_addr_resolve("127.0.0.1", 0);
ONV(ne_addr_result(addr),
("failed to resolve 127.0.0.1: %s",
ne_addr_error(addr, buffer, sizeof buffer)));
ONN("ne_addr_first returned NULL", ne_addr_first(addr) == NULL);
ONN("ne_iaddr_print didn't return buffer",
ne_iaddr_print(ne_addr_first(addr), buffer, sizeof buffer) != buffer);
ONV(strcmp(buffer, "127.0.0.1"), ("ntop gave `%s' not 127.0.0.1", buffer));
ne_addr_destroy(addr);
return OK;
}
示例12: lock_collection
static int lock_collection(void)
{
struct ne_lock dummy;
char *tmp,*tmp2;
CALL(getlock(ne_lockscope_exclusive, NE_DEPTH_INFINITE));
PRECOND(gotlock);
memcpy(&dummy, &reslock, sizeof(reslock));
dummy.token = NULL;
dummy.uri.path = collZ;
dummy.owner = ne_strdup("litmus: owner lock");
dummy.depth = NE_DEPTH_INFINITE;
dummy.type = ne_locktype_write;
dummy.scope = ne_lockscope_exclusive;
ONNREQ2("LOCK on second collection for further tests",
ne_lock(i_session, &dummy));
gotlock = ne_lock_copy(&dummy);
ne_lockstore_add(store, gotlock);
/* Testing creation of directories under a collection */
ONV(ne_mkcol(i_session, collX),
("MKCOL %s: %s", collX, ne_get_error(i_session)));
ONV(ne_mkcol(i_session, collY),
("MKCOL %s: %s", collY, ne_get_error(i_session)));
upload_foo("lockcoll/collX/temp");
tmp = ne_concat(collY,"copy-temp",NULL);
ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp),
("collection COPY `%s' to `%s': %s", res2, tmp,
ne_get_error(i_session)));
free(tmp);
tmp2=ne_concat(collZ,"testing",NULL);
ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp2),
("collection COPY `%s' to `%s': %s", res2, tmp2,
ne_get_error(i_session)));
ne_free(res3);
res3 = ne_concat(i_path,"not-existing",NULL);
/* change res to point to a normal resource for subsequent
* {not_,}owner_modify tests */
res = ne_concat(coll, "lockme.txt", NULL);
return upload_foo("lockcoll/lockme.txt");
}
示例13: peek_expect
/* do a sock_peek() on sock for 'len' bytes, and expect 'str'. */
static int peek_expect(ne_socket *sock, const char *str, size_t len)
{
ssize_t ret;
memset(buffer, '@', sizeof buffer);
ret = ne_sock_peek(sock, buffer, len);
ONV((ssize_t)len != ret,
("peek got %" NE_FMT_SSIZE_T " bytes not %" NE_FMT_SIZE_T, ret, len));
ONV(memcmp(str, buffer, len),
("peek mismatch: `%.*s' not `%.*s'",
(int)len, buffer, (int)len, str));
ONV(buffer[len] != '@',
("buffer overrun: %" NE_FMT_SSIZE_T "nth byte was '%c' not '@'",
len, buffer[len]));
return OK;
}
示例14: discard_request
int discard_request(ne_socket *sock)
{
char buffer[1024];
size_t offset = want_header?strlen(want_header):0;
clength = 0;
NE_DEBUG(NE_DBG_HTTP, "Discarding request...\n");
do {
ONV(ne_sock_readline(sock, buffer, 1024) < 0,
("error reading line: %s", ne_sock_error(sock)));
NE_DEBUG(NE_DBG_HTTP, "[req] %s", buffer);
if (strncasecmp(buffer, "content-length:", 15) == 0) {
clength = atoi(buffer + 16);
}
if (got_header != NULL && want_header != NULL &&
strncasecmp(buffer, want_header, offset) == 0 &&
buffer[offset] == ':') {
char *value = buffer + offset + 1;
if (*value == ' ') value++;
got_header(ne_shave(value, "\r\n"));
}
} while (strcmp(buffer, "\r\n") != 0);
return OK;
}
示例15: addr_reverse
static int addr_reverse(void)
{
ne_inet_addr *ia = ne_iaddr_make(ne_iaddr_ipv4, raw_127);
char buf[128], *syshost = NULL;
#ifdef HAVE_GETHOSTNAME
char host[128];
if (gethostname(host, sizeof host) == 0) {
syshost = host;
}
#endif
ONN("ne_iaddr_make returned NULL", ia == NULL);
ONN("reverse lookup for 127.0.0.1 failed",
ne_iaddr_reverse(ia, buf, sizeof buf) != 0);
ONV(!(strcmp(buf, "localhost.localdomain") == 0
|| strcmp(buf, "localhost") == 0
|| (syshost && strcmp(buf, syshost) == 0)),
("reverse lookup for 127.0.0.1 got %s", buf));
ne_iaddr_free(ia);
return OK;
}