summaryrefslogtreecommitdiff
path: root/revdep/utility.h
blob: d98ade12ec5d0d2fca329f48ad02e0c53ca57ff8 (plain)
    1 // Copyright (C) 2015 James Buren
    2 //
    3 // This file is part of revdep.
    4 //
    5 // revdep is free software: you can redistribute it and/or modify
    6 // it under the terms of the GNU General Public License as published by
    7 // the Free Software Foundation, either version 3 of the License, or
    8 // (at your option) any later version.
    9 //
   10 // revdep is distributed in the hope that it will be useful,
   11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 // GNU General Public License for more details.
   14 //
   15 // You should have received a copy of the GNU General Public License
   16 // along with revdep.  If not, see <http://www.gnu.org/licenses/>.
   17 
   18 #pragma once
   19 
   20 #define new(T,N)     ((T*)xmalloc(sizeof(T)*(N)))
   21 #define renew(P,T,N) ((T*)xrealloc((P),sizeof(T)*(N)))
   22 
   23 typedef void (*parse_cb_t) (int record, int field, char *start, char *end);
   24 
   25 enum
   26 {
   27 	LOG_BRIEF,
   28 	LOG_INFO_1,
   29 	LOG_INFO_2,
   30 	LOG_ERROR,
   31 	LOG_DEBUG
   32 };
   33 
   34 extern void *xmalloc(unsigned int bytes);
   35 extern void *xrealloc(void *p, unsigned int bytes);
   36 extern char *xstrdup(const char *in);
   37 extern void logger(int level, const char *fmt, ...) __attribute__((format(printf,2,3)));
   38 extern char *strtrim(char *s);
   39 extern unsigned int string_crc32(const char *s);
   40 extern int open_file_in_memory(const char *path, int *fd, char **text, unsigned int *length);
   41 extern void close_file_in_memory(int fd, char *text, unsigned int length);
   42 extern int parse_file_in_memory(char *text, parse_cb_t cb);
   43 extern int get_ld_for_file(const char *pkg, const char *path, const char **ld);

Generated by cgit