コード例 #1
0
//This overrides serves back the captcha using AmmCaptch!
void * serve_captcha_page(struct AmmServer_DynamicRequest  * rqst)
{
  #if ENABLE_CAPTCHA_SYSTEM
  char captchaIDStr[MAX_LONG_URL_SIZE]={0};
  if ( _GET(myurl_server,rqst,"id",captchaIDStr,MAX_LONG_URL_SIZE) ) { fprintf(stderr,"Captcha ID for image requested %s \n",captchaIDStr); }
  unsigned int captchaID = atoi(captchaIDStr);

  rqst->contentSize=rqst->MAXcontentSize;
  AmmCaptcha_getCaptchaFrame(captchaID,rqst->content,&rqst->contentSize);
  #endif
  return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: bstrds/AmmarServer
int AmmCaptcha_copyCaptchaJPEGImageWithCopy(unsigned int captchaID, char *mem,unsigned long * mem_size)
{
  unsigned long frameLength = *mem_size; //10KB more than enough
  char * captchaFrame = (char *) malloc(sizeof(char) * frameLength);
  if (captchaFrame!=0)
  {
   AmmCaptcha_getCaptchaFrame(captchaID,captchaFrame,&frameLength);
   fprintf(stderr,"Copying back %lu bytes of captcha.jpg\n",frameLength);
   memcpy(mem,captchaFrame,sizeof(char) * frameLength);
   fprintf(stderr,"Survived , marking frameLength as %lu \n",frameLength);
   *mem_size=frameLength;
   free(captchaFrame);
  } else
  {
   fprintf(stderr,"Could not allocate frame for captcha image ( size %lu ) \n",frameLength);
  }
}