NSIS-ka
A free C++ implementation of NSIS protocols

Changeset 4163


Ignore:
Timestamp:
Jul 23, 2009, 5:03:14 PM (8 years ago)
Author:
stud-lenk
Message:
  • Add a preliminary class networkinterface and a typedef for list<networkinterface>
  • Extend configpar to also parse a list of network interfaces into a list<networkinterfaces> type
Location:
protlib/branches/20090723-multicast
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • protlib/branches/20090723-multicast/include/configpar.h

    r4107 r4163  
    3838#include "protlib_types.h"
    3939#include "address.h"
     40#include "networkinterface.h"
    4041#include <list>
    4142#include <string>
  • protlib/branches/20090723-multicast/src/Makefile

    r4157 r4163  
    105105TP_QUERY_ENCAP_OBJ= tp_queryencap.o
    106106
    107 PROTLIB_OBJS    = address.o ie.o tp.o tp_over_tcp.o tp_over_tls_tcp.o \
     107PROTLIB_OBJS    = networkinterface.o address.o ie.o tp.o tp_over_tcp.o tp_over_tls_tcp.o \
    108108                  cmsghdr_util.o tp_over_udp.o $(TP_QUERY_ENCAP_OBJ) tp_over_uds.o \
    109109                  $(TP_SCTPOBJ) connectionmap.o connectionmap_uds.o queuemanager.o fqueue.o \
  • protlib/branches/20090723-multicast/src/configpar.cpp

    r4157 r4163  
    279279}
    280280
     281// interface list
     282template <>
     283istream&
     284configpar< list<networkinterface> >::readVal(std::istream &in) {
     285        std::string tmp;
     286        bool success= false;
     287        while ( in >> tmp ) {
     288                networkinterface iface(tmp.c_str(), &success);
     289                if ( success )
     290                        value.push_back(iface);
     291                else
     292                        throw configParExceptionParseError("invalid interface `" + tmp + "'");
     293        }
     294        return in;
     295}
     296
     297template <>
     298istream&
     299configpar< list<networkinterface> >::readValFromConfig(std::istream &in) {
     300        std::string tmp= parse_quoted_string(in);
     301        stringstream inputstr(tmp);
     302
     303        bool success= false;
     304        while ( inputstr >> tmp ) {
     305                networkinterface iface(tmp.c_str(), &success);
     306                if ( success )
     307                        value.push_back(iface);
     308                else
     309                        throw configParExceptionParseError("invalid interface `" + tmp + "'");
     310        }
     311        return in;
     312}
     313
     314// write network interface list quoted to a config file
     315template <>
     316ostream&
     317configpar< list<networkinterface> >::writeValToConfig(ostream& outstream) const
     318{
     319        std::stringstream ifaceliststr;
     320        ifaceliststr << value;
     321        write_quoted_string(outstream, ifaceliststr.str());
     322        return outstream;
     323}
     324
    281325// write a string quoted (with escape chars) to a config file
    282326template <>
Note: See TracChangeset for help on using the changeset viewer.