It was thus said that the Great Jochen Kunz once stated:
On Sat, 26 Nov 2011 17:09:18 +0100
"nierveze" <nierveze at radio-astronomie.com> wrote:
is the a tool to make proms from *.bin output
from compilers?
that is to say a program that divides the 16 bits into two slices of 8
bits to make proms?
It would be helpfull to know the OS on which you have to do
this.
On somthing unixish I would write a piece of C, about:
open( input);
fstat( input, &stat);
input_buf = mmap( input);
close( input);
open( out_put_even);
lseek( output_even, stat.size / 2 - 1);
write( output_even, "", 1);
output_even_buf = mmap( output_even);
close( output_even);
open( out_put_odd);
lseek( output_odd, stat.size / 2 - 1);
write( output_,odd "", 1);
output_odd_buf = mmap( output_odd);
close( output_odd);
for (size_t i = 0; i < stat.size; i += 2) {
output_even_buf[i / 2] = input_buf[i];
output_odd_buf[i / 2] = input_buf[i + 1];
}
munmap( output_even);
munmap( output_odd);
Chuck's is more portable I think, to non-Unix systems. Alternatively:
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
int i;
if (argc == 1)
{
fprintf(stderr,"usage: %s inputfile...\n",argv[0]);
return EXIT_FAILURE;
}
for (i = 1 ; i < argc ; i++)
{
char evenname[FILENAME_MAX];
char oddname [FILENAME_MAX];
FILE *fpin;
FILE *fpeven;
FILE *fpodd;
int c;
int odd;
sprintf(evenname,"%s.even",argv[i]);
sprintf(oddname, "%s.odd", argv[i]);
fpin = fopen(argv[i],"rb");
if (fpin == NULL)
{
perror(argv[i]);
continue;
}
fpeven = fopen(evenname,"wb");
if (fpeven == NULL)
{
perror(evenname);
fclose(fpin);
continue;
}
fpodd = fopen(oddname,"wb");
if (fpodd == NULL)
{
perror(oddname);
fclose(fpeven);
fclose(fpin);
continue;
}
odd = 0;
while((c = fgetc(fpin)) != EOF)
{
if (odd)
fputc(c,fpodd);
else
fputc(c,fpeven);
odd = !odd;
}
fclose(fpodd);
fclose(fpeven);
fclose(fpin);
}
return EXIT_SUCCESS;
}
is portable to anything with an ANSI C compiler (C89).
-spc (And can be run on a directory full of files)