WrFFrBuf.c revision a966c04f
1a966c04fSmrg/*
2a966c04fSmrg * Copyright (C) 1989-95 GROUPE BULL
3a966c04fSmrg *
4a966c04fSmrg * Permission is hereby granted, free of charge, to any person obtaining a copy
5a966c04fSmrg * of this software and associated documentation files (the "Software"), to
6a966c04fSmrg * deal in the Software without restriction, including without limitation the
7a966c04fSmrg * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8a966c04fSmrg * sell copies of the Software, and to permit persons to whom the Software is
9a966c04fSmrg * furnished to do so, subject to the following conditions:
10a966c04fSmrg *
11a966c04fSmrg * The above copyright notice and this permission notice shall be included in
12a966c04fSmrg * all copies or substantial portions of the Software.
13a966c04fSmrg *
14a966c04fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15a966c04fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16a966c04fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17a966c04fSmrg * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18a966c04fSmrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19a966c04fSmrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20a966c04fSmrg *
21a966c04fSmrg * Except as contained in this notice, the name of GROUPE BULL shall not be
22a966c04fSmrg * used in advertising or otherwise to promote the sale, use or other dealings
23a966c04fSmrg * in this Software without prior written authorization from GROUPE BULL.
24a966c04fSmrg */
25a966c04fSmrg
26a966c04fSmrg/*****************************************************************************\
27a966c04fSmrg* WrFFrBuf.c:                                                                 *
28a966c04fSmrg*                                                                             *
29a966c04fSmrg*  XPM library                                                                *
30a966c04fSmrg*  Write a memory buffer to a file, provided as a convenience.                *
31a966c04fSmrg*                                                                             *
32a966c04fSmrg*  Developed by Arnaud Le Hors                                                *
33a966c04fSmrg\*****************************************************************************/
34a966c04fSmrg
35a966c04fSmrg/* October 2004, source code review by Thomas Biege <thomas@suse.de> */
36a966c04fSmrg
37a966c04fSmrg#ifdef HAVE_CONFIG_H
38a966c04fSmrg#include <config.h>
39a966c04fSmrg#endif
40a966c04fSmrg#include "XpmI.h"
41a966c04fSmrg
42a966c04fSmrgint
43a966c04fSmrgXpmWriteFileFromBuffer(filename, buffer)
44a966c04fSmrg    char *filename;
45a966c04fSmrg    char *buffer;
46a966c04fSmrg{
47a966c04fSmrg    int fcheck, len;
48a966c04fSmrg    FILE *fp = fopen(filename, "w");
49a966c04fSmrg
50a966c04fSmrg    if (!fp)
51a966c04fSmrg	return XpmOpenFailed;
52a966c04fSmrg
53a966c04fSmrg    len = strlen(buffer);
54a966c04fSmrg    fcheck = fwrite(buffer, len, 1, fp);
55a966c04fSmrg    fclose(fp);
56a966c04fSmrg    if (fcheck != 1)
57a966c04fSmrg	return XpmOpenFailed; /* maybe use a better return value */
58a966c04fSmrg
59a966c04fSmrg    return XpmSuccess;
60a966c04fSmrg}
61