diff --git a/Microsoft C v6ax/BIN/C1.ERR b/Microsoft C v6ax/BIN/C1.ERR new file mode 100644 index 0000000..7ed59ba --- /dev/null +++ b/Microsoft C v6ax/BIN/C1.ERR @@ -0,0 +1,429 @@ +/* SCCSWHAT( "@(#)c1.err 3.69 90/02/01 12:58:41 " ) */ + /* warnings */ + +4001 "nonstandard extension used - '%Fs'" +4002 "too many actual parameters for macro '%s'" +4003 "not enough actual parameters for macro '%s'" +4004 "missing ')' after 'defined'" +4005 "'%s' : macro redefinition" +4006 "#undef expected an identifier" +4007 "'%Fs' : must be '%Fs'" +4008 "'%Fs' : '%Fs' attribute on data ignored" +4009 "string too big, trailing characters truncated" +4011 "identifier truncated to '%Fs'" +4012 "float constant in a cross compilation" /* XC */ +4014 "'%Fs' : type of bit field must be unsigned" /* QC2 */ +4015 "'%Fs' : type of bit field must be integral" +4016 "'%s' : no function return type, using int as default" +4017 "cast of int expression to far pointer" +4018 "'%Fs' : signed/unsigned mismatch" +4020 "'%Fs' : too many actual parameters" +4021 "'%Fs' : too few actual parameters" +4022 "'%Fs' : pointer mismatch : parameter %d" +4023 "'%Fs' : _based pointer passed to unprototyped function : parameter %d" +4024 "'%Fs' : different types : parameter %d" +4026 "function declared with formal argument list" +4027 "function declared without formal argument list" +4028 "parameter %d declaration different" +4029 "declared parameter list different from definition" +4030 "first parameter list longer than the second" +4031 "second parameter list longer than the first" +4032 "unnamed struct/union as parameter" +4033 "function must return a value" +4034 "sizeof returns 0" +4035 "'%Fs' : no return value" +4037 "'%Fs' : formal parameters ignored" /* QC2 */ +4038 "'%Fs' : formal parameter has bad storage class" /* QC2 */ +4040 "memory attribute on '%Fs' ignored" +4042 "'%Fs' : has bad storage class" +4044 "_huge on '%Fs' ignored, must be an array" +4045 "'%s' : array bounds overflow" +4046 "'&' on function/array, ignored" /* QC2 */ +4047 "'%s' : different levels of indirection" +4048 "array's declared subscripts different" +4049 "'%s' : indirection to different types" +4050 "'%s' : different code attributes" +4051 "type conversion - possible loss of data" +4053 "at least one void operand" +4056 "overflow in constant arithmetic" /* QC2, c1, c23 */ +4058 "address of automatic (local) variable taken, DS != SS" /* QC, c23 */ +4059 "segment lost in conversion" /* QC, c23 */ +4060 "conversion of long address to short address" /* QC2 */ +4061 "long/short mismatch in argument : conversion supplied" /* QC, c23 */ +4062 "near/far mismatch in argument : conversion supplied" /* QC, c23 */ +4067 "unexpected characters following '%s' directive - newline expected" +4068 "unknown pragma" +4069 "conversion of near pointer to long integer" /* QC, c23 */ +4071 "'%Fs' : no function prototype given" +4072 "'%Fs' : no function prototype on _fastcall function" +4074 "nonstandard extension used - '%s'" /* QC2 */ +4075 "size of switch expression or case constant too large - converted to int" /* QC2 */ +4076 "'%s' : may be used on integral types only" +4077 "unknown check_stack option" +4078 "case constant '%ld' too big for the type of switch expression" +4079 "unexpected token '%s'" +4080 "expected identifier for segment name, found '%s'" +4081 "expected a comma, found '%s'" +4082 "expected an identifier, found '%s'" +4083 "expected '(', found '%s'" +4084 "expected a pragma directive, found '%s'" +4085 "expected [on | off]" +4086 "expected [1 | 2 | 4]" +4087 "'%Fs' : declared with void parameter list" +4088 "'%Fs' : pointer mismatch : parameter %d, parameter list %d" +4089 "'%Fs' : different types : parameter %d, parameter list %d" +4090 "different 'const/volatile' qualifiers" +4091 "no symbols were declared" +4092 "untagged enum/struct/union declared no symbols" +4093 "unescaped newline in character constant in inactive code" +4095 "expected ')', found '%s'" +4096 "'%Fs' must be used with '%Fs'" +4098 "void function returning a value" +4100 "'%Fs' : unreferenced formal parameter" +4101 "'%Fs' : unreferenced local variable" +4102 "'%Fs' : unreferenced label" +4104 "'%s' : near data in same_seg pragma, ignored" +4105 "'%Fs' : code modifiers only on function or pointer to function" +4106 "pragma requires integer between 1 and 127" +4107 "pragma requires integer between 15 and 255" +4108 "pragma requires integer between 79 and 132" +4109 "unexpected identifier '%s'" +4110 "unexpected token 'int constant'" +4111 "unexpected token 'string'" +4112 "macro name '%s' is reserved, '%s' ignored" +4113 "function parameter lists differed" +4114 "same type qualifier used more than once" +4115 "'%Fs' : type definition in formal parameter list" +4116 "(no tag) : type definition in formal parameter list" +4118 "pragma not supported" +4119 "different bases '%Fs' and '%Fs' specified" +4120 "_based/unbased mismatch" +4123 "different base expressions specified" +4124 "_fastcall with stack checking is inefficient" +4125 "decimal digit terminates octal escape sequence" +4126 "'%c' : unknown memory model flag" +4127 "conditional expression is constant" +4128 "storage-class specifier after type" +4129 "'%c' : unrecognized character escape sequence" +4130 "'%Fs' : logical operation on address of string constant" +4131 "'%Fs' : uses old-style declarator" +4132 "'%Fs' : const object should be initialized" +4135 "conversion between different integral types" +4136 "conversion between different floating types" +4137 "'%Fs' : no return value from floating-point function" +4138 "'*/' found outside of comment" +4139 "'0x%x' : hex escape sequence is out of range" +4140 "'%Fs' : redefined, preceding references may be invalid" /* QC */ +4185 "near call to '%Fs' in different segment" /* QC, c23 */ +4206 "assignment within conditional expression" /* QC, c23 */ +4401 "'%s' : member is bit field" +4402 "must use PTR operator" +4403 "illegal PTR operator" +4404 "period on directive ignored" +4405 "'%s' : identifier is reserved word" +4406 "operand on directive ignored" +4407 "operand size conflict" +4408 "'%s' : ambiguous label" /* QC2 */ +4409 "illegal instruction size" +4410 "illegal size for operand" +4411 "'%s' : symbol resolves to displacement register" +4412 "'%s' : identifier is also assembler mnemonic" +4413 "'%Fs' : redefined, preceding references may be invalid" /* QC2 */ +4414 "'%Fs' : short jump to function converted to near" +4000 "UNKNOWN WARNING\n\t\tContact Microsoft Product Support Services" + /* errors */ + +2001 "newline in constant" +2003 "expected 'defined id'" +2004 "expected 'defined(id)'" +2005 "#line expected a line number, found '%s'" +2006 "#include expected a file name, found '%s'" +2007 "#define syntax" +2008 "'%c' : unexpected in macro definition" +2009 "reuse of macro formal '%Fs'" +2010 "'%c' : unexpected in macro formal-parameter list" +2012 "missing name following '<'" +2013 "missing '>'" +2014 "preprocessor command must start as first non-white-space" +2015 "too many characters in constant" +2016 "no closing single quotation mark" +2017 "illegal escape sequence" +2018 "unknown character '0x%x'" +2019 "expected preprocessor directive, found '%c'" +2021 "expected exponent value, not '%c'" +2022 "'%ld' : too big for character" +2023 "divide by 0" +2024 "mod by 0" +2025 "'%s' : enum/struct/union type redefinition" +2026 "'%s' : member of enum redefinition" +2027 "use of undefined enum/struct/union '%Fs'" +2028 "struct/union member needs to be inside a struct/union" +2030 "'%Fs' : struct/union member redefinition" +2031 "'%Fs' : function cannot be struct/union member" +2033 "'%Fs' : bit field cannot have indirection" +2034 "'%Fs' : type of bit field too small for number of bits" +2035 "struct/union '%Fs' : unknown size" +2036 "left of '%s%s' must have a struct/union base type" /* QC2 */ +2037 "left of '%s' specifies undefined struct/union '%Fs'" +2038 "'%s' : not struct/union member" +2039 "'->' : left operand must point to struct/union" /* QC2 */ +2040 "'.' : left operand must have struct/union type" /* QC2 */ +2041 "illegal digit '%c' for base %d" +2042 "signed/unsigned keywords mutually exclusive" +2043 "illegal break" +2044 "illegal continue" +2045 "'%s' : label redefined" +2046 "illegal case" +2047 "illegal default" +2048 "more than one default" +2049 "case value '%ld' already used" +2050 "nonintegral switch expression" +2051 "case expression not constant" +2052 "case expression not integral" +2053 "case value %d already used" /* QC2 */ +2054 "expected '(' to follow '%Fs'" +2055 "expected formal-parameter list, not a type list" +2056 "illegal expression" +2057 "expected constant expression" +2058 "constant expression is not integral" +2059 "syntax error : '%s'" +2060 "syntax error : end-of-file found" +2061 "syntax error : identifier '%s'" +2062 "type '%s' unexpected" +2063 "'%s' : not a function" +2064 "term does not evaluate to a function" +2065 "'%s' : undefined" +2066 "cast to function type is illegal" +2067 "cast to array type is illegal" +2068 "illegal cast" +2069 "cast of void term to nonvoid" +2070 "illegal sizeof operand" +2071 "'%Fs' : illegal storage class" +2072 "'%Fs' : initialization of a function" +2075 "'%Fs' : array initialization needs curly braces" +2076 "'%Fs' : struct/union initialization needs curly braces" +2077 "nonscalar field initializer '%Fs'" +2078 "too many initializers" +2079 "'%Fs' uses undefined struct/union '%Fs'" +2080 "illegal far _fastcall function" +2081 "'%Fs' : illegal memory attribute" /* QC2 */ +2082 "redefinition of formal parameter '%Fs'" +2084 "function '%Fs' already has a body" +2085 "'%Fs' : not in formal-parameter list" +2086 "'%Fs' : redefinition" +2087 "'%Fs' : missing subscript" +2090 "function returns array" +2091 "function returns function" +2092 "array element type cannot be function" +2093 "cannot use address of automatic variable as static initializer" +2094 "label '%Fs' was undefined" +2095 "'%Fs' : actual has type void : parameter %d" +2096 "struct/union comparison illegal" +2097 "illegal initialization" +2098 "nonaddress expression" +2099 "nonconstant initializer" +2100 "illegal indirection" +2101 "'&' on constant" +2102 "'&' requires lvalue" +2103 "'&' on register variable" +2104 "'&' on bit field ignored" +2105 "'%s' needs lvalue" +2106 "'%s' : left operand must be lvalue" +2107 "illegal index, indirection not allowed" +2108 "nonintegral index" +2109 "subscript on nonarray" +2110 "pointer + pointer" +2111 "pointer + nonintegral value" +2112 "illegal pointer subtraction" +2113 "pointer subtracted from nonpointer" +2114 "'%s' : pointer on left; needs integral right" +2115 "'%s' : incompatible types" +2116 "'%s' : illegal %s operand" /* QC2 */ +2117 "'%s' : illegal for struct/union" +2118 "negative subscript" +2119 "typedef types both define indirection" +2120 "void illegal with all types" +2121 "'%s' : bad %Fs operand" +2124 "divide or mod by zero" +2125 "'%Fs' : allocation exceeds 64K" /* QC, c23 */ +2127 "parameter allocation exceeds 32K" /* QC, c23 */ +2130 "#line expected a string containing the file name, found '%s'" +2131 "more than one memory attribute" +2132 "syntax error : unexpected identifier" +2133 "'%Fs' : unknown size" +2134 "'%Fs' : struct/union too large" +2136 "'%Fs' : prototype must have parameter types" +2137 "empty character constant" +2138 "unmatched close comment '*/'" /* QC2 */ +2139 "type following '%s' is illegal" +2140 "argument cannot be function type" +2141 "value out of range for enum constant" +2142 "ellipsis requires three periods" /* QC2 */ +2143 "syntax error : missing '%s' before '%s'" +2144 "syntax error : missing '%s' before type '%Fs'" +2145 "syntax error : missing '%s' before identifier" +2146 "syntax error : missing '%s' before identifier '%s'" +2147 "unknown size" +2148 "array too large" +2149 "'%Fs' : named bit field cannot have 0 width" +2150 "'%Fs' : bit field must have type int, signed int, or unsigned int" +2151 "more than one language attribute" +2152 "'%s' : pointers to functions with different attributes" +2153 "hex constants must have at least 1 hex digit" +2154 "'%Fs' : does not refer to a segment name" +2156 "pragma must be outside function" +2157 "'%s' : must be declared before use in pragma list" +2158 "'%s' : is a function" +2159 "more than one storage class specified" +2160 "## cannot occur at the beginning of a macro definition" +2161 "## cannot occur at the end of a macro definition" +2162 "expected macro formal parameter" +2163 "'%s' : not available as an intrinsic function" +2164 "'%s' : intrinsic function not declared" +2165 "'%s' : cannot modify pointers to data" +2166 "lvalue specifies const object" +2167 "'%Fs' : too many actual parameters for intrinsic" +2168 "'%Fs' : too few actual parameters for intrinsic" +2169 "'%Fs' : intrinsic function, cannot be defined" +2170 "'%s' : not declared as a function, cannot be intrinsic" +2171 "'%s' : illegal operand" +2172 "'%Fs' : actual is not a pointer : parameter %d" +2173 "'%Fs' : actual is not a pointer : parameter %d, parameter list %d" +2174 "'%Fs' : actual has type void : parameter %d, parameter list %d" +2175 "'%Fs' : unresolved external" /* QC */ +2176 "static huge data not supported by /qc" /* QC */ +2177 "constant too big" +2178 "'%s' : storage class for same_seg variables must be extern" +2179 "'%Fs' : was used in same_seg, but storage class is no longer extern" +2180 "controlling expression has type void" +2181 "pragma requires command line option '%s'" /* QC2 */ +2182 "'%Fs' : has type void" +2183 "pragma requires command line option '%Fs'" /* QC */ +2185 "'%Fs' : illegal _based allocation" +2187 "cast of near function pointer to far function pointer" +2188 "#error : %s" /* QC2 */ +2189 "#error : %Fs" +2193 "'%Fs' : already in a segment" +2194 "'%Fs' : is a text segment" +2195 "'%Fs' : is a data segment" +2196 "/ML cannot be used with floating point" /* QC */ +2198 "'%Fs' : tried to be allocated in code segment '%Fs'" /* QC2 */ +2199 "'%Fs' : tried to be allocated in data segment '%Fs'" /* QC2 */ +2200 "'%Fs' : function has already been defined" +2201 "'%Fs' : storage class must be extern" +2202 "'interrupt' function must be 'far'" /* QC2 */ +2203 "'%s' function must be 'cdecl'" /* QC2 */ +2204 "'saveregs/interrupt' modifiers mutually exclusive" /* QC2 */ +2205 "'%Fs' : cannot initialize extern block-scoped variables" +2206 "'%Fs' : typedef cannot be used for function definition" +2207 "'%Fs' in struct/union '%Fs' has a zero-sized array" +2208 "no members defined using this type" +2209 "type cast in _based construct must be (_segment)" +2210 "'%Fs' : must be near/far data pointer" +2211 "(_segment) applied to function identifier '%s'" +2212 "'%Fs' : _based not available for functions/pointers to functions" +2213 "'%s' : illegal argument to _based" +2214 "pointers based on void require the use of :>" +2215 ":> operator only for objects based on void" +2216 "'%Fs' may not be used with '%Fs'" +2217 "'%Fs' must be used with '%Fs'" +2218 "type in _based construct must be void" +2219 "syntax error : type qualifier must be after '*'" +2220 "warning treated as error - no object file generated" +2221 "'.' : left operand points to struct/union, use '->'" +2222 "'->' : left operand has struct/union type, use '.'" +2223 "left of '->%Fs' must point to struct/union" +2224 "left of '.%Fs' must have struct/union type" +2225 "'%Fs' : first member of struct is unnamed" +2400 "in-line syntax error in '%s', found '%Fs'" +2401 "'%s' : register must be base in '%s'" +2402 "'%s' : register must be index in '%s'" +2403 "'%s' : register must be base/index in '%s'" +2404 "'%s' : illegal register in '%s'" +2405 "illegal short forward reference with offset" +2406 "'%s' : name undefined in '%s'" +2407 "illegal float register in '%s'" +2408 "illegal type on PTR operator in '%s'" +2409 "illegal type used as operator in '%s'" +2410 "'%s' : ambiguous member name in '%s'" +2411 "'%s' : illegal struct/union member in '%s'" +2412 "'%Fs' : case insensitive label redefined" +2413 "'%s' : illegal align size" +2414 "illegal number of operands" +2415 "improper operand type" +2416 "'%s' : illegal opcode for processor" +2417 "divide by zero in '%s'" +2418 "'%Fs' : not in a register" +2419 "mod by zero in '%s'" +2420 "'%s' : illegal symbol in %s" +2421 "PTR operator used with register in '%s'" +2422 "illegal segment override in '%s'" +2424 "'%Fs' : improper expression in '%s'" +2425 "'%Fs' : nonconstant expression in '%s'" +2426 "'%Fs' : illegal operator in '%s'" +2427 "'%Fs' : jump referencing label is out of range" /* QC */ +2428 "'%Fs' : segment redefinition" /* QC2 */ +2429 "'%Fs' : illegal far label reference" +2000 "UNKNOWN ERROR\n\t\tContact Microsoft Product Support Services" + + /* fatals */ + +1001 "Internal Compiler Error\n\t\t(compiler file '%s', line %d)\n\t\tContact Microsoft Product Support Services" +1003 "error count exceeds %d; stopping compilation" +1004 "unexpected end-of-file found" +1005 "string too big for buffer" +1006 "write error on compiler-generated file" +1007 "unrecognized flag '%s' in '%s'" +1008 "no input file specified" +1009 "compiler limit : macros nested too deeply" +1010 "compiler limit : macro expansion too big" +1011 "compiler limit : '%s': macro definition too big" +1012 "unmatched parenthesis - missing '%c'" +1013 "cannot open source file '%s'" /* QC2 */ +1014 "too many include files" +1015 "cannot open include file '%s'" /* QC2 */ +1016 "#if[n]def expected an identifier" +1017 "invalid integer constant expression" +1018 "unexpected '#elif'" +1019 "unexpected '#else'" +1020 "unexpected '#endif'" +1021 "invalid preprocessor command '%s'" +1022 "expected '#endif'" +1023 "cannot open source file '%Fs'" +1024 "cannot open include file '%Fs'" +1025 "compiler terminated by user" /* QC */ +1026 "parser stack overflow, please simplify your program" +1027 "DGROUP data allocation exceeds 64K" /* QC, c23 */ +1028 "'%s' : segment allocation exceeds 64K" /* QC */ +1031 "compiler limit : function calls nested too deeply" /* QC, c23 */ +1032 "cannot open object listing file '%s'" /* QC, c23 */ +1035 "expression too complex, please simplify" /* QC, c23 */ +1037 "cannot open object file '%s'" /* QC, c23 */ +1041 "cannot open compiler intermediate file - no more files" +1042 "cannot open compiler intermediate file - no such file or directory" +1043 "cannot open compiler intermediate file" +1044 "out of disk space for compiler intermediate file" +1045 "floating-point overflow" /* QC2 */ +1047 "limit of %s exceeded at '%s'" +1048 "unknown option '%c' in '%s'" +1049 "invalid numerical argument '%s'" +1052 "compiler limit : #if/#ifdef blocks nested too deeply" +1053 "compiler limit : struct/union nested too deeply" +1054 "compiler limit : initializers nested too deeply" +1055 "compiler limit : out of keys" +1056 "compiler limit : out of macro expansion space" +1057 "unexpected end-of-file in macro expansion (missing ')'?)" +1059 "compiler is out of near heap space" +1060 "compiler is out of far heap space" +1061 "compiler limit : blocks nested too deeply" /* QC */ +1062 "error writing to preprocessor output file" +1063 "compiler limit : compiler stack overflow" /* QC */ +1064 "compiler limit : token overflowed internal buffer" +1068 "cannot open file '%s'" +1069 "write error on file '%s'" /* QC */ +1070 "mismatched #if/#endif pair in file '%Fs'" +1071 "unexpected end-of-file found in comment" +1072 "'%Fs' : cannot read file" +1126 "'%Fs' : automatic allocation exceeds %s" /* QC, c23 */ +1127 "'%Fs' : segment redefinition" +1000 "UNKNOWN FATAL ERROR\n\t\tContact Microsoft Product Support Services" diff --git a/Microsoft C v6ax/BIN/C1.EXE b/Microsoft C v6ax/BIN/C1.EXE new file mode 100644 index 0000000..04955ff Binary files /dev/null and b/Microsoft C v6ax/BIN/C1.EXE differ diff --git a/Microsoft C v6ax/BIN/C1L.EXE b/Microsoft C v6ax/BIN/C1L.EXE new file mode 100644 index 0000000..7efe14e Binary files /dev/null and b/Microsoft C v6ax/BIN/C1L.EXE differ diff --git a/Microsoft C v6ax/BIN/C2.EXE b/Microsoft C v6ax/BIN/C2.EXE new file mode 100644 index 0000000..6c6d4aa Binary files /dev/null and b/Microsoft C v6ax/BIN/C2.EXE differ diff --git a/Microsoft C v6ax/BIN/C23.ERR b/Microsoft C v6ax/BIN/C23.ERR new file mode 100644 index 0000000..08dc834 --- /dev/null +++ b/Microsoft C v6ax/BIN/C23.ERR @@ -0,0 +1,78 @@ + /* fatals */ + +1001 "Internal Compiler Error\n\t\t(compiler file '%s', line %d)\n\t\tContact Microsoft Product Support Services" +1002 "compiler is out of heap space in Pass 2" +1003 "error count exceeds %d; stopping compilation" +1004 "unexpected end-of-file found" +1005 "string too big for buffer" +1006 "write error on compiler intermediate file" +1007 "unrecognized flag '%s' in '%s'" +1013 "cannot open source file '%s'" +1027 "DGROUP data allocation exceeds 64K" +1029 "there are > 512 bytes of arguments" +1030 "there are > 512 bytes of local variables" +1032 "cannot open object listing file '%s'" +1033 "cannot open assembly language output file '%s'" +1035 "expression too complex, please simplify" +1036 "cannot open source listing file '%s'" +1037 "cannot open object file '%s'" +1039 "unrecoverable heap overflow in Pass 3" +1040 "unexpected end-of-file in source file '%s'" +1041 "cannot open compiler intermediate file - no more files" +1042 "cannot open compiler intermediate file - no such file or directory" +1043 "cannot open compiler intermediate file" +1044 "out of disk space for compiler intermediate file" +1045 "floating-point overflow" +1046 "bad '%s' flag, would overwrite '%s' with '%s'" +1047 "too many '%s' flags, '%s'" +1048 "unknown option '%c' in '%s'" +1049 "invalid numerical argument '%s'" +1050 "'%s' : code segment too large" +1066 "intrinsic not implemented" +1090 "'%s' data allocation exceeds 64K" +1126 "'%s' : automatic allocation exceeds %s" +1127 "'%s': segment redefinition" +1000 "UNKNOWN FATAL ERROR\n\t\tContact Microsoft Product Support Services" + /* errors */ + +2125 "'%s' : allocation exceeds 64K" +2127 "parameter allocation exceeds 32K" +2128 "'%s' : huge array cannot be aligned to segment boundary" +2129 "static function '%s' not found" +2418 "'%s' : not in a register" +2220 "warning treated as error - no object file generated" +2427 "'%s' : jump referencing label is out of range" +2000 "UNKNOWN ERROR\n\t\tContact Microsoft Product Support Services" + + /* warnings */ + +4056 "overflow in constant arithmetic" +4057 "overflow in constant multiplication" +4058 "address of automatic (local) variable taken, DS != SS" +4059 "segment lost in conversion" +4061 "long/short mismatch in argument : conversion supplied" +4062 "near/far mismatch in argument : conversion supplied" +4063 "'%s' : function too large for post-optimizer" +4065 "recoverable heap overflow in post-optimizer - some optimizations may be missed" +4066 "local symbol table overflow - some local symbols may be missing in listings" +4069 "conversion of near pointer to long integer" +4073 "scoping too deep, deepest scoping merged when debugging" +4127 "conditional expression is constant" +4185 "near call to '%s' in different segment" +4186 "string too long - truncated to %d characters" +4200 "local variable '%s' used without having been initialized" +4201 "local variable '%s' may be used without having been initialized" +4202 "unreachable code" +4203 "'%s' : function too large for global optimizations" +4204 "'%s' : in-line assembler precludes global optimizations" +4205 "statement has no effect" +4206 "assignment within conditional expression" +4207 "'%s' : function too large for global optimizations (%s)" /* +internal use */ +4208 "Ran out of heap at: %s" /* internal use */ +4209 "comma operator within array index expression" +4300 "insufficient memory to process debugging information" +4301 "loss of debugging information caused by optimization" +4323 "potential divide by 0" +4324 "potential mod by 0" +4000 "UNKNOWN WARNING\n\t\tContact Microsoft Product Support Services" diff --git a/Microsoft C v6ax/BIN/C2L.EXE b/Microsoft C v6ax/BIN/C2L.EXE new file mode 100644 index 0000000..72bbb84 Binary files /dev/null and b/Microsoft C v6ax/BIN/C2L.EXE differ diff --git a/Microsoft C v6ax/BIN/C3.EXE b/Microsoft C v6ax/BIN/C3.EXE new file mode 100644 index 0000000..b461e30 Binary files /dev/null and b/Microsoft C v6ax/BIN/C3.EXE differ diff --git a/Microsoft C v6ax/BIN/CL.ERR b/Microsoft C v6ax/BIN/CL.ERR new file mode 100644 index 0000000..d63970c --- /dev/null +++ b/Microsoft C v6ax/BIN/CL.ERR @@ -0,0 +1,36 @@ + /* error messages */ + +2001 "too many symbols predefined with /D" +2002 "conflict in memory-model specification" +2003 "missing source file name" +2008 "limit of %s exceeded at '%s'" +2011 "only one floating-point option allowed" +2012 "too many linker flags on command line" +2013 "incomplete model specification" +2016 "'%s' and '%s' are incompatible" +2018 "cannot open linker response file" +2019 "cannot overwrite the source/object file, '%s'" +2020 "%s option requires extended keywords to be enabled (/Ze)" +2021 "invalid numerical argument '%s'" +2022 "cannot open help file, '%s'" +2027 "could not execute '%s'" +2028 "too many open files, cannot redirect '%s'" +2030 "INTERNAL COMPILER ERROR in '%s'\n\t\tContact Microsoft Product Support Services" +2031 "too many flags/files on command line" +2000 "UNKNOWN COMMAND LINE ERROR\n\t\tContact Microsoft Product Support Services" + + /* warning messages */ + +4001 "listing overrides assembly output" +4002 "ignoring unknown flag '%s'" +4003 "different processors selected for code generation" +4005 "could not locate '%s';\nPlease enter new file name (full path) or Ctrl-C to quit: " +4007 "/C ignored (must also specify /P or /E or /EP)" +4009 "threshold only for far/huge data, ignored" +4011 "preprocessing overrides source listing" +4012 "function declarations override source listing" +4013 "combined listing overrides object listing" +4014 "invalid value '%d' for '%s'; default '%d' is used" +4018 ".DEF files supported in protected mode only" +4019 "string too long; truncated to '%d' characters" +4000 "UNKNOWN COMMAND LINE WARNING\n\t\tContact Microsoft Product Support Services" diff --git a/Microsoft C v6ax/BIN/CL.EXE b/Microsoft C v6ax/BIN/CL.EXE new file mode 100644 index 0000000..f8e89b6 Binary files /dev/null and b/Microsoft C v6ax/BIN/CL.EXE differ diff --git a/Microsoft C v6ax/BIN/CL.MSG b/Microsoft C v6ax/BIN/CL.MSG new file mode 100644 index 0000000..6121a0c --- /dev/null +++ b/Microsoft C v6ax/BIN/CL.MSG @@ -0,0 +1,96 @@ +C COMPILER OPTIONS +-MEMORY MODEL- +/AS small model (default) +/AC compact model +/AM medium model +/AL large model +/AH huge model +/AT tiny model (.COM files) +-OPTIMIZATION- +/O enable optimization (same as /Ot) +/Oa ignore aliasing +/Od disable optimizations +/Oe enable registers allocations +/Og enable global optimization +/Oi enable intrinsic functions +/Ol enable loop optimizations +/On disable "unsafe" optimizations +/Op enable precision optimizations +/Or disable in_line return +/Os optimize for space +/Ot optimize for speed (default) +/Ow assume aliasing in function calls +/Ox max. optimization (/Oegilt /Gs) +-CODE GENERATION- +/G0 8086 instructions (default) +/G1 186 instructions +/G2 286 instructions +/Gm put strings in constant segment +/Gc Pascal style function calls +/Gr _fastcall type calls +/Gs no stack checking +/Gt[number] data size threshold +/Gw Windows entry sequence +-OUTPUT FILES- +/Fa[assembly listing file] +/Fb[bound executable file] +/Fc[mixed source/object listing file] +/Fe +/Fl[object listing file] +/Fm[map file] +/Fo +/Fr[source browser info file] +/FR[extended source browser info file] +/Fs[source listing file] +-PREPROCESSOR- +/C don't strip comments +/D[=text] define macro +/E preprocess to stdout +/EP same as /E but no #line +/I add #include path +/P preprocess to file +/U remove predefined macro +/u remove all predefined macros +/X ignore "standard places" +-LANGUAGE- +/Za disable extensions +/Zd line number information +/Ze enable extensions (default) +/Zg generate declarations +/Zi symbolic debugging information +/Zl remove default library info +/Zp[n] pack structs on n-byte boundary +/Zs syntax check only +-FLOATING POINT- +/FPa calls with altmath +/FPc calls with emulator +/FPc87 calls with 8087 library +/FPi inline with emulator (default) +/FPi87 inline with 8087 +-SOURCE LISTING- +/Sl set line width +/Sp set page length +/St set title string +/Ss set subtitle string +-MISCELLANEOUS- +/B[123] to invoke different C[123] +/c compile only, no link +/H external name length +/J default char type is unsigned +/qc use quick compile feature +/Tc compile file without .c +/V set version string +/W warning level +-MASM SUPPORT- +/MA +/Ta assemble file without .asm +/Fx[MASM's cross-reference file] +-LINKING- +/F stack size (hex. bytes) +/Lc link compatibility mode executable +/Lr link compatibility mode executable +/Lp link protect mode executable +/link [linker_options_and_libraries] +/ML link C runtime as part of DLL +/MD use C runtime as DLL +/MT support multi-thread diff --git a/Microsoft C v6ax/BIN/CV.EXE b/Microsoft C v6ax/BIN/CV.EXE new file mode 100644 index 0000000..b6f7ddd Binary files /dev/null and b/Microsoft C v6ax/BIN/CV.EXE differ diff --git a/Microsoft C v6ax/BIN/FIXSHIFT.COM b/Microsoft C v6ax/BIN/FIXSHIFT.COM new file mode 100644 index 0000000..ef521a1 Binary files /dev/null and b/Microsoft C v6ax/BIN/FIXSHIFT.COM differ diff --git a/Microsoft C v6ax/BIN/HIMEM.SYS b/Microsoft C v6ax/BIN/HIMEM.SYS new file mode 100644 index 0000000..a7f2edf Binary files /dev/null and b/Microsoft C v6ax/BIN/HIMEM.SYS differ diff --git a/Microsoft C v6ax/BIN/MSHERC.COM b/Microsoft C v6ax/BIN/MSHERC.COM new file mode 100644 index 0000000..b06167c Binary files /dev/null and b/Microsoft C v6ax/BIN/MSHERC.COM differ diff --git a/Microsoft C v6ax/BIN/NEW-CONF.SYS b/Microsoft C v6ax/BIN/NEW-CONF.SYS new file mode 100644 index 0000000..b4818ff --- /dev/null +++ b/Microsoft C v6ax/BIN/NEW-CONF.SYS @@ -0,0 +1,3 @@ +files=20 +buffers=10 +device=C:\C600\BIN\himem.sys diff --git a/Microsoft C v6ax/BIN/NEW-VARS.BAT b/Microsoft C v6ax/BIN/NEW-VARS.BAT new file mode 100644 index 0000000..d26818e --- /dev/null +++ b/Microsoft C v6ax/BIN/NEW-VARS.BAT @@ -0,0 +1,5 @@ +SET PATH=C:\C600\BINB;C:\C600\BIN;Z:\ +SET LIB=C:\C600\LIB +SET INCLUDE=C:\C600\INCLUDE +SET HELPFILES=C:\C600\HELP\*.HLP +SET INIT=C:\C600\INIT diff --git a/Microsoft C v6ax/BIN/NMAKE.EXE b/Microsoft C v6ax/BIN/NMAKE.EXE new file mode 100644 index 0000000..e61ec52 Binary files /dev/null and b/Microsoft C v6ax/BIN/NMAKE.EXE differ diff --git a/Microsoft C v6ax/BIN/NMK.COM b/Microsoft C v6ax/BIN/NMK.COM new file mode 100644 index 0000000..69923a8 Binary files /dev/null and b/Microsoft C v6ax/BIN/NMK.COM differ diff --git a/Microsoft C v6ax/BIN/QCC.EXE b/Microsoft C v6ax/BIN/QCC.EXE new file mode 100644 index 0000000..87f69ba Binary files /dev/null and b/Microsoft C v6ax/BIN/QCC.EXE differ diff --git a/Microsoft C v6ax/BIN/RAMDRIVE.SYS b/Microsoft C v6ax/BIN/RAMDRIVE.SYS new file mode 100644 index 0000000..4741ec6 Binary files /dev/null and b/Microsoft C v6ax/BIN/RAMDRIVE.SYS differ diff --git a/Microsoft C v6ax/BIN/SMARTDRV.SYS b/Microsoft C v6ax/BIN/SMARTDRV.SYS new file mode 100644 index 0000000..e7fbb75 Binary files /dev/null and b/Microsoft C v6ax/BIN/SMARTDRV.SYS differ diff --git a/Microsoft C v6ax/BINB/BIND.EXE b/Microsoft C v6ax/BINB/BIND.EXE new file mode 100644 index 0000000..0166085 Binary files /dev/null and b/Microsoft C v6ax/BINB/BIND.EXE differ diff --git a/Microsoft C v6ax/BINB/CVPACK.EXE b/Microsoft C v6ax/BINB/CVPACK.EXE new file mode 100644 index 0000000..a661ca8 Binary files /dev/null and b/Microsoft C v6ax/BINB/CVPACK.EXE differ diff --git a/Microsoft C v6ax/BINB/EXEHDR.EXE b/Microsoft C v6ax/BINB/EXEHDR.EXE new file mode 100644 index 0000000..d7b50dd Binary files /dev/null and b/Microsoft C v6ax/BINB/EXEHDR.EXE differ diff --git a/Microsoft C v6ax/BINB/HELPMAKE.EXE b/Microsoft C v6ax/BINB/HELPMAKE.EXE new file mode 100644 index 0000000..8277653 Binary files /dev/null and b/Microsoft C v6ax/BINB/HELPMAKE.EXE differ diff --git a/Microsoft C v6ax/BINB/ILINK.EXE b/Microsoft C v6ax/BINB/ILINK.EXE new file mode 100644 index 0000000..d2916cc Binary files /dev/null and b/Microsoft C v6ax/BINB/ILINK.EXE differ diff --git a/Microsoft C v6ax/BINB/ILINKSTB.OVL b/Microsoft C v6ax/BINB/ILINKSTB.OVL new file mode 100644 index 0000000..758cce1 Binary files /dev/null and b/Microsoft C v6ax/BINB/ILINKSTB.OVL differ diff --git a/Microsoft C v6ax/BINB/IMPLIB.EXE b/Microsoft C v6ax/BINB/IMPLIB.EXE new file mode 100644 index 0000000..035c8af Binary files /dev/null and b/Microsoft C v6ax/BINB/IMPLIB.EXE differ diff --git a/Microsoft C v6ax/BINB/LIB.EXE b/Microsoft C v6ax/BINB/LIB.EXE new file mode 100644 index 0000000..6f32d54 Binary files /dev/null and b/Microsoft C v6ax/BINB/LIB.EXE differ diff --git a/Microsoft C v6ax/BINB/LINK.EXE b/Microsoft C v6ax/BINB/LINK.EXE new file mode 100644 index 0000000..743e4e6 Binary files /dev/null and b/Microsoft C v6ax/BINB/LINK.EXE differ diff --git a/Microsoft C v6ax/BINB/QH.EXE b/Microsoft C v6ax/BINB/QH.EXE new file mode 100644 index 0000000..630e829 Binary files /dev/null and b/Microsoft C v6ax/BINB/QH.EXE differ diff --git a/Microsoft C v6ax/BINB/README.DOC b/Microsoft C v6ax/BINB/README.DOC new file mode 100644 index 0000000..ebc4ceb --- /dev/null +++ b/Microsoft C v6ax/BINB/README.DOC @@ -0,0 +1,218 @@ + + README.DOC File + + README File for Microsoft(R) CodeView for Windows, version 3.05, + Microsoft C Compiler, version 6.00AX. + + (C) Copyright Microsoft Corporation, 1991 + +========================================================================== +This file contains information on the software on the Microsoft C +Supplemental Tools diskette. + +This file contains 4 major sections: + SECTION 1. Information on installing the software on the Supplemental + Tools diskette (this diskette). + SECTION 2. Information on Microsoft CodeView for Windows, version 3.05. + SECTION 3. Information on the DOS-extended version of Microsoft C, + version 6.00AX. + +PLEASE READ ALL INFORMATION IN THIS FILE BEFORE INSTALLING ANY OF THE +SOFTWARE ON YOUR MACHINE. + +======================================================================= +SECTION 1. Supplemental Tools- installation instructions + + NOTE: We strongly suggest that you copy the DOS-extended C Compiler + to a directory different than the location of Microsoft C, + version 6.00A-- and use it from this new directory. + + +Invocation of SETUP: + MS-DOS users: use SETUP.BAT + OS/2 users: use SETUP.CMD + Usage: + setup compiler-directory [CVW-directory] + Where: + compiler-directory: the path where you want the DOS-extended + compiler to be placed + CVW-directory: the path where you want the single-monitor + version of Microsoft CodeView for Windows + to be placed. + Example: SETUP c:\msc\c600ax c:\msc\cvw305 + Will install the compiler in C:\MSC\C600AX directory + and CodeView for Windows in C:\MSC\CV305 directory + +Single file decompression: + Usage: + decomp src-filename dest-filename + + +Files contained on this (these) diskettes: + + Terminology: + "extender-ready": the .EXE is a protect-mode .EXE, but does not + actually contain the DOS-extender. These .EXEs + are invoked (by default) from the CL.EXE + driver by using the new -EM switch. + + C1L.EXE -- extender-ready C Compiler- large-model 1st pass + C2L.EXE -- extender-ready C Compiler- large-model 2nd pass + C3L.EXE -- extender-ready C Compiler- large-model 3rd pass + CL.EXE -- DOS extended C Compiler driver, version 6.00AX + CV.HLP -- New help file for CodeView for Windows, version 3.05 + (replaces CVW.HLP from CodeView for Windows, version 3.00 + CVW.EXE -- Single-monitor capable CodeView for Windows, version 3.05 + README.DOC -- The file you are reading + VCV.386 -- driver required when running CVW.EXE on non-VGA + systems + SETUP.BAT -- Setup driver-- calls DECOMP.EXE to decompress the + files + DECOMP.EXE -- Decompression utility (this is bound so it will run + on either DOS or OS/2 + SETUP.CMD -- OS/2 version of SETUP.BAT + +======================================================================= +SECTION 2. Microsoft CodeView for Windows, version 3.05 + +This section contains information on the Microsoft CodeView for Windows +debugger (CVW), version 3.05, with which you can use a single monitor +for debugging programs. Single-monitor debugging and other features +new to CVW version 3.05 are described in this readme file. All other +features work as described in chapter 7, "Debugging in Protected Mode: +CodeView for Windows," in the Windows 3.0 Software Development Kit +Tools Manual. + +This section has five parts: + +Part Note +---- ---- +1 Requirements +2 Starting CVW +3 The Output Command +4 The Debugging Display + +----------------------< Part 1: Requirements >--------------------------- + +These requirements are the same as for CVW version 3.0: + + - At least 384K of extended memory. For applications with many symbols, + 1 megabyte or more of extended memory is required. + + - For 80386/486-based systems, the WINDEBUG.386 driver is recommended. + Place the driver in your Windows SYSTEM directory and add the + following entry to the [386enh] section of your Windows SYSTEM.INI + file: + + device=windebug.386 + +For single-monitor debugging, you must have one of the following: + + - A VGA monitor. CVW directly supports single-monitor debugging with + a VGA monitor. No additional driver is needed. + + - An EGA or other monitor with a 386/486-based system. With a non-VGA + monitor, you must install the VCV.386 driver. Place the driver in + your Windows SYSTEM directory and add the following entry to the + [386enh] section of your Windows SYSTEM.INI file: + + device=vcv.386 + +-----------------------< Part 2: Starting CVW >---------------------------- + +The default startup is single-monitor. If you want to debug with two +monitors, include the /2 option described below. + + +VGA Monitor +----------- + +If you are using a VGA monitor, start CVW as described in the section +"Starting a Debugging Session" of chapter 7, "Debugging in Protected + Mode: CodeView for Windows," in the Microsoft Windows SDK Tools manual. + + +Other Monitors +-------------- + +If you are not using a VGA monitor on a 386/486 system, start CVW +with /V command-line option. + +The /V option enables single-monitor debugging with any display. You must +have the VCV.386 driver to use this option. + + +Two Monitors (the /2 option) +---------------------------- + +If you have installed the VCV.386 driver for single-monitor debugging, but +you want CVW to use a second monitor for debugging, start CVW with the /2 +option. + +(The /8 is still available and works as described in the section +"Starting a Debugging Session" of chapter 7, "Debugging in Protected +Mode: CodeView for Windows," in the Microsoft Windows SDK Tools manual.) + +--------------------< Part 3: The Output Command >------------------------- + +The Output command on the CVW View menu allows screen exchange with a +single monitor. You can also execute the command by pressing F4. + +Press any key to return to the CVW screen. + +The Output command is not available if you do not use a VGA monitor or if +you start CVW with the /V option. + +-----------------< Part 4: The Debugging Display >-------------------------- + +VGA (Without the /V Option) +--------------------------- + +The display is 50 lines only. + + +With /V Option +-------------- + +The display is 25 lines only. + +============================================================================ +SECTION 3. Information on DOS-extended Microsoft C Compiler, version 6.00AX + +Usage: The DOS-extended C Compiler, version 6.00AX should be used +only when you have encountered capacity limitation in Microsoft C Compiler +version 6.00A. + +System Requirements: + - MS DOS 3.0 or higher + One of the following: + - Microsoft Windows, version 3.0; 386 enhanced-mode DOS shell + (DPMI server) with at least 1mb extended-memory available. + - VCPI compliant extended-memory manager, such as 386Max(tm) from + Qualitas or QEMM from Quarterdeck Systems) with at least 1Mb + of extended-memory available. + - Microsoft Corporation's HIMEM.SYS and EMM386.SYS (from Microsoft + Windows, version 3.0, package-- for example) with at least 1Mb + extended memory available. + - Microsoft HIMEM.SYS (sets aside first 64K of extended-memory as + "himem" area-- compiler uses the remainder. + +Invocation: There is a single new switch to the CL driver which will +cause the DOS-extended CL.EXE (and all three large-model compiler passes) +to be invoked. This new switch is: -EM. +Note: the -B[1|2|3] switch can still be used to ovveride the passes. + + Example: + For a traditional MAKE file: + cl -EM -AS -Gsw -Oas -Zpe generic.c + For a .MAK file, created from the Microsoft Programmer's WorkBench, + change the global C flags to look like: + CFLAGS_G = /EM /W2 /BATCH + +Performance: You may notice that version C6.00AX takes slightly longer +to compile than version 6.00A. This is expected-- as the 2nd and 3rd +passes of the compiler are large-model programs (in C6.00A these are +medium-model) and, of course, a large-model program uses 32-bit +pointers, and can be slighty slower. Therefore, only use the +DOS-extended compiler if you are encountering capacity limitations. + diff --git a/Microsoft C v6ax/BINB/SETUP.EXE b/Microsoft C v6ax/BINB/SETUP.EXE new file mode 100644 index 0000000..6ea9eaa Binary files /dev/null and b/Microsoft C v6ax/BINB/SETUP.EXE differ diff --git a/Microsoft C v6ax/CODE/E.C b/Microsoft C v6ax/CODE/E.C new file mode 100644 index 0000000..b593041 --- /dev/null +++ b/Microsoft C v6ax/CODE/E.C @@ -0,0 +1,35 @@ +#include + +#ifndef MWC +#include +#include +#endif + +#define DIGITS_TO_FIND 200 /*9009*/ + +int main() { + + int N = DIGITS_TO_FIND; + int x = 0; + int a[ DIGITS_TO_FIND ]; + int n; + + for (n = N - 1; n > 0; --n) { + a[n] = 1; + } + + a[1] = 2, a[0] = 0; + while (N > 9) { + n = N--; + while (--n) { + a[n] = x % n; + + x = 10 * a[n-1] + x/n; + } + printf("%d", x); + } + + printf( "\ndone\n" ); + + return 0; +} diff --git a/Microsoft C v6ax/CODE/SIEVE.C b/Microsoft C v6ax/CODE/SIEVE.C new file mode 100644 index 0000000..236f1d4 --- /dev/null +++ b/Microsoft C v6ax/CODE/SIEVE.C @@ -0,0 +1,35 @@ +/* sieve.c */ + +/* Eratosthenes Sieve Prime Number Program in C from Byte Jan 1983 + to compare the speed. */ + +#include + +#define TRUE 1 +#define FALSE 0 +#define SIZE 8190 +typedef int bool; + +char flags[SIZE+1]; + +int main() + { + int i,k; + int prime,count,iter; + + for (iter = 1; iter <= 10; iter++) { /* do program 10 times */ + count = 0; /* initialize prime counter */ + for (i = 0; i <= SIZE; i++) /* set all flags TRUE */ + flags[i] = TRUE; + for (i = 0; i <= SIZE; i++) { + if (flags[i]) { /* found a prime */ + prime = i + i + 3; /* twice index + 3 */ + for (k = i + prime; k <= SIZE; k += prime) + flags[k] = FALSE; /* kill all multiples */ + count++; /* primes found */ + } + } + } + printf("%d primes.\n",count); /*primes found in 10th pass */ + return 0; + } diff --git a/Microsoft C v6ax/CODE/TM.C b/Microsoft C v6ax/CODE/TM.C new file mode 100644 index 0000000..d9a4c13 --- /dev/null +++ b/Microsoft C v6ax/CODE/TM.C @@ -0,0 +1,169 @@ +#include + +#ifdef AZTEC86 +#include +#endif + +#ifdef HISOFTC +#include +#endif + +#ifdef INTELC +#include +#endif + +#ifdef WATCOM +#include +#include +#endif + + +#ifdef powerc +#define allocs 50 +#else +#ifdef HISOFTC +#define allocs 66 /* not enough RAM with hisoft to go higher */ +#else +/* most c runtimes work up to 69, but use 66 to have a consistent benchmark */ +#define allocs 66 +#endif +#endif + +int logging = 1; + +char * memset_x( p, v, c ) char * p; int v; int c; +{ + unsigned char * pc = (unsigned char *) p; + unsigned char val = (unsigned char) ( v & 0xff ); + int i; + + if ( 0 == p ) + { + printf( "request to memset a null pointer\n" ); + exit( 1 ); + } + + if ( logging ) +#ifdef CPMTIME + printf( " memset p %u, v %d, val %x, c %d\n", p, v, val, c ); +#else + +#ifdef HISOFTC + printf( " memset p %u, v %d, val %x, c %d\n", p, v, val, c ); +#else + printf( " memset p %p, v %d, val %x, c %d\n", p, v, val, c ); +#endif +#endif + + for ( i = 0; i < c; i++ ) + *pc++ = val; + return p; +} + +void chkmem( p, v, c ) char * p; int v; int c; +{ + unsigned char * pc = (unsigned char *) p; + unsigned char val = (unsigned char) ( v & 0xff ); + int i; + + if ( 0 == p ) + { + printf( "request to chkmem a null pointer\n" ); + exit( 1 ); + } + + for ( i = 0; i < c; i++ ) + { + if ( *pc != val ) + { +#ifdef CPMTIME + printf( "memory isn't as expected! p %u, v %d, c %d, *pc %d\n",p, v, c, *pc ); +#else + printf( "memory isn't as expected! p %p, v %d, c %d, *pc %d\n",p, v, c, *pc ); +#endif + exit( 1 ); + } + pc++; + } +} + +int main( argc, argv ) int argc; char * argv[]; +{ + int i, cb, c_cb, j; + char * pc; + char * ap[ allocs ]; + + logging = ( argc > 1 ); + pc = argv[ 0 ]; /* evade compiler warning */ + + for ( j = 0; j < 10; j++ ) + { + if ( logging ) + printf( "in alloc mode\n" ); + + for ( i = 0; i < allocs; i++ ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 5; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + ap[ i ] = (char *) malloc( cb ); + memset_x( ap[ i ], 0xaa, cb ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + + if ( logging ) + printf( "in free mode, even first\n" ); + + for ( i = 0; i < allocs; i += 2 ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 3; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + chkmem( ap[ i ], 0xaa, cb ); + memset_x( ap[ i ], 0xff, cb ); + free( ap[ i ] ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + + if ( logging ) + printf( "in free mode, now odd\n" ); + + for ( i = 1; i < allocs; i += 2 ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 7; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + chkmem( ap[ i ], 0xaa, cb ); + memset_x( ap[ i ], 0xff, cb ); + free( ap[ i ] ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + } + + printf( "success\n" ); + return 0; +} diff --git a/Microsoft C v6ax/CODE/TTT.C b/Microsoft C v6ax/CODE/TTT.C new file mode 100644 index 0000000..92c5eef --- /dev/null +++ b/Microsoft C v6ax/CODE/TTT.C @@ -0,0 +1,527 @@ +/* + This version builds with old compilers including: + Aztec C 1.06 for 8080 & Z80 on CP/M. + Microsoft C Compiler V1.04 for 8086 on DOS. (This is Lattice C) + Microsoft C Compiler V2.03 for 8086 on DOS. (Still Lattice C) + Microsoft C Compiler V3.00 for 8086 on DOS. + QuickC 1.0 + Turbo C 2.0 + The syntax is old and reminds me of 7th grade summer vacation. + Much of this code is awkward to satisfy the lowest common denominator of many compilers. + unsigned long isn't supported in many older compilers, so long is used instead. + Early DOS and CP/M require register variabes to be int, not char or other types. + The perf improvement of using register-int instead of stack-char is worth it. +*/ + +#define LINT_ARGS + +#include + +#ifdef DOSTIME +#include +#include +#endif + +#define true 1 +#define false 0 + +/* Function Pointers are the fastest implementation for almost every compiler */ +#define UseFunPointers 1 +#define UseWinner2 2 +#define UseLookForWinner 3 +#define WinMethod UseFunPointers + +#define ABPrune true /* alpha beta pruning */ +#define WinLosePrune true /* stop early on win/lose */ +#define ScoreWin 6 +#define ScoreTie 5 +#define ScoreLose 4 +#define ScoreMax 9 +#define ScoreMin 2 +#define DefaultIterations 10 + +#define PieceX 1 +#define PieceO 2 +#define PieceBlank 0 + +typedef char ttype; /* 8-bit and 16-bit cpus do best with char aside from register in locals */ + +int g_Iterations = DefaultIterations; +ttype g_board[ 9 ]; + +#if WinMethod == UseFunPointers + +ttype pos0func() +{ + /* using "register int" instead of "ttype" for x is faster on 8086 and Z80 */ + register int x = g_board[0]; + + if ( ( x == g_board[1] && x == g_board[2] ) || + ( x == g_board[3] && x == g_board[6] ) || + ( x == g_board[4] && x == g_board[8] ) ) + return x; + return PieceBlank; +} + +ttype pos1func() +{ + register int x = g_board[1]; + + if ( ( x == g_board[0] && x == g_board[2] ) || + ( x == g_board[4] && x == g_board[7] ) ) + return x; + return PieceBlank; +} + +ttype pos2func() +{ + register int x = g_board[2]; + + if ( ( x == g_board[0] && x == g_board[1] ) || + ( x == g_board[5] && x == g_board[8] ) || + ( x == g_board[4] && x == g_board[6] ) ) + return x; + return PieceBlank; +} + +ttype pos3func() +{ + register int x = g_board[3]; + + if ( ( x == g_board[4] && x == g_board[5] ) || + ( x == g_board[0] && x == g_board[6] ) ) + return x; + return PieceBlank; +} + +ttype pos4func() +{ + register int x = g_board[4]; + + if ( ( x == g_board[0] && x == g_board[8] ) || + ( x == g_board[2] && x == g_board[6] ) || + ( x == g_board[1] && x == g_board[7] ) || + ( x == g_board[3] && x == g_board[5] ) ) + return x; + return PieceBlank; +} + +ttype pos5func() +{ + register int x = g_board[5]; + + if ( ( x == g_board[3] && x == g_board[4] ) || + ( x == g_board[2] && x == g_board[8] ) ) + return x; + return PieceBlank; +} + +ttype pos6func() +{ + register int x = g_board[6]; + + if ( ( x == g_board[7] && x == g_board[8] ) || + ( x == g_board[0] && x == g_board[3] ) || + ( x == g_board[4] && x == g_board[2] ) ) + return x; + return PieceBlank; +} + +ttype pos7func() +{ + register int x = g_board[7]; + + if ( ( x == g_board[6] && x == g_board[8] ) || + ( x == g_board[1] && x == g_board[4] ) ) + return x; + return PieceBlank; +} + +ttype pos8func() +{ + register int x = g_board[8]; + + if ( ( x == g_board[6] && x == g_board[7] ) || + ( x == g_board[2] && x == g_board[5] ) || + ( x == g_board[0] && x == g_board[4] ) ) + return x; + return PieceBlank; +} + +typedef ttype pfunc_t(); + +pfunc_t * winner_functions[9] = +{ + pos0func, + pos1func, + pos2func, + pos3func, + pos4func, + pos5func, + pos6func, + pos7func, + pos8func +}; + +#endif + +#if WinMethod == UseWinner2 + +ttype winner2( move ) ttype move; +{ + register int x; /* faster than ttype x on the stack */ + + switch( move ) /* msc v3 from 1985 generates a jump table! */ + { + case 0: + { + x = g_board[ 0 ]; + if ( ( ( x == g_board[1] ) && ( x == g_board[2] ) ) || + ( ( x == g_board[3] ) && ( x == g_board[6] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[8] ) ) ) + return x; + break; + } + case 1: + { + x = g_board[ 1 ]; + if ( ( ( x == g_board[0] ) && ( x == g_board[2] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[7] ) ) ) + return x; + break; + } + case 2: + { + x = g_board[ 2 ]; + if ( ( ( x == g_board[0] ) && ( x == g_board[1] ) ) || + ( ( x == g_board[5] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[6] ) ) ) + return x; + break; + } + case 3: + { + x = g_board[ 3 ]; + if ( ( ( x == g_board[4] ) && ( x == g_board[5] ) ) || + ( ( x == g_board[0] ) && ( x == g_board[6] ) ) ) + return x; + break; + } + case 4: + { + x = g_board[ 4 ]; + if ( ( ( x == g_board[0] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[2] ) && ( x == g_board[6] ) ) || + ( ( x == g_board[1] ) && ( x == g_board[7] ) ) || + ( ( x == g_board[3] ) && ( x == g_board[5] ) ) ) + return x; + break; + } + case 5: + { + x = g_board[ 5 ]; + if ( ( ( x == g_board[3] ) && ( x == g_board[4] ) ) || + ( ( x == g_board[2] ) && ( x == g_board[8] ) ) ) + return x; + break; + } + case 6: + { + x = g_board[ 6 ]; + if ( ( ( x == g_board[7] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[0] ) && ( x == g_board[3] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[2] ) ) ) + return x; + break; + } + case 7: + { + x = g_board[ 7 ]; + if ( ( ( x == g_board[6] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[1] ) && ( x == g_board[4] ) ) ) + return x; + break; + } + case 8: + { + x = g_board[ 8 ]; + if ( ( ( x == g_board[6] ) && ( x == g_board[7] ) ) || + ( ( x == g_board[2] ) && ( x == g_board[5] ) ) || + ( ( x == g_board[0] ) && ( x == g_board[4] ) ) ) + return x; + break; + } + } + + return PieceBlank; +} /*winner2*/ + +#endif + +#if WinMethod == UseLookForWinner + +ttype LookForWinner() +{ + register int p = g_board[0]; /* faster as register int than ttype on 8086 and Z80 */ + if ( PieceBlank != p ) + { + if ( p == g_board[1] && p == g_board[2] ) + return p; + + if ( p == g_board[3] && p == g_board[6] ) + return p; + } + + p = g_board[3]; + if ( PieceBlank != p && p == g_board[4] && p == g_board[5] ) + return p; + + p = g_board[6]; + if ( PieceBlank != p && p == g_board[7] && p == g_board[8] ) + return p; + + p = g_board[1]; + if ( PieceBlank != p && p == g_board[4] && p == g_board[7] ) + return p; + + p = g_board[2]; + if ( PieceBlank != p && p == g_board[5] && p == g_board[8] ) + return p; + + p = g_board[4]; + if ( PieceBlank != p ) + { + if ( ( p == g_board[0] ) && ( p == g_board[8] ) ) + return p; + + if ( ( p == g_board[2] ) && ( p == g_board[6] ) ) + return p; + } + + return PieceBlank; +} /*LookForWinner*/ + +#endif + +int g_IMoves = 0; + +ttype MinMax( alpha, beta, depth, move ) ttype alpha; ttype beta; ttype depth; ttype move; +{ + ttype pieceMove, score; /* better perf with char than int. out of registers so use stack */ + register int p, value; /* better perf with these as an int on Z80, 8080, and 8086 */ + + g_IMoves++; + + if ( depth >= 4 ) + { +#if WinMethod == UseFunPointers + p = ( * winner_functions[ move ] )(); +#endif +#if WinMethod == UseWinner2 + p = winner2( move ); +#endif +#if WinMethod == UseLookForWinner + p = LookForWinner(); +#endif + + if ( PieceBlank != p ) + { + if ( PieceX == p ) + return ScoreWin; + + return ScoreLose; + } + + if ( 8 == depth ) + return ScoreTie; + } + + if ( depth & 1 ) + { + value = ScoreMin; + pieceMove = PieceX; + } + else + { + value = ScoreMax; + pieceMove = PieceO; + } + + for ( p = 0; p < 9; p++ ) + { + if ( PieceBlank == g_board[ p ] ) + { + g_board[p] = pieceMove; + score = MinMax( alpha, beta, depth + 1, p ); + g_board[p] = PieceBlank; + + if ( depth & 1 ) + { +#if WinLosePrune /* #if statements must be in first column for MS C 1.0 */ + if ( ScoreWin == score ) + return ScoreWin; +#endif + + if ( score > value ) + { + value = score; + +#if ABPrune + if ( value >= beta ) + return value; + if ( value > alpha ) + alpha = value; +#endif + } + } + else + { +#if WinLosePrune + if ( ScoreLose == score ) + return ScoreLose; +#endif + + if ( score < value ) + { + value = score; + +#if ABPrune + if ( value <= alpha ) + return value; + if ( value < beta ) + beta = value; +#endif + } + } + } + } + + return value; +} /*MinMax*/ + +long g_Moves = 0; + +int FindSolution( position ) ttype position; +{ + register int i; + + for ( i = 0; i < 9; i++ ) + g_board[ i ] = PieceBlank; + + g_board[ position ] = PieceX; + + for ( i = 0; i < g_Iterations; i++ ) + { + g_IMoves = 0; + MinMax( ScoreMin, ScoreMax, 0, position ); + g_Moves += g_IMoves; /* do the 4-byte long addition once per loop to save work */ + } + + return 0; +} /*FindSolution*/ + +#ifdef CPMTIME + +struct CPMTimeValue +{ + int h, m, s, l; +}; + +void print_time_now() +{ + /* This CP/M BDOS call of 105 is only implemented in NTVCM -- it's not a standard CP/M 2.2 call */ + + struct CPMTimeValue t; + t.h = t.m = t.s = t.l = 0; + + bdos( 105, &t ); + printf( "current time: %02d:%02d:%02d.%02d\n", t.h, t.m, t.s, t.l ); +} /*print_time_now*/ + +long get_ms() +{ + /* This CP/M BDOS call of 105 is only implemented in NTVCM -- it's not a standard CP/M 2.2 call */ + + long h, m, s, l; + struct CPMTimeValue t; + t.h = t.m = t.s = t.l = 0; + + bdos( 105, &t ); + h = t.h; + m = t.m; + s = t.s; + l = t.l; + + return h * 3600000 + m * 60000 + s * 1000 + l * 10; +} /*get_ms*/ + +#else /* no elif with old compilers */ + +#ifdef DOSTIME + +void print_time_now() +{ + /* Make a DOS interrupt call to get the time */ + + union REGS wrIn, wrOut; + + wrIn.h.ah = 0x2c; + intdos( &wrIn, &wrOut ); + printf( "current time: %02d:%02d:%02d.%02d\n", wrOut.h.ch, wrOut.h.cl, wrOut.h.dh, wrOut.h.dl ); + fflush( stdout ); +} /*print_time_now*/ + +long get_ms() +{ + /* this function takes about 3 milliseconds on the original IBM PC */ + + long h, m, s, l; + union REGS wrIn, wrOut; + + wrIn.h.ah = 0x2c; + intdos( &wrIn, &wrOut ); + + h = wrOut.h.ch; + m = wrOut.h.cl; + s = wrOut.h.dh; + l = wrOut.h.dl; + + return h * 3600000 + m * 60000 + s * 1000 + l * 10; +} /*get_ms*/ + +#else + +/* must do this on actual CP/M machines */ + +int print_time_now() { return 0; } +long get_ms() { return 0; } + +#endif +#endif + +int main( argc, argv ) int argc; char * argv[]; +{ + long start_time, end_time; + + if ( 2 == argc ) + sscanf( argv[ 1 ], "%d", &g_Iterations ); /* no atoi in MS C 1.0 */ + + start_time = get_ms(); + + FindSolution( 0 ); + FindSolution( 1 ); + FindSolution( 4 ); + + end_time = get_ms(); + + printf( "runtime in ms: %ld\n", end_time - start_time ); + printf( "move count: %ld\n", g_Moves ); /* 6493 * g_Iterations */ + printf( "iteration count: %d\n", g_Iterations ); + printf( "method: %s\n", + ( WinMethod == UseFunPointers ) ? "function pointers" : + ( WinMethod == UseWinner2 ) ? "winner2" : + ( WinMethod == UseLookForWinner ) ? "look for winner" : + "invalid method" ); + return 0; +} /*main*/ + diff --git a/Microsoft C v6ax/CODE/m.bat b/Microsoft C v6ax/CODE/m.bat new file mode 100644 index 0000000..3cd00e1 --- /dev/null +++ b/Microsoft C v6ax/CODE/m.bat @@ -0,0 +1,4 @@ +ntvdm -c -r:.. -e:path=c:\bin;c:\binb,include=c:\include,lib=c:\lib ..\bin\cl.exe /nologo /B1 C1L /B2 C2L /Owx /Fe%1.exe /Fc%1.cod %1.c +ntvdm -c -p %1 + + diff --git a/Microsoft C v6ax/HELP/CL.HLP b/Microsoft C v6ax/HELP/CL.HLP new file mode 100644 index 0000000..968af98 Binary files /dev/null and b/Microsoft C v6ax/HELP/CL.HLP differ diff --git a/Microsoft C v6ax/HELP/CLANG.HLP b/Microsoft C v6ax/HELP/CLANG.HLP new file mode 100644 index 0000000..5ac0172 Binary files /dev/null and b/Microsoft C v6ax/HELP/CLANG.HLP differ diff --git a/Microsoft C v6ax/HELP/CV.HLP b/Microsoft C v6ax/HELP/CV.HLP new file mode 100644 index 0000000..c3122e2 Binary files /dev/null and b/Microsoft C v6ax/HELP/CV.HLP differ diff --git a/Microsoft C v6ax/HELP/LINK.HLP b/Microsoft C v6ax/HELP/LINK.HLP new file mode 100644 index 0000000..80f5784 Binary files /dev/null and b/Microsoft C v6ax/HELP/LINK.HLP differ diff --git a/Microsoft C v6ax/HELP/PWB.HLP b/Microsoft C v6ax/HELP/PWB.HLP new file mode 100644 index 0000000..62c43aa Binary files /dev/null and b/Microsoft C v6ax/HELP/PWB.HLP differ diff --git a/Microsoft C v6ax/HELP/QH.HLP b/Microsoft C v6ax/HELP/QH.HLP new file mode 100644 index 0000000..5185c83 Binary files /dev/null and b/Microsoft C v6ax/HELP/QH.HLP differ diff --git a/Microsoft C v6ax/HELP/UTILERR.HLP b/Microsoft C v6ax/HELP/UTILERR.HLP new file mode 100644 index 0000000..1b82a5c Binary files /dev/null and b/Microsoft C v6ax/HELP/UTILERR.HLP differ diff --git a/Microsoft C v6ax/HELP/UTILS.HLP b/Microsoft C v6ax/HELP/UTILS.HLP new file mode 100644 index 0000000..993cf12 Binary files /dev/null and b/Microsoft C v6ax/HELP/UTILS.HLP differ diff --git a/Microsoft C v6ax/INCLUDE/ASSERT.H b/Microsoft C v6ax/INCLUDE/ASSERT.H new file mode 100644 index 0000000..01d9058 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/ASSERT.H @@ -0,0 +1,34 @@ +/*** +*assert.h - define the assert macro +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines the assert(exp) macro. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#undef assert + +#ifdef NDEBUG + +#define assert(exp) ((void)0) + +#else + +void _FAR_ _cdecl _assert(void _FAR_ *, void _FAR_ *, unsigned); +#define assert(exp) \ + ( (exp) ? (void) 0 : _assert(#exp, __FILE__, __LINE__) ) + +#endif /* NDEBUG */ diff --git a/Microsoft C v6ax/INCLUDE/BIOS.H b/Microsoft C v6ax/INCLUDE/BIOS.H new file mode 100644 index 0000000..7e5ea77 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/BIOS.H @@ -0,0 +1,175 @@ +/*** +*bios.h - declarations for bios interface functions and supporting definitions +* +* Copyright (c) 1987-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file declares the constants, structures, and functions +* used for accessing and using various BIOS interfaces. +* +****/ + +#ifndef _MT + +/* manifest constants for BIOS serial communications (RS-232) support */ + +/* serial port services */ + +#define _COM_INIT 0 /* init serial port */ +#define _COM_SEND 1 /* send character */ +#define _COM_RECEIVE 2 /* receive character */ +#define _COM_STATUS 3 /* get serial port status */ + +/* serial port initializers. One and only one constant from each of the + * following four groups - character size, stop bit, parity, and baud rate - + * must be specified in the initialization byte. + */ + +/* character size initializers */ + +#define _COM_CHR7 2 /* 7 bits characters */ +#define _COM_CHR8 3 /* 8 bits characters */ + +/* stop bit values - on or off */ + +#define _COM_STOP1 0 /* 1 stop bit */ +#define _COM_STOP2 4 /* 2 stop bits */ + +/* parity initializers */ + +#define _COM_NOPARITY 0 /* no parity */ +#define _COM_ODDPARITY 8 /* odd parity */ +#define _COM_EVENPARITY 24 /* even parity */ + +/* baud rate initializers */ + +#define _COM_110 0 /* 110 baud */ +#define _COM_150 32 /* 150 baud */ +#define _COM_300 64 /* 300 baud */ +#define _COM_600 96 /* 600 baud */ +#define _COM_1200 128 /* 1200 baud */ +#define _COM_2400 160 /* 2400 baud */ +#define _COM_4800 192 /* 4800 baud */ +#define _COM_9600 224 /* 9600 baud */ + + +/* manifest constants for BIOS disk support */ + +/* disk services */ + +#define _DISK_RESET 0 /* reset disk controller */ +#define _DISK_STATUS 1 /* get disk status */ +#define _DISK_READ 2 /* read disk sectors */ +#define _DISK_WRITE 3 /* write disk sectors */ +#define _DISK_VERIFY 4 /* verify disk sectors */ +#define _DISK_FORMAT 5 /* format disk track */ + +/* struct used to send/receive information to/from the BIOS disk services */ + +#ifndef _DISKINFO_T_DEFINED + +struct diskinfo_t { + unsigned drive; + unsigned head; + unsigned track; + unsigned sector; + unsigned nsectors; + void _far *buffer; + }; + +#define _DISKINFO_T_DEFINED + +#endif + + +/* manifest constants for BIOS keyboard support */ + +/* keyboard services */ + +#define _KEYBRD_READ 0 /* read next character from keyboard */ +#define _KEYBRD_READY 1 /* check for keystroke */ +#define _KEYBRD_SHIFTSTATUS 2 /* get current shift key status */ + +/* services for enhanced keyboards */ + +#define _NKEYBRD_READ 0x10 /* read next character from keyboard */ +#define _NKEYBRD_READY 0x11 /* check for keystroke */ +#define _NKEYBRD_SHIFTSTATUS 0x12 /* get current shift key status */ + + +/* manifest constants for BIOS printer support */ + +/* printer services */ + +#define _PRINTER_WRITE 0 /* write character to printer */ +#define _PRINTER_INIT 1 /* intialize printer */ +#define _PRINTER_STATUS 2 /* get printer status */ + + +/* manifest constants for BIOS time of day support */ + +/* time of day services */ + +#define _TIME_GETCLOCK 0 /* get current clock count */ +#define _TIME_SETCLOCK 1 /* set current clock count */ + + +#ifndef _REGS_DEFINED + +/* word registers */ + +struct WORDREGS { + unsigned int ax; + unsigned int bx; + unsigned int cx; + unsigned int dx; + unsigned int si; + unsigned int di; + unsigned int cflag; + }; + +/* byte registers */ + +struct BYTEREGS { + unsigned char al, ah; + unsigned char bl, bh; + unsigned char cl, ch; + unsigned char dl, dh; + }; + +/* general purpose registers union - + * overlays the corresponding word and byte registers. + */ + +union REGS { + struct WORDREGS x; + struct BYTEREGS h; + }; + +/* segment registers */ + +struct SREGS { + unsigned int es; + unsigned int cs; + unsigned int ss; + unsigned int ds; + }; + +#define _REGS_DEFINED + +#endif /* _REGS_DEFINED */ + + +/* function prototypes */ + +unsigned _cdecl _bios_disk(unsigned, struct diskinfo_t *); +unsigned _cdecl _bios_equiplist(void); +unsigned _cdecl _bios_keybrd(unsigned); +unsigned _cdecl _bios_memsize(void); +unsigned _cdecl _bios_printer(unsigned, unsigned, unsigned); +unsigned _cdecl _bios_serialcom(unsigned, unsigned, unsigned); +unsigned _cdecl _bios_timeofday(unsigned, long *); +int _cdecl int86(int, union REGS *, union REGS *); +int _cdecl int86x(int, union REGS *, union REGS *, struct SREGS *); + +#endif /* _MT */ diff --git a/Microsoft C v6ax/INCLUDE/CONIO.H b/Microsoft C v6ax/INCLUDE/CONIO.H new file mode 100644 index 0000000..92266a1 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/CONIO.H @@ -0,0 +1,36 @@ +/*** +*conio.h - console and port I/O declarations +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This include file contains the function declarations for +* the MS C V2.03 compatible console and port I/O routines. +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* function prototypes */ + +char _FAR_ * _FAR_ _cdecl cgets(char _FAR_ *); +int _FAR_ _cdecl cprintf(const char _FAR_ *, ...); +int _FAR_ _cdecl cputs(const char _FAR_ *); +int _FAR_ _cdecl cscanf(const char _FAR_ *, ...); +int _FAR_ _cdecl getch(void); +int _FAR_ _cdecl getche(void); +int _FAR_ _cdecl inp(unsigned); +unsigned _FAR_ _cdecl inpw(unsigned); +int _FAR_ _cdecl kbhit(void); +int _FAR_ _cdecl outp(unsigned, int); +unsigned _FAR_ _cdecl outpw(unsigned, unsigned); +int _FAR_ _cdecl putch(int); +int _FAR_ _cdecl ungetch(int); diff --git a/Microsoft C v6ax/INCLUDE/CTYPE.H b/Microsoft C v6ax/INCLUDE/CTYPE.H new file mode 100644 index 0000000..da616df --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/CTYPE.H @@ -0,0 +1,96 @@ +/*** +*ctype.h - character conversion macros and ctype macros +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines macros for character classification/conversion. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + + +/* + * This declaration allows the user access to the ctype look-up + * array _ctype defined in ctype.obj by simply including ctype.h + */ + +#ifdef _DLL +extern unsigned char _FAR_ _cdecl _ctype[]; +#else +extern unsigned char _near _cdecl _ctype[]; +#endif + +/* set bit masks for the possible character types */ + +#define _UPPER 0x1 /* upper case letter */ +#define _LOWER 0x2 /* lower case letter */ +#define _DIGIT 0x4 /* digit[0-9] */ +#define _SPACE 0x8 /* tab, carriage return, newline, */ + /* vertical tab or form feed */ +#define _PUNCT 0x10 /* punctuation character */ +#define _CONTROL 0x20 /* control character */ +#define _BLANK 0x40 /* space char */ +#define _HEX 0x80 /* hexadecimal digit */ + +/* character classification function prototypes */ + +#ifndef _CTYPE_DEFINED +int _FAR_ _cdecl isalpha(int); +int _FAR_ _cdecl isupper(int); +int _FAR_ _cdecl islower(int); +int _FAR_ _cdecl isdigit(int); +int _FAR_ _cdecl isxdigit(int); +int _FAR_ _cdecl isspace(int); +int _FAR_ _cdecl ispunct(int); +int _FAR_ _cdecl isalnum(int); +int _FAR_ _cdecl isprint(int); +int _FAR_ _cdecl isgraph(int); +int _FAR_ _cdecl iscntrl(int); +int _FAR_ _cdecl toupper(int); +int _FAR_ _cdecl tolower(int); +int _FAR_ _cdecl _tolower(int); +int _FAR_ _cdecl _toupper(int); +int _FAR_ _cdecl isascii(int); +int _FAR_ _cdecl toascii(int); +int _FAR_ _cdecl iscsymf(int); +int _FAR_ _cdecl iscsym(int); +#define _CTYPE_DEFINED +#endif + +/* the character classification macro definitions */ + +#define isalpha(_c) ( (_ctype+1)[_c] & (_UPPER|_LOWER) ) +#define isupper(_c) ( (_ctype+1)[_c] & _UPPER ) +#define islower(_c) ( (_ctype+1)[_c] & _LOWER ) +#define isdigit(_c) ( (_ctype+1)[_c] & _DIGIT ) +#define isxdigit(_c) ( (_ctype+1)[_c] & _HEX ) +#define isspace(_c) ( (_ctype+1)[_c] & _SPACE ) +#define ispunct(_c) ( (_ctype+1)[_c] & _PUNCT ) +#define isalnum(_c) ( (_ctype+1)[_c] & (_UPPER|_LOWER|_DIGIT) ) +#define isprint(_c) ( (_ctype+1)[_c] & (_BLANK|_PUNCT|_UPPER|_LOWER|_DIGIT) ) +#define isgraph(_c) ( (_ctype+1)[_c] & (_PUNCT|_UPPER|_LOWER|_DIGIT) ) +#define iscntrl(_c) ( (_ctype+1)[_c] & _CONTROL ) +#ifndef NO_EXT_KEYS +#define toupper(_c) ( (islower(_c)) ? _toupper(_c) : (_c) ) +#define tolower(_c) ( (isupper(_c)) ? _tolower(_c) : (_c) ) +#endif +#define _tolower(_c) ( (_c)-'A'+'a' ) +#define _toupper(_c) ( (_c)-'a'+'A' ) +#define isascii(_c) ( (unsigned)(_c) < 0x80 ) +#define toascii(_c) ( (_c) & 0x7f ) + +/* MS C version 2.0 extended ctype macros */ + +#define iscsymf(_c) (isalpha(_c) || ((_c) == '_')) +#define iscsym(_c) (isalnum(_c) || ((_c) == '_')) diff --git a/Microsoft C v6ax/INCLUDE/DIRECT.H b/Microsoft C v6ax/INCLUDE/DIRECT.H new file mode 100644 index 0000000..4487f56 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/DIRECT.H @@ -0,0 +1,36 @@ +/*** +*direct.h - function declarations for directory handling/creation +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This include file contains the function declarations for the library +* functions related to directory handling and creation. +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + +/* function prototypes */ + +int _FAR_ _cdecl chdir(const char _FAR_ *); +int _FAR_ _cdecl _chdrive(int); +char _FAR_ * _FAR_ _cdecl getcwd(char _FAR_ *, int); +char _FAR_ * _FAR_ _cdecl _getdcwd(int, char _FAR_ *, int); +int _FAR_ _cdecl _getdrive(void); +int _FAR_ _cdecl mkdir(const char _FAR_ *); +int _FAR_ _cdecl rmdir(const char _FAR_ *); diff --git a/Microsoft C v6ax/INCLUDE/DOS.H b/Microsoft C v6ax/INCLUDE/DOS.H new file mode 100644 index 0000000..80b843a --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/DOS.H @@ -0,0 +1,209 @@ +/*** +*dos.h - definitions for MS-DOS interface routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Defines the structs and unions used for the direct DOS interface +* routines; includes macros to access the segment and offset +* values of far pointers, so that they may be used by the routines; and +* provides function prototypes for direct DOS interface functions. +* +****/ + + +#ifndef _REGS_DEFINED + +/* word registers */ + +struct WORDREGS { + unsigned int ax; + unsigned int bx; + unsigned int cx; + unsigned int dx; + unsigned int si; + unsigned int di; + unsigned int cflag; + }; + + +/* byte registers */ + +struct BYTEREGS { + unsigned char al, ah; + unsigned char bl, bh; + unsigned char cl, ch; + unsigned char dl, dh; + }; + + +/* general purpose registers union - + * overlays the corresponding word and byte registers. + */ + +union REGS { + struct WORDREGS x; + struct BYTEREGS h; + }; + + +/* segment registers */ + +struct SREGS { + unsigned int es; + unsigned int cs; + unsigned int ss; + unsigned int ds; + }; + +#define _REGS_DEFINED + +#endif + + +/* dosexterror structure */ + +#ifndef _DOSERROR_DEFINED + +struct DOSERROR { + int exterror; + char class; + char action; + char locus; + }; + +#define _DOSERROR_DEFINED + +#endif + + +/* _dos_findfirst structure */ + +#ifndef _FIND_T_DEFINED + +struct find_t { + char reserved[21]; + char attrib; + unsigned wr_time; + unsigned wr_date; + long size; + char name[13]; + }; + +#define _FIND_T_DEFINED + +#endif + + +/* _dos_getdate/_dossetdate and _dos_gettime/_dos_settime structures */ + +#ifndef _DATETIME_T_DEFINED + +struct dosdate_t { + unsigned char day; /* 1-31 */ + unsigned char month; /* 1-12 */ + unsigned int year; /* 1980-2099 */ + unsigned char dayofweek; /* 0-6, 0=Sunday */ + }; + +struct dostime_t { + unsigned char hour; /* 0-23 */ + unsigned char minute; /* 0-59 */ + unsigned char second; /* 0-59 */ + unsigned char hsecond; /* 0-99 */ + }; + +#define _DATETIME_T_DEFINED + +#endif + + +/* _dos_getdiskfree structure */ + +#ifndef _DISKFREE_T_DEFINED + +struct diskfree_t { + unsigned total_clusters; + unsigned avail_clusters; + unsigned sectors_per_cluster; + unsigned bytes_per_sector; + }; + +#define _DISKFREE_T_DEFINED + +#endif + + +/* manifest constants for _hardresume result parameter */ + +#define _HARDERR_IGNORE 0 /* Ignore the error */ +#define _HARDERR_RETRY 1 /* Retry the operation */ +#define _HARDERR_ABORT 2 /* Abort program issuing Interrupt 23h */ +#define _HARDERR_FAIL 3 /* Fail the system call in progress */ + /* _HARDERR_FAIL is not supported on DOS 2.x */ + +/* File attribute constants */ + +#define _A_NORMAL 0x00 /* Normal file - No read/write restrictions */ +#define _A_RDONLY 0x01 /* Read only file */ +#define _A_HIDDEN 0x02 /* Hidden file */ +#define _A_SYSTEM 0x04 /* System file */ +#define _A_VOLID 0x08 /* Volume ID file */ +#define _A_SUBDIR 0x10 /* Subdirectory */ +#define _A_ARCH 0x20 /* Archive file */ + +/* macros to break C "far" pointers into their segment and offset components + */ + +#define FP_SEG(fp) (*((unsigned _far *)&(fp)+1)) +#define FP_OFF(fp) (*((unsigned _far *)&(fp))) + + +/* external variable declarations */ + +extern unsigned int _near _cdecl _osversion; + + +/* function prototypes */ + +#ifndef _MT +int _cdecl bdos(int, unsigned int, unsigned int); +void _cdecl _chain_intr(void (_cdecl _interrupt _far *)()); +void _cdecl _disable(void); +unsigned _cdecl _dos_allocmem(unsigned, unsigned *); +unsigned _cdecl _dos_close(int); +unsigned _cdecl _dos_creat(const char *, unsigned, int *); +unsigned _cdecl _dos_creatnew(const char *, unsigned, int *); +unsigned _cdecl _dos_findfirst(const char *, unsigned, struct find_t *); +unsigned _cdecl _dos_findnext(struct find_t *); +unsigned _cdecl _dos_freemem(unsigned); +void _cdecl _dos_getdate(struct dosdate_t *); +void _cdecl _dos_getdrive(unsigned *); +unsigned _cdecl _dos_getdiskfree(unsigned, struct diskfree_t *); +unsigned _cdecl _dos_getfileattr(const char *, unsigned *); +unsigned _cdecl _dos_getftime(int, unsigned *, unsigned *); +void _cdecl _dos_gettime(struct dostime_t *); +void (_cdecl _interrupt _far * _cdecl _dos_getvect(unsigned))(); +void _cdecl _dos_keep(unsigned, unsigned); +unsigned _cdecl _dos_open(const char *, unsigned, int *); +unsigned _cdecl _dos_read(int, void _far *, unsigned, unsigned *); +unsigned _cdecl _dos_setblock(unsigned, unsigned, unsigned *); +unsigned _cdecl _dos_setdate(struct dosdate_t *); +void _cdecl _dos_setdrive(unsigned, unsigned *); +unsigned _cdecl _dos_setfileattr(const char *, unsigned); +unsigned _cdecl _dos_setftime(int, unsigned, unsigned); +unsigned _cdecl _dos_settime(struct dostime_t *); +void _cdecl _dos_setvect(unsigned, void (_cdecl _interrupt _far *)()); +unsigned _cdecl _dos_write(int, const void _far *, unsigned, unsigned *); +int _cdecl dosexterr(struct DOSERROR *); +void _cdecl _enable(void); +void _cdecl _harderr(void (_far *)()); +void _cdecl _hardresume(int); +void _cdecl _hardretn(int); +int _cdecl intdos(union REGS *, union REGS *); +int _cdecl intdosx(union REGS *, union REGS *, struct SREGS *); +int _cdecl int86(int, union REGS *, union REGS *); +int _cdecl int86x(int, union REGS *, union REGS *, struct SREGS *); +#endif /* _MT */ + +void _cdecl segread(struct SREGS *); diff --git a/Microsoft C v6ax/INCLUDE/ERRNO.H b/Microsoft C v6ax/INCLUDE/ERRNO.H new file mode 100644 index 0000000..f9ef60c --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/ERRNO.H @@ -0,0 +1,71 @@ +/*** +*errno.h - system wide error numbers (set by system calls) +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the system-wide error numbers (set by +* system calls). Conforms to the XENIX standard. Extended +* for compatibility with Uniforum standard. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* declare reference to errno */ + +#ifdef _MT +extern int _far * _cdecl _far volatile _errno(void); +#define errno (*_errno()) +#else +extern int _near _cdecl volatile errno; +#endif + +/* Error Codes */ + +#define EZERO 0 +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EUCLEAN 35 +#define EDEADLOCK 36 diff --git a/Microsoft C v6ax/INCLUDE/FCNTL.H b/Microsoft C v6ax/INCLUDE/FCNTL.H new file mode 100644 index 0000000..86c5f95 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/FCNTL.H @@ -0,0 +1,35 @@ +/*** +*fcntl.h - file control options used by open() +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines constants for the file control options used +* by the open() function. +* [System V] +* +****/ + +#define O_RDONLY 0x0000 /* open for reading only */ +#define O_WRONLY 0x0001 /* open for writing only */ +#define O_RDWR 0x0002 /* open for reading and writing */ +#define O_APPEND 0x0008 /* writes done at eof */ + +#define O_CREAT 0x0100 /* create and open file */ +#define O_TRUNC 0x0200 /* open and truncate */ +#define O_EXCL 0x0400 /* open only if file doesn't already exist */ + +/* O_TEXT files have sequences translated to on read()'s, +** and sequences translated to on write()'s +*/ + +#define O_TEXT 0x4000 /* file mode is text (translated) */ +#define O_BINARY 0x8000 /* file mode is binary (untranslated) */ + +/* macro to translate the C 2.0 name used to force binary mode for files */ + +#define O_RAW O_BINARY + +/* Open handle inherit bit */ + +#define O_NOINHERIT 0x0080 /* child process doesn't inherit file */ diff --git a/Microsoft C v6ax/INCLUDE/FLOAT.H b/Microsoft C v6ax/INCLUDE/FLOAT.H new file mode 100644 index 0000000..cdeaa1b --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/FLOAT.H @@ -0,0 +1,140 @@ +/*** +*float.h - constants for floating point values +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains defines for a number of implementation dependent +* values which are commonly used by sophisticated numerical (floating +* point) programs. +* [ANSI] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#define DBL_DIG 15 /* # of decimal digits of precision */ +#define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */ +#define DBL_MANT_DIG 53 /* # of bits in mantissa */ +#define DBL_MAX 1.7976931348623158e+308 /* max value */ +#define DBL_MAX_10_EXP 308 /* max decimal exponent */ +#define DBL_MAX_EXP 1024 /* max binary exponent */ +#define DBL_MIN 2.2250738585072014e-308 /* min positive value */ +#define DBL_MIN_10_EXP (-307) /* min decimal exponent */ +#define DBL_MIN_EXP (-1021) /* min binary exponent */ +#define DBL_RADIX 2 /* exponent radix */ +#define DBL_ROUNDS 1 /* addition rounding: near */ + +#define FLT_DIG 7 /* # of decimal digits of precision */ +#define FLT_EPSILON 1.192092896e-07F /* smallest such that 1.0+FLT_EPSILON != 1.0 */ +#define FLT_GUARD 0 +#define FLT_MANT_DIG 24 /* # of bits in mantissa */ +#define FLT_MAX 3.402823466e+38F /* max value */ +#define FLT_MAX_10_EXP 38 /* max decimal exponent */ +#define FLT_MAX_EXP 128 /* max binary exponent */ +#define FLT_MIN 1.175494351e-38F /* min positive value */ +#define FLT_MIN_10_EXP (-37) /* min decimal exponent */ +#define FLT_MIN_EXP (-125) /* min binary exponent */ +#define FLT_NORMALIZE 0 +#define FLT_RADIX 2 /* exponent radix */ +#define FLT_ROUNDS 1 /* addition rounding: near */ + +#define LDBL_DIG 19 /* # of decimal digits of precision */ +#define LDBL_EPSILON 5.4210108624275221706e-020 /* smallest such that 1.0+LDBL_EPSILON != 1.0 */ +#define LDBL_MANT_DIG 64 /* # of bits in mantissa */ +#define LDBL_MAX 1.189731495357231765e+4932L /* max value */ +#define LDBL_MAX_10_EXP 4932 /* max decimal exponent */ +#define LDBL_MAX_EXP 16384 /* max binary exponent */ +#define LDBL_MIN 3.3621031431120935063e-4932L /* min positive value */ +#define LDBL_MIN_10_EXP (-4931) /* min decimal exponent */ +#define LDBL_MIN_EXP (-16381) /* min binary exponent */ +#define LDBL_RADIX 2 /* exponent radix */ +#define LDBL_ROUNDS 1 /* addition rounding: near */ + + +/* + * 8087/80287 math control information + */ + + +/* User Control Word Mask and bit definitions. + * These definitions match the 8087/80287 + */ + +#define MCW_EM 0x003f /* interrupt Exception Masks */ +#define EM_INVALID 0x0001 /* invalid */ +#define EM_DENORMAL 0x0002 /* denormal */ +#define EM_ZERODIVIDE 0x0004 /* zero divide */ +#define EM_OVERFLOW 0x0008 /* overflow */ +#define EM_UNDERFLOW 0x0010 /* underflow */ +#define EM_INEXACT 0x0020 /* inexact (precision) */ + +#define MCW_IC 0x1000 /* Infinity Control */ +#define IC_AFFINE 0x1000 /* affine */ +#define IC_PROJECTIVE 0x0000 /* projective */ + +#define MCW_RC 0x0c00 /* Rounding Control */ +#define RC_CHOP 0x0c00 /* chop */ +#define RC_UP 0x0800 /* up */ +#define RC_DOWN 0x0400 /* down */ +#define RC_NEAR 0x0000 /* near */ + +#define MCW_PC 0x0300 /* Precision Control */ +#define PC_24 0x0000 /* 24 bits */ +#define PC_53 0x0200 /* 53 bits */ +#define PC_64 0x0300 /* 64 bits */ + + +/* initial Control Word value */ + +#define CW_DEFAULT ( IC_AFFINE + RC_NEAR + PC_64 + EM_DENORMAL + EM_UNDERFLOW + EM_INEXACT ) + + +/* user Status Word bit definitions */ + +#define SW_INVALID 0x0001 /* invalid */ +#define SW_DENORMAL 0x0002 /* denormal */ +#define SW_ZERODIVIDE 0x0004 /* zero divide */ +#define SW_OVERFLOW 0x0008 /* overflow */ +#define SW_UNDERFLOW 0x0010 /* underflow */ +#define SW_INEXACT 0x0020 /* inexact (precision) */ + + +/* invalid subconditions (SW_INVALID also set) */ + +#define SW_UNEMULATED 0x0040 /* unemulated instruction */ +#define SW_SQRTNEG 0x0080 /* square root of a neg number */ +#define SW_STACKOVERFLOW 0x0200 /* FP stack overflow */ +#define SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */ + + +/* Floating point error signals and return codes */ + +#define FPE_INVALID 0x81 +#define FPE_DENORMAL 0x82 +#define FPE_ZERODIVIDE 0x83 +#define FPE_OVERFLOW 0x84 +#define FPE_UNDERFLOW 0x85 +#define FPE_INEXACT 0x86 + +#define FPE_UNEMULATED 0x87 +#define FPE_SQRTNEG 0x88 +#define FPE_STACKOVERFLOW 0x8a +#define FPE_STACKUNDERFLOW 0x8b + +#define FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ + +/* function prototypes */ + +unsigned int _FAR_ _cdecl _clear87(void); +unsigned int _FAR_ _cdecl _control87(unsigned int, unsigned int); +void _FAR_ _cdecl _fpreset(void); +unsigned int _FAR_ _cdecl _status87(void); diff --git a/Microsoft C v6ax/INCLUDE/GRAPH.H b/Microsoft C v6ax/INCLUDE/GRAPH.H new file mode 100644 index 0000000..7d6b9b0 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/GRAPH.H @@ -0,0 +1,427 @@ +/*** +*graph.h - declare constants, functions, and macros for graphics library +* +* Copyright (c) 1987 - 1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file declares the graphics library functions and the +* structures and manifest constants that are used with them. +* +***************************************************************************/ + + +/* force word packing to avoid possible -Zp override */ +#pragma pack(2) + +/* user-visible declarations for Quick-C Graphics Library */ + +#ifndef _VIDEOCONFIG_DEFINED +/* structure for _getvideoconfig() as visible to user */ +struct videoconfig { + short numxpixels; /* number of pixels on X axis */ + short numypixels; /* number of pixels on Y axis */ + short numtextcols; /* number of text columns available */ + short numtextrows; /* number of text rows available */ + short numcolors; /* number of actual colors */ + short bitsperpixel; /* number of bits per pixel */ + short numvideopages; /* number of available video pages */ + short mode; /* current video mode */ + short adapter; /* active display adapter */ + short monitor; /* active display monitor */ + short memory; /* adapter video memory in K bytes */ +}; +#define _VIDEOCONFIG_DEFINED +#endif + + +#ifndef _XYCOORD_DEFINED +/* return value of _setvieworg(), etc. */ +struct xycoord { + short xcoord; + short ycoord; +}; +#define _XYCOORD_DEFINED +#endif + + +/* structure for text position */ +#ifndef _RCCOORD_DEFINED +struct rccoord { + short row; + short col; +}; +#define _RCCOORD_DEFINED +#endif + + + +/* ERROR HANDLING */ +short _far _cdecl _grstatus(void); + +/* Error Status Information returned by _grstatus() */ + +/* successful */ +#define _GROK 0 + +/* errors */ +#define _GRERROR (-1) +#define _GRMODENOTSUPPORTED (-2) +#define _GRNOTINPROPERMODE (-3) +#define _GRINVALIDPARAMETER (-4) +#define _GRFONTFILENOTFOUND (-5) +#define _GRINVALIDFONTFILE (-6) +#define _GRCORRUPTEDFONTFILE (-7) +#define _GRINSUFFICIENTMEMORY (-8) +#define _GRINVALIDIMAGEBUFFER (-9) + +/* warnings */ +#define _GRNOOUTPUT 1 +#define _GRCLIPPED 2 +#define _GRPARAMETERALTERED 3 + + +/* SETUP AND CONFIGURATION */ + +short _far _cdecl _setvideomode(short); +short _far _cdecl _setvideomoderows(short,short); /* return rows; 0 if error */ + +/* arguments to _setvideomode() */ +#define _MAXRESMODE (-3) /* graphics mode with highest resolution */ +#define _MAXCOLORMODE (-2) /* graphics mode with most colors */ +#define _DEFAULTMODE (-1) /* restore screen to original mode */ +#define _TEXTBW40 0 /* 40-column text, 16 grey */ +#define _TEXTC40 1 /* 40-column text, 16/8 color */ +#define _TEXTBW80 2 /* 80-column text, 16 grey */ +#define _TEXTC80 3 /* 80-column text, 16/8 color */ +#define _MRES4COLOR 4 /* 320 x 200, 4 color */ +#define _MRESNOCOLOR 5 /* 320 x 200, 4 grey */ +#define _HRESBW 6 /* 640 x 200, BW */ +#define _TEXTMONO 7 /* 80-column text, BW */ +#define _HERCMONO 8 /* 720 x 348, BW for HGC */ +#define _MRES16COLOR 13 /* 320 x 200, 16 color */ +#define _HRES16COLOR 14 /* 640 x 200, 16 color */ +#define _ERESNOCOLOR 15 /* 640 x 350, BW */ +#define _ERESCOLOR 16 /* 640 x 350, 4 or 16 color */ +#define _VRES2COLOR 17 /* 640 x 480, BW */ +#define _VRES16COLOR 18 /* 640 x 480, 16 color */ +#define _MRES256COLOR 19 /* 320 x 200, 256 color */ +#define _ORESCOLOR 64 /* 640 x 400, 1 of 16 colors (Olivetti) */ + +short _far _cdecl _setactivepage(short); +short _far _cdecl _setvisualpage(short); +short _far _cdecl _getactivepage(void); +short _far _cdecl _getvisualpage(void); + +/* videoconfig adapter values */ +/* these manifest constants can be used to determine the type of the active */ +/* adapter, using either simple comparisons or the bitwise-AND operator (&) */ +#define _MDPA 0x0001 /* Monochrome Display Adapter (MDPA) */ +#define _CGA 0x0002 /* Color Graphics Adapter (CGA) */ +#define _EGA 0x0004 /* Enhanced Graphics Adapter (EGA) */ +#define _VGA 0x0008 /* Video Graphics Array (VGA) */ +#define _MCGA 0x0010 /* MultiColor Graphics Array (MCGA) */ +#define _HGC 0x0020 /* Hercules Graphics Card (HGC) */ +#define _OCGA 0x0042 /* Olivetti Color Graphics Adapter (OCGA) */ +#define _OEGA 0x0044 /* Olivetti Enhanced Graphics Adapter (OEGA) */ +#define _OVGA 0x0048 /* Olivetti Video Graphics Array (OVGA) */ + +/* videoconfig monitor values */ +/* these manifest constants can be used to determine the type of monitor in */ +/* use, using either simple comparisons or the bitwise-AND operator (&) */ +#define _MONO 0x0001 /* Monochrome */ +#define _COLOR 0x0002 /* Color (or Enhanced emulating color) */ +#define _ENHCOLOR 0x0004 /* Enhanced Color */ +#define _ANALOGMONO 0x0008 /* Analog Monochrome only */ +#define _ANALOGCOLOR 0x0010 /* Analog Color only */ +#define _ANALOG 0x0018 /* Analog Monochrome and Color modes */ + +struct videoconfig _far * _far _cdecl _getvideoconfig(struct videoconfig _far *); + + + +/* COORDINATE SYSTEMS */ + +struct xycoord _far _cdecl _setvieworg(short, short); +#define _setlogorg _setvieworg /* obsolescent */ + +struct xycoord _far _cdecl _getviewcoord(short, short); +#define _getlogcoord _getviewcoord /* obsolescent */ + +struct xycoord _far _cdecl _getphyscoord(short, short); + +void _far _cdecl _setcliprgn(short, short, short, short); +void _far _cdecl _setviewport(short, short, short, short); + + +/* OUTPUT ROUTINES */ + +/* control parameters for _ellipse, _rectangle, _pie and _polygon */ +#define _GBORDER 2 /* draw outline only */ +#define _GFILLINTERIOR 3 /* fill using current fill mask */ + +/* parameters for _clearscreen */ +#define _GCLEARSCREEN 0 +#define _GVIEWPORT 1 +#define _GWINDOW 2 + +void _far _cdecl _clearscreen(short); + +struct xycoord _far _cdecl _moveto(short, short); +struct xycoord _far _cdecl _getcurrentposition(void); + +short _far _cdecl _lineto(short, short); +short _far _cdecl _rectangle(short, short, short, short, short); +short _far _cdecl _polygon(short, const struct xycoord _far *, short); +short _far _cdecl _arc(short, short, short, short, short, short, short, short); +short _far _cdecl _ellipse(short, short, short, short, short); +short _far _cdecl _pie(short, short, short, short, short, short, short, short, short); + +short _far _cdecl _getarcinfo(struct xycoord _far *, struct xycoord _far *, struct xycoord _far *); + +short _far _cdecl _setpixel(short, short); +short _far _cdecl _getpixel(short, short); +short _far _cdecl _floodfill(short, short, short); + + +/* PEN COLOR, LINE STYLE, WRITE MODE, FILL PATTERN */ + +short _far _cdecl _setcolor(short); +short _far _cdecl _getcolor(void); + +void _far _cdecl _setlinestyle(unsigned short); +unsigned short _far _cdecl _getlinestyle(void); + +short _far _cdecl _setwritemode(short); +short _far _cdecl _getwritemode(void); + +void _far _cdecl _setfillmask(const unsigned char _far *); +unsigned char _far * _far _cdecl _getfillmask(unsigned char _far *); + +/* COLOR SELECTION */ + +long _far _cdecl _setbkcolor(long); +long _far _cdecl _getbkcolor(void); + +long _far _cdecl _remappalette(short, long); +short _far _cdecl _remapallpalette(const long _far *); +short _far _cdecl _selectpalette(short); + + +/* TEXT */ +/* parameters for _displaycursor */ +#define _GCURSOROFF 0 +#define _GCURSORON 1 + +/* parameters for _wrapon */ +#define _GWRAPOFF 0 +#define _GWRAPON 1 + + +/* direction parameters for _scrolltextwindow */ +#define _GSCROLLUP 1 +#define _GSCROLLDOWN (-1) + +/* request maximum number of rows in _settextrows and _setvideomoderows */ +#define _MAXTEXTROWS (-1) + +short _far _cdecl _settextrows(short); /* returns # rows set; 0 if error */ +void _far _cdecl _settextwindow(short, short, short, short); +void _far _cdecl _gettextwindow(short _far *, short _far *, short _far *, short _far *); +void _far _cdecl _scrolltextwindow(short); +void _far _cdecl _outmem(const unsigned char _far *, short); +void _far _cdecl _outtext(const unsigned char _far *); +short _far _cdecl _wrapon(short); + +short _far _cdecl _displaycursor(short); +short _far _cdecl _settextcursor(short); +short _far _cdecl _gettextcursor(void); + +struct rccoord _far _cdecl _settextposition(short, short); +struct rccoord _far _cdecl _gettextposition(void); + +short _far _cdecl _settextcolor(short); +short _far _cdecl _gettextcolor(void); + + +/* SCREEN IMAGES */ + +void _far _cdecl _getimage(short, short, short, short, char _huge *); +void _far _cdecl _putimage(short, short, char _huge *, short); +long _far _cdecl _imagesize(short, short, short, short); + +/* "action verbs" for _putimage() and _setwritemode() */ +#define _GPSET 3 +#define _GPRESET 2 +#define _GAND 1 +#define _GOR 0 +#define _GXOR 4 + + +/* Color values are used with _setbkcolor in graphics modes and also by + _remappalette and _remapallpalette. Also known as palette colors. + Not to be confused with color indices (aka. color attributes). */ + +/* universal color values (all color modes): */ +#define _BLACK 0x000000L +#define _BLUE 0x2a0000L +#define _GREEN 0x002a00L +#define _CYAN 0x2a2a00L +#define _RED 0x00002aL +#define _MAGENTA 0x2a002aL +#define _BROWN 0x00152aL +#define _WHITE 0x2a2a2aL +#define _GRAY 0x151515L +#define _LIGHTBLUE 0x3F1515L +#define _LIGHTGREEN 0x153f15L +#define _LIGHTCYAN 0x3f3f15L +#define _LIGHTRED 0x15153fL +#define _LIGHTMAGENTA 0x3f153fL +#define _YELLOW 0x153f3fL +#define _BRIGHTWHITE 0x3f3f3fL + +/* the following is obsolescent and defined only for backward compatibility */ +#define _LIGHTYELLOW _YELLOW + +/* mono mode F (_ERESNOCOLOR) color values: */ +#define _MODEFOFF 0L +#define _MODEFOFFTOON 1L +#define _MODEFOFFTOHI 2L +#define _MODEFONTOOFF 3L +#define _MODEFON 4L +#define _MODEFONTOHI 5L +#define _MODEFHITOOFF 6L +#define _MODEFHITOON 7L +#define _MODEFHI 8L + +/* mono mode 7 (_TEXTMONO) color values: */ +#define _MODE7OFF 0L +#define _MODE7ON 1L +#define _MODE7HI 2L + + +/* Warning: these '_xy' entrypoints are undocumented. + They may or may not be supported in future versions. */ +struct xycoord _far _cdecl _moveto_xy(struct xycoord); +short _far _cdecl _lineto_xy(struct xycoord); +short _far _cdecl _rectangle_xy(short,struct xycoord,struct xycoord); +short _far _cdecl _arc_xy(struct xycoord, struct xycoord, struct xycoord, struct xycoord); +short _far _cdecl _ellipse_xy(short, struct xycoord, struct xycoord); +short _far _cdecl _pie_xy(short, struct xycoord, struct xycoord, struct xycoord, struct xycoord); +short _far _cdecl _getpixel_xy(struct xycoord); +short _far _cdecl _setpixel_xy(struct xycoord); +short _far _cdecl _floodfill_xy(struct xycoord, short); +void _far _cdecl _getimage_xy(struct xycoord,struct xycoord, char _huge *); +long _far _cdecl _imagesize_xy(struct xycoord,struct xycoord); +void _far _cdecl _putimage_xy(struct xycoord, char _huge *, short); + + +/* WINDOW COORDINATE SYSTEM */ + +#ifndef _WXYCOORD_DEFINED +/* structure for window coordinate pair */ +struct _wxycoord { + double wx; /* window x coordinate */ + double wy; /* window y coordinate */ + }; +#define _WXYCOORD_DEFINED +#endif + + +/* define real coordinate window - returns non-zero if successful */ +short _far _cdecl _setwindow(short,double,double,double,double); + +/* convert from view to window coordinates */ +struct _wxycoord _far _cdecl _getwindowcoord(short,short); +struct _wxycoord _far _cdecl _getwindowcoord_xy(struct xycoord); + +/* convert from window to view coordinates */ +struct xycoord _far _cdecl _getviewcoord_w(double,double); +struct xycoord _far _cdecl _getviewcoord_wxy(const struct _wxycoord _far *); + +/* return the window coordinates of the current graphics output + position as an _wxycoord structure. no error return. */ +struct _wxycoord _far _cdecl _getcurrentposition_w(void); + + +/* window coordinate entry points for graphics output routines */ + +/* returns nonzero if successful; otherwise 0 */ +short _far _cdecl _arc_w(double, double, double, double, double, double, double, double); +short _far _cdecl _arc_wxy(const struct _wxycoord _far *, const struct _wxycoord _far *, const struct _wxycoord _far *, const struct _wxycoord _far *); + +/* returns nonzero if successful; otherwise 0 */ +short _far _cdecl _ellipse_w(short, double, double, double, double); +short _far _cdecl _ellipse_wxy(short, const struct _wxycoord _far *, const struct _wxycoord _far *); + +/* returns nonzero if successful; otherwise 0 */ +short _far _cdecl _floodfill_w(double, double, short); + +/* returns pixel value at given point; -1 if unsuccessful. */ +short _far _cdecl _getpixel_w(double, double); + +/* returns nonzero if successful; otherwise 0 */ +short _far _cdecl _lineto_w(double, double); + +/* returns the view coordinates of the previous output + position as an _xycoord structure. no error return */ +struct _wxycoord _far _cdecl _moveto_w(double, double); + +/* returns nonzero if successful; otherwise 0 */ +short _far _cdecl _pie_w(short, double, double, double, double, double, double, double, double); +short _far _cdecl _pie_wxy(short, const struct _wxycoord _far *, const struct _wxycoord _far *, const struct _wxycoord _far *, const struct _wxycoord _far *); + +/* returns nonzero if successful; otherwise 0 */ +short _far _cdecl _rectangle_w(short, double, double, double, double); +short _far _cdecl _rectangle_wxy(short, const struct _wxycoord _far *, const struct _wxycoord _far *); + +/* returns nonzero if successful; otherwise 0 */ +short _far _cdecl _polygon_w(short, const double _far *, short); +short _far _cdecl _polygon_wxy(short, const struct _wxycoord _far *, short); + +/* returns previous color; -1 if unsuccessful */ +short _far _cdecl _setpixel_w(double, double); + + +/* window coordinate image routines */ + +/* no return value */ +void _far _cdecl _getimage_w(double, double, double, double, char _huge *); +void _far _cdecl _getimage_wxy(const struct _wxycoord _far *, const struct _wxycoord _far *, char _huge *); + +/* returns the image's storage size in bytes */ +long _far _cdecl _imagesize_w(double, double, double, double); +long _far _cdecl _imagesize_wxy(const struct _wxycoord _far *, const struct _wxycoord _far *); + +/* no return value */ +void _far _cdecl _putimage_w(double, double ,char _huge * ,short); + + +/* FONTS */ + +#ifndef _FONTINFO_DEFINED +/* structure for _getfontinfo() */ +struct _fontinfo { + int type; /* b0 set = vector,clear = bit map */ + int ascent; /* pix dist from top to baseline */ + int pixwidth; /* character width in pixels, 0=prop */ + int pixheight; /* character height in pixels */ + int avgwidth; /* average character width in pixels */ + char filename[81]; /* file name including path */ + char facename[32]; /* font name */ +}; +#define _FONTINFO_DEFINED +#endif + + +/* font function prototypes */ +short _far _cdecl _registerfonts( const unsigned char _far *); +void _far _cdecl _unregisterfonts( void ); +short _far _cdecl _setfont( const unsigned char _far * ); +short _far _cdecl _getfontinfo( struct _fontinfo _far * ); +void _far _cdecl _outgtext( const unsigned char _far * ); +short _far _cdecl _getgtextextent( const unsigned char _far * ); +struct xycoord _far _cdecl _setgtextvector( short, short ); +struct xycoord _far _cdecl _getgtextvector(void); + +/* restore default packing */ +#pragma pack() diff --git a/Microsoft C v6ax/INCLUDE/IO.H b/Microsoft C v6ax/INCLUDE/IO.H new file mode 100644 index 0000000..40d1968 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/IO.H @@ -0,0 +1,47 @@ +/*** +*io.h - declarations for low-level file handling and I/O functions +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains the function declarations for the low-level +* file handling and I/O functions. +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* function prototypes */ + +int _FAR_ _cdecl access(const char _FAR_ *, int); +int _FAR_ _cdecl chmod(const char _FAR_ *, int); +int _FAR_ _cdecl chsize(int, long); +int _FAR_ _cdecl close(int); +int _FAR_ _cdecl creat(const char _FAR_ *, int); +int _FAR_ _cdecl dup(int); +int _FAR_ _cdecl dup2(int, int); +int _FAR_ _cdecl eof(int); +long _FAR_ _cdecl filelength(int); +int _FAR_ _cdecl isatty(int); +int _FAR_ _cdecl locking(int, int, long); +long _FAR_ _cdecl lseek(int, long, int); +char _FAR_ * _FAR_ _cdecl mktemp(char _FAR_ *); +int _FAR_ _cdecl open(const char _FAR_ *, int, ...); +int _FAR_ _cdecl _pipe(int _FAR_ *, unsigned int, int); +int _FAR_ _cdecl read(int, void _FAR_ *, unsigned int); +int _FAR_ _cdecl remove(const char _FAR_ *); +int _FAR_ _cdecl rename(const char _FAR_ *, const char _FAR_ *); +int _FAR_ _cdecl setmode(int, int); +int _FAR_ _cdecl sopen(const char _FAR_ *, int, int, ...); +long _FAR_ _cdecl tell(int); +int _FAR_ _cdecl umask(int); +int _FAR_ _cdecl unlink(const char _FAR_ *); +int _FAR_ _cdecl write(int, const void _FAR_ *, unsigned int); diff --git a/Microsoft C v6ax/INCLUDE/LIMITS.H b/Microsoft C v6ax/INCLUDE/LIMITS.H new file mode 100644 index 0000000..09b74ef --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/LIMITS.H @@ -0,0 +1,33 @@ +/*** +*limits.h - implementation dependent values +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Contains defines for a number of implementation dependent values +* which are commonly used in C programs. +* [ANSI] +* +****/ + +#define CHAR_BIT 8 /* number of bits in a char */ +#define SCHAR_MIN (-127) /* minimum signed char value */ +#define SCHAR_MAX 127 /* maximum signed char value */ +#define UCHAR_MAX 0xff /* maximum unsigned char value */ +#ifndef _CHAR_UNSIGNED +#define CHAR_MIN SCHAR_MIN /* mimimum char value */ +#define CHAR_MAX SCHAR_MAX /* maximum char value */ +#else +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#endif +#define MB_LEN_MAX 1 /* max. # bytes in multibyte char */ +#define SHRT_MIN (-32767) /* minimum (signed) short value */ +#define SHRT_MAX 32767 /* maximum (signed) short value */ +#define USHRT_MAX 0xffff /* maximum unsigned short value */ +#define INT_MIN (-32767) /* minimum (signed) int value */ +#define INT_MAX 32767 /* maximum (signed) int value */ +#define UINT_MAX 0xffff /* maximum unsigned int value */ +#define LONG_MIN (-2147483647) /* minimum (signed) long value */ +#define LONG_MAX 2147483647 /* maximum (signed) long value */ +#define ULONG_MAX 0xffffffff /* maximum unsigned long value */ diff --git a/Microsoft C v6ax/INCLUDE/LOCALE.H b/Microsoft C v6ax/INCLUDE/LOCALE.H new file mode 100644 index 0000000..ffa7abd --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/LOCALE.H @@ -0,0 +1,78 @@ +/*** +*locale.h - definitions/declarations for localization routines +* +* Copyright (c) 1988-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the structures, values, macros, and functions +* used by the localization routines. +* [ANSI] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* define NULL pointer value */ + +#ifndef NULL +#if (_MSC_VER >= 600) +#define NULL ((void *)0) +#elif (defined(M_I86SM) || defined(M_I86MM)) +#define NULL 0 +#else +#define NULL 0L +#endif +#endif + + +/* Locale categories */ + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 + +#define LC_MIN LC_ALL +#define LC_MAX LC_TIME + + +/* Locale convention structure */ + +#ifndef _LCONV_DEFINED +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + }; +#define _LCONV_DEFINED +#endif + +/* function prototypes */ + +char _FAR_ * _FAR_ _cdecl setlocale(int, const char _FAR_ *); +struct lconv _FAR_ * _FAR_ _cdecl localeconv(void); diff --git a/Microsoft C v6ax/INCLUDE/MALLOC.H b/Microsoft C v6ax/INCLUDE/MALLOC.H new file mode 100644 index 0000000..c1df810 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/MALLOC.H @@ -0,0 +1,136 @@ +/*** +*malloc.h - declarations and definitions for memory allocation functions +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* Contains the function declarations for memory allocation functions; +* also defines manifest constants and types used by the heap routines. +* [System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + + +/* constants for based heap routines */ + +#if (_MSC_VER >= 600) +#define _NULLSEG ((_segment)0) +#define _NULLOFF ((void _based(void) *)0xffff) +#endif + + +/* constants for _heapchk/_heapset/_heapwalk routines */ + +#define _HEAPEMPTY (-1) +#define _HEAPOK (-2) +#define _HEAPBADBEGIN (-3) +#define _HEAPBADNODE (-4) +#define _HEAPEND (-5) +#define _HEAPBADPTR (-6) +#define _FREEENTRY 0 +#define _USEDENTRY 1 + + +/* maximum heap request that can ever be honored */ + +#define _HEAP_MAXREQ 0xFFE8 + + +/* types and structures */ + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + + +#ifndef _HEAPINFO_DEFINED +typedef struct _heapinfo { + int _far * _pentry; + size_t _size; + int _useflag; + } _HEAPINFO; +#define _HEAPINFO_DEFINED +#endif + + +/* external variable declarations */ + +#ifdef _DLL +extern unsigned int _FAR_ _cdecl _amblksiz; +#else +extern unsigned int _near _cdecl _amblksiz; +#endif + + +/* based heap function prototypes */ + +#if (_MSC_VER >= 600) +void _based(void) * _FAR_ _cdecl _bcalloc(_segment, size_t, size_t); +void _based(void) * _FAR_ _cdecl _bexpand(_segment, + void _based(void) *, size_t); +void _FAR_ _cdecl _bfree(_segment, void _based(void) *); +int _FAR_ _cdecl _bfreeseg(_segment); +int _FAR_ _cdecl _bheapadd(_segment, void _based(void) *, size_t); +int _FAR_ _cdecl _bheapchk(_segment); +int _FAR_ _cdecl _bheapmin(_segment); +_segment _FAR_ _cdecl _bheapseg(size_t); +int _FAR_ _cdecl _bheapset(_segment, unsigned int); +int _FAR_ _cdecl _bheapwalk(_segment, _HEAPINFO *); +void _based(void) * _FAR_ _cdecl _bmalloc(_segment, size_t); +size_t _FAR_ _cdecl _bmsize(_segment, void _based(void) *); +void _based(void) * _FAR_ _cdecl _brealloc(_segment, + void _based(void) *, size_t); +#endif + + +/* function prototypes */ + +void _FAR_ * _FAR_ _cdecl alloca(size_t); +void _FAR_ * _FAR_ _cdecl calloc(size_t, size_t); +void _FAR_ * _FAR_ _cdecl _expand(void _FAR_ *, size_t); +void _far * _FAR_ _cdecl _fcalloc(size_t, size_t); +void _far * _FAR_ _cdecl _fexpand(void _far *, size_t); +void _FAR_ _cdecl _ffree(void _far *); +int _FAR_ _cdecl _fheapchk(void); +int _FAR_ _cdecl _fheapmin(void); +int _FAR_ _cdecl _fheapset(unsigned int); +int _FAR_ _cdecl _fheapwalk(_HEAPINFO _FAR_ *); +void _far * _FAR_ _cdecl _fmalloc(size_t); +size_t _FAR_ _cdecl _fmsize(void _far *); +void _far * _FAR_ _cdecl _frealloc(void _far *, size_t); +unsigned int _FAR_ _cdecl _freect(size_t); +void _FAR_ _cdecl free(void _FAR_ *); +void _huge * _FAR_ _cdecl halloc(long, size_t); +void _FAR_ _cdecl hfree(void _huge *); +int _FAR_ _cdecl _heapadd(void _far *, size_t); +int _FAR_ _cdecl _heapchk(void); +int _FAR_ _cdecl _heapmin(void); +int _FAR_ _cdecl _heapset(unsigned int); +int _FAR_ _cdecl _heapwalk(_HEAPINFO _FAR_ *); +void _FAR_ * _FAR_ _cdecl malloc(size_t); +size_t _FAR_ _cdecl _memavl(void); +size_t _FAR_ _cdecl _memmax(void); +size_t _FAR_ _cdecl _msize(void _FAR_ *); +void _near * _FAR_ _cdecl _ncalloc(size_t, size_t); +void _near * _FAR_ _cdecl _nexpand(void _near *, size_t); +void _FAR_ _cdecl _nfree(void _near *); +int _FAR_ _cdecl _nheapchk(void); +int _FAR_ _cdecl _nheapmin(void); +int _FAR_ _cdecl _nheapset(unsigned int); +int _FAR_ _cdecl _nheapwalk(_HEAPINFO _FAR_ *); +void _near * _FAR_ _cdecl _nmalloc(size_t); +size_t _FAR_ _cdecl _nmsize(void _near *); +void _near * _FAR_ _cdecl _nrealloc(void _near *, size_t); +void _FAR_ * _FAR_ _cdecl realloc(void _FAR_ *, size_t); +size_t _FAR_ _cdecl stackavail(void); diff --git a/Microsoft C v6ax/INCLUDE/MATH.H b/Microsoft C v6ax/INCLUDE/MATH.H new file mode 100644 index 0000000..4eafae5 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/MATH.H @@ -0,0 +1,235 @@ +/*** +*math.h - definitions and declarations for math library +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains constant definitions and external subroutine +* declarations for the math subroutine library. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + + +/* definition of exception struct - this struct is passed to the matherr + * routine when a floating point exception is detected + */ + +#ifndef _EXCEPTION_DEFINED +struct exception { + int type; /* exception type - see below */ + char _FAR_ *name; /* name of function where error occured */ + double arg1; /* first argument to function */ + double arg2; /* second argument (if any) to function */ + double retval; /* value to be returned by function */ + } ; +#define _EXCEPTION_DEFINED +#endif + + +/* definition of a complex struct to be used by those who use cabs and + * want type checking on their argument + */ + +#ifndef _COMPLEX_DEFINED +struct complex { + double x,y; /* real and imaginary parts */ + } ; +#define _COMPLEX_DEFINED +#endif + + +/* Constant definitions for the exception type passed in the exception struct + */ + +#define DOMAIN 1 /* argument domain error */ +#define SING 2 /* argument singularity */ +#define OVERFLOW 3 /* overflow range error */ +#define UNDERFLOW 4 /* underflow range error */ +#define TLOSS 5 /* total loss of precision */ +#define PLOSS 6 /* partial loss of precision */ + +#define EDOM 33 +#define ERANGE 34 + + +/* definitions of HUGE and HUGE_VAL - respectively the XENIX and ANSI names + * for a value returned in case of error by a number of the floating point + * math routines + */ + +#ifndef _DLL +extern double _near _cdecl HUGE; +#define HUGE_VAL HUGE + +#else /* _DLL */ +extern double _FAR_ _cdecl HUGE; +#define HUGE_VAL HUGE + +#endif /* _DLL */ + + +/* function prototypes */ + +#ifdef _MT /* function prototypes for _MT version */ +int _FAR_ _cdecl abs(int); +double _FAR_ _pascal acos(double); +double _FAR_ _pascal asin(double); +double _FAR_ _pascal atan(double); +double _FAR_ _pascal atan2(double, double); +double _FAR_ _pascal atof(const char _FAR_ *); +double _FAR_ _pascal cabs(struct complex); +double _FAR_ _pascal ceil(double); +double _FAR_ _pascal cos(double); +double _FAR_ _pascal cosh(double); +int _FAR_ _cdecl dieeetomsbin(double _FAR_ *, double _FAR_ *); +int _FAR_ _cdecl dmsbintoieee(double _FAR_ *, double _FAR_ *); +double _FAR_ _pascal exp(double); +double _FAR_ _pascal fabs(double); +int _FAR_ _cdecl fieeetomsbin(float _FAR_ *, float _FAR_ *); +double _FAR_ _pascal floor(double); +double _FAR_ _pascal fmod(double, double); +int _FAR_ _cdecl fmsbintoieee(float _FAR_ *, float _FAR_ *); +double _FAR_ _pascal frexp(double, int _FAR_ *); +double _FAR_ _pascal hypot(double, double); +double _FAR_ _pascal j0(double); +double _FAR_ _pascal j1(double); +double _FAR_ _pascal jn(int, double); +long _FAR_ _cdecl labs(long); +double _FAR_ _pascal ldexp(double, int); +double _FAR_ _pascal log(double); +double _FAR_ _pascal log10(double); +int _FAR_ _cdecl matherr(struct exception _FAR_ *); +double _FAR_ _pascal modf(double, double _FAR_ *); +double _FAR_ _pascal pow(double, double); +double _FAR_ _pascal sin(double); +double _FAR_ _pascal sinh(double); +double _FAR_ _pascal sqrt(double); +double _FAR_ _pascal tan(double); +double _FAR_ _pascal tanh(double); +double _FAR_ _pascal y0(double); +double _FAR_ _pascal y1(double); +double _FAR_ _pascal yn(int, double); + +#else /* function prototypes for non _MT version */ +int _FAR_ _cdecl abs(int); +double _FAR_ _cdecl acos(double); +double _FAR_ _cdecl asin(double); +double _FAR_ _cdecl atan(double); +double _FAR_ _cdecl atan2(double, double); +double _FAR_ _cdecl atof(const char _FAR_ *); +double _FAR_ _cdecl cabs(struct complex); +double _FAR_ _cdecl ceil(double); +double _FAR_ _cdecl cos(double); +double _FAR_ _cdecl cosh(double); +int _FAR_ _cdecl dieeetomsbin(double _FAR_ *, double _FAR_ *); +int _FAR_ _cdecl dmsbintoieee(double _FAR_ *, double _FAR_ *); +double _FAR_ _cdecl exp(double); +double _FAR_ _cdecl fabs(double); +int _FAR_ _cdecl fieeetomsbin(float _FAR_ *, float _FAR_ *); +double _FAR_ _cdecl floor(double); +double _FAR_ _cdecl fmod(double, double); +int _FAR_ _cdecl fmsbintoieee(float _FAR_ *, float _FAR_ *); +double _FAR_ _cdecl frexp(double, int _FAR_ *); +double _FAR_ _cdecl hypot(double, double); +double _FAR_ _cdecl j0(double); +double _FAR_ _cdecl j1(double); +double _FAR_ _cdecl jn(int, double); +long _FAR_ _cdecl labs(long); +double _FAR_ _cdecl ldexp(double, int); +double _FAR_ _cdecl log(double); +double _FAR_ _cdecl log10(double); +int _FAR_ _cdecl matherr(struct exception _FAR_ *); +double _FAR_ _cdecl modf(double, double _FAR_ *); +double _FAR_ _cdecl pow(double, double); +double _FAR_ _cdecl sin(double); +double _FAR_ _cdecl sinh(double); +double _FAR_ _cdecl sqrt(double); +double _FAR_ _cdecl tan(double); +double _FAR_ _cdecl tanh(double); +double _FAR_ _cdecl y0(double); +double _FAR_ _cdecl y1(double); +double _FAR_ _cdecl yn(int, double); +#endif + + +/* definition of _exceptionl struct - this struct is passed to the _matherrl + * routine when a floating point exception is detected in a long double routine + */ + +#ifndef _LD_EXCEPTION_DEFINED +struct _exceptionl { + int type; /* exception type - see below */ + char _FAR_ *name; /* name of function where error occured */ + long double arg1; /* first argument to function */ + long double arg2; /* second argument (if any) to function */ + long double retval; /* value to be returned by function */ + } ; +#define _LD_EXCEPTION_DEFINED +#endif + + +/* definition of a _complexl struct to be used by those who use _cabsl and + * want type checking on their argument + */ + +#ifndef _LD_COMPLEX_DEFINED +struct _complexl { + long double x,y; /* real and imaginary parts */ + } ; +#define _LD_COMPLEX_DEFINED +#endif + + +#ifndef _DLL +extern long double _near _cdecl _LHUGE; +#define _LHUGE_VAL _LHUGE + +#else /* _DLL */ +extern long double _FAR_ _cdecl _LHUGE; +#define _LHUGE_VAL _LHUGE + +#endif /* _DLL */ + +long double _FAR_ _cdecl acosl(long double); +long double _FAR_ _cdecl asinl(long double); +long double _FAR_ _cdecl atanl(long double); +long double _FAR_ _cdecl atan2l(long double, long double); +long double _FAR_ _cdecl _atold(const char _FAR_ *); +long double _FAR_ _cdecl cabsl(struct _complexl); +long double _FAR_ _cdecl ceill(long double); +long double _FAR_ _cdecl cosl(long double); +long double _FAR_ _cdecl coshl(long double); +long double _FAR_ _cdecl expl(long double); +long double _FAR_ _cdecl fabsl(long double); +long double _FAR_ _cdecl floorl(long double); +long double _FAR_ _cdecl fmodl(long double, long double); +long double _FAR_ _cdecl frexpl(long double, int _FAR_ *); +long double _FAR_ _cdecl hypotl(long double, long double); +long double _FAR_ _cdecl _j0l(long double); +long double _FAR_ _cdecl _j1l(long double); +long double _FAR_ _cdecl _jnl(int, long double); +long double _FAR_ _cdecl ldexpl(long double, int); +long double _FAR_ _cdecl logl(long double); +long double _FAR_ _cdecl log10l(long double); +int _FAR_ _cdecl _matherrl(struct _exceptionl _FAR_ *); +long double _FAR_ _cdecl modfl(long double, long double _FAR_ *); +long double _FAR_ _cdecl powl(long double, long double); +long double _FAR_ _cdecl sinl(long double); +long double _FAR_ _cdecl sinhl(long double); +long double _FAR_ _cdecl sqrtl(long double); +long double _FAR_ _cdecl tanl(long double); +long double _FAR_ _cdecl tanhl(long double); +long double _FAR_ _cdecl _y0l(long double); +long double _FAR_ _cdecl _y1l(long double); +long double _FAR_ _cdecl _ynl(int, long double); diff --git a/Microsoft C v6ax/INCLUDE/MEMORY.H b/Microsoft C v6ax/INCLUDE/MEMORY.H new file mode 100644 index 0000000..77fbbbb --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/MEMORY.H @@ -0,0 +1,56 @@ +/*** +*memory.h - declarations for buffer (memory) manipulation routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This include file contains the function declarations for the +* buffer (memory) manipulation routines. +* [System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + + +/* function prototypes */ + +void _FAR_ * _FAR_ _cdecl memccpy(void _FAR_ *, const void _FAR_ *, + int, unsigned int); +void _FAR_ * _FAR_ _cdecl memchr(const void _FAR_ *, int, size_t); +int _FAR_ _cdecl memcmp(const void _FAR_ *, const void _FAR_ *, + size_t); +void _FAR_ * _FAR_ _cdecl memcpy(void _FAR_ *, const void _FAR_ *, + size_t); +int _FAR_ _cdecl memicmp(const void _FAR_ *, const void _FAR_ *, + unsigned int); +void _FAR_ * _FAR_ _cdecl memset(void _FAR_ *, int, size_t); +void _FAR_ _cdecl movedata(unsigned int, unsigned int, unsigned int, + unsigned int, unsigned int); + + +/* model independent function prototypes */ + +void _far * _far _cdecl _fmemccpy(void _far *, const void _far *, + int, unsigned int); +void _far * _far _cdecl _fmemchr(const void _far *, int, size_t); +int _far _cdecl _fmemcmp(const void _far *, const void _far *, + size_t); +void _far * _far _cdecl _fmemcpy(void _far *, const void _far *, + size_t); +int _far _cdecl _fmemicmp(const void _far *, const void _far *, + unsigned int); +void _far * _far _cdecl _fmemset(void _far *, int, size_t); diff --git a/Microsoft C v6ax/INCLUDE/PGCHART.H b/Microsoft C v6ax/INCLUDE/PGCHART.H new file mode 100644 index 0000000..f89e4b6 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/PGCHART.H @@ -0,0 +1,221 @@ +/*** +*pgchart.h - Declare constants, functions and macros for charting library. +* +* Copyright (c) 1988-1990, Microsoft Corporation, All rights reserved. +* +*Purpose: +* This file declares the presentation graphics library functions and +* the structures and manifest constants that are used with them. +* +***************************************************************************/ + +/* Force word alignment to avoid possible -Zp override */ +#pragma pack(2) + +/* Required for the missing value definition */ +#ifndef FLT_MAX +#define FLT_MAX 3.402823466e+38F /* max value */ +#endif + +#define _PG_PALETTELEN 16 /* Number of entries in internal palette */ +#define _PG_MAXCHARTTYPE 5 /* Maximum available chart type */ +#define _PG_MAXCHARTSTYLE 2 /* Maximum chart style */ +#define _PG_TITLELEN 70 /* Maximum title text length */ + +#define _PG_LEFT 1 /* Positions used for titles and legends */ +#define _PG_CENTER 2 +#define _PG_RIGHT 3 +#define _PG_BOTTOM 4 +#define _PG_OVERLAY 5 + +#define _PG_LINEARAXIS 1 /* Used to specify axis types */ +#define _PG_LOGAXIS 2 + +#define _PG_DECFORMAT 1 /* Used to specify tic mark label format */ +#define _PG_EXPFORMAT 2 + +#define _PG_BARCHART 1 /* Charttype for a bar chart */ +#define _PG_COLUMNCHART 2 /* Charttype for a column chart */ +#define _PG_PLAINBARS 1 /* Styles for bar and column charts */ +#define _PG_STACKEDBARS 2 + +#define _PG_LINECHART 3 /* Charttype for a line chart */ +#define _PG_SCATTERCHART 4 /* Charttype for a scatter chart */ +#define _PG_POINTANDLINE 1 /* Styles for line and scatter charts */ +#define _PG_POINTONLY 2 + +#define _PG_PIECHART 5 /* Charttype for pie chart */ +#define _PG_PERCENT 1 /* Styles for pie charts */ +#define _PG_NOPERCENT 2 + +#define _PG_MISSINGVALUE (-FLT_MAX) /* Indicates missing data values */ + +/* Error codes */ + +/* Numbers greater than 100 will terminate chart routine, others will cause + * default values to be used + */ +#define _PG_NOTINITIALIZED 102 /* If library not initialized */ +#define _PG_BADSCREENMODE 103 /* Graphics mode not set before charting */ +#define _PG_BADCHARTSTYLE 04 /* Chart style invalid */ +#define _PG_BADCHARTTYPE 104 /* Chart type invalid */ +#define _PG_BADLEGENDWINDOW 105 /* Invalid legend window specified */ +#define _PG_BADCHARTWINDOW 07 /* x1=x2 or y1=y2 in chart window spec. */ +#define _PG_BADDATAWINDOW 107 /* If chart window is too small */ +#define _PG_NOMEMORY 108 /* Not enough memory for data arrays */ +#define _PG_BADLOGBASE 05 /* Log base <= 0 */ +#define _PG_BADSCALEFACTOR 06 /* Scale factor = 0 */ +#define _PG_TOOSMALLN 109 /* Number of data points <= 0 */ +#define _PG_TOOFEWSERIES 110 /* Number of series <= 0 */ + +/* Typedefs */ + +/* Typedef for chart title */ +#ifndef _TITLETYPE_DEFINED +typedef struct { + char title[_PG_TITLELEN]; /* Title text */ + short titlecolor; /* Internal palette color for title text */ + short justify; /* _PG_LEFT, _PG_CENTER, _PG_RIGHT */ +} titletype; +#define _TITLETYPE_DEFINED +#endif + +/* Typedef for chart axes */ +#ifndef _AXISTYPE_DEFINED +typedef struct { + short grid; /* TRUE=grid lines drawn; FALSE no lines */ + short gridstyle; /* Style number from style pool for grid lines */ + titletype axistitle; /* Title definition for axis */ + short axiscolor; /* Color for axis */ + short labeled; /* TRUE=tic marks and titles drawn */ + short rangetype; /* _PG_LINEARAXIS, _PG_LOGAXIS */ + float logbase; /* Base used if log axis */ + short autoscale; /* TRUE=next 7 values calculated by system */ + float scalemin; /* Minimum value of scale */ + float scalemax; /* Maximum value of scale */ + float scalefactor; /* Scale factor for data on this axis */ + titletype scaletitle; /* Title definition for scaling factor */ + float ticinterval; /* Distance between tic marks (world coord.) */ + short ticformat; /* _PG_EXPFORMAT or _PG_DECFORMAT for tic labels */ + short ticdecimals; /* Number of decimals for tic labels (max=9)*/ +} axistype; +#define _AXISTYPE_DEFINED +#endif + +/* Typedef used for defining chart and data windows */ +#ifndef _WINDOWTYPE_DEFINED +typedef struct { + short x1; /* Left edge of window in pixels */ + short y1; /* Top edge of window in pixels */ + short x2; /* Right edge of window in pixels */ + short y2; /* Bottom edge of window in pixels */ + short border; /* TRUE for border, FALSE otherwise */ + short background; /* Internal palette color for window bgnd */ + short borderstyle; /* Style bytes for window border */ + short bordercolor; /* Internal palette color for window border */ +} windowtype; +#define _WINDOWTYPE_DEFINED +#endif + +/* Typedef for legend definition */ +#ifndef _LEGENDTYPE_DEFINED +typedef struct { + short legend; /* TRUE=draw legend; FALSE=no legend */ + short place; /* _PG_RIGHT, _PG_BOTTOM, _PG_OVERLAY */ + short textcolor; /* Internal palette color for text */ + short autosize; /* TRUE=system calculates size */ + windowtype legendwindow; /* Window definition for legend */ +} legendtype; +#define _LEGENDTYPE_DEFINED +#endif + +/* Typedef for legend definition */ +#ifndef _CHARTENV_DEFINED +typedef struct { + short charttype; /* _PG_BAR, _PG_COLUMN, _PG_LINE, _PG_SCATTER, _PG_PIE */ + short chartstyle; /* Style for selected chart type */ + windowtype chartwindow; /* Window definition for overall chart */ + windowtype datawindow; /* Window definition for data part of chart */ + titletype maintitle; /* Main chart title */ + titletype subtitle; /* Chart sub-title */ + axistype xaxis; /* Definition for X-axis */ + axistype yaxis; /* Definition for Y-axis */ + legendtype legend; /* Definition for legend */ +} chartenv; +#define _CHARTENV_DEFINED +#endif + +/* Typedef for character bitmap */ +#ifndef _CHARMAP_DEFINED +typedef unsigned char charmap[8]; +#define _CHARMAP_DEFINED +#endif + +/* Typedef for pattern bitmap */ +#ifndef _FILLMAP_DEFINED +typedef unsigned char fillmap[8]; +#define _FILLMAP_DEFINED +#endif + +/* Typedef for palette entry definition */ +#ifndef _PALETTEENTRY_DEFINED +typedef struct { + unsigned short color; + unsigned short style; + fillmap fill; + char plotchar; +} paletteentry; +#define _PALETTEENTRY_DEFINED +#endif + +/* Typedef for palette definition */ +#ifndef _PALETTETYPE_DEFINED +typedef paletteentry palettetype[_PG_PALETTELEN]; +#define _PALETTETYPE_DEFINED +#endif + +/* Typedef for style sets */ +#ifndef _STYLESET_DEFINED +typedef unsigned short styleset[_PG_PALETTELEN]; +#define _STYLESET_DEFINED +#endif + +/* Function prototypes for charting routines */ + +short _far _cdecl _pg_initchart(void); +short _far _cdecl _pg_defaultchart(chartenv _far *, short, short); + +short _far _cdecl _pg_chart(chartenv _far *, const char _far * const _far *, const float _far *, short); +short _far _cdecl _pg_chartms(chartenv _far *, const char _far * const _far *, const float _far *, short, short, short, const char _far * const _far *); + +short _far _cdecl _pg_chartscatter(chartenv _far *, const float _far *, const float _far *, short); +short _far _cdecl _pg_chartscatterms(chartenv _far *, const float _far *, const float _far *, short, short, short, const char _far * const _far *); + +short _far _cdecl _pg_chartpie(chartenv _far *, const char _far * const _far *, const float _far *, const short _far *, short); + +/* Function prototypes for support routines */ + +short _far _cdecl _pg_hlabelchart(chartenv _far *, short, short, short, const char _far *); +short _far _cdecl _pg_vlabelchart(chartenv _far *, short, short, short, const char _far *); + +short _far _cdecl _pg_analyzechart(chartenv _far *, const char _far * const _far *, const float _far *, short); +short _far _cdecl _pg_analyzechartms(chartenv _far *, const char _far * const _far *, const float _far *, short, short, short, const char _far * const _far *); + +short _far _cdecl _pg_analyzescatter(chartenv _far *, const float _far *, const float _far *, short); +short _far _cdecl _pg_analyzescatterms(chartenv _far *, const float _far *, const float _far *, short, short, short, const char _far * const _far *); + +short _far _cdecl _pg_analyzepie(chartenv _far *, const char _far * const _far *, const float _far *, const short _far *, short); + +short _far _cdecl _pg_getpalette(paletteentry _far *); +short _far _cdecl _pg_setpalette(const paletteentry _far *); +short _far _cdecl _pg_resetpalette(void); + +void _far _cdecl _pg_getstyleset(unsigned short _far *); +void _far _cdecl _pg_setstyleset(const unsigned short _far *); +void _far _cdecl _pg_resetstyleset(void); + +short _far _cdecl _pg_getchardef(short, unsigned char _far *); +short _far _cdecl _pg_setchardef(short, const unsigned char _far *); + +/* Restore default packing */ +#pragma pack() diff --git a/Microsoft C v6ax/INCLUDE/PROCESS.H b/Microsoft C v6ax/INCLUDE/PROCESS.H new file mode 100644 index 0000000..6df4da1 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/PROCESS.H @@ -0,0 +1,91 @@ +/*** +*process.h - definition and declarations for process control functions +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains the declarations and definitions for the +* spawnxx, execxx, and various other process control routines. +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* mode values for spawnxx routines + * (only P_WAIT and P_OVERLAY are supported on MS-DOS) + */ + +#ifndef _MT +extern int _near _cdecl _p_overlay; +#endif + +#define P_WAIT 0 +#define P_NOWAIT 1 +#ifdef _MT +#define P_OVERLAY 2 +#else +#define P_OVERLAY _p_overlay +#endif +#define OLD_P_OVERLAY 2 +#define P_NOWAITO 3 +#define P_DETACH 4 + + +/* action codes used with cwait() */ + +#define WAIT_CHILD 0 +#define WAIT_GRANDCHILD 1 + + +/* function prototypes */ + +#ifdef _MT +int _FAR_ _cdecl _beginthread(void(_cdecl _FAR_ *)(void _FAR_ *), + void _FAR_ *, unsigned, void _FAR_ *); +void _FAR_ _cdecl _endthread(void); +#endif +void _FAR_ _cdecl abort(void); +void _FAR_ _cdecl _cexit(void); +void _FAR_ _cdecl _c_exit(void); +int _FAR_ _cdecl cwait(int _FAR_ *, int, int); +int _FAR_ _cdecl execl(const char _FAR_ *, const char _FAR_ *, ...); +int _FAR_ _cdecl execle(const char _FAR_ *, const char _FAR_ *, ...); +int _FAR_ _cdecl execlp(const char _FAR_ *, const char _FAR_ *, ...); +int _FAR_ _cdecl execlpe(const char _FAR_ *, const char _FAR_ *, ...); +int _FAR_ _cdecl execv(const char _FAR_ *, + const char _FAR_ * const _FAR_ *); +int _FAR_ _cdecl execve(const char _FAR_ *, + const char _FAR_ * const _FAR_ *, const char _FAR_ * const _FAR_ *); +int _FAR_ _cdecl execvp(const char _FAR_ *, + const char _FAR_ * const _FAR_ *); +int _FAR_ _cdecl execvpe(const char _FAR_ *, + const char _FAR_ * const _FAR_ *, const char _FAR_ * const _FAR_ *); +void _FAR_ _cdecl exit(int); +void _FAR_ _cdecl _exit(int); +int _FAR_ _cdecl getpid(void); +int _FAR_ _cdecl spawnl(int, const char _FAR_ *, const char _FAR_ *, + ...); +int _FAR_ _cdecl spawnle(int, const char _FAR_ *, const char _FAR_ *, + ...); +int _FAR_ _cdecl spawnlp(int, const char _FAR_ *, const char _FAR_ *, + ...); +int _FAR_ _cdecl spawnlpe(int, const char _FAR_ *, const char _FAR_ *, + ...); +int _FAR_ _cdecl spawnv(int, const char _FAR_ *, + const char _FAR_ * const _FAR_ *); +int _FAR_ _cdecl spawnve(int, const char _FAR_ *, + const char _FAR_ * const _FAR_ *, const char _FAR_ * const _FAR_ *); +int _FAR_ _cdecl spawnvp(int, const char _FAR_ *, + const char _FAR_ * const _FAR_ *); +int _FAR_ _cdecl spawnvpe(int, const char _FAR_ *, + const char _FAR_ * const _FAR_ *, const char _FAR_ * const _FAR_ *); +int _FAR_ _cdecl system(const char _FAR_ *); +int _FAR_ _cdecl wait(int _FAR_ *); diff --git a/Microsoft C v6ax/INCLUDE/SEARCH.H b/Microsoft C v6ax/INCLUDE/SEARCH.H new file mode 100644 index 0000000..5a3d11c --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SEARCH.H @@ -0,0 +1,41 @@ +/*** +*search.h - declarations for searcing/sorting routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains the declarations for the sorting and +* searching routines. +* [System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + + +/* function prototypes */ + +void _FAR_ * _FAR_ _cdecl lsearch(const void _FAR_ *, void _FAR_ *, + unsigned int _FAR_ *, unsigned int, int (_FAR_ _cdecl *) + (const void _FAR_ *, const void _FAR_ *)); +void _FAR_ * _FAR_ _cdecl lfind(const void _FAR_ *, const void _FAR_ *, + unsigned int _FAR_ *, unsigned int, int (_FAR_ _cdecl *) + (const void _FAR_ *, const void _FAR_ *)); +void _FAR_ * _FAR_ _cdecl bsearch(const void _FAR_ *, const void _FAR_ *, + size_t, size_t, int (_FAR_ _cdecl *)(const void _FAR_ *, + const void _FAR_ *)); +void _FAR_ _cdecl qsort(void _FAR_ *, size_t, size_t, int (_FAR_ _cdecl *) + (const void _FAR_ *, const void _FAR_ *)); diff --git a/Microsoft C v6ax/INCLUDE/SETJMP.H b/Microsoft C v6ax/INCLUDE/SETJMP.H new file mode 100644 index 0000000..aee124b --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SETJMP.H @@ -0,0 +1,37 @@ +/*** +*setjmp.h - definitions/declarations for setjmp/longjmp routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the machine-dependent buffer used by +* setjmp/longjmp to save and restore the program state, and +* declarations for those routines. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* define the buffer type for holding the state information */ + +#define _JBLEN 9 /* bp, di, si, sp, ret addr, ds */ + +#ifndef _JMP_BUF_DEFINED +typedef int jmp_buf[_JBLEN]; +#define _JMP_BUF_DEFINED +#endif + + +/* function prototypes */ + +int _FAR_ _cdecl setjmp(jmp_buf); +void _FAR_ _cdecl longjmp(jmp_buf, int); diff --git a/Microsoft C v6ax/INCLUDE/SHARE.H b/Microsoft C v6ax/INCLUDE/SHARE.H new file mode 100644 index 0000000..26d1d79 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SHARE.H @@ -0,0 +1,15 @@ +/*** +*share.h - defines file sharing modes for sopen +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the file sharing modes for sopen(). +* +****/ + +#define SH_COMPAT 0x00 /* compatibility mode */ +#define SH_DENYRW 0x10 /* deny read/write mode */ +#define SH_DENYWR 0x20 /* deny write mode */ +#define SH_DENYRD 0x30 /* deny read mode */ +#define SH_DENYNO 0x40 /* deny none mode */ diff --git a/Microsoft C v6ax/INCLUDE/SIGNAL.H b/Microsoft C v6ax/INCLUDE/SIGNAL.H new file mode 100644 index 0000000..8787ed8 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SIGNAL.H @@ -0,0 +1,71 @@ +/*** +*signal.h - defines signal values and routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the signal values and declares the signal functions. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifdef _DLL +#define _LOADDS_ _loadds +#else +#define _LOADDS_ +#endif + +#ifndef _SIG_ATOMIC_T_DEFINED +typedef int sig_atomic_t; +#define _SIG_ATOMIC_T_DEFINED +#endif + + +#define NSIG 23 /* maximum signal number + 1 */ + +/* signal types */ +/* SIGINT, SIGFPE, SIGILL, SIGSEGV, and SIGABRT are recognized on DOS 3.x */ + +#define SIGINT 2 /* interrupt - corresponds to DOS 3.x int 23H */ +#define SIGILL 4 /* illegal instruction - invalid function image */ +#define SIGFPE 8 /* floating point exception */ +#define SIGSEGV 11 /* segment violation */ +#define SIGTERM 15 /* Software termination signal from kill */ +#define SIGUSR1 16 /* User defined signal 1 */ +#define SIGUSR2 17 /* User defined signal 2 */ +#define SIGUSR3 20 /* User defined signal 3 */ +#define SIGBREAK 21 /* Ctrl-Break sequence */ +#define SIGABRT 22 /* abnormal termination triggered by abort call */ + + +/* signal action codes */ +/* SIG_DFL and SIG_IGN are recognized on DOS 3.x */ + +#define SIG_DFL (void (_FAR_ _cdecl _LOADDS_ *)())0 /* default signal action */ +#define SIG_IGN (void (_FAR_ _cdecl _LOADDS_ *)())1 /* ignore */ +#define SIG_SGE (void (_FAR_ _cdecl _LOADDS_ *)())3 /* signal gets error */ +#define SIG_ACK (void (_FAR_ _cdecl _LOADDS_ *)())4 /* error if handler not setup */ + + +/* signal error value (returned by signal call on error) */ + +#define SIG_ERR (void (_FAR_ _cdecl _LOADDS_ *)())-1 /* signal error value */ + + +/* function prototypes */ + +void (_FAR_ _cdecl _LOADDS_ * _FAR_ _cdecl signal(int, + void (_FAR_ _cdecl _LOADDS_ *)()))(); +#ifndef _MT +int _FAR_ _cdecl raise(int); +#endif diff --git a/Microsoft C v6ax/INCLUDE/STDARG.H b/Microsoft C v6ax/INCLUDE/STDARG.H new file mode 100644 index 0000000..32b9df4 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/STDARG.H @@ -0,0 +1,42 @@ +/*** +*stdarg.h - defines ANSI-style macros for variable argument functions +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines ANSI-style macros for accessing arguments +* of functions which take a variable number of arguments. +* [ANSI] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* define NULL pointer value */ + +#ifndef NULL +#if (_MSC_VER >= 600) +#define NULL ((void *)0) +#elif (defined(M_I86SM) || defined(M_I86MM)) +#define NULL 0 +#else +#define NULL 0L +#endif +#endif + +#ifndef _VA_LIST_DEFINED +typedef char _FAR_ *va_list; +#define _VA_LIST_DEFINED +#endif + +#define va_start(ap,v) ap = (va_list)&v + sizeof(v) +#define va_arg(ap,t) ((t _FAR_ *)(ap += sizeof(t)))[-1] +#define va_end(ap) ap = NULL diff --git a/Microsoft C v6ax/INCLUDE/STDDEF.H b/Microsoft C v6ax/INCLUDE/STDDEF.H new file mode 100644 index 0000000..20d4236 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/STDDEF.H @@ -0,0 +1,65 @@ +/*** +*stddef.h - definitions/declarations for common constants, types, variables +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains definitions and declarations for some commonly +* used constants, types, and variables. +* [ANSI] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* define the NULL pointer value and the offsetof() macro */ + +#ifndef NULL +#if (_MSC_VER >= 600) +#define NULL ((void *)0) +#elif (defined(M_I86SM) || defined(M_I86MM)) +#define NULL 0 +#else +#define NULL 0L +#endif +#endif + +#define offsetof(s,m) (size_t)&(((s *)0)->m) + + +/* declare reference to errno */ + +#ifdef _MT +extern int _far * _cdecl _far volatile _errno(void); +#define errno (*_errno()) +#else +extern int _near _cdecl volatile errno; +#endif + + +/* define the implementation dependent size types */ + +#ifndef _PTRDIFF_T_DEFINED +typedef int ptrdiff_t; +#define _PTRDIFF_T_DEFINED +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + + +#ifdef _MT +/* define pointer to thread id value */ + +extern int _far *_threadid; +#endif diff --git a/Microsoft C v6ax/INCLUDE/STDIO.H b/Microsoft C v6ax/INCLUDE/STDIO.H new file mode 100644 index 0000000..0200bfe --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/STDIO.H @@ -0,0 +1,224 @@ +/*** +*stdio.h - definitions/declarations for standard I/O routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the structures, values, macros, and functions +* used by the level 2 I/O ("standard I/O") routines. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + +#ifndef _VA_LIST_DEFINED +typedef char _FAR_ *va_list; +#define _VA_LIST_DEFINED +#endif + +/* buffered I/O macros */ + +#define BUFSIZ 512 +#ifdef _MT +#define _NFILE 40 +#else +#define _NFILE 20 +#endif +#define EOF (-1) + +#ifndef _FILE_DEFINED +struct _iobuf { + char _FAR_ *_ptr; + int _cnt; + char _FAR_ *_base; + char _flag; + char _file; + }; +typedef struct _iobuf FILE; +#define _FILE_DEFINED +#endif + + +/* P_tmpnam: Directory where temporary files may be created. + * L_tmpnam size = size of P_tmpdir + * + 1 (in case P_tmpdir does not end in "\\") + * + 6 (for the temp number string) + * + 1 (for the null terminator) + */ + +#define P_tmpdir "\\" +#define L_tmpnam sizeof(P_tmpdir)+8 + + +/* fseek constants */ + +#define SEEK_CUR 1 +#define SEEK_END 2 +#define SEEK_SET 0 + + +/* minimum guaranteed filename length, open file count, and unique + * tmpnam filenames. + */ + +#define FILENAME_MAX 63 +#define FOPEN_MAX 20 +#define SYS_OPEN 20 +#define TMP_MAX 32767 + + +/* define NULL pointer value */ + +#ifndef NULL +#if (_MSC_VER >= 600) +#define NULL ((void *)0) +#elif (defined(M_I86SM) || defined(M_I86MM)) +#define NULL 0 +#else +#define NULL 0L +#endif +#endif + + +/* declare _iob[] array */ + +#ifndef _STDIO_DEFINED +#ifdef _DLL +extern FILE _FAR_ _cdecl _iob[]; +#else +extern FILE _near _cdecl _iob[]; +#endif +#endif + + +/* define file position type */ + +#ifndef _FPOS_T_DEFINED +typedef long fpos_t; +#define _FPOS_T_DEFINED +#endif + + +/* standard file pointers */ + +#define stdin (&_iob[0]) +#define stdout (&_iob[1]) +#define stderr (&_iob[2]) +#define stdaux (&_iob[3]) +#define stdprn (&_iob[4]) + + +#define _IOREAD 0x01 +#define _IOWRT 0x02 + +#define _IOFBF 0x0 +#define _IOLBF 0x40 +#define _IONBF 0x04 + +#define _IOMYBUF 0x08 +#define _IOEOF 0x10 +#define _IOERR 0x20 +#define _IOSTRG 0x40 +#define _IORW 0x80 + + +/* function prototypes */ + +#ifndef _STDIO_DEFINED +int _FAR_ _cdecl _filbuf(FILE _FAR_ *); +int _FAR_ _cdecl _flsbuf(int, FILE _FAR_ *); +FILE _FAR_ * _FAR_ _cdecl _fsopen(const char _FAR_ *, + const char _FAR_ *, int); +void _FAR_ _cdecl clearerr(FILE _FAR_ *); +int _FAR_ _cdecl fclose(FILE _FAR_ *); +int _FAR_ _cdecl fcloseall(void); +FILE _FAR_ * _FAR_ _cdecl fdopen(int, const char _FAR_ *); +int _FAR_ _cdecl feof(FILE _FAR_ *); +int _FAR_ _cdecl ferror(FILE _FAR_ *); +int _FAR_ _cdecl fflush(FILE _FAR_ *); +int _FAR_ _cdecl fgetc(FILE _FAR_ *); +int _FAR_ _cdecl fgetchar(void); +int _FAR_ _cdecl fgetpos(FILE _FAR_ *, fpos_t _FAR_ *); +char _FAR_ * _FAR_ _cdecl fgets(char _FAR_ *, int, FILE _FAR_ *); +int _FAR_ _cdecl fileno(FILE _FAR_ *); +int _FAR_ _cdecl flushall(void); +FILE _FAR_ * _FAR_ _cdecl fopen(const char _FAR_ *, + const char _FAR_ *); +int _FAR_ _cdecl fprintf(FILE _FAR_ *, const char _FAR_ *, ...); +int _FAR_ _cdecl fputc(int, FILE _FAR_ *); +int _FAR_ _cdecl fputchar(int); +int _FAR_ _cdecl fputs(const char _FAR_ *, FILE _FAR_ *); +size_t _FAR_ _cdecl fread(void _FAR_ *, size_t, size_t, FILE _FAR_ *); +FILE _FAR_ * _FAR_ _cdecl freopen(const char _FAR_ *, + const char _FAR_ *, FILE _FAR_ *); +int _FAR_ _cdecl fscanf(FILE _FAR_ *, const char _FAR_ *, ...); +int _FAR_ _cdecl fsetpos(FILE _FAR_ *, const fpos_t _FAR_ *); +int _FAR_ _cdecl fseek(FILE _FAR_ *, long, int); +long _FAR_ _cdecl ftell(FILE _FAR_ *); +size_t _FAR_ _cdecl fwrite(const void _FAR_ *, size_t, size_t, + FILE _FAR_ *); +int _FAR_ _cdecl getc(FILE _FAR_ *); +int _FAR_ _cdecl getchar(void); +char _FAR_ * _FAR_ _cdecl gets(char _FAR_ *); +int _FAR_ _cdecl getw(FILE _FAR_ *); +void _FAR_ _cdecl perror(const char _FAR_ *); +int _FAR_ _cdecl _pclose(FILE _FAR_ *); +FILE _FAR_ * _FAR_ _cdecl _popen(const char _FAR_ *, + const char _FAR_ *); +int _FAR_ _cdecl printf(const char _FAR_ *, ...); +int _FAR_ _cdecl putc(int, FILE _FAR_ *); +int _FAR_ _cdecl putchar(int); +int _FAR_ _cdecl puts(const char _FAR_ *); +int _FAR_ _cdecl putw(int, FILE _FAR_ *); +int _FAR_ _cdecl remove(const char _FAR_ *); +int _FAR_ _cdecl rename(const char _FAR_ *, const char _FAR_ *); +void _FAR_ _cdecl rewind(FILE _FAR_ *); +int _FAR_ _cdecl rmtmp(void); +int _FAR_ _cdecl scanf(const char _FAR_ *, ...); +void _FAR_ _cdecl setbuf(FILE _FAR_ *, char _FAR_ *); +int _FAR_ _cdecl setvbuf(FILE _FAR_ *, char _FAR_ *, int, size_t); +int _FAR_ _cdecl sprintf(char _FAR_ *, const char _FAR_ *, ...); +int _FAR_ _cdecl sscanf(const char _FAR_ *, const char _FAR_ *, ...); +char _FAR_ * _FAR_ _cdecl tempnam(char _FAR_ *, char _FAR_ *); +FILE _FAR_ * _FAR_ _cdecl tmpfile(void); +char _FAR_ * _FAR_ _cdecl tmpnam(char _FAR_ *); +int _FAR_ _cdecl ungetc(int, FILE _FAR_ *); +int _FAR_ _cdecl unlink(const char _FAR_ *); +int _FAR_ _cdecl vfprintf(FILE _FAR_ *, const char _FAR_ *, va_list); +int _FAR_ _cdecl vprintf(const char _FAR_ *, va_list); +int _FAR_ _cdecl vsprintf(char _FAR_ *, const char _FAR_ *, va_list); +#define _STDIO_DEFINED +#endif + +/* macro definitions */ + +#define feof(_stream) ((_stream)->_flag & _IOEOF) +#define ferror(_stream) ((_stream)->_flag & _IOERR) +#define fileno(_stream) ((int)(unsigned char)(_stream)->_file) +#define getc(_stream) (--(_stream)->_cnt >= 0 ? 0xff & *(_stream)->_ptr++ \ + : _filbuf(_stream)) +#define putc(_c,_stream) (--(_stream)->_cnt >= 0 \ + ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream))) +#define getchar() getc(stdin) +#define putchar(_c) putc((_c),stdout) + +#ifdef _MT +#undef getc +#undef putc +#undef getchar +#undef putchar +#endif diff --git a/Microsoft C v6ax/INCLUDE/STDLIB.H b/Microsoft C v6ax/INCLUDE/STDLIB.H new file mode 100644 index 0000000..6f7c558 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/STDLIB.H @@ -0,0 +1,204 @@ +/*** +*stdlib.h - declarations/definitions for commonly used library functions +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This include file contains the function declarations for +* commonly used library functions which either don't fit somewhere +* else, or, like toupper/tolower, can't be declared in the normal +* place for other reasons. +* [ANSI] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifdef _DLL +#define _LOADDS_ _loadds +#else +#define _LOADDS_ +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + +/* define NULL pointer value */ + +#ifndef NULL +#if (_MSC_VER >= 600) +#define NULL ((void *)0) +#elif (defined(M_I86SM) || defined(M_I86MM)) +#define NULL 0 +#else +#define NULL 0L +#endif +#endif + +/* definition of the return type for the onexit() function */ + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +#ifndef _ONEXIT_T_DEFINED +typedef int (_FAR_ _cdecl _LOADDS_ * _cdecl onexit_t)(); +#define _ONEXIT_T_DEFINED +#endif + + +/* data structure definitions for div and ldiv runtimes. */ + +#ifndef _DIV_T_DEFINED + +typedef struct _div_t { + int quot; + int rem; +} div_t; + +typedef struct _ldiv_t { + long quot; + long rem; +} ldiv_t; + +#define _DIV_T_DEFINED +#endif + +/* maximum value that can be returned by the rand function. */ + +#define RAND_MAX 0x7fff + + +/* min and max macros */ + +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) + + +/* sizes for buffers used by the _makepath() and _splitpath() functions. + * note that the sizes include space for 0-terminator + */ + +#define _MAX_PATH 260 /* max. length of full pathname */ +#define _MAX_DRIVE 3 /* max. length of drive component */ +#define _MAX_DIR 256 /* max. length of path component */ +#define _MAX_FNAME 256 /* max. length of file name component */ +#define _MAX_EXT 256 /* max. length of extension component */ + +/* external variable declarations */ + +#ifdef _MT +extern int _far * _cdecl _far volatile _errno(void); +extern unsigned _far * _cdecl _far __doserrno(void); +#define errno (*_errno()) +#define _doserrno (*__doserrno()) +#else +extern int _near _cdecl volatile errno; /* XENIX style error number */ +extern int _near _cdecl _doserrno; /* MS-DOS system error value */ +#endif +extern char * _near _cdecl sys_errlist[]; /* perror error message table */ +extern int _near _cdecl sys_nerr; /* # of entries in sys_errlist table */ + +#ifdef _DLL +extern char ** _FAR_ _cdecl environ; /* pointer to environment table */ +extern int _FAR_ _cdecl _fmode; /* default file translation mode */ +extern int _FAR_ _cdecl _fileinfo; /* open file info mode (for spawn) */ +#else +extern char ** _near _cdecl environ; /* pointer to environment table */ +extern int _near _cdecl _fmode; /* default file translation mode */ +extern int _near _cdecl _fileinfo; /* open file info mode (for spawn) */ +#endif + +extern unsigned int _near _cdecl _psp; /* Program Segment Prefix */ + +/* OS major/minor version numbers */ + +extern unsigned char _near _cdecl _osmajor; +extern unsigned char _near _cdecl _osminor; + +#define DOS_MODE 0 /* Real Address Mode */ +#define OS2_MODE 1 /* Protected Address Mode */ + +extern unsigned char _near _cdecl _osmode; + + +/* function prototypes */ + +#ifdef _MT +double _FAR_ _pascal atof(const char _FAR_ *); +double _FAR_ _pascal strtod(const char _FAR_ *, char _FAR_ * _FAR_ *); +ldiv_t _FAR_ _pascal ldiv(long, long); +#else /* not _MT */ +double _FAR_ _cdecl atof(const char _FAR_ *); +double _FAR_ _cdecl strtod(const char _FAR_ *, char _FAR_ * _FAR_ *); +ldiv_t _FAR_ _cdecl ldiv(long, long); +#endif + +void _FAR_ _cdecl abort(void); +int _FAR_ _cdecl abs(int); +int _FAR_ _cdecl atexit(void (_cdecl _FAR_ _LOADDS_ *)(void)); +int _FAR_ _cdecl atoi(const char _FAR_ *); +long _FAR_ _cdecl atol(const char _FAR_ *); +long double _FAR_ _cdecl _atold(const char _FAR_ *); +void _FAR_ * _FAR_ _cdecl bsearch(const void _FAR_ *, const void _FAR_ *, + size_t, size_t, int (_FAR_ _cdecl *)(const void _FAR_ *, + const void _FAR_ *)); +void _FAR_ * _FAR_ _cdecl calloc(size_t, size_t); +div_t _FAR_ _cdecl div(int, int); +char _FAR_ * _FAR_ _cdecl ecvt(double, int, int _FAR_ *, int _FAR_ *); +void _FAR_ _cdecl exit(int); +void _FAR_ _cdecl _exit(int); +char _FAR_ * _FAR_ _cdecl fcvt(double, int, int _FAR_ *, int _FAR_ *); +void _FAR_ _cdecl free(void _FAR_ *); +char _FAR_ * _FAR_ _cdecl _fullpath(char _FAR_ *, const char _FAR_ *, + size_t); +char _FAR_ * _FAR_ _cdecl gcvt(double, int, char _FAR_ *); +char _FAR_ * _FAR_ _cdecl getenv(const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl itoa(int, char _FAR_ *, int); +long _FAR_ _cdecl labs(long); +unsigned long _FAR_ _cdecl _lrotl(unsigned long, int); +unsigned long _FAR_ _cdecl _lrotr(unsigned long, int); +char _FAR_ * _FAR_ _cdecl ltoa(long, char _FAR_ *, int); +void _FAR_ _cdecl _makepath(char _FAR_ *, const char _FAR_ *, + const char _FAR_ *, const char _FAR_ *, const char _FAR_ *); +void _FAR_ * _FAR_ _cdecl malloc(size_t); +onexit_t _FAR_ _cdecl onexit(onexit_t); +void _FAR_ _cdecl perror(const char _FAR_ *); +int _FAR_ _cdecl putenv(const char _FAR_ *); +void _FAR_ _cdecl qsort(void _FAR_ *, size_t, size_t, int (_FAR_ _cdecl *) + (const void _FAR_ *, const void _FAR_ *)); +unsigned int _FAR_ _cdecl _rotl(unsigned int, int); +unsigned int _FAR_ _cdecl _rotr(unsigned int, int); +int _FAR_ _cdecl rand(void); +void _FAR_ * _FAR_ _cdecl realloc(void _FAR_ *, size_t); +void _FAR_ _cdecl _searchenv(const char _FAR_ *, const char _FAR_ *, + char _FAR_ *); +void _FAR_ _cdecl _splitpath(const char _FAR_ *, char _FAR_ *, + char _FAR_ *, char _FAR_ *, char _FAR_ *); +void _FAR_ _cdecl srand(unsigned int); +long _FAR_ _cdecl strtol(const char _FAR_ *, char _FAR_ * _FAR_ *, + int); +long double _FAR_ _cdecl _strtold(const char _FAR_ *, + char _FAR_ * _FAR_ *); +unsigned long _FAR_ _cdecl strtoul(const char _FAR_ *, + char _FAR_ * _FAR_ *, int); +void _FAR_ _cdecl swab(char _FAR_ *, char _FAR_ *, int); +int _FAR_ _cdecl system(const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl ultoa(unsigned long, char _FAR_ *, int); + +#ifndef tolower /* tolower has been undefined - use function */ +int _FAR_ _cdecl tolower(int); +#endif /* tolower */ + +#ifndef toupper /* toupper has been undefined - use function */ +int _FAR_ _cdecl toupper(int); +#endif /* toupper */ diff --git a/Microsoft C v6ax/INCLUDE/STRING.H b/Microsoft C v6ax/INCLUDE/STRING.H new file mode 100644 index 0000000..6c640ac --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/STRING.H @@ -0,0 +1,121 @@ +/*** +*string.h - declarations for string manipulation functions +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains the function declarations for the string +* manipulation functions. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + +/* function prototypes */ + +void _FAR_ * _FAR_ _cdecl memccpy(void _FAR_ *, const void _FAR_ *, + int, unsigned int); +void _FAR_ * _FAR_ _cdecl memchr(const void _FAR_ *, int, size_t); +int _FAR_ _cdecl memcmp(const void _FAR_ *, const void _FAR_ *, + size_t); +int _FAR_ _cdecl memicmp(const void _FAR_ *, const void _FAR_ *, + unsigned int); +void _FAR_ * _FAR_ _cdecl memcpy(void _FAR_ *, const void _FAR_ *, + size_t); +void _FAR_ * _FAR_ _cdecl memmove(void _FAR_ *, const void _FAR_ *, + size_t); +void _FAR_ * _FAR_ _cdecl memset(void _FAR_ *, int, size_t); +void _FAR_ _cdecl movedata(unsigned int, unsigned int, unsigned int, + unsigned int, unsigned int); +char _FAR_ * _FAR_ _cdecl strcat(char _FAR_ *, const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strchr(const char _FAR_ *, int); +int _FAR_ _cdecl strcmp(const char _FAR_ *, const char _FAR_ *); +int _FAR_ _cdecl strcmpi(const char _FAR_ *, const char _FAR_ *); +int _FAR_ _cdecl strcoll(const char _FAR_ *, const char _FAR_ *); +int _FAR_ _cdecl stricmp(const char _FAR_ *, const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strcpy(char _FAR_ *, const char _FAR_ *); +size_t _FAR_ _cdecl strcspn(const char _FAR_ *, const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strdup(const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl _strerror(const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strerror(int); +size_t _FAR_ _cdecl strlen(const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strlwr(char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strncat(char _FAR_ *, const char _FAR_ *, + size_t); +int _FAR_ _cdecl strncmp(const char _FAR_ *, const char _FAR_ *, + size_t); +int _FAR_ _cdecl strnicmp(const char _FAR_ *, const char _FAR_ *, + size_t); +char _FAR_ * _FAR_ _cdecl strncpy(char _FAR_ *, const char _FAR_ *, + size_t); +char _FAR_ * _FAR_ _cdecl strnset(char _FAR_ *, int, size_t); +char _FAR_ * _FAR_ _cdecl strpbrk(const char _FAR_ *, + const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strrchr(const char _FAR_ *, int); +char _FAR_ * _FAR_ _cdecl strrev(char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strset(char _FAR_ *, int); +size_t _FAR_ _cdecl strspn(const char _FAR_ *, const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strstr(const char _FAR_ *, + const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strtok(char _FAR_ *, const char _FAR_ *); +char _FAR_ * _FAR_ _cdecl strupr(char _FAR_ *); +size_t _FAR_ _cdecl strxfrm (char _FAR_ *, const char _FAR_ *, + size_t); + +/* model independent function prototypes */ + +void _far * _far _cdecl _fmemccpy(void _far *, const void _far *, + int, unsigned int); +void _far * _far _cdecl _fmemchr(const void _far *, int, size_t); +int _far _cdecl _fmemcmp(const void _far *, const void _far *, + size_t); +void _far * _far _cdecl _fmemcpy(void _far *, const void _far *, + size_t); +int _far _cdecl _fmemicmp(const void _far *, const void _far *, + unsigned int); +void _far * _far _cdecl _fmemmove(void _far *, const void _far *, + size_t); +void _far * _far _cdecl _fmemset(void _far *, int, size_t); +char _far * _far _cdecl _fstrcat(char _far *, const char _far *); +char _far * _far _cdecl _fstrchr(const char _far *, int); +int _far _cdecl _fstrcmp(const char _far *, const char _far *); +int _far _cdecl _fstricmp(const char _far *, const char _far *); +char _far * _far _cdecl _fstrcpy(char _far *, const char _far *); +size_t _far _cdecl _fstrcspn(const char _far *, const char _far *); +char _far * _far _cdecl _fstrdup(const char _far *); +char _near * _far _cdecl _nstrdup(const char _far *); +size_t _far _cdecl _fstrlen(const char _far *); +char _far * _far _cdecl _fstrlwr(char _far *); +char _far * _far _cdecl _fstrncat(char _far *, const char _far *, + size_t); +int _far _cdecl _fstrncmp(const char _far *, const char _far *, + size_t); +int _far _cdecl _fstrnicmp(const char _far *, const char _far *, + size_t); +char _far * _far _cdecl _fstrncpy(char _far *, const char _far *, + size_t); +char _far * _far _cdecl _fstrnset(char _far *, int, size_t); +char _far * _far _cdecl _fstrpbrk(const char _far *, + const char _far *); +char _far * _far _cdecl _fstrrchr(const char _far *, int); +char _far * _far _cdecl _fstrrev(char _far *); +char _far * _far _cdecl _fstrset(char _far *, int); +size_t _far _cdecl _fstrspn(const char _far *, const char _far *); +char _far * _far _cdecl _fstrstr(const char _far *, + const char _far *); +char _far * _far _cdecl _fstrtok(char _far *, const char _far *); +char _far * _far _cdecl _fstrupr(char _far *); diff --git a/Microsoft C v6ax/INCLUDE/SYS/LOCKING.H b/Microsoft C v6ax/INCLUDE/SYS/LOCKING.H new file mode 100644 index 0000000..856adf0 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SYS/LOCKING.H @@ -0,0 +1,16 @@ +/*** +*sys\locking.h - flags for locking() function +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the flags for the locking() function. +* [System V] +* +****/ + +#define LK_UNLCK 0 /* unlock the file region */ +#define LK_LOCK 1 /* lock the file region */ +#define LK_NBLCK 2 /* non-blocking lock */ +#define LK_RLCK 3 /* lock for writing */ +#define LK_NBRLCK 4 /* non-blocking lock for writing */ diff --git a/Microsoft C v6ax/INCLUDE/SYS/STAT.H b/Microsoft C v6ax/INCLUDE/SYS/STAT.H new file mode 100644 index 0000000..845d658 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SYS/STAT.H @@ -0,0 +1,59 @@ +/*** +*sys\stat.h - defines structure used by stat() and fstat() +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the structure used by the stat() and fstat() +* routines. +* [System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + +/* define structure for returning status information */ + +#ifndef _STAT_DEFINED +struct stat { + dev_t st_dev; + ino_t st_ino; + unsigned short st_mode; + short st_nlink; + short st_uid; + short st_gid; + dev_t st_rdev; + off_t st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; + }; +#define _STAT_DEFINED +#endif + +#define S_IFMT 0170000 /* file type mask */ +#define S_IFDIR 0040000 /* directory */ +#define S_IFCHR 0020000 /* character special */ +#define S_IFREG 0100000 /* regular */ +#define S_IREAD 0000400 /* read permission, owner */ +#define S_IWRITE 0000200 /* write permission, owner */ +#define S_IEXEC 0000100 /* execute/search permission, owner */ + + +/* function prototypes */ + +int _FAR_ _cdecl fstat(int, struct stat _FAR_ *); +int _FAR_ _cdecl stat(char _FAR_ *, struct stat _FAR_ *); diff --git a/Microsoft C v6ax/INCLUDE/SYS/TIMEB.H b/Microsoft C v6ax/INCLUDE/SYS/TIMEB.H new file mode 100644 index 0000000..88159d9 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SYS/TIMEB.H @@ -0,0 +1,42 @@ +/*** +*sys\timeb.h - definition/declarations for ftime() +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file define the ftime() function and the types it uses. +* [System V] +* +*******************************************************************************/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + +/* structure returned by ftime system call */ + +#ifndef _TIMEB_DEFINED +struct timeb { + time_t time; + unsigned short millitm; + short timezone; + short dstflag; + }; +#define _TIMEB_DEFINED +#endif + + +/* function prototypes */ + +void _FAR_ _cdecl ftime(struct timeb _FAR_ *); diff --git a/Microsoft C v6ax/INCLUDE/SYS/TYPES.H b/Microsoft C v6ax/INCLUDE/SYS/TYPES.H new file mode 100644 index 0000000..c57ab6c --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SYS/TYPES.H @@ -0,0 +1,31 @@ +/*** +*sys\types.h - types returned by system level calls for file and time info +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines types used in defining values returned by system +* level calls for file status and time information. +* [System V] +* +****/ + +#ifndef _INO_T_DEFINED +typedef unsigned short ino_t; /* i-node number (not used on DOS) */ +#define _INO_T_DEFINED +#endif + +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + +#ifndef _DEV_T_DEFINED +typedef short dev_t; /* device code */ +#define _DEV_T_DEFINED +#endif + +#ifndef _OFF_T_DEFINED +typedef long off_t; /* file offset value */ +#define _OFF_T_DEFINED +#endif diff --git a/Microsoft C v6ax/INCLUDE/SYS/UTIME.H b/Microsoft C v6ax/INCLUDE/SYS/UTIME.H new file mode 100644 index 0000000..5f140fa --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/SYS/UTIME.H @@ -0,0 +1,43 @@ +/*** +*sys\utime.h - definitions/declarations for utime() +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the structure used by the utime routine to set +* new file access and modification times. NOTE - MS-DOS +* does not recognize access time, so this field will +* always be ignored and the modification time field will be +* used to set the new time. +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + +/* define struct used by utime() function */ + +#ifndef _UTIMBUF_DEFINED +struct utimbuf { + time_t actime; /* access time */ + time_t modtime; /* modification time */ + }; +#define _UTIMBUF_DEFINED +#endif + + +/* function prototypes */ + +int _FAR_ _cdecl utime(char _FAR_ *, struct utimbuf _FAR_ *); diff --git a/Microsoft C v6ax/INCLUDE/TIME.H b/Microsoft C v6ax/INCLUDE/TIME.H new file mode 100644 index 0000000..0c5c444 --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/TIME.H @@ -0,0 +1,114 @@ +/*** +*time.h - definitions/declarations for time routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains the various declarations and definitions +* for the time routines. +* [ANSI/System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* implementation defined time types */ + +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + +#ifndef _CLOCK_T_DEFINED +typedef long clock_t; +#define _CLOCK_T_DEFINED +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#define _SIZE_T_DEFINED +#endif + +/* structure for use with localtime(), gmtime(), etc. */ + +#ifndef _TM_DEFINED +struct tm { + int tm_sec; /* seconds after the minute - [0,59] */ + int tm_min; /* minutes after the hour - [0,59] */ + int tm_hour; /* hours since midnight - [0,23] */ + int tm_mday; /* day of the month - [1,31] */ + int tm_mon; /* months since January - [0,11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday - [0,6] */ + int tm_yday; /* days since January 1 - [0,365] */ + int tm_isdst; /* daylight savings time flag */ + }; +#define _TM_DEFINED +#endif + + +/* define NULL pointer value */ + +#ifndef NULL +#if (_MSC_VER >= 600) +#define NULL ((void *)0) +#elif (defined(M_I86SM) || defined(M_I86MM)) +#define NULL 0 +#else +#define NULL 0L +#endif +#endif + + +/* clock ticks macro - ANSI version */ + +#define CLOCKS_PER_SEC 1000 + +/* clock ticks macro - archaic version */ + +#define CLK_TCK 1000 + + +/* extern declarations for the global variables used by the ctime family of + * routines. + */ + +#ifdef _DLL +extern int _FAR_ _cdecl daylight; /* non-zero if daylight savings time is used */ +extern long _FAR_ _cdecl timezone; /* difference in seconds between GMT and local time */ +extern char _FAR_ * _FAR_ _cdecl tzname[2]; /* standard/daylight savings time zone names */ +#else +extern int _near _cdecl daylight; /* non-zero if daylight savings time is used */ +extern long _near _cdecl timezone; /* difference in seconds between GMT and local time */ +extern char * _near _cdecl tzname[2]; /* standard/daylight savings time zone names */ +#endif + + +/* function prototypes */ + +#ifdef _MT +double _FAR_ _pascal difftime(time_t, time_t); +#else +double _FAR_ _cdecl difftime(time_t, time_t); +#endif + +char _FAR_ * _FAR_ _cdecl asctime(const struct tm _FAR_ *); +char _FAR_ * _FAR_ _cdecl ctime(const time_t _FAR_ *); +clock_t _FAR_ _cdecl clock(void); +struct tm _FAR_ * _FAR_ _cdecl gmtime(const time_t _FAR_ *); +struct tm _FAR_ * _FAR_ _cdecl localtime(const time_t _FAR_ *); +time_t _FAR_ _cdecl mktime(struct tm _FAR_ *); +size_t _FAR_ _cdecl strftime(char _FAR_ *, size_t, const char _FAR_ *, + const struct tm _FAR_ *); +char _FAR_ * _FAR_ _cdecl _strdate(char _FAR_ *); +char _FAR_ * _FAR_ _cdecl _strtime(char _FAR_ *); +time_t _FAR_ _cdecl time(time_t _FAR_ *); +void _FAR_ _cdecl tzset(void); diff --git a/Microsoft C v6ax/INCLUDE/VARARGS.H b/Microsoft C v6ax/INCLUDE/VARARGS.H new file mode 100644 index 0000000..b0d0a0b --- /dev/null +++ b/Microsoft C v6ax/INCLUDE/VARARGS.H @@ -0,0 +1,43 @@ +/*** +*varargs.h - XENIX style macros for variable argument functions +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines XENIX style macros for accessing arguments of a +* function which takes a variable number of arguments. +* [System V] +* +****/ + +#if defined(_DLL) && !defined(_MT) +#error Cannot define _DLL without _MT +#endif + +#ifdef _MT +#define _FAR_ _far +#else +#define _FAR_ +#endif + +/* define NULL pointer value */ + +#ifndef NULL +#if (_MSC_VER >= 600) +#define NULL ((void *)0) +#elif (defined(M_I86SM) || defined(M_I86MM)) +#define NULL 0 +#else +#define NULL 0L +#endif +#endif + +#ifndef _VA_LIST_DEFINED +typedef char _FAR_ *va_list; +#define _VA_LIST_DEFINED +#endif + +#define va_dcl va_list va_alist; +#define va_start(ap) ap = (va_list)&va_alist +#define va_arg(ap,t) ((t _FAR_ *)(ap += sizeof(t)))[-1] +#define va_end(ap) ap = NULL diff --git a/Microsoft C v6ax/LIB/API.LIB b/Microsoft C v6ax/LIB/API.LIB new file mode 100644 index 0000000..40cb02c Binary files /dev/null and b/Microsoft C v6ax/LIB/API.LIB differ diff --git a/Microsoft C v6ax/LIB/BINMODE.OBJ b/Microsoft C v6ax/LIB/BINMODE.OBJ new file mode 100644 index 0000000..a443384 Binary files /dev/null and b/Microsoft C v6ax/LIB/BINMODE.OBJ differ diff --git a/Microsoft C v6ax/LIB/CLIBC7.LIB b/Microsoft C v6ax/LIB/CLIBC7.LIB new file mode 100644 index 0000000..86709da Binary files /dev/null and b/Microsoft C v6ax/LIB/CLIBC7.LIB differ diff --git a/Microsoft C v6ax/LIB/CLIBCA.LIB b/Microsoft C v6ax/LIB/CLIBCA.LIB new file mode 100644 index 0000000..6b87701 Binary files /dev/null and b/Microsoft C v6ax/LIB/CLIBCA.LIB differ diff --git a/Microsoft C v6ax/LIB/CLIBCE.LIB b/Microsoft C v6ax/LIB/CLIBCE.LIB new file mode 100644 index 0000000..321b418 Binary files /dev/null and b/Microsoft C v6ax/LIB/CLIBCE.LIB differ diff --git a/Microsoft C v6ax/LIB/CRTCOM.LIB b/Microsoft C v6ax/LIB/CRTCOM.LIB new file mode 100644 index 0000000..724b1aa Binary files /dev/null and b/Microsoft C v6ax/LIB/CRTCOM.LIB differ diff --git a/Microsoft C v6ax/LIB/FILEINFO.OBJ b/Microsoft C v6ax/LIB/FILEINFO.OBJ new file mode 100644 index 0000000..bb57b86 Binary files /dev/null and b/Microsoft C v6ax/LIB/FILEINFO.OBJ differ diff --git a/Microsoft C v6ax/LIB/GRAPHICS.LIB b/Microsoft C v6ax/LIB/GRAPHICS.LIB new file mode 100644 index 0000000..088387f Binary files /dev/null and b/Microsoft C v6ax/LIB/GRAPHICS.LIB differ diff --git a/Microsoft C v6ax/LIB/LLIBC7.LIB b/Microsoft C v6ax/LIB/LLIBC7.LIB new file mode 100644 index 0000000..7355ae3 Binary files /dev/null and b/Microsoft C v6ax/LIB/LLIBC7.LIB differ diff --git a/Microsoft C v6ax/LIB/LLIBCA.LIB b/Microsoft C v6ax/LIB/LLIBCA.LIB new file mode 100644 index 0000000..0d1bc12 Binary files /dev/null and b/Microsoft C v6ax/LIB/LLIBCA.LIB differ diff --git a/Microsoft C v6ax/LIB/LLIBCE.LIB b/Microsoft C v6ax/LIB/LLIBCE.LIB new file mode 100644 index 0000000..e6b0d2c Binary files /dev/null and b/Microsoft C v6ax/LIB/LLIBCE.LIB differ diff --git a/Microsoft C v6ax/LIB/MLIBC7.LIB b/Microsoft C v6ax/LIB/MLIBC7.LIB new file mode 100644 index 0000000..e838595 Binary files /dev/null and b/Microsoft C v6ax/LIB/MLIBC7.LIB differ diff --git a/Microsoft C v6ax/LIB/MLIBCA.LIB b/Microsoft C v6ax/LIB/MLIBCA.LIB new file mode 100644 index 0000000..4543a71 Binary files /dev/null and b/Microsoft C v6ax/LIB/MLIBCA.LIB differ diff --git a/Microsoft C v6ax/LIB/MLIBCE.LIB b/Microsoft C v6ax/LIB/MLIBCE.LIB new file mode 100644 index 0000000..8303a84 Binary files /dev/null and b/Microsoft C v6ax/LIB/MLIBCE.LIB differ diff --git a/Microsoft C v6ax/LIB/PGCHART.LIB b/Microsoft C v6ax/LIB/PGCHART.LIB new file mode 100644 index 0000000..54f4743 Binary files /dev/null and b/Microsoft C v6ax/LIB/PGCHART.LIB differ diff --git a/Microsoft C v6ax/LIB/RMFIXUP.OBJ b/Microsoft C v6ax/LIB/RMFIXUP.OBJ new file mode 100644 index 0000000..792235c Binary files /dev/null and b/Microsoft C v6ax/LIB/RMFIXUP.OBJ differ diff --git a/Microsoft C v6ax/LIB/SETARGV.OBJ b/Microsoft C v6ax/LIB/SETARGV.OBJ new file mode 100644 index 0000000..7578cac Binary files /dev/null and b/Microsoft C v6ax/LIB/SETARGV.OBJ differ diff --git a/Microsoft C v6ax/LIB/SLIBC7.LIB b/Microsoft C v6ax/LIB/SLIBC7.LIB new file mode 100644 index 0000000..189c5a0 Binary files /dev/null and b/Microsoft C v6ax/LIB/SLIBC7.LIB differ diff --git a/Microsoft C v6ax/LIB/SLIBCA.LIB b/Microsoft C v6ax/LIB/SLIBCA.LIB new file mode 100644 index 0000000..995c32a Binary files /dev/null and b/Microsoft C v6ax/LIB/SLIBCA.LIB differ diff --git a/Microsoft C v6ax/LIB/SLIBCE.LIB b/Microsoft C v6ax/LIB/SLIBCE.LIB new file mode 100644 index 0000000..4117d7f Binary files /dev/null and b/Microsoft C v6ax/LIB/SLIBCE.LIB differ diff --git a/Microsoft C v6ax/LIB/TXTONLY.OBJ b/Microsoft C v6ax/LIB/TXTONLY.OBJ new file mode 100644 index 0000000..e4a83bc Binary files /dev/null and b/Microsoft C v6ax/LIB/TXTONLY.OBJ differ diff --git a/Microsoft C v6ax/LIB/VARSTCK.OBJ b/Microsoft C v6ax/LIB/VARSTCK.OBJ new file mode 100644 index 0000000..546771c Binary files /dev/null and b/Microsoft C v6ax/LIB/VARSTCK.OBJ differ diff --git a/Microsoft C v6ax/SOURCE/DOC/SAMPLES.DOC b/Microsoft C v6ax/SOURCE/DOC/SAMPLES.DOC new file mode 100644 index 0000000..c32e3da --- /dev/null +++ b/Microsoft C v6ax/SOURCE/DOC/SAMPLES.DOC @@ -0,0 +1,76 @@ + + SAMPLES.DOC File + + Notes on sample programs included with the Microsoft(R) + C Optimizing Compiler Version 6.00 + + (C) Copyright Microsoft Corporation, 1990 + + + Files Description + ----- ----------- + + GRDEMO.MAK GRDEMO illustrates general graphics techniques + GRDEMO.C including drawing, animation, palette + MENU.C switching, window adjustment, menus, and + MENU.H turtle graphics. The MENU and TURTLE modules + TURTLE.C are independent modules that could be used + TURTLE.H in your own programs. Real mode only. + + CHRTDEMO.MAK CHRTDEMO illustrates presentation graphics + CHRTDEMO.C techniques. You can use this program as a tool + CHRTSUPT.C for testing different modes and options before + CHRTDEMO.H building them into your own programs. Real mode + only. + + SORTDEMO.C Visually illustrates six different sorting + algorithms. The source code demonstrates how + to make OS/2 calls. Real or protect mode. + + SNAP.C Runs in the background and saves the current + screen in a file when a hot key is pressed. + Protect mode only. + + INCLUDE.C A PWB extension file that implements an include + command that finds and opens include files. + + TXTFMT.C A PWB extension file that implements various + commands related to text formatting. You can use + these commands to format paragraphs, center + text, change case, and insert or delete tab + spaces. + + FILTER.C A PWB extension file that implements a filter + command. You can use it to replace a block of + text with the output of a user-specified + filter (such as the DOS SORT program). + +======================< Note on Graphics Libraries >======================= + +GRDEMO and CHRTDEMO require GRAPHICS.LIB. CHRTDEMO also requires +PGCHART.LIB. SORTDEMO requires GRAPHICS.LIB for DOS or GRTEXTP.LIB for +OS/2. If you did not request these libraries in your combined library +files during setup, you will get "unresolved external" linker errors +when you try to compile the programs. + +If you are using CL, specify the library names on the command line. +For example, use this command line to compile GRDEMO: + + CL GRDEMO.C MENU.C TURTLE.C GRAPHICS.LIB + +If you are using PWB, you can use the supplied program list (.MAK) +files. These automatically add the appropriate libraries. + +======================< Note on Naming Conventions >======================= + +The example programs use a subset of the naming conventions used in +OS/2 and Windows include files. In this convention, the first +character of an identifier is a lowercase letter called a prefix. +Common prefixes include p (pointer), a (array), i (index), and c +(count). After the prefix, there may be an additional lowercase tag, +usually indicating type. Common tags include ch (char), f (flag), sz +(zero-terminated string) l (long), and x or y (x or y coordinate). +Following this there may be one or more qualifiers, each beginning +with an uppercase letter. For example, an identifier called +achFileName is an array (a) of characters (ch) containing a file name +(FileName). diff --git a/Microsoft C v6ax/SOURCE/DOC/STARTUP.DOC b/Microsoft C v6ax/SOURCE/DOC/STARTUP.DOC new file mode 100644 index 0000000..d241a4c --- /dev/null +++ b/Microsoft C v6ax/SOURCE/DOC/STARTUP.DOC @@ -0,0 +1,132 @@ +C Runtime Library Startup Sources +--------------------------------- + +The directory \startup and its subdirectories contain the files +necessary for building the startup portion of the C runtime library. +The \startup directory contains the startup source files, the include +files, the batch file, and the make file used to build the startup object +files. The subdirectories of \startup contain OS specific sources. + +The startup object files can be built by invoking startup.bat (DOS) or +startup.cmd (OS/2) from within the \startup directory. This batch file +assumes the following: + + (1) nmake.exe, nmk.com, link.exe, the C compiler, and the assembler + must be in the execution path. MASM 5.0 and C 6.0 or later are + required to build the startup sources. + + (2) For OS/2, os2.lib must be in the directory specified by the LIB + environment variable. + + (3) environment variable INCLUDE must be set to the directory that + contains your C include files + +Startup will create four memory model specific subdirectories (i.e., S, M, C, +and L) and place the appropriate object files there. Under each memory model +subdirectory, startup creates two addition subdirectories OS2 and DOS where +OS specific objects reside. + +The include files stdio.h and ctype.h are required for building the +startup source file wild.c but are not included on the \startup directory +because they exist on the directory containing the standard include files. +A make variable called CINC controls where the makefile looks for these +include files. STARTUP sets CINC to the current value of the INCLUDE +environment variable. This variable should be set to the location of +the C include files. CINC can also be set in the makefile if you wish +to run the makefile separately. + +The message "" is generated when some of the assembly language +source files are assembled. This message is expected and is totally benign. + +The startup batch file requires as arguments a list of capital letters +describing the memory models you wish to build. For example, +"startup S L" will build the small and large model startup objects. +Startup will then link the objects with a sample C program called nulbody.c +(consisting of a null main functions) to produce nulbody.exe. +[Invoking startup. with no arguments will give usage information.] + +If you wish to build startup sources for only one operating system +(i.e. DOS or OS/2), type "DOS" or "OS2" as the first argument to the +startup batch file. + +Note: startup sources written in assembly language have been edited with +tab stops set to 8. Startup sources written in C have been edited with +tab stops set to 4. + +The following files are contained in the \startup directory: + +Startup source files (OS independent): + rchkstk.asm + fmsghdr.asm + chkstk.asm + chksum.asm + crt0fp.asm + setargv.asm + wild.c + +Startup source files (OS specific): + crt0.asm + crt0dat.asm + crt0msg.asm + execmsg.asm (DOS only) + nmsghdr.asm + stdalloc.asm + stdenvp.asm + stdargv.asm + +Startup include files: + cmacros.inc + heap.inc + msdos.inc + msdos.h + register.h + rterr.inc + version.inc + +File count files: + _file.c + file2.h + +Make and batch files: + startup.bat: builds objs and links null program on DOS + startup.cmd: builds objs and links null program on OS/2 + makefile: contains rules for building startup sources + nulbody.c: null c program + nulbody.lnk: link script for linking null program + +Documentation: + readme.doc: information about \startup directory structure + and contents + + + +Placing the Stack outside of DGROUP +----------------------------------- + + If your program requires a large amount of stack space, the run time +library can be configured to place the stack in a seperate segment +outside of DGROUP. By doing this, the stack can be up to 64K in size +without reducing the amount of storage available in DGROUP for near +data. In order to do this your program must be either compact, large, +or huge model. You must also direct the compiler to assume that +that SS != DS. Thus, your memory model specification should be -ACw, +-ALw, or -AHw. See the compiler documentation for more information +about these options. + + To use a far stack, you must assemble the startup sources provided +with C 6.0. In the startup sources directory is a file called "makefile" +which controls the startup module build process for the run time library. +To enable a far stack, you need to edit the makefile. Near the top of +the file are two lines which begin "CFLAGS=" and "ASMFLAGS=". You should +add the text " -DFARSTACK" to the end of these two lines. Then build +the startup modules according to instructions given previously in this +file. You should then use the LIB utility to replace the startup modules +in your library with the new modules you have built. When linking, the +size of the stack can be controlled with the /STACK command line option. + + If you are creating DOS programs, the size of your .EXE file will be +increased by the size of your stack. This is a consequence of the DOS +.EXE format. To reduce the size of your .EXE file, link with the +/EXEPACK option. + + --- End --- diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.C b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.C new file mode 100644 index 0000000..64518d7 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.C @@ -0,0 +1,1095 @@ +#include +#include +#include +#include +#include +#include +#include "chrtdemo.h" + +/* Structures for system configuration and chart environment. */ +struct videoconfig vc; +chartenv ce; + +/* Category variables. */ +short cCat; +char _far *aCat[MAXVALUES]; + +/* Series variables. */ +short cSeries; +short _far acSeries[MAXSERIES]; +char _far *aSeriesName[MAXSERIES]; + +/* Temporary holding array for all data. Data values for multi-series + * bar, column, and line charts remain here. Data for other kinds of + * charts are transferred to the arrays below. + */ +float _far aValue[MAXSERIES][MAXVALUES]; + +/* Data values for single-series charts. First array is used for + * bar, column, line, and pie. First and second are both used for + * single-series scatter. + */ +float _far axValue[MAXVALUES]; +float _far ayValue[MAXVALUES]; + +/* Data values for multi-series scatter charts. */ +float _far axValueMS[MAXVALUES][MAXVALUES]; +float _far ayValueMS[MAXVALUES][MAXVALUES]; + +/* Exploded flags for pie chart. */ +short _far aExplode[MAXVALUES]; + +/* Variable used to track control and screen position. */ +struct SCREENINFO si; + +/* Colors of menus and prompts. */ +struct tagColor co; + +/* Flags to indicate whether to use imported or default data. */ +BOOL fDefault = TRUE; + +/* Arrays of strings used by the Menu function. The first string is the + * menu title. The next non-null strings are the menu selections. A null + * string indicates the end of the list. + */ +char *pszChartOpt[] = + { "Options", "Screen Mode", "Windows", "Titles", + "Axis (X and Y)", "Legend", "Fonts", "Reset", "" }; + +char *pszChartType[] = + { "Type", "Bar", "Column", "Line", "Scatter", "Pie", "" }; + +char *pszMainMenu[] = + { "Main Menu", "Demo", "View Chart", "Chart Type", "Options", + "Show Chart Data", "Quit", "" }; + +/* Sample data. */ +#define O_JUICE 0 +#define I_TEA 1 +#define H_CHOC 2 +#define TEMPERATURE 3 + +char _far *aQuarters[] = + { "First", "Second", "Third", "Fourth" }; + +char _far *aMonths[] = + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + +float _far aSales[3][12] = +{ + { 3.6F, 3.2F, 3.3F, 3.4F, 3.1F, 2.9F, + 3.0F, 3.6F, 3.2F, 3.3F, 3.5F, 3.9F }, + { 1.0F, 1.3F, 1.4F, 1.7F, 2.2F, 2.9F, + 2.9F, 3.1F, 2.6F, 1.8F, 1.1F, 1.2F }, + { 2.4F, 2.3F, 2.0F, 1.6F, 1.3F, 1.0F, + 0.9F, 0.8F, 1.1F, 1.4F, 1.9F, 2.5F } +}; + +float _far aTemperature[12] = + { 2.9F, 3.2F, 3.9F, 4.8F, 6.0F, 6.5F, + 7.0F, 7.2F, 6.0F, 4.7F, 4.1F, 3.0F }; + +char _far *aSalesTitles[] = + { "Orange Juice Sales", "Iced Tea Sales", "Hot Chocolate Sales" }; + +char *TempTitle = "Average Temperature"; + +int main() +{ + Initialize(); + MainMenu(); + + /* Reset the video mode and screen colors prior to leaving. */ + _setvideomode( _DEFAULTMODE ); + _settextcolor( co.InfoColor ); + _clearscreen( _GCLEARSCREEN ); + + return 0; +} + +/* ChartOptions - Gets chart options. + * + * Params: None + */ +void ChartOptions() +{ + int iChoice; + + PushTitle( pszChartOpt[0] ); + while( (iChoice = Menu( pszChartOpt )) != ESCAPE ) + { + + /* Get chart options. */ + switch( iChoice ) + { + + /* Branch to the appropriate menu. */ + case 1: + ScreenMode(); + break; + + case 2: + Windows(); + break; + + case 3: + Titles(); + break; + + case 4: + Axes(); + break; + + case 5: + Legend(); + break; + + case 6: + FontOptions(); + break; + + case 7: + ResetOptions(); + break; + + } + } + PopTitle(); +} + +/* ChartType - Gets chart type. + * + * Params: None + */ +void ChartType() +{ + int iChoice; + + /* Get chart type. */ + PushTitle( pszChartType[0] ); + iChoice = Menu( pszChartType ); + + if( iChoice != ESCAPE ) + { + /* Set the chart type, and get the chart style. */ + ce.charttype = iChoice; + switch( iChoice ) + { + + case 1: + case 2: + iChoice = BlankMenu( "Style", "Plain Bars", "Stacked Bars" ); + break; + + case 3: + case 4: + iChoice = BlankMenu( "Style", "Lines-Points", "Points Only" ); + break; + + case 5: + iChoice = BlankMenu( "Style", "Percent", "No Percent" ); + } + + if( iChoice != ESCAPE) + ce.chartstyle = iChoice; + + /* Set default data without changing environment defaults. */ + DefaultData( ce.charttype, ce.chartstyle, FALSE ); + PopTitle(); + } + PopTitle(); +} + +/* ClearData - Clears category and value data. + * + * Params: fConfirm - flag specifying whether to query for confirmation + */ +void ClearData( BOOL fConfirm ) +{ + char chResponse = 'Y'; + int iCat; + + WrtForm( 18 ); + + /* Query for confirmation. */ + if( fConfirm ) + chResponse = InputCh( "Are you sure? ", "YN\x1b" ); + + if( chResponse == 'Y' ) + { + + /* Clear all relevant data. */ + for( iCat = 0; iCat < cCat; iCat++ ) + aCat[iCat] = NULL; + cCat = 0; + cSeries = 0; + } +} + +/* DefaultData - Initializes default data for each kind of chart. + * + * Params: iType - Chart type to be initialized + * iStyle - Chart style + * fClear - Signal to clear all defaults + */ +void DefaultData( short iType, short iStyle, BOOL fClear ) +{ + int iCat, iValue, iSubValue, iSeries; + + /* Call default chart to clear old values. */ + if( fClear ) + _pg_defaultchart( &ce, iType, iStyle ); + + /* Initialize category titles. */ + cCat = 12; + for( iCat = 0; iCat < cCat; iCat++ ) + aCat[iCat] = aMonths[iCat]; + + switch( ce.charttype ) + { + + /* Initialize data for each chart type. */ + case _PG_BARCHART: + + strcpy( ce.maintitle.title, "Orange Juice and Iced Tea Sales" ); + cSeries = 2; + for( iSeries = 0; iSeries < cSeries; iSeries++ ) + { + aSeriesName[iSeries] = aSalesTitles[iSeries]; + acSeries[iSeries] = cCat; + for( iValue = 0; iValue < cCat; iValue++ ) + aValue[iSeries][iValue] = (float)aSales[iSeries][iValue]; + } + break; + + case _PG_COLUMNCHART: + + strcpy( ce.maintitle.title, "Orange Juice Sales" ); + cSeries = 1; + for( iSeries = 0; iSeries < cSeries; iSeries++ ) + { + aSeriesName[iSeries] = aSalesTitles[iSeries]; + acSeries[iSeries] = cCat; + for( iValue = 0; iValue < cCat; iValue++ ) + aValue[iSeries][iValue] = (float)aSales[iSeries][iValue]; + } + break; + + case _PG_LINECHART: + + strcpy( ce.maintitle.title, "Beverage Sales" ); + cSeries = 3; + for( iSeries = 0; iSeries < cSeries; iSeries++ ) + { + aSeriesName[iSeries] = aSalesTitles[iSeries]; + acSeries[iSeries] = cCat; + for( iValue = 0; iValue < cCat; iValue++ ) + aValue[iSeries][iValue] = (float)aSales[iSeries][iValue]; + } + break; + + case _PG_SCATTERCHART: + + strcpy( ce.maintitle.title, + "Average Temperature Compared to Beverage Sales" ); + /* ce.chartstyle = _PG_POINTONLY; */ + cSeries = 4; + + aSeriesName[0] = aSalesTitles[I_TEA]; + aSeriesName[2] = aSalesTitles[H_CHOC]; + acSeries[0] = acSeries[1] = acSeries[2] = acSeries[3] = 12; + for( iValue = 0; iValue < 12; iValue++ ) + { + aValue[0][iValue] = (float)aSales[I_TEA][iValue] ; + aValue[1][iValue] = (float)aSales[TEMPERATURE][iValue] ; + aValue[2][iValue] = (float)aSales[H_CHOC][iValue] ; + aValue[3][iValue] = (float)aSales[TEMPERATURE][iValue] ; + } + break; + + case _PG_PIECHART: + default: + + strcpy( ce.maintitle.title, "Iced Tea Sales" ); + cCat = 4; + for( iCat = 0; iCat < cCat; iCat++ ) + aCat[iCat] = aQuarters[iCat]; + + cSeries = 1; + aSeriesName[0] = aSalesTitles[I_TEA]; + acSeries[0] = cCat; + + for( iValue = 0; iValue < cCat; iValue++ ) + { + aValue[0][iValue] = 0.0; + for( iSubValue = 0; iSubValue < 3; iSubValue++ ) + aValue[0][iValue] += (float)aSales[I_TEA][iSubValue * iValue]; + } + aExplode[3] = 1; + break; + } +} + +/* Demo - Displays a series of sample charts. + * + * Params: None + */ +void Demo() +{ + int cValue; + palettetype palette_struct; + + /* Display the sample data in spreadsheet form. */ + ShowSampleData(); + + DefaultData( _PG_PIECHART, _PG_NOPERCENT, TRUE ); + + /* Set video mode and draw charts. For each chart, set default + * data and modify any desired environment fields. If error, + * terminate demo. + */ + _setvideomode( si.mode ); + + cValue = 4; + strcpy( ce.subtitle.title, "Default Pie Chart" ); + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + strcpy( ce.subtitle.title, "Customized Pie Chart" ); + ce.chartstyle = _PG_PERCENT; + ce.legend.place = _PG_BOTTOM; + if (si.fColor) + { + ce.maintitle.titlecolor = ce.subtitle.titlecolor = 0; + ce.chartwindow.background = 1; + ce.datawindow.background = ce.legend.legendwindow.background = 6; + ce.legend.textcolor = 1; + } + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + cValue = 12; + DefaultData( _PG_BARCHART, _PG_PLAINBARS, TRUE ); + strcpy( ce.subtitle.title, "Default Bar Chart" ); + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + strcpy( ce.subtitle.title, "Customized Stacked Bar Chart" ); + strcpy( ce.xaxis.axistitle.title, "Sales in Thousands" ); + strcpy( ce.yaxis.axistitle.title, "Month" ); + ce.chartstyle = _PG_STACKEDBARS; + ce.legend.place = _PG_RIGHT; + ce.xaxis.ticdecimals = 2; + if (si.fColor) + { + ce.maintitle.titlecolor = ce.subtitle.titlecolor = 12; + ce.chartwindow.background = 7; + ce.datawindow.background = 8; + ce.legend.textcolor = 0; + ce.legend.legendwindow.background = 8; + ce.legend.autosize = FALSE; + ce.legend.legendwindow.y1 = vc.numypixels - 85; + ce.legend.legendwindow.y2 = vc.numypixels - 45; + } + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + DefaultData( _PG_COLUMNCHART, _PG_PLAINBARS, TRUE ); + strcpy( ce.subtitle.title, "Default Column Chart" ); + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + strcpy( ce.subtitle.title, "Customized Column Chart" ); + strcpy( ce.xaxis.axistitle.title, "Month" ); + strcpy( ce.yaxis.axistitle.title, "Sales in Thousands" ); + ce.legend.place = _PG_BOTTOM; + if (si.fColor) + { + ce.maintitle.titlecolor = 0; + ce.subtitle.titlecolor = 0; + ce.chartwindow.background = 8; + ce.datawindow.background = 2; + ce.legend.legendwindow.background = 10; + } + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + DefaultData( _PG_LINECHART, _PG_POINTANDLINE, TRUE ); + strcpy( ce.subtitle.title, "Default Line Chart" ); + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + strcpy( ce.subtitle.title, "Customized Line Chart" ); + strcpy( ce.xaxis.axistitle.title, "Month" ); + strcpy( ce.yaxis.axistitle.title, "Sales in Thousands" ); + ce.legend.place = _PG_RIGHT; + if (si.fColor) + { + ce.maintitle.titlecolor = 1; + ce.subtitle.titlecolor = 1; + ce.chartwindow.background = 3; + ce.datawindow.background = 7; + ce.legend.legendwindow.background = 7; + ce.legend.autosize = FALSE; + ce.legend.legendwindow.y1 = vc.numypixels - 85; + ce.legend.legendwindow.y2 = vc.numypixels - 45; + } + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + DefaultData( _PG_SCATTERCHART, _PG_POINTONLY, TRUE ); + strcpy( ce.subtitle.title, "Default Scatter Chart" ); + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + cSeries = 4; + strcpy( ce.subtitle.title, "Customized Scatter Chart" ); + strcpy( ce.xaxis.axistitle.title, "Sales in Thousands" ); + strcpy( ce.yaxis.axistitle.title, "Average Temperature" ); + ce.legend.place = _PG_RIGHT; + if (si.fColor) + { + ce.maintitle.titlecolor = 0; + ce.subtitle.titlecolor = 0; + ce.chartwindow.background = 4; + ce.datawindow.background = 8; + ce.legend.legendwindow.background = 8; + ce.legend.autosize = FALSE; + ce.legend.legendwindow.y1 = vc.numypixels - 85; + ce.legend.legendwindow.y2 = vc.numypixels - 45; + } + if( ViewChart() ) + return; + else + _clearscreen( _GCLEARSCREEN ); + + DefaultData( _PG_BARCHART, _PG_PERCENT, TRUE ); +} + +/* FindVideoMode - Finds the "best" video mode for the adaptor in use. + * + * Params: vc - structure of type struct videoconfig + * + * Returns: Best mode + */ +int FindVideoMode( struct videoconfig vc ) +{ + switch( vc.adapter ) + { + case _CGA: + case _OCGA: + return _HRESBW; + case _EGA: + case _OEGA: + return( vc.monitor == _MONO ) ? _ERESNOCOLOR : _ERESCOLOR; + case _VGA: + case _OVGA: + case _MCGA: + return _VRES16COLOR; + case _HGC: + return _HERCMONO; + default: + return _DEFAULTMODE; + } +} + +/* Initialize - Does various initialization tasks. + * + * Params: None + */ +void Initialize( void ) +{ + int iSeries, iValue; + + /* Initialize all value arrays to missing. */ + for( iSeries = 0; iSeries < MAXSERIES; iSeries++ ) + { + + axValue[iSeries] = _PG_MISSINGVALUE; + ayValue[iSeries] = _PG_MISSINGVALUE; + + for( iValue = 0; iValue < MAXVALUES; iValue++ ) + aValue[iSeries][iValue] = _PG_MISSINGVALUE; + + for( iValue = 0; iValue < MAXVALUES; iValue++ ) + { + axValueMS[iSeries][iValue] = _PG_MISSINGVALUE; + ayValueMS[iSeries][iValue] = _PG_MISSINGVALUE; + } + } + + /* Initialize zero sets. */ + cSeries = 0; + + /* Initialize default chart environment, screen mode, and data. */ + _pg_initchart(); + _getvideoconfig( &vc ); + + /* Find the best available mode for display. + * Don't set 256 color, medium resolution (_MRES256COLOR). + */ + si.mode = FindVideoMode( vc ); + + if( si.mode == _TEXTMONO ) + { + _clearscreen( _GCLEARSCREEN ); + _outtext( "No graphics available. Can't run chart demo." ); + exit( 1 ); + } + + SetDisplayColors(); + + SetGraphMode( si.mode ); + DefaultData( _PG_BARCHART, _PG_PLAINBARS, TRUE ); + + _setvideomode( _DEFAULTMODE ); + + +} + +/* MainMenu - Manages the main menu. + * + * Params: None + */ +void MainMenu( void ) +{ + int iChoice; + char chResponse = 'Y'; + char chVerify; + + PushTitle( pszMainMenu[0] ); + do + { + /* If the user selects Quit, iChoice will contain 6. If the + * user presses ESCAPE, iChoice will be ESCAPE, which is + * equal to 27. In any case, we can test both conditions + * by checking to see whether iChoice is less than 6. + */ + while( (iChoice = Menu( pszMainMenu )) < 6 ) + { + /* Get main menu selection. */ + switch( iChoice ) + { + + case 1: + /* Display demo charts. */ + Demo(); + _setvideomode( _DEFAULTMODE ); + break; + + case 2: + /* Set graphics video mode, display current chart, + * and restore text video mode. + */ + _setvideomode( si.mode ); + ViewChart(); + _setvideomode( _DEFAULTMODE ); + break; + + case 3: + /* Get chart type and style. */ + ChartType(); + break; + + case 4: + /* Get chart options. */ + ChartOptions(); + break; + case 5: + /* Show chart data. */ + ShowChartData(); + break; + + } + + } + + /* If the user is trying to leave the program using the ESCAPE + * key, we must verify the choice. This is done to prevent + * an eager typist from pressing ESCAPE one time too often + * and exiting at an unanticipated point. + */ + if( iChoice == ESCAPE ) + { + Help( "Press \"Q\" to Actually Quit", co.InputColor ); + + putchar( BEEP ); + _settextposition( si.help - 1, 32 ); + chVerify = getch(); + if( tolower( chVerify ) != 'q' ) + iChoice = 0; + else + iChoice = 6; + } + + } while( iChoice != 6 ); + PopTitle(); +} + +/* ResetOptions - After confirmation, resets chart options to default. + * + * Params: None + */ +void ResetOptions() +{ + char chResponse; + + /* Prompt for confirmation before setting default environment. */ + ClrForm(); + Help( "Type 'Y' to reset all options, 'N' to keep them.", co.InputColor ); + chResponse = InputCh( "Are you sure? ", "YN\x1b" ); + if( chResponse == 'Y' ) + _pg_defaultchart( &ce, 1, 1 ); + +} + +/* SetGraphMode - Tests the specified graphics mode and sets the xMax + * and yMax values in the si (Screen Information) structure. + * + * Params: mode number + * + * Return: FALSE if mode invalid, TRUE if valid + */ +BOOL SetGraphMode(int mode) +{ + if (!_setvideomode( mode ) ) + return FALSE; + else + { + _getvideoconfig ( &vc ); + if( !vc.numxpixels ) + return FALSE; + si.xMax = vc.numxpixels; + si.yMax = vc.numypixels; + si.mode = mode; + + /* Set flag to indicate whether multiple colors are available. */ + si.fColor = iscolor( mode ); + + return TRUE; + } +} + +/* ShowChartData - Displays the data in the chart environment. + * + * Params: None + */ +void ShowChartData() +{ + int iRow = 2; + struct _fontinfo fd; + static char *szContinue = + "Press any key to continue, ESC to return to the menu."; + + _clearscreen( _GCLEARSCREEN ); + SprintAt( iRow++, 1, "short charttype = %d", ce.charttype ); + SprintAt( iRow++, 1, "short chartstyle = %d", ce.chartstyle ); + SprintAt( iRow++, 1, "windowtype chartwindow =" ); + iRow = ShowWindowType( iRow, 1, ce.chartwindow ); + SprintAt( iRow++, 1, "windowtype datawindow =" ); + iRow = ShowWindowType( iRow, 1, ce.datawindow ); + SprintAt( ++iRow, 1, szContinue ); + if( getch() == ESCAPE ) + return; + + iRow = 2; + _clearscreen( _GCLEARSCREEN ); + SprintAt( iRow++, 1, "titletype maintitle =" ); + iRow = ShowTitleType( iRow, 1, ce.maintitle ); + SprintAt( iRow++, 1, "titletype subtitle =" ); + iRow = ShowTitleType( iRow, 1, ce.subtitle ); + SprintAt( ++iRow, 1, szContinue ); + if( getch() == ESCAPE ) + return; + + iRow = 2; + _clearscreen( _GCLEARSCREEN ); + SprintAt( iRow++, 1, "axistype xaxis =" ); + iRow = ShowAxisType( iRow, 1, ce.xaxis ); + SprintAt( ++iRow, 1, szContinue ); + if( getch() == ESCAPE ) + return; + + iRow = 2; + _clearscreen( _GCLEARSCREEN ); + SprintAt( iRow++, 1, "axistype yaxis =" ); + iRow = ShowAxisType( iRow, 1, ce.yaxis ); + SprintAt( ++iRow, 1, szContinue ); + if( getch() == ESCAPE ) + return; + + iRow = 2; + _clearscreen( _GCLEARSCREEN ); + SprintAt( iRow++, 1, "legendtype legend =" ); + iRow = ShowLegendType( iRow, 1, ce.legend ); + SprintAt( ++iRow, 1, szContinue ); + if( getch() == ESCAPE ) + return; + + iRow = 2; + _clearscreen( _GCLEARSCREEN ); + if( _getfontinfo( &fd ) != -1 ) + { + SprintAt( iRow++, 1, "struct _fontinfo =" ); + iRow = ShowFontInfo( iRow, 1, fd ); + SprintAt( ++iRow, 1, "Press any key to continue . . ." ); + getch(); + } +} + +/* ShowAxisType - Displays data in a variable of type "axistype". + * + * Params: iRow - Row at which to start + * iCol - Column from which to indent + * theAxis - Variable of type "axistype" to display + * + * Return: Next available row + */ +int ShowAxisType( int iRow, int iCol, axistype theAxis ) +{ + SprintAt( iRow++, iCol + 5, "short .grid = %d", theAxis.grid ); + SprintAt( iRow++, iCol + 5, "short .gridstyle = %d", theAxis.gridstyle ); + SprintAt( iRow++, iCol + 5, "titletype axistitle=" ); + iRow = ShowTitleType( iRow, iCol + 5, theAxis.axistitle ); + SprintAt( iRow++, iCol + 5, "short .axiscolor = %d", theAxis.axiscolor ); + SprintAt( iRow++, iCol + 5, "short .labeled = %s", + (theAxis.labeled) ? "TRUE" : "FALSE" ); + SprintAt( iRow++, iCol + 5, "short .rangetype = %d", theAxis.rangetype ); + SprintAt( iRow++, iCol + 5, "float .logbase = %f", theAxis.logbase ); + SprintAt( iRow++, iCol + 5, "short .autoscale = %s", + (theAxis.autoscale) ? "TRUE" : "FALSE" ); + SprintAt( iRow++, iCol + 5, "float .scalemin = %f", theAxis.scalemin ); + SprintAt( iRow++, iCol + 5, "float .scalemax = %f", theAxis.scalemax ); + SprintAt( iRow++, iCol + 5, "float .scalefactor = %f", theAxis.scalefactor ); + iRow = ShowTitleType( iRow, iCol + 5, theAxis.scaletitle ); + SprintAt( iRow++, iCol + 5, "float .ticinterval = %f", theAxis.ticinterval ); + SprintAt( iRow++, iCol + 5, "short .ticformat = %d", theAxis.ticformat ); + SprintAt( iRow++, iCol + 5, "short .ticdecimals = %d", theAxis.ticdecimals ); + + return iRow; +} + +/* ShowFontInfo - Displays data in a variable of type "_fontinfo". + * + * Params: iRow - Row at which to start + * iCol - Column from which to indent + * theFont - Variable of type "_fontinfo" to display + * + * Return: Next available row + */ +int ShowFontInfo( int iRow, int iCol, struct _fontinfo theFont ) +{ + SprintAt( iRow++, iCol + 5, "int .type = %d", theFont.type ); + SprintAt( iRow++, iCol + 5, "int .ascent = %d", theFont.ascent ); + SprintAt( iRow++, iCol + 5, "int .pixwidth = %d", theFont.pixwidth ); + SprintAt( iRow++, iCol + 5, "int .pixheight = %d", theFont.pixheight ); + SprintAt( iRow++, iCol + 5, "int .avgwidth = %d", theFont.avgwidth ); + SprintAt( iRow++, iCol + 5, "char .filename = %s", theFont.filename ); + SprintAt( iRow++, iCol + 5, "char .facename = %s", theFont.facename ); + + return iRow; +} + +/* ShowLegendType - Displays data in a variable of type "legendtype". + * + * Params: iRow - Row at which to start + * iCol - Column from which to indent + * theLegend - Variable of type "legendtype" to display + * + * Return: Next available row + */ +int ShowLegendType( int iRow, int iCol, legendtype theLegend ) +{ + SprintAt( iRow++, iCol + 5, "short .legend = %s", + (theLegend.legend) ? "TRUE" : "FALSE" ); + SprintAt( iRow++, iCol + 5, "short .place = %d", theLegend.place ); + SprintAt( iRow++, iCol + 5, "short .textcolor = %d", theLegend.textcolor ); + SprintAt( iRow++, iCol + 5, "short .autosize = %d", theLegend.autosize ); + SprintAt( iRow++, iCol + 5, "windowtype legendwindow =" ); + iRow = ShowWindowType( iRow, iCol + 5, theLegend.legendwindow ); + + return iRow; +} + +/* ShowSampleData - Displays the sample data for the demo. + * + * Params: None + */ +void ShowSampleData() +{ + int iCat, y, iSeries, iValue; + char szTmp[80]; + + /* Display data in table format. */ + _clearscreen( _GCLEARSCREEN ); + PrintAt( 1, 40 - strlen(szTmp) / 2, "Data in Table Format", -1 ); + + /* Write titles and draw separator line. */ + y = 3; + for( iCat = 1; iCat <= 12; iCat++ ) + PrintAt( y, iCat * 6, aMonths[iCat - 1], -1 ); + + memset( szTmp, '-', 69 ); + szTmp[69] = 0; + PrintAt( ++y, 6, szTmp, -1 ); + + /* Write data. */ + for( iSeries = 1; iSeries <= 3; iSeries++ ) + { + PrintAt( y += 2, 4, aSalesTitles[iSeries - 1], -1 ); + y += 2; + for( iValue = 1; iValue <= 12; iValue++ ) + { + sprintf( szTmp, "%#3.2f", aSales[iSeries - 1][iValue - 1] ); + PrintAt( y, iValue * 6, (char _far *)szTmp, -1 ); + } + } + PrintAt( y += 2, 4, TempTitle, -1 ); + y += 2; + for( iValue = 1; iValue <= 12; iValue++ ) + { + sprintf( szTmp, "%#3.1f", aTemperature[iValue - 1] ); + PrintAt( y, iValue * 6, szTmp, -1 ); + } + + PrintAt( y += 2, 1, "Press any key to continue . . .", -1 ); + getche(); +} + +/* ShowTitleType - Displays data in a variable of type "titletype". + * + * Params: iRow - Row at which to start + * iCol - Column from which to indent + * theTitle - Variable of type "titletype" to display + * + * Return: Next available row + */ +int ShowTitleType( int iRow, int iCol, titletype theTitle ) +{ + SprintAt( iRow++, iCol + 5, "char .title[%d] = \"%s\"", _PG_TITLELEN, + theTitle.title ); + SprintAt( iRow++, iCol + 5, "short .titlecolor = %d", theTitle.titlecolor ); + SprintAt( iRow++, iCol + 5, "short .justify = %d", theTitle.justify ); + + return iRow; +} + +/* ShowWindowType - Displays data in a variable of type "windowtype". + * + * Params: iRow - Row at which to start + * iCol - Column from which to indent + * theWindow - Variable of type "windowtype" to display + * + * Return: Next available row + */ +int ShowWindowType( int iRow, int iCol, windowtype theWindow ) +{ + SprintAt( iRow++, iCol + 5, "short .x1 = %d", theWindow.x1 ); + SprintAt( iRow++, iCol + 5, "short .y1 = %d", theWindow.y1 ); + SprintAt( iRow++, iCol + 5, "short .x2 = %d", theWindow.x2 ); + SprintAt( iRow++, iCol + 5, "short .y2 = %d", theWindow.y2 ); + SprintAt( iRow++, iCol + 5, "short .border = %d", theWindow.border ); + SprintAt( iRow++, iCol + 5, "short .background = %d", theWindow.background ); + SprintAt( iRow++, iCol + 5, "short .borderstyle = %d", theWindow.borderstyle ); + SprintAt( iRow++, iCol + 5, "short .bordercolor = %d", theWindow.bordercolor ); + + return iRow; +} + +/* ShowError - Displays error message for one of the chart library + * errors. + * + * Params: iErr - Error number + */ +void ShowError( int iErr ) +{ + char szTmp[50]; + + /* Change to text screen. */ + _setvideomode( _DEFAULTMODE ); + + /* Select the error text. */ + switch( iErr ) + { + case _PG_NOTINITIALIZED: + strcpy( szTmp, "Chart Library Not Initialized" ); + break; + case _PG_BADSCREENMODE: + strcpy( szTmp, "Invalid Screen Mode" ); + break; + case _PG_BADCHARTTYPE: + strcpy( szTmp, "Invalid Chart Type" ); + break; + case _PG_BADCHARTSTYLE: + strcpy( szTmp, "Invalid Chart Style" ); + break; + case _PG_BADLEGENDWINDOW: + strcpy( szTmp, "Invalid Legend Window" ); + break; + case _PG_BADDATAWINDOW: + strcpy( szTmp, "No Room for Data window" ); + break; + case _PG_BADCHARTWINDOW: + strcpy( szTmp, "Invalid Chart window coordinates" ); + break; + case _PG_NOMEMORY: + strcpy( szTmp, "Not Enough Memory for Data Arrays" ); + break; + case _PG_BADLOGBASE: + strcpy( szTmp, "X or Y log base <= 0" ); + break; + case _PG_BADSCALEFACTOR: + strcpy( szTmp, "X or Y scale factor = 0" ); + break; + case _PG_TOOSMALLN: + strcpy( szTmp, "Too few data values" ); + break; + case _PG_TOOFEWSERIES: + strcpy( szTmp, "No data series specified" ); + break; + default: + strcpy( szTmp, "Unknown error" ); + } + + ErrorMsg( szTmp ); +} + +/* ViewChart - Draws the current chart. + * + * Params: None + */ +int ViewChart() +{ + int cValue, iValue, iSeries, iErr; + + /* Make sure some data exists. */ + if( cSeries <= 0 ) + { + fDefault = TRUE; + DefaultData( ce.charttype, ce.chartstyle, FALSE ); + } + + /* Find the longest series. */ + cValue = 0; + for( iSeries = 0; iSeries < cSeries; iSeries++ ) + if( acSeries[iSeries] > cValue ) + cValue = acSeries[iSeries]; + + _setvideomode( si.mode ); + + + /* Process depending on the type of chart. */ + switch( ce.charttype ) + { + + case _PG_PIECHART: + case _PG_BARCHART: + case _PG_COLUMNCHART: + case _PG_LINECHART: + + /* Initialize data and draw pie chart or single-series bar, + * column, or line chart. + */ + if( (cSeries == 1) ||( ce.charttype == _PG_PIECHART) ) + { + + /* Transfer data into a single-dimension array. */ + for( iValue = 0; iValue < cValue; iValue++ ) + axValue[iValue] = aValue[0][iValue]; + + /* Draw chart. */ + if( ce.charttype == _PG_PIECHART ) + iErr = _pg_chartpie( &ce, aCat, axValue, + aExplode, cValue ); + else + iErr = _pg_chart( &ce, aCat, axValue, cValue ); + } + /* If multiple-series, then data is OK. Just draw chart. */ + else + iErr = _pg_chartms( &ce, aCat, (float _far *)aValue, + cSeries, cValue, cValue, aSeriesName ); + break; + + case _PG_SCATTERCHART: + + /* Make sure there are enough data sets. */ + if( cSeries == 1 ) + { + _setvideomode( _DEFAULTMODE ); + si.help = 10; + ErrorMsg( "Too few value data columns for scatter chart." ); + return 1; + + } + /* If it's a single-series scatter, transfer data to one- + * dimensional arrays and make chart call. + */ + else if( cSeries == 2 ) + { + for( iValue = 0; iValue < cValue; iValue++ ) + { + axValue[iValue] = aValue[0][iValue]; + ayValue[iValue] = aValue[1][iValue]; + } + cSeries = 1; + iErr = _pg_chartscatter( &ce, axValue, ayValue, cValue ); + + } + /* If it's a multiple-series scatter, transfer odd columns to + * X-axis data array and even columns to Y-axis array and make + * chart call. + */ + else + { + + for( iSeries = 1; iSeries < cSeries; iSeries += 2 ) + { + aSeriesName[iSeries / 2] = aSeriesName[iSeries - 1]; + for( iValue = 0; iValue < cValue; iValue++ ) + { + axValueMS[iSeries / 2][iValue] = + aValue[iSeries - 1][iValue]; + ayValueMS[iSeries / 2][iValue] = + aValue[iSeries][iValue]; + } + } + cSeries /= 2; + + iErr = _pg_chartscatterms( &ce, (float _far *)axValueMS, + (float _far *)ayValueMS, + cSeries, cValue, cValue, + aSeriesName ); + } + } + + if( !fDefault ) + ClearData( FALSE ); + + /* If error, show it, else wait for keypress with chart on screen. */ + if( iErr ) + { + ShowError( iErr ); + return iErr; + } + else + return ( getch() == ESCAPE ); /* ESCAPE means stop demo */ +} diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.H b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.H new file mode 100644 index 0000000..69f7922 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.H @@ -0,0 +1,146 @@ +/* File: CHRTDEMO.H + * + * Common definitions for major modules of CHRTDEMO. + */ + +/* Include only once */ +#ifndef CHRTDEMO_H +#define CHRTDEMO_H + +/* --- For graphics adaptors that are color capable: --- */ +#define C_INPUTCOLOR 11 /* Color for data input */ +#define C_HILITECOLOR 10 /* Color for first-letter highlights */ +#define C_FORMCOLOR 15 /* Color for screen form lines and help */ +#define C_TITLECOLOR 15 /* Color for QuickCHART title */ +#define C_ERRORCOLOR 14 /* Color for error lines */ +#define C_INFOCOLOR 7 /* Color non-input data on screen */ + +/* --- For graphics adaptors that are not color capable: --- */ +#define M_INPUTCOLOR 7 /* Color for data input */ +#define M_HILITECOLOR 15 /* Color for first-letter highlights */ +#define M_FORMCOLOR 7 /* Color for screen form lines and help */ +#define M_TITLECOLOR 15 /* Color for QuickCHART title */ +#define M_ERRORCOLOR 15 /* Color for error lines */ +#define M_INFOCOLOR 7 /* Color non-input data on screen */ + +/* Define macros to determine whether the graphics adaptor is color-capable. */ +#define ismono(m) ( ((m) == _MRESNOCOLOR) || ((m) == _HRESBW) || \ + ((m) == _HERCMONO) || ((m) == _ERESNOCOLOR) || \ + ((m) == _VRES2COLOR) ) +#define iscolor(m) (!ismono(m)) + +/* ASCII codes for commonly used control functions. */ +#define BEEP 7 +#define ESCAPE 27 + +/* Constant limits. */ +#define MAXVALUES 12 +#define MAXSERIES 4 + +/* Constants that identify typefaces to ChooseFont. */ +enum tagTypeFace +{ + COURIER, + HELV, + TMS_RMN, + MODERN, + SCRIPT, + ROMAN, + NOFONT +}; + +typedef enum tagBool { FALSE, TRUE } BOOL; + +/* Variables used to track control and screen position. */ +struct SCREENINFO +{ + int top; /* Row under top form line */ + int bot; /* Row above bottom form line */ + int mid; /* Middle line of form */ + int help; /* Line number of help line */ + int mode; /* Current screen mode */ + int xMax; + int yMax; + BOOL fColor; +}; + +/* This variable holds either the constants #defined for color + * graphics adaptors (those that are formed: C_xxxxxCOLOR) or those + * #defined for monochrome graphics adaptors (those that are formed: + * M_xxxxxCOLOR). They do NOT control the color of the presentation + * graphics -- just the color of the menus and prompts. + */ +struct tagColor +{ + short InputColor; /* Color for input requests */ + short HiliteColor; /* Color for prompt highlights */ + short FormColor; /* Color for input forms/menus */ + short TitleColor; /* Color for titles */ + short ErrorColor; /* Color for error messages */ + short InfoColor; /* Color for informations msgs. */ +}; + +/* Declarations of functions in CHRTDEMO.C */ +void ChartOptions( void ); +void ChartType( void ); +void ClearData( BOOL fConfirm ); +void DefaultData( short iType, short iStyle, BOOL fClear ); +int FindVideoMode( struct videoconfig vc ); +void Initialize( void ); +int main( void ); +void MainMenu( void ); +void ResetOptions( void ); +void Demo( void ); +BOOL SetGraphMode( int mode ); +void ShowError( int iErr ); +void ShowChartData( void ); +int ShowAxisType( int iRow, int iCol, axistype theAxis ); +int ShowFontInfo( int iRow, int iCol, struct _fontinfo theFont ); +int ShowLegendType( int iRow, int iCol, legendtype theLegend ); +void ShowSampleData( void ); +int ShowTitleType( int iRow, int iCol, titletype theTitle ); +int ShowWindowType( int iRow, int iCol, windowtype theWindow ); +int ViewChart( void ); + +/* Declarations of functions in CHRTOPT.C */ +void Axes( void ); +void Axis( axistype *pat ); +void AxisRange( axistype *pat ); +void AxisScale( axistype *pat ); +void AxisTics( axistype *pat ); +void Border( windowtype *pwt ); +int ChangeTypeface( int iFaceIndex ); +void ChooseFont( int WhichFont, int Height ); +void ChartWindow( void ); +void DataWindow( void ); +void FontOptions( void ); +void Justify( titletype *ptt ); +void Legend( void ); +void LegendPlace( void ); +void ScreenMode( void ); +void TitleOpt( titletype *ptt ); +void Titles( void ); +void Windows( void ); +void WindowSize( windowtype *pwt ); + +/* Declaration of functions in CHRTSUPT.C */ +int BlankMenu( char *pchTitle, char *pchChoice1, char *pchChoice2 ); +void ClrForm( void ); +void ClrHelp( void ); +void ErrorMsg( char *pchMsg ); +void Help( char *pchMsg, short sColor ); +int InputCh( char *pchPrompt, char *pchAccept ); +int InputInt( char *pchPrompt, int iOld, int iMin, int iMax ); +float InputFloat( char *pchPrompt, float fOld ); +char *InputStr( char *pchPrompt, char *pchOld ); +BOOL InRange( int Value, int iMin, int iMax ); +int Menu( char *pszMenuList[] ); +void PopTitle( void ); +void PushTitle( char *pchOldTitle ); +void PrintAt(int row, int column, char far * lpszString, short sColor); +void PrintChar(int row, int column, char cChar, short sColor); +void SetDisplayColors( void ); +void SprintAt( int iRow, int iCol, char * szFmt, ... ); +void WrtForm( int yBot ); + +#endif /* CHRTDEMO_H */ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.MAK b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.MAK new file mode 100644 index 0000000..bc9d6d1 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTDEMO.MAK @@ -0,0 +1,75 @@ +PROJ = CHRTDEMO +PROJFILE = CHRTDEMO.MAK +DEBUG = 1 + +PWBRMAKE = pwbrmake +NMAKE = nmake +LINKER = link +ILINK = ilink +LRF = echo > NUL +BIND = bind +RC = rc +IMPLIB = implib +LFLAGS_G = /NOI /NOE /BATCH +LFLAGS_D = /CO /INC /FAR /PACKC +LFLAGS_R = /EXE /FAR /PACKC +MAPFILE_D = NUL +MAPFILE_R = NUL +CC = cl +CFLAGS_G = /W2 /BATCH +CFLAGS_D = /qc /Gi$(PROJ).mdt /Zr /Zi /Od +CFLAGS_R = /Ot /Oi /Ol /Oe /Og /Gs +LLIBS_R = /NOD:SLIBCE SLIBCER +LLIBS_D = /NOD:SLIBCE SLIBCER +ASM = masm +AFLAGS_G = /Mx /T +AFLAGS_D = /Zi +LLIBS_G = graphics.lib pgchart.lib + +OBJS = CHRTDEMO.obj CHRTOPT.obj CHRTSUPT.obj + +all: $(PROJ).exe + +.SUFFIXES: .c .obj + +CHRTDEMO.obj : CHRTDEMO.C + +CHRTOPT.obj : CHRTOPT.C + +CHRTSUPT.obj : CHRTSUPT.C + + +$(PROJ).bsc : + +$(PROJ).exe : $(OBJS) +!IF $(DEBUG) + $(LRF) @<<$(PROJ).lrf +$(RT_OBJS) $(OBJS: = +^ +),$@,$(MAPFILE_D),$(LLIBS_G) $(LLIBS_D) $(LIBS),$(DEF_FILE) $(LFLAGS_G) $(LFLAGS_D); +<< +!ELSE + $(LRF) @<<$(PROJ).lrf +$(RT_OBJS) $(OBJS: = +^ +),$@,$(MAPFILE_R),$(LLIBS_G) $(LLIBS_R) $(LIBS),$(DEF_FILE) $(LFLAGS_G) $(LFLAGS_R); +<< +!ENDIF +!IF $(DEBUG) + $(ILINK) -a -e "$(LINKER) @$(PROJ).lrf" $@ +!ELSE + $(LINKER) @$(PROJ).lrf +!ENDIF + + +.c.obj : +!IF $(DEBUG) + $(CC) /c $(CFLAGS_G) $(CFLAGS_D) /Fo$@ $< +!ELSE + $(CC) /c $(CFLAGS_G) $(CFLAGS_R) /Fo$@ $< +!ENDIF + + +run: $(PROJ).exe + $(PROJ).exe $(RUNFLAGS) + +debug: $(PROJ).exe + CV $(CVFLAGS) $(PROJ).exe $(RUNFLAGS) diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/CHRTOPT.C b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTOPT.C new file mode 100644 index 0000000..a673353 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTOPT.C @@ -0,0 +1,911 @@ +#include +#include +#include +#include +#include +#include "chrtdemo.h" + +/* Structures for system configuration and chart environment. */ +extern struct videoconfig vc; +extern chartenv ce; + +/* Variable used to track control and screen position. */ +extern struct SCREENINFO si; + +/* Colors of menus and prompts. */ +extern struct tagColor co; + +/* Arrays of strings used by the Menu function. The first string is the + * menu title. The next non-null strings are the menu selections. A null + * string indicates the end of the list. + */ +char *pszAxes[] = + { "Axis", "X Axis", "Y Axis", "" }; + +char *pszAxis[] = + { "? Options", "Grid", "Axis Title", "Color", + "Range Type", "Scale", "Tic Marks", "" }; + +char *pszAuto[] = + { "Auto", "Auto", "Manual", "" }; + +char *pszBorder[] = + { "Type", "Color", "Style", "" }; + +char *pszChartWindow[] = + { "Chart", "Size", "Color (Background)", "Border", "" }; + +char *pszDataWindow[] = + { "Data", "Color (Background)", "Border", "" }; + +char * pszFontOpt[] = + { "Font Options", "Change Typeface", "Set Character Size", "" }; + +char *pszJustify[] = + { "Justify", "Left", "Center", "Right", "" }; + +char *pszLegendWindow[] = + { "Options", "Place", "Text Color", "Size", "Color (Background)", + "Border", "" }; + +char *pszPlace[] = + { "Place", "Right", "Bottom", "Overlay", "" }; + +char *pszScale[] = + { "Scale", "Low (Min)", "High (Max)", "Scale Factor", "Title", "" }; + +char *pszSize[] = + { "Size", "Top", "Left", "Bottom", "Right", "" }; + +char *pszTic[] = + { "Tic Type", "Interval", "Format", "Decimals", "" }; + +char *pszTitleOpt[] = + { "", "Text", "Color", "Justify", "" }; + +char *pszTitles[] = + { "Title", "Main Title", "Sub Title", "" }; + +char *pszTypeface[] = + { "Type Faces", "Courier", "Helv", "Tms Rmn", "Modern", "Script", + "Roman", "None", "" }; + +char *pszWindows[] = + { "Window", "Chart Window", "Data Window", "" }; + +/* Axes - Selects X or Y axis. + * + * Params: none + */ +void Axes() +{ + int iChoice; + static axistype *patAxis[2] = { &ce.xaxis, &ce.yaxis }; + + /* Get menu choice and call appropriate axis Menu. */ + PushTitle( pszAxes[0] ); + Help( "Choose 'X' or 'Y' Axis", co.InputColor ); + while( (iChoice = Menu( pszAxes )) != ESCAPE ) + { + /* Modify axis title, depending on choice. */ + pszAxis[0][0] = (--iChoice == 0) ? 'X' : 'Y'; + + /* Obtain axis information for appropriate axis. */ + Axis( patAxis[iChoice] ); + } + PopTitle(); +} + +/* Axis - Selects axis options. + * + * Params: pat - Pointer to axistype variable + */ +void Axis( axistype *pat ) +{ + int iChoice; + + PushTitle( pszAxis[0] ); + while( (iChoice = Menu( pszAxis )) != ESCAPE ) + { + + /* Get Axis option. */ + switch( iChoice ) + { + case 1: + /* Grid or not? */ + iChoice = BlankMenu( "Grid", "Grid", "No Grid" ); + switch( iChoice ) + { + + case 1: + /* If yes, set grid flag and get the grid style. */ + pat->grid = TRUE; + Help( "Enter a number in the range 0-10.", + co.InputColor ); + pat->gridstyle = + InputInt( "Grid Style? ", pat->gridstyle, 0, 10 ); + break; + + case 2: + /* If no, clear grid flag. */ + pat->grid = FALSE; + } + PopTitle(); + break; + + case 2: + /* Select axis title options. */ + pszTitleOpt[0] = "Axis Title"; + TitleOpt( &pat->axistitle ); + break; + + case 3: + /* Select color. */ + Help( "Enter a number in the range 0-15.", co.InputColor ); + pat->axiscolor = + InputInt( "Axis Color? ", pat->axiscolor, 0, 15 ); + break; + + case 4: + /* Get the axis range. */ + AxisRange( pat ); + break; + + case 5: + /* Get the axis scale. */ + AxisScale( pat ); + break; + + case 6: + /* Get axis tic mark options. */ + AxisTics( pat ); + break; + + } + } + PopTitle(); +} + +/* AxisRange - Selects range for an axis. + * + * Params: pat - pointer to axistype variable + */ +void AxisRange( axistype *pat ) +{ + int iChoice; + + iChoice = BlankMenu( "Range Type", "Normal", "Log" ); + switch( iChoice ) + { + case 1: + /* Set range type to linear. */ + pat->rangetype = _PG_LINEARAXIS; + break; + + case 2: + /* Set range type to log, then query for log base. */ + pat->rangetype = _PG_LOGAXIS; + Help( "Enter a value greater than or equal 2.", co.InputColor ); + pat->logbase = (float)InputInt( "Log base? ", + (int)pat->logbase, 2, 0 ); + break; + } + PopTitle(); +} + +/* AxisScale - Selects scale options for an axis. + * + * Params: pat - pointer to axistype variable + */ +void AxisScale( axistype *pat ) +{ + int iChoice; + + PushTitle( pszAuto[0] ); + iChoice = Menu( pszAuto ); + switch( iChoice ) + { + + case 1: + /* Set AutoScale flag. */ + pat->autoscale = TRUE; + break; + + case 2: + + /* Clear AutoScale flag and get scale options. */ + pat->autoscale = FALSE; + PushTitle( pszScale[0] ); + while( (iChoice = Menu( pszScale )) != ESCAPE ) + { + + switch( iChoice ) + { + + case 1: + /* Query for scale minimum. */ + Help( "Enter the range minimum value.", co.InputColor ); + pat->scalemin = + (float)InputInt( "Minimum? ", + (int)pat->scalemin, 1, 0 ); + break; + + case 2: + /* Query for scale maximum. */ + Help( "Enter the range maximum value.", co.InputColor ); + pat->scalemin = + (float)InputInt( "Minimum? ", + (int)pat->scalemin, 1, 0 ); + break; + + case 3: + /* Query for scale factor. */ + Help( "Enter scale factor (must be 1 or greater).", + co.InputColor ); + pat->scalefactor = + (float)InputInt( "Scale Factor? ", + (int)pat->scalefactor, 1, 0 ); + break; + + case 4: + /* Modify scale title, then use menu to get + * title options. + */ + pszTitleOpt[0] = "Scale Title"; + TitleOpt( &pat->scaletitle ); + + } + } + PopTitle(); + } + PopTitle(); +} + +/* AxisTics - Selects tic options for an axis. + * + * Params: pat - pointer to axistype variable + */ +void AxisTics( axistype *pat ) +{ + int iChoice; + + PushTitle( pszTic[0] ); + while( (iChoice = Menu( pszTic )) != ESCAPE ) + { + switch( iChoice ) + { + + case 1: + /* Query for tic interval. */ + Help( "Enter distance in data units.", co.InputColor ); + pat->ticinterval = + InputFloat( "Distance between tic marks? ", + pat->ticinterval ); + pat->autoscale = FALSE; + break; + + case 2: + /* Query for tic format. */ + iChoice = BlankMenu( "Tic Format", "Normal", "Log" ); + if( iChoice != ESCAPE ) + pat->ticformat = iChoice; + break; + + case 3: + /* Query for number of decimal places per tic. */ + pat->ticdecimals = + InputInt( "Enter decimal places (0 to 9). ", + pat->ticdecimals, 0, 9 ); + pat->autoscale = FALSE; + break; + } + + } + PopTitle(); +} + +/* Border - Specifies border information for a window. + * + * Params: pwt - Pointer to windowtype variable + */ +void Border( windowtype *pwt ) +{ + int iChoice; + + /* Ask whether a border is wanted. */ + iChoice = BlankMenu( "Border", "Border", "No Border" ); + switch( iChoice ) + { + + case 1: + + /* If border, set Border flag and query for border options. */ + pwt->border= TRUE; + PushTitle( pszBorder[0] ); + while( (iChoice = Menu( pszBorder )) != ESCAPE ) + { + switch( iChoice ) + { + case 1: + /* Query for border color. */ + Help( "Enter a color in the range 0-15.", + co.InputColor ); + pwt->bordercolor = + InputInt( "Border color? ", + pwt->bordercolor, 0, 15 ); + break; + + case 2: + /* Query for border style. */ + Help( "Enter a style in the range 0-10.", co.InputColor ); + pwt->borderstyle = + InputInt( "Border style? ", + pwt->borderstyle, 0, 10 ); + } + } + PopTitle(); + break; + + case 2: + /* If no border, clear Border flag. */ + pwt->border= FALSE; + } + PopTitle(); +} + +/* ChangeTypeface - Allow the user to specify a new type face. + * + * Params: iFaceIndex - index of last typeface + * + * Return: index of new typeface + */ + +int ChangeTypeface( int iFaceIndex ) +{ + int iChoice; + + /* Get menu choice and call appropriate axis Menu. */ + PushTitle( pszFontOpt[0] ); + Help( "Choose one of the type faces listed.", co.InputColor ); + + if( (iChoice = Menu( pszTypeface ) - 1) != ESCAPE ) + { + /* If the user wants the system font, unregister the other fonts. */ + if( iChoice == NOFONT ) + _unregisterfonts(); + + /* If the user wants any font but the system font, make sure the + * fonts are registered. + */ + else + { + /* If last face was NOFONT, register fonts. */ + if( iFaceIndex == NOFONT ) + { + /* Assumes font files are in current directory. + * Could be enhanced to handle any directory. + */ + if( _registerfonts( "*.FON" ) < 0 ) + ErrorMsg( "Font files must be in current directory" ); + else + iFaceIndex = iChoice; + } + else + iFaceIndex = iChoice; + } + } + + PopTitle(); + return iFaceIndex; +} + +/* ChooseFont - Chooses a font from the font library. + * + * Params: WhichFont - A member of the set [COURIER, HELV, TMS_RMN, + * MODERN, SCRIPT, ROMAN, NOFONT] + * Height - The desired height of the text (in pixels) + */ + +void ChooseFont( int WhichFont, int Height ) +{ + static char *FontIds[] = + { + "courier", "helv", "tms rmn", "modern", "script", "roman" + }; + char SetCommand[30]; + + /* Construct the command to send to _setfont. */ + sprintf( SetCommand, "t'%s'h%dw0b", FontIds[WhichFont], Height ); + + if( _setfont( SetCommand ) < 0 ) + { + _outtext( "Could not set. Try different font or size" ); + getch(); + } +} + +/* ChartWindow - Gets chart window information. + * + * Params: None + */ +void ChartWindow() +{ + int iChoice; + + PushTitle( pszChartWindow[0] ); + while( (iChoice = Menu( pszChartWindow )) != ESCAPE ) + { + + /* Get window options. */ + switch( iChoice ) + { + + case 1: + /* Get window size. */ + WindowSize( &ce.chartwindow ); + break; + + case 2: + /* Query for background color. */ + Help( "Enter a number in the range 0-15", co.InputColor ); + ce.chartwindow.background = + InputInt( "Background Color? ", ce.chartwindow.background, + 0, 15 ); + break; + + case 3: + + /* Get border options. */ + Border( &ce.chartwindow ); + + } + } + PopTitle(); +} + +/* DataWindow - Geta data window information. + * + * Params: None + */ +void DataWindow() +{ + int iChoice; + + PushTitle( pszDataWindow[0] ); + while( (iChoice = Menu( pszDataWindow )) != ESCAPE ) + { + + /* Get data window menu options. */ + switch( iChoice ) + { + + case 1: + /* Query for background color. */ + Help( "Enter a number in the range 0-15", co.InputColor ); + ce.datawindow.background = + InputInt( "Background Color? ", + ce.datawindow.background, + 0, 15 ); + break; + + case 2: + /* Get border options. */ + Border( &ce.datawindow ); + break; + + } + } + PopTitle(); +} + +/* FontOptions - Allows the user to modify the font used for display. + * + * Params: None + */ + +void FontOptions() +{ + int iChoice; + static int iFaceIndex = NOFONT; + static int iTypeSize = 8; + + /* Get menu choice and call appropriate axis Menu. */ + PushTitle( pszFontOpt[0] ); + + while( (iChoice = Menu( pszFontOpt )) != ESCAPE ) + { + switch( iChoice ) + { + /* Change Typeface. */ + case 1: + iFaceIndex = ChangeTypeface( iFaceIndex ); + ChooseFont( iFaceIndex, iTypeSize ); + break; + + /* Change Type Size. */ + case 2: + + if( iFaceIndex == NOFONT ) + { + ErrorMsg( "Select a font first" ); + break; + } + + iTypeSize = InputInt( "Enter a type size. ", iTypeSize, + 8, 128 ); + + ChooseFont( iFaceIndex, iTypeSize ); + break; + + default: + break; + } + } + PopTitle(); +} + +/* Justify - Gets title justification option. + * + * Params: Pointer to titletype variable + */ +void Justify( titletype *ptt ) +{ + int iChoice; + + PushTitle( pszJustify[0] ); + iChoice = Menu( pszJustify ); + switch( iChoice ) + { + + /* Set justification. */ + case 1: + case 2: + case 3: + ptt->justify = iChoice; + } + PopTitle(); +} + +/* Legend - Asks whether a legend is desired, and if so, gets + * legend options. + * + * Params: None + */ +void Legend() +{ + int iChoice; + + /* Is legend desired? */ + iChoice = BlankMenu( "Legend", "Legend", "No Legend" ); + switch( iChoice ) + { + case 1: + /* If legend, set legend flag and get options. */ + ce.legend.legend = TRUE; + PushTitle( pszLegendWindow[0] ); + do + { + iChoice = Menu( pszLegendWindow ); + switch( iChoice ) + { + + case 1: + /* Get legend place. */ + LegendPlace(); + break; + + case 2: + /* Query for legend color. */ + Help( "Enter a number in the range 0-15.", co.InputColor ); + ce.legend.textcolor = + InputInt( "Text color? ", + ce.legend.textcolor, + 0, 15 ); + break; + + case 3: + /* Get auto or manual sizing. */ + PushTitle( "Auto Legend" ); + iChoice = Menu( pszAuto ); + + /* Set or clear the autosize flag. If manual + * sizing was selected, get legend size. + */ + switch( iChoice ) + { + case 1: + ce.legend.autosize = TRUE; + break; + + case 2: + ce.legend.autosize = FALSE; + WindowSize( &ce.legend.legendwindow ); + } + PopTitle(); + break; + + case 4: + /* Query for background color. */ + Help( "Type a number in the range 0-15.", co.InputColor ); + ce.legend.legendwindow.background = + InputInt( "Background color? ", + ce.legend.legendwindow.background, + 0, 15 ); + break; + + case 5: + /* Get border options for legend window. */ + Border( &ce.legend.legendwindow ); + } + + } while( iChoice != ESCAPE ); + PopTitle(); + break; + + case 2: + /* If no legend wanted, clear flag. */ + ce.legend.legend = FALSE; + + } + PopTitle(); +} + +/* LegendPlace - Gets legend placement option. + * + * Params: None + */ +void LegendPlace() +{ + int iChoice; + + /* Get legend placement. */ + PushTitle( pszPlace[0] ); + iChoice = Menu( pszPlace ); + switch( iChoice ) + { + + case 1: + ce.legend.place = _PG_RIGHT; + break; + + case 2: + ce.legend.place = _PG_BOTTOM; + break; + + case 3: + ce.legend.place = _PG_OVERLAY; + } + PopTitle(); +} + +/* ScreenMode - Gets a new screen mode. + * + * Params: None + */ +void ScreenMode() +{ + int iMode, i; + char szTmp[80], szHlp[80]; + static int iLegal[5][11] = + { + { 3, 4, 5, 6 }, + { 4, 4, 5, 6, 64 }, + { 4, 4, 5, 6, 19 }, + { 7, 4, 5, 6, 13, 14, 15, 16 }, + { 10, 4, 5, 6, 13, 14, 15, 16, 17, 18, 19 } + }; + int iAdaptor; + + PushTitle( "Screen Mode" ); + + /* Show appropriate help line for adaptor. */ + switch( vc.adapter ) + { + case _HGC: + PopTitle(); + return; + case _CGA: + iAdaptor = 0; + break; + case _OCGA: + iAdaptor = 1; + break; + case _MCGA: + iAdaptor = 2; + break; + case _EGA: + case _OEGA: + if( vc.adapter == _MONO ) + { + PopTitle(); + return; + } + else + iAdaptor = 3; + break; + case _VGA: + case _OVGA: + iAdaptor = 4; + break; + } + + /* Form the help line (which gives the choices legal for + * the adaptor sensed in the user's machine). + */ + for( iMode = 0, szHlp[0] = '\0'; iMode <= iLegal[iAdaptor][0]; ++iMode ) + { + if( iMode == 0 ) + strcpy( szTmp, "Enter " ); + else if( iMode < iLegal[iAdaptor][0] ) + sprintf( szTmp, "%d, ", iLegal[iAdaptor][iMode] ); + else + sprintf( szTmp, "or %d", iLegal[iAdaptor][iMode] ); + strcat( szHlp, szTmp ); + } + + WrtForm( 18 ); + Help( szHlp, co.InputColor ); + + /* Query for screen mode. */ + for( ;; ) + { + iMode = InputInt( "Screen Mode? ", si.mode, 1, 64 ); + for( i = 1; i <= iLegal[iAdaptor][0]; ++i ) /* Test legal values */ + if( iMode == iLegal[iAdaptor][i] ) /* If a match is found */ + break; /* Terminate for loop */ + if( iMode == iLegal[iAdaptor][i] ) /* If it's a match, */ + break; /* terminate do loop, */ + else /* otherwise BEEP, and */ + putchar( BEEP ); /* solicit correct data */ + } + + PopTitle(); + if( SetGraphMode( iMode ) ) + _setvideomode( _DEFAULTMODE ); + else + ShowError( _PG_BADSCREENMODE ); + + /* Force rescaling of the chart by resetting the window + * rectangles for the chart and data windows to zero size. + */ + ce.chartwindow.x1 = ce.chartwindow.x2 = ce.chartwindow.y1 = + ce.chartwindow.y2 = 0; + ce.datawindow = ce.chartwindow; +} + +/* TitleOpt - Gets title options. + * + * Params: ptt - Pointer to titletype variable + */ +void TitleOpt( titletype *ptt ) +{ + int iChoice; + + PushTitle( pszTitleOpt[0] ); + do + { + iChoice = Menu( pszTitleOpt ); + switch( iChoice ) + { + + case 1: + /* Query for title text. */ + Help( "70 characters maximum length.", co.InputColor ); + InputStr( "Enter Text: ", ptt->title ); + break; + + case 2: + /* Query for title color color. */ + Help( "Enter a number in the range 0-15.", co.InputColor ); + ptt->titlecolor = + InputInt( "Title Color? ", ptt->titlecolor, 0, 15 ); + break; + + case 3: + /* Get justify option. */ + Justify( ptt ); + } + ClrHelp(); + + } while( iChoice != ESCAPE ); + PopTitle(); +} + +/* Titles - Manages Main and Sub title menus. + * + * Params: None + */ +void Titles() +{ + int iChoice; + + PushTitle( pszTitles[0] ); + do + { + iChoice = Menu( pszTitles ); + switch( iChoice ) + { + + case 1: + /* Fix menu title and get options for main title. */ + pszTitleOpt[0] = "MainTitle"; + TitleOpt( &ce.maintitle ); + break; + + case 2: + /* Fix menu title and get options for subtitle. */ + pszTitleOpt[0] = "Sub Title"; + TitleOpt( &ce.subtitle ); + } + } while( iChoice != ESCAPE ); + PopTitle(); +} + +/* Windows - Selects chart or data window, and gets options for either. + * + * Params: None + */ +void Windows() +{ + int iChoice; + + PushTitle( pszWindows[0] ); + do + { + + /* Select window and get options for it. */ + iChoice = Menu( pszWindows ); + switch( iChoice ) + { + + case 1: + ChartWindow(); + break; + + case 2: + DataWindow(); + + } + } while( iChoice != ESCAPE ); + PopTitle(); +} + +/* WindowSize - Gets coordinates for window location and size. + * + * Params: pwt - pointer to windowtype variable + */ +void WindowSize( windowtype *pwt ) +{ + int iChoice; + + /* Get window size settings. */ + PushTitle( pszSize[0] ); + do + { + /* Query for top, bottom, left, or right of window. */ + iChoice = Menu( pszSize ); + switch( iChoice ) + { + + case 1: + Help( "Enter window top in pixels.", co.InputColor ); + pwt->y1 = InputInt( "Top? ", pwt->y1, 0, si.yMax ); + break; + + case 2: + Help( "Enter window Left in pixels.", co.InputColor ); + pwt->x1 = InputInt( "Left? ", pwt->x1, 0, si.xMax ); + break; + + case 3: + Help( "Enter window bottom in pixels.", co.InputColor ); + pwt->y2 = InputInt( "Bottom? ", pwt->y2, 0, si.yMax ); + break; + + case 4: + Help( "Enter window right in pixels.", co.InputColor ); + pwt->x2 = InputInt( "Right? ", pwt->x2, 0, si.xMax ); + } + } while( iChoice != ESCAPE ); + PopTitle(); +} diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/CHRTSUPT.C b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTSUPT.C new file mode 100644 index 0000000..9f0fd45 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/CHRTSUPT.C @@ -0,0 +1,481 @@ +#include +#include +#include +#include +#include +#include +#include +#include "chrtdemo.h" + +/* Variables to manage menus. */ +int cMenuLevel = 0; /* Current menu level */ +char *szMenuTitles[10]; /* Stack of menu titles */ + +char *pszBlankMenu[4]; + +/* Variables used to track control and screen position. */ +extern struct SCREENINFO si; + +/* Colors of menus and prompts. */ +extern struct tagColor co; + +/* BlankMenu - Gets responses to two specified choices. + * + * Params: pchTitle - Menu title string + * pchChoice1 - Selection 1 string + * pchChoice2 - Selection 2 string + * + * Return: Number of choice, or ESCAPE + */ +int BlankMenu( char *pchTitle, char *pchChoice1, char *pchChoice2 ) +{ + int iChoice; + + /* Initialize title and selections. */ + pszBlankMenu[0] = pchTitle; + pszBlankMenu[1] = pchChoice1; + pszBlankMenu[2] = pchChoice2; + pszBlankMenu[3] = "\0"; + PushTitle( pszBlankMenu[0]); + + while( TRUE ) + { + /* Accept only first letter of either selection, or ESC. */ + iChoice = Menu( pszBlankMenu ); + switch( iChoice ) + { + case 1: + case 2: + case ESCAPE: + return iChoice; + } + } +} + +/* ClrForm - Clears the center of the screen form. + * + * Params: None + */ +void ClrForm() +{ + + /* Set partial screen window and clear it, then reset full screen. */ + _settextwindow( si.top, 1, si.bot, 80 ); + _clearscreen( _GWINDOW ); + _settextwindow( 1, 1, 25, 80 ); + +} + +/* ClrHelp - Clears the current help line. + * + * Params: None + */ +void ClrHelp() +{ + /* Decrement the help line counter and clear the line. */ + _settextwindow( --si.help, 1, si.help, 80 ); + _clearscreen( _GWINDOW ); + _settextwindow( 1, 1, 25, 80 ); +} + +/* ErrorMsg - Displays an error message. + * + * Params: pchMsg - error message string + */ +void ErrorMsg( char *pchMsg ) +{ + + /* Beep, set error color, and display error message and continue prompt. */ + putch( BEEP ); + Help( pchMsg, co.ErrorColor ); + Help( "Press any key to continue.", co.ErrorColor ); + + /* Wait for keypress and clear help lines. */ + getch(); + ClrHelp(); + ClrHelp(); + +} + +/* Help - Displays a help line on the screen. + * + * Params: pchMsg - error message string + * sColor - color for message + */ +void Help( char *pchMsg, short sColor ) +{ + + struct rccoord rcCursor; + + /* Save current cursor position. */ + rcCursor = _gettextposition(); + + /* Print out help line and increment Helpline position variable. */ + PrintAt( si.help++, 5, pchMsg, sColor ); + + /* Restore cursor position. */ + _settextposition( rcCursor.row, rcCursor.col ); + +} + +/* InputCh - Prompts for and returns a character of input. + * + * Params: pchPrompt - Prompt string + * pchAccept - String of acceptable characters (case insensitive) + * + * Return: Character entered + */ +int InputCh( char *pchPrompt, char *pchAccept ) +{ + int chResponse; + + /* Display prompt. */ + PrintAt( si.mid, 10, pchPrompt, co.InputColor ); + + /* Loop until response is valid. */ + while( TRUE ) + { + chResponse = toupper( getch() ); + + /* Display and return if acceptable character, or beep if not. */ + if( *strchr( pchAccept, chResponse) ) + { + _settextcolor( co.InfoColor ); + putch( chResponse ); + return chResponse; + } + else + putch( BEEP ); + } +} + +/* InputInt - Prompts for and returns an integer value within a + * specified range. + * + * Params: pchPrompt - Prompt string + * iOld - Previous value + * iMin - Minimum value of range + * iMax - Maximum value of range + * + * Return: integer input by user + */ +int InputInt( char *pchPrompt, int iOld, int iMin, int iMax ) +{ + int i; + char szTmp[70]; + + /* Prompt for a string input and convert to an integer until a + * value in the specified range is given. Then return the value. + */ + do + { + InputStr( pchPrompt, itoa( iOld, szTmp, 10) ); + i = atoi( szTmp ); + } while( !InRange( i, iMin, iMax) ); + return i; +} + +/* InputFloat - Prompts for and returns a float value. + * + * Params: pchPrompt - Prompt string + * fOld - Previous value + * + * Return: float input by user + */ +float InputFloat( char *pchPrompt, float fOld ) +{ + char szTmp[70]; + + /* Prompt for a string input and convert to a float. */ + sprintf( szTmp, "%f", fOld ); + InputStr( pchPrompt, szTmp ); + return (float)atof( szTmp ); +} + +/* InputStr - Prompts for a string. Displays the previous string + * until the first character is given. Then replaces it with new + * entry. + * + * Params: pchPrompt - Prompt string + * pchOld - Charater buffer containing previous string; it + * must be long enough to hold new string + * + * Return: pointer to pchOld, which now contains new string + */ +char *InputStr( char *pchPrompt, char *pchOld ) +{ + char szTmp[81]; + int x = 5, y = si.mid, ch; + + /* Display prompt in center of form. */ + ClrForm(); + PrintAt( y, x, pchPrompt, co.InputColor ); + x += strlen( pchPrompt ); + + /* Print the old value for reference. */ + _outtext( pchOld ); + _settextposition( y, x ); + + /* Wait for input. When received, clear old string. */ + while( !(ch = kbhit()) ) + ; + memset( szTmp, ' ', 80 ); + szTmp[80] = '\0'; + PrintAt( y, x, szTmp, -1 ); + + /* Get new string. If string entered, return it. If null string + * (ENTER key pressed), return old value. + */ + _settextcolor( co.InfoColor ); + _settextposition( y, x ); + szTmp[0] = 70; /* Maximum length to be read */ + + cgets( szTmp ); + if( szTmp[1] > 0 ) /* Are any characters read? */ + { + strcpy( pchOld, &szTmp[2] ); + return &szTmp[2]; + } + else + { + _settextposition( y, x ); + return pchOld; + } +} + +/* InRange - Checks an integer to see if it is in a specified range. + * + * Params: iValue - Integer to check + * iMin - Minimum value of range + * iMax - Maximim value of range + * + * Return: TRUE if in range, FALSE if not + */ +BOOL InRange( int Value, int iMin, int iMax ) +{ + /* Check range and return true if valid, false if not. Note that + * (iMin >= iMax) is taken as a signal to check only the minimum + * value; there is no maximum. + */ + if( Value >= iMin ) + if( (Value <= iMax) || (iMin >= iMax) ) + return TRUE; + else + { + ErrorMsg( "Invalid value." ); + return FALSE; + } +} + +/* Menu - Draws menu on screen and returns choice number. + * + * Params: array of menu strings + * + * Return: number corresponding to the choice made from the menu + */ +int Menu( char *pszMenuList[] ) +{ + int iItem, cItem, yItem, x = 10; + int chResponse; + + /* Count menu items. */ + for( cItem = 1; *pszMenuList[cItem]; cItem++ ) + ; + --cItem; + + + /* Clear the form and print the items in the menu. */ + WrtForm( 10 + cItem ); + for( iItem = 1, yItem = 8; iItem <= cItem; iItem++, yItem++ ) + { + PrintAt( yItem, x, pszMenuList[iItem], co.InputColor ); + PrintChar( yItem, x, pszMenuList[iItem][0], co.HiliteColor ); + } + ++yItem; + + /* Display prompt and help. */ + if( strcmpi( pszMenuList[0], "main menu" ) ) /* If not the main menu */ + Help( "Type the first letter of your selection or ESC to back up.", + co.InputColor ); + else + Help( "Type the first letter of your selection or \"Q\" to quit.", + co.InputColor ); + + PrintAt( yItem, x += 5, "Choice? ", co.InfoColor ); + x += 8; + + /* Loop until a valid choice is made. Beep at invalid choices. */ + while( TRUE ) + { + _settextposition( yItem, x ); + chResponse = toupper( getch() ); + + /* Back up for ESC. */ + if( chResponse == 27 ) + { + ClrHelp(); + return ESCAPE; + } + + /* Search first letters of choices for a match. If found, return + * choice and clear help line. + */ + for( iItem = 1; iItem <= cItem; iItem++ ) + { + if( chResponse == toupper( pszMenuList[iItem][0]) ) + { + putch( chResponse ); + ClrHelp(); + return iItem; + } + } + + /* If we get here, no valid choice was found, so beep and repeat. */ + putch( BEEP ); + } +} + +/* PopTitle - Pops a menu title from the menu stack. + * + * Params: None + */ +void PopTitle() +{ + szMenuTitles[--cMenuLevel] = ""; +} + +/* PrintAt - Prints a string at the row/column coordinates + * specified, in the specified color. + * + * Params: row - row at which to begin output of string + * col - column at which to begin output of string + * lpszString - zero (null) terminated string + * sColor - color in which to output string (-1 if + * PrintAt should leave color alone) + */ +void PrintAt( int row, int column, char _far *lpszString, short sColor ) +{ + if( sColor != -1 ) + _settextcolor( sColor ); + _settextposition( row, column ); + _outtext( lpszString ); +} + +/* PrintChar - Prints a character at the row/column coordinates + * specified, in the specified color. + * + * Params: row - row at which to begin output of string + * col - column at which to begin output of string + * cChar - character to print + * sColor - color in which to output string (-1 if + * PrintChar should leave color alone) + */ +void PrintChar(int row, int column, char cChar, short sColor) +{ + char szTiny[2]; + + szTiny[0] = cChar; + szTiny[1] = '\0'; + PrintAt( row, column, szTiny, sColor ); +} + +/* PushTitle - Pushes a menu title on to the menu stack. + * + * Params: pchTitle - title string to push + */ +void PushTitle( char *pchTitle ) +{ + szMenuTitles[cMenuLevel++] = pchTitle; +} + +/* SetDisplayColors - Set the colors to values appropriate to the display + * adaptor being used. + * + * Parms: None + */ +void SetDisplayColors() +{ + if( ismono( si.mode ) ) + { + co.InputColor = M_INPUTCOLOR; + co.HiliteColor = M_HILITECOLOR; + co.FormColor = M_FORMCOLOR; + co.TitleColor = M_TITLECOLOR; + co.ErrorColor = M_ERRORCOLOR; + co.InfoColor = M_INFOCOLOR; + } + else + { + co.InputColor = C_INPUTCOLOR; + co.HiliteColor = C_HILITECOLOR; + co.FormColor = C_FORMCOLOR; + co.TitleColor = C_TITLECOLOR; + co.ErrorColor = C_ERRORCOLOR; + co.InfoColor = C_INFOCOLOR; + } +} + +/* SprintAt - Format a string, using sprintf() and output to screen + * using PrintAt. + * + * Parms: iRow - Row at which to begin display + * iCol - Column at which to begin display + * szFmt - Format string (see run-time library documentation for + * correct formation of a format string) + * ... - Variables to output + */ +void SprintAt( int iRow, int iCol, char * szFmt, ... ) +{ + char szTmp[81]; + va_list Marker; + va_list saveMarker; + + va_start( Marker, szFmt ); + saveMarker = Marker; + vsprintf( szTmp, szFmt, Marker ); + va_end( Marker ); + + PrintAt( iRow, iCol, szTmp, -1 ); +} + +/* WrtForm - Displays screen form. + * + * Params: yBot - Row number of the bottom row + */ +void WrtForm( int yBot ) +{ + int i; + char szTmp[81]; + + /* Print message in upper right. */ + _clearscreen( _GCLEARSCREEN ); + PrintAt( 1, 55, "Presentation Graphics Demo", co.TitleColor ); + + /* Clear the top separator line. */ + memset( szTmp, ' ', 79 ); + szTmp[79] = 0; + + /* Display each level of the menu title. */ + _settextposition( 5, 5 ); + for( i = 0; i < cMenuLevel; i++ ) + { + if( i ) + _outtext( " - " ); + _outtext( szMenuTitles[i] ); + } + + /* Display the top separator line. */ + memset( szTmp, 196, 80 ); + szTmp[80] = 0; + PrintAt( 6, 1, szTmp, co.FormColor ); + + /* Display the bottom separator line. */ + PrintAt( yBot, 1, szTmp, co.FormColor ); + + /* Set the global screen variables. */ + + si.help = yBot + 1; + si.top = 7; + si.bot = yBot - 1; + si.mid = (si.top + si.bot) / 2; +} diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/COURB.FON b/Microsoft C v6ax/SOURCE/SAMPLES/COURB.FON new file mode 100644 index 0000000..b0ef8d1 Binary files /dev/null and b/Microsoft C v6ax/SOURCE/SAMPLES/COURB.FON differ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/GRDEMO.C b/Microsoft C v6ax/SOURCE/SAMPLES/GRDEMO.C new file mode 100644 index 0000000..cc88a7c --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/GRDEMO.C @@ -0,0 +1,679 @@ +/* GRDEMO.C - Demonstrates capabilities of the Microsoft graphics library. + * Uses MENU module to display menus. Uses TURTLE module for Turtle + * graphics. This program runs only in DOS and requires GRAPHICS.LIB. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "turtle.h" +#include "menu.h" + +/* Function prototypes */ +int main( void ); +void Circles( void ); +void Sphere( void ); +int Polygons( void ); +int Spiral( int angle, double inc ); +int InSpiral( double side, int angle, int inc ); +void Bug( void ); +void Adjust( void ); +void Diamond( double xy ); + +/* Returns a random number between min and max, which must be in + * integer range. + */ +#define getrandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min)) + +/* Constants */ +#define PI 3.141593 +#define LASTATR 15 +#define NLASTATR 14 + +/* Array and enum for main menu */ +ITEM mnuMain[] = +{ /* Highlight Char Pos */ + { 0, "Quit" }, /* Q 0 */ + { 0, "Circles" }, /* C 0 */ + { 0, "Rotating Sphere" }, /* R 0 */ + { 0, "Tunnel" }, /* T 0 */ + { 0, "Spiral" }, /* S 0 */ + { 0, "Inverted Spiral" }, /* I 0 */ + { 0, "Bug" }, /* B 0 */ + { 0, "Adjust Window" }, /* A 0 */ + { 0, "Mode Change" }, /* M 0 */ + { 0, "" } +}; + +/* Define constants (0, 1, 2,...) for menu choices */ +enum CHOICES +{ + QUIT, CIRCLES, SPHERE, TUNNEL, SPIRAL, INSPIRAL, BUG, ADJUST, CHANGE +}; + +/* Arrays of video mode menu items and of corresponding mode numbers. + * Each has a temporary array containing all items, and a pointer version + * including all except Olivetti. + */ +ITEM mnuModesT[] = +{ /* Highlight Char Pos */ + { 0, "ORESCOLOR " }, /* O 0 */ + { 4, "MRES4COLOR " }, /* 4 4 */ + { 4, "MRESNOCOLOR" }, /* N 4 */ + { 4, "HRESBW" }, /* B 4 */ + { 0, "MRES16COLOR" }, /* M 0 */ + { 0, "HRES16COLOR" }, /* H 0 */ + { 0, "ERESCOLOR" }, /* E 0 */ + { 4, "VRES2COLOR" }, /* 2 4 */ + { 0, "VRES16COLOR" }, /* V 0 */ + { 1, "MRES256COLOR" }, /* R 4 */ + { 0, "" } +}; +ITEM *mnuModes = &mnuModesT[1]; /* Default is no Olivetti mode */ + +int aModesT[] = +{ + _ORESCOLOR, + _MRES4COLOR, + _MRESNOCOLOR, + _HRESBW, + _MRES16COLOR, + _HRES16COLOR, + _ERESCOLOR, + _VRES2COLOR, + _VRES16COLOR, + _MRES256COLOR, + _TEXTMONO, + _ERESNOCOLOR, + _HERCMONO +}; +int *aModes = &aModesT[1]; /* Default is no Olivetti mode */ + +/* Global video configuration */ +struct videoconfig vc; + +int main() +{ + int rowMid, colMid; + int fColor, fFirstTime = TRUE; + int iMode, iMainCur = 0, iModesCur = 0; + + _displaycursor( _GCURSOROFF ); + _getvideoconfig( &vc ); + rowMid = vc.numtextrows / 2; + colMid = vc.numtextcols / 2; + + /* Select best graphics mode, adjust menus, set color flag. Note + * that this requires checking both the adapter and the mode. + */ + switch( vc.adapter ) + { + case _OCGA: + mnuModes = &mnuModesT[0]; /* Turn on Olivetti mode */ + aModes = &aModesT[0]; + case _CGA: + mnuModesT[4].achItem[0] = '\0'; /* Turn off EGA modes */ + iMode = _MRES4COLOR; + break; + case _HGC: + mnuModesT[7].achItem[0] = '\0'; + iMode = _HERCMONO; + break; + case _OEGA: + mnuModes = &mnuModesT[0]; /* Turn on Olivetti mode */ + aModes = &aModesT[0]; + case _EGA: + mnuModesT[7].achItem[0] = '\0'; /* Turn off VGA modes */ + if( vc.memory > 64 ) + iMode = _ERESCOLOR; + else + iMode = _HRES16COLOR; + break; + case _OVGA: + mnuModes = &mnuModesT[0]; /* Turn on Olivetti mode */ + aModes = &aModesT[0]; + case _VGA: + iMode = _VRES16COLOR; + break; + case _MCGA: + iMode = _MRES256COLOR; + break; + case _MDPA: + default: + puts( "No graphics mode available.\n" ); + return TRUE; + } + switch( vc.mode ) + { + case _TEXTBW80: + case _TEXTBW40: + fColor = FALSE; + break; + case _TEXTMONO: + case _ERESNOCOLOR: + case _HERCMONO: + fColor = FALSE; + if( iMode != _HERCMONO ) + iMode = _ERESNOCOLOR; + mnuMain[8].achItem[0] = '\0'; /* Turn off mode change */ + break; + default: + fColor = TRUE; + break; + } + + /* Find current mode in mode array. */ + for( iModesCur = 0; aModes[iModesCur] != iMode; iModesCur++ ) + ; + + /* Seed randomizer with time. */ + srand( (unsigned)time( NULL ) ); + + while( TRUE ) + { + /* Set text mode and optionally clear the screen to blue. */ + _setvideomode(_DEFAULTMODE ); + if( fColor ) + _setbkcolor( (long)_TBLUE ); + _clearscreen( _GCLEARSCREEN ); + + /* Select from menu. */ + iMainCur = Menu( rowMid, colMid, mnuMain, iMainCur ); + + /* Set graphics mode and initialize turtle graphics. Put border + * on window. + */ + if( iMainCur != CHANGE ) + { + _setvideomode( iMode ); + _displaycursor( _GCURSOROFF ); + _getvideoconfig( &vc ); + InitTurtle( &vc ); + Rectangle( 2 * tc.xMax, 2 * tc.yMax ); + } + + /* Branch to menu choice. */ + switch( iMainCur ) + { + case QUIT: + _setvideomode( _DEFAULTMODE ); + return FALSE; + case CIRCLES: + Circles(); + break; + case SPHERE: + Sphere(); + break; + case TUNNEL: + PenDown( FALSE ); + MoveTo( -tc.xMax * .2, tc.yMax * .15 ); + PenDown( TRUE ); + Polygons(); + while( !GetKey( NO_WAIT ) ) + NextColorValue( DEFAULT ); /* Rotate palette */ + break; + case SPIRAL: + if( Spiral( getrandom( 30, 80 ), (double)getrandom( 1, 5 ) ) ) + break; + while( !GetKey( NO_WAIT ) ) + NextColorValue( DEFAULT ); + break; + case INSPIRAL: + NextColorIndex( 0 ); + if( InSpiral( (double)getrandom( 8, 20 ), + getrandom( 4, 22 ), + getrandom( 3, 31 ) ) ) + break; + while( !GetKey( NO_WAIT ) ) + NextColorValue( DEFAULT ); + break; + case BUG: + Bug(); + break; + case ADJUST: + Adjust(); + continue; + case CHANGE: + if( fColor ) + _setbkcolor( (long)_TBLUE ); + _clearscreen( _GCLEARSCREEN ); + + iModesCur = Menu( rowMid, colMid, mnuModes, iModesCur ); + iMode = aModes[iModesCur]; + if( vc.adapter == _MCGA ) + switch( iMode ) + { + case _MRES16COLOR: + case _HRES16COLOR: + case _ERESCOLOR: + case _VRES16COLOR: + _settextposition( 1, 22 ); + _outtext( "Mode not recognized" ); + iMode = _MRES256COLOR; + } + break; + } + } +} + +/* Circles - Draw circles of varying sizes and colors on screen in a + * round pattern. + * + * Params: None + * + * Return: None + * + * Uses: tc + */ +void Circles() +{ + double x, y, xyRadius; + int fFill, fPenDown; + + /* Initialize and save pen and fill flags. */ + if( tc.cci <= 4 ) + fFill = SetFill( FALSE ); + else + fFill = SetFill( TRUE ); + fPenDown = PenDown( FALSE ); + + while( TRUE ) + { + /* Draw circles. */ + for( xyRadius = 10.0; xyRadius <= 130.0; xyRadius++ ) + { + x = (tc.xMax - 30) * atan( sin( xyRadius / PI ) ); + y = (tc.yMax - 30) * atan( cos( xyRadius / PI ) ); + MoveTo( x, y ); + PenColor( NextColorIndex( DEFAULT ) ); + Circle( xyRadius ); + if( GetKey( NO_WAIT ) ) + { + PenDown( fPenDown ); + SetFill( fFill ); + return; + } + } + + /* For palette modes (except 256 color), start over. */ + if( tc.ccv == 64 || tc.ccv == 16 ) + { + _clearscreen( _GCLEARSCREEN ); + SetFill( FALSE ); + MoveTo( 0.0, 0.0 ); + PenColor( WHITE ); + Rectangle( 2 * tc.xMax, 2 * tc.yMax ); + SetFill( fFill ); + NextColorValue( DEFAULT ); + } + } +} + +/* Sphere - Draw and fill slices of a sphere. Rotate colors in EGA+ modes + * with more than 4 color indexes. + * + * Params: None + * + * Return: None + * + * Uses: tc + */ +void Sphere() +{ + double xCur, xSize, ySize, xInc; + short ciBorder, fFill; + + ySize = xSize = tc.yMax * 0.9 * 2; + fFill = SetFill( FALSE ); + NextColorIndex( 0 ); + xInc = xSize / 14; + ciBorder = PenColor( DEFAULT ); + BorderColor( ciBorder ); + + /* Draw slices. */ + for( xCur = xInc; xCur <= xSize; xCur += xInc * 2 ) + Ellipse( xCur, ySize ); + SetFill( TRUE ); + PenDown( FALSE ); + Turn( 90 ); + xSize /= 2; + MoveTo( xSize - xInc, 0.0 ); + + NextColorValue( LIMITED ); + + /* Fill slices. */ + while( tc.xCur >= (-xSize + xInc)) + { + PenColor( NextColorIndex( DEFAULT ) ); + FillIn(); + Move( -xInc ); + } + + while( !GetKey( NO_WAIT ) ) + NextColorValue( LIMITED ); + + PenDown( TRUE ); + SetFill( fFill ); +} + +/* Polygons - Draws polygons (starting with triangle) of increasing + * size by incrementing the number of sides without changing the + * length of sides. Make sure pen is down. + * + * Params: None + * + * Return: 1 for user interrupt, 0 for edge of screen encountered + * + * Uses: tc + */ +int Polygons() +{ + int cSides = 3, atrib = 1; + double dxy = tc.yUnit; + + while( TRUE ) + { + PenColor( NextColorIndex( DEFAULT ) ); + if( !Poly( cSides++, dxy += 1.5 ) ) + return FALSE; + if( GetKey( NO_WAIT ) ) + return TRUE; + } +} + +/* Spiral - Draw a spiral by incrementing the length of each side + * of a rotating figure. + * + * Params: ang - determines tightness + * xyInc - determines size of sides + * + * Return: 1 for user interrupt, 0 for edge of screen encountered + * + * Uses: tc + */ +int Spiral( int ang, double xyInc ) +{ + double xy = tc.yUnit; + + while( TRUE ) + { + PenColor( NextColorIndex( DEFAULT ) ); + if( !Move( xy += xyInc ) ) + return FALSE; + Turn( ang ); + if( GetKey( NO_WAIT ) ) + return TRUE; + } +} + +/* InSpiral - Draw an inverted spiral by increasing each angle + * of a rotating figure while keeping the length of sides constant. + * + * Params: xy - determines size + * ang - initial angle determines shape + * angInc - determines tightness and shape + * + * Return: 1 for user interrupt, 0 for edge of screen encountered + */ +int InSpiral( double xy, int ang, int angInc ) +{ + while( TRUE ) + { + PenColor( NextColorIndex( DEFAULT ) ); + if( !Move( xy ) ) + return FALSE; + Turn( ang += angInc ); + if( GetKey( NO_WAIT )) + return TRUE; + } +} + +/* Bug - Draws a winged bug on the screen. Then moves it randomly + * around the screen. + * + * Params: None + * + * Return: None + * + * Uses: tc + */ +void Bug() +{ + + static unsigned char uTopWing[] = { 0x81, 0x3c, 0xc3, 0x66, + 0x66, 0x0f, 0xf0, 0x18 }; + static unsigned char uBotWing[] = { 0x66, 0x0f, 0xf0, 0x18, + 0x81, 0x3c, 0xc3, 0x66 }; + char *buffer; /* Buffer for image */ + + /* Draw bug. */ + PenDown( FALSE ); + SetFill( TRUE ); + Move( 40.0 ); /* Draw and fill front wings */ + Turn( 90 ); + Move( 80.0 ); + PenColor( 1 ); + _setfillmask( uTopWing ); + Ellipse( 172.0, 70.0 ); + Turn( 180 ); + Move( 160.0 ); + Ellipse( 172.0, 70.0 ); + Turn(-90 ); + MoveTo( 0.0, 0.0 ); + Move( 25.0 ); /* Draw and fill back wings */ + Turn( 90 ); + Move( 70.0 ); + PenColor( 2 ); + _setfillmask( uBotWing ); + Ellipse( 150.0, 70.0 ); + Turn( 180 ); + Move( 140.0 ); + Ellipse( 150.0, 70.0 ); + Turn(-90 ); + MoveTo( 0.0, 0.0 ); + _setfillmask( NULL ); /* Draw body */ + PenColor( 3 ); + BorderColor( 3 ); + Ellipse( 52.0, 220.0 ); + PenColor( 1 ); /* Drill eyes */ + BorderColor( 1 ); + SetFill( FALSE ); + Move( 90.0 ); + Turn( 90 ); + Move( 22.0 ); + Circle( 20.0 ); + PenColor( 0 ); + FillIn(); + PenColor( 1 ); + Turn( 180 ); + Move( 44.0 ); + Circle( 20.0 ); + PenColor( 0 ); + FillIn(); + + /* Move into position - top-right of image. */ + MoveTo( 0.0, 0.0 ); + TurnTo( 0 ); + Move( 120.0 ); + Turn( -90 ); + Move( 175.0 ); + Turn( 90 ); + + /* Size image and allocate memory for it. */ + buffer = (char *)malloc( (size_t)ImageSize( 350.0, 240.0 ) ); + GetImage( 350.0, 240.0, buffer ); + + /* Move randomly, adjusting at edges. */ + while( !GetKey( NO_WAIT ) ) + { + if( tc.xCur <= (-tc.xMax + 15.0) ) + TurnTo( 90 ); + else if( tc.yCur <= (-tc.yMax + 15.0) ) + TurnTo( 180 ); + else if( tc.xCur >= (tc.xMax - 365.0) ) + TurnTo( 270 ); + else if( tc.yCur >= (tc.yMax - 255.0) ) + TurnTo( 0 ); + else + Turn( getrandom( -20, 20 ) ); + Move( 3.0 ); + PutImage( buffer, _GPSET ); + } + free( (char *)buffer ); +} + +/* Adjust - Allow the user to interactively adjust the display window. + * Unshifted direction keys adjust the window size. Shifted direction + * keys move the window. The numeric keypad plus and minus keys adjust + * aspect without changing the window. A window frame and a diamond give + * visual feedback on adjustments. + * + * Params: None + * + * Return: None + * + * Uses: tc and vc + */ +#define WININC 4 +void Adjust() +{ + short iWriteMode; + double xyRadius = 400.0, xEdge, yEdge; + char achT[40]; + + /* Display instructions. */ + _clearscreen( _GCLEARSCREEN ); + _settextposition( 2, 2 ); + _outtext(" Grey PLUS and MINUS Adjust aspect" ); + _settextposition( 3, 2 ); + _outtext(" Cursor keys Size window" ); + _settextposition( 4, 2 ); + _outtext(" SHIFT cursor keys Move window" ); + _settextposition( 5, 2 ); + _outtext(" ENTER Finished" ); + + /* Save old write mode and set XOR so you can erase figures by + * redrawing. This allows lines to overwrite text without erasing. + */ + iWriteMode = _getwritemode(); + _setwritemode( _GXOR ); + + while( TRUE ) + { + /* Display data. */ + _settextposition( 6, 2 ); + sprintf( achT, " ratio=%1.2f xMax=%.f yMax=%.f", + tc.yxRatio, tc.xMax, tc.yMax ); + _outtext( achT ); + + /* Calculate current box edges. */ + xEdge = 2 * tc.xMax; + yEdge = 2 * tc.yMax; + + /* Draw border rectangle and diamond that illustrates ratio. */ + Rectangle( xEdge, yEdge ); + Diamond( xyRadius ); + + switch( GetKey( CLEAR_WAIT ) ) + { + /* Adjust aspect. */ + case N_MINUS: + if( tc.yxRatio > 0.4 ) + tc.yxRatio = (tc.xMax - (WININC * tc.yUnit)) / tc.yMax; + break; + + case N_PLUS: + if( tc.yxRatio < 8.0 ) + tc.yxRatio = (tc.xMax + (WININC * tc.yUnit)) / tc.yMax; + break; + + /* Adjust window size. */ + case U_RT: + if( tc.xsLeft < (vc.numxpixels / 3) ) + tc.xsLeft += WININC; + if( tc.xsRight > (vc.numxpixels - (vc.numxpixels / 3)) ) + tc.xsRight -= WININC; + break; + case U_LT: + if( tc.xsLeft ) + tc.xsLeft -= WININC; + if( tc.xsRight < vc.numxpixels ) + tc.xsRight += WININC; + break; + case U_DN: + if( tc.ysTop < (vc.numypixels / 3) ) + tc.ysTop += WININC; + if( tc.ysBot > (vc.numypixels - (vc.numypixels / 3)) ) + tc.ysBot -= WININC; + break; + case U_UP: + if( tc.ysTop ) + tc.ysTop -= WININC; + if( tc.ysBot < vc.numypixels ) + tc.ysBot += WININC; + break; + + /* Adjust window position. */ + case S_LT: + if( tc.xsLeft ) + { + tc.xsLeft -= WININC; + tc.xsRight -= WININC; + } + break; + case S_RT: + if( tc.xsRight < vc.numxpixels ) + { + tc.xsLeft += WININC; + tc.xsRight += WININC; + } + break; + case S_UP: + if( tc.ysTop ) + { + tc.ysTop -= WININC; + tc.ysBot -= WININC; + } + break; + case S_DN: + if( tc.ysBot < vc.numypixels ) + { + tc.ysTop += WININC; + tc.ysBot += WININC; + } + break; + + /* Finished. */ + case ENTER: + _setwritemode( iWriteMode ); + return; + + /* Ignore unknown key. */ + default: + break; + } + /* Redraw figures to erase them. Reset defaults. */ + Rectangle( xEdge, yEdge ); + Diamond( xyRadius ); + Home(); + } +} + +/* Routine used by Adjust to draw its diamond. */ +void Diamond( double xy ) +{ + PenDown( FALSE ); + MoveTo( 0.0, xy ); + PenDown( TRUE ); + MoveTo( xy, 0.0 ); + MoveTo( 0.0, -xy ); + MoveTo( -xy, 0.0 ); + MoveTo( 0.0, xy ); + PenDown( FALSE ); + MoveTo( 0.0, 0.0 ); + PenDown( TRUE ); +} diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/GRDEMO.MAK b/Microsoft C v6ax/SOURCE/SAMPLES/GRDEMO.MAK new file mode 100644 index 0000000..e3a1c00 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/GRDEMO.MAK @@ -0,0 +1,74 @@ +PROJ = GRDEMO +PROJFILE = GRDEMO.MAK +DEBUG = 1 + +PWBRMAKE = pwbrmake +NMAKE = nmake +LINKER = link +ILINK = ilink +LRF = echo > NUL +BIND = bind +RC = rc +IMPLIB = implib +LFLAGS_G = /NOI /NOE /BATCH +LFLAGS_D = /CO /INC /FAR /PACKC +LFLAGS_R = /EXE /FAR /PACKC +MAPFILE_D = NUL +MAPFILE_R = NUL +CC = cl +CFLAGS_G = /W2 /BATCH +CFLAGS_D = /qc /Gi$(PROJ).mdt /Zr /Zi /Od +CFLAGS_R = /Ot /Oi /Ol /Oe /Og /Gs +LLIBS_R = /NOD:SLIBCE SLIBCER +LLIBS_D = /NOD:SLIBCE SLIBCER +ASM = masm +AFLAGS_G = /Mx /T +AFLAGS_D = /Zi + +OBJS = GRDEMO.obj MENU.obj TURTLE.obj + +all: $(PROJ).exe + +.SUFFIXES: .c .obj + +GRDEMO.obj : GRDEMO.C + +MENU.obj : MENU.C + +TURTLE.obj : TURTLE.C + + +$(PROJ).bsc : + +$(PROJ).exe : $(OBJS) +!IF $(DEBUG) + $(LRF) @<<$(PROJ).lrf +$(RT_OBJS) $(OBJS: = +^ +),$@,$(MAPFILE_D),$(LLIBS_G) $(LLIBS_D) $(LIBS),$(DEF_FILE) $(LFLAGS_G) $(LFLAGS_D); +<< +!ELSE + $(LRF) @<<$(PROJ).lrf +$(RT_OBJS) $(OBJS: = +^ +),$@,$(MAPFILE_R),$(LLIBS_G) $(LLIBS_R) $(LIBS),$(DEF_FILE) $(LFLAGS_G) $(LFLAGS_R); +<< +!ENDIF +!IF $(DEBUG) + $(ILINK) -a -e "$(LINKER) @$(PROJ).lrf" $@ +!ELSE + $(LINKER) @$(PROJ).lrf +!ENDIF + + +.c.obj : +!IF $(DEBUG) + $(CC) /c $(CFLAGS_G) $(CFLAGS_D) /Fo$@ $< +!ELSE + $(CC) /c $(CFLAGS_G) $(CFLAGS_R) /Fo$@ $< +!ENDIF + + +run: $(PROJ).exe + $(PROJ).exe $(RUNFLAGS) + +debug: $(PROJ).exe + CV $(CVFLAGS) $(PROJ).exe $(RUNFLAGS) diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/HELVB.FON b/Microsoft C v6ax/SOURCE/SAMPLES/HELVB.FON new file mode 100644 index 0000000..81750c0 Binary files /dev/null and b/Microsoft C v6ax/SOURCE/SAMPLES/HELVB.FON differ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/MENU.C b/Microsoft C v6ax/SOURCE/SAMPLES/MENU.C new file mode 100644 index 0000000..60506da --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/MENU.C @@ -0,0 +1,326 @@ +/* MENU - Module of functions to put menus on the screen and handle keyboard + * input. To use it, include the MENU.H file in your program. The following + * functions are public: + * + * Menu - Puts a menu on screen and reads input for it + * Box - Puts a box on screen (fill it yourself) + * GetKey - Gets ASCII or function key + * _outchar - Displays character using current text position and color + * + * The following structures are defined: + * + * MENU - Defines menu colors, box type, and centering + * ITEM - Defines text of menu item and index of highlight character + * + * The global variable "mnuAtrib" has type MENU. Change this variable to + * change menu appearance. + */ + +#include +#include +#include +#include +#include +#include "menu.h" + +/* Prototype for internal function */ +static void Itemize( int row, int col, int fCur, ITEM itm, int cBlank ); + +/* Default menu attribute. The default works for color or B&W. You can + * override the default value by defining your own MENU variable and + * assigning it to mnuAtrib, or you can modify specific fields at + * run time. For example, you could use a different attribute for color + * than for black and white. + */ +MENU mnuAtrib = +{ + _TBLACK, _TBLACK, _TWHITE, _TBRIGHTWHITE, _TBRIGHTWHITE, + _TWHITE, _TWHITE, _TBLACK, _TWHITE, _TBLACK, + TRUE, + 'Ú', '¿', 'Ù', 'À', '³', 'Ä' +}; + +/* Menu - Puts menu on screen and reads menu input from keyboard. When a + * highlighted hot key or ENTER is pressed, returns the index of the + * selected menu item. + * + * Params: row and col - If "fCentered" attribute of "mnuAtrib" is true, + * center row and column of menu; otherwise top left of menu + * aItem - array of structure containing the text of each item + * and the index of the highlighted hot key + * iCur - index of the current selection--pass 0 for first item, + * or maintain a static value + * + * Return: The index of the selected item + * + * Uses: mnuAtrib + */ +int Menu( int row, int col, ITEM aItem[], int iCur ) +{ + int cItem, cchItem = 2; /* Counts of items and chars per item */ + int i, iPrev; /* Indexes - temporary and previous */ + int acchItem[MAXITEM]; /* Array of counts of character in items */ + char *pchT; /* Temporary character pointer */ + char achHilite[36]; /* Array for highlight characters */ + unsigned uKey; /* Unsigned key code */ + long bgColor; /* Screen color, position, and cursor */ + short fgColor; + struct rccoord rc; + unsigned fCursor; + + /* Save screen information. */ + fCursor = _displaycursor( _GCURSOROFF ); + bgColor = _getbkcolor(); + fgColor = _gettextcolor(); + rc = _gettextposition(); + + /* Count items, find longest, and put count of each in array. Also, + * put the highlighted character from each in a string. + */ + for( cItem = 0; aItem[cItem].achItem[0]; cItem++ ) + { + acchItem[cItem] = strlen( aItem[cItem].achItem ); + cchItem = (acchItem[cItem] > cchItem) ? acchItem[cItem] : cchItem; + i = aItem[cItem].iHilite; + achHilite[cItem] = aItem[cItem].achItem[i]; + } + cchItem += 2; + achHilite[cItem] = 0; /* Null-terminate and lowercase string */ + strlwr( achHilite ); + + /* Adjust if centered, and draw menu box. */ + if( mnuAtrib.fCentered ) + { + row -= cItem / 2; + col -= cchItem / 2; + } + Box( row++, col++, cItem, cchItem ); + + /* Put items on menu. */ + for( i = 0; i < cItem; i++ ) + { + if( i == iCur ) + Itemize( row + i, col, TRUE, aItem[i], cchItem - acchItem[i] ); + else + Itemize( row + i, col, FALSE, aItem[i], cchItem - acchItem[i] ); + } + + while( TRUE ) + { + /* Wait until a uKey is pressed, then evaluate it. */ + uKey = GetKey( WAIT ); + switch( uKey ) + { + case U_UP: /* Up key */ + iPrev = iCur; + iCur = (iCur > 0) ? (--iCur % cItem) : cItem - 1; + break; + case U_DN: /* Down key */ + iPrev = iCur; + iCur = (iCur < cItem) ? (++iCur % cItem) : 0; + break; + default: + if( uKey > 256 ) /* Ignore unknown function key */ + continue; + pchT = strchr( achHilite, (char)tolower( uKey ) ); + if( pchT != NULL ) /* If in highlight string, */ + iCur = pchT - achHilite;/* evaluate and fall through */ + else + continue; /* Ignore unknown ASCII key */ + case ENTER: + _setbkcolor( bgColor ); + _settextcolor( fgColor ); + _settextposition( rc.row, rc.col ); + _displaycursor( fCursor ); + return iCur; + } + /* Redisplay current and previous. */ + Itemize( row + iCur, col, + TRUE, aItem[iCur], cchItem - acchItem[iCur] ); + Itemize( row + iPrev, col, + FALSE, aItem[iPrev], cchItem - acchItem[iPrev] ); + } +} + +/* Box - Draw menu box, filling interior with blanks of the border color. + * + * Params: row and col - upper left of box + * rowLast and colLast - height and width + * + * Return: None + * + * Uses: mnuAtrib + */ +void Box( int row, int col, int rowLast, int colLast ) +{ + int i; + char achT[MAXITEM + 2]; /* Temporary array of characters */ + + /* Set color and position. */ + _settextposition( row, col ); + _settextcolor( mnuAtrib.fgBorder ); + _setbkcolor( mnuAtrib.bgBorder ); + + /* Draw box top. */ + achT[0] = mnuAtrib.chNW; + memset( achT + 1, mnuAtrib.chEW, colLast ); + achT[colLast + 1] = mnuAtrib.chNE; + achT[colLast + 2] = 0; + _outtext( achT ); + + /* Draw box sides and center. */ + achT[0] = mnuAtrib.chNS; + memset( achT + 1, ' ', colLast ); + achT[colLast + 1] = mnuAtrib.chNS; + achT[colLast + 2] = 0; + for( i = 1; i <= rowLast; ++i ) + { + _settextposition( row + i, col ); + _outtext( achT ); + } + + /* Draw box bottom. */ + _settextposition( row + rowLast + 1, col ); + achT[0] = mnuAtrib.chSW; + memset( achT + 1, mnuAtrib.chEW, colLast ); + achT[colLast + 1] = mnuAtrib.chSE; + achT[colLast + 2] = 0; + _outtext( achT ); +} + +/* Itemize - Display one selection (item) of a menu. This function + * is normally only used internally by Menu. + * + * Params: row and col - top left of menu + * fCur - flag set if item is current selection + * itm - structure containing item text and index of highlight + * cBlank - count of blanks to fill + * + * Return: none + * + * Uses: mnuAtrib + */ +void Itemize( int row, int col, int fCur, ITEM itm, int cBlank ) +{ + int i; + char achT[MAXITEM]; /* Temporary array of characters */ + + /* Set text position and color. */ + _settextposition( row, col ); + if( fCur ) + { + _settextcolor( mnuAtrib.fgSelect ); + _setbkcolor( mnuAtrib.bgSelect ); + } + else + { + _settextcolor( mnuAtrib.fgNormal ); + _setbkcolor( mnuAtrib.bgNormal ); + } + + /* Display item and fill blanks. */ + strcat( strcpy( achT, " " ), itm.achItem ); + _outtext( achT ); + memset( achT, ' ', cBlank-- ); + achT[cBlank] = 0; + _outtext( achT ); + + /* Set position and color of highlight character, then display it. */ + i = itm.iHilite; + _settextposition( row, col + i + 1 ); + if( fCur ) + { + _settextcolor( mnuAtrib.fgSelHilite ); + _setbkcolor( mnuAtrib.bgSelHilite ); + } + else + { + _settextcolor( mnuAtrib.fgNormHilite ); + _setbkcolor( mnuAtrib.bgNormHilite ); + } + _outchar( itm.achItem[i] ); +} + +/* GetKey - Gets a key from the keyboard. This routine distinguishes + * between ASCII keys and function or control keys with different shift + * states. It also accepts a flag to return immediately if no key is + * available. + * + * Params: fWait - Code to indicate how to handle keyboard buffer: + * NO_WAIT Return 0 if no key in buffer, else return key + * WAIT Return first key if available, else wait for key + * CLEAR_WAIT Throw away any key in buffer and wait for new key + * + * Return: One of the following: + * + * Keytype High Byte Low Byte + * ------- --------- -------- + * No key available (only with NO_WAIT) 0 0 + * ASCII value 0 ASCII code + * Unshifted function or keypad 1 scan code + * Shifted function or keypad 2 scan code + * CTRL function or keypad 3 scan code + * ALT function or keypad 4 scan code + * + * Note: getkey cannot return codes for keys not recognized by BIOS + * int 16, such as the CTRL-UP or the 5 key on the numeric keypad. + */ +unsigned GetKey( int fWait ) +{ + unsigned uKey, uShift; + + /* If CLEAR_WAIT, drain the keyboard buffer. */ + if( fWait == CLEAR_WAIT ) + while( _bios_keybrd( _KEYBRD_READY ) ) + _bios_keybrd( _KEYBRD_READ ); + + /* If NO_WAIT, return 0 if there is no key ready. */ + if( !fWait && !_bios_keybrd( _KEYBRD_READY ) ) + return FALSE; + + /* Get key code. */ + uKey = _bios_keybrd( _KEYBRD_READ ); + + /* If low byte is not zero, it's an ASCII key. Check scan code to see + * if it's on the numeric keypad. If not, clear high byte and return. + */ + if( uKey & 0x00ff ) + if( (uKey >> 8) < 69 ) + return( uKey & 0x00ff ); + + /* For function keys and numeric keypad, put scan code in low byte + * and shift state codes in high byte. + */ + uKey >>= 8; + uShift = _bios_keybrd( _KEYBRD_SHIFTSTATUS ) & 0x000f; + switch( uShift ) + { + case 0: + return( 0x0100 | uKey ); /* None (1) */ + case 1: + case 2: + case 3: + return( 0x0200 | uKey ); /* Shift (2) */ + case 4: + return( 0x0300 | uKey ); /* Control (3) */ + case 8: + return( 0x0400 | uKey ); /* Alt (4) */ + } +} + +/* _outchar - Display a character. This is the character equivalent of + * _outtext. It is affected by _settextposition, _settextcolor, and + * _setbkcolor. It should not be used in loops. Build strings and then + * _outtext to show multiple characters. + * + * Params: out - character to be displayed + * + * Return: none + */ +void _outchar( char out ) +{ + static char achT[2] = " "; /* Temporary array of characters */ + + achT[0] = out; + _outtext( achT ); +} diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/MENU.H b/Microsoft C v6ax/SOURCE/SAMPLES/MENU.H new file mode 100644 index 0000000..224ba56 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/MENU.H @@ -0,0 +1,71 @@ +/* Function prototypes, macros, structure, and global variables for + * Menu and related functions. + */ + +/* Include only once */ +#ifndef MENU_H +#define MENU_H + +#define TRUE 1 +#define FALSE 0 + +/* Sample key codes for getkey. Additional codes in the same format may + * be added. + */ +#define U_UP 0x0148 /* Unshifted */ +#define U_DN 0x0150 +#define U_LT 0x014b +#define U_RT 0x014d +#define S_UP 0x0248 /* Shifted */ +#define S_DN 0x0250 +#define S_LT 0x024b +#define S_RT 0x024d + +#define N_PLUS 0x014e /* PLUS and MINUS on numeric keypad */ +#define N_MINUS 0x014a + +#define ENTER 13 /* ASCII */ + +/* Action codes for getkey */ +enum WAITACTION { NO_WAIT, WAIT, CLEAR_WAIT }; + +/* Text output colors. Note that monochrome can only use _TBLACK, + * _TWHITE, _TBRIGHTWHITE, and _TUNDERLINE. Graphics black-and-white + * can only use the first three of these. The first eight colors + * can be used as background colors (although they may need to be + * cast to long). + */ +enum TEXTCOLORS +{ + _TBLACK, _TBLUE, _TGREEN, _TCYAN, + _TRED, _TMAGENTA, _TBROWN, _TWHITE, + _TGREY, _TLIGHTBLUE, _TLIGHTGREEN, _TLIGHTCYAN, + _TLIGHTRED, _TLIGHTMAGENTA, _TLIGHTYELLOW, _TBRIGHTWHITE, + _TUNDERLINE = 1 +}; + +/* Structure and global variable for menu attributes */ +typedef struct _MENU +{ + int fgBorder, fgNormal, fgSelect, fgNormHilite, fgSelHilite; + long bgBorder, bgNormal, bgSelect, bgNormHilite, bgSelHilite; + int fCentered; + unsigned char chNW, chNE, chSE, chSW, chNS, chEW; +} MENU; +extern MENU mnuAtrib; + +/* Structure and maximum length for menu items */ +#define MAXITEM 20 +typedef struct _ITEM +{ + int iHilite; + char achItem[MAXITEM]; +} ITEM; + +/* Public menu, output, and input functions */ +int Menu( int row, int col, ITEM aItem[], int iCur ); +void Box( int row, int col, int rowLast, int colLast ); +unsigned GetKey( int fWait ); +void _outchar( char out ); + +#endif /* MENU_H */ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/MODERN.FON b/Microsoft C v6ax/SOURCE/SAMPLES/MODERN.FON new file mode 100644 index 0000000..80d693d Binary files /dev/null and b/Microsoft C v6ax/SOURCE/SAMPLES/MODERN.FON differ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/ROMAN.FON b/Microsoft C v6ax/SOURCE/SAMPLES/ROMAN.FON new file mode 100644 index 0000000..9dfb50e Binary files /dev/null and b/Microsoft C v6ax/SOURCE/SAMPLES/ROMAN.FON differ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/SCRIPT.FON b/Microsoft C v6ax/SOURCE/SAMPLES/SCRIPT.FON new file mode 100644 index 0000000..5d2ead6 Binary files /dev/null and b/Microsoft C v6ax/SOURCE/SAMPLES/SCRIPT.FON differ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/SORTDEMO.C b/Microsoft C v6ax/SOURCE/SAMPLES/SORTDEMO.C new file mode 100644 index 0000000..12bee0e --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/SORTDEMO.C @@ -0,0 +1,834 @@ +/* SORTDEMO -This program graphically demonstrates six common sorting + * algorithms. It prints 25 or 43 horizontal bars of different lengths + * in random order, then sorts the bars from shortest to longest. + * The program can beep to generate different pitches, depending on the + * length and position of the bar. + * + * The program can be created for DOS or OS/2. To create for OS/2, define + * the symbol OS2. Command lines for DOS and OS/2 are shown below: + * + * DOS: + * cl /Lr sortdemo.c graphics.lib + * + * OS/2: + * cl /Lp /DOS2 sortdemo.c grtextp.lib + */ + +#include // _outtext, _settextcolor, _settextposition +#include // strlen +#include // sprintf +#include // getch +#include // srand, rand, toupper +#include // malloc, free +#include // time, clock + +enum BOOL { FALSE, TRUE }; + +/* Structure type for colored bars */ +typedef struct _BAR +{ + char len; + char clr; +} BAR; + +/* Structure type for screen cells */ +typedef struct _CELL +{ + char chChar; + char chAttr; +} CELL; + +/* Function prototypes */ +void main( void ); +void Cls( void ); +void InitMenu( void ); // Menu Functions +void DrawFrame( int iTop, int Left, int Width, int Height ); +void RunMenu( void ); +void DrawTime( int iCurrentRow ); +void InitBars( void ); // Bar functions +void ReInitBars( void ); +void DrawBar( int iRow ); +void SwapBars( int iRow1, int iRow2 ); +void Swaps( BAR *one, BAR *two ); +void InsertionSort( void ); // Sort functions +void BubbleSort( void ); +void HeapSort( void ); +void PercolateUp( int iMaxLevel ); +void PercolateDown( int iMaxLevel ); +void ExchangeSort( void ); +void ShellSort( void ); +void QuickSort( int iLow, int iHigh ); +void Beep( int frequency, int duration ); +void Sleep( clock_t wait ); + +/* Macro */ +#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min)) +#define _outtextxy( ach, x, y ) { _settextposition( y, x ); \ + _outtext( ach ); } + +/* Constants */ +#define ESC 27 +#define BLANK 32 +#define BLOCK 223 +#define TOP 1 +#define FIRSTMENU (TOP + 6) +#define LEFTCOLUMN 48 +#define PROMPTPOS 27 +#define WIDTH (80 - LEFTCOLUMN) +#define HEIGHT (cszMenu + 2) +#define MENUCOLOR 15 +#define BLANKCOLOR 7 +#define BACKCOLOR 0L +#define PAUSELIMIT 900 + +/* Global variables */ +clock_t clStart, clFinish, clPause = 30L; +int fSound, iCurChoice, iSwaps, iCompares, cRow; + +BAR abarWork[43], abarPerm[43]; // Temporary and permanent sort arrays + +char *aszMenu[] = +{ + "", + " C Sorting Demo", + "", + " Time Swap Comp", + "", + "Insertion", + "Bubble", + "Heap", + "Exchange", + "Shell", + "Quick", + "", + "Toggle Sound: ", + "", + "Pause Factor: ", + "< (Slower)", + "> (Faster)", + "", + "Type first character of", + "choice ( I B H E S Q T < > )", + "or ESC key to end program: " + "", +}; +int cszMenu = sizeof( aszMenu ) / sizeof( aszMenu[0] ); + +void main() +{ + cRow = _settextrows( 43 ); + _clearscreen( _GCLEARSCREEN ); + _displaycursor( _GCURSOROFF ); + InitBars(); + InitMenu(); + RunMenu(); // Respond to menu until quit + _setvideomode( _DEFAULTMODE ); +} + + +/* InitMenu - Calls the DrawFrame procedure to draw the frame around the + * sort menu, then prints the different options stored in the menu array. + */ +void InitMenu() +{ + int i; + char ach[15]; + + _settextcolor( MENUCOLOR ); + _setbkcolor( BACKCOLOR ); + DrawFrame( TOP, LEFTCOLUMN - 3, WIDTH + 3, HEIGHT ); + for( i = 0; i < cszMenu; i++ ) + _outtextxy( aszMenu[i], LEFTCOLUMN, TOP + i + 1 ); + + /* Print the current value for Sound. */ + if( fSound ) + strcpy( ach, "ON " ); + else + strcpy( ach, "OFF" ); + + _outtextxy( ach, LEFTCOLUMN + 14, cszMenu - 7 ); + sprintf( ach, "%3.3u", clPause / 30 ); + _outtextxy( ach, LEFTCOLUMN + 14, cszMenu - 5 ); + + /* Erase the speed option if the length of the pause is at a limit. */ + strcpy( ach, " " ); + if( clPause == PAUSELIMIT ) + _outtextxy( ach, LEFTCOLUMN, cszMenu - 4 ); + if( clPause == 0L ) + _outtextxy( ach, LEFTCOLUMN, cszMenu - 3 ); +} + + +/* DrawFrame - Draws a rectangular frame using the double-line box + * characters. The parameters iTop, iLeft, iWidth, and iHeight are + * the row and column arguments for the upper-left and lower-right + * corners of the frame. + */ +void DrawFrame( int iTop, int iLeft, int iWidth, int iHeight ) +{ + enum { ULEFT = 201, URIGHT = 187, + LLEFT = 200, LRIGHT = 188, VERTICAL = 186, HORIZONTAL = 205 + }; + int iRow; + char achTmp[80]; + + memset( achTmp, HORIZONTAL, iWidth ); + achTmp[0] = ULEFT; + achTmp[iWidth - 1] = URIGHT; + achTmp[iWidth] = '\0'; + _outtextxy( achTmp, iLeft, iTop ); + + memset( achTmp, BLANK, iWidth ); + achTmp[0] = VERTICAL; + achTmp[iWidth - 1] = VERTICAL; + for( iRow = iTop + 1; iRow <= iHeight; iRow++ ) + _outtextxy( achTmp, iLeft, iRow ); + + memset( achTmp, HORIZONTAL, iWidth ); + achTmp[0] = LLEFT; + achTmp[iWidth - 1] = LRIGHT; + _outtextxy( achTmp, iLeft, iTop + iHeight ); +} + + +/* RunMenu - The RunMenu procedure first calls the ReInitBars + * procedure to make sure the abarWork is in its unsorted form, then + * prompts the user to make one of the following choices: + * + * - Run one of the sorting algorithms + * - Toggle sound on or off + * - Increase or decrease speed + * - End the program + */ +void RunMenu() +{ + char ch; + + while( TRUE ) + { + iSwaps = iCompares = 0; + _settextposition( TOP + cszMenu, LEFTCOLUMN + PROMPTPOS ); + _displaycursor( _GCURSORON ); + ch = getch(); + _displaycursor( _GCURSOROFF ); + + /* Branch to the appropriate procedure depending on the key. */ + switch( toupper( ch ) ) + { + case 'I': + iCurChoice = 0; + ReInitBars(); + InsertionSort(); + DrawTime( 0 ); // Print final time + break; + case 'B': + iCurChoice = 1; + ReInitBars(); + BubbleSort(); + DrawTime( 0 ); + break; + + case 'H': + iCurChoice = 2; + ReInitBars(); + HeapSort(); + DrawTime( 0 ); + break; + + case 'E': + iCurChoice = 3; + ReInitBars(); + ExchangeSort(); + DrawTime( 0 ); + break; + + case 'S': + iCurChoice = 4; + ReInitBars(); + ShellSort(); + DrawTime( 0 ); + break; + + case 'Q': + iCurChoice = 5; + ReInitBars(); + QuickSort( 0, cRow ); + DrawTime( 0 ); + break; + + case '>': + /* Decrease pause length to speed up sorting time, then + * redraw the menu to clear any timing results (since + * they won't compare with future results). + */ + if( clPause ) + clPause -= 30L; + InitMenu(); + break; + + case '<': + /* Increase pause length to slow down sorting time. */ + if( clPause <= 900L ) + clPause += 30L; + InitMenu(); + break; + + case 'T': + fSound = !fSound; + InitMenu(); + break; + + case ESC: + return; + + default: // Unknown key ignored + break; + } + } +} + + +/* DrawTime - Prints seconds elapsed since the given sorting routine + * started. Note that this time includes both the time it takes to redraw + * the bars plus the pause while Beep plays a note, and thus is not an + * accurate indication of sorting speed. + */ +void DrawTime( int iCurrentRow ) +{ + char achTiming[80]; + + _settextcolor( MENUCOLOR ); + clFinish = clock(); + + sprintf( achTiming, "%7.2f %4.i %4.i", + (float)(clFinish - clStart) / CLOCKS_PER_SEC, + iSwaps, iCompares ); + + /* Print the number of seconds elapsed */ + _outtextxy( achTiming, LEFTCOLUMN + 11, FIRSTMENU + iCurChoice ); + if( fSound ) + { + Beep( 60 * iCurrentRow, 75 ); // Play note + Sleep( clPause - 75L ); // Pause adjusted for note duration + } + else + Sleep( clPause ); // Pause +} + + +/* InitBars - Initializes the bar arrays and the menu box. + */ +void InitBars() +{ + struct videoconfig vc; + int aTemp[43], iRow, iRowMax, iRand, iColorMax, iLength; + + /* Seed the random-number generator. */ + srand( (unsigned)time( NULL ) ); + fSound = TRUE; + clPause = 30L; + + /* If monochrome or color burst disabled, use one color */ + _getvideoconfig( &vc ); + if( (vc.monitor == _MONO) || (vc.mode == _TEXTBW80) || + (vc.mode == _TEXTBW40) ) + iColorMax = 1; + else + iColorMax = 15; + + /* Randomize an array of rows. */ + for( iRow = 0; iRow < cRow; iRow++ ) + aTemp[iRow] = iRow + 1; + iRowMax = cRow - 1; + for( iRow = 0; iRow < cRow; iRow++ ) + { + /* Find a random element in aTemp between 0 and iRowMax, + * then assign the value in that element to iLength. + */ + iRand = GetRandom( 0, iRowMax ); + iLength = aTemp[iRand]; + + /* Overwrite the value in aTemp[iRand] with the value in + * aTemp[iRowMax] so the value in aTemp[iRand] is + * chosen only once. + */ + aTemp[iRand] = aTemp[iRowMax]; + + /* Decrease the value of iRowMax so that aTemp[iRowMax] can't + * be chosen on the next pass through the loop. + */ + --iRowMax; + abarPerm[iRow].len = iLength; + if( iColorMax == 1 ) + abarPerm[iRow].clr = BLANKCOLOR; + else + abarPerm[iRow].clr = iLength % iColorMax + 1; + } + + /* Assign permanent sort values to temporary and draw unsorted bars. */ + ReInitBars(); +} + + +/* ReInitBars - Restores the array abarWork to its original unsorted + * state and draws the unsorted bars. + */ +void ReInitBars() +{ + int iRow; + + clStart = clock(); + for( iRow = 0; iRow < cRow; iRow++ ) + { + abarWork[iRow] = abarPerm[iRow]; + DrawBar( iRow ); + } +} + + +/* DrawBar - Prints a bar at a specified row by first blanking the + * old bar, then drawing a new bar having the length and color given in + * the work array. + */ +void DrawBar( int iRow ) +{ + int cSpace; + char achT[43]; + + memset( achT, BLOCK, abarWork[iRow].len ); + cSpace = cRow - abarWork[iRow].len; + memset( achT + abarWork[iRow].len, ' ', cSpace ); + achT[cRow] = '\0'; + _settextcolor( abarWork[iRow].clr ); + _outtextxy( achT, 0, iRow + 1 ); +} + + +/* SwapBars - Calls DrawBar twice to switch the two bars in iRow1 and + * iRow2, then calls DrawTime to update the time. + */ +void SwapBars( int iRow1, int iRow2 ) +{ + DrawBar( iRow1 ); + DrawBar( iRow2 ); + DrawTime( iRow1 ); +} + + +/* Swaps - Exchanges two bar structures. + */ +void Swaps( BAR *bar1, BAR *bar2 ) +{ + BAR barTmp; + + ++iSwaps; + barTmp = *bar1; + *bar1 = *bar2; + *bar2 = barTmp; +} + + +/* InsertionSort - InsertionSort compares the length of each element + * with the lengths of all the preceding elements. When the appropriate + * place for the new element is found, the element is inserted and + * all the other elements are moved down one place. + */ +void InsertionSort() +{ + BAR barTemp; + int iRow, iRowTmp, iLength; + + /* Start at the top. */ + for( iRow = 0; iRow < cRow; iRow++ ) + { + barTemp = abarWork[iRow]; + iLength = barTemp.len; + + /* As long as the length of the temporary element is greater than + * the length of the original, keep shifting the elements down. + */ + for( iRowTmp = iRow; iRowTmp; iRowTmp-- ) + { + iCompares++; + if( abarWork[iRowTmp - 1].len > iLength ) + { + ++iSwaps; + abarWork[iRowTmp] = abarWork[iRowTmp - 1]; + DrawBar( iRowTmp ); // Print the new bar + DrawTime( iRowTmp ); // Print the elapsed time + + } + else // Otherwise, exit + break; + } + + /* Insert the original bar in the temporary position. */ + abarWork[iRowTmp] = barTemp; + DrawBar( iRowTmp ); + DrawTime( iRowTmp ); + } +} + + +/* BubbleSort - BubbleSort cycles through the elements, comparing + * adjacent elements and swapping pairs that are out of order. It + * continues to do this until no out-of-order pairs are found. + */ +void BubbleSort() +{ + int iRow, iSwitch, iLimit = cRow; + + /* Move the longest bar down to the bottom until all are in order. */ + do + { + iSwitch = 0; + for( iRow = 0; iRow < iLimit; iRow++ ) + { + /* If two adjacent elements are out of order, swap their values + * and redraw those two bars. + */ + iCompares++; + if( abarWork[iRow].len > abarWork[iRow + 1].len ) + { + Swaps( &abarWork[iRow], &abarWork[iRow + 1] ); + SwapBars( iRow, iRow + 1 ); + iSwitch = iRow; + } + } + + /* Sort on next pass only to where the last switch was made. */ + iLimit = iSwitch; + } while( iSwitch ); +} + + +/* HeapSort - HeapSort (also called TreeSort) works by calling + * PercolateUp and PercolateDown. PercolateUp organizes the elements + * into a "heap" or "tree," which has the properties shown below: + * + * element[1] + * / \ + * element[2] element[3] + * / \ / \ + * element[4] element[5] element[6] element[7] + * / \ / \ / \ / \ + * ... ... ... ... ... ... ... ... + * + * + * Each "parent node" is greater than each of its "child nodes"; for + * example, element[1] is greater than element[2] or element[3]; + * element[4] is greater than element[5] or element[6], and so forth. + * Therefore, once the first loop in HeapSort is finished, the + * largest element is in element[1]. + * + * The second loop rebuilds the heap (with PercolateDown), but starts + * at the top and works down, moving the largest elements to the bottom. + * This has the effect of moving the smallest elements to the top and + * sorting the heap. + */ +void HeapSort() +{ + int i; + + for( i = 1; i < cRow; i++ ) + PercolateUp( i ); + + for( i = cRow - 1; i > 0; i-- ) + { + Swaps( &abarWork[0], &abarWork[i] ); + SwapBars( 0, i ); + PercolateDown( i - 1 ); + } +} + + +/* PercolateUp - Converts elements into a "heap" with the largest + * element at the top (see the diagram above). + */ +void PercolateUp( int iMaxLevel ) +{ + int i = iMaxLevel, iParent; + + /* Move the value in abarWork[iMaxLevel] up the heap until it has + * reached its proper node (that is, until it is greater than either + * of its child nodes, or until it has reached 1, the top of the heap). + */ + while( i ) + { + iParent = i / 2; // Get the subscript for the parent node + + iCompares++; + if( abarWork[i].len > abarWork[iParent].len ) + { + /* The value at the current node is bigger than the value at + * its parent node, so swap these two array elements. + */ + Swaps( &abarWork[iParent], &abarWork[i] ); + SwapBars( iParent, i ); + i = iParent; + } + else + /* Otherwise, the element has reached its proper place in the + * heap, so exit this procedure. + */ + break; + } +} + + +/* PercolateDown - Converts elements to a "heap" with the largest elements + * at the bottom. When this is done to a reversed heap (largest elements + * at top), it has the effect of sorting the elements. + */ +void PercolateDown( int iMaxLevel ) +{ + int iChild, i = 0; + + /* Move the value in abarWork[0] down the heap until it has reached + * its proper node (that is, until it is less than its parent node + * or until it has reached iMaxLevel, the bottom of the current heap). + */ + while( TRUE ) + { + /* Get the subscript for the child node. */ + iChild = 2 * i; + + /* Reached the bottom of the heap, so exit this procedure. */ + if( iChild > iMaxLevel ) + break; + + /* If there are two child nodes, find out which one is bigger. */ + if( iChild + 1 <= iMaxLevel ) + { + iCompares++; + if( abarWork[iChild + 1].len > abarWork[iChild].len ) + iChild++; + } + + iCompares++; + if( abarWork[i].len < abarWork[iChild].len ) + { + /* Move the value down since it is still not bigger than + * either one of its children. + */ + Swaps( &abarWork[i], &abarWork[iChild] ); + SwapBars( i, iChild ); + i = iChild; + } + else + /* Otherwise, abarWork has been restored to a heap from 1 to + * iMaxLevel, so exit. + */ + break; + } +} + + +/* ExchangeSort - The ExchangeSort compares each element--starting with + * the first--with every following element. If any of the following + * elements is smaller than the current element, it is exchanged with + * the current element and the process is repeated for the next element. + */ +void ExchangeSort() +{ + int iRowCur, iRowMin, iRowNext; + + for( iRowCur = 0; iRowCur < cRow; iRowCur++ ) + { + iRowMin = iRowCur; + for( iRowNext = iRowCur; iRowNext < cRow; iRowNext++ ) + { + iCompares++; + if( abarWork[iRowNext].len < abarWork[iRowMin].len ) + { + iRowMin = iRowNext; + DrawTime( iRowNext ); + } + } + + /* If a row is shorter than the current row, swap those two + * array elements. + */ + if( iRowMin > iRowCur ) + { + Swaps( &abarWork[iRowCur], &abarWork[iRowMin] ); + SwapBars( iRowCur, iRowMin ); + } + } +} + + +/* ShellSort - ShellSort is similar to the BubbleSort. However, it + * begins by comparing elements that are far apart (separated by the + * value of the iOffset variable, which is initially half the distance + * between the first and last element), then comparing elements that + * are closer together. When iOffset is one, the last iteration of + * is merely a bubble sort. + */ +void ShellSort() +{ + int iOffset, iSwitch, iLimit, iRow; + + /* Set comparison offset to half the number of bars. */ + iOffset = cRow / 2; + + while( iOffset ) + { + /* Loop until offset gets to zero. */ + iLimit = cRow - iOffset; + do + { + iSwitch = FALSE; // Assume no switches at this offset. + + /* Compare elements and switch ones out of order. */ + for( iRow = 0; iRow <= iLimit; iRow++ ) + { + iCompares++; + if( abarWork[iRow].len > abarWork[iRow + iOffset].len ) + { + Swaps( &abarWork[iRow], &abarWork[iRow + iOffset] ); + SwapBars( iRow, iRow + iOffset ); + iSwitch = iRow; + } + } + + /* Sort on next pass only to where last switch was made. */ + iLimit = iSwitch - iOffset; + } while( iSwitch ); + + /* No switches at last offset, try one half as big. */ + iOffset = iOffset / 2; + } +} + + +/* QuickSort - QuickSort works by picking a random "pivot" element, + * then moving every element that is bigger to one side of the pivot, + * and every element that is smaller to the other side. QuickSort is + * then called recursively with the two subdivisions created by the pivot. + * Once the number of elements in a subdivision reaches two, the recursive + * calls end and the array is sorted. + */ +void QuickSort( int iLow, int iHigh ) +{ + int iUp, iDown, iBreak; + + if( iLow < iHigh ) + { + /* Only two elements in this subdivision; swap them if they are + * out of order, then end recursive calls. + */ + if( (iHigh - iLow) == 1 ) + { + iCompares++; + if( abarWork[iLow].len > abarWork[iHigh].len ) + { + Swaps( &abarWork[iLow], &abarWork[iHigh] ); + SwapBars( iLow, iHigh ); + } + } + else + { + iBreak = abarWork[iHigh].len; + do + { + /* Move in from both sides towards the pivot element. */ + iUp = iLow; + iDown = iHigh; + iCompares++; + while( (iUp < iDown) && (abarWork[iUp].len <= iBreak) ) + iUp++; + iCompares++; + while( (iDown > iUp) && (abarWork[iDown].len >= iBreak) ) + iDown--; + /* If we haven't reached the pivot, it means that two + * elements on either side are out of order, so swap them. + */ + if( iUp < iDown ) + { + Swaps( &abarWork[iUp], &abarWork[iDown] ); + SwapBars( iUp, iDown ); + } + } while ( iUp < iDown ); + + /* Move pivot element back to its proper place in the array. */ + Swaps( &abarWork[iUp], &abarWork[iHigh] ); + SwapBars( iUp, iHigh ); + + /* Recursively call the QuickSort procedure (pass the smaller + * subdivision first to use less stack space). + */ + if( (iUp - iLow) < (iHigh - iUp) ) + { + QuickSort( iLow, iUp - 1 ); + QuickSort( iUp + 1, iHigh ); + } + else + { + QuickSort( iUp + 1, iHigh ); + QuickSort( iLow, iUp - 1 ); + } + } + } +} + +/* Beep - Sounds the speaker for a time specified in microseconds by + * duration at a pitch specified in hertz by frequency. + */ +void Beep( int frequency, int duration ) +{ +/* Use system call for OS/2 */ +#if defined( OS2 ) +#define INCL_NOCOMMON +#define INCL_NOPM +#define INCL_DOSPROCESS +#include + DosBeep( frequency, duration ); +#else +/* Define procedure for DOS */ + int control; + + /* If frequency is 0, Beep doesn't try to make a sound. It + * just sleeps for the duration. + */ + if( frequency ) + { + /* 75 is about the shortest reliable duration of a sound. */ + if( duration < 75 ) + duration = 75; + + /* Prepare timer by sending 10111100 to port 43. */ + outp( 0x43, 0xb6 ); + + /* Divide input frequency by timer ticks per second and + * write (byte by byte) to timer. + */ + frequency = (unsigned)(1193180L / frequency); + outp( 0x42, (char)frequency ); + outp( 0x42, (char)(frequency >> 8) ); + + /* Save speaker control byte. */ + control = inp( 0x61 ); + + /* Turn on the speaker (with bits 0 and 1). */ + outp( 0x61, control | 0x3 ); + } + + Sleep( (clock_t)duration ); + + /* Turn speaker back on if necessary. */ + if( frequency ) + outp( 0x61, control ); + +#endif /* DOS version */ +} + +/* Pauses for a specified number of microseconds. */ +void Sleep( clock_t wait ) +{ + clock_t goal; + + goal = wait + clock(); + while( goal >= clock() ) + ; +} diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/SORTDEMO.MAK b/Microsoft C v6ax/SOURCE/SAMPLES/SORTDEMO.MAK new file mode 100644 index 0000000..7ef304b --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/SORTDEMO.MAK @@ -0,0 +1,84 @@ +PROJ = SORTDEMO +PROJFILE = SORTDEMO.MAK +DEBUG = 1 + +PWBRMAKE = pwbrmake +NMAKE = nmake +LINKER = link +ILINK = ilink +LRF = echo > NUL +BIND = bind +RC = rc +IMPLIB = implib +LFLAGS_G = /NOI /NOE /BATCH +LFLAGS_D = /CO /INC /FAR /PACKC +LFLAGS_R = /EXE /FAR /PACKC +MAPFILE_D = NUL +MAPFILE_R = NUL +CC = cl +CFLAGS_G = /W2 /BATCH +CFLAGS_D = /qc /Gi$(PROJ).mdt /Zr /Zi /Od +CFLAGS_R = /Ot /Oi /Ol /Oe /Og /Gs +LLIBS_R = /NOD:SLIBCE SLIBCER +LLIBS_D = /NOD:SLIBCE SLIBCER +ASM = masm +AFLAGS_G = /Mx /T +AFLAGS_D = /Zi +LLIBS_G = graphics.lib + +OBJS = SORTDEMO.obj +SBRS = SORTDEMO.sbr + +all: $(PROJ).exe + +.SUFFIXES: .c .sbr .obj + +SORTDEMO.obj : SORTDEMO.C + +SORTDEMO.sbr : SORTDEMO.C + + +$(PROJ).bsc : $(SBRS) + $(PWBRMAKE) @<< +$(BRFLAGS) $(SBRS) +<< + +$(PROJ).exe : $(OBJS) +!IF $(DEBUG) + $(LRF) @<<$(PROJ).lrf +$(RT_OBJS) $(OBJS: = +^ +),$@,$(MAPFILE_D),$(LLIBS_G) $(LLIBS_D) $(LIBS),$(DEF_FILE) $(LFLAGS_G) $(LFLAGS_D); +<< +!ELSE + $(LRF) @<<$(PROJ).lrf +$(RT_OBJS) $(OBJS: = +^ +),$@,$(MAPFILE_R),$(LLIBS_G) $(LLIBS_R) $(LIBS),$(DEF_FILE) $(LFLAGS_G) $(LFLAGS_R); +<< +!ENDIF +!IF $(DEBUG) + $(ILINK) -a -e "$(LINKER) @$(PROJ).lrf" $@ +!ELSE + $(LINKER) @$(PROJ).lrf +!ENDIF + + +.c.sbr : +!IF $(DEBUG) + $(CC) /Zs $(CFLAGS_G) $(CFLAGS_D) /FR$@ $< +!ELSE + $(CC) /Zs $(CFLAGS_G) $(CFLAGS_R) /FR$@ $< +!ENDIF + +.c.obj : +!IF $(DEBUG) + $(CC) /c $(CFLAGS_G) $(CFLAGS_D) /Fo$@ $< +!ELSE + $(CC) /c $(CFLAGS_G) $(CFLAGS_R) /Fo$@ $< +!ENDIF + + +run: $(PROJ).exe + $(PROJ).exe $(RUNFLAGS) + +debug: $(PROJ).exe + CV $(CVFLAGS) $(PROJ).exe $(RUNFLAGS) diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/TMSRB.FON b/Microsoft C v6ax/SOURCE/SAMPLES/TMSRB.FON new file mode 100644 index 0000000..cfa764d Binary files /dev/null and b/Microsoft C v6ax/SOURCE/SAMPLES/TMSRB.FON differ diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/TURTLE.C b/Microsoft C v6ax/SOURCE/SAMPLES/TURTLE.C new file mode 100644 index 0000000..7ef9076 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/TURTLE.C @@ -0,0 +1,449 @@ +/* TURTLE - Module of functions to implement turtle graphics. Turtle graphics + * is a model for specifying relative movements of an imaginary pointer whose + * direction, color, visibility, and other attributes are given default + * values using turtle functions. To use the turtle module, include TURTLE.H + * in your program. The following functions (many defined as macros) + * are public : + * + * InitTurtle - Initiate turtle graphics + * Home - Reset turtle defaults + * PenDown - Set pen visibility + * SetFill - Set fill state + * PenColor - Set pen color index + * BorderColor - Set border color index + * Turn - Set direction relative to current + * TurnTo - Set absolute direction + * Move - Move in current direction + * MoveTo - Move to absolute location + * Poly - Draw a polygon + * Circle - Draw a circle with center at current location + * Ellipse - Draw an ellipse with center at current location + * Rectangle - Draw a rectangle with center at current location + * ImageSize - Get size of rectangle with top-left origin + * GetImage - Get rectangular image with top-left origin + * PutImage - Put rectangular image with top-left origin + * FillIn - Fill from the current location to border + * NextColorIndex - Rotate to next color index + * NextColorValue - Rotate to next color value + * OnScreen - Report whether current location is on screen + * RGB - Combine Red, Green, and Blue elements of color value + * + * The TURTLE structure, the "tc" global variable (having TURTLE type), and + * "vlColors" variable are defined. However, these are not normally used + * directly by the programmer. + */ + +#include +#include +#include +#include "turtle.h" + +#define PI 3.141593 + +long cvlColors[256]; /* Array of long color values */ + +TURTLE tc = { 1.39 }; /* Initial aspect - adjust for your screen */ + +/* InitTurtle - Initializes all turtle defaults. This function should be + * called at least once (after _setvideomode and _getvideoconfig) and + * additionally after any change to a new graphics mode. + * + * Params: vc - pointer to videoconfig structure + * + * Return: 0 if fail, 1 if success + * + * Uses: tc structure variable cvlColors array + */ +short InitTurtle( struct videoconfig *vc ) +{ + int i; + unsigned cvuInc, cvuRed, cvuGreen, cvuBlue; /* Unsigned portions of */ + static int mode = -1; /* color values */ + + /* Terminate if not graphics mode. */ + if( !vc->numxpixels ) + return 0; + + /* If mode has changed, set window coordinates. */ + if( mode != vc->mode ) + { + mode = vc->mode; + tc.xsLeft = tc.ysTop = 0; + tc.xsRight = vc->numxpixels - 1; + tc.ysBot = vc->numypixels - 1; + } + + /* Set palette flag. */ + switch( vc->adapter ) + { + case _MDPA: + case _CGA: + case _OCGA: + case _HGC: + tc.fPalette = FALSE; + break; + default: + tc.fPalette = TRUE; + break; + } + + /* Set palette defaults. */ + switch( vc->mode ) + { + case _HRESBW: + case _HERCMONO: + case _ERESNOCOLOR: + case _ORESCOLOR: + case _VRES2COLOR: + tc.ccv = 0; + tc.cci = 2; + return Home(); + case _MRES256COLOR: /* Active bits in this order: */ + cvuInc = 12; + tc.ccv = tc.cci = 125; /* ???????? ??bbbbbb ??gggggg ??rrrrrr */ + break; + case _ERESCOLOR: + if( vc->memory == 64 ) + { + cvuInc = 32; + tc.ccv = 16; /* ???????? ??????Bb ??????Gg ??????Rr */ + tc.cci = 4; + break; + } /* Else fall through */ + case _VRES16COLOR: + cvuInc = 16; + tc.ccv = 64; /* ???????? ??????bb ??????gg ??????rr */ + tc.cci = 16; + break; + case _MRES4COLOR: + case _MRESNOCOLOR: + cvuInc = 32; + tc.ccv = 16; /* ???????? ??????Bb ??????Gg ??????Rr */ + tc.cci = 4; + break; + case _MRES16COLOR: + case _HRES16COLOR: + cvuInc = 32; + tc.cci = tc.ccv = 16; /* ???????? ??????Bb ??????Gg ??????Rr */ + break; + } + + /* Fill palette arrays. */ + for( i = 0, cvuBlue = 0; cvuBlue < 64; cvuBlue += cvuInc ) + for( cvuGreen = 0; cvuGreen < 64; cvuGreen += cvuInc ) + for( cvuRed = 0; cvuRed < 64; cvuRed += cvuInc ) + { + cvlColors[i] = RGB( cvuRed, cvuGreen, cvuBlue ); + /* Special case of 6 bits for 16 colors (RGBI). + * If both bits are on for any color, intensity is set. + * If one bit is set for a color, that color is on. + */ + if( cvuInc == 32 ) + cvlColors[i + 8] = cvlColors[i] | (cvlColors[i] >> 1); + i++; + } + cvlColors[tc.ccv - 1] = _BRIGHTWHITE; + NextColorValue( DEFAULT ); + return Home(); +} + +/* Home - Resets turtle defaults. This function can be called if you have + * not changed the video mode, but you want to put the turtle back in + * the center of the window and restore all defaults. For example, you can + * change the absolute window corners and then call it to set a new + * turtle window. + * + * Params: None + * + * Return: 0 if fail, 1 if success + * + * Uses: tc + */ +short Home() +{ + struct _wxycoord xy1, xy2; + + _setviewport( tc.xsLeft, tc.ysTop, tc.xsRight, tc.ysBot ); + + /* Set the window based on screen height 1000 and width based on + * aspect ratio. + */ + tc.yMax = 500.0; + tc.xMax = tc.yMax * tc.yxRatio; + if( !_setwindow( FALSE, -tc.xMax, -tc.yMax, tc.xMax, tc.yMax ) ) + return 0; + + /* Calculate the unit size of 1 pixel using Y axis. */ + xy1 = _getwindowcoord( 1, 1 ); + xy2 = _getwindowcoord( 1, 2 ); + tc.yUnit = xy2.wy - xy1.wy; + + /* Set defaults for current pixel, angle, pen state and fill state. */ + tc.xCur = tc.yCur = 0.0; + _moveto_w( tc.xCur, tc.yCur ); + TurnTo( 0 ); + PenDown( TRUE ); + SetFill( FALSE ); + + /* Make white the last color index and set pen and border to it. */ + _remappalette( WHITE, _BRIGHTWHITE ); + BorderColor( WHITE ); + PenColor( WHITE ); + _setbkcolor( _BLACK ); + return 1; +} + +/* PenDown - Sets the visibility of the pen used by Move and MoveTo. The + * state can be TRUE (visible), FALSE (invisible), or DEFAULT (return + * current without changing). + * + * Params: fPenDown + * + * Return: current pen state + * + * Uses: tc + */ +int PenDown( int fPenDown ) +{ + switch( fPenDown ) + { + case DEFAULT: + break; + case FALSE: + tc.fPenDown = FALSE; + break; + default: + tc.fPenDown = TRUE; + break; + } + return tc.fPenDown; +} + +/* SetFill - Determines the state of filling figures such as Rectangle, + * Circle, and Ellipse. State can be TRUE (fill inside), FALSE (border + * only), or DEFAULT (return current fill state). + * + * Params: fFill + * + * Return: current fill state + * + * Uses: tc + */ +short SetFill( short fFill ) +{ + switch( fFill ) + { + case DEFAULT: + break; + case _GBORDER: + case FALSE: + tc.fFill = _GBORDER; + break; + default: + tc.fFill = _GFILLINTERIOR; + break; + } + return tc.fFill; +} + +/* PenColor - Sets the color index of the pen. + * + * Params: ciCur - any color index of DEFAULT to return without changing + * + * Return: current pen color index + * + * Uses: tc + */ +short PenColor( short ciCur ) +{ + if( ciCur != DEFAULT ) + _setcolor( tc.ciCur = ciCur ); + return tc.ciCur; +} + +/* BorderColor - Sets the color index of the border that will be recognized + * by fills. + * + * Params: ciBorder - any color index of DEFAULT to return without changing + * + * Return: current border color index + * + * Uses: tc + */ +short BorderColor( short border ) +{ + if( border != DEFAULT ) + tc.ciBorder = border; + return tc.ciBorder; +} + +/* Turn - Sets a new direction relative to the current direction. + * + * Params: angCur - a positive (clockwise) or negative (counterclockwise) + * angle in degrees + * + * Return: new current absolute angle + * + * Uses: tc + */ +short Turn( short angCur ) +{ + return( tc.angCur = ((tc.angCur + angCur) % CIRCUMFERENCE) ); +} + +/* TurnTo - Sets a new absolute direction. + * + * Params: angCur - a positive (clockwise) or negative (counterclockwise) + * angle in degrees (0 points to 12 o'clock) + * + * Return: new current absolute angle + * + * Uses: tc + */ +short TurnTo( short angCur ) +{ + if( angCur < 0 ) + return( tc.angCur = 360 - (angCur % CIRCUMFERENCE) ); + else + return( tc.angCur = angCur % CIRCUMFERENCE ); +} + +/* Move - Moves from the current position in the current direction for a + * specified distance. A line is drawn if the pen is down. The current + * position is reset to the destination. + * + * Params: dxy - difference between current xy and new xy + * + * Return: 0 if new position is off screen, nonzero if on screen + * + * Uses: tc + */ +short Move( double dxy ) +{ + double dx, dy; /* Differences of X and Y */ + double angT; + + /* Calculate new X and Y positions. */ + angT = (tc.angCur - 90) * (PI / HALFCIRCUMFERENCE); + dx = dxy * cos( angT ); + dy = dxy * sin( angT ); + + /* Move, drawing if pen down, then update position */ + if( tc.fPenDown ) + _lineto_w( tc.xCur + dx, tc.yCur + dy ); + else + _moveto_w( tc.xCur + dx, tc.yCur + dy ); + tc.xCur += dx; + tc.yCur += dy; + return OnScreen(); +} + +/* MoveTo - Moves from the current position to a specified position. A + * line is drawn if the pen is down. The current position is reset to the + * destination. The current direction is not changed. + * + * Params: x and y - destination position + * + * Return: 0 if new position is off screen, nonzero if on screen + * + * Uses: tc + */ +short MoveTo( double x, double y ) +{ + if( tc.fPenDown ) + _lineto_w( x, y ); + else + _moveto_w( x, y ); + tc.xCur = x; + tc.yCur = y; + return OnScreen(); +} + +/* Poly - Draws a polygon. + * + * Params: cSide - count of polygon sides + * dxySide - distance of each side + * + * Return: 0 if any part of polygon is off screen, nonzero if on screen + */ +short Poly( int cSide, double dxySide ) +{ + short i, angT, fPen, ret = TRUE; + + /* Make sure pen is down (restore pen state when done). */ + fPen = PenDown( TRUE ); + + /* Calculate angle, then draw each side. */ + angT = 360 / cSide; + for( i = 1; i <= cSide; i++ ) + { + ret = Move( dxySide ) && ret; + Turn( angT ); + } + PenDown( fPen ); + return ret; +} + +/* NextColorIndex - Rotate to next color index. First attribute (normally + * background) and last attribute (white) are skipped. + * + * Params: ciCur - Specify DEFAULT to use color index from last call, + * or specify a new color to rotate from + * + * Return: rotated color index + * + * Uses: tc + */ +short NextColorIndex( short ciCur ) +{ + static short ciPrev = 0; /* Static to retain index between calls */ + + /* Assign new current if given. */ + if( ciCur != DEFAULT ) + ciPrev = ciCur; + + /* Toggle for two-color modes, rotate for multi-color modes. */ + if( tc.cci == 2 ) + return( ciPrev = !ciPrev ); + else + return( ciPrev = (++ciPrev % (tc.cci - 1)) ); +} + +/* NextColorValue - Rotate to next color value for adapters (EGA + * and higher) that support remappable palettes. + * + * Params: fAction - DEFAULT (rotate all) or LIMITED (rotate first 14 only) + * + * Return: None + * + * Uses: tc + */ +void NextColorValue( int fAction ) +{ + static int icvCur = 1; /* Current index into color value array */ + static int ciCur = 1; /* Current color index */ + int icvT; /* Temporary index into color values */ + int i; + + /* Ignore modes with no palette values. */ + if( !tc.fPalette || !tc.ccv ) + return; + + /* Increment and rotate color value index. */ + icvT = (++icvCur % (tc.ccv - 2)) + 1; + + + /* DEFAULT - Remap all color indexes, 14 at a time. For most modes, + * this is all the indexes except first and last. For 256-color + * mode, rotating all available indexes would be too slow. + */ + if( fAction == DEFAULT ) + for( i = 1; i <= 14; i++ ) + _remappalette( (ciCur++ % (tc.cci - 2)) + 1, + cvlColors[(icvT++ % (tc.ccv - 2)) + 1] ); + + /* LIMITED - Rotate only the first 14 color indexes. */ + else + for( i = 1; i <= 14; i++ ) + _remappalette( i, cvlColors[(icvT++ % (tc.ccv - 1)) + 1] ); +} diff --git a/Microsoft C v6ax/SOURCE/SAMPLES/TURTLE.H b/Microsoft C v6ax/SOURCE/SAMPLES/TURTLE.H new file mode 100644 index 0000000..51e1f80 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/SAMPLES/TURTLE.H @@ -0,0 +1,105 @@ +/* Function prototypes, macros, structure, and global variables for + * Turtle Graphics functions. + */ + +/* Include only once */ +#ifndef TURTLE_H +#define TURTLE_H + +/* Initiate and set defaults */ +short InitTurtle( struct videoconfig *vc ); +short Home( void ); + +/* Control pen and color */ +int PenDown( int state ); +short SetFill( short state ); +short PenColor( short atrib ); +short BorderColor( short border ); + +/* Control angle */ +short Turn( short angle ); +short TurnTo( short angle ); + +/* Turtle movement */ +short Move( double distance ); +short MoveTo( double x, double y ); +short Poly( int number, double side ); + +/* Rotate color index or value */ +short NextColorIndex( short ciCur ); +void NextColorValue( int fAction ); + +/* Put a circle with radius at current location. */ +#define Circle( r ) _ellipse_w( tc.fFill, tc.xCur-(r), tc.yCur-(r), \ + tc.xCur+(r), tc.yCur+(r) ) + +/* Puts an ellipse with width and height at current location. */ +#define Ellipse( w, h ) _ellipse_w( tc.fFill, \ + tc.xCur-((w)/2), tc.yCur-((h)/2), \ + tc.xCur+((w)/2), tc.yCur+((h)/2) ) + +/* Puts the center of a rectangle with width and height + * at current location. + */ +#define Rectangle( w, h ) _rectangle_w( tc.fFill, \ + tc.xCur-((w)/2), tc.yCur-((h)/2), \ + tc.xCur+((w)/2), tc.yCur+((h)/2) ) + +/* Gets the imagesize of an image with width and height + * with left-top at current location. Returns image size. + */ +#define ImageSize( w, h ) _imagesize_w( tc.xCur, tc.yCur, \ + tc.xCur+(w), tc.yCur+(h) ) + +/* Gets an image with width and height with left-top + * at current location. Returns image buffer. + */ +#define GetImage( w,h,buf) _getimage_w( tc.xCur, tc.yCur, \ + tc.xCur+(w), tc.yCur+(h), buf ) + +/* Puts the top-left corner of a specified image at current location + * using a specified action (_GPSET, _GPRESET, _GAND, _GOR, _GXOR). + */ +#define PutImage( buf, act ) _putimage_w( tc.xCur, tc.yCur, buf, act ) + +/* Fills starting at the current location and continues to border. */ +#define FillIn() _floodfill_w( tc.xCur, tc.yCur, tc.ciBorder ) + +/* Returns nonzero if the current location is onscreen. */ +#define OnScreen() (!((tc.xCur < -tc.xMax) || (tc.xCur > tc.xMax) || \ + (tc.yCur < -tc.yMax) || (tc.yCur > tc.yMax))) + +/* Returns a long int mixed from red, green, and blue bytes. */ +#define RGB( r,g,b) (((long)((b) << 8 | (g)) << 8) | (r)) + +/* Constants */ +#define CIRCUMFERENCE 360 +#define HALFCIRCUMFERENCE 180 + +#define DEFAULT -1 +#define LIMITED 0 +#define TRUE 1 +#define FALSE 0 +#define WHITE (tc.cci - 1) + +/* Structures for configuration and other data */ +typedef struct _TURTLE +{ + double yxRatio; /* Y to X aspect ratio */ + double xMax, yMax; /* Maximum x and y */ + double yUnit; /* Window size of one pixel */ + double xCur, yCur; /* Current position */ + short cci; /* Count of color indexes */ + short ccv; /* Count of color values */ + short ciCur; /* Current color index */ + short ciBorder; /* Current border color index */ + short angCur; /* Current angle */ + int fPenDown; /* Pen state */ + int fFill; /* Fill state */ + int fPalette; /* Palette availability */ + short xsLeft, xsRight; /* Absolute window corners */ + short ysTop, ysBot; +} TURTLE; +extern TURTLE tc; + +#endif /* TURTLE_H */ diff --git a/Microsoft C v6ax/SOURCE/STARTUP/CHKSTK.ASM b/Microsoft C v6ax/SOURCE/STARTUP/CHKSTK.ASM new file mode 100644 index 0000000..65d9290 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/CHKSTK.ASM @@ -0,0 +1,188 @@ + page ,132 + title chkstk - C stack checking routine +;*** +;chkstk.asm - C stack checking routine +; +; Copyright (c) 1985-1990 Microsoft Corporation, All Rights Reserved +; +;Purpose: +; Provides support for automatic stack checking in C procedures +; when stack checking is enabled. +; +;******************************************************************************* + +.xlist +?PLM=0 +?WIN=0 + +; +; The way this code is structured, the following switch combinations better +; not be defined. +; + +; +; The USE_EXTERN flag indicates whether this module will be the default +; stack checking module for the library or not. If so, the stack checking +; data and subroutines must be defined. If not, the data and subroutines +; are NOT defined (i.e., they are externals that reside in the default +; stack checking object). +; +ifdef MI_NEAR + memS equ 1 ; near version + xchkstk equ <_aNchkstk> + ifdef mem_m ; if the default memory model is + USE_EXTERNS equ 1 ; medium or large, then use externs + endif ; in this module + ifdef mem_l + USE_EXTERNS equ 1 + endif + +elseifdef MI_FAR + memM equ 1 ; far version + xchkstk equ <_aFchkstk> + ifdef mem_s ; if the default memory model is + USE_EXTERNS equ 1 ; small or compact, then use externs + endif ; in this module + ifdef mem_c + USE_EXTERNS equ 1 + endif + +else + include version.inc ; default version +endif + +include cmacros.inc +include msdos.inc + +.list + +sBegin data + assumes ds,data + +extrn _end:word ; stack bottom + +ifdef USE_EXTERNS +; Use the data that is in the default stack checking module. + + if sizeC + externCP _aaltstkovr ; alternate stack overflow + endif + + extrn STKHQQ:word + +else ;not USE_EXTERNS + + globalCP _aaltstkovr,-1 ; alternate stack overflow -- define always so + ; mixed model works + + public STKHQQ ; used by parasitic heap +ifdef FARSTACK + ;far stack has bottom at 0 + STKHQQ dw STACKSLOP ; initial value +else + STKHQQ dw dataoffset _end+STACKSLOP ; initial value +endif + +endif ;not USE_EXTERNS + +sEnd data + + +sBegin code +assumes ds,data +assumes cs,code + +externNP _amsg_exit ; write error and die + +page +;*** +;_chkstk - check stack upon procedure entry +; +;Purpose: +; Provide stack checking on procedure entry. +; +; [LLIBCDLL.LIB NOTE: Unlike other LLIBCDLL routines, DS != DGROUP +; when chkstk() is called.] +; +;Entry: +; AX = size of local frame +; +;Exit: +; SP = new stackframe if successful +; +;Uses: +; AX, BX, CX, DX +; +;Exceptions: +; Gives out of memory error and aborts if there is not enough +; stack space for the routine. +; +;******************************************************************************* + +ifndef USE_EXTERNS +; Define old label name in default model version +labelP +endif + +% labelP + +if sizeC + pop cx ; get return offset + pop dx ; get return segment +else + pop cx ; get return offset +endif + + mov bx,sp ; bp = current SP + + + sub bx,ax ; bx = new position + jc OMerr ; error - out of memory + + + + cmp bx,[STKHQQ] ; SP - AX : STKHQQ (for heap/stack) + jb OMerr ; error - out of memory + mov sp,bx ; set new stack pointer + + + + + +if sizeC + push dx ; push segment + push cx ; push offset +chkproc proc far + ret ; far return to dx:cx +chkproc endp +else + jmp cx ; return to cx +endif + +OMerr: +if sizeC + push dx ; user segment +endif + push cx ; user offset + + +if sizeC + mov ax,word ptr [_aaltstkovr] + inc ax + jnz altstkovr +endif + + + xor ax,ax + jmp _amsg_exit ; give stack overflow and die + + +if sizeC +altstkovr: + jmp [_aaltstkovr] ; Pascal/FORTRAN stack overflow +endif + + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/CHKSUM.ASM b/Microsoft C v6ax/SOURCE/STARTUP/CHKSUM.ASM new file mode 100644 index 0000000..7a17d2b --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/CHKSUM.ASM @@ -0,0 +1,152 @@ + page ,132 + title chksum - _nullcheck routine for C +;*** +;chksum.asm - _nullcheck routine for C +; +; Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; This routine is used to check for assignment through a null pointer. +; Memory at DGROUP:0 is checked for destructive assignments. This +; routine is not particularly effective in compact and large models. +; A stub may be provoded for this routine without affecting the +; behavior of a correctly written C program. +; +;******************************************************************************* + +?DF= 1 ; this is special for c startup +include version.inc +.xlist +include cmacros.inc +include rterr.inc +.list + +createSeg _TEXT, code, word, public, CODE, <> + +createSeg NULL, null, para, public, BEGDATA,DGROUP +createSeg _DATA, data, word, public, DATA, DGROUP + +createSeg HDR, nhdr, byte, public, MSG, DGROUP +createSeg MSG, nmsg, byte, public, MSG, DGROUP +createSeg PAD, npad, byte, common, MSG, DGROUP +createSeg EPAD, nepad, byte, common, MSG, DGROUP + +defGrp DGROUP ; define DGROUP + +codeOFFSET equ offset _TEXT: +dataOFFSET equ offset DGROUP: + + +sBegin null +assumes ds,data + +BIAS= 55h + +chkpt db 8 dup(0) ; for null pointer assignment + CHKSUM= 18h ; has to be correct or error + db 'MS Run-Time Library - Copyright (c) 1990, Microsoft Corp' +chkb db CHKSUM ; checksum byte + db 0 ; leaves al = 0 +chkln= $ - chkpt ; length to checksum + + public __anullsize ; label at end of null segment +labelB _anullsize + +sEnd null + +sBegin nmsg +assumes ds,data + + _RTERR _RT_NULLPTR, 'null pointer assignment', _RT_STANDARD + +sEnd + +sBegin npad +assumes ds,data + dw -1 +; no padding for now; +; MAX padding would be +; db 20 dup(0) +sEnd + +externP _NMSG_WRITE ; pascal calling +externP _FF_MSGBANNER ; pascal calling + +sBegin code +assumes cs,code +assumes ds,data + + +page +;*** +;_nullcheck - check-sum of start of DGROUP segment to detect null-ptr-assignmt. +; +;Purpose: +; _nullcheck cumulatively xor's all the bytes from ds:0 through 1 past end +; of copyright string, finally xor'ing an arbitrary non-zero constant. +; This is used to check if a null pointer has been written to. +; +; This version can be called as many times as the user wants. +; The function returns zero if the checksum is OK. +; +; Note that this checksum only detects (DS:0) null pointer assignments +; but not (0:0) null pointer assignments. +; +;Entry: +; Assumes DS points to the beginning of DGROUP. +; +;Exit: +; Returns : AX = 0 if no error; AX = 1 if error. +; +;Uses: +; BX,CX,DX,ES are destroyed. +; +;Exceptions: +; If _nullcheck check-sum fails, an error message is written +; to standard error, and the routine returns an error code (AX = 1). +; +;******************************************************************************* + +cProc _nullcheck,,<> +cBegin nogen ; no arguments - so no frame + + + push si + + xor si,si ; start at DS:0 + mov cx,chkln + xor ah,ah + cld + +chkloop: ; loop to 1 past end of copyrt. string + lodsb + xor ah,al ; accumulate xor total in AH + loop chkloop + + xor ah,BIAS ; XOR out the initial BIAS + jz setzero + + callcrt _FF_MSGBANNER ; (1) "\r\n" to stderr + ; (2) FORTRAN $DEBUG file/line + ; if _Fline is set (not in C) + ; (3) "run-time error" banner + mov ax,_RT_NULLPTR ; null pointer assignment message no. + push ax + callcrt _NMSG_WRITE ; write message out + mov ax,1 ; indicate error occurred + +; ax = 0 if the checksum is OK + +setzero: + pop si + + + + ret + +cEnd nogen + + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/CMACROS.INC b/Microsoft C v6ax/SOURCE/STARTUP/CMACROS.INC new file mode 100644 index 0000000..a73c33e --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/CMACROS.INC @@ -0,0 +1,922 @@ +comment $ +cmacros - assembly macros for interfacing to HHLs +(C)Copyright Microsoft Corp. 1984-1990 +$ +.xcref ??_out +??_out MACRO string +ifndef ?QUIET +%out string +endif +ENDM +if1 +outif MACRO name,defval,onmsg,offmsg +ifndef name +ifb +name=0 +else +name=defval +endif +endif +if name +name=1 +ifnb +??_out +endif +else +ifnb +??_out +endif +endif +endm +error MACRO msg +bug +%out E r r o r ----- msg +ENDM +??_out +outif memS,0, +outif memM,0, +outif memL,0, +outif memC,0, +outif memH,0, +memMOD= memS + memM + memL + memC + memH +if memMOD ne 1 +if memMOD eq 0 +memS= 1 +outif memS,0, +else +error +endif +endif +sizeC= memM + memL + memH +sizeD= memL + memC + (memH*2) +outif ?DF,0, +outif ?WIN,1, +outif ?PLM,1, +endif +.XCREF +.XCREF ?N,?AX,?AH,?AL,?BX,?BH +.XCREF ?BL,?CX,?CH,?CL,?DX,?DH +.XCREF ?DL,?SI,?DI,?ES,?DS,?BP +.XCREF ?SP,?SS,?CS +.XCREF ?RSL,?CPD,?argl,?argc,?BA +.XCREF ?ACB,???,?PO +.XCREF ?PAS,?PC +.XCREF Uconcat,mPush,mPop +.XCREF ?RI,?pp,?pp1,?al1 +.XCREF ?aD,?AP,?Atal,?pd,?dd,?dd1,?ex1 +.XCREF ?pg,?pg1,?aloc,?cs1,?cs2 +.XCREF ?lb1,?lblpu +.XCREF ?DF,?PLM,?WIN,?IA,?PU,?ADJ +.CREF +?RSL = 0 +?CPD = 0 +?ArgL = 0 +?ArgC = 0 +?BA = 0 +?ACB = 0 +??? = 0 +?PO = 0 +?PAS = 0 +?PC = 0 +?IA = 0 +?PU = 0 +?ADJ = 0 +?lblpu = 0 +?N = 0000000000000000B +?AX = 0000000000000011B +?AH = 0000000000000001B +?AL = 0000000000000010B +?BX = 0000000000001100B +?BH = 0000000000000100B +?BL = 0000000000001000B +?CX = 0000000000110000B +?CH = 0000000000010000B +?CL = 0000000000100000B +?DX = 0000000011000000B +?DH = 0000000001000000B +?DL = 0000000010000000B +?SI = 0000000100000000B +?DI = 0000001000000000B +?ES = 0000010000000000B +?DS = 0000100000000000B +?BP = 0001000000000000B +?SP = 0010000000000000B +?SS = 0100000000000000B +?CS = 1000000000000000B +uconcat macro n1,n2,o1,o2,p1,p2 +n1&n2 o1&o2 p1&p2 +endm +mpush macro rV +irp x, +if rV AND ?&&x +push x +endif +endm +endm +mpop macro rV +irp x, +if rV AND ?&&x +pop x +endif +endm +endm +SAVE macro rL +?RSL = 0 +?RI ?RSL, +endm +smashes macro n,rL +.xcref +.xcref ?SM&n +.cref +?SM&n = 0 +?RI ?SM&n, +endm +?RI macro n,rL +irp x, +ifdef ?&&x +n = n or ?&&x +endif +endm +endm +parmB macro nl +?pp <&nL>,,2,1 +endm +parmW macro nl +?pp <&nL>,,2,2 +endm +parmD macro nl +ife ?PLM +irp x, +?pp <&&x>,,0,4 +?pp ,,2,2 +?pp ,,2,2 +endm +else +irp x, +?pp ,,2,2 +?pp ,,2,2 +?pp <&&x>,,0,4 +endm +endif +endm +parmQ macro nl +?pp <&nL>,,8,8 +endm +parmT macro nl +?pp <&nL>,,10,10 +endm +if sizeC +parmCP macro nl +parmD +endm +else +parmCP macro nl +parmW +endm +endif +if sizeD +parmDP macro nl +parmD +endm +else +parmDP macro nl +parmW +endm +endif +?pp macro nL,t,l,s +if ?CPD +.xcref +ife ?PLM +irp x, +?pp1 x,,%?PO,%?adj,%(?PO+?adj) +?PO = ?PO + l +.xcref ?T&&x +?T&&x = s +endm +else +irp x, +?PO = ?PO + l +?pp1 x,,%?PO,%?adj,%(?PO+?adj) +.xcref ?T&&x +?T&&x = s +endm +endif +.cref +else +%out Parm(s) "&nl" declared outside proc def. +endif +endm +?pp1 macro n,t,o,a,b +ife ?PLM +n equ t ptr [bp+b] +else +n equ t ptr [bp+a+?PO-o] +endif +endm +localB macro nL +?aLoc <&nL>,,1,1,0 +endm +localW macro nL +?aLoc <&nL>,,2,2,1 +endm +localD macro nL +irp x, +?aLoc ,,2,2,1 +?aLoc ,,2,2,1 +?aLoc <&&x>,,0,4,1 +endm +endm +localQ macro nL +?aLoc <&nL>,,8,8,1 +endm +localT macro nL +?aLoc <&nL>,,10,10,1 +endm +if sizeC +localCP macro nL +localD +endm +else +localCP macro nL +localW +endm +endif +if sizeD +localDP macro nL +localD +endm +else +localDP macro nL +localW +endm +endif +localV macro n,a +?aLoc <&n>,,%(&a),0,1 +endm +?aLoc macro nL,t,l,s,a +if ?CPD +.xcref +??? = ??? + l +if a +??? = ((??? + 1) AND 0FFFEH) +endif +irp x, +?aL1 x,,%??? +.xcref ?T&&x +?T&&x = s +endm +.cref +else +%out Locals "&nl" declared outside procedure def. +endif +endm +?aL1 macro n,t,o +if ?IA +n equ t [bp-?IA-o] +else +n equ t [bp-o] +endif +endm +globalB macro n,i,s +?aD ,1 +?dd n,1,,,, +endm +globalW macro n,i,s +?aD ,2 +?dd n,1,,,, +endm +globalD macro n,i,s +?aD ,4 +?dd n,1,,
,, +endm +globalQ macro n,i,s +?aD ,8 +?dd n,1,,,, +endm +globalT macro n,i,s +?aD ,10 +?dd n,1,,
,, +endm +if sizeC +globalCP macro n,i,s +globalD n,, +endm +else +globalCP macro n,i,s +globalW n,, +endm +endif +if sizeD +globalDP macro n,i,s +globalD n,, +endm +else +globalDP macro n,i,s +globalW n,, +endm +endif +staticB macro n,i,s +?aD ,1 +?dd n,0,,,, +endm +staticW macro n,i,s +?aD ,2 +?dd n,0,,,, +endm +staticD macro n,i,s +?aD ,4 +?dd n,0,,
,, +endm +staticQ macro n,i,s +?aD ,8 +?dd n,0,,,, +endm +staticT macro n,i,s +?aD ,10 +?dd n,0,,
,, +endm +if sizeC +staticCP macro n,i,s +staticD n,, +endm +else +staticCP macro n,i,s +staticW n,, +endm +endif +if sizeD +staticDP macro n,i,s +staticD n,, +endm +else +staticDP macro n,i,s +staticW n,, +endm +endif +?dd macro n,p,t,d,i,s +ife ?PLM +n label t +?dd1 _&n,p,,, +else +?dd1 n,p,,, +endif +endm +?dd1 macro n,p,d,i,s +if p +PUBLIC n +endif +ifb +n d i +else +ifb +n d s DUP (?) +else +n d s DUP (i) +endif +endif +endm +externB macro nL +?ex1 <&nL>,1, +endm +externW macro nL +?ex1 <&nL>,2, +endm +externD macro nL +?ex1 <&nL>,4, +endm +externQ macro nL +?ex1 <&nL>,8, +endm +externT macro nL +?ex1 <&nL>,10, +endm +externNP macro nL +?ex1 <&nL>,2, +endm +externFP macro nL +?ex1 <&nL>,4, +endm +if sizeC +externP macro nL +?ex1 <&nL>,4, +endm +else +externP macro nL +?ex1 <&nL>,2, +endm +endif +if sizeC +externCP macro nL +?ex1 <&nL>,4, +endm +else +externCP macro nL +?ex1 <&nL>,2, +endm +endif +if sizeD +externDP macro nL +?ex1 <&nL>,4, +endm +else +externDP macro nL +?ex1 <&nL>,2, +endm +endif +?ex1 macro nL,s,d +irp x, +.xcref +.xcref ?T&&x +.cref +?T&&x = s +ife ?PLM +extrn _&&x:&d +x equ _&&x +else +extrn x:&d +endif +endm +endm +labelB macro nL +?lb1 <&nL>,1, +endm +labelW macro nL +?lb1 <&nL>,2, +endm +labelD macro nL +?lb1 <&nL>,4, +endm +labelQ macro nL +?lb1 <&nL>,8, +endm +labelT macro nL +?lb1 <&nL>,10, +endm +labelNP macro nL +?lb1 <&nL>,2, +endm +labelFP macro nL +?lb1 <&nL>,4, +endm +if sizeC +labelP macro nL +?lb1 <&nL>,4, +endm +else +labelP macro nL +?lb1 <&nL>,2, +endm +endif +if sizeC +labelCP macro nL +?lb1 <&nL>,4, +endm +else +labelCP macro nL +?lb1 <&nL>,2, +endm +endif +if sizeD +labelDP macro nL +?lb1 <&nL>,4, +endm +else +labelDP macro nL +?lb1 <&nL>,2, +endm +endif +?lb1 macro nL,s,d +?lblpu = 0 +irp x, +ifidn , +?lblpu = 1 +else +.xcref +.xcref ?T&&x +.cref +?T&&x = s +ife ?PLM +if ?lblpu +public _&&x +endif +_&&x label &d +x equ _&&x +else +if ?lblpu +public x +endif +x label &d +endif +endif +endm +endm +defB macro nL +?aD <&nL>,1 +endm +defW macro nL +?aD <&nL>,2 +endm +defD macro nL +?aD <&nL>,4 +endm +defQ macro nL +?aD <&nL>,8 +endm +defT macro nL +?aD <&nL>,10 +endm +if sizeC +defCP macro nL +defD +endm +else +defCP macro nL +defW +endm +endif +if sizeD +defDP macro nL +defD +endm +else +defDP macro nL +defW +endm +endif +?aD macro nL,s +irp x, +.xcref +.xcref ?T&&x +.cref +?T&&x = s +endm +endm +regPtr macro n,S,O +.xcref +.xcref ?T&n,?SR&n,?OR&n +.cref +?T&n = 0FFFFH +?SR&n = 0 +?RI ?SR&n,<&S> +?OR&n = 0 +?RI ?OR&n,<&O> +endm +arg macro aL +irp x, +?argc = ?argc + 1 +?Atal ,%?argc +endm +endm +?Atal macro n,i +.xcref +.xcref ?ALI&i +.cref +?ALI&i ¯o +?AP n +&endm +endm +?AP macro n +?argl = ?argl + 2 +ifdef ?T&n +ife ?T&n-1 +push word ptr (n) +exitm +endif +ife ?T&n-2 +push n +exitm +endif +ife ?T&n-4 +push word ptr (n)+2 +push word ptr (n) +?argl = ?argl + 2 +exitm +endif +ife ?T&n-8 +push word ptr (n)+6 +push word ptr (n)+4 +push word ptr (n)+2 +push word ptr (n) +?argl = ?argl + 6 +exitm +endif +ife ?T&n-0FFFFH +mpush %(?SR&n),1 +mpush %(?OR&n),1 +?argl = ?argl + 2 +exitm +endif +ife ?T&n +push word ptr (n) +exitm +endif +endif +push n +endm +ife ?PLM +ccall macro n,a,sleaze +ifnb +Arg +endif +ifdef ?SM&n +?RSL = ?RSL AND ?SM&n +endif +mpush %?RSL +?argl = 0 +?ACB = ?argc +rept ?argc +uconcat ,%?ACB +uconcat ,,,%?ACB +?ACB = ?ACB - 1 +endm +ife ?PLM +ifb +call _&n +else +call n +endif +else +call n +endif +if ?argl +add sp,?argl +endif +mpop %?RSL +?RSL = 0 +?argc = 0 +?argl = 0 +endm +else +ccall macro n,a +ifnb +Arg +endif +ifdef ?SM&n +?RSL = ?RSL AND ?SM&n +endif +mpush %?RSL +?argl = 0 +?ACB = 1 +rept ?argc +uconcat ,%?ACB +uconcat ,,,%?ACB +?ACB = ?ACB + 1 +endm +ife ?PLM +call _&n +else +call n +endif +mpop %?RSL +?RSL = 0 +?argc = 0 +?argl = 0 +endm +endif +cProc macro n,cl,s +?pd n,,,4 +endm +?pd macro n,c,a,i +if ?CPD +?UTPE +endif +?CPD = 1 +??? = 0 +?argc = 0 +?BA = 0 +?PO = 0 +?PU = 0 +?IA = 0 +?adj = i +?PAS = 0 +ifnb +?RI ?PAS, +endif +?PC = sizeC +irp x, +ifidn , +?PC = 1 +endif +ifidn , +?PC = 0 +endif +ifidn , +?PU = 1 +endif +endm +if ?PC +if ?WIN +?IA = 2 +endif +?adj = ?adj + 2 +endif +ife ?PLM +ife ?PC +n label near +else +n label far +endif +?pg <_&n>,%?PU,%?PC,%?PAS +else +?pg ,%?PU,%?PC,%?PAS +endif +endm +?pg macro n,p,c,a +.xcref +cBegin ¯o g +.xcref +?pg1 ,c,a,%?PO +?CPD = 0 +?argc = 0 +?BA = 1 +??? = (???+1) AND 0FFFEH +if p +PUBLIC n +endif +ife c +n proc NEAR +else +n proc FAR +endif +ifidn , +if ???+?PO+a +??_out +endif +else +if ?IA +mov ax,ds +nop +inc bp +push bp +mov bp,sp +push ds +mov ds,ax +else +push bp +mov bp,sp +endif +if ??? +sub sp,??? +endif +mPush a,1 +endif +.cref +purge cBegin +&endm +?UTPE ¯o +%out Unterminated Procedure Definition: "&n" +&endm +endm +?pg1 macro n,c,a,o +.xcref +cEnd ¯o g +.xcref +?BA = 0 +ifidn , +if o+a +??_out +endif +else +mPop a,1 +if ?IA +sub bp,2 +mov sp,bp +pop ds +pop bp +dec bp +else +ifdif , +mov sp,bp +endif +pop bp +endif +ife ?PLM +ret +else +ret o +endif +endif +n endp +.cref +purge cEnd +&endm +.cref +endm +assumes macro s,g +local assumed +assumed = 0 +ifidn , +assume s&:_TEXT +assumed = 1 +endif +ifidn , +assume s&:_TEXT +assumed = 1 +endif +ifidn , +assume s&:dgroup +assumed = 1 +endif +ifidn , +assume s&:dgroup +assumed = 1 +endif +ife assumed +assume s&:&g +endif +endm +createSeg macro n,ln,a,co,cl,grp +ifnb +addSeg grp,n +endif +ifnb +n segment a co '&cl' +else +n segment a co +endif +n ends +?cs1 , +endm +if1 +ASMpass=1 +else +ASMpass=2 +endif +addSeg macro grp,seg +ifndef def_&grp +def_&grp= 0 +endif +if def_&grp ne ASMpass +add_&grp ¯o s +in_&grp ,s +&endm +in_&grp ¯o sl,s +ifb +grp group sl +else +add_&grp ¯o ns +in_&grp ,ns +&endm +endif +&endm +def_&grp=ASMpass +else +add_&grp seg +endif +endm +defGrp macro nam +addSeg nam +endm +?cs1 macro n,ln +begin&ln ¯o +?cs2 +n segment +&endm +endm +?cs2 macro n +sEnd ¯o +n ends +&endm +endm +sBegin macro ln +begin&ln +endm +ife ?DF +createSeg _TEXT,code,word,public,CODE +createSeg _DATA,data,word,public,DATA,DGROUP +defGrp DGROUP +codeOFFSET equ OFFSET _TEXT: +dataOFFSET equ OFFSET DGROUP: +endif +errnz macro x +if2 +if x +errnz1 ,%(x) +endif +endif +endm +errnz1 macro x1,x2 += *ERRNZ* x1 = x2 +endm +errn$ macro l,x +errnz +ENDM + +; Extra macros for the c-runtime package +; +; Macro for calling another run-time-library function. +; Does a PUSH CS/CALL NEAR in compact/large models, except +; for QuickC. --PHG, 5-24-89 + +callcrt MACRO funcname +ifdef _QC2 + call funcname +else + if sizeC + push cs + call near ptr (funcname) + else + call funcname + endif +endif +ENDM diff --git a/Microsoft C v6ax/SOURCE/STARTUP/CRT0FP.ASM b/Microsoft C v6ax/SOURCE/STARTUP/CRT0FP.ASM new file mode 100644 index 0000000..602420d --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/CRT0FP.ASM @@ -0,0 +1,94 @@ + page ,132 + title crt0fp - floating point not loaded trap +;*** +;crt0fp.asm - floating point not loaded trap +; +; Copyright (c) 1986-1990, Microsoft Corporation, All Rights Reserved +; +;Purpose: +; To trap certain cases where certain necessary floating-point +; software is not loaded. Two specific cases are when 87.LIB +; is linked in but no coprocessor is present, and when floating +; point i/o conversions are done, but no floating-point variables +; or expressions are used in the program. +; +;******************************************************************************* + +?DF= 1 ; this is special for c startup +include version.inc +.xlist +include cmacros.inc +include rterr.inc +.list + +createSeg _TEXT, code, word, public, CODE, <> +createSeg _DATA, data, word, public, DATA, DGROUP + +createSeg HDR, nhdr, byte, public, MSG, DGROUP +createSeg MSG, nmsg, byte, public, MSG, DGROUP +createSeg PAD, npad, byte, common, MSG, DGROUP +createSeg EPAD, nepad, byte, common, MSG, DGROUP + +defGrp DGROUP ; define DGROUP + + +; Messages used by _fptrap + +sBegin nmsg +assumes ds,data + + _RTERR _RT_FLOAT, 'floating-point support not loaded', _RT_STANDARD + +sEnd + +sBegin npad +assumes ds,data + dw -1 +; no padding for now; +; MAX padding would be +; db 22 dup(0) +sEnd + +sBegin code +assumes cs,code + +externNP _amsg_exit + +page +;*** +;_fptrap - trap for missing floating-point software +; +;Purpose: +; Catches these cases of incomplete f.p. software linked into a program. +; +; (1) 87.LIB chosen, but no coprocessor present; +; (i.e., emulator not linked) +; +; (2) "%e", "%f", and "%g" i/o conversion formats specified, but +; not all conversion software has been linked in, because the +; program did not use any floating-point variables or expressions. +; +;Entry: +; None. +; +;Exit: +; None. +; +;Uses: +; AX. +; +;Exceptions: +; Transfers control to _amsg_exit which ... +; - Writes error message to standard error: "floating point not loaded"; +; - Terminates the program by calling _exit(). +;******************************************************************************* + +labelNP + + + mov ax,_RT_FLOAT ; issue floating point not loaded + jmp _amsg_exit ; and die + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0.ASM new file mode 100644 index 0000000..7ad9320 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0.ASM @@ -0,0 +1,591 @@ + page ,132 + title crt0 - C start up routine +;*** +;crt0.asm - C start up routine +; +; Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; How startup works in a few words - +; +; The startup and termination is performed by a few modules +; +; crt0.asm DOS 2.x/3.x specific init/term +; crt0msg.asm DOS 2.x/3.x error messages +; (winstart.asm) Windows specific init/term (not included) +; +; crt0dat.asm remainder of shared DOS 3.x init/term +; +; ************* IMPORTANT ***************************************** +; +; The "DOSSEG" directive in this module must not be removed or else +; the user will have to link with the "/DOSSEG" linker switch in +; order to get proper segment ordering. +; +; See the C documentation for more information about the /DOSSEG switch. +; +; All assembler modules must be assembled with the /Mx switch, i.e. +; +; masm -Mx crt0,; +; +; .COM Files: +; (1) Start at location 0x100 +; (2) No stack segment +; (3) All segments grouped together +; (4) All seg registers the same at _astart. +; +;******************************************************************************* + +;*******************************;* + DOSSEG ;* specifies DOS SEGment ordering * +;*******************************;* + +?DF= 1 ; this is special for c startup + +.xlist +include version.inc + +include cmacros.inc +include msdos.inc +include heap.inc +include rterr.inc +.list + +ifdef FARSTACK +ife sizeD + error +endif +endif + +ifdef _COM_ + if sizeC or sizeD + error + endif +endif ;_COM_ + + page +;=========================================================================== +; +; Segment definitions +; +; The segment order is essentially the same as in XENIX. +; This module is edited after assembly to contain a dosseg comment +; record for the linker. +; +;=========================================================================== + +createSeg _TEXT, code, word, public, CODE, <> +createSeg C_ETEXT,etext, word, public, ENDCODE,<> + +createSeg _DATA, data, word, public, DATA, DGROUP + +createSeg XIQC, xiqcseg, word, common, DATA, DGROUP + +ifndef _COM_ +ifdef FARSTACK +; This segment has STACK class so it is at the end of DGROUP; it is the first +; entry in the near heap. +createSeg NEARHEAP, stubheap, para, <>, STACK, DGROUP +; Here is the real stack, not in DGROUP +createSeg STACK, stack, para, stack, STACK, <> +else ; not FARSTACK +createSeg STACK, stack, para, stack, STACK, DGROUP +endif ;FARSTACK +endif + +ifdef _COM_ +DGROUP group _TEXT, C_ETEXT, _DATA ; define DGROUP +else +defGrp DGROUP ; define DGROUP +endif + +codeOFFSET equ offset _TEXT: +dataOFFSET equ offset DGROUP: + + +page + +public __acrtused ; trick to force in startup + __acrtused = 9876h ; funny value not easily matched in SYMDEB + +extrn __acrtmsg:abs ; trick to pull in startup messages + + +_STACK_SIZE = 2048 ; Default stack size = 2K + +ifndef _COM_ +sBegin stack +assumes ds,data + db _STACK_SIZE dup (?) ; stack space +sEnd +endif ;_COM_ + +ifdef FARSTACK +; Set up the first entry in the near heap +sBegin stubheap + stubheap_size dw 1 ; 0-length free entry + stubheap_next dw _HEAP_END ; mark end of heap +sEnd +endif ;FARSTACK + +page + +externP main ; C main program + +externP exit ; exit ( code ) + +if sizeC +extrn __exit:far ; _exit ( code) (cmacros name conflict) +else +extrn __exit:near +endif + + +createSeg DBDATA, dbdata, word, common, DATA, DGROUP ;* +defGrp DGROUP ;* +sBegin dbdata ; Debugger Screen swap setup segment +assumes ds,data +globalW __aDBswpflg,0 ;* Flag == __aDBswpyes if should attempt swapping +globalW __aDBswpchk,___aDBretaddr ;* By default points to a model dependent ret +globalW __aDBrterr,___aDBretaddr ;* +globalW __aDBexit,___aDBretaddr ;* (Report we are exiting) +staticD __aDBcallbk,0 ;* Call back address to debugger +ifdef _COM_ +globalW __aDBptrchk,0 +else +globalW __aDBptrchk,C_ETEXT +endif +sEnd + public __aDBdoswp +__aDBdoswp = 0d6d6h + +sBegin xiqcseg +externW __qczrinit ;* QC -Zr initializer call address +sEnd + +sBegin data + +extrn _edata:byte ; end of data (start of bss) +extrn _end:byte ; end of bss (start of stack) + +externW _psp ; psp:0 (paragraph #) +externW __argc +externDP __argv +externDP environ + +; these are used by DOS C memory management (not used in Windows) + +globalW _atopsp,0 ; top of stack (heap bottom) +globalW _aexit_rtn, ; NEAR pointer + +;* +;* The following (_asizds and _nheap_desc) must be in this order! +;* + +globalW _asizds,0 ; DGROUP size - 1 (in bytes) + +labelW ; near heap descriptor +_heap_seg_desc <0,_HEAP_NEAR OR _HEAP_MODIFY, 0,0,0,0,0,0> +.ERRE flags eq 2 ; flags better be second word + +.ERRE _asizds+2 EQ _nheap_desc ; make sure! + +; Heap segment limits (for use with QC) + +globalW _aseghi,0 ; highest heap segment so far +globalW _aseglo,0 ; lowest allowable heap segment + + + + +sEnd + + page + + +externP _cinit ; run-time initializers + +externP _NMSG_WRITE ; pascal - write error message to stdout +externP _FF_MSGBANNER ; pascal - error message banner + ; (includes FORTRAN $DEBUG info) + +externP _setargv ; process command line arguments +externP _setenvp ; process environment + + +sBegin code +assumes cs,code + +assumes ds,nothing + + +page +;*** +;_astart - start of all C programs +; +;Purpose: +; Startup routine to initialize C run-time environment +; +;Entry: +; +;Exit: +; Exits to DOS via exit(). +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +ifdef _COM_ + org 0100h ; .COM files start at 0100h +endif + +labelNP ; start address of all "C" programs + +; check MS-DOS version for 2.0 or later + + callos VERSION ; AX must be preserved until later + cmp al,2 ; check for version 2 or later + jae setup ; yes - continue with setup +ifdef _COM_ ; DOS puts 0 on stack for .COM files + retn ; DOS 1.0 exit program (int 20h at psp:0) +else ; _COM_ + xor ax,ax + push es ; push warm start vector es:ax = psp:0 + push ax + retf ; DOS 1.0 exit program (int 20h at psp:0) +endif ; _COM_ + +setup: + +ifdef _COM_ + mov di,ds ; di = DGROUP + mov si,ds:[DOS_MAXPARA] ; get max. paragraph +else + mov di,DGROUP ; di = DGROUP + mov si,ds:[DOS_MAXPARA] ; get max. paragraph +endif ;_COM_ + +ifdef _COM_ + mov cs:[_dataseg],di ; save dgroup for future +endif + + sub si,di ; si = # para in data area + cmp si,1000h ; if more than 64K + jb setSP + + mov si,1000H ; use full 64K (-16) + +setSP: + +ifdef _COM_ + ; + ; .COM files - allocate stack (-2 for _asizds limit) + ; [Do the calculation in a temp register in case it overflows.] + ; + mov ax,dataoffset _end ; go to end of DGROUP + add ax,(_STACK_SIZE-2) ; stack is beyond that + jnc SPok ; jump out if stack ok (ax = new sp) + ;fall thru ; error - not enough stack space + +else + +ifdef FARSTACK + jmp short SPok ; stack can't be too big, if .EXE was loaded +else ;no FARSTACK + cli ; turn off interrupts + mov ss,di ; SS = DGROUP + add sp,dataoffset _end-2 ; 2 for _asizds limit + sti ; turn interrupts back on + jnc SPok + + push ss ; establish DS=DGROUP for + pop ds ; _FF_MSGBANNER -> _NMSG_WRITE -> _NMSG_TEXT +endif ;FARSTACK + +endif ;_COM_ + +; +; Error - Not enough stack space +; + + callcrt _FF_MSGBANNER ; for "\r\nrun-time error " banner + xor ax,ax ; stack overflow error message (_RT_STACK=0) + push ax + callcrt _NMSG_WRITE + mov ax,DOS_terminate shl 8 + 255 + callos ; terminate process with 255 + +SPok: + +ifdef _COM_ + ; ax = new sp value + mov sp,ax ; set new sp value +endif + +ifdef FARSTACK + mov ds, di ; reload dgroup + assumes ds, data +else + assumes ss,data +endif + + +ifdef _COM_ ;* Setup __aDBptrchk for com programs + mov __aDBptrchk,cs ;* +endif ;_COM_ + +; at this point: +; COM files: DS = DI = ES = SS = DGROUP +; EXE files: DI = SS = DGROUP, DS = ES = PSP +; FARSTACK: DI = DS = DGROUP, ES = PSP, SS = STACK + +; +; Save size of dgroup +; + + mov ax,si ; si = # paragraphs in dgroup + mov cl,4 + shl ax,cl ; ax = size of dgroup (bytes) + dec ax ; ax = size DGROUP - 1 + mov [_asizds],ax ; Size of Global Data Segment + +; +; Carve an initial near heap out of the bottom of the stack +; + +ifdef FARSTACK + ; for far stacks, we use the dummy subheap segment instead + mov bx,dataoffset _nheap_desc ; ds:bx = near heap descriptor + mov [bx].checksum,ds ; save dgroup in near heap desc + mov [bx].segsize, dataOFFSET(stubheap_next) + 2 + mov [bx].last, dataOFFSET(stubheap_next) + mov [bx].start, dataOFFSET(stubheap_size) + mov [bx].rover, dataOFFSET(stubheap_size) + +else + mov bx,dataoffset _nheap_desc ; ss:bx = near heap descriptor + mov ss:[bx].checksum,ss ; save dgroup in near heap desc + + and sp,not 1 ; make even (if not) + mov ss:[bx].segsize,sp ; save as segment size + + .ERRE _HEAP_END -2 ; make sure they're equal + mov ax,_HEAP_END ; get end-of-heap flag + push ax ; into place + mov ss:[bx].last,sp ; pointer to end-of-heap + not ax ; ax = 1 (0-length free entry) + push ax ; first heap entry + mov ss:[bx].start,sp; init start/rover + mov ss:[bx].rover,sp +endif + +; +; Now initialize the top of stack location +; + + mov [_atopsp],sp ; Top of Stack Region + +; release extra space to DOS + + add si,di ; si = DGROUP + # para in DGROUP +ifdef FARSTACK + ; at this point es still has the psp address + mov es:[DOS_MAXPARA],si ; fix psp:2 +else + mov ds:[DOS_MAXPARA],si ; fix psp:2 +endif + + mov bx,es ; bx = PSP base + sub bx,si ; bx = - # para used + neg bx + callos setmem ; set memory block size +ifdef FARSTACK + ; for FARSTACK, es has the psp address, ds = DGROUP + mov [_psp],es +else + ; no FARSTACK, ds = psp, ss = DGROUP + mov [_psp],ds ; save psp:0 +endif + +; zero data areas (_BSS and c_common) + +ifdef FARSTACK + push ds + pop es ; ES = DGROUP + assumes es, data +else + +ifndef _COM_ + push ss + pop es ; ES = DGROUP +endif ;_COM_ + assumes es,data + +endif ;FARSTACK + +; at this point: +; COM files: DS = ES = SS = DGROUP +; EXE files: SS = ES = DGROUP, DS = PSP +; FARSTACK: DS = ES = DGROUP, SS = STACK + + cld ; set direction flag (up) + mov di,dataOFFSET _edata ; beginning of bss area + mov cx,dataOFFSET _end ; end of bss area + sub cx,di + xor ax,ax + rep stosb ; zero bss + + +; C segmentation conventions set up here (DS=SS and CLD) + +ifndef _COM_ +ifndef FARSTACK + push ss ; set up initial DS=ES=SS, CLD + pop ds +endif ;FARSTACK +endif ;_COM_ + assumes ds,data + +; OK, we now have DS = ES = DGROUP for all models, and SS = DGROUP +; except for the far stack model. + +; Must run this initializer prior to any far heap allocations being +; done. This means that we have hack-ed this in here. There should +; be a better solution for C7 + + mov cx,__qczrinit ;* Get initializer addr + jcxz @F ;* Is it zero? + call cx ;* No -- call indirect through +@@: + +; process command line and environment + + call _setenvp ; crack environment + call _setargv ; crack command line + +; +; Zero bp for debugging backtrace support (i.e., mark top-of-stack). +; + + xor bp,bp ; mark top stack frame for SYMDEB + +; do necessary initialization + + call _cinit ; shared by DOS and Windows + +ifndef _COM_ +ifdef FARSTACK + mov ax, DGROUP + mov ds, ax ; ds = DGROUP +else + push ss + pop ds ; ds = DGROUP +endif ;FARSTACK +endif ;_COM_ + assumes ds,data + +; call main and exit + +if sizeD + push word ptr [environ+2] ; the environment is not always in DS +endif + push word ptr [environ] + +if sizeD + push word ptr [__argv+2] ; the arguments are not always in DS +endif + push word ptr [__argv] + + push [__argc] ; argument count + + call main ; main ( argc , argv , envp ) + +; use whatever is in ax after returning here from the main program + + push ax + callcrt exit ; exit (AX) + ; _exit will call terminators + +___aDBretaddr: ; label to appropriate "RET" + ret ; Default dbdata address + + +page +;*** +;_amsg_exit, _cintDIV - Fast exit fatal errors +; +;Purpose: +; Exit the program with error code of 255 and appropriate error +; message. cintDIV is used for integer divide by zero, amsg_exit +; is for other run time errors. +; +;Entry: +; AX = error message number (amsg_exit only). +; +;Exit: +; calls exit() [cintDIV] or indirect through _aexit_rtn [amg_exit]. +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +labelNP + + assumes ds,nothing +ifndef FARSTACK + assumes ss,data +endif + +; _cintDIV establishes ds = DGROUP + + mov ax,cs:[_dataseg] ; reestablish DS=DGROUP + mov ds, ax +ifdef FARSTACK + assumes ds, data +endif + + mov ax,_RT_INTDIV ; Integer divide by zero interrupt + mov [_aexit_rtn],codeoffset _exit ; call high-level exit() + ; to cause file buffer flushing + +labelNP + + push ax ; message number for _NMSG_WRITE + callcrt _FF_MSGBANNER ; run-time error message banner + callcrt _NMSG_WRITE ; write error message to stdout + + cmp __aDBswpflg,__aDBdoswp ;* Aware debugger as parent? + jne @F ;* No -- skip + pop ax + push ax + call __aDBrterr ;* Yes -- report a runtime error +@@: + + assumes ds,data + + mov ax,255 + push ax +if sizeC + push cs ; _exit is compiled far + ; but called near +endif + call word ptr [_aexit_rtn] ; _exit(255) ordinarily + ; (or exit(255) for div by 0) + ; NEAR routine pointer + +; Location that holds DGROUP segment (necessary for .COM file support) + +ifdef _COM_ +globalW _dataseg,0 ; will hold DGROUP + +else ;not _COM_ +globalW _dataseg,DGROUP + +endif ;not _COM_ + +sEnd + end _astart ; start address diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0DAT.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0DAT.ASM new file mode 100644 index 0000000..620d7a3 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0DAT.ASM @@ -0,0 +1,916 @@ + page ,132 + title crt0dat - DOS and Windows shared startup and termination +;*** +;crt0dat.asm - DOS and Windows shared startup and termination +; +; Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; Shared startup and termination. +; +; NOTE: This source is included in crt0.asm for assembly purposes +; when building .COM startup. This is so the .COM startup resides +; in a single special object that can be supplied to the user. +; +;******************************************************************************* + +_NFILE_ = 20 ; Maximum number of file handles + +?DF = 1 ;; tell cmacros.inc we want to define our own segments + +.xlist +include version.inc +include cmacros.inc +include msdos.inc +.list + +ifdef FARSTACK +ife sizeD +error +endif +endif + +ifdef _COM_ + if sizeC or sizeD + error + endif +endif ;_COM_ + +createSeg _TEXT, code, word, public, CODE, <> +createSeg CDATA, cdata, word, common, DATA, DGROUP +createSeg _DATA, data, word, public, DATA, DGROUP + +createSeg DBDATA, dbdata, word, common, DATA, DGROUP + +createSeg XIQC, xiqcseg, word, common, DATA, DGROUP ; QC initializer -Zr (DOS only) + +createSeg XIFB, xifbseg, word, public, DATA, DGROUP +createSeg XIF, xifseg, word, public, DATA, DGROUP ; far init's +createSeg XIFE, xifeseg, word, public, DATA, DGROUP + +createSeg XIB, xibseg, word, public, DATA, DGROUP +createSeg XI, xiseg, word, public, DATA, DGROUP ; init's +createSeg XIE, xieseg, word, public, DATA, DGROUP + +createSeg XOB, xobseg, word, public, BSS, DGROUP +createSeg XO, xoseg, word, public, BSS, DGROUP ; onexit table +createSeg XOE, xoeseg, word, public, BSS, DGROUP + +createSeg XPB, xpbseg, word, public, DATA, DGROUP +createSeg XP, xpseg, word, public, DATA, DGROUP ; preterm's +createSeg XPE, xpeseg, word, public, DATA, DGROUP + +createSeg XCB, xcbseg, word, public, DATA, DGROUP +createSeg XC, xcseg, word, public, DATA, DGROUP ; term's +createSeg XCE, xceseg, word, public, DATA, DGROUP + +createSeg XCFB, xcfbseg, word, public, DATA, DGROUP +createSeg XCF, xcfseg, word, public, DATA, DGROUP ; far term's +createSeg XCFE, xcfeseg, word, public, DATA, DGROUP + +ifdef _COM_ +createSeg EMULATOR_DATA, EmData, para, public, FAR_DATA, DGROUP +createSeg EMULATOR_TEXT, EmCode, para, public, CODE, DGROUP +endif ;_COM_ + +defGrp DGROUP ; define DGROUP + +codeOFFSET equ offset _TEXT: +dataOFFSET equ offset DGROUP: + +page +sBegin xifbseg +xifbegin label byte +sEnd xifbseg + +sBegin xifeseg +xifend label byte +sEnd xifeseg + +sBegin xibseg +xibegin label byte +sEnd xibseg + +sBegin xieseg +xiend label byte +sEnd xieseg + +sBegin xobseg +xontab label byte ; start of onexit table +sEnd xobseg + +sBegin xoeseg +xonend label byte +sEnd xoeseg + +sBegin xpbseg +xpbegin label byte ; end of onexit table +sEnd xpbseg + +sBegin xpeseg +xpend label byte +sEnd xpeseg + +sBegin xcbseg +xcbegin label byte +sEnd xcbseg + +sBegin xceseg +xcend label byte +sEnd xceseg + +sBegin xcfbseg +xcfbegin label byte +sEnd xifbseg + +sBegin xcfeseg +xcfend label byte +sEnd xcfeseg + +sBegin cdata ; floating point setup segment +assumes ds,data + + dw 0 ; force segment to be at least 0's +labelD ; public for signal +fpmath dd 1 dup (?) ; linking trick for fp +fpdata dd 1 dup (?) +fpsignal dd 1 dup (?) ; fp signal message + +sEnd + + +sBegin dbdata ;* + assumes ds,data ;* Used to do the running under +externW __aDBswpflg ;* a debugger screen swapping +externW __aDBexit ;* +sEnd dbdata ;* + extrn __aDBdoswp:ABS ;* + +sBegin xiqcseg +globalW __qczrinit, 0 ;* QC -Zr initializer call address +sEnd xiqcseg + + +ifdef _COM_ + sBegin EmData + labelB _EmDataLabel + sEnd EmData + + sBegin EmCode + globalW _EmDataSeg,0 + sEnd EmCode + +else ;not _COM + EMULATOR_DATA segment para public 'FAR_DATA' + EMULATOR_DATA ends + + EMULATOR_TEXT segment para public 'CODE' + + public __EmDataSeg + __EmDataSeg dw EMULATOR_DATA + + EMULATOR_TEXT ends +endif ;not _COM_ + +sBegin data +assumes ds,data + +; special C environment string + + labelB + cfile db '_C_FILE_INFO=' + cfilex db 0 + cfileln = cfilex-cfile + +globalD _aintdiv,0 ; divide error interrupt vector save + +globalT _fac,0 ; floating accumulator +globalW errno,0 ; initial error code +globalW _umaskval,0 ; initial umask value + +;=============== following must be in this order + +globalW _pspadr,0 ; psp:0 (far * to PSP segment) +globalW _psp,0 ; psp:0 (paragraph #) + +;=============== above must be in this order + +;=============== following must be in this order + +labelW +labelB +globalB _osmajor,0 +labelB +globalB _osminor,0 + +;=============== above must be in this order + + +globalB _osmode,0 ; 0 = real mode + +labelW +globalW _doserrno,0 ; initial DOS error code + +globalW _nfile,_NFILE_ ; maximum number of file handles + +labelB + db 3 dup (FOPEN+FTEXT) ; stdin, stdout, stderr + db 2 dup (FOPEN) ; stdaux, stdprn + db _NFILE_-5 dup (0) ; the other 15 handles + + +globalW __argc,0 +globalDP __argv,0 +globalDP environ,0 ; environment pointer + +labelD ; pointer to program name + dw dataOFFSET dos2nam +ifdef _COM_ + dw 0 ; No relocations in tiny model +elseifdef _QC2 + dw 0 ; No DGROUP references allowed +elseifdef _WINDOWS + dw 0 ; No DGROUP references allowed +else ;DEFAULT + dw DGROUP +endif + +dos2nam db 0 ; dummy argv[0] for DOS 2.X + + +; signal related common data + +globalW _child,0 ; flag used to handle signals from child process + +;Overlay related data + +globalB _ovlflag,0 ;Overlay flag (0 = no overlays) +globalB _intno,0 ;Overlay interrupt value (e.g., 3F) +globalD _ovlvec,0 ;Address of original overlay handler + + +sEnd data + +page +externNP _fptrap + +externP _cintDIV + +externP _nullcheck + +ifdef FARSTACK +endif + +sBegin code +assumes cs,code + +if sizeC +global proc far +endif + +page +;*** +;_cinit - C initialization +; +;Purpose: +; This routine performs the shared DOS and Windows initialization. +; The following order of initialization must be preserved - +; +; 1. Integer divide interrupt vector setup +; 2. Floating point initialization +; 3. Copy ;C_FILE_INFO into _osfile +; 4. Check for devices for file handles 0 - 4 +; 5. General C initializer routines +; +;Entry: +; +;Exit: +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +cProc _cinit,,<> + +cBegin ; no local frame to set up in standard libs + +assumes ds,data +ifndef FARSTACK +assumes ss,data +endif + +; +; Initialize the DGROUP portion of _pgmptr. We must do this at +; runtime since there are no load-time fixups in .COM files. +; +ifdef _COM_ + mov word ptr [_pgmptr+2],ds ; init seg portion of _pgmptr +endif ;_COM_ + + +; *** Increase File Handle Count *** +; +; (1) This code only works on DOS Version 3.3 and later. +; (2) This code is intentially commented out; the user must enable +; this code to access more than 20 files. +; +; mov ah,67h ; system call number +; mov bx,_NFILE_ ; number of file handles to allow +; callos ; issue the system call +; ;check for error here, if desired (if carry set, AX equals error code) +; +; *** End Increase File Handle Count *** + + +; 1. Integer divide interrupt vector setup + + mov ax,DOS_getvector shl 8 + 0 + callos ; save divide error interrupt + mov word ptr [_aintdiv],bx + mov word ptr [_aintdiv+2],es + + push cs + pop ds + assumes ds,nothing + mov ax,DOS_setvector shl 8 + 0 + mov dx,codeOFFSET _cintDIV + callos ; set divide error interrupt + push ss + pop ds + assumes ds,data + +; 2. Floating point initialization + +if memS + cmp word ptr [fpmath], 0 ; Note: make sure offset __fpmath != 0 + je nofloat_i + + mov word ptr [fpmath+2], cs ; fix up these far addresses + mov word ptr [fpsignal+2], cs ; in the small model math libs + + ifdef _COM_ + mov [_EmDataSeg], cs + mov ax, offset DGROUP:_EmDataLabel + sub ax, offset EMULATOR_DATA:_EmDataLabel + mov cl, 4 + shr ax, cl + add [_EmDataSeg], ax + endif ;_COM_ + +else ;not memS + mov cx,word ptr [fpmath+2] + jcxz nofloat_i +endif ;not memS + + mov es,[_psp] ; psp segment + mov si,es:[DOS_ENVP] ; environment segment +ifdef FARSTACK + mov ax, word ptr [fpdata] + mov dx, word ptr [fpdata+2] +else + lds ax,[fpdata] ; get task data area + assumes ds,nothing + mov dx,ds ; into dx:ax +endif + xor bx,bx ; (si) = environment segment + call [fpmath] ; fpmath(0) - init +ifdef FARSTACK + mov ax, DGROUP + mov ds, ax +endif + jnc fpok + +ifndef FARSTACK + push ss ; restore ds from ss + pop ds +endif + jmp _fptrap ; issue "Floating point not loaded" + ; error and abort + +fpok: +ifdef FARSTACK + mov ax, word ptr [fpsignal] + mov dx, word ptr [fpsignal+2] +else + lds ax,[fpsignal] ; get signal address + assumes ds,nothing + mov dx,ds +endif + mov bx,3 + call [fpmath] ; fpmath(3) - set signal address +ifdef FARSTACK + mov ax, DGROUP + mov ds, ax ; restore DS=DGROUP +else + push ss + pop ds + assumes ds,data +endif + +nofloat_i: + +; 3. Copy _C_FILE_INFO= into _osfile + +; fix up files inherited from parent using _C_FILE_INFO= + + mov es,[_psp] ; es = PSP + mov cx,word ptr es:[DOS_envp] ; es = user's environment + jcxz nocfi ; no environment !!! + mov es,cx + xor di,di ; start at 0 + +cfilp: + cmp byte ptr es:[di],0 ; check for end of environment + je nocfi ; yes - not found + mov cx,cfileln + mov si,dataOFFSET cfile + repe cmpsb ; compare for '_C_FILE_INFO=' + je gotcfi ; yes - now do something with it + mov cx,07FFFh ; environment max = 32K + xor ax,ax + repne scasb ; search for end of current string + jne nocfi ; no 00 !!! - assume end of env. + jmp cfilp ; keep searching + +; found _C_FILE_INFO= and transfer info into _osfile + +gotcfi: + push es + push ds + pop es ; es = DGROUP + pop ds ; ds = env. segment + assumes ds,nothing + assumes es,data + mov si,di ; si = startup of _osfile info + mov di,dataOFFSET _osfile ; di = _osfile block + + mov cl, 4 + +osfile_lp: + lodsb + sub al, 'A' + jb donecfi + shl al, cl + xchg dx, ax + + lodsb + sub al, 'A' + jb donecfi + or al, dl + stosb + jmp short osfile_lp + +donecfi: +ifdef FARSTACK + push es +else + push ss +endif + pop ds ; ds = DGROUP + assumes ds,data + +nocfi: + + + +; 4. Check for devices for file handles 0 - 4 +; +; Clear the FDEV bit (which might be inherited from C_FILE_INFO) +; and then call DOS to see if it really is a device or not +; + mov bx,4 + +devloop: + and _osfile[bx],not FDEV ; clear FDEV bit on principal + + mov ax,DOS_ioctl shl 8 + 0 ; issue ioctl(0) to get dev info + callos + jc notdev + + test dl,80h ; is it a device ? + jz notdev ; no + or _osfile[bx],FDEV ; yes - set FDEV bit + +notdev: + dec bx + jns devloop + + + +; 5. General C initializer routines + + mov si,dataOFFSET xifbegin + mov di,dataOFFSET xifend +if sizeC + call initterm ; call the far initializers +else + call farinitterm ; call the far initializers +endif + + mov si,dataOFFSET xibegin + mov di,dataOFFSET xiend + call initterm ; call the initializers + + + ret +cEnd ; standard C libs + + +page +;*** +;exit(status), _exit(status), _cexit(void), _c_exit(void) - C termination +; +;Purpose: +; +; Entry points: +; +; exit(code): Performs all the C termination functions +; and terminates the process with the return code +; supplied by the user. +; +; _exit(code): Performs a quick exit routine that does not +; do certain 'high-level' exit processing. The _exit +; routine terminates the process with the return code +; supplied by the user. +; +; _cexit(): Performs the same C lib termination processing +; as exit(code) but returns control to the caller +; when done (i.e., does NOT terminate the process). +; +; _c_exit(): Performs the same C lib termination processing +; as _exit(code) but returns control to the caller +; when done (i.e., does NOT terminate the process). +; +; Termination actions: +; +; exit(), _cexit (): +; +; 1. call user's terminator routines +; 2. call C runtime preterminators +; +; _exit(), _c_exit(): +; +; 3. call C runtime terminators +; 4. perform _nullcheck() for null pointer assignment +; 5. terminate floating point +; 6. reset divide by zero interrupt vector +; 7. restore int 3F handler +; 8. return to DOS or caller +; +; Notes: +; +; The termination sequence is complicated due to the multiple entry +; points sharing the common code body while having different entry/exit +; sequences. +; +;Entry: +; exit(), _exit() +; int status - exit status (0-255) +; +; _cexit(), _c_exit() +; +; +;Exit: +; exit(), _exit() +; +; +; _cexit(), _c_exit() +; Return to caller +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +; +;--- exit(): Full exit and term process --- +; + +public _exit +_exit: +cProc dummy1,<>,<> + + parmw status ; termination code + +cBegin + + xor cx,cx ; exit(): cl = 0, ch = 0 + jmp short common1 ; join common code + +cEnd + +; +;--- _exit(): Quickie exit and term process --- +; + +public __exit +__exit: +cProc dummy2,<>,<> + + parmw status ; termination code + +cBegin + + mov cx,1 ; _exit(): cl = 1, ch = 0 + jmp short common1 ; join common code + +cEnd + +if sizeC +global endp +endif + +; +;--- _cexit(): Full exit and return to caller --- +; + +cProc _cexit,, + +cBegin + + mov cx,(1 SHL 8) ; _cexit(): ch = 1, cl = 0 + jmp short common1 ; join common code + +cEnd + +; +;--- _c_exit(): Quickie exit and return to caller --- +; + +cProc _c_exit,, + +cBegin + + mov cx,(1 SHL 8)+1 ; _c_exit(): ch = 1, cl = 1 + ;fall through + +; +;--- Common entry point --- +; cx = entry value: +; cl = full vs quick exit path +; 0 = exit() code +; 1 = _exit() code +; ch = term process vs return to caller +; 0 = term process +; 1 = return to caller +; + +common1: ; all code paths join here + +assumes ds,data +ifndef FARSTACK +assumes ss,data +endif + +; +; If _exit()/_c_exit(), jump over the initial termination processing +; cx = entry code +; + + push cx ; save entry code on top of stack + or cl,cl ; cl != 0 means _exit()/_c_exit() + jnz short common2 ; if _exit()/_c_exit(), jump down + ;fall thru ; continue (exit, _cexit) + + +; 1. call user terminators +; - onexit processing + + mov si,dataOFFSET xontab ; beginning of onexit table + mov di,dataOFFSET xonend ; end of onexit table + call initterm + +; 2. call C runtime preterminators +; - flushall +; - rmtmp + + mov si,dataOFFSET xpbegin ; beginning of pre-terminators + mov di,dataOFFSET xpend ; end of pre-terminators + call initterm + + ;* + ;* Tell the debugger we are going to exit + ;* + ; *** NOTE: Currently, this appears to be called for both + ; exit() and _cexit(). Is this what we want? + ; + + cmp __aDBswpflg,__aDBdoswp ;* Are we under a debugger? + jne @F ;* No -- skip forward + cCall __aDBexit ;* Yes -- tell it we are exiting +@@: + +; +;--- Common entry point --- +; + +common2: ; __exit() enters here + + +; 3. perform C terminators + + mov si,dataOFFSET xcbegin + mov di,dataOFFSET xcend + call initterm ; call the terminators + + mov si,dataOFFSET xcfbegin + mov di,dataOFFSET xcfend +if sizeC + call initterm ; call the far terminators +else + call farinitterm ; call the far terminators +endif + +; 4. perform _nullcheck() for null pointer assignment + +ifndef _COM_ ; DS:0 is the PSP in .COM files! + + call _nullcheck ; check data in NULL data segment at DS:0 + ; this must be far call in large code models + ; since user can stub it out + or ax,ax ; zero if no null ptr assignment detected + jz afternullchk + + pop ax ; get entry code + or ah,ah ; ah != 0 means _cexit()/_c_exit() + push ax ; put it back for later + jnz short afternullchk ; jump if no status value (_cexit/_c_exit) + + cmp status,0 ; zero if no other error has occurred + jnz short afternullchk + mov status,255 ; nonzero status to indicate an + ; null-pointer-assignment error +afternullchk: + +endif ;_COM_ + +; 5. terminate floating point +; 6. reset divide by zero interrupt vector +; 7. restore int 3F handler + + call _ctermsub ; fast cleanup + +; 8. return to the DOS or caller + + pop ax ; get entry code off top of stack + or ah,ah ; ah = 0 means term process + jnz returning ; skip down if not term'ing + +; 8a. return to the DOS + +exiting: + mov ax,status ; get return value + + callos terminate ; exit with al = return code + + + ;*** PROCESS IS TERMINATED *** + +; 8b. Return to caller. + +returning: + +cEnd + + +page +;*** +;_ctermsub - more C termination code +; +;Purpose: +; This routine +; (1) performs floating-point termination +; (2) resets the divide by zero interrupt vector +; (3) restore int 3F handler +; +;Entry: +; +;Exit: +; +;Uses: +; AX,BX,CX,DX. +; +;Exceptions: +; +;******************************************************************************* + +labelNP + +; 4. terminate floating point + + + mov cx,word ptr [fpmath+2] ; test for floating point + jcxz nofloat_t ; no + + mov bx,2 ; yes - cleanup + call [fpmath] + +nofloat_t: + + +; 5. reset divide by zero interrupt vector + + push ds + lds dx,[_aintdiv] ; ds:dx = restore vector + mov ax,DOS_setvector shl 8 + 0 + callos ; set divide error interrupt + pop ds + +; 6. restore overlay interrupt vector + + cmp byte ptr [_ovlflag],0 ; Overlays in use ?? + jz done_ovlvec ; if 0, don't restore overlay vector + push ds ; save ds + mov al,byte ptr [_intno] ; overlay interrupt number + lds dx,dword ptr [_ovlvec] ; original ovl interrupt vector + callos setvector ; restore the overlay vector + pop ds ; restore ds +done_ovlvec: + ret + + +page +;*** +;initterm - do a set of initializers or terminators +; +;Purpose: +; The initializors and terminators may be written in C +; so we are assuming C conventions (DS=SS, CLD, SI and DI preserved) +; We go through them in reverse order for onexit. +; +;Entry: +; SI = start of procedure list +; DI = end of procedure list +; +;Exit: +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +initterm: + cmp si,di ; are we done? + jae itdone ; yes - no more + +if sizeC + sub di,4 + mov ax,[di] + or ax,[di+2] + jz initterm ; skip null procedures + call dword ptr [di] +else + dec di + dec di + mov cx,[di] + jcxz initterm ; skip null procedures + call cx +endif + jmp initterm ; keep looping + +itdone: + ret + +page +ife sizeC ; S/C models only +;*** +;farinitterm - do a set of far initializers or terminators +; +;Purpose: +; The initializors and terminators may be written in C +; so we are assuming C conventions (DS=SS, CLD, SI and DI preserved) +; We go through them in reverse order for onexit. +; +;Entry: +; SI = start of procedure list +; DI = end of procedure list +; +;Exit: +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +farinitterm: + cmp si,di ; are we done? + jae faritdone ; yes - no more + + sub di,4 + mov ax,[di] + or ax,[di+2] + jz farinitterm ; skip null procedures + call dword ptr [di] + jmp farinitterm ; keep looping + +faritdone: + ret +endif ;sizeC +sEnd + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0MSG.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0MSG.ASM new file mode 100644 index 0000000..6c6e262 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/CRT0MSG.ASM @@ -0,0 +1,126 @@ + page ,132 + title crt0msg - startup messages +;*** +;dos/crt0msg.asm - startup error messages +; +; Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; Core collection of error messages contained in programs +; which use the C startup code; also contains _FF_MSGBANNER +; for writing the first portion of run-time error messages. +; +;******************************************************************************* + + +?DF= 1 ; this is special for c startup +include version.inc +.xlist +include cmacros.inc +include rterr.inc +.list + +createSeg HDR, nhdr, byte, public, MSG, DGROUP +createSeg MSG, nmsg, byte, public, MSG, DGROUP +createSeg PAD, npad, byte, common, MSG, DGROUP +createSeg EPAD, nepad, byte, common, MSG, DGROUP + +createSeg _TEXT, code, word, public, CODE, <> +createSeg _DATA, data, word, public, DATA, DGROUP + +defGrp DGROUP ; define DGROUP + + +public __acrtmsg +__acrtmsg= 9876h + +; Messages used by crt0.asm + +sBegin nmsg +assumes ds,data + + _RTERR _RT_STACK, 'stack overflow', _RT_STANDARD + _RTERR _RT_INTDIV, 'integer divide by 0', _RT_STANDARD + _RTERR _RT_SPACEENV, 'not enough space for environment', _RT_STANDARD + ; Special error message entries + _RTERR _RT_CRNL, <13,10>, _RT_STRING + _RTERR _RT_BANNER, 'run-time error ', _RT_STRING + +sEnd nmsg + +sBegin npad +assumes ds,data + dw -1 +; no padding for now; +; MAX padding would be +; db 114 dup(0) +sEnd + +externP _NMSG_WRITE + +sBegin data + assumes ds,data + +globalCP _adbgmsg,0 ; For C, _FF_DBGMSG is inactive, so + ; _adbgmsg is set to null; + ; For FORTRAN, _adbgmsg is set to + ; point to _FF_DBGMSG in dbginit + ; initializer in dbgmsg.asm + +sEnd data + + +sBegin code + assumes cs,code + assumes ds,data + +page +;*** +;_FF_MSGBANNER - writes out first part of run-time error messages +; +;Purpose: +; This routine writes "\r\nrun-time error " to standard error. +; +; For FORTRAN $DEBUG error messages, it also uses the _FF_DBGMSG +; routine whose address is stored in the _adbgmsg variable to print out +; file and line number information associated with the run-time error. +; If the value of _adbgmsg is found to be null, then the _FF_DBGMSG +; routine won't be called from here (the case for C-only programs). +; +;Entry: +; No arguments. +; +;Exit: +; Nothing returned. +; +;Uses: +; AX,BX,CX,DX,ES are destroyed. +; +;Exceptions: +; None handled. +; +;******************************************************************************* + +cProc _FF_MSGBANNER,,<> + +cBegin + mov ax,_RT_CRNL ; "\r\n" to begin error message + push ax + callcrt _NMSG_WRITE +if sizeC + cmp word ptr [__adbgmsg+2],0 +else ; not needed for C-only version + cmp [__adbgmsg],0 +endif + jz dbgmsg_inactive + call [__adbgmsg] ; near or far call as appropriate +dbgmsg_inactive: + mov ax,_RT_BANNER ; run-time error message banner + push ax + callcrt _NMSG_WRITE +cEnd + +sEnd code + + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/EXECMSG.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/EXECMSG.ASM new file mode 100644 index 0000000..9ab2ec3 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/EXECMSG.ASM @@ -0,0 +1,58 @@ + page ,132 + title execmsg.asm - exec messages +;*** +;execmsg.asm - exec error messages +; +; Copyright (c) 1987-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; error messages used with exec*() library functions +; (and spawn*() functions with P_OVERLAY). +; +;******************************************************************************* + + +?DF= 1 ; this is special to define segments +include version.inc +.xlist +include cmacros.inc +include rterr.inc +.list + +createSeg HDR, nhdr, byte, public, MSG, DGROUP +createSeg MSG, nmsg, byte, public, MSG, DGROUP +createSeg PAD, npad, byte, common, MSG, DGROUP +createSeg EPAD, nepad, byte, common, MSG, DGROUP + +defGrp DGROUP ; define DGROUP + + +public __execmsg +__execmsg= 9876h + +; Messages used by doexec.asm + +sBegin nmsg +assumes ds,data + +; +; WARNING - Doexec.asm expects these three messages to be together +; these messages must always have '$' on the end +; (the _RTERR macrotakes care of this). + + + _RTERR _RT_EXECMEM, 'not enough memory on exec', _RT_DOLLAR + _RTERR _RT_EXECFORM, 'invalid format on exec', _RT_DOLLAR + _RTERR _RT_EXECENV, 'invalid environment on exec', _RT_DOLLAR + +sEnd + +sBegin npad +assumes ds,data + dw -1 +; no padding for now; +; MAX padding would be +; db 72 dup(0) +sEnd + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/NMSGHDR.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/NMSGHDR.ASM new file mode 100644 index 0000000..18ad52a --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/NMSGHDR.ASM @@ -0,0 +1,178 @@ + page ,132 + title nmsghdr - near message handler and finder +;*** +;nmsghdr.asm - near message handler and finder +; +; Copyright (c) 1986-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; Near message handler and finder. +; +;******************************************************************************* + + +?DF= 1 ; this is special for c startup +include version.inc +?PLM= 1 ; pascal calling conventions +.xlist +include cmacros.inc +include msdos.inc +.list + +createSeg _TEXT, code, word, public, CODE, <> + +createSeg _DATA, data, word, public, DATA, DGROUP + +createSeg HDR, nhdr, byte, public, MSG, DGROUP +createSeg MSG, nmsg, byte, public, MSG, DGROUP +createSeg PAD, npad, byte, common, MSG, DGROUP +createSeg EPAD, nepad, byte, common, MSG, DGROUP + +createSeg DBDATA, dbdata, word, common, DATA, DGROUP ;* + +defGrp DGROUP ; define DGROUP + +codeOFFSET equ offset _TEXT: +dataOFFSET equ offset DGROUP: + + +sBegin nhdr +assumes ds,data + + db '<>' + + +stnmsg label byte + +sEnd + +sBegin npad +assumes ds,data + + dw -1 ; message padding marker + +sEnd + +sBegin nepad +assumes ds,data + + db -1 + +sEnd + +sBegin dbdata ;* + assumes ds,data ;* Used to do the running under +externW ___aDBswpflg ;* a debugger screen swapping +externW ___aDBswpchk ;* +sEnd dbdata ;* + extrn __aDBdoswp:ABS ;* + + +sBegin code +assumes cs,code +assumes ds,data + +page +;*** +;__NMSG_TEXT(messagenumber) - find message for given message number +; +;Purpose: +; This routine returns a near pointer to the message associated with +; messagenumber. If the message does not exist, then a 0 is returned. +; +; This routine assumes DS = DGROUP +; +;Entry: +; ==PASCAL CALLING CONVENTIONS== +; messagenumber = WORD message number of desired message +; +;Exit: +; AX = pointer to message text or 0 if no message exists. +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +cProc __NMSG_TEXT,, ; pascal calling + + parmW msgt + +cBegin + push ds + pop es + mov dx,msgt ; dx = message number + mov si,dataOFFSET stnmsg ; start of near messages + +tloop: + lodsw ; ax = current message number + cmp ax,dx + je found ; found it - return address + inc ax + xchg ax,si + jz found ; at end and not found - return 0 + xchg di,ax + xor ax,ax + mov cx,-1 + repne scasb ; skip until 00 + mov si,di + jmp tloop ; try next entry + +found: + xchg ax,si +cEnd + + +page +;*** +;__NMSGWRITE(messagenumber) - writes message on stderr +; +;Purpose: +; This routine writes the message associated with messagenumber +; to stderr. +; +;Entry: +; ==PASCAL CALLING CONVENTIONS== +; messagenumber = WORD number of desired message +; +;Exit: +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +cProc __NMSG_WRITE,, ; pascal calling + + parmW msgw + +cBegin + push msgw + callcrt __NMSG_TEXT ; find near text pointer + or ax,ax + jz nowrite ; don't write anything if not there + + + xchg dx,ax ; ds:dx = string address + mov di,dx + xor ax,ax + mov cx,-1 + repne scasb ; es = ds from __NMSG_TEXT + not cx + dec cx ; cx = string length + mov bx,2 + cmp ___aDBswpflg,__aDBdoswp ;* Aware debugger as parent? + jne @F ;* No -- skip + call ___aDBswpchk ;* Yes -- see if we need to swap screens +@@: + callos write + + +nowrite: +cEnd + +sEnd + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/NULBODY.LNK b/Microsoft C v6ax/SOURCE/STARTUP/DOS/NULBODY.LNK new file mode 100644 index 0000000..34fdb1a --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/NULBODY.LNK @@ -0,0 +1,3 @@ +dos\nulbody dos\crt0 dos\crt0dat crt0fp dos\crt0msg dos\nmsghdr + +chksum dos\stdargv dos\stdalloc dos\stdenvp +dos\nulbody/NOI/MAP/NOE; diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDALLOC.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDALLOC.ASM new file mode 100644 index 0000000..1dbf472 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDALLOC.ASM @@ -0,0 +1,122 @@ + page ,132 + title stdalloc - memory allocation routine for stdargv, stdenvp +;*** +;stdalloc.asm - memory allocation routine for stdargv, stdenvp +; +; Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; Memory allocation for stdargv and stdenvp. +; +;******************************************************************************* + +include version.inc +.xlist +include cmacros.inc +include msdos.inc +include heap.inc +.list + + +sBegin data +assumes ds,data + +externW _amblksiz ; heap seg growth increment + +sEnd data + +externP malloc ; get heap memory + +sBegin code +assumes ds,data +assumes cs,code + +externNP _amsg_exit ; write error and die routine + +page +;*** +;_myalloc - argument/environment allocation +; +;Purpose: +; Used to allocate heap space for both wildcard arguments +; and environment strings, ptrs. +; +; Tries to find space in heap, failing this spits out error +; message and dies. +; +;Entry: +; AX = total number of bytes to allocate table and strings +; CX = error message number in case of death. +; DS = DGROUP +; +;Exit: +; DX:AX = address of allocated memory +; +;Uses: +; CX +;Preserves: +; BX, SI, DI, ES, DS +;Exceptions: +; If can't get enough memory, gives error (code in CX) and dies. +; +;******************************************************************************* + + +cProc _myalloc, + +cBegin + +assumes ds,data + + push bx ; save registers + push es + push cx + +; +; Call malloc() to get the memory +; Set the grow increment to a small value so that we don't eat up +; too much memory at runtime. +; + mov cx,_HEAP_GROWSTART ; startup grow increment + xchg cx,[_amblksiz] ; set temp grow increment and save original + + push cx ; save original grow increment + push ax ; ax = size to allocate + call malloc ; heap request + ; return value = or + pop bx ; clean off stack + pop [_amblksiz] ; restore original grow increment + + pop cx ; restore error message code +if sizeD + mov bx,dx ; preserve dx + or bx,ax ; malloc return NULL ?? +else + mov dx,ds ; dx:ax = address + or ax,ax ; malloc return NULL ?? +endif + jz _hpovr ; yes, return an error + +; +; Success +; dx:ax = memory address +; +_hpok: + pop es ; restore registers + pop bx + + ret + +; +; Error +; cx = error message code +; +_hpovr: + mov ax,cx ; error 2009/2008: no space for enviroment/arguments + jmp _amsg_exit ; give error and die + +cEnd + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDARGV.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDARGV.ASM new file mode 100644 index 0000000..11f812e --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDARGV.ASM @@ -0,0 +1,757 @@ + page ,132 + title stdargv - standard & wildcard _setargv routine +;*** +;stdargv.asm - standard & wildcard _setargv routine +; +; Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; processes program command line, with or without wildcard expansion +; +;******************************************************************************* + + +ifdef WILDCARD + name _setargv ; wildcard _setargv routine +else + name stdargv ; standard _setargv routine +endif + +ifdef WILDCARD +?DF = 1 ; tell cmacros.inc we want to define our own segments +endif + + .xlist +include version.inc +include cmacros.inc +include msdos.inc +include rterr.inc + .list + + +ifdef FARSTACK +ife sizeD + error +endif +endif + +ifdef WILDCARD ; ********************************************** + +createSeg _TEXT, code, word, public, CODE, <> +createSeg _DATA, data, word, public, DATA, DGROUP + +createSeg HDR, nhdr, byte, public, MSG, DGROUP +createSeg MSG, nmsg, byte, public, MSG, DGROUP +createSeg PAD, npad, byte, common, MSG, DGROUP +createSeg EPAD, nepad, byte, common, MSG, DGROUP + +defGrp DGROUP ; define DGROUP + +dataOFFSET equ offset DGROUP: + +; Message used by ___setargv (wildcard version of __setargv) + +sBegin nmsg +assumes ds,data + + _RTERR _RT_SPACEARG, 'not enough space for arguments', _RT_STANDARD + +sEnd + +sBegin npad +assumes ds,data + dw -1 +; no padding for now; +; MAX padding would be +; db 25 dup(0) +sEnd + + +externP _cwild ; Wildcard Expander +externNP _amsg_exit ; error handler (unable to allocate) + +endif ; WILDCARD ; ********************************************** + + +sBegin data +assumes ds,data + +C_CR equ 0DH ; ASCII carriage return + +C_BLANK equ ' ' ; ASCII space character +C_TAB equ 09h ; ASCII horizontal tab character + +C_QUOTE equ '"' ; ASCII (double) Quote Charater +C_BACKSLASH equ '\' ; ASCII backward slash character + +externDP __argv ; argument string array address +externW __argc ; count of argument strings +externW _psp ; address of Program Segment Prefix +externW _osversion ; address of DOS version +externD _pgmptr ; far ptr to name of program + + +staticCP retadr,0 ; return address + + +ifdef WILDCARD ; ********************************************** + +dta_flag db 0 ; Has DMA been set yet? + +file_reserv db 21 dup (0) +file_attrib db 0 +file_time dw 0 +file_date dw 0 +file_sizel dw 0 +file_sizeh dw 0 +file_name db 13 dup (0) + +endif ; WILDCARD ; ********************************************** + +sEnd + +; **************************************** + +jmps MACRO target + jmp short target + ENDM + +lje MACRO target + LOCAL temp + jne temp + jmp target +temp: + ENDM + +DELIM MACRO target + cmp al,C_CR ;; Test for end-of-line character + je target + or al,al ;; Either Carriage Return or Null + je target + ENDM + +LDELIM MACRO target + cmp al,C_CR ;; Test for end-of-line character + lje target + or al,al ;; Either Carriage Return or Null + lje target + ENDM + +; **************************************** + +sBegin code + +assumes ds,data +ifdef FARSTACK +assumes ss,nothing +else +assumes ss,data +endif +assumes cs,code + + +page +;*** +;_setargv, __setargv - set up "argc" and "argv" for C programs +; +;Purpose: +; Gets the command line from the PSP and moves the information +; to its place on the stack. +; +; SIDE EFFECTS: +; Allocates space on the stack for the argument strings +; and a list of pointers to them. +; ASSUMPTIONS: +; Under DOS 2, there is no argv[0] string, so we store a null +; char ('\0'). +; +; Under DOS 3 and later, the argv[0] string is found in the +; environment segment, after the double null that terminates +; that segment and after a word of value 1. The rest of the +; command line is found in the Program Segment Prefix at +; offset 81H, and is terminated by a 0DH. This command "tail" +; cannot be greater than 126 bytes in length. +; +; Quote marks and backslashes are treated specially. A quoted +; string is passed as a single argument, not including the +; opening and closing quote characters. A quote may be imbedded +; in a string by placing an odd number of backslashes (`\') +; before it. Each pair of backslashes which precedes a quote +; results in a single backslash in the resultant string. +; An even number of backslashes followed by a quote results in +; half that many backslashes, and the quote begins or ends the +; quoted part of the string as is appropriate. Backslashes not +; followed by a quote are treated normally. +; +; [""] ==> [] +; [\"] ==> ["] +; [" \" "] == [ " ] +; [" \\"] == [ \] +; [" \\ "] == [ \\ ] +; [" \\\" "] == [ \" ] +; etc. +; ["one two three"] ==> [one two three] +; [one" two "three] ==> [one two three] +; [o"ne two t"hree] ==> [one two three] +; ["one \"two\" three"] ==> [one "two" three] +; ["x\\\"x"] ==> [x\"x] +; +;Entry: +; +;Exit: +; "argv" points to a null-terminated list of pointers to ASCIZ +; strings, each of which is an argument from the command line. +; "argc" is the number of arguments. The strings are copied from +; the Program Segment Prefix into space allocated on the stack. +; The list of pointers is also located on the stack. +; +;Uses: +; All registers except DS, SS, and BP are modified +; Note especially that SI and DI are NOT preserved! +; +;Exceptions: +; +;******************************************************************************* + +ifdef WILDCARD ; ********************************************** + +labelP + +else ; ********************************************** + +labelP + +endif ; WILDCARD ; ********************************************** + + pop word ptr [retadr] ; get return address (offset) +if sizeC + pop word ptr [retadr+2] ; get return address (segment) +endif +; +; Check and store DOS version. This is done here because it cannot be done +; in CRT0.ASM (Windows replaces CRT0.ASM with their own code) and _setargv() +; is the only other place in the startup code where the DOS version number +; needed. +; + callos VERSION + mov [_osversion],ax + mov dx,1 ; dx = number of bytes in argv[0] if DOS 2.x + cmp al,2 + je dos_two + + mov es,_psp + mov es,es:[DOS_envp] ; get environment segment + mov word ptr [_pgmptr+2],es ; set global variable "_pgmptr" + xor ax,ax + cwd ; DX=0 + mov cx,8000H + xor di,di ; scan from beginning of environment +find_env_end: + repne scasb + scasb + jne find_env_end +; + inc di ; skip count word (always 0x0001) + inc di + mov word ptr [_pgmptr],di ; set global variable "_pgmptr" + mov cx,-1 + repne scasb + not cx + mov dx,cx ; DX=number of bytes in argv[0] +dos_two: +ifdef FARSTACK + push ds + pop es + assumes es,data ; set ES=DGROUP +endif + mov di,1 ; always start with one argument + mov si,81H + mov ds,_psp + + + assumes ds,nothing +;* +;* Count the command tail arguments +;* +; +; DI will count the number of arguments +; DX will count the number of bytes needed for the arguments +; (not including the null terminators) +; +arg100: +arg110: + lodsb + cmp al,C_BLANK + je arg110 + cmp al,C_TAB + je arg110 + + DELIM arg400 + + inc di ; Another argument +; +; Parse an argument +; +arg200: + dec si ; back up to reload character +arg210: + lodsb + + cmp al,C_BLANK + je arg100 + cmp al,C_TAB + je arg100 ; white space terminates argument + + DELIM arg400 + + cmp al,C_QUOTE + je arg310 + + cmp al,C_BACKSLASH + je arg220 + + inc dx + jmps arg210 +; +; Count backslashes +; +arg220: + xor cx,cx +arg221: + inc cx ; CX counts the backslashes + lodsb + cmp al,C_BACKSLASH + je arg221 +; + cmp al,C_QUOTE + je arg230 + + add dx,cx ; not followed by `"' -- treat `\'s normally + jmp arg200 +; +arg230: + mov ax,cx + shr cx,1 + adc dx,cx ; add 1 for every pair of backslashes + test al,1 ; plus 1 for the " if odd number of \ + jnz arg210 ; " was escaped with a \ + jmps arg310 ; " opens a quoted substring +; +; Enter a quoted string +; +arg300: + dec si ; back up to reload character +arg310: + lodsb + + DELIM arg400 + + cmp al,C_QUOTE + je arg210 ; end of quoted portion of string + + cmp al,C_BACKSLASH + je arg320 + + inc dx + jmp arg310 +; +; Count backslashes +; +arg320: + xor cx,cx +arg321: + inc cx ; CX counts the backslashes + lodsb + cmp al,C_BACKSLASH + je arg321 +; + cmp al,C_QUOTE + je arg330 + + add dx,cx ; not followed by `"' -- treat `\'s normally + jmp arg300 +; +arg330: + mov ax,cx + shr cx,1 + adc dx,cx ; add 1 for every pair of backslashes + test al,1 ; plus 1 for the " if odd number of \ + jnz arg310 ; " was escaped with a \ + jmps arg210 ; " closes a quoted substring +; +; Command line is fully parsed - compute number of bytes needed +; +arg400: +; +; Number of bytes needed = +; Number of bytes used to make strings + +; Number of bytes used to terminate strings + +; sizeof(DATAPTR) * ( number of arguments + 1 ) +; +ifdef FARSTACK + push es +else + push ss +endif ;FARSTACK + pop ds ; Restore DS = DGROUP + assumes ds,data + + mov __argc,di ; Store number of arguments + + add dx,di ; add in terminator bytes +ifdef WILDCARD + add dx,di ; add in Wildcard flag bytes +endif + inc di ; add one for NULL pointer + shl di,1 +if sizeD + shl di,1 +endif + add dx,di ; add space for pointers to space for chars + + inc dx + and dl,not 1 ; Round up to an even number of bytes +; +; Allocate space on the stack +; +; DX is the total number of bytes needed for strings and pointers +; DI is the number of bytes needed for the pointers +; + sub sp,dx + mov ax,sp + + mov word ptr (__argv),ax +if sizeD + mov word ptr (__argv+2),ss +endif +; +; Copy argument strings and addresses onto heap/stack +; Address table is on the top, strings below that +; + mov bx,ax + add di,bx + + push ss ; ES=SS + pop es ; ES:DI is where the string copies will go +ifndef FARSTACK + assumes es,data +endif + +; +; DS:SI points to the argv[0] +; +; ES:BX points to where argv[0],argv[1],argv[2],... go +; ES:DI points to where *argv[0],*argv[1],*argv[2],... go +; For wildcard version only: +; ES:DX points to the wildcard flag character (prepended to argument) +; during the creation of each argument +; + mov ss:[bx],di ; argv[i] - offset part +if sizeD + mov ss:[bx+2],ss ; argv[i] - segment part + add bx,4 +else + inc bx + inc bx +endif + + lds si,[_pgmptr] ; copy argv[0], either fake or from env seg + assumes ds,nothing + +ifdef WILDCARD + movsb + dec si ; copy first character as quote flag +endif + +copy_argv0: + lodsb + stosb + or al,al + jnz copy_argv0 + + +; +; DS:SI points to the raw command tail string +; + +ifdef FARSTACK + + mov si, DGROUP + mov ds, si ; DS = DGROUP + + assumes ds, data + mov ds, [_psp] + assumes ds, nothing ; let DS = psp +else + mov ds,ss:[_psp] ; DS:SI is where the source strings are +endif ;FARSTACK + mov si,81H ; address of strings + + assumes ds,nothing + + jmps arg510 +; +; Skip blanks +; +arg500: + xor ax,ax + stosb +arg510: + lodsb + cmp al,C_BLANK + je arg510 + cmp al,C_TAB + je arg510 + +ifdef WILDCARD + LDELIM arg810 +else +if sizeD + LDELIM arg810 +else + DELIM arg810 +endif +endif + + mov ss:[bx],di +if sizeD + mov ss:[bx+2],ss + add bx,4 +else + inc bx + inc bx +endif + +ifdef WILDCARD + mov dx,di + stosb ; initialize wildcard flag +endif +; +; +; Parse an argument +; +arg600: + dec si ; back up to reload character +arg610: + lodsb + + cmp al,C_BLANK + je arg500 + cmp al,C_TAB + je arg500 ; white space terminates argument + + DELIM arg800 + + cmp al,C_QUOTE + je arg710x + + cmp al,C_BACKSLASH + je arg620 + + stosb + jmps arg610 +; +; Count backslashes +; +arg620: + xor cx,cx +arg621: + inc cx ; CX counts the backslashes + lodsb + cmp al,C_BACKSLASH + je arg621 +; + cmp al,C_QUOTE + je arg630 + + mov al,C_BACKSLASH + rep stosb ; not followed by `"' -- treat `\'s normally + jmp arg600 +; +arg630: + mov al,C_BACKSLASH + shr cx,1 + rep stosb + jnc arg710x ; " opens a quoted substring + mov al,C_QUOTE + stosb + jmp arg610 ; " was escaped with a \ +; +; Enter a quoted string +; +ifdef WILDCARD +arg710x: + inc si ; undoes the "DEC SI" between arg700 and arg710 +endif + +arg700x: + +ifdef WILDCARD + xchg dx,di ; set the wildcard flag character to `"' + mov al,C_QUOTE + stosb + dec di + xchg dx,di +endif + +arg700: + dec si ; back up to reload character + +ifndef WILDCARD +arg710x: +endif + +arg710: + lodsb + + DELIM arg800 + + cmp al,C_QUOTE + je arg610 ; end of quoted portion of string + + cmp al,C_BACKSLASH + je arg720 + + stosb + jmp arg710 +; +; Count backslashes +; +arg720: + xor cx,cx +arg721: + inc cx ; CX counts the backslashes + lodsb + cmp al,C_BACKSLASH + je arg721 +; + cmp al,C_QUOTE + je arg730 + + mov al,C_BACKSLASH + rep stosb ; not followed by `"' -- treat `\'s normally + jmp arg700x +; +arg730: + mov al,C_BACKSLASH + shr cx,1 + rep stosb ; store 1 for every pair of backslashes + jnc arg610 ; " closes a quoted substring + mov al,C_QUOTE ; " was escaped with a \ + stosb + jmps arg710x +; +; Terminate last argument string, terminate list of argument pointers +; +arg800: + xor ax,ax + stosb ; null-terminate final argument +arg810: + +ifdef FARSTACK + mov ax, DGROUP + mov ds, ax +else + push ss ; default is SS == DGROUP + pop ds +endif + assumes ds,data + +ifdef FARSTACK + mov word ptr ss:[bx],0 + mov word ptr ss:[bx+2],0 +else + mov word ptr [bx],0 ; add null pointer to __argv[] +if sizeD + mov word ptr [bx+2],0 +endif +endif ;FARSTACK + +ifndef WILDCARD + jmp [retadr] ; THE END +else + call _cwild + test ax,ax + jz no_arg_err + + mov ax,_RT_SPACEARG ; 'not enough space for arguments' + jmp _amsg_exit ; + +no_arg_err: + jmp [retadr] + +page +;*** +;_find(dir) - find first matching file name against pattern "dir" +; +;Purpose: +; _find(dir) - Find first matching file name against pattern "dir" +; If dir == NULL, then get next match for current pattern. +; +;Entry: +; dir = DATA PTR of pattern to match +; +;Exit: +; AX = the address of a static area containing the file name if a +; match was found. Returns NULL if no match was found. +; +;Uses: +; CX,DX, [dta_flag]. +; +;Exceptions: +; +;******************************************************************************* + +cProc _find, + parmdp dir +cBegin + test [dta_flag],-1 + jnz not_very_first + + mov [dta_flag],-1 +; +; Set DTA, where the match structure is returned +; + mov dx,dataOFFSET file_reserv + callos setdma +; +not_very_first: + mov ah,DOS_findnext ; assume not first + +if sizeD + push ds + lds dx,dir + mov cx,ds + jcxz find_next +else + mov dx,dir + test dx,dx + jz find_next +endif + mov cx,A_D ; match directories as well as files + mov ah,DOS_findfirst +find_next: + callos +if sizeD + pop ds +endif + mov ax,dataOFFSET file_name +if sizeD + mov dx,ds +endif + jnc retname + + xor ax,ax ; return 0 for no more matches +if sizeD + cwd +endif + +retname: + +cEnd + +endif ; WILDCARD ; *********************************************** + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDENVP.ASM b/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDENVP.ASM new file mode 100644 index 0000000..02166b0 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/DOS/STDENVP.ASM @@ -0,0 +1,334 @@ + page ,132 + title stdenvp - standard _setenvp routine +;*** +;stdenvp.asm - standard _setenvp routine +; +; Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; This module is called by the C start-up routine to set up "environ". +; It copies the environment strings and a null-terminated table of +; pointers to those strings into the heap. +; The global symbol "_environ" is set to point to this array. +; +;******************************************************************************* + + +include version.inc +.xlist +include cmacros.inc +include msdos.inc +include rterr.inc +.list + +ifdef FARSTACK +ife sizeD + error +endif +endif + +externNP _myalloc ; allocation routine for arguments + +sBegin data +assumes ds,data + +externDP environ ; environment pointer +externW _psp ; PSP segment # +externB _acfinfo ; _C_FILE_INFO string + +sEnd data + +sBegin code +assumes ds,data +assumes cs,code +ifndef FARSTACK +assumes ss,data +endif + +page +;*** +;_stdenvp - set up "envp" for C programs +; +;Purpose: +; Reads the environment and build the envp array for C programs. +; +;Entry: +; The environment strings occur at the beginning of the segment. +; The list of environment strings is terminated by an extra null +; byte. Thus two null bytes in a row indicate the end of the +; last environment string and the end of the environment, resp. +; +;Exit: +; "environ" points to a null-terminated list of pointers to ASCIZ +; strings, each of which is of the form "VAR=VALUE". The strings +; are copied from the environment segment into space allocated on +; the heap. The list of pointers is also located on there. +; +;Uses: +; Locks the environment segment before use, and unlocks afterward +; Allocates space on the heapfor the environment strings +; and a list of pointers to them. +; +; All registers except DS, SS, and BP are modified +; Note especially that SI and DI are NOT preserved! +; +;Exceptions: +; +;******************************************************************************* + +cProc _setenvp,, + +if sizeD + localW envseg ; segment OS environment segment + localW envtab ; segment environment pointer table +ifdef FARSTACK + localW datagroup ; segment of the DGROUP +endif ;FARSTACK +endif ;sizeD + +cBegin + + mov es,[_psp] ; es = PSP seg + assumes es,nothing + mov bx,word ptr es:[DOS_ENVP] + mov es,bx ; es = OS environment segment +if sizeD + mov [envseg],es ; save OS seg on stack for later +endif +ifdef FARSTACK + mov [datagroup],ds ; save DGROUP for later +endif + +; +; --- Scan the list of environment strings calculating the following +; values: +; (1) si will count the number of environment strings +; (2) di will count the number of bytes the strings occupy +; Stop on a null string +; +; bx = es = OS environment segment +; ds = DGROUP +; + + xor ax,ax ; ax = 0 (search byte) + xor si,si ; si = 0 (env pointer count) + xor di,di ; di = 0 (initial offset) + mov cx,-1 ; cx = ffff (infinite count) + + or bx,bx ; OS env seg == NULL ?? + jz noenv ; yes, no environment + cmp byte ptr es:[0],0 ; OS env seg start with null byte ?? + je noenv ; yes, no environment + +scanenv: + repnz scasb + inc si ; si = envp count + scasb + jnz scanenv + +noenv: + mov ax,di ; ax = length of env strings + inc ax + and al,not 1 ; round up to even + + inc si ; si = env pointer count + 1 (for null) + mov di,si ; di = env pointer count (save) + shl si,1 ; si = env pointer count * 2 +if sizeD + shl si,1 ; si = env pointer count * 4 +endif + +; +; --- Allocate space for environment strings +; ax = # bytes for env strings +; si = # bytes for env pointers +; di = # of pointers +; es = OS environment segment +; ds = ss = DGROUP (ss = stack for FARSTACK) +; + ; allocate space for strings + ; ax = size needed for strings + mov cx,_RT_SPACEENV ; error message in case of death. + call _myalloc ; takes ax = total # of bytes needed +if sizeD + push dx ; push segment to string area +endif + push ax ; push offset to string area + + ; allocate space for the pointer table + + mov ax,si ; ax = space for pointers + call _myalloc ; takes ax = total # of bytes needed + mov word ptr [environ],ax ; init environ +if sizeD + mov word ptr [environ+2],dx ; segment address for large model + mov word ptr [envtab],dx ; save segment here too +endif + +; +; --- Successfully allocated space for env table and strings +; Init registers for env copy loop +; +; ax = offset to env table area +; di = # of pointers +; es = OS environment segment +; ds = DGROUP +; tos = offset to string area +if sizeD +; tos-2 = segment to string area +endif +; + +env_ok: + +if sizeD + push es + pop ds ; ds = OS env segment + assumes es,nothing + assumes ds,nothing +else + push es + push ds + pop es ; es = DGROUP + pop ds ; ds = OS env segment + assumes es,data + assumes ds,nothing +endif + + mov cx,di ; cx = envcnt + mov bx,ax ; bx = offset env pointers area + xor si,si ; si = OS env string area + pop di ; di = offset env string area +if sizeD + pop es ; es:di = pointer env string area +endif + + +; +; --- Check for no environment +; + + dec cx ; adjust for the last entry of 0000 + jcxz envdone ; done - no environment + +; +; --- Loop through the environment +; (1) Setup the environment table of pointers (environ) +; (2) Copy the environment strings into our address space +; (3) Do NOT copy the _C_FILE_INFO string +; +if sizeD +; cx = # of env strings left to copy +; bx = offset of env pointer table +; ds:si = pointer to OS environment area +; es:di = pointer to next envstrg destination +else +; cx = # of env strings left to copy +; ds:si = offset to OS environment area +; es:bx = offset of env pointer table +; es:di = pointer to next envstrg destination +; es = DGROUP +endif + +envloop: + + ; --- Check for _C_FILE_INFO + + mov ax,ds:[si] ; get first two bytes of string +ifdef FARSTACK + push ds + mov ds,[datagroup] + assumes ds,data + cmp ax,word ptr [_acfinfo] ; compare to "_C" + pop ds + assumes ds,nothing +else + cmp ax,word ptr ss:[_acfinfo] ; is it "_C" ? +endif ;FARSTACK + jne not_cfi ; nope, continue + + push cx ; save context + push si + push di +if sizeD + push es +ifdef FARSTACK + mov es,[datagroup] ; es = DGROUP +else + push ss + pop es ; es = DGROUP +endif ;FARSTACK +endif + + mov di,dataOFFSET _acfinfo ; es:di = pointer to _C_FILE_INFO + mov cx,6 ; length of string in words + repe cmpsw ; compare the strings + +if sizeD + pop es ; restore context +endif + pop di + pop si + pop cx + ; is it _C_FILE_INFO ?? + je envcopy ; yes, don't store this one + ;fall thru ; nope, store it + + ; --- store env string pointer in table + +not_cfi: + +if sizeD + mov ds,[envtab] ; ds:bx = next table entry +endif + ; es:di = next env string area +if sizeD + mov ds:[bx],di ; save env string pointer in table + mov ds:[bx+2],es + add bx,4 ; bump table pointer +else + mov es:[bx],di ; save env string pointer in table + inc bx ; bump table pointer + inc bx +endif + + ; --- copy string from OS segment into our memory + +envcopy: + +if sizeD + mov ds,[envseg] ; ds:si = string in OS seg +endif + +envcpy: + lodsb ; get a char from OS segment + stosb ; copy into library space + or al,al ; end of string ?? + jnz envcpy ; nope, continue copying string + + loop envloop ; do the next environment variable + +; +; --- Done copying strings +; put a null at the end of the envtab table +; + +envdone: + +if sizeD + mov ds,[envtab] ; ds:bx = env table pointer + mov ds:[bx],cx ; store a null + mov ds:[bx+2],cx +else + mov es:[bx],cx ; store a null +endif + +if sizeD +cEnd +else +cEnd +endif + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/EMOEM.ASM b/Microsoft C v6ax/SOURCE/STARTUP/EMOEM.ASM new file mode 100644 index 0000000..c609292 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/EMOEM.ASM @@ -0,0 +1,442 @@ + +; +; +; Copyright (C) Microsoft Corporation, 1987-90 +; +; This Module contains Proprietary Information of Microsoft +; Corporation and should be treated as Confidential. +; +title emoem.asm - OEM dependent code for 80x87 + +;-------------------------------------------------------------------- +; +; OEM customization routines for 8087/80287/80387 coprocessor +; +; This module is designed to work with the following +; Microsoft language releases: +; +; Microsoft C 3.00 and later +; Microsoft FORTRAN 77 3.30 and later +; Microsoft Pascal 3.30 and later +; +; This module supersedes the OEMR7.ASM module used in earlier +; versions of Microsoft FORTRAN 77 and Pascal. The documentation +; provided with the FORTRAN and Pascal releases refers to the old +; OEMR7.ASM module and is only slightly relevant to this module. +; +; The following routines need to be written to properly handle the +; 8087/808287/80387 installation, termination, and interrupt handler +; +; __FPINSTALL87 install 80x87 interrupt handler +; __FPTERMINATE87 deinstall 80x87 interrupt handler +; __fpintreset reset OEM hardware if an 80x87 interrupt +; +; ***** NEW INSTRUCTIONS ***** +; +; If you want a PC clone version, do nothing. The libraries are +; setup for working on IBM PC's and clones. +; +; These instructions only need to be followed if a non-IBM PC +; clone version is desired. +; +; This module should be assembled with the +; Microsoft Macro Assembler Version 4.00 or later as follows: +; +; masm -DOEM -r emoem.asm; +; +; Most hardware handles the 8087/80287/80387 in one of the following +; three ways - +; +; 1. NMI - IBM PC and clones all handle the interrupt this way +; 2. single 8259 +; 3. master/slave 8259 +; +; Manufacturer specific initialization is supported for these 3 +; machine configurations either by modifying this file and replacing +; the existing EMOEM module in the math libraries or by patching +; the .LIB and .EXE files directly. +; +; LIB 87-+EMOEM; +; LIB EM-+EMOEM; +; +;-------------------------------------------------------------------- + +ifdef OEM +if1 + %out OEM version for non-clone support +endif +endif + +;--------------------------------------------------------------------- +; Assembly constants. +;--------------------------------------------------------------------- + +; MS-DOS OS calls + + OPSYS EQU 21H + SETVECOP EQU 25H + GETVECOP EQU 35H + DOSVERSION EQU 30h + CTLCVEC EQU 23h + +EMULATOR_DATA segment para public 'FAR_DATA' +assume ds:EMULATOR_DATA + +; User may place data here if DS is setup properly. +; Recommend keeping the data items in the code segment. + +EMULATOR_DATA ends + + + +EMULATOR_TEXT segment para public 'CODE' +assume cs:EMULATOR_TEXT + + public __FPINSTALL87 ; DO NOT CHANGE THE CASE ON + public __FPTERMINATE87 ; THESE PUBLIC DEFINITIONS + + extrn __FPEXCEPTION87:near ; DO NOT CHANGE CASE + + + + +ifdef OEM + +;*********************************************************************** +; +; Hardware dependent parameters in the 80x87 exception handler. +; +; For machines using 2 8259's to handle the 80x87 exception, be sure that +; the slave 8259 is the 1st below and the master is the 2nd. +; +; The last 4 fields allow you to enable extra interrupt lines into the +; 8259s. It should only be necessary to use these fields if the 80x87 +; interrupt is being masked out by the 8259 PIC. +; +; The ocw2's (EOI commands) can be either non-specific (20H) or +; specific (6xH where x=0 to 7). If you do not know which interrupt +; request line on the 8259 the 80x87 exception uses, then you should issue +; the non-specific EOI (20H). Interrupts are off at this point in the +; interrupt handler so a higher priority interrupt will not be seen. + +oeminfo struc +oemnum db 0 ; MS-DOS OEM number (IBM is 00h) +intnum db 2 ; IBM PC clone interrupt number +share db 0 ; nonzero if original vector should be taken +a8259 dw 0 ; 1st 8259 (A0=0) port # +aocw2 db 0 ; 1st 8259 (A0=0) EOI command +b8259 dw 0 ; 2nd 8259 (A0=0) port # +bocw2 db 0 ; 2nd 8259 (A0=0) EOI command +a8259m dw 0 ; 1st 8259 (A0=1) port # +aocw1m db 0 ; 1st 8259 (A0=1) value to mask against IMR +b8259m dw 0 ; 2nd 8259 (A0=1) port # +bocw1m db 0 ; 2nd 8259 (A0=1) value to mask against IMR +oeminfo ends + +;----------------------------------------------------------------------- +; OEM specific 80x87 information +; +; If the OEM number returned from the DOS version call matches, +; this information is automatically moved into the oem struc below. + +oemtab label byte ; Table of OEM specific values for 80x87 + +; OEM#, int, shr, a59, acw2,b59, bcw2,a59m,acw1,b59m,bcw1 + +;TI Professional Computer +TI_prof oeminfo <028h,047h,000h,018h,020h,0000,0000,0000,0000,0000,0000> + + db 0 ; end of table + +; Unique pattern that can be searched for with the debugger so that +; .LIB or .EXE files can be patched with the correct values. +; If new values are patched into .LIB or .EXE files, care must be +; taken in insure the values are correct. In particular, words and +; bytes are intermixed in oeminfo structure. Remember words are +; stored low byte - high byte in memory on the 8086 family. + + db '<<8087>>' ; older versions used '<8087>' + +; Some manufacturer's machines can not be differentiated by the +; OEM number returned by the MS-DOS version check system call. +; For these machines it is necessary to replace the line below + +oem1 oeminfo <> ; default values for IBM PC & clones + +; with one of the following. If your machine has an 80x87 capability +; and it is not in the list below, you should contact your hardware +; manufacturer for the necessary information. + +;ACT Apricot +;oem1 oeminfo <000h,055h,000h,000h,020h,000h,000h,000h,000h,000h,000h> + +;NEC APC3 and PC-9801 (OEM number returned by NEC MS-DOS's is different) +;oem1 oeminfo <000h,016h,000h,008h,066h,000h,067h,00Ah,0BFh,002h,07Fh> + +;--------------------------------------------------------------------- + +aoldIMR db 0 ; 1st 8259 original IMR value +boldIMR db 0 ; 2nd 8259 original IMR value + +endif ;OEM + +statwd dw 0 ; Temporary for status word +oldvec dd 0 ; Old value in 80x87 exception interrupt vector +ctlc dd 0 ; Old value of Control-C vector (INT 23h) + +page + +;--------------------------------------------------------------------- +; +; Perform OEM specific initialization of the 80x87. +; + +__FPINSTALL87: + push ds ; DS = EMULATOR_DATA + + push cs ; Move current CS to DS for opsys calls. + pop ds +assume ds:EMULATOR_TEXT + +ifdef OEM + push ds + pop es ; CS = DS = ES + mov ah,DOSVERSION + int OPSYS ; bh = OEM# + cld + mov si,offset oemtab ; start of OEM 80x87 info table + mov di,offset oem1+1 + mov cx,(size oem1)-1 +OEMloop: + lodsb ; get OEM# + or al,al + jz OEMdone ; OEM# = 0 - did not find OEM + cmp al,bh ; correct OEM# + je OEMfound + add si,cx ; skip over OEM information + jmp OEMloop + +OEMfound: + rep movsb ; move the information + +OEMdone: ; done with automatic customization +endif ;OEM + +; Save old interrupt vector. +; Ask operating system for vector. + +ifdef OEM + mov al,[oem1].intnum ; Interrupt vector number. + mov ah,GETVECOP ; Operating system call interrupt. +else + mov ax,GETVECOP shl 8 + 2 ; get interrupt vector 2 +endif ;OEM + int OPSYS ; Call operating system. + + mov word ptr [oldvec],bx ; Squirrel away old vector. + mov word ptr [oldvec+2],es + +; Have operating system install interrupt vectors. + +SetVector: + mov dx,offset __fpinterrupt87 ; Load DX with 80x87 interrupt handler. +ifdef OEM + mov ah,SETVECOP ; Set interrupt vector code in AH. + mov al,[oem1].intnum ; Set vector number. +else + mov ax,SETVECOP shl 8 + 2 ; set interrupt vector 2 +endif ;OEM + int OPSYS ; Install vector. + +; Intercept Control-C vector to guarentee cleanup + + mov ax,GETVECOP shl 8 + CTLCVEC + int OPSYS + mov word ptr [ctlc],bx + mov word ptr [ctlc+2],es + mov dx,offset ctlcexit + mov ax,SETVECOP shl 8 + CTLCVEC + int OPSYS + +ifdef OEM + +; set up 8259's so that 80x87 interrupts are enabled + + mov ah,[oem1].aocw1m ; get mask for 1st 8259 IMR + or ah,ah ; if 0, don't need to do this + jz installdone ; and only 1 8259 + mov dx,[oem1].a8259m ; get port number for 1st 8259 (A0=1) + in al,dx ; read old IMR value + mov [aoldIMR],al ; save it to restore at termination + and al,ah ; mask to enable interrupt + jmp short $+2 ; for 286's + out dx,al ; write out new mask value + + mov ah,[oem1].bocw1m ; get mask for 2nd 8259 IMR + or ah,ah ; if 0, don't need to do this + jz installdone ; + mov dx,[oem1].b8259m ; get port number for 2nd 8259 (A0=1) + in al,dx ; read old IMR value + mov [boldIMR],al ; save it to restore at termination + and al,ah ; mask to enable interrupt + jmp short $+2 ; for 286's + out dx,al ; write out new mask value + +installdone: + +endif ;OEM + +assume ds:EMULATOR_DATA + pop ds + ret + + +page +; __FPTERMINATE87 +; +; This routine should do the OEM 80x87 cleanup. This routine is called +; before the program exits. +; +; DS = EMULATOR_DATA + +__FPTERMINATE87: + push ds + push ax + push dx + +ifdef OEM + mov ah,SETVECOP + mov al,[oem1].intnum +else + mov ax,SETVECOP shl 8 + 2 +endif ;OEM + lds dx,[oldvec] + int OPSYS + +ifdef OEM + +; reset 8259 IMR's to original state + + push cs + pop ds ; DS = CS +assume ds:EMULATOR_TEXT + cmp [oem1].aocw1m,0 ; did we have to change 1st 8259 IMR + je term2nd8259 ; no - check 2nd 8259 + mov al,[aoldIMR] ; get old IMR + mov dx,[oem1].a8259m ; get 1st 8259 (A0=1) port # + out dx,al ; restore IMR + +term2nd8259: + cmp [oem1].bocw1m,0 ; did we have to change 2nd 8259 IMR + je terminatedone ; no + mov al,[boldIMR] ; get old IMR + mov dx,[oem1].b8259m ; get 2nd 8259 (A0=1) port # + out dx,al ; restore IMR + +terminatedone: + +endif ;OEM + + pop dx + pop ax + pop ds +assume ds:EMULATOR_DATA + ret + + +; Forced cleanup of 80x87 exception handling on Control-C + +ctlcexit: + push ax + push dx + push ds + call __FPTERMINATE87 ; forced cleanup of exception handler + lds dx,[ctlc] ; load old control C vector + mov ax,SETVECOP shl 8 + CTLCVEC + int OPSYS + pop ds + pop dx + pop ax + jmp [ctlc] ; go through old vector + +page +; __fpinterrupt87 +; +; This is the 80x87 exception interrupt routine. +; +; All OEM specific interrupt and harware handling should be done in +; __fpintreset because __FPEXCEPTION87 (the OEM independent 80x87 +; exception handler) may not return. __FPEXCEPTION87 also turns +; interrupts back on. +; + +PENDINGBIT= 80h ; Bit in status word for interrupt pending + +__fpinterrupt87: +assume ds:nothing + nop + fnstsw [statwd] ; Store out exceptions + push cx ; waste time + mov cx,3 +self: + loop self + pop cx + test byte ptr [statwd],PENDINGBIT ; Test for 80x87 interrupt + jz not87int ; Not an 80x87 interrupt. + +ifdef OEM + call __fpintreset ; OEM interrupt reset routine +endif ;OEM + + call __FPEXCEPTION87 ; 80x87 error handling - may not return + ; this routine turns interrupts back on + +ifdef OEM + cmp [oem1].share,0 ; Should we execute the old interrupt routine? + jnz not87int ; if so then do it + ; else return from interrupt + +; If you fall through here to do further hardware resetting, things +; may not always work because __FPEXCEPTION87 does not always return +; This only happens when the 80x87 handler gets an exception that is +; a fatal error in the language runtimes. I.e., divide by zero +; is a fatal error in all the languages, unless the control word has +; set to mask out divide by zero errors. + +endif ;OEM + +done8087: + iret + +not87int: + jmp [oldvec] ; We should never return from here. + + +ifdef OEM + + +__fpintreset: + push ax + push dx + mov al,[oem1].aocw2 ; Load up EOI instruction. + or al,al ; Is there at least one 8259 to be reset? + jz Reset8259ret ; no + mov dx,[oem1].a8259 + out dx,al ; Reset (master) 8259 interrupt controller. + mov al,[oem1].bocw2 ; Load up EOI instruction. + or al,al ; Is there a slave 8259 to be reset? + jz Reset8259ret + mov dx,[oem1].b8259 + out dx,al ; Reset slave 8259 interrupt controller. + +Reset8259ret: + pop dx + pop ax + ret + +endif ;OEM + + +EMULATOR_TEXT ends + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/FILE2.H b/Microsoft C v6ax/SOURCE/STARTUP/FILE2.H new file mode 100644 index 0000000..f4bd6e4 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/FILE2.H @@ -0,0 +1,58 @@ +/*** +*file2.h - auxiliary file structure used internally by file run-time routines +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file defines the auxiliary file structure used internally by +* the file run time routines. +* [Internal] +* +****/ + +/* + Define the FILE2 structure. + + [Note that we depend on the FILE2 structure being the same size as a + FILE structure (see macro definitions).] +*/ + +#define FILE2 struct _iobuf2 + +extern FILE2 { + char _flag2; + char _charbuf; + int _bufsiz; + int __tmpnum; +#if (defined(M_I86SM) || defined(M_I86MM)) + char _padding[2]; /* pad out to size of FILE structure */ +#else + char _padding[6]; /* pad out to size of FILE structure */ +#endif + } near _iob2[]; + +#define _IOYOURBUF 0x01 +#define _IOFEOF 0x08 +#define _IOFLRTN 0x10 +#define _IOCTRLZ 0x20 + +/* Macros for getting _iob[] index and translating (FILE *) to (FILE2 *) */ + +#define _iob2_(s) (*((FILE2 near *) ((char near *)_iob2 + ((char *)s - (char *)_iob)))) +#define _iob_index(s) ( (FILE *) s - (FILE *)_iob) + +/* General use macros */ + +#define inuse(s) ((s)->_flag & (_IOREAD|_IOWRT|_IORW)) +#define mbuf(s) ((s)->_flag & _IOMYBUF) +#define nbuf(s) ((s)->_flag & _IONBF) +#define ybuf(s) (_iob2_(s)._flag2 & _IOYOURBUF) +#define bigbuf(s) (mbuf(s) || ybuf(s)) +#define anybuf(s) ((s)->_flag & (_IOMYBUF|_IONBF) || ybuf(s)) +#define _tmpnum(s) _iob2_(s).__tmpnum + +/* Optimized macros for use when the (FILE2 *) pointer is already known */ + +#define ybuf2(s2) ((s2)->_flag2 & _IOYOURBUF) +#define bigbuf2(s,s2) (mbuf(s) || ybuf2(s2)) +#define anybuf2(s,s2) ((s)->_flag & (_IOMYBUF|_IONBF) || ybuf2(s2)) diff --git a/Microsoft C v6ax/SOURCE/STARTUP/FMSGHDR.ASM b/Microsoft C v6ax/SOURCE/STARTUP/FMSGHDR.ASM new file mode 100644 index 0000000..b8ca489 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/FMSGHDR.ASM @@ -0,0 +1,123 @@ + page ,132 + title fmsghdr - far message handler and finder +;*** +;fmsghdr.asm - far message handler and finder +; +; Copyright (c) 1986-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; Far message handler and finder. +; +;******************************************************************************* + + +?DF= 1 ; this is special for c startup +include version.inc +?PLM= 1 ; pascal calling conventions +.xlist +include cmacros.inc +include msdos.inc +.list + +createSeg _TEXT, code, word, public, CODE, <> + +createSeg _DATA, data, word, public, DATA, DGROUP + +createSeg FAR_HDR,fhdr, byte, public, FAR_MSG,FMGROUP +createSeg FAR_MSG,fmsg, byte, public, FAR_MSG,FMGROUP +createSeg FAR_PAD,fpad, byte, common, FAR_MSG,FMGROUP +createSeg FAR_EPAD,fepad, byte, common, FAR_MSG,FMGROUP + +defGrp DGROUP ; define DGROUP +defGrp FMGROUP ; define FMGROUP + +codeOFFSET equ offset _TEXT: +fmsgOFFSET equ offset FMGROUP: + + +sBegin fhdr +assumes ds,data + + db '<>' +stfmsg label byte + +sEnd + +SBegin fpad +assumes ds,data + + dw -1 ; message padding marker + +sEnd + +sBegin fepad +assumes ds,data + + db -1 + +sEnd + + +sBegin code +assumes cs,code +assumes ds,data + +page +;*** +;__FMSG_TEXT(messagenumber) - find message for given message number +; +;Purpose: +; This routine returns a far pointer to the message associated with +; messagenumber. If the message does not exist, then a 0:0 is returned. +; +;Entry: +; ==PASCAL CALLING CONVENTIONS== +; messagenumber = WORD number of desired message +; +;Exit: +; DX:AX = pointer to message text or 0:0 if message doesn't exist +; +;Uses: +; +;Exceptions: +; +;******************************************************************************* + +cProc __FMSG_TEXT,, ; pascal calling + +parmW msgt + +cBegin + mov ax,FMGROUP + mov ds,ax ; ds = FMGROUP (force it always) + push ds + pop es + mov dx,msgt ; dx = message number + mov si,fmsgOFFSET stfmsg ; start of far messages + +tloop: + lodsw ; ax = current message number + cmp ax,dx + je found ; found it - return address + inc ax + xchg ax,si + jz found ; at end and not found - return 0 + xchg di,ax + xor ax,ax + mov cx,-1 + repne scasb ; skip until 00 + mov si,di + jmp tloop ; try next entry + +found: + xchg ax,si + cwd ; zero out dx in case NULL + or ax,ax + jz notfound + mov dx,ds ; remember segment selector +notfound: +cEnd + +sEnd + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/HEAP.INC b/Microsoft C v6ax/SOURCE/STARTUP/HEAP.INC new file mode 100644 index 0000000..afc998a --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/HEAP.INC @@ -0,0 +1,113 @@ +;*** +;heap.inc - definitions and structures for C library heap +; +; Copyright (c) 1987-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; This file contains definitions and structures used by +; the C library heap routines. +; +;******************************************************************************* + +; +; --- Heap segment descriptor --- +; +; [***NOTE*** Some heap routines make assumptions about the layout of the +; heap descriptor. If this descriptor changes, some routines may break.] +; + +_heap_seg_desc struc + checksum dw ? ; checksum area + flags dw ? ; flags word + segsize dw ? ; size of segment + start dw ? ; offset of first heap entry + rover dw ? ; rover offset + last dw ? ; offset to end-of-heap marker + nextseg dd ? ; far pointer to next _heap_seg_desc + prevseg dd ? ; far pointer to previous _heap_seg_desc +_heap_seg_desc ends + +; +; _heap_seg_desc.flags bit offsets +; + +_HEAP_MODIFY equ 01h ; heap segment size can be modified +_HEAP_FREE equ 02h ; heap segment may be freed up to OS +_HEAP_NEAR equ 04h ; heap segment is part of the near heap +_HEAP_BASED equ 08h ; heap segment is part of the based heap + +; +; --- Heap Linked List Descriptor --- +; +; [***NOTE*** Some heap routines make assumptions about the layout of the +; heap list descriptor. If this descriptor changes, some routines may break.] +; + +_heap_list_desc struc + startseg dd 0 ; pointer to first heap descriptor + roverseg dd 0 ; rover pointer + lastseg dd 0 ; pointer to last heap descriptor + segflags dw 0 ; flags word for init'ing new segs +_heap_list_desc ends + +; +; --- General Use Heap Constants --- +; + +_HEAP_END equ 0FFFEh ; End-of-heap flag +_HEAP_COALESCE equ 0FFFEh ; Coalesce segment value +_HEAP_GROWSEG equ 2 shl 12 ; Default (8K) heap seg growth increment +_HEAP_GROWSTART equ 2 shl 9 ; Startup heap seg growth size (1K) +_HEAP_MAXREQ equ 0FFFCh - (size _heap_seg_desc) ; Max heap request size +_HEAP_MINSEG equ ((size _heap_seg_desc) + 4) ; Min size heap segment + +; +; --- Heap Check/Set/Walk Definitions --- +; + +; Heap info structure used by heapwalk + +_heapinfo struc + _pentry_off dw ? ; far pointer to heap entry (offset) + _pentry_seg dw ? ; far pointer to heap entry (segment) + _size dw ? ; size of entry + _useflag dw ? ; in use flag +_heapinfo ends + +; +; Heap Check/Set/Walk Constants +; [NOTE: These definitions must match malloc.h] +; + +_HEAPEMPTY equ -1 +_HEAPOK equ -2 +_HEAPBADBEGIN equ -3 +_HEAPBADNODE equ -4 +_HEAPEND equ -5 +_HEAPBADPTR equ -6 + +_HEAPSET_NOFILL equ 07FFFh + +_FREEENTRY equ 0 +_USEDENTRY equ 1 + +; +; Return value denoting failure for based heap functions of based pointer +; return type. The name and definition must correspond to the one given +; in MALLOC.H. +; + +_NULLOFF equ -1 + + +IFDEF M_XENIX +; +; --- XENIX Heap Support --- +; + +BR_ARGSEG equ 1 ; specified segment +BR_NEWSEG equ 2 ; new segment +BR_IMPSEG equ 3 ; last or new segment +BR_FREESEG equ 4 ; free segment + +ENDIF diff --git a/Microsoft C v6ax/SOURCE/STARTUP/MAKEFILE b/Microsoft C v6ax/SOURCE/STARTUP/MAKEFILE new file mode 100644 index 0000000..43da09d --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/MAKEFILE @@ -0,0 +1,226 @@ +############################################################# +# +# Copyright (c) 1986-1990, Microsoft Corporation. All rights reserved. +# +# makefile for building c runtime startup objects +# and linking null c program +# +# This makefile is invoked by STARTUP.. +# See STARTUP. for usage information. +# +############################################################# + +SRC=.. +INC=.. + +CFLAGS=-A$(MODEL) -I$(INC) -I$(CINC) -Oart -Gs -c +CL=cl $(CFLAGS) + +ASMFLAGS= -Mx -Dmem_$(MODEL) -I$(INC) +ASM=masm $(ASMFLAGS) + +CMACROS=$(INC)\version.inc $(INC)\cmacros.inc + + +# target list + +all: dos os2 + +# DOS objects + +dos: \ + dos\crt0.obj \ + dos\crt0dat.obj \ + dos\crt0msg.obj \ + fmsghdr.obj \ + dos\nmsghdr.obj \ + chksum.obj \ + dos\stdargv.obj \ + dos\stdalloc.obj \ + dos\stdenvp.obj \ + dos\nchkstk.obj \ + dos\fchkstk.obj \ + dos\nrchkstk.obj \ + dos\frchkstk.obj \ + dos\_file.obj \ + ..\setargv.obj \ + dos\_setargv.obj \ + wild.obj \ + crt0fp.obj \ + dos\execmsg.obj \ + dos\nulbody.obj \ + dosstart + +# OS/2 objects + +os2: \ + os2\crt0.obj \ + os2\crt0dat.obj \ + os2\crt0msg.obj \ + fmsghdr.obj \ + os2\nmsghdr.obj \ + chksum.obj \ + os2\stdargv.obj \ + os2\stdalloc.obj \ + os2\stdenvp.obj \ + os2\nchkstk.obj \ + os2\fchkstk.obj \ + os2\nrchkstk.obj \ + os2\frchkstk.obj \ + os2\_file.obj \ + ..\setargv.obj \ + os2\_setargv.obj \ + wild.obj \ + crt0fp.obj \ + os2\nulbody.obj \ + os2start + +# .COM file (tiny model) support + +crtcom: ..\s\dos\crtcom.lib + + +# startup modules + +dos\crt0.obj: $(SRC)\dos\crt0.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\heap.inc $(INC)\rterr.inc + $(ASM) $(SRC)\dos\crt0.asm,dos\crt0.obj; + +os2\crt0.obj: $(SRC)\os2\crt0.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\heap.inc $(INC)\rterr.inc + $(ASM) $(SRC)\os2\crt0.asm,os2\crt0.obj; + +dos\crt0dat.obj: $(SRC)\dos\crt0dat.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) $(SRC)\dos\crt0dat.asm,dos\crt0dat.obj; + +os2\crt0dat.obj: $(SRC)\os2\crt0dat.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) $(SRC)\os2\crt0dat.asm,os2\crt0dat.obj; + +dos\crt0msg.obj: $(SRC)\dos\crt0msg.asm $(CMACROS) $(INC)\rterr.inc + $(ASM) $(SRC)\dos\crt0msg.asm,dos\crt0msg.obj; + +os2\crt0msg.obj: $(SRC)\os2\crt0msg.asm $(CMACROS) $(INC)\rterr.inc + $(ASM) $(SRC)\os2\crt0msg.asm,os2\crt0msg.obj; + +fmsghdr.obj: $(SRC)\fmsghdr.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) $(SRC)\fmsghdr.asm; + +dos\nmsghdr.obj: $(SRC)\dos\nmsghdr.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) $(SRC)\dos\nmsghdr.asm,dos\nmsghdr.obj; + +os2\nmsghdr.obj: $(SRC)\os2\nmsghdr.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) $(SRC)\os2\nmsghdr.asm,os2\nmsghdr.obj; + +chksum.obj: $(SRC)\chksum.asm $(CMACROS) $(INC)\rterr.inc + $(ASM) $(SRC)\chksum.asm; + +dos\stdargv.obj: $(SRC)\dos\stdargv.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\rterr.inc + $(ASM) $(SRC)\dos\stdargv.asm,dos\stdargv.obj; + +os2\stdargv.obj: $(SRC)\os2\stdargv.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\rterr.inc + $(ASM) $(SRC)\os2\stdargv.asm,os2\stdargv.obj; + +dos\stdalloc.obj: $(SRC)\dos\stdalloc.asm $(CMACROS) \ + $(INC)\heap.inc $(INC)\msdos.inc + $(ASM) $(SRC)\dos\stdalloc.asm,dos\stdalloc.obj; + +os2\stdalloc.obj: $(SRC)\os2\stdalloc.asm $(CMACROS) \ + $(INC)\heap.inc $(INC)\msdos.inc + $(ASM) $(SRC)\os2\stdalloc.asm,os2\stdalloc.obj; + +dos\stdenvp.obj: $(SRC)\dos\stdenvp.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\rterr.inc + $(ASM) $(SRC)\dos\stdenvp.asm,dos\stdenvp.obj; + +os2\stdenvp.obj: $(SRC)\os2\stdenvp.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\rterr.inc + $(ASM) $(SRC)\os2\stdenvp.asm,os2\stdenvp.obj; + +dos\nchkstk.obj: $(SRC)\chkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DMI_NEAR $(SRC)\chkstk.asm,dos\nchkstk.obj; + +dos\fchkstk.obj: $(SRC)\chkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DMI_FAR $(SRC)\chkstk.asm,dos\fchkstk.obj; + +os2\nchkstk.obj: $(SRC)\chkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DOS2 -DMI_NEAR $(SRC)\chkstk.asm,os2\nchkstk.obj; + +os2\fchkstk.obj: $(SRC)\chkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DOS2 -DMI_FAR $(SRC)\chkstk.asm,os2\fchkstk.obj; + +dos\nrchkstk.obj: $(SRC)\rchkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DMI_NEAR $(SRC)\rchkstk.asm,dos\nrchkstk.obj; + +dos\frchkstk.obj: $(SRC)\rchkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DMI_FAR $(SRC)\rchkstk.asm,dos\frchkstk.obj; + +os2\nrchkstk.obj: $(SRC)\rchkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DOS2 -DMI_NEAR $(SRC)\rchkstk.asm,os2\nrchkstk.obj; + +os2\frchkstk.obj: $(SRC)\rchkstk.asm $(CMACROS) $(INC)\msdos.inc + $(ASM) -DOS2 -DMI_FAR $(SRC)\rchkstk.asm,os2\frchkstk.obj; + +# .com file modules (tiny model) + +..\s\dos\com0.obj: $(SRC)\dos\crt0.asm $(CMACROS) $(INC)\heap.inc $(INC)\msdos.inc \ + $(INC)\rterr.inc + $(ASM) -D_COM_ $(SRC)\dos\crt0.asm,..\s\dos\com0.obj; + +..\s\dos\com0dat.obj: $(SRC)\dos\crt0dat.asm $(CMACROS) $(INC)\rterr.inc + $(ASM) -D_COM_ $(SRC)\dos\crt0dat.asm,..\s\dos\com0dat.obj; + +..\s\dos\crtcom.lib: ..\s\dos\com0.obj ..\s\dos\com0dat.obj + if exist ..\s\dos\crtcom.lib del ..\s\dos\crtcom.lib + lib ..\s\dos\crtcom.lib ..\s\dos\com0.obj+..\s\dos\com0dat.obj; + +# stdio file module + +dos\_file.obj: $(SRC)\_file.c $(CINC)\stdio.h $(INC)\file2.h + $(CL) -Zel -Fodos\_file.obj $(SRC)\_file.c + +os2\_file.obj: $(SRC)\_file.c $(CINC)\stdio.h $(INC)\file2.h + $(CL) -Zel -DOS2 -Foos2\_file.obj $(SRC)\_file.c + +# wild card expansion support modules + +..\setargv.obj: $(SRC)\setargv.asm $(CMACROS) + $(ASM) $(SRC)\setargv.asm,..\setargv.obj; + +dos\_setargv.obj: $(SRC)\dos\stdargv.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\rterr.inc + $(ASM) -DWILDCARD $(SRC)\dos\stdargv.asm,dos\_setargv.obj; + +os2\_setargv.obj: $(SRC)\os2\stdargv.asm $(CMACROS) $(INC)\msdos.inc \ + $(INC)\rterr.inc + $(ASM) -DWILDCARD $(SRC)\os2\stdargv.asm,os2\_setargv.obj; + +wild.obj: $(SRC)\wild.c $(CINC)\stdio.h $(CINC)\ctype.h $(INC)\register.h $(CINC)\ctype.h + $(CL) -Zel $(SRC)\wild.c + + +# error message modules + +crt0fp.obj: $(SRC)\crt0fp.asm $(CMACROS) $(INC)\rterr.inc + $(ASM) $(SRC)\crt0fp.asm; + +dos\execmsg.obj: $(SRC)\dos\execmsg.asm $(CMACROS) $(INC)\rterr.inc + $(ASM) $(SRC)\dos\execmsg.asm,dos\execmsg.obj; + + +# small program + +dos\nulbody.obj: $(SRC)\nulbody.c + $(CL) -Fodos\nulbody.obj $(SRC)\nulbody.c + +os2\nulbody.obj: $(SRC)\nulbody.c + $(CL) -Foos2\nulbody.obj $(SRC)\nulbody.c + +# this step is always done because the target does not exist + +dosstart: + link @$(SRC)\dos\nulbody.lnk + +os2start: + link @$(SRC)\os2\nulbody.lnk diff --git a/Microsoft C v6ax/SOURCE/STARTUP/MSDOS.H b/Microsoft C v6ax/SOURCE/STARTUP/MSDOS.H new file mode 100644 index 0000000..9c8e4dc --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/MSDOS.H @@ -0,0 +1,134 @@ +/*** +*msdos.h - MS-DOS definitions for C runtime +* +* Copyright (c) 1987-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* The file contains the MS-DOS definitions (function request numbers, +* flags, etc.) used by the C runtime. +* [Internal] +* +****/ + +/* __osfile flag values for DOS file handles */ + +#define FOPEN 0x01 /* file handle open */ +#define FEOFLAG 0x02 /* end of file has been encountered */ +#define FCRLF 0x04 /* CR-LF across read buffer (in text mode) */ +#define FPIPE 0x08 /* file handle refers to a pipe */ +#define FRDONLY 0x10 /* file handle associated with read only file */ +#define FAPPEND 0x20 /* file handle opened O_APPEND */ +#define FDEV 0x40 /* file handle refers to device */ +#define FTEXT 0x80 /* file handle is in text mode */ + +#define DOS_kill 0x00 /* terminate */ +#define DOS_echoread 0x01 /* read keyboard and echo */ +#define DOS_display 0x02 /* display character */ +#define DOS_auxinput 0x03 /* auxiliary input */ +#define DOS_auxoutput 0x04 /* auxiliary output */ +#define DOS_print 0x05 /* print character */ +#define DOS_conio 0x06 /* direct console i/o */ +#define DOS_coninput 0x07 /* direct console input */ +#define DOS_readkbd 0x08 /* read keyboard */ +#define DOS_message 0x09 /* display string */ +#define DOS_bufkbdin 0x0a /* buffered keyboard input */ +#define DOS_kbdstatus 0x0b /* check keyboard status */ +#define DOS_flshread 0x0c /* flush buffer and read keyboard */ +#define DOS_diskreset 0x0d /* disk reset */ +#define DOS_selectdisk 0x0e /* select default disk */ +#define DOS_fcbopen 0x0f /* open file with fcb */ +#define DOS_fcbclose 0x10 /* close file with fcb */ +#define DOS_fcbfirst 0x11 /* search for first entry with fcb */ +#define DOS_fcbnext 0x12 /* search for next entry with fcb */ +#define DOS_fcbdelete 0x13 /* delete file with fcb */ +#define DOS_fcbsread 0x14 /* sequential read with fcb */ +#define DOS_fcbswrite 0x15 /* sequential write with fcb */ +#define DOS_fcbcreate 0x16 /* create file with fcb */ +#define DOS_fcbrename 0x17 /* rename file with fcb */ +#define DOS_currentd 0x19 /* current default disk */ +#define DOS_setDMA 0x1a /* set DMA */ +#define DOS_fcbrread 0x21 /* random read with fcb */ +#define DOS_fcbrwrite 0x22 /* random write with fcb */ +#define DOS_fcbsize 0x23 /* file size with fcb */ +#define DOS_fcbsetrec 0x24 /* set relative record with fcb */ +#define DOS_setvector 0x25 /* set interrupt vector */ +#define DOS_fcbbread 0x27 /* random block read with fcb */ +#define DOS_fcbbwrite 0x28 /* random block write with fcb */ +#define DOS_fcbparse 0x29 /* parse file name with fcb */ +#define DOS_getdate 0x2a /* get date */ +#define DOS_setdate 0x2b /* set date */ +#define DOS_gettime 0x2c /* get time */ +#define DOS_settime 0x2d /* set time */ +#define DOS_verify 0x2e /* set/reset verify flag */ +#define DOS_getDMA 0x2f /* get DMA */ +#define DOS_version 0x30 /* get version number */ +#define DOS_keep 0x31 /* keep process */ +#define DOS_cntlc 0x33 /* Cntl-C check */ +#define DOS_getvector 0x35 /* get interrupt vector */ +#define DOS_getdskspc 0x36 /* get disk free space */ +#define DOS_country 0x38 /* get country dependent info */ +#define DOS_mkdir 0x39 /* make subdirectory */ +#define DOS_rmdir 0x3a /* remove subdirectory */ +#define DOS_chdir 0x3b /* change subdirectory */ +#define DOS_create 0x3c /* create pathname */ +#define DOS_open 0x3d /* open pathname */ +#define DOS_close 0x3e /* close file handle */ +#define DOS_read 0x3f /* read from file handle */ +#define DOS_write 0x40 /* write from file handle */ +#define DOS_delete 0x41 /* delete pathname */ +#define DOS_lseek 0x42 /* move file pointer */ +#define DOS_filemode 0x43 /* get/set attributes of pathname */ +#define DOS_ioctl 0x44 /* ioctl for devices */ +#define DOS_dup 0x45 /* duplicate file handle */ +#define DOS_forcedup 0x46 /* force duplicate file handle */ +#define DOS_curdir 0x47 /* get current directory */ +#define DOS_allocmem 0x48 /* allocate memory block */ +#define DOS_freemem 0x49 /* free memory block */ +#define DOS_setmem 0x4a /* set size of memory block */ +#define DOS_exec 0x4b /* load and execute program */ +#define DOS_terminate 0x4c /* terminate process with errorcode */ +#define DOS_wait 0x4d /* get child process return code */ +#define DOS_findfirst 0x4e /* find first file match */ +#define DOS_findnext 0x4f /* find next file match */ +#define DOS_getverify 0x54 /* return current verify flag */ +#define DOS_rename 0x56 /* rename pathname */ +#define DOS_filedate 0x57 /* get/set file handle date/time */ +#define DOS_locking 0x5C /* file record locking/unlocking */ +#define DOS_sleep 0x89 /* delay process execution */ + +/* DOS errno values for setting __doserrno in C routines */ + +#define E_ifunc 1 /* invalid function code */ +#define E_nofile 2 /* file not found */ +#define E_nopath 3 /* path not found */ +#define E_toomany 4 /* too many open files */ +#define E_access 5 /* access denied */ +#define E_ihandle 6 /* invalid handle */ +#define E_arena 7 /* arena trashed */ +#define E_nomem 8 /* not enough memory */ +#define E_iblock 9 /* invalid block */ +#define E_badenv 10 /* bad environment */ +#define E_badfmt 11 /* bad format */ +#define E_iaccess 12 /* invalid access code */ +#define E_idata 13 /* invalid data */ +#define E_unknown 14 /* ??? unknown error ??? */ +#define E_idrive 15 /* invalid drive */ +#define E_curdir 16 /* current directory */ +#define E_difdev 17 /* not same device */ +#define E_nomore 18 /* no more files */ +#define E_maxerr2 19 /* unknown error - Version 2.0 */ +#define E_sharerr 32 /* sharing violation */ +#define E_lockerr 33 /* locking violation */ +#define E_maxerr3 34 /* unknown error - Version 3.0 */ +#define E_exist 80 /* file already exists */ + +/* DOS file attributes */ + +#define A_RO 0x1 /* read only */ +#define A_H 0x2 /* hidden */ +#define A_S 0x4 /* system */ +#define A_V 0x8 /* volume id */ +#define A_D 0x10 /* directory */ +#define A_A 0x20 /* archive */ + +#define A_MOD (A_RO+A_H+A_S+A_A) /* changeable attributes */ diff --git a/Microsoft C v6ax/SOURCE/STARTUP/MSDOS.INC b/Microsoft C v6ax/SOURCE/STARTUP/MSDOS.INC new file mode 100644 index 0000000..0e2ed89 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/MSDOS.INC @@ -0,0 +1,183 @@ +;*** +;msdos.inc - MS-DOS definitions for C runtime +; +; Copyright (c) 1987-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; This file contains the MS-DOS definitions (DOS function request +; numbers, flags, etc) used by the C runtime. +; +;******************************************************************************* + + +;_NFILE equ 20 ; maximum # files per process + +ifdef OS2 +STACKSLOP equ 512 ; stack slop for OS/2 system call overhead +else +STACKSLOP equ 256 ; stack slop for DOS interrupt overhead +endif + +; __osfile flag values for DOS file handles + +FOPEN equ 01H ; file handle open +FEOFLAG equ 02H ; end of file has been encountered +FCRLF equ 04H ; CR-LF across read buffer (in text mode) +FPIPE equ 08H ; file handle refers to a pipe +FRDONLY equ 10H ; file handle associated with read only file +FAPPEND equ 20H ; file handle opened O_APPEND +FDEV equ 40H ; file handle refers to device +FTEXT equ 80H ; file handle is in text mode + + +callos MACRO func +ifnb + mov ah,DOS_&func +endif + int DOS + ENDM + + +DOS equ 21H ; MS-DOS interrupt + +DOS_exit equ 00000H ; exit offset (PSP:0000) +DOS_maxpara equ 00002H ; maximum paragraph (PSP:0002) +DOS_envp equ 0002cH ; environment address (PSP:002c) +DOS_cmdline equ 00080H ; command line offset (PSP:0080) + +DOS_kill equ 00H ; terminate +DOS_echoread equ 01H ; read keyboard and echo +DOS_display equ 02H ; display character +DOS_auxinput equ 03H ; auxiliary input +DOS_auxoutput equ 04H ; auxiliary output +DOS_print equ 05H ; print character +DOS_conio equ 06H ; direct console i/o +DOS_coninput equ 07H ; direct console input +DOS_readkbd equ 08H ; read keyboard +DOS_message equ 09H ; display string +DOS_bufkbdin equ 0aH ; buffered keyboard input +DOS_kbdstatus equ 0bH ; check keyboard status +DOS_flshread equ 0cH ; flush buffer and read keyboard +DOS_diskreset equ 0dH ; disk reset +DOS_selectdisk equ 0eH ; select default disk +DOS_fcbopen equ 0fH ; open file with fcb +DOS_fcbclose equ 10H ; close file with fcb +DOS_fcbfirst equ 11H ; search for first entry with fcb +DOS_fcbnext equ 12H ; search for next entry with fcb +DOS_fcbdelete equ 13H ; delete file with fcb +DOS_fcbsread equ 14H ; sequential read with fcb +DOS_fcbswrite equ 15H ; sequential write with fcb +DOS_fcbcreate equ 16H ; create file with fcb +DOS_fcbrename equ 17H ; rename file with fcb +DOS_currentd equ 19H ; current default disk +DOS_setDMA equ 1aH ; set DMA +DOS_fcbrread equ 21H ; random read with fcb +DOS_fcbrwrite equ 22H ; random write with fcb +DOS_fcbsize equ 23H ; file size with fcb +DOS_fcbsetrec equ 24H ; set relative record with fcb +DOS_setvector equ 25H ; set interrupt vector +DOS_fcbbread equ 27H ; random block read with fcb +DOS_fcbbwrite equ 28H ; random block write with fcb +DOS_fcbparse equ 29H ; parse file name with fcb +DOS_getdate equ 2aH ; get date +DOS_setdate equ 2bH ; set date +DOS_gettime equ 2cH ; get time +DOS_settime equ 2dH ; set time +DOS_verify equ 2eH ; set/reset verify flag +DOS_getDMA equ 2fH ; get DMA +DOS_version equ 30H ; get version number +DOS_keep equ 31H ; keep process +DOS_cntlc equ 33H ; Cntl-C check +DOS_getvector equ 35H ; get interrupt vector +DOS_getdskspc equ 36H ; get disk free space +DOS_country equ 38H ; get country dependent info +DOS_mkdir equ 39H ; make subdirectory +DOS_rmdir equ 3aH ; remove subdirectory +DOS_chdir equ 3bH ; change subdirectory +DOS_create equ 3cH ; create pathname +DOS_open equ 3dH ; open pathname +DOS_close equ 3eH ; close file handle +DOS_read equ 3fH ; read from file handle +DOS_write equ 40H ; write from file handle +DOS_delete equ 41H ; delete pathname +DOS_lseek equ 42H ; move file pointer +DOS_filemode equ 43H ; get/set attributes of pathname +DOS_ioctl equ 44H ; ioctl for devices +DOS_dup equ 45H ; duplicate file handle +DOS_forcedup equ 46H ; force duplicate file handle +DOS_curdir equ 47H ; get current directory +DOS_allocmem equ 48H ; allocate memory block +DOS_freemem equ 49H ; free memory block +DOS_setmem equ 4aH ; set size of memory block +DOS_exec equ 4bH ; load and execute program +DOS_terminate equ 4cH ; terminate process with errorcode +DOS_wait equ 4dH ; get child process return code +DOS_findfirst equ 4eH ; find first file match +DOS_findnext equ 4fH ; find next file match +DOS_getverify equ 54H ; return current verify flag +DOS_rename equ 56H ; rename pathname +DOS_filedate equ 57H ; get/set file handle date/time +DOS_createnew equ 5BH ; create new file +DOS_locking equ 5CH ; file record locking/unlocking +DOS_sleep equ 89H ; delay process execution + + +; DOS error codes + +doserr MACRO num,name,text +name equ num + ENDM + +doserr 1, E_ifunc, +doserr 2, E_nofile, +doserr 3, E_nopath, +doserr 4, E_toomany, +doserr 5, E_access, +doserr 6, E_ihandle, +doserr 7, E_arena, +doserr 8, E_nomem, +doserr 9, E_iblock, +doserr 10, E_badenv, +doserr 11, E_badfmt, +doserr 12, E_iaccess, +doserr 13, E_idata, +doserr 14, E_unknown, +doserr 15, E_idrive, +doserr 16, E_curdir, +doserr 17, E_difdev, +doserr 18, E_nomore, +doserr 19, E_maxerr2, + +; the following errors can occur only in DOS 3.0 + +doserr 32, E_sharerr, +doserr 33, E_lockerr, +doserr 34, E_maxerr3, + +doserr 80, E_exist, + + +; DOS file attributes + +A_ro equ 01H ; read-only file +A_h equ 02H ; hidden +A_s equ 04H ; system +A_v equ 08H ; volume ID +A_d equ 10H ; directory +A_a equ 20H ; archive + +A_mod equ A_ro+A_h+A_s+A_a ; modifiable attributes + +; OS/2 file creation bits + +F_CREATFLAG equ 10h +F_OPENFLAG equ 01h +F_TRUNCFLAG equ 02H + +; OS/2 device mask + +IS_DEV equ 1 +IS_PIPE equ 2 + +; end of msdos.inc +;----------------------------------------------------------------------- diff --git a/Microsoft C v6ax/SOURCE/STARTUP/NULBODY.C b/Microsoft C v6ax/SOURCE/STARTUP/NULBODY.C new file mode 100644 index 0000000..032204e --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/NULBODY.C @@ -0,0 +1,2 @@ +main() { +} diff --git a/Microsoft C v6ax/SOURCE/STARTUP/RCHKSTK.ASM b/Microsoft C v6ax/SOURCE/STARTUP/RCHKSTK.ASM new file mode 100644 index 0000000..56dccc0 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/RCHKSTK.ASM @@ -0,0 +1,171 @@ + page ,132 + title rchkstk - C stack checking routine (saves registers) +;*** +;rchkstk.asm - C stack checking routine (saves registers) +; +; Copyright (c) 1988-1990 Microsoft Corporation, All Rights Reserved +; +;Purpose: +; Provides support for automatic stack checking in C procedures +; when stack checking is enabled. The check stack routines built +; by this module save ALL registers across call (except CX). +; This routine is used when the user specifies the -Gr +; or _fastcall option. +; +;******************************************************************************* + +.xlist +?PLM=0 +?WIN=0 + +; +; Determine which version of chkstk we're building +; +ifdef MI_NEAR + memS equ 1 ; near version + _rchkstk equ <_aNrchkstk> +elseifdef MI_FAR + memM equ 1 ; far version + _rchkstk equ <_aFrchkstk> +else + %OUT *** ERROR: No model specified **** + .ERR +endif + +include cmacros.inc +include msdos.inc + +.list + + externNP _amsg_exit ; write error and die + + + +sBegin data +assumes ds,data + + extrn STKHQQ:word ; stack limit + +if sizeC + externCP _aaltstkovr ; alternate stack overflow +endif + +sEnd data + + +sBegin code +assumes ds,data +assumes cs,code + +page +;*** +;_rchkstk - check stack upon procedure entry (saves registers) +; +;Purpose: +; Provides support for automatic stack checking in C procedures +; when stack checking is enabled. The check stack routines built +; by this module save ALL registers across call (except CX). +; This routine is used when the user specifies the -Gr +; or _fastcall option. +; +; [LLIBCDLL.LIB NOTE: Unlike other LLIBCDLL routines, DS != DGROUP +; when chkstk() is called.] +; +;Entry: +; CX = size of local frame +; +;Exit: +; SP = new stackframe if successful +; +;Uses: +; *** Preserves all registers except CX *** +; +;Exceptions: +; Gives out of memory error and aborts if there is not enough +; stack space for the routine. +; +;******************************************************************************* + + +% labelP + +; +; --- Calculate the new SP --- +; + + push si ; save si/di around calculation + push di + + mov di,sp ; di = sp + sub di,cx ; di = new position + jc stack_err ; error - out of stack + + + + + cmp di,[STKHQQ] ; new position ok ? + jb stack_err ; nope - out of stack + + + + +; +; --- New SP value is ok --- +; Move the return values down to where the new SP will be, restore bx, +; and return. [NOTE: Be careful to always keep SP at the bottom of the +; stack in case an interrupt occurs during this sequence.] +; +; di = new SP +; + + mov si,sp ; si = old sp + mov sp,di ; sp = final value + jcxz done ; no moves needed if 0 temps + + mov cx,ss ; es = ss + mov es,cx + + movs word ptr es:[di],word ptr ss:[si] ; move saved di + movs word ptr es:[di],word ptr ss:[si] ; move saved si + movs word ptr es:[di],word ptr ss:[si] ; move saved return off +if sizeC + movs word ptr es:[di],word ptr ss:[si] ; move saved return seg +endif + + +done: + pop di ; restore di/si + pop si +if sizeC + retf ; far return to caller +else + retn ; near return to caller +endif + + +; +; --- ERROR: Stack overflow --- +; + + +stack_err: + +if sizeC + pop di ; make return on top of stack + pop si + mov ax,word ptr [_aaltstkovr] + inc ax ; alt stack overflow handler defined ?? + jnz altstkovr ; jump, if so +endif + + xor ax,ax ; ax = _RT_STACK = 0 + jmp _amsg_exit ; give stack overflow and die + +if sizeC +altstkovr: + jmp [_aaltstkovr] ; Pascal/FORTRAN stack overflow +endif + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/REGISTER.H b/Microsoft C v6ax/SOURCE/STARTUP/REGISTER.H new file mode 100644 index 0000000..64fdae2 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/REGISTER.H @@ -0,0 +1,21 @@ +/*** +*register.h - definitions for register variable specifiers +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* This file contains definitions for register variable specifiers. +* [Internal] +* +****/ + +#define REG1 register +#define REG2 register + +#define REG3 +#define REG4 +#define REG5 +#define REG6 +#define REG7 +#define REG8 +#define REG9 diff --git a/Microsoft C v6ax/SOURCE/STARTUP/RTERR.INC b/Microsoft C v6ax/SOURCE/STARTUP/RTERR.INC new file mode 100644 index 0000000..a50acae --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/RTERR.INC @@ -0,0 +1,136 @@ + +;*** +;rterr.inc - Runtime Error Messages +; +; Copyright (c) 1988-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; This file contains all of the fatal C library runtime error +; messages and a macro that allows routines to easily set up +; the message format. +; +;******************************************************************************* + + +; +; --- Runtime Error Constants --- +; [NOTE: These must be 3-char strings (see _RTERR macro).] +; + +_RT_STACK equ <000> ; stack overflow +_RT_NULLPTR equ <001> ; null pointer assignment +_RT_FLOAT equ <002> ; floating point not loaded +_RT_INTDIV equ <003> ; integer divide by 0 +; <004> +;--- The following 3 EXEC message must be in order (see DOS exec code) --- +_RT_EXECMEM equ <005> ; not enough memory on exec +_RT_EXECFORM equ <006> ; bad format on exec +_RT_EXECENV equ <007> ; bad environment on exec +;--- +_RT_SPACEARG equ <008> ; not enough space for arguments +_RT_SPACEENV equ <009> ; not enough space for environment +_RT_ABORT equ <010> ; Abnormal program termination +; <011> +_RT_NPTR equ <012> ; illegal near pointer use +_RT_FPTR equ <013> ; illegal far pointer use +_RT_BREAK equ <014> ; control-BREAK encountered (QC 1.0 only) +_RT_INT equ <015> ; unexpected interrupt (QC 1.0 only) +_RT_THREAD equ <016> ; not enough space for thread data +_RT_LOCK equ <017> ; unexpected multi-thread lock error +_RT_HEAP equ <018> ; unexpected heap error +_RT_CRNL equ <252> ; \r\n +_RT_BANNER equ <255> ; runtime error (banner) + +; +; The 3 EXEC messages must be in order for DOS (see DOS exec code). +; + +.ERRE (_RT_EXECFORM EQ _RT_EXECMEM+1) +.ERRE (_RT_EXECENV EQ _RT_EXECFORM+1) + +; +; --- Message types --- +; [See _RTERR macro description for info on these types.] +; + +_RT_STANDARD equ 1 +_RT_STRING equ 2 +_RT_DOLLAR equ 3 + + +;*** +; _RTERR - Macro to generate runtime error message data entries +; +;Purpose: +; +; Generate the appropriate data format for +; various types of runtime error messages. +; +; Standard C library error numbers have the format: +; +; R6 +; +; where: +; R = Error occurred at runtime +; 6 = C library routine error series +; = 3-digit code indicating the error that occurred +; +;Entry: +; errnum = runtime error number (one of the above parameters) +; errmsg = ascii string with error message in it +; msgtype = message type: +; _RT_STANDARD = standard 'R6' message format +; _RT_STRING = simply store the supplied string +; _RT_DOLLAR = terminate message with '$' +; (for use with DOS EXEC messages) +; +;Exit: +; Allocate storage as follows: +; +; _RT_STANDARD: +; dw +; db 'R6',13,10,'- ',13,10,0 +; +; _RT_STRING: +; dw +; db '',0 +; +; _RT_DOLLAR: +; dw +; db 13,10,'run-time error ' +; db 'R6',13,10,'- ',13,10,'$',0 +; +;Exceptions: +; +;******************************************************************************* + + +; +; Form the message data as follows: +; (1) Store the error number +; (2) Form the appropriate ascii message (based on message type) +; (3) Terminate message with a null char +; +; [To get masm to store the ascii value of the error number, prepend a +; '%' char to the errnum arg and call a second macro to build the string.] +; + +_RTERR MACRO errnum, errmsg, msgtype + _RTERR1 %&errnum, , msgtype + ENDM + +_RTERR1 MACRO errnum, errmsg, msgtype + dw errnum + IF (msgtype EQ _RT_STANDARD) + db 'R6&errnum',13,10,'- ',&errmsg,13,10 + ELSEIF (msgtype EQ _RT_STRING) + db &errmsg + ELSEIF (msgtype EQ _RT_DOLLAR) + db 13,10,'run-time error ' + db 'R6&errnum',13,10,'- ',&errmsg,13,10,'$' + ELSE + %OUT Unknown _RTERR option + .ERR + ENDIF + db 0 + ENDM diff --git a/Microsoft C v6ax/SOURCE/STARTUP/SETARGV.ASM b/Microsoft C v6ax/SOURCE/STARTUP/SETARGV.ASM new file mode 100644 index 0000000..0817e37 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/SETARGV.ASM @@ -0,0 +1,53 @@ + page ,132 + title setargv - generic _setargv routine +;*** +;setargv.asm - generic _setargv routine +; +; Copyright (c) 1986-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; Generic _setargv. +; This stub module is for use with all memory models +; and for both Protected-mode and Real-mode libraries. +; +;******************************************************************************* + + +include version.inc +.xlist +include cmacros.inc +.list + + public __setargv ; this module + + extrn ___setargv:near ; actual wildcard expander + +sBegin code + + assumes cs,code +;*** +;_setargv - sets argv by calling __setargv +; +;Purpose: +; Routine directly transfers to __setargv (defined in stdargv.asm). +; +;Entry: +; See __setargv. +; +;Exit: +; See __setargv. +; +;Uses: +; See __setargv. +; +;Exceptions: +; See __setargv. +; +;******************************************************************************* + +__setargv: + jmp ___setargv ; jump to library routine to do real work + +sEnd code + + end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/STARTUP.BAT b/Microsoft C v6ax/SOURCE/STARTUP/STARTUP.BAT new file mode 100644 index 0000000..f4b66f1 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/STARTUP.BAT @@ -0,0 +1,107 @@ +echo off +REM +REM Copyright (c) 1986-1990, Microsoft Corporation. All rights reserved. +REM +REM batch file used to invoke make file to build startup +REM Usage: startup [os] (models) +REM [os] is an optional parameter specifying the operating +REM system: use either "DOS" or "OS2", if neither is +REM given, both are built +REM (models) is a blank separated list of memory +REM model designators as follows: +REM S: small model +REM M: medium model +REM C: compact model +REM L: large model +REM Examples: +REM startup OS2 S M +REM builds small and medium model objects for OS/2 +REM and links with null c program +REM +REM startup S C M L +REM builds objects for all memory models +REM and links with null c program + +if NOT "%1" == "" goto firstdir +echo Usage: startup [os] (models) +echo [os] is an optional operating system designator, either +echo DOS or OS2 +echo (models) is a blank separated list of memory +echo model designators as follows: +echo S: small model +echo M: medium model +echo C: compact model +echo L: large model +echo Example: +echo startup DOS S M +echo builds small and medium model DOS objects and +echo links with null c program +goto end + +:firstdir +SET TARGET=all + +if "%1" == "DOS" goto dos +if not "%1" == "dos" goto notdos +:dos +SET TARGET=DOS +shift +goto nextdir + +:notdos +if "%1" == "OS2" goto os2 +if not "%1" == "os2" goto notos2 +:os2 +SET TARGET=OS2 +shift +goto nextdir + +:notos2 +:nextdir +if "%1" == "" goto finished + +if "%1" == "S" goto argok +if "%1" == "M" goto argok +if "%1" == "C" goto argok +if "%1" == "L" goto argok +echo off +echo Error: invalid argument to startup.bat +echo The valid arguments to startup.bat are S, M, C, L, DOS and OS2. +echo The model designators must be upper case. +goto end + +:argok +echo You may see directory creation errors -- ignore these. +echo on +mkdir %1 +mkdir %1\dos +mkdir %1\os2 +cd %1 +nmk CINC=%INCLUDE% MODEL=%1 %TARGET% /F ..\makefile +IF ERRORLEVEL 1 goto failure + +echo off +rem check for Small model DOS objects, build crtcom.obj for them +if %TARGET%==OS2 goto nocrtcom +if NOT %1==S goto nocrtcom +echo on +nmk CINC=%INCLUDE% MODEL=%1 crtcom /F ..\makefile +if errorlevel 1 goto failure + +:nocrtcom +echo off + +cd .. + +shift +goto nextdir + +:failure +echo off +ECHO *** startup build/link failed *** + +:finished +set TARGET= +echo **** Finished + +:end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/STARTUP.CMD b/Microsoft C v6ax/SOURCE/STARTUP/STARTUP.CMD new file mode 100644 index 0000000..857f376 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/STARTUP.CMD @@ -0,0 +1,107 @@ +echo off +REM +REM Copyright (c) 1986-1990, Microsoft Corporation. All rights reserved. +REM +REM batch file used to invoke make file to build startup +REM Usage: startup [os] (models) +REM [os] is an optional parameter specifying the operating +REM system: use either "DOS" or "OS2", if neither is +REM given, both are built +REM (models) is a blank separated list of memory +REM model designators as follows: +REM S: small model +REM M: medium model +REM C: compact model +REM L: large model +REM Examples: +REM startup OS2 S M +REM builds small and medium model objects for OS/2 +REM and links with null c program +REM +REM startup S C M L +REM builds objects for all memory models +REM and links with null c program + +if NOT "%1" == "" goto firstdir +echo Usage: startup [os] (models) +echo [os] is an optional operating system designator, either +echo DOS or OS2 +echo (models) is a blank separated list of memory +echo model designators as follows: +echo S: small model +echo M: medium model +echo C: compact model +echo L: large model +echo Example: +echo startup DOS S M +echo builds small and medium model DOS objects and +echo links with null c program +goto end + +:firstdir +SET TARGET=all + +if "%1" == "DOS" goto dos +if not "%1" == "dos" goto notdos +:dos +SET TARGET=DOS +shift +goto nextdir + +:notdos +if "%1" == "OS2" goto os2 +if not "%1" == "os2" goto notos2 +:os2 +SET TARGET=OS2 +shift +goto nextdir + +:notos2 +:nextdir +if "%1" == "" goto finished + +if "%1" == "S" goto argok +if "%1" == "M" goto argok +if "%1" == "C" goto argok +if "%1" == "L" goto argok +echo off +echo Error: invalid argument to startup.bat +echo The valid arguments to startup.bat are S, M, C, L, DOS and OS2. +echo The model designators must be upper case. +goto end + +:argok +echo You may see directory creation errors -- ignore these. +echo on +mkdir %1 +mkdir %1\dos +mkdir %1\os2 +cd %1 +nmake CINC=%INCLUDE% MODEL=%1 %TARGET% /F ..\makefile +IF ERRORLEVEL 1 goto failure + +echo off +rem check for Small model DOS objects, build crtcom.obj for them +if %TARGET%==OS2 goto nocrtcom +if NOT %1==S goto nocrtcom +echo on +nmake CINC=%INCLUDE% MODEL=%1 crtcom /F ..\makefile +if errorlevel 1 goto failure + +:nocrtcom +echo off + +cd .. + +shift +goto nextdir + +:failure +echo off +ECHO *** startup build/link failed *** + +:finished +set TARGET= +echo **** Finished + +:end diff --git a/Microsoft C v6ax/SOURCE/STARTUP/VERSION.INC b/Microsoft C v6ax/SOURCE/STARTUP/VERSION.INC new file mode 100644 index 0000000..8767645 --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/VERSION.INC @@ -0,0 +1,33 @@ +;*** +;version.inc - defines current memory model +; +; Copyright (c) 1987-1990, Microsoft Corporation. All rights reserved. +; +;Purpose: +; This file defines the current memory model being used. +; +;******************************************************************************* + +?PLM= 0 + +ifdef _WINDOWS + ?WIN= 1 ; windows entry/exit sequence +else + ?WIN= 0 +endif + +ifdef mem_s + memS equ 1 ; small model +endif + +ifdef mem_m + memM equ 1 ; medium model +endif + +ifdef mem_c + memC equ 1 ; compact model +endif + +ifdef mem_l + memL equ 1 ; large model +endif diff --git a/Microsoft C v6ax/SOURCE/STARTUP/WILD.C b/Microsoft C v6ax/SOURCE/STARTUP/WILD.C new file mode 100644 index 0000000..723767a --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/WILD.C @@ -0,0 +1,299 @@ +/*** +*wild.c - wildcard expander +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* expands wildcards in argv +* +* handles '*' (none or more of any char), '?' (exactly one char), and +* '[string]' (chars which match string chars or between n1 and n2 if +* 'n1-n2'in string inclusive) +* +*******************************************************************************/ + +#include +#include +#include +#include + + +/* +** these are the data structures +** +** __argv +** ------- ------ +** | |---->| |---->"arg0" +** ------- ------ +** | |---->"arg1" +** ------ +** .... +** ------ +** | |---->"argn" +** ------ +** |NULL| +** ------ +** argend +** ------- +** ------- | | +** | | __argc ------- +** ------- | +** | +** arghead V +** ------ --------- ---------- +** | |---->| | |----> .... ---->| |NULL| +** ------ --------- ---------- +** | | +** V V +** "narg0" "nargn" +*/ + +#define SLASHCHAR '\\' +#define FWDSLASHCHAR '/' +#define SLASH "\\" +#define FWDSLASH "/" +#define STAR "*.*" + +#define WILDSTRING "*?" + +char *strdup(); +char *strpbrk(); +char *strcpy(); +char *strncpy(); +char *strcat(); +char *malloc(); +char *_find(); + +static int match (); +static int add (); +static sort (); + + extern int __argc; + extern char * * __argv; + +struct argnode { + char *argptr; + struct argnode *nextnode; +}; + +static struct argnode *arghead; +static struct argnode *argend; + +/*** +*int _cwild() - wildcard expander +* +*Purpose: +* expands wildcard in file specs in argv +* +* handles '*' (none or more of any char), '?' (exactly one char), and +* '[string]' (chars which match string chars or between n1 and n2 +* if 'n1-n2' in string inclusive) +* +*Entry: +* +*Exit: +* returns 0 if successful, -1 if any malloc() calls fail +* if problems with malloc, the old argc and argv are not touched +* +*Exceptions: +* +*******************************************************************************/ + +int +_cwild () +{ + REG1 char **argv = __argv; + REG2 struct argnode *nodeptr; + REG3 int argc; + REG4 char **tmp; + char *wchar; + int ptr, sptr, arglen; + + arghead = argend = NULL; + + for (argv = __argv; *argv; argv++) /* for each arg... */ + if ( *(*argv)++ == '"' ) + /* strip leading quote from quoted arg */ + { + if (add(*argv)) + return(-1); + } + else if (wchar = strpbrk( *argv, WILDSTRING )) { + /* attempt to expand arg with wildcard */ + if (match( *argv, wchar )) + return(-1); + } + else if (add( *argv )) /* normal arg, just add */ + return(-1); + + /* count the args */ + for (argc = 0, nodeptr = arghead; nodeptr; + nodeptr = nodeptr->nextnode, argc++) + ; + + /* try to get new arg vector */ + if (!(tmp = (char **)malloc(sizeof(char *)*(argc+1)))) + return(-1); + + /* the new arg vector... */ + __argv = tmp; + + /* the new arg count... */ + __argc = argc; + + /* install the new args */ + for (nodeptr = arghead; nodeptr; nodeptr = nodeptr->nextnode) + *tmp++ = nodeptr->argptr; + + /* the terminal NULL */ + *tmp = NULL; + + /* free up local data */ + for (nodeptr = arghead; nodeptr; nodeptr = arghead) { + arghead = arghead->nextnode; + free(nodeptr); + } + + /* return success */ + return(0); +} + + +/*** +*match(arg, ptr) - [STATIC] +* +*Purpose: +* +*Entry: +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +static int +match (arg, ptr) +REG4 char *arg; +REG1 char *ptr; +{ + REG2 char *new; + REG3 int length; + char *all; + REG5 struct argnode *first; + REG6 int gotone = 0; + + while (ptr != arg && *ptr != SLASHCHAR && *ptr != FWDSLASHCHAR + && *ptr != ':') { + /* find first slash or ':' before wildcard */ + ptr--; + } + + if (*ptr == ':' && ptr != arg+1) /* weird name, just add it as is */ + return(add(arg)); + + if (*ptr == SLASHCHAR || *ptr == FWDSLASHCHAR + || *ptr == ':') /* pathname */ + length = ptr - arg + 1; /* length of dir prefix */ + + if (new = _find(arg)) { /* get the first file name */ + first = argend; + + do { /* got a file name */ + if (strcmp(new, ".") && strcmp(new, "..")) { + if (*ptr != SLASHCHAR && *ptr != ':' + && *ptr != FWDSLASHCHAR ) { + /* current directory; don't need path */ + if (!(arg = strdup(new)) || add(arg)) + return(-1); + } + else /* add full pathname */ + if (!(all=malloc(length+strlen(new)+1)) + || add(strcpy(strncpy(all,arg,length)+length,new) + - length)) + return(-1); + + gotone++; + } + + } + while (new = _find(NULL)); /* get following files */ + + if (gotone) { + sort(first ? first->nextnode : arghead); + return(0); + } + } + + return(add(arg)); /* no match */ +} + +/*** +*add(arg) - [STATIC] +* +*Purpose: +* +*Entry: +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +static int +add (arg) +char *arg; +{ + REG1 struct argnode *nodeptr; + + if (!(nodeptr = (struct argnode *)malloc(sizeof(struct argnode)))) + return(-1); + + nodeptr->argptr = arg; + nodeptr->nextnode = NULL; + + if (arghead) + argend->nextnode = nodeptr; + else + arghead = nodeptr; + + argend = nodeptr; + return(0); +} + + +/*** +*sort(first) - [STATIC] +* +*Purpose: +* +*Entry: +* +*Exit: +* +*Exceptions: +* +*******************************************************************************/ + +static +sort (first) +REG2 struct argnode *first; +{ + REG1 struct argnode *nodeptr; + REG3 char *temp; + + if (first) /* something to sort */ + while (nodeptr = first->nextnode) { + do { + if (strcmp(nodeptr->argptr, first->argptr) < 0) { + temp = first->argptr; + first->argptr = nodeptr->argptr; + nodeptr->argptr = temp; + } + } + while (nodeptr = nodeptr->nextnode); + + first = first->nextnode; + } +} diff --git a/Microsoft C v6ax/SOURCE/STARTUP/_FILE.C b/Microsoft C v6ax/SOURCE/STARTUP/_FILE.C new file mode 100644 index 0000000..f0a130e --- /dev/null +++ b/Microsoft C v6ax/SOURCE/STARTUP/_FILE.C @@ -0,0 +1,88 @@ +/*** +*_file.c - perprocess file and buffer data declarations +* +* Copyright (c) 1985-1990, Microsoft Corporation. All rights reserved. +* +*Purpose: +* file and buffer data declarations +* +*******************************************************************************/ + +#include +#include + +#define _NEAR_ near + +/* Number of files */ + +#define _NFILE_ 20 + +/* + * Buffer for stdin. + * Declare it such that the data space is allocated at .EXE load time, not in + * the .EXE file itself. Under DOS, this means that it must be declared near. + */ + +#ifdef OS2 +char _bufin[BUFSIZ]; +#else +char _NEAR_ _bufin[BUFSIZ]; +#endif + + +/* + * FILE descriptors; preset for stdin/out/err/aux/prn + */ + + +FILE _NEAR_ _cdecl _iob[ _NFILE_ ] = { + /* ptr, cnt, base, flag, file */ + { + _bufin, 0, _bufin, _IOREAD, 0 } + , + { + NULL, 0, NULL, _IOWRT, 1 } + , + { + NULL, 0, NULL, _IOWRT, 2 } + , +#ifndef OS2 + { + NULL, 0, NULL, _IORW|_IONBF, 3 } + , + { + NULL, 0, NULL, _IOWRT, 4 } + , +#endif +}; + + +/* + * FILE2 descriptors; preset for stdin/out/err/aux/prn + */ + + +FILE2 _NEAR_ _iob2[ _NFILE_ ] = { + /* flag2, charbuf */ + { + _IOYOURBUF, '\0', BUFSIZ } + , + { + 0, '\0', 0 } + , + { + 0, '\0', 0 } + , +#ifndef OS2 + { + 0, '\0', 0 } + , + { + 0, '\0', 0 } + , +#endif +}; + + +/* pointer to end of descriptors */ +FILE * _NEAR_ _lastiob = &_iob[ _NFILE_ -1];