Esempio n. 1
0
/*
 * This program writes all the files from a jarfile to stdout and inflates
 * where needed.
 */
int main(int argc, char *argv[])
{
    gchar *filename;
    if (argc < 2) {
	filename = "./ide.jar\0";
    } else {
	filename = argv[1];
    }

    Inkjar::JarFileReader jar_file_reader(filename);
    
    for (;;) {
	GByteArray *gba = jar_file_reader.get_next_file();
	if (gba == NULL) {
	    char *c_ptr;
	    gchar *last_filename = jar_file_reader.get_last_filename();
	    if (last_filename == NULL)
		break;
	    if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) {
		if (*(++c_ptr) == '\0') {
		    g_free(last_filename);
		    continue;
		}
	    }
	} else if (gba->len > 0)
	    ::write(1, gba->data, gba->len);
	else
	    break;
    }
    return 0;
}
Esempio n. 2
0
int main (int argc, const char **argv)
{
    if (argc == 1) {
        usage();
    }

    // Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example)
    Gtk::Main::init_gtkmm_internals();

    Gtk::Main main_instance (&argc, const_cast<char ***>(&argv));

    struct SPSlideShow ss;

    int num_parsed_options = 0;

    // the list of arguments is in the net line
    for (int i = 1; i < argc; i++) {
        if ((argv[i][0] == '-')) {
            if (!strcmp(argv[i], "--")) {
                break;
            }
            else if ((!strcmp(argv[i], "-t"))) {
                if (i + 1 >= argc) {
                    usage();
                }
                ss.timer = atoi(argv[i+1]);
                num_parsed_options = i+1;
                i++;
            }
            else {
                usage();
            }
        }
    }

    GtkWidget *w;
    int i;

    bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    LIBXML_TEST_VERSION

    Inkscape::GC::init();
    Inkscape::Preferences::get(); // ensure preferences are initialized

    gtk_init (&argc, (char ***) &argv);

#ifdef lalaWITH_MODULES
    g_warning ("Have to autoinit modules (lauris)");
    sp_modulesys_init();
#endif /* WITH_MODULES */

    /* We must set LC_NUMERIC to default, or otherwise */
    /* we'll end with localised SVG files :-( */

    setlocale (LC_NUMERIC, "C");

    ss.size = 32;
    ss.length = 0;
    ss.current = 0;
    ss.slides = g_new (char *, ss.size);
    ss.current = 0;
    ss.doc = NULL;
    ss.view = NULL;
    ss.fullscreen = false;

    Inkscape::Application::create(argv[0], true);
    //Inkscape::Application &inkscape = Inkscape::Application::instance();

    // starting at where the commandline options stopped parsing because
    // we want all the files to be in the list
    for (i = num_parsed_options + 1 ; i < argc; i++) {
        struct stat st;
        if (stat (argv[i], &st)
              || !S_ISREG (st.st_mode)
              || (st.st_size < 64)) {
            fprintf(stderr, "could not open file %s\n", argv[i]);
        } else {

    #ifdef WITH_INKJAR
            if (is_jar(argv[i])) {
                Inkjar::JarFileReader jar_file_reader(argv[i]);
                for (;;) {
                    GByteArray *gba = jar_file_reader.get_next_file();
                    if (gba == NULL) {
                        char *c_ptr;
                        gchar *last_filename = jar_file_reader.get_last_filename();
                        if (last_filename == NULL)
                            break;
                        if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) {
                            if (*(++c_ptr) == '\0') {
                                g_free(last_filename);
                                continue;
                            }
                        }
                    } else if (gba->len > 0) {
                        //::write(1, gba->data, gba->len);
                        /* Append to list */
                        if (ss.length >= ss.size) {
                            /* Expand */
                            ss.size <<= 1;
                            ss.slides = g_renew (char *, ss.slides, ss.size);
                        }

                        ss.doc = SPDocument::createNewDocFromMem ((const gchar *)gba->data,
                                           gba->len,
                                           TRUE);
                        gchar *last_filename = jar_file_reader.get_last_filename();
                        if (ss.doc) {
                            ss.slides[ss.length++] = strdup (last_filename);
                            (ss.doc)->setUri (last_filename);
                        }
                        g_byte_array_free(gba, TRUE);
                        g_free(last_filename);
                    } else {
                        break;
                    }
                }
            } else {
    #endif /* WITH_INKJAR */
            /* Append to list */
            if (ss.length >= ss.size) {