Beispiel #1
0
        public static bool GetArgument(string option, PString8 *buf)
        {
            int argumentIndex;
            int argumentLen;

            Diagnostics.Assert(option != null, "CommandLine.GetArgument(): argument `option' is null");
            Diagnostics.Assert(buf != null, "CommandLine.GetArgument(): argument `buf' is null");

            if (commandLine == null)
            {
                return(false);
            }

            argumentIndex = IndexOfArgument(option);

            if (argumentIndex < 0)
            {
                return(false);
            }

            argumentLen = GetArgumentLength(argumentIndex);

            buf->Concat(commandLine, argumentIndex, argumentLen);

            return(true);
        }
Beispiel #2
0
 public unsafe static void Error(PString8 *msg)
 {
     TextMode.SaveAttributes();
     SetErrorTextAttributes();
     TextMode.WriteLine(msg);
     TextMode.RestoreAttributes();
 }
Beispiel #3
0
 /// <summary>
 /// Writes <paramref name="len" /> characters of the string
 /// <paramref name="message" /> to the screen, starting with
 /// the character at index <paramref name="offset" />.
 /// </summary>
 public unsafe static void WriteSubstring(PString8 *message, int offset, int len)
 {
     for (int i = offset; i < message->Length && i < offset + len; ++i)
     {
         WriteChar(message->GetChar(i));
     }
 }
Beispiel #4
0
        public unsafe static void Warning(string msg)
        {
            TextMode.SaveAttributes();
            PString8 *buf = PString8.Wrap(intermediateStringBuffer, MaxMessageLength);

            SetWarningTextAttributes();

            buf->Concat("Warning: ");
            buf->Concat(msg);
            TextMode.WriteLine(buf);

            TextMode.RestoreAttributes();
        }
Beispiel #5
0
        public static void Execute(CommandExecutionContext *context)
        {
            byte *rawbuf = stackalloc byte [EntryModule.MaxKeyMapNameLength];

            if (context->parameters->Compare("--list") == 0)
            {
                ListKeyMaps();
            }
            else if (context->parameters->Compare(0, "--set ", 0, 6) == 0 &&
                     context->parameters->Length > 6)
            {
                PString8 *buf = PString8.Wrap(rawbuf,
                                              EntryModule.MaxKeyMapNameLength);
                buf->Clear();
                TextMode.Write(context->parameters->Length);
                TextMode.WriteLine();
                buf->Concat(context->parameters, 6, context->parameters->Length - 6);

                if (KeyMap.GetBuiltinKeyMap(buf) == null)
                {
                    TextMode.SaveAttributes();
                    TextMode.Foreground = TextColor.Red;
                    TextMode.Write("Unknown keymap `");
                    TextMode.Write(buf);
                    TextMode.Write("'");
                    TextMode.RestoreAttributes();
                }
                else
                {
                    TextMode.Write("Setting key map to `");
                    TextMode.Write(buf);
                    TextMode.Write("'");
                    KeyMap.SetKeyMap(buf);
                }
            }
            else if (context->parameters->Length == 0)
            {
                TextMode.Write("Current key map: ");
                TextMode.WriteLine(KeyMap.GetCurrentKeyMapName());
            }
            else
            {
                TextMode.WriteLine("Usage: keymap [--list|--set NAME]");
            }
        }
Beispiel #6
0
        public static void Execute(CommandExecutionContext *context)
        {
            SharpOS.Kernel.Foundation.Time time = new SharpOS.Kernel.Foundation.Time();
            byte *    rawbuf = stackalloc byte [50];
            PString8 *pstr   = PString8.Wrap(rawbuf, 50);

            if (context->parameters->Compare("--hw") == 0)
            {
                Clock.GetHardwareTime(time);
            }
            else
            {
                Clock.GetCurrentTime(time);
            }

            time.ToString(pstr);
            TextMode.WriteLine(pstr);
        }
Beispiel #7
0
        /// <summary>
        /// Induce a kernel panic. Prints the meessage, stage, and error code
        /// then halts the computer.
        /// <summary>
        public unsafe static void Panic(string msg, KernelStage stage, KernelError code)
        {
            TextMode.Write("Panic: ");
            TextMode.WriteLine(msg);
#if false
            PString8 *buf = PString8.Wrap(intermediateStringBuffer, MaxMessageLength);

            buf->Concat("Stage: ");
            buf->Concat((int)stage, false);
            buf->ConcatLine();

            buf->Concat("  Error: ");
            buf->Concat((int)code, false);
            buf->ConcatLine();

            TextMode.SaveAttributes();
            SetErrorTextAttributes();
            TextMode.ClearScreen();
            TextMode.WriteLine("SharpOS");
            TextMode.WriteLine("Kernel Panic. Your system was halted to ensure your security.");
            TextMode.Write("  Stage: ");
            TextMode.Write((int)stage, false);
            TextMode.WriteLine();
            TextMode.Write("  Error: ");
            TextMode.Write((int)code, false);
            TextMode.WriteLine();

            TextMode.WriteLine();
            TextMode.WriteLine("              ,  ");
            TextMode.WriteLine("      |\\   /\\/ \\/|   ,_");
            TextMode.WriteLine("      ; \\/`     '; , \\_',");
            TextMode.WriteLine("       \\        / ");
            TextMode.WriteLine("        '.    .'    /`.");
            TextMode.WriteLine("    jgs   `~~` , /\\ `\"`");
            TextMode.WriteLine("              .  `\"");

            TextMode.WriteLine();
            TextMode.WriteLine("The SharpOS Project would appreciate your feedback on this bug.");

            TextMode.RestoreAttributes();
#endif
            EntryModule.Halt();
        }
Beispiel #8
0
 /// <summary>
 /// Concatenates <paramref name="str" />.
 /// </summary>
 public int Concat(PString8 *str)
 {
     return(Concat(str, 0, 0));
 }
Beispiel #9
0
 /// <summary>
 /// Sets the current keymap to a built-in one specified by
 /// <paramref name="name" />.
 /// </summary>
 public static void SetKeyMap(PString8 *name)
 {
     SetKeyMap(name->Pointer, name->Length);
 }
Beispiel #10
0
 /// <summary>
 /// Concatenates from <paramref name="str" /> the
 /// characters at indices <paramref name="offset" /> to
 /// <paramref name="offset" /> + <paramref name="len" />.
 /// </summary>
 public int Concat(PString8 *str, int offset, int len)
 {
     return(Concat(str->Pointer, str->Length, offset, len));
 }
Beispiel #11
0
        public unsafe void ToString(PString8 *str)
        {
            if (str == null)
            {
                throw new ArgumentNullException("str");
            }

            if (DayOfWeekString != null)
            {
                str->Concat(DayOfWeekString);
                str->Concat(" ");
            }

            if (MonthString != null)
            {
                // January 1, 2008
                str->Concat(MonthString);
                str->Concat(" ");
                str->Concat(Day);
                str->Concat(", ");
                str->Concat(Year);
            }
            else
            {
                // 2008/1/1
                str->Concat(Year);
                str->Concat("/");
                str->Concat(Month);
                str->Concat("/");
                str->Concat(Day);
            }

            str->Concat(" ");
            str->Concat(Hour);
            str->Concat(":");

            if (Minute < 10)
            {
                str->Concat("0");
            }

            str->Concat(Minute);

            str->Concat(":");

            if (Second < 10)
            {
                str->Concat("0");
            }

            str->Concat(Second);
            str->Concat(".");
            str->Concat(Millisecond);

            if (CurrentTimezone != 0)
            {
                str->Concat(" ");

                if (TimezoneString != null)
                {
                    str->Concat(TimezoneString);
                }
                else
                {
                    str->Concat("UTC");
                    if (CurrentTimezone < 0)
                    {
                        str->Concat("+");
                    }
                    str->Concat(CurrentTimezone);
                }
            }
            else
            {
                str->Concat(" UTC");
            }
        }
Beispiel #12
0
 /// <summary>
 /// Gets the address of a builtin keymap included in the kernel
 /// via the keymap archive resource in SharpOS.Kernel.dll. The
 /// archive is generated by the SharpOS keymap compiler.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="nameLen">The name len.</param>
 /// <returns></returns>
 public static void *GetBuiltinKeyMap(PString8 *name)
 {
     return(GetBuiltinKeyMap(name->Pointer, name->Length));
 }
Beispiel #13
0
 public unsafe static void WriteLine(PString8 *message, int value)
 {
     Write(message);
     Write(value);
     WriteLine();
 }
Beispiel #14
0
 public int IndexOf(int from, PString8 *substr, int count)
 {
     return(IndexOf(from, substr, 0, count));
 }
Beispiel #15
0
 public unsafe static int ToInt32(PString8 *str)
 {
     return(ToInt32(str->Pointer, 0, str->Length, str->Length));
 }
Beispiel #16
0
 public unsafe static void Write(PString8 *str)
 {
     Write(str->Pointer, str->Length);
 }
Beispiel #17
0
 public int IndexOf(int from, PString8 *substr, int offset, int count)
 {
     return(IndexOf(from, substr->Pointer, substr->Length, offset, count));
 }
Beispiel #18
0
 /// <summary>
 /// Compares <paramref name="count" /> characters of the
 /// string against <paramref name="str" />.
 /// </summary>
 public int Compare(PString8 *str, int count)
 {
     return(ByteString.Compare(Pointer, str->Pointer, count));
 }
Beispiel #19
0
 public int IndexOf(int from, PString8 *substr)
 {
     return(IndexOf(from, substr, 0, 0));
 }
Beispiel #20
0
 public int IndexOf(PString8 *substr)
 {
     return(IndexOf(0, substr, 0, 0));
 }
Beispiel #21
0
 /// <summary>
 /// Compares <paramref name="count" /> characters of the
 /// string against <paramref name="str" />.
 /// </summary>
 public int Compare(int from, PString8 *str, int offset, int count)
 {
     return(ByteString.Compare(Pointer, from, str->Pointer, offset, count));
 }
Beispiel #22
0
 /// <summary>
 /// Compares the string against <paramref name="str" />.
 /// </summary>
 public int Compare(PString8 *str)
 {
     return(Compare(str, 0));
 }
Beispiel #23
0
 public unsafe static int ToInt32(PString8 *str, int offset, int length)
 {
     return(ToInt32(str->Pointer, offset, length, str->Length));
 }