Changeset 18


Ignore:
Timestamp:
Nov 7, 2005 3:47:28 PM (19 years ago)
Author:
bennylp
Message:

Added file I/O and file access API

Location:
pjproject/main/pjlib
Files:
6 added
15 edited

Legend:

Unmodified
Added
Removed
  • pjproject/main/pjlib/build

    • Property svn:ignore
      •  

        old new  
        66*.opt 
        77*.plg 
         8test*.txt 
  • pjproject/main/pjlib/build/os-win32.mak

    r2 r18  
    88# to all operating systems should go in Makefile instead. 
    99# 
    10 export PJLIB_OBJS +=    addr_resolv_sock.o guid_win32.o ioqueue_winnt.o \ 
     10export PJLIB_OBJS +=    addr_resolv_sock.o guid_win32.o \ 
    1111                        log_writer_stdout.o os_core_win32.o \ 
    1212                        os_error_win32.o os_time_ansi.o os_timestamp_common.o \ 
    1313                        os_timestamp_win32.o \ 
    1414                        pool_policy_malloc.o sock_bsd.o sock_select.o 
     15 
     16export PJLIB_OBJS +=    ioqueue_win32.o 
     17#export PJLIB_OBJS +=   ioqueue_select.o 
     18 
     19export PJLIB_OBJS +=    file_io_win32.o 
     20#export PJLIB_OBJS +=   file_io_ansi.o 
    1521 
    1622# 
  • pjproject/main/pjlib/build/pjlib.dsp

    r17 r18  
    195195# Begin Source File 
    196196 
     197SOURCE=..\src\pj\file_access_win32.c 
     198# End Source File 
     199# Begin Source File 
     200 
     201SOURCE=..\src\pj\file_io_ansi.c 
     202# PROP Exclude_From_Build 1 
     203# End Source File 
     204# Begin Source File 
     205 
     206SOURCE=..\src\pj\file_io_win32.c 
     207# End Source File 
     208# Begin Source File 
     209 
    197210SOURCE=..\src\pj\guid.c 
    198211# End Source File 
     
    474487 
    475488SOURCE=..\include\pj\fifobuf.h 
     489# End Source File 
     490# Begin Source File 
     491 
     492SOURCE=..\include\pj\file_access.h 
     493# End Source File 
     494# Begin Source File 
     495 
     496SOURCE=..\include\pj\file_io.h 
    476497# End Source File 
    477498# Begin Source File 
  • pjproject/main/pjlib/build/pjlib_test.dsp

    r17 r18  
    108108# Begin Source File 
    109109 
     110SOURCE="..\src\pjlib-test\file.c" 
     111# End Source File 
     112# Begin Source File 
     113 
    110114SOURCE="..\src\pjlib-test\ioq_perf.c" 
    111115# End Source File 
  • pjproject/main/pjlib/include/pj/addr_resolv.h

    r6 r18  
    1515 
    1616/** 
    17  * @defgroup pj_addr_resolve Address Resolution 
     17 * @defgroup pj_addr_resolve Network Address Resolution 
    1818 * @ingroup PJ_IO 
    1919 * @{ 
  • pjproject/main/pjlib/include/pj/ioqueue.h

    r14 r18  
    1515 
    1616/** 
    17  * @defgroup PJ_IO Network I/O 
    18  * @brief Network I/O 
     17 * @defgroup PJ_IO Input/Output 
     18 * @brief Input/Output 
    1919 * @ingroup PJ_OS 
    2020 * 
     
    5353 * completed. 
    5454 * 
     55 * The I/O Queue can work on both socket and file descriptors. For  
     56 * asynchronous file operations however, one must make sure that the correct 
     57 * file I/O back-end is used, because not all file I/O back-end can be 
     58 * used with the ioqueue. Please see \ref PJ_FILE_IO for more details. 
     59 * 
    5560 * The framework works natively in platforms where asynchronous operation API 
    5661 * exists, such as in Windows NT with IoCompletionPort/IOCP. In other  
     
    6166 * The I/O queue provides more than just unified abstraction. It also: 
    6267 *  - makes sure that the operation uses the most effective way to utilize 
    63  *    the underlying mechanism, to provide the maximum theoritical 
     68 *    the underlying mechanism, to achieve the maximum theoritical 
    6469 *    throughput possible on a given platform. 
    6570 *  - choose the most efficient mechanism for event polling on a given 
     
    488493                                          int *addrlen); 
    489494 
    490  
    491495/** 
    492496 * Instruct the I/O Queue to write to the handle. This function will return 
     
    530534 
    531535/** 
    532  * This function behaves similarly as #pj_ioqueue_write(), except that 
    533  * pj_sock_sendto() (or equivalent) will be called to send the data. 
     536 * Instruct the I/O Queue to write to the handle. This function will return 
     537 * immediately (i.e. non-blocking) regardless whether some data has been  
     538 * transfered. If the function can't complete immediately, the caller will 
     539 * be notified about the completion when it calls pj_ioqueue_poll(). If  
     540 * operation completes immediately and data has been transfered, the function 
     541 * returns PJ_SUCCESS and the callback will NOT be called. 
    534542 * 
    535543 * @param key       the key that identifies the handle. 
  • pjproject/main/pjlib/include/pj/list.h

    r11 r18  
    4646 * @hideinitializer 
    4747 */ 
    48 #define PJ_DECL_LIST_MEMBER(type)  type *prev; /** List @a prev. */ \ 
    49                                    type *next  /** List @a next. */  
     48#define PJ_DECL_LIST_MEMBER(type)                       \ 
     49                                   /** List @a prev. */ \ 
     50                                   type *prev;          \ 
     51                                   /** List @a next. */ \ 
     52                                   type *next  
    5053 
    5154 
  • pjproject/main/pjlib/include/pj/pool.h

    r11 r18  
    127127struct pj_pool_t 
    128128{ 
    129     PJ_DECL_LIST_MEMBER(struct pj_pool_t); 
     129    PJ_DECL_LIST_MEMBER(struct pj_pool_t);  /**< Standard list elements.    */ 
    130130 
    131131    /** Pool name */ 
  • pjproject/main/pjlib/include/pj/types.h

    r4 r18  
    6464#define PJ_FALSE    0 
    6565 
     66/** 
     67 * File offset type. 
     68 */ 
     69#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0 
     70typedef pj_int64_t pj_off_t; 
     71#else 
     72typedef pj_ssize_t pj_off_t; 
     73#endif 
    6674 
    6775/////////////////////////////////////////////////////////////////////////////// 
  • pjproject/main/pjlib/include/pj/xml.h

    r11 r18  
    3131struct pj_xml_attr 
    3232{ 
    33     PJ_DECL_LIST_MEMBER(pj_xml_attr); 
    34     pj_str_t    name;       /**< Attribute name. */ 
    35     pj_str_t    value;      /**< Attribute value. */ 
     33    PJ_DECL_LIST_MEMBER(pj_xml_attr);   /**< Standard list elements.    */ 
     34    pj_str_t    name;                   /**< Attribute name.            */ 
     35    pj_str_t    value;                  /**< Attribute value.          */ 
    3636}; 
    3737 
     
    4040typedef struct pj_xml_node_head 
    4141{ 
    42     PJ_DECL_LIST_MEMBER(pj_xml_node); 
     42    PJ_DECL_LIST_MEMBER(pj_xml_node);   /**< Standard list elements.    */ 
    4343} pj_xml_node_head; 
    4444 
     
    4646struct pj_xml_node 
    4747{ 
    48     PJ_DECL_LIST_MEMBER(pj_xml_node);   /** List @a prev and @a next member */ 
    49     pj_str_t            name;           /** Node name. */ 
    50     pj_xml_attr         attr_head;      /** Attribute list. */ 
    51     pj_xml_node_head    node_head;      /** Node list. */ 
    52     pj_str_t            content;        /** Node content. */ 
     48    PJ_DECL_LIST_MEMBER(pj_xml_node);   /**< List @a prev and @a next member */ 
     49    pj_str_t            name;           /**< Node name.                      */ 
     50    pj_xml_attr         attr_head;      /**< Attribute list.                */ 
     51    pj_xml_node_head    node_head;      /**< Node list.                      */ 
     52    pj_str_t            content;        /**< Node content.                  */ 
    5353}; 
    5454 
  • pjproject/main/pjlib/include/pjlib.h

    r4 r18  
    1717#include <pj/except.h> 
    1818#include <pj/fifobuf.h> 
     19#include <pj/file_access.h> 
     20#include <pj/file_io.h> 
    1921#include <pj/guid.h> 
    2022#include <pj/hash.h> 
  • pjproject/main/pjlib/src/pj/ioqueue_winnt.c

    r11 r18  
    3636 
    3737/* 
    38  * OVERLAP structure for send and receive. 
     38 * OVERLAPPPED structure for send and receive. 
    3939 */ 
    4040typedef struct ioqueue_overlapped 
     
    7676}; 
    7777 
     78/* Type of handle in the key. */ 
     79enum handle_type 
     80{ 
     81    HND_IS_UNKNOWN, 
     82    HND_IS_FILE, 
     83    HND_IS_SOCKET, 
     84}; 
     85 
    7886/* 
    7987 * Structure for individual socket. 
     
    8492    HANDLE              hnd; 
    8593    void               *user_data; 
     94    enum handle_type    hnd_type; 
    8695#if PJ_HAS_TCP 
    8796    int                 connecting; 
     
    318327    rec->ioqueue = ioqueue; 
    319328    rec->hnd = (HANDLE)sock; 
     329    rec->hnd_type = HND_IS_SOCKET; 
    320330    rec->user_data = user_data; 
    321331    pj_memcpy(&rec->cb, cb, sizeof(pj_ioqueue_callback)); 
     
    364374    } 
    365375#endif 
     376    if (key->hnd_type == HND_IS_FILE) { 
     377        CloseHandle(key->hnd); 
     378    } 
    366379    return PJ_SUCCESS; 
    367380} 
     
    506519 
    507520    PJ_CHECK_STACK(); 
    508     PJ_ASSERT_RETURN(key && op_key && buffer, PJ_EINVAL); 
     521    PJ_ASSERT_RETURN(key && op_key && buffer && length, PJ_EINVAL); 
    509522 
    510523    op_key_rec = (union operation_key*)op_key->internal__; 
  • pjproject/main/pjlib/src/pjlib-samples/list.c

    r6 r18  
    1616{ 
    1717    // This must be the first member declared in the struct! 
    18     PJ_DECL_LIST_MEMBER(struct my_node) 
     18    PJ_DECL_LIST_MEMBER(struct my_node); 
    1919    int value; 
    2020}; 
  • pjproject/main/pjlib/src/pjlib-test/test.c

    r17 r18  
    3232    mem = &caching_pool.factory; 
    3333 
     34    pj_log_set_level(3); 
     35    pj_log_set_decor(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |  
     36                     PJ_LOG_HAS_MICRO_SEC); 
     37 
    3438    rc = pj_init(); 
    3539    if (rc != 0) { 
     
    3842    } 
    3943     
    40     pj_log_set_level(3); 
    41     pj_log_set_decor(PJ_LOG_HAS_NEWLINE); 
    4244    pj_dump_config(); 
    4345    pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 ); 
     
    127129#endif 
    128130 
     131#if INCLUDE_FILE_TEST 
     132    DO_TEST( file_test() ); 
     133#endif 
     134 
    129135#if INCLUDE_XML_TEST 
    130136    DO_TEST( xml_test() ); 
  • pjproject/main/pjlib/src/pjlib-test/test.h

    r11 r18  
    99#define GROUP_OS                    0 
    1010#define GROUP_DATA_STRUCTURE        0 
    11 #define GROUP_NETWORK               1 
     11#define GROUP_NETWORK               0 
     12#define GROUP_FILE                  1 
    1213#define GROUP_EXTRA                 0 
    1314 
     
    3334#define INCLUDE_TCP_IOQUEUE_TEST    GROUP_NETWORK 
    3435#define INCLUDE_IOQUEUE_PERF_TEST   GROUP_NETWORK 
     36#define INCLUDE_FILE_TEST           GROUP_FILE 
    3537#define INCLUDE_XML_TEST            GROUP_EXTRA 
    3638 
     
    6971extern int tcp_ioqueue_test(void); 
    7072extern int ioqueue_perf_test(void); 
     73extern int file_test(void); 
    7174extern int xml_test(void); 
    7275 
Note: See TracChangeset for help on using the changeset viewer.