Skip to content

Commit

Permalink
Merge pull request #43 from lioncash/func
Browse files Browse the repository at this point in the history
Mark identifiers as internally linked where appropriate
  • Loading branch information
SciresM authored Aug 17, 2018
2 parents e6227c8 + 29e27ee commit 0269d0b
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void aes_decrypt(aes_ctx_t *ctx, void *dst, const void *src, size_t l) {
mbedtls_cipher_finish(&ctx->cipher_dec, NULL, NULL);
}

void get_tweak(unsigned char *tweak, size_t sector) {
static void get_tweak(unsigned char *tweak, size_t sector) {
for (int i = 0xF; i >= 0; i--) { /* Nintendo LE custom tweak... */
tweak[i] = (unsigned char)(sector & 0xFF);
sector >>= 8;
Expand Down
2 changes: 1 addition & 1 deletion filepath.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int os_rmdir(const oschar_t *dir) {
#endif
}

void filepath_update(filepath_t *fpath) {
static void filepath_update(filepath_t *fpath) {
memset(fpath->os_path, 0, MAX_PATH * sizeof(oschar_t));
os_strcpy(fpath->os_path, fpath->char_path);
}
Expand Down
4 changes: 2 additions & 2 deletions kip.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ char *kip1_get_json(kip1_ctx_t *ctx) {
return output_str;
}

void kip1_blz_uncompress(void *hdr_end) {
static void kip1_blz_uncompress(void *hdr_end) {
uint32_t addl_size = ((uint32_t *)hdr_end)[-1];
uint32_t header_size = ((uint32_t *)hdr_end)[-2];
uint32_t cmp_and_hdr_size = ((uint32_t *)hdr_end)[-3];
Expand Down Expand Up @@ -175,7 +175,7 @@ void kip1_blz_uncompress(void *hdr_end) {
}
}

void *kip1_uncompress(kip1_ctx_t *ctx, uint64_t *size) {
static void *kip1_uncompress(kip1_ctx_t *ctx, uint64_t *size) {
/* Make new header with correct sizes, fixed flags. */
kip1_header_t new_header = *ctx->header;
for (unsigned int i = 0; i < 3; i++) {
Expand Down
4 changes: 2 additions & 2 deletions nax0.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "sha.h"
#include "nax0.h"

size_t nax0_read(nax0_ctx_t *ctx, uint64_t offset, void *dst, size_t size) {
static size_t nax0_read(nax0_ctx_t *ctx, uint64_t offset, void *dst, size_t size) {
if (ctx->num_files == 1) {
fseeko64(ctx->files[0], offset, SEEK_SET);
return fread(dst, 1, size, ctx->files[0]);
Expand Down Expand Up @@ -151,7 +151,7 @@ void nax0_save(nax0_ctx_t *ctx) {
free(buf);
}

const char *nax0_get_key_summary(unsigned int k) {
static const char *nax0_get_key_summary(unsigned int k) {
switch (k) {
case 0:
return "Save";
Expand Down
36 changes: 18 additions & 18 deletions nca.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void nca_init(nca_ctx_t *ctx) {
}

/* Updates the CTR for an offset. */
void nca_update_ctr(unsigned char *ctr, uint64_t ofs) {
static void nca_update_ctr(unsigned char *ctr, uint64_t ofs) {
ofs >>= 4;
for (unsigned int j = 0; j < 0x8; j++) {
ctr[0x10-j-1] = (unsigned char)(ofs & 0xFF);
Expand All @@ -23,7 +23,7 @@ void nca_update_ctr(unsigned char *ctr, uint64_t ofs) {
}

/* Updates the CTR for a bktr offset. */
void nca_update_bktr_ctr(unsigned char *ctr, uint32_t ctr_val, uint64_t ofs) {
static void nca_update_bktr_ctr(unsigned char *ctr, uint32_t ctr_val, uint64_t ofs) {
ofs >>= 4;
for (unsigned int j = 0; j < 0x8; j++) {
ctr[0x10-j-1] = (unsigned char)(ofs & 0xFF);
Expand Down Expand Up @@ -74,7 +74,7 @@ void nca_section_fseek(nca_section_ctx_t *ctx, uint64_t offset) {
}
}

size_t nca_bktr_section_physical_fread(nca_section_ctx_t *ctx, void *buffer, size_t count) {
static size_t nca_bktr_section_physical_fread(nca_section_ctx_t *ctx, void *buffer, size_t count) {
size_t read = 0; /* XXX */
size_t size = 1;
char block_buf[0x10];
Expand Down Expand Up @@ -311,7 +311,7 @@ void nca_free_section_contexts(nca_ctx_t *ctx) {
}
}

void nca_save(nca_ctx_t *ctx) {
static void nca_save(nca_ctx_t *ctx) {
/* Save header. */
filepath_t *header_path = &ctx->tool_ctx->settings.header_path;

Expand Down Expand Up @@ -657,7 +657,7 @@ void nca_decrypt_key_area(nca_ctx_t *ctx) {
}


char *nca_get_distribution_type(nca_ctx_t *ctx) {
static char *nca_get_distribution_type(nca_ctx_t *ctx) {
switch (ctx->header.distribution) {
case 0:
return "Download";
Expand All @@ -668,7 +668,7 @@ char *nca_get_distribution_type(nca_ctx_t *ctx) {
}
}

char *nca_get_content_type(nca_ctx_t *ctx) {
static char *nca_get_content_type(nca_ctx_t *ctx) {
switch (ctx->header.content_type) {
case 0:
return "Program";
Expand All @@ -685,15 +685,15 @@ char *nca_get_content_type(nca_ctx_t *ctx) {
}
}

char *nca_get_encryption_type(nca_ctx_t *ctx) {
static char *nca_get_encryption_type(nca_ctx_t *ctx) {
if (ctx->has_rights_id) {
return "Titlekey crypto";
} else {
return "Standard crypto";
}
}

void nca_print_key_area(nca_ctx_t *ctx) {
static void nca_print_key_area(nca_ctx_t *ctx) {
if (ctx->format_version == NCAVERSION_NCA0_BETA) {
printf("Key Area (Encrypted):\n");
memdump(stdout, "Key (RSA-OAEP Encrypted): ", &ctx->header.encrypted_keys, 0x100);
Expand Down Expand Up @@ -727,7 +727,7 @@ void nca_print_key_area(nca_ctx_t *ctx) {
}
}

char *nca_get_section_type(nca_section_ctx_t *meta) {
static char *nca_get_section_type(nca_section_ctx_t *meta) {
switch (meta->type) {
case PFS0: {
if (meta->pfs0_ctx.is_exefs) return "ExeFS";
Expand All @@ -743,7 +743,7 @@ char *nca_get_section_type(nca_section_ctx_t *meta) {
}


void nca_print_sections(nca_ctx_t *ctx) {
static void nca_print_sections(nca_ctx_t *ctx) {
printf("Sections:\n");
for (unsigned int i = 0; i < 4; i++) {
if (ctx->section_contexts[i].is_present) { /* Section exists. */
Expand Down Expand Up @@ -839,7 +839,7 @@ void nca_print(nca_ctx_t *ctx) {
printf("\n");
}

validity_t nca_section_check_external_hash_table(nca_section_ctx_t *ctx, unsigned char *hash_table, uint64_t data_ofs, uint64_t data_len, uint64_t block_size, int full_block) {
static validity_t nca_section_check_external_hash_table(nca_section_ctx_t *ctx, unsigned char *hash_table, uint64_t data_ofs, uint64_t data_len, uint64_t block_size, int full_block) {
if (block_size == 0) {
/* Block size of 0 is always invalid. */
return VALIDITY_INVALID;
Expand Down Expand Up @@ -879,7 +879,7 @@ validity_t nca_section_check_external_hash_table(nca_section_ctx_t *ctx, unsigne

}

validity_t nca_section_check_hash_table(nca_section_ctx_t *ctx, uint64_t hash_ofs, uint64_t data_ofs, uint64_t data_len, uint64_t block_size, int full_block) {
static validity_t nca_section_check_hash_table(nca_section_ctx_t *ctx, uint64_t hash_ofs, uint64_t data_ofs, uint64_t data_len, uint64_t block_size, int full_block) {
if (block_size == 0) {
/* Block size of 0 is always invalid. */
return VALIDITY_INVALID;
Expand All @@ -906,7 +906,7 @@ validity_t nca_section_check_hash_table(nca_section_ctx_t *ctx, uint64_t hash_of
return result;
}

void nca_save_pfs0_file(nca_section_ctx_t *ctx, uint32_t i, filepath_t *dirpath) {
static void nca_save_pfs0_file(nca_section_ctx_t *ctx, uint32_t i, filepath_t *dirpath) {
if (i >= ctx->pfs0_ctx.header->num_files) {
fprintf(stderr, "Could not save file %"PRId32"!\n", i);
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -1438,7 +1438,7 @@ void nca_save_pfs0_section(nca_section_ctx_t *ctx) {
}

/* RomFS functions... */
int nca_is_romfs_file_updated(nca_section_ctx_t *ctx, uint64_t file_offset, uint64_t file_size) {
static int nca_is_romfs_file_updated(nca_section_ctx_t *ctx, uint64_t file_offset, uint64_t file_size) {
/* All files in a Base RomFS are "updated". */
if (ctx->type == ROMFS) {
return 1;
Expand All @@ -1459,7 +1459,7 @@ int nca_is_romfs_file_updated(nca_section_ctx_t *ctx, uint64_t file_offset, uint
return 0;
}

int nca_visit_romfs_file(nca_section_ctx_t *ctx, uint32_t file_offset, filepath_t *dir_path) {
static int nca_visit_romfs_file(nca_section_ctx_t *ctx, uint32_t file_offset, filepath_t *dir_path) {
romfs_fentry_t *entry;
if (ctx->type == ROMFS) {
entry = romfs_get_fentry(ctx->romfs_ctx.files, file_offset);
Expand Down Expand Up @@ -1506,7 +1506,7 @@ int nca_visit_romfs_file(nca_section_ctx_t *ctx, uint32_t file_offset, filepath_
return found_file;
}

int nca_visit_nca0_romfs_file(nca_section_ctx_t *ctx, uint32_t file_offset, filepath_t *dir_path) {
static int nca_visit_nca0_romfs_file(nca_section_ctx_t *ctx, uint32_t file_offset, filepath_t *dir_path) {
romfs_fentry_t *entry = romfs_get_fentry(ctx->nca0_romfs_ctx.files, file_offset);
filepath_t *cur_path = calloc(1, sizeof(filepath_t));
if (cur_path == NULL) {
Expand Down Expand Up @@ -1540,7 +1540,7 @@ int nca_visit_nca0_romfs_file(nca_section_ctx_t *ctx, uint32_t file_offset, file
return found_file;
}

int nca_visit_romfs_dir(nca_section_ctx_t *ctx, uint32_t dir_offset, filepath_t *parent_path) {
static int nca_visit_romfs_dir(nca_section_ctx_t *ctx, uint32_t dir_offset, filepath_t *parent_path) {
romfs_direntry_t *entry;
if (ctx->type == ROMFS) {
entry = romfs_get_direntry(ctx->romfs_ctx.directories, dir_offset);
Expand Down Expand Up @@ -1585,7 +1585,7 @@ int nca_visit_romfs_dir(nca_section_ctx_t *ctx, uint32_t dir_offset, filepath_t
return any_files;
}

int nca_visit_nca0_romfs_dir(nca_section_ctx_t *ctx, uint32_t dir_offset, filepath_t *parent_path) {
static int nca_visit_nca0_romfs_dir(nca_section_ctx_t *ctx, uint32_t dir_offset, filepath_t *parent_path) {
romfs_direntry_t *entry = romfs_get_direntry(ctx->nca0_romfs_ctx.directories, dir_offset);
filepath_t *cur_path = calloc(1, sizeof(filepath_t));
if (cur_path == NULL) {
Expand Down
4 changes: 2 additions & 2 deletions nca0_romfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "nca0_romfs.h"

/* NCA0 RomFS functions... */
void nca0_romfs_visit_file(nca0_romfs_ctx_t *ctx, uint32_t file_offset, filepath_t *dir_path) {
static void nca0_romfs_visit_file(nca0_romfs_ctx_t *ctx, uint32_t file_offset, filepath_t *dir_path) {
romfs_fentry_t *entry = romfs_get_fentry(ctx->files, file_offset);
filepath_t *cur_path = calloc(1, sizeof(filepath_t));
if (cur_path == NULL) {
Expand Down Expand Up @@ -32,7 +32,7 @@ void nca0_romfs_visit_file(nca0_romfs_ctx_t *ctx, uint32_t file_offset, filepath
}
}

void nca0_romfs_visit_dir(nca0_romfs_ctx_t *ctx, uint32_t dir_offset, filepath_t *parent_path) {
static void nca0_romfs_visit_dir(nca0_romfs_ctx_t *ctx, uint32_t dir_offset, filepath_t *parent_path) {
romfs_direntry_t *entry = romfs_get_direntry(ctx->directories, dir_offset);
filepath_t *cur_path = calloc(1, sizeof(filepath_t));
if (cur_path == NULL) {
Expand Down
22 changes: 11 additions & 11 deletions npdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "rsa.h"
#include "cJSON.h"

const char *svc_names[0x80] = {
static const char * const svc_names[0x80] = {
"svcUnknown",
"svcSetHeapSize",
"svcSetMemoryPermission",
Expand Down Expand Up @@ -141,7 +141,7 @@ const char *svc_names[0x80] = {
#define MAX_FS_PERM_BOOL 0x1B
#define FS_PERM_MASK_NODEBUG 0xBFFFFFFFFFFFFFFFULL

const fs_perm_t fs_permissions_rw[MAX_FS_PERM_RW] = {
static const fs_perm_t fs_permissions_rw[MAX_FS_PERM_RW] = {
{"MountContentType2", 0x8000000000000801},
{"MountContentType5", 0x8000000000000801},
{"MountContentType3", 0x8000000000000801},
Expand Down Expand Up @@ -183,7 +183,7 @@ const fs_perm_t fs_permissions_rw[MAX_FS_PERM_RW] = {
{"HostAccess", 0xC000000000400000}
};

const fs_perm_t fs_permissions_bool[MAX_FS_PERM_BOOL] = {
static const fs_perm_t fs_permissions_bool[MAX_FS_PERM_BOOL] = {
{"BisCache", 0x8000000000000080},
{"EraseMmc", 0x8000000000000080},
{"GameCardCertificate", 0x8000000000000010},
Expand Down Expand Up @@ -224,7 +224,7 @@ char *npdm_get_proc_category(int process_category) {
}
}

char *kac_get_app_type(uint32_t app_type) {
static char *kac_get_app_type(uint32_t app_type) {
switch (app_type) {
case 0:
return "System Module";
Expand All @@ -237,7 +237,7 @@ char *kac_get_app_type(uint32_t app_type) {
}
}

void kac_add_mmio(kac_t *kac, kac_mmio_t *mmio) {
static void kac_add_mmio(kac_t *kac, kac_mmio_t *mmio) {
/* Perform an ordered insertion. */
if (kac->mmio == NULL || mmio->address < kac->mmio->address) {
mmio->next = kac->mmio;
Expand Down Expand Up @@ -450,7 +450,7 @@ void kac_print(const uint32_t *descriptors, uint32_t num_descriptors) {
}

/* Modified from https://stackoverflow.com/questions/23457305/compare-strings-with-wildcard */
int match(const char *pattern, const char *candidate, int p, int c) {
static int match(const char *pattern, const char *candidate, int p, int c) {
if (pattern[p] == '\0') {
return candidate[c] == '\0';
} else if (pattern[p] == '*') {
Expand All @@ -464,7 +464,7 @@ int match(const char *pattern, const char *candidate, int p, int c) {
}
}

int sac_matches(sac_entry_t *lst, char *service) {
static int sac_matches(sac_entry_t *lst, char *service) {
sac_entry_t *cur = lst;
while (cur != NULL) {
if (match(cur->service, service, 0, 0)) return 1;
Expand All @@ -473,7 +473,7 @@ int sac_matches(sac_entry_t *lst, char *service) {
return 0;
}

void sac_parse(char *sac, uint32_t sac_size, sac_entry_t *r_host, sac_entry_t *r_accesses, sac_entry_t **out_hosts, sac_entry_t **out_accesses) {
static void sac_parse(char *sac, uint32_t sac_size, sac_entry_t *r_host, sac_entry_t *r_accesses, sac_entry_t **out_hosts, sac_entry_t **out_accesses) {
sac_entry_t *accesses = NULL;
sac_entry_t *hosts = NULL;
sac_entry_t *cur_entry = NULL;
Expand Down Expand Up @@ -513,7 +513,7 @@ void sac_parse(char *sac, uint32_t sac_size, sac_entry_t *r_host, sac_entry_t *r
*out_accesses = accesses;
}

void sac_print(char *acid_sac, uint32_t acid_size, char *aci0_sac, uint32_t aci0_size) {
static void sac_print(char *acid_sac, uint32_t acid_size, char *aci0_sac, uint32_t aci0_size) {
/* Parse the ACID sac. */
sac_entry_t *acid_accesses = NULL;
sac_entry_t *acid_hosts = NULL;
Expand Down Expand Up @@ -558,7 +558,7 @@ void sac_print(char *acid_sac, uint32_t acid_size, char *aci0_sac, uint32_t aci0



void fac_print(fac_t *fac, fah_t *fah) {
static void fac_print(fac_t *fac, fah_t *fah) {
if (fac->version == fah->version) {
printf(" Version: %"PRId32"\n", fac->version);
} else {
Expand Down Expand Up @@ -705,7 +705,7 @@ void cJSON_AddU64ToObject(cJSON *obj, const char *name, uint64_t val) {
cJSON_AddStringToObject(obj, name, buf);
}

cJSON *sac_get_json(char *sac, uint32_t sac_size) {
static cJSON *sac_get_json(char *sac, uint32_t sac_size) {
cJSON *sac_json = cJSON_CreateObject();
char service[9] = {0};
uint32_t ofs = 0;
Expand Down
2 changes: 1 addition & 1 deletion nso.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "lz4.h"
#include "sha.h"

void *nso_uncompress(nso0_ctx_t *ctx) {
static void *nso_uncompress(nso0_ctx_t *ctx) {
/* Make new header with correct sizes, fixed flags. */
nso0_header_t new_header = *ctx->header;
for (unsigned int i = 0; i < 3; i++) {
Expand Down
2 changes: 1 addition & 1 deletion packages.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void pk21_process(pk21_ctx_t *ctx) {
}
}

const char *pk21_get_section_name(int section) {
static const char *pk21_get_section_name(int section) {
switch (section) {
case 0: return "Kernel";
case 1: return "INI1";
Expand Down
2 changes: 1 addition & 1 deletion pfs0.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void pfs0_process(pfs0_ctx_t *ctx) {

}

void pfs0_save_file(pfs0_ctx_t *ctx, uint32_t i, filepath_t *dirpath) {
static void pfs0_save_file(pfs0_ctx_t *ctx, uint32_t i, filepath_t *dirpath) {
if (i >= ctx->header->num_files) {
fprintf(stderr, "Could not save file %"PRId32"!\n", i);
exit(EXIT_FAILURE);
Expand Down
Loading

0 comments on commit 0269d0b

Please sign in to comment.