Artifact 7c4a77b60767c783c091da402f82a3df38b40ed7f3c8f07198990c36cf3954b4:
- File misc.c — part of check-in [c14cf350df] at 2014-05-15 21:36:21 on branch manualheaven — Move src and doc files to top directory (user: base@atomicules.co.uk size: 1874) [more...]
- File
src/misc.c
— part of check-in
[11403de3f1]
at
2011-01-30 19:00:30
on branch origin/tweaks
— Fix more compiler warnings
git-svn-id: https://pwman.svn.sourceforge.net/svnroot/pwman/trunk@117 db5f1c25-4851-472e-ac1e-5437d07aece1 (user: gagravarr@users.sourceforge.net size: 1874)
/* * PWMan - Password Management Software * * Copyright (C) 2002 Ivan Kelly <ivan@ivankelly.net> * * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdlib.h> #include <pwman.h> #include <ui.h> void _stderr_print(char *fmt, va_list ap) { int d, c; char *s; while(*fmt){ if(*fmt == '%'){ switch(*++fmt){ case 's': /* string */ s = va_arg(ap, char*); fputs(s, stderr); break; case 'd': /* int */ d = va_arg(ap, int); fprintf(stderr, "%d", d); break; case 'c': /* char */ c = va_arg(ap, int); fputc(c, stderr); break; default: fputc('%', stderr); fputc(*fmt, stderr); break; } } else { fputc(*fmt, stderr); } *fmt++; } va_end(ap); fputc('\n', stderr); } void pw_abort(char *fmt, ... ) { va_list ap; va_start(ap, fmt); _stderr_print(fmt, ap); exit(1); } void debug(char *fmt, ... ) { #ifdef DEBUG va_list ap; fputs("PWMan Debug% ", stderr); va_start(ap, fmt); _stderr_print(fmt, ap); #endif } char * trim_ws(char *str) { int i; for(i = (strlen(str) - 1); i >= 0; i--){ if(str[i] != ' '){ return str; } else { str[i] = 0; } } ui_statusline_msg(str); }