Skip to content
Snippets Groups Projects
Commit 056eafe6 authored by rswindell's avatar rswindell
Browse files

Added support for -y command-line switch which forces the saving of changes

without prompting the user (for automated configuration changes via script).
parent 04d4f503
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
scfg_t cfg; /* Synchronet Configuration */ scfg_t cfg; /* Synchronet Configuration */
uifcapi_t uifc; /* User Interface (UIFC) Library API */ uifcapi_t uifc; /* User Interface (UIFC) Library API */
BOOL no_dirchk=FALSE,forcesave=FALSE; BOOL no_dirchk=FALSE,forcesave=FALSE;
static BOOL auto_save=FALSE;
extern BOOL all_msghdr; extern BOOL all_msghdr;
extern BOOL no_msghdr; extern BOOL no_msghdr;
char **opt; char **opt;
...@@ -144,6 +145,9 @@ int main(int argc, char **argv) ...@@ -144,6 +145,9 @@ int main(int argc, char **argv)
textmode(atoi(argv[i]+2)); textmode(atoi(argv[i]+2));
#endif #endif
break; break;
case 'Y':
auto_save=TRUE;
break;
default: default:
printf("\nusage: scfg [ctrl_dir] [options]" printf("\nusage: scfg [ctrl_dir] [options]"
"\n\noptions:\n\n" "\n\noptions:\n\n"
...@@ -166,6 +170,7 @@ int main(int argc, char **argv) ...@@ -166,6 +170,7 @@ int main(int argc, char **argv)
#endif #endif
"-l# = set screen lines to # (default=auto-detect)\r\n" "-l# = set screen lines to # (default=auto-detect)\r\n"
"-b# = set automatic back-up level (default=%d)\r\n" "-b# = set automatic back-up level (default=%d)\r\n"
"-y = automatically save changes (don't ask)\r\n"
,backup_level ,backup_level
); );
exit(0); exit(0);
...@@ -550,14 +555,18 @@ int save_changes(int mode) ...@@ -550,14 +555,18 @@ int save_changes(int mode)
{ {
int i=0; int i=0;
if(!uifc.changes) if(!uifc.changes)
return(2); return(2);
strcpy(opt[0],"Yes"); if(auto_save==TRUE) { /* -y switch used, return "Yes" */
strcpy(opt[1],"No"); uifc.changes=0;
opt[2][0]=0; return(0);
if(mode&WIN_SAV && uifc.savdepth) }
uifc.savnum++; strcpy(opt[0],"Yes");
SETHELP(WHERE); strcpy(opt[1],"No");
opt[2][0]=0;
if(mode&WIN_SAV && uifc.savdepth)
uifc.savnum++;
SETHELP(WHERE);
/* /*
Save uifc.changes: Save uifc.changes:
...@@ -566,12 +575,12 @@ these uifc.changes, select Yes. If you are positive you DO NOT want to save ...@@ -566,12 +575,12 @@ these uifc.changes, select Yes. If you are positive you DO NOT want to save
these uifc.changes, select No. If you are not sure and want to review the these uifc.changes, select No. If you are not sure and want to review the
configuration before deciding, hit  ESC . configuration before deciding, hit  ESC .
*/ */
i=uifc.list(mode|WIN_ACT,0,0,0,&i,0,"Save Changes",opt); i=uifc.list(mode|WIN_ACT,0,0,0,&i,0,"Save Changes",opt);
if(mode&WIN_SAV && uifc.savdepth && uifc.savnum) if(mode&WIN_SAV && uifc.savdepth && uifc.savnum)
uifc.savnum--; uifc.savnum--;
if(i!=-1) if(i!=-1)
uifc.changes=0; uifc.changes=0;
return(i); return(i);
} }
void txt_cfg() void txt_cfg()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment