Beispiel #1
0
//This function adds a Resource Handler for the pages stats.html and formtest.html and associates stats , form and their callback functions
void init_dynamic_content()
{
  indexPage=AmmServer_ReadFileToMemory(indexPagePath,&indexPageLength);
  if (indexPage==0) { AmmServer_Error("Could not find Index Page file %s ",indexPagePath); exit(0); }

  AmmServer_AddResourceHandler(default_server,&screenContext,"screen.jpg",512000,400,&prepare_screen_content_callback,SAME_PAGE_FOR_ALL_CLIENTS);
  AmmServer_AddResourceHandler(default_server,&indexPageContext,"/index.html",4096,0,&prepare_index_content_callback,SAME_PAGE_FOR_ALL_CLIENTS);
  AmmServer_AddResourceHandler(default_server,&commandContext,"/cmd",4096,0,&prepare_command_content_callback,DIFFERENT_PAGE_FOR_EACH_CLIENT);
}
Beispiel #2
0
struct AmmServer_MemoryHandler *  AmmServer_ReadFileToMemoryHandler(const char * filename)
{
  struct AmmServer_MemoryHandler * mh = ( struct AmmServer_MemoryHandler * ) malloc(sizeof(struct AmmServer_MemoryHandler));
  if (mh==0) { return 0; }

   mh->content = AmmServer_ReadFileToMemory(filename,&mh->contentSize);
   mh->contentCurrentLength = mh->contentSize;

   if (mh->content==0)
   {
     free(mh);
     return 0;
   }

   return mh;
}
Beispiel #3
0
int loadPostContent(char * postHeaderFilename,struct post * ourPost)
{
 ourPost->message = AmmServer_ReadFileToMemory(postHeaderFilename,&ourPost->messageSize);
 return 1;
}