wmauda: Fix installation dir
[dockapps.git] / wmpower-0.4.3 / src / power_management / lib_utils / lib_utils.c
blob0c6ef3cecb1f92b8405247a744727a4aef82c691
1 /***************************************************************************
2 lib_utils.c - description
3 -------------------
4 begin : Sun Jan 20 15:34:25 CET 2002
5 copyright : (C) 2002-2004 by Noberasco Michele
6 e-mail : noberasco.gnu@disi.unige.it
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 * *
26 ***************************************************************************/
28 #define MAX 255
30 #include <dirent.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <stdarg.h>
35 #include <time.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <fcntl.h>
39 #include <unistd.h>
40 #include <envz.h>
41 #include "lib_utils.h"
44 char *jump_next_line(char *ptr)
46 char *temp;
48 if (!ptr) return NULL;
50 for (temp=ptr; temp[0]!='\0'; temp++)
51 if (temp[0] == '\n') return (temp+1);
53 return NULL;
56 /* append any number of strings to dst */
57 char *StrApp (char **dst, ...)
59 int len = 1;
60 char *pt, *temp;
61 va_list va;
63 if (dst) if (*dst) len += strlen(*dst);
64 va_start(va, dst);
65 for (;;)
67 pt = va_arg(va, char *);
68 if (!pt) break;
69 len += strlen(pt);
72 va_end (va);
74 temp = (char *) calloc((size_t)len, sizeof(char));
76 if (dst) if (*dst)
78 strcpy(temp, *dst);
79 free(*dst);
82 va_start(va, dst);
84 for (;;)
86 pt = va_arg(va, char *);
87 if (!pt) break;
88 strcat(temp, pt);
90 va_end (va);
92 if (dst) *dst = temp;
94 return temp;