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

rpl_wk_status rpl_mod_db_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 75 of file mod_db.c.

References rpl_db_escape_string(), rpl_db_query(), rpl_fs_resolve_paths(), rpl_log_info(), rpl_me_free(), rpl_me_malloc(), rpl_message_get(), rpl_reg_search(), rpl_str_concat(), rpl_wa_get_contributor(), rpl_wa_get_filename(), rpl_wa_get_mime_type(), rpl_wa_get_rel_dir(), rpl_wa_get_tidy_stat_desc(), and rpl_wa_get_tmpl_stat_desc().

Referenced by rpl_mod_db_configure().

{
      rpl_wk_status status = RPL_WK_OK;
#ifdef HAVE_MYSQL
      rpl_str_t msg, parsed_query, mime_type, fn, rdp, fp, key;
      rpl_reg_item item;
      int length;

    assert((filename != NULL) && (statbuf != NULL));

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

      if(S_ISREG(statbuf.st_mode))
      {
            /* extract key information */
            if(rpl_fs_resolve_paths(filename, rpl_db_base_dir, &rdp, &fp))
                  return RPL_WK_ERR;
            key = rpl_reg_create_key(rdp, fp);

            /* search for asset in registry and audit meta-data */            
            item = rpl_reg_search(key);   

            length = strlen((rpl_c_str_t)rpl_wa_get_filename(*item)) 
                              + strlen((rpl_c_str_t)rpl_wa_get_rel_dir(*item)) 
                              + strlen((rpl_c_str_t)rpl_wa_get_mime_type(*item)) 
                              + strlen((rpl_c_str_t)rpl_wa_get_contributor(*item)) 
                              + strlen((rpl_c_str_t)rpl_wa_get_tidy_stat_desc(*item)) 
                              + strlen((rpl_c_str_t)rpl_wa_get_tmpl_stat_desc(*item)) 
                              + strlen(webassets_insert) 
                              + 20;
            parsed_query = (rpl_str_t)rpl_me_malloc(length);
            sprintf(parsed_query, webassets_insert,
                        rpl_db_escape_string(rpl_wa_get_filename(*item)),
                        rpl_db_escape_string(rpl_wa_get_rel_dir(*item)),
                        rpl_db_escape_string(rpl_wa_get_contributor(*item)),
                        rpl_db_escape_string(rpl_wa_get_mime_type(*item)),
                        rpl_db_escape_string(rpl_wa_get_tidy_stat_desc(*item)),
                        rpl_db_escape_string(rpl_wa_get_tmpl_stat_desc(*item)));

            rpl_db_query(parsed_query);   
            rpl_me_free(parsed_query);
      } 
#endif

      return status; 
}


Generated by  Doxygen 1.6.0   Back to index