Skip to content

Commit

Permalink
Arguments No Warning Applied, Version Date & Time Fix, README
Browse files Browse the repository at this point in the history
  • Loading branch information
RaJiska committed Aug 11, 2018
1 parent 0b9d1f8 commit df98990
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set (JAPM_LICENSE_WEBSITE "\"https://opensource.org/licenses/BSD-3-Clause\"")
set (JAPM_NAME_SHORT "\"JAPM\"")
set (JAPM_NAME_COMPLETE "\"Just Another PBO Manager\"")
set (JAPM_VERSION_MAJOR 0)
set (JAPM_VERSION_MINOR 2)
set (JAPM_VERSION_MINOR 8)
set (JAPM_PATH_MAX_LENGTH 260)

set (INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
Expand Down Expand Up @@ -67,7 +67,7 @@ endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Winit-self -Wwrite-strings \
-Wcast-align -Wshadow -Wredundant-decls -Wfloat-equal -Wunreachable-code \
-Wundef -Wlogical-op -Winline -Wdouble-promotion -Wno-pointer-sign \
-Wno-unused-variable"
-Wno-unused-variable -fno-stack-protector"
)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Ofast")

Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# JAPM (Just Another PBO Manager)
Utility allowing you to pack / unpack Bohemia Interactive's PBO files for Arma 3 game. Implemented in C and is cross-platform Linux / Windows, this piece of software can be used in automatized scripts which may come handy for server owners.

## Features
- Pack / Unpack
- Supports Extended Header Format
- Supports Compression

## Building From Sources
#### Linux
```
$ mkdir build && cd build
$ cmake ..
$ make
```

#### Windows (cross-building)
```
$ mkdir build && cd build
$ cmake -DCMAKE_TOOLCHAIN_FILE=../windows.cmake ..
$ make
```

## USAGE
```
$ ./JAPM -h
USAGE
./JAPM [OPTIONS] input [output]
OPTIONS
-h Print this help message and discard other options
-q Quiet: does not print status
-w No warning
-v Display version and discard other options
```

## Credits
[SHA1 Library](https://github.com/clibs/sha1) by Steve Reid

## Thanks
- Mikero for his PBO File Format wiki page
- The various people who helped me searching how it was all working
2 changes: 1 addition & 1 deletion include/japm_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define JAPM_NAME_SHORT "JAPM"
#define JAPM_NAME_COMPLETE "Just Another PBO Manager"
#define JAPM_VERSION_MAJOR 0
#define JAPM_VERSION_MINOR 2
#define JAPM_VERSION_MINOR 8

#define JAPM_PATH_MAX_LENGTH 260
#define JAPM_PATH_FORBIDDEN_CHARS "<>:\"\\/|?*"
Expand Down
2 changes: 1 addition & 1 deletion src/args/args_print_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

void args_print_version(void)
{
printf(JAPM_NAME_SHORT " (" JAPM_NAME_COMPLETE ") version %d.%d compiled on " __TIMESTAMP__ "\n"
printf(JAPM_NAME_SHORT " (" JAPM_NAME_COMPLETE ") version %d.%d compiled on " __DATE__ " " __TIME__ "\n"
"\n"
"Copyright (C) " JAPM_AUTHOR " <" JAPM_AUTHOR_WEBSITE ">\n"
"License " JAPM_LICENSE " <" JAPM_LICENSE_WEBSITE ">\n",
Expand Down
2 changes: 1 addition & 1 deletion src/japm.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static inline enum japm_action determine_action(const arguments_t *args)
if (S_ISREG(st.st_mode)) {
if ((buf = strstr(args->input, ".pbo")) && !strcmp(buf, ".pbo"))
return JAPM_ACTION_UNPACK;
else
else if (!ARGS->no_warning)
FNC_WARN("Input file (%s) does not have the .pbo extension: skipping", args->input);
}
if (S_ISDIR(st.st_mode))
Expand Down
4 changes: 2 additions & 2 deletions src/pbo/pbo_close.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ void pbo_close(pbo_t *pbo)
UnmapViewOfFile(pbo->map);
CloseHandle(pbo->map_handle);
#else
if (munmap(pbo->map, pbo->len) == -1)
if (munmap(pbo->map, pbo->len) == -1 && !ARGS->no_warning)
FNC_WARN("Could not unmap %s\n", pbo->filename);
#endif /* _WIN32 */
if (fclose(pbo->f) == EOF)
if (fclose(pbo->f) == EOF && !ARGS->no_warning)
FNC_WARN("Could not close %s\n", pbo->filename);
free(pbo->filename);
while (pbo->entries) {
Expand Down
7 changes: 5 additions & 2 deletions src/pbo/pbo_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ static inline bool print_from_ptr(
byte_t data_buf[18];
ssize_t start_offset = *bytes_buffered - real_ptr;

if (start_offset < 0)
return FNC_WARN_RET(bool, false, "Pointer offset < 0 (%lld), skipping file", start_offset);
if (start_offset < 0) {
if (!ARGS->no_warning)
FNC_WARN("Pointer offset < 0 (%lld), skipping file", start_offset);
return false;
}
for (ssize_t it = 0; it < to_read; ++it) {
fwrite(buffer + start_offset + it, 1, 1, f);
buffer[(*bytes_buffered)++] = buffer[start_offset + it];
Expand Down
3 changes: 2 additions & 1 deletion src/pbo/pbo_retrieve_entries.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ static char *get_unknown_filename(char *buf)
JAPM_UNKNOWN_FILE_DIR, JAPM_UNKNOWN_FILENAME,
unknown_file_no, JAPM_UNKNOWN_FILEEXT);
++unknown_file_no;
FNC_WARN("Entry with special name renamed -> %s", buf);
if (!ARGS->no_warning)
FNC_WARN("Entry with special name renamed -> %s", buf);
return buf;
}

Expand Down

0 comments on commit df98990

Please sign in to comment.