Hello,
I've developed an embedded web-server using "Snorkel API" (http://snorkelembedded.webs.com)
in C++, and generated a QR code based on information submitted from the client (browser).
Now I'm trying to display the dynamic QR code (which is saved in a .jpg file) in the client-browser, but it's not working. The Snorkel embedded web-server is based on defining the HTML code within the C++ code as follows:
#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><img src="QR4.jpg" alt="QR code" width=178 height=178</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");
exit (1);
}
http = snorkel_obj_create (snorkel_obj_server, 2,
NULL );
if (!http)
{
perror ("could not create http server\n");
exit (1);
}
if (snorkel_obj_set (http,
snorkel_attrib_listener,
port,
0 )
!= SNORKEL_SUCCESS)
{
fprintf (stderr, "could not create listener\n");
snorkel_obj_destroy (http);
exit (1);
}
if (snorkel_obj_set (http,
snorkel_attrib_uri,
GET,
"/index.html",
contenttype_text, index_htm) != SNORKEL_SUCCESS)
{
perror ("could not overload index.html");
snorkel_obj_destroy (http);
exit (1);
}
if (snorkel_obj_set(http, snorkel_attrib_ipvers, IPVERS_IPV4, SOCK_SET) != SNORKEL_SUCCESS)
{
fprintf (stderr, "error could not set ip version\n");
exit (1);
}
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);
exit (1);
}
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);
}
I don't know, maybe the problem is within the HTML code i'm writing.
Can some body pleeeeeeease help me, I'm trying to solve this problem for a week now.
Best Regards.
Rania