~ubuntu-branches/ubuntu/saucy/clamav/saucy

« back to all changes in this revision

Viewing changes to win32/compat/w32_errno.c

  • Committer: Bazaar Package Importer
  • Author(s): Leonel Nunez
  • Date: 2008-02-11 22:52:13 UTC
  • mfrom: (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20080211225213-p2uwj4czso1w2f8h
Tags: upstream-0.92~dfsg
ImportĀ upstreamĀ versionĀ 0.92~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Copyright (C) 2009 Sourcefire, Inc.
3
 
 *
4
 
 *  Authors: aCaB <acab@clamav.net>
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License version 2 as
8
 
 *  published by the Free Software Foundation.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 
 *  MA 02110-1301, USA.
19
 
 */
20
 
 
21
 
#include <string.h>
22
 
#include "w32_errno.h"
23
 
 
24
 
char *w32_strerror(int errnum) {
25
 
    int i;
26
 
    for(i=0; i<sizeof(w32_errnos) / sizeof(w32_errnos[0]); i++) {
27
 
        if(w32_errnos[i].err == errnum)
28
 
            return w32_errnos[i].strerr;
29
 
    }
30
 
    return "Unknown error";
31
 
}
32
 
 
33
 
int w32_strerror_r(int errnum, char *buf, size_t buflen) {
34
 
    strncpy(buf, w32_strerror(errnum), buflen);
35
 
    if(buflen) buf[buflen-1] = '\0';
36
 
    return 0;
37
 
}