1
/* Copyright (C) 2011 Edward Der-Hua Liu, Hsin-Chu, Taiwan
3
* This library is free software; you can redistribute it and/or
4
* modify it under the terms of the GNU Lesser General Public
5
* License as published by the Free Software Foundation; either
6
* version 2.1 of the License, or (at your option) any later version.
8
* This library is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with this library; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
#if !CLIENT_LIB || DEBUG
25
void p_err(char *fmt,...)
31
vsprintf(out, fmt, args);
35
fprintf(stderr, "%s\n", out);
37
if (getenv("NO_GTK_INIT"))
38
fprintf(stderr, "%s\n", out);
40
GtkWidget *dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
45
gtk_dialog_run (GTK_DIALOG (dialog));
46
gtk_widget_destroy (dialog);
53
if (getenv("HIME_ERR_COREDUMP"))
59
#if !CLIENT_LIB || DEBUG
60
static void init_out_fp()
63
if (getenv("HIME_DBG_TMP") || 0) {
65
sprintf(fname, "/tmp/himedbg-%d-%d", getuid(), getpid());
66
out_fp = fopen(fname, "w");
76
void dbg_time(char *fmt,...)
84
struct tm *ltime = localtime(&t);
85
dbg("%02d:%02d:%02d ", ltime->tm_hour, ltime->tm_min, ltime->tm_sec);
88
vfprintf(out_fp, fmt, args);
95
void __hime_dbg_(char *fmt,...)
102
vfprintf(out_fp, fmt, args);
110
return (char *)strerror(errno);
121
void *memdup(void *p, int n)
131
// can handle eol with \n \r \n\r \r\n
132
char *myfgets(char *buf, int bufN, FILE *fp)
136
while (!feof(fp) && out - buf < bufN) {
139
if (fread(&a, 1, 1, fp) != 1)
143
if (fread(&b, 1, 1, fp)==1)
145
fseek(fp, -1, SEEK_CUR);
150
if (fread(&b, 1, 1, fp)==1)
152
fseek(fp, -1, SEEK_CUR);