libansilove

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

init.c (747B)


      1 /*
      2  * init.c
      3  * libansilove 1.3.1
      4  * https://www.ansilove.org
      5  *
      6  * Copyright (c) 2011-2022 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  * SPDX-License-Identifier: BSD-2-Clause
     13  */
     14 
     15 #include <sys/mman.h>
     16 
     17 #include <string.h>
     18 #include "ansilove.h"
     19 
     20 int
     21 ansilove_init(struct ansilove_ctx *ctx, struct ansilove_options *options)
     22 {
     23 	if (ctx == NULL || options == NULL) {
     24 		if (ctx)
     25 			ctx->error = ANSILOVE_INVALID_PARAM;
     26 
     27 		return -1;
     28 	}
     29 
     30 	memset(ctx, 0, sizeof(*ctx));
     31 	memset(options, 0, sizeof(*options));
     32 
     33 	ctx->buffer = MAP_FAILED;
     34 
     35 	/* default to 8 if bits option is not specified */
     36 	options->bits = 8;
     37 
     38 	return 0;
     39 }