This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
57 changed files
with
13,795 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
|
||
namespace Xnb | ||
{ | ||
/* | ||
public class OpAttribute : Attribute | ||
{ | ||
public OpAttribute (int opcode) | ||
{ | ||
} | ||
} | ||
*/ | ||
|
||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct)] | ||
public class RequestAttribute : Attribute | ||
{ | ||
public RequestAttribute (int opcode) | ||
{ | ||
} | ||
} | ||
|
||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method)] | ||
public class ReplyAttribute : Attribute | ||
{ | ||
public ReplyAttribute (Type reply) | ||
{ | ||
} | ||
|
||
public ReplyAttribute (int opcode) | ||
{ | ||
} | ||
} | ||
|
||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct)] | ||
public class EventAttribute : Attribute | ||
{ | ||
public EventAttribute (int number) | ||
{ | ||
} | ||
} | ||
|
||
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Struct)] | ||
public class ErrorAttribute : Attribute | ||
{ | ||
public ErrorAttribute (int number) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
|
||
using System.Net.Sockets; | ||
|
||
using Mono.Unix; | ||
using Mono.Unix.Native; | ||
|
||
namespace Xnb | ||
{ | ||
using Auth; | ||
|
||
//System.Net.IPAddress.NetworkToHostOrder(); | ||
public class Authenticator | ||
{ | ||
public static void GetAuthInfoHack (int fd, out AuthInfo authinfo) | ||
{ | ||
/* | ||
string fname = UnixMarshal.PtrToStringUnix (XauFileName ()); | ||
Trace.WriteLine ("auth fname: " + fname); | ||
*/ | ||
|
||
Xau xau = new Xau (); | ||
//string fname = xau.GetFileName (); | ||
|
||
//foreach (Xauth xauth in xau.ReadAuths (fname)) | ||
foreach (Xauth xauth in xau) { | ||
Trace.WriteLine (xauth.Name); | ||
} | ||
|
||
/* | ||
UnixFileInfo ufi = new UnixFileInfo (fname); | ||
UnixStream us = ufi.OpenRead (); | ||
Trace.WriteLine ("a: " + us.Handle); | ||
IntPtr auth = XauReadAuth (us.Handle); | ||
Trace.WriteLine ("auth: " + auth); | ||
us.Close (); | ||
*/ | ||
|
||
IntPtr authPtr = XauGetAuthByAddr ((ushort)AddressFamily.Unix, (ushort) 5, "rover", 1, "1"); | ||
Trace.WriteLine ("authPtr: " + authPtr); | ||
|
||
authinfo = new AuthInfo (); | ||
} | ||
|
||
//TODO | ||
public static AuthInfo GetAuthInfo (Socket sock) | ||
{ | ||
return new AuthInfo (); | ||
} | ||
|
||
public AuthInfo GetAuthInfo (int fd) | ||
{ | ||
string sockName = ""; | ||
IntPtr authPtr = GetAuthPtr (sockName); | ||
|
||
//return null; | ||
return new AuthInfo (); | ||
} | ||
|
||
string[] authnames = {"MIT-MAGIC-COOKIE-1"}; | ||
|
||
[DllImport ("Xau")] | ||
//[return: MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Mono.Unix.Native.FileNameMarshaler))] | ||
//static extern string XauFileName (); | ||
static extern IntPtr XauFileName (); | ||
//[DllImport ("X11")] | ||
[DllImport ("Xau")] | ||
static extern IntPtr XauReadAuth (int fd); | ||
//static extern IntPtr XauReadAuth (int fd); | ||
|
||
[DllImport ("Xau")] | ||
//Xauth *XauGetAuthByAddr (unsigned short family, unsigned short address_length, char *address, unsigned short number_length, char *number); | ||
static extern IntPtr XauGetAuthByAddr (ushort family, ushort address_length, string address, ushort number_length, string number); | ||
|
||
[DllImport ("Xau")] | ||
//Xauth *XauGetBestAuthByAddr (unsigned short family, unsigned short address_length, char *address, unsigned short number_length, char *number, int types_length, char **types, int *type_lengths); | ||
static extern IntPtr XauGetBestAuthByAddr (ushort family, ushort address_length, string address, ushort number_length, string number, int types_length, string[] types, int[] type_lengths); | ||
|
||
public IntPtr GetAuthPtr (string sockName) | ||
{ | ||
int[] authnamelens = new int[authnames.Length]; | ||
|
||
for (int i = 0 ; i != authnames.Length ; i++) | ||
authnamelens[i] = authnames[i].Length; | ||
|
||
IntPtr authPtr = XauGetBestAuthByAddr (0, 0, "", 0, "", authnames.Length, authnames, authnamelens); | ||
|
||
return authPtr; | ||
} | ||
} | ||
|
||
//TODO: maybe this is an IMessagePart? | ||
[StructLayout (LayoutKind.Sequential, CharSet=CharSet.Ansi)] | ||
public struct AuthInfo | ||
{ | ||
public int NameLen; | ||
public string Name; | ||
public int DataLen; | ||
//public byte[] Data; | ||
public IntPtr Data; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Xnb | ||
{ | ||
using Protocol.Xnb; | ||
|
||
public static class Aux | ||
{ | ||
public static byte GetDepth (Connection c, Screen screen) | ||
{ | ||
//Drawable drawable; | ||
|
||
//drawable.Window = screen.Root; | ||
|
||
return 0; | ||
} | ||
|
||
public static Screen GetScreen (Connection c, int screen) | ||
{ | ||
//foreach (Screen s in c.Setup.Roots) {} | ||
|
||
//Trace.WriteLine (c.Setup.Roots.Length); | ||
//return c.Setup.Roots[screen]; | ||
|
||
return new Screen (); | ||
} | ||
|
||
public static Visualtype GetVisualtype (Connection c, int scr, uint vid) | ||
{ | ||
return new Visualtype (); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
The MIT X11 License covers the files in Xnb | ||
|
||
|
||
Copyright (c) 2006 Alp Toker | ||
Parts Copyright (c) The Xcb Project | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
using System; | ||
using System.IO; | ||
|
||
class CodeWriter | ||
{ | ||
enum Language | ||
{ | ||
CSharp, C, | ||
} | ||
|
||
private StreamWriter w; | ||
|
||
public CodeWriter (string fname) | ||
{ | ||
Init (fname); | ||
} | ||
|
||
Language lang; | ||
|
||
Language LanguageForExtension (string ext) | ||
{ | ||
switch (ext) { | ||
case ".h": | ||
case ".c": | ||
return Language.C; | ||
case ".cs": | ||
default: | ||
return Language.CSharp; | ||
} | ||
} | ||
|
||
void Init (string fname) | ||
{ | ||
if (File.Exists (fname)) { | ||
File.Delete (fname); | ||
} | ||
|
||
lang = LanguageForExtension (Path.GetExtension (fname)); | ||
|
||
switch (lang) { | ||
case Language.C: | ||
Indenter = " "; | ||
break; | ||
|
||
case Language.CSharp: | ||
default: | ||
Indenter = "\t"; | ||
break; | ||
} | ||
|
||
FileStream fs = new FileStream (fname, FileMode.OpenOrCreate, FileAccess.Write); | ||
w = new StreamWriter (fs); | ||
|
||
if (lang == Language.CSharp) { | ||
w.WriteLine ("//------------------------------------------------------------------------------"); | ||
w.WriteLine ("// <auto-generated>"); | ||
w.WriteLine ("// This code was generated by a tool."); | ||
w.WriteLine ("// </auto-generated>"); | ||
w.WriteLine ("//------------------------------------------------------------------------------"); | ||
w.WriteLine (); | ||
} else { | ||
WriteComment ("This code was generated by a tool."); | ||
} | ||
|
||
} | ||
|
||
public string Indenter = "\t"; | ||
string cur_indent = ""; | ||
int level = 0; | ||
|
||
public void Indent () | ||
{ | ||
level++; | ||
cur_indent = ""; | ||
for (int i = 0; i != level ; i++) cur_indent += Indenter; | ||
} | ||
|
||
public void Unindent () | ||
{ | ||
level--; | ||
cur_indent = ""; | ||
for (int i = 0; i != level ; i++) cur_indent += Indenter; | ||
} | ||
|
||
public void Write (string text) | ||
{ | ||
w.Write (text); | ||
} | ||
|
||
public void WriteLine (string text) | ||
{ | ||
WriteLine (text, true); | ||
} | ||
|
||
public void WriteLine (string text, bool autoindent) | ||
{ | ||
char[] opentags = {'{', '('}; | ||
char[] closetags = {'}', ')'}; | ||
|
||
if (autoindent && text.TrimStart (closetags) != text) | ||
Unindent (); | ||
|
||
if (!text.StartsWith ("#")) | ||
w.Write (cur_indent); | ||
|
||
w.WriteLine (text); | ||
|
||
if (autoindent && text.TrimEnd (opentags) != text) | ||
Indent (); | ||
} | ||
|
||
public void WriteLine (string text, params CodeWriter[] ccs) | ||
{ | ||
foreach (CodeWriter cc in ccs) | ||
WriteLine (text, "", cc, ""); | ||
} | ||
|
||
public void WriteLine (string text, CodeWriter cc, string suffix) | ||
{ | ||
WriteLine (text, "", cc, suffix); | ||
} | ||
|
||
public void WriteLine (string text, string prefix, CodeWriter cc) | ||
{ | ||
WriteLine (text, prefix, cc, ""); | ||
} | ||
|
||
public void WriteLine (string text, string prefix, CodeWriter cc, string suffix) | ||
{ | ||
WriteLine (text); | ||
cc.WriteLine (prefix + text + suffix); | ||
} | ||
|
||
public void WriteComment (string text) | ||
{ | ||
w.WriteLine ("/* " + text + " */"); | ||
} | ||
|
||
public void WriteLine () | ||
{ | ||
w.WriteLine (""); | ||
} | ||
|
||
public void Close () | ||
{ | ||
w.Flush (); | ||
w.Close (); | ||
} | ||
} | ||
|
Oops, something went wrong.