1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - makelst
3   File:     arch.c
4 
5   Copyright 2006-2008 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 #include "arch.h"
18 
19 
20 /*---------------------------------------------------------
21  Find size of entry from entry header
22  --------------------------------------------------------*/
AR_GetEntrySize(ArchHdr * ArHdr)23 u32 AR_GetEntrySize( ArchHdr* ArHdr)
24 {
25     u16 i;
26     u32 digit = 1;
27     u32 size = 0;
28 
29     /*----- Check how many digits there are -----*/
30     for( i=0; i<10; i++) {
31         if( ArHdr->ar_size[i] == 0x20) {
32             break;
33         }else{
34             digit *= 10;
35         }
36     }
37     digit /= 10;
38     /*----------------------------*/
39 
40     /*----- Calculate size  -----*/
41     for( i=0; i<10; i++) {
42         size += (*(((u8*)(ArHdr->ar_size))+i) - 0x30) * digit;	//Convert char to u8
43         if( digit == 1) {
44             break;
45         }else{
46 	        digit /= 10;
47         }
48     }
49     /*----------------------------*/
50 
51     return size;
52 }
53