Author: marten Date: Mon Oct 19 21:16:36 2009 New Revision: 1237 Log: Renamed camelcase function names to underscore names Modified: trunk/community-operator/co_client.c Modified: trunk/community-operator/co_client.c ============================================================================== --- trunk/community-operator/co_client.c Mon Oct 19 20:59:44 2009 (r1236) +++ trunk/community-operator/co_client.c Mon Oct 19 21:16:36 2009 (r1237) @@ -17,7 +17,11 @@ #include <string.h> #include <unistd.h> +static int create_client_socket(struct sockaddr_in6 *srv_addr); static void print_deny_reason(int reason); +static int receive_certificate(char **cert); +static int request_cert(void); +static int write_cert_file(char *cert, const char *filename); static int sock; @@ -28,7 +32,7 @@ * @param filename the filename (file will be overwritten) * @return 0 on success, -1 otherwise */ -static int writeCertFile(char *cert, char *filename) +static int write_cert_file(char *cert,const char *filename) { FILE *f; @@ -69,7 +73,7 @@ * @param srv_addr HIT of the server * @return filedescriptor for the socket */ -static int createClientSocket(struct sockaddr_in6 *srv_addr) +static int create_client_socket(struct sockaddr_in6 *srv_addr) { int s; struct timeval to; @@ -78,31 +82,29 @@ to.tv_usec = 0; if ((s = socket(PF_INET6, SOCK_DGRAM, 0)) == 0) { - printf("socket() failed.\n"); + PISA_ERROR("socket() failed.\n"); exit(-1); } if (connect(s, (struct sockaddr *)srv_addr, sizeof(struct sockaddr_in6)) == -1) { - printf("connect to srv_addr failed.\n"); + PISA_ERROR("connect to srv_addr failed.\n"); exit(-1); } if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof(to))) - printf("Could not set a receive timeout.\n"); + PISA_ERROR("Could not set a receive timeout.\n"); return s; } -static int sock; - /** * Request a certificate from the server using the previously opened socket. * @todo define protocol * * @return 0 on success, -1 otherwise */ -static int sendRequest(void) +static int request_cert(void) { int sent; co_packet *packet; @@ -135,7 +137,7 @@ * @param cert place to store the newly malloced certificate * @return 0 for success, -1 for permanent failure, -2 for retry */ -static int receiveCertificate(char **cert) +static int receive_certificate(char **cert) { co_packet *packet; ssize_t count; @@ -198,17 +200,17 @@ srv_addr.sin6_family = AF_INET6; inet_pton(PF_INET6, srv_hit, &(srv_addr.sin6_addr)); srv_addr.sin6_port = htons(port); - sock = createClientSocket(&srv_addr); + sock = create_client_socket(&srv_addr); for (count = 0; count < retries; count++) { - if (sendRequest() < 0) + if (request_cert() < 0) break; - if (receiveCertificate(&cert) != -2) + if (receive_certificate(&cert) != -2) break; } if (cert) { - writeCertFile(cert, "test-cert"); + write_cert_file(cert, "test-cert"); free(cert); printf("Certificate was successfully retrieved.\n"); } else