dvifile::dvifile(const dvifile *old, fontPool *fp) { errorMsg.clear(); errorCounter = 0; page_offset.clear(); suggestedPageSize = 0; numberOfExternalPSFiles = 0; numberOfExternalNONPSFiles = 0; sourceSpecialMarker = old->sourceSpecialMarker; have_complainedAboutMissingPDF2PS = false; dviData = old->dviData; filename = old->filename; size_of_file = old->size_of_file; end_pointer = dvi_Data()+size_of_file; if (dvi_Data() == 0) { kError(kvs::dvi) << "Not enough memory to copy the DVI-file." << endl; return; } font_pool = fp; filename = old->filename; generatorString = old->generatorString; total_pages = old->total_pages; tn_table.clear(); process_preamble(); find_postamble(); read_postamble(); prepare_pages(); }
static void accept_callback(Widget w, XtPointer client_data, XtPointer call_data) { XmFileSelectionBoxCallbackStruct *fcb; struct filesel_callback *callback; UNUSED(w); ASSERT(client_data != NULL, "struct filesel_callback pointer expected in client data"); callback = (struct filesel_callback *)client_data; /* get the filename from the file selection box */ fcb = (XmFileSelectionBoxCallbackStruct *)call_data; if (callback->browse_fname != NULL) { XtFree(callback->browse_fname); callback->browse_fname = NULL; } XmStringGetLtoR(fcb->value, G_charset, &callback->browse_fname); if (0 && callback->must_exist) { FILE *tmp_fp = XFOPEN(callback->browse_fname, "r"); dviErrFlagT errflag = NO_ERROR; if (tmp_fp == NULL) { popup_message(XtParent(callback->shell), MSG_ERR, NULL, "Could not open %s: %s.\n", callback->browse_fname, strerror(errno)); /* leave file selection box open */ return; } else if (!process_preamble(tmp_fp, &errflag) || !find_postamble(tmp_fp, &errflag) || !read_postamble(tmp_fp, &errflag, True #if DELAYED_MKTEXPK , False #endif )) { popup_message(XtParent(callback->shell), MSG_ERR, NULL, "Error opening %s:\n%s.", callback->browse_fname, get_dvi_error(errflag)); fclose(tmp_fp); /* leave file selection box open */ return; } else { /* file is OK */ fclose(tmp_fp); } } /* success; close dialog, and call our callback */ XtUnmanageChild(callback->shell); callback->func_ptr(callback->browse_fname, callback->data); }
dvifile::dvifile(const QString& fname, fontPool* pool) { #ifdef DEBUG_DVIFILE kDebug(kvs::dvi) << "init_dvi_file: " << fname; #endif errorMsg.clear(); errorCounter = 0; page_offset.clear(); suggestedPageSize = 0; numberOfExternalPSFiles = 0; numberOfExternalNONPSFiles = 0; font_pool = pool; sourceSpecialMarker = true; have_complainedAboutMissingPDF2PS = false; QFile file(fname); filename = file.fileName(); file.open( QIODevice::ReadOnly ); size_of_file = file.size(); dviData.resize(size_of_file); // Sets the end pointer for the bigEndianByteReader so that the // whole memory buffer is readable end_pointer = dvi_Data()+size_of_file; if (dvi_Data() == 0) { kError(kvs::dvi) << "Not enough memory to load the DVI-file."; return; } file.read((char *)dvi_Data(), size_of_file); file.close(); if (file.error() != QFile::NoError) { kError(kvs::dvi) << "Could not load the DVI-file."; return; } tn_table.clear(); total_pages = 0; process_preamble(); find_postamble(); read_postamble(); prepare_pages(); return; }
/* * Call this method to actually dissect the multipart body. * NOTE - Only do so if a boundary string has been found! */ static int dissect_multipart(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) { proto_tree *subtree; proto_item *ti; proto_item *type_ti; multipart_info_t *m_info = get_multipart_info(pinfo, (const char*)data); gint header_start = 0; gint body_index = 0; gboolean last_boundary = FALSE; if (m_info == NULL) { /* * We can't get the required multipart information */ proto_tree_add_expert(tree, pinfo, &ei_multipart_no_required_parameter, tvb, 0, -1); call_dissector(data_handle, tvb, pinfo, tree); return tvb_reported_length(tvb); } /* Clean up the memory if an exception is thrown */ /* CLEANUP_PUSH(cleanup_multipart_info, m_info); */ /* Add stuff to the protocol tree */ ti = proto_tree_add_item(tree, proto_multipart, tvb, 0, -1, ENC_NA); subtree = proto_item_add_subtree(ti, ett_multipart); proto_item_append_text(ti, ", Type: %s, Boundary: \"%s\"", m_info->type, m_info->boundary); /* Show multi-part type as a generated field */ type_ti = proto_tree_add_string(subtree, hf_multipart_type, tvb, 0, 0, pinfo->match_string); PROTO_ITEM_SET_GENERATED(type_ti); /* * Make no entries in Protocol column and Info column on summary display, * but stop sub-dissectors from clearing entered text in summary display. */ col_set_fence(pinfo->cinfo, COL_INFO); /* * Process the multipart preamble */ header_start = process_preamble(subtree, tvb, m_info, &last_boundary); if (header_start == -1) { call_dissector(data_handle, tvb, pinfo, subtree); /* Clean up the dynamically allocated memory */ cleanup_multipart_info(m_info); return tvb_reported_length(tvb); } /* * Process the encapsulated bodies */ while (last_boundary == FALSE) { header_start = process_body_part(subtree, tvb, m_info, pinfo, header_start, body_index++, &last_boundary); if (header_start == -1) { /* Clean up the dynamically allocated memory */ cleanup_multipart_info(m_info); return tvb_reported_length(tvb); } } /* * Process the multipart trailer */ if (tvb_reported_length_remaining(tvb, header_start) > 0) { proto_tree_add_item(subtree, hf_multipart_trailer, tvb, header_start, -1, ENC_NA); } /* Clean up the dynamically allocated memory */ cleanup_multipart_info(m_info); return tvb_reported_length(tvb); }