Skip to content
Snippets Groups Projects
Commit 3dcfd97d authored by deuce's avatar deuce
Browse files

Make the external command-lines user configurable.

parent 5feb8e6b
No related branches found
No related tags found
No related merge requests found
...@@ -14,156 +14,156 @@ void update_stats_callback(GtkWidget *wiggy, gpointer data) ...@@ -14,156 +14,156 @@ void update_stats_callback(GtkWidget *wiggy, gpointer data)
} }
void on_guru_brain1_activate(GtkWidget *wiggy, gpointer data) { void on_guru_brain1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.ctrl_dir,"guru.dat"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"guru.dat");
} }
void on_text_strings1_activate(GtkWidget *wiggy, gpointer data) { void on_text_strings1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.ctrl_dir,"text.dat"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"text.dat");
} }
void on_default_colours1_activate(GtkWidget *wiggy, gpointer data) { void on_default_colours1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.ctrl_dir,"attr.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"attr.cfg");
} }
void on_nodes_full_message1_activate(GtkWidget *wiggy, gpointer data) { void on_nodes_full_message1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"nonodes.txt"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"nonodes.txt");
} }
void on_answer_screen1_activate(GtkWidget *wiggy, gpointer data) { void on_answer_screen1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"answer.asc"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"answer.asc");
} }
void on_logon_message1_activate(GtkWidget *wiggy, gpointer data) { void on_logon_message1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"menu/logon.asc"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"menu/logon.asc");
} }
void on_auto_message1_activate(GtkWidget *wiggy, gpointer data) { void on_auto_message1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"menu/auto.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"menu/auto.msg");
} }
void on_zip_file_comment1_activate(GtkWidget *wiggy, gpointer data) { void on_zip_file_comment1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"zipmsg.txt"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"zipmsg.txt");
} }
void on_system_information1_activate(GtkWidget *wiggy, gpointer data) { void on_system_information1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"system.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"system.msg");
} }
void on_new_user_message1_activate(GtkWidget *wiggy, gpointer data) { void on_new_user_message1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"newuser.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"newuser.msg");
} }
void on_new_user_welcome_email1_activate(GtkWidget *wiggy, gpointer data) { void on_new_user_welcome_email1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"welcome.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"welcome.msg");
} }
void on_new_user_password_failure1_activate(GtkWidget *wiggy, gpointer data) { void on_new_user_password_failure1_activate(GtkWidget *wiggy, gpointer data) {
edit_text_file(cfg.text_dir,"nupguess.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"nupguess.msg");
} }
void on_new_user_feedbakc_instructions1_activate(GtkWidget *wiggy, gpointer data) void on_new_user_feedbakc_instructions1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"feedback.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"feedback.msg");
} }
void on_allowed_rlogin_list1_activate(GtkWidget *wiggy, gpointer data) void on_allowed_rlogin_list1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"rlogin.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"rlogin.cfg");
} }
void on_alias_list1_activate(GtkWidget *wiggy, gpointer data) void on_alias_list1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"alias.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"alias.cfg");
} }
void on_domain_list1_activate(GtkWidget *wiggy, gpointer data) void on_domain_list1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"domains.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"domains.cfg");
} }
void on_spam_bait_list1_activate(GtkWidget *wiggy, gpointer data) void on_spam_bait_list1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"spambait.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"spambait.cfg");
} }
void on_spam_block_list1_activate(GtkWidget *wiggy, gpointer data) void on_spam_block_list1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"spamblock.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"spamblock.cfg");
} }
void on_allowed_relay_list1_activate(GtkWidget *wiggy, gpointer data) void on_allowed_relay_list1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"relay.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"relay.cfg");
} }
void on_dnsbased_blacklists1_activate(GtkWidget *wiggy, gpointer data) void on_dnsbased_blacklists1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"dns_blacklist.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"dns_blacklist.cfg");
} }
void on_dnsblacklist_exempt_ips1_activate(GtkWidget *wiggy, gpointer data) void on_dnsblacklist_exempt_ips1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"dnsbl_exempt.cfg.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"dnsbl_exempt.cfg.cfg");
} }
void on_external_mail_processing1_activate(GtkWidget *wiggy, gpointer data) void on_external_mail_processing1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"mailproc.ini"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"mailproc.ini");
} }
void on_login_message1_activate(GtkWidget *wiggy, gpointer data) void on_login_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"ftplogin.txt"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftplogin.txt");
} }
void on_failed_login_mesage1_activate(GtkWidget *wiggy, gpointer data) void on_failed_login_mesage1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"ftpbadlogin.txt"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftpbadlogin.txt");
} }
void on_hello_message1_activate(GtkWidget *wiggy, gpointer data) void on_hello_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"ftphello.txt"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftphello.txt");
} }
void on_goodbye_message1_activate(GtkWidget *wiggy, gpointer data) void on_goodbye_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"ftpbye.txt"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"ftpbye.txt");
} }
void on_filename_aliases1_activate(GtkWidget *wiggy, gpointer data) void on_filename_aliases1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"ftpalias.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"ftpalias.cfg");
} }
void on_mime_types1_activate(GtkWidget *wiggy, gpointer data) void on_mime_types1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"mime_types.ini"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"mime_types.ini");
} }
void on_cgi_environment_variables1_activate(GtkWidget *wiggy, gpointer data) void on_cgi_environment_variables1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"cgi_env.ini"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"cgi_env.ini");
} }
void on_external_content_handlers1_activate(GtkWidget *wiggy, gpointer data) void on_external_content_handlers1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"web_handler.ini"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"web_handler.ini");
} }
void on_servicesini1_activate(GtkWidget *wiggy, gpointer data) void on_servicesini1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"services.ini"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"services.ini");
} }
void on_error_log1_activate(GtkWidget *wiggy, gpointer data) void on_error_log1_activate(GtkWidget *wiggy, gpointer data)
{ {
view_text_file(cfg.logs_dir,"error.log"); exec_cmdstr(gtkm_conf.view_text_file ,cfg.logs_dir,"error.log");
} }
void on_statistics_log1_activate(GtkWidget *wiggy, gpointer data) void on_statistics_log1_activate(GtkWidget *wiggy, gpointer data)
{ {
view_stdout(cfg.exec_dir,"slog"); exec_cmdstr(gtkm_conf.view_stdout ,cfg.exec_dir,"slog");
} }
void on_todays_log1_activate(GtkWidget *wiggy, gpointer data) void on_todays_log1_activate(GtkWidget *wiggy, gpointer data)
...@@ -175,7 +175,7 @@ void on_todays_log1_activate(GtkWidget *wiggy, gpointer data) ...@@ -175,7 +175,7 @@ void on_todays_log1_activate(GtkWidget *wiggy, gpointer data)
t=time(NULL); t=time(NULL);
tm=localtime(&t); tm=localtime(&t);
sprintf(fn,"logs/%02d%02d%02d.log",tm->tm_mon+1,tm->tm_mday,tm->tm_year%100); sprintf(fn,"logs/%02d%02d%02d.log",tm->tm_mon+1,tm->tm_mday,tm->tm_year%100);
view_text_file(cfg.logs_dir,fn); exec_cmdstr(gtkm_conf.view_text_file, cfg.logs_dir,fn);
} }
void on_yesterdays_log1_activate(GtkWidget *wiggy, gpointer data) void on_yesterdays_log1_activate(GtkWidget *wiggy, gpointer data)
...@@ -188,7 +188,7 @@ void on_yesterdays_log1_activate(GtkWidget *wiggy, gpointer data) ...@@ -188,7 +188,7 @@ void on_yesterdays_log1_activate(GtkWidget *wiggy, gpointer data)
t-=24*60*60; t-=24*60*60;
tm=localtime(&t); tm=localtime(&t);
sprintf(fn,"logs/%02d%02d%02d.log",tm->tm_mon+1,tm->tm_mday,tm->tm_year%100); sprintf(fn,"logs/%02d%02d%02d.log",tm->tm_mon+1,tm->tm_mday,tm->tm_year%100);
view_text_file(cfg.logs_dir,fn); exec_cmdstr(gtkm_conf.view_text_file, cfg.logs_dir,fn);
} }
void on_another_days_log1_activate(GtkWidget *wiggy, gpointer data) { void on_another_days_log1_activate(GtkWidget *wiggy, gpointer data) {
...@@ -197,87 +197,87 @@ void on_another_days_log1_activate(GtkWidget *wiggy, gpointer data) { ...@@ -197,87 +197,87 @@ void on_another_days_log1_activate(GtkWidget *wiggy, gpointer data) {
void on_spam_log1_activate(GtkWidget *wiggy, gpointer data) void on_spam_log1_activate(GtkWidget *wiggy, gpointer data)
{ {
view_text_file(cfg.logs_dir,"spam.log"); exec_cmdstr(gtkm_conf.view_text_file, cfg.logs_dir,"spam.log");
} }
void on_ip_address_filter1_activate(GtkWidget *wiggy, gpointer data) void on_ip_address_filter1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"ip.can"); exec_cmdstr(gtkm_conf.edit_text_file, cfg.text_dir,"ip.can");
} }
void on_ip_address_filter_silent1_activate(GtkWidget *wiggy, gpointer data) void on_ip_address_filter_silent1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"ip-silent.can"); exec_cmdstr(gtkm_conf.edit_text_file, cfg.text_dir,"ip-silent.can");
} }
void on_ip_address_filter_message1_activate(GtkWidget *wiggy, gpointer data) void on_ip_address_filter_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"badip.msg"); exec_cmdstr(gtkm_conf.edit_text_file, cfg.text_dir,"badip.msg");
} }
void on_host_name_filter1_activate(GtkWidget *wiggy, gpointer data) void on_host_name_filter1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"host.can"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"host.can");
} }
void on_host_name_filter_message1_activate(GtkWidget *wiggy, gpointer data) void on_host_name_filter_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"badhost.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badhost.msg");
} }
void on_user_name_filter1_activate(GtkWidget *wiggy, gpointer data) void on_user_name_filter1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"name.can"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"name.can");
} }
void on_user_name_filter_message1_activate(GtkWidget *wiggy, gpointer data) void on_user_name_filter_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"badname.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badname.msg");
} }
void on_email_address_filter1_activate(GtkWidget *wiggy, gpointer data) void on_email_address_filter1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"email.can"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"email.can");
} }
void on_email_address_filter_message1_activate(GtkWidget *wiggy, gpointer data) void on_email_address_filter_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"bademail.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"bademail.msg");
} }
void on_email_subject_filter1_activate(GtkWidget *wiggy, gpointer data) void on_email_subject_filter1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"subject.can"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"subject.can");
} }
void on_file_name_filter1_activate(GtkWidget *wiggy, gpointer data) void on_file_name_filter1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"file.can"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"file.can");
} }
void on_file_name_filter_message1_activate(GtkWidget *wiggy, gpointer data) void on_file_name_filter_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"badfile.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badfile.msg");
} }
void on_phone_number_filter1_activate(GtkWidget *wiggy, gpointer data) void on_phone_number_filter1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"phone.can"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"phone.can");
} }
void on_phone_number_filter_message1_activate(GtkWidget *wiggy, gpointer data) void on_phone_number_filter_message1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.text_dir,"badphone.msg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.text_dir,"badphone.msg");
} }
void on_twit_list1_activate(GtkWidget *wiggy, gpointer data) void on_twit_list1_activate(GtkWidget *wiggy, gpointer data)
{ {
edit_text_file(cfg.ctrl_dir,"twitlist.cfg"); exec_cmdstr(gtkm_conf.edit_text_file,cfg.ctrl_dir,"twitlist.cfg");
} }
void on_hack_attempt_log1_activate(GtkWidget *wiggy, gpointer data) void on_hack_attempt_log1_activate(GtkWidget *wiggy, gpointer data)
{ {
view_text_file(cfg.logs_dir,"hack.log"); exec_cmdstr(gtkm_conf.view_text_file,cfg.logs_dir,"hack.log");
} }
void on_configure1_activate(GtkWidget *wiggy, gpointer data) void on_configure1_activate(GtkWidget *wiggy, gpointer data)
...@@ -512,7 +512,8 @@ void clear_errors(GtkWidget *wiggy, gpointer data) ...@@ -512,7 +512,8 @@ void clear_errors(GtkWidget *wiggy, gpointer data)
void on_about1_activate(GtkWidget *wiggy, gpointer data) void on_about1_activate(GtkWidget *wiggy, gpointer data)
{ {
GladeXML *axml; GladeXML *axml;
axml = glade_xml_new("gtkmonitor.glade", "AboutWindow", NULL);
axml = glade_xml_new(glade_path, "AboutWindow", NULL);
if(axml==NULL) { if(axml==NULL) {
fprintf(stderr,"Could not locate AboutWindow widget\n"); fprintf(stderr,"Could not locate AboutWindow widget\n");
return; return;
...@@ -698,7 +699,7 @@ on_list1_activate(GtkWidget *wiggy, gpointer data) ...@@ -698,7 +699,7 @@ on_list1_activate(GtkWidget *wiggy, gpointer data)
GtkListStore *lstore = NULL; GtkListStore *lstore = NULL;
GtkTreeSelection *lsel; GtkTreeSelection *lsel;
lxml = glade_xml_new("gtkmonitor.glade", "UserListWindow", NULL); lxml = glade_xml_new(glade_path, "UserListWindow", NULL);
if(lxml==NULL) { if(lxml==NULL) {
fprintf(stderr,"Could not locate UserListWindow widget\n"); fprintf(stderr,"Could not locate UserListWindow widget\n");
return; return;
...@@ -1069,7 +1070,7 @@ void on_text_file1_activate(GtkWidget *wiggy, gpointer data) ...@@ -1069,7 +1070,7 @@ void on_text_file1_activate(GtkWidget *wiggy, gpointer data)
char fn[MAX_PATH+1]; char fn[MAX_PATH+1];
select_filename(wiggy, "Edit Text File", "Text Files", "*.txt", cfg.text_dir, fn); select_filename(wiggy, "Edit Text File", "Text Files", "*.txt", cfg.text_dir, fn);
if(fn[0]) if(fn[0])
edit_text_file(NULL, fn); exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
} }
void on_javascript_file1_activate(GtkWidget *wiggy, gpointer data) void on_javascript_file1_activate(GtkWidget *wiggy, gpointer data)
...@@ -1077,7 +1078,7 @@ void on_javascript_file1_activate(GtkWidget *wiggy, gpointer data) ...@@ -1077,7 +1078,7 @@ void on_javascript_file1_activate(GtkWidget *wiggy, gpointer data)
char fn[MAX_PATH+1]; char fn[MAX_PATH+1];
select_filename(wiggy, "Edit Javascript File", "Javascript Files", "*.js", cfg.exec_dir, fn); select_filename(wiggy, "Edit Javascript File", "Javascript Files", "*.js", cfg.exec_dir, fn);
if(fn[0]) if(fn[0])
edit_text_file(NULL, fn); exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
} }
void on_configuration_file1_activate(GtkWidget *wiggy, gpointer data) void on_configuration_file1_activate(GtkWidget *wiggy, gpointer data)
...@@ -1086,7 +1087,7 @@ void on_configuration_file1_activate(GtkWidget *wiggy, gpointer data) ...@@ -1086,7 +1087,7 @@ void on_configuration_file1_activate(GtkWidget *wiggy, gpointer data)
select_filename(wiggy, "Edit Configuration File", "Configuration Files", "*.cfg;*.ini;*.conf", cfg.ctrl_dir, fn); select_filename(wiggy, "Edit Configuration File", "Configuration Files", "*.cfg;*.ini;*.conf", cfg.ctrl_dir, fn);
if(fn[0]) if(fn[0])
edit_text_file(NULL, fn); exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
} }
void on_edit_and_compile_baja_script1_activate(GtkWidget *wiggy, gpointer data) void on_edit_and_compile_baja_script1_activate(GtkWidget *wiggy, gpointer data)
...@@ -1100,28 +1101,28 @@ void on_edit_and_compile_baja_script1_activate(GtkWidget *wiggy, gpointer data) ...@@ -1100,28 +1101,28 @@ void on_edit_and_compile_baja_script1_activate(GtkWidget *wiggy, gpointer data)
run_cmd_mutex_initalized=1; run_cmd_mutex_initalized=1;
} }
if(fn[0]) { if(fn[0]) {
edit_text_file(NULL, fn); exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
/* Spin on the lock waiting for the edit command to start */ /* Spin on the lock waiting for the edit command to start */
while(!pthread_mutex_trylock(&run_cmd_mutex)) while(!pthread_mutex_trylock(&run_cmd_mutex))
pthread_mutex_unlock(&run_cmd_mutex); pthread_mutex_unlock(&run_cmd_mutex);
sprintf(compile, "baja %s", fn); sprintf(compile, "baja %s", fn);
view_stdout(cfg.exec_dir,compile); exec_cmdstr(gtkm_conf.view_stdout,cfg.exec_dir,compile);
} }
} }
void on_index1_activate(GtkWidget *wiggy, gpointer data) void on_index1_activate(GtkWidget *wiggy, gpointer data)
{ {
view_html_file(cfg.ctrl_dir,"../docs/index.htm"); exec_cmdstr(gtkm_conf.view_html_file,cfg.ctrl_dir,"../docs/index.htm");
} }
void on_sysop_manual1_activate(GtkWidget *wiggy, gpointer data) void on_sysop_manual1_activate(GtkWidget *wiggy, gpointer data)
{ {
view_html_file(cfg.ctrl_dir,"../docs/sysop.html"); exec_cmdstr(gtkm_conf.view_html_file,cfg.ctrl_dir,"../docs/sysop.html");
} }
void on_frequently_asked_questions_faq1_activate(GtkWidget *wiggy, gpointer data) void on_frequently_asked_questions_faq1_activate(GtkWidget *wiggy, gpointer data)
{ {
view_text_file(cfg.ctrl_dir,"../docs/v3cfgfaq.txt"); exec_cmdstr(gtkm_conf.view_text_file,cfg.ctrl_dir,"../docs/v3cfgfaq.txt");
} }
void on_preview_file1_activate(GtkWidget *wiggy, gpointer data) void on_preview_file1_activate(GtkWidget *wiggy, gpointer data)
...@@ -1130,13 +1131,12 @@ void on_preview_file1_activate(GtkWidget *wiggy, gpointer data) ...@@ -1130,13 +1131,12 @@ void on_preview_file1_activate(GtkWidget *wiggy, gpointer data)
select_filename(wiggy, "Preview File", "ANSI/Ctrl-A Files", "*.ans;*.asc;*.msg", cfg.text_dir, fn); select_filename(wiggy, "Preview File", "ANSI/Ctrl-A Files", "*.ans;*.asc;*.msg", cfg.text_dir, fn);
if(fn[0]) if(fn[0])
view_ctrla_file(NULL, fn); exec_cmdstr(gtkm_conf.view_ctrla_file,NULL, fn);
} }
void on_edit_and_preview_file1_activate(GtkWidget *wiggy, gpointer data) void on_edit_and_preview_file1_activate(GtkWidget *wiggy, gpointer data)
{ {
char fn[MAX_PATH+1]; char fn[MAX_PATH+1];
char compile[MAX_PATH*2+1];
select_filename(wiggy, "Edit and Preview File", "ANSI/Ctrl-A Files", "*.ans;*.asc;*.msg", cfg.text_dir, fn); select_filename(wiggy, "Edit and Preview File", "ANSI/Ctrl-A Files", "*.ans;*.asc;*.msg", cfg.text_dir, fn);
if(!run_cmd_mutex_initalized) { if(!run_cmd_mutex_initalized) {
...@@ -1144,12 +1144,11 @@ void on_edit_and_preview_file1_activate(GtkWidget *wiggy, gpointer data) ...@@ -1144,12 +1144,11 @@ void on_edit_and_preview_file1_activate(GtkWidget *wiggy, gpointer data)
run_cmd_mutex_initalized=1; run_cmd_mutex_initalized=1;
} }
if(fn[0]) { if(fn[0]) {
edit_text_file(NULL, fn); exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
/* Spin on the lock waiting for the edit command to start */ /* Spin on the lock waiting for the edit command to start */
while(!pthread_mutex_trylock(&run_cmd_mutex)) while(!pthread_mutex_trylock(&run_cmd_mutex))
pthread_mutex_unlock(&run_cmd_mutex); pthread_mutex_unlock(&run_cmd_mutex);
sprintf(compile, "baja %s", fn); exec_cmdstr(gtkm_conf.view_ctrla_file, NULL, fn);
view_ctrla_file(NULL, fn);
} }
} }
...@@ -1188,7 +1187,7 @@ void sendmessageto_node(GtkWidget *wiggy, gpointer data) ...@@ -1188,7 +1187,7 @@ void sendmessageto_node(GtkWidget *wiggy, gpointer data)
/* If utime() failed for some reason, sleep for a second */ /* If utime() failed for some reason, sleep for a second */
if(fdate(fn)!=edited) if(fdate(fn)!=edited)
SLEEP(1000); SLEEP(1000);
edit_text_file(NULL, fn); exec_cmdstr(gtkm_conf.edit_text_file, NULL, fn);
/* Spin on the lock waiting for the edit command to start */ /* Spin on the lock waiting for the edit command to start */
while(!pthread_mutex_trylock(&run_cmd_mutex)) while(!pthread_mutex_trylock(&run_cmd_mutex))
pthread_mutex_unlock(&run_cmd_mutex); pthread_mutex_unlock(&run_cmd_mutex);
...@@ -1224,3 +1223,48 @@ void sendmessageto_node(GtkWidget *wiggy, gpointer data) ...@@ -1224,3 +1223,48 @@ void sendmessageto_node(GtkWidget *wiggy, gpointer data)
} }
} }
} }
void on_properties1_activate(GtkWidget *wiggy, gpointer data)
{
GladeXML *pxml;
GtkWidget *dialog;
GtkWidget *w;
pxml = glade_xml_new(glade_path, "PreferencesDialog", NULL);
if(pxml==NULL) {
fprintf(stderr,"Could not locate PreferencesDialog widget\n");
return;
}
/* connect the signals in the interface */
glade_xml_signal_autoconnect(pxml);
dialog=glade_xml_get_widget(pxml, "PreferencesDialog");
/* Put in the current values */
w=glade_xml_get_widget(pxml,"eEditTextFile");
gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.edit_text_file);
w=glade_xml_get_widget(pxml,"eViewTextFile");
gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_text_file);
w=glade_xml_get_widget(pxml,"eViewStdout");
gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_stdout);
w=glade_xml_get_widget(pxml,"eViewCtrlAFile");
gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_ctrla_file);
w=glade_xml_get_widget(pxml,"eViewHTMLFile");
gtk_entry_set_text(GTK_ENTRY(w),gtkm_conf.view_html_file);
switch(gtk_dialog_run(GTK_DIALOG(dialog))) {
case GTK_RESPONSE_OK:
/* Read out the new values */
w=glade_xml_get_widget(pxml,"eEditTextFile");
strcpy(gtkm_conf.edit_text_file,gtk_entry_set_text(GTK_ENTRY(w)));
w=glade_xml_get_widget(pxml,"eViewTextFile");
strcpy(gtkm_conf.view_text_file,gtk_entry_set_text(GTK_ENTRY(w)));
w=glade_xml_get_widget(pxml,"eViewStdout");
strcpy(gtkm_conf.view_stdout,gtk_entry_set_text(GTK_ENTRY(w)));
w=glade_xml_get_widget(pxml,"eViewCtrlAFile");
strcpy(gtkm_conf.view_ctrla_file,gtk_entry_set_text(GTK_ENTRY(w)));
w=glade_xml_get_widget(pxml,"eViewHTMLFile");
strcpy(gtkm_conf.view_html_file,gtk_entry_set_text(GTK_ENTRY(w)));
write_ini();
}
gtk_widget_destroy(dialog);
}
#include "dirwrap.h"
#include "ini_file.h"
#include "events.h" #include "events.h"
#include "gtkmonitor.h" #include "gtkmonitor.h"
#include "dirwrap.h"
scfg_t cfg; scfg_t cfg;
GladeXML *xml; GladeXML *xml;
int nodes=0; int nodes=0;
GtkListStore *store = NULL; GtkListStore *store = NULL;
GtkTreeSelection *sel; GtkTreeSelection *sel;
struct gtkmonitor_config gtkm_conf;
char glade_path[MAX_PATH+1];
void read_ini(void)
{
FILE *inif;
char path[MAX_PATH+1];
complete_path(path, cfg.ctrl_dir, "gtkmonitor.ini");
inif=fopen(path, "r");
iniReadString(inif, "commands", "ViewStdOut", "%f | xmessage -file -", gtkm_conf.view_stdout);
iniReadString(inif, "commands", "ViewTextFile", "xmessage -file %f", gtkm_conf.view_text_file);
iniReadString(inif, "commands", "EditTextFile", "xedit %f",gtkm_conf.edit_text_file);
iniReadString(inif, "commands", "ViewCtrlAFile", "%!asc2ans %f | %!syncview -l",gtkm_conf.view_ctrla_file);
iniReadString(inif, "commands", "ViewHTMLFile", "firefox file://%f", gtkm_conf.view_html_file);
if(inif)
fclose(inif);
else
write_ini();
}
void write_ini(void)
{
FILE *inif;
char path[MAX_PATH+1];
str_list_t inifile;
complete_path(path, cfg.ctrl_dir, "gtkmonitor.ini");
inif=fopen(path, "r");
if(inif) {
inifile=iniReadFile(inif);
fclose(inif);
}
else
inifile=strListInit();
iniSetString(&inifile, "commands", "ViewStdOut", gtkm_conf.view_stdout, NULL);
iniSetString(&inifile, "commands", "ViewTextFile", gtkm_conf.view_text_file, NULL);
iniSetString(&inifile, "commands", "EditTextFile", gtkm_conf.edit_text_file, NULL);
iniSetString(&inifile, "commands", "ViewCtrlAFile", gtkm_conf.view_ctrla_file, NULL);
iniSetString(&inifile, "commands", "ViewHTMLFile", gtkm_conf.view_html_file, NULL);
inif=fopen(path, "w");
if(inif) {
iniWriteFile(inif, inifile);
fclose(inif);
}
else
display_message("Cannot Create .ini File","Unable to create the .ini file. Check your permissions.","gtk-dialog-error");
strListFree(&inifile);
}
void refresh_events(void) void refresh_events(void)
{ {
...@@ -387,6 +438,9 @@ int read_config(void) ...@@ -387,6 +438,9 @@ int read_config(void)
/* Read the ctrl struct */ /* Read the ctrl struct */
refresh_events(); refresh_events();
/* Read the .ini file */
read_ini();
/* Passing any non-NULL argument is required to set up the timeout */ /* Passing any non-NULL argument is required to set up the timeout */
if(refresh_data(refresh_data)) if(refresh_data(refresh_data))
return(-1); return(-1);
...@@ -394,8 +448,6 @@ int read_config(void) ...@@ -394,8 +448,6 @@ int read_config(void)
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
char glade_path[MAX_PATH+1];
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
glade_init(); glade_init();
......
...@@ -103,7 +103,6 @@ ...@@ -103,7 +103,6 @@
<child> <child>
<widget class="GtkImageMenuItem" id="properties1"> <widget class="GtkImageMenuItem" id="properties1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property>
<property name="label">gtk-properties</property> <property name="label">gtk-properties</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<signal name="activate" handler="on_properties1_activate" last_modification_time="Thu, 09 Mar 2006 17:06:10 GMT"/> <signal name="activate" handler="on_properties1_activate" last_modification_time="Thu, 09 Mar 2006 17:06:10 GMT"/>
...@@ -3376,4 +3375,369 @@ Set9</property> ...@@ -3376,4 +3375,369 @@ Set9</property>
</child> </child>
</widget> </widget>
<widget class="GtkDialog" id="PreferencesDialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Preferences</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">True</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="icon_name">gtk-preferences</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="label" translatable="yes">Command Lines</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table6">
<property name="visible">True</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
<property name="column_spacing">10</property>
<child>
<widget class="GtkEntry" id="eViewTextFile">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">xmessage -file %f</property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="eViewStdout">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">%f | xmessage -file -</property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="eViewHTMLFile">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">firefox file://%f</property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="eViewCtrlAFile">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">%!asc2ans %f | %!syncview -l</property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label25">
<property name="visible">True</property>
<property name="label" translatable="yes">Edit Text File</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="label" translatable="yes">View Text File</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label27">
<property name="visible">True</property>
<property name="label" translatable="yes">View Stdout</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="eEditTextFile">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">xedit %f</property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label28">
<property name="visible">True</property>
<property name="label" translatable="yes">View HTML File</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label29">
<property name="visible">True</property>
<property name="label" translatable="yes">View Ctrl-A File</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface> </glade-interface>
...@@ -6,13 +6,24 @@ ...@@ -6,13 +6,24 @@
#include "sbbs.h" #include "sbbs.h"
extern scfg_t cfg; struct gtkmonitor_config {
extern GladeXML *xml; char view_stdout[MAX_PATH+1]; /* %f | xmessage -file - */
extern int nodes; char view_text_file[MAX_PATH+1]; /* xmessage -file %f */
extern GtkListStore *store; char edit_text_file[MAX_PATH+1]; /* xedit %f */
char view_ctrla_file[MAX_PATH+1];/* %!asc2ans %f | %ssyncview -l */
char view_html_file[MAX_PATH+1]; /* firefox file://%f */
};
extern struct gtkmonitor_config gtkm_conf;
extern scfg_t cfg;
extern GladeXML *xml;
extern int nodes;
extern GtkListStore *store;
extern GtkTreeSelection *sel; extern GtkTreeSelection *sel;
extern char glade_path[MAX_PATH+1];
int refresh_data(gpointer data); int refresh_data(gpointer data);
void refresh_events(void); void refresh_events(void);
void write_ini(void);
#endif #endif
...@@ -8,16 +8,124 @@ ...@@ -8,16 +8,124 @@
int run_cmd_mutex_initalized=0; int run_cmd_mutex_initalized=0;
pthread_mutex_t run_cmd_mutex; pthread_mutex_t run_cmd_mutex;
void run_cmdline(void *cmdline) /*****************************************************************************/
/* Returns command line generated from instr with %c replacments */
/*****************************************************************************/
char *mycmdstr(char *instr, char *fpath)
{
char str[256],str2[128];
int i,j,len;
#if 0
char cmd[MAX_PATH+1];
#else
char *cmd;
#endif
cmd=(char *)malloc(MAX_PATH+1);
if(cmd==NULL) {
display_message("malloc() Error", "Cannot allocate enough memory for the message", "gtk-dialog-error");
return(NULL);
}
len=strlen(instr);
for(i=j=0;i<len && j<128;i++) {
if(instr[i]=='%') {
i++;
cmd[j]=0;
switch(toupper(instr[i])) {
case 'F': /* File path */
strcat(cmd,fpath);
break;
case 'G': /* Temp directory */
if(cfg.temp_dir[0]!='\\'
&& cfg.temp_dir[0]!='/'
&& cfg.temp_dir[1]!=':') {
strcpy(str,cfg.ctrl_dir);
strcat(str,cfg.temp_dir);
if(FULLPATH(str2,str,40))
strcpy(str,str2);
backslash(str);
strcat(cmd,str);
}
else
strcat(cmd,cfg.temp_dir);
break;
case 'J':
if(cfg.data_dir[0]!='\\'
&& cfg.data_dir[0]!='/'
&& cfg.data_dir[1]!=':') {
strcpy(str,cfg.ctrl_dir);
strcat(str,cfg.data_dir);
if(FULLPATH(str2,str,40))
strcpy(str,str2);
backslash(str);
strcat(cmd,str);
}
else
strcat(cmd,cfg.data_dir);
break;
case 'K':
strcat(cmd,cfg.ctrl_dir);
break;
case 'O': /* SysOp */
strcat(cmd,cfg.sys_op);
break;
case 'Q': /* QWK ID */
strcat(cmd,cfg.sys_id);
break;
case '!': /* EXEC Directory */
strcat(cmd,cfg.exec_dir);
break;
case '@': /* EXEC Directory for DOS/OS2/Win32, blank for Unix */
#ifndef __unix__
strcat(cmd,cfg.exec_dir);
#endif
break;
case '%': /* %% for percent sign */
strcat(cmd,"%");
break;
case '.': /* .exe for DOS/OS2/Win32, blank for Unix */
#ifndef __unix__
strcat(cmd,".exe");
#endif
break;
case '?': /* Platform */
#ifdef __OS2__
strcpy(str,"OS2");
#else
strcpy(str,PLATFORM_DESC);
#endif
strlwr(str);
strcat(cmd,str);
break;
default: /* unknown specification */
sprintf(cmd,"ERROR Checking Command Line '%s'",instr);
display_message("Command line Error",cmd,"gtk-dialog-error");
free(cmd);
return(NULL);
}
j=strlen(cmd);
}
else
cmd[j++]=instr[i];
}
cmd[j]=0;
return(cmd);
}
void exec_cmdline(void *cmdline)
{ {
GtkWidget *w; GtkWidget *w;
if(cmdline==NULL)
return;
if(!run_cmd_mutex_initalized) { if(!run_cmd_mutex_initalized) {
pthread_mutex_init(&run_cmd_mutex, NULL); pthread_mutex_init(&run_cmd_mutex, NULL);
run_cmd_mutex_initalized=1; run_cmd_mutex_initalized=1;
} }
pthread_mutex_lock(&run_cmd_mutex); pthread_mutex_lock(&run_cmd_mutex);
system((char *)cmdline); system((char *)cmdline);
free(cmdline);
w=glade_xml_get_widget(xml, "MainWindow"); w=glade_xml_get_widget(xml, "MainWindow");
gtk_widget_set_sensitive(GTK_WIDGET(w), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(w), TRUE);
pthread_mutex_unlock(&run_cmd_mutex); pthread_mutex_unlock(&run_cmd_mutex);
...@@ -32,12 +140,12 @@ char *complete_path(char *dest, char *path, char *filename) ...@@ -32,12 +140,12 @@ char *complete_path(char *dest, char *path, char *filename)
else else
dest[0]=0; dest[0]=0;
strcat(dest, filename); if(filename != NULL)
fexistcase(dest); /* Fixes upr/lwr case fname */ strcat(dest, filename);
fexistcase(dest); /* TODO: Hack: Fixes upr/lwr case fname */
return(dest); return(dest);
} }
/* ToDo: This will need to read the command-line from a config file */
void run_external(char *path, char *filename) void run_external(char *path, char *filename)
{ {
static char cmdline[MAX_PATH*2]; static char cmdline[MAX_PATH*2];
...@@ -45,85 +153,19 @@ void run_external(char *path, char *filename) ...@@ -45,85 +153,19 @@ void run_external(char *path, char *filename)
w=glade_xml_get_widget(xml, "MainWindow"); w=glade_xml_get_widget(xml, "MainWindow");
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
_beginthread(run_cmdline, 0, complete_path(cmdline,path,filename)); complete_path(cmdline,path,filename);
_beginthread(exec_cmdline, 0, strdup(cmdline));
} }
/* ToDo: This will need to read the command-line from a config file */ void exec_cmdstr(char *cmdstr, char *path, char *filename)
void view_stdout(char *path, char *filename)
{ {
static char cmdline[MAX_PATH*2];
char p[MAX_PATH+1];
GtkWidget *w;
sprintf(cmdline, "%s | xmessage -file -", complete_path(p,path,filename));
w=glade_xml_get_widget(xml, "MainWindow");
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
_beginthread(run_cmdline, 0, cmdline);
}
/* ToDo: This will need to read the command-line from a config file */
void view_text_file(char *path, char *filename)
{
static char cmdline[MAX_PATH*2];
char p[MAX_PATH+1]; char p[MAX_PATH+1];
GtkWidget *w; GtkWidget *w;
complete_path(p,path,filename); complete_path(p,path,filename);
if(!fexist(p)) {
sprintf(cmdline,"The file %s does not exist.",p);
display_message("File Does Not Exist", cmdline, "gtk-dialog-error");
}
else {
if(access(p,R_OK)) {
sprintf(cmdline,"Cannot read the file %s... check your permissions.",p);
display_message("Cannot Read File", cmdline, "gtk-dialog-error");
}
else {
sprintf(cmdline, "xmessage -file %s", p);
w=glade_xml_get_widget(xml, "MainWindow");
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
_beginthread(run_cmdline, 0, cmdline);
}
}
}
/* ToDo: This will need to read the command-line from a config file */
void edit_text_file(char *path, char *filename)
{
static char cmdline[MAX_PATH*2];
char p[MAX_PATH+1];
GtkWidget *w;
sprintf(cmdline, "xedit %s", complete_path(p,path,filename));
w=glade_xml_get_widget(xml, "MainWindow");
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
_beginthread(run_cmdline, 0, cmdline);
}
/* ToDo: This will need to read the command-line from a config file */
void view_ctrla_file(char *path, char *filename)
{
static char cmdline[MAX_PATH*2];
char p[MAX_PATH+1];
GtkWidget *w;
sprintf(cmdline, "%sasc2ans %s | %ssyncview -l", cfg.exec_dir, complete_path(p,path,filename), cfg.exec_dir);
w=glade_xml_get_widget(xml, "MainWindow");
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
_beginthread(run_cmdline, 0, cmdline);
}
/* ToDo: This will need to read the command-line from a config file */
void view_html_file(char *path, char *filename)
{
static char cmdline[MAX_PATH*2];
char p[MAX_PATH+1];
GtkWidget *w;
sprintf(cmdline, "firefox file://%s", complete_path(p,path,filename));
w=glade_xml_get_widget(xml, "MainWindow"); w=glade_xml_get_widget(xml, "MainWindow");
gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
_beginthread(run_cmdline, 0, cmdline); _beginthread(exec_cmdline, 0, mycmdstr(cmdstr, p));
} }
void touch_sem(char *path, char *filename) void touch_sem(char *path, char *filename)
......
...@@ -6,16 +6,12 @@ ...@@ -6,16 +6,12 @@
extern int run_cmd_mutex_initalized; extern int run_cmd_mutex_initalized;
extern pthread_mutex_t run_cmd_mutex; extern pthread_mutex_t run_cmd_mutex;
void exec_cmdstr(char *cmdstr, char *path, char *filename);
void run_cmdline(void *cmdline); void run_cmdline(void *cmdline);
void run_external(char *path, char *filename); void run_external(char *path, char *filename);
void view_stdout(char *path, char *filename);
void view_text_file(char *path, char *filename);
void edit_text_file(char *path, char *filename);
void view_html_file(char *path, char *filename);
char *getsizestr(char *outstr, long size, BOOL bytes); char *getsizestr(char *outstr, long size, BOOL bytes);
char *getnumstr(char *outstr, ulong size); char *getnumstr(char *outstr, ulong size);
void touch_sem(char *path, char *filename); void touch_sem(char *path, char *filename);
void display_message(char *title, char *message, char *icon); void display_message(char *title, char *message, char *icon);
void view_ctrla_file(char *path, char *filename);
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment