No empty .Rs/.Re
[netbsd-mini2440.git] / sys / external / intel-public / acpica / dist / tools / acpisrc / asfile.c
blobd6561898095efd07a870de6b09ebf9767f7534fe
2 /******************************************************************************
4 * Module Name: asfile - Main module for the acpi source processor utility
6 *****************************************************************************/
8 /******************************************************************************
10 * 1. Copyright Notice
12 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
13 * All rights reserved.
15 * 2. License
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
41 * 3. Conditions
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
117 #include "acpisrc.h"
119 /* Local prototypes */
121 void
122 AsDoWildcard (
123 ACPI_CONVERSION_TABLE *ConversionTable,
124 char *SourcePath,
125 char *TargetPath,
126 int MaxPathLength,
127 int FileType,
128 char *WildcardSpec);
130 BOOLEAN
131 AsDetectLoneLineFeeds (
132 char *Filename,
133 char *Buffer);
135 static inline int
136 AsMaxInt (int a, int b)
138 return (a > b ? a : b);
142 /******************************************************************************
144 * FUNCTION: AsDoWildcard
146 * DESCRIPTION: Process files via wildcards
148 ******************************************************************************/
150 void
151 AsDoWildcard (
152 ACPI_CONVERSION_TABLE *ConversionTable,
153 char *SourcePath,
154 char *TargetPath,
155 int MaxPathLength,
156 int FileType,
157 char *WildcardSpec)
159 void *DirInfo;
160 char *Filename;
161 char *SourceDirPath;
162 char *TargetDirPath;
163 char RequestedFileType;
166 if (FileType == FILE_TYPE_DIRECTORY)
168 RequestedFileType = REQUEST_DIR_ONLY;
170 else
172 RequestedFileType = REQUEST_FILE_ONLY;
175 VERBOSE_PRINT (("Checking for %s source files in directory \"%s\"\n",
176 WildcardSpec, SourcePath));
178 /* Open the directory for wildcard search */
180 DirInfo = AcpiOsOpenDirectory (SourcePath, WildcardSpec, RequestedFileType);
181 if (DirInfo)
184 * Get all of the files that match both the
185 * wildcard and the requested file type
187 while ((Filename = AcpiOsGetNextFilename (DirInfo)))
189 /* Looking for directory files, must check file type */
191 switch (RequestedFileType)
193 case REQUEST_DIR_ONLY:
195 /* If we actually have a dir, process the subtree */
197 if (!AsCheckForDirectory (SourcePath, TargetPath, Filename,
198 &SourceDirPath, &TargetDirPath))
200 VERBOSE_PRINT (("Subdirectory: %s\n", Filename));
202 AsProcessTree (ConversionTable, SourceDirPath, TargetDirPath);
203 free (SourceDirPath);
204 free (TargetDirPath);
206 break;
208 case REQUEST_FILE_ONLY:
210 /* Otherwise, this is a file, not a directory */
212 VERBOSE_PRINT (("File: %s\n", Filename));
214 AsProcessOneFile (ConversionTable, SourcePath, TargetPath,
215 MaxPathLength, Filename, FileType);
216 break;
218 default:
219 break;
223 /* Cleanup */
225 AcpiOsCloseDirectory (DirInfo);
230 /******************************************************************************
232 * FUNCTION: AsProcessTree
234 * DESCRIPTION: Process the directory tree. Files with the extension ".C" and
235 * ".H" are processed as the tree is traversed.
237 ******************************************************************************/
239 ACPI_NATIVE_INT
240 AsProcessTree (
241 ACPI_CONVERSION_TABLE *ConversionTable,
242 char *SourcePath,
243 char *TargetPath)
245 int MaxPathLength;
248 MaxPathLength = AsMaxInt (strlen (SourcePath), strlen (TargetPath));
250 if (!(ConversionTable->Flags & FLG_NO_FILE_OUTPUT))
252 if (ConversionTable->Flags & FLG_LOWERCASE_DIRNAMES)
254 strlwr (TargetPath);
257 VERBOSE_PRINT (("Creating Directory \"%s\"\n", TargetPath));
258 if (mkdir (TargetPath))
260 if (errno != EEXIST)
262 printf ("Could not create target directory\n");
263 return -1;
268 /* Do the C source files */
270 AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength,
271 FILE_TYPE_SOURCE, "*.c");
273 /* Do the C header files */
275 AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength,
276 FILE_TYPE_HEADER, "*.h");
278 /* Do the Lex file(s) */
280 AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength,
281 FILE_TYPE_SOURCE, "*.l");
283 /* Do the yacc file(s) */
285 AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength,
286 FILE_TYPE_SOURCE, "*.y");
288 /* Do any ASL files */
290 AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength,
291 FILE_TYPE_HEADER, "*.asl");
293 /* Do any subdirectories */
295 AsDoWildcard (ConversionTable, SourcePath, TargetPath, MaxPathLength,
296 FILE_TYPE_DIRECTORY, "*");
298 return 0;
302 /******************************************************************************
304 * FUNCTION: AsDetectLoneLineFeeds
306 * DESCRIPTION: Find LF without CR.
308 ******************************************************************************/
310 BOOLEAN
311 AsDetectLoneLineFeeds (
312 char *Filename,
313 char *Buffer)
315 UINT32 i = 1;
316 UINT32 LfCount = 0;
317 UINT32 LineCount = 0;
320 if (!Buffer[0])
322 return FALSE;
325 while (Buffer[i])
327 if (Buffer[i] == 0x0A)
329 if (Buffer[i-1] != 0x0D)
331 LfCount++;
333 LineCount++;
335 i++;
338 if (LfCount)
340 if (LineCount == LfCount)
342 if (!Gbl_IgnoreLoneLineFeeds)
344 printf ("%s: ****File has UNIX format**** (LF only, not CR/LF) %d lines\n",
345 Filename, LfCount);
348 else
350 printf ("%s: %d lone linefeeds in file\n", Filename, LfCount);
352 return TRUE;
355 return (FALSE);
359 /******************************************************************************
361 * FUNCTION: AsConvertFile
363 * DESCRIPTION: Perform the requested transforms on the file buffer (as
364 * determined by the ConversionTable and the FileType).
366 ******************************************************************************/
368 void
369 AsConvertFile (
370 ACPI_CONVERSION_TABLE *ConversionTable,
371 char *FileBuffer,
372 char *Filename,
373 ACPI_NATIVE_INT FileType)
375 UINT32 i;
376 UINT32 Functions;
377 ACPI_STRING_TABLE *StringTable;
378 ACPI_IDENTIFIER_TABLE *ConditionalTable;
379 ACPI_IDENTIFIER_TABLE *LineTable;
380 ACPI_IDENTIFIER_TABLE *MacroTable;
381 ACPI_TYPED_IDENTIFIER_TABLE *StructTable;
384 switch (FileType)
386 case FILE_TYPE_SOURCE:
387 Functions = ConversionTable->SourceFunctions;
388 StringTable = ConversionTable->SourceStringTable;
389 LineTable = ConversionTable->SourceLineTable;
390 ConditionalTable = ConversionTable->SourceConditionalTable;
391 MacroTable = ConversionTable->SourceMacroTable;
392 StructTable = ConversionTable->SourceStructTable;
393 break;
395 case FILE_TYPE_HEADER:
396 Functions = ConversionTable->HeaderFunctions;
397 StringTable = ConversionTable->HeaderStringTable;
398 LineTable = ConversionTable->HeaderLineTable;
399 ConditionalTable = ConversionTable->HeaderConditionalTable;
400 MacroTable = ConversionTable->HeaderMacroTable;
401 StructTable = ConversionTable->HeaderStructTable;
402 break;
404 default:
405 printf ("Unknown file type, cannot process\n");
406 return;
410 Gbl_StructDefs = strstr (FileBuffer, "/* acpisrc:StructDefs");
411 Gbl_Files++;
412 VERBOSE_PRINT (("Processing %u bytes\n", strlen (FileBuffer)));
414 if (ConversionTable->LowerCaseTable)
416 for (i = 0; ConversionTable->LowerCaseTable[i].Identifier; i++)
418 AsLowerCaseString (ConversionTable->LowerCaseTable[i].Identifier,
419 FileBuffer);
423 /* Process all the string replacements */
425 if (StringTable)
427 for (i = 0; StringTable[i].Target; i++)
429 AsReplaceString (StringTable[i].Target, StringTable[i].Replacement,
430 StringTable[i].Type, FileBuffer);
434 if (LineTable)
436 for (i = 0; LineTable[i].Identifier; i++)
438 AsRemoveLine (FileBuffer, LineTable[i].Identifier);
442 if (ConditionalTable)
444 for (i = 0; ConditionalTable[i].Identifier; i++)
446 AsRemoveConditionalCompile (FileBuffer, ConditionalTable[i].Identifier);
450 if (MacroTable)
452 for (i = 0; MacroTable[i].Identifier; i++)
454 AsRemoveMacro (FileBuffer, MacroTable[i].Identifier);
458 if (StructTable)
460 for (i = 0; StructTable[i].Identifier; i++)
462 AsInsertPrefix (FileBuffer, StructTable[i].Identifier, StructTable[i].Type);
466 /* Process the function table */
468 for (i = 0; i < 32; i++)
470 /* Decode the function bitmap */
472 switch ((1 << i) & Functions)
474 case 0:
475 /* This function not configured */
476 break;
479 case CVT_COUNT_TABS:
481 AsCountTabs (FileBuffer, Filename);
482 break;
485 case CVT_COUNT_NON_ANSI_COMMENTS:
487 AsCountNonAnsiComments (FileBuffer, Filename);
488 break;
491 case CVT_CHECK_BRACES:
493 AsCheckForBraces (FileBuffer, Filename);
494 break;
497 case CVT_TRIM_LINES:
499 AsTrimLines (FileBuffer, Filename);
500 break;
503 case CVT_COUNT_LINES:
505 AsCountSourceLines (FileBuffer, Filename);
506 break;
509 case CVT_BRACES_ON_SAME_LINE:
511 AsBracesOnSameLine (FileBuffer);
512 break;
515 case CVT_MIXED_CASE_TO_UNDERSCORES:
517 AsMixedCaseToUnderscores (FileBuffer);
518 break;
521 case CVT_LOWER_CASE_IDENTIFIERS:
523 AsLowerCaseIdentifiers (FileBuffer);
524 break;
527 case CVT_REMOVE_DEBUG_MACROS:
529 AsRemoveDebugMacros (FileBuffer);
530 break;
533 case CVT_TRIM_WHITESPACE:
535 AsTrimWhitespace (FileBuffer);
536 break;
539 case CVT_REMOVE_EMPTY_BLOCKS:
541 AsRemoveEmptyBlocks (FileBuffer, Filename);
542 break;
545 case CVT_REDUCE_TYPEDEFS:
547 AsReduceTypedefs (FileBuffer, "typedef union");
548 AsReduceTypedefs (FileBuffer, "typedef struct");
549 break;
552 case CVT_SPACES_TO_TABS4:
554 AsTabify4 (FileBuffer);
555 break;
558 case CVT_SPACES_TO_TABS8:
560 AsTabify8 (FileBuffer);
561 break;
563 case CVT_COUNT_SHORTMULTILINE_COMMENTS:
565 #ifdef ACPI_FUTURE_IMPLEMENTATION
566 AsTrimComments (FileBuffer, Filename);
567 #endif
568 break;
570 default:
572 printf ("Unknown conversion subfunction opcode\n");
573 break;
577 if (ConversionTable->NewHeader)
579 AsReplaceHeader (FileBuffer, ConversionTable->NewHeader);
584 /******************************************************************************
586 * FUNCTION: AsProcessOneFile
588 * DESCRIPTION: Process one source file. The file is opened, read entirely
589 * into a buffer, converted, then written to a new file.
591 ******************************************************************************/
593 ACPI_NATIVE_INT
594 AsProcessOneFile (
595 ACPI_CONVERSION_TABLE *ConversionTable,
596 char *SourcePath,
597 char *TargetPath,
598 int MaxPathLength,
599 char *Filename,
600 ACPI_NATIVE_INT FileType)
602 char *Pathname;
603 char *OutPathname = NULL;
606 /* Allocate a file pathname buffer for both source and target */
608 Pathname = calloc (MaxPathLength + strlen (Filename) + 2, 1);
609 if (!Pathname)
611 printf ("Could not allocate buffer for file pathnames\n");
612 return -1;
615 Gbl_FileType = FileType;
617 /* Generate the source pathname and read the file */
619 if (SourcePath)
621 strcpy (Pathname, SourcePath);
622 strcat (Pathname, "/");
625 strcat (Pathname, Filename);
627 if (AsGetFile (Pathname, &Gbl_FileBuffer, &Gbl_FileSize))
629 return -1;
632 Gbl_HeaderSize = 0;
633 if (strstr (Filename, ".asl"))
635 Gbl_HeaderSize = LINES_IN_ASL_HEADER; /* Lines in default ASL header */
637 else if (strstr (Gbl_FileBuffer, LEGAL_HEADER_SIGNATURE))
639 Gbl_HeaderSize = LINES_IN_LEGAL_HEADER; /* Normal C file and H header */
641 else if (strstr (Gbl_FileBuffer, LINUX_HEADER_SIGNATURE))
643 Gbl_HeaderSize = LINES_IN_LINUX_HEADER; /* Linuxized C file and H header */
646 /* Process the file in the buffer */
648 Gbl_MadeChanges = FALSE;
649 if (!Gbl_IgnoreLoneLineFeeds && Gbl_HasLoneLineFeeds)
652 * All lone LFs will be converted to CR/LF
653 * (when file is written, Windows version only)
655 printf ("Converting lone linefeeds\n");
656 Gbl_MadeChanges = TRUE;
659 AsConvertFile (ConversionTable, Gbl_FileBuffer, Pathname, FileType);
661 if (!(ConversionTable->Flags & FLG_NO_FILE_OUTPUT))
663 if (!(Gbl_Overwrite && !Gbl_MadeChanges))
665 /* Generate the target pathname and write the file */
667 OutPathname = calloc (MaxPathLength + strlen (Filename) + 2 + strlen (TargetPath), 1);
668 if (!OutPathname)
670 printf ("Could not allocate buffer for file pathnames\n");
671 return -1;
674 strcpy (OutPathname, TargetPath);
675 if (SourcePath)
677 strcat (OutPathname, "/");
678 strcat (OutPathname, Filename);
681 AsPutFile (OutPathname, Gbl_FileBuffer, ConversionTable->Flags);
685 free (Gbl_FileBuffer);
686 free (Pathname);
687 if (OutPathname)
689 free (OutPathname);
692 return 0;
696 /******************************************************************************
698 * FUNCTION: AsCheckForDirectory
700 * DESCRIPTION: Check if the current file is a valid directory. If not,
701 * construct the full pathname for the source and target paths.
702 * Checks for the dot and dot-dot files (they are ignored)
704 ******************************************************************************/
706 ACPI_NATIVE_INT
707 AsCheckForDirectory (
708 char *SourceDirPath,
709 char *TargetDirPath,
710 char *Filename,
711 char **SourcePath,
712 char **TargetPath)
714 char *SrcPath;
715 char *TgtPath;
718 if (!(strcmp (Filename, ".")) ||
719 !(strcmp (Filename, "..")))
721 return -1;
724 SrcPath = calloc (strlen (SourceDirPath) + strlen (Filename) + 2, 1);
725 if (!SrcPath)
727 printf ("Could not allocate buffer for directory source pathname\n");
728 return -1;
731 TgtPath = calloc (strlen (TargetDirPath) + strlen (Filename) + 2, 1);
732 if (!TgtPath)
734 printf ("Could not allocate buffer for directory target pathname\n");
735 free (SrcPath);
736 return -1;
739 strcpy (SrcPath, SourceDirPath);
740 strcat (SrcPath, "/");
741 strcat (SrcPath, Filename);
743 strcpy (TgtPath, TargetDirPath);
744 strcat (TgtPath, "/");
745 strcat (TgtPath, Filename);
747 *SourcePath = SrcPath;
748 *TargetPath = TgtPath;
749 return 0;
753 /******************************************************************************
755 * FUNCTION: AsGetFile
757 * DESCRIPTION: Open a file and read it entirely into a an allocated buffer
759 ******************************************************************************/
762 AsGetFile (
763 char *Filename,
764 char **FileBuffer,
765 UINT32 *FileSize)
768 int FileHandle;
769 UINT32 Size;
770 char *Buffer;
773 /* Binary mode leaves CR/LF pairs */
775 FileHandle = open (Filename, O_BINARY | O_RDONLY);
776 if (!FileHandle)
778 printf ("Could not open %s\n", Filename);
779 return -1;
782 if (fstat (FileHandle, &Gbl_StatBuf))
784 printf ("Could not get file status for %s\n", Filename);
785 goto ErrorExit;
789 * Create a buffer for the entire file
790 * Add plenty extra buffer to accomodate string replacements
792 Size = Gbl_StatBuf.st_size;
793 Gbl_TotalSize += Size;
795 Buffer = calloc (Size * 2, 1);
796 if (!Buffer)
798 printf ("Could not allocate buffer of size %d\n", Size * 2);
799 goto ErrorExit;
802 /* Read the entire file */
804 Size = read (FileHandle, Buffer, Size);
805 if (Size == -1)
807 printf ("Could not read the input file %s\n", Filename);
808 goto ErrorExit;
811 Buffer [Size] = 0; /* Null terminate the buffer */
812 close (FileHandle);
814 /* Check for unix contamination */
816 Gbl_HasLoneLineFeeds = AsDetectLoneLineFeeds (Filename, Buffer);
819 * Convert all CR/LF pairs to LF only. We do this locally so that
820 * this code is portable across operating systems.
822 AsConvertToLineFeeds (Buffer);
824 *FileBuffer = Buffer;
825 *FileSize = Size;
827 return 0;
830 ErrorExit:
832 close (FileHandle);
833 return -1;
837 /******************************************************************************
839 * FUNCTION: AsPutFile
841 * DESCRIPTION: Create a new output file and write the entire contents of the
842 * buffer to the new file. Buffer must be a zero terminated string
844 ******************************************************************************/
847 AsPutFile (
848 char *Pathname,
849 char *FileBuffer,
850 UINT32 SystemFlags)
852 UINT32 FileSize;
853 int DestHandle;
854 int OpenFlags;
857 /* Create the target file */
859 OpenFlags = O_TRUNC | O_CREAT | O_WRONLY | O_BINARY;
861 if (!(SystemFlags & FLG_NO_CARRIAGE_RETURNS))
863 /* Put back the CR before each LF */
865 AsInsertCarriageReturns (FileBuffer);
868 DestHandle = open (Pathname, OpenFlags, S_IREAD | S_IWRITE);
869 if (DestHandle == -1)
871 perror ("Could not create destination file");
872 printf ("Could not create destination file \"%s\"\n", Pathname);
873 return -1;
876 /* Write the buffer to the file */
878 FileSize = strlen (FileBuffer);
879 write (DestHandle, FileBuffer, FileSize);
881 close (DestHandle);
883 return 0;