Exemple #1
0
void            main (int argc, char *argv[])
{
#define	BITSTR_BUFSIZE	140
    FILE           *instream;
    FILE           *aa_stderr = stderr;
    char            stringbuf[BITSTR_BUFSIZE + 2];
    char            charbuf[9 * BITSTR_BUFSIZE];
    char            fname_tree[80];
    int             mychar;
    int             oops;
    int             i;
    union {
	INT             integer;
	char            chars[2];
    }               charcount;

    if (argc <= 1) {
	puts ("Usage:  hdecode [hucfile] cypherfile");
	return;
    }
    if (argc >= 3) {
	hctree = NULL;
	append_ext (fname_tree, sizeof (fname_tree), argv[1], EXT_HDECODE);
	hctree_name = fname_tree;
	argv++;
    }
    if ((instream = fopen (argv[1], "rb")) == NULL) {
	fprintf (aa_stderr, "Cannot open cypherfile '%s'.\n", argv[1]);
	exit (2);
    }
MAINLOOP:
    /**************/
    if ((mychar = fgetc (instream)) == EOF)
	return;
    charcount.chars[0] = mychar;
    if ((mychar = fgetc (instream)) == EOF)
	return;
    charcount.chars[1] = mychar;
    if (charcount.integer > sizeof (charbuf) - 2) {
	oops = TRUE;
	charcount.integer = sizeof (charbuf) - 2;
    }
    else
	oops = FALSE;
/*    printf("\n\n***** charcount = %d %s*****\n",
	charcount.integer, (oops) ? "(reduced)" : "");*/
    for (i = 0; i < BITSTR_BUFSIZE; i++) {
	if ((mychar = fgetc (instream)) == EOF) {
	    fprintf (aa_stderr, "\n" PROGNAME "202 Unexpected EOF '%s'.\n",
		argv[1]);
	    exit (2);
	}
	stringbuf[i] = mychar;
    }
    hc_decode (stringbuf, charbuf, charcount.integer, hctree_id);
    for (i = 0; i < charcount.integer; i++)
	putchar (charbuf[i]);
    goto MAINLOOP;
    /************/
}  /* end of function main */
Exemple #2
0
static int frsave( LWFileReqLocal *local, OPENFILENAME *ofn )
{
   int result;

   ofn->Flags |= OFN_HIDEREADONLY;
   result = GetSaveFileName( ofn );

   if ( result ) {
      local->result = 1;

      if (( unsigned ) strlen( ofn->lpstrFile ) >= local->bufLen ) {
         local->result = -1;
         return 0;
      }

      if ( !strchr( ofn->lpstrFile, '.' ))
         append_ext( ofn->lpstrFile, ofn->lpstrFilter );

      strcpy( local->fullName, ofn->lpstrFile );
      strcpy( local->path, ofn->lpstrFile );
      local->path[ ofn->nFileOffset ] = 0;
      strcpy( local->baseName, ofn->lpstrFile + ofn->nFileOffset );

   }
   else
      local->result = 0;

   return 1;
}