Hey Everyone, I was hoping you could give me a little help here. I am trying to use a helper method I made in a program of mine, and I do not seem to be having any luck. Whenever I do something wrong, I get a "Interrupted System Call" error.
I can't seem to find a clear definition of what this means, but it looks like there is a problem with the way my helper method is called.
Here is how I call it in main()
Code:
getURL(test, toHere); // a little helper method to extract the URL from the string "test"
And here is what the helper method looks like.
Code:
//This method will extract a URL from source and put it in dest
void *getURL(char *source, char *dest) {
// No idea why I have the * in "*getURL()" it just stopped giving me problems w/ it.
printf("Starting void method thing: %s\n", source);
char *origin1;
origin1 = strstr(source, "GET"); // Find the GET http request
origin1 += strlen("GET "); // increment origin1 to the beginning of the URL
int i = 0;
for ( i = 0; i < strlen(origin1); i++) { // starting from origin.. search the whole string
if ( *(origin1+i) == '/' || *(origin1+i) == ' ' )
break; // if you find a '/' or a space, you've reached the end of the URL
}
strncpy(dest, origin1, i); // This line is causing the error!
dest[i] = '\0'; // Incase the last char isn't NULL
puts(dest); // Print for satisfaction :(
}
The line "strncpy(dest,origin1,i);" is the line causing me trouble. I am at a loss here because I am not getting any compilation errors about incorrect parameter types or anything. the int i has the value 15 after the for loop, so that should be fine as well.
I have also used memcpy(&dest, origin1, i); This seemed to work, but I was unable to output dest to sys.out after that
If anyone could help me with this, it would be most appreciated! Even an explanation on "Interrupted system call" would be a great help.