📄 userinp.c
字号:
/*
Copyright 1994-2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
You may contact the author at:
mailto::camille@bluegrass.net
or by snail mail at:
David Lindauer
850 Washburn Ave Apt 99
Louisville, KY 40222
*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <dos.h>
#include <time.h>
#include "langext.h"
#include "defines.h"
#include "types.h"
#include "subs.h"
#include "globals.h"
/* USERINP.C */
void scan_env(byte *output,byte *string)
BeginDeclarations
byte name[256];
byte *p = name ;
EndDeclarations
BeginCode
While *string IsNotZero
BeginWhile
If *string == '%'
Then
p = name ;
string++ ;
While *string IsNotZero && *string != '%'
BeginWhile
*p++ = *string++ ;
EndWhile ;
If *string IsNotZero
Then
string++ ;
EndIf ;
*p = 0 ;
p = getenv(name) ;
If p IsNotNull
Then
strcpy(output,p) ;
output += strlen(output) ;
EndIf ;
Else
*output++ = *string++ ;
EndIf ;
EndWhile ;
*output = 0 ;
EndCode
/*+-------------------------------------------------------------------------+
| |
| get_filenames_from_user |
| |
+-------------------------------------------------------------------------+*/
void get_filenames_from_user(bit_16 argc, byte *argv[])
BeginDeclarations
byte *env_var;
bit_16 i;
file_info_ptr file_entry;
#define File_entry (*file_entry)
token_stack_ptr source_element;
#define Source_element (*source_element)
FILE *fil ;
byte linebuf[1024] ;
byte tempbuf[256] ;
char buf[260] ;
EndDeclarations
BeginCode
user_input_start_time = Now;
/*+-------------------------------------------------------------------------+
| |
| concatenate the environment files into parm_string |
| |
+-------------------------------------------------------------------------+*/
copy_string(parm_string, null_string);
copy_string(default_filename, program_directory_string);
change_extension(default_filename, env_extension_string);
If file_exists(default_filename, 0)
Then
concat_string(parm_string, at_string);
concat_string(parm_string, default_filename);
concat_string(parm_string, space_string);
EndIf;
copy_string(token, default_filename);
cut_string(token,
0,
reverse_index_string(token,
0xFFFF,
backslash_string) + 1);
process_filename(token);
If (file_exists(token, 0)) AndIf
(compare_string(token, default_filename) IsNotZero)
Then
concat_string(parm_string, at_string);
concat_string(parm_string, token);
concat_string(parm_string, space_string);
EndIf;
/*+-------------------------------------------------------------------------+
| |
| concatenate the LINK environment variable into parm_string |
| |
+-------------------------------------------------------------------------+*/
#ifdef XXXXX
env_var = (byte *) getenv("LINK");
If env_var IsNull
Then
#endif
env_var = (byte *) "";
#ifdef XXXXX
EndIf;
#endif
concat_string(parm_string, string(BytePtr(env_var)));
concat_string(parm_string, space_string);
/*+-------------------------------------------------------------------------+
| |
| concatenate the config file into parm_string |
| |
| breaking with tradition so I can do line-oriented input |
+-------------------------------------------------------------------------+*/
If Length(program_config_file_string) IsNotZero
Then
If (fil = fopen(String(program_config_file_string),"r")) IsNotNull
Then
While Not feof(fil)
BeginWhile
linebuf[0] = 0;
fgets(tempbuf,256,fil) ;
scan_env(linebuf,tempbuf) ;
If linebuf[0] IsNotZero
Then
If linebuf[strlen(linebuf)-1] Is '\n'
Then
linebuf[strlen(linebuf)-1] = 0 ;
EndIf
concat_string(parm_string,string(linebuf)) ;
concat_string(parm_string, space_string) ;
EndIf
EndWhile
EndIf
EndIf
/*+-------------------------------------------------------------------------+
| |
| concatenate the parm line into parm_string |
| |
+-------------------------------------------------------------------------+*/
For i=1; i<argc; i++
BeginFor
If i Exceeds 1
Then
concat_string(parm_string, space_string);
EndIf;
concat_string(parm_string, string(BytePtr(argv[i])));
EndFor;
/*+-------------------------------------------------------------------------+
| |
| Start input processing with the parm line. |
| |
+-------------------------------------------------------------------------+*/
source_element = get_free_token_source_element();
Source_element.source_file = Null;
Source_element.token_string = parm_string;
Source_element.token_string_index = 0;
Push source_element OnTo token_stack EndPush;
token_break_char = ' ';
/*+-------------------------------------------------------------------------+
| |
| Process OBJ file list |
| |
+-------------------------------------------------------------------------+*/
default_extension = obj_extension_string;
copy_string(default_filename, null_string);
default_prompt = "OBJ file(s)%s: ";
prompting_for = 1;
process_user_input_files(Addr(obj_file_list),
True);
/*+-------------------------------------------------------------------------+
| |
| Process EXE file |
| |
+-------------------------------------------------------------------------+*/
If comfile.val IsTrue
Then
default_extension = com_extension_string;
default_prompt = "COM file[%s]: ";
Else
If sysfile.val IsTrue
Then
default_extension = sys_extension_string;
default_prompt = "SYS file[%s]: ";
Else
If build_DLL.val IsTrue
Then
default_extension = dll_extension_string;
default_prompt = "DLL file[%s]: ";
Else
default_extension = exe_extension_string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -