Beispiel #1
0
int main(int argc, char *argv[])
{
    int pkfd,skfd;
    unsigned char pk[crypto_box_PUBLICKEYBYTES];
    unsigned char sk[crypto_box_SECRETKEYBYTES];
    if(argc!=3) err_usage();
    pkfd = open_excl(argv[1]); if(pkfd==-1) err_open(argv[1]);
    skfd = open_excl(argv[2]); if(skfd==-1) err_open(argv[2]);
    if(crypto_box_keypair(pk,sk)!=0) err_keypair();
    if(write(pkfd,pk,sizeof(pk))!=sizeof(pk)) err_write(argv[1]);
    if(write(skfd,sk,sizeof(sk))!=sizeof(sk)) err_write(argv[2]);
    return 0;
}
Beispiel #2
0
void OpenExec()
{
	if(open_exec(tempname1)==-1)
	{
		CopyFile(oldfilename,tempname1);
		if(open_exec(tempname1)==-1) err_open(tempname1);
	}
}
int main(int argc, char *argv[])
{
    int skfd;
    unsigned char sk[crypto_secretbox_KEYBYTES];
    if(argc!=2) err_usage();
    skfd = open_excl(argv[1]); if(skfd==-1) err_open(argv[1]);
    randombytes(sk,crypto_secretbox_KEYBYTES);
    if(write(skfd,sk,sizeof(sk))!=sizeof(sk)) err_write(argv[1]);
    return 0;
}
Beispiel #4
0
int main(int argc, char *argv[])
{
  char outname[PATHLEN];
  char line[PATHLEN];
  char temp[PATHLEN];
  char *file;
  FFIND *ff;
  FILE *fp=NULL;
  word dofile, i;

  if (argc < 3)
    usage();

  strcpy(outname, argv[1]);

  if (!strchr(outname, '.'))
    strcat(outname, ".fiz");

  if ((outfile=fopen(outname, "w+b"))==NULL)
    err_open(temp);

  make_crctable();

  for (i=2; i < argc; i++)
  {
    dofile=FALSE;
      
    if (*argv[i]=='@')
    {
      dofile=TRUE;

      argv[i]++;
      
      if ((fp=fopen(argv[i], "r"))==NULL)
      {
        printf("Error reading %s!\n", argv[i]);
        continue;
      }
    }

    while (!dofile || fgets(line, PATHLEN, fp))
    {
      if (fp)
      {
        word x;

        if (line[x=strlen(line)-1]=='\n')
          line[x]='\0';

        file=line;
      }
      else file=argv[i];
      
      if ((ff=FindOpen(file, 0))==NULL)
      {
        printf("can't find %s\n", file);
        continue;
      }

      do
      {
        char *p;

        strcpy(temp, file);

        p=strrchr(temp, '\\');

        if (p)
          p[1]='\0';
        else *temp='\0';

        strcat(temp, ff->szName);

        if (stricmp(temp, outname) != 0)
          arcit(temp);
      }
      while (FindNext(ff)==0);

      FindClose(ff);

      if (!dofile)
        break;
    }
    
    if (dofile)
    {
      fclose(fp);
      fp=NULL;
    }
  }

  fclose(outfile);

  return 0;
}
Beispiel #5
0
void arcit(char *inname)
{
  struct _fizhdr fh;
  char *p;
  long pos;

  if ((infile=fopen(inname, "rb"))==NULL)
    err_open(inname);

  printf("archiving %s", inname);
  fflush(stdout);

  origsize=compsize=unpackable=0;
  
  crc=INIT_CRC;
  
  pos=ftell(outfile);
  
  if (fwrite((char *)&fh, sizeof(fh), 1, outfile) != 1)
    err_write("archive");

  /* strip off the path specification */

  if ((p=strrchr(inname, '\\'))==NULL)
    p=inname;
  else p++;

  if (fwrite(p, strlen(p), 1, outfile) != 1)
    err_write("archive");

  
  encode();

  if (unpackable)
  {
    printf("storing");
    fflush(stdout);

    fh.method=0;
    fseek(outfile, pos+sizeof(fh)+strlen(p), SEEK_SET);
    fseek(infile, 0L, SEEK_SET);
    store();
  }
  else
  {
    fh.method=1;
  }

  fh.id=FIZ_ID;
  fh.fnlen=strlen(p);
  fh.origsize=origsize;
  fh.compsize=compsize;
  fh.crc = crc;
  get_fdt(fileno(infile), &fh.date);

  fseek(outfile, pos, SEEK_SET);

  if (fwrite((char *)&fh, sizeof(fh), 1, outfile) != 1)
    err_write("archive");

  fseek(outfile, 0L, SEEK_END);

  fclose(infile);

  printf("\n");
}