aibika 1.3.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'mime/types'
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'pg'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'prawn'
4
+ exit if defined?(Aibika)
5
+ Prawn::Document.generate('prawn_sample.pdf') do
6
+ text 'Hello, World!'
7
+ font.instance_eval { find_font('Helvetica.afm') } or raise
8
+ end
9
+ File.unlink('prawn_sample.pdf')
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ exit if defined?(Aibika)
4
+ $stdin.readchar
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ gem 'sys-proctable'
5
+ require 'sys/proctable'
6
+ require 'time'
7
+ include Sys
8
+
9
+ # Everything
10
+ ProcTable.ps do |p|
11
+ puts "#{p.pid} #{p.comm}"
12
+ end
data/samples/tk.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tk'
4
+ root = TkRoot.new { title 'Hello, World!' }
5
+ TkLabel.new(root) do
6
+ text 'Hello, World!'
7
+ pack do
8
+ padx 15
9
+ pady 15
10
+ side 'left'
11
+ end
12
+ end
13
+ Tk.mainloop
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tk'
4
+ require 'tkextlib'
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'watir'
5
+ exit if defined?(Aibika)
6
+
7
+ test_site = 'http://www.google.com'
8
+
9
+ ie = Watir::IE.new
10
+
11
+ puts 'Beginning of test: Google search.'
12
+ puts " Step 1: go to the test site: #{test_site}"
13
+ ie.goto test_site
14
+
15
+ puts " Step 2: enter 'pickaxe' in the search text field."
16
+ ie.text_field(:name, 'q').set 'pickaxe' # "q" is the name of the search field
17
+
18
+ puts " Step 3: click the 'Google Search' button."
19
+ ie.button(:name, 'btnG').click # "btnG" is the name of the Search button
20
+
21
+ puts ' Expected Result:'
22
+ puts " A Google page with results should be shown. 'Programming Ruby' should be high on the list."
23
+
24
+ puts ' Actual Result:'
25
+ if ie.text.include? 'Programming Ruby'
26
+ puts " Test Passed. Found the test string: 'Programming Ruby'. Actual Results match Expected Results."
27
+ else
28
+ puts " Test Failed! Could not find: 'Programming Ruby'."
29
+ end
30
+
31
+ ie.close
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'win32/api'
4
+ exit if defined?(Aibika)
5
+ Win32::API.new('MessageBox', 'LPPI', 'I', 'user32').call(0, 'Hello, World!', 'Greeting', 0)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'win32ole'
4
+ WIN32OLE.new('Wscript.Shell')
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'wx'
5
+
6
+ # Main window frame with a button.
7
+ class MyMainWindow < Wx::Frame
8
+ MY_BUTTON_ID = 1001
9
+ def initialize
10
+ super(nil, -1, 'AIBIKA wxWidgets sample application')
11
+ @button = Wx::Button.new(self, MY_BUTTON_ID, 'AIBIKA Sample')
12
+ evt_button(MY_BUTTON_ID) { close }
13
+ end
14
+ end
15
+
16
+ # The sample application.
17
+ class MyApp < Wx::App
18
+ def on_init
19
+ @frame = MyMainWindow.new
20
+ @frame.show
21
+ end
22
+ end
23
+
24
+ # Create MyApp
25
+ app = MyApp.new
26
+
27
+ # Run MyApp (unless Aibika is currently defined, and we are compiling
28
+ # the application).
29
+ app.main_loop unless defined?(Aibika)
Binary file
data/src/Makefile ADDED
@@ -0,0 +1,37 @@
1
+ SRCS = lzma/LzmaDec.c
2
+ OBJS = $(SRCS:.c=.o) stubicon.o
3
+ CC = gcc
4
+ BINDIR = $(CURDIR)/../share/aibika
5
+
6
+ CFLAGS = -Wall -O2 -DWITH_LZMA -Ilzma -s
7
+ STUB_CFLAGS = -D_CONSOLE $(CFLAGS)
8
+ STUBW_CFLAGS = -mwindows $(CFLAGS)
9
+ # -D_MBCS
10
+
11
+ all: stub.exe stubw.exe edicon.exe
12
+
13
+ stubicon.o: stub.rc
14
+ windres -i $< -o $@
15
+
16
+ stub.exe: $(OBJS) stub.o
17
+ $(CC) $(STUB_CFLAGS) $(OBJS) stub.o -o stub
18
+
19
+ stubw.exe: $(OBJS) stubw.o
20
+ $(CC) $(STUBW_CFLAGS) $(OBJS) stubw.o -o stubw
21
+
22
+ edicon.exe: edicon.o
23
+ $(CC) $(CFLAGS) edicon.o -o edicon
24
+
25
+ stub.o: stub.c
26
+ $(CC) $(STUB_CFLAGS) -o $@ -c $<
27
+
28
+ stubw.o: stub.c
29
+ $(CC) $(STUBW_CFLAGS) -o $@ -c $<
30
+
31
+ clean:
32
+ rm -f $(OBJS) stub.exe stubw.exe edicon.exe edicon.o stubw.o stub.o
33
+
34
+ install: stub.exe stubw.exe edicon.exe
35
+ cp -f stub.exe $(BINDIR)/stub.exe
36
+ cp -f stubw.exe $(BINDIR)/stubw.exe
37
+ cp -f edicon.exe $(BINDIR)/edicon.exe
data/src/edicon.c ADDED
@@ -0,0 +1,146 @@
1
+ /**
2
+ Changes the Icon in a PE executable.
3
+ */
4
+
5
+ #include <windows.h>
6
+ #include <stdio.h>
7
+
8
+ #pragma pack(push, 2)
9
+
10
+ /* Icon file header */
11
+ typedef struct
12
+ {
13
+ WORD Reserved;
14
+ WORD ResourceType;
15
+ WORD ImageCount;
16
+ } IconFileHeader;
17
+
18
+ /* Icon File directory entry structure */
19
+ typedef struct
20
+ {
21
+ BYTE Width;
22
+ BYTE Height;
23
+ BYTE Colors;
24
+ BYTE Reserved;
25
+ WORD Planes;
26
+ WORD BitsPerPixel;
27
+ DWORD ImageSize;
28
+ DWORD ImageOffset;
29
+ } IconDirectoryEntry;
30
+
31
+ /* Group Icon Resource directory entry structure */
32
+ typedef struct
33
+ {
34
+ BYTE Width;
35
+ BYTE Height;
36
+ BYTE Colors;
37
+ BYTE Reserved;
38
+ WORD Planes;
39
+ WORD BitsPerPixel;
40
+ DWORD ImageSize;
41
+ WORD ResourceID;
42
+ } IconDirResEntry, *PIconDirResEntry;
43
+
44
+ /* Group Icon Structore (RT_GROUP_ICON) */
45
+ typedef struct
46
+ {
47
+ WORD Reserved;
48
+ WORD ResourceType;
49
+ WORD ImageCount;
50
+ IconDirResEntry Enries[0]; /* Number of these is in ImageCount */
51
+ } GroupIcon;
52
+
53
+ #pragma pack(pop)
54
+
55
+ BOOL UpdateIcon(LPTSTR ExecutableFileName, LPTSTR IconFileName)
56
+ {
57
+ HANDLE h = BeginUpdateResource(ExecutableFileName, FALSE);
58
+ if (h == INVALID_HANDLE_VALUE)
59
+ {
60
+ printf("Failed to BeginUpdateResource\n");
61
+ return FALSE;
62
+ }
63
+
64
+ /* Read the Icon file */
65
+ HANDLE hIconFile = CreateFile(IconFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
66
+ if (hIconFile == INVALID_HANDLE_VALUE)
67
+ {
68
+ fprintf(stderr, "Failed to open icon file.\n");
69
+ return FALSE;
70
+ }
71
+ DWORD Size = GetFileSize(hIconFile, NULL);
72
+ BYTE* Data = LocalAlloc(LMEM_FIXED, Size);
73
+ DWORD BytesRead;
74
+ if (!ReadFile(hIconFile, Data, Size, &BytesRead, NULL))
75
+ {
76
+ fprintf(stderr, "Failed to read icon file.\n");
77
+ return FALSE;
78
+ }
79
+ CloseHandle(hIconFile);
80
+
81
+ IconFileHeader* header = (IconFileHeader*)Data;
82
+ IconDirectoryEntry* entries = (IconDirectoryEntry*)(header + 1);
83
+
84
+ /* Create the RT_ICON resources */
85
+ int i;
86
+ for (i = 0; i < header->ImageCount; ++i)
87
+ {
88
+ BOOL b = UpdateResource(h, MAKEINTRESOURCE(RT_ICON), MAKEINTRESOURCE(101 + i), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), Data + entries[i].ImageOffset, entries[i].ImageSize);
89
+ if (!b)
90
+ {
91
+ fprintf(stderr, "failed to UpdateResource %lu\n", GetLastError());
92
+ return FALSE;
93
+ }
94
+ }
95
+
96
+ /* Create the RT_GROUP_ICON structure */
97
+ DWORD GroupIconSize = sizeof(GroupIcon) + header->ImageCount * sizeof(IconDirectoryEntry);
98
+ GroupIcon* gi = (GroupIcon*)LocalAlloc(LMEM_FIXED, GroupIconSize);
99
+ gi->Reserved = 0;
100
+ gi->ResourceType = header->ResourceType;
101
+ gi->ImageCount = header->ImageCount;
102
+ for (i = 0; i < header->ImageCount; ++i)
103
+ {
104
+ IconDirResEntry* e = &gi->Enries[i];
105
+ e->Width = entries[i].Width;
106
+ e->Height = entries[i].Height;
107
+ e->Colors = entries[i].Colors;
108
+ e->Reserved = entries[i].Reserved;
109
+ e->Planes = entries[i].Planes;
110
+ e->BitsPerPixel = entries[i].BitsPerPixel;
111
+ e->ImageSize = entries[i].ImageSize;
112
+ e->ResourceID = 101 + i;
113
+ }
114
+
115
+ /* Save the RT_GROUP_ICON resource */
116
+ BOOL b = UpdateResource(h, MAKEINTRESOURCE(RT_GROUP_ICON), MAKEINTRESOURCE(100), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), gi, GroupIconSize);
117
+ if (!b)
118
+ {
119
+ fprintf(stderr, "Failed to create group icon.\n");
120
+ return FALSE;
121
+ }
122
+
123
+ if (!EndUpdateResource(h, FALSE))
124
+ {
125
+ fprintf(stderr, "Failed to EndUpdateResource.\n");
126
+ return FALSE;
127
+ }
128
+
129
+ return TRUE;
130
+ }
131
+
132
+ int main(int argc, char* argv[])
133
+ {
134
+ if (argc == 3)
135
+ {
136
+ if (UpdateIcon(argv[1], argv[2]))
137
+ return 0;
138
+ else
139
+ return -1;
140
+ }
141
+ else
142
+ {
143
+ fprintf(stderr, "Usage: edicon.exe <exefile> <icofile>\n");
144
+ return -1;
145
+ }
146
+ }