Logo Search packages:      
Sourcecode: rapple version File versions  Download package

rpl_wk_status rpl_mod_parse_process ( rpl_c_str_t  filename,
struct stat  statbuf 
)

Parameters:
filename name of file to be registered.
st_buf stat of file.

Definition at line 70 of file mod_parse.c.

References rpl_fs_f2str(), rpl_fs_resolve_paths(), rpl_fs_str2f(), rpl_log_error(), rpl_log_info(), rpl_me_free(), rpl_me_malloc(), rpl_message_get(), rpl_parse(), rpl_reg_search(), rpl_str_concat(), and rpl_wa_is_transformable().

Referenced by rpl_mod_parse_configure().

{
      rpl_wk_status status = RPL_WK_OK;
      rpl_reg_item item;
      rpl_str_t msg, rdp, fp, key, outfp, ctnt, pctnt;

    assert(filename != NULL);

      msg = rpl_str_concat(rpl_message_get("WK_PROCESSING", RPL_EOM), "parse ", filename, RPL_STR_EOC);
      rpl_log_info(msg);
      rpl_me_free(msg);

      if(S_ISREG(statbuf.st_mode))
      {
            if(rpl_fs_resolve_paths(filename, rpl_parse_base_dir, &rdp, &fp))
                  return RPL_WK_ERR;
            key = rpl_reg_create_key(rdp, fp);

            /* write the parsed file to the appropriate location in the datastore */
            outfp = (rpl_str_t)rpl_me_malloc(strlen(out_dir) + strlen(rdp) + strlen(fp) + 3);
            sprintf(outfp, "%s/%s/%s", out_dir, rdp, fp);

            /* retrieve asset from registry */
            item = rpl_reg_search(key);
            if(item == &RPL_REG_WA_NULL)
            {
                  rpl_log_error(rpl_message_get("REG_ASSET_NOT_FOUND", key, RPL_EOM));
                  return RPL_WK_ERR;
            }
            
      if(rpl_wa_is_transformable(*item))
            {
                  ctnt = rpl_fs_f2str(filename);
                  pctnt = rpl_parse(ctnt);
                  rpl_fs_str2f(pctnt, outfp);
                  /* without the check we can get free junk pointer errors */
                  if(strlen(pctnt) > 0)
                        rpl_me_free(pctnt);
                  rpl_me_free(ctnt);

            } else {
                  rpl_fs_cp(filename, (rpl_c_str_t)outfp);
            }

            if(strlen(rdp) > 0)
                  rpl_me_free(rdp);
            if(strlen(fp) > 0)
                  rpl_me_free(fp);
            rpl_me_free(outfp);
      } 

      return status; 
}


Generated by  Doxygen 1.6.0   Back to index