⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mem.c

📁 使用于OS/2下的小工具的C源程序,使用于OS/2下的小工具的C源程序
💻 C
字号:
/*
* MEM.C - Displays the largest free block of RAM memory.
*
* PROGRAMMER:	    Martti Ylikoski
* CREATED:	    5.12.1990
*/
static char *VERSION="Version  1.1. Copyright(c) Martti Ylikoski, 1990, 1991. " ;
/*
* NOTE: When making dual-mode program use _bios_memsize.
*/

#include <stdio.h>
#include <string.h>
//#undef MSDOS
#ifdef MSDOS
#include <bios.h>
#else
#define INCL_DOS
#include <os2.h>
#endif
#include <param.h>
#include <paramstd.h>
ParamEntry pentry[12] = {
     "P", &ParamSetPause, 0,
     "F", &ParamSetFold, 0,
     "V", &ParamSetVerbose, 1,
     "R", &ParamSetReport, 1,
     "S", &ParamSetSubDirs, 0,
     "?", &ParamSetHelp, 1,
     "H", &ParamSetHelp, 1,
     "NOD", &ParamSetNoDefault, 0,
     "TEST", &ParamSetTest, 0,
     "Y", &ParamSetYes, 0,
     "N", &ParamSetTest, 0,
     "\0", NULL, 0
} ;

ParamBlock params = {
    "/-",   IGNORECASE | NOPRIORITY | NOTRIGGERSALLOWED ,
    pentry
} ;

static char *progname, *fname	;
extern unsigned long pflags ; /* needed because of paramstd */

int main(int argc, char *argv[])
{
#ifdef MSDOS
unsigned long size ;
#else
ULONG size ;
#endif
char p1[15], p2[15] ;
int i, j ;

   progname = argv[0] ;

   ParamHandle(&params, &argc, argv) ;

   if (pflags & PA_HELP)
   {
      printf("%s - displays the size of the largest contiguous free block of memory.\n", progname) ;
      puts(VERSION) ;
      puts("Usage: mem [/R] | [/V] | [/? | /H]") ;
      puts("Where,") ;
      puts("     /R    = Report    /V = Verbose");
      puts("     /H,/? = Help") ;
      return( 0 ) ;
   }



   if (pflags & PA_VERBOSE)
#ifdef MSDOS
      printf("_bios_memsize (INT 0x12) \n") ;
   size = 1024 * _bios_memsize() ;
#else
      printf("DosMemAvail()\n") ;
   DosMemAvail(&size) ;
#endif


   sprintf(p1, "%lu", size ) ;
   strrev(p1) ;

   for (i=0, j = 0; i < strlen(p1) ; i++, j++)
   {
      if (i%3 == 0 && i != 0)
      {
	p2[j] = ',' ;
	j++;
      }

      p2[j] = p1[i] ;
   }
   p2[j] = '\0' ;
   strrev(p2) ;

   if (pflags & PA_REPORT)
      printf("[MEM]\nFreemem = %lu", size) ;
   else
      printf("\nLargest block of free memory is %s bytes.\n", p2) ;
   return( 0 ) ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -