Checkpoint calls main(argc, argv) with exactly one argument: argv[0] is the * id of the title highlighted when the user ran the script, as 16 uppercase hex * characters, or "" if nothing was selected. selected_title() returns the same * string, for code that is not inside main(). * * Titles are otherwise addressed by *catalog index* — 0 .. titles_count()-1, the * same order as Checkpoint's o
| 139 | * same order as Checkpoint's own list. An index is only valid during this run; |
| 140 | * never store one. To go from an id back to an index, use title_find(). */ |
| 141 | void section_context(int argc, char** argv) |
| 142 | { |
| 143 | char line[LINEN]; |
| 144 | char* id; |
| 145 | char* name; |
| 146 | char* code; |
| 147 | char* path; |
| 148 | int count; |
| 149 | int idx; |
| 150 | int shown; |
| 151 | int i; |
| 152 | |
| 153 | count = titles_count(); |
| 154 | sprintf(line, "catalog holds %d titles", count); |
| 155 | logline(line); |
| 156 | |
| 157 | if (argc > 0 && strlen(argv[0]) > 0) { |
| 158 | idx = title_find(argv[0]); |
| 159 | printf("launched on title %s -> catalog index %d\n", argv[0], idx); |
| 160 | if (idx >= 0) { |
| 161 | name = title_name(idx); |
| 162 | printf(" name: %s\n", name); |
| 163 | free(name); |
| 164 | } |
| 165 | } |
| 166 | else { |
| 167 | printf("launched with no title selected (argv[0] is empty)\n"); |
| 168 | idx = -1; |
| 169 | } |
| 170 | |
| 171 | /* Everything you can ask about a title. Note that the strings are copies |
| 172 | * you own; freeing them in a loop like this one is the point. */ |
| 173 | shown = 0; |
| 174 | for (i = 0; i < count && shown < 5; i++) { |
| 175 | id = title_id(i); |
| 176 | name = title_name(i); |
| 177 | code = title_product_code(i); |
| 178 | /* kind 0 = save backups, 1 = extdata backups; the path ends in '/' */ |
| 179 | path = title_backup_path(i, 0); |
| 180 | |
| 181 | printf("[%d] %s %s\n", i, id, name); |
| 182 | printf(" code=%s cart=%d save=%d extdata=%d\n", code, title_is_cart(i), title_has_save(i), title_has_extdata(i)); |
| 183 | printf(" backups: %s\n", path); |
| 184 | |
| 185 | free(id); |
| 186 | free(name); |
| 187 | free(code); |
| 188 | free(path); |
| 189 | shown++; |
| 190 | } |
| 191 | if (count > shown) { |
| 192 | printf("... %d more\n", count - shown); |
| 193 | } |
| 194 | |
| 195 | printf("app root: %s\n", g_root); |
| 196 | printf("this console: %s\n", g_is_switch ? "Switch" : "3DS"); |
| 197 | } |
| 198 |