void XP_Abort (char * message, ...) { #ifdef DEBUG if (message) XP_Trace (message); BreakToSourceDebugger_ (); #endif }
void npl_ScriptPlugin(MWContext *context, lo_DocState *state, PA_Tag *tag, size_t line_buf_len, char * mimebuf) { char * suffix = NULL; char * fname = NULL; char * embedtagstr = NULL; char * NET_suffix = NULL; PA_Tag * newTag = NULL; NET_StreamClass* viewstream = NULL; URL_Struct* urls = NULL; int streamStatus = 0; int id = 0; if (!context || !state || !tag || (line_buf_len <= 0) || !mimebuf){ XP_Trace("npl_ScriptPlugin: Invalid input(s)."); return; /* no need to goto clean_exit, since havn't alloc'd anything */ } urls = NET_CreateURLStruct("internal_url.", NET_DONT_RELOAD); ALLOC_CHECK(urls,id,abnormal_exit); /* NETLib gives me a pointer here instead of a copy of the string, so I have to make my own, make checks, etc. */ NET_suffix = NET_cinfo_find_ext(mimebuf); if (!NET_suffix) goto abnormal_exit; suffix = PR_smprintf("internal_url.%s", NET_suffix); ALLOC_CHECK(suffix,id,abnormal_exit); XP_FREEIF(urls->address); StrAllocCopy(urls->address , suffix); ALLOC_CHECK(urls->address,id,abnormal_exit); XP_FREEIF(urls->content_name); StrAllocCopy(urls->content_name, suffix); ALLOC_CHECK(urls->content_name,id,abnormal_exit); XP_FREEIF(urls->content_type); StrAllocCopy(urls->content_type, mimebuf); ALLOC_CHECK(urls->content_type,id,abnormal_exit); urls->must_cache = 1; /* ugly flag for mailto and saveas */ viewstream = NET_StreamBuilder(FO_CACHE_ONLY, urls, context); ALLOC_CHECK(viewstream,id,abnormal_exit); streamStatus = (*viewstream->put_block)(viewstream,(CONST char*)state->line_buf, line_buf_len); if (streamStatus <= 0) goto abnormal_exit; (*viewstream->complete)(viewstream); /* Now build internal embed tag pointing to this source: */ fname = WH_FileName(urls->cache_file, xpCache); ALLOC_CHECK(fname,id,abnormal_exit); embedtagstr = PR_smprintf("<EMBED SRC=file:///%s HIDDEN=TRUE>", fname); ALLOC_CHECK(embedtagstr,id,abnormal_exit); newTag = LO_CreateHiddenEmbedTag(tag,embedtagstr); ALLOC_CHECK(newTag,id,abnormal_exit); lo_FormatEmbed(context,state,newTag); goto normal_exit; abnormal_exit: XP_Trace("npl_ScriptPlugin: Abnormal termination, id = %d",id); if (urls) { XP_FREEIF(urls->content_type); XP_FREEIF(urls->content_name); XP_FREEIF(urls->address); XP_FREE( urls); } normal_exit: XP_FREEIF(newTag); XP_FREEIF(embedtagstr); XP_FREEIF(fname); XP_FREEIF(viewstream); XP_FREEIF(suffix); return; }