// Active user phonebook viewer with decrypted passwords :-)
// (c) DZh, one of last day of 1998 year
// Visual C++ note:
//   Add rasapi32.lib into you Project/Settings/Link/Object_Modules
#include <windows.h>
#include <stdio.h>
#include <ras.h>

#define MAX_ENTRIES 20

void main(void)
{
  LPRASENTRYNAME EntryArray = new (RASENTRYNAME[MAX_ENTRIES]);
  DWORD lpcb = sizeof(RASENTRYNAME)*MAX_ENTRIES;
  DWORD lpcEntries;
  DWORD i, e;
  int lpfPassword;
  RASDIALPARAMS DialEntry;
  RASENTRY EntryParam;
  DWORD dwEntryInfoSize = sizeof(RASENTRY);

  printf("Active phonebook:\n");
  printf("Entry : Phone : Login/Pass\n");
  EntryArray[0].dwSize = sizeof(RASENTRYNAME);
  if( (e = RasEnumEntries( NULL, "", EntryArray, &lpcb,
                                          &lpcEntries)) == 0 )
    for(i=0;i<lpcEntries;i++)
    {
      strcpy(DialEntry.szEntryName, EntryArray[i].szEntryName);
      DialEntry.dwSize = sizeof(RASDIALPARAMS);
      RasGetEntryDialParams("", &DialEntry, &lpfPassword );

      EntryParam.dwSize = sizeof(RASENTRY);
      RasGetEntryProperties("", DialEntry.szEntryName,
                    &EntryParam, &dwEntryInfoSize, NULL, NULL);

      printf("%s : %s : %s/%s\n", DialEntry.szEntryName,
            EntryParam.szLocalPhoneNumber,
            DialEntry.szUserName,
            lpfPassword==1?DialEntry.szPassword:"no_password");
    }
  else
    printf("RasEnumEntries error? Code:%d\n", e);
}
