Example #1
0
static long
write_and_compress_bytes(FILE *file, char *addr, long bytes, os_vm_offset_t file_offset,
                         int compression)
{
    long here, data;

    bytes = (bytes+os_vm_page_size-1)&~(os_vm_page_size-1);

#ifdef LISP_FEATURE_WIN32
    long count;
    /* touch every single page in the space to force it to be mapped. */
    for (count = 0; count < bytes; count += 0x1000) {
        volatile int temp = addr[count];
    }
#endif

    fflush(file);
    here = ftell(file);
    fseek(file, 0, SEEK_END);
    data = (ftell(file)+os_vm_page_size-1)&~(os_vm_page_size-1);
    fseek(file, data, SEEK_SET);
    write_bytes_to_file(file, addr, bytes, compression);
    fseek(file, here, SEEK_SET);
    return ((data - file_offset) / os_vm_page_size) - 1;
}
Example #2
0
int writebyte(int myfile, int byte)
{
	struct flos_file *flosfile;

	flosfile = (char *) myfile;
	if (flosfile->name[0]==0)
		return (-1);

	if (write_bytes_to_file( (flosfile)->name, &byte, get_bank(), 1) != 0)
		return (-1);
	flosfile->position++;
	
	return (byte);
}
Example #3
0
int					convert_to_binary(t_function *functions, char *filename)
{
	t_list		*bytes;
	t_list		*bytes_end;
	t_list		*size_bytes;

	bytes = NULL;
	bytes_end = NULL;
	if (!(add_exec_magic_to_bytes(&bytes, &bytes_end)))
		return (0);
	if (!(size_bytes = add_header_to_bytes(functions, &bytes_end)))
		return (0);
	if (!(add_functions(functions->next, &bytes_end)))
		return (0);
	if (!(update_size_bytes(size_bytes, functions->next)))
		return (0);
	return (write_bytes_to_file(filename, bytes));
}
Example #4
0
int main(int argc, char *argv[])
{
    if (argc < 2 || argc > 3) {
        fprintf(stderr, "usage: %s [bytes] pathname\n", argv[0]);
        return 1;
    }

    char *filename = argc == 2 ? argv[1] : argv[2];
    int smin = 0, smax = 10000, sdef = 100, s = argc == 2 ? sdef : atoi(argv[1]);

    if ((s < smin) || (s > smax)) { s = sdef; }

    if (write_rlimit_fsize() != 0) { return 1; }
    if (set_soft_rlimit_fsize(50) != 0) { return 1; }
    if (write_bytes_to_file(filename, s) != 0) { return 1; }

    return 0;
}