libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

init.c (703B)


      1 /*
      2  * init.c
      3  * libansilove 1.2.4
      4  * https://www.ansilove.org
      5  *
      6  * Copyright (c) 2011-2020 Stefan Vogt, Brian Cassidy, and Frederic Cambus
      7  * All rights reserved.
      8  *
      9  * libansilove is licensed under the BSD 2-Clause License.
     10  * See LICENSE file for details.
     11  */
     12 
     13 #include <sys/mman.h>
     14 
     15 #include <string.h>
     16 #include "ansilove.h"
     17 
     18 int
     19 ansilove_init(struct ansilove_ctx *ctx, struct ansilove_options *options)
     20 {
     21 	if (ctx == NULL || options == NULL) {
     22 		if (ctx)
     23 			ctx->error = ANSILOVE_INVALID_PARAM;
     24 
     25 		return -1;
     26 	}
     27 
     28 	memset(ctx, 0, sizeof(*ctx));
     29 	memset(options, 0, sizeof(*options));
     30 
     31 	ctx->buffer = MAP_FAILED;
     32 
     33 	/* default to 8 if bits option is not specified */
     34 	options->bits = 8;
     35 
     36 	return 0;
     37 }