+ while(1)
+ {
+ // If there is a script file
+ if (script_file)
+ {
+ if (!fgets(script_cmd_buf, sizeof(script_cmd_buf), script_file))
+ {
+ fclose(script_file);
+ script_file = NULL;
+ }
+ else
+ {
+ char *nl;
+ nl = strrchr(script_cmd_buf, '\r');
+ if (nl) *nl = '\0';
+ nl = strrchr(script_cmd_buf, '\n');
+ if (nl) *nl = '\0';
+
+ if ((cmd = (char*) malloc(strlen(script_cmd_buf))) != NULL)
+ {
+ memset(cmd, 0, strlen(script_cmd_buf));
+ strcpy(cmd, script_cmd_buf);
+ printf("%s\n", cmd);
+ }
+ }
+ }
+
+ if (!script_file)
+ {
+ cmd = readline(PROXPROMPT);
+ }
+