2023-01-18 Fred Gleason <fredg@paravelsystems.com>

* Modified the 'cwrap' helper to emit C++ compatible output.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2023-01-18 11:39:38 -05:00
parent 567fe756b7
commit 269232f585
3 changed files with 14 additions and 10 deletions

View File

@ -23930,3 +23930,5 @@
2023-01-18 Fred Gleason <fredg@paravelsystems.com> 2023-01-18 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdservice(8) that could cause dropboxes to be * Fixed a bug in rdservice(8) that could cause dropboxes to be
instantiated with invalid segue level values. instantiated with invalid segue level values.
2023-01-18 Fred Gleason <fredg@paravelsystems.com>
* Modified the 'cwrap' helper to emit C++ compatible output.

View File

@ -1,9 +1,9 @@
// cwrap.cpp // cwrap.cpp
// //
// A utility for wrapping arbitrary file data in C-compaibile source // A utility for wrapping arbitrary file data in C/C++-compatible source
// statements. // statements.
// //
// (C) Copyright 2003,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2003-2023 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as // it under the terms of the GNU General Public License version 2 as
@ -90,11 +90,11 @@ int main(int argc,char *argv[])
// Open Files // Open Files
// //
if((input_fd=open(input_name,O_RDONLY))<0) { if((input_fd=open(input_name,O_RDONLY))<0) {
perror("wrapdat"); perror("cwrap");
exit(1); exit(1);
} }
if((output_desc=fopen(output_name,"w"))==NULL) { if((output_desc=fopen(output_name,"w"))==NULL) {
perror("wrapdat"); perror("cwrap");
exit(1); exit(1);
} }
@ -103,9 +103,11 @@ int main(int argc,char *argv[])
// //
memset(&stat,0,sizeof(struct stat)); memset(&stat,0,sizeof(struct stat));
if(fstat(input_fd,&stat)) { if(fstat(input_fd,&stat)) {
perror("wrapdat"); perror("cwrap");
exit(1); exit(1);
} }
fprintf(output_desc,"extern const unsigned char %s[%ld];\n",
var_name,stat.st_size+1);
fprintf(output_desc,"const unsigned char %s[%ld] = {\n", fprintf(output_desc,"const unsigned char %s[%ld] = {\n",
var_name,stat.st_size+1); var_name,stat.st_size+1);

View File

@ -3,7 +3,7 @@
// A utility for wrapping arbitrary file data in C-compaibile source // A utility for wrapping arbitrary file data in C-compaibile source
// statements. // statements.
// //
// (C) Copyright 2003,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2003-2023 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as // it under the terms of the GNU General Public License version 2 as
@ -20,10 +20,10 @@
// //
// //
#ifndef WRAPDAT_H #ifndef CWRAP_H
#define WRAPDAT_H #define CWRAP_H
#define USAGE "wrapdat [-o|--output-file <file>] <file>\n" #define USAGE "cwrap [-o|--output-file <file>] <file>\n"
// //
// Data Values per Line // Data Values per Line
@ -31,4 +31,4 @@
#define LINE_LENGTH 16 #define LINE_LENGTH 16
#endif // WRAPDAT_H #endif // CWRAP_H