hello,
I've used "snorkel API" to develop an embedded web-server which allows the client to submit some information through a "POST form", and based on this information, a QR code has been generated.
Now the problem is that I cannot display the QR code (Which is saves as .jpg image).
The Snorkel API use provides an HTTP based UI to manage the service that I'm trying to provide. (it provides an HTTP based UI as the primary end-user interface).
So, whenever I run my C++ embedded web-server (snorkel), I open the internet explorer and write http://localhost:80 to get the end-user interface.
Everything is working just fine, except for displaying the image, which i think is a programming mistake, which i cannot find.
Here is the code, if someone can help, I'd really appreciate it:
#pragma hdrstop
#pragma argsused
#include <snorkel.h>
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>
call_status_t index_htm(snorkel_obj_t http,
snorkel_obj_t outstream)
{
if (snorkel_printf (outstream, "<html><body><h2><img src=<c:\users\rania\documents\snorkel> width=178 height=178"
"</h2></body></html>\r\n")== SNORKEL_ERROR)
return HTTP_ERROR;
return HTTP_SUCCESS;
}
void syntax (char *pszProg)
{
fprintf (stderr, "syntax error:\n");
fprintf (stderr, "%s [-p <port>]\n", pszProg);
exit (1);
}
void main (int argc, char *argv[])
{
int i = 1;
int port = 80;
snorkel_obj_t http = 0;
char szExit[10];
for (; i < argc; i++)
{
if (argv[i][0] == '-' || argv[i][0] == '/')
{
char carg = argv[i][1];
switch (carg)
{
case 'p':
port = atoi (argv[i + 1]);
i++;
break;
default:
syntax (argv[0]);
break;
}
}
}
if (snorkel_init () != SNORKEL_SUCCESS)
{
perror ("could not initialize snorkel\n");
}
http = snorkel_obj_create (snorkel_obj_server, 2,
"/Users/rania/Documents/Snorkel PRACTICE" );
if (!http)
{
perror ("could not create http server\n");
}
if (snorkel_obj_set (http,
snorkel_attrib_listener,
port,
0 )
!= SNORKEL_SUCCESS)
{
fprintf (stderr, "could not create listener\n");
snorkel_obj_destroy (http);
}
if (snorkel_obj_set (http,
snorkel_attrib_uri,
GET,
"/index.html",
contenttype_binary, index_htm) != SNORKEL_SUCCESS)
{
perror ("could not overload index.html");
snorkel_obj_destroy (http);
}
if (snorkel_obj_set(http, snorkel_attrib_ipvers, IPVERS_IPV4, SOCK_SET) != SNORKEL_SUCCESS)
{
fprintf (stderr, "error could not set ip version\n");
}
fprintf (stderr, "\n\n[HTTP] starting embedded server\n");
if (snorkel_obj_start (http) != SNORKEL_SUCCESS)
{
perror ("could not start server\n");
snorkel_obj_destroy (http);
}
fprintf (stderr, "\n[HTTP] started.\n\n"
"--hit enter to terminate--\n");
fgets (szExit, sizeof (szExit), stdin);
fprintf (stderr, "[HTTP] bye\n");
snorkel_obj_destroy (http);
exit (0);
}
Please, need your help.
Best Regards.