| 1 | /* |
| 2 | * libvidstab.c |
| 3 | * |
| 4 | * Created on: Feb 21, 2011 |
| 5 | * Copyright (C) Georg Martius - February 2011 |
| 6 | * |
| 7 | * This file is part of transcode, a video stream processing tool |
| 8 | * |
| 9 | * transcode is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * transcode is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with GNU Make; see the file COPYING. If not, write to |
| 21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include "libvidstab.h" |
| 26 | |
| 27 | #include <string.h> |
| 28 | #include <stdio.h> |
| 29 | #include <stdarg.h> |
| 30 | |
| 31 | /**** default values for memory and logging ****/ |
| 32 | |
| 33 | /// memory allocation with zero initialization |
| 34 | void* _zalloc(size_t size){ |
| 35 | return memset(malloc(size),0,size); |
| 36 | } |
| 37 | |
| 38 | /// logging function |
| 39 | int _vs_log(int type, const char* tag, const char* format, ...){ |
| 40 | fprintf(stderr,"%s (%s):", |
| 41 | type == VS_ERROR_TYPE ? "Error: " : |
| 42 | type == VS_WARN_TYPE ? "Warn: " : |
| 43 | type == VS_INFO_TYPE ? "Info: " : |
| 44 | type == VS_MSG_TYPE ? "Msg: " : "Unknown", |
| 45 | tag); |
| 46 | va_list ap; |
| 47 | va_start (ap, format); |
| 48 | vfprintf (stderr, format, ap); |
| 49 | va_end (ap); |
| 50 | fprintf(stderr,"\n"); |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | vs_malloc_t vs_malloc = malloc; |
| 56 | vs_realloc_t vs_realloc = realloc; |
| 57 | vs_free_t vs_free = free; |
| 58 | vs_zalloc_t vs_zalloc = _zalloc; |
| 59 | |
| 60 | vs_strdup_t vs_strdup = strdup; |
| 61 | |
| 62 | vs_log_t vs_log = _vs_log; |
| 63 | int VS_ERROR_TYPE = 0; |
| 64 | int VS_WARN_TYPE = 1; |
| 65 | int VS_INFO_TYPE = 2; |
| 66 | int VS_MSG_TYPE = 3; |
| 67 | |
| 68 | int VS_ERROR = -1; |
| 69 | int VS_OK = 0; |
| 70 | |
| 71 | /* |
| 72 | * Local variables: |
| 73 | * c-file-style: "stroustrup" |
| 74 | * c-file-offsets: ((case-label . *) (statement-case-intro . *)) |
| 75 | * indent-tabs-mode: nil |
| 76 | * End: |
| 77 | * |
| 78 | * vim: expandtab shiftwidth=4: |
| 79 | */ |