/*
**    $Id: globalcompact.c,v 1.2 1993/06/26 22:11:15 pjs Exp $
**    Copyright (C) 1993  Patrick Sweeney
**
**    This program is free software; you can redistribute it and/or modify
**    it under the terms of the GNU General Public License as published by
**    the Free Software Foundation; either version 2 of the License, or
**    any later version.
**
**    This program is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with this program; if not, write to the Free Software
**    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "windows.h"
#include "memory.h"
#include "handle.h"
#include <stdio.h>

/* Ordinal=25 */
DWORD
GlobalCompact(DWORD dwMinFree)
{
	FILE *f;
	char buf[255];
	long int phys, swap, dummy;

	if ((f = fopen("/proc/meminfo", "r")) == NULL)
	{
		/* did you mount /proc? */
		return 0;
	}
	if (fscanf(f, "%s", buf) != 1)
		return 0;
	if (fscanf(f, "%s%ld%ld%ld", buf, &dummy, &dummy, &phys) != 4 ||
	    fscanf(f, "%s%ld%ld%ld", buf, &dummy, &dummy, &swap) != 4)
		return 0;
	return (DWORD) (phys + swap);
}
