1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-07-01 04:06:23 +03:00
fped/util.h
werner 5a86125002 Added Postscript outout for measurements, plus assorted changes.
- postscript.c: added patterns backhatchpath and crosspath (for pad overlaid 
  with solder paste)
- postscript.c: added measurements
- postscript.c: prefixed style parameters with PS_ to avoid future conflicts
  with gui_style.h
- when changing the default unit, we now cancel the selection, and refresh 
  canvas and current position
- on-screen measurements now suppress the unit if set to anything but "auto"
- use  __attribute__((format(printf, ...))) for printf-like functions
- the unit selector now has a white background to make it clearer that it can 
  be clicked



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5461 99fdad57-331a-0410-800a-d7fa5415bdb3
2009-08-16 11:21:48 +00:00

60 lines
1.4 KiB
C

/*
* util.h - Common utility functions
*
* Written 2006, 2009 by Werner Almesberger
* Copyright 2006, 2009 Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef UTIL_H
#define UTIL_H
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#define alloc_size(s) \
({ void *alloc_size_tmp = malloc(s); \
if (!alloc_size_tmp) \
abort(); \
alloc_size_tmp; })
#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
#define zalloc_type(t) \
({ t *zalloc_type_tmp = alloc_type(t); \
memset(zalloc_type_tmp, 0, sizeof(t)); \
zalloc_type_tmp; })
#define stralloc(s) \
({ char *stralloc_tmp = strdup(s); \
if (!stralloc_tmp) \
abort(); \
stralloc_tmp; })
#define strnalloc(s, n) \
({ char *strnalloc_tmp = alloc_size((n)+1); \
if (!strnalloc_tmp) \
abort(); \
strncpy(strnalloc_tmp, (s), (n)); \
strnalloc_tmp[n] = 0; \
strnalloc_tmp; })
char *stralloc_vprintf(const char *fmt, va_list ap);
char *stralloc_printf(const char *fmt, ...)
__attribute__((format(printf, 1, 2)));
int is_id_char(char c, int first);
int is_id(const char *s);
const char *unique(const char *s);
#endif /* !UTIL_H */