how to get percentage
#9
this one should compile cleanly with gcc.

Code:
$ cat print-restore.c
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <sys/stat.h>
#include <time.h>
#include <getopt.h>
#include <unistd.h>

typedef uint32_t uint;
typedef uint64_t uint64;

typedef struct
{
  uint   version_bin;
  char   cwd[256];
  uint   argc;
  char   argv[30][256];
  uint   pw_min;
  uint64 pw_skip;
  char   unused[232];

} restore_data_t;

static void read_restore (const char *eff_restore_file, restore_data_t *rd)
{
  FILE *fp = fopen (eff_restore_file, "rb");

  if (fp == NULL)
  {
    fprintf (stderr, "ERROR: restore file '%s': %s\n", eff_restore_file, strerror (errno));

    exit (-1);
  }

  size_t nread = fread (rd, sizeof (restore_data_t), 1, fp);

  if (nread != 1)
  {
    fprintf (stderr, "ERROR: cannot read %s\n", eff_restore_file);

    exit (-1);
  }

  fclose (fp);

  if (chdir (rd->cwd))
  {
    fprintf (stderr, "ERROR: cannot chdir to %s: %s\n", rd->cwd, strerror (errno));

    exit (-1);
  }
}

int main (int argc, char *argv[])
{
  if (argc != 2)
  {
    fprintf (stderr, "usage: %s restore-file\n", argv[0]);

    return (-1);
  }

  restore_data_t *rd = (restore_data_t *) malloc (sizeof (restore_data_t));

  memset (rd, 0, sizeof (restore_data_t));

  read_restore (argv[1], rd);

  printf ("%llu\n", rd->pw_skip);

  return 0;
}


Messages In This Thread
how to get percentage - by koursan - 09-17-2011, 12:03 AM
RE: how to get percentage - by atom - 09-17-2011, 09:45 AM
RE: how to get percentage - by tonygr82 - 10-04-2011, 10:25 PM
RE: how to get percentage - by atom - 10-05-2011, 09:42 AM
RE: how to get percentage - by tonygr82 - 10-05-2011, 04:37 PM
RE: how to get percentage - by tonygr82 - 10-07-2011, 06:09 AM
RE: how to get percentage - by atom - 10-07-2011, 09:36 AM
RE: how to get percentage - by tonygr82 - 10-07-2011, 05:30 PM
RE: how to get percentage - by atom - 10-07-2011, 05:49 PM
RE: how to get percentage - by tonygr82 - 10-08-2011, 05:18 PM
RE: how to get percentage - by KT819GM - 10-08-2011, 06:08 PM
RE: how to get percentage - by tonygr82 - 10-08-2011, 06:40 PM
RE: how to get percentage - by koursan - 10-09-2011, 10:41 AM
RE: how to get percentage - by tonygr82 - 10-14-2011, 07:57 AM
RE: how to get percentage - by atom - 10-14-2011, 09:38 AM
RE: how to get percentage - by atom - 10-24-2011, 12:37 PM