4 * berrno is a simplistic errno handler that works for
5 * Unix, Win32, and Bacula bpipes.
7 * See berrno.h for how to use berrno.
9 * Kern Sibbald, July MMIV
15 Copyright (C) 2004 Kern Sibbald and John Walker
17 This program is free software; you can redistribute it and/or
18 modify it under the terms of the GNU General Public License as
19 published by the Free Software Foundation; either version 2 of
20 the License, or (at your option) any later version.
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public
28 License along with this program; if not, write to the Free
29 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
36 const char *berrno::strerror()
41 if (errnum && b_errno_win32) {
42 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
43 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
46 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
51 pm_strcpy(&buf_, msg);
53 return (const char *)buf_;
56 if (bstrerror(berrno_, buf_, 1024) < 0) {
57 return "Invalid errno. No error message possible.";
59 return (const char *)buf_;
76 fileset = (FILESET *)malloc(sizeof(FILESET));
77 memset(fileset, 0, sizeof(FILESET));
78 fileset->mylist.init();
80 printf("Manual allocation/destruction of list:\n");
82 for (int i=0; i<20; i++) {
83 sprintf(buf, "This is item %d", i);
84 fileset->mylist.append(bstrdup(buf));
86 for (int i=0; i< fileset->mylist.size(); i++) {
87 printf("Item %d = %s\n", i, (char *)fileset->mylist[i]);
89 fileset->mylist.destroy();
92 printf("Allocation/destruction using new delete\n");
93 mlist = new alist(10);
95 for (int i=0; i<20; i++) {
96 sprintf(buf, "This is item %d", i);
97 mlist->append(bstrdup(buf));
99 for (int i=0; i< mlist->size(); i++) {
100 printf("Item %d = %s\n", i, (char *)mlist->get(i));