Skip to content

Commit 82bbbc0

Browse files
committed
Revert "Merge pull request ps2dev#673 from israpps/romimg-fix"
This reverts commit ed5ead7, reversing changes made to 50072a4.
1 parent 398c0e6 commit 82bbbc0

File tree

8 files changed

+35
-66
lines changed

8 files changed

+35
-66
lines changed

samples/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ release-samples:
2323
$(MKDIR) -p $(SHARE_TARGET)
2424
cp -f Makefile_sample $(SAMPLES_TARGET)/Makefile
2525
cp -f Makefile.pref_sample $(SAMPLES_TARGET)/Makefile.pref
26-
cp -f Makefile.ioprp_sample $(SAMPLES_TARGET)/Makefile.ioprp
2726
cp -f Makefile.eeglobal_sample $(SAMPLES_TARGET)/Makefile.eeglobal
2827
cp -f Makefile.eeglobal_cpp_sample $(SAMPLES_TARGET)/Makefile.eeglobal_cpp
2928
cp -f Makefile.iopglobal_sample $(SAMPLES_TARGET)/Makefile.iopglobal

samples/Makefile.eeglobal_sample

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,12 @@ $(EE_ERL): $(EE_OBJS)
9292
$(EE_LIB): $(EE_OBJS)
9393
$(DIR_GUARD)
9494
$(EE_AR) cru $(EE_LIB) $(EE_OBJS)
95+
96+
$(IOPRP_BIN): $(IOPRP_CONTENTS)
97+
ifeq (_$(IOPRP_CONTENTS)_,__)
98+
$(error Cannot generate IOPRP if 'IOPRP_CONTENTS' variable is empty)
99+
else
100+
$(DIR_GUARD)
101+
romimg -c $@ $<
102+
endif
103+

samples/Makefile.ioprp_sample

Lines changed: 0 additions & 15 deletions
This file was deleted.

tools/romimg/src/main.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <string.h>
88
#include <sys/stat.h>
99
#include <unistd.h>
10-
#include <ctype.h>
1110

1211
#include "romimg.h"
1312

@@ -35,15 +34,13 @@ static void DisplayROMImgDetails(const ROMIMG *ROMImg)
3534

3635
static void DisplaySyntaxHelp(void)
3736
{
38-
printf("Syntax:\n"
39-
"ROMIMG -c <ROM image> <files>\n\tCreate ROM image *\n"
37+
printf(REDBOLD"Syntax error"DEFCOL". Syntax:\n"
38+
"ROMIMG -c <ROM image> <files>\n\tCreate ROM image\n"
4039
"ROMIMG -l <ROM image>\n\tList files in ROM image\n"
41-
"ROMIMG -a <ROM image> <file(s)>\n\tAdd file(s) to ROM image *\n"
40+
"ROMIMG -a <ROM image> <file(s)>\n\tAdd file(s) to ROM image\n"
4241
"ROMIMG -d <ROM image> <file(s)>\n\tDelete file(s) from ROM image\n"
4342
"ROMIMG -x <ROM image>\n\tExtract all files from ROM image\n"
44-
"ROMIMG -x <ROM image> <file>\n\tExtract file from ROM image\n"
45-
"\n note*: write the switch in uppercase to perform filename transformation (eg: 'ioman.irx' > 'IOMAN')\n"
46-
);
43+
"ROMIMG -x <ROM image> <file>\n\tExtract file from ROM image\n");
4744
}
4845

4946
static void DisplayAddDeleteOperationResult(int result, const char *InvolvedFile)
@@ -83,30 +80,31 @@ int main(int argc, char **argv)
8380

8481
if (argc < 2) {
8582
DisplaySyntaxHelp();
83+
DPRINTF("ERROR: LESS THAN TWO ARGS PROVIDED\n");
8684
return EINVAL;
8785
}
8886

89-
if (argc >= 4 && strcasecmp(argv[1], "-c") == 0) {
87+
if (argc >= 4 && strcmp(argv[1], "-c") == 0) {
9088
if ((result = CreateBlankROMImg(argv[2], &ROMImg)) == 0) {
9189
for (FilesAffected = 0, i = 0; i < argc - 3; i++) {
9290
printf("Adding file '%s'", argv[3 + i]);
93-
if ((result = AddFile(&ROMImg, argv[3 + i], isupper(argv[1][1]))) == 0)
91+
if ((result = AddFile(&ROMImg, argv[3 + i])) == 0)
9492
FilesAffected++;
9593
printf(result == 0 ? GRNBOLD" done!"DEFCOL"\n" : REDBOLD" failed!"DEFCOL"\n");
9694
}
9795

9896
if (FilesAffected > 0) {
99-
printf("Writing image... ");
97+
printf("Writing image...");
10098
printf("%s", (result = WriteROMImg(argv[2], &ROMImg)) == 0 ? GRNBOLD"done!"DEFCOL"\n" : REDBOLD"failed!"DEFCOL"\n");
10199
}
102100
UnloadROMImg(&ROMImg);
103101
} else
104-
ERROR("(Internal fault) Can't create blank image file: %d (%s). Please report.\n", result, strerror(result));
105-
} else if (argc >= 4 && strcasecmp(argv[1], "-a") == 0) {
102+
ERROR("(Internal fault) Can't create blank image file: %d. Please report.\n", result);
103+
} else if (argc >= 4 && strcmp(argv[1], "-a") == 0) {
106104
if ((result = LoadROMImg(&ROMImg, argv[2])) == 0) {
107105
for (i = 0, FilesAffected = 0; i < argc - 3; i++) {
108106
printf("Adding file '%s'", argv[3 + i]);
109-
if ((result = AddFile(&ROMImg, argv[3 + i], isupper(argv[1][1]))) == 0)
107+
if ((result = AddFile(&ROMImg, argv[3 + i])) == 0)
110108
FilesAffected++;
111109
DisplayAddDeleteOperationResult(result, argv[3 + i]);
112110
}

tools/romimg/src/platform.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <errno.h>
66
#include <stdlib.h>
7-
#include <ctype.h>
87
#include "dprintf.h"
98
#if defined(_WIN32) || defined(WIN32)
109
#include <windows.h>
@@ -115,12 +114,3 @@ int GetCurrentWorkingDirectory(char *buffer, unsigned int BufferSize)
115114
return EIO;
116115
#endif
117116
}
118-
119-
void upperbuff(char *temp)
120-
{
121-
char *s = temp;
122-
while (*s) {
123-
*s = toupper((unsigned char) *s);
124-
s++;
125-
}
126-
}

tools/romimg/src/platform.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ int GetLocalhostName(char *buffer, unsigned int BufferSize);
66
unsigned int GetSystemDate(void);
77
unsigned int GetFileCreationDate(const char *path);
88
int GetCurrentWorkingDirectory(char *buffer, unsigned int BufferSize);
9-
void upperbuff(char *temp);
109

1110
#if defined(_WIN32) || defined(WIN32)
1211
#define PATHSEP '\\'
1312
#else
1413
#define PATHSEP '/'
1514
#endif
1615

17-
#endif /* __PLATFORM_H__ */
16+
#endif /* __PLATFORM_H__ */

tools/romimg/src/romimg.c

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66
#include <stdio.h>
77
#include <stdlib.h>
88
#include <string.h>
9-
#include <unistd.h>
10-
#include <limits.h>
119

1210
#include "platform.h"
1311
#include "romimg.h"
1412
#include "SonyRX.h"
1513

16-
#define IMAGE_COMMENT_BASESIZE 31
17-
1814
struct ROMImgStat
1915
{
2016
void *image;
@@ -143,7 +139,12 @@ static int GetExtInfoStat(const struct ROMImgStat *ImageStat, struct RomDirFileF
143139
int CreateBlankROMImg(const char *filename, ROMIMG *ROMImg)
144140
{
145141
unsigned int CommentLength;
146-
char LocalhostName[32] = {0}, cwd[PATH_MAX] = {0}, UserName[32] = {0};
142+
char LocalhostName[32], cwd[128];
143+
#if defined(_WIN32) || defined(WIN32)
144+
char UserName[32] = "";
145+
#else
146+
char* UserName;
147+
#endif
147148
struct FileEntry *ResetFile;
148149
struct ExtInfoFieldEntry *ExtInfoEntry;
149150

@@ -153,15 +154,14 @@ int CreateBlankROMImg(const char *filename, ROMIMG *ROMImg)
153154
#if defined(_WIN32) || defined(WIN32)
154155
GetUsername(UserName, sizeof(UserName));
155156
#else
156-
getlogin_r(UserName, sizeof(UserName));
157+
UserName = getenv("USER");
157158
#endif
158159
GetLocalhostName(LocalhostName, sizeof(LocalhostName));
159160
GetCurrentWorkingDirectory(cwd, sizeof(cwd));
160161
/* Comment format: YYYYMMDD-XXXYYY,conffile,<filename>,<user>@<localhost>/<image path> */
161-
CommentLength = IMAGE_COMMENT_BASESIZE + strlen(filename) + sizeof(LocalhostName) + sizeof(UserName) + sizeof(cwd);
162-
ROMImg->comment = (char *)malloc( CommentLength+1);
163-
if (!ROMImg->comment) return ENOMEM;
164-
snprintf(ROMImg->comment, CommentLength, "%08x,conffile,%s,%s@%s/%s", ROMImg->date, filename, UserName, LocalhostName, cwd);
162+
CommentLength = 31 + strlen(filename) + strlen(UserName) + strlen(LocalhostName) + strlen(cwd);
163+
ROMImg->comment = (char *)malloc(CommentLength);
164+
sprintf(ROMImg->comment, "%08x,conffile,%s,%s@%s/%s", ROMImg->date, filename, (UserName[0] =='\0')?"":UserName, LocalhostName, cwd);
165165

166166
// Create a blank RESET file.
167167
ROMImg->NumFiles = 1;
@@ -452,26 +452,15 @@ static int AddExtInfoStat(struct FileEntry *file, unsigned char type, void *data
452452
return result;
453453
}
454454

455-
int AddFile(ROMIMG *ROMImg, const char *path, int upperconv)
455+
int AddFile(ROMIMG *ROMImg, const char *path)
456456
{
457-
char tbuf[9] = "\0"; // we dont need a large buf, this is for filling in the filename on ROMFS
458457
FILE *InputFile;
459458
int result;
460459
unsigned int FileDateStamp;
461460
unsigned short FileVersion;
462461
if ((InputFile = fopen(path, "rb")) != NULL) {
463462
const char* fname = strrchr(path, PATHSEP);
464463
if (fname == NULL) fname = path; else fname++;
465-
if (upperconv) {
466-
strncpy(tbuf, fname, sizeof(tbuf));
467-
tbuf[sizeof(tbuf) - 1] = '\0';
468-
if (tbuf[0] != '\0') {
469-
upperbuff(tbuf);
470-
fname = tbuf;
471-
char* T = strrchr(fname, '.');
472-
if (T != NULL) *T = '\0'; //null terminate extension
473-
}
474-
}
475464
int size;
476465
fseek(InputFile, 0, SEEK_END);
477466
size = ftell(InputFile);
@@ -487,7 +476,7 @@ int AddFile(ROMIMG *ROMImg, const char *path, int upperconv)
487476
file = &ROMImg->files[ROMImg->NumFiles - 1];
488477
memset(&ROMImg->files[ROMImg->NumFiles - 1], 0, sizeof(struct FileEntry));
489478

490-
strncpy(file->RomDir.name, fname, sizeof(file->RomDir.name));
479+
strncpy(file->RomDir.name, fname, sizeof(file->RomDir.name) - 1);
491480
file->RomDir.name[sizeof(file->RomDir.name) - 1] = '\0';
492481
file->RomDir.ExtInfoEntrySize = 0;
493482

tools/romimg/src/romimg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ int CreateBlankROMImg(const char *filename, ROMIMG *ROMImg);
6868
int WriteROMImg(const char *file, const ROMIMG *ROMImg);
6969
int LoadROMImg(ROMIMG *ROMImg, const char *path);
7070
void UnloadROMImg(ROMIMG *ROMImg);
71-
int AddFile(ROMIMG *ROMImg, const char *path, int upperconv);
71+
int AddFile(ROMIMG *ROMImg, const char *path);
7272
int DeleteFile(ROMIMG *ROMImg, const char *filename);
7373
int ExtractFile(const ROMIMG *ROMImg, const char *filename, const char *FileToExtract);
7474
int IsFileExists(const ROMIMG *ROMImg, const char *filename);
7575

76-
#endif /* __ROMING_H__ */
76+
#endif /* __ROMING_H__ */

0 commit comments

Comments
 (0)