libnx  v4.2.2
ncm.h
Go to the documentation of this file.
1 /**
2  * @file ncm.h
3  * @brief Content Manager (ncm) service IPC wrapper.
4  * @author Adubbz & zhuowei
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../services/ncm_types.h"
10 #include "../services/fs.h"
11 #include "../sf/service.h"
12 
13 /// ContentStorage
14 typedef struct {
15  Service s; ///< IContentStorage
17 
18 /// ContentMetaDatabase
19 typedef struct {
20  Service s; ///< IContentMetaDatabase
22 
23 /// RightsId
24 typedef struct {
25  FsRightsId rights_id;
26  u8 key_generation; ///< [3.0.0+]
27  u8 pad[7]; ///< [3.0.0+]
28 } NcmRightsId;
29 
30 /// Initialize ncm.
31 Result ncmInitialize(void);
32 
33 /// Exit ncm.
34 void ncmExit(void);
35 
36 /// Gets the Service object for the actual ncm service session.
38 
39 Result ncmCreateContentStorage(NcmStorageId storage_id);
40 Result ncmCreateContentMetaDatabase(NcmStorageId storage_id);
41 Result ncmVerifyContentStorage(NcmStorageId storage_id);
42 Result ncmVerifyContentMetaDatabase(NcmStorageId storage_id);
43 Result ncmOpenContentStorage(NcmContentStorage* out_content_storage, NcmStorageId storage_id);
44 Result ncmOpenContentMetaDatabase(NcmContentMetaDatabase* out_content_meta_database, NcmStorageId storage_id);
45 Result ncmCloseContentStorageForcibly(NcmStorageId storage_id); ///< [1.0.0]
47 Result ncmCleanupContentMetaDatabase(NcmStorageId storage_id);
48 Result ncmActivateContentStorage(NcmStorageId storage_id); ///< [2.0.0+]
49 Result ncmInactivateContentStorage(NcmStorageId storage_id); ///< [2.0.0+]
50 Result ncmActivateContentMetaDatabase(NcmStorageId storage_id); ///< [2.0.0+]
51 Result ncmInactivateContentMetaDatabase(NcmStorageId storage_id); ///< [2.0.0+]
52 Result ncmInvalidateRightsIdCache(void); ///< [9.0.0+]
53 
54 void ncmContentStorageClose(NcmContentStorage* cs);
55 Result ncmContentStorageGeneratePlaceHolderId(NcmContentStorage* cs, NcmPlaceHolderId* out_id);
56 Result ncmContentStorageCreatePlaceHolder(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id, s64 size);
57 Result ncmContentStorageDeletePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id);
58 Result ncmContentStorageHasPlaceHolder(NcmContentStorage* cs, bool* out, const NcmPlaceHolderId* placeholder_id);
59 Result ncmContentStorageWritePlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, u64 offset, const void* data, size_t data_size);
60 Result ncmContentStorageRegister(NcmContentStorage* cs, const NcmContentId* content_id, const NcmPlaceHolderId* placeholder_id);
61 Result ncmContentStorageDelete(NcmContentStorage* cs, const NcmContentId* content_id);
62 Result ncmContentStorageHas(NcmContentStorage* cs, bool* out, const NcmContentId* content_id);
63 Result ncmContentStorageGetPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmContentId* content_id);
64 Result ncmContentStorageGetPlaceHolderPath(NcmContentStorage* cs, char* out_path, size_t out_size, const NcmPlaceHolderId* placeholder_id);
65 Result ncmContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs);
66 Result ncmContentStorageListPlaceHolder(NcmContentStorage* cs, NcmPlaceHolderId* out_ids, s32 count, s32* out_count);
67 Result ncmContentStorageGetContentCount(NcmContentStorage* cs, s32* out_count);
68 Result ncmContentStorageListContentId(NcmContentStorage* cs, NcmContentId* out_ids, s32 count, s32* out_count, s32 start_offset);
69 Result ncmContentStorageGetSizeFromContentId(NcmContentStorage* cs, s64* out_size, const NcmContentId* content_id);
70 Result ncmContentStorageDisableForcibly(NcmContentStorage* cs);
71 Result ncmContentStorageRevertToPlaceHolder(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, const NcmContentId* old_content_id, const NcmContentId* new_content_id); ///< [2.0.0+]
72 Result ncmContentStorageSetPlaceHolderSize(NcmContentStorage* cs, const NcmPlaceHolderId* placeholder_id, s64 size); ///< [2.0.0+]
73 Result ncmContentStorageReadContentIdFile(NcmContentStorage* cs, void* out_data, size_t out_data_size, const NcmContentId* content_id, s64 offset); ///< [2.0.0+]
74 Result ncmContentStorageGetRightsIdFromPlaceHolderId(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmPlaceHolderId* placeholder_id); ///< [2.0.0+]
75 Result ncmContentStorageGetRightsIdFromContentId(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmContentId* content_id); ///< [2.0.0+]
76 Result ncmContentStorageWriteContentForDebug(NcmContentStorage* cs, const NcmContentId* content_id, s64 offset, const void* data, size_t data_size); ///< [2.0.0+]
80 Result ncmContentStorageGetSizeFromPlaceHolderId(NcmContentStorage* cs, s64* out_size, const NcmPlaceHolderId* placeholder_id); ///< [4.0.0+]
82 Result ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(NcmContentStorage* cs, NcmRightsId* out_rights_id, const NcmPlaceHolderId* placeholder_id, const NcmContentId* cache_content_id); ///< [8.0.0+]
83 Result ncmContentStorageRegisterPath(NcmContentStorage* cs, const NcmContentId* content_id, const char *path); ///< [13.0.0+]
85 
86 void ncmContentMetaDatabaseClose(NcmContentMetaDatabase* db);
87 Result ncmContentMetaDatabaseSet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, const void* data, u64 data_size);
88 Result ncmContentMetaDatabaseGet(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u64* out_size, void* out_data, u64 out_data_size);
89 Result ncmContentMetaDatabaseRemove(NcmContentMetaDatabase* db, const NcmContentMetaKey *key);
90 Result ncmContentMetaDatabaseGetContentIdByType(NcmContentMetaDatabase* db, NcmContentId* out_content_id, const NcmContentMetaKey* key, NcmContentType type);
91 Result ncmContentMetaDatabaseListContentInfo(NcmContentMetaDatabase* db, s32* out_entries_written, NcmContentInfo* out_info, s32 count, const NcmContentMetaKey* key, s32 start_index);
92 Result ncmContentMetaDatabaseList(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type, u64 id, u64 id_min, u64 id_max, NcmContentInstallType install_type);
93 Result ncmContentMetaDatabaseGetLatestContentMetaKey(NcmContentMetaDatabase* db, NcmContentMetaKey* out_key, u64 id);
94 Result ncmContentMetaDatabaseListApplication(NcmContentMetaDatabase* db, s32* out_entries_total, s32* out_entries_written, NcmApplicationContentMetaKey* out_keys, s32 count, NcmContentMetaType meta_type);
95 Result ncmContentMetaDatabaseHas(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key);
96 Result ncmContentMetaDatabaseHasAll(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* keys, s32 count);
97 Result ncmContentMetaDatabaseGetSize(NcmContentMetaDatabase* db, u64* out_size, const NcmContentMetaKey* key);
98 Result ncmContentMetaDatabaseGetRequiredSystemVersion(NcmContentMetaDatabase* db, u32* out_version, const NcmContentMetaKey* key);
99 Result ncmContentMetaDatabaseGetPatchId(NcmContentMetaDatabase* db, u64* out_patch_id, const NcmContentMetaKey* key);
100 Result ncmContentMetaDatabaseDisableForcibly(NcmContentMetaDatabase* db);
101 Result ncmContentMetaDatabaseLookupOrphanContent(NcmContentMetaDatabase* db, bool* out_orphaned, const NcmContentId* content_ids, s32 count);
102 Result ncmContentMetaDatabaseCommit(NcmContentMetaDatabase* db);
103 Result ncmContentMetaDatabaseHasContent(NcmContentMetaDatabase* db, bool* out, const NcmContentMetaKey* key, const NcmContentId* content_id);
104 Result ncmContentMetaDatabaseListContentMetaInfo(NcmContentMetaDatabase* db, s32* out_entries_written, void* out_meta_info, s32 count, const NcmContentMetaKey* key, s32 start_index);
105 Result ncmContentMetaDatabaseGetAttributes(NcmContentMetaDatabase* db, const NcmContentMetaKey* key, u8* out);
s64
int64_t s64
64-bit signed integer.
Definition: types.h:28
FsRightsId
Definition: fs.h:23
ncmContentStorageSetPlaceHolderSize
Result ncmContentStorageSetPlaceHolderSize(NcmContentStorage *cs, const NcmPlaceHolderId *placeholder_id, s64 size)
[2.0.0+]
NcmContentMetaKey
ContentMetaKey.
Definition: ncm_types.h:72
ncmActivateContentMetaDatabase
Result ncmActivateContentMetaDatabase(NcmStorageId storage_id)
[2.0.0+]
NcmStorageId
NcmStorageId
StorageId.
Definition: ncm_types.h:12
ncmContentStorageGetRightsIdFromContentId
Result ncmContentStorageGetRightsIdFromContentId(NcmContentStorage *cs, NcmRightsId *out_rights_id, const NcmContentId *content_id)
[2.0.0+]
NcmContentMetaDatabase
ContentMetaDatabase.
Definition: ncm.h:19
ncmInitialize
Result ncmInitialize(void)
Initialize ncm.
NcmApplicationContentMetaKey
ApplicationContentMetaKey.
Definition: ncm_types.h:81
u8
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
NcmContentType
NcmContentType
ContentType.
Definition: ncm_types.h:23
ncmContentStorageRegisterPath
Result ncmContentStorageRegisterPath(NcmContentStorage *cs, const NcmContentId *content_id, const char *path)
[13.0.0+]
ncmInactivateContentMetaDatabase
Result ncmInactivateContentMetaDatabase(NcmStorageId storage_id)
[2.0.0+]
NcmRightsId::key_generation
u8 key_generation
[3.0.0+]
Definition: ncm.h:26
ncmContentStorageGetTotalSpaceSize
Result ncmContentStorageGetTotalSpaceSize(NcmContentStorage *cs, s64 *out_size)
[2.0.0+]
ncmContentStorageGetSizeFromPlaceHolderId
Result ncmContentStorageGetSizeFromPlaceHolderId(NcmContentStorage *cs, s64 *out_size, const NcmPlaceHolderId *placeholder_id)
[4.0.0+]
s32
int32_t s32
32-bit signed integer.
Definition: types.h:27
ncmInvalidateRightsIdCache
Result ncmInvalidateRightsIdCache(void)
[9.0.0+]
NcmContentInfo
ContentInfo.
Definition: ncm_types.h:87
ncmContentStorageWriteContentForDebug
Result ncmContentStorageWriteContentForDebug(NcmContentStorage *cs, const NcmContentId *content_id, s64 offset, const void *data, size_t data_size)
[2.0.0+]
ncmContentStorageClearRegisteredPath
Result ncmContentStorageClearRegisteredPath(NcmContentStorage *cs)
[13.0.0+]
ncmExit
void ncmExit(void)
Exit ncm.
ncmContentMetaDatabaseGetRequiredApplicationVersion
Result ncmContentMetaDatabaseGetRequiredApplicationVersion(NcmContentMetaDatabase *db, u32 *out_version, const NcmContentMetaKey *key)
[2.0.0+]
ncmCloseContentStorageForcibly
Result ncmCloseContentStorageForcibly(NcmStorageId storage_id)
[1.0.0]
ncmContentStorageGetFreeSpaceSize
Result ncmContentStorageGetFreeSpaceSize(NcmContentStorage *cs, s64 *out_size)
[2.0.0+]
ncmContentStorageFlushPlaceHolder
Result ncmContentStorageFlushPlaceHolder(NcmContentStorage *cs)
[3.0.0+]
ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset
Result ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(NcmContentMetaDatabase *db, NcmContentId *out_content_id, const NcmContentMetaKey *key, NcmContentType type, u8 id_offset)
[5.0.0+]
u32
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
ncmInactivateContentStorage
Result ncmInactivateContentStorage(NcmStorageId storage_id)
[2.0.0+]
u64
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
ncmCloseContentMetaDatabaseForcibly
Result ncmCloseContentMetaDatabaseForcibly(NcmStorageId storage_id)
[1.0.0]
ncmActivateContentStorage
Result ncmActivateContentStorage(NcmStorageId storage_id)
[2.0.0+]
Result
u32 Result
Function error code result type.
Definition: types.h:44
ncmContentStorageGetRightsIdFromPlaceHolderId
Result ncmContentStorageGetRightsIdFromPlaceHolderId(NcmContentStorage *cs, NcmRightsId *out_rights_id, const NcmPlaceHolderId *placeholder_id)
[2.0.0+]
NcmContentStorage
ContentStorage.
Definition: ncm.h:14
ncmContentStorageRevertToPlaceHolder
Result ncmContentStorageRevertToPlaceHolder(NcmContentStorage *cs, const NcmPlaceHolderId *placeholder_id, const NcmContentId *old_content_id, const NcmContentId *new_content_id)
[2.0.0+]
NcmContentMetaDatabase::s
Service s
IContentMetaDatabase.
Definition: ncm.h:20
ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache
Result ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(NcmContentStorage *cs, NcmRightsId *out_rights_id, const NcmPlaceHolderId *placeholder_id, const NcmContentId *cache_content_id)
[8.0.0+]
ncmContentStorageReadContentIdFile
Result ncmContentStorageReadContentIdFile(NcmContentStorage *cs, void *out_data, size_t out_data_size, const NcmContentId *content_id, s64 offset)
[2.0.0+]
NcmContentStorage::s
Service s
IContentStorage.
Definition: ncm.h:15
Service
Service object structure.
Definition: service.h:13
NcmContentMetaType
NcmContentMetaType
ContentMetaType.
Definition: ncm_types.h:34
NcmPlaceHolderId
PlaceHolderId.
Definition: ncm_types.h:67
ncmGetServiceSession
Service * ncmGetServiceSession(void)
Gets the Service object for the actual ncm service session.
NcmContentInstallType
NcmContentInstallType
ContentInstallType.
Definition: ncm_types.h:55
NcmContentId
ContentId.
Definition: ncm_types.h:62
ncmContentStorageRepairInvalidFileAttribute
Result ncmContentStorageRepairInvalidFileAttribute(NcmContentStorage *cs)
[4.0.0+]
NcmRightsId
RightsId.
Definition: ncm.h:24