Permalink
Browse files

Version 0.5

  • Loading branch information...
1 parent 3a0cd9d commit c70b1af104de1eb0f13e536d0d1efb5e488aeb3a asergey committed Jan 31, 2009

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -57,8 +57,8 @@ public class AbstractNode
{
private void InitBlock()
{
- ntype = NTYPE_R6;
- flags = dFlagExtendedReferences | dFlagExtendedPidsPorts;
+ //ntype = NTYPE_R6;
+ //flags = dFlagExtendedReferences | dFlagExtendedPidsPorts;
}
static AbstractNode()
{
@@ -78,64 +78,75 @@ static AbstractNode()
}
catch
{
- defaultCookie = string.Empty;
+ defaultCookie = null;
+ }
+
+ if (defaultCookie == null)
+ {
+ System.String dotCookieFilename = System.Environment.GetEnvironmentVariable("HOME")
+ + System.IO.Path.DirectorySeparatorChar
+ + ".erlang.cookie";
+ System.IO.StreamReader br = null;
+ try
+ {
+ System.IO.FileInfo dotCookieFile = new System.IO.FileInfo(dotCookieFilename);
+ br = new System.IO.StreamReader(new System.IO.StreamReader(dotCookieFile.FullName).BaseStream);
+ defaultCookie = br.ReadLine().Trim();
+ }
+ catch (System.IO.IOException)
+ {
+ defaultCookie = null;
+ }
+ finally
+ {
+ try
+ {
+ if (br != null)
+ br.Close();
+ }
+ catch (System.IO.IOException)
+ {
+ }
+ }
}
- //System.String dotCookieFilename = System.Environment.GetEnvironmentVariable("HOME")
- // + System.IO.Path.DirectorySeparatorChar
- // + ".erlang.cookie";
- //System.IO.StreamReader br = null;
- //try
- //{
- // System.IO.FileInfo dotCookieFile = new System.IO.FileInfo(dotCookieFilename);
- // br = new System.IO.StreamReader(new System.IO.StreamReader(dotCookieFile.FullName).BaseStream);
- // defaultCookie = br.ReadLine().Trim();
- //}
- //catch (System.IO.IOException)
- //{
- // defaultCookie = "";
- //}
- //finally
- //{
- // try
- // {
- // if (br != null)
- // br.Close();
- // }
- // catch (System.IO.IOException)
- // {
- // }
- //}
+ if (defaultCookie == null)
+ defaultCookie = string.Empty;
}
}
internal static System.String localHost = null;
internal System.String _node;
internal System.String _host;
internal System.String _alive;
internal System.String _cookie;
- internal static System.String defaultCookie = null;
-
+ internal System.String _longName;
+ public static string defaultCookie = null;
+ public static bool useShortNames = false;
+
// Node types
internal const int NTYPE_R6 = 110; // 'n' post-r5, all nodes
internal const int NTYPE_R4_ERLANG = 109;
// 'm' Only for source compatibility
internal const int NTYPE_R4_HIDDEN = 104;
// 'h' Only for source compatibility
-
+
// Node capability flags
internal const int dFlagPublished = 1;
internal const int dFlagAtomCache = 2;
internal const int dFlagExtendedReferences = 4;
internal const int dFlagDistMonitor = 8;
internal const int dFlagFunTags = 16;
internal const int dFlagExtendedPidsPorts = 256; // pshaffer
+ internal const int dFlagBitBinaries = 1024;
+ internal const int dFlagNewFloats = 2048;
internal int ntype = NTYPE_R6; // pshaffer
internal int _proto = 0; // tcp/ip
internal int _distHigh = 5; // Cannot talk to nodes before R6
internal int _distLow = 5; // Cannot talk to nodes before R6
internal int _creation = 0;
- internal int flags = dFlagExtendedReferences | dFlagExtendedPidsPorts; // pshaffer
+ internal int flags = dFlagExtendedReferences | dFlagExtendedPidsPorts
+ | dFlagBitBinaries | dFlagNewFloats | dFlagDistMonitor; // pshaffer
/*initialize hostname and default cookie */
protected internal AbstractNode()
@@ -146,19 +157,20 @@ protected internal AbstractNode()
/*
* Create a node with the given name and the default cookie.
**/
- protected internal AbstractNode(System.String node):this(node, defaultCookie)
+ protected internal AbstractNode(System.String node)
+ : this(node, defaultCookie, false)
{
}
-
+
/*
* Create a node with the given name and cookie.
**/
- protected internal AbstractNode(System.String name, System.String cookie)
+ protected internal AbstractNode(System.String name, System.String cookie, bool shortName)
{
InitBlock();
this._cookie = cookie;
-
- int i = name.IndexOf((System.Char) '@', 0);
+
+ int i = name.IndexOf((System.Char)'@', 0);
if (i < 0)
{
_alive = name;
@@ -169,25 +181,46 @@ protected internal AbstractNode(System.String name, System.String cookie)
_alive = name.Substring(0, (i) - (0));
_host = name.Substring(i + 1, (name.Length) - (i + 1));
}
-
+
if (_alive.Length > 0xff)
{
_alive = _alive.Substring(0, (0xff) - (0));
}
-
- _node = _alive + "@" + _host;
+
+ _longName = _alive + "@" + _host;
+ _node = node(_longName, shortName);
}
-
+
+ public static string node(System.String _node, bool _shortName)
+ {
+ if (_shortName || useShortNames)
+ {
+ int i = _node.IndexOf('@');
+ i = i < 0 ? 0 : i + 1;
+ int j = _node.IndexOf((System.Char)'.', i);
+ return (j < 0) ? _node : _node.Substring(0, i + j - 2);
+ }
+ else
+ {
+ return _node;
+ }
+ }
+
/*
* Get the name of this node.
*
* @return the name of the node represented by this object.
**/
- public virtual System.String node()
+ public string node()
{
- return _node;
+ return useShortNames ? _node : _longName;
}
-
+
+ public string nodeLongName()
+ {
+ return _longName;
+ }
+
/*
* Get the hostname part of the nodename. Nodenames are composed of
* two parts, an alivename and a hostname, separated by '@'. This
Oops, something went wrong.

0 comments on commit c70b1af

Please sign in to comment.