Category : Files from Magazines
Archive   : MAR91.ZIP
Filename : 2N03072A

 
Output of file : 2N03072A contained in archive : MAR91.ZIP
/* Push.C - This program, when used with Pop.C, provides
a mechanism by which the current working disk
and path may be saved in a memory stack and
restored later by Pop.C.

Warning: This software uses undocumented
features of MS-DOS

Copyright Michael Klos 1990, All rights reserved.

Compiles with Microsoft Quick C, Large or Huge Model
*/

#ifdef Debug
#include /* For debug only */
#endif

#include
#include
#include
#include "Push_Pop.h"

void main(void)
{
word allocation_mode;
word path_buffer;

/* Get and save the current memory
allocation strategy. */
allocation_mode = _dos_getmemmode();

/* Change the strategy to get a block
from the end of memory. */
_dos_setmemmode(_allocate_last);

if (_dos_allocmem((_MAX_PATH+15)/16, &path_buffer)) {
_dos_setmemmode(allocation_mode); /* Restore */
exit(1);
}
/* Restore strategy. */
_dos_setmemmode(allocation_mode);

#ifdef Debug
printf("Segment allocated for path is: %4X\n", path_buffer);
#endif

FP_OFF(mem) = 0;
FP_SEG(mem) = path_buffer - 1;

/* Assign ownership of this memory block to push/pop by
assigning a block owner that MS-DOS cannot assign and
which pop can identify later */

mem->block[1] = low(Signature);
mem->block[2] = high(Signature);

/* Get the current working directory. */
getcwd(&mem->block[16], _MAX_PATH);

#ifdef Debug
printf("Current directory is: %s\n", &mem->block[16]);
#endif
exit(0); /* Report success */
}

int _dos_getmemmode(void)
{
union REGS registers;

/* WARNING: UNDOCUMENTED MS-DOS FUNCTION */
/* Get the current memory allocation strategy. */
registers.x.ax = 0x5800;
return intdos(®isters, ®isters);
}

void _dos_setmemmode(int strategy)
{
union REGS registers;

/* WARNING: UNDOCUMENTED MS-DOS FUNCTION */
/* Set a new memory allocation strategy. */
registers.x.ax = 0x5800;
registers.h.bl = (unsigned char) strategy;
intdos(®isters, ®isters);
}


  3 Responses to “Category : Files from Magazines
Archive   : MAR91.ZIP
Filename : 2N03072A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/