Changeset 850 for releases

Show
Ignore:
Timestamp:
04/24/06 20:57:25 (3 years ago)
Author:
aj
Message:

use limits.h where necessary.
convert reader(int) to path in ifdhandler, not ct_socket_listen.
use ct_format_path also in ifdproxy code.
fix solaris compile (thanks to William Wanders).

Location:
releases/openct-0.6.7/src
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • releases/openct-0.6.7/src/ct/socket.c

    r824 r850  
    2323#include <arpa/inet.h> 
    2424#include <netdb.h> 
     25#include <limits.h> 
    2526 
    2627#include <openct/logging.h> 
     
    240241 * Listen on a socket 
    241242 */ 
    242 int ct_socket_listen(ct_socket_t * sock, int reader, int mode) 
    243 { 
    244         char path[PATH_MAX]; 
    245         char file[PATH_MAX]; 
    246  
    247         snprintf(file, PATH_MAX, "%d", reader); 
    248         if (! ct_format_path(path, PATH_MAX, file)) { 
    249                 return -1; 
    250         } 
    251  
     243int ct_socket_listen(ct_socket_t * sock, const char *path, int mode) 
     244{ 
    252245        ct_socket_close(sock); 
    253246        if (ct_socket_make(sock, CT_MAKESOCK_BIND, path) < 0) 
  • releases/openct-0.6.7/src/ifd/ifdhandler.c

    r820 r850  
    2222#include <limits.h> 
    2323 
     24#include <openct/path.h> 
    2425#include <openct/ifd.h> 
    2526#include <openct/conf.h> 
     
    3536static int opt_foreground = 0; 
    3637static int opt_info = 0; 
    37 static unsigned int opt_reader = -1; 
     38static const char *opt_reader = NULL; 
    3839 
    3940static void usage(int exval); 
     
    7273                        break; 
    7374                case 'r': 
    74                         opt_reader = atoi(optarg); 
     75                        opt_reader = optarg; 
    7576                        break; 
    7677                case 's': 
     
    111112         * prevent race condition 
    112113         */ 
    113         status = ct_status_alloc_slot(&opt_reader); 
    114         if (status == NULL) { 
    115                 ct_error("too many readers, no reader slot available"); 
    116                 return 1; 
     114        { 
     115                unsigned int r; 
     116                char path[PATH_MAX]; 
     117 
     118                status = ct_status_alloc_slot(&r); 
     119                if (status == NULL) { 
     120                        ct_error("too many readers, no reader slot available"); 
     121                        return 1; 
     122                } 
     123                snprintf(path,PATH_MAX,"%d",r); 
     124                opt_reader=strdup(path); 
    117125        } 
    118126 
     
    177185        int rc; 
    178186        struct sigaction act; 
     187        char path[PATH_MAX]; 
     188        char file[PATH_MAX]; 
     189 
     190        if (! ct_format_path(path, PATH_MAX, file)) { 
     191                ct_error("ct_format_path failed!"); 
     192                exit(1); 
     193        } 
    179194 
    180195        /* Activate reader */ 
  • releases/openct-0.6.7/src/ifd/ifdproxy.c

    r775 r850  
    2525#include <pwd.h> 
    2626#include <grp.h> 
    27  
     27#include <limits.h> 
     28 
     29#include <openct/path.h> 
    2830#include <openct/socket.h> 
    2931#include <openct/server.h> 
     
    3234#include "ria.h" 
    3335 
    34 #define DEFAULT_SERVER_PATH     OPENCT_SOCKET_PATH "/proxy" 
    35  
    3636static int opt_foreground = 0; 
    3737static char *opt_config = NULL; 
    3838static const char *opt_device_port = ":6666"; 
    39 static const char *opt_server_port = OPENCT_SOCKET_PATH "/proxy"; 
     39static const char *opt_server_port = "proxy"; 
    4040static const char *opt_chroot = NULL; 
    4141static const char *opt_user = NULL; 
     
    175175{ 
    176176        int rc; 
     177        char path[PATH_MAX]; 
     178 
     179        if (! ct_format_path(path, PATH_MAX, opt_server_port)) { 
     180                return -1; 
     181        } 
     182 
    177183 
    178184        if (argc != 0) 
     
    181187                ct_socket_reuseaddr(1); 
    182188 
    183         if ((rc = ria_svc_listen(opt_server_port, 1)) < 0) { 
     189        if ((rc = ria_svc_listen(path, 1)) < 0) { 
    184190                ct_error("Cannot bind to server port \"%s\": %s\n", 
    185                          opt_server_port, ct_strerror(rc)); 
     191                         path, ct_strerror(rc)); 
    186192                return rc; 
    187193        } 
  • releases/openct-0.6.7/src/ifd/ria.c

    r846 r850  
    1818#include <fcntl.h> 
    1919#include <errno.h> 
    20  
     20#include <limits.h> 
     21 
     22#include <openct/path.h> 
    2123#include <openct/socket.h> 
    2224#include <openct/server.h> 
     
    3537{ 
    3638        ria_client_t *clnt; 
    37         int reader; 
     39        char path[PATH_MAX]; 
    3840        int rc; 
    3941 
    40         if (scanf("5d",address,&reader) != 1) { 
    41                 ct_error("can't parse address \"%s\"",address); 
     42        if (! address) { 
     43                return NULL; 
     44        } 
     45 
     46        if (! ct_format_path(path, PATH_MAX, address)) { 
    4247                return NULL; 
    4348        } 
     
    5156 
    5257        clnt->sock = ct_socket_new(1024); 
    53         if ((rc = ct_socket_connect(clnt->sock, reader)) < 0) { 
    54                 ct_error("Failed to connect to RIA server %d: %s", 
    55                          reader, ct_strerror(rc)); 
     58        if ((rc = ct_socket_connect(clnt->sock, path)) < 0) { 
     59                ct_error("Failed to connect to RIA server \"%s\": %s", 
     60                         path, ct_strerror(rc)); 
    5661                ria_free(clnt); 
    5762                return NULL; 
  • releases/openct-0.6.7/src/ifd/sys-linux.c

    r831 r850  
    2525#include <fcntl.h> 
    2626#include <errno.h> 
     27#include <limits.h> 
    2728#ifdef HAVE_LIBUSB 
    2829#include <usb.h> 
  • releases/openct-0.6.7/src/ifd/sys-solaris.c

    r831 r850  
    186186} 
    187187 
     188void 
    188189close_ep(int interface, int endpoint, int direction) 
    189190{ 
     
    529530} 
    530531 
    531 int ifd_sysdep_usb:open(const char *device) 
     532int ifd_sysdep_usb_open(const char *device) 
    532533{ 
    533534        return open(device, O_RDWR); 
  • releases/openct-0.6.7/src/ifd/sys-sunray.c

    r831 r850  
    2121#include <unistd.h> 
    2222#include <errno.h> 
     23#include <limits.h> 
     24 
    2325#include <openct/driver.h> 
    2426#define USB_READ_INTERRUPT_TIMEOUT_WORKAROUND 1 
  • releases/openct-0.6.7/src/include/openct/socket.h

    r820 r850  
    5858extern void             ct_socket_reuseaddr(int); 
    5959extern int              ct_socket_connect(ct_socket_t *, const char *); 
    60 extern int              ct_socket_listen(ct_socket_t *, int, int); 
     60extern int              ct_socket_listen(ct_socket_t *, const char *, int); 
    6161extern ct_socket_t *    ct_socket_accept(ct_socket_t *); 
    6262extern void             ct_socket_close(ct_socket_t *);