Exemple #1
0
/* Resets all unsaved compile related options */
int reset_unsaved_compile(select_menu *menu,void *arg)
{
	select_menu *current;
	select_item *it;

	current=find_menu(CONF_EXCLUDED_MODS,main_menu);
	for (it=current->item_list;it;it=it->next)
		it->enabled=it->prev_state;
	current->child_changed=CHILD_NO_CHANGES;

	current=find_menu(CONF_COMPILE_FLAGS,main_menu);
	for (it=current->item_list;it;it=it->next)
		it->enabled=it->prev_state;
	current->child_changed=CHILD_NO_CHANGES;

	current=find_menu(CONF_INSTALL_PREFIX,main_menu);
	if (install_prefix != prev_prefix) {
		if (install_prefix) {
			free(install_prefix);
			install_prefix=NULL;
		}
		install_prefix=prev_prefix;
	}
	current->child_changed=CHILD_NO_CHANGES;

	
	print_notice(NOTICE_Y,NOTICE_X,1,"Changes have been reset. Press any key to continue");

	return 0;
}
Exemple #2
0
int parse_make_conf()
{
	enum dep_states state;
	FILE *conf = fopen(MAKE_CONF_FILE,"r");
	char *p;
	int defs=0;

	if (!conf) {
		/* if we cannot find the Makefile.conf, try the template */
		conf = fopen(MAKE_TEMP_FILE, "r");
		if (!conf) {
			fprintf(output,"Failed to open [%s]\n",MAKE_TEMP_FILE);
			return -1;
		}
	}
	state = PARSE_DEPENDENCIES;

	while ( fgets ( read_buf, READ_BUF_SIZE, conf ) != NULL ) {
		p = read_buf;
		if (*p=='\n') {
			if (state == PARSE_COMPILE_DEFS && defs==1)
				state=PARSE_PREFIX;
			continue;
		}

		switch ((unsigned char)state) {
			case PARSE_DEPENDENCIES:
				if (*p == '#') {
					if (parse_dep_line(p,find_menu(CONF_EXCLUDED_MODS,main_menu)) < 0) {
						fprintf(output,"Failed to parse dep line [%s]\n",p);
					}
				} else if (*p == 'e') {
					state = PARSE_INCLUDE_MODULES;
				}
				break;
			case PARSE_INCLUDE_MODULES:
				if (parse_include_line(p,find_menu(CONF_EXCLUDED_MODS,main_menu)) < 0) {
					fprintf(output,"Failed to parse include line [%s]\n",p);
				}
				state = PARSE_COMPILE_DEFS;
				break;
			case PARSE_COMPILE_DEFS:
				if (parse_defs_line(p,find_menu(CONF_COMPILE_FLAGS,main_menu)) < 0) {
					fprintf(output,"Failed to parse compile defs [%s]\n",p);
				}
				defs=1;
				break;
			case PARSE_PREFIX:
				if (parse_prefix_line(p,find_menu(CONF_INSTALL_PREFIX,main_menu)) < 0) {
					fprintf(output,"Failed to parse prefix line [%s]\n",p);
				}
				break;
		}
	}

	fclose(conf);
	return 0;
}
Exemple #3
0
void addto_menu(char men[], char item[], char comm[])
/* Adds an item to a menu */
{
  int n = find_menu(men);
  if (n<0) { create_menu(men); n = find_menu(men); }
  if (menus[n].numb == 9) return;
  strcpy(menus[n].iname[menus[n].numb],item);
  strcpy(menus[n].icommand[menus[n].numb],comm);
  menus[n].numb++;
}
Exemple #4
0
/* Will globally save everything the user has altered */
int save_all_changes(select_menu *menu,void *arg)
{
	static char name_buf[128];
	select_menu *current;
	cfg_gen_t *it;
	
#if MENUCONFIG_HAVE_SOURCES > 0
	/* Take care of compile related options */	
	if (dump_make_conf(menu,arg) < 0)
		fprintf(output,"Failed to save all compile related options\n");
#else
	if (run_locally && dump_make_conf(menu,arg) < 0)
		fprintf(output,"Failed to save all compile related options\n");
#endif

	/* Save changes to all types of configs */
	for (it=configs;it->name;it++) {
		strcpy(name_buf,"Save ");
		strcat(name_buf,it->name);
		current=find_menu(name_buf,main_menu);
		if (save_m4_def(current,NULL) < 0) 
			fprintf(output,"Failed to save cfg %s\n",it->name);
	}

	return 0;
}
Exemple #5
0
void push_menu(const char nnn[])
/* Pushes a menu to be visible */
{
  int n,i,bn;
  int men = find_menu(nnn);
  if (men < 0) return;
  n = menus[men].numb;
  for (i=0; i<9; i++) but[i]->hide();
  for (i=0; i<n; i++)
  {
    bn = numb2but(i,n-1);
    but[bn]->show();
    but[bn]->label(menus[men].iname[i]);
  }
  strcpy(stack[stsize],nnn);
  stsize++;
}
Exemple #6
0
Inkscape::XML::Node *
Effect::find_menu (Inkscape::XML::Node * menustruct, const gchar *name)
{
    if (menustruct == NULL) return NULL;
    for (Inkscape::XML::Node * child = menustruct;
            child != NULL;
            child = child->next()) {
        if (!strcmp(child->name(), name)) {
            return child;
        }
        Inkscape::XML::Node * firstchild = child->firstChild();
        if (firstchild != NULL) {
            Inkscape::XML::Node *found = find_menu (firstchild, name);
            if (found)
                return found;
        }
    }
    return NULL;
}
Exemple #7
0
/* Save all related compile options to Makefile.conf*/
int dump_make_conf(select_menu *menu,void *arg)
{
	select_menu *current;
	select_item *it;
	int i,k=0;

	FILE *f = fopen(MAKE_CONF_FILE,"w");

	/* START compile MODULES related options */
	current = find_menu(CONF_EXCLUDED_MODS,main_menu);
	for (it=current->item_list;it;it=it->next) {
		for (i=0;i<it->dependency_no;i++) {
			if (i==0)
				fprintf(f,"#%s=%s|%s\n",it->name,it->description,it->dependency[i]);
			else
				fprintf(f,"#%s=%s\n",it->name,it->dependency[i]);
			if (it->enabled) {
				print_notice(NOTICE_Y+k++,NOTICE_X,0,
					"You have enabled the '%s' module, so please install '%s'\n",
					it->name,it->dependency[i]);
			}
		}
		it->prev_state=it->enabled;
	}

	print_notice(NOTICE_Y+k,NOTICE_X,1,"Press any key to continue\n");

	fprintf(f,"\nexclude_modules?= ");
	for (it=current->item_list;it;it=it->next) {
		fprintf(f,"%s ",it->name);
	}

	fprintf(f,"\n\ninclude_modules?= ");
	for (it=current->item_list;it;it=it->next) {
		if (it->enabled)
			fprintf(f,"%s ",it->name);
	}

	current->child_changed=CHILD_NO_CHANGES;
	/* END compile MODULES related options */
	fprintf(f,"\n\n");

	/* START compile DEFS related options */
	current = find_menu(CONF_COMPILE_FLAGS,main_menu);
	for (it=current->item_list;it;it=it->next) {
		fprintf(f,"%sDEFS+= -D%s #%s",
			it->enabled?"":"#",it->name,it->description);
		if (strcmp(it->name,"USE_TLS") == 0 && it->enabled)
			fprintf(f,"TLS=1\n");
		else if (strcmp(it->name,"USE_SCTP") == 0 && it->enabled)
			fprintf(f,"SCTP=1\n");
		it->prev_state=it->enabled;
	}

	current->child_changed=CHILD_NO_CHANGES;
	/* END compile DEFS related options */
	
	/* START install prefix related options */
	current=find_menu(CONF_INSTALL_PREFIX,main_menu);
	fprintf(f,"\nPREFIX=%s",install_prefix?install_prefix:DEFAULT_INSTALL_PREFIX);
	
	prev_prefix=install_prefix;
	current->child_changed=CHILD_NO_CHANGES;
	/* END install prefix related options */

	fclose(f);
	return 0;
}
Exemple #8
0
/* Runs 'make install' */
int run_make_install(select_menu *menu,void *arg)
{
	int ret=0,status;
	select_menu *current;
	select_item *it;
	
	/* save current tty modes */
	def_prog_mode();
	/* restore original tty modes */
	endwin();

	/* temporarily ignore SIGINT 
	 * in case child is killed, we do not want to also exit main app
	 */
	signal(SIGINT, SIG_IGN);
	ret=fork();
	if (ret<0) {
		fprintf(output,"Failed to fork process\n");
		goto end;
	}
	if (ret > 0) {
		/* parent */
		wait(&status);
		if (status != 0) {
			fprintf(output,"Command failed to execute properly\n");
			goto end;
		}
	} else {
		/* child */
		/* Do not propagate SIGINT to parent
		   but propagate SIGWINCH to adjust
		window size */
		signal(SIGINT, SIG_DFL);
		/* check if TLS or SCTP, set env vars */
		current = find_menu(CONF_COMPILE_FLAGS,main_menu);
		for (it=current->item_list;it;it=it->next) {
			if (memcmp(it->name,"USE_TLS",7) == 0 &&
					it->enabled == 1) {
				setenv("TLS", "1", 1);
				continue;
			}
			if (memcmp(it->name,"USE_SCTP",8) == 0 &&
					it->enabled == 1) {
				setenv("SCTP", "1", 1);
				continue;
			}
		}

		execlp("make","make","install",(char *)0);
		exit(-1);
	}

end:
	/* Restore SIGINT handler */
	signal(SIGINT,_quit_handler);	
	printf("\n\nPress any key to return to menuconfig\n\n");
	getch();

	/* restore save modes, repaint screen */
	refresh();
	return ret;
}
Exemple #9
0
/* Save all related compile options to Makefile.conf*/
int dump_make_conf(select_menu *menu,void *arg)
{
	select_menu *current;
	select_item *it;
	int i,k=0;
	int start_grp=0, prev_grp=0;

	FILE *f = fopen(MAKE_CONF_FILE,"w");
	if (!f) {
		fprintf(stderr,"Failed to open [%s]\n",MAKE_CONF_FILE);
		return -1;
	}

	/* START compile MODULES related options */
	current = find_menu(CONF_EXCLUDED_MODS,main_menu);
	for (it=current->item_list;it;it=it->next) {
		for (i=0;i<it->dependency_no;i++) {
			if (i==0)
				fprintf(f,"#%s=%s|%s\n",it->name,it->description,it->dependency[i]);
			else
				fprintf(f,"#%s=%s\n",it->name,it->dependency[i]);
			if (it->enabled) {
				print_notice(NOTICE_Y+k++,NOTICE_X,0,
					"You have enabled the '%s' module, so please install '%s'\n",
					it->name,it->dependency[i]);
			}
		}
		it->prev_state=it->enabled;
	}

	print_notice(NOTICE_Y+k,NOTICE_X,1,"Press any key to continue\n");

	fprintf(f,"\nexclude_modules?= ");
	for (it=current->item_list;it;it=it->next) {
		fprintf(f,"%s ",it->name);
	}

	fprintf(f,"\n\ninclude_modules?= ");
	for (it=current->item_list;it;it=it->next) {
		if (it->enabled)
			fprintf(f,"%s ",it->name);
	}

	current->child_changed=CHILD_NO_CHANGES;
	/* END compile MODULES related options */
	fprintf(f,"\n\n");

	/* START compile DEFS related options */
	current = find_menu(CONF_COMPILE_FLAGS,main_menu);
	for (it=current->item_list;it;it=it->next) {
		if (it->group_idx && !start_grp) {
			start_grp = 1;
			prev_grp = it->group_idx>0 ? it->group_idx : -it->group_idx;
			fprintf(f, "%s\n", GRP_START_STR);
		}
		if (start_grp)
			if ((it->group_idx>0 && (it->group_idx != prev_grp)) ||
				(it->group_idx<0 && (-it->group_idx != prev_grp)) ||
				it->group_idx==0) {
				start_grp = 0;
				fprintf(f, "%s\n", GRP_END_STR);
			}

		fprintf(f,"%sDEFS+= -D%s #%s",
			it->enabled?"":"#",it->name,it->description);
		it->prev_state=it->enabled;
	}

	if (!it && start_grp)
		fprintf(f, "%s\n", GRP_END_STR);

	current->child_changed=CHILD_NO_CHANGES;
	/* END compile DEFS related options */

	/* START install prefix related options */
	current=find_menu(CONF_INSTALL_PREFIX,main_menu);
	fprintf(f,"\nPREFIX=%s",install_prefix?install_prefix:DEFAULT_INSTALL_PREFIX);

	prev_prefix=install_prefix;
	current->child_changed=CHILD_NO_CHANGES;
	/* END install prefix related options */

	fclose(f);
	return 0;
}
Exemple #10
0
Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp)
    : Extension(in_repr, in_imp),
      _id_noprefs(Glib::ustring(get_id()) + ".noprefs"),
      _name_noprefs(Glib::ustring(_(get_name())) + _(" (No preferences)")),
      _verb(get_id(), get_name(), NULL, NULL, this, true),
      _verb_nopref(_id_noprefs.c_str(), _name_noprefs.c_str(), NULL, NULL, this, false),
      _menu_node(NULL), _workingDialog(true),
      _prefDialog(NULL)
{
    Inkscape::XML::Node * local_effects_menu = NULL;

    // This is a weird hack
    if (!strcmp(this->get_id(), "org.inkscape.filter.dropshadow"))
        return;

    bool hidden = false;

    no_doc = false;
    no_live_preview = false;

    if (repr != NULL) {

        for (Inkscape::XML::Node *child = sp_repr_children(repr); child != NULL; child = child->next()) {
            if (!strcmp(child->name(), INKSCAPE_EXTENSION_NS "effect")) {
                if (child->attribute("needs-document") && !strcmp(child->attribute("needs-document"), "false")) {
                  no_doc = true;
                }
                if (child->attribute("needs-live-preview") && !strcmp(child->attribute("needs-live-preview"), "false")) {
                  no_live_preview = true;
                }
                for (Inkscape::XML::Node *effect_child = sp_repr_children(child); effect_child != NULL; effect_child = effect_child->next()) {
                    if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "effects-menu")) {
                        // printf("Found local effects menu in %s\n", this->get_name());
                        local_effects_menu = sp_repr_children(effect_child);
                        if (effect_child->attribute("hidden") && !strcmp(effect_child->attribute("hidden"), "true")) {
                            hidden = true;
                        }
                    }
                    if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "menu-name") ||
                            !strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "_menu-name")) {
                        // printf("Found local effects menu in %s\n", this->get_name());
                        _verb.set_name(sp_repr_children(effect_child)->content());
                    }
                    if (!strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "menu-tip") ||
                            !strcmp(effect_child->name(), INKSCAPE_EXTENSION_NS "_menu-tip")) {
                        // printf("Found local effects menu in %s\n", this->get_name());
                        _verb.set_tip(sp_repr_children(effect_child)->content());
                    }
                } // children of "effect"
                break; // there can only be one effect
            } // find "effect"
        } // children of "inkscape-extension"
    } // if we have an XML file

    if (INKSCAPE != NULL) {
        if (_effects_list == NULL)
            _effects_list = find_menu(inkscape_get_menus(INKSCAPE), EFFECTS_LIST);
        if (_filters_list == NULL)
            _filters_list = find_menu(inkscape_get_menus(INKSCAPE), FILTERS_LIST);
    }

    if ((_effects_list != NULL || _filters_list != NULL)) {
        Inkscape::XML::Document *xml_doc;
        xml_doc = _effects_list->document();
        _menu_node = xml_doc->createElement("verb");
        _menu_node->setAttribute("verb-id", this->get_id(), false);

        if (!hidden) {
            if (_filters_list &&
                local_effects_menu && 
                local_effects_menu->attribute("name") && 
                !strcmp(local_effects_menu->attribute("name"), ("Filters"))) {
                merge_menu(_filters_list->parent(), _filters_list, sp_repr_children(local_effects_menu), _menu_node);
            } else if (_effects_list) {
                merge_menu(_effects_list->parent(), _effects_list, local_effects_menu, _menu_node);
            }
        }
    }

    return;
}
Exemple #11
0
void dobut(Fl_Widget *, long arg)
/* handles a button push */
{
  int men = find_menu(stack[stsize-1]);
  int n = menus[men].numb;
  int bn = but2numb( (int) arg, n-1);
  if (menus[men].icommand[bn][0] == '@')
    push_menu(menus[men].icommand[bn]);
  else {

#ifdef _WIN32
    STARTUPINFO		suInfo;		// Process startup information
    PROCESS_INFORMATION	prInfo;		// Process information

    memset(&suInfo, 0, sizeof(suInfo));
    suInfo.cb = sizeof(suInfo);

    int icommand_length = strlen(menus[men].icommand[bn]);

    char* copy_of_icommand = new char[icommand_length+1];
    strcpy(copy_of_icommand,menus[men].icommand[bn]);

    // On _WIN32 the .exe suffix needs to be appended to the command
    // whilst leaving any additional parameters unchanged - this
    // is required to handle the correct conversion of cases such as : 
    // `../fluid/fluid valuators.fl' to '../fluid/fluid.exe valuators.fl'.

    // skip leading spaces.
    char* start_command = copy_of_icommand;
    while(*start_command == ' ') ++start_command;

    // find the space between the command and parameters if one exists.
    char* start_parameters = strchr(start_command,' ');

    char* command = new char[icommand_length+6]; // 6 for extra 'd.exe\0'

    if (start_parameters==NULL) { // no parameters required.
#  ifdef _DEBUG
      sprintf(command, "%sd.exe", start_command);
#  else
      sprintf(command, "%s.exe", start_command);
#  endif // _DEBUG
    } else { // parameters required.
      // break the start_command at the intermediate space between
      // start_command and start_parameters.
      *start_parameters = 0;
      // move start_paremeters to skip over the intermediate space.
      ++start_parameters;

#  ifdef _DEBUG
      sprintf(command, "%sd.exe %s", start_command, start_parameters);
#  else
      sprintf(command, "%s.exe %s", start_command, start_parameters);
#  endif // _DEBUG
    }

    CreateProcess(NULL, command, NULL, NULL, FALSE,
                  NORMAL_PRIORITY_CLASS, NULL, NULL, &suInfo, &prInfo);
	
    delete command;
    delete copy_of_icommand;
	
#else // NON _WIN32 systems.

    int icommand_length = strlen(menus[men].icommand[bn]);
    char* command = new char[icommand_length+5]; // 5 for extra './' and ' &\0' 

    sprintf(command, "./%s &", menus[men].icommand[bn]);
    system(command);

    delete command;
#endif // _WIN32
  }
}