@Duoas:
If i don't generate a static program the kernel gives this message and halts at the point where it should start my gui (wich is also the init program):
1 2
|
Error: could not start /sbin/init
kernel panic: VFS: init not syncing!
|
With the following program:
1 2 3 4 5 6
|
#include <iostream>
int main()
{
std::cout << "Hello!\n";
}
|
When compiles static it outputs:
1 2 3 4
|
<a lot of messages from the kernel, but all coming down to: "i'm starting up!">
Hello!
Init successfully executed, shutting down...
<a lot of shutdown messages>
|
You see why i need to!?
I know why it's needed, if you don't use static it will ask for shared libs whice aren't there (it's part of the programs task to create them).
@king214:
Your idea was the first thing i tried anyway (i've read so many refrences and tuts since the day i started programming, it must have been in one cause it was my first idea).
Sadly it didn't work, an empty array was transmitted, i've also made this demo code for you (it didn't work either):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
#include <stdio>
void print_array(char *array[], int arrlen)
{
// the (int)(arrlen - 1) is to keep the loop from going once to much
// and causing it to print out an non-existing array value causing an "Segmentation Fault"
for (int i = 0; i < (int)(arrlen - 1)
{
std::cout << "Array value " << (int)(i + 1) << ": " << array[i] << "\n";
}
}
int main(void)
{
char *myarray[] = {"Hello,", "I'm an array which was passed to an function!"};
print_array(myarray, 2);
return 0;
}
|
The code should output this:
1 2
|
Array value 1: Hello,
Array value 2: I'm an array which was passed to an function!
|
But instead it doesn't produce any output!
So i went thinking,
then i had it:
Once i made an webcrawler which uses an array to pass the data to the next function using an scheme like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
page source downloader
| (not an array, an string containing the unmodified page source)
An spacer (an array is passed to the next function containing everything that was seperated using an space, e.g. if the source is Hello World!, it passes an array with the values array[0] = "Hello" and array[1] = "World!")
|
url-filter (this filters every thing other than url's out, meaning it only passes url's found in src/href tags to the next)
|
domain-filter (removes url's pointing to external domains, url's going to an subdomain of the primary domain we're crawling are permitted)
|
image-filter (it removes everything what points to images/movies/any other a/v content)
|
script-filter (this removes any url's to scripts, like the image-filter this wouldn't be needed if i only scanned the href tags, but i need to scan (i)frames to since a lot of sites, including mine, use them)
|
custom-filter (you can set extensions which you don't want)
|
page-filter (is part of the custom filter but this one removes pages containing a string in the name that shouldn't be scanned, e.g. login pages)
|
recent-url-filter (removes url's logged by the follower so it doesn't enter an endless loop)
|
map-builder (put's it all in a nice diagram and outputs it to file, doesn't modify the array of url's)
|
link-follower (follows/logs the urls passed to it and restarts the process)
|
However it didn't work.
So i added a print_array function and set the follower to not follow (so the messages don't disappear in others),
but there was no output (exept for the page source downloader)!
I found out that i can only pass
int
arrays to functions,
just like with my new project i need to pass text (
char *
/
string
arrays.
So i (re-)used my old solution to the problem: first convert the array to an vector before passing it on.
Although you are right about the int array, i need to pass an char * array and that doesn't work.
I use ncurses for the gaphics.
I've build an .h file containing self-written function which make a lot of thing faster,
like when i need to open a window containing a menu i use this function:
1 2 3 4 5 6 7 8
|
// the null at the end is something from ncurses, else it doesn't display a thing
char *choicesa[] = {"a", "b", "c", (char*)NULL,};
// winnum is an int var i use to make sure i don't overwrite anything, and is initialized with val -1 so the first window gets passed 0
winnum++;
// the 1 at the end is an color pair i defined at the init section of the program
// i'm not at home now so i don't have the code i used to convert the array to vector
// there are more options but they are self defining when not passed
show_menu((WINDOW*)win[winnum], x, y, (char*)"Menu Title", choices, 1);
|
and after right use that code (three lines when comments are stripped) produces an window containing this (i use the box function to create a nicer layout, but this is the best i can to represent it):
1 2 3 4 5 6
|
| Menu Title |
+-------------+
| * a |
| b |
| c |
+-------------+
|
I've got compareble functions for other things and tricks
So now you know how my system is constructed (there is of course way more backwork and some extra's).
If you wanna know why i'm doing this:
Just because i can, cause it's a nice challenge and without challanges we wouldn't be learning anything and so i can improve my skills and size up my knowlege.
Greetings