/*
   grab.c - "grap" a specified part of a file
   Linux Ripper's Toolkit v0.1(BETA)
   by Belgorath <belgo@share.net>
*/

#include <stdio.h>

int main(int argc, char *argv[])
{
  FILE *fp1;
  FILE *fp2;
  int x;

  if(argc!=5) {
    printf("Usage: grab <file> <start_pos> <length> <outfile>\r\n");
    exit(-1);
  }
  if((fp1=fopen(argv[1],"r"))==NULL) {
    printf("grab: unable to open input.\r\n");
    exit(-1);
  }
  if((fp2=fopen(argv[4],"w"))==NULL) {
    printf("grab: unable to open output.\r\n");
    exit(-1);
  }
  fseek(fp1,atol(argv[2]),SEEK_SET);
  for(x=0;x<atol(argv[3]);x++) fputc(fgetc(fp1),fp2);
  fclose(fp1);
  fclose(fp2);
}
