public SimpleStreamConnection(SocketStreamConnection clientSocket, MessageReceiveHandler receiveEventHandler, LogCallback logCallbackHandler) { m_logCallback = logCallbackHandler; m_pipe = clientSocket; m_pipe.MessageReceived += new MessageEventHandler(ReceiveMessage); m_messageReceiveHandler = receiveEventHandler; }
public DispatchManager( object sender, // Agent reference for callbacks Options options, WaterFlowManager incomingFlowManager, IOWorker ioWorker, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { this.sender = sender; this.incomingFlowManager = incomingFlowManager; this.ioWorker = ioWorker; this.logCallback = logCallback; this.logLevel = logLevel; messageQueue = new LinkedList<IncomingMessage>(); objectMap = new Dictionary<string, IncomingMessageHandler>(); anyObjectCallback = null; int numOfThreads = options.dispatcherThreads; dispatchers = new List<Thread>(); for (int i = 0; i != numOfThreads; ++i) { Thread th = new Thread((new Dispatcher(this)).run); th.Name = "YAMI4 message dispatcher"; th.IsBackground = true; th.Start(); dispatchers.Add(th); } }
public LogSubscriber(ILogger logger) { m_logger = logger; m_callback = OnLogCallback; IntPtr hCallback = Marshal.GetFunctionPointerForDelegate(m_callback); LibVlcMethods.libvlc_log_subscribe(ref m_subscriber, hCallback, IntPtr.Zero); }
public ChannelReader( NetworkUtils.TransportChannel connection, IncomingMessageDispatchCallback incomingMessageDispatchCallback, string target, Options options, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { this.connection = connection; this.incomingMessageDispatchCallback = incomingMessageDispatchCallback; this.target = target; this.logCallback = logCallback; this.logLevel = logLevel; incomingFrames = new Dictionary<int, IncomingMessageFrames>(); if (connection != null) { if (connection.connectedChannel != null) { // stream-based connection headerBuffer = new MemoryStream(Frame.FRAME_HEADER_SIZE); setReadingFrameHeaderState(); } else { // datagram-based connection wholeFrameBuffer = new byte[options.udpFrameSize]; state = InputState.READING_WHOLE_FRAMES; } } deliverAsRawBinary = options.deliverAsRawBinary; }
public LogSubscriber(ILogger logger, IntPtr pInstance) { _mInstance = pInstance; _mLogger = logger; _mCallback = OnLogCallback; var hCallback = Marshal.GetFunctionPointerForDelegate(_mCallback); LibVlcMethods.libvlc_log_set(_mInstance, hCallback, IntPtr.Zero); }
internal Listener( Socket channel, string resolvedTarget, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { this.channel = channel; this.resolvedTarget = resolvedTarget; this.logCallback = logCallback; this.logLevel = logLevel; }
// Parameter incomingMessageDispatchCallback not used here internal UdpListener( Socket channel, string resolvedTarget, IncomingMessageDispatchCallback incomingMessageDispatchCallback, Options options, LogCallback logCallback, LogEventArgs.LogLevel logLevel) : base(channel, resolvedTarget, logCallback, logLevel) { this.channel = channel; this.options = options; }
internal ChannelWriter( NetworkUtils.TransportChannel connection, string target, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { this.connection = connection; this.target = target; this.logCallback = logCallback; this.logLevel = logLevel; outgoingFrames = new List<OutgoingFrame>(); }
protected override void Dispose(bool disposing) { if (m_subscriber.func != IntPtr.Zero) { LibVlcMethods.libvlc_log_unsubscribe(ref m_subscriber); } if (disposing) { m_callback = null; } }
public static void arwRegisterLogCallback(LogCallback lcb) { if (lcb != null) { logCallback = lcb; logCallbackGCH = GCHandle.Alloc(logCallback); // Does not need to be pinned, see http://stackoverflow.com/a/19866119/316487 } if (Application.platform == RuntimePlatform.IPhonePlayer) ARNativePluginStatic.arwRegisterLogCallback(logCallback); else ARNativePlugin.arwRegisterLogCallback(logCallback); if (lcb == null) { logCallback = null; logCallbackGCH.Free(); } }
protected override void Dispose(bool disposing) { try { LibVlcMethods.libvlc_log_unset(_mInstance); } catch (Exception) { } if (disposing) { _mCallback = null; } }
public void Log(string line) { //InnerSpaceAPI.InnerSpace.Echo(string.Format("{0:HH:mm:ss} {1}", DateTime.Now, line)); if (this.InvokeRequired) { LogCallback cb = new LogCallback(Log); this.Invoke(cb, new object[] { line }); } else { string output = string.Format("{0:HH:mm:ss} {1}\n", DateTime.Now, line); tbLog.AppendText(output); } }
public VirtualDevice() { _tapcfg = NativeLib.GetInstance(); int version = _tapcfg.get_version(); if (version != TAPCFG_VERSION) { string theirVersion = (version >> 16) + "." + (version & 0xffff); string ourVersion = (TAPCFG_VERSION >> 16) + "." + (TAPCFG_VERSION & 0xffff); throw new Exception("Library version mismatch, got " + theirVersion + " required " + ourVersion); } _handle = _tapcfg.init(); if (_handle == IntPtr.Zero) { throw new Exception("Error initializing the tapcfg library"); } LogCallback = new LogCallback(defaultCallback); }
public void LogText(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.textLog.InvokeRequired) { LogCallback d = new LogCallback(LogText); this.Invoke(d, new object[] { text }); } else { textLog.Text += text + "\r\n"; textLog.SelectionStart = textLog.TextLength; textLog.ScrollToCaret(); } }
internal Channel(string target, Options options, IncomingMessageDispatchCallback incomingMessageDispatchCallback, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { this.target = target; this.options = options; this.logCallback = logCallback; this.logLevel = logLevel; connect(incomingMessageDispatchCallback); if (logCallback != null) { logCallback.Log(LogEventArgs.LogLevel.LOW, "Connected to " + target); } }
// used by listener when accepting new connections internal Channel(Socket acceptedChannel, string sourceTarget, IncomingMessageDispatchCallback incomingMessageDispatchCallback, Options options, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { this.target = sourceTarget; this.options = options; this.connection = new NetworkUtils.TransportChannel(acceptedChannel); this.logCallback = logCallback; this.logLevel = logLevel; createReaderWriter(incomingMessageDispatchCallback); if (logCallback != null) { logCallback.Log(LogEventArgs.LogLevel.LOW, "Accepted connection from " + target); } }
public IOWorker( IDictionary<string, Channel> channels, IDictionary<string, Listener> listeners, WaterFlowManager incomingFlowManager, Options options, IncomingMessageDispatchCallback incomingMessageDispatchCallback, ConnectionEventCallback connectionEventCallback, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { this.channels = channels; this.listeners = listeners; this.incomingFlowManager = incomingFlowManager; this.options = options; this.incomingMessageDispatchCallback = incomingMessageDispatchCallback; this.connectionEventCallback = connectionEventCallback; this.logCallback = logCallback; this.logLevel = logLevel; listenersForSelection = new Dictionary<Socket, Listener>(); channelsForSelection = new Dictionary<Socket, Channel>(); stopRequest = false; }
internal static Listener prepareServer(string target, IncomingMessageDispatchCallback incomingMessageDispatchCallback, Options options, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { if(protocolIsTcp(target)) { return prepareTcpServer(target, incomingMessageDispatchCallback, options, logCallback, logLevel); } else if(protocolIsUdp(target)) { return prepareUdpServer(target, incomingMessageDispatchCallback, options, logCallback, logLevel); } else { throw new BadProtocolException(target); } }
public static void SetLogCallback(LogCallback callback) { Log.m_LogCallback = callback; }
public static void RegisterLogCallbackThreaded(LogCallback handler){}
void SetLog(LogCallback cb) { _logCallback = cb ?? throw new ArgumentException(nameof(cb)); Native.LibVLCLogSet(NativeReference, cb, IntPtr.Zero); }
public static void RegisterLogCallbackThreaded(LogCallback handler) { RegisterLogCallback(handler, true); }
public Form1(string [] args) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // mModuleKey = Registry.LocalMachine.CreateSubKey(@"Software\EarLab"); mApplicationKey = Registry.CurrentUser.CreateSubKey(@"Software\EarLab\EarLab GUI"); mLogCallback = new LogCallback(LogCallback); mModuleDirectory = new RegistryString(mModuleKey, "ModulesPath", @"C:\Program Files\EarLab\Modules"); mInputDirectory = new RegistryString(mApplicationKey, "InputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Signals"); mOutputDirectory = new RegistryString(mApplicationKey, "OutputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Output"); mDiagramFile = new RegistryString(mApplicationKey, "RunParameterFile", null); mParameterFile = new RegistryString(mApplicationKey, "ModuleParameterFile", null); mFrameCount = new RegistryInt(mApplicationKey, "FrameCount", 0); mEnableSuperuserMode = new RegistryBool(mApplicationKey, "SuperuserMode", false); udFrameCount.Value = mFrameCount.Value; mWindowState = new RegistryFormWindowState(mApplicationKey, "WindowState", FormWindowState.Normal); mWindowLocation = new RegistryPoint(mApplicationKey, "WindowLocation", this.Location); mWindowSize = new RegistrySize(mApplicationKey, "WindowSize", this.MinimumSize); this.Location = mWindowLocation.Value; this.Size = mWindowSize.Value; this.WindowState = mWindowState.Value; if (mEnableSuperuserMode.Value) { menuEnvironment.Enabled = true; menuEnvironment.Visible = true; menuFileOpenDiagram.Enabled = true; menuFileOpenDiagram.Visible = true; menuFileOpenParameters.Enabled = true; menuFileOpenParameters.Visible = true; menuFileSeparator.Enabled = true; menuFileSeparator.Visible = true; } if (args.Length > 0) { bool dashN = false; // -n <FrameCount> bool dashI = false; // -i <InputDirectory> bool dashO = false; // -o <OutputDirectory> bool DiagramFileSpecified = false; bool ParameterFileSpecified = false; RunningFromCommandLineInput = false; try { for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "-n": try { FrameCount = int.Parse(args[++i]); dashN = true; } catch (FormatException) { throw new ApplicationException("Frame count (-n) must be a non-zero positive integer. \"" + args[i] + "\" is invalid"); } break; case "-m": ModuleDirectory = args[++i]; break; case "-i": InputDirectory = args[++i]; dashI = true; break; case "-o": OutputDirectory = args[++i]; dashO = true; break; case "-l": LoadAndWait = true; break; default: if (!DiagramFileSpecified) { DiagramFile = args[i]; DiagramFileSpecified = true; } else { if (!ParameterFileSpecified) { ParameterFile = args[i]; ParameterFileSpecified = true; } else { throw new ApplicationException("Too many parameters specified"); } } break; } // switch } // for if (dashN && dashI && dashO && DiagramFileSpecified && ParameterFileSpecified) { RunningFromCommandLineInput = true; } } // try catch (ApplicationException e) { string Message; Message = e.Message + "\n"; Message += "Usage: EarLabGUI -n <NumFrames> [-m <ModuleDirectory>] [-i <InputDirectory>] [-o <OutputDirectory>]\n"; Message += " <DiagramFile> <ParameterFile>\n"; Message += "\n"; Message += "Where: <NumFrames> is a positive integer which is the number of frames over\n"; Message += " which the simulation will be run\n"; Message += " <ModuleDirectory> is a directory path that contains the module executables\n"; Message += " that will be used for this simulation. If this option is not provided,\n"; Message += " the module directory defaults to the directory into which EarLab was installed.\n"; Message += " <InputDirectory> is a directory path that contains the input files for the model.\n"; Message += " <OutputDirectory> is a directory path that will contain the output files produced by the model.\n"; Message += " <DiagramFile> is a file that describes an Earlab model\n"; Message += " <ParameterFile> is a parameter file that contains parameter definitions\n"; Message += " for all modules specified by the <DiagramFile>.\n"; System.Windows.Forms.MessageBox.Show(Message); } } else { RunningFromCommandLineInput = false; } if (LoadAndWait) { RunningFromCommandLineInput = false; } udFrameCount.Focus(); UpdateStatusDisplay(); if (RunningFromCommandLineInput) { timerCommandlineRun.Enabled = true; } }
/// <summary>Allow developers to register their own log handling routine</summary> /// <param name="logDelegate">The log delegate</param> public void RegisterLogDelegate(LogCallback logDelegate) { _logDelegate = logDelegate; }
public TestLogSink(LogCallback callback) { _callback = callback; }
public static void RegisterLogCallback(LogCallback handler) { RegisterLogCallback(handler, false); }
public static IAuthenticationService CreateAAD <TOptions>(LogCallback logCallback, Action <PublicClientApplicationBuilder> configureBuilder = null) where TOptions : class, IAADOptions, new() => Create(GetAADConfiguration <TOptions>(), logCallback, configureBuilder);
private static extern void SetLogCallbackExternal(IntPtr ModelPtr, LogCallback theCallback);
public static extern void aruwpRegisterLogCallback(LogCallback callback);
/// <summary> /// Initializes the log. /// </summary> /// <param name="logMethod"> /// The callback method to invoke when a log entry is created. /// </param> public static void Initialize(LogCallback logMethod) { LogCallback = logMethod; }
/// <summary>Allows you to listen in on log events! Any callback subscribed here will be called when /// something is logged. This does honor the Log.Filter, so filtered logs will not be received here.</summary> /// <param name="onLog">The function to call when a log event occurs.</param> public static void Subscribe(LogCallback onLog) { callbacks.Add(onLog); // This prevents the callback from getting GCed NativeAPI.log_subscribe(onLog); }
/// <summary> /// Initializes the log. /// </summary> /// <param name="logMethod"> /// The callback method to invoke when a log entry is created. /// </param> /// <param name="prefix"> /// The value to use as a prefix for log entries. /// </param> public static void Initialize(LogCallback logMethod, string prefix) { LogCallback = logMethod; Prefix = prefix; }
public static extern void SetLogCallback(LogCallback log, LogCallback logWarning, LogCallback logError);
public virtual void Log(string text, LogLevels level, LogIndents indentBefore, LogIndents indentAfter) { LogCallback?.Invoke(text, level, indentBefore, indentAfter); }
/// <summary> /// Listen to logs sent by the server /// </summary> /// <param name="callback">Called when a log message is received</param> public void Listen(LogCallback callback) { Callback = callback; }
public LogCallbackPrinter(LogCallback callback) { this.callback = callback; }
protected void log(string msg, Level level) { #if DEBUG StackTrace st = new StackTrace(); StackFrame callerFrame = st.GetFrame(2); string callerInfo = callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "()"; LogCallback callback = new LogCallback(logCallback); callback.BeginInvoke(msg, level, DateTime.Now, callerInfo, Thread.CurrentThread.ManagedThreadId, null, null); #endif }
public void TestInit() { TestCommon.ResetInternalStaticCaches(); _callback = Substitute.For <LogCallback>(); }
public static void RegisterLogCallback(LogCallback handler){}
static extern IntPtr rsid_set_log_clbk(LogCallback clbk, int minLevel, int do_formatting);
private void log(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (logBox.InvokeRequired) { LogCallback d = new LogCallback(log); this.Invoke(d, new object[] { text }); } else { logBox.AppendText(text + Environment.NewLine); Console.WriteLine("log: " + text); } }
public Form1(string [] args) { try { mMainForm = this; mModuleKey = Registry.CurrentUser.CreateSubKey(@"Software\EarLab"); mApplicationKey = Registry.CurrentUser.CreateSubKey(@"Software\EarLab\EarLab GUI"); mLogCallback = new LogCallback(LogCallback); mModuleDirectory = new RegistryString(mModuleKey, "ModulesPath", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"EarLab\Modules")); if (!Directory.Exists(mModuleDirectory.Value)) { mModuleDirectory.Value = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"EarLab\Modules"); if (!Directory.Exists(mModuleDirectory.Value)) { MessageBox.Show(@"Module directory not found", @"Simulator error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } mInputDirectory = new RegistryString(mApplicationKey, "InputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Signals"); mOutputDirectory = new RegistryString(mApplicationKey, "OutputDirectory", System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") + @"\My Documents\EarLab\Output"); mDiagramFile = new RegistryString(mApplicationKey, "RunParameterFile", null); mParameterFile = new RegistryString(mApplicationKey, "ModuleParameterFile", null); mFrameCount = new RegistryInt(mApplicationKey, "FrameCount", 1); #if DEBUG mEnableSuperuserMode = new RegistryBool(mApplicationKey, "SuperuserMode", true); #else mEnableSuperuserMode = new RegistryBool(mApplicationKey, "SuperuserMode", false); #endif mWindowState = new RegistryFormWindowState(mApplicationKey, "WindowState", FormWindowState.Normal); mWindowLocation = new RegistryPoint(mApplicationKey, "WindowLocation", this.Location); mWindowSize = new RegistrySize(mApplicationKey, "WindowSize", this.MinimumSize); } catch (Exception e) { MessageBox.Show("Exception caught while creating application registry keys: " + e.ToString()); } try { InitializeComponent(); } catch (Exception e) { MessageBox.Show("Exception caught during call to InitializeComponent: " + e.ToString()); } udFrameCount.Value = mFrameCount.Value; this.Location = mWindowLocation.Value; this.Size = mWindowSize.Value; this.WindowState = mWindowState.Value; CheckForIllegalCrossThreadCalls = false; if (mEnableSuperuserMode.Value) { menuEnvironment.Enabled = true; menuEnvironment.Visible = true; menuFileOpenDiagram.Enabled = true; menuFileOpenDiagram.Visible = true; menuFileOpenParameters.Enabled = true; menuFileOpenParameters.Visible = true; menuFileSeparator.Enabled = true; menuFileSeparator.Visible = true; } else { menuEnvironment.Enabled = false; menuEnvironment.Visible = false; menuFileOpenDiagram.Enabled = false; menuFileOpenDiagram.Visible = false; menuFileOpenParameters.Enabled = false; menuFileOpenParameters.Visible = false; menuFileSeparator.Enabled = false; menuFileSeparator.Visible = false; } if ((args != null) && (args.Length > 0)) { if (args.Length == 1) { // This should be a file name for us to open and parse ReadSimulationFile(args[0]); } else { bool dashN = false; // -n <FrameCount> bool dashI = false; // -i <InputDirectory> bool dashO = false; // -o <OutputDirectory> bool DiagramFileSpecified = false; bool ParameterFileSpecified = false; RunningFromCommandLineInput = false; try { for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "-n": try { FrameCount = int.Parse(args[++i]); dashN = true; } catch (FormatException) { throw new ApplicationException("Frame count (-n) must be a non-zero positive integer. \"" + args[i] + "\" is invalid"); } break; case "-m": ModuleDirectory = args[++i]; break; case "-i": InputDirectory = args[++i]; dashI = true; break; case "-o": OutputDirectory = args[++i]; dashO = true; break; case "-l": LoadAndWait = true; break; default: if (!DiagramFileSpecified) { DiagramFile = args[i]; DiagramFileSpecified = true; } else { if (!ParameterFileSpecified) { ParameterFile = args[i]; ParameterFileSpecified = true; } else { throw new ApplicationException("Too many parameters specified"); } } break; } // switch } // for if (dashN && dashI && dashO && DiagramFileSpecified && ParameterFileSpecified) { RunningFromCommandLineInput = true; } } // try catch (ApplicationException e) { string Message; Message = e.Message + "\n"; Message += "Usage: EarLabGUI -n <NumFrames> [-m <ModuleDirectory>] [-i <InputDirectory>] [-o <OutputDirectory>]\n"; Message += " <DiagramFile> <ParameterFile>\n"; Message += "\n"; Message += "Where: <NumFrames> is a positive integer which is the number of frames over\n"; Message += " which the simulation will be run\n"; Message += " <ModuleDirectory> is a directory path that contains the module executables\n"; Message += " that will be used for this simulation. If this option is not provided,\n"; Message += " the module directory defaults to the directory into which EarLab was installed.\n"; Message += " <InputDirectory> is a directory path that contains the input files for the model.\n"; Message += " <OutputDirectory> is a directory path that will contain the output files produced by the model.\n"; Message += " <DiagramFile> is a file that describes an Earlab model\n"; Message += " <ParameterFile> is a parameter file that contains parameter definitions\n"; Message += " for all modules specified by the <DiagramFile>.\n"; System.Windows.Forms.MessageBox.Show(Message); } } } else { RunningFromCommandLineInput = false; } if (LoadAndWait) { RunningFromCommandLineInput = false; } udFrameCount.Focus(); UpdateStatusDisplay(); if (RunningFromCommandLineInput) { timerCommandlineRun.Enabled = true; } }
public static void RegisterLogCallback(LogCallback handle) { logCallback += handle; }
private static extern void SetDebugLogCallback(LogCallback functionDelegate);
private static UdpListener prepareUdpServer(string target, IncomingMessageDispatchCallback incomingMessageDispatchCallback, Options options, LogCallback logCallback, LogEventArgs.LogLevel logLevel) { IpComponents udpComponents = parseUdp(target); string hostName = udpComponents.hostName; int port = udpComponents.port; Socket s = CreateUDPSocket(); IPEndPoint address; string boundHostName; if(hostName == "*") { // bind to the wildcard local address // and resolve to the local hostname address = new IPEndPoint(IPAddress.Any, port); boundHostName = Dns.GetHostName(); } else { //TODO: translation for empty result (if possible) address = new IPEndPoint( Dns.GetHostAddresses(hostName)[0], port); boundHostName = hostName; } s.Blocking = false; s.Bind(address); // get the actual address of this socket int boundPort = ((IPEndPoint)s.LocalEndPoint).Port; string resolvedTarget = formatUdpTarget(boundHostName, boundPort); return new UdpListener(s, resolvedTarget, incomingMessageDispatchCallback, options, logCallback, logLevel); }
public static TrrntZipStatus CheckZipFiles(ref List <ZippedFile> zippedFiles, int threadId, LogCallback statusLogCallBack) { TrrntZipStatus tzStatus = TrrntZipStatus.Unknown; // ***************************** RULE 1 ************************************* // Directory separator should be a '/' a '\' is invalid and should be replaced with '/' // // check if any '\' = 92 need converted to '/' = 47 // this needs done before the sort, so that the sort is correct. // return BadDirectorySeparator if errors found. bool error1 = false; foreach (ZippedFile t in zippedFiles) { char[] bytes = t.Name.ToCharArray(); bool fixDir = false; for (int j = 0; j < bytes.Length; j++) { if (bytes[j] != 92) { continue; } fixDir = true; bytes[j] = (char)47; tzStatus |= TrrntZipStatus.BadDirectorySeparator; if (!error1 && Program.VerboseLogging) { error1 = true; statusLogCallBack?.Invoke(threadId, "Incorrect directory separator found"); } } if (fixDir) { t.Name = new string(bytes); } } // ***************************** RULE 2 ************************************* // All Files in a torrentzip should be sorted with a lower case file compare. // // if needed sort the files correctly, and return Unsorted if errors found. bool error2 = false; bool thisSortFound = true; while (thisSortFound) { thisSortFound = false; for (int i = 0; i < zippedFiles.Count - 1; i++) { int c = TrrntZipStringCompare(zippedFiles[i].Name, zippedFiles[i + 1].Name); if (c > 0) { ZippedFile T = zippedFiles[i]; zippedFiles[i] = zippedFiles[i + 1]; zippedFiles[i + 1] = T; tzStatus |= TrrntZipStatus.Unsorted; thisSortFound = true; if (!error2 && Program.VerboseLogging) { error2 = true; statusLogCallBack?.Invoke(threadId, "Incorrect file order found"); } } } } // ***************************** RULE 3 ************************************* // Directory marker files are only needed if they are empty directories. // // now that the files are sorted correctly, we can see if there are unneeded // directory files, by first finding directory files (these end in a '\' character ascii 92) // and then checking if the next file is a file in that found directory. // If we find this 2 entry pattern (directory followed by file in that directory) // then the directory entry should not be present and the torrentzip is incorrect. // return ExtraDirectoryEnteries if error is found. bool error3 = false; for (int i = 0; i < zippedFiles.Count - 1; i++) { // check if this is a directory entry if (zippedFiles[i].Name[zippedFiles[i].Name.Length - 1] != 47) { continue; } // check if the next filename is shorter or equal to this filename. // if it is shorter or equal it cannot be a file in the directory. if (zippedFiles[i + 1].Name.Length <= zippedFiles[i].Name.Length) { continue; } // check if the directory part of the two file enteries match // if they do we found an incorrect directory entry. bool delete = true; for (int j = 0; j < zippedFiles[i].Name.Length; j++) { if (zippedFiles[i].Name[j] != zippedFiles[i + 1].Name[j]) { delete = false; break; } } // we found an incorrect directory so remove it. if (delete) { zippedFiles.RemoveAt(i); tzStatus |= TrrntZipStatus.ExtraDirectoryEnteries; if (!error3 && Program.VerboseLogging) { error3 = true; statusLogCallBack?.Invoke(threadId, "Un-needed directory records found"); } i--; } } // check for repeat files bool error4 = false; for (int i = 0; i < zippedFiles.Count - 1; i++) { if (zippedFiles[i].Name == zippedFiles[i + 1].Name) { tzStatus |= TrrntZipStatus.RepeatFilesFound; if (!error4 && Program.VerboseLogging) { error4 = true; statusLogCallBack?.Invoke(threadId, "Duplcate file enteries found"); } } } return(tzStatus); }
/// <summary> /// Initializes the log. /// </summary> /// <param name="logMethod"> /// The callback method to invoke when a log entry is created. /// </param> /// <param name="prefix"> /// The value to use as a prefix for log entries. /// </param> /// <param name="prefixTimestamp"> /// Indicates whether to prefix log entries with a timestamp. /// </param> public static void Initialize(LogCallback logMethod, string prefix, bool prefixTimestamp) { LogCallback = logMethod; Prefix = prefix; PrefixTimeStamp = prefixTimestamp; }
public abstract void set_log_callback(IntPtr tapcfg, LogCallback cb);
/// <summary>If you subscribed to the log callback, you can unsubscribe that callback here!</summary> /// <param name="onLog">The subscribed callback to remove.</param> public static void Unsubscribe(LogCallback onLog) { callbacks.Remove(onLog); NativeAPI.log_unsubscribe(onLog); }
internal static extern void LibVLCLogSet(IntPtr instance, LogCallback cb, IntPtr data);
public static IDisposable Start(LogCallback callback) { var sink = new TestLogSink(callback); Logger.Sink = sink; return Disposable.Create(() => Logger.Sink = null); }
public static extern int gofw_start( [MarshalAs(UnmanagedType.FunctionPtr)] LogCallback created, string log_level, string china_list, string upstream, string localaddr, string auth, string key, string domain, int partial, int dns_size, int udp_port, int udp_tcp);
public static extern void SetLogCallback(LogCallback logCallback);
/// <summary> /// Sets up CurveFlow's logging system to a custom callback function /// </summary> /// <param name="log">The Callback function where the string will be pushed</param> /// <param name="messageTypeMask">Bitmask of the MessageTypes that will be sent</param> public void InitializeLog(LogCallback log, MessageType messageTypeMask) { CFLog.SetupLog(messageTypeMask, log); }
private static extern int OVR_FlushLog(LogCallback handler);
/// <summary> /// Listen to logs sent by the server. /// </summary> /// <param name="callback">Called when a log message is received.</param> public void Listen(LogCallback callback) { ThrowIfDisposed(); Callback = callback; }
public static void RegisterLogCallback(LogCallback handler) { throw new NotImplementedException(); }
/// <summary> Log Event </summary> /// <param name="text">Text for log</param> /// <remarks>Invoked from threaded process</remarks> private void LogEvent(string text) { var callBack = new LogCallback(Log); Invoke(callBack, text); }