/* Maximum length of the linked list for the command line history */
-#define MAX_HISTORY 15
+#ifndef CONFIG_FEATURE_COMMAND_HISTORY
+#define MAX_HISTORY 15
+#else
+#define MAX_HISTORY CONFIG_FEATURE_COMMAND_HISTORY
+#endif
+
#if MAX_HISTORY < 1
#warning cmdedit: You set MAX_HISTORY < 1. The history algorithm switched off.
#else
return 0;
}
}
+
+#ifdef CONFIG_FEATURE_COMMAND_SAVEHISTORY
+extern void load_history ( const char *fromfile )
+{
+ FILE *fp;
+ int hi;
+
+ /* cleanup old */
+
+ for(hi = n_history; hi > 0; ) {
+ hi--;
+ free ( history [hi] );
+ }
+
+ if (( fp = fopen ( fromfile, "r" ))) {
+
+ for ( hi = 0; hi < MAX_HISTORY; ) {
+ char * hl = get_line_from_file(fp);
+ int l;
+
+ if(!hl)
+ break;
+ chomp(hl);
+ l = strlen(hl);
+ if(l >= BUFSIZ)
+ hl[BUFSIZ-1] = 0;
+ if(l == 0 || hl[0] == ' ') {
+ free(hl);
+ continue;
+ }
+ history [hi++] = hl;
+ }
+ fclose ( fp );
+ }
+ cur_history = n_history = hi;
+}
+
+extern void save_history ( const char *tofile )
+{
+ FILE *fp = fopen ( tofile, "w" );
+
+ if ( fp ) {
+ int i;
+
+ for ( i = 0; i < n_history; i++ ) {
+ fputs ( history [i], fp );
+ fputc ( '\n', fp );
+ }
+ fclose ( fp );
+ }
+}
+#endif
+
#endif
enum {