src/chxj_hdml.c
/**
 * converts from CHTML to hdml.
 *
 * @param r    [i] Requet_rec is appointed.
 * @param spec [i] The result of the device specification processing which 
 *                 was done in advance is appointed.
 * @param src  [i] The character string before the converting is appointed.
 * @return         The character string after the converting is returned.
 */
converts from CHTML to hdml.
@param r    [i] Requet_rec is appointed.
@param spec [i] The result of the device specification processing which
was done in advance is appointed.
@param src  [i] The character string before the converting is appointed.
@return         The character string after the converting is returned.
converts from CHTML to hdml . @param r [ i ] Requet_rec is appointed . @param spec [ i ] The result of the device specification processing which was done in advance is appointed . @param src [ i ] The character string before the converting is appointed . @return The character string after the converting is returned .
char *
chxj_convert_hdml(
  request_rec        *r, 
  device_table       *spec, 
  const char         *src, 
  apr_size_t         srclen, 
  apr_size_t         *dstlen,
  chxjconvrule_entry *entryp,
  cookie_t           *UNUSED(cookie)
)
{
  char      *dst;
  char      *buf;
  Doc       doc;
  hdml_t    hdml;
  dst = NULL;
  buf = NULL;
  *dstlen = srclen;
  dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
  if (dst) {
    DBG(r,"i found qrcode xml");
    return dst;
  }
  DBG(r,"not found qrcode xml");
  s_init_hdml(&hdml,&doc,r, spec);
  hdml.entryp = entryp;
  chxj_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
#ifdef DUMP_LOG
  chxj_dump_out("[src] CHTML->HDML", src, srclen);
#endif
  buf = (char *)apr_table_get(r->headers_out, (const char *)"Location");
  if (buf) {
    DBG(r, "Location is not null[Location:%s]", buf);
    s_output_to_hdml_out(&hdml, 
        "<HDML VERSION=3.0 MARKABLE=TRUE PUBLIC=TRUE>\r\n"
        "<NODISPLAY MARKABLE=TRUE PUBLIC=TRUE TITLE=\" \">\r\n"
        "<ACTION TYPE=ACCEPT TASK=GO DEST=\""
        );
    s_output_to_hdml_out(&hdml, buf);
    s_output_to_hdml_out(&hdml,
        "\">\r\n"
        "</NODISPLAY>\r\n"
        "</HDML>\r\n"
        );
    dst = apr_pstrdup(r->pool, hdml.out);
  }
  else {
    char *ss = apr_palloc(r->pool, srclen + 1);
    memset(ss, 0, srclen + 1);
    memcpy(ss, src, srclen);
    DBG(r, "input strlen(src)=[%d]", (int)srclen);
    DBG(r, "[[[[%s]]]", src);
    qs_init_malloc(&doc); 
    qs_init_root_node(&doc);
    ss[srclen] = '\0';
    qs_parse_string(&doc, ss, srclen);
    s_hdml_count_radio_tag(&hdml, qs_get_root(&doc));
    chxj_node_convert(spec,r,(void*)&hdml, &doc, qs_get_root(&doc), 0);
    dst = hdml.out;
    DBG(r,"tmp=[%s]", dst);
    qs_all_free(&doc,QX_LOGMARK);
  }
#ifdef DUMP_LOG
  chxj_dump_out("[dst] CHTML->HDML", hdml.out, hdml.out_len);
#endif
  if (!dst) {
    *dstlen = srclen;
    return apr_pstrdup(r->pool,src);
  }
  *dstlen = hdml.out_len;
  dst[hdml.out_len] = 0;
  return dst;
}
char * chxj_convert_hdml ( request_rec * r , device_table * spec , const char * src , apr_size_t srclen , apr_size_t * dstlen , chxjconvrule_entry * entryp , cookie_t * UNUSED ( cookie ) ) { char * dst ; char * buf ; Doc doc ; hdml_t hdml ; dst = NULL ; buf = NULL ; * dstlen = srclen ; dst = chxj_qr_code_blob_handler ( r , src , ( size_t * ) dstlen ) ; if ( dst ) { DBG ( r , " " ) ; return dst ; } DBG ( r , " " ) ; s_init_hdml ( & hdml , & doc , r , spec ) ; hdml . entryp = entryp ; chxj_set_content_type ( r , " " ) ; #ifdef DUMP_LOG chxj_dump_out ( " " , src , srclen ) ; #endif buf = ( char * ) apr_table_get ( r -> headers_out , ( const char * ) " " ) ; if ( buf ) { DBG ( r , " " , buf ) ; s_output_to_hdml_out ( & hdml , " \r \n " " \" \" \r \n " " \" " ) ; s_output_to_hdml_out ( & hdml , buf ) ; s_output_to_hdml_out ( & hdml , " \" \r \n " " \r \n " " \r \n " ) ; dst = apr_pstrdup ( r -> pool , hdml . out ) ; } else { char * ss = apr_palloc ( r -> pool , srclen + 1 ) ; memset ( ss , 0 , srclen + 1 ) ; memcpy ( ss , src , srclen ) ; DBG ( r , " " , ( int ) srclen ) ; DBG ( r , " " , src ) ; qs_init_malloc ( & doc ) ; qs_init_root_node ( & doc ) ; ss [ srclen ] = ' \0 ' ; qs_parse_string ( & doc , ss , srclen ) ; s_hdml_count_radio_tag ( & hdml , qs_get_root ( & doc ) ) ; chxj_node_convert ( spec , r , ( void * ) & hdml , & doc , qs_get_root ( & doc ) , 0 ) ; dst = hdml . out ; DBG ( r , " " , dst ) ; qs_all_free ( & doc , QX_LOGMARK ) ; } #ifdef DUMP_LOG chxj_dump_out ( " " , hdml . out , hdml . out_len ) ; #endif if ( ! dst ) { * dstlen = srclen ; return apr_pstrdup ( r -> pool , src ) ; } * dstlen = hdml . out_len ; dst [ hdml . out_len ] = 0 ; return dst ; }
converts from CHTML to hdml.
converts from CHTML to hdml .
/*--------------------------------------------------------------------------*/ /* If qrcode xml                                                            */ /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ /* initialize hdml structure                                                */ /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ /* DEBUG                                                                    */ /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ /* It is examined whether there is a location header. It ends without doing */ /* anything when is.                                                        */ /*--------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ /* The Location header generates tag in an initial HDML machine for the   */ /* uncorrespon dence.                                                     */ /*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ /* Here, the parsing of the received character string is done             */ /*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/ /* The number of radiobuttons is counted.                                 */ /*------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ /* DEBUG                                                                    */ /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ /* When there is no processing result, former character string is copied    */ /* and it returns it.                                                       */ /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ /* Null is set at the end of the character string to make sure.             */ /*--------------------------------------------------------------------------*/