protected override bool checkOption(string option, string argument, string endpoint) { if (option.Equals("-h")) { if (argument == null) { throw new Ice.EndpointParseException("no argument provided for -h option in endpoint " + endpoint); } host_ = argument; } else if (option.Equals("-p")) { if (argument == null) { throw new Ice.EndpointParseException("no argument provided for -p option in endpoint " + endpoint); } try { port_ = int.Parse(argument, CultureInfo.InvariantCulture); } catch (FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint " + endpoint; throw e; } if (port_ < 0 || port_ > 65535) { throw new Ice.EndpointParseException("port value `" + argument + "' out of range in endpoint " + endpoint); } } else if (option.Equals("--sourceAddress")) { if (argument == null) { throw new Ice.EndpointParseException("no argument provided for --sourceAddress option in endpoint " + endpoint); } sourceAddr_ = Network.getNumericAddress(argument); if (sourceAddr_ == null) { throw new Ice.EndpointParseException( "invalid IP address provided for --sourceAddress option in endpoint " + endpoint); } } else { return(false); } return(true); }
protected override bool checkOption(string option, string argument, string endpoint) { switch (option[1]) { case 'r': { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -r option in endpoint " + endpoint + _delegate.options(); throw e; } _resource = argument; return(true); } default: { return(false); } } }
protected override bool checkOption(string option, string argument, string endpoint) { if (base.checkOption(option, argument, endpoint)) { return(true); } if (option.Equals("-c")) { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in " + endpoint; throw e; } _connect = true; } else if (option.Equals("-z")) { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint; throw e; } _compress = true; } else if (option.Equals("-v") || option.Equals("-e")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for " + option + " option in endpoint " + endpoint; throw e; } try { Ice.EncodingVersion v = Ice.Util.stringToEncodingVersion(argument); if (v.major != 1 || v.minor != 0) { instance_.logger().warning("deprecated udp endpoint option: " + option); } } catch (Ice.VersionParseException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid version `" + argument + "' in endpoint " + endpoint + ":\n" + ex.str; throw e; } } else if (option.Equals("--ttl")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint " + endpoint; throw e; } try { _mcastTtl = int.Parse(argument, CultureInfo.InvariantCulture); } catch (FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint " + endpoint; throw e; } if (_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint " + endpoint; throw e; } } else if (option.Equals("--interface")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint " + endpoint; throw e; } _mcastInterface = argument; } else { return(false); } return(true); }
protected override bool checkOption(string option, string argument, string endpoint) { if(option.Equals("-h")) { if(argument == null) { throw new Ice.EndpointParseException("no argument provided for -h option in endpoint " + endpoint); } host_ = argument; } else if(option.Equals("-p")) { if(argument == null) { throw new Ice.EndpointParseException("no argument provided for -p option in endpoint " + endpoint); } try { port_ = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint " + endpoint; throw e; } if(port_ < 0 || port_ > 65535) { throw new Ice.EndpointParseException("port value `" + argument + "' out of range in endpoint " + endpoint); } } else if(option.Equals("--sourceAddress")) { if(argument == null) { throw new Ice.EndpointParseException("no argument provided for --sourceAddress option in endpoint " + endpoint); } sourceAddr_ = Network.getNumericAddress(argument); if(sourceAddr_ == null) { throw new Ice.EndpointParseException( "invalid IP address provided for --sourceAddress option in endpoint " + endpoint); } } else { return false; } return true; }
public EndpointI create(string str, bool oaEndpoint) { string[] arr = IceUtilInternal.StringUtil.splitString(str, " \t\r\n"); if (arr == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quote"; throw e; } if (arr.Length == 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "value has no non-whitespace characters"; throw e; } List <string> v = new List <string>(arr); string protocol = v[0]; v.RemoveAt(0); if (protocol.Equals("default")) { protocol = _instance.defaultsAndOverrides().defaultProtocol; } EndpointFactory factory = null; lock (this) { for (int i = 0; i < _factories.Count; i++) { EndpointFactory f = _factories[i]; if (f.protocol().Equals(protocol)) { factory = f; } } } if (factory != null) { EndpointI e = factory.create(v, oaEndpoint); if (v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } return(e); // Code below left in place for debugging. /* * EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint); * BasicStream bs = new BasicStream(_instance, true); * e.streamWrite(bs); * Buffer buf = bs.getBuffer(); * buf.b.position(0); * short type = bs.readShort(); * EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs); * System.Console.Error.WriteLine("Normal: " + e); * System.Console.Error.WriteLine("Opaque: " + ue); * return e; */ } // // If the stringified endpoint is opaque, create an unknown endpoint, // then see whether the type matches one of the known endpoints. // if (protocol.Equals("opaque")) { EndpointI ue = new OpaqueEndpointI(v); if (v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } factory = get(ue.type()); if (factory != null) { // // Make a temporary stream, write the opaque endpoint data into the stream, // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // Ice.OutputStream os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding); os.writeShort(ue.type()); ue.streamWrite(os); Ice.InputStream iss = new Ice.InputStream(_instance, Ice.Util.currentProtocolEncoding, os.getBuffer(), true); iss.pos(0); iss.readShort(); // type iss.startEncapsulation(); EndpointI e = factory.read(iss); iss.endEncapsulation(); return(e); } return(ue); // Endpoint is opaque, but we don't have a factory for its type. } return(null); }
public TcpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; char[] separators = { ' ', '\t', '\n', '\r' }; string[] arr = str.Split(separators); int i = 0; while(i < arr.Length) { if(arr[i].Length == 0) { i++; continue; } string option = arr[i++]; if(option.Length != 2 || option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `tcp " + str + "'"; throw e; } string argument = null; if(i < arr.Length && arr[i].Length > 0 && arr[i][0] != '-') { argument = arr[i++]; if(argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } switch(option[1]) { case 'h': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `tcp " + str + "'"; throw e; } _host = argument; break; } case 'p': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `tcp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } if(_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `tcp " + str + "'"; throw e; } break; } case 't': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -t option in endpoint `tcp " + str + "'"; throw e; } try { _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } break; } case 'z': { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `tcp " + str + "'"; throw e; } _compress = true; break; } default: { parseOption(option, argument, "tcp", str); break; } } } if(_host == null) { _host = _instance.defaultsAndOverrides().defaultHost; } else if(_host.Equals("*")) { if(oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `tcp " + str + "'"); } } if(_host == null) { _host = ""; } calcHashValue(); }
private List<EndpointI> parseEndpoints(string endpts, bool oaEndpoints) { int beg; int end = 0; string delim = " \t\n\r"; List<EndpointI> endpoints = new List<EndpointI>(); while(end < endpts.Length) { beg = IceUtilInternal.StringUtil.findFirstNotOf(endpts, delim, end); if(beg == -1) { break; } end = beg; while(true) { end = endpts.IndexOf((System.Char) ':', end); if(end == -1) { end = endpts.Length; break; } else { bool quoted = false; int quote = beg; while(true) { quote = endpts.IndexOf((System.Char) '\"', quote); if(quote == -1 || end < quote) { break; } else { quote = endpts.IndexOf((System.Char) '\"', ++quote); if(quote == -1) { break; } else if(end < quote) { quoted = true; break; } ++quote; } } if(!quoted) { break; } ++end; } } if(end == beg) { ++end; continue; } string s = endpts.Substring(beg, (end) - (beg)); EndpointI endp = instance_.endpointFactoryManager().create(s, oaEndpoints); if(endp == null) { Ice.EndpointParseException e2 = new Ice.EndpointParseException(); e2.str = "invalid object adapter endpoint `" + s + "'"; throw e2; } endpoints.Add(endp); ++end; } return endpoints; }
public UdpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { instance_ = instance; _host = null; _port = 0; _connect = false; _compress = false; string delim = " \t\n\r"; int beg; int end = 0; while(true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(beg == -1) { break; } end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } string option = str.Substring(beg, end - beg); if(option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'"; throw e; } string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(argumentBeg != -1 && str[argumentBeg] != '-') { beg = argumentBeg; if(str[beg] == '\"') { end = IceUtilInternal.StringUtil.findFirstOf(str, "\"", beg + 1); if(end == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'"; throw e; } else { ++end; } } else { end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } } argument = str.Substring(beg, end - beg); if(argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } if(option.Equals("-h")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `udp " + str + "'"; throw e; } _host = argument; } else if(option.Equals("-p")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `udp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else if(option.Equals("-c")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'"; throw e; } _connect = true; } else if(option.Equals("-z")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'"; throw e; } _compress = true; } else if(option.Equals("-v") || option.Equals("-e")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for " + option + " option in endpoint " + "`udp " + str + "'"; throw e; } try { Ice.EncodingVersion v = Ice.Util.stringToEncodingVersion(argument); if(v.major != 1 || v.minor != 0) { instance_.initializationData().logger.warning("deprecated udp endpoint option: " + option); } } catch(Ice.VersionParseException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid version `" + argument + "' in endpoint `udp " + str + "':\n" + ex.str; throw e; } } else if(option.Equals("--interface")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint `udp " + str + "'"; throw e; } _mcastInterface = argument; } else if(option.Equals("--ttl")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint `udp " + str + "'"; throw e; } try { _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else { parseOption(option, argument, "udp", str); } } if(_host == null) { _host = instance_.defaultsAndOverrides().defaultHost; } else if(_host.Equals("*")) { if(oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'"); } } if(_host == null) { _host = ""; } calcHashValue(); }
public Reference create(string s, string propertyPrefix) { if(s.Length == 0) { return null; } const string delim = " \t\n\r"; int beg; int end = 0; beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end); if(beg == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "no non-whitespace characters found in `" + s + "'"; throw e; } // // Extract the identity, which may be enclosed in single // or double quotation marks. // string idstr = null; end = IceUtilInternal.StringUtil.checkQuote(s, beg); if(end == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "mismatched quotes around identity in `" + s + "'"; throw e; } else if(end == 0) { end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg); if(end == -1) { end = s.Length; } idstr = s.Substring(beg, end - beg); } else { beg++; // Skip leading quote idstr = s.Substring(beg, end - beg); end++; // Skip trailing quote } if(beg == end) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "no identity in `" + s + "'"; throw e; } // // Parsing the identity may raise IdentityParseException. // Ice.Identity ident = instance_.stringToIdentity(idstr); if(ident.name.Length == 0) { // // An identity with an empty name and a non-empty // category is illegal. // if(ident.category.Length > 0) { Ice.IllegalIdentityException e = new Ice.IllegalIdentityException(); e.id = ident; throw e; } // // Treat a stringified proxy containing two double // quotes ("") the same as an empty string, i.e., // a null proxy, but only if nothing follows the // quotes. // else if(IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid characters after identity in `" + s + "'"; throw e; } else { return null; } } string facet = ""; Reference.Mode mode = Reference.Mode.ModeTwoway; bool secure = false; string adapter = ""; while(true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end); if(beg == -1) { break; } if(s[beg] == ':' || s[beg] == '@') { break; } end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg); if(end == -1) { end = s.Length; } if(beg == end) { break; } string option = s.Substring(beg, end - beg); if(option.Length != 2 || option[0] != '-') { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "expected a proxy option but found `" + option + "' in `" + s + "'"; throw e; } // // Check for the presence of an option argument. The // argument may be enclosed in single or double // quotation marks. // string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end); if(argumentBeg != -1) { char ch = s[argumentBeg]; if(ch != '@' && ch != ':' && ch != '-') { beg = argumentBeg; end = IceUtilInternal.StringUtil.checkQuote(s, beg); if(end == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "mismatched quotes around value for " + option + " option in `" + s + "'"; throw e; } else if(end == 0) { end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg); if(end == -1) { end = s.Length; } argument = s.Substring(beg, end - beg); } else { beg++; // Skip leading quote argument = s.Substring(beg, end - beg); end++; // Skip trailing quote } } } // // If any new options are added here, // IceInternal::Reference::toString() and its derived classes must be updated as well. // switch(option[1]) { case 'f': { if(argument == null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "no argument provided for -f option in `" + s + "'"; throw e; } try { facet = IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.Length); } catch(System.ArgumentException argEx) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid facet in `" + s + "': " + argEx.Message; throw e; } break; } case 't': { if(argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -t option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeTwoway; break; } case 'o': { if(argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -o option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeOneway; break; } case 'O': { if(argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -O option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeBatchOneway; break; } case 'd': { if(argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -d option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeDatagram; break; } case 'D': { if(argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -D option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeBatchDatagram; break; } case 's': { if(argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -s option in `" + s + "'"; throw e; } secure = true; break; } default: { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unknown option `" + option + "' in `" + s + "'"; throw e; } } } if(beg == -1) { return create(ident, facet, mode, secure, null, null, propertyPrefix); } ArrayList endpoints = new ArrayList(); if(s[beg] == ':') { ArrayList unknownEndpoints = new ArrayList(); end = beg; while(end < s.Length && s[end] == ':') { beg = end + 1; end = beg; while(true) { end = s.IndexOf(':', end); if(end == -1) { end = s.Length; break; } else { bool quoted = false; int quote = beg; while(true) { quote = s.IndexOf((System.Char) '\"', quote); if(quote == -1 || end < quote) { break; } else { quote = s.IndexOf((System.Char) '\"', ++quote); if(quote == -1) { break; } else if(end < quote) { quoted = true; break; } ++quote; } } if(!quoted) { break; } ++end; } } string es = s.Substring(beg, end - beg); EndpointI endp = instance_.endpointFactoryManager().create(es, false); if(endp != null) { endpoints.Add(endp); } else { unknownEndpoints.Add(es); } } if(endpoints.Count == 0) { Debug.Assert(unknownEndpoints.Count > 0); Ice.EndpointParseException e2 = new Ice.EndpointParseException(); e2.str = "invalid endpoint `" + unknownEndpoints[0] + "' in `" + s + "'"; throw e2; } else if(unknownEndpoints.Count != 0 && instance_.initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Endpoints", 1) > 0) { StringBuilder msg = new StringBuilder("Proxy contains unknown endpoints:"); int sz = unknownEndpoints.Count; for(int idx = 0; idx < sz; ++idx) { msg.Append(" `"); msg.Append((string)unknownEndpoints[idx]); msg.Append("'"); } instance_.initializationData().logger.warning(msg.ToString()); } EndpointI[] ep = (EndpointI[])endpoints.ToArray(typeof(EndpointI)); return create(ident, facet, mode, secure, ep, null, propertyPrefix); } else if(s[beg] == '@') { beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, beg + 1); if(beg == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "missing adapter id in `" + s + "'"; throw e; } string adapterstr = null; end = IceUtilInternal.StringUtil.checkQuote(s, beg); if(end == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "mismatched quotes around adapter id in `" + s + "'"; throw e; } else if(end == 0) { end = IceUtilInternal.StringUtil.findFirstOf(s, delim, beg); if(end == -1) { end = s.Length; } adapterstr = s.Substring(beg, end - beg); } else { beg++; // Skip leading quote adapterstr = s.Substring(beg, end - beg); end++; // Skip trailing quote } if(end != s.Length && IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid trailing characters after `" + s.Substring(0, end + 1) + "' in `" + s + "'"; throw e; } try { adapter = IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length); } catch(System.ArgumentException argEx) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid adapter id in `" + s + "': " + argEx.Message; throw e; } if(adapter.Length == 0) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "empty adapter id in `" + s + "'"; throw e; } return create(ident, facet, mode, secure, null, adapter, propertyPrefix); } Ice.ProxyParseException ex = new Ice.ProxyParseException(); ex.str = "malformed proxy `" + s + "'"; throw ex; }
private List <EndpointI> parseEndpoints(string endpts, bool oaEndpoints) { int beg; int end = 0; string delim = " \t\n\r"; List <EndpointI> endpoints = new List <EndpointI>(); while (end < endpts.Length) { beg = IceUtilInternal.StringUtil.findFirstNotOf(endpts, delim, end); if (beg == -1) { break; } end = beg; while (true) { end = endpts.IndexOf((System.Char) ':', end); if (end == -1) { end = endpts.Length; break; } else { bool quoted = false; int quote = beg; while (true) { quote = endpts.IndexOf((System.Char) '\"', quote); if (quote == -1 || end < quote) { break; } else { quote = endpts.IndexOf((System.Char) '\"', ++quote); if (quote == -1) { break; } else if (end < quote) { quoted = true; break; } ++quote; } } if (!quoted) { break; } ++end; } } if (end == beg) { ++end; continue; } string s = endpts.Substring(beg, (end) - (beg)); EndpointI endp = instance_.endpointFactoryManager().create(s, oaEndpoints); if (endp == null) { Ice.EndpointParseException e2 = new Ice.EndpointParseException(); e2.str = "invalid object adapter endpoint `" + s + "'"; throw e2; } endpoints.Add(endp); ++end; } return(endpoints); }
protected override bool checkOption(string option, string argument, string endpoint) { if (base.checkOption(option, argument, endpoint)) { return(true); } switch (option[1]) { case 't': { if (argument == null) { throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint); } if (argument.Equals("infinite")) { _timeout = -1; } else { try { _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); if (_timeout < 1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; throw e; } } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; throw e; } } return(true); } case 'z': { if (argument != null) { throw new Ice.EndpointParseException("unexpected argument `" + argument + "' provided for -z option in " + endpoint); } _compress = true; return(true); } default: { return(false); } } }
public Reference create(string s, string propertyPrefix) { if (s.Length == 0) { return(null); } const string delim = " \t\n\r"; int beg; int end = 0; beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end); if (beg == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "no non-whitespace characters found in `" + s + "'"; throw e; } // // Extract the identity, which may be enclosed in single // or double quotation marks. // string idstr = null; end = IceUtilInternal.StringUtil.checkQuote(s, beg); if (end == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "mismatched quotes around identity in `" + s + "'"; throw e; } else if (end == 0) { end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg); if (end == -1) { end = s.Length; } idstr = s.Substring(beg, end - beg); } else { beg++; // Skip leading quote idstr = s.Substring(beg, end - beg); end++; // Skip trailing quote } if (beg == end) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "no identity in `" + s + "'"; throw e; } // // Parsing the identity may raise IdentityParseException. // Ice.Identity ident = instance_.stringToIdentity(idstr); if (ident.name.Length == 0) { // // An identity with an empty name and a non-empty // category is illegal. // if (ident.category.Length > 0) { Ice.IllegalIdentityException e = new Ice.IllegalIdentityException(); e.id = ident; throw e; } // // Treat a stringified proxy containing two double // quotes ("") the same as an empty string, i.e., // a null proxy, but only if nothing follows the // quotes. // else if (IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid characters after identity in `" + s + "'"; throw e; } else { return(null); } } string facet = ""; Reference.Mode mode = Reference.Mode.ModeTwoway; bool secure = false; Ice.EncodingVersion encoding = instance_.defaultsAndOverrides().defaultEncoding; Ice.ProtocolVersion protocol = Ice.Util.Protocol_1_0; string adapter = ""; while (true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end); if (beg == -1) { break; } if (s[beg] == ':' || s[beg] == '@') { break; } end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg); if (end == -1) { end = s.Length; } if (beg == end) { break; } string option = s.Substring(beg, end - beg); if (option.Length != 2 || option[0] != '-') { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "expected a proxy option but found `" + option + "' in `" + s + "'"; throw e; } // // Check for the presence of an option argument. The // argument may be enclosed in single or double // quotation marks. // string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end); if (argumentBeg != -1) { char ch = s[argumentBeg]; if (ch != '@' && ch != ':' && ch != '-') { beg = argumentBeg; end = IceUtilInternal.StringUtil.checkQuote(s, beg); if (end == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "mismatched quotes around value for " + option + " option in `" + s + "'"; throw e; } else if (end == 0) { end = IceUtilInternal.StringUtil.findFirstOf(s, delim + ":@", beg); if (end == -1) { end = s.Length; } argument = s.Substring(beg, end - beg); } else { beg++; // Skip leading quote argument = s.Substring(beg, end - beg); end++; // Skip trailing quote } } } // // If any new options are added here, // IceInternal::Reference::toString() and its derived classes must be updated as well. // switch (option[1]) { case 'f': { if (argument == null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "no argument provided for -f option in `" + s + "'"; throw e; } try { facet = IceUtilInternal.StringUtil.unescapeString(argument, 0, argument.Length); } catch (System.ArgumentException argEx) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid facet in `" + s + "': " + argEx.Message; throw e; } break; } case 't': { if (argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -t option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeTwoway; break; } case 'o': { if (argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -o option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeOneway; break; } case 'O': { if (argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -O option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeBatchOneway; break; } case 'd': { if (argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -d option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeDatagram; break; } case 'D': { if (argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -D option in `" + s + "'"; throw e; } mode = Reference.Mode.ModeBatchDatagram; break; } case 's': { if (argument != null) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unexpected argument `" + argument + "' provided for -s option in `" + s + "'"; throw e; } secure = true; break; } case 'e': { if (argument == null) { throw new Ice.ProxyParseException("no argument provided for -e option `" + s + "'"); } try { encoding = Ice.Util.stringToEncodingVersion(argument); } catch (Ice.VersionParseException e) { throw new Ice.ProxyParseException("invalid encoding version `" + argument + "' in `" + s + "':\n" + e.str); } break; } case 'p': { if (argument == null) { throw new Ice.ProxyParseException("no argument provided for -p option `" + s + "'"); } try { protocol = Ice.Util.stringToProtocolVersion(argument); } catch (Ice.VersionParseException e) { throw new Ice.ProxyParseException("invalid protocol version `" + argument + "' in `" + s + "':\n" + e.str); } break; } default: { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "unknown option `" + option + "' in `" + s + "'"; throw e; } } } if (beg == -1) { return(create(ident, facet, mode, secure, protocol, encoding, null, null, propertyPrefix)); } List <EndpointI> endpoints = new List <EndpointI>(); if (s[beg] == ':') { List <string> unknownEndpoints = new List <string>(); end = beg; while (end < s.Length && s[end] == ':') { beg = end + 1; end = beg; while (true) { end = s.IndexOf(':', end); if (end == -1) { end = s.Length; break; } else { bool quoted = false; int quote = beg; while (true) { quote = s.IndexOf((System.Char) '\"', quote); if (quote == -1 || end < quote) { break; } else { quote = s.IndexOf((System.Char) '\"', ++quote); if (quote == -1) { break; } else if (end < quote) { quoted = true; break; } ++quote; } } if (!quoted) { break; } ++end; } } string es = s.Substring(beg, end - beg); EndpointI endp = instance_.endpointFactoryManager().create(es, false); if (endp != null) { endpoints.Add(endp); } else { unknownEndpoints.Add(es); } } if (endpoints.Count == 0) { Debug.Assert(unknownEndpoints.Count > 0); Ice.EndpointParseException e2 = new Ice.EndpointParseException(); e2.str = "invalid endpoint `" + unknownEndpoints[0] + "' in `" + s + "'"; throw e2; } else if (unknownEndpoints.Count != 0 && instance_.initializationData().properties.getPropertyAsIntWithDefault( "Ice.Warn.Endpoints", 1) > 0) { StringBuilder msg = new StringBuilder("Proxy contains unknown endpoints:"); int sz = unknownEndpoints.Count; for (int idx = 0; idx < sz; ++idx) { msg.Append(" `"); msg.Append((string)unknownEndpoints[idx]); msg.Append("'"); } instance_.initializationData().logger.warning(msg.ToString()); } EndpointI[] ep = endpoints.ToArray(); return(create(ident, facet, mode, secure, protocol, encoding, ep, null, propertyPrefix)); } else if (s[beg] == '@') { beg = IceUtilInternal.StringUtil.findFirstNotOf(s, delim, beg + 1); if (beg == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "missing adapter id in `" + s + "'"; throw e; } string adapterstr = null; end = IceUtilInternal.StringUtil.checkQuote(s, beg); if (end == -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "mismatched quotes around adapter id in `" + s + "'"; throw e; } else if (end == 0) { end = IceUtilInternal.StringUtil.findFirstOf(s, delim, beg); if (end == -1) { end = s.Length; } adapterstr = s.Substring(beg, end - beg); } else { beg++; // Skip leading quote adapterstr = s.Substring(beg, end - beg); end++; // Skip trailing quote } if (end != s.Length && IceUtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid trailing characters after `" + s.Substring(0, end + 1) + "' in `" + s + "'"; throw e; } try { adapter = IceUtilInternal.StringUtil.unescapeString(adapterstr, 0, adapterstr.Length); } catch (System.ArgumentException argEx) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "invalid adapter id in `" + s + "': " + argEx.Message; throw e; } if (adapter.Length == 0) { Ice.ProxyParseException e = new Ice.ProxyParseException(); e.str = "empty adapter id in `" + s + "'"; throw e; } return(create(ident, facet, mode, secure, protocol, encoding, null, adapter, propertyPrefix)); } Ice.ProxyParseException ex = new Ice.ProxyParseException(); ex.str = "malformed proxy `" + s + "'"; throw ex; }
public EndpointI create(string str, bool oaEndpoint) { lock(this) { string s = str.Trim(); if(s.Length == 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "value has no non-whitespace characters"; throw e; } Regex p = new Regex("([ \t\n\r]+)|$"); Match m = p.Match(s); Debug.Assert(m.Success); string protocol = s.Substring(0, m.Index); if(protocol.Equals("default")) { protocol = instance_.defaultsAndOverrides().defaultProtocol; } for(int i = 0; i < _factories.Count; i++) { EndpointFactory f = (EndpointFactory)_factories[i]; if(f.protocol().Equals(protocol)) { return f.create(s.Substring(m.Index + m.Length), oaEndpoint); // Code below left in place for debugging. /* EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint); BasicStream bs = new BasicStream(instance_, true); e.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); short type = bs.readShort(); EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs); System.Console.Error.WriteLine("Normal: " + e); System.Console.Error.WriteLine("Opaque: " + ue); return e; */ } } // // If the stringified endpoint is opaque, create an unknown endpoint, // then see whether the type matches one of the known endpoints. // if(protocol.Equals("opaque")) { EndpointI ue = new OpaqueEndpointI(s.Substring(m.Index + m.Length)); for(int i = 0; i < _factories.Count; i++) { EndpointFactory f = (EndpointFactory)_factories[i]; if(f.type() == ue.type()) { // // Make a temporary stream, write the opaque endpoint data into the stream, // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // BasicStream bs = new BasicStream(instance_, Ice.Util.currentProtocolEncoding, true); ue.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); bs.readShort(); // type return f.read(bs); } } return ue; // Endpoint is opaque, but we don't have a factory for its type. } return null; } }
private List<EndpointI> parseEndpoints(string endpts, bool oaEndpoints) { int beg; int end = 0; string delim = " \t\n\r"; List<EndpointI> endpoints = new List<EndpointI>(); while(end < endpts.Length) { beg = IceUtilInternal.StringUtil.findFirstNotOf(endpts, delim, end); if(beg == -1) { break; } end = beg; while(true) { end = endpts.IndexOf((System.Char) ':', end); if(end == -1) { end = endpts.Length; break; } else { bool quoted = false; int quote = beg; while(true) { quote = endpts.IndexOf((System.Char) '\"', quote); if(quote == -1 || end < quote) { break; } else { quote = endpts.IndexOf((System.Char) '\"', ++quote); if(quote == -1) { break; } else if(end < quote) { quoted = true; break; } ++quote; } } if(!quoted) { break; } ++end; } } if(end == beg) { ++end; continue; } string s = endpts.Substring(beg, (end) - (beg)); EndpointI endp = instance_.endpointFactoryManager().create(s, oaEndpoints); if(endp == null) { #if COMPACT if(s.StartsWith("ssl", StringComparison.Ordinal) || s.StartsWith("wss", StringComparison.Ordinal)) { instance_.initializationData().logger.warning( "ignoring endpoint `" + s + "': IceSSL is not supported with the .NET Compact Framework"); ++end; continue; } #else if(AssemblyUtil.runtime_ == AssemblyUtil.Runtime.Mono && (s.StartsWith("ssl", StringComparison.Ordinal) || s.StartsWith("wss", StringComparison.Ordinal))) { instance_.initializationData().logger.warning( "ignoring endpoint `" + s + "': IceSSL is not supported with Mono"); ++end; continue; } #endif Ice.EndpointParseException e2 = new Ice.EndpointParseException(); e2.str = "invalid object adapter endpoint `" + s + "'"; throw e2; } endpoints.Add(endp); ++end; } return endpoints; }
protected override bool checkOption(string option, string argument, string endpoint) { switch(option[1]) { case 'r': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -r option in endpoint " + endpoint + _delegate.options(); throw e; } _resource = argument; return true; } default: { return false; } } }
protected override bool checkOption(string option, string argument, string endpoint) { if(base.checkOption(option, argument, endpoint)) { return true; } if(option.Equals("-c")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in " + endpoint; throw e; } _connect = true; } else if(option.Equals("-z")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint; throw e; } _compress = true; } else if(option.Equals("-v") || option.Equals("-e")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for " + option + " option in endpoint " + endpoint; throw e; } try { Ice.EncodingVersion v = Ice.Util.stringToEncodingVersion(argument); if(v.major != 1 || v.minor != 0) { instance_.logger().warning("deprecated udp endpoint option: " + option); } } catch(Ice.VersionParseException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid version `" + argument + "' in endpoint " + endpoint + ":\n" + ex.str; throw e; } } else if(option.Equals("--ttl")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint " + endpoint; throw e; } try { _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint " + endpoint; throw e; } if(_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint " + endpoint; throw e; } } else if(option.Equals("--interface")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint " + endpoint; throw e; } _mcastInterface = argument; } else { return false; } return true; }
public EndpointI create(string str, bool oaEndpoint) { lock (this) { string s = str.Trim(); if (s.Length == 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "value has no non-whitespace characters"; throw e; } Regex p = new Regex("([ \t\n\r]+)|$"); Match m = p.Match(s); Debug.Assert(m.Success); string protocol = s.Substring(0, m.Index); if (protocol.Equals("default")) { protocol = instance_.defaultsAndOverrides().defaultProtocol; } for (int i = 0; i < _factories.Count; i++) { EndpointFactory f = (EndpointFactory)_factories[i]; if (f.protocol().Equals(protocol)) { return(f.create(s.Substring(m.Index + m.Length), oaEndpoint)); // Code below left in place for debugging. /* * EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint); * BasicStream bs = new BasicStream(instance_, true); * e.streamWrite(bs); * Buffer buf = bs.getBuffer(); * buf.b.position(0); * short type = bs.readShort(); * EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs); * System.Console.Error.WriteLine("Normal: " + e); * System.Console.Error.WriteLine("Opaque: " + ue); * return e; */ } } // // If the stringified endpoint is opaque, create an unknown endpoint, // then see whether the type matches one of the known endpoints. // if (protocol.Equals("opaque")) { EndpointI ue = new OpaqueEndpointI(s.Substring(m.Index + m.Length)); for (int i = 0; i < _factories.Count; i++) { EndpointFactory f = (EndpointFactory)_factories[i]; if (f.type() == ue.type()) { // // Make a temporary stream, write the opaque endpoint data into the stream, // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // BasicStream bs = new BasicStream(instance_, Ice.Util.currentProtocolEncoding, true); ue.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); bs.readShort(); // type return(f.read(bs)); } } return(ue); // Endpoint is opaque, but we don't have a factory for its type. } return(null); } }
public UdpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { instance_ = instance; _host = null; _port = 0; _connect = false; _compress = false; string delim = " \t\n\r"; int beg; int end = 0; while (true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if (beg == -1) { break; } end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if (end == -1) { end = str.Length; } string option = str.Substring(beg, end - beg); if (option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'"; throw e; } string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if (argumentBeg != -1 && str[argumentBeg] != '-') { beg = argumentBeg; if (str[beg] == '\"') { end = IceUtilInternal.StringUtil.findFirstOf(str, "\"", beg + 1); if (end == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'"; throw e; } else { ++end; } } else { end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if (end == -1) { end = str.Length; } } argument = str.Substring(beg, end - beg); if (argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } if (option.Equals("-h")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `udp " + str + "'"; throw e; } _host = argument; } else if (option.Equals("-p")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `udp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if (_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else if (option.Equals("-c")) { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'"; throw e; } _connect = true; } else if (option.Equals("-z")) { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'"; throw e; } _compress = true; } else if (option.Equals("-v") || option.Equals("-e")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for " + option + " option in endpoint " + "`udp " + str + "'"; throw e; } try { Ice.EncodingVersion v = Ice.Util.stringToEncodingVersion(argument); if (v.major != 1 || v.minor != 0) { instance_.initializationData().logger.warning("deprecated udp endpoint option: " + option); } } catch (Ice.VersionParseException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid version `" + argument + "' in endpoint `udp " + str + "':\n" + ex.str; throw e; } } else if (option.Equals("--interface")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint `udp " + str + "'"; throw e; } _mcastInterface = argument; } else if (option.Equals("--ttl")) { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint `udp " + str + "'"; throw e; } try { _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if (_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else { parseOption(option, argument, "udp", str); } } if (_host == null) { _host = instance_.defaultsAndOverrides().defaultHost; } else if (_host.Equals("*")) { if (oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'"); } } if (_host == null) { _host = ""; } calcHashValue(); }
public EndpointI create(string str, bool oaEndpoint) { string[] arr = IceUtilInternal.StringUtil.splitString(str, " \t\r\n"); if(arr == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quote"; throw e; } if(arr.Length == 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "value has no non-whitespace characters"; throw e; } List<string> v = new List<string>(arr); string protocol = v[0]; v.RemoveAt(0); if(protocol.Equals("default")) { protocol = instance_.defaultsAndOverrides().defaultProtocol; } EndpointFactory factory = null; lock(this) { for(int i = 0; i < _factories.Count; i++) { EndpointFactory f = _factories[i]; if(f.protocol().Equals(protocol)) { factory = f; } } } if(factory != null) { EndpointI e = factory.create(v, oaEndpoint); if(v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } return e; // Code below left in place for debugging. /* EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint); BasicStream bs = new BasicStream(instance_, true); e.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); short type = bs.readShort(); EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs); System.Console.Error.WriteLine("Normal: " + e); System.Console.Error.WriteLine("Opaque: " + ue); return e; */ } // // If the stringified endpoint is opaque, create an unknown endpoint, // then see whether the type matches one of the known endpoints. // if(protocol.Equals("opaque")) { EndpointI ue = new OpaqueEndpointI(v); if(v.Count > 0) { Ice.EndpointParseException ex = new Ice.EndpointParseException(); ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; throw ex; } factory = get(ue.type()); if(factory != null) { // // Make a temporary stream, write the opaque endpoint data into the stream, // and ask the factory to read the endpoint data from that stream to create // the actual endpoint. // BasicStream bs = new BasicStream(instance_, Ice.Util.currentProtocolEncoding); bs.writeShort(ue.type()); ue.streamWrite(bs); Buffer buf = bs.getBuffer(); buf.b.position(0); buf.b.limit(buf.size()); bs.readShort(); // type bs.startReadEncaps(); EndpointI e = factory.read(bs); bs.endReadEncaps(); return e; } return ue; // Endpoint is opaque, but we don't have a factory for its type. } return null; }
public TcpEndpointI(Instance instance, string str, bool oaEndpoint) : base("") { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; char[] separators = { ' ', '\t', '\n', '\r' }; string[] arr = str.Split(separators); int i = 0; while (i < arr.Length) { if (arr[i].Length == 0) { i++; continue; } string option = arr[i++]; if (option.Length != 2 || option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `tcp " + str + "'"; throw e; } string argument = null; if (i < arr.Length && arr[i].Length > 0 && arr[i][0] != '-') { argument = arr[i++]; if (argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } switch (option[1]) { case 'h': { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `tcp " + str + "'"; throw e; } _host = argument; break; } case 'p': { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `tcp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } if (_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `tcp " + str + "'"; throw e; } break; } case 't': { if (argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -t option in endpoint `tcp " + str + "'"; throw e; } try { _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch (System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid timeout value `" + argument + "' in endpoint `tcp " + str + "'"; throw e; } break; } case 'z': { if (argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `tcp " + str + "'"; throw e; } _compress = true; break; } default: { parseOption(option, argument, "tcp", str); break; } } } if (_host == null) { _host = _instance.defaultsAndOverrides().defaultHost; } else if (_host.Equals("*")) { if (oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `tcp " + str + "'"); } } if (_host == null) { _host = ""; } calcHashValue(); }
protected override bool checkOption(string option, string argument, string endpoint) { if(base.checkOption(option, argument, endpoint)) { return true; } switch(option[1]) { case 't': { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -t option in endpoint " + endpoint; throw e; } if(argument.Equals("infinite")) { _timeout = -1; } else { try { _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture); if(_timeout < 1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; throw e; } } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; throw e; } } return true; } case 'z': { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint; throw e; } _compress = true; return true; } default: { return false; } } }
public UdpEndpointI(Instance instance, string str, bool oaEndpoint) { instance_ = instance; _host = null; _port = 0; _protocolMajor = Protocol.protocolMajor; _protocolMinor = Protocol.protocolMinor; _encodingMajor = Protocol.encodingMajor; _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = false; string delim = " \t\n\r"; int beg; int end = 0; while(true) { beg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(beg == -1) { break; } end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } string option = str.Substring(beg, end - beg); if(option[0] != '-') { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "expected an endpoint option but found `" + option + "' in endpoint `udp " + str + "'"; throw e; } string argument = null; int argumentBeg = IceUtilInternal.StringUtil.findFirstNotOf(str, delim, end); if(argumentBeg != -1 && str[argumentBeg] != '-') { beg = argumentBeg; if(str[beg] == '\"') { end = IceUtilInternal.StringUtil.findFirstOf(str, "\"", beg + 1); if(end == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "mismatched quotes around `" + argument + "' in endpoint `udp " + str + "'"; throw e; } else { ++end; } } else { end = IceUtilInternal.StringUtil.findFirstOf(str, delim, beg); if(end == -1) { end = str.Length; } } argument = str.Substring(beg, end - beg); if(argument[0] == '\"' && argument[argument.Length - 1] == '\"') { argument = argument.Substring(1, argument.Length - 2); } } if(option.Equals("-v")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -v option in endpoint `udp " + str + "'"; throw e; } int pos = argument.IndexOf((System.Char) '.'); if(pos == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "malformed protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } string majStr = argument.Substring(0, (pos) - (0)); string minStr = argument.Substring(pos + 1, (argument.Length) - (pos + 1)); int majVersion; int minVersion; try { majVersion = System.Int32.Parse(majStr, CultureInfo.InvariantCulture); minVersion = System.Int32.Parse(minStr, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "range error in protocol version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion != Protocol.protocolMajor) { Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException(); e.badMajor = majVersion < 0?majVersion + 255:majVersion; e.badMinor = minVersion < 0?minVersion + 255:minVersion; e.major = Protocol.protocolMajor; e.minor = Protocol.protocolMinor; throw e; } _protocolMajor = (byte)majVersion; _protocolMinor = (byte)minVersion; } else if(option.Equals("-e")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -e option in endpoint `udp " + str + "'"; throw e; } int pos = argument.IndexOf((System.Char) '.'); if(pos == -1) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "malformed encoding version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } string majStr = argument.Substring(0, (pos) - (0)); string minStr = argument.Substring(pos + 1, (argument.Length) - (pos + 1)); int majVersion; int minVersion; try { majVersion = System.Int32.Parse(majStr, CultureInfo.InvariantCulture); minVersion = System.Int32.Parse(minStr, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid encoding version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "range error in encoding version `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(majVersion != Protocol.encodingMajor) { Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException(); e.badMajor = majVersion < 0?majVersion + 255:majVersion; e.badMinor = minVersion < 0?minVersion + 255:minVersion; e.major = Protocol.encodingMajor; e.minor = Protocol.encodingMinor; throw e; } _encodingMajor = (byte)majVersion; _encodingMinor = (byte)minVersion; } else if(option.Equals("-h")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -h option in endpoint `udp " + str + "'"; throw e; } _host = argument; } else if(option.Equals("-p")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for -p option in endpoint `udp " + str + "'"; throw e; } try { _port = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid port value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_port < 0 || _port > 65535) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "port value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else if(option.Equals("-c")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -c option in `udp " + str + "'"; throw e; } _connect = true; } else if(option.Equals("-z")) { if(argument != null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unexpected argument `" + argument + "' provided for -z option in `udp " + str + "'"; throw e; } _compress = true; } else if(option.Equals("--interface")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --interface option in endpoint `udp " + str + "'"; throw e; } _mcastInterface = argument; } else if(option.Equals("--ttl")) { if(argument == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "no argument provided for --ttl option in endpoint `udp " + str + "'"; throw e; } try { _mcastTtl = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } catch(System.FormatException ex) { Ice.EndpointParseException e = new Ice.EndpointParseException(ex); e.str = "invalid TTL value `" + argument + "' in endpoint `udp " + str + "'"; throw e; } if(_mcastTtl < 0) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "TTL value `" + argument + "' out of range in endpoint `udp " + str + "'"; throw e; } } else { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = "unknown option `" + option + "' in `udp " + str + "'"; throw e; } } if(_host == null) { _host = instance_.defaultsAndOverrides().defaultHost; } else if(_host.Equals("*")) { if(oaEndpoint) { _host = null; } else { throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `udp " + str + "'"); } } if(_host == null) { _host = ""; } calcHashValue(); }