rbb 99/05/25 10:04:15
Modified: apr/network_io/unix poll.c sendrecv.c sockets.c sockopt.c apr/test client.c server.c testproc.c testsock.c testthread.c testtime.c apr/threadproc/unix proc.c signals.c thread.c threadcancel.c threadpriv.c apr/time/unix access.c time.c include apr_errno.h apr_network_io.h apr_thread_proc.h apr_time.h Log: This brings the rest of the apr files up to par. Every apr function now returns a status code. Sopme of the test programs no longer work, I'll looking into those. Revision Changes Path 1.9 +23 -14 apache-apr/apr/network_io/unix/poll.c Index: poll.c =================================================================== RCS file: /home/cvs/apache-apr/apr/network_io/unix/poll.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- poll.c 1999/05/24 02:23:43 1.8 +++ poll.c 1999/05/25 17:03:44 1.9 @@ -60,12 +60,14 @@ #include <sys/poll.h> -ap_pollfd_t *ap_setup_poll(ap_context_t *cont, ap_int32_t num) +ap_status_t ap_setup_poll(ap_context_t *cont, ap_int32_t num, struct pollfd_t **new) { - struct pollfd_t *new; - new = (struct pollfd_t *)ap_palloc(cont->pool, sizeof(struct pollfd_t) * num); - new->cntxt = cont; - return new; + (*new) = (struct pollfd_t *)ap_palloc(cont->pool, sizeof(struct pollfd_t) * num); + if ((*new) == NULL) { + return APR_ENOMEM; + } + (*new)->cntxt = cont; + return APR_SUCCESS; } ap_int16_t get_event(ap_int16_t event) @@ -108,24 +110,25 @@ return rv; } -void ap_add_poll_socket(struct pollfd_t *aprset, +ap_status_t ap_add_poll_socket(struct pollfd_t *aprset, struct socket_t *sock, ap_int16_t event, ap_int32_t pos) { aprset[pos].sock = sock; aprset[pos].events = get_event(event); + return APR_SUCCESS; } -ap_int32_t ap_poll(struct pollfd_t *aprset, ap_int32_t nsds, ap_int32_t timeout) +ap_status_t ap_poll(struct pollfd_t *aprset, ap_int32_t *nsds, ap_int32_t timeout) { int i; struct pollfd *pollset; int rv; pollset = (struct pollfd *)ap_palloc(aprset->cntxt->pool, - sizeof(struct pollfd) * nsds); + sizeof(struct pollfd) * (*nsds)); - for (i = 0; i < nsds; i++) { + for (i = 0; i < (*nsds); i++) { pollset[i].fd = aprset[i].sock->socketdes; pollset[i].events = aprset[i].events; } @@ -134,16 +137,22 @@ timeout *= 1000; } - rv = poll(pollset, nsds, timeout); + rv = poll(pollset, (*nsds), timeout); + (*nsds) = rv; - for (i = 0; i < nsds; i++) { + for (i = 0; i < (*nsds); i++) { aprset[i].revents = get_revent(pollset[i].revents); } - return rv; + + if ((*nsds) < 0) { + return errno; + } + return APR_SUCCESS; } -ap_int16_t ap_get_revents(struct pollfd_t *aprset, ap_int32_t pos) +ap_status_t ap_get_revents(struct pollfd_t *aprset, ap_int32_t pos, ap_int16_t *event) { - return aprset[pos].revents; + (*event) = aprset[pos].revents; + return APR_SUCCESS; } 1.9 +14 -10 apache-apr/apr/network_io/unix/sendrecv.c Index: sendrecv.c =================================================================== RCS file: /home/cvs/apache-apr/apr/network_io/unix/sendrecv.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- sendrecv.c 1999/05/24 02:04:08 1.8 +++ sendrecv.c 1999/05/25 17:03:48 1.9 @@ -61,12 +61,12 @@ #include "apr_network_io.h" #include <sys/time.h> -ap_ssize_t ap_send(struct socket_t *sock, const char *buf, int len, time_t sec) +ap_status_t ap_send(struct socket_t *sock, const char *buf, ap_ssize_t *len, time_t sec) { ssize_t rv; do { - rv = write(sock->socketdes, buf, len); + rv = write(sock->socketdes, buf, (*len)); } while (rv == -1 && errno == EINTR); if (rv == -1 && errno == EAGAIN && sec > 0) { @@ -84,23 +84,25 @@ } while (srv == -1 && errno == EINTR); if (srv < 1) { - return (ap_ssize_t) -1; + (*len) = -1; + return errno; } else { do { - rv = write(sock->socketdes, buf, len); + rv = write(sock->socketdes, buf, (*len)); } while (rv == -1 && errno == EINTR); } } - return (ap_ssize_t) rv; + (*len) = rv; + return APR_SUCCESS; } -ap_ssize_t ap_recv(struct socket_t *sock, char *buf, int len, time_t sec) +ap_status_t ap_recv(struct socket_t *sock, char *buf, ap_ssize_t *len, time_t sec) { ssize_t rv; do { - rv = read(sock->socketdes, buf, len); + rv = read(sock->socketdes, buf, (*len)); } while (rv == -1 && errno == EINTR); if (rv == -1 && errno == EAGAIN && sec > 0) { @@ -118,14 +120,16 @@ } while (srv == -1 && errno == EINTR); if (srv < 1) { - return (ap_ssize_t) -1; + (*len) = -1; + return errno; } else { do { - rv = read(sock->socketdes, buf, len); + rv = read(sock->socketdes, buf, (*len)); } while (rv == -1 && errno == EINTR); } } - return (ap_ssize_t) rv; + (*len) = rv; + return APR_SUCCESS; } 1.17 +53 -39 apache-apr/apr/network_io/unix/sockets.c Index: sockets.c =================================================================== RCS file: /home/cvs/apache-apr/apr/network_io/unix/sockets.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- sockets.c 1999/05/24 02:04:08 1.16 +++ sockets.c 1999/05/25 17:03:48 1.17 @@ -72,34 +72,38 @@ return APR_SUCCESS; } else { - return APR_FAILURE; + return errno; } } -struct socket_t *ap_create_tcp_socket(ap_context_t *cont) +ap_status_t ap_create_tcp_socket(ap_context_t *cont, struct socket_t **new) { - struct socket_t *thesocket; + (*new) = (struct socket_t *)ap_palloc(cont->pool, sizeof(struct socket_t)); - thesocket = (struct socket_t *)ap_palloc(cont->pool, sizeof(struct socket_t)); - - thesocket->cntxt = cont; - thesocket->socketdes = socket(AF_INET ,SOCK_STREAM, IPPROTO_TCP); - thesocket->remote_hostname = NULL; - - thesocket->addr = (struct sockaddr_in *)ap_palloc(thesocket->cntxt->pool, + if ((*new) == NULL) { + return APR_ENOMEM; + } + (*new)->cntxt = cont; + (*new)->addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt->pool, sizeof(struct sockaddr_in)); - thesocket->addr->sin_family = AF_INET; - thesocket->addr_len = sizeof(*thesocket->addr); - - if (thesocket->socketdes < 0) { - return NULL; + if ((*new)->addr == NULL) { + return APR_ENOMEM; } - else { - ap_register_cleanup(thesocket->cntxt->pool, (void *)thesocket, - socket_cleanup, NULL); - return thesocket; + + (*new)->socketdes = socket(AF_INET ,SOCK_STREAM, IPPROTO_TCP); + (*new)->remote_hostname = NULL; + + (*new)->addr->sin_family = AF_INET; + + (*new)->addr_len = sizeof(*(*new)->addr); + + if ((*new)->socketdes < 0) { + return errno; } + ap_register_cleanup((*new)->cntxt->pool, (void *)(*new), + socket_cleanup, NULL); + return APR_SUCCESS; } ap_status_t ap_shutdown(struct socket_t *thesocket, ap_shutdown_how_e how) @@ -108,14 +112,14 @@ return APR_SUCCESS; } else { - return APR_FAILURE; + return errno; } } ap_status_t ap_close_socket(struct socket_t *thesocket) { - socket_cleanup(thesocket); ap_kill_cleanup(thesocket->cntxt->pool, thesocket, socket_cleanup); + return socket_cleanup(thesocket); } ap_status_t ap_setport(struct socket_t *sock, ap_uint32_t port) @@ -128,7 +132,7 @@ { sock->addr->sin_addr.s_addr = INADDR_ANY; if (bind(sock->socketdes, (struct sockaddr *)sock->addr, sock->addr_len) == -1) - return APR_FAILURE; + return errno; else return APR_SUCCESS; } @@ -136,35 +140,39 @@ ap_status_t ap_listen(struct socket_t *sock, ap_int32_t backlog) { if (listen(sock->socketdes, backlog) == -1) - return APR_FAILURE; + return errno; else return APR_SUCCESS; } -struct socket_t *ap_accept(const struct socket_t *sock) +ap_status_t ap_accept(const struct socket_t *sock, struct socket_t **new) { - struct socket_t *new = (struct socket_t *)ap_palloc(sock->cntxt->pool, - sizeof(struct socket_t)); struct hostent *hptr; + + (*new) = (struct socket_t *)ap_palloc(sock->cntxt->pool, + sizeof(struct socket_t)); - new->cntxt = sock->cntxt; - new->addr = (struct sockaddr_in *)ap_palloc(new->cntxt->pool, + (*new)->cntxt = sock->cntxt; + (*new)->addr = (struct sockaddr_in *)ap_palloc((*new)->cntxt->pool, sizeof(struct sockaddr_in)); - new->addr_len = sizeof(struct sockaddr_in); + (*new)->addr_len = sizeof(struct sockaddr_in); - new->socketdes = accept(sock->socketdes, (struct sockaddr *)new->addr, &new->addr_len); + (*new)->socketdes = accept(sock->socketdes, (struct sockaddr *)(*new)->addr, + &(*new)->addr_len); - if (new->socketdes < 0) { - return NULL; + if ((*new)->socketdes < 0) { + return errno; } - hptr = gethostbyaddr((char *)&new->addr->sin_addr, sizeof(struct in_addr), AF_INET); + hptr = gethostbyaddr((char *)&(*new)->addr->sin_addr, + sizeof(struct in_addr), AF_INET); if (hptr != NULL) { - new->remote_hostname = strdup(hptr->h_name); + (*new)->remote_hostname = strdup(hptr->h_name); } - ap_register_cleanup(new->cntxt->pool, (void *)new, socket_cleanup, NULL); - return new; + ap_register_cleanup((*new)->cntxt->pool, (void *)(*new), + socket_cleanup, NULL); + return APR_SUCCESS; } ap_status_t ap_connect(struct socket_t *sock, char *hostname) @@ -173,8 +181,14 @@ hp = gethostbyname(hostname); - if ((sock->socketdes < 0) || (!hp) || (!sock->addr)) { - return APR_FAILURE; + if ((sock->socketdes < 0) || (!sock->addr)) { + return APR_ENOTSOCK; + } + if (!hp) { + if (h_errno == TRY_AGAIN) { + return EAGAIN; + } + return h_errno; } memcpy((char *)&sock->addr->sin_addr, hp->h_addr_list[0], hp->h_length); @@ -185,7 +199,7 @@ if ((connect(sock->socketdes, sock->addr, sock->addr_len) < 0) && (errno != EINPROGRESS)) { - return APR_FAILURE; + return errno; } else { sock->remote_hostname = strdup(hostname); 1.7 +26 -14 apache-apr/apr/network_io/unix/sockopt.c Index: sockopt.c =================================================================== RCS file: /home/cvs/apache-apr/apr/network_io/unix/sockopt.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- sockopt.c 1999/05/24 02:04:08 1.6 +++ sockopt.c 1999/05/25 17:03:48 1.7 @@ -56,6 +56,7 @@ #include "networkio.h" #include "apr_network_io.h" #include "apr_general.h" +#include "apr_lib.h" #include <errno.h> #include <string.h> #include <sys/socket.h> @@ -79,10 +80,13 @@ /* XXXX: this breaks things, but an alternative isn't obvious...*/ return -1; #endif - return fcntl(sd, F_SETFL, fd_flags); + if (fcntl(sd, F_SETFL, fd_flags) == -1) { + return errno; + } + return APR_SUCCESS; } -int sononblock(int sd) +ap_status_t sononblock(int sd) { int fd_flags; @@ -97,7 +101,10 @@ /* XXXX: this breaks things, but an alternative isn't obvious...*/ return -1; #endif - return fcntl(sd, F_SETFL, fd_flags); + if (fcntl(sd, F_SETFL, fd_flags) == -1) { + return errno; + } + return APR_SUCCESS; } @@ -105,6 +112,7 @@ { int one; struct linger li; + ap_status_t stat; if (on) one = 1; @@ -113,34 +121,34 @@ if (opt & APR_SO_KEEPALIVE) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (char *) one, sizeof(int)) == -1) { - return APR_FAILURE; + return errno; } } if (opt & APR_SO_DEBUG) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, (char *) one, sizeof(int)) == -1) { - return APR_FAILURE; + return errno; } } if (opt & APR_SO_REUSEADDR) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (char *) one, sizeof(int)) == -1) { - return APR_FAILURE; + return errno; } } if (opt & APR_SO_NONBLOCK) { if (on) { - if (soblock(sock->socketdes) == -1) - return APR_FAILURE; + if ((stat = soblock(sock->socketdes)) != APR_SUCCESS) + return stat; } else { - if (sononblock(sock->socketdes) == -1) - return APR_FAILURE; + if ((stat = sononblock(sock->socketdes)) != APR_SUCCESS) + return stat; } } if (opt & APR_SO_LINGER) { li.l_onoff = on; li.l_linger = MAX_SECS_TO_LINGER; if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) { - return APR_FAILURE; + return errno; } } return APR_SUCCESS; @@ -149,14 +157,18 @@ ap_status_t ap_gethostname(ap_context_t *cont, char *buf, int len) { if (gethostname(buf, len) == -1) - return APR_FAILURE; + return errno; else return APR_SUCCESS; } -char *ap_get_remote_hostname(struct socket_t *sock) +ap_status_t ap_get_remote_hostname(struct socket_t *sock, char **name) { - return sock->remote_hostname; + (*name) = ap_pstrdup(sock->cntxt->pool, sock->remote_hostname); + if (*name) { + return APR_SUCCESS; + } + return APR_ENOMEM; } 1.6 +18 -10 apache-apr/apr/test/client.c Index: client.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/client.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- client.c 1999/05/24 02:04:10 1.5 +++ client.c 1999/05/25 17:03:53 1.6 @@ -69,21 +69,27 @@ ap_context_t *context; ap_socket_t *sock; ap_int32_t rv; + ap_ssize_t length; struct timeval timeout; char datasend[STRLEN] = "Send data test"; char datarecv[STRLEN]; - context = ap_initialize(NULL); + fprintf(stdout, "Creating context......."); + if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) { + fprintf(stderr, "Something went wrong\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); fprintf(stdout, "\tClient: Creating new socket......."); - if ((sock = ap_create_tcp_socket(context)) == NULL) { + if (ap_create_tcp_socket(context, &sock) != APR_SUCCESS) { fprintf(stderr, "Couldn't create socket\n"); exit(-1); } fprintf(stdout, "OK\n"); fprintf(stdout, "\tClient: Setting socket option NONBLOCK......."); - if (ap_setsocketopt(sock, APR_SO_NONBLOCK, 1) == APR_FAILURE) { + if (ap_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Couldn't set socket option\n"); exit(-1); @@ -91,7 +97,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tClient: Setting port for socket......."); - if (ap_setport(sock, 8021) == APR_FAILURE) { + if (ap_setport(sock, 8021) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Couldn't set the port correctly\n"); exit(-1); @@ -99,7 +105,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tClient: Connecting to socket......."); - if (ap_connect(sock, "localhost") == APR_FAILURE) { + if (ap_connect(sock, "localhost") != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Could not connect\n"); exit(-1); @@ -107,15 +113,17 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tClient: Trying to send data over socket......."); - if (ap_send(sock, datasend, STRLEN, 5) != STRLEN) { + length = STRLEN; + if (ap_send(sock, datasend, &length, 5) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Problem sending data\n"); exit(-1); } fprintf(stdout, "OK\n"); - + + length = STRLEN; fprintf(stdout, "\tClient: Trying to receive data over socket......."); - if (ap_recv(sock, datarecv, STRLEN, 5) != STRLEN) { + if (ap_recv(sock, datarecv, &length, 5) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Problem receiving data\n"); exit(-1); @@ -128,7 +136,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tClient: Shutting down socket......."); - if (ap_shutdown(sock, APR_SHUTDOWN_WRITE) == APR_FAILURE) { + if (ap_shutdown(sock, APR_SHUTDOWN_WRITE) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Could not shutdown socket\n"); exit(-1); @@ -136,7 +144,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tClient: Closing down socket......."); - if (ap_close_socket(sock) == APR_FAILURE) { + if (ap_close_socket(sock) != APR_SUCCESS) { fprintf(stderr, "Could not shutdown socket\n"); exit(-1); } 1.7 +24 -16 apache-apr/apr/test/server.c Index: server.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/server.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- server.c 1999/05/24 02:04:11 1.6 +++ server.c 1999/05/25 17:03:53 1.7 @@ -68,22 +68,28 @@ ap_context_t *context; ap_socket_t *sock; ap_socket_t *sock2; + ap_ssize_t length; ap_int32_t rv; ap_pollfd_t *sdset; char datasend[STRLEN]; char datarecv[STRLEN] = "Recv data test"; - context = ap_initialize(NULL); + fprintf(stdout, "Creating context......."); + if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) { + fprintf(stderr, "Could not create a context\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Creating new socket......."); - if ((sock = ap_create_tcp_socket(context)) == NULL) { + if (ap_create_tcp_socket(context, &sock) != APR_SUCCESS) { fprintf(stderr, "Couldn't create socket\n"); exit(-1); } fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Setting socket option NONBLOCK......."); - if (ap_setsocketopt(sock, APR_SO_NONBLOCK, 1) == APR_FAILURE) { + if (ap_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Couldn't set socket option\n"); exit(-1); @@ -91,7 +97,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Setting port for socket......."); - if (ap_setport(sock, 8021) == APR_FAILURE) { + if (ap_setport(sock, 8021) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Couldn't set the port correctly\n"); exit(-1); @@ -99,15 +105,15 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Binding socket to port......."); - if (ap_bind(sock) == APR_FAILURE) { + if (ap_bind(sock) != APR_SUCCESS) { ap_close_socket(sock); - fprintf(stderr, "Could not bind %d\n", errno); + fprintf(stderr, "Could not bind\n"); exit(-1); } fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Listening to socket......."); - if (ap_listen(sock, 8021) == APR_FAILURE) { + if (ap_listen(sock, 8021) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Could not listen\n"); exit(-1); @@ -115,13 +121,13 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Setting up socket for polling......."); - sdset = ap_setup_poll(context, 1); + ap_setup_poll(context, 1, &sdset); ap_add_poll_socket(sdset, sock, APR_POLLIN, 0); fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Beginning to poll for socket......."); - rv = ap_poll(sdset, 1, -1); - if (rv == -1) { + rv = 1; + if (ap_poll(sdset, &rv, -1) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Select caused an error\n"); exit(-1); @@ -134,15 +140,16 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Accepting a connection......."); - if ((sock2 = ap_accept(sock)) == NULL) { + if (ap_accept(sock, &sock2) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Could not accept connection.\n"); exit(-1); } fprintf(stdout, "OK\n"); + length = STRLEN; fprintf(stdout, "\tServer: Trying to recv data from socket......."); - if (ap_recv(sock2, datasend, STRLEN, 5) != STRLEN) { + if (ap_recv(sock2, datasend, &length, 5) != APR_SUCCESS) { ap_close_socket(sock); ap_close_socket(sock2); fprintf(stderr, "Problem recving data\n"); @@ -156,8 +163,9 @@ } fprintf(stdout, "OK\n"); + length = STRLEN; fprintf(stdout, "\tServer: Sending data over socket......."); - if (ap_send(sock2, datarecv, STRLEN, 5) != STRLEN) { + if (ap_send(sock2, datarecv, &length, 5) != APR_SUCCESS) { ap_close_socket(sock); ap_close_socket(sock2); fprintf(stderr, "Problem sending data\n"); @@ -166,7 +174,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: Shutting down accepte socket......."); - if (ap_shutdown(sock2, APR_SHUTDOWN_READ) == APR_FAILURE) { + if (ap_shutdown(sock2, APR_SHUTDOWN_READ) != APR_SUCCESS) { ap_close_socket(sock); ap_close_socket(sock2); fprintf(stderr, "Problem shutting down\n"); @@ -175,7 +183,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: closing duplicate socket......."); - if (ap_close_socket(sock2) == APR_FAILURE) { + if (ap_close_socket(sock2) != APR_SUCCESS) { ap_close_socket(sock); fprintf(stderr, "Problem closing down\n"); exit(-1); @@ -183,7 +191,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tServer: closing original socket......."); - if (ap_close_socket(sock) == APR_FAILURE) { + if (ap_close_socket(sock) != APR_SUCCESS) { fprintf(stderr, "Problem closing down\n"); exit(-1); } 1.6 +24 -16 apache-apr/apr/test/testproc.c Index: testproc.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testproc.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- testproc.c 1999/05/24 02:04:12 1.5 +++ testproc.c 1999/05/25 17:03:54 1.6 @@ -71,41 +71,45 @@ ap_proc_t *newproc; ap_procattr_t *attr; ap_file_t *testfile; - ap_ssize_t rv; - char buf[256]; + ap_ssize_t rv, length; + char *buf; char *args[3]; char *teststr = "Whooo Hoooo\n"; - context = ap_initialize(NULL); + fprintf(stdout, "Creating context......."); + if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) { + fprintf(stderr, "Could not create context\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); if (argc > 1) { - fprintf(stdout, "%s", teststr); + write(STDOUT_FILENO, teststr, strlen(teststr)); exit(1); } fprintf(stdout, "Creating procattr......."); - attr = ap_createprocattr_init(context); - if (attr == NULL) { + if (ap_createprocattr_init(context, &attr) != APR_SUCCESS) { fprintf(stderr, "Could not create attr\n"); exit(-1);; } fprintf(stdout, "OK.\n"); fprintf(stdout, "Setting attr pipes, all three......."); - if (ap_setprocattr_io(attr, 1, 1, 1) == APR_FAILURE) { + if (ap_setprocattr_io(attr, 1, 1, 1) != APR_SUCCESS) { fprintf(stderr, "Could not set pipes attr\n"); exit(-1); } fprintf(stdout, "OK.\n"); fprintf(stdout, "Setting attr dir......."); - if (ap_setprocattr_dir(attr, "proctest") == APR_FAILURE) { + if (ap_setprocattr_dir(attr, "proctest") != APR_SUCCESS) { fprintf(stderr, "Could not set directory attr\n"); exit(-1); } fprintf(stdout, "OK.\n"); fprintf(stdout, "Setting attr cmd type......."); - if (ap_setprocattr_cmdtype(attr, APR_PROGRAM) == APR_FAILURE) { + if (ap_setprocattr_cmdtype(attr, APR_PROGRAM) != APR_SUCCESS) { fprintf(stderr, "Could not set cmd type attr\n"); exit(-1); } @@ -116,24 +120,28 @@ args[2] = NULL; fprintf(stdout, "Createing a new process......."); - if ((newproc = ap_create_process(context, "../testproc", args, NULL, attr)) == NULL) { + if (ap_create_process(context, "../testproc", args, NULL, attr, &newproc) != APR_SUCCESS) { fprintf(stderr, "Could not create the new process\n"); exit(-1); } fprintf(stdout, "OK.\n"); fprintf(stdout, "Grabbing child's stdout......."); - if ((testfile = ap_get_childout(newproc)) == NULL) { + if (ap_get_childout(newproc, &testfile) != APR_SUCCESS) { fprintf(stderr, "Could not get child's stdout\n"); exit(-1); } fprintf(stdout, "OK.\n"); + length = 256; fprintf(stdout, "Checking the data read from pipe to child......."); - rv = ap_read(testfile, buf, 256); - buf[rv] = '\0'; - if (!strcmp(buf, teststr)) - fprintf(stdout,"OK\n"); - else fprintf(stderr, "Uh-Oh\n"); + if (ap_read(testfile, buf, &length) == APR_SUCCESS) { + fprintf(stdout, "%s %s\n", buf, teststr); + fprintf(stdout, "%d %d\n", strlen(buf), strlen(teststr)); + if (!strcmp(buf, teststr)) + fprintf(stdout,"OK\n"); + else fprintf(stderr, "Uh-Oh\n"); + } + else fprintf(stderr, "Read failed.\n"); } 1.9 +12 -8 apache-apr/apr/test/testsock.c Index: testsock.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testsock.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- testsock.c 1999/05/24 02:04:13 1.8 +++ testsock.c 1999/05/25 17:03:54 1.9 @@ -72,7 +72,12 @@ ap_status_t s1; ap_status_t s2; - context = ap_initialize(NULL); + fprintf(stdout, "Creating context......."); + if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) { + fprintf(stderr, "Could not vreate context\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); fprintf(stdout, "This test relies on the process test working. Please\n"); fprintf(stdout, "run that test first, and only run this test when it\n"); @@ -80,25 +85,24 @@ fprintf(stdout, "server and client by yourself.\n"); fprintf(stdout, "Creating children to run network tests.......\n"); - attr1 = ap_createprocattr_init(context); - attr2 = ap_createprocattr_init(context); - + ap_createprocattr_init(context, &attr1); + ap_createprocattr_init(context, &attr2); if (attr1 == NULL || attr2 == NULL) { fprintf(stderr, "Problem creating proc attrs\n"); exit(-1); } - proc1 = ap_create_process(context, "server", NULL, NULL, attr1); - proc2 = ap_create_process(context, "client", NULL, NULL, attr2); + ap_create_process(context, "server", NULL, NULL, attr1, &proc1); + ap_create_process(context, "client", NULL, NULL, attr2, &proc2); if (proc1 == NULL || proc2 == NULL) { fprintf(stderr, "Problem spawning new process\n"); exit(-1); } - while ((s1 = ap_wait_proc(proc1, APR_NOWAIT)) == APR_FAILURE && - (s2 = ap_wait_proc(proc2, APR_NOWAIT)) == APR_FAILURE) + while ((s1 = ap_wait_proc(proc1, APR_NOWAIT)) != APR_SUCCESS && + (s2 = ap_wait_proc(proc2, APR_NOWAIT)) != APR_SUCCESS) continue; if (s1 == APR_SUCCESS) { 1.6 +4 -4 apache-apr/apr/test/testthread.c Index: testthread.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testthread.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- testthread.c 1999/05/25 03:22:07 1.5 +++ testthread.c 1999/05/25 17:03:54 1.6 @@ -131,10 +131,10 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "Starting all the threads......."); - t1 = ap_create_thread(context, NULL, thread_func1, NULL); - t2 = ap_create_thread(context, NULL, thread_func2, NULL); - t3 = ap_create_thread(context, NULL, thread_func3, NULL); - t4 = ap_create_thread(context, NULL, thread_func4, NULL); + ap_create_thread(context, NULL, thread_func1, NULL, &t1); + ap_create_thread(context, NULL, thread_func2, NULL, &t2); + ap_create_thread(context, NULL, thread_func3, NULL, &t3); + ap_create_thread(context, NULL, thread_func4, NULL, &t4); if (t1 == NULL || t2 == NULL || t3 == NULL || t4 == NULL) { fprintf(stderr, "Error starting thread\n"); exit(-1); 1.3 +20 -23 apache-apr/apr/test/testtime.c Index: testtime.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testtime.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- testtime.c 1999/05/24 02:04:13 1.2 +++ testtime.c 1999/05/25 17:03:54 1.3 @@ -69,36 +69,39 @@ ap_int32_t rv = 0; ap_int64_t t1, t2; - context = ap_initialize(NULL); + fprintf(stdout, "Creating context......."); + if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) { + fprintf(stderr, "could not create context\n"); + exit(-1); + } + fprintf(stdout, "OK\n"); fprintf(stdout, "Testing Time functions.\n"); fprintf(stdout, "\tMaking new time variable......."); - time = ap_make_time(context); - if (time == NULL) { + if (ap_make_time(context, &time) != APR_SUCCESS) { fprintf(stderr, "Couldn't allocate memory\n"); exit(-1); } fprintf(stdout, "OK\n"); fprintf(stdout, "\tGetting current time......."); - if (ap_current_time(time) == APR_FAILURE) { + if (ap_current_time(time) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the time\n"); exit(-1); } fprintf(stdout, "OK\n"); fprintf(stdout, "\tExploding Current time......."); - if (ap_explode_time(time, APR_UTCTIME) == APR_FAILURE) { + if (ap_explode_time(time, APR_UTCTIME) != APR_SUCCESS) { fprintf(stderr, "Couldn't explode the time\n"); exit(-1); } fprintf(stdout, "OK\n"); - time2 = ap_make_time(context); + ap_make_time(context, &time2); fprintf(stdout, "\tGetting the number of seconds......."); - rv = ap_get_sec(time); - if (rv < 0) { + if (ap_get_sec(time, &rv) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the seconds\n"); exit(-1); } @@ -106,8 +109,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tGetting the number of minutes......."); - rv = ap_get_min(time); - if (rv < 0) { + if (ap_get_min(time, &rv) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the minutes\n"); exit(-1); } @@ -115,8 +117,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tGetting the number of hours......."); - rv = ap_get_hour(time); - if (rv < 0) { + if (ap_get_hour(time, &rv) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the hours\n"); exit(-1); } @@ -124,8 +125,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tGetting the number of days......."); - rv = ap_get_mday(time); - if (rv < 0) { + if (ap_get_mday(time, &rv) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the days\n"); exit(-1); } @@ -133,8 +133,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tGetting the month ......."); - rv = ap_get_mon(time); - if (rv < 0) { + if (ap_get_mon(time, &rv) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the month\n"); exit(-1); } @@ -142,8 +141,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tGetting the year......."); - rv = ap_get_year(time); - if (rv < 0) { + if (ap_get_year(time, &rv) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the year\n"); exit(-1); } @@ -151,8 +149,7 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tGetting the weekday......."); - rv = ap_get_wday(time); - if (rv < 0) { + if (ap_get_wday(time, &rv) != APR_SUCCESS) { fprintf(stderr, "Couldn't get the week day\n"); exit(-1); } @@ -160,15 +157,15 @@ fprintf(stdout, "OK\n"); fprintf(stdout, "\tImploding the time......."); - if (ap_implode_time(time2) == APR_FAILURE) { + if (ap_implode_time(time2) != APR_SUCCESS) { fprintf(stderr, "Couldn't implode time\n"); exit(-1); } fprintf(stdout, "OK\n"); fprintf(stdout, "\tComparing two time values......."); - t1 = ap_get_curtime(time); - t2 = ap_get_curtime(time2); + ap_get_curtime(time, &t1); + ap_get_curtime(time2, &t2); if ((t1 == -1) || (t2 == -1) || (t1 != t2)) { fprintf(stderr, "Values don't match\n"); exit(-1); 1.13 +76 -49 apache-apr/apr/threadproc/unix/proc.c Index: proc.c =================================================================== RCS file: /home/cvs/apache-apr/apr/threadproc/unix/proc.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- proc.c 1999/05/24 02:04:19 1.12 +++ proc.c 1999/05/25 17:04:02 1.13 @@ -59,37 +59,47 @@ #include "apr_thread_proc.h" #include "apr_file_io.h" #include "apr_general.h" +#include "apr_lib.h" #include <signal.h> #include <string.h> #include <sys/wait.h> -struct procattr_t *ap_createprocattr_init(ap_context_t *cont) +ap_status_t ap_createprocattr_init(ap_context_t *cont, struct procattr_t **new) { - struct procattr_t *new = (struct procattr_t *)ap_palloc(cont->pool, sizeof(struct procattr_t)); + (*new) = (struct procattr_t *)ap_palloc(cont->pool, + sizeof(struct procattr_t)); - new->cntxt = cont; - new->parent_in = NULL; - new->child_in = NULL; - new->parent_out = NULL; - new->child_out = NULL; - new->parent_err = NULL; - new->child_err = NULL; - new->currdir = NULL; - new->cmdtype = APR_PROGRAM; - return new; + if ((*new) == NULL) { + return APR_ENOMEM; + } + (*new)->cntxt = cont; + (*new)->parent_in = NULL; + (*new)->child_in = NULL; + (*new)->parent_out = NULL; + (*new)->child_out = NULL; + (*new)->parent_err = NULL; + (*new)->child_err = NULL; + (*new)->currdir = NULL; + (*new)->cmdtype = APR_PROGRAM; + return APR_SUCCESS; } ap_status_t ap_setprocattr_io(struct procattr_t *attr, ap_int32_t in, ap_int32_t out, ap_int32_t err) { + ap_status_t stat; if (in) { attr->parent_in = (ap_file_t *)ap_palloc(attr->cntxt->pool, sizeof(ap_file_t)); attr->child_in = (ap_file_t *)ap_palloc(attr->cntxt->pool, sizeof(ap_file_t)); - if (ap_create_pipe(attr->cntxt, attr->child_in, - attr->parent_in) == APR_FAILURE) { - return APR_FAILURE; + if ((attr->parent_in == NULL) || (attr->child_in == NULL)) { + return APR_ENOMEM; + } + + if ((stat = ap_create_pipe(attr->cntxt, attr->child_in, + attr->parent_in)) != APR_SUCCESS) { + return stat; } } if (out) { @@ -97,64 +107,84 @@ sizeof(ap_file_t)); attr->child_out = (ap_file_t *)ap_palloc(attr->cntxt->pool, sizeof(ap_file_t)); - if (ap_create_pipe(attr->cntxt, attr->parent_out, - attr->child_out) == APR_FAILURE) { - return APR_FAILURE; + + if ((attr->parent_out == NULL) || (attr->child_out == NULL)) { + return APR_ENOMEM; } + + if ((stat = ap_create_pipe(attr->cntxt, attr->parent_out, + attr->child_out)) != APR_SUCCESS) { + return stat; + } } if (err) { attr->parent_err = (ap_file_t *)ap_palloc(attr->cntxt->pool, sizeof(ap_file_t)); attr->child_err = (ap_file_t *)ap_palloc(attr->cntxt->pool, sizeof(ap_file_t)); - if (ap_create_pipe(attr->cntxt, attr->parent_err, - attr->child_err) == APR_FAILURE) { - return APR_FAILURE; + if ((attr->parent_err == NULL) || (attr->child_err == NULL)) { + return APR_ENOMEM; + } + + if ((stat = ap_create_pipe(attr->cntxt, attr->parent_err, + attr->child_err)) != APR_SUCCESS) { + return stat; } } + return APR_SUCCESS; } ap_status_t ap_setprocattr_dir(struct procattr_t *attr, char *dir) { - attr->currdir = strdup(dir); + attr->currdir = ap_pstrdup(attr->cntxt->pool, dir); + if (attr->currdir) { + return APR_SUCCESS; + } + return APR_ENOMEM; } ap_status_t ap_setprocattr_cmdtype(struct procattr_t *attr, ap_cmdtype_e cmd) { attr->cmdtype = cmd; + return APR_SUCCESS; } -ap_int32_t ap_fork(struct proc_t *proc) +ap_status_t ap_fork(struct proc_t *proc) { int pid; if ((pid = fork()) < 0) { - return -1; + return errno; } else if (pid == 0) { proc->pid = pid; proc->attr = NULL; - return pid; + return APR_INCHILD; } proc->pid = pid; proc->attr = NULL; - return 1; + return APR_INPARENT; } -struct proc_t *ap_create_process(ap_context_t *cont, char *progname, +ap_status_t ap_create_process(ap_context_t *cont, char *progname, char *const args[], char **env, - struct procattr_t *attr) + struct procattr_t *attr, struct proc_t **new) { - struct proc_t *new = (struct proc_t *)ap_palloc(cont->pool, sizeof(struct proc_t)); int i; char **newargs; + + (*new) = (struct proc_t *)ap_palloc(cont->pool, sizeof(struct proc_t)); + + if ((*new) == NULL) { + return APR_ENOMEM; + } - if ((new->pid = fork()) < 0) { - return NULL; + if (((*new)->pid = fork()) < 0) { + return errno; } - else if (new->pid == 0) { + else if ((*new)->pid == 0) { /* child process */ if (attr->child_in) { ap_close(attr->parent_in); @@ -212,43 +242,40 @@ ap_close(attr->child_err); } - new->attr = attr; - return new; + (*new)->attr = attr; + return APR_SUCCESS; } -ap_file_t *ap_get_childin(struct proc_t *proc) +ap_status_t ap_get_childin(struct proc_t *proc, ap_file_t **new) { - return proc->attr->parent_in; + (*new) = proc->attr->parent_in; + return APR_SUCCESS; } -ap_file_t *ap_get_childout(struct proc_t *proc) +ap_status_t ap_get_childout(struct proc_t *proc, ap_file_t **new) { - return proc->attr->parent_out; + (*new) = proc->attr->parent_out; + return APR_SUCCESS; } -ap_file_t *ap_get_childerr(struct proc_t *proc) +ap_status_t ap_get_childerr(struct proc_t *proc, ap_file_t **new) { - return proc->attr->parent_err; + (*new) = proc->attr->parent_err; + return APR_SUCCESS; } ap_status_t ap_wait_proc(struct proc_t *proc, ap_wait_how_e wait) { if (!proc) - return APR_FAILURE; + return APR_ENOPROC; if (wait == APR_WAIT) { if (waitpid(proc->pid, NULL, WUNTRACED) > 0) return APR_SUCCESS; - return APR_FAILURE; + return errno; } if (waitpid(proc->pid, NULL, WUNTRACED | WNOHANG) > 0) return APR_SUCCESS; - return APR_FAILURE; + return errno; } - -void ap_exit_proc(ap_context_t *cont) -{ - ap_destroy_pool(cont->pool); -} - 1.4 +5 -2 apache-apr/apr/threadproc/unix/signals.c Index: signals.c =================================================================== RCS file: /home/cvs/apache-apr/apr/threadproc/unix/signals.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- signals.c 1999/05/24 02:04:19 1.3 +++ signals.c 1999/05/25 17:04:03 1.4 @@ -62,8 +62,11 @@ #include <string.h> #include <sys/wait.h> -void ap_kill(struct proc_t *proc, int signal) +ap_status_t ap_kill(struct proc_t *proc, int signal) { - kill(proc->pid, signal); + if (kill(proc->pid, signal) == -1) { + return errno; + } + return APR_SUCCESS; } 1.7 +57 -24 apache-apr/apr/threadproc/unix/thread.c Index: thread.c =================================================================== RCS file: /home/cvs/apache-apr/apr/threadproc/unix/thread.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- thread.c 1999/05/24 02:29:28 1.6 +++ thread.c 1999/05/25 17:04:03 1.7 @@ -58,23 +58,36 @@ #include "apr_general.h" -struct threadattr_t *ap_create_threadattr(ap_context_t *cont) +ap_status_t ap_create_threadattr(ap_context_t *cont, struct threadattr_t **new) { - struct threadattr_t *new; + ap_status_t stat; - new = (struct threadattr_t *)ap_palloc(cont->pool, sizeof(struct threadattr_t)); - new->cntxt = cont; - new->attr = (pthread_attr_t *)ap_palloc(new->cntxt->pool, sizeof(pthread_attr_t)); - pthread_attr_init(new->attr); + (*new) = (struct threadattr_t *)ap_palloc(cont->pool, + sizeof(struct threadattr_t)); + (*new)->attr = (pthread_attr_t *)ap_palloc(cont->pool, + sizeof(pthread_attr_t)); + + if ((*new) == NULL || (*new)->attr == NULL) { + return APR_ENOMEM; + } + + (*new)->cntxt = cont; + stat = pthread_attr_init((*new)->attr); + + if (stat == 0) { + return APR_SUCCESS; + } + return stat; } ap_status_t ap_setthreadattr_detach(struct threadattr_t *attr, ap_int32_t on) { - if (pthread_attr_setdetachstate(attr->attr, on) == 0) { + ap_status_t stat; + if ((stat = pthread_attr_setdetachstate(attr->attr, on)) == 0) { return APR_SUCCESS; } else { - return APR_FAILURE; + return stat; } } @@ -84,56 +97,76 @@ pthread_attr_getdetachstate(attr->attr, &state); if (state == 1) - return APR_SUCCESS; - return APR_FAILURE; + return APR_DETACH; + return APR_NOTDETACH; } -struct thread_t *ap_create_thread(ap_context_t *cont, struct threadattr_t *attr, ap_thread_start_t func, void *data) +ap_status_t ap_create_thread(ap_context_t *cont, struct threadattr_t *attr, + ap_thread_start_t func, void *data, + struct thread_t **new) { - struct thread_t *new; + ap_status_t stat; pthread_attr_t *temp; - new = (struct thread_t *)ap_palloc(cont->pool, sizeof(struct thread_t)); + (*new) = (struct thread_t *)ap_palloc(cont->pool, sizeof(struct thread_t)); + + if ((*new) == NULL) { + return APR_ENOMEM; + } + + (*new)->td = (pthread_t *)ap_palloc(cont->pool, sizeof(pthread_t)); + + if ((*new)->td == NULL) { + return APR_ENOMEM; + } - new->cntxt = cont; - new->td = (pthread_t *)ap_palloc(new->cntxt->pool, sizeof(pthread_t)); + (*new)->cntxt = cont; if (attr) temp = attr->attr; else temp = NULL; + + stat = ap_create_context(cont, NULL, &(*new)->cntxt); + if (stat != APR_SUCCESS) { + return stat; + } - new->cntxt = ap_create_sub_context(cont, NULL); - if (pthread_create(new->td, temp, func, data) == 0) { - return new; + if ((stat = pthread_create((*new)->td, temp, func, data)) == 0) { + return APR_SUCCESS; } else { - return NULL; + return stat; } } -void ap_thread_exit(ap_context_t *cont, ap_status_t *retval) +ap_status_t ap_thread_exit(ap_thread_t *thd, ap_status_t *retval) { + ap_destroy_pool(thd->cntxt->pool); pthread_exit(retval); } ap_status_t ap_thread_join(struct thread_t *thd, ap_status_t *retval) { - if (pthread_join(*thd->td,(void *)&retval) == 0) { + ap_status_t stat; + + if ((stat = pthread_join(*thd->td,(void *)&retval)) == 0) { return APR_SUCCESS; } else { - return APR_FAILURE; + return stat; } } ap_status_t ap_thread_detach(struct thread_t *thd) { - if (pthread_detach(*thd->td) == 0) { + ap_status_t stat; + + if ((stat = pthread_detach(*thd->td)) == 0) { return APR_SUCCESS; } else { - return APR_FAILURE; + return stat; } } 1.4 +9 -6 apache-apr/apr/threadproc/unix/threadcancel.c Index: threadcancel.c =================================================================== RCS file: /home/cvs/apache-apr/apr/threadproc/unix/threadcancel.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- threadcancel.c 1999/05/24 02:04:20 1.3 +++ threadcancel.c 1999/05/25 17:04:03 1.4 @@ -60,32 +60,35 @@ ap_status_t ap_cancel_thread(struct thread_t *thd) { - if (pthread_cancel(*thd->td) == 0) { + ap_status_t stat; + if ((stat = pthread_cancel(*thd->td)) == 0) { return APR_SUCCESS; } else { - return APR_FAILURE; + return stat; } } ap_status_t ap_setcanceltype(ap_context_t *cont, ap_int32_t type) { - if (pthread_setcanceltype(type, NULL) == 0) { + ap_status_t stat; + if ((stat = pthread_setcanceltype(type, NULL)) == 0) { return APR_SUCCESS; } else { - return APR_FAILURE; + return stat; } } ap_status_t ap_setcancelstate(ap_context_t *cont, ap_int32_t type) { - if (pthread_setcanceltype(type, NULL) == 0) { + ap_status_t stat; + if ((stat = pthread_setcanceltype(type, NULL)) == 0) { return APR_SUCCESS; } else { - return APR_FAILURE; + return stat; } } 1.5 +22 -13 apache-apr/apr/threadproc/unix/threadpriv.c Index: threadpriv.c =================================================================== RCS file: /home/cvs/apache-apr/apr/threadproc/unix/threadpriv.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- threadpriv.c 1999/05/24 02:04:20 1.4 +++ threadpriv.c 1999/05/25 17:04:03 1.5 @@ -58,38 +58,47 @@ #include "apr_general.h" #include "apr_errno.h" -struct threadkey_t *ap_create_thread_private(ap_context_t *cont, void (*dest)(void *)) +ap_status_t ap_create_thread_private(ap_context_t *cont, void (*dest)(void *), + struct threadkey_t **key) { - struct threadkey_t *key; - key = (struct threadkey_t *)ap_palloc(cont->pool, sizeof(struct threadkey_t)); - key->cntxt = cont; + ap_status_t stat; + (*key) = (struct threadkey_t *)ap_palloc(cont->pool, sizeof(struct threadkey_t)); - if (pthread_key_create(&key->key, dest) == 0) { - return key; + if ((*key) == NULL) { + return APR_ENOMEM; } - return NULL; + + (*key)->cntxt = cont; + + if ((stat = pthread_key_create(&(*key)->key, dest)) == 0) { + return stat; + } + return stat; } -void *ap_get_thread_private(struct threadkey_t *key) +ap_status_t ap_get_thread_private(struct threadkey_t *key, void **new) { - return pthread_getspecific(key->key); + (*new) = pthread_getspecific(key->key); + return APR_SUCCESS; } ap_status_t ap_set_thread_private(struct threadkey_t *key, void *priv) { - if (pthread_setspecific(key->key, priv)== 0) { + ap_status_t stat; + if ((stat = pthread_setspecific(key->key, priv)) == 0) { return APR_SUCCESS; } else { - return APR_FAILURE; + return stat; } } ap_status_t ap_delete_thread_private(struct threadkey_t *key) { - if (pthread_key_delete(key->key) == 0) { + ap_status_t stat; + if ((stat = pthread_key_delete(key->key)) == 0) { return APR_SUCCESS; } - return APR_FAILURE; + return stat; } 1.4 +104 -23 apache-apr/apr/time/unix/access.c Index: access.c =================================================================== RCS file: /home/cvs/apache-apr/apr/time/unix/access.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- access.c 1999/05/24 02:04:22 1.3 +++ access.c 1999/05/25 17:04:07 1.4 @@ -60,107 +60,188 @@ #include <errno.h> #include <string.h> -ap_int64_t ap_get_curtime(struct atime_t *time) +ap_status_t ap_get_curtime(struct atime_t *time, ap_int64_t *rv) { - return time->currtime; + if (time) { + (*rv) = time->currtime; + return APR_SUCCESS; + } + return APR_ENOTIME; } -ap_int32_t ap_get_sec(struct atime_t *time) +ap_status_t ap_get_sec(struct atime_t *time, ap_int32_t *rv) { - return time->explodedtime->tm_sec; + if (time) { + (*rv) = time->explodedtime->tm_sec; + return APR_SUCCESS; + } + return APR_ENOTIME; } -ap_int32_t ap_get_min(struct atime_t *time) +ap_status_t ap_get_min(struct atime_t *time, ap_int32_t *rv) { - return time->explodedtime->tm_min; + if (time) { + (*rv) = time->explodedtime->tm_min; + return APR_SUCCESS; + } + return APR_ENOTIME; } -ap_int32_t ap_get_hour(struct atime_t *time) +ap_status_t ap_get_hour(struct atime_t *time, ap_int32_t *rv) { - return time->explodedtime->tm_hour; + if (time) { + (*rv) = time->explodedtime->tm_hour; + return APR_SUCCESS; + } + return APR_ENOTIME; } -ap_int32_t ap_get_mday(struct atime_t *time) +ap_status_t ap_get_mday(struct atime_t *time, ap_int32_t *rv) { - return time->explodedtime->tm_mday; + if (time) { + (*rv) = time->explodedtime->tm_mday; + return APR_SUCCESS; + } + return APR_ENOTIME; } -ap_int32_t ap_get_mon(struct atime_t *time) +ap_status_t ap_get_mon(struct atime_t *time, ap_int32_t *rv) { - return time->explodedtime->tm_mon; + if (time) { + (*rv) = time->explodedtime->tm_mon; + return APR_SUCCESS; + } + return APR_ENOTIME; } -ap_int32_t ap_get_year(struct atime_t *time) +ap_status_t ap_get_year(struct atime_t *time, ap_int32_t *rv) { - return time->explodedtime->tm_year; + if (time) { + (*rv) = time->explodedtime->tm_year; + return APR_SUCCESS; + } + return APR_ENOTIME; } -ap_int32_t ap_get_wday(struct atime_t *time) +ap_status_t ap_get_wday(struct atime_t *time, ap_int32_t *rv) { - return time->explodedtime->tm_wday; + if (time) { + (*rv) = time->explodedtime->tm_wday; + return APR_SUCCESS; + } + return APR_ENOTIME; } -void ap_set_sec(struct atime_t *time, ap_int32_t value) +ap_status_t ap_set_sec(struct atime_t *time, ap_int32_t value) { + if (!time) { + return APR_ENOTIME; + } if (time->explodedtime == NULL) { time->explodedtime = (struct tm *)ap_palloc(time->cntxt->pool, sizeof(struct tm)); } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } time->explodedtime->tm_sec = value; + return APR_SUCCESS; } -void ap_set_min(struct atime_t *time, ap_int32_t value) +ap_status_t ap_set_min(struct atime_t *time, ap_int32_t value) { + if (!time) { + return APR_ENOTIME; + } if (time->explodedtime == NULL) { time->explodedtime = (struct tm *)ap_palloc(time->cntxt->pool, sizeof(struct tm)); } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } time->explodedtime->tm_min = value; + return APR_SUCCESS; } -void ap_set_hour(struct atime_t *time, ap_int32_t value) +ap_status_t ap_set_hour(struct atime_t *time, ap_int32_t value) { + if (!time) { + return APR_ENOTIME; + } if (time->explodedtime == NULL) { time->explodedtime = (struct tm *)ap_palloc(time->cntxt->pool, sizeof(struct tm)); } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } time->explodedtime->tm_hour = value; + return APR_SUCCESS; } -void ap_set_mday(struct atime_t *time, ap_int32_t value) +ap_status_t ap_set_mday(struct atime_t *time, ap_int32_t value) { + if (!time) { + return APR_ENOTIME; + } if (time->explodedtime == NULL) { time->explodedtime = (struct tm *)ap_palloc(time->cntxt->pool, sizeof(struct tm)); } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } time->explodedtime->tm_mday = value; + return APR_SUCCESS; } -void ap_set_mon(struct atime_t *time, ap_int32_t value) +ap_status_t ap_set_mon(struct atime_t *time, ap_int32_t value) { + if (!time) { + return APR_ENOTIME; + } if (time->explodedtime == NULL) { time->explodedtime = (struct tm *)ap_palloc(time->cntxt->pool, sizeof(struct tm)); } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } time->explodedtime->tm_mon = value; + return APR_SUCCESS; } -void ap_set_year(struct atime_t *time, ap_int32_t value) +ap_status_t ap_set_year(struct atime_t *time, ap_int32_t value) { + if (!time) { + return APR_ENOTIME; + } if (time->explodedtime == NULL) { time->explodedtime = (struct tm *)ap_palloc(time->cntxt->pool, sizeof(struct tm)); } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } time->explodedtime->tm_year = value; + return APR_SUCCESS; } -void ap_set_wday(struct atime_t *time, ap_int32_t value) +ap_status_t ap_set_wday(struct atime_t *time, ap_int32_t value) { + if (!time) { + return APR_ENOTIME; + } if (time->explodedtime == NULL) { time->explodedtime = (struct tm *)ap_palloc(time->cntxt->pool, sizeof(struct tm)); } + if (time->explodedtime == NULL) { + return APR_ENOMEM; + } time->explodedtime->tm_wday = value; + return APR_SUCCESS; } 1.4 +12 -11 apache-apr/apr/time/unix/time.c Index: time.c =================================================================== RCS file: /home/cvs/apache-apr/apr/time/unix/time.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- time.c 1999/05/24 02:04:22 1.3 +++ time.c 1999/05/25 17:04:07 1.4 @@ -61,20 +61,23 @@ #include <errno.h> #include <string.h> -struct atime_t *ap_make_time(ap_context_t *cont) +ap_status_t ap_make_time(ap_context_t *cont, struct atime_t **new) { - struct atime_t *new; - new = (struct atime_t *)ap_palloc(cont->pool, sizeof(struct atime_t)); + (*new) = (struct atime_t *)ap_palloc(cont->pool, sizeof(struct atime_t)); - new->cntxt = cont; - new->explodedtime = NULL; - return new; + if ((*new) == NULL) { + return APR_ENOMEM; + } + + (*new)->cntxt = cont; + (*new)->explodedtime = NULL; + return APR_SUCCESS; } ap_status_t ap_current_time(struct atime_t *new) { if (time(&new->currtime) == -1) { - return APR_FAILURE; + return errno; } return APR_SUCCESS; } @@ -104,8 +107,7 @@ year = time->explodedtime->tm_year; if (year < 70 || ((sizeof(time_t) <= 4) && (year >= 138))) { - errno = EBAD_DATE; - return APR_FAILURE; + return APR_EBADDATE; } /* shift new year to 1st March in order to make leap year calc easy */ @@ -124,8 +126,7 @@ time->explodedtime->tm_min) * 60 + time->explodedtime->tm_sec; if (days < 0) { - errno = EBAD_DATE; /* must have overflowed */ - return APR_FAILURE; + return APR_EBADDATE; } time->currtime = days; /* must be a valid time */ return APR_SUCCESS; 1.14 +79 -53 apache-apr/include/apr_errno.h Index: apr_errno.h =================================================================== RCS file: /home/cvs/apache-apr/include/apr_errno.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- apr_errno.h 1999/05/25 03:14:19 1.13 +++ apr_errno.h 1999/05/25 17:04:09 1.14 @@ -260,117 +260,143 @@ #else #define APR_EWOULDBLOCK 3031 #endif -/* -#ifdef EBUSY -#define APR_EBUSY EBUSY + +#ifdef EPROTONOSUPPORT +#define APR_EPROTONOSUPPORT EPROTONOSUPPORT #else -#define APR_EBUSY 3021 +#define APR_EPROTONOSUPPORT 3032 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef ENOTSOCK +#define APR_ENOTSOCK ENOTSOCK #else -#define APR_EBUSY 3021 +#define APR_ENOTSOCK 3033 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef ENOTCONN +#define APR_ENOTCONN ENOTCONN #else -#define APR_EBUSY 3021 +#define APR_ENOTCONN 3034 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef EOPNOTSUPP +#define APR_EOPNOTSUPP EOPNOTSUPP #else -#define APR_EBUSY 3021 +#define APR_EOPNOTSUPP 3035 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef HOST_NOT_FOUND +#define APR_EHOSTNOTFOUND HOST_NOT_FOUND #else -#define APR_EBUSY 3021 +#define APR_EHOSTNOTFOUND 3036 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef NO_DATA +#define APR_ENODATA NO_DATA #else -#define APR_EBUSY 3021 +#define APR_ENODATA 3037 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef NO_ADDRESS +#define APR_ENOADDRESS NO_ADDRESS #else -#define APR_EBUSY 3021 +#define APR_ENOADDRESS 3038 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef NO_RECOVERY +#define APR_ENORECOVERY NO_RECOVERY #else -#define APR_EBUSY 3021 +#define APR_ENORECOVERY 3039 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef EISCONN +#define APR_EISCONN EISCONN #else -#define APR_EBUSY 3021 +#define APR_EISCONN 3040 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef ETIMEDOUT +#define APR_ETIMEDOUT ETIMEDOUT #else -#define APR_EBUSY 3021 +#define APR_ETIMEDOUT 3041 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef ECONNREFUSED +#define APR_ECONNREFUSED ECONNREFUSED #else -#define APR_EBUSY 3021 +#define APR_ECONNREFUSED 3042 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef ENETUNREACH +#define APR_ENETUNREACH ENETUNREACH #else -#define APR_EBUSY 3021 +#define APR_ENETUNREACH 3043 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef EADDRINUSE +#define APR_EADDRINUSE EADDRINUSE #else -#define APR_EBUSY 3021 +#define APR_EADDRINUSE 3044 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef EINPROGRESS +#define APR_EINPROGRESS EINPROGRESS #else -#define APR_EBUSY 3021 +#define APR_EINPROGRESS 3045 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef EALREADY +#define APR_EALREADY EALREADY #else -#define APR_EBUSY 3021 +#define APR_EALREADY 3046 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef EAFNOSUPPORT +#define APR_EAFNOSUPPORT EAFNOSUPPORT #else -#define APR_EBUSY 3021 +#define APR_EAFNOSUPPORT 3047 #endif -#ifdef EBUSY -#define APR_EBUSY EBUSY +#ifdef ENOPROTOOPT +#define APR_ENOPROTOOPT ENOPROTOOPT #else -#define APR_EBUSY 3021 +#define APR_ENOPROTOOPT 3048 #endif -*/ +#ifdef ENOCHILD +#define APR_ENOCHILD ENOCHILD +#else +#define APR_ENOCHILD 3049 +#endif +#ifdef ESRCH +#define APR_ESRCH ESRCH +#else +#define APR_ESRCH 3050 +#endif +#ifdef ENOTSUP +#define APR_ENOTSUP ENOTSUP +#else +#define APR_ENOTSUP 3051 +#endif + + +/* APR ERROR VALUES */ #define APR_ENOSTAT 4001 #define APR_ENOPOOL 4002 #define APR_ENOFILE 4003 #define APR_EBADDATE 4004 #define APR_ENOCONT 4005 +#define APR_ENOPROC 4006 +#define APR_ENOTIME 4007 + +/* APR STATUS VALUES */ +#define APR_INCHILD 5001 +#define APR_INPARENT 5002 +#define APR_DETACH 5003 +#define APR_NOTDETACH 5004 + #ifdef __cplusplus } 1.22 +9 -9 apache-apr/include/apr_network_io.h Index: apr_network_io.h =================================================================== RCS file: /home/cvs/apache-apr/include/apr_network_io.h,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- apr_network_io.h 1999/05/24 02:04:23 1.21 +++ apr_network_io.h 1999/05/25 17:04:09 1.22 @@ -93,28 +93,28 @@ /* function definitions */ -ap_socket_t *ap_create_tcp_socket(ap_context_t *); +ap_status_t ap_create_tcp_socket(ap_context_t *, ap_socket_t **); ap_status_t ap_shutdown(ap_socket_t *, ap_shutdown_how_e); ap_status_t ap_close_socket(ap_socket_t *); ap_status_t ap_bind(ap_socket_t *); ap_status_t ap_listen(ap_socket_t *, ap_int32_t); -ap_socket_t *ap_accept(const ap_socket_t *); +ap_status_t ap_accept(const ap_socket_t *, ap_socket_t **); ap_status_t ap_connect(ap_socket_t *, char *); -char *aprget_remote_hostname(ap_socket_t *); +ap_status_t ap_get_remote_hostname(ap_socket_t *, char **); ap_status_t ap_gethostname(ap_context_t *, char *, int); -ap_ssize_t ap_send(ap_socket_t *, const char *, int, time_t); -ap_ssize_t ap_recv(ap_socket_t *, char *, int, time_t); +ap_status_t ap_send(ap_socket_t *, const char *, ap_ssize_t *, time_t); +ap_status_t ap_recv(ap_socket_t *, char *, ap_ssize_t *, time_t); ap_status_t ap_setsocketopt(ap_socket_t *, ap_int32_t, ap_int32_t); ap_status_t ap_setport(ap_socket_t *, ap_uint32_t); -ap_pollfd_t *ap_setup_poll(ap_context_t *, ap_int32_t); -ap_int32_t ap_poll(ap_pollfd_t *, ap_int32_t, ap_int32_t); -void ap_add_poll_socket(ap_pollfd_t *, ap_socket_t *, ap_int16_t, ap_int32_t); -ap_int16_t ap_get_revents(ap_pollfd_t *, ap_int32_t); +ap_status_t ap_setup_poll(ap_context_t *, ap_int32_t, ap_pollfd_t **); +ap_status_t ap_poll(ap_pollfd_t *, ap_int32_t *, ap_int32_t); +ap_status_t ap_add_poll_socket(ap_pollfd_t *, ap_socket_t *, ap_int16_t, ap_int32_t); +ap_status_t ap_get_revents(ap_pollfd_t *, ap_int32_t, ap_int16_t *); /* accessor functions */ 1.12 +20 -12 apache-apr/include/apr_thread_proc.h Index: apr_thread_proc.h =================================================================== RCS file: /home/cvs/apache-apr/include/apr_thread_proc.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- apr_thread_proc.h 1999/05/24 02:04:24 1.11 +++ apr_thread_proc.h 1999/05/25 17:04:09 1.12 @@ -82,11 +82,12 @@ typedef void *(*ap_thread_start_t)(void *); /* Thread Function definitions */ -ap_threadattr_t *ap_create_threadattr(ap_context_t *); +ap_status_t ap_create_threadattr(ap_context_t *, ap_threadattr_t **); ap_status_t ap_setthreadattr_detach(ap_threadattr_t *, ap_int32_t); ap_status_t ap_getthreadattr_detach(ap_threadattr_t *); -ap_thread_t *ap_create_thread(ap_context_t *, ap_threadattr_t *, ap_thread_start_t, void *); -void ap_thread_exit(ap_context_t *, ap_status_t *); +ap_status_t ap_create_thread(ap_context_t *, ap_threadattr_t *, + ap_thread_start_t, void *, ap_thread_t **); +ap_status_t ap_thread_exit(ap_thread_t *, ap_status_t *); ap_status_t ap_thread_join(ap_thread_t *thd, ap_status_t *); ap_status_t ap_thread_detach(ap_thread_t *); @@ -94,22 +95,29 @@ ap_status_t ap_setcanceltype(ap_context_t *, ap_int32_t); ap_status_t ap_setcancelstate(ap_context_t *, ap_int32_t); +ap_status_t ap_create_thread_private(ap_context_t *, void (*dest)(void *), + ap_key_t **); +ap_status_t ap_get_thread_private(ap_key_t *, void **); +ap_status_t ap_set_thread_private(ap_key_t *, void *); +ap_status_t ap_delete_thread_private(ap_key_t *); /* Process Function definitions */ -ap_procattr_t *ap_createprocattr_init(ap_context_t *); -ap_status_t ap_setprocattr_io(ap_procattr_t *, ap_int32_t, ap_int32_t, ap_int32_t); +ap_status_t ap_createprocattr_init(ap_context_t *, ap_procattr_t **); +ap_status_t ap_setprocattr_io(ap_procattr_t *, ap_int32_t, ap_int32_t, + ap_int32_t); ap_status_t ap_setprocattr_dir(ap_procattr_t *, char *); ap_status_t ap_setprocattr_cmdtype(ap_procattr_t *, ap_cmdtype_e); -ap_file_t *ap_get_childin(ap_proc_t *); -ap_file_t *ap_get_childout(ap_proc_t *); -ap_file_t *ap_get_childerr(ap_proc_t *); - -ap_int32_t ap_fork(ap_proc_t *); -ap_proc_t *ap_create_process(ap_context_t *, char *, char *const [], char **, ap_procattr_t *); +ap_status_t ap_get_childin(ap_proc_t *, ap_file_t **); +ap_status_t ap_get_childout(ap_proc_t *, ap_file_t **); +ap_status_t ap_get_childerr(ap_proc_t *, ap_file_t **); + +ap_status_t ap_fork(ap_proc_t *); +ap_status_t ap_create_process(ap_context_t *, char *, char *const [], char **, + ap_procattr_t *, ap_proc_t **); ap_status_t ap_wait_proc(ap_proc_t *, ap_wait_how_e); -void ap_kill(ap_proc_t *, ap_int32_t); +ap_status_t ap_kill(ap_proc_t *, ap_int32_t); #ifdef __cplusplus } #endif 1.3 +16 -16 apache-apr/include/apr_time.h Index: apr_time.h =================================================================== RCS file: /home/cvs/apache-apr/include/apr_time.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- apr_time.h 1999/05/24 02:04:24 1.2 +++ apr_time.h 1999/05/25 17:04:10 1.3 @@ -68,29 +68,29 @@ typedef struct atime_t ap_time_t; /* Function Definitions */ -ap_time_t *ap_make_time(ap_context_t *); +ap_status_t ap_make_time(ap_context_t *, ap_time_t **); ap_status_t ap_current_time(ap_time_t *); ap_status_t ap_explode_time(ap_time_t *, ap_timetype_e); ap_status_t ap_implode_time(ap_time_t *); /* accessor functions */ -ap_int64_t ap_get_curtime(ap_time_t *); +ap_status_t ap_get_curtime(ap_time_t *, ap_int64_t *); -ap_int32_t ap_get_sec(ap_time_t *); -ap_int32_t ap_get_min(ap_time_t *); -ap_int32_t ap_get_hour(ap_time_t *); -ap_int32_t ap_get_mday(ap_time_t *); -ap_int32_t ap_get_mon(ap_time_t *); -ap_int32_t ap_get_year(ap_time_t *); -ap_int32_t ap_get_wday(ap_time_t *); +ap_status_t ap_get_sec(ap_time_t *, ap_int32_t *); +ap_status_t ap_get_min(ap_time_t *, ap_int32_t *); +ap_status_t ap_get_hour(ap_time_t *, ap_int32_t *); +ap_status_t ap_get_mday(ap_time_t *, ap_int32_t *); +ap_status_t ap_get_mon(ap_time_t *, ap_int32_t *); +ap_status_t ap_get_year(ap_time_t *, ap_int32_t *); +ap_status_t ap_get_wday(ap_time_t *, ap_int32_t *); -void ap_set_sec(ap_time_t *, ap_int32_t); -void ap_set_min(ap_time_t *, ap_int32_t); -void ap_set_hour(ap_time_t *, ap_int32_t); -void ap_set_mday(ap_time_t *, ap_int32_t); -void ap_set_mon(ap_time_t *, ap_int32_t); -void ap_set_year(ap_time_t *, ap_int32_t); -void ap_set_wday(ap_time_t *, ap_int32_t); +ap_status_t ap_set_sec(ap_time_t *, ap_int32_t); +ap_status_t ap_set_min(ap_time_t *, ap_int32_t); +ap_status_t ap_set_hour(ap_time_t *, ap_int32_t); +ap_status_t ap_set_mday(ap_time_t *, ap_int32_t); +ap_status_t ap_set_mon(ap_time_t *, ap_int32_t); +ap_status_t ap_set_year(ap_time_t *, ap_int32_t); +ap_status_t ap_set_wday(ap_time_t *, ap_int32_t); #ifdef __cplusplus }